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
Except block handles 'BaseException'
mahmoud/boltons/tests/test_tbutils.py
[ { "content": "# -*- coding: utf-8 -*-\n\nimport sys\n\ntry:\n from cStringIO import StringIO\nexcept:\n from io import StringIO\n\nfrom boltons.tbutils import (TracebackInfo,\n ExceptionInfo,\n ParsedException,\n print_exception,\n fix_print_exception,\n ContextualCallpoint,\n ContextualExceptionInfo)\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def test_exception_info():\n # test ExceptionInfo and TracebackInfo and hooks, via StringIOs\n builtin_exc_hook = sys.excepthook\n fix_print_exception()\n tbi_str = ''\n\n def test():\n raise ValueError('yay fun')\n\n fake_stderr1 = StringIO()\n fake_stderr2 = StringIO()\n sys.stderr = fake_stderr1\n\n try:\n test()\n except:\n _, _, exc_traceback = sys.exc_info()\n tbi = TracebackInfo.from_traceback(exc_traceback)\n exc_info = ExceptionInfo.from_exc_info(*sys.exc_info())\n exc_info2 = ExceptionInfo.from_current()\n tbi_str = str(tbi)\n print_exception(*sys.exc_info(), file=fake_stderr2)\n new_exc_hook_res = fake_stderr2.getvalue()\n builtin_exc_hook(*sys.exc_info())\n builtin_exc_hook_res = fake_stderr1.getvalue()\n finally:\n sys.stderr = sys.__stderr__\n\n # Single frame\n single_frame_str = tbi.frames[-1].tb_frame_str()\n assert 'in test' in single_frame_str\n assert 'yay fun' in single_frame_str\n\n # Traceback info\n assert len(tbi_str.splitlines()) == 5\n assert 'yay fun' in tbi_str\n\n # Full except hook output\n assert 'ValueError: yay fun' in new_exc_hook_res\n assert \"ValueError('yay fun')\" in new_exc_hook_res\n assert len(new_exc_hook_res) > len(tbi_str)\n\n assert new_exc_hook_res == builtin_exc_hook_res", "metadata": "root.test_exception_info", "header": "['module', '___EOS___']", "index": 36 } ]
[ { "span": "except:", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 7 }, { "span": "except:", "start_line": 51, "start_column": 4, "end_line": 51, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "c", "String", "IO_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "io_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "bolt", "ons_", "._", "tb", "utils_", "import_", "(_", "Trace", "back", "Info_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Except", "ion", "Info_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Pars", "ed", "Exception_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "print", "\\u", "exception_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "fix", "\\u", "print", "\\u", "exception_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Context", "ual", "Call", "point_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Context", "ual", "Except", "ion", "Info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "exception", "\\u", "info_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "test", " ", "Except", "ion", "Info", " ", "and", " ", "Trace", "back", "Info", " ", "and", " ", "hook", "s", ",", " ", "via", " ", "String", "IO", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bui", "lti", "n", "\\u", "exc", "\\u", "hook_", "=_", "sys_", "._", "except", "hook_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fix", "\\u", "print", "\\u", "exception_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tb", "i", "\\u", "str_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "ya", "y", " ", "fun", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fake", "\\u", "std", "err", "1_", "=_", "String", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fake", "\\u", "std", "err", "2_", "=_", "String", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stderr_", "=_", "fake", "\\u", "std", "err", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test_", "(_", ")_", "\\u\\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_", ",_", "\\u_", ",_", "exc", "\\u", "traceback_", "=_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tb", "i_", "=_", "Trace", "back", "Info_", "._", "from", "\\u", "traceback_", "(_", "exc", "\\u", "traceback_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exc", "\\u", "info_", "=_", "Except", "ion", "Info_", "._", "from", "\\u", "exc", "\\u", "info_", "(_", "*_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exc", "\\u", "info", "2_", "=_", "Except", "ion", "Info_", "._", "from", "\\u", "current_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tb", "i", "\\u", "str_", "=_", "str_", "(_", "tb", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print", "\\u", "exception_", "(_", "*_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", ",_", "file_", "=_", "fake", "\\u", "std", "err", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "exc", "\\u", "hook", "\\u", "res_", "=_", "fake", "\\u", "std", "err", "2_", "._", "getvalue_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bui", "lti", "n", "\\u", "exc", "\\u", "hook_", "(_", "*_", "sys_", "._", "exc", "\\u", "info_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bui", "lti", "n", "\\u", "exc", "\\u", "hook", "\\u", "res_", "=_", "fake", "\\u", "std", "err", "1_", "._", "getvalue_", "(_", ")_", "\\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 ", " _", "sys_", "._", "stderr_", "=_", "sys_", "._", "\\u\\u", "std", "err", "\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sing", "le", " ", "frame_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "single", "\\u", "frame", "\\u", "str_", "=_", "tb", "i_", "._", "frames_", "[_", "-_", "1_", "]_", "._", "tb", "\\u", "frame", "\\u", "str_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "'", "in", " ", "test", "'_", "in_", "single", "\\u", "frame", "\\u", "str_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "'", "ya", "y", " ", "fun", "'_", "in_", "single", "\\u", "frame", "\\u", "str_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Trace", "back", " ", "info_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "len_", "(_", "tb", "i", "\\u", "str_", "._", "splitlines_", "(_", ")_", ")_", "==_", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "'", "ya", "y", " ", "fun", "'_", "in_", "tb", "i", "\\u", "str_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Full", " ", "except", " ", "hook", " ", "output_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "'", "Value", "Error", ":", " ", "ya", "y", " ", "fun", "'_", "in_", "new", "\\u", "exc", "\\u", "hook", "\\u", "res_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "Value", "Error", "('", "ya", "y", " ", "fun", "')\"_", "in_", "new", "\\u", "exc", "\\u", "hook", "\\u", "res_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "new", "\\u", "exc", "\\u", "hook", "\\u", "res_", ")_", ">_", "len_", "(_", "tb", "i", "\\u", "str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "new", "\\u", "exc", "\\u", "hook", "\\u", "res_", "==_", "bui", "lti", "n", "\\u", "exc", "\\u", "hook", "\\u", "res_", "\\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, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Testing equality to None
thecopy/apiary2postman/apiary2postman/apiary2postman.py
[ { "content": "def main():\n\n parser = argparse.ArgumentParser(description='Generate Postman collections from Apiary API/Blueprint', formatter_class=argparse.RawDescriptionHelpFormatter,\n epilog='Examples:\\n\\t' + argv[0] + ' --pretty api awattgarde\\n\\t' \n + argv[0] + ' --only-collection --output awattgarde_collection.postman api awattgarde\\n\\t'\n + argv[0] + ' --only-collection json blueprint.json\\n\\t'\n +'cat blueprint.json | ' + argv[0] + ' json > awattgarde_collection.postman\\n\\t' )\n\n\n subparsers = parser.add_subparsers(help='',title='subcommands', \n description='valid subcommands')\n\n parser_blueprint = subparsers.add_parser('blueprint', description='blueprint: Read Blueprint API markup, then convert it using drafter, then generate Postman collection JSON.',\n help='Read Blueprint API markup, then convert it using drafter, then generate Postman collection JSON. Use \"blueprint -h\" for more help.')\n\n parser_json = subparsers.add_parser('json', description='json: Use prepared JSON to generate the Postman collection.',help='Use prepared JSON. Use \"json -h\" for more help.')\n \n parser_api = subparsers.add_parser('api', description='api: Use the Apiary API to fetch the Blueprint markup, then convert it using drafter, then generate Postman collection JSON.',\n help='Use the Apiary API to fetch the JSON. Use \"api -h\" for more help.')\n\n parser.add_argument('--pretty', dest='pretty', action='store_true', default=False,\n help='generate pretty JSON')\n parser.add_argument('--only-collection', dest='only_collection', action='store_const', \n const=True, default=False,\n help='generate Postman JSON for the first collection only.')\n parser_api.add_argument('key', metavar='api-key', nargs='?',\n help='the Apiary API token. If not supplied APIARY_API_KEY environment variable is used.') \n parser_api.add_argument('name', metavar='api-name', nargs=1,\n help='the name of the api on apiary. I.e. testapi311 for http://docs.testapi311.apiary.io/') \n parser_json.add_argument('input', metavar='input', type=file, nargs='?', default=stdin,\n help='input file, formatted as JSON. If not supplied, stdin is used.') \n parser_blueprint.add_argument('blueprint_input', metavar='input', type=file, nargs='?', default=stdin,\n help='input file, formatted as Blueprint API Markup. If not supplied, stdin is used.') \n parser.add_argument('--output', metavar='output', type=argparse.FileType('w'), nargs=1, default=stdout,\n help='output file. Outputs Postman collection JSON. If not supplied, stdout is used.')\n\n args = parser.parse_args()\n\n input = ''\n if hasattr(args, 'input'):\n # JSON mode\n input = args.input.read()\n elif hasattr(args, 'blueprint_input'):\n # blueprint mode\n check_drafter()\n input = blueprint2json(args.blueprint_input.read())\n else:\n # API mode\n check_drafter()\n\n apikey = None\n if args.key != None:\n apikey = args.key\n else:\n apikey = os.environ.get('APIARY_API_KEY')\n\n if apikey == None:\n print 'Please provide an api-key or set APIARY_API_KEY'\n exit(4)\n\n blueprint = fetch_blueprint(args.name[0], apikey)\n input = blueprint2json(blueprint)\n \n output = args.output \n if args.output != stdout:\n output = output[0]\n\n write(input, output, args.only_collection, args.pretty)", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 49 } ]
[ { "span": "apikey == None:", "start_line": 105, "start_column": 11, "end_line": 105, "end_column": 25 } ]
[]
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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parser_", "=_", "argparse_", "._", "Arg", "ument", "Parser_", "(_", "description_", "=_", "'", "Generate", " ", "Post", "man", " ", "collection", "s", " ", "from", " ", "Ap", "iar", "y", " ", "API", "/", "Blue", "print", "'_", ",_", "formatter", "\\u", "class_", "=_", "argparse_", "._", "Ra", "w", "Descripti", "on", "Help", "Formatter_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "epilog_", "=_", "'", "Exam", "ples", ":\\\\", "n", "\\\\", "t", "'_", "+_", "argv_", "[_", "0_", "]_", "+_", "'", " ", "--", "pretty", " ", "api", " ", "awa", "tt", "gard", "e", "\\\\", "n", "\\\\", "t", "'_", "\\u\\u\\uNL\\u\\u\\u_", "+_", "argv_", "[_", "0_", "]_", "+_", "'", " ", "--", "only", "-", "collection", " ", "--", "output", " ", "awa", "tt", "gard", "e\\u", "collection", ".", "post", "man", " ", "api", " ", "awa", "tt", "gard", "e", "\\\\", "n", "\\\\", "t", "'_", "\\u\\u\\uNL\\u\\u\\u_", "+_", "argv_", "[_", "0_", "]_", "+_", "'", " ", "--", "only", "-", "collection", " ", "json", " ", "blue", "print", ".", "json", "\\\\", "n", "\\\\", "t", "'_", "\\u\\u\\uNL\\u\\u\\u_", "+_", "'", "cat", " ", "blue", "print", ".", "json", " ", "|", " ", "'_", "+_", "argv_", "[_", "0_", "]_", "+_", "'", " ", "json", " ", ">", " ", "awa", "tt", "gard", "e\\u", "collection", ".", "post", "man", "\\\\", "n", "\\\\", "t", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "subparsers_", "=_", "parser_", "._", "add", "\\u", "subparsers_", "(_", "help_", "=_", "''_", ",_", "title_", "=_", "'", "subcommands", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "description_", "=_", "'", "valid", " ", "subcommands", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser", "\\u", "blueprint_", "=_", "subparsers_", "._", "add", "\\u", "parser_", "(_", "'", "blue", "print", "'_", ",_", "description_", "=_", "'", "blue", "print", ":", " ", "Read", " ", "Blue", "print", " ", "API", " ", "markup", ",", " ", "then", " ", "convert", " ", "it", " ", "usi", "ng", " ", "draft", "er", ",", " ", "then", " ", "generat", "e", " ", "Post", "man", " ", "collection", " ", "JSO", "N", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "Read", " ", "Blue", "print", " ", "API", " ", "markup", ",", " ", "then", " ", "convert", " ", "it", " ", "usi", "ng", " ", "draft", "er", ",", " ", "then", " ", "generat", "e", " ", "Post", "man", " ", "collection", " ", "JSO", "N", ".", " ", "Us", "e", " ", "\"", "blue", "print", " ", "-", "h", "\"", " ", "for", " ", "more", " ", "help", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser", "\\u", "json_", "=_", "subparsers_", "._", "add", "\\u", "parser_", "(_", "'", "json", "'_", ",_", "description_", "=_", "'", "json", ":", " ", "Us", "e", " ", "prepared", " ", "JSO", "N", " ", "to", " ", "generat", "e", " ", "the", " ", "Post", "man", " ", "collection", ".'_", ",_", "help_", "=_", "'", "Us", "e", " ", "prepared", " ", "JSO", "N", ".", " ", "Us", "e", " ", "\"", "json", " ", "-", "h", "\"", " ", "for", " ", "more", " ", "help", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser", "\\u", "api_", "=_", "subparsers_", "._", "add", "\\u", "parser_", "(_", "'", "api", "'_", ",_", "description_", "=_", "'", "api", ":", " ", "Us", "e", " ", "the", " ", "Ap", "iar", "y", " ", "API", " ", "to", " ", "fetch", " ", "the", " ", "Blue", "print", " ", "markup", ",", " ", "then", " ", "convert", " ", "it", " ", "usi", "ng", " ", "draft", "er", ",", " ", "then", " ", "generat", "e", " ", "Post", "man", " ", "collection", " ", "JSO", "N", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "Us", "e", " ", "the", " ", "Ap", "iar", "y", " ", "API", " ", "to", " ", "fetch", " ", "the", " ", "JSO", "N", ".", " ", "Us", "e", " ", "\"", "api", " ", "-", "h", "\"", " ", "for", " ", "more", " ", "help", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "pretty", "'_", ",_", "dest_", "=_", "'", "pretty", "'_", ",_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "default_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "generat", "e", " ", "pretty", " ", "JSO", "N", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "only", "-", "collection", "'_", ",_", "dest_", "=_", "'", "only", "\\u", "collection", "'_", ",_", "action_", "=_", "'", "store", "\\u", "const", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "const_", "=_", "True_", ",_", "default_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "generat", "e", " ", "Post", "man", " ", "JSO", "N", " ", "for", " ", "the", " ", "first", " ", "collection", " ", "only", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser", "\\u", "api_", "._", "add", "\\u", "argument_", "(_", "'", "key", "'_", ",_", "metavar_", "=_", "'", "api", "-", "key", "'_", ",_", "nargs_", "=_", "'?'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "the", " ", "Ap", "iar", "y", " ", "API", " ", "token", ".", " ", "If", " ", "not", " ", "supplie", "d", " ", "API", "ARY", "\\u", "API", "\\u", "KEY", " ", "environ", "ment", " ", "variab", "le", " ", "is", " ", "used", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser", "\\u", "api_", "._", "add", "\\u", "argument_", "(_", "'", "name", "'_", ",_", "metavar_", "=_", "'", "api", "-", "name", "'_", ",_", "nargs_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "the", " ", "name", " ", "of", " ", "the", " ", "api", " ", "on", " ", "api", "ary", ".", " ", "I", ".", "e", ".", " ", "testa", "pi", "311", " ", "for", " ", "http", "://", "docs", ".", "testa", "pi", "311", ".", "api", "ary", ".", "io", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser", "\\u", "json_", "._", "add", "\\u", "argument_", "(_", "'", "input", "'_", ",_", "metavar_", "=_", "'", "input", "'_", ",_", "type_", "=_", "file_", ",_", "nargs_", "=_", "'?'_", ",_", "default_", "=_", "stdin_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "input", " ", "file", ",", " ", "format", "ted", " ", "as", " ", "JSO", "N", ".", " ", "If", " ", "not", " ", "supplie", "d", ",", " ", "std", "in", " ", "is", " ", "used", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser", "\\u", "blueprint_", "._", "add", "\\u", "argument_", "(_", "'", "blue", "print", "\\u", "input", "'_", ",_", "metavar_", "=_", "'", "input", "'_", ",_", "type_", "=_", "file_", ",_", "nargs_", "=_", "'?'_", ",_", "default_", "=_", "stdin_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "input", " ", "file", ",", " ", "format", "ted", " ", "as", " ", "Blue", "print", " ", "API", " ", "Mark", "up", ".", " ", "If", " ", "not", " ", "supplie", "d", ",", " ", "std", "in", " ", "is", " ", "used", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "output", "'_", ",_", "metavar_", "=_", "'", "output", "'_", ",_", "type_", "=_", "argparse_", "._", "File", "Type_", "(_", "'", "w", "'_", ")_", ",_", "nargs_", "=_", "1_", ",_", "default_", "=_", "stdout_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "output", " ", "file", ".", " ", "Output", "s", " ", "Post", "man", " ", "collection", " ", "JSO", "N", ".", " ", "If", " ", "not", " ", "supplie", "d", ",", " ", "stdout", " ", "is", " ", "used", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "parser_", "._", "parse", "\\u", "args_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "input_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "hasattr_", "(_", "args_", ",_", "'", "input", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "JSO", "N", " ", "mode_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "input_", "=_", "args_", "._", "input_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "hasattr_", "(_", "args_", ",_", "'", "blue", "print", "\\u", "input", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "blue", "print", " ", "mode_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "check", "\\u", "draft", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "input_", "=_", "blue", "print", "2j", "son_", "(_", "args_", "._", "blue", "print", "\\u", "input_", "._", "read_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "API", " ", "mode_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "check", "\\u", "draft", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "apikey_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "args_", "._", "key_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "apikey_", "=_", "args_", "._", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "apikey_", "=_", "os_", "._", "environ_", "._", "get_", "(_", "'", "API", "ARY", "\\u", "API", "\\u", "KEY", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "apikey_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "Ple", "ase", " ", "provide", " ", "an", " ", "api", "-", "key", " ", "or", " ", "set", " ", "API", "ARY", "\\u", "API", "\\u", "KEY", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exit_", "(_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "blueprint_", "=_", "fetch", "\\u", "blueprint_", "(_", "args_", "._", "name_", "[_", "0_", "]_", ",_", "apikey_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "input_", "=_", "blue", "print", "2j", "son_", "(_", "blueprint_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "output_", "=_", "args_", "._", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "args_", "._", "output_", "!=_", "stdout_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "output_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "write_", "(_", "input_", ",_", "output_", ",_", "args_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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, 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 ]
Unused import
twoolie/NBT/examples/map.py
[ { "content": "#!/usr/bin/env python\n\"\"\"\nPrints a map of the entire world.\n\"\"\"\n\nimport locale, os, sys\nimport re, math\nfrom struct import pack, unpack\n# local module\ntry:\n import nbt\nexcept ImportError:\n # nbt not in search path. Let's see if it can be found in the parent folder\n extrasearchpath = os.path.realpath(os.path.join(__file__,os.pardir,os.pardir))\n if not os.path.exists(os.path.join(extrasearchpath,'nbt')):\n raise\n sys.path.append(extrasearchpath)\nfrom nbt.region import RegionFile\nfrom nbt.chunk import Chunk\nfrom nbt.world import WorldFolder,McRegionWorldFolder\n# PIL module (not build-in)\ntry:\n from PIL import Image\nexcept ImportError:\n # PIL not in search path. Let's see if it can be found in the parent folder\n sys.stderr.write(\"Module PIL/Image not found. Pillow (a PIL fork) can be found at http://python-imaging.github.io/\\n\")\n # Note: it may also be possible that PIL is installed, but JPEG support is disabled or broken\n sys.exit(70) # EX_SOFTWARE\n\n\n\n\n## Color functions for map generation ##\n\n# Hue given in degrees,\n# saturation and lightness given either in range 0-1 or 0-100 and returned in kind\n\n\n# From http://www.easyrgb.com/index.php?X=MATH&H=19#text19\n\n\n\n\nif __name__ == '__main__':\n if (len(sys.argv) == 1):\n print(\"No world folder specified!\")\n sys.exit(64) # EX_USAGE\n if sys.argv[1] == '--noshow' and len(sys.argv) > 2:\n show = False\n world_folder = sys.argv[2]\n else:\n show = True\n world_folder = sys.argv[1]\n # clean path name, eliminate trailing slashes. required for os.path.basename()\n world_folder = os.path.normpath(world_folder)\n if (not os.path.exists(world_folder)):\n print(\"No such folder as \"+world_folder)\n sys.exit(72) # EX_IOERR\n \n sys.exit(main(world_folder, show))\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def get_heightmap_image(chunk, buffer=False, gmin=False, gmax=False):\n points = chunk.blocks.generate_heightmap(buffer, True)\n # Normalize the points\n hmin = min(points) if (gmin == False) else gmin # Allow setting the min/max explicitly, in case this is part of a bigger map\n hmax = max(points) if (gmax == False) else gmax\n hdelta = hmax-hmin+0.0\n pixels = \"\"\n for y in range(16):\n for x in range(16):\n # pix X => mc -Z\n # pix Y => mc X\n offset = (15-x)*16+y\n height = int((points[offset]-hmin)/hdelta*255)\n if (height < 0): height = 0\n if (height > 255): height = 255\n pixels += pack(\">B\", height)\n im = Image.fromstring('L', (16,16), pixels)\n return im", "metadata": "root.get_heightmap_image", "header": "['module', '___EOS___']", "index": 29 }, { "content": "def get_map(chunk):\n # Show an image of the chunk from above\n pixels = b\"\"\n block_colors = {\n 0: {'h':0, 's':0, 'l':0}, # Air\n 1: {'h':0, 's':0, 'l':32}, # Stone\n 2: {'h':94, 's':42, 'l':32}, # Grass\n 3: {'h':27, 's':51, 'l':15}, # Dirt\n 4: {'h':0, 's':0, 'l':25}, # Cobblestone\n 8: {'h':228, 's':50, 'l':23}, # Water\n 9: {'h':228, 's':50, 'l':23}, # Water\n 10: {'h':16, 's':100, 'l':48}, # Lava\n 11: {'h':16, 's':100, 'l':48}, # Lava\n 12: {'h':53, 's':22, 'l':58}, # Sand\n 13: {'h':21, 's':18, 'l':20}, # Gravel\n 17: {'h':35, 's':93, 'l':15}, # Wood\n 18: {'h':114, 's':64, 'l':22}, # Leaves\n 24: {'h':48, 's':31, 'l':40}, # Sandstone\n 37: {'h':60, 's':100, 'l':60}, # Yellow Flower\n 38: {'h':0, 's':100, 'l':50}, # Red Flower\n 50: {'h':60, 's':100, 'l':50}, # Torch\n 51: {'h':55, 's':100, 'l':50}, # Fire\n 59: {'h':123, 's':60, 'l':50}, # Crops\n 60: {'h':35, 's':93, 'l':15}, # Farmland\n 78: {'h':240, 's':10, 'l':85}, # Snow\n 79: {'h':240, 's':10, 'l':95}, # Ice\n 81: {'h':126, 's':61, 'l':20}, # Cacti\n 82: {'h':7, 's':62, 'l':23}, # Clay\n 83: {'h':123, 's':70, 'l':50}, # Sugarcane\n 86: {'h':24, 's':100, 'l':45}, # Pumpkin\n 91: {'h':24, 's':100, 'l':45}, # Jack-o-lantern\n }\n for z in range(16):\n for x in range(16):\n # Find the highest block in this column\n ground_height = 127\n tints = []\n for y in range(127,-1,-1):\n block_id = chunk.blocks.get_block(x,y,z)\n block_data = chunk.blocks.get_data(x,y,z)\n if (block_id == 8 or block_id == 9):\n tints.append({'h':228, 's':50, 'l':23}) # Water\n elif (block_id == 18):\n if (block_data == 1):\n tints.append({'h':114, 's':64, 'l':22}) # Redwood Leaves\n elif (block_data == 2):\n tints.append({'h':93, 's':39, 'l':10}) # Birch Leaves\n else:\n tints.append({'h':114, 's':64, 'l':22}) # Normal Leaves\n elif (block_id == 79):\n tints.append({'h':240, 's':5, 'l':95}) # Ice\n elif (block_id == 51):\n tints.append({'h':55, 's':100, 'l':50}) # Fire\n elif (block_id != 0 or y == 0):\n # Here is ground level\n ground_height = y\n break\n\n color = block_colors[block_id] if (block_id in block_colors) else {'h':0, 's':0, 'l':100}\n height_shift = (ground_height-64)*0.25\n \n final_color = {'h':color['h'], 's':color['s'], 'l':color['l']+height_shift}\n if final_color['l'] > 100: final_color['l'] = 100\n if final_color['l'] < 0: final_color['l'] = 0\n \n # Apply tints from translucent blocks\n for tint in reversed(tints):\n final_color = hsl_slide(final_color, tint, 0.4)\n\n rgb = hsl2rgb(final_color['h'], final_color['s'], final_color['l'])\n\n pixels += pack(\"BBB\", rgb[0], rgb[1], rgb[2])\n im = Image.frombytes('RGB', (16,16), pixels)\n return im", "metadata": "root.get_map", "header": "['module', '___EOS___']", "index": 48 }, { "content": "def hsl_slide(hsl1, hsl2, ratio):\n if (abs(hsl2['h'] - hsl1['h']) > 180):\n if (hsl1['h'] > hsl2['h']):\n hsl1['h'] -= 360\n else:\n hsl1['h'] += 360\n \n # Find location of two colors on the H/S color circle\n p1x = math.cos(math.radians(hsl1['h']))*hsl1['s']\n p1y = math.sin(math.radians(hsl1['h']))*hsl1['s']\n p2x = math.cos(math.radians(hsl2['h']))*hsl2['s']\n p2y = math.sin(math.radians(hsl2['h']))*hsl2['s']\n \n # Slide part of the way from tint to base color\n avg_x = p1x + ratio*(p2x-p1x)\n avg_y = p1y + ratio*(p2y-p1y)\n avg_h = math.atan(avg_y/avg_x)\n avg_s = avg_y/math.sin(avg_h)\n avg_l = hsl1['l'] + ratio*(hsl2['l']-hsl1['l'])\n avg_h = math.degrees(avg_h)\n \n #print('tint: %s base: %s avg: %s %s %s' % (tint,final_color,avg_h,avg_s,avg_l))\n return {'h':avg_h, 's':avg_s, 'l':avg_l}", "metadata": "root.hsl_slide", "header": "['module', '___EOS___']", "index": 128 }, { "content": "def hsl2rgb(H,S,L):\n H = H/360.0\n S = S/100.0 # Turn into a percentage\n L = L/100.0\n if (S == 0):\n return (int(L*255), int(L*255), int(L*255))\n var_2 = L * (1+S) if (L < 0.5) else (L+S) - (S*L)\n var_1 = 2*L - var_2\n\n def hue2rgb(v1, v2, vH):\n if (vH < 0): vH += 1\n if (vH > 1): vH -= 1\n if ((6*vH)<1): return v1 + (v2-v1)*6*vH\n if ((2*vH)<1): return v2\n if ((3*vH)<2): return v1 + (v2-v1)*(2/3.0-vH)*6\n return v1\n \n R = int(255*hue2rgb(var_1, var_2, H + (1.0/3)))\n G = int(255*hue2rgb(var_1, var_2, H))\n B = int(255*hue2rgb(var_1, var_2, H - (1.0/3)))\n return (R,G,B)", "metadata": "root.hsl2rgb", "header": "['module', '___EOS___']", "index": 154 }, { "content": "def main(world_folder, show=True):\n world = McRegionWorldFolder(world_folder) # map still only supports McRegion maps\n bb = world.get_boundingbox()\n map = Image.new('RGB', (16*bb.lenx(),16*bb.lenz()))\n t = world.chunk_count()\n try:\n i =0.0\n for chunk in world.iter_chunks():\n if i % 50 ==0:\n sys.stdout.write(\"Rendering image\")\n elif i % 2 == 0:\n sys.stdout.write(\".\")\n sys.stdout.flush()\n elif i % 50 == 49:\n sys.stdout.write(\"%5.1f%%\\n\" % (100*i/t))\n i +=1\n chunkmap = get_map(chunk)\n x,z = chunk.get_coords()\n map.paste(chunkmap, (16*(x-bb.minx),16*(z-bb.minz)))\n print(\" done\\n\")\n filename = os.path.basename(world_folder)+\".png\"\n map.save(filename,\"PNG\")\n print(\"Saved map as %s\" % filename)\n except KeyboardInterrupt:\n print(\" aborted\\n\")\n filename = os.path.basename(world_folder)+\".partial.png\"\n map.save(filename,\"PNG\")\n print(\"Saved map as %s\" % filename)\n return 75 # EX_TEMPFAIL\n if show:\n map.show()\n return 0 # NOERR", "metadata": "root.main", "header": "['module', '___EOS___']", "index": 177 } ]
[ { "span": "import locale, os, sys", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 22 }, { "span": "import re, math", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 15 }, { "span": "from struct import pack, unpack", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 31 }, { "span": "import nbt", "start_line": 10, "start_column": 4, "end_line": 10, "end_column": 14 }, { "span": "from nbt.region import RegionFile", "start_line": 17, "start_column": 0, "end_line": 17, "end_column": 33 }, { "span": "from nbt.chunk import Chunk", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 27 }, { "span": "from nbt.world import WorldFolder,McRegionWorldFolder", "start_line": 19, "start_column": 0, "end_line": 19, "end_column": 53 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Print", "s", " ", "a", " ", "map", " ", "of", " ", "the", " ", "entire", " ", "world", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "locale_", ",_", "os_", ",_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", ",_", "math_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "struct_", "import_", "pack_", ",_", "unpack_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "local", " ", "module_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "nb", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "nb", "t", " ", "not", " ", "in", " ", "search", " ", "path", ".", " ", "Let", "'", "s", " ", "see", " ", "if", " ", "it", " ", "can", " ", "be", " ", "found", " ", "in", " ", "the", " ", "parent", " ", "folder_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extra", "search", "path_", "=_", "os_", "._", "path_", "._", "realpath_", "(_", "os_", "._", "path_", "._", "join_", "(_", "\\u\\u", "file\\u\\u_", ",_", "os_", "._", "pardir_", ",_", "os_", "._", "pardir_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "os_", "._", "path_", "._", "join_", "(_", "extra", "search", "path_", ",_", "'", "nb", "t", "'_", ")_", ")_", ":_", "\\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_", "sys_", "._", "path_", "._", "append_", "(_", "extra", "search", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "nb", "t_", "._", "region_", "import_", "Region", "File_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "nb", "t_", "._", "chunk_", "import_", "Chunk_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "nb", "t_", "._", "world_", "import_", "Wor", "ld", "Folder_", ",_", "Mc", "Region", "Wor", "ld", "Folder_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "PI", "L", " ", "module", " ", "(", "not", " ", "build", "-", "in", ")_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "PIL_", "import_", "Image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "PI", "L", " ", "not", " ", "in", " ", "search", " ", "path", ".", " ", "Let", "'", "s", " ", "see", " ", "if", " ", "it", " ", "can", " ", "be", " ", "found", " ", "in", " ", "the", " ", "parent", " ", "folder_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "stderr_", "._", "write_", "(_", "\"", "Modul", "e", " ", "PI", "L", "/", "Image", " ", "not", " ", "found", ".", " ", "Pil", "low", " ", "(", "a", " ", "PI", "L", " ", "fork", ")", " ", "can", " ", "be", " ", "found", " ", "at", " ", "http", "://", "python", "-", "imagin", "g", ".", "git", "hub", ".", "io", "/\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Not", "e", ":", " ", "it", " ", "may", " ", "als", "o", " ", "be", " ", "possib", "le", " ", "tha", "t", " ", "PI", "L", " ", "is", " ", "install", "ed", ",", " ", "but", " ", "JP", "EG", " ", "support", " ", "is", " ", "disable", "d", " ", "or", " ", "broken", "_", "\\u\\u\\uNL\\u\\u\\u_", "sys_", "._", "exit_", "(_", "70_", ")_", "#", " ", "EX", "\\u", "SOFT", "WARE", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "##", " ", "Color", " ", "function", "s", " ", "for", " ", "map", " ", "generat", "ion", " ", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Hu", "e", " ", "give", "n", " ", "in", " ", "degr", "ees", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "saturation", " ", "and", " ", "light", "ness", " ", "give", "n", " ", "eit", "her", " ", "in", " ", "range", " ", "0", "-1", " ", "or", " ", "0", "-1", "00", " ", "and", " ", "return", "ed", " ", "in", " ", "kind_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fro", "m", " ", "http", "://", "www", ".", "easy", "rgb", ".", "com", "/", "index", ".", "php", "?", "X", "=", "MATH", "&", "H", "=", "1", "9", "#", "text1", "9_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "len_", "(_", "sys_", "._", "argv_", ")_", "==_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "No", " ", "world", " ", "folder", " ", "specified", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "64_", ")_", "#", " ", "EX", "\\u", "USAGE", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "sys_", "._", "argv_", "[_", "1_", "]_", "==_", "'--", "nos", "how", "'_", "and_", "len_", "(_", "sys_", "._", "argv_", ")_", ">_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "show_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "world", "\\u", "folder_", "=_", "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 ", " _", "show_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "world", "\\u", "folder_", "=_", "sys_", "._", "argv_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "clean", " ", "path", " ", "name", ",", " ", "eliminat", "e", " ", "trail", "ing", " ", "slash", "es", ".", " ", "require", "d", " ", "for", " ", "os", ".", "path", ".", "basen", "ame", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "world", "\\u", "folder_", "=_", "os_", "._", "path_", "._", "normpath_", "(_", "world", "\\u", "folder_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "world", "\\u", "folder_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "No", " ", "suc", "h", " ", "folder", " ", "as", " ", "\"_", "+_", "world", "\\u", "folder_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "72_", ")_", "#", " ", "EX", "\\u", "IO", "ERR_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sys_", "._", "exit_", "(_", "main_", "(_", "world", "\\u", "folder_", ",_", "show_", ")_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "height", "map", "\\u", "image_", "(_", "chunk_", ",_", "buffer_", "=_", "False_", ",_", "gm", "in_", "=_", "False_", ",_", "gma", "x_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "points_", "=_", "chunk_", "._", "blocks_", "._", "generat", "e\\u", "height", "map_", "(_", "buffer_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Normalize", " ", "the", " ", "points_", "\\u\\u\\uNL\\u\\u\\u_", "hmi", "n_", "=_", "min_", "(_", "points_", ")_", "if_", "(_", "gm", "in_", "==_", "False_", ")_", "else_", "gm", "in_", "#", " ", "All", "ow", " ", "setti", "ng", " ", "the", " ", "min", "/", "max", " ", "explicit", "ly", ",", " ", "in", " ", "case", " ", "this", " ", "is", " ", "part", " ", "of", " ", "a", " ", "bigger", " ", "map_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hma", "x_", "=_", "max_", "(_", "points_", ")_", "if_", "(_", "gma", "x_", "==_", "False_", ")_", "else_", "gma", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hd", "elt", "a_", "=_", "hma", "x_", "-_", "hmi", "n_", "+_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pixels_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "y_", "in_", "range_", "(_", "16_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "x_", "in_", "range_", "(_", "16_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "pix", " ", "X", " ", "=>", " ", "mc", " ", "-", "Z_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "pix", " ", "Y", " ", "=>", " ", "mc", " ", "X_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "offset_", "=_", "(_", "15_", "-_", "x_", ")_", "*_", "16_", "+_", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "height_", "=_", "int_", "(_", "(_", "points_", "[_", "offset_", "]_", "-_", "hmi", "n_", ")_", "/_", "hd", "elt", "a_", "*_", "255_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "height_", "<_", "0_", ")_", ":_", "height_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "height_", ">_", "255_", ")_", ":_", "height_", "=_", "255_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pixels_", "+=_", "pack_", "(_", "\">", "B", "\"_", ",_", "height_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "im_", "=_", "Image_", "._", "fromstring_", "(_", "'", "L", "'_", ",_", "(_", "16_", ",_", "16_", ")_", ",_", "pixels_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "im_", "\\u\\u\\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", "map_", "(_", "chunk_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Show", " ", "an", " ", "image", " ", "of", " ", "the", " ", "chunk", " ", "from", " ", "above_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pixels_", "=_", "b", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "block", "\\u", "colors_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "0_", ":_", "{_", "'", "h", "'_", ":_", "0_", ",_", "'", "s", "'_", ":_", "0_", ",_", "'", "l", "'_", ":_", "0_", "}_", ",_", "#", " ", "Air", "_", "\\u\\u\\uNL\\u\\u\\u_", "1_", ":_", "{_", "'", "h", "'_", ":_", "0_", ",_", "'", "s", "'_", ":_", "0_", ",_", "'", "l", "'_", ":_", "32_", "}_", ",_", "#", " ", "Stone", "_", "\\u\\u\\uNL\\u\\u\\u_", "2_", ":_", "{_", "'", "h", "'_", ":_", "94_", ",_", "'", "s", "'_", ":_", "42_", ",_", "'", "l", "'_", ":_", "32_", "}_", ",_", "#", " ", "Gra", "ss_", "\\u\\u\\uNL\\u\\u\\u_", "3_", ":_", "{_", "'", "h", "'_", ":_", "27_", ",_", "'", "s", "'_", ":_", "51_", ",_", "'", "l", "'_", ":_", "15_", "}_", ",_", "#", " ", "Dir", "t_", "\\u\\u\\uNL\\u\\u\\u_", "4_", ":_", "{_", "'", "h", "'_", ":_", "0_", ",_", "'", "s", "'_", ":_", "0_", ",_", "'", "l", "'_", ":_", "25_", "}_", ",_", "#", " ", "Cob", "bles", "tone_", "\\u\\u\\uNL\\u\\u\\u_", "8_", ":_", "{_", "'", "h", "'_", ":_", "228_", ",_", "'", "s", "'_", ":_", "50_", ",_", "'", "l", "'_", ":_", "23_", "}_", ",_", "#", " ", "Water", "_", "\\u\\u\\uNL\\u\\u\\u_", "9_", ":_", "{_", "'", "h", "'_", ":_", "228_", ",_", "'", "s", "'_", ":_", "50_", ",_", "'", "l", "'_", ":_", "23_", "}_", ",_", "#", " ", "Water", "_", "\\u\\u\\uNL\\u\\u\\u_", "10_", ":_", "{_", "'", "h", "'_", ":_", "16_", ",_", "'", "s", "'_", ":_", "100_", ",_", "'", "l", "'_", ":_", "48_", "}_", ",_", "#", " ", "La", "va_", "\\u\\u\\uNL\\u\\u\\u_", "11_", ":_", "{_", "'", "h", "'_", ":_", "16_", ",_", "'", "s", "'_", ":_", "100_", ",_", "'", "l", "'_", ":_", "48_", "}_", ",_", "#", " ", "La", "va_", "\\u\\u\\uNL\\u\\u\\u_", "12_", ":_", "{_", "'", "h", "'_", ":_", "53_", ",_", "'", "s", "'_", ":_", "22_", ",_", "'", "l", "'_", ":_", "58_", "}_", ",_", "#", " ", "Sand", "_", "\\u\\u\\uNL\\u\\u\\u_", "13_", ":_", "{_", "'", "h", "'_", ":_", "21_", ",_", "'", "s", "'_", ":_", "18_", ",_", "'", "l", "'_", ":_", "20_", "}_", ",_", "#", " ", "Grav", "el_", "\\u\\u\\uNL\\u\\u\\u_", "17_", ":_", "{_", "'", "h", "'_", ":_", "35_", ",_", "'", "s", "'_", ":_", "93_", ",_", "'", "l", "'_", ":_", "15_", "}_", ",_", "#", " ", "Wood", "_", "\\u\\u\\uNL\\u\\u\\u_", "18_", ":_", "{_", "'", "h", "'_", ":_", "114_", ",_", "'", "s", "'_", ":_", "64_", ",_", "'", "l", "'_", ":_", "22_", "}_", ",_", "#", " ", "Leav", "es_", "\\u\\u\\uNL\\u\\u\\u_", "24_", ":_", "{_", "'", "h", "'_", ":_", "48_", ",_", "'", "s", "'_", ":_", "31_", ",_", "'", "l", "'_", ":_", "40_", "}_", ",_", "#", " ", "Sand", "stone", "_", "\\u\\u\\uNL\\u\\u\\u_", "37_", ":_", "{_", "'", "h", "'_", ":_", "60_", ",_", "'", "s", "'_", ":_", "100_", ",_", "'", "l", "'_", ":_", "60_", "}_", ",_", "#", " ", "Ye", "llow", " ", "Flow", "er_", "\\u\\u\\uNL\\u\\u\\u_", "38_", ":_", "{_", "'", "h", "'_", ":_", "0_", ",_", "'", "s", "'_", ":_", "100_", ",_", "'", "l", "'_", ":_", "50_", "}_", ",_", "#", " ", "Red", " ", "Flow", "er_", "\\u\\u\\uNL\\u\\u\\u_", "50_", ":_", "{_", "'", "h", "'_", ":_", "60_", ",_", "'", "s", "'_", ":_", "100_", ",_", "'", "l", "'_", ":_", "50_", "}_", ",_", "#", " ", "Tor", "ch_", "\\u\\u\\uNL\\u\\u\\u_", "51_", ":_", "{_", "'", "h", "'_", ":_", "55_", ",_", "'", "s", "'_", ":_", "100_", ",_", "'", "l", "'_", ":_", "50_", "}_", ",_", "#", " ", "Fire", "_", "\\u\\u\\uNL\\u\\u\\u_", "59_", ":_", "{_", "'", "h", "'_", ":_", "123_", ",_", "'", "s", "'_", ":_", "60_", ",_", "'", "l", "'_", ":_", "50_", "}_", ",_", "#", " ", "Cro", "ps_", "\\u\\u\\uNL\\u\\u\\u_", "60_", ":_", "{_", "'", "h", "'_", ":_", "35_", ",_", "'", "s", "'_", ":_", "93_", ",_", "'", "l", "'_", ":_", "15_", "}_", ",_", "#", " ", "Far", "mla", "nd_", "\\u\\u\\uNL\\u\\u\\u_", "78_", ":_", "{_", "'", "h", "'_", ":_", "240_", ",_", "'", "s", "'_", ":_", "10_", ",_", "'", "l", "'_", ":_", "85_", "}_", ",_", "#", " ", "Snow", "_", "\\u\\u\\uNL\\u\\u\\u_", "79_", ":_", "{_", "'", "h", "'_", ":_", "240_", ",_", "'", "s", "'_", ":_", "10_", ",_", "'", "l", "'_", ":_", "95_", "}_", ",_", "#", " ", "Ice", "_", "\\u\\u\\uNL\\u\\u\\u_", "81_", ":_", "{_", "'", "h", "'_", ":_", "126_", ",_", "'", "s", "'_", ":_", "61_", ",_", "'", "l", "'_", ":_", "20_", "}_", ",_", "#", " ", "Ca", "cti", "_", "\\u\\u\\uNL\\u\\u\\u_", "82_", ":_", "{_", "'", "h", "'_", ":_", "7_", ",_", "'", "s", "'_", ":_", "62_", ",_", "'", "l", "'_", ":_", "23_", "}_", ",_", "#", " ", "Cla", "y_", "\\u\\u\\uNL\\u\\u\\u_", "83_", ":_", "{_", "'", "h", "'_", ":_", "123_", ",_", "'", "s", "'_", ":_", "70_", ",_", "'", "l", "'_", ":_", "50_", "}_", ",_", "#", " ", "Sug", "arc", "ane", "_", "\\u\\u\\uNL\\u\\u\\u_", "86_", ":_", "{_", "'", "h", "'_", ":_", "24_", ",_", "'", "s", "'_", ":_", "100_", ",_", "'", "l", "'_", ":_", "45_", "}_", ",_", "#", " ", "Pump", "kin", "_", "\\u\\u\\uNL\\u\\u\\u_", "91_", ":_", "{_", "'", "h", "'_", ":_", "24_", ",_", "'", "s", "'_", ":_", "100_", ",_", "'", "l", "'_", ":_", "45_", "}_", ",_", "#", " ", "Jack", "-", "o", "-", "lant", "ern", "_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "z_", "in_", "range_", "(_", "16_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "x_", "in_", "range_", "(_", "16_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Fin", "d", " ", "the", " ", "high", "est", " ", "block", " ", "in", " ", "this", " ", "column_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ground", "\\u", "height_", "=_", "127_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tint", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "y_", "in_", "range_", "(_", "127_", ",_", "-_", "1_", ",_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "block", "\\u", "id_", "=_", "chunk_", "._", "blocks_", "._", "get", "\\u", "block_", "(_", "x_", ",_", "y_", ",_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "block", "\\u", "data_", "=_", "chunk_", "._", "blocks_", "._", "get", "\\u", "data_", "(_", "x_", ",_", "y_", ",_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "block", "\\u", "id_", "==_", "8_", "or_", "block", "\\u", "id_", "==_", "9_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "tint", "s_", "._", "append_", "(_", "{_", "'", "h", "'_", ":_", "228_", ",_", "'", "s", "'_", ":_", "50_", ",_", "'", "l", "'_", ":_", "23_", "}_", ")_", "#", " ", "Water", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "block", "\\u", "id_", "==_", "18_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "(_", "block", "\\u", "data_", "==_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "tint", "s_", "._", "append_", "(_", "{_", "'", "h", "'_", ":_", "114_", ",_", "'", "s", "'_", ":_", "64_", ",_", "'", "l", "'_", ":_", "22_", "}_", ")_", "#", " ", "Red", "wood", " ", "Leav", "es_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "block", "\\u", "data_", "==_", "2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "tint", "s_", "._", "append_", "(_", "{_", "'", "h", "'_", ":_", "93_", ",_", "'", "s", "'_", ":_", "39_", ",_", "'", "l", "'_", ":_", "10_", "}_", ")_", "#", " ", "Bir", "ch", " ", "Leav", "es_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "tint", "s_", "._", "append_", "(_", "{_", "'", "h", "'_", ":_", "114_", ",_", "'", "s", "'_", ":_", "64_", ",_", "'", "l", "'_", ":_", "22_", "}_", ")_", "#", " ", "Normal", " ", "Leav", "es_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "block", "\\u", "id_", "==_", "79_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "tint", "s_", "._", "append_", "(_", "{_", "'", "h", "'_", ":_", "240_", ",_", "'", "s", "'_", ":_", "5_", ",_", "'", "l", "'_", ":_", "95_", "}_", ")_", "#", " ", "Ice", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "block", "\\u", "id_", "==_", "51_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "tint", "s_", "._", "append_", "(_", "{_", "'", "h", "'_", ":_", "55_", ",_", "'", "s", "'_", ":_", "100_", ",_", "'", "l", "'_", ":_", "50_", "}_", ")_", "#", " ", "Fire", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "block", "\\u", "id_", "!=_", "0_", "or_", "y_", "==_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Her", "e", " ", "is", " ", "ground", " ", "level_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "ground", "\\u", "height_", "=_", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "color_", "=_", "block", "\\u", "colors_", "[_", "block", "\\u", "id_", "]_", "if_", "(_", "block", "\\u", "id_", "in_", "block", "\\u", "colors_", ")_", "else_", "{_", "'", "h", "'_", ":_", "0_", ",_", "'", "s", "'_", ":_", "0_", ",_", "'", "l", "'_", ":_", "100_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "height", "\\u", "shift_", "=_", "(_", "ground", "\\u", "height_", "-_", "64_", ")_", "*_", "0.25_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "final", "\\u", "color_", "=_", "{_", "'", "h", "'_", ":_", "color_", "[_", "'", "h", "'_", "]_", ",_", "'", "s", "'_", ":_", "color_", "[_", "'", "s", "'_", "]_", ",_", "'", "l", "'_", ":_", "color_", "[_", "'", "l", "'_", "]_", "+_", "height", "\\u", "shift_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "final", "\\u", "color_", "[_", "'", "l", "'_", "]_", ">_", "100_", ":_", "final", "\\u", "color_", "[_", "'", "l", "'_", "]_", "=_", "100_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "final", "\\u", "color_", "[_", "'", "l", "'_", "]_", "<_", "0_", ":_", "final", "\\u", "color_", "[_", "'", "l", "'_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Apply", " ", "tint", "s", " ", "from", " ", "transl", "uce", "nt", " ", "blocks_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "tint", "_", "in_", "reversed_", "(_", "tint", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "final", "\\u", "color_", "=_", "hs", "l\\u", "slide_", "(_", "final", "\\u", "color_", ",_", "tint", "_", ",_", "0.4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rgb_", "=_", "hs", "l2", "rgb_", "(_", "final", "\\u", "color_", "[_", "'", "h", "'_", "]_", ",_", "final", "\\u", "color_", "[_", "'", "s", "'_", "]_", ",_", "final", "\\u", "color_", "[_", "'", "l", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pixels_", "+=_", "pack_", "(_", "\"", "BBB", "\"_", ",_", "rgb_", "[_", "0_", "]_", ",_", "rgb_", "[_", "1_", "]_", ",_", "rgb_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "im_", "=_", "Image_", "._", "from", "bytes_", "(_", "'", "RGB", "'_", ",_", "(_", "16_", ",_", "16_", ")_", ",_", "pixels_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "im_", "\\u\\u\\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_", "hs", "l\\u", "slide_", "(_", "hs", "l1_", ",_", "hs", "l2_", ",_", "ratio_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "abs_", "(_", "hs", "l2_", "[_", "'", "h", "'_", "]_", "-_", "hs", "l1_", "[_", "'", "h", "'_", "]_", ")_", ">_", "180_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "hs", "l1_", "[_", "'", "h", "'_", "]_", ">_", "hs", "l2_", "[_", "'", "h", "'_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hs", "l1_", "[_", "'", "h", "'_", "]_", "-=_", "360_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hs", "l1_", "[_", "'", "h", "'_", "]_", "+=_", "360_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fin", "d", " ", "location", " ", "of", " ", "two", " ", "colors", " ", "on", " ", "the", " ", "H", "/", "S", " ", "color", " ", "circle_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "p1", "x_", "=_", "math_", "._", "cos_", "(_", "math_", "._", "radians_", "(_", "hs", "l1_", "[_", "'", "h", "'_", "]_", ")_", ")_", "*_", "hs", "l1_", "[_", "'", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p1", "y_", "=_", "math_", "._", "sin_", "(_", "math_", "._", "radians_", "(_", "hs", "l1_", "[_", "'", "h", "'_", "]_", ")_", ")_", "*_", "hs", "l1_", "[_", "'", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p2", "x_", "=_", "math_", "._", "cos_", "(_", "math_", "._", "radians_", "(_", "hs", "l2_", "[_", "'", "h", "'_", "]_", ")_", ")_", "*_", "hs", "l2_", "[_", "'", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p2", "y_", "=_", "math_", "._", "sin_", "(_", "math_", "._", "radians_", "(_", "hs", "l2_", "[_", "'", "h", "'_", "]_", ")_", ")_", "*_", "hs", "l2_", "[_", "'", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Slide", " ", "part", " ", "of", " ", "the", " ", "way", " ", "from", " ", "tint", " ", "to", " ", "base", " ", "color_", "\\u\\u\\uNL\\u\\u\\u_", "avg", "\\u", "x_", "=_", "p1", "x_", "+_", "ratio_", "*_", "(_", "p2", "x_", "-_", "p1", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "avg", "\\u", "y_", "=_", "p1", "y_", "+_", "ratio_", "*_", "(_", "p2", "y_", "-_", "p1", "y_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "avg", "\\u", "h_", "=_", "math_", "._", "atan", "_", "(_", "avg", "\\u", "y_", "/_", "avg", "\\u", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "avg", "\\u", "s_", "=_", "avg", "\\u", "y_", "/_", "math_", "._", "sin_", "(_", "avg", "\\u", "h_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "avg", "\\u", "l_", "=_", "hs", "l1_", "[_", "'", "l", "'_", "]_", "+_", "ratio_", "*_", "(_", "hs", "l2_", "[_", "'", "l", "'_", "]_", "-_", "hs", "l1_", "[_", "'", "l", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "avg", "\\u", "h_", "=_", "math_", "._", "degrees_", "(_", "avg", "\\u", "h_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", "('", "tint", ":", " ", "%", "s", " ", "base", ":", " ", "%", "s", " ", "avg", ":", " ", "%", "s", " ", "%", "s", " ", "%", "s", "'", " ", "%", " ", "(", "tint", ",", "final", "\\u", "color", ",", "avg", "\\u", "h", ",", "avg", "\\u", "s", ",", "avg", "\\u", "l", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "{_", "'", "h", "'_", ":_", "avg", "\\u", "h_", ",_", "'", "s", "'_", ":_", "avg", "\\u", "s_", ",_", "'", "l", "'_", ":_", "avg", "\\u", "l_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "hs", "l2", "rgb_", "(_", "H_", ",_", "S_", ",_", "L_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "H_", "=_", "H_", "/_", "360.", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "S_", "=_", "S_", "/_", "100.0_", "#", " ", "Turn", " ", "int", "o", " ", "a", " ", "percentage_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "L_", "=_", "L_", "/_", "100.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "S_", "==_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "int_", "(_", "L_", "*_", "255_", ")_", ",_", "int_", "(_", "L_", "*_", "255_", ")_", ",_", "int_", "(_", "L_", "*_", "255_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "var", "\\u", "2_", "=_", "L_", "*_", "(_", "1_", "+_", "S_", ")_", "if_", "(_", "L_", "<_", "0.5_", ")_", "else_", "(_", "L_", "+_", "S_", ")_", "-_", "(_", "S_", "*_", "L_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "var", "\\u", "1_", "=_", "2_", "*_", "L_", "-_", "var", "\\u", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "hue", "2r", "gb_", "(_", "v1_", ",_", "v2_", ",_", "v", "H_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "v", "H_", "<_", "0_", ")_", ":_", "v", "H_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "v", "H_", ">_", "1_", ")_", ":_", "v", "H_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "(_", "6_", "*_", "v", "H_", ")_", "<_", "1_", ")_", ":_", "return_", "v1_", "+_", "(_", "v2_", "-_", "v1_", ")_", "*_", "6_", "*_", "v", "H_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "(_", "2_", "*_", "v", "H_", ")_", "<_", "1_", ")_", ":_", "return_", "v2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "(_", "3_", "*_", "v", "H_", ")_", "<_", "2_", ")_", ":_", "return_", "v1_", "+_", "(_", "v2_", "-_", "v1_", ")_", "*_", "(_", "2_", "/_", "3.0_", "-_", "v", "H_", ")_", "*_", "6_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "v1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "R_", "=_", "int_", "(_", "255_", "*_", "hue", "2r", "gb_", "(_", "var", "\\u", "1_", ",_", "var", "\\u", "2_", ",_", "H_", "+_", "(_", "1.0_", "/_", "3_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G_", "=_", "int_", "(_", "255_", "*_", "hue", "2r", "gb_", "(_", "var", "\\u", "1_", ",_", "var", "\\u", "2_", ",_", "H_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "B_", "=_", "int_", "(_", "255_", "*_", "hue", "2r", "gb_", "(_", "var", "\\u", "1_", ",_", "var", "\\u", "2_", ",_", "H_", "-_", "(_", "1.0_", "/_", "3_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "R_", ",_", "G_", ",_", "B_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "main_", "(_", "world", "\\u", "folder_", ",_", "show_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "world_", "=_", "Mc", "Region", "Wor", "ld", "Folder_", "(_", "world", "\\u", "folder_", ")_", "#", " ", "map", " ", "still", " ", "only", " ", "support", "s", " ", "Mc", "Region", " ", "maps_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bb_", "=_", "world_", "._", "get", "\\u", "bound", "ing", "box_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "map_", "=_", "Image_", "._", "new_", "(_", "'", "RGB", "'_", ",_", "(_", "16_", "*_", "bb_", "._", "len", "x_", "(_", ")_", ",_", "16_", "*_", "bb_", "._", "len", "z_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "world_", "._", "chunk", "\\u", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "chunk_", "in_", "world_", "._", "iter", "\\u", "chunks_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "i_", "%_", "50_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "stdout_", "._", "write_", "(_", "\"", "Rendering", " ", "image", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "i_", "%_", "2_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "stdout_", "._", "write_", "(_", "\".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "stdout_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "i_", "%_", "50_", "==_", "49_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "stdout_", "._", "write_", "(_", "\"%", "5.1", "f", "%%", "\\\\", "n", "\"_", "%_", "(_", "100_", "*_", "i_", "/_", "t_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "i_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "chunk", "map_", "=_", "get", "\\u", "map_", "(_", "chunk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", ",_", "z_", "=_", "chunk_", "._", "get", "\\u", "coords_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "map_", "._", "paste_", "(_", "chunk", "map_", ",_", "(_", "16_", "*_", "(_", "x_", "-_", "bb_", "._", "minx_", ")_", ",_", "16_", "*_", "(_", "z_", "-_", "bb_", "._", "min", "z_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", " ", "don", "e", "\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filename_", "=_", "os_", "._", "path_", "._", "basename_", "(_", "world", "\\u", "folder_", ")_", "+_", "\".", "png", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "map_", "._", "save_", "(_", "filename_", ",_", "\"", "PNG", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "Save", "d", " ", "map", " ", "as", " ", "%", "s", "\"_", "%_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "board", "Interrupt_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", " ", "abort", "ed", "\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filename_", "=_", "os_", "._", "path_", "._", "basename_", "(_", "world", "\\u", "folder_", ")_", "+_", "\".", "partial", ".", "png", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "map_", "._", "save_", "(_", "filename_", ",_", "\"", "PNG", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "\"", "Save", "d", " ", "map", " ", "as", " ", "%", "s", "\"_", "%_", "filename_", ")_", "\\u\\u\\uNEWL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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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/contrib/gis/tests/test_measure.py
[ { "content": " def testAddition(self):\n \"Test addition & subtraction\"\n d1 = D(m=100)\n d2 = D(m=200)\n\n d3 = d1 + d2\n self.assertEqual(d3.m, 300)\n d3 += d1\n self.assertEqual(d3.m, 400)\n \n d4 = d1 - d2\n self.assertEqual(d4.m, -100)\n d4 -= d1\n self.assertEqual(d4.m, -200)\n \n try:\n d5 = d1 + 1\n except TypeError, e:\n pass\n else:\n self.fail('Distance + number should raise TypeError')\n\n try:\n d5 = d1 - 1\n except TypeError, e:\n pass\n else:\n self.fail('Distance - number should raise TypeError')\n\n try:\n d1 += 1\n except TypeError, e:\n pass\n else:\n self.fail('Distance += number should raise TypeError')\n\n try:\n d1 -= 1\n except TypeError, e:\n pass\n else:\n self.fail('Distance -= number should raise TypeError')", "metadata": "root.DistanceTest.testAddition", "header": "['class', 'DistanceTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 48 }, { "content": " def testAddition(self):\n \"Test addition & subtraction\"\n a1 = A(sq_m=100)\n a2 = A(sq_m=200)\n\n a3 = a1 + a2\n self.assertEqual(a3.sq_m, 300)\n a3 += a1\n self.assertEqual(a3.sq_m, 400)\n \n a4 = a1 - a2\n self.assertEqual(a4.sq_m, -100)\n a4 -= a1\n self.assertEqual(a4.sq_m, -200)\n \n try:\n a5 = a1 + 1\n except TypeError, e:\n pass\n else:\n self.fail('Area + number should raise TypeError')\n\n try:\n a5 = a1 - 1\n except TypeError, e:\n pass\n else:\n self.fail('Area - number should raise TypeError')\n\n try:\n a1 += 1\n except TypeError, e:\n pass\n else:\n self.fail('Area += number should raise TypeError')\n\n try:\n a1 -= 1\n except TypeError, e:\n pass\n else:\n self.fail('Area -= number should raise TypeError')", "metadata": "root.AreaTest.testAddition", "header": "['class', 'AreaTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 203 }, { "content": " def testMultiplication(self):\n \"Test multiplication & division\"\n a1 = A(sq_m=100)\n\n a3 = a1 * 2\n self.assertEqual(a3.sq_m, 200)\n a3 = 2 * a1\n self.assertEqual(a3.sq_m, 200)\n a3 *= 5\n self.assertEqual(a3.sq_m, 1000)\n \n a4 = a1 / 2\n self.assertEqual(a4.sq_m, 50)\n a4 /= 5\n self.assertEqual(a4.sq_m, 10)\n \n try:\n a5 = a1 * A(sq_m=1)\n except TypeError, e:\n pass\n else:\n self.fail('Area * Area should raise TypeError')\n\n try:\n a1 *= A(sq_m=1)\n except TypeError, e:\n pass\n else:\n self.fail('Area *= Area should raise TypeError')\n \n try:\n a5 = a1 / A(sq_m=1)\n except TypeError, e:\n pass\n else:\n self.fail('Area / Area should raise TypeError')\n\n try:\n a1 /= A(sq_m=1)\n except TypeError, e:\n pass\n else:\n self.fail('Area /= Area should raise TypeError')", "metadata": "root.AreaTest.testMultiplication", "header": "['class', 'AreaTest', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 246 } ]
[ { "span": "d5 ", "start_line": 64, "start_column": 12, "end_line": 64, "end_column": 14 }, { "span": "a5 ", "start_line": 219, "start_column": 12, "end_line": 219, "end_column": 14 }, { "span": "a5 ", "start_line": 263, "start_column": 12, "end_line": 263, "end_column": 14 } ]
[ { "span": "d5 ", "start_line": 71, "start_column": 12, "end_line": 71, "end_column": 14 }, { "span": "a5 ", "start_line": 226, "start_column": 12, "end_line": 226, "end_column": 14 }, { "span": "a5 ", "start_line": 277, "start_column": 12, "end_line": 277, "end_column": 14 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "class_", "Distan", "ce", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Addition", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Test", " ", "addition", " ", "&", " ", "subtract", "ion", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d1_", "=_", "D_", "(_", "m_", "=_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d2_", "=_", "D_", "(_", "m_", "=_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "d3_", "=_", "d1_", "+_", "d2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "d3_", "._", "m_", ",_", "300_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d3_", "+=_", "d1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "d3_", "._", "m_", ",_", "400_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "d4", "_", "=_", "d1_", "-_", "d2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "d4", "_", "._", "m_", ",_", "-_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d4", "_", "-=_", "d1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "d4", "_", "._", "m_", ",_", "-_", "200_", ")_", "\\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 ", " _", "d5", "_", "=_", "d1_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "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_", "._", "fail_", "(_", "'", "Distan", "ce", " ", "+", " ", "number", " ", "shou", "ld", " ", "raise", " ", "Type", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d5", "_", "=_", "d1_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "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_", "._", "fail_", "(_", "'", "Distan", "ce", " ", "-", " ", "number", " ", "shou", "ld", " ", "raise", " ", "Type", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d1_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "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_", "._", "fail_", "(_", "'", "Distan", "ce", " ", "+=", " ", "number", " ", "shou", "ld", " ", "raise", " ", "Type", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d1_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "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_", "._", "fail_", "(_", "'", "Distan", "ce", " ", "-=", " ", "number", " ", "shou", "ld", " ", "raise", " ", "Type", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Area", "Test_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Addition", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Test", " ", "addition", " ", "&", " ", "subtract", "ion", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a1_", "=_", "A_", "(_", "sq", "\\u", "m_", "=_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a2_", "=_", "A_", "(_", "sq", "\\u", "m_", "=_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "a3_", "=_", "a1_", "+_", "a2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "a3_", "._", "sq", "\\u", "m_", ",_", "300_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a3_", "+=_", "a1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "a3_", "._", "sq", "\\u", "m_", ",_", "400_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "a4_", "=_", "a1_", "-_", "a2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "a4_", "._", "sq", "\\u", "m_", ",_", "-_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a4_", "-=_", "a1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "a4_", "._", "sq", "\\u", "m_", ",_", "-_", "200_", ")_", "\\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 ", " _", "a5", "_", "=_", "a1_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "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_", "._", "fail_", "(_", "'", "Area", " ", "+", " ", "number", " ", "shou", "ld", " ", "raise", " ", "Type", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a5", "_", "=_", "a1_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "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_", "._", "fail_", "(_", "'", "Area", " ", "-", " ", "number", " ", "shou", "ld", " ", "raise", " ", "Type", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a1_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "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_", "._", "fail_", "(_", "'", "Area", " ", "+=", " ", "number", " ", "shou", "ld", " ", "raise", " ", "Type", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a1_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "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_", "._", "fail_", "(_", "'", "Area", " ", "-=", " ", "number", " ", "shou", "ld", " ", "raise", " ", "Type", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Area", "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", "Multipl", "ication", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Test", " ", "multiplication", " ", "&", " ", "divisi", "on", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a1_", "=_", "A_", "(_", "sq", "\\u", "m_", "=_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "a3_", "=_", "a1_", "*_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "a3_", "._", "sq", "\\u", "m_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a3_", "=_", "2_", "*_", "a1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "a3_", "._", "sq", "\\u", "m_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a3_", "*=_", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "a3_", "._", "sq", "\\u", "m_", ",_", "1000_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "a4_", "=_", "a1_", "/_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "a4_", "._", "sq", "\\u", "m_", ",_", "50_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a4_", "/=_", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "a4_", "._", "sq", "\\u", "m_", ",_", "10_", ")_", "\\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 ", " _", "a5", "_", "=_", "a1_", "*_", "A_", "(_", "sq", "\\u", "m_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "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_", "._", "fail_", "(_", "'", "Area", " ", "*", " ", "Area", " ", "shou", "ld", " ", "raise", " ", "Type", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a1_", "*=_", "A_", "(_", "sq", "\\u", "m_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "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_", "._", "fail_", "(_", "'", "Area", " ", "*=", " ", "Area", " ", "shou", "ld", " ", "raise", " ", "Type", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a5", "_", "=_", "a1_", "/_", "A_", "(_", "sq", "\\u", "m_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "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_", "._", "fail_", "(_", "'", "Area", " ", "/", " ", "Area", " ", "shou", "ld", " ", "raise", " ", "Type", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "a1_", "/=_", "A_", "(_", "sq", "\\u", "m_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Type", "Error_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "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_", "._", "fail_", "(_", "'", "Area", " ", "/", "=", " ", "Area", " ", "shou", "ld", " ", "raise", " ", "Type", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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 ]
Except block handles 'BaseException'
nltk/nltk/nltk/app/chartparser_app.py
[ { "content": " def destroy(self, *e):\n if self._root is None: return\n try: self._root.destroy()\n except: pass\n self._root = None", "metadata": "root.ChartMatrixView.destroy", "header": "['class', 'ChartMatrixView', '(', 'object', ')', ':', '___EOS___']", "index": 151 }, { "content": " def remove_callback(self, event, func=None):\n if func is None: del self._callbacks[event]\n else:\n try: del self._callbacks[event][func]\n except: pass", "metadata": "root.ChartMatrixView.remove_callback", "header": "['class', 'ChartMatrixView', '(', 'object', ')', ':', '___EOS___']", "index": 211 }, { "content": " def destroy(self, *e):\n if self._root is None: return\n try: self._root.destroy()\n except: pass\n self._root = None", "metadata": "root.ChartResultsView.destroy", "header": "['class', 'ChartResultsView', '(', 'object', ')', ':', '___EOS___']", "index": 448 }, { "content": " def destroy(self, *e):\n if self._root is None: return\n try: self._root.destroy()\n except: pass\n self._root = None", "metadata": "root.ChartComparer.destroy", "header": "['class', 'ChartComparer', '(', 'object', ')', ':', '___EOS___']", "index": 531 }, { "content": " def remove_callback(self, event, func=None):\n if func is None: del self._callbacks[event]\n else:\n try: del self._callbacks[event][func]\n except: pass", "metadata": "root.ChartView.remove_callback", "header": "['class', 'ChartView', '(', 'object', ')', ':', '___EOS___']", "index": 1577 }, { "content": " def help(self, *e):\n self._animating = 0\n # The default font's not very legible; try using 'fixed' instead.\n try:\n ShowText(self._root, 'Help: Chart Parser Application',\n (__doc__ or '').strip(), width=75, font='fixed')\n except:\n ShowText(self._root, 'Help: Chart Parser Application',\n (__doc__ or '').strip(), width=75)", "metadata": "root.ChartParserApp.help", "header": "['class', 'ChartParserApp', '(', 'object', ')', ':', '___EOS___']", "index": 1972 } ]
[ { "span": "except: ", "start_line": 154, "start_column": 8, "end_line": 154, "end_column": 15 }, { "span": "except: ", "start_line": 215, "start_column": 12, "end_line": 215, "end_column": 19 }, { "span": "except: ", "start_line": 451, "start_column": 8, "end_line": 451, "end_column": 15 }, { "span": "except: ", "start_line": 534, "start_column": 8, "end_line": 534, "end_column": 15 }, { "span": "except: ", "start_line": 1581, "start_column": 12, "end_line": 1581, "end_column": 19 }, { "span": "except:", "start_line": 1978, "start_column": 8, "end_line": 1978, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Char", "t", "Matrix", "View_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "destroy_", "(_", "self_", ",_", "*_", "e_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "root_", "is_", "None_", ":_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "self_", "._", "\\u", "root_", "._", "destroy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "root_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Char", "t", "Matrix", "View_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "callback_", "(_", "self_", ",_", "event_", ",_", "func_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "func_", "is_", "None_", ":_", "del_", "self_", "._", "\\u", "callbacks_", "[_", "event_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "del_", "self_", "._", "\\u", "callbacks_", "[_", "event_", "]_", "[_", "func_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Char", "t", "Result", "s", "View_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "destroy_", "(_", "self_", ",_", "*_", "e_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "root_", "is_", "None_", ":_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "self_", "._", "\\u", "root_", "._", "destroy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "root_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Char", "t", "Compare", "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_", "destroy_", "(_", "self_", ",_", "*_", "e_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "root_", "is_", "None_", ":_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "self_", "._", "\\u", "root_", "._", "destroy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "root_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Char", "t", "View_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "callback_", "(_", "self_", ",_", "event_", ",_", "func_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "func_", "is_", "None_", ":_", "del_", "self_", "._", "\\u", "callbacks_", "[_", "event_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "del_", "self_", "._", "\\u", "callbacks_", "[_", "event_", "]_", "[_", "func_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Char", "t", "Parser", "App_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "help_", "(_", "self_", ",_", "*_", "e_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "animati", "ng_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "default", " ", "font", "'", "s", " ", "not", " ", "very", " ", "leg", "ibl", "e", ";", " ", "try", " ", "usi", "ng", " ", "'", "fixed", "'", " ", "inst", "ead", "._", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Show", "Text_", "(_", "self_", "._", "\\u", "root_", ",_", "'", "Help", ":", " ", "Char", "t", " ", "Parser", " ", "Applica", "tion", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\\u\\u", "doc\\u\\u_", "or_", "''_", ")_", "._", "strip_", "(_", ")_", ",_", "width_", "=_", "75_", ",_", "font_", "=_", "'", "fixed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Show", "Text_", "(_", "self_", "._", "\\u", "root_", ",_", "'", "Help", ":", " ", "Char", "t", " ", "Parser", " ", "Applica", "tion", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\\u\\u", "doc\\u\\u_", "or_", "''_", ")_", "._", "strip_", "(_", ")_", ",_", "width_", "=_", "75_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 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, 0, 1, 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, 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, 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, 1, 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, 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 ]
Unused import
ericholscher/django-kong/kong/utils.py
[ { "content": "import datetime\nimport StringIO\nimport sys\n\nfrom django.conf import settings\nfrom django.core.mail import mail_managers, mail_admins\nfrom django.template.loader import render_to_string\nfrom django.contrib.sites.models import Site\n\nfrom twill.parse import execute_string\nfrom twill.errors import TwillAssertionError\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def _send_error(kong_site, test, content):\n real_site = Site.objects.get_current()\n message = render_to_string('kong/failed_email.txt', {'kong_site': kong_site,\n 'test': test,\n 'error': content,\n 'real_site': real_site})\n if getattr(settings, 'KONG_MAIL_MANAGERS', False):\n mail_managers('Kong Test Failed: %s (%s)' % (test, kong_site), message)\n if getattr(settings, 'KONG_MAIL_ADMINS', False):\n mail_admins('Kong Test Failed: %s (%s)' % (test, kong_site), message)", "metadata": "root._send_error", "header": "['module', '___EOS___']", "index": 12 }, { "content": "def _send_recovery(kong_site, test, content):\n real_site = Site.objects.get_current()\n message = render_to_string(\n 'kong/recovered_email.txt', {\n 'kong_site': kong_site,\n 'test': test,\n 'content': content,\n 'real_site': real_site\n }\n )\n if getattr(settings, 'KONG_MAIL_MANAGERS', False):\n mail_managers('Kong Test Recovered: %s (%s)' % (test, kong_site), message)\n if getattr(settings, 'KONG_MAIL_ADMINS', False):\n mail_admins('Kong Test Recovered: %s (%s)' % (test, kong_site), message)", "metadata": "root._send_recovery", "header": "['module', '___EOS___']", "index": 23 }, { "content": "def execute_test(site, test):\n import twill.commands as commands\n #Avoid circular import\n from kong.models import TestResult\n twill_script = test.render(site)\n content = ''\n old_err = sys.stderr\n new_err = StringIO.StringIO()\n commands.ERR = new_err\n\n now = datetime.datetime.now()\n try:\n if getattr(settings, 'KONG_RESET_BROWSER', False):\n execute_string(twill_script, no_reset = False)\n else:\n execute_string(twill_script)\n succeeded = True\n content = new_err.getvalue().strip()\n except Exception, e:\n succeeded = False\n content = new_err.getvalue().strip() + \"\\n\\nException:\\n\\n\" + str(e)\n\n end = datetime.datetime.now()\n duration = end - now\n duration = duration.microseconds\n commands.ERR = old_err\n result = TestResult.objects.create(site=site,\n test=test,\n succeeded=succeeded,\n duration=duration,\n content=content)\n\n if result.notification_needed and result.failed:\n _send_error(site, test, content)\n if result.notification_needed and result.succeeded:\n _send_recovery(site, test, content)\n\n return succeeded", "metadata": "root.execute_test", "header": "['module', '___EOS___']", "index": 38 } ]
[ { "span": "from twill.errors import TwillAssertionError", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 44 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "conf_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "mail_", "import_", "mail", "\\u", "managers_", ",_", "mail", "\\u", "admins_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "template_", "._", "loader_", "import_", "render", "\\u", "to", "\\u", "string_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "sites_", "._", "models_", "import_", "Site_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "twi", "ll_", "._", "parse_", "import_", "execute", "\\u", "string_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "twi", "ll_", "._", "errors_", "import_", "Twi", "ll", "Assert", "ion", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "send", "\\u", "error_", "(_", "kon", "g", "\\u", "site_", ",_", "test_", ",_", "content_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "real", "\\u", "site_", "=_", "Site_", "._", "objects_", "._", "get", "\\u", "current_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "render", "\\u", "to", "\\u", "string_", "(_", "'", "kon", "g", "/", "fail", "ed", "\\u", "email", ".", "txt", "'_", ",_", "{_", "'", "kon", "g", "\\u", "site", "'_", ":_", "kon", "g", "\\u", "site_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "test", "'_", ":_", "test_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "error", "'_", ":_", "content_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "real", "\\u", "site", "'_", ":_", "real", "\\u", "site_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "getattr_", "(_", "settings_", ",_", "'", "KO", "NG", "\\u", "MAIL", "\\u", "MANAGER", "S", "'_", ",_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mail", "\\u", "managers_", "(_", "'", "Kon", "g", " ", "Test", " ", "Fail", "ed", ":", " ", "%", "s", " ", "(%", "s", ")'_", "%_", "(_", "test_", ",_", "kon", "g", "\\u", "site_", ")_", ",_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "getattr_", "(_", "settings_", ",_", "'", "KO", "NG", "\\u", "MAIL", "\\u", "ADM", "INS", "'_", ",_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mail", "\\u", "admins_", "(_", "'", "Kon", "g", " ", "Test", " ", "Fail", "ed", ":", " ", "%", "s", " ", "(%", "s", ")'_", "%_", "(_", "test_", ",_", "kon", "g", "\\u", "site_", ")_", ",_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "send", "\\u", "recover", "y_", "(_", "kon", "g", "\\u", "site_", ",_", "test_", ",_", "content_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "real", "\\u", "site_", "=_", "Site_", "._", "objects_", "._", "get", "\\u", "current_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "message_", "=_", "render", "\\u", "to", "\\u", "string_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "kon", "g", "/", "recovered", "\\u", "email", ".", "txt", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "kon", "g", "\\u", "site", "'_", ":_", "kon", "g", "\\u", "site_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "test", "'_", ":_", "test_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "content", "'_", ":_", "content_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "real", "\\u", "site", "'_", ":_", "real", "\\u", "site_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "getattr_", "(_", "settings_", ",_", "'", "KO", "NG", "\\u", "MAIL", "\\u", "MANAGER", "S", "'_", ",_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mail", "\\u", "managers_", "(_", "'", "Kon", "g", " ", "Test", " ", "Recover", "ed", ":", " ", "%", "s", " ", "(%", "s", ")'_", "%_", "(_", "test_", ",_", "kon", "g", "\\u", "site_", ")_", ",_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "getattr_", "(_", "settings_", ",_", "'", "KO", "NG", "\\u", "MAIL", "\\u", "ADM", "INS", "'_", ",_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mail", "\\u", "admins_", "(_", "'", "Kon", "g", " ", "Test", " ", "Recover", "ed", ":", " ", "%", "s", " ", "(%", "s", ")'_", "%_", "(_", "test_", ",_", "kon", "g", "\\u", "site_", ")_", ",_", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "execute", "\\u", "test_", "(_", "site_", ",_", "test_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "twi", "ll_", "._", "commands_", "as_", "commands_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Av", "oid", " ", "circular", " ", "import_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "kon", "g_", "._", "models_", "import_", "Test", "Result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "twi", "ll", "\\u", "script_", "=_", "test_", "._", "render_", "(_", "site_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "old", "\\u", "err_", "=_", "sys_", "._", "stderr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "err_", "=_", "String", "IO_", "._", "String", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "commands_", "._", "ERR_", "=_", "new", "\\u", "err_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "now_", "=_", "datetime_", "._", "datetime_", "._", "now_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "getattr_", "(_", "settings_", ",_", "'", "KO", "NG", "\\u", "RESE", "T", "\\u", "BROWSER", "'_", ",_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "execute", "\\u", "string_", "(_", "twi", "ll", "\\u", "script_", ",_", "no", "\\u", "reset_", "=_", "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 ", " _", "execute", "\\u", "string_", "(_", "twi", "ll", "\\u", "script_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "succeeded_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content_", "=_", "new", "\\u", "err_", "._", "getvalue_", "(_", ")_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "succeeded_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "content_", "=_", "new", "\\u", "err_", "._", "getvalue_", "(_", ")_", "._", "strip_", "(_", ")_", "+_", "\"\\\\", "n", "\\\\", "n", "Except", "ion", ":\\\\", "n", "\\\\", "n", "\"_", "+_", "str_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "end_", "=_", "datetime_", "._", "datetime_", "._", "now_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "duration_", "=_", "end_", "-_", "now_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "duration_", "=_", "duration_", "._", "microseconds_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "commands_", "._", "ERR_", "=_", "old", "\\u", "err_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "Test", "Result_", "._", "objects_", "._", "create_", "(_", "site_", "=_", "site_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "test_", "=_", "test_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "succeeded_", "=_", "succeeded_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "duration_", "=_", "duration_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content_", "=_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "result_", "._", "notification", "\\u", "needed_", "and_", "result_", "._", "failed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "send", "\\u", "error_", "(_", "site_", ",_", "test_", ",_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "result_", "._", "notification", "\\u", "needed_", "and_", "result_", "._", "succeeded_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "send", "\\u", "recover", "y_", "(_", "site_", ",_", "test_", ",_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "succeeded_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused local variable
pedrodgcouto/kivy.data_grid/data_grid.py
[ { "content": "\tdef remove_row(self, n_cols, instance, **kwargs):\n\t\tchilds = self.parent.children\n\t\tselected = 0\n\t\tfor ch in childs:\n\t\t\tfor c in reversed(ch.children):\n\t\t\t\tif c.id != \"Header_Label\":\n\t\t\t\t\tif c.state == \"down\":\n\t\t\t\t\t\tself.remove_widget(c)\n\t\t\t\t\t\tprint str(c.id) + ' - ' + str(c.state)\n\t\t\t\t\t\tselected += 1\n\t\tif selected == 0:\n\t\t\tfor ch in childs:\n\t\t\t\tcount_01 = n_cols\n\t\t\t\tcount_02 = 0\n\t\t\t\tcount = 0\n\t\t\t\twhile (count < n_cols):\n\t\t\t\t\tif n_cols != len(ch.children):\n\t\t\t\t\t\tfor c in ch.children:\n\t\t\t\t\t\t\tif c.id != \"Header_Label\":\n\t\t\t\t\t\t\t\tprint \"Length: \" + str(len(ch.children))\n\t\t\t\t\t\t\t\tprint \"N_cols: \" + str(n_cols + 1)\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tself.remove_widget(c)\n\t\t\t\t\t\t\t\tcount += 1\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\telse:\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\telse:\n\t\t\t\t\t\tbreak", "metadata": "root.DataGrid.remove_row", "header": "['class', 'DataGrid', '(', 'GridLayout', ')', ':', '___EOS___']", "index": 126 } ]
[ { "span": "count_01 ", "start_line": 138, "start_column": 4, "end_line": 138, "end_column": 12 }, { "span": "count_02 ", "start_line": 139, "start_column": 4, "end_line": 139, "end_column": 12 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Data", "Grid_", "(_", "Grid", "Layout_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "remove", "\\u", "row_", "(_", "self_", ",_", "n", "\\u", "cols_", ",_", "instance_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "childs_", "=_", "self_", "._", "parent_", "._", "children_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "selected_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "ch_", "in_", "childs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "for_", "c_", "in_", "reversed_", "(_", "ch_", "._", "children_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "if_", "c_", "._", "id_", "!=_", "\"", "Head", "er", "\\u", "Label", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "if_", "c_", "._", "state_", "==_", "\"", "down", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "self_", "._", "remove", "\\u", "widget_", "(_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "str_", "(_", "c_", "._", "id_", ")_", "+_", "'", " ", " ", " ", "-", " ", " ", " ", "'_", "+_", "str_", "(_", "c_", "._", "state_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "selected_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "selected_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "for_", "ch_", "in_", "childs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "count", "\\u", "01_", "=_", "n", "\\u", "cols_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count", "\\u", "02_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "(_", "count_", "<_", "n", "\\u", "cols_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "if_", "n", "\\u", "cols_", "!=_", "len_", "(_", "ch_", "._", "children_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t_", "for_", "c_", "in_", "ch_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t\t_", "if_", "c_", "._", "id_", "!=_", "\"", "Head", "er", "\\u", "Label", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t\t\t\t_", "print_", "\"", "Length", ":", " ", "\"_", "+_", "str_", "(_", "len_", "(_", "ch_", "._", "children_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "N", "\\u", "cols", ":", " ", "\"_", "+_", "str_", "(_", "n", "\\u", "cols_", "+_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "remove", "\\u", "widget_", "(_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count_", "+=_", "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 ]
Unused local variable
fp7-ofelia/ocf/vt_manager/src/python/vt_manager/controller/dispatchers/ui/PolicyDispatcher.py
[ { "content": "def policy_create(request,table):\n\n\terrors = []\n rules = []\n\tmapps = RuleTableManager.getActionMappings()\n\tpriorityList = RuleTableManager.getPriorityList()\n\tcondMapps = RuleTableManager.getConditionMappings()\n\n\n\treturn simple.direct_to_template(request,\n template = 'policyEngine/policy_create.html',\n extra_context = {'user': request.user,\n 'CurrentTable': table,\n\t\t\t\t\t\t\t 'mappings':mapps,\n\t\t\t\t\t\t\t 'priorityList':priorityList,\n\t\t\t\t\t\t\t 'allMappings':RuleTableManager.GetResolverMappings(table),\n\t\t\t\t\t\t\t 'ConditionMappings':condMapps,\n 'ActionMappings':RuleTableManager.getActionMappings()},\n )", "metadata": "root.policy_create", "header": "['module', '___EOS___']", "index": 36 }, { "content": "def rule_create(request,table_name=None):\n\n\terrors = list()\n\tformMode = request.POST.get(\"conditionMode\")\n\ttableName = request.POST.get(\"table\")\n\tPreviousPriority = request.POST.get(\"ppriority\")\n editing = request.POST.get(\"editing\")\n ruleid = request.POST.get(\"uuid\")\n ruleCondition = request.POST.get(\"condition\")\n ruleDesc = request.POST.get(\"description\")\n ruleError = request.POST.get(\"error_message\")\n ruleType = request.POST.get(\"type\")\n ruleAction = request.POST.get(\"action\")\n ruleValue = request.POST.get(\"value\")\n rulePriority = request.POST.get(\"priority\")\n ruleEnable = request.POST.get(\"enable\")\n previousTable = request.POST.get(\"hidden_name\")\n\texpertRule = request.POST.get(\"expertRule\")\n\tnewConditions = request.POST.get(\"conditionID\")\t\n\tsaved = request.POST.get(\"saved\")\n\n if rulePriority == 'Last' or rulePriority == '':\n priority = None\n else:\n priority = int(rulePriority)\n\n\tif formMode == \"easy\":\n\t#Avoid empty fields\n# \tif ruleDesc == \"\":\n# \terrors.append(\"Description Field is empty\")\n \tif ruleError == \"\":\n \terrors.append(\"Error Message field is empty\")\n \tif ruleCondition == \"\":\n \terrors.append(\"Condition field is empty\")\n\t\ttry:\n\t\t\tstr(ruleDesc)\n\t\texcept:\n\t\t\terrors.append(\"Only ascii characters are allowed in Description field\")\n\t\ttry:\n\t\t\tstr(ruleError)\n\t\texcept:\n\t\t\terrors.append(\"Only ascii characters are allowed in Error Message field\")\n\t\ttry:\n\t\t\tstr(ruleCondition)\n\t\texcept:\n\t\t\terrors.append(\"Only ascii characters are allowed in Conditions\")\n\n\t\n\n if request.POST.get(\"enable\") == 'enable':\n enable = True\n else:\n enable = False\n\tif ruleType == \"terminal\":\n\t\truleType = \"\"\n\t\n\tif saved == None:\n\t\tsaved = False\n\t#Rule String convertion required\n\tif formMode == \"easy\":\n\t\tif ruleAction != \"None\":\n\t\t\tstrings = \"if \" + ruleCondition + \" then \" + ruleValue + \" \" + ruleType + \" do \" + ruleAction + \" denyMessage \" + ruleError + \" #\" + ruleDesc\n\t\telse:\n\t\t\tstrings = \"if \" + ruleCondition + \" then \" + ruleValue + \" \" + ruleType + \" denyMessage \" + ruleError + \" #\" + ruleDesc\n\telse:\n\t\tstrings = expertRule\n\t\ttry:\n\t\t\tstr(expertRule)\n\t\texcept:\n\t\t\terrors.append(\"Only ascii characters are allowed in a Rule\")\n\t\n\ttry:\n\t\tif errors:\n raise Exception(\"\")\n\t\t\n\t\tif editing == '1':\n\t\t\t#Editing Rules Case:\n \tif previousTable == tableName:\n\t\t\t\ttry:\n\t\t\t\t\tRuleTableManager.editRule(strings,enable,priority,PreviousPriority,tableName)\n\t\t\t\texcept Exception as e:\n\t\t\t\t\traise e\n \t#else:\n\t\t\t\t#Moving a rule to a different RuleTable --> this is not possible yet \n \t#print 'Changing table...'\n \t#RuleTableManager.AddRule(strings,enable,priority,tableName=tableName)\n \t#print 'successful add to ' + tableName\n \t#RuleTableManager.RemoveRule(None,int(PreviousPriority),'oldTableName')\n \t#print 'remove from ' + previousTable + ' successful'\n \telse:\n \tRuleTableManager.AddRule(strings,enable,priority,tableName=tableName)\n\n return HttpResponseRedirect(\"/policies\")\t\t\n\n\texcept Exception as e:\n\n\t\terrors.append(e)\n\t\terrors.insert(0,\"The Rule cannot be generated. Reason(s):\")#Insterting the main message error in the first position of the table\n\t\tpriority = RuleTableManager.getPriorityList(tableName)\n\t\tpriority = RuleTableManager.getPriorityList(tableName)\n\t\t\n\t\t#if a rule index is the last, insert \"LAST\" in the rule priority instead the true index.\n\t\ttry:\n\t\t\tint(rulePriority)\n\t\t\tif int(rulePriority) in priority:\n\t\t\t\tpriority.pop(priority.index(int(rulePriority)))\n\t\texcept:\n\t\t\trulePriority = \"Last\"\n\n\t\tif ruleValue == \"accept\":\n\t\t\tvalue2 = [\"deny\"]\n\t\telse:\n\t\t\tvalue2 = [\"accept\"]\n\n\t\tif ruleType == \"nonterminal\":\n\t\t\ttype2 = [\"terminal\"]\n\t\telse:\n\t\t\truleType = \"terminal\"\n\t\t\ttype2 = [\"nonterminal\"]\n\n\n\t\tcontext = {'user': request.user,\n 'saved':True,\n 'CurrentTable':tableName,\n 'priority':PreviousPriority,\n 'enabled':ruleEnable,\n\t\t\t 'load':'True',\n 'valueS':ruleValue,\n 'valueD':value2,\n 'terminalS':ruleType,\n 'terminalD':type2,\n 'errorMsg':ruleError,\n 'description':ruleDesc,\n 'condition':\" \" + ruleCondition + \" \",\n 'ptable':tableName,\n\t\t\t 'edit': request.POST.get('edit'),\n 'action':ruleAction,\n 'PrioritySel':rulePriority,\n 'priorityList':priority,\n 'allMappings':RuleTableManager.GetResolverMappings(tableName),\n 'ConditionMappings':RuleTableManager.getConditionMappings(),\n 'ActionMappings':RuleTableManager.getActionMappings(),\n 'errors': errors,\n 'rule_uuid':ruleid,}\n\n\t\treturn simple.direct_to_template(request,\n \t \t\ttemplate = 'policyEngine/policy_create.html',\n \t\textra_context = context)", "metadata": "root.rule_create", "header": "['module', '___EOS___']", "index": 79 } ]
[ { "span": "errors ", "start_line": 38, "start_column": 1, "end_line": 38, "end_column": 7 }, { "span": "rules ", "start_line": 39, "start_column": 8, "end_line": 39, "end_column": 13 }, { "span": "newConditions ", "start_line": 97, "start_column": 1, "end_line": 97, "end_column": 14 }, { "span": "saved ", "start_line": 136, "start_column": 2, "end_line": 136, "end_column": 7 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "policy", "\\u", "create_", "(_", "request_", ",_", "table_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "errors_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rules_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mapp", "s_", "=_", "Rule", "Table", "Manager_", "._", "get", "Action", "Mappings", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "priorit", "y", "List_", "=_", "Rule", "Table", "Manager_", "._", "get", "Prior", "it", "y", "List_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cond", "Map", "ps_", "=_", "Rule", "Table", "Manager_", "._", "get", "Cond", "ition", "Mappings", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "simple_", "._", "direct", "\\u", "to", "\\u", "template_", "(_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template_", "=_", "'", "policy", "Engine", "/", "policy", "\\u", "create", ".", "html", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "context_", "=_", "{_", "'", "user", "'_", ":_", "request_", "._", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Curr", "ent", "Table", "'_", ":_", "table_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mapping", "s", "'_", ":_", "mapp", "s_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "priorit", "y", "List", "'_", ":_", "priorit", "y", "List_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "all", "Mappings", "'_", ":_", "Rule", "Table", "Manager_", "._", "Get", "Resolv", "er", "Mappings", "_", "(_", "table_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Cond", "ition", "Mappings", "'_", ":_", "cond", "Map", "ps_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Action", "Mappings", "'_", ":_", "Rule", "Table", "Manager_", "._", "get", "Action", "Mappings", "_", "(_", ")_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "rule", "\\u", "create_", "(_", "request_", ",_", "table", "\\u", "name_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "errors_", "=_", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form", "Mode_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "condition", "Mode", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "table", "Name_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "table", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Prev", "ious", "Priority_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "ppr", "ior", "it", "y", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "editin", "g_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "editin", "g", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rule", "id_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "uuid", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rule", "Condition_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "condition", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rule", "Desc_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "description", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rule", "Error_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "error", "\\u", "message", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rule", "Type_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "type", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rule", "Action_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "action", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rule", "Value_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "value", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rule", "Priority_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "priorit", "y", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rule", "Enable_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "enable", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "previ", "ous", "Table_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "hidden", "\\u", "name", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expert", "Rule_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "expert", "Rule", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "Conditions", "_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "condition", "ID", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "saved_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "saved", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "rule", "Priority_", "==_", "'", "Las", "t", "'_", "or_", "rule", "Priority_", "==_", "''_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "priority_", "=_", "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 ", " _", "priority_", "=_", "int_", "(_", "rule", "Priority_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "form", "Mode_", "==_", "\"", "easy", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Av", "oid", " ", "empty", " ", "fields_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " \t", "if", " ", "rule", "Des", "c", " ", "==", " ", "\"\"", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "\t", "error", "s", ".", "append", "(\"", "Descripti", "on", " ", "Field", " ", "is", " ", "empty", "\")", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " \t", "_", "if_", "rule", "Error_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " ", " ", "\t_", "errors_", "._", "append_", "(_", "\"", "Error", " ", "Messag", "e", " ", "field", " ", "is", " ", "empty", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "rule", "Condition_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " ", " ", "\t_", "errors_", "._", "append_", "(_", "\"", "Cond", "ition", " ", "field", " ", "is", " ", "empty", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "str_", "(_", "rule", "Desc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "errors_", "._", "append_", "(_", "\"", "On", "ly", " ", "ascii", " ", "character", "s", " ", "are", " ", "allow", "ed", " ", "in", " ", "Descripti", "on", " ", "field", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "str_", "(_", "rule", "Error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "errors_", "._", "append_", "(_", "\"", "On", "ly", " ", "ascii", " ", "character", "s", " ", "are", " ", "allow", "ed", " ", "in", " ", "Error", " ", "Messag", "e", " ", "field", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "str_", "(_", "rule", "Condition_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "errors_", "._", "append_", "(_", "\"", "On", "ly", " ", "ascii", " ", "character", "s", " ", "are", " ", "allow", "ed", " ", "in", " ", "Conditions", "\"_", ")_", "\\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_", "if_", "request_", "._", "POST_", "._", "get_", "(_", "\"", "enable", "\"_", ")_", "==_", "'", "enable", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "enable_", "=_", "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 ", " _", "enable_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "rule", "Type_", "==_", "\"", "termina", "l", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "rule", "Type_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "saved_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "saved_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Rule", " ", "String", " ", "convert", "ion", " ", "required_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "form", "Mode_", "==_", "\"", "easy", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "if_", "rule", "Action_", "!=_", "\"", "Non", "e", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "strings_", "=_", "\"", "if", " ", "\"_", "+_", "rule", "Condition_", "+_", "\"", " ", "then", " ", "\"_", "+_", "rule", "Value_", "+_", "\"", " ", "\"_", "+_", "rule", "Type_", "+_", "\"", " ", "do", " ", "\"_", "+_", "rule", "Action_", "+_", "\"", " ", "deny", "Messag", "e", " ", "\"_", "+_", "rule", "Error_", "+_", "\"", " ", "#\"_", "+_", "rule", "Desc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "strings_", "=_", "\"", "if", " ", "\"_", "+_", "rule", "Condition_", "+_", "\"", " ", "then", " ", "\"_", "+_", "rule", "Value_", "+_", "\"", " ", "\"_", "+_", "rule", "Type_", "+_", "\"", " ", "deny", "Messag", "e", " ", "\"_", "+_", "rule", "Error_", "+_", "\"", " ", "#\"_", "+_", "rule", "Desc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "strings_", "=_", "expert", "Rule_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "str_", "(_", "expert", "Rule_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "errors_", "._", "append_", "(_", "\"", "On", "ly", " ", "ascii", " ", "character", "s", " ", "are", " ", "allow", "ed", " ", "in", " ", "a", " ", "Rule", "\"_", ")_", "\\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\t", "\t_", "if_", "errors_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "raise_", "Exception_", "(_", "\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "editin", "g_", "==_", "'", "1", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Editing", " ", "Rule", "s", " ", "Case", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " ", " ", "\t_", "if_", "previ", "ous", "Table_", "==_", "table", "Name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "Rule", "Table", "Manager_", "._", "edit", "Rule_", "(_", "strings_", ",_", "enable_", ",_", "priority_", ",_", "Prev", "ious", "Priority_", ",_", "table", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "raise_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "else", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Movi", "ng", " ", "a", " ", "rule", " ", "to", " ", "a", " ", "different", " ", "Rule", "Table", " ", "-->", " ", "this", " ", "is", " ", "not", " ", "possib", "le", " ", "ye", "t", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "'", "Chang", "ing", " ", "table", "...'_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Rule", "Table", "Manager", ".", "Add", "Rule", "(", "string", "s", ",", "enable", ",", "priorit", "y", ",", "table", "Name", "=", "table", "Name", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "'", "success", "ful", " ", "add", " ", "to", " ", "'", " ", "+", " ", "table", "Name_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Rule", "Table", "Manager", ".", "Remove", "Rule", "(", "Non", "e", ",", "int", "(", "Prev", "ious", "Prior", "it", "y", "),", "'", "old", "Table", "Name", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "'", "remove", " ", "from", " ", "'", " ", "+", " ", " ", "previ", "ous", "Table", " ", "+", " ", "'", " ", "success", "ful", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " ", " ", "\t_", "Rule", "Table", "Manager_", "._", "Add", "Rule_", "(_", "strings_", ",_", "enable_", ",_", "priority_", ",_", "table", "Name_", "=_", "table", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "\"/", "poli", "cies", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "errors_", "._", "append_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "errors_", "._", "insert_", "(_", "0_", ",_", "\"", "The", " ", "Rule", " ", "cann", "ot", " ", "be", " ", "generat", "ed", ".", " ", "Rea", "son", "(", "s", "):\"_", ")_", "#", "Ins", "ter", "ting", " ", "the", " ", "main", " ", "message", " ", "error", " ", "in", " ", "the", " ", "first", " ", "position", " ", "of", " ", "the", " ", "table_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "priority_", "=_", "Rule", "Table", "Manager_", "._", "get", "Prior", "it", "y", "List_", "(_", "table", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "priority_", "=_", "Rule", "Table", "Manager_", "._", "get", "Prior", "it", "y", "List_", "(_", "table", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "if", " ", "a", " ", "rule", " ", "index", " ", "is", " ", "the", " ", "last", ",", " ", "insert", " ", "\"", "LAS", "T", "\"", " ", "in", " ", "the", " ", "rule", " ", "priorit", "y", " ", "inst", "ead", " ", "the", " ", "true", " ", "index", "._", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "int_", "(_", "rule", "Priority_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "int_", "(_", "rule", "Priority_", ")_", "in_", "priority_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "priority_", "._", "pop_", "(_", "priority_", "._", "index_", "(_", "int_", "(_", "rule", "Priority_", ")_", ")_", ")_", "\\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\t", "\t\t_", "rule", "Priority_", "=_", "\"", "Las", "t", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "rule", "Value_", "==_", "\"", "accept", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "value2_", "=_", "[_", "\"", "deny", "\"_", "]_", "\\u\\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_", "value2_", "=_", "[_", "\"", "accept", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "rule", "Type_", "==_", "\"", "nont", "ermina", "l", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "type2_", "=_", "[_", "\"", "termina", "l", "\"_", "]_", "\\u\\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_", "rule", "Type_", "=_", "\"", "termina", "l", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "type2_", "=_", "[_", "\"", "nont", "ermina", "l", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "context_", "=_", "{_", "'", "user", "'_", ":_", "request_", "._", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "saved", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Curr", "ent", "Table", "'_", ":_", "table", "Name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "priorit", "y", "'_", ":_", "Prev", "ious", "Priority_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "enable", "d", "'_", ":_", "rule", "Enable_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "load", "'_", ":_", "'", "Tru", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "value", "S", "'_", ":_", "rule", "Value_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "value", "D", "'_", ":_", "value2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "termina", "l", "S", "'_", ":_", "rule", "Type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "termina", "l", "D", "'_", ":_", "type2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "error", "Msg", "'_", ":_", "rule", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "description", "'_", ":_", "rule", "Desc_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "condition", "'_", ":_", "\"", " ", "\"_", "+_", "rule", "Condition_", "+_", "\"", " ", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ptable", "'_", ":_", "table", "Name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "edit", "'_", ":_", "request_", "._", "POST_", "._", "get_", "(_", "'", "edit", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "action", "'_", ":_", "rule", "Action_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Prior", "it", "y", "Sel", "'_", ":_", "rule", "Priority_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "priorit", "y", "List", "'_", ":_", "priority_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "all", "Mappings", "'_", ":_", "Rule", "Table", "Manager_", "._", "Get", "Resolv", "er", "Mappings", "_", "(_", "table", "Name_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Cond", "ition", "Mappings", "'_", ":_", "Rule", "Table", "Manager_", "._", "get", "Cond", "ition", "Mappings", "_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Action", "Mappings", "'_", ":_", "Rule", "Table", "Manager_", "._", "get", "Action", "Mappings", "_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "error", "s", "'_", ":_", "errors_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rule", "\\u", "uuid", "'_", ":_", "rule", "id_", ",_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "simple_", "._", "direct", "\\u", "to", "\\u", "template_", "(_", "request_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template_", "=_", "'", "policy", "Engine", "/", "policy", "\\u", "create", ".", "html", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "\\u", "context_", "=_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, 2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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
deanhiller/databus/webapp/play1.3.x/modules/docviewer/commands.py
[ { "content": "# Here you can create play commands that are specific to the module, and extend existing commands\nimport os, os.path\nimport getopt\nimport sys\nimport subprocess\n\nMODULE = 'docviewer'\n\n# Commands that are specific to your module\n\nCOMMANDS = ['doc:export']\n\n\n# This will be executed before any command (new, run...)\n\n\n# This will be executed after any command (new, run...)\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def execute(**kargs):\n command = kargs.get(\"command\")\n app = kargs.get(\"app\")\n args = kargs.get(\"args\")\n env = kargs.get(\"env\")\n\n if command == \"doc:export\":\n print \"~ Generating project documentation\"\n print \"~ \"\n java_cmd = app.java_cmd([], None, \"play.modules.docviewer.ExportDocumentationGenerator\", args)\n try:\n subprocess.call(java_cmd, env=os.environ)\n except OSError:\n print \"Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly (the java executable should reside at JAVA_HOME/bin/java). \"\n sys.exit(-1)\n print", "metadata": "root.execute", "header": "['module', '___EOS___']", "index": 12 }, { "content": "def before(**kargs):\n command = kargs.get(\"command\")\n app = kargs.get(\"app\")\n args = kargs.get(\"args\")\n env = kargs.get(\"env\")", "metadata": "root.before", "header": "['module', '___EOS___']", "index": 30 }, { "content": "def after(**kargs):\n command = kargs.get(\"command\")\n app = kargs.get(\"app\")\n args = kargs.get(\"args\")\n env = kargs.get(\"env\")\n\n if command == \"new\":\n pass", "metadata": "root.after", "header": "['module', '___EOS___']", "index": 38 } ]
[ { "span": "import getopt", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 13 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "Her", "e", " ", "you", " ", "can", " ", "create", " ", "play", " ", "command", "s", " ", "tha", "t", " ", "are", " ", "specific", " ", "to", " ", "the", " ", "module", ",", " ", "and", " ", "extend", " ", "exist", "ing", " ", "commands_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", ",_", "os_", "._", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "getopt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "subprocess_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "MODULE_", "=_", "'", "doc", "viewer", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Command", "s", " ", "tha", "t", " ", "are", " ", "specific", " ", "to", " ", "your", " ", "module_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "COMMANDS_", "=_", "[_", "'", "doc", ":", "export", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "will", " ", "be", " ", "executed", " ", "bef", "ore", " ", "any", " ", "command", " ", "(", "new", ",", " ", "run", "...)", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "will", " ", "be", " ", "executed", " ", "after", " ", "any", " ", "command", " ", "(", "new", ",", " ", "run", "...)", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "execute_", "(_", "**_", "kargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command_", "=_", "kargs_", "._", "get_", "(_", "\"", "command", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "=_", "kargs_", "._", "get_", "(_", "\"", "app", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "=_", "kargs_", "._", "get_", "(_", "\"", "args", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "env_", "=_", "kargs_", "._", "get_", "(_", "\"", "env", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "command_", "==_", "\"", "doc", ":", "export", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "~", " ", "Generat", "ing", " ", "project", " ", "documentation", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "~", " ", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "java", "\\u", "cmd_", "=_", "app_", "._", "java", "\\u", "cmd_", "(_", "[_", "]_", ",_", "None_", ",_", "\"", "play", ".", "module", "s", ".", "doc", "viewer", ".", "Export", "Document", "ation", "Generat", "or", "\"_", ",_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "subprocess_", "._", "call_", "(_", "java", "\\u", "cmd_", ",_", "env_", "=_", "os_", "._", "environ_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "OSE", "rror_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"", "Cou", "ld", " ", "not", " ", "execute", " ", "the", " ", "java", " ", "executable", ",", " ", "plea", "se", " ", "make", " ", "sure", " ", "the", " ", "JAVA", "\\u", "HOM", "E", " ", "environ", "ment", " ", "variab", "le", " ", "is", " ", "set", " ", "proper", "ly", " ", "(", "the", " ", "java", " ", "executable", " ", "shou", "ld", " ", "reside", " ", "at", " ", "JAVA", "\\u", "HOM", "E", "/", "bin", "/", "java", ").", " ", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "before_", "(_", "**_", "kargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command_", "=_", "kargs_", "._", "get_", "(_", "\"", "command", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "=_", "kargs_", "._", "get_", "(_", "\"", "app", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "=_", "kargs_", "._", "get_", "(_", "\"", "args", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "env_", "=_", "kargs_", "._", "get_", "(_", "\"", "env", "\"_", ")_", "\\u\\u\\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_", "after_", "(_", "**_", "kargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "command_", "=_", "kargs_", "._", "get_", "(_", "\"", "command", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "=_", "kargs_", "._", "get_", "(_", "\"", "app", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "args_", "=_", "kargs_", "._", "get_", "(_", "\"", "args", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "env_", "=_", "kargs_", "._", "get_", "(_", "\"", "env", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "command_", "==_", "\"", "new", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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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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 ]
Imprecise assert
openstack/cloudbase-init/cloudbaseinit/tests/osutils/test_windows.py
[ { "content": " @mock.patch('cloudbaseinit.osutils.windows.Win32_PROFILEINFO')\n def _test_create_user_logon_session(self, mock_Win32_PROFILEINFO, logon,\n loaduser, load_profile=True,\n last_error=None):\n self._wintypes_mock.HANDLE = mock.MagicMock()\n pi = self.windows_utils.Win32_PROFILEINFO()\n advapi32 = self._windll_mock.advapi32\n userenv = self._windll_mock.userenv\n kernel32 = self._windll_mock.kernel32\n\n advapi32.LogonUserW.return_value = logon\n\n if not logon:\n with self.assert_raises_windows_message(\n \"User logon failed: %r\", last_error):\n self._winutils.create_user_logon_session(\n self._USERNAME, self._PASSWORD, domain='.',\n load_profile=load_profile)\n\n elif load_profile and not loaduser:\n userenv.LoadUserProfileW.return_value = None\n kernel32.CloseHandle.return_value = None\n with self.assert_raises_windows_message(\n \"Cannot load user profile: %r\", last_error):\n self._winutils.create_user_logon_session(\n self._USERNAME, self._PASSWORD, domain='.',\n load_profile=load_profile)\n\n userenv.LoadUserProfileW.assert_called_with(\n self._wintypes_mock.HANDLE.return_value,\n self._ctypes_mock.byref.return_value)\n self._ctypes_mock.byref.assert_called_with(pi)\n\n kernel32.CloseHandle.assert_called_with(\n self._wintypes_mock.HANDLE.return_value)\n\n elif not load_profile:\n response = self._winutils.create_user_logon_session(\n self._USERNAME, self._PASSWORD, domain='.',\n load_profile=load_profile)\n self.assertTrue(response is not None)\n else:\n size = 1024\n self._ctypes_mock.sizeof.return_value = size\n\n mock_Win32_PROFILEINFO.return_value = loaduser\n\n response = self._winutils.create_user_logon_session(\n self._USERNAME, self._PASSWORD, domain='.',\n load_profile=load_profile)\n\n userenv.LoadUserProfileW.assert_called_with(\n self._wintypes_mock.HANDLE.return_value,\n self._ctypes_mock.byref.return_value)\n self.assertTrue(response is not None)", "metadata": "root.TestWindowsUtils._test_create_user_logon_session", "header": "['class', 'TestWindowsUtils', '(', 'testutils', '.', 'CloudbaseInitTestBase', ')', ':', '___EOS___']", "index": 402 }, { "content": " @mock.patch('cloudbaseinit.osutils.windows.WindowsUtils'\n '.get_user_sid')\n def _test_get_user_home(self, user_sid, mock_get_user_sid):\n mock_get_user_sid.return_value = user_sid\n\n with self.snatcher:\n response = self._winutils.get_user_home(self._USERNAME)\n\n if user_sid:\n mock_get_user_sid.assert_called_with(self._USERNAME)\n self._winreg_mock.OpenKey.assert_called_with(\n self._winreg_mock.HKEY_LOCAL_MACHINE,\n 'SOFTWARE\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\'\n 'ProfileList\\\\%s' % mock_get_user_sid())\n self.assertTrue(response is not None)\n self._winreg_mock.QueryValueEx.assert_called_with(\n self._winreg_mock.OpenKey.return_value.__enter__.return_value,\n 'ProfileImagePath')\n else:\n self.assertEqual(\n [\"Home directory not found for user %r\" % self._USERNAME],\n self.snatcher.output)\n self.assertTrue(response is None)", "metadata": "root.TestWindowsUtils._test_get_user_home", "header": "['class', 'TestWindowsUtils', '(', 'testutils', '.', 'CloudbaseInitTestBase', ')', ':', '___EOS___']", "index": 522 }, { "content": " def _test_get_volume_label(self, ret_val):\n label = mock.MagicMock()\n max_label_size = 261\n drive = 'Fake_drive'\n self._ctypes_mock.create_unicode_buffer.return_value = label\n self._windll_mock.kernel32.GetVolumeInformationW.return_value = ret_val\n\n response = self._winutils.get_volume_label(drive)\n\n if ret_val:\n self.assertTrue(response is not None)\n else:\n self.assertTrue(response is None)\n\n self._ctypes_mock.create_unicode_buffer.assert_called_with(\n max_label_size)\n self._windll_mock.kernel32.GetVolumeInformationW.assert_called_with(\n drive, label, max_label_size, 0, 0, 0, 0, 0)", "metadata": "root.TestWindowsUtils._test_get_volume_label", "header": "['class', 'TestWindowsUtils', '(', 'testutils', '.', 'CloudbaseInitTestBase', ')', ':', '___EOS___']", "index": 1117 } ]
[ { "span": "self.assertTrue(response is not None)", "start_line": 442, "start_column": 12, "end_line": 442, "end_column": 49 }, { "span": "self.assertTrue(response is not None)", "start_line": 456, "start_column": 12, "end_line": 456, "end_column": 49 }, { "span": "self.assertTrue(response is not None)", "start_line": 536, "start_column": 12, "end_line": 536, "end_column": 49 }, { "span": "self.assertTrue(response is None)", "start_line": 544, "start_column": 12, "end_line": 544, "end_column": 45 }, { "span": "self.assertTrue(response is not None)", "start_line": 1127, "start_column": 12, "end_line": 1127, "end_column": 49 }, { "span": "self.assertTrue(response is None)", "start_line": 1129, "start_column": 12, "end_line": 1129, "end_column": 45 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Window", "s", "Utils_", "(_", "testutils_", "._", "Cloud", "base", "Ini", "t", "Test", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "mock_", "._", "patch_", "(_", "'", "cloudb", "ase", "init", ".", "osu", "til", "s", ".", "windows", ".", "Win", "32", "\\u", "PROFILE", "INFO", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "test\\u", "create", "\\u", "user", "\\u", "logo", "n", "\\u", "session_", "(_", "self_", ",_", "mock", "\\u", "Win", "32", "\\u", "PROFILE", "INFO_", ",_", "logo", "n_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "load", "user_", ",_", "load", "\\u", "profile_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "last", "\\u", "error_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "wintype", "s", "\\u", "mock_", "._", "HANDLE_", "=_", "mock_", "._", "Mag", "ic", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pi_", "=_", "self_", "._", "windows", "\\u", "utils_", "._", "Win", "32", "\\u", "PROFILE", "INFO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "adv", "api", "32_", "=_", "self_", "._", "\\u", "wind", "ll", "\\u", "mock_", "._", "adv", "api", "32_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "env_", "=_", "self_", "._", "\\u", "wind", "ll", "\\u", "mock_", "._", "user", "env_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kernel32_", "=_", "self_", "._", "\\u", "wind", "ll", "\\u", "mock_", "._", "kernel32_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "adv", "api", "32_", "._", "Logo", "n", "User", "W_", "._", "return", "\\u", "value_", "=_", "logo", "n_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "logo", "n_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "self_", "._", "assert", "\\u", "raise", "s", "\\u", "windows", "\\u", "message_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "User", " ", "logo", "n", " ", "fail", "ed", ":", " ", "%", "r", "\"_", ",_", "last", "\\u", "error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "win", "utils_", "._", "create", "\\u", "user", "\\u", "logo", "n", "\\u", "session_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "USERNAME_", ",_", "self_", "._", "\\u", "PASSWORD_", ",_", "domain_", "=_", "'.'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "load", "\\u", "profile_", "=_", "load", "\\u", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "load", "\\u", "profile_", "and_", "not_", "load", "user_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "env_", "._", "Load", "User", "Profil", "e", "W_", "._", "return", "\\u", "value_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kernel32_", "._", "Clos", "e", "Handle_", "._", "return", "\\u", "value_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "self_", "._", "assert", "\\u", "raise", "s", "\\u", "windows", "\\u", "message_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Cann", "ot", " ", "load", " ", "user", " ", "profile", ":", " ", "%", "r", "\"_", ",_", "last", "\\u", "error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "win", "utils_", "._", "create", "\\u", "user", "\\u", "logo", "n", "\\u", "session_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "USERNAME_", ",_", "self_", "._", "\\u", "PASSWORD_", ",_", "domain_", "=_", "'.'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "load", "\\u", "profile_", "=_", "load", "\\u", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "user", "env_", "._", "Load", "User", "Profil", "e", "W_", "._", "assert", "\\u", "call", "ed", "\\u", "with_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "wintype", "s", "\\u", "mock_", "._", "HANDLE_", "._", "return", "\\u", "value_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "ctype", "s", "\\u", "mock_", "._", "byref_", "._", "return", "\\u", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "ctype", "s", "\\u", "mock_", "._", "byref_", "._", "assert", "\\u", "call", "ed", "\\u", "with_", "(_", "pi_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kernel32_", "._", "Clos", "e", "Handle_", "._", "assert", "\\u", "call", "ed", "\\u", "with_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "wintype", "s", "\\u", "mock_", "._", "HANDLE_", "._", "return", "\\u", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "load", "\\u", "profile_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "\\u", "win", "utils_", "._", "create", "\\u", "user", "\\u", "logo", "n", "\\u", "session_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "USERNAME_", ",_", "self_", "._", "\\u", "PASSWORD_", ",_", "domain_", "=_", "'.'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "load", "\\u", "profile_", "=_", "load", "\\u", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "response_", "is_", "not_", "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 ", " _", "size_", "=_", "1024_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "ctype", "s", "\\u", "mock_", "._", "sizeof_", "._", "return", "\\u", "value_", "=_", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "mock", "\\u", "Win", "32", "\\u", "PROFILE", "INFO_", "._", "return", "\\u", "value_", "=_", "load", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "response_", "=_", "self_", "._", "\\u", "win", "utils_", "._", "create", "\\u", "user", "\\u", "logo", "n", "\\u", "session_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "USERNAME_", ",_", "self_", "._", "\\u", "PASSWORD_", ",_", "domain_", "=_", "'.'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "load", "\\u", "profile_", "=_", "load", "\\u", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "user", "env_", "._", "Load", "User", "Profil", "e", "W_", "._", "assert", "\\u", "call", "ed", "\\u", "with_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "wintype", "s", "\\u", "mock_", "._", "HANDLE_", "._", "return", "\\u", "value_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "ctype", "s", "\\u", "mock_", "._", "byref_", "._", "return", "\\u", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "response_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Window", "s", "Utils_", "(_", "testutils_", "._", "Cloud", "base", "Ini", "t", "Test", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "mock_", "._", "patch_", "(_", "'", "cloudb", "ase", "init", ".", "osu", "til", "s", ".", "windows", ".", "Window", "s", "Ut", "il", "s", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'.", "get", "\\u", "user", "\\u", "sid", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "test\\u", "get", "\\u", "user", "\\u", "home_", "(_", "self_", ",_", "user", "\\u", "sid_", ",_", "mock", "\\u", "get", "\\u", "user", "\\u", "sid_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "get", "\\u", "user", "\\u", "sid_", "._", "return", "\\u", "value_", "=_", "user", "\\u", "sid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "self_", "._", "snat", "cher", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "self_", "._", "\\u", "win", "utils_", "._", "get", "\\u", "user", "\\u", "home_", "(_", "self_", "._", "\\u", "USERNAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "user", "\\u", "sid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "get", "\\u", "user", "\\u", "sid_", "._", "assert", "\\u", "call", "ed", "\\u", "with_", "(_", "self_", "._", "\\u", "USERNAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "winr", "eg", "\\u", "mock_", "._", "Open", "Key_", "._", "assert", "\\u", "call", "ed", "\\u", "with_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "winr", "eg", "\\u", "mock_", "._", "HKEY", "\\u", "LOCAL", "\\u", "MACHINE", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "SOFT", "WARE", "\\\\\\\\", "Micro", "soft", "\\\\\\\\", "Window", "s", " ", "NT", "\\\\\\\\", "Curr", "ent", "Version", "\\\\\\\\'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Profil", "e", "List", "\\\\\\\\", "%", "s", "'_", "%_", "mock", "\\u", "get", "\\u", "user", "\\u", "sid_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "response_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "winr", "eg", "\\u", "mock_", "._", "Query", "Value", "Ex_", "._", "assert", "\\u", "call", "ed", "\\u", "with_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "winr", "eg", "\\u", "mock_", "._", "Open", "Key_", "._", "return", "\\u", "value_", "._", "\\u\\u", "enter\\u\\u_", "._", "return", "\\u", "value_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Profil", "e", "Image", "Path", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"", "Home", " ", "director", "y", " ", "not", " ", "found", " ", "for", " ", "user", " ", "%", "r", "\"_", "%_", "self_", "._", "\\u", "USERNAME_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "snat", "cher", "_", "._", "output_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "response_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Window", "s", "Utils_", "(_", "testutils_", "._", "Cloud", "base", "Ini", "t", "Test", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "test\\u", "get", "\\u", "volume", "\\u", "label_", "(_", "self_", ",_", "ret", "\\u", "val_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "label_", "=_", "mock_", "._", "Mag", "ic", "Mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "\\u", "label", "\\u", "size_", "=_", "261_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "drive_", "=_", "'", "Fake", "\\u", "drive", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "ctype", "s", "\\u", "mock_", "._", "create", "\\u", "unicode", "\\u", "buffer_", "._", "return", "\\u", "value_", "=_", "label_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "wind", "ll", "\\u", "mock_", "._", "kernel32_", "._", "Get", "Volume", "Information", "W_", "._", "return", "\\u", "value_", "=_", "ret", "\\u", "val_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "response_", "=_", "self_", "._", "\\u", "win", "utils_", "._", "get", "\\u", "volume", "\\u", "label_", "(_", "drive_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "ret", "\\u", "val_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "response_", "is_", "not_", "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_", "._", "assert", "True_", "(_", "response_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "ctype", "s", "\\u", "mock_", "._", "create", "\\u", "unicode", "\\u", "buffer_", "._", "assert", "\\u", "call", "ed", "\\u", "with_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "max", "\\u", "label", "\\u", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "wind", "ll", "\\u", "mock_", "._", "kernel32_", "._", "Get", "Volume", "Information", "W_", "._", "assert", "\\u", "call", "ed", "\\u", "with_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "drive_", ",_", "label_", ",_", "max", "\\u", "label", "\\u", "size_", ",_", "0_", ",_", "0_", ",_", "0_", ",_", "0_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
jesolem/PCV/examples/ch8_gesture_recognition.py
[ { "content": "from PIL import Image\nfrom numpy import *\nfrom pylab import *\n\nfrom svmutil import *\nimport os\n\nfrom PCV.classifiers import knn, bayes\nfrom PCV.tools import imtools\nfrom PCV.localdescriptors import dsift, sift\n\n\n\"\"\"\nThis script collects the three classifiers applied to the hand gesture\nrecognition test.\n\nIf you have created the data files with the dsift features, this will\nreproduce all confucion matrices in Chapter 8.\n\nUse the if statements at the bottom to turn on/off different combinations.\n\"\"\"\n\n\n\n\n\n\n\n\n# read training data\n####################\nfeatures,labels = read_gesture_features_labels('../data/hand_gesture/train/')\nprint 'training data is:', features.shape, len(labels)\n\n# read test data\n####################\ntest_features,test_labels = read_gesture_features_labels('../data/hand_gesture/test/')\nprint 'test data is:', test_features.shape, len(test_labels)\n\nclassnames = unique(labels)\nnbr_classes = len(classnames)\n\n\nif False:\n # reduce dimensions with PCA\n from PCV.tools import pca\n\n V,S,m = pca.pca(features)\n\n # keep most important dimensions\n V = V[:50]\n features = array([dot(V,f-m) for f in features])\n test_features = array([dot(V,f-m) for f in test_features])\n\n\nif True:\n # test kNN\n k = 1\n knn_classifier = knn.KnnClassifier(labels,features)\n res = array([knn_classifier.classify(test_features[i],k) for i in range(len(test_labels))]) # TODO kan goras battre\n\n\nif False:\n # test Bayes\n bc = bayes.BayesClassifier()\n blist = [features[where(labels==c)[0]] for c in classnames]\n\n bc.train(blist,classnames)\n res = bc.classify(test_features)[0]\n\n\nif False:\n # test SVM\n # convert to lists for libsvm\n features = map(list,features)\n test_features = map(list,test_features)\n\n # create conversion function for the labels\n transl = {}\n for i,c in enumerate(classnames):\n transl[c],transl[i] = i,c\n\n # create SVM\n prob = svm_problem(convert_labels(labels,transl),features)\n param = svm_parameter('-t 0')\n\n # train SVM on data\n m = svm_train(prob,param)\n\n # how did the training do?\n res = svm_predict(convert_labels(labels,transl),features,m)\n\n # test the SVM\n res = svm_predict(convert_labels(test_labels,transl),test_features,m)[0]\n res = convert_labels(res,transl)\n\n\n# accuracy\nacc = sum(1.0*(res==test_labels)) / len(test_labels)\nprint 'Accuracy:', acc\n\nprint_confusion(res,test_labels,classnames)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def read_gesture_features_labels(path):\n # create list of all files ending in .dsift\n featlist = [os.path.join(path,f) for f in os.listdir(path) if f.endswith('.dsift')]\n\n # read the features\n features = []\n for featfile in featlist:\n l,d = sift.read_features_from_file(featfile)\n features.append(d.flatten())\n features = array(features)\n\n # create labels\n labels = [featfile.split('/')[-1][0] for featfile in featlist]\n\n return features,array(labels)", "metadata": "root.read_gesture_features_labels", "header": "['module', '___EOS___']", "index": 23 }, { "content": "def convert_labels(labels,transl):\n \"\"\" Convert between strings and numbers. \"\"\"\n return [transl[l] for l in labels]", "metadata": "root.convert_labels", "header": "['module', '___EOS___']", "index": 40 }, { "content": "def print_confusion(res,labels,classnames):\n\n n = len(classnames)\n\n # confusion matrix\n class_ind = dict([(classnames[i],i) for i in range(n)])\n\n confuse = zeros((n,n))\n for i in range(len(test_labels)):\n confuse[class_ind[res[i]],class_ind[test_labels[i]]] += 1\n\n print 'Confusion matrix for'\n print classnames\n print confuse", "metadata": "root.print_confusion", "header": "['module', '___EOS___']", "index": 45 } ]
[ { "span": "from PIL import Image", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 21 }, { "span": "from PCV.tools import imtools", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 29 }, { "span": "from PCV.localdescriptors import dsift, sift", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 44 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "PIL_", "import_", "Image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "numpy_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pylab_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "svm", "util_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "PC", "V_", "._", "classifiers_", "import_", "knn", "_", ",_", "bayes", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "PC", "V_", "._", "tools_", "import_", "im", "tools_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "PC", "V_", "._", "locald", "escri", "pto", "rs_", "import_", "dsi", "ft_", ",_", "sift", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Thi", "s", " ", "script", " ", "collect", "s", " ", "the", " ", "three", " ", "classif", "iers", " ", "applied", " ", "to", " ", "the", " ", "hand", " ", "gesture", "\\", "10", ";", "recognition", " ", "test", ".", "\\", "10", ";", "\\", "10", ";", "If", " ", "you", " ", "have", " ", "created", " ", "the", " ", "data", " ", "files", " ", "with", " ", "the", " ", "dsi", "ft", " ", "features", ",", " ", "this", " ", "will", "\\", "10", ";", "reproduce", " ", "all", " ", "conf", "uci", "on", " ", "matric", "es", " ", "in", " ", "Chap", "ter", " ", "8", ".", "\\", "10", ";", "\\", "10", ";", "Us", "e", " ", "the", " ", "if", " ", "statem", "ents", " ", "at", " ", "the", " ", "bottom", " ", "to", " ", "turn", " ", "on", "/", "off", " ", "different", " ", "combinat", "ion", "s", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "read", " ", "train", "ing", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "#########", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "features_", ",_", "labels_", "=_", "read", "\\u", "gesture", "\\u", "features", "\\u", "labels_", "(_", "'../", "data", "/", "hand", "\\u", "gesture", "/", "train", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "train", "ing", " ", "data", " ", "is", ":'_", ",_", "features_", "._", "shape_", ",_", "len_", "(_", "labels_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "read", " ", "test", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "#########", "_", "\\u\\u\\uNL\\u\\u\\u_", "test\\u", "features_", ",_", "test\\u", "labels_", "=_", "read", "\\u", "gesture", "\\u", "features", "\\u", "labels_", "(_", "'../", "data", "/", "hand", "\\u", "gesture", "/", "test", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "test", " ", "data", " ", "is", ":'_", ",_", "test\\u", "features_", "._", "shape_", ",_", "len_", "(_", "test\\u", "labels_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class", "names_", "=_", "unique_", "(_", "labels_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nbr", "\\u", "classes_", "=_", "len_", "(_", "class", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "reduce", " ", "dimension", "s", " ", "with", " ", "PCA", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "PC", "V_", "._", "tools_", "import_", "pca_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "V_", ",_", "S_", ",_", "m_", "=_", "pca_", "._", "pca_", "(_", "features_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "keep", " ", "most", " ", "importa", "nt", " ", "dimensions_", "\\u\\u\\uNL\\u\\u\\u_", "V_", "=_", "V_", "[_", ":_", "50_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "features_", "=_", "array_", "(_", "[_", "dot_", "(_", "V_", ",_", "f_", "-_", "m_", ")_", "for_", "f_", "in_", "features_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test\\u", "features_", "=_", "array_", "(_", "[_", "dot_", "(_", "V_", ",_", "f_", "-_", "m_", ")_", "for_", "f_", "in_", "test\\u", "features_", "]_", ")_", "\\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_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "test", " ", "k", "NN_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "k_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "knn", "\\u", "classifier_", "=_", "knn", "_", "._", "Kn", "n", "Classifier_", "(_", "labels_", ",_", "features_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "array_", "(_", "[_", "knn", "\\u", "classifier_", "._", "classify_", "(_", "test\\u", "features_", "[_", "i_", "]_", ",_", "k_", ")_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "test\\u", "labels_", ")_", ")_", "]_", ")_", "#", " ", "TOD", "O", " ", "kan", " ", "gor", "as", " ", "batt", "re_", "\\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_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "test", " ", "Bayes", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bc_", "=_", "bayes", "_", "._", "Bayes", "Classifier_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blis", "t_", "=_", "[_", "features_", "[_", "where_", "(_", "labels_", "==_", "c_", ")_", "[_", "0_", "]_", "]_", "for_", "c_", "in_", "class", "names_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bc_", "._", "train_", "(_", "blis", "t_", ",_", "class", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "bc_", "._", "classify_", "(_", "test\\u", "features_", ")_", "[_", "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_", "if_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "test", " ", "SV", "M_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "convert", " ", "to", " ", "lists", " ", "for", " ", "libs", "vm_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "features_", "=_", "map_", "(_", "list_", ",_", "features_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test\\u", "features_", "=_", "map_", "(_", "list_", ",_", "test\\u", "features_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "conve", "rsi", "on", " ", "function", " ", "for", " ", "the", " ", "labels_", "\\u\\u\\uNL\\u\\u\\u_", "transl", "_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", ",_", "c_", "in_", "enumerate_", "(_", "class", "names_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "transl", "_", "[_", "c_", "]_", ",_", "transl", "_", "[_", "i_", "]_", "=_", "i_", ",_", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "SV", "M_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prob_", "=_", "svm", "\\u", "problem_", "(_", "convert", "\\u", "labels_", "(_", "labels_", ",_", "transl", "_", ")_", ",_", "features_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "param_", "=_", "svm", "\\u", "parameter_", "(_", "'-", "t", " ", "0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "train", " ", "SV", "M", " ", "on", " ", "data_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "=_", "svm", "\\u", "train_", "(_", "prob_", ",_", "param_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "how", " ", "did", " ", "the", " ", "train", "ing", " ", "do", "?", "_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "svm", "\\u", "predict_", "(_", "convert", "\\u", "labels_", "(_", "labels_", ",_", "transl", "_", ")_", ",_", "features_", ",_", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "test", " ", "the", " ", "SV", "M_", "\\u\\u\\uNL\\u\\u\\u_", "res_", "=_", "svm", "\\u", "predict_", "(_", "convert", "\\u", "labels_", "(_", "test\\u", "labels_", ",_", "transl", "_", ")_", ",_", "test\\u", "features_", ",_", "m_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "=_", "convert", "\\u", "labels_", "(_", "res_", ",_", "transl", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "accuracy_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "acc_", "=_", "sum_", "(_", "1.0_", "*_", "(_", "res_", "==_", "test\\u", "labels_", ")_", ")_", "/_", "len_", "(_", "test\\u", "labels_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Accu", "rac", "y", ":'_", ",_", "acc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print", "\\u", "confusion", "_", "(_", "res_", ",_", "test\\u", "labels_", ",_", "class", "names_", ")_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "read", "\\u", "gesture", "\\u", "features", "\\u", "labels_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "create", " ", "list", " ", "of", " ", "all", " ", "files", " ", "ending", " ", "in", " ", ".", "dsi", "ft_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "feat", "list_", "=_", "[_", "os_", "._", "path_", "._", "join_", "(_", "path_", ",_", "f_", ")_", "for_", "f_", "in_", "os_", "._", "listdir_", "(_", "path_", ")_", "if_", "f_", "._", "endswith_", "(_", "'.", "dsi", "ft", "'_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "read", " ", "the", " ", "features_", "\\u\\u\\uNL\\u\\u\\u_", "features_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "feat", "file_", "in_", "feat", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l_", ",_", "d_", "=_", "sift", "_", "._", "read", "\\u", "features", "\\u", "from", "\\u", "file_", "(_", "feat", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "features_", "._", "append_", "(_", "d_", "._", "flatten_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "features_", "=_", "array_", "(_", "features_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "labels_", "\\u\\u\\uNL\\u\\u\\u_", "labels_", "=_", "[_", "feat", "file_", "._", "split_", "(_", "'/'_", ")_", "[_", "-_", "1_", "]_", "[_", "0_", "]_", "for_", "feat", "file_", "in_", "feat", "list_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "features_", ",_", "array_", "(_", "labels_", ")_", "\\u\\u\\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_", "convert", "\\u", "labels_", "(_", "labels_", ",_", "transl", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Convert", " ", "bet", "ween", " ", "string", "s", " ", "and", " ", "numbers", ".", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "transl", "_", "[_", "l_", "]_", "for_", "l_", "in_", "labels_", "]_", "\\u\\u\\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_", "print", "\\u", "confusion", "_", "(_", "res_", ",_", "labels_", ",_", "class", "names_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "n_", "=_", "len_", "(_", "class", "names_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "confusion", " ", "matrix_", "\\u\\u\\uNL\\u\\u\\u_", "class", "\\u", "ind_", "=_", "dict_", "(_", "[_", "(_", "class", "names_", "[_", "i_", "]_", ",_", "i_", ")_", "for_", "i_", "in_", "range_", "(_", "n_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "conf", "use_", "=_", "zeros_", "(_", "(_", "n_", ",_", "n_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "test\\u", "labels_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "conf", "use_", "[_", "class", "\\u", "ind_", "[_", "res_", "[_", "i_", "]_", "]_", ",_", "class", "\\u", "ind_", "[_", "test\\u", "labels_", "[_", "i_", "]_", "]_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "'", "Conf", "usion", " ", "matrix", " ", "for", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "class", "names_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "conf", "use_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
xraypy/xraylarch/plugins/xsw/YongsCode/SimpleParratt_Panel.py
[ { "content": " def __init__(self, parent, id, title):\n wx.Dialog.__init__(self, parent, id, 'SimRefl: mirror reflectivity simulation', size=(450, 420))\n self.plot_on = 0\n LogList=['Yes', 'No']\n xUnitList=['m rad', 'Deg', 'qz']\n xcol2=180\n btnSim = wx.Button(self, 1, 'Simulate!', (30,20))\n wx.StaticText(self, -1, 'y-axis in log?', (xcol2, 5))\n self.cb0 = wx.ComboBox(self, 0, 'No', (xcol2, 25), (95, 25), LogList, wx.CB_DROPDOWN)\n wx.StaticText(self, -1, 'x-axis unit?', (xcol2, 50))\n self.cb1 = wx.ComboBox(self, 0, 'm rad', (xcol2, 70), (95, 25), xUnitList, wx.CB_DROPDOWN)\n wx.StaticText(self, -1, \"incident x-ray energy (eV)\", (5, 50))\n self.Text1 = wx.TextCtrl(self, 2, '7000.0', (10, 70))\n wx.StaticText(self, -1, \"film material\", (5, 100))\n self.Text2 = wx.TextCtrl(self, 3, 'Pt', (10, 120))\n wx.StaticText(self, -1, \"film thickness (Angstrom)\", (5, 150))\n self.Text3 = wx.TextCtrl(self, 4, '400.0', (10, 170))\n wx.StaticText(self, -1, \"film density (g/cm^3)\", (5, 200))\n self.Text4 = wx.TextCtrl(self, 5, '21.45', (10, 220))\n wx.StaticText(self, -1, \"rms roughness for all interfaces (Angstrom)\", (5, 250))\n self.Text5 = wx.TextCtrl(self, 6, '1.0', (10, 270))\n wx.StaticText(self, -1, \"substrate material\", (xcol2-5, 100))\n self.Text6 = wx.TextCtrl(self, 7, 'Si', (xcol2, 120))\n wx.StaticText(self, -1, \"substrate density (g/cm^3)\", (xcol2-5, 150))\n self.Text7 = wx.TextCtrl(self, 8, '2.33', (xcol2, 170))\n wx.StaticText(self, -1, \"Include 50 Angstrom Cr underlayer?\", (xcol2-5, 200))\n CrList=['Yes', 'No']\n self.cb2 = wx.ComboBox(self, 10, 'Yes', (xcol2, 220), (95, 25), CrList, wx.CB_DROPDOWN)\n wx.StaticText(self, -1, \"define arbitrary layer structure\", (5, 310))\n self.Text8 = wx.TextCtrl(self, 12, 'GaAs/GaAs(250)/Fe(40)/Au(20)', (10, 330), (300, 25))\n btnSim = wx.Button(self, 11, 'Simulate arbitrary structure.', (10,360))\n\n wx.EVT_BUTTON(self, 1, self.OnSimulate)\n wx.EVT_TEXT(self, 3, self.OnText2)\n wx.EVT_TEXT(self, 7, self.OnText6)\n wx.EVT_CLOSE(self, self.OnQuit)\n wx.EVT_BUTTON(self, 11, self.OnSimulate1)", "metadata": "root.Plot.__init__", "header": "['class', 'Plot', '(', 'wx', '.', 'Dialog', ')', ':', '___EOS___']", "index": 13 }, { "content": " def OnSimulate1(self, event): # for arbitrary structure\n reload(SimpleParratt)\n # --- Retrive values from panel --------------\n # self.Text1\n text=self.Text1.GetValue()\n eV0=float(text)\n eV0_min=500\n if eV0<=eV0_min: eV0=eV0_min+10.\n # self.Text2\n film_mat=self.Text2.GetValue()\n # self.Text3\n text=self.Text3.GetValue()\n film_thick=float(text)\n # self.Text4\n text=self.Text4.GetValue()\n film_den=float(text)\n # self.Text5\n text=self.Text5.GetValue()\n film_roughness=float(text)\n # self.Text6\n subs_mat=self.Text6.GetValue()\n # self.Text7\n text=self.Text7.GetValue()\n subs_den=float(text)\n # self.cb2\n text=self.cb2.GetValue()\n use_Cr=0\n if text=='Yes': use_Cr=1\n # self.cb1\n text=self.cb1.GetValue()\n xUnit='m rad'\n xUnit=text\n # self.cb0\n text=self.cb0.GetValue()\n use_Log=False\n if text=='Yes': use_Log=True\n if use_Cr==1:\n NumLayers=2\n else:\n NumLayers=1\n LayerStructure0=self.Text8.GetValue()\n import read_FilmName\n film1=read_FilmName.Film(LayerStructure0)\n film1.get_structure()\n film1.reverse_structure() # reverse the layer order so that the top is vaccum\n layer_mat=[];\tlayer_thick=[];\t layer_den=[];\t layer_rough=[]; layer_tag=[]\n layer_thc=[]; layer_la=[]\n print 'energy(eV) \\t layer \\t th_c(Deg.) \\t th_c(m rad) \\t absorption_length(micron) \\t density (g/cc)\\n'\n for (ii, layer1) in enumerate(film1.LayerList):\n layer_mat.append(str(layer1.composition))\n inputfile='NominalDensity.txt'\n f=open(inputfile)\n lines=f.readlines()\n out=1.0\n for line in lines:\n if not line.startswith('#'):\n words=line.split(',')\n if layer1.composition==words[0]:\n temp=words[1].split()\n out=temp[0]\n layer1.density=float(out)\n f.close()\n layer_den.append(float(layer1.density))\n layer_thick.append(float(layer1.thickness))\n layer_rough.append(float(layer1.rms))\n layer_tag.append(str(layer1.tag))\n out=readf1f2a.get_delta(layer1.composition, layer1.density, eV0)\n la_layer=out[2]*10000.0 # absorption length in cm, convert to microns\n delta_layer=out[0]\n thc_layer=(2.*delta_layer)**(0.5)*180./math.pi # critical angle in deg\n if ii==1:\n thc_toplayer=thc_layer\n print '%4.1f \\t %s \\t %4.4f \\t %4.4f \\t %4.1f \\t %s\\n' % \\\n (eV0, layer1.composition+'-'+layer1.tag, thc_layer, thc_layer*math.pi/180.*1000., la_layer, layer1.density)\n th_step=0.001\n th_range=numpy.arange(0.000, thc_toplayer*12.0, th_step) # angular range\n depths=[0.0] # calculate efield intensity at air/film interface\n #print layer_mat\n #print layer_thick\n #print layer_den\n #print layer_rough\n #layer_mat=['He', 'Cr', 'Si']; layer_thick=[0, 10., 10000]; layer_den=[1,1,1]; layer_rough=[1,1,1]\n # --- call reflectivity in SimpleParratt.py\t ------------------\n SimpleParratt.reflectivity(eV0, th_range, layer_mat, layer_thick, layer_den,\\\n layer_rough, layer_tag, depths)\n # --- Plot ----------------------------------------------------\n if self.plot_on==1:\n print self.plot_on\n self.plot.Destroy()\n #self.frm.Destroy()\n frm = wx.Frame(self, 1, 'SimpleParratt.txt', size=(600,450))\n self.data=[]; self.data0=[]\n th0=0;\trefl_half=1e6\n inputfile='SimpleParratt.txt'\n f=open(inputfile)\n lines=f.readlines()\n self.xMin=1e6; self.xMax=-1e6; self.yMin=1e6; self.yMax=-1e6\n for line in lines:\n if line.startswith('#'):\tcontinue\n words=line.split()\n if xUnit=='m rad':\n xx=float(words[0])*math.pi/180.0*1000.\t# convert deg to m rad\n if xUnit=='Deg':\n xx=float(words[0])\n if xUnit=='qz':\n ang=float(words[0])\n qz=4*math.pi*(eV0/1000.0/12.39842)*math.sin(ang*math.pi/180.0)\n xx=qz\n if self.xMin>xx: self.xMin=xx\n if self.xMax<=xx: self.xMax=xx\n yy=float(words[1])\n if self.yMin>yy: self.yMin=yy\n if self.yMax<=yy: self.yMax=yy\n self.data.append((xx, yy))\n self.data0.append((xx, 0.5))\n temp=abs(yy-0.5)\n if temp<=refl_half:\n refl_half=temp\n th0=xx\n self.yMax=1.0\n f.close()\n sample=''\n for (ii,item) in enumerate(layer_mat):\n if ii==0:\n sample='vacuum'\n else:\n sample=sample+'/'+item\n #title=str(eV0)+'eV, '+sample+', Refl.=0.5 at '+str(th0)+' m rad.'\n text0=' m rad.'\n text1='Incident angle (m rad)'\n if xUnit=='Deg':\n text0=' Deg'\n text1='Incident angle (Deg)'\n if xUnit=='qz':\n text0=' qz (1/Angstrom)'\n text1='qz (1/Agnstrom)'\n title='%4.1f, %s, %s %s %3.3f %s' % (eV0, 'eV', sample, 'Refl.=0.5 at', th0, text0)\n #------------------------------------------------\n client = plot.PlotCanvas(frm)\n # 9/1/2010: enable zooming function, double click for default size\n client.SetEnableZoom(True)\n line = plot.PolyLine(self.data, legend='', colour='red', width=1)\n line0 = plot.PolyLine(self.data0, legend='', colour='black', width=0.5)\n gc = plot.PlotGraphics([line, line0], title, text1, 'Reflectivity')\n client.setLogScale((False,False))\n if use_Log==True: client.setLogScale((False,True))\n client.Draw(gc,\t xAxis= (self.xMin,self.xMax), yAxis= (self.yMin,self.yMax))\n frm.Show(True)\n self.plot_on = 1\n self.plot=frm\n #------------------------------------------------", "metadata": "root.Plot.OnSimulate1", "header": "['class', 'Plot', '(', 'wx', '.', 'Dialog', ')', ':', '___EOS___']", "index": 238 } ]
[ { "span": "btnSim ", "start_line": 43, "start_column": 8, "end_line": 43, "end_column": 14 }, { "span": "film_mat=", "start_line": 247, "start_column": 8, "end_line": 247, "end_column": 16 }, { "span": "film_thick=", "start_line": 250, "start_column": 8, "end_line": 250, "end_column": 18 }, { "span": "film_den=", "start_line": 253, "start_column": 8, "end_line": 253, "end_column": 16 }, { "span": "film_roughness=", "start_line": 256, "start_column": 8, "end_line": 256, "end_column": 22 }, { "span": "subs_mat=", "start_line": 258, "start_column": 8, "end_line": 258, "end_column": 16 }, { "span": "subs_den=", "start_line": 261, "start_column": 8, "end_line": 261, "end_column": 16 }, { "span": "NumLayers=", "start_line": 275, "start_column": 12, "end_line": 275, "end_column": 21 }, { "span": "NumLayers=", "start_line": 277, "start_column": 12, "end_line": 277, "end_column": 21 }, { "span": "layer_thc=", "start_line": 284, "start_column": 8, "end_line": 284, "end_column": 17 }, { "span": "layer_la=", "start_line": 284, "start_column": 22, "end_line": 284, "end_column": 30 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Plot_", "(_", "wx_", "._", "Dialog_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parent_", ",_", "id_", ",_", "title_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wx_", "._", "Dialog_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "parent_", ",_", "id_", ",_", "'", "Sim", "Ref", "l", ":", " ", "mirror", " ", "reflect", "ivity", " ", "simulati", "on", "'_", ",_", "size_", "=_", "(_", "450_", ",_", "420_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "plot", "\\u", "on_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Log", "List_", "=_", "[_", "'", "Ye", "s", "'_", ",_", "'", "No", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x", "Unit", "List_", "=_", "[_", "'", "m", " ", "rad", "'_", ",_", "'", "Deg", "'_", ",_", "'", "qz", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xco", "l2_", "=_", "180_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "btn", "Sim_", "=_", "wx_", "._", "Button_", "(_", "self_", ",_", "1_", ",_", "'", "Simulate", "!'_", ",_", "(_", "30_", ",_", "20_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "Static", "Text_", "(_", "self_", ",_", "-_", "1_", ",_", "'", "y", "-", "axis", " ", "in", " ", "log", "?'_", ",_", "(_", "xco", "l2_", ",_", "5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cb", "0_", "=_", "wx_", "._", "Comb", "o", "Box_", "(_", "self_", ",_", "0_", ",_", "'", "No", "'_", ",_", "(_", "xco", "l2_", ",_", "25_", ")_", ",_", "(_", "95_", ",_", "25_", ")_", ",_", "Log", "List_", ",_", "wx_", "._", "CB", "\\u", "DROP", "DOWN_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "Static", "Text_", "(_", "self_", ",_", "-_", "1_", ",_", "'", "x", "-", "axis", " ", "unit", "?'_", ",_", "(_", "xco", "l2_", ",_", "50_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cb", "1_", "=_", "wx_", "._", "Comb", "o", "Box_", "(_", "self_", ",_", "0_", ",_", "'", "m", " ", "rad", "'_", ",_", "(_", "xco", "l2_", ",_", "70_", ")_", ",_", "(_", "95_", ",_", "25_", ")_", ",_", "x", "Unit", "List_", ",_", "wx_", "._", "CB", "\\u", "DROP", "DOWN_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "Static", "Text_", "(_", "self_", ",_", "-_", "1_", ",_", "\"", "incident", " ", "x", "-", "ray", " ", "energ", "y", " ", "(", "e", "V", ")\"_", ",_", "(_", "5_", ",_", "50_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Text", "1_", "=_", "wx_", "._", "Text", "Ctrl_", "(_", "self_", ",_", "2_", ",_", "'", "7000", ".0", "'_", ",_", "(_", "10_", ",_", "70_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "Static", "Text_", "(_", "self_", ",_", "-_", "1_", ",_", "\"", "film", " ", "material", "\"_", ",_", "(_", "5_", ",_", "100_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Text", "2_", "=_", "wx_", "._", "Text", "Ctrl_", "(_", "self_", ",_", "3_", ",_", "'", "Pt", "'_", ",_", "(_", "10_", ",_", "120_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "Static", "Text_", "(_", "self_", ",_", "-_", "1_", ",_", "\"", "film", " ", "thick", "ness", " ", "(", "Ang", "stro", "m", ")\"_", ",_", "(_", "5_", ",_", "150_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Text", "3_", "=_", "wx_", "._", "Text", "Ctrl_", "(_", "self_", ",_", "4_", ",_", "'", "400", ".0", "'_", ",_", "(_", "10_", ",_", "170_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "Static", "Text_", "(_", "self_", ",_", "-_", "1_", ",_", "\"", "film", " ", "densit", "y", " ", "(", "g", "/", "cm", "^", "3", ")\"_", ",_", "(_", "5_", ",_", "200_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Text", "4_", "=_", "wx_", "._", "Text", "Ctrl_", "(_", "self_", ",_", "5_", ",_", "'", "21.", "4", "5", "'_", ",_", "(_", "10_", ",_", "220_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "Static", "Text_", "(_", "self_", ",_", "-_", "1_", ",_", "\"", "rms", " ", "rough", "ness", " ", "for", " ", "all", " ", "interface", "s", " ", "(", "Ang", "stro", "m", ")\"_", ",_", "(_", "5_", ",_", "250_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Text", "5_", "=_", "wx_", "._", "Text", "Ctrl_", "(_", "self_", ",_", "6_", ",_", "'", "1.0", "'_", ",_", "(_", "10_", ",_", "270_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "Static", "Text_", "(_", "self_", ",_", "-_", "1_", ",_", "\"", "substrat", "e", " ", "material", "\"_", ",_", "(_", "xco", "l2_", "-_", "5_", ",_", "100_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Text", "6_", "=_", "wx_", "._", "Text", "Ctrl_", "(_", "self_", ",_", "7_", ",_", "'", "Si", "'_", ",_", "(_", "xco", "l2_", ",_", "120_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "Static", "Text_", "(_", "self_", ",_", "-_", "1_", ",_", "\"", "substrat", "e", " ", "densit", "y", " ", "(", "g", "/", "cm", "^", "3", ")\"_", ",_", "(_", "xco", "l2_", "-_", "5_", ",_", "150_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Text", "7_", "=_", "wx_", "._", "Text", "Ctrl_", "(_", "self_", ",_", "8_", ",_", "'", "2.3", "3", "'_", ",_", "(_", "xco", "l2_", ",_", "170_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "Static", "Text_", "(_", "self_", ",_", "-_", "1_", ",_", "\"", "Include", " ", "50", " ", "Ang", "stro", "m", " ", "Cr", " ", "underl", "aye", "r", "?\"_", ",_", "(_", "xco", "l2_", "-_", "5_", ",_", "200_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Cr", "List_", "=_", "[_", "'", "Ye", "s", "'_", ",_", "'", "No", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cb", "2_", "=_", "wx_", "._", "Comb", "o", "Box_", "(_", "self_", ",_", "10_", ",_", "'", "Ye", "s", "'_", ",_", "(_", "xco", "l2_", ",_", "220_", ")_", ",_", "(_", "95_", ",_", "25_", ")_", ",_", "Cr", "List_", ",_", "wx_", "._", "CB", "\\u", "DROP", "DOWN_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "Static", "Text_", "(_", "self_", ",_", "-_", "1_", ",_", "\"", "defin", "e", " ", "arbitra", "ry", " ", "layer", " ", "structure", "\"_", ",_", "(_", "5_", ",_", "310_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Text", "8_", "=_", "wx_", "._", "Text", "Ctrl_", "(_", "self_", ",_", "12_", ",_", "'", "Ga", "As", "/", "Ga", "As", "(", "250", ")/", "Fe", "(", "40", ")/", "Au", "(", "20", ")'_", ",_", "(_", "10_", ",_", "330_", ")_", ",_", "(_", "300_", ",_", "25_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "btn", "Sim_", "=_", "wx_", "._", "Button_", "(_", "self_", ",_", "11_", ",_", "'", "Simulate", " ", "arbitra", "ry", " ", "structure", ".'_", ",_", "(_", "10_", ",_", "360_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "wx_", "._", "EV", "T", "\\u", "BUTTON_", "(_", "self_", ",_", "1_", ",_", "self_", "._", "On", "Simulate", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "EV", "T", "\\u", "TEXT_", "(_", "self_", ",_", "3_", ",_", "self_", "._", "On", "Text", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "EV", "T", "\\u", "TEXT_", "(_", "self_", ",_", "7_", ",_", "self_", "._", "On", "Text", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "EV", "T", "\\u", "CLOSE_", "(_", "self_", ",_", "self_", "._", "On", "Quit_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wx_", "._", "EV", "T", "\\u", "BUTTON_", "(_", "self_", ",_", "11_", ",_", "self_", "._", "On", "Simulate", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Plot_", "(_", "wx_", "._", "Dialog_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "On", "Simulate", "1_", "(_", "self_", ",_", "event_", ")_", ":_", "#", " ", "for", " ", "arbitra", "ry", " ", "structure_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "reload_", "(_", "Simple", "Par", "rat", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "---", " ", "Retri", "ve", " ", "values", " ", "from", " ", "panel", " ", "--------------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "self", ".", "Text", "1_", "\\u\\u\\uNL\\u\\u\\u_", "text_", "=_", "self_", "._", "Text", "1_", "._", "Get", "Value_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e", "V0", "_", "=_", "float_", "(_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e", "V0", "\\u", "min_", "=_", "500_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "e", "V0", "_", "<=_", "e", "V0", "\\u", "min_", ":_", "e", "V0", "_", "=_", "e", "V0", "\\u", "min_", "+_", "10._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "self", ".", "Text", "2_", "\\u\\u\\uNL\\u\\u\\u_", "film", "\\u", "mat_", "=_", "self_", "._", "Text", "2_", "._", "Get", "Value_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "self", ".", "Text", "3_", "\\u\\u\\uNL\\u\\u\\u_", "text_", "=_", "self_", "._", "Text", "3_", "._", "Get", "Value_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "film", "\\u", "thick", "_", "=_", "float_", "(_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "self", ".", "Text", "4_", "\\u\\u\\uNL\\u\\u\\u_", "text_", "=_", "self_", "._", "Text", "4_", "._", "Get", "Value_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "film", "\\u", "den_", "=_", "float_", "(_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "self", ".", "Text", "5_", "\\u\\u\\uNL\\u\\u\\u_", "text_", "=_", "self_", "._", "Text", "5_", "._", "Get", "Value_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "film", "\\u", "rough", "ness_", "=_", "float_", "(_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "self", ".", "Text", "6_", "\\u\\u\\uNL\\u\\u\\u_", "subs", "\\u", "mat_", "=_", "self_", "._", "Text", "6_", "._", "Get", "Value_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "self", ".", "Text", "7_", "\\u\\u\\uNL\\u\\u\\u_", "text_", "=_", "self_", "._", "Text", "7_", "._", "Get", "Value_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subs", "\\u", "den_", "=_", "float_", "(_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "self", ".", "cb", "2_", "\\u\\u\\uNL\\u\\u\\u_", "text_", "=_", "self_", "._", "cb", "2_", "._", "Get", "Value_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "use", "\\u", "Cr", "_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "text_", "==_", "'", "Ye", "s", "'_", ":_", "use", "\\u", "Cr", "_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "self", ".", "cb", "1_", "\\u\\u\\uNL\\u\\u\\u_", "text_", "=_", "self_", "._", "cb", "1_", "._", "Get", "Value_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x", "Unit_", "=_", "'", "m", " ", "rad", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x", "Unit_", "=_", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "self", ".", "cb", "0_", "\\u\\u\\uNL\\u\\u\\u_", "text_", "=_", "self_", "._", "cb", "0_", "._", "Get", "Value_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "use", "\\u", "Log_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "text_", "==_", "'", "Ye", "s", "'_", ":_", "use", "\\u", "Log_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "use", "\\u", "Cr", "_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Num", "Layers_", "=_", "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 ", " _", "Num", "Layers_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Layer", "Structur", "e0_", "=_", "self_", "._", "Text", "8_", "._", "Get", "Value_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "read", "\\u", "Film", "Name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "film", "1_", "=_", "read", "\\u", "Film", "Name_", "._", "Film", "_", "(_", "Layer", "Structur", "e0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "film", "1_", "._", "get", "\\u", "structure_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "film", "1_", "._", "reverse", "\\u", "structure_", "(_", ")_", "#", " ", "reverse", " ", "the", " ", "layer", " ", "order", " ", "so", " ", "tha", "t", " ", "the", " ", "top", " ", "is", " ", "vac", "cum", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "layer", "\\u", "mat_", "=_", "[_", "]_", ";_", "layer", "\\u", "thick", "_", "=_", "[_", "]_", ";_", "layer", "\\u", "den_", "=_", "[_", "]_", ";_", "layer", "\\u", "rough", "_", "=_", "[_", "]_", ";_", "layer", "\\u", "tag_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "layer", "\\u", "th", "c_", "=_", "[_", "]_", ";_", "layer", "\\u", "la_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "energ", "y", "(", "e", "V", ")", " ", "\\\\", "t", " ", "layer", " ", "\\\\", "t", " ", "th", "\\u", "c", "(", "Deg", ".)", " ", "\\\\", "t", " ", "th", "\\u", "c", "(", "m", " ", "rad", ")", " ", "\\\\", "t", " ", "absor", "ption", "\\u", "length", "(", "micro", "n", ")", " ", "\\\\", "t", " ", "densit", "y", " ", "(", "g", "/", "cc", ")\\\\", "n", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "(_", "ii_", ",_", "layer", "1_", ")_", "in_", "enumerate_", "(_", "film", "1_", "._", "Layer", "List_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "layer", "\\u", "mat_", "._", "append_", "(_", "str_", "(_", "layer", "1_", "._", "composition_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inputfile_", "=_", "'", "Nomi", "nal", "Den", "sity", ".", "txt", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "open_", "(_", "inputfile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lines_", "=_", "f_", "._", "readlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "out_", "=_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "line_", "in_", "lines_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "line_", "._", "startswith_", "(_", "'#'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "words_", "=_", "line_", "._", "split_", "(_", "','_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "layer", "1_", "._", "composition_", "==_", "words_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "temp_", "=_", "words_", "[_", "1_", "]_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "out_", "=_", "temp_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "layer", "1_", "._", "density_", "=_", "float_", "(_", "out_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "layer", "\\u", "den_", "._", "append_", "(_", "float_", "(_", "layer", "1_", "._", "density_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "layer", "\\u", "thick", "_", "._", "append_", "(_", "float_", "(_", "layer", "1_", "._", "thickness_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "layer", "\\u", "rough", "_", "._", "append_", "(_", "float_", "(_", "layer", "1_", "._", "rms_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "layer", "\\u", "tag_", "._", "append_", "(_", "str_", "(_", "layer", "1_", "._", "tag_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "out_", "=_", "readf", "1f", "2a", "_", "._", "get", "\\u", "delta_", "(_", "layer", "1_", "._", "composition_", ",_", "layer", "1_", "._", "density_", ",_", "e", "V0", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "la", "\\u", "layer_", "=_", "out_", "[_", "2_", "]_", "*_", "10000", ".0_", "#", " ", "absor", "ption", " ", "length", " ", "in", " ", "cm", ",", " ", "convert", " ", "to", " ", "micro", "ns_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "delta", "\\u", "layer_", "=_", "out_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "th", "c\\u", "layer_", "=_", "(_", "2._", "*_", "delta", "\\u", "layer_", ")_", "**_", "(_", "0.5_", ")_", "*_", "180._", "/_", "math_", "._", "pi_", "#", " ", "critic", "al", " ", "angle", " ", "in", " ", "deg_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ii_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "th", "c\\u", "top", "layer_", "=_", "th", "c\\u", "layer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "'%", "4.1", "f", " ", "\\\\", "t", " ", "%", "s", " ", "\\\\", "t", " ", "%", "4.4", "f", " ", "\\\\", "t", " ", "%", "4.4", "f", " ", "\\\\", "t", " ", "%", "4.1", "f", " ", "\\\\", "t", " ", "%", "s", "\\\\", "n", "'_", "%_", "(_", "e", "V0", "_", ",_", "layer", "1_", "._", "composition_", "+_", "'-'_", "+_", "layer", "1_", "._", "tag_", ",_", "th", "c\\u", "layer_", ",_", "th", "c\\u", "layer_", "*_", "math_", "._", "pi_", "/_", "180._", "*_", "1000._", ",_", "la", "\\u", "layer_", ",_", "layer", "1_", "._", "density_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "th", "\\u", "step_", "=_", "0.001_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "th", "\\u", "range_", "=_", "numpy_", "._", "arange_", "(_", "0.000_", ",_", "th", "c\\u", "top", "layer_", "*_", "12.0_", ",_", "th", "\\u", "step_", ")_", "#", " ", "angular", " ", "range_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "depths_", "=_", "[_", "0.0_", "]_", "#", " ", "calcul", "ate", " ", "efi", "eld", " ", "intensity", " ", "at", " ", "air", "/", "film", " ", "interface_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "print", " ", "layer", "\\u", "mat_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "layer", "\\u", "thick", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "layer", "\\u", "den_", "\\u\\u\\uNL\\u\\u\\u_", "#", "print", " ", "layer", "\\u", "rough", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "layer", "\\u", "mat", "=[", "'", "He", "',", " ", "'", "Cr", "',", " ", "'", "Si", "']", ";", " ", "layer", "\\u", "thick", "=[", "0", ",", " ", "10.", ",", " ", "10000", "];", " ", "layer", "\\u", "den", "=[", "1", ",", "1", ",", "1", "];", " ", "layer", "\\u", "rough", "=[", "1", ",", "1", ",", "1", "]_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "---", " ", "call", " ", "reflect", "ivity", " ", "in", " ", "Simple", "Par", "rat", "t", ".", "py", "\t", " ", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "Simple", "Par", "rat", "t_", "._", "reflect", "ivity", "_", "(_", "e", "V0", "_", ",_", "th", "\\u", "range_", ",_", "layer", "\\u", "mat_", ",_", "layer", "\\u", "thick", "_", ",_", "layer", "\\u", "den_", ",_", "layer", "\\u", "rough", "_", ",_", "layer", "\\u", "tag_", ",_", "depths_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "---", " ", "Plot", " ", "--------------", "--------------", "--------------", "----------", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "plot", "\\u", "on_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "self_", "._", "plot", "\\u", "on_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "plot_", "._", "Destroy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "frm", ".", "Destr", "oy", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "frm_", "=_", "wx_", "._", "Frame_", "(_", "self_", ",_", "1_", ",_", "'", "Simple", "Par", "rat", "t", ".", "txt", "'_", ",_", "size_", "=_", "(_", "600_", ",_", "450_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "data_", "=_", "[_", "]_", ";_", "self_", "._", "data", "0_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "th", "0_", "=_", "0_", ";_", "refl", "\\u", "half_", "=_", "1e6_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inputfile_", "=_", "'", "Simple", "Par", "rat", "t", ".", "txt", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "=_", "open_", "(_", "inputfile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lines_", "=_", "f_", "._", "readlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "x", "Min_", "=_", "1e6_", ";_", "self_", "._", "x", "Max_", "=_", "-_", "1e6_", ";_", "self_", "._", "y", "Min_", "=_", "1e6_", ";_", "self_", "._", "y", "Max_", "=_", "-_", "1e6_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "line_", "in_", "lines_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "line_", "._", "startswith_", "(_", "'#'_", ")_", ":_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "words_", "=_", "line_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "x", "Unit_", "==_", "'", "m", " ", "rad", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xx_", "=_", "float_", "(_", "words_", "[_", "0_", "]_", ")_", "*_", "math_", "._", "pi_", "/_", "180.0_", "*_", "1000._", "#", " ", "convert", " ", "deg", " ", "to", " ", "m", " ", "rad_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "x", "Unit_", "==_", "'", "Deg", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "xx_", "=_", "float_", "(_", "words_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "x", "Unit_", "==_", "'", "qz", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ang_", "=_", "float_", "(_", "words_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qz", "_", "=_", "4_", "*_", "math_", "._", "pi_", "*_", "(_", "e", "V0", "_", "/_", "1000.0_", "/_", "12.3", "984", "2_", ")_", "*_", "math_", "._", "sin_", "(_", "ang_", "*_", "math_", "._", "pi_", "/_", "180.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xx_", "=_", "qz", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "x", "Min_", ">_", "xx_", ":_", "self_", "._", "x", "Min_", "=_", "xx_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "x", "Max_", "<=_", "xx_", ":_", "self_", "._", "x", "Max_", "=_", "xx_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "yy_", "=_", "float_", "(_", "words_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "y", "Min_", ">_", "yy_", ":_", "self_", "._", "y", "Min_", "=_", "yy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "y", "Max_", "<=_", "yy_", ":_", "self_", "._", "y", "Max_", "=_", "yy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "data_", "._", "append_", "(_", "(_", "xx_", ",_", "yy_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "data", "0_", "._", "append_", "(_", "(_", "xx_", ",_", "0.5_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp_", "=_", "abs_", "(_", "yy_", "-_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "temp_", "<=_", "refl", "\\u", "half_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "refl", "\\u", "half_", "=_", "temp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "th", "0_", "=_", "xx_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "y", "Max_", "=_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sample_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "(_", "ii_", ",_", "item_", ")_", "in_", "enumerate_", "(_", "layer", "\\u", "mat_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "ii_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sample_", "=_", "'", "vacuum", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sample_", "=_", "sample_", "+_", "'/'_", "+_", "item_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "title", "=", "str", "(", "e", "V0", ")+", "'", "e", "V", ",", " ", "'+", "sample", "+'", ",", " ", "Ref", "l", ".", "=", "0.", "5", " ", "at", " ", "'+", "str", "(", "th", "0", ")+", "'", " ", "m", " ", "rad", ".'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "text", "0_", "=_", "'", " ", "m", " ", "rad", ".'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text1", "_", "=_", "'", "Inciden", "t", " ", "angle", " ", "(", "m", " ", "rad", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "x", "Unit_", "==_", "'", "Deg", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "text", "0_", "=_", "'", " ", "Deg", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text1", "_", "=_", "'", "Inciden", "t", " ", "angle", " ", "(", "Deg", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "x", "Unit_", "==_", "'", "qz", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "text", "0_", "=_", "'", " ", "qz", " ", "(", "1", "/", "Ang", "stro", "m", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text1", "_", "=_", "'", "qz", " ", "(", "1", "/", "Ag", "nstr", "om", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "title_", "=_", "'%", "4.1", "f", ",", " ", "%", "s", ",", " ", "%", "s", " ", "%", "s", " ", "%", "3.3", "f", " ", "%", "s", "'_", "%_", "(_", "e", "V0", "_", ",_", "'", "e", "V", "'_", ",_", "sample_", ",_", "'", "Ref", "l", ".", "=", "0.", "5", " ", "at", "'_", ",_", "th", "0_", ",_", "text", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "-----", "_", "\\u\\u\\uNL\\u\\u\\u_", "client_", "=_", "plot_", "._", "Plot", "Canvas_", "(_", "frm_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "9", "/", "1", "/", "2010", ":", " ", "enable", " ", "zoom", "ing", " ", "function", ",", " ", "double", " ", "click", " ", "for", " ", "default", " ", "size_", "\\u\\u\\uNL\\u\\u\\u_", "client_", "._", "Set", "Enable", "Zoom", "_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "line_", "=_", "plot_", "._", "Poly", "Line_", "(_", "self_", "._", "data_", ",_", "legend_", "=_", "''_", ",_", "colour_", "=_", "'", "red", "'_", ",_", "width_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "line", "0_", "=_", "plot_", "._", "Poly", "Line_", "(_", "self_", "._", "data", "0_", ",_", "legend_", "=_", "''_", ",_", "colour_", "=_", "'", "black", "'_", ",_", "width_", "=_", "0.5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gc_", "=_", "plot_", "._", "Plot", "Graphic", "s_", "(_", "[_", "line_", ",_", "line", "0_", "]_", ",_", "title_", ",_", "text1", "_", ",_", "'", "Reflect", "ivity", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "._", "set", "Log", "Scale_", "(_", "(_", "False_", ",_", "False_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "use", "\\u", "Log_", "==_", "True_", ":_", "client_", "._", "set", "Log", "Scale_", "(_", "(_", "False_", ",_", "True_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "._", "Draw_", "(_", "gc_", ",_", "x", "Axis_", "=_", "(_", "self_", "._", "x", "Min_", ",_", "self_", "._", "x", "Max_", ")_", ",_", "y", "Axis_", "=_", "(_", "self_", "._", "y", "Min_", ",_", "self_", "._", "y", "Max_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "frm_", "._", "Show_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "plot", "\\u", "on_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
`__eq__` not overridden when adding attributes
gawel/irc3/irc3/plugins/cron.py
[ { "content": "@irc3.plugin\nclass Crons(list):\n\n\n\n\n\n\n\n\n", "metadata": "root.Crons", "header": "['module', '___EOS___']", "index": 32 }, { "content": " def __init__(self, context):\n self.context = context\n self.log = logging.getLogger(__name__)\n self.factory = irc3.utils.maybedotted('aiocron.Cron')\n self.debug = self.log.getEffectiveLevel() == logging.DEBUG\n self.started = False", "metadata": "root.Crons.__init__", "header": "['class', 'Crons', '(', 'list', ')', ':', '___EOS___']", "index": 35 }, { "content": " def connection_made(self):\n if not self.started:\n self.start()", "metadata": "root.Crons.connection_made", "header": "['class', 'Crons', '(', 'list', ')', ':', '___EOS___']", "index": 42 }, { "content": " def before_reload(self):\n self.stop()\n self[:] = []", "metadata": "root.Crons.before_reload", "header": "['class', 'Crons', '(', 'list', ')', ':', '___EOS___']", "index": 46 }, { "content": " def after_reload(self):\n self.start()", "metadata": "root.Crons.after_reload", "header": "['class', 'Crons', '(', 'list', ')', ':', '___EOS___']", "index": 50 }, { "content": " @irc3.extend\n def add_cron(self, cronline, callback, uuid=None):\n cron = self.factory(cronline, callback, start=False, uuid=uuid,\n loop=self.context.loop)\n self.append(cron)\n if self.started:\n cron.start()\n return cron", "metadata": "root.Crons.add_cron", "header": "['class', 'Crons', '(', 'list', ')', ':', '___EOS___']", "index": 53 }, { "content": " @irc3.extend\n def remove_cron(self, cron=None):\n cron.stop()\n self.remove(cron)", "metadata": "root.Crons.remove_cron", "header": "['class', 'Crons', '(', 'list', ')', ':', '___EOS___']", "index": 62 }, { "content": " def start(self):\n self.started = True\n for cron in self:\n cron.start()", "metadata": "root.Crons.start", "header": "['class', 'Crons', '(', 'list', ')', ':', '___EOS___']", "index": 67 }, { "content": " def stop(self):\n self.context.log.info('Stoping existing crons...')\n self.started = False\n for cron in self:\n cron.stop()", "metadata": "root.Crons.stop", "header": "['class', 'Crons', '(', 'list', ')', ':', '___EOS___']", "index": 72 }, { "content": " def __repr__(self):\n return '<Crons ({0}) at {1}>'.format(len(self), id(self))", "metadata": "root.Crons.__repr__", "header": "['class', 'Crons', '(', 'list', ')', ':', '___EOS___']", "index": 78 } ]
[ { "span": "class Crons(list):", "start_line": 33, "start_column": 0, "end_line": 33, "end_column": 18 } ]
[ { "span": "self.context ", "start_line": 36, "start_column": 8, "end_line": 36, "end_column": 20 }, { "span": "self.log ", "start_line": 37, "start_column": 8, "end_line": 37, "end_column": 16 }, { "span": "self.factory ", "start_line": 38, "start_column": 8, "end_line": 38, "end_column": 20 }, { "span": "self.debug ", "start_line": 39, "start_column": 8, "end_line": 39, "end_column": 18 }, { "span": "self.started ", "start_line": 40, "start_column": 8, "end_line": 40, "end_column": 20 }, { "span": "self.started ", "start_line": 68, "start_column": 8, "end_line": 68, "end_column": 20 }, { "span": "self.started ", "start_line": 74, "start_column": 8, "end_line": 74, "end_column": 20 } ]
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_", "@_", "irc", "3_", "._", "plugin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class_", "Cro", "ns_", "(_", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Cro", "ns_", "(_", "list_", ")_", ":_", "\\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_", ",_", "context_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "context_", "=_", "context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "log_", "=_", "logging_", "._", "get", "Logger_", "(_", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "factory_", "=_", "irc", "3_", "._", "utils_", "._", "may", "bed", "ott", "ed_", "(_", "'", "aio", "cron", ".", "Cro", "n", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "debug_", "=_", "self_", "._", "log_", "._", "get", "Effe", "ctive", "Level_", "(_", ")_", "==_", "logging_", "._", "DEBUG_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "started_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cro", "ns_", "(_", "list_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "connecti", "on", "\\u", "made", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "started_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cro", "ns_", "(_", "list_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "bef", "ore", "\\u", "reload_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "[_", ":_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cro", "ns_", "(_", "list_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "after", "\\u", "reload_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cro", "ns_", "(_", "list_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "irc", "3_", "._", "extend_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "add", "\\u", "cron_", "(_", "self_", ",_", "cron", "line_", ",_", "callback_", ",_", "uuid_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cron_", "=_", "self_", "._", "factory_", "(_", "cron", "line_", ",_", "callback_", ",_", "start_", "=_", "False_", ",_", "uuid_", "=_", "uuid_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "loop_", "=_", "self_", "._", "context_", "._", "loop_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "append_", "(_", "cron_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "started_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cron_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "cron_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cro", "ns_", "(_", "list_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "irc", "3_", "._", "extend_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "remove", "\\u", "cron_", "(_", "self_", ",_", "cron_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cron_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "remove_", "(_", "cron_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cro", "ns_", "(_", "list_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "start_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "started_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "cron_", "in_", "self_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cron_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cro", "ns_", "(_", "list_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "stop_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "context_", "._", "log_", "._", "info_", "(_", "'", "Sto", "ping", " ", "exist", "ing", " ", "cron", "s", "...'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "started_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "cron_", "in_", "self_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cron_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Cro", "ns_", "(_", "list_", ")_", ":_", "\\u\\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", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'<", "Cro", "ns", " ", "({", "0", "})", " ", "at", " ", "{", "1", "}>", "'_", "._", "format_", "(_", "len_", "(_", "self_", ")_", ",_", "id_", "(_", "self_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 2, 2, 2, 2, 2, 2, 2, 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, 3, 1, 1, 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 ]
Imprecise assert
caseman/grease/test/component_test.py
[ { "content": "\tdef test_fields(self):\n\t\tfrom grease.component import Component\n\t\tc = Component()\n\t\tself.assertEqual(len(c.fields), 0)\n\n\t\tc = Component(f1=int, f2=float, f3=str)\n\t\tself.assertEqual(len(c.fields), 3)\n\t\tself.assertEqual(c.fields['f1'].name, 'f1')\n\t\tself.assertEqual(c.fields['f1'].type, int)\n\t\tself.assertTrue(c.fields['f1'].component is c)\n\t\tself.assertEqual(c.fields['f2'].name, 'f2')\n\t\tself.assertEqual(c.fields['f2'].type, float)\n\t\tself.assertTrue(c.fields['f2'].component is c)\n\t\tself.assertEqual(c.fields['f3'].name, 'f3')\n\t\tself.assertEqual(c.fields['f3'].type, str)\n\t\tself.assertTrue(c.fields['f3'].component is c)", "metadata": "root.GeneralTestCase.test_fields", "header": "['class', 'GeneralTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 10 }, { "content": "\tdef test_add_no_data(self):\n\t\tfrom grease.component import Component\n\t\tc = Component()\n\t\tc.set_world(world)\n\t\tentity = TestEntity()\n\t\tself.assertFalse(entity in c)\n\t\ted = c.set(entity)\n\t\tself.assertTrue(entity in c)\n\t\tself.assertEqual(list(c), [entity])", "metadata": "root.GeneralTestCase.test_add_no_data", "header": "['class', 'GeneralTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 31 }, { "content": "\tdef test_add_kw_data(self):\n\t\tfrom grease.component import Component\n\t\tc = Component(x=float, y=float, name=str)\n\t\tc.set_world(world)\n\t\tentity = TestEntity()\n\t\tself.assertFalse(entity in c)\n\t\ted = c.set(entity, x=10, y=-1, name=\"timmy!\")\n\t\tself.assertTrue(entity in c)\n\t\tself.assertEqual(ed.x, 10)\n\t\tself.assertEqual(ed.y, -1)\n\t\tself.assertEqual(ed.name, \"timmy!\")", "metadata": "root.GeneralTestCase.test_add_kw_data", "header": "['class', 'GeneralTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 41 }, { "content": "\tdef test_add_data_object(self):\n\t\tfrom grease.component import Component\n\t\tc = Component(sweat=int, odor=str)\n\t\tc.set_world(world)\n\t\tclass Data: pass\n\t\td = Data()\n\t\td.sweat = 100\n\t\td.odor = \"rank\"\n\t\tentity = TestEntity()\n\t\ted = c.set(entity, d)\n\t\tself.assertTrue(entity in c)\n\t\tself.assertEqual(ed.sweat, 100)\n\t\tself.assertEqual(ed.odor, \"rank\")", "metadata": "root.GeneralTestCase.test_add_data_object", "header": "['class', 'GeneralTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 53 }, { "content": "\tdef test_add_with_data_object_and_kw(self):\n\t\tfrom grease.component import Component\n\t\tc = Component(state=str, time=float)\n\t\tc.set_world(world)\n\t\tclass Data: pass\n\t\td = Data()\n\t\td.state = \"grimey\"\n\t\td.time = 12.5\n\t\tentity = TestEntity()\n\t\ted = c.set(entity, d, state=\"greasy\")\n\t\tself.assertTrue(entity in c)\n\t\tself.assertEqual(ed.state, \"greasy\")\n\t\tself.assertEqual(ed.time, 12.5)", "metadata": "root.GeneralTestCase.test_add_with_data_object_and_kw", "header": "['class', 'GeneralTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 67 }, { "content": "\tdef test_getitem(self):\n\t\tfrom grease.component import Component\n\t\tc = Component()\n\t\tc.set_world(world)\n\t\tentity = TestEntity()\n\t\tself.assertRaises(KeyError, lambda: c[entity])\n\t\ted = c.set(entity)\n\t\tself.assertTrue(c[entity] is ed)", "metadata": "root.GeneralTestCase.test_getitem", "header": "['class', 'GeneralTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 123 }, { "content": "\tdef test_remove_and_contains(self):\n\t\tfrom grease.component import Component\n\t\tc = Component()\n\t\tc.set_world(world)\n\t\te1 = TestEntity()\n\t\te2 = TestEntity()\n\t\tself.assertFalse(c.remove(e1))\n\t\tc.set(e1)\n\t\tc.set(e2)\n\t\tself.assertTrue(c.remove(e1))\n\t\tself.assertTrue(e1 in c)\n\t\tc.step(0)\n\t\tself.assertFalse(e1 in c)\n\t\tself.assertTrue(e2 in c)\n\t\tself.assertFalse(c.remove(e1))\n\t\tc.step(0)\n\t\tself.assertTrue(c.remove(e2))\n\t\tself.assertTrue(e2 in c)\n\t\tc.step(0)\n\t\tself.assertFalse(e2 in c)\n\t\tself.assertFalse(e2 in c)", "metadata": "root.GeneralTestCase.test_remove_and_contains", "header": "['class', 'GeneralTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 132 }, { "content": "\tdef test_set_world(self):\n\t\tfrom grease.component import Component\n\t\tc = Component()\n\t\tworld = object()\n\t\tc.set_world(world)\n\t\tself.assertTrue(c.world is world)", "metadata": "root.GeneralTestCase.test_set_world", "header": "['class', 'GeneralTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 179 }, { "content": "\tdef test_entities_set(self):\n\t\tfrom grease.component import Component\n\t\tc = Component()\n\t\tc.set_world(world)\n\t\tself.assertEqual(len(c.entities), 0)\n\t\tentity1 = TestEntity()\n\t\tentity2 = TestEntity()\n\t\tentity3 = TestEntity()\n\t\tc.set(entity1)\n\t\tc.set(entity2)\n\t\tc.set(entity3)\n\t\tself.assertEqual(len(c.entities), 3)\n\t\tself.assertTrue(entity1 in c.entities)\n\t\tself.assertTrue(entity2 in c.entities)\n\t\tself.assertTrue(entity3 in c.entities)\n\t\tc.remove(entity2)\n\t\tself.assertEqual(len(c.entities), 2)\n\t\tself.assertTrue(entity1 in c.entities)\n\t\tself.assertFalse(entity2 in c.entities)\n\t\tself.assertTrue(entity3 in c.entities)", "metadata": "root.GeneralTestCase.test_entities_set", "header": "['class', 'GeneralTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 186 } ]
[ { "span": "self.assertTrue(c.fields['f1'].component is c)", "start_line": 19, "start_column": 2, "end_line": 19, "end_column": 48 }, { "span": "self.assertTrue(c.fields['f2'].component is c)", "start_line": 22, "start_column": 2, "end_line": 22, "end_column": 48 }, { "span": "self.assertTrue(c.fields['f3'].component is c)", "start_line": 25, "start_column": 2, "end_line": 25, "end_column": 48 }, { "span": "self.assertFalse(entity in c)", "start_line": 36, "start_column": 2, "end_line": 36, "end_column": 31 }, { "span": "self.assertTrue(entity in c)", "start_line": 38, "start_column": 2, "end_line": 38, "end_column": 30 }, { "span": "self.assertFalse(entity in c)", "start_line": 46, "start_column": 2, "end_line": 46, "end_column": 31 }, { "span": "self.assertTrue(entity in c)", "start_line": 48, "start_column": 2, "end_line": 48, "end_column": 30 }, { "span": "self.assertTrue(entity in c)", "start_line": 63, "start_column": 2, "end_line": 63, "end_column": 30 }, { "span": "self.assertTrue(entity in c)", "start_line": 77, "start_column": 2, "end_line": 77, "end_column": 30 }, { "span": "self.assertTrue(c[entity] is ed)", "start_line": 130, "start_column": 2, "end_line": 130, "end_column": 34 }, { "span": "self.assertTrue(e1 in c)", "start_line": 142, "start_column": 2, "end_line": 142, "end_column": 26 }, { "span": "self.assertFalse(e1 in c)", "start_line": 144, "start_column": 2, "end_line": 144, "end_column": 27 }, { "span": "self.assertTrue(e2 in c)", "start_line": 145, "start_column": 2, "end_line": 145, "end_column": 26 }, { "span": "self.assertTrue(e2 in c)", "start_line": 149, "start_column": 2, "end_line": 149, "end_column": 26 }, { "span": "self.assertFalse(e2 in c)", "start_line": 151, "start_column": 2, "end_line": 151, "end_column": 27 }, { "span": "self.assertFalse(e2 in c)", "start_line": 152, "start_column": 2, "end_line": 152, "end_column": 27 }, { "span": "self.assertTrue(c.world is world)", "start_line": 184, "start_column": 2, "end_line": 184, "end_column": 35 }, { "span": "self.assertTrue(entity1 in c.entities)", "start_line": 198, "start_column": 2, "end_line": 198, "end_column": 40 }, { "span": "self.assertTrue(entity2 in c.entities)", "start_line": 199, "start_column": 2, "end_line": 199, "end_column": 40 }, { "span": "self.assertTrue(entity3 in c.entities)", "start_line": 200, "start_column": 2, "end_line": 200, "end_column": 40 }, { "span": "self.assertTrue(entity1 in c.entities)", "start_line": 203, "start_column": 2, "end_line": 203, "end_column": 40 }, { "span": "self.assertFalse(entity2 in c.entities)", "start_line": 204, "start_column": 2, "end_line": 204, "end_column": 41 }, { "span": "self.assertTrue(entity3 in c.entities)", "start_line": 205, "start_column": 2, "end_line": 205, "end_column": 40 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "General", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "def_", "test\\u", "fields_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "from_", "gre", "ase_", "._", "component_", "import_", "Component_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "Component_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "c_", "._", "fields_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "c_", "=_", "Component_", "(_", "f1_", "=_", "int_", ",_", "f2_", "=_", "float_", ",_", "f3_", "=_", "str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "c_", "._", "fields_", ")_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "c_", "._", "fields_", "[_", "'", "f1", "'_", "]_", "._", "name_", ",_", "'", "f1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "c_", "._", "fields_", "[_", "'", "f1", "'_", "]_", "._", "type_", ",_", "int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "c_", "._", "fields_", "[_", "'", "f1", "'_", "]_", "._", "component_", "is_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "c_", "._", "fields_", "[_", "'", "f2", "'_", "]_", "._", "name_", ",_", "'", "f2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "c_", "._", "fields_", "[_", "'", "f2", "'_", "]_", "._", "type_", ",_", "float_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "c_", "._", "fields_", "[_", "'", "f2", "'_", "]_", "._", "component_", "is_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "c_", "._", "fields_", "[_", "'", "f3", "'_", "]_", "._", "name_", ",_", "'", "f3", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "c_", "._", "fields_", "[_", "'", "f3", "'_", "]_", "._", "type_", ",_", "str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "c_", "._", "fields_", "[_", "'", "f3", "'_", "]_", "._", "component_", "is_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "General", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "add", "\\u", "no", "\\u", "data_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "from_", "gre", "ase_", "._", "component_", "import_", "Component_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "Component_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "set\\u", "world_", "(_", "world_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity_", "=_", "Test", "Entity_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "entity_", "in_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ed_", "=_", "c_", "._", "set_", "(_", "entity_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "entity_", "in_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "list_", "(_", "c_", ")_", ",_", "[_", "entity_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "General", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "add", "\\u", "kw", "\\u", "data_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "from_", "gre", "ase_", "._", "component_", "import_", "Component_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "Component_", "(_", "x_", "=_", "float_", ",_", "y_", "=_", "float_", ",_", "name_", "=_", "str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "set\\u", "world_", "(_", "world_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity_", "=_", "Test", "Entity_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "entity_", "in_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ed_", "=_", "c_", "._", "set_", "(_", "entity_", ",_", "x_", "=_", "10_", ",_", "y_", "=_", "-_", "1_", ",_", "name_", "=_", "\"", "tim", "my", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "entity_", "in_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "ed_", "._", "x_", ",_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "ed_", "._", "y_", ",_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "ed_", "._", "name_", ",_", "\"", "tim", "my", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "General", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "add", "\\u", "data\\u", "object_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "from_", "gre", "ase_", "._", "component_", "import_", "Component_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "Component_", "(_", "swe", "at_", "=_", "int_", ",_", "odo", "r_", "=_", "str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "set\\u", "world_", "(_", "world_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class_", "Data_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "=_", "Data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "._", "swe", "at_", "=_", "100_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "._", "odo", "r_", "=_", "\"", "rank", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity_", "=_", "Test", "Entity_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ed_", "=_", "c_", "._", "set_", "(_", "entity_", ",_", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "entity_", "in_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "ed_", "._", "swe", "at_", ",_", "100_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "ed_", "._", "odo", "r_", ",_", "\"", "rank", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "General", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "add", "\\u", "with", "\\u", "data\\u", "object\\u", "and", "\\u", "kw_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "from_", "gre", "ase_", "._", "component_", "import_", "Component_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "Component_", "(_", "state_", "=_", "str_", ",_", "time_", "=_", "float_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "set\\u", "world_", "(_", "world_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class_", "Data_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "=_", "Data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "._", "state_", "=_", "\"", "gri", "me", "y", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "._", "time_", "=_", "12.", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity_", "=_", "Test", "Entity_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ed_", "=_", "c_", "._", "set_", "(_", "entity_", ",_", "d_", ",_", "state_", "=_", "\"", "gre", "asy", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "entity_", "in_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "ed_", "._", "state_", ",_", "\"", "gre", "asy", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "ed_", "._", "time_", ",_", "12.", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "General", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "getitem", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "from_", "gre", "ase_", "._", "component_", "import_", "Component_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "Component_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "set\\u", "world_", "(_", "world_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity_", "=_", "Test", "Entity_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Key", "Error_", ",_", "lambda_", ":_", "c_", "[_", "entity_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ed_", "=_", "c_", "._", "set_", "(_", "entity_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "c_", "[_", "entity_", "]_", "is_", "ed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "General", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "remove", "\\u", "and", "\\u", "contains_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "from_", "gre", "ase_", "._", "component_", "import_", "Component_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "Component_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "set\\u", "world_", "(_", "world_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e1_", "=_", "Test", "Entity_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "e2_", "=_", "Test", "Entity_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "c_", "._", "remove_", "(_", "e1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "set_", "(_", "e1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "set_", "(_", "e2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "c_", "._", "remove_", "(_", "e1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "e1_", "in_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "step_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "e1_", "in_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "e2_", "in_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "c_", "._", "remove_", "(_", "e1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "step_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "c_", "._", "remove_", "(_", "e2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "e2_", "in_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "step_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "e2_", "in_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "e2_", "in_", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "General", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "set\\u", "world_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "from_", "gre", "ase_", "._", "component_", "import_", "Component_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "Component_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "world_", "=_", "object_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "set\\u", "world_", "(_", "world_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "c_", "._", "world_", "is_", "world_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "General", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "entit", "ies", "\\u", "set_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "from_", "gre", "ase_", "._", "component_", "import_", "Component_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "=_", "Component_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "set\\u", "world_", "(_", "world_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "c_", "._", "entities_", ")_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity", "1_", "=_", "Test", "Entity_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity", "2_", "=_", "Test", "Entity_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity", "3_", "=_", "Test", "Entity_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "set_", "(_", "entity", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "set_", "(_", "entity", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "set_", "(_", "entity", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "c_", "._", "entities_", ")_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "entity", "1_", "in_", "c_", "._", "entities_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "entity", "2_", "in_", "c_", "._", "entities_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "entity", "3_", "in_", "c_", "._", "entities_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "remove_", "(_", "entity", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "c_", "._", "entities_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "entity", "1_", "in_", "c_", "._", "entities_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "entity", "2_", "in_", "c_", "._", "entities_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "entity", "3_", "in_", "c_", "._", "entities_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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np\n\nimport theano \nimport theano.tensor as T\n\nimport lasagne as nn\n\nimport data\nimport load\nimport nn_plankton\nimport dihedral\nimport tmp_dnn\nimport tta\n\n\n\npatch_sizes = [(95, 95), (47, 47)]\naugmentation_params = {\n 'zoom_range': (1 / 1.6, 1.6),\n 'rotation_range': (0, 360),\n 'shear_range': (-20, 20),\n 'translation_range': (-10, 10),\n 'do_flip': True,\n 'allow_stretch': 1.3,\n}\n\nbatch_size = 128 // 4\nchunk_size = 32768 // 4\nnum_chunks_train = 840\n\nmomentum = 0.9\nlearning_rate_schedule = {\n 0: 0.0015,\n 700: 0.00015,\n 800: 0.000015,\n}\n\nvalidate_every = 20\nsave_every = 20\nkeep_every = 100\n\ntest_pred_file = \"predictions/weighted_blend.npy\"\n\n\nscale_factors = [estimate_scale, 5.0] # combine size-based rescaling + fixed rescaling\n \n\n# augmentation_transforms_test = []\n# for flip in [True, False]:\n# for zoom in [1/1.3, 1/1.2, 1/1.1, 1.0, 1.1, 1.2, 1.3]:\n# for rot in np.linspace(0.0, 360.0, 5, endpoint=False):\n# tf = data.build_augmentation_transform(zoom=(zoom, zoom), rotation=rot, flip=flip)\n# augmentation_transforms_test.append(tf)\naugmentation_transforms_test = tta.build_quasirandom_transforms(70, **{\n 'zoom_range': (1 / 1.4, 1.4),\n 'rotation_range': (0, 360),\n 'shear_range': (-10, 10),\n 'translation_range': (-8, 8),\n 'do_flip': True,\n 'allow_stretch': 1.2,\n})\n\n\n\n# data_loader = load.ZmuvMultiscaleDataLoader(scale_factors=scale_factors, num_chunks_train=num_chunks_train,\n# patch_sizes=patch_sizes, chunk_size=chunk_size, augmentation_params=augmentation_params,\n# augmentation_transforms_test=augmentation_transforms_test)\n\ndata_loader = load.ShardedResampledPseudolabelingZmuvMultiscaleDataLoader(shard=1,\n test_pred_file=test_pred_file, train_sample_weight=0.333,\n scale_factors=scale_factors, num_chunks_train=num_chunks_train,\n patch_sizes=patch_sizes, chunk_size=chunk_size, augmentation_params=augmentation_params,\n augmentation_transforms_test=augmentation_transforms_test)\n\n\n# Conv2DLayer = nn.layers.cuda_convnet.Conv2DCCLayer\n# MaxPool2DLayer = nn.layers.cuda_convnet.MaxPool2DCCLayer\n\nConv2DLayer = tmp_dnn.Conv2DDNNLayer\nMaxPool2DLayer = tmp_dnn.MaxPool2DDNNLayer\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def estimate_scale(img):\n return np.maximum(img.shape[0], img.shape[1]) / 85.0", "metadata": "root.estimate_scale", "header": "['module', '___EOS___']", "index": 43 }, { "content": "def build_model():\n l0_variable = nn.layers.InputLayer((batch_size, 1, patch_sizes[0][0], patch_sizes[0][1]))\n l0c = dihedral.CyclicSliceLayer(l0_variable)\n\n l1a = Conv2DLayer(l0c, num_filters=32, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1), nonlinearity=nn_plankton.leaky_relu)\n l1b = Conv2DLayer(l1a, num_filters=16, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1), nonlinearity=nn_plankton.leaky_relu)\n l1 = MaxPool2DLayer(l1b, ds=(3, 3), strides=(2, 2))\n l1r = dihedral.CyclicConvRollLayer(l1)\n\n l2a = Conv2DLayer(l1r, num_filters=64, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1), nonlinearity=nn_plankton.leaky_relu)\n l2b = Conv2DLayer(l2a, num_filters=32, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1), nonlinearity=nn_plankton.leaky_relu)\n l2 = MaxPool2DLayer(l2b, ds=(3, 3), strides=(2, 2))\n l2r = dihedral.CyclicConvRollLayer(l2)\n\n l3a = Conv2DLayer(l2r, num_filters=128, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1), nonlinearity=nn_plankton.leaky_relu)\n l3b = Conv2DLayer(l3a, num_filters=128, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1), nonlinearity=nn_plankton.leaky_relu)\n l3c = Conv2DLayer(l3b, num_filters=64, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1), nonlinearity=nn_plankton.leaky_relu)\n l3 = MaxPool2DLayer(l3c, ds=(3, 3), strides=(2, 2))\n l3r = dihedral.CyclicConvRollLayer(l3)\n\n l4a = Conv2DLayer(l3r, num_filters=256, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1), nonlinearity=nn_plankton.leaky_relu)\n l4b = Conv2DLayer(l4a, num_filters=256, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1), nonlinearity=nn_plankton.leaky_relu)\n l4c = Conv2DLayer(l4b, num_filters=128, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1), nonlinearity=nn_plankton.leaky_relu) \n l4 = MaxPool2DLayer(l4c, ds=(3, 3), strides=(2, 2))\n l4r = dihedral.CyclicConvRollLayer(l4)\n l4f = nn.layers.flatten(l4r)\n\n l5 = nn.layers.DenseLayer(l4f, num_units=256, W=nn_plankton.Orthogonal(1.0), b=nn.init.Constant(0.1), nonlinearity=nn_plankton.leaky_relu)\n l5r = dihedral.CyclicRollLayer(l5)\n\n l6 = nn.layers.DenseLayer(l5r, num_units=256, W=nn_plankton.Orthogonal(1.0), b=nn.init.Constant(0.1), nonlinearity=nn_plankton.leaky_relu)\n l_variable = dihedral.CyclicPoolLayer(l6, pool_function=nn_plankton.rms)\n\n\n # fixed scale part\n l0_fixed = nn.layers.InputLayer((batch_size, 1, patch_sizes[1][0], patch_sizes[1][1]))\n l0c = dihedral.CyclicSliceLayer(l0_fixed)\n\n l1a = Conv2DLayer(l0c, num_filters=16, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1))\n l1b = Conv2DLayer(l1a, num_filters=8, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1))\n l1 = MaxPool2DLayer(l1b, ds=(3, 3), strides=(2, 2))\n l1r = dihedral.CyclicConvRollLayer(l1)\n\n l2a = Conv2DLayer(l1r, num_filters=32, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1))\n l2b = Conv2DLayer(l2a, num_filters=16, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1))\n l2 = MaxPool2DLayer(l2b, ds=(3, 3), strides=(2, 2))\n l2r = dihedral.CyclicConvRollLayer(l2)\n\n l3a = Conv2DLayer(l2r, num_filters=64, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1))\n l3b = Conv2DLayer(l3a, num_filters=64, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1))\n l3c = Conv2DLayer(l3b, num_filters=32, filter_size=(3, 3), border_mode=\"same\", W=nn_plankton.Conv2DOrthogonal(1.0), b=nn.init.Constant(0.1))\n l3 = MaxPool2DLayer(l3c, ds=(3, 3), strides=(2, 2))\n l3r = dihedral.CyclicConvRollLayer(l3)\n l3f = nn.layers.flatten(l3r)\n\n l4 = nn.layers.DenseLayer(l3f, num_units=128, W=nn_plankton.Orthogonal(1.0), b=nn.init.Constant(0.1))\n l4r = dihedral.CyclicRollLayer(l4)\n\n l5 = nn.layers.DenseLayer(l4r, num_units=128, W=nn_plankton.Orthogonal(1.0), b=nn.init.Constant(0.1))\n l_fixed = dihedral.CyclicPoolLayer(l5, pool_function=nn_plankton.rms) \n\n\n # merge the parts\n l_merged = nn.layers.concat([l_variable, l_fixed])\n\n l7 = nn.layers.DenseLayer(l_merged, num_units=data.num_classes, nonlinearity=T.nnet.softmax, W=nn_plankton.Orthogonal(1.0))\n\n return [l0_variable, l0_fixed], l7", "metadata": "root.build_model", "header": "['module', '___EOS___']", "index": 84 } ]
[ { "span": "import theano ", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 13 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "theano_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "theano_", "._", "tensor_", "as_", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "lasagne_", "as_", "nn_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "load_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "nn", "\\u", "plan", "kto", "n_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "dihedral", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tmp", "\\u", "dnn", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tta", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "patch", "\\u", "sizes_", "=_", "[_", "(_", "95_", ",_", "95_", ")_", ",_", "(_", "47_", ",_", "47_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "augmenta", "tion", "\\u", "params_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zoom", "\\u", "range", "'_", ":_", "(_", "1_", "/_", "1.6_", ",_", "1.6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rotati", "on", "\\u", "range", "'_", ":_", "(_", "0_", ",_", "360_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "shear", "\\u", "range", "'_", ":_", "(_", "-_", "20_", ",_", "20_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "translatio", "n", "\\u", "range", "'_", ":_", "(_", "-_", "10_", ",_", "10_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "do", "\\u", "flip", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "allow", "\\u", "stretch", "'_", ":_", "1.3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "batch", "\\u", "size_", "=_", "128_", "//_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "chunk", "\\u", "size_", "=_", "32768_", "//_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "chunks", "\\u", "train_", "=_", "840", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "momentum_", "=_", "0.9_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "learn", "ing", "\\u", "rate", "\\u", "schedule_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "0_", ":_", "0.001", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "700_", ":_", "0.0001", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "800_", ":_", "0.00001", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "validat", "e\\u", "every_", "=_", "20_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "save", "\\u", "every_", "=_", "20_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "keep", "\\u", "every_", "=_", "100_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "test\\u", "pred", "\\u", "file_", "=_", "\"", "predicti", "ons", "/", "weight", "ed", "\\u", "blend", ".", "npy", "\"_", "\\u\\u\\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_", "scale", "\\u", "factors_", "=_", "[_", "estimate", "\\u", "scale_", ",_", "5.0_", "]_", "#", " ", "combin", "e", " ", "size", "-", "based", " ", "resc", "alin", "g", " ", "+", " ", "fixed", " ", "resc", "alin", "g_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "augmenta", "tion", "\\u", "transform", "s", "\\u", "test", " ", "=", " ", "[]", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "flip", " ", "in", " ", "[", "Tru", "e", ",", " ", "Fal", "se", "]:", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "zoom", " ", "in", " ", "[", "1", "/", "1.3", ",", " ", "1", "/", "1.2", ",", " ", "1", "/", "1.1", ",", " ", "1.0", ",", " ", "1.1", ",", " ", "1.2", ",", " ", "1.3", "]:", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "for", " ", "rot", " ", "in", " ", "np", ".", "lins", "pace", "(", "0.", "0", ",", " ", "360.", "0", ",", " ", "5", ",", " ", "endpoint", "=", "Fal", "se", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "tf", " ", "=", " ", "data", ".", "build", "\\u", "augmenta", "tion", "\\u", "transform", "(", "zoom", "=(", "zoom", ",", " ", "zoom", "),", " ", "rotati", "on", "=", "rot", ",", " ", "flip", "=", "flip", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "augmenta", "tion", "\\u", "transform", "s", "\\u", "test", ".", "append", "(", "tf", ")_", "\\u\\u\\uNL\\u\\u\\u_", "augmenta", "tion", "\\u", "transform", "s", "\\u", "test_", "=_", "tta", "_", "._", "build", "\\u", "quas", "ira", "ndo", "m", "\\u", "transforms_", "(_", "70_", ",_", "**_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zoom", "\\u", "range", "'_", ":_", "(_", "1_", "/_", "1.4_", ",_", "1.4_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rotati", "on", "\\u", "range", "'_", ":_", "(_", "0_", ",_", "360_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "shear", "\\u", "range", "'_", ":_", "(_", "-_", "10_", ",_", "10_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "translatio", "n", "\\u", "range", "'_", ":_", "(_", "-_", "8_", ",_", "8_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "do", "\\u", "flip", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "allow", "\\u", "stretch", "'_", ":_", "1.2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "data\\u", "load", "er", " ", "=", " ", "load", ".", "Zm", "uv", "Multi", "scale", "Data", "Load", "er", "(", "scale", "\\u", "factor", "s", "=", "scale", "\\u", "factor", "s", ",", " ", "num", "\\u", "chunks", "\\u", "train", "=", "num", "\\u", "chunks", "\\u", "train", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "patch", "\\u", "size", "s", "=", "patch", "\\u", "size", "s", ",", " ", "chunk", "\\u", "size", "=", "chunk", "\\u", "size", ",", " ", "augmenta", "tion", "\\u", "params", "=", "augmenta", "tion", "\\u", "params", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "augmenta", "tion", "\\u", "transform", "s", "\\u", "test", "=", "augmenta", "tion", "\\u", "transform", "s", "\\u", "test", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data\\u", "loader_", "=_", "load_", "._", "Shard", "ed", "Res", "ample", "d", "Pse", "udo", "labeling", "Zm", "uv", "Multi", "scale", "Data", "Loader_", "(_", "shard_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "test\\u", "pred", "\\u", "file_", "=_", "test\\u", "pred", "\\u", "file_", ",_", "train", "\\u", "sample", "\\u", "weight_", "=_", "0.333", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "scale", "\\u", "factors_", "=_", "scale", "\\u", "factors_", ",_", "num", "\\u", "chunks", "\\u", "train_", "=_", "num", "\\u", "chunks", "\\u", "train_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "patch", "\\u", "sizes_", "=_", "patch", "\\u", "sizes_", ",_", "chunk", "\\u", "size_", "=_", "chunk", "\\u", "size_", ",_", "augmenta", "tion", "\\u", "params_", "=_", "augmenta", "tion", "\\u", "params_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "augmenta", "tion", "\\u", "transform", "s", "\\u", "test_", "=_", "augmenta", "tion", "\\u", "transform", "s", "\\u", "test_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Conv", "2", "DL", "aye", "r", " ", "=", " ", "nn", ".", "layer", "s", ".", "cud", "a", "\\u", "conv", "net", ".", "Conv", "2", "DC", "CL", "ayer_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Max", "Poo", "l2", "DL", "aye", "r", " ", "=", " ", "nn", ".", "layer", "s", ".", "cud", "a", "\\u", "conv", "net", ".", "Max", "Poo", "l2", "DC", "CL", "ayer_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Conv", "2", "DL", "ayer_", "=_", "tmp", "\\u", "dnn", "_", "._", "Conv", "2", "DD", "NN", "Layer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Max", "Poo", "l2", "DL", "ayer_", "=_", "tmp", "\\u", "dnn", "_", "._", "Max", "Poo", "l2", "DD", "NN", "Layer_", "\\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_", "estimate", "\\u", "scale_", "(_", "img_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "np_", "._", "maximum_", "(_", "img_", "._", "shape_", "[_", "0_", "]_", ",_", "img_", "._", "shape_", "[_", "1_", "]_", ")_", "/_", "85.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "build", "\\u", "model_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l", "0", "\\u", "variable_", "=_", "nn_", "._", "layers_", "._", "Inp", "ut", "Layer_", "(_", "(_", "batch", "\\u", "size_", ",_", "1_", ",_", "patch", "\\u", "sizes_", "[_", "0_", "]_", "[_", "0_", "]_", ",_", "patch", "\\u", "sizes_", "[_", "0_", "]_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l", "0c", "_", "=_", "dihedral", "_", "._", "Cyc", "lic", "Slice", "Layer_", "(_", "l", "0", "\\u", "variable_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l1", "a_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l", "0c", "_", ",_", "num", "\\u", "filters_", "=_", "32_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ",_", "nonlinearity", "_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "leak", "y", "\\u", "relu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l1", "b_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l1", "a_", ",_", "num", "\\u", "filters_", "=_", "16_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ",_", "nonlinearity", "_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "leak", "y", "\\u", "relu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l1_", "=_", "Max", "Poo", "l2", "DL", "ayer_", "(_", "l1", "b_", ",_", "ds_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "strides_", "=_", "(_", "2_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l1", "r_", "=_", "dihedral", "_", "._", "Cyc", "lic", "Conv", "Roll", "Layer_", "(_", "l1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l2", "a_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l1", "r_", ",_", "num", "\\u", "filters_", "=_", "64_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ",_", "nonlinearity", "_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "leak", "y", "\\u", "relu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l2", "b_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l2", "a_", ",_", "num", "\\u", "filters_", "=_", "32_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ",_", "nonlinearity", "_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "leak", "y", "\\u", "relu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l2_", "=_", "Max", "Poo", "l2", "DL", "ayer_", "(_", "l2", "b_", ",_", "ds_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "strides_", "=_", "(_", "2_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l2", "r_", "=_", "dihedral", "_", "._", "Cyc", "lic", "Conv", "Roll", "Layer_", "(_", "l2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l3", "a_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l2", "r_", ",_", "num", "\\u", "filters_", "=_", "128_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ",_", "nonlinearity", "_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "leak", "y", "\\u", "relu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l3", "b_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l3", "a_", ",_", "num", "\\u", "filters_", "=_", "128_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ",_", "nonlinearity", "_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "leak", "y", "\\u", "relu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l3", "c_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l3", "b_", ",_", "num", "\\u", "filters_", "=_", "64_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ",_", "nonlinearity", "_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "leak", "y", "\\u", "relu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l3_", "=_", "Max", "Poo", "l2", "DL", "ayer_", "(_", "l3", "c_", ",_", "ds_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "strides_", "=_", "(_", "2_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l3", "r_", "=_", "dihedral", "_", "._", "Cyc", "lic", "Conv", "Roll", "Layer_", "(_", "l3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l4", "a_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l3", "r_", ",_", "num", "\\u", "filters_", "=_", "256_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ",_", "nonlinearity", "_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "leak", "y", "\\u", "relu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l4", "b_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l4", "a_", ",_", "num", "\\u", "filters_", "=_", "256_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ",_", "nonlinearity", "_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "leak", "y", "\\u", "relu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l4", "c_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l4", "b_", ",_", "num", "\\u", "filters_", "=_", "128_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ",_", "nonlinearity", "_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "leak", "y", "\\u", "relu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l4", "_", "=_", "Max", "Poo", "l2", "DL", "ayer_", "(_", "l4", "c_", ",_", "ds_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "strides_", "=_", "(_", "2_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l4", "r_", "=_", "dihedral", "_", "._", "Cyc", "lic", "Conv", "Roll", "Layer_", "(_", "l4", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l4", "f_", "=_", "nn_", "._", "layers_", "._", "flatten_", "(_", "l4", "r_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l", "5_", "=_", "nn_", "._", "layers_", "._", "Den", "se", "Layer_", "(_", "l4", "f_", ",_", "num", "\\u", "units_", "=_", "256_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Ortho", "gon", "al_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ",_", "nonlinearity", "_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "leak", "y", "\\u", "relu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l", "5", "r_", "=_", "dihedral", "_", "._", "Cyc", "lic", "Roll", "Layer_", "(_", "l", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l", "6_", "=_", "nn_", "._", "layers_", "._", "Den", "se", "Layer_", "(_", "l", "5", "r_", ",_", "num", "\\u", "units_", "=_", "256_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Ortho", "gon", "al_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ",_", "nonlinearity", "_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "leak", "y", "\\u", "relu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l\\u", "variable_", "=_", "dihedral", "_", "._", "Cyc", "lic", "Poo", "l", "Layer_", "(_", "l", "6_", ",_", "pool", "\\u", "function_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "rms_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fixed", " ", "scale", " ", "part_", "\\u\\u\\uNL\\u\\u\\u_", "l", "0", "\\u", "fixed_", "=_", "nn_", "._", "layers_", "._", "Inp", "ut", "Layer_", "(_", "(_", "batch", "\\u", "size_", ",_", "1_", ",_", "patch", "\\u", "sizes_", "[_", "1_", "]_", "[_", "0_", "]_", ",_", "patch", "\\u", "sizes_", "[_", "1_", "]_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l", "0c", "_", "=_", "dihedral", "_", "._", "Cyc", "lic", "Slice", "Layer_", "(_", "l", "0", "\\u", "fixed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l1", "a_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l", "0c", "_", ",_", "num", "\\u", "filters_", "=_", "16_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l1", "b_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l1", "a_", ",_", "num", "\\u", "filters_", "=_", "8_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l1_", "=_", "Max", "Poo", "l2", "DL", "ayer_", "(_", "l1", "b_", ",_", "ds_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "strides_", "=_", "(_", "2_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l1", "r_", "=_", "dihedral", "_", "._", "Cyc", "lic", "Conv", "Roll", "Layer_", "(_", "l1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l2", "a_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l1", "r_", ",_", "num", "\\u", "filters_", "=_", "32_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l2", "b_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l2", "a_", ",_", "num", "\\u", "filters_", "=_", "16_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l2_", "=_", "Max", "Poo", "l2", "DL", "ayer_", "(_", "l2", "b_", ",_", "ds_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "strides_", "=_", "(_", "2_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l2", "r_", "=_", "dihedral", "_", "._", "Cyc", "lic", "Conv", "Roll", "Layer_", "(_", "l2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l3", "a_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l2", "r_", ",_", "num", "\\u", "filters_", "=_", "64_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l3", "b_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l3", "a_", ",_", "num", "\\u", "filters_", "=_", "64_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l3", "c_", "=_", "Conv", "2", "DL", "ayer_", "(_", "l3", "b_", ",_", "num", "\\u", "filters_", "=_", "32_", ",_", "filter", "\\u", "size_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "border", "\\u", "mode_", "=_", "\"", "same", "\"_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Conv", "2", "DO", "rt", "hog", "onal", "_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l3_", "=_", "Max", "Poo", "l2", "DL", "ayer_", "(_", "l3", "c_", ",_", "ds_", "=_", "(_", "3_", ",_", "3_", ")_", ",_", "strides_", "=_", "(_", "2_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l3", "r_", "=_", "dihedral", "_", "._", "Cyc", "lic", "Conv", "Roll", "Layer_", "(_", "l3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l3", "f_", "=_", "nn_", "._", "layers_", "._", "flatten_", "(_", "l3", "r_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l4", "_", "=_", "nn_", "._", "layers_", "._", "Den", "se", "Layer_", "(_", "l3", "f_", ",_", "num", "\\u", "units_", "=_", "128_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Ortho", "gon", "al_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l4", "r_", "=_", "dihedral", "_", "._", "Cyc", "lic", "Roll", "Layer_", "(_", "l4", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l", "5_", "=_", "nn_", "._", "layers_", "._", "Den", "se", "Layer_", "(_", "l4", "r_", ",_", "num", "\\u", "units_", "=_", "128_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Ortho", "gon", "al_", "(_", "1.0_", ")_", ",_", "b_", "=_", "nn_", "._", "init_", "._", "Constant_", "(_", "0.1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l\\u", "fixed_", "=_", "dihedral", "_", "._", "Cyc", "lic", "Poo", "l", "Layer_", "(_", "l", "5_", ",_", "pool", "\\u", "function_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "rms_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "merge", " ", "the", " ", "parts_", "\\u\\u\\uNL\\u\\u\\u_", "l\\u", "merged_", "=_", "nn_", "._", "layers_", "._", "concat_", "(_", "[_", "l\\u", "variable_", ",_", "l\\u", "fixed_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "l7", "_", "=_", "nn_", "._", "layers_", "._", "Den", "se", "Layer_", "(_", "l\\u", "merged_", ",_", "num", "\\u", "units_", "=_", "data_", "._", "num", "\\u", "classes_", ",_", "nonlinearity", "_", "=_", "T_", "._", "nnet", "_", "._", "softmax_", ",_", "W_", "=_", "nn", "\\u", "plan", "kto", "n_", "._", "Ortho", "gon", "al_", "(_", "1.0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "[_", "l", "0", "\\u", "variable_", ",_", "l", "0", "\\u", "fixed_", "]_", ",_", "l7", "_" ]
[ 4, 4, 4, 4, 4, 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, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
worldcompany/djangoembed/oembed/providers.py
[ { "content": "import datetime\nimport httplib2\nimport re\nimport time\nfrom urllib import urlencode\n\ntry:\n import Image\nexcept ImportError:\n from PIL import Image\ntry:\n from cStringIO import StringIO\nexcept ImportError:\n from StringIO import StringIO\n\nfrom django.conf import settings\nfrom django.contrib.sites.models import Site\nfrom django.core.files import storage\nfrom django.core.urlresolvers import get_resolver\nfrom django.db.models.fields import DateTimeField, DateField\nfrom django.db.models.fields.files import ImageField, ImageFieldFile\nfrom django.template import RequestContext, Context\nfrom django.template.loader import render_to_string, get_template\nfrom django.utils import simplejson\n\nfrom oembed.constants import OEMBED_ALLOWED_SIZES, OEMBED_THUMBNAIL_SIZE\nfrom oembed.exceptions import OEmbedException, OEmbedHTTPException\nfrom oembed.image_processors import image_processor\nfrom oembed.resources import OEmbedResource\nfrom oembed.utils import (fetch_url, get_domain, mock_request, cleaned_sites, \n size_to_nearest, relative_to_full, scale)\n\n\nresolver = get_resolver(None)\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class BaseProvider(object):\n \"\"\"\n Base class for OEmbed resources.\n \"\"\"\n regex = None # regex this provider will match\n provides = True # allow this provider to be accessed by third parties\n ", "metadata": "root.BaseProvider", "header": "['module', '___EOS___']", "index": 36 }, { "content": " def request_resource(self, url, **kwargs):\n \"\"\"\n Get an OEmbedResource from one of the providers configured in this \n provider according to the resource url.\n \n Args:\n url: The url of the resource to get.\n format: Desired response format (json or xml).\n **kwargs: Optional parameters to pass in to the provider.\n \n Returns:\n OEmbedResource object.\n \n If no object returned, raises OEmbedException\n \"\"\"\n raise NotImplementedError", "metadata": "root.BaseProvider.request_resource", "header": "['class', 'BaseProvider', '(', 'object', ')', ':', '___EOS___']", "index": 43 }, { "content": "class HTTPProvider(BaseProvider):\n \"\"\"\n Provider class for HTTP providers, like YouTube - basically\n a proxy.\n \"\"\"\n endpoint_url = ''\n provides = False # since this is generally a proxy to a pre-existing oembed\n # provider, do not re-provide it\n \n # NOTE: these attributes are only required if provides = True\n # see http://oembed.com/ section 2.1 for how to define\n # but the gist is, this is a list of urls with wildcards\n # indicating what will match, instead of regex bits, i.e.\n # http://flickr.com/photos/*\n url_scheme = None\n resource_type = None # one of 'photo', 'video', 'rich' or 'link'\n \n \n \n \n ", "metadata": "root.HTTPProvider", "header": "['module', '___EOS___']", "index": 61 }, { "content": " def __init__(self):\n self._validate()", "metadata": "root.HTTPProvider.__init__", "header": "['class', 'HTTPProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 78 }, { "content": " def _validate(self):\n if self.provides and (not self.url_scheme or not self.resource_type):\n raise AttributeError(\n 'If you want to provide %s up-stream, a url_scheme and ' \\\n 'resource_type must be specified' % self.__name__)\n if self.provides and self.resource_type not in ('photo', 'video', 'rich', 'link'):\n raise ValueError('resource_type must be one of \"photo\", \"video\", \"rich\" or \"link\"')", "metadata": "root.HTTPProvider._validate", "header": "['class', 'HTTPProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 81 }, { "content": " def _fetch(self, url):\n \"\"\"\n Fetches from a URL, respecting GZip encoding, etc.\n \n Returns an OEmbedResource instance\n \"\"\"\n return fetch_url(url)", "metadata": "root.HTTPProvider._fetch", "header": "['class', 'HTTPProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 89 }, { "content": " def convert_to_resource(self, headers, raw_response, params):\n if 'content-type' not in headers:\n raise OEmbedException('Missing mime-type in response')\n \n content_type = headers['content-type'].split(';')[0]\n \n if content_type in ('text/javascript', 'application/json'):\n try:\n json_response = simplejson.loads(raw_response)\n resource = OEmbedResource.create(json_response)\n except ValueError:\n raise OEmbedException('Unable to parse response json')\n else:\n raise OEmbedException('Invalid mime-type - %s' % headers['content-type'])\n return resource", "metadata": "root.HTTPProvider.convert_to_resource", "header": "['class', 'HTTPProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 97 }, { "content": " def request_resource(self, url, **kwargs):\n \"\"\"\n Request an OEmbedResource for a given url. Some valid keyword args:\n - format\n - maxwidth\n - maxheight\n \"\"\"\n params = kwargs\n \n params['url'] = url\n params['format'] = 'json'\n \n if '?' in self.endpoint_url:\n url_with_qs = '%s&%s' % (self.endpoint_url.rstrip('&'), urlencode(params))\n else:\n url_with_qs = \"%s?%s\" % (self.endpoint_url, urlencode(params))\n \n headers, raw_response = self._fetch(url_with_qs)\n resource = self.convert_to_resource(headers, raw_response, params)\n \n return resource", "metadata": "root.HTTPProvider.request_resource", "header": "['class', 'HTTPProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 113 }, { "content": "class DjangoProviderOptions(object):\n model = None # required\n named_view = '' # required: the name of this models' detail view\n fields_to_match = {} # mapping of regex_field -> model attr for lookups\n \n valid_sizes = OEMBED_ALLOWED_SIZES\n thumbnail_sizes = OEMBED_THUMBNAIL_SIZE\n image_processor = image_processor()\n force_fit = False\n \n year_part = 'year'\n month_part = 'month'\n day_part = 'day'\n\n context_varname = 'object'\n \n abstract = False\n \n \n \n image_field = property(_image_field)\n \n date_field = property(_date_field)", "metadata": "root.DjangoProviderOptions", "header": "['module', '___EOS___']", "index": 136 }, { "content": " def __init__(self, meta_options, provider_class):\n for k, v in meta_options.__dict__.items():\n if not k.startswith('_'):\n # because we are using properties, which are descriptors,\n # an AttributeError will be raised if we try to setattr()\n # to change a property (like image_field), so make changes\n # to the __dict__ instead\n self.__dict__[k] = v\n \n self.provider_class = provider_class\n \n if not self.abstract:\n self._validate()\n if not getattr(self, 'template_name', None):\n self.template_name = 'oembed/provider/%s_%s.html' % (\n self.model._meta.app_label, self.model._meta.module_name\n )", "metadata": "root.DjangoProviderOptions.__init__", "header": "['class', 'DjangoProviderOptions', '(', 'object', ')', ':', '___EOS___']", "index": 154 }, { "content": " def _validate(self):\n if self.model is None:\n raise OEmbedException('Provider %s requires a model' % self.provider_class.__name__)\n if not self.named_view:\n raise OEmbedException('Provider %s requires a named_view' % self.provider_class.__name__)", "metadata": "root.DjangoProviderOptions._validate", "header": "['class', 'DjangoProviderOptions', '(', 'object', ')', ':', '___EOS___']", "index": 172 }, { "content": " def _image_field(self):\n \"\"\"\n Try to automatically detect an image field\n \"\"\"\n for field in self.model._meta.fields:\n if isinstance(field, ImageField):\n return field.name", "metadata": "root.DjangoProviderOptions._image_field", "header": "['class', 'DjangoProviderOptions', '(', 'object', ')', ':', '___EOS___']", "index": 178 }, { "content": " def _date_field(self):\n \"\"\"\n Try to automatically detect an image field\n \"\"\"\n for field in self.model._meta.fields:\n if isinstance(field, (DateTimeField, DateField)):\n return field.name", "metadata": "root.DjangoProviderOptions._date_field", "header": "['class', 'DjangoProviderOptions', '(', 'object', ')', ':', '___EOS___']", "index": 187 }, { "content": "class DjangoProviderMetaclass(type):", "metadata": "root.DjangoProviderMetaclass", "header": "['module', '___EOS___']", "index": 197 }, { "content": " def __new__(cls, name, bases, attrs):\n \"\"\"\n Provides namespacing of Meta options\n \"\"\"\n # these are any overrides defined on the incoming provider class\n meta = attrs.pop('Meta', None)\n \n provider_class = super(DjangoProviderMetaclass, cls).__new__(\n cls, name, bases, attrs)\n \n # see if the provider class is extending any class that has its own\n # set of overrides\n for b in bases:\n base_meta = getattr(b, '_meta', None)\n if not base_meta:\n continue\n \n for (k, v) in base_meta.__dict__.items():\n if not k.startswith('_') and k != 'abstract' and k not in meta.__dict__:\n meta.__dict__[k] = v\n \n if meta:\n # instantiate the options class, passing in our provider\n _meta = DjangoProviderOptions(meta, provider_class)\n \n # bolt the options onto the new provider class\n provider_class._meta = _meta\n \n return provider_class", "metadata": "root.DjangoProviderMetaclass.__new__", "header": "['class', 'DjangoProviderMetaclass', '(', 'type', ')', ':', '___EOS___']", "index": 198 }, { "content": "class DjangoProvider(BaseProvider):\n \"\"\"\n Provider class for Django apps\n \n Examples:\n \n class PhotoProvider(DjangoProvider):\n class Meta:\n model = Photo\n named_view = 'photo_detail'\n fields_to_match = {'object_id': 'id'}\n \n def author_name(self, obj):\n return obj.user.username\n \n def title(self, obj):\n return obj.title\n \n class VideoProvider(DjangoDateBasedProvider):\n class Meta:\n model = Video\n named_view = 'video_detail'\n fields_to_match = {'slug': 'slug'}\n \n valid_sizes = ((400, 300), (600, 450)) # embed will automatically resize\n force_fit = True # don't scale dimensions, force fit\n \n def html(self, obj):\n return self.render_html(\n obj,\n context=Context({'width': self.width, 'height': self.height}), \n context_varname='video')\n \n ...\n \"\"\"\n __metaclass__ = DjangoProviderMetaclass\n \n resource_type = None # photo, link, video or rich\n \n \n \n regex = property(_build_regex)\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ", "metadata": "root.DjangoProvider", "header": "['module', '___EOS___']", "index": 229 }, { "content": " def __init__(self):\n self._validate()", "metadata": "root.DjangoProvider.__init__", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 268 }, { "content": " def _validate(self):\n if self.resource_type not in ('photo', 'video', 'rich', 'link'):\n raise ValueError('resource_type must be one of \"photo\", \"video\", \"rich\" or \"link\"')", "metadata": "root.DjangoProvider._validate", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 271 }, { "content": " def _build_regex(self):\n \"\"\"\n Performs a reverse lookup on a named view and generates\n a list of regexes that match that object. It generates\n regexes with the domain name included, using sites provided\n by the get_sites() method.\n \n >>> regex = provider.regex\n >>> regex.pattern\n 'http://(www2.kusports.com|www2.ljworld.com|www.lawrence.com)/photos/(?P<year>\\\\d{4})/(?P<month>\\\\w{3})/(?P<day>\\\\d{1,2})/(?P<object_id>\\\\d+)/$'\n \"\"\"\n # get the regexes from the urlconf\n url_patterns = resolver.reverse_dict.get(self._meta.named_view)\n \n try:\n regex = url_patterns[1]\n except TypeError:\n raise OEmbedException('Error looking up %s' % self._meta.named_view)\n \n # get a list of normalized domains\n cleaned_sites = self.get_cleaned_sites()\n \n site_regexes = []\n \n for site in self.get_sites():\n site_regexes.append(cleaned_sites[site.pk][0])\n \n # join the sites together with the regex 'or'\n sites = '|'.join(site_regexes)\n \n # create URL-matching regexes for sites\n regex = re.compile('(%s)/%s' % (sites, regex))\n \n return regex", "metadata": "root.DjangoProvider._build_regex", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 275 }, { "content": " def get_sites(self):\n \"\"\"\n Return sites whose domains should be checked against\n \"\"\"\n return Site.objects.all()", "metadata": "root.DjangoProvider.get_sites", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 311 }, { "content": " def get_cleaned_sites(self):\n \"\"\"\n Attribute-caches the sites/regexes returned by\n `oembed.utils.cleaned_sites`\n \"\"\"\n if not getattr(self, '_clean_sites', None):\n self._clean_sites = cleaned_sites()\n return self._clean_sites", "metadata": "root.DjangoProvider.get_cleaned_sites", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 317 }, { "content": " def provider_from_url(self, url):\n \"\"\"\n Given a URL for any of our sites, try and match it to one, returning\n the domain & name of the match. If no match is found, return current.\n \n Returns a tuple of domain, site name -- used to determine 'provider'\n \"\"\"\n domain = get_domain(url)\n site_tuples = self.get_cleaned_sites().values()\n for domain_re, name, normalized_domain in site_tuples:\n if re.match(domain_re, domain):\n return normalized_domain, name\n site = Site.objects.get_current()\n return site.domain, site.name", "metadata": "root.DjangoProvider.provider_from_url", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 326 }, { "content": " def get_params(self, url):\n \"\"\"\n Extract the named parameters from a url regex. If the url regex does not contain\n named parameters, they will be keyed _0, _1, ...\n \n * Named parameters\n Regex:\n /photos/^(?P<year>\\d{4})/(?P<month>\\w{3})/(?P<day>\\d{1,2})/(?P<object_id>\\d+)/\n \n URL:\n http://www2.ljworld.com/photos/2009/oct/11/12345/\n \n Return Value:\n {u'day': '11', u'month': 'oct', u'object_id': '12345', u'year': '2009'}\n \n * Unnamed parameters\n Regex:\n /blah/([\\w-]+)/(\\d+)/\n \n URL:\n http://www.example.com/blah/hello/123/\n \n Return Value:\n {u'_0': 'hello', u'_1': '123'}\n \"\"\"\n match = re.match(self.regex, url)\n if match is not None:\n params = match.groupdict()\n if not params:\n params = {}\n for i, group in enumerate(match.groups()[1:]):\n params['_%s' % i] = group\n return params\n \n raise OEmbedException('No regex matched the url %s' % (url))", "metadata": "root.DjangoProvider.get_params", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 341 }, { "content": " def get_queryset(self):\n return self._meta.model._default_manager.all()", "metadata": "root.DjangoProvider.get_queryset", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 377 }, { "content": " def get_object(self, url):\n \"\"\"\n Fields to match is a mapping of url params to fields, so for\n the photos example above, it would be:\n \n fields_to_match = { 'object_id': 'id' }\n \n This procedure parses out named params from a URL and then uses\n the fields_to_match dictionary to generate a query.\n \"\"\"\n params = self.get_params(url)\n query = {}\n for key, value in self._meta.fields_to_match.iteritems():\n try:\n query[value] = params[key]\n except KeyError:\n raise OEmbedException('%s was not found in the urlpattern parameters. Valid names are: %s' % (key, ', '.join(params.keys())))\n \n try:\n obj = self.get_queryset().get(**query)\n except self._meta.model.DoesNotExist:\n raise OEmbedException('Requested object not found')\n \n return obj", "metadata": "root.DjangoProvider.get_object", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 380 }, { "content": " def render_html(self, obj, context=None):\n \"\"\"\n Generate the 'html' attribute of an oembed resource using a template.\n Sort of a corollary to the parser's render_oembed method. By default,\n the current mapping will be passed in as the context.\n \n OEmbed templates are stored in:\n \n oembed/provider/[app_label]_[model].html\n \n -- or --\n \n oembed/provider/media_video.html\n \"\"\" \n provided_context = context or Context()\n context = RequestContext(mock_request())\n context.update(provided_context)\n \n context.push()\n context[self._meta.context_varname] = obj\n rendered = render_to_string(self._meta.template_name, context)\n context.pop()\n return rendered", "metadata": "root.DjangoProvider.render_html", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 405 }, { "content": " def map_attr(self, mapping, attr, obj):\n \"\"\"\n A kind of cheesy method that allows for callables or attributes to\n be used interchangably\n \"\"\"\n if attr not in mapping and hasattr(self, attr):\n if not callable(getattr(self, attr)):\n mapping[attr] = getattr(self, attr)\n else:\n mapping[attr] = getattr(self, attr)(obj)", "metadata": "root.DjangoProvider.map_attr", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 429 }, { "content": " def get_image(self, obj):\n \"\"\"\n Return an ImageFileField instance\n \"\"\"\n if self._meta.image_field:\n return getattr(obj, self._meta.image_field)", "metadata": "root.DjangoProvider.get_image", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 440 }, { "content": " def resize(self, image_field, new_width=None, new_height=None):\n \"\"\"\n Resize an image to the 'best fit' width & height, maintaining\n the scale of the image, so a 500x500 image sized to 300x400\n will actually be scaled to 300x300.\n \n Params:\n image: ImageFieldFile to be resized (i.e. model.image_field)\n new_width & new_height: desired maximums for resizing\n \n Returns:\n the url to the new image and the new width & height\n (http://path-to-new-image, 300, 300)\n \"\"\"\n if isinstance(image_field, ImageFieldFile) and \\\n image_field.field.width_field and \\\n image_field.field.height_field:\n # use model fields\n current_width = getattr(image_field.instance, image_field.field.width_field)\n current_height = getattr(image_field.instance, image_field.field.height_field)\n else:\n # use PIL\n try:\n file_obj = storage.default_storage.open(image_field.name, 'rb')\n img_obj = Image.open(file_obj)\n current_width, current_height = img_obj.size\n except IOError:\n return (image_field.url, 0, 0) \n \n # determine if resizing needs to be done (will not scale up)\n if current_width < new_width:\n if not new_height or current_height < new_height:\n return (image_field.url, current_width, current_height)\n \n # calculate ratios\n new_width, new_height = scale(current_width, current_height, new_width, new_height)\n \n # use the image_processor defined in the settings, or PIL by default\n return self._meta.image_processor.resize(image_field, new_width, new_height)", "metadata": "root.DjangoProvider.resize", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 447 }, { "content": " def resize_photo(self, obj, mapping, maxwidth=None, maxheight=None):\n url, width, height = self.resize(\n self.get_image(obj), \n *size_to_nearest(maxwidth, maxheight, self._meta.valid_sizes))\n mapping.update(url=url, width=width, height=height)", "metadata": "root.DjangoProvider.resize_photo", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 487 }, { "content": " def thumbnail(self, obj, mapping):\n url, width, height = self.resize(\n self.get_image(obj), \n *size_to_nearest(allowed_sizes=self._meta.thumbnail_sizes))\n mapping.update(thumbnail_url=url, thumbnail_width=width, \n thumbnail_height=height)", "metadata": "root.DjangoProvider.thumbnail", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 493 }, { "content": " def preprocess(self, obj, mapping, **kwargs):\n \"\"\"\n Pre-processing hook. Called by map_to_dictionary()\n \"\"\"\n pass", "metadata": "root.DjangoProvider.preprocess", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 500 }, { "content": " def postprocess(self, obj, mapping, **kwargs):\n \"\"\"\n Post-processing hook. Called by map_to_dictionary()\n \"\"\"\n pass", "metadata": "root.DjangoProvider.postprocess", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 506 }, { "content": " def map_to_dictionary(self, url, obj, **kwargs):\n \"\"\"\n Build a dictionary of metadata for the requested object.\n \"\"\"\n maxwidth = kwargs.get('maxwidth', None)\n maxheight = kwargs.get('maxheight', None)\n \n provider_url, provider_name = self.provider_from_url(url)\n \n mapping = {\n 'version': '1.0',\n 'url': url,\n 'provider_name': provider_name,\n 'provider_url': provider_url,\n 'type': self.resource_type\n }\n \n # a hook\n self.preprocess(obj, mapping, **kwargs)\n \n # resize image if we have a photo, otherwise use the given maximums\n if self.resource_type == 'photo' and self.get_image(obj):\n self.resize_photo(obj, mapping, maxwidth, maxheight)\n elif self.resource_type in ('video', 'rich', 'photo'):\n width, height = size_to_nearest(\n maxwidth,\n maxheight,\n self._meta.valid_sizes,\n self._meta.force_fit\n )\n mapping.update(width=width, height=height)\n \n # create a thumbnail\n if self.get_image(obj):\n self.thumbnail(obj, mapping)\n \n # map attributes to the mapping dictionary. if the attribute is\n # a callable, it must have an argument signature of\n # (self, obj)\n for attr in ('title', 'author_name', 'author_url', 'html'):\n self.map_attr(mapping, attr, obj)\n \n # fix any urls\n if 'url' in mapping:\n mapping['url'] = relative_to_full(mapping['url'], url)\n \n if 'thumbnail_url' in mapping:\n mapping['thumbnail_url'] = relative_to_full(mapping['thumbnail_url'], url)\n \n if 'html' not in mapping and mapping['type'] in ('video', 'rich'):\n mapping['html'] = self.render_html(obj, context=Context(mapping))\n \n # a hook\n self.postprocess(obj, mapping, **kwargs)\n \n return mapping", "metadata": "root.DjangoProvider.map_to_dictionary", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 512 }, { "content": " def request_resource(self, url, **kwargs):\n \"\"\"\n Request an OEmbedResource for a given url. Some valid keyword args:\n - format\n - maxwidth\n - maxheight\n \"\"\"\n obj = self.get_object(url)\n \n mapping = self.map_to_dictionary(url, obj, **kwargs)\n \n resource = OEmbedResource.create(mapping)\n resource.content_object = obj\n \n return resource", "metadata": "root.DjangoProvider.request_resource", "header": "['class', 'DjangoProvider', '(', 'BaseProvider', ')', ':', '___EOS___']", "index": 569 }, { "content": "class DjangoDateBasedProvider(DjangoProvider):\n \"\"\"\n Provider for Django models that use date-based urls\n \"\"\"\n ", "metadata": "root.DjangoDateBasedProvider", "header": "['module', '___EOS___']", "index": 585 }, { "content": " def _validate(self):\n super(DjangoDateBasedProvider, self)._validate()\n if not self._meta.date_field:\n raise OEmbedException('date_field not found for %s' % self.__class__.__name__)", "metadata": "root.DjangoDateBasedProvider._validate", "header": "['class', 'DjangoDateBasedProvider', '(', 'DjangoProvider', ')', ':', '___EOS___']", "index": 589 }, { "content": " def get_object(self, url, month_format='%b', day_format='%d'):\n \"\"\"\n Parses the date from a url and uses it in the query. For objects which\n are unique for date.\n \"\"\"\n params = self.get_params(url)\n try:\n year = params[self._meta.year_part]\n month = params[self._meta.month_part]\n day = params[self._meta.day_part]\n except KeyError:\n try:\n # named lookups failed, so try to get the date using the first\n # three parameters\n year, month, day = params['_0'], params['_1'], params['_2']\n except KeyError:\n raise OEmbedException('Error extracting date from url parameters')\n \n try:\n tt = time.strptime('%s-%s-%s' % (year, month, day),\n '%s-%s-%s' % ('%Y', month_format, day_format))\n date = datetime.date(*tt[:3])\n except ValueError:\n raise OEmbedException('Error parsing date from: %s' % url)\n\n # apply the date-specific lookups\n if isinstance(self._meta.model._meta.get_field(self._meta.date_field), DateTimeField):\n min_date = datetime.datetime.combine(date, datetime.time.min)\n max_date = datetime.datetime.combine(date, datetime.time.max)\n query = {'%s__range' % self._meta.date_field: (min_date, max_date)}\n else:\n query = {self._meta.date_field: date}\n \n # apply the regular search lookups\n for key, value in self._meta.fields_to_match.iteritems():\n try:\n query[value] = params[key]\n except KeyError:\n raise OEmbedException('%s was not found in the urlpattern parameters. Valid names are: %s' % (key, ', '.join(params.keys())))\n \n try:\n obj = self.get_queryset().get(**query)\n except self._meta.model.DoesNotExist:\n raise OEmbedException('Requested object not found')\n \n return obj", "metadata": "root.DjangoDateBasedProvider.get_object", "header": "['class', 'DjangoDateBasedProvider', '(', 'DjangoProvider', ')', ':', '___EOS___']", "index": 594 } ]
[ { "span": "import httplib2", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 15 }, { "span": "from cStringIO import StringIO", "start_line": 11, "start_column": 4, "end_line": 11, "end_column": 34 }, { "span": "from StringIO import StringIO", "start_line": 13, "start_column": 4, "end_line": 13, "end_column": 33 }, { "span": "from django.conf import settings", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 32 }, { "span": "from django.template.loader import render_to_string, get_template", "start_line": 22, "start_column": 0, "end_line": 22, "end_column": 65 }, { "span": "from oembed.exceptions import OEmbedException, OEmbedHTTPException", "start_line": 26, "start_column": 0, "end_line": 26, "end_column": 66 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "httplib2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "urllib_", "import_", "urlencode_", "\\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_", "Image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "PIL_", "import_", "Image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "c", "String", "IO_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "String", "IO_", "import_", "String", "IO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "django_", "._", "conf_", "import_", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "sites_", "._", "models_", "import_", "Site_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "files_", "import_", "storage_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "urlresolvers_", "import_", "get", "\\u", "resolver_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "._", "fields_", "import_", "Date", "Time", "Field_", ",_", "Date", "Field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "db_", "._", "models_", "._", "fields_", "._", "files_", "import_", "Image", "Field_", ",_", "Image", "Field", "File_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "template_", "import_", "Request", "Context_", ",_", "Context_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "template_", "._", "loader_", "import_", "render", "\\u", "to", "\\u", "string_", ",_", "get", "\\u", "template_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "utils_", "import_", "simplejson_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "oem", "bed_", "._", "constants_", "import_", "OE", "MB", "ED", "\\u", "ALLOWED", "\\u", "SIZE", "S_", ",_", "OE", "MB", "ED", "\\u", "THUMB", "NA", "IL", "\\u", "SIZE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "oem", "bed_", "._", "exceptions_", "import_", "OE", "mbed", "Exception_", ",_", "OE", "mbed", "HTTP", "Exception_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "oem", "bed_", "._", "image", "\\u", "processors_", "import_", "image", "\\u", "processor_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "oem", "bed_", "._", "resources_", "import_", "OE", "mbed", "Resource_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "oem", "bed_", "._", "utils_", "import_", "(_", "fetch", "\\u", "url_", ",_", "get", "\\u", "domain_", ",_", "mock", "\\u", "request_", ",_", "clean", "ed", "\\u", "sites_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "size", "\\u", "to", "\\u", "nearest_", ",_", "relative", "\\u", "to", "\\u", "full_", ",_", "scale_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "resolver_", "=_", "get", "\\u", "resolver_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\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_", "class_", "Base", "Provider_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Base", " ", "class", " ", "for", " ", "OE", "mbed", " ", "resource", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "regex_", "=_", "None_", "#", " ", "regex", " ", "this", " ", "provide", "r", " ", "will", " ", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "provides_", "=_", "True_", "#", " ", "allow", " ", "this", " ", "provide", "r", " ", "to", " ", "be", " ", "accesse", "d", " ", "by", " ", "third", " ", "parties", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Base", "Provider_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "request", "\\u", "resource_", "(_", "self_", ",_", "url_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Get", " ", "an", " ", "OE", "mbed", "Reso", "urc", "e", " ", "from", " ", "one", " ", "of", " ", "the", " ", "provide", "rs", " ", "configur", "ed", " ", "in", " ", "this", " ", "\\", "10", ";", " ", " ", " ", " ", "provide", "r", " ", "according", " ", "to", " ", "the", " ", "resource", " ", "url", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "url", ":", " ", "The", " ", "url", " ", "of", " ", "the", " ", "resource", " ", "to", " ", "get", ".", "\\", "10", ";", " ", " ", " ", " ", "format", ":", " ", "Des", "ired", " ", "response", " ", "format", " ", "(", "json", " ", "or", " ", "xml", ").", "\\", "10", ";", " ", " ", " ", " ", "**", "kwarg", "s", ":", " ", "Optio", "nal", " ", "parameter", "s", " ", "to", " ", "pass", " ", "in", " ", "to", " ", "the", " ", "provide", "r", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "OE", "mbed", "Reso", "urc", "e", " ", "object", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "no", " ", "object", " ", "return", "ed", ",", " ", "raise", "s", " ", "OE", "mbed", "Except", "ion", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "HTTP", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Provider", " ", "class", " ", "for", " ", "HTTP", " ", "provide", "rs", ",", " ", "like", " ", "You", "Tu", "be", " ", "-", " ", "basic", "ally", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "proxy", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "endpoint", "\\u", "url_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "provides_", "=_", "False_", "#", " ", "sinc", "e", " ", "this", " ", "is", " ", "genera", "ll", "y", " ", "a", " ", "proxy", " ", "to", " ", "a", " ", "pre", "-", "exist", "ing", " ", "oem", "bed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "provide", "r", ",", " ", "do", " ", "not", " ", "re", "-", "provide", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "NOTE", ":", " ", "these", " ", "attribute", "s", " ", "are", " ", "only", " ", "require", "d", " ", "if", " ", "provide", "s", " ", "=", " ", "True_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "see", " ", "http", "://", "oem", "bed", ".", "com", "/", " ", "section", " ", "2.1", " ", "for", " ", "how", " ", "to", " ", "define_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "but", " ", "the", " ", "gist", " ", "is", ",", " ", "this", " ", "is", " ", "a", " ", "list", " ", "of", " ", "urls", " ", "with", " ", "wildcards", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "indicati", "ng", " ", "what", " ", "will", " ", "match", ",", " ", "inst", "ead", " ", "of", " ", "regex", " ", "bits", ",", " ", "i", ".", "e", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "http", "://", "flickr", ".", "com", "/", "photo", "s", "/*", "_", "\\u\\u\\uNL\\u\\u\\u_", "url", "\\u", "scheme_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resource", "\\u", "type_", "=_", "None_", "#", " ", "one", " ", "of", " ", "'", "photo", "',", " ", "'", "video", "',", " ", "'", "rich", "'", " ", "or", " ", "'", "link", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "HTTP", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "validate_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "HTTP", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "validate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "provides_", "and_", "(_", "not_", "self_", "._", "url", "\\u", "scheme_", "or_", "not_", "self_", "._", "resource", "\\u", "type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Attribute", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "If", " ", "you", " ", "want", " ", "to", " ", "provide", " ", "%", "s", " ", "up", "-", "stream", ",", " ", "a", " ", "url", "\\u", "sche", "me", " ", "and", " ", "'_", "'", "resource", "\\u", "type", " ", "must", " ", "be", " ", "specified", "'_", "%_", "self_", "._", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "provides_", "and_", "self_", "._", "resource", "\\u", "type_", "not_", "in_", "(_", "'", "photo", "'_", ",_", "'", "video", "'_", ",_", "'", "rich", "'_", ",_", "'", "link", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "resource", "\\u", "type", " ", "must", " ", "be", " ", "one", " ", "of", " ", "\"", "photo", "\",", " ", "\"", "video", "\",", " ", "\"", "rich", "\"", " ", "or", " ", "\"", "link", "\"'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "HTTP", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "fetch_", "(_", "self_", ",_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Fetche", "s", " ", "from", " ", "a", " ", "URL", ",", " ", "respec", "ting", " ", "GZ", "ip", " ", "encoding", ",", " ", "etc", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "an", " ", "OE", "mbed", "Reso", "urc", "e", " ", "instance", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "fetch", "\\u", "url_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "HTTP", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "convert", "\\u", "to", "\\u", "resource_", "(_", "self_", ",_", "headers_", ",_", "raw", "\\u", "response_", ",_", "params_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "content", "-", "type", "'_", "not_", "in_", "headers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "OE", "mbed", "Exception_", "(_", "'", "Missing", " ", "mime", "-", "type", " ", "in", " ", "response", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "content", "\\u", "type_", "=_", "headers_", "[_", "'", "content", "-", "type", "'_", "]_", "._", "split_", "(_", "';'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "content", "\\u", "type_", "in_", "(_", "'", "text", "/", "javascript", "'_", ",_", "'", "applica", "tion", "/", "json", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "json", "\\u", "response_", "=_", "simplejson_", "._", "loads_", "(_", "raw", "\\u", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resource_", "=_", "OE", "mbed", "Resource_", "._", "create_", "(_", "json", "\\u", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "OE", "mbed", "Exception_", "(_", "'", "Una", "ble", " ", "to", " ", "parse", " ", "response", " ", "json", "'_", ")_", "\\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_", "OE", "mbed", "Exception_", "(_", "'", "Inva", "lid", " ", "mime", "-", "type", " ", "-", " ", "%", "s", "'_", "%_", "headers_", "[_", "'", "content", "-", "type", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "resource_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "HTTP", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "request", "\\u", "resource_", "(_", "self_", ",_", "url_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Request", " ", "an", " ", "OE", "mbed", "Reso", "urc", "e", " ", "for", " ", "a", " ", "give", "n", " ", "url", ".", " ", " ", "Some", " ", "valid", " ", "keyw", "ord", " ", "args", ":", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "format", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "maxw", "idt", "h", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "max", "height", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "=_", "kwargs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "params_", "[_", "'", "url", "'_", "]_", "=_", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "[_", "'", "format", "'_", "]_", "=_", "'", "json", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'?'_", "in_", "self_", "._", "endpoint", "\\u", "url_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url", "\\u", "with", "\\u", "qs_", "=_", "'%", "s", "&%", "s", "'_", "%_", "(_", "self_", "._", "endpoint", "\\u", "url_", "._", "rstrip_", "(_", "'&'_", ")_", ",_", "urlencode_", "(_", "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 ", " _", "url", "\\u", "with", "\\u", "qs_", "=_", "\"%", "s", "?", "%", "s", "\"_", "%_", "(_", "self_", "._", "endpoint", "\\u", "url_", ",_", "urlencode_", "(_", "params_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "headers_", ",_", "raw", "\\u", "response_", "=_", "self_", "._", "\\u", "fetch_", "(_", "url", "\\u", "with", "\\u", "qs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resource_", "=_", "self_", "._", "convert", "\\u", "to", "\\u", "resource_", "(_", "headers_", ",_", "raw", "\\u", "response_", ",_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "resource_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "Dj", "ang", "o", "Provider", "Options_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "model_", "=_", "None_", "#", " ", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "named", "\\u", "view_", "=_", "''_", "#", " ", "require", "d", ":", " ", "the", " ", "name", " ", "of", " ", "this", " ", "model", "s", "'", " ", "deta", "il", " ", "view_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fields", "\\u", "to", "\\u", "match_", "=_", "{_", "}_", "#", " ", "mapping", " ", "of", " ", "regex", "\\u", "field", " ", "->", " ", "model", " ", "attr", " ", "for", " ", "lookups", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "valid", "\\u", "sizes_", "=_", "OE", "MB", "ED", "\\u", "ALLOWED", "\\u", "SIZE", "S_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "thumbnail", "\\u", "sizes_", "=_", "OE", "MB", "ED", "\\u", "THUMB", "NA", "IL", "\\u", "SIZE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image", "\\u", "processor_", "=_", "image", "\\u", "processor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "force", "\\u", "fit_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "year", "\\u", "part_", "=_", "'", "year", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "month", "\\u", "part_", "=_", "'", "month", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "day", "\\u", "part_", "=_", "'", "day", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "context", "\\u", "varname_", "=_", "'", "object", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "abstract_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "image", "\\u", "field_", "=_", "property_", "(_", "\\u", "image", "\\u", "field_", ")_", "\\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_", "date", "\\u", "field_", "=_", "property_", "(_", "\\u", "date", "\\u", "field_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider", "Options_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "meta", "\\u", "options_", ",_", "provide", "r", "\\u", "class_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "k_", ",_", "v_", "in_", "meta", "\\u", "options_", "._", "\\u\\u", "dict\\u\\u_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "k_", "._", "startswith_", "(_", "'\\u'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "bec", "aus", "e", " ", "we", " ", "are", " ", "usi", "ng", " ", "proper", "ties", ",", " ", "whi", "ch", " ", "are", " ", "descrip", "tors", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "an", " ", "Attribute", "Error", " ", "will", " ", "be", " ", "raise", "d", " ", "if", " ", "we", " ", "try", " ", "to", " ", "setattr", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "change", " ", "a", " ", "property", " ", "(", "like", " ", "image", "\\u", "field", "),", " ", "so", " ", "make", " ", "changes_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "the", " ", "\\u\\u", "dict", "\\u\\u", " ", "inst", "ead_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u\\u", "dict\\u\\u_", "[_", "k_", "]_", "=_", "v_", "\\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_", "._", "provide", "r", "\\u", "class_", "=_", "provide", "r", "\\u", "class_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "self_", "._", "abstract_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "validate_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "getattr_", "(_", "self_", ",_", "'", "template", "\\u", "name", "'_", ",_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "template", "\\u", "name_", "=_", "'", "oem", "bed", "/", "provide", "r", "/", "%", "s", "\\u", "%", "s", ".", "html", "'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "model_", "._", "\\u", "meta_", "._", "app", "\\u", "label_", ",_", "self_", "._", "model_", "._", "\\u", "meta_", "._", "module", "\\u", "name_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider", "Options_", "(_", "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_", "\\u", "validate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "model_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "OE", "mbed", "Exception_", "(_", "'", "Provider", " ", "%", "s", " ", "require", "s", " ", "a", " ", "model", "'_", "%_", "self_", "._", "provide", "r", "\\u", "class_", "._", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "named", "\\u", "view_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "OE", "mbed", "Exception_", "(_", "'", "Provider", " ", "%", "s", " ", "require", "s", " ", "a", " ", "named", "\\u", "view", "'_", "%_", "self_", "._", "provide", "r", "\\u", "class_", "._", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider", "Options_", "(_", "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", "image", "\\u", "field_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Tr", "y", " ", "to", " ", "automati", "call", "y", " ", "detect", " ", "an", " ", "image", " ", "field", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "field_", "in_", "self_", "._", "model_", "._", "\\u", "meta_", "._", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "field_", ",_", "Image", "Field_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "field_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider", "Options_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "date", "\\u", "field_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Tr", "y", " ", "to", " ", "automati", "call", "y", " ", "detect", " ", "an", " ", "image", " ", "field", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "field_", "in_", "self_", "._", "model_", "._", "\\u", "meta_", "._", "fields_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "field_", ",_", "(_", "Date", "Time", "Field_", ",_", "Date", "Field_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "field_", "._", "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_", "class_", "Dj", "ang", "o", "Provider", "Meta", "class_", "(_", "type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider", "Meta", "class_", "(_", "type_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "new\\u\\u_", "(_", "cls_", ",_", "name_", ",_", "bases_", ",_", "attrs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Prov", "ides", " ", "names", "pacing", " ", "of", " ", "Meta", " ", "options", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "these", " ", "are", " ", "any", " ", "override", "s", " ", "defin", "ed", " ", "on", " ", "the", " ", "inco", "ming", " ", "provide", "r", " ", "class_", "\\u\\u\\uNL\\u\\u\\u_", "meta_", "=_", "attrs_", "._", "pop_", "(_", "'", "Meta", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "provide", "r", "\\u", "class_", "=_", "super_", "(_", "Dj", "ang", "o", "Provider", "Meta", "class_", ",_", "cls_", ")_", "._", "\\u\\u", "new\\u\\u_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "cls_", ",_", "name_", ",_", "bases_", ",_", "attrs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "see", " ", "if", " ", "the", " ", "provide", "r", " ", "class", " ", "is", " ", "extend", "ing", " ", "any", " ", "class", " ", "tha", "t", " ", "has", " ", "its", " ", "own_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "set", " ", "of", " ", "overrides_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "b_", "in_", "bases_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "base", "\\u", "meta_", "=_", "getattr_", "(_", "b_", ",_", "'\\u", "meta", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "base", "\\u", "meta_", ":_", "\\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_", "for_", "(_", "k_", ",_", "v_", ")_", "in_", "base", "\\u", "meta_", "._", "\\u\\u", "dict\\u\\u_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "k_", "._", "startswith_", "(_", "'\\u'_", ")_", "and_", "k_", "!=_", "'", "abstract", "'_", "and_", "k_", "not_", "in_", "meta_", "._", "\\u\\u", "dict\\u\\u_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "meta_", "._", "\\u\\u", "dict\\u\\u_", "[_", "k_", "]_", "=_", "v_", "\\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_", "meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "instantiate", " ", "the", " ", "options", " ", "class", ",", " ", "passi", "ng", " ", "in", " ", "our", " ", "provider_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "meta_", "=_", "Dj", "ang", "o", "Provider", "Options_", "(_", "meta_", ",_", "provide", "r", "\\u", "class_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "bolt", " ", "the", " ", "options", " ", "onto", " ", "the", " ", "new", " ", "provide", "r", " ", "class_", "\\u\\u\\uNL\\u\\u\\u_", "provide", "r", "\\u", "class_", "._", "\\u", "meta_", "=_", "\\u", "meta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "provide", "r", "\\u", "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_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Provider", " ", "class", " ", "for", " ", "Dj", "ang", "o", " ", "apps", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Exam", "ples", ":", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "class", " ", "Photo", "Provider", "(", "Dj", "ang", "o", "Provider", "):", "\\", "10", ";", " ", " ", " ", " ", "class", " ", "Meta", ":", "\\", "10", ";", " ", " ", " ", " ", "model", " ", "=", " ", "Photo", "\\", "10", ";", " ", " ", " ", " ", "named", "\\u", "view", " ", "=", " ", "'", "photo", "\\u", "deta", "il", "'", "\\", "10", ";", " ", " ", " ", " ", "fields", "\\u", "to", "\\u", "match", " ", "=", " ", "{", "'", "object\\u", "id", "':", " ", "'", "id", "'}", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "author", "\\u", "name", "(", "self", ",", " ", "obj", "):", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "obj", ".", "user", ".", "user", "name", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "title", "(", "self", ",", " ", "obj", "):", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "obj", ".", "title", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "class", " ", "Vid", "eo", "Provider", "(", "Dj", "ang", "o", "Date", "Base", "d", "Provider", "):", "\\", "10", ";", " ", " ", " ", " ", "class", " ", "Meta", ":", "\\", "10", ";", " ", " ", " ", " ", "model", " ", "=", " ", "Vid", "eo", "\\", "10", ";", " ", " ", " ", " ", "named", "\\u", "view", " ", "=", " ", "'", "video", "\\u", "deta", "il", "'", "\\", "10", ";", " ", " ", " ", " ", "fields", "\\u", "to", "\\u", "match", " ", "=", " ", "{", "'", "slug", "':", " ", "'", "slug", "'}", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "valid", "\\u", "size", "s", " ", "=", " ", "((", "400", ",", " ", "300", "),", " ", "(", "600", ",", " ", "450", "))", " ", "#", " ", "embed", " ", "will", " ", "automati", "call", "y", " ", "resiz", "e", "\\", "10", ";", " ", " ", " ", " ", "force", "\\u", "fit", " ", "=", " ", "Tru", "e", " ", "#", " ", "don", "'", "t", " ", "scale", " ", "dimension", "s", ",", " ", "force", " ", "fit", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "html", "(", "self", ",", " ", "obj", "):", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "self", ".", "render", "\\u", "html", "(", "\\", "10", ";", " ", " ", " ", " ", "obj", ",", "\\", "10", ";", " ", " ", " ", " ", "context", "=", "Context", "({", "'", "widt", "h", "':", " ", "self", ".", "widt", "h", ",", " ", "'", "height", "':", " ", "self", ".", "height", "})", ",", " ", "\\", "10", ";", " ", " ", " ", " ", "context", "\\u", "varname", "='", "video", "')", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "...", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "metaclass\\u\\u_", "=_", "Dj", "ang", "o", "Provider", "Meta", "class_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "resource", "\\u", "type_", "=_", "None_", "#", " ", "photo", ",", " ", "link", ",", " ", "video", " ", "or", " ", "rich", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "regex_", "=_", "property_", "(_", "\\u", "build", "\\u", "regex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "validate_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "validate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "resource", "\\u", "type_", "not_", "in_", "(_", "'", "photo", "'_", ",_", "'", "video", "'_", ",_", "'", "rich", "'_", ",_", "'", "link", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "resource", "\\u", "type", " ", "must", " ", "be", " ", "one", " ", "of", " ", "\"", "photo", "\",", " ", "\"", "video", "\",", " ", "\"", "rich", "\"", " ", "or", " ", "\"", "link", "\"'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "build", "\\u", "regex_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Perform", "s", " ", "a", " ", "reverse", " ", "look", "up", " ", "on", " ", "a", " ", "named", " ", "view", " ", "and", " ", "generat", "es", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "list", " ", "of", " ", "regex", "es", " ", "tha", "t", " ", "match", " ", "tha", "t", " ", "object", ".", " ", " ", "It", " ", "generat", "es", "\\", "10", ";", " ", " ", " ", " ", "regex", "es", " ", "with", " ", "the", " ", "domain", " ", "name", " ", "include", "d", ",", " ", "usi", "ng", " ", "sites", " ", "provided", "\\", "10", ";", " ", " ", " ", " ", "by", " ", "the", " ", "get", "\\u", "sites", "()", " ", "method", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "regex", " ", "=", " ", "provide", "r", ".", "regex", "\\", "10", ";", " ", " ", " ", " ", ">>>", " ", "regex", ".", "pattern", "\\", "10", ";", " ", " ", " ", " ", "'", "http", "://", "(", "www", "2", ".", "kus", "port", "s", ".", "com", "|", "www", "2", ".", "lj", "world", ".", "com", "|", "www", ".", "law", "ren", "ce", ".", "com", ")/", "photo", "s", "/(", "?", "P", "<", "year", ">\\\\", "\\\\", "d", "{", "4", "})", "/(", "?", "P", "<", "month", ">\\\\", "\\\\", "w", "{", "3", "})", "/(", "?", "P", "<", "day", ">\\\\", "\\\\", "d", "{", "1", ",", "2", "})", "/(", "?", "P", "<", "object\\u", "id", ">\\\\", "\\\\", "d", "+)", "/$", "'", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "get", " ", "the", " ", "regex", "es", " ", "from", " ", "the", " ", "url", "conf_", "\\u\\u\\uNL\\u\\u\\u_", "url", "\\u", "patterns_", "=_", "resolver_", "._", "reverse", "\\u", "dict_", "._", "get_", "(_", "self_", "._", "\\u", "meta_", "._", "named", "\\u", "view_", ")_", "\\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 ", " _", "regex_", "=_", "url", "\\u", "patterns_", "[_", "1_", "]_", "\\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 ", " _", "raise_", "OE", "mbed", "Exception_", "(_", "'", "Error", " ", "look", "ing", " ", "up", " ", "%", "s", "'_", "%_", "self_", "._", "\\u", "meta_", "._", "named", "\\u", "view_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "a", " ", "list", " ", "of", " ", "normali", "zed", " ", "domains_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "clean", "ed", "\\u", "sites_", "=_", "self_", "._", "get", "\\u", "clean", "ed", "\\u", "sites_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "site", "\\u", "regexes_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "site_", "in_", "self_", "._", "get", "\\u", "sites_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "site", "\\u", "regexes_", "._", "append_", "(_", "clean", "ed", "\\u", "sites_", "[_", "site_", "._", "pk_", "]_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "join", " ", "the", " ", "sites", " ", "tog", "ether", " ", "with", " ", "the", " ", "regex", " ", "'", "or", "'_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sites_", "=_", "'|'_", "._", "join_", "(_", "site", "\\u", "regexes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "URL", "-", "matchi", "ng", " ", "regex", "es", " ", "for", " ", "sites_", "\\u\\u\\uNL\\u\\u\\u_", "regex_", "=_", "re_", "._", "compile_", "(_", "'(", "%", "s", ")/", "%", "s", "'_", "%_", "(_", "sites_", ",_", "regex_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "regex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "\\u", "sites_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", " ", "sites", " ", "who", "se", " ", "domains", " ", "shou", "ld", " ", "be", " ", "checke", "d", " ", "against", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Site_", "._", "objects_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "clean", "ed", "\\u", "sites_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Attribute", "-", "cache", "s", " ", "the", " ", "sites", "/", "regex", "es", " ", "return", "ed", " ", "by", "\\", "10", ";", " ", " ", " ", " ", "`", "oem", "bed", ".", "util", "s", ".", "clean", "ed", "\\u", "sites", "`", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "getattr_", "(_", "self_", ",_", "'\\u", "clean", "\\u", "sites", "'_", ",_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "clean", "\\u", "sites_", "=_", "clean", "ed", "\\u", "sites_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "\\u", "clean", "\\u", "sites_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "provide", "r", "\\u", "from", "\\u", "url_", "(_", "self_", ",_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Give", "n", " ", "a", " ", "URL", " ", "for", " ", "any", " ", "of", " ", "our", " ", "sites", ",", " ", "try", " ", "and", " ", "match", " ", "it", " ", "to", " ", "one", ",", " ", "return", "ing", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "domain", " ", "&", " ", "name", " ", "of", " ", "the", " ", "match", ".", " ", " ", "If", " ", "no", " ", "match", " ", "is", " ", "found", ",", " ", "return", " ", "current", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "a", " ", "tuple", " ", "of", " ", "domain", ",", " ", "site", " ", "name", " ", "--", " ", "used", " ", "to", " ", "dete", "rmin", "e", " ", "'", "provide", "r", "'", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "domain_", "=_", "get", "\\u", "domain_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "site", "\\u", "tuples_", "=_", "self_", "._", "get", "\\u", "clean", "ed", "\\u", "sites_", "(_", ")_", "._", "values_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "domain", "\\u", "re_", ",_", "name_", ",_", "normali", "zed", "\\u", "domain_", "in_", "site", "\\u", "tuples_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "re_", "._", "match_", "(_", "domain", "\\u", "re_", ",_", "domain_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "normali", "zed", "\\u", "domain_", ",_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "site_", "=_", "Site_", "._", "objects_", "._", "get", "\\u", "current_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "site_", "._", "domain_", ",_", "site_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "params_", "(_", "self_", ",_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Extract", " ", "the", " ", "named", " ", "parameter", "s", " ", "from", " ", "a", " ", "url", " ", "regex", ".", " ", " ", "If", " ", "the", " ", "url", " ", "regex", " ", "doe", "s", " ", "not", " ", "contain", "\\", "10", ";", " ", " ", " ", " ", "named", " ", "parameter", "s", ",", " ", "the", "y", " ", "will", " ", "be", " ", "keyed", " ", "\\u", "0", ",", " ", "\\u", "1", ",", " ", "...", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "*", " ", "Name", "d", " ", "parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "Rege", "x", ":", "\\", "10", ";", " ", " ", " ", " ", "/", "photo", "s", "/", "^", "(?", "P", "<", "year", ">\\\\", "d", "{", "4", "})", "/(", "?", "P", "<", "month", ">\\\\", "w", "{", "3", "})", "/(", "?", "P", "<", "day", ">\\\\", "d", "{", "1", ",", "2", "})", "/(", "?", "P", "<", "object\\u", "id", ">\\\\", "d", "+)", "/", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "URL", ":", "\\", "10", ";", " ", " ", " ", " ", "http", "://", "www", "2", ".", "lj", "world", ".", "com", "/", "photo", "s", "/", "200", "9", "/", "oct", "/", "11", "/", "12345", "/", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", " ", "Value", ":", "\\", "10", ";", " ", " ", " ", " ", "{", "u", "'", "day", "':", " ", "'", "11", "',", " ", "u", "'", "month", "':", " ", "'", "oct", "',", " ", "u", "'", "object\\u", "id", "':", " ", "'", "12345", "',", " ", "u", "'", "year", "':", " ", "'", "200", "9", "'}", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "*", " ", "Un", "named", " ", "parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "Rege", "x", ":", "\\", "10", ";", " ", " ", " ", " ", "/", "bla", "h", "/([", "\\\\", "w", "-]+)", "/(", "\\\\", "d", "+)", "/", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "URL", ":", "\\", "10", ";", " ", " ", " ", " ", "http", "://", "www", ".", "example", ".", "com", "/", "bla", "h", "/", "hell", "o", "/", "123", "/", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", " ", "Value", ":", "\\", "10", ";", " ", " ", " ", " ", "{", "u", "'\\u", "0", "':", " ", "'", "hell", "o", "',", " ", "u", "'\\u", "1", "':", " ", "'", "123", "'}", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "match_", "=_", "re_", "._", "match_", "(_", "self_", "._", "regex_", ",_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "=_", "match_", "._", "groupdict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "params_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", ",_", "group_", "in_", "enumerate_", "(_", "match_", "._", "groups_", "(_", ")_", "[_", "1_", ":_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "params_", "[_", "'\\u", "%", "s", "'_", "%_", "i_", "]_", "=_", "group_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "params_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "OE", "mbed", "Exception_", "(_", "'", "No", " ", "regex", " ", "matche", "d", " ", "the", " ", "url", " ", "%", "s", "'_", "%_", "(_", "url_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "queryset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "meta_", "._", "model_", "._", "\\u", "default", "\\u", "manager_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "object_", "(_", "self_", ",_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Field", "s", " ", "to", " ", "match", " ", "is", " ", "a", " ", "mapping", " ", "of", " ", "url", " ", "params", " ", "to", " ", "fields", ",", " ", "so", " ", "for", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "photo", "s", " ", "example", " ", "above", ",", " ", "it", " ", "wou", "ld", " ", "be", ":", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "fields", "\\u", "to", "\\u", "match", " ", "=", " ", "{", " ", "'", "object\\u", "id", "':", " ", "'", "id", "'", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "procedure", " ", "parse", "s", " ", "out", " ", "named", " ", "params", " ", "from", " ", "a", " ", "URL", " ", "and", " ", "then", " ", "use", "s", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "fields", "\\u", "to", "\\u", "match", " ", "dictionar", "y", " ", "to", " ", "generat", "e", " ", "a", " ", "query", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "=_", "self_", "._", "get", "\\u", "params_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "self_", "._", "\\u", "meta_", "._", "fields", "\\u", "to", "\\u", "match_", "._", "iteritems_", "(_", ")_", ":_", "\\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 ", " _", "query_", "[_", "value_", "]_", "=_", "params_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "OE", "mbed", "Exception_", "(_", "'%", "s", " ", "was", " ", "not", " ", "found", " ", "in", " ", "the", " ", "urlpa", "tter", "n", " ", "parameter", "s", ".", " ", " ", "Valid", " ", "names", " ", "are", ":", " ", "%", "s", "'_", "%_", "(_", "key_", ",_", "',", " ", "'_", "._", "join_", "(_", "params_", "._", "keys_", "(_", ")_", ")_", ")_", ")_", "\\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 ", " _", "obj_", "=_", "self_", "._", "get", "\\u", "queryset_", "(_", ")_", "._", "get_", "(_", "**_", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "self_", "._", "\\u", "meta_", "._", "model_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "OE", "mbed", "Exception_", "(_", "'", "Requeste", "d", " ", "object", " ", "not", " ", "found", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "obj_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "render", "\\u", "html_", "(_", "self_", ",_", "obj_", ",_", "context_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Generate", " ", "the", " ", "'", "html", "'", " ", "attribute", " ", "of", " ", "an", " ", "oem", "bed", " ", "resource", " ", "usi", "ng", " ", "a", " ", "template", ".", "\\", "10", ";", " ", " ", " ", " ", "Sort", " ", "of", " ", "a", " ", "coro", "llar", "y", " ", "to", " ", "the", " ", "parser", "'", "s", " ", "render", "\\u", "oem", "bed", " ", "method", ".", " ", " ", "By", " ", "default", ",", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "current", " ", "mapping", " ", "will", " ", "be", " ", "pass", "ed", " ", "in", " ", "as", " ", "the", " ", "context", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "OE", "mbed", " ", "template", "s", " ", "are", " ", "store", "d", " ", "in", ":", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "oem", "bed", "/", "provide", "r", "/", "[", "app", "\\u", "label", "]\\u", "[", "model", "].", "html", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "--", " ", "or", " ", "--", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "oem", "bed", "/", "provide", "r", "/", "media", "\\u", "video", ".", "html", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "provided", "\\u", "context_", "=_", "context_", "or_", "Context_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "=_", "Request", "Context_", "(_", "mock", "\\u", "request_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "update_", "(_", "provided", "\\u", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "context_", "._", "push_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "[_", "self_", "._", "\\u", "meta_", "._", "context", "\\u", "varname_", "]_", "=_", "obj_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rendered_", "=_", "render", "\\u", "to", "\\u", "string_", "(_", "self_", "._", "\\u", "meta_", "._", "template", "\\u", "name_", ",_", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "context_", "._", "pop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "rendered_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "map", "\\u", "attr_", "(_", "self_", ",_", "mapping_", ",_", "attr_", ",_", "obj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "kind", " ", "of", " ", "chees", "y", " ", "method", " ", "tha", "t", " ", "allow", "s", " ", "for", " ", "calla", "bles", " ", "or", " ", "attribute", "s", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "be", " ", "used", " ", "interc", "hang", "abl", "y", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "attr_", "not_", "in_", "mapping_", "and_", "hasattr_", "(_", "self_", ",_", "attr_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "callable_", "(_", "getattr_", "(_", "self_", ",_", "attr_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mapping_", "[_", "attr_", "]_", "=_", "getattr_", "(_", "self_", ",_", "attr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mapping_", "[_", "attr_", "]_", "=_", "getattr_", "(_", "self_", ",_", "attr_", ")_", "(_", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "image_", "(_", "self_", ",_", "obj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", " ", "an", " ", "Image", "File", "Field", " ", "instance", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "meta_", "._", "image", "\\u", "field_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "getattr_", "(_", "obj_", ",_", "self_", "._", "\\u", "meta_", "._", "image", "\\u", "field_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "resize_", "(_", "self_", ",_", "image", "\\u", "field_", ",_", "new", "\\u", "width_", "=_", "None_", ",_", "new", "\\u", "height_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Resize", " ", "an", " ", "image", " ", "to", " ", "the", " ", "'", "best", " ", "fit", "'", " ", "widt", "h", " ", "&", " ", "height", ",", " ", "maintain", "ing", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "scale", " ", "of", " ", "the", " ", "image", ",", " ", "so", " ", "a", " ", "500", "x5", "00", " ", "image", " ", "sized", " ", "to", " ", "300", "x4", "00", "\\", "10", ";", " ", " ", " ", " ", "will", " ", "actual", "ly", " ", "be", " ", "scale", "d", " ", "to", " ", "300", "x3", "00", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Param", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "image", ":", " ", "Image", "Field", "File", " ", "to", " ", "be", " ", "resized", " ", "(", "i", ".", "e", ".", " ", "model", ".", "image", "\\u", "field", ")", "\\", "10", ";", " ", " ", " ", " ", "new", "\\u", "widt", "h", " ", "&", " ", "new", "\\u", "height", ":", " ", "desi", "red", " ", "maxim", "um", "s", " ", "for", " ", "resiz", "ing", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "url", " ", "to", " ", "the", " ", "new", " ", "image", " ", "and", " ", "the", " ", "new", " ", "widt", "h", " ", "&", " ", "height", "\\", "10", ";", " ", " ", " ", " ", "(", "http", "://", "path", "-", "to", "-", "new", "-", "image", ",", " ", "300", ",", " ", "300", ")", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "image", "\\u", "field_", ",_", "Image", "Field", "File_", ")_", "and_", "image", "\\u", "field_", "._", "field_", "._", "widt", "h", "\\u", "field_", "and_", "image", "\\u", "field_", "._", "field_", "._", "height", "\\u", "field_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "use", " ", "model", " ", "fields_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "current", "\\u", "width_", "=_", "getattr_", "(_", "image", "\\u", "field_", "._", "instance_", ",_", "image", "\\u", "field_", "._", "field_", "._", "widt", "h", "\\u", "field_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "current", "\\u", "height_", "=_", "getattr_", "(_", "image", "\\u", "field_", "._", "instance_", ",_", "image", "\\u", "field_", "._", "field_", "._", "height", "\\u", "field_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "use", " ", "PIL_", "\\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 ", " _", "file", "\\u", "obj_", "=_", "storage_", "._", "default", "\\u", "storage_", "._", "open_", "(_", "image", "\\u", "field_", "._", "name_", ",_", "'", "rb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "img", "\\u", "obj_", "=_", "Image_", "._", "open_", "(_", "file", "\\u", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "current", "\\u", "width_", ",_", "current", "\\u", "height_", "=_", "img", "\\u", "obj_", "._", "size_", "\\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 ", " _", "return_", "(_", "image", "\\u", "field_", "._", "url_", ",_", "0_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "dete", "rmin", "e", " ", "if", " ", "resiz", "ing", " ", "need", "s", " ", "to", " ", "be", " ", "don", "e", " ", "(", "will", " ", "not", " ", "scale", " ", "up", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "current", "\\u", "width_", "<_", "new", "\\u", "width_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "new", "\\u", "height_", "or_", "current", "\\u", "height_", "<_", "new", "\\u", "height_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "image", "\\u", "field_", "._", "url_", ",_", "current", "\\u", "width_", ",_", "current", "\\u", "height_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "calcul", "ate", " ", "ratios_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new", "\\u", "width_", ",_", "new", "\\u", "height_", "=_", "scale_", "(_", "current", "\\u", "width_", ",_", "current", "\\u", "height_", ",_", "new", "\\u", "width_", ",_", "new", "\\u", "height_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "use", " ", "the", " ", "image", "\\u", "process", "or", " ", "defin", "ed", " ", "in", " ", "the", " ", "settings", ",", " ", "or", " ", "PI", "L", " ", "by", " ", "default_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "self_", "._", "\\u", "meta_", "._", "image", "\\u", "processor_", "._", "resize_", "(_", "image", "\\u", "field_", ",_", "new", "\\u", "width_", ",_", "new", "\\u", "height_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "resiz", "e\\u", "photo_", "(_", "self_", ",_", "obj_", ",_", "mapping_", ",_", "maxw", "idth_", "=_", "None_", ",_", "max", "height_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", ",_", "width_", ",_", "height_", "=_", "self_", "._", "resize_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "get", "\\u", "image_", "(_", "obj_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "*_", "size", "\\u", "to", "\\u", "nearest_", "(_", "maxw", "idth_", ",_", "max", "height_", ",_", "self_", "._", "\\u", "meta_", "._", "valid", "\\u", "sizes_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mapping_", "._", "update_", "(_", "url_", "=_", "url_", ",_", "width_", "=_", "width_", ",_", "height_", "=_", "height_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "thumbnail_", "(_", "self_", ",_", "obj_", ",_", "mapping_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", ",_", "width_", ",_", "height_", "=_", "self_", "._", "resize_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "get", "\\u", "image_", "(_", "obj_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "*_", "size", "\\u", "to", "\\u", "nearest_", "(_", "allow", "ed", "\\u", "sizes_", "=_", "self_", "._", "\\u", "meta_", "._", "thumbnail", "\\u", "sizes_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mapping_", "._", "update_", "(_", "thumbnail", "\\u", "url_", "=_", "url_", ",_", "thumbnail", "\\u", "width_", "=_", "width_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "thumbnail", "\\u", "height_", "=_", "height_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "preprocess_", "(_", "self_", ",_", "obj_", ",_", "mapping_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Pre", "-", "process", "ing", " ", "hook", ".", " ", " ", "Call", "ed", " ", "by", " ", "map", "\\u", "to", "\\u", "dictionar", "y", "()", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "postprocess", "_", "(_", "self_", ",_", "obj_", ",_", "mapping_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Post", "-", "process", "ing", " ", "hook", ".", " ", " ", "Call", "ed", " ", "by", " ", "map", "\\u", "to", "\\u", "dictionar", "y", "()", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "map", "\\u", "to", "\\u", "dictionary_", "(_", "self_", ",_", "url_", ",_", "obj_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Build", " ", "a", " ", "dictionar", "y", " ", "of", " ", "metadata", " ", "for", " ", "the", " ", "request", "ed", " ", "object", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "maxw", "idth_", "=_", "kwargs_", "._", "get_", "(_", "'", "maxw", "idt", "h", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "height_", "=_", "kwargs_", "._", "get_", "(_", "'", "max", "height", "'_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "provide", "r", "\\u", "url_", ",_", "provide", "r", "\\u", "name_", "=_", "self_", "._", "provide", "r", "\\u", "from", "\\u", "url_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "mapping_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "version", "'_", ":_", "'", "1.0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "url_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "provide", "r", "\\u", "name", "'_", ":_", "provide", "r", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "provide", "r", "\\u", "url", "'_", ":_", "provide", "r", "\\u", "url_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "self_", "._", "resource", "\\u", "type_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "a", " ", "hook_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "preprocess_", "(_", "obj_", ",_", "mapping_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "resiz", "e", " ", "image", " ", "if", " ", "we", " ", "have", " ", "a", " ", "photo", ",", " ", "other", "wis", "e", " ", "use", " ", "the", " ", "give", "n", " ", "maxim", "ums_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "resource", "\\u", "type_", "==_", "'", "photo", "'_", "and_", "self_", "._", "get", "\\u", "image_", "(_", "obj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "resiz", "e\\u", "photo_", "(_", "obj_", ",_", "mapping_", ",_", "maxw", "idth_", ",_", "max", "height_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "resource", "\\u", "type_", "in_", "(_", "'", "video", "'_", ",_", "'", "rich", "'_", ",_", "'", "photo", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "width_", ",_", "height_", "=_", "size", "\\u", "to", "\\u", "nearest_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "maxw", "idth_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "max", "height_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "meta_", "._", "valid", "\\u", "sizes_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "meta_", "._", "force", "\\u", "fit_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mapping_", "._", "update_", "(_", "width_", "=_", "width_", ",_", "height_", "=_", "height_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", " ", "a", " ", "thumbnail_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "get", "\\u", "image_", "(_", "obj_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "thumbnail_", "(_", "obj_", ",_", "mapping_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "map", " ", "attribute", "s", " ", "to", " ", "the", " ", "mapping", " ", "dictionar", "y", ".", " ", " ", "if", " ", "the", " ", "attribute", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "a", " ", "calla", "ble", ",", " ", "it", " ", "must", " ", "have", " ", "an", " ", "argu", "ment", " ", "signa", "ture", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "self", ",", " ", "obj", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "attr_", "in_", "(_", "'", "title", "'_", ",_", "'", "author", "\\u", "name", "'_", ",_", "'", "author", "\\u", "url", "'_", ",_", "'", "html", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "map", "\\u", "attr_", "(_", "mapping_", ",_", "attr_", ",_", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "fix", " ", "any", " ", "urls_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "url", "'_", "in_", "mapping_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mapping_", "[_", "'", "url", "'_", "]_", "=_", "relative", "\\u", "to", "\\u", "full_", "(_", "mapping_", "[_", "'", "url", "'_", "]_", ",_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "thumbnail", "\\u", "url", "'_", "in_", "mapping_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mapping_", "[_", "'", "thumbnail", "\\u", "url", "'_", "]_", "=_", "relative", "\\u", "to", "\\u", "full_", "(_", "mapping_", "[_", "'", "thumbnail", "\\u", "url", "'_", "]_", ",_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "html", "'_", "not_", "in_", "mapping_", "and_", "mapping_", "[_", "'", "type", "'_", "]_", "in_", "(_", "'", "video", "'_", ",_", "'", "rich", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mapping_", "[_", "'", "html", "'_", "]_", "=_", "self_", "._", "render", "\\u", "html_", "(_", "obj_", ",_", "context_", "=_", "Context_", "(_", "mapping_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "a", " ", "hook_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "postprocess", "_", "(_", "obj_", ",_", "mapping_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "mapping_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Provider_", "(_", "Base", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "request", "\\u", "resource_", "(_", "self_", ",_", "url_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Request", " ", "an", " ", "OE", "mbed", "Reso", "urc", "e", " ", "for", " ", "a", " ", "give", "n", " ", "url", ".", " ", " ", "Some", " ", "valid", " ", "keyw", "ord", " ", "args", ":", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "format", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "maxw", "idt", "h", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "max", "height", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "obj_", "=_", "self_", "._", "get", "\\u", "object_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "mapping_", "=_", "self_", "._", "map", "\\u", "to", "\\u", "dictionary_", "(_", "url_", ",_", "obj_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "resource_", "=_", "OE", "mbed", "Resource_", "._", "create_", "(_", "mapping_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "resource_", "._", "content", "\\u", "object_", "=_", "obj_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "resource_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "Dj", "ang", "o", "Date", "Base", "d", "Provider_", "(_", "Dj", "ang", "o", "Provider_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Provider", " ", "for", " ", "Dj", "ang", "o", " ", "model", "s", " ", "tha", "t", " ", "use", " ", "date", "-", "based", " ", "urls", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Date", "Base", "d", "Provider_", "(_", "Dj", "ang", "o", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "validate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Dj", "ang", "o", "Date", "Base", "d", "Provider_", ",_", "self_", ")_", "._", "\\u", "validate_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "self_", "._", "\\u", "meta_", "._", "date", "\\u", "field_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "OE", "mbed", "Exception_", "(_", "'", "date", "\\u", "field", " ", "not", " ", "found", " ", "for", " ", "%", "s", "'_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dj", "ang", "o", "Date", "Base", "d", "Provider_", "(_", "Dj", "ang", "o", "Provider_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "object_", "(_", "self_", ",_", "url_", ",_", "month", "\\u", "format_", "=_", "'%", "b", "'_", ",_", "day", "\\u", "format_", "=_", "'%", "d", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Pars", "es", " ", "the", " ", "date", " ", "from", " ", "a", " ", "url", " ", "and", " ", "use", "s", " ", "it", " ", "in", " ", "the", " ", "query", ".", " ", " ", "For", " ", "object", "s", " ", "whi", "ch", "\\", "10", ";", " ", " ", " ", " ", "are", " ", "unique", " ", "for", " ", "date", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "=_", "self_", "._", "get", "\\u", "params_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "year_", "=_", "params_", "[_", "self_", "._", "\\u", "meta_", "._", "year", "\\u", "part_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "month_", "=_", "params_", "[_", "self_", "._", "\\u", "meta_", "._", "month", "\\u", "part_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "day_", "=_", "params_", "[_", "self_", "._", "\\u", "meta_", "._", "day", "\\u", "part_", "]_", "\\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 ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "named", " ", "lookups", " ", "fail", "ed", ",", " ", "so", " ", "try", " ", "to", " ", "get", " ", "the", " ", "date", " ", "usi", "ng", " ", "the", " ", "first_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "three", " ", "parameters_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "year_", ",_", "month_", ",_", "day_", "=_", "params_", "[_", "'\\u", "0", "'_", "]_", ",_", "params_", "[_", "'\\u", "1", "'_", "]_", ",_", "params_", "[_", "'\\u", "2", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "OE", "mbed", "Exception_", "(_", "'", "Error", " ", "extracti", "ng", " ", "date", " ", "from", " ", "url", " ", "parameter", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tt_", "=_", "time_", "._", "strptime_", "(_", "'%", "s", "-%", "s", "-%", "s", "'_", "%_", "(_", "year_", ",_", "month_", ",_", "day_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'%", "s", "-%", "s", "-%", "s", "'_", "%_", "(_", "'%", "Y", "'_", ",_", "month", "\\u", "format_", ",_", "day", "\\u", "format_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "date_", "=_", "datetime_", "._", "date_", "(_", "*_", "tt_", "[_", ":_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "OE", "mbed", "Exception_", "(_", "'", "Error", " ", "pars", "ing", " ", "date", " ", "from", ":", " ", "%", "s", "'_", "%_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "appl", "y", " ", "the", " ", "date", "-", "specific", " ", "lookups", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "self_", "._", "\\u", "meta_", "._", "model_", "._", "\\u", "meta_", "._", "get", "\\u", "field_", "(_", "self_", "._", "\\u", "meta_", "._", "date", "\\u", "field_", ")_", ",_", "Date", "Time", "Field_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "min", "\\u", "date_", "=_", "datetime_", "._", "datetime_", "._", "combine_", "(_", "date_", ",_", "datetime_", "._", "time_", "._", "min_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "\\u", "date_", "=_", "datetime_", "._", "datetime_", "._", "combine_", "(_", "date_", ",_", "datetime_", "._", "time_", "._", "max_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "{_", "'%", "s", "\\u\\u", "range", "'_", "%_", "self_", "._", "\\u", "meta_", "._", "date", "\\u", "field_", ":_", "(_", "min", "\\u", "date_", ",_", "max", "\\u", "date_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "{_", "self_", "._", "\\u", "meta_", "._", "date", "\\u", "field_", ":_", "date_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "appl", "y", " ", "the", " ", "regular", " ", "search", " ", "lookups", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "self_", "._", "\\u", "meta_", "._", "fields", "\\u", "to", "\\u", "match_", "._", "iteritems_", "(_", ")_", ":_", "\\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 ", " _", "query_", "[_", "value_", "]_", "=_", "params_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "OE", "mbed", "Exception_", "(_", "'%", "s", " ", "was", " ", "not", " ", "found", " ", "in", " ", "the", " ", "urlpa", "tter", "n", " ", "parameter", "s", ".", " ", " ", "Valid", " ", "names", " ", "are", ":", " ", "%", "s", "'_", "%_", "(_", "key_", ",_", "',", " ", "'_", "._", "join_", "(_", "params_", "._", "keys_", "(_", ")_", ")_", ")_", ")_", "\\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 ", " _", "obj_", "=_", "self_", "._", "get", "\\u", "queryset_", "(_", ")_", "._", "get_", "(_", "**_", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "self_", "._", "\\u", "meta_", "._", "model_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "OE", "mbed", "Exception_", "(_", "'", "Requeste", "d", " ", "object", " ", "not", " ", "found", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "obj_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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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 ]
Except block handles 'BaseException'
shellderp/sublime-robot-plugin/lib/robot/variables/__init__.py
[ { "content": "def _set_cli_vars(settings):\n for path, args in settings['VariableFiles']:\n try:\n GLOBAL_VARIABLES.set_from_file(path, args)\n except:\n msg, details = utils.get_error_details()\n LOGGER.error(msg)\n LOGGER.info(details)\n for varstr in settings['Variables']:\n try:\n name, value = varstr.split(':', 1)\n except ValueError:\n name, value = varstr, ''\n GLOBAL_VARIABLES['${%s}' % name] = value", "metadata": "root._set_cli_vars", "header": "['module', '___EOS___']", "index": 61 } ]
[ { "span": "except:", "start_line": 65, "start_column": 8, "end_line": 65, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "set\\u", "cli", "\\u", "vars_", "(_", "settings_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "path_", ",_", "args_", "in_", "settings_", "[_", "'", "Varia", "ble", "Files", "'_", "]_", ":_", "\\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 ", " _", "GLOB", "AL", "\\u", "VARIABLES", "_", "._", "set\\u", "from", "\\u", "file_", "(_", "path_", ",_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", ",_", "details_", "=_", "utils_", "._", "get", "\\u", "error", "\\u", "details_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "LOGGER_", "._", "error_", "(_", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "LOGGER_", "._", "info_", "(_", "details_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "vars", "tr_", "in_", "settings_", "[_", "'", "Varia", "bles", "'_", "]_", ":_", "\\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 ", " _", "name_", ",_", "value_", "=_", "vars", "tr_", "._", "split_", "(_", "':'_", ",_", "1_", ")_", "\\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 ", " _", "name_", ",_", "value_", "=_", "vars", "tr_", ",_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "GLOB", "AL", "\\u", "VARIABLES", "_", "[_", "'$", "{%", "s", "}'_", "%_", "name_", "]_", "=_", "value_" ]
[ 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, 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 ]
Except block handles 'BaseException'
eallik/spinoff/twisted/plugins/startnode.py
[ { "content": " def makeService(self, options):\n actor = options['actor']\n if not actor:\n fatal(\"error: no actor specified\")\n sys.exit(1)\n\n try:\n module_path, actor_cls_name = actor.rsplit('.', 1)\n except ValueError:\n fatal(\"error: invalid path to actor %s\" % actor)\n sys.exit(1)\n\n try:\n mod = __import__(module_path, globals(), locals(), [actor_cls_name], -1)\n except ImportError:\n fatal(\"error: could not import %s:\\n%s\" % (actor, traceback.format_exc()))\n sys.exit(1)\n\n try:\n actor_cls = getattr(mod, actor_cls_name)\n except AttributeError:\n fatal(\"error: no such actor %s\" % actor)\n sys.exit(1)\n\n kwargs = {}\n\n if options['params'] is not _EMPTY:\n params = 'dict(%s)' % (options['params'],)\n try:\n params = eval(params)\n except:\n fatal(\"error: could not parse parameters\")\n sys.exit(1)\n else:\n kwargs['init_params'] = params\n\n if options['message'] is not _EMPTY:\n initial_message = options['message']\n try:\n initial_message = eval(initial_message)\n except:\n fatal(\"error: could not parse initial message\")\n sys.exit(1)\n else:\n kwargs['initial_message'] = initial_message\n\n if options['name']:\n name = options['name']\n if '/' in name:\n fatal(\"invalid name: names cannot contain slashes\")\n sys.exit(1)\n else:\n kwargs['name'] = name\n\n if options['remoting']:\n nodeid = options['remoting']\n try:\n _validate_nodeid(nodeid)\n except TypeError:\n fatal(\"invalid node ID\")\n sys.exit(1)\n else:\n kwargs['nodeid'] = nodeid\n\n kwargs['keep_running'] = options['keeprunning']\n\n m = MultiService()\n actor_runner = ActorRunner(actor_cls, **kwargs)\n actor_runner.setServiceParent(m)\n\n # manhole\n\n if options['remotedebugging']:\n port = options['remotedebuggingport']\n try:\n port = int(port)\n except ValueError:\n fatal(\"Invalid port specified: %r\" % port)\n sys.exit(1)\n\n username = options['remotedebuggingusername']\n password = options['remotedebuggingpassword']\n\n manhole = self.make_manhole_server(port, username, password)\n manhole.setServiceParent(m)\n\n return m", "metadata": "root.ActorRunnerMaker.makeService", "header": "['class', 'ActorRunnerMaker', '(', 'object', ')', ':', '___EOS___']", "index": 56 } ]
[ { "span": "except:", "start_line": 86, "start_column": 12, "end_line": 86, "end_column": 19 }, { "span": "except:", "start_line": 96, "start_column": 12, "end_line": 96, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Act", "or", "Run", "ner", "Maker_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "make", "Service_", "(_", "self_", ",_", "options_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "actor_", "=_", "options_", "[_", "'", "actor", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "actor_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fatal_", "(_", "\"", "error", ":", " ", "no", " ", "actor", " ", "specified", "\"_", ")_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "module", "\\u", "path_", ",_", "actor", "\\u", "cls", "\\u", "name_", "=_", "actor_", "._", "rsplit_", "(_", "'.'_", ",_", "1_", ")_", "\\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 ", " _", "fatal_", "(_", "\"", "error", ":", " ", "invalid", " ", "path", " ", "to", " ", "actor", " ", "%", "s", "\"_", "%_", "actor_", ")_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mod_", "=_", "\\u\\u", "import\\u\\u_", "(_", "module", "\\u", "path_", ",_", "globals_", "(_", ")_", ",_", "locals_", "(_", ")_", ",_", "[_", "actor", "\\u", "cls", "\\u", "name_", "]_", ",_", "-_", "1_", ")_", "\\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 ", " _", "fatal_", "(_", "\"", "error", ":", " ", "coul", "d", " ", "not", " ", "import", " ", "%", "s", ":\\\\", "n", "%", "s", "\"_", "%_", "(_", "actor_", ",_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", ")_", ")_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "actor", "\\u", "cls_", "=_", "getattr_", "(_", "mod_", ",_", "actor", "\\u", "cls", "\\u", "name_", ")_", "\\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 ", " _", "fatal_", "(_", "\"", "error", ":", " ", "no", " ", "suc", "h", " ", "actor", " ", "%", "s", "\"_", "%_", "actor_", ")_", "\\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_", "kwargs_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "options_", "[_", "'", "params", "'_", "]_", "is_", "not_", "\\u", "EMPTY_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "=_", "'", "dict", "(%", "s", ")'_", "%_", "(_", "options_", "[_", "'", "params", "'_", "]_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "=_", "eval_", "(_", "params_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fatal_", "(_", "\"", "error", ":", " ", "coul", "d", " ", "not", " ", "parse", " ", "parameter", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "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 ", " _", "kwargs_", "[_", "'", "init", "\\u", "params", "'_", "]_", "=_", "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_", "if_", "options_", "[_", "'", "message", "'_", "]_", "is_", "not_", "\\u", "EMPTY_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial", "\\u", "message_", "=_", "options_", "[_", "'", "message", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "initial", "\\u", "message_", "=_", "eval_", "(_", "initial", "\\u", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fatal_", "(_", "\"", "error", ":", " ", "coul", "d", " ", "not", " ", "parse", " ", "initial", " ", "message", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "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 ", " _", "kwargs_", "[_", "'", "initial", "\\u", "message", "'_", "]_", "=_", "initial", "\\u", "message_", "\\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_", "options_", "[_", "'", "name", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "options_", "[_", "'", "name", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'/'_", "in_", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fatal_", "(_", "\"", "invalid", " ", "name", ":", " ", "names", " ", "cann", "ot", " ", "contain", " ", "slash", "es", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "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 ", " _", "kwargs_", "[_", "'", "name", "'_", "]_", "=_", "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_", "options_", "[_", "'", "remo", "ting", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nodeid_", "=_", "options_", "[_", "'", "remo", "ting", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "validat", "e\\u", "nodeid_", "(_", "nodeid_", ")_", "\\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 ", " _", "fatal_", "(_", "\"", "invalid", " ", "node", " ", "ID", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "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 ", " _", "kwargs_", "[_", "'", "nodeid", "'_", "]_", "=_", "nodeid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "kwargs_", "[_", "'", "keep", "\\u", "runn", "ing", "'_", "]_", "=_", "options_", "[_", "'", "keep", "runn", "ing", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "=_", "Multi", "Service_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "actor", "\\u", "runner_", "=_", "Act", "or", "Runner_", "(_", "actor", "\\u", "cls_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "actor", "\\u", "runner_", "._", "set", "Service", "Parent_", "(_", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "man", "hole_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "options_", "[_", "'", "remote", "debugg", "ing", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "port_", "=_", "options_", "[_", "'", "remote", "debugg", "ing", "port", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "port_", "=_", "int_", "(_", "port_", ")_", "\\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 ", " _", "fatal_", "(_", "\"", "Inva", "lid", " ", "port", " ", "specified", ":", " ", "%", "r", "\"_", "%_", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sys_", "._", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "username_", "=_", "options_", "[_", "'", "remote", "debugg", "ingu", "ser", "name", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "password_", "=_", "options_", "[_", "'", "remote", "debugg", "ing", "password", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "man", "hole_", "=_", "self_", "._", "make", "\\u", "man", "hole", "\\u", "server_", "(_", "port_", ",_", "username_", ",_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "man", "hole_", "._", "set", "Service", "Parent_", "(_", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "m_", "\\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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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 ]
Variable defined multiple times
corelan/dnshjmon/dnshjmon.py
[ { "content": " def initConfigFile(self):\n print \"[+] Creating a new config file.\"\n i_server = \"\"\n i_port = 25\n i_timeout = 300\n i_auth = \"no\"\n i_user = \"\"\n i_pass = \"\"\n i_from = \"\"\n i_to = \"\"\n i_tls = \"no\"\n\n while True:\n i_server = raw_input(' > Enter smtp mail server IP or hostname: ')\n if not i_server == \"\":\n break\n\n while True:\n i_port = raw_input(' > Enter mail server port (default: 25): ')\n if not str(i_port) == \"\":\n try:\n i_port = int(i_port)\n break\n except:\n continue\n else:\n i_port = 25\n break\n\n while True:\n i_from = raw_input(\" > Enter 'From' email address: \")\n if not i_from == \"\":\n break\n\n while True:\n i_to = raw_input(\" > Enter 'To' email address: \")\n if not i_to == \"\":\n break\n\n while True:\n i_timeout = raw_input(' > Enter mail server timeout (in seconds, default: 300): ')\n if not str(i_timeout) == \"\":\n try:\n i_timeout = int(i_timeout)\n break\n except:\n continue\n else:\n i_timeout = 300\n break\n\n while True:\n i_auth = raw_input(' > Does server require authentication? (yes/no, default: no): ')\n i_auth = i_auth.lower()\n if i_auth == \"\":\n i_auth = \"no\"\n if i_auth in [\"yes\", \"no\"]:\n break\n\n if i_auth == \"yes\":\n while True:\n i_user = raw_input(' > Username: ')\n if not i_user == \"\":\n break\n while True:\n i_pass = raw_input(' > Password: ')\n if not i_pass == \"\":\n break\n\n while True:\n i_tls = raw_input(' > Does server require/support STARTTLS ? (yes/no, default: no): ')\n i_tls = i_tls.lower()\n if i_tls == \"\":\n i_tls = \"no\"\n if i_tls in [\"yes\", \"no\"]:\n break\n\n initserverdata = []\n initserverdata.append(\"server=%s\" % i_server)\n initserverdata.append(\"port=%d\" % i_port)\n initserverdata.append(\"from=%s\" % i_from)\n initserverdata.append(\"to=%s\" % i_to)\n initserverdata.append(\"timeout=%d\" % i_timeout)\n initserverdata.append(\"auth=%s\" % i_auth)\n initserverdata.append(\"user=%s\" % i_user)\n initserverdata.append(\"pass=%s\" % i_pass)\n initserverdata.append(\"tls=%s\" % i_tls)\n\n self.serverinfo = {}\n self.serverinfo[i_server] = initserverdata\n self.writeConfigFile()\n return", "metadata": "root.MailConfig.initConfigFile", "header": "['class', 'MailConfig', ':', '___EOS___']", "index": 250 } ]
[ { "span": "i_port ", "start_line": 253, "start_column": 8, "end_line": 253, "end_column": 14 }, { "span": "i_timeout ", "start_line": 254, "start_column": 8, "end_line": 254, "end_column": 17 }, { "span": "i_auth ", "start_line": 255, "start_column": 8, "end_line": 255, "end_column": 14 }, { "span": "i_tls ", "start_line": 260, "start_column": 8, "end_line": 260, "end_column": 13 } ]
[ { "span": "i_port ", "start_line": 268, "start_column": 12, "end_line": 268, "end_column": 18 }, { "span": "i_timeout ", "start_line": 290, "start_column": 12, "end_line": 290, "end_column": 21 }, { "span": "i_auth ", "start_line": 302, "start_column": 12, "end_line": 302, "end_column": 18 }, { "span": "i_tls ", "start_line": 320, "start_column": 12, "end_line": 320, "end_column": 17 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "class_", "Mail", "Config_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "init", "Config", "File_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "\"[", "+]", " ", "Creat", "ing", " ", "a", " ", "new", " ", "config", " ", "file", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i", "\\u", "server_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i", "\\u", "port_", "=_", "25_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i", "\\u", "timeout_", "=_", "300_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i", "\\u", "auth_", "=_", "\"", "no", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i", "\\u", "user_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i", "\\u", "pass_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i", "\\u", "from_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i", "\\u", "to_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i", "\\u", "tls_", "=_", "\"", "no", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i", "\\u", "server_", "=_", "raw", "\\u", "input_", "(_", "'", " ", " ", " ", " ", ">", " ", "Enter", " ", "smt", "p", " ", "mail", " ", "server", " ", "IP", " ", "or", " ", "host", "name", ":", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "i", "\\u", "server_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i", "\\u", "port_", "=_", "raw", "\\u", "input_", "(_", "'", " ", " ", " ", " ", ">", " ", "Enter", " ", "mail", " ", "server", " ", "port", " ", "(", "default", ":", " ", "25", "):", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "str_", "(_", "i", "\\u", "port_", ")_", "==_", "\"\"_", ":_", "\\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 ", " ", "_", "i", "\\u", "port_", "=_", "int_", "(_", "i", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i", "\\u", "port_", "=_", "25_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i", "\\u", "from_", "=_", "raw", "\\u", "input_", "(_", "\"", " ", " ", " ", " ", ">", " ", "Enter", " ", "'", "Fro", "m", "'", " ", "email", " ", "address", ":", " ", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "i", "\\u", "from_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i", "\\u", "to_", "=_", "raw", "\\u", "input_", "(_", "\"", " ", " ", " ", " ", ">", " ", "Enter", " ", "'", "To", "'", " ", "email", " ", "address", ":", " ", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "i", "\\u", "to_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i", "\\u", "timeout_", "=_", "raw", "\\u", "input_", "(_", "'", " ", " ", " ", " ", ">", " ", "Enter", " ", "mail", " ", "server", " ", "timeo", "ut", " ", "(", "in", " ", "second", "s", ",", " ", "default", ":", " ", "300", "):", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "str_", "(_", "i", "\\u", "timeout_", ")_", "==_", "\"\"_", ":_", "\\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 ", " ", "_", "i", "\\u", "timeout_", "=_", "int_", "(_", "i", "\\u", "timeout_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i", "\\u", "timeout_", "=_", "300_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i", "\\u", "auth_", "=_", "raw", "\\u", "input_", "(_", "'", " ", " ", " ", " ", ">", " ", "Do", "es", " ", "server", " ", "require", " ", "authenticat", "ion", "?", " ", "(", "ye", "s", "/", "no", ",", " ", "default", ":", " ", "no", "):", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i", "\\u", "auth_", "=_", "i", "\\u", "auth_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "i", "\\u", "auth_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i", "\\u", "auth_", "=_", "\"", "no", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "i", "\\u", "auth_", "in_", "[_", "\"", "ye", "s", "\"_", ",_", "\"", "no", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "i", "\\u", "auth_", "==_", "\"", "ye", "s", "\"_", ":_", "\\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 ", " _", "i", "\\u", "user_", "=_", "raw", "\\u", "input_", "(_", "'", " ", " ", " ", " ", ">", " ", "User", "name", ":", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "i", "\\u", "user_", "==_", "\"\"_", ":_", "\\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_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i", "\\u", "pass_", "=_", "raw", "\\u", "input_", "(_", "'", " ", " ", " ", " ", ">", " ", "Passw", "ord", ":", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "i", "\\u", "pass_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "while_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i", "\\u", "tls_", "=_", "raw", "\\u", "input_", "(_", "'", " ", " ", " ", " ", ">", " ", "Do", "es", " ", "server", " ", "require", "/", "support", " ", "START", "TLS", " ", "?", " ", "(", "ye", "s", "/", "no", ",", " ", "default", ":", " ", "no", "):", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i", "\\u", "tls_", "=_", "i", "\\u", "tls_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "i", "\\u", "tls_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i", "\\u", "tls_", "=_", "\"", "no", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "i", "\\u", "tls_", "in_", "[_", "\"", "ye", "s", "\"_", ",_", "\"", "no", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "inits", "erver", "data_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inits", "erver", "data_", "._", "append_", "(_", "\"", "server", "=", "%", "s", "\"_", "%_", "i", "\\u", "server_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inits", "erver", "data_", "._", "append_", "(_", "\"", "port", "=", "%", "d", "\"_", "%_", "i", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inits", "erver", "data_", "._", "append_", "(_", "\"", "from", "=", "%", "s", "\"_", "%_", "i", "\\u", "from_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inits", "erver", "data_", "._", "append_", "(_", "\"", "to", "=", "%", "s", "\"_", "%_", "i", "\\u", "to_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inits", "erver", "data_", "._", "append_", "(_", "\"", "timeo", "ut", "=", "%", "d", "\"_", "%_", "i", "\\u", "timeout_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inits", "erver", "data_", "._", "append_", "(_", "\"", "auth", "=", "%", "s", "\"_", "%_", "i", "\\u", "auth_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inits", "erver", "data_", "._", "append_", "(_", "\"", "user", "=", "%", "s", "\"_", "%_", "i", "\\u", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inits", "erver", "data_", "._", "append_", "(_", "\"", "pass", "=", "%", "s", "\"_", "%_", "i", "\\u", "pass_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inits", "erver", "data_", "._", "append_", "(_", "\"", "tls", "=", "%", "s", "\"_", "%_", "i", "\\u", "tls_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "server", "info_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "server", "info_", "[_", "i", "\\u", "server_", "]_", "=_", "inits", "erver", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "write", "Config", "File_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 0, 1, 1, 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, 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, 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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 ]
Testing equality to None
googlearchive/appengine-crowdguru-python/guru.py
[ { "content": " @classmethod\n def assign_question(cls, user):\n \"\"\"Gets an unanswered question and assigns it to a user to answer.\n\n Args:\n user: datastore_types.IM: The identity of the user to assign a\n question to.\n\n Returns:\n The Question entity assigned to the user, or None if there are no\n unanswered questions.\n \"\"\"\n question = None\n while question is None or user not in question.assignees:\n # Assignments made before this timestamp have expired.\n expiry = (datetime.datetime.now()\n - datetime.timedelta(seconds=MAX_ANSWER_TIME))\n\n # Find a candidate question\n query = cls.query(cls.answerer == None, cls.last_assigned < expiry)\n # If a question has never been assigned, order by when it was asked\n query = query.order(cls.last_assigned, cls.asked)\n candidates = [candidate for candidate in query.fetch(2)\n if candidate.asker != user]\n if not candidates:\n # No valid questions in queue.\n break\n\n # Try and assign it\n question = cls._try_assign(candidates[0].key, user, expiry)\n\n # Expire the assignment after a couple of minutes\n return question", "metadata": "root.Question.assign_question", "header": "['class', 'Question', '(', 'ndb', '.', 'Model', ')', ':', '___EOS___']", "index": 127 }, { "content": " @classmethod\n def get_asked(cls, user):\n \"\"\"Returns the user's outstanding asked question, if any.\n\n Args:\n user: datastore_types.IM: The identity of the user asking.\n\n Returns:\n An unanswered Question entity asked by the user, or None if there\n are no unanswered questions.\n \"\"\"\n query = cls.query(cls.asker == user, cls.answer == None)\n return query.get()", "metadata": "root.Question.get_asked", "header": "['class', 'Question', '(', 'ndb', '.', 'Model', ')', ':', '___EOS___']", "index": 174 }, { "content": " @classmethod\n def get_answering(cls, user):\n \"\"\"Returns the question the user is answering, if any.\n\n Args:\n user: datastore_types.IM: The identity of the user answering.\n\n Returns:\n An unanswered Question entity assigned to the user, or None if there\n are no unanswered questions.\n \"\"\"\n query = cls.query(cls.assignees == user, cls.answer == None)\n return query.get()", "metadata": "root.Question.get_answering", "header": "['class', 'Question', '(', 'ndb', '.', 'Model', ')', ':', '___EOS___']", "index": 188 }, { "content": " def post(self, status):\n \"\"\"POST handler for XMPP presence.\n\n Args:\n status: A string which will be either available or unavailable\n and will indicate the status of the user.\n \"\"\"\n sender = self.request.get('from')\n im_from = datastore_types.IM('xmpp', bare_jid(sender))\n suspend = (status == 'unavailable')\n query = Question.query(Question.asker == im_from,\n Question.answer == None,\n Question.suspended == (not suspend))\n question = query.get()\n if question:\n question.suspended = suspend\n question.put()", "metadata": "root.XmppPresenceHandler.post", "header": "['class', 'XmppPresenceHandler', '(', 'webapp2', '.', 'RequestHandler', ')', ':', '___EOS___']", "index": 325 } ]
[ { "span": "cls.answerer == None,", "start_line": 146, "start_column": 30, "end_line": 146, "end_column": 50 }, { "span": "cls.answer == None)", "start_line": 185, "start_column": 45, "end_line": 185, "end_column": 63 }, { "span": "cls.answer == None)", "start_line": 199, "start_column": 49, "end_line": 199, "end_column": 67 }, { "span": "Question.answer == None,", "start_line": 336, "start_column": 31, "end_line": 336, "end_column": 54 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "class_", "Question_", "(_", "ndb_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "assign", "\\u", "question_", "(_", "cls_", ",_", "user_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Get", "s", " ", "an", " ", "una", "nsw", "ere", "d", " ", "question", " ", "and", " ", "assign", "s", " ", "it", " ", "to", " ", "a", " ", "user", " ", "to", " ", "answer", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "user", ":", " ", "datast", "ore", "\\u", "types", ".", "IM", ":", " ", "The", " ", "identi", "ty", " ", "of", " ", "the", " ", "user", " ", "to", " ", "assign", " ", "a", "\\", "10", ";", " ", " ", " ", " ", "question", " ", "to", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "Quest", "ion", " ", "entity", " ", "assign", "ed", " ", "to", " ", "the", " ", "user", ",", " ", "or", " ", "Non", "e", " ", "if", " ", "there", " ", "are", " ", "no", "\\", "10", ";", " ", " ", " ", " ", "una", "nsw", "ere", "d", " ", "question", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "question_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "question_", "is_", "None_", "or_", "user_", "not_", "in_", "question_", "._", "assignee", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Assign", "ment", "s", " ", "made", " ", "bef", "ore", " ", "this", " ", "timestamp", " ", "have", " ", "expir", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expiry_", "=_", "(_", "datetime_", "._", "datetime_", "._", "now_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "-_", "datetime_", "._", "timedelta_", "(_", "seconds_", "=_", "MAX", "\\u", "ANSWER", "\\u", "TIME_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fin", "d", " ", "a", " ", "candidate", " ", "question_", "\\u\\u\\uNL\\u\\u\\u_", "query_", "=_", "cls_", "._", "query_", "(_", "cls_", "._", "answer", "er_", "==_", "None_", ",_", "cls_", "._", "last", "\\u", "assigned_", "<_", "expiry_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "a", " ", "question", " ", "has", " ", "neve", "r", " ", "bee", "n", " ", "assign", "ed", ",", " ", "order", " ", "by", " ", "whe", "n", " ", "it", " ", "was", " ", "ask", "ed_", "\\u\\u\\uNL\\u\\u\\u_", "query_", "=_", "query_", "._", "order_", "(_", "cls_", "._", "last", "\\u", "assigned_", ",_", "cls_", "._", "ask", "ed_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "candidates_", "=_", "[_", "candidate_", "for_", "candidate_", "in_", "query_", "._", "fetch_", "(_", "2_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "candidate_", "._", "ask", "er_", "!=_", "user_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "candidates_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "No", " ", "valid", " ", "question", "s", " ", "in", " ", "queue", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Tr", "y", " ", "and", " ", "assign", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "question_", "=_", "cls_", "._", "\\u", "try", "\\u", "assign_", "(_", "candidates_", "[_", "0_", "]_", "._", "key_", ",_", "user_", ",_", "expiry_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Expire", " ", "the", " ", "assign", "ment", " ", "after", " ", "a", " ", "couple", " ", "of", " ", "minutes_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "question_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Question_", "(_", "ndb_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "ask", "ed_", "(_", "cls_", ",_", "user_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "the", " ", "user", "'", "s", " ", "outstanding", " ", "ask", "ed", " ", "question", ",", " ", "if", " ", "any", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "user", ":", " ", "datast", "ore", "\\u", "types", ".", "IM", ":", " ", "The", " ", "identi", "ty", " ", "of", " ", "the", " ", "user", " ", "ask", "ing", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "An", " ", "una", "nsw", "ere", "d", " ", "Quest", "ion", " ", "entity", " ", "ask", "ed", " ", "by", " ", "the", " ", "user", ",", " ", "or", " ", "Non", "e", " ", "if", " ", "there", "\\", "10", ";", " ", " ", " ", " ", "are", " ", "no", " ", "una", "nsw", "ere", "d", " ", "question", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "cls_", "._", "query_", "(_", "cls_", "._", "ask", "er_", "==_", "user_", ",_", "cls_", "._", "answer_", "==_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "query_", "._", "get_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Question_", "(_", "ndb_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "answer", "ing_", "(_", "cls_", ",_", "user_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", "s", " ", "the", " ", "question", " ", "the", " ", "user", " ", "is", " ", "answer", "ing", ",", " ", "if", " ", "any", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "user", ":", " ", "datast", "ore", "\\u", "types", ".", "IM", ":", " ", "The", " ", "identi", "ty", " ", "of", " ", "the", " ", "user", " ", "answer", "ing", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "An", " ", "una", "nsw", "ere", "d", " ", "Quest", "ion", " ", "entity", " ", "assign", "ed", " ", "to", " ", "the", " ", "user", ",", " ", "or", " ", "Non", "e", " ", "if", " ", "there", "\\", "10", ";", " ", " ", " ", " ", "are", " ", "no", " ", "una", "nsw", "ere", "d", " ", "question", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "cls_", "._", "query_", "(_", "cls_", "._", "assignee", "s_", "==_", "user_", ",_", "cls_", "._", "answer_", "==_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "query_", "._", "get_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Xm", "pp", "Presence", "Handler_", "(_", "webapp2_", "._", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "post_", "(_", "self_", ",_", "status_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "POST", " ", "handler", " ", "for", " ", "XMPP", " ", "presen", "ce", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "status", ":", " ", "A", " ", "string", " ", "whi", "ch", " ", "will", " ", "be", " ", "eit", "her", " ", "avail", "able", " ", "or", " ", "unava", "ilab", "le", "\\", "10", ";", " ", " ", " ", "and", " ", "will", " ", "indicat", "e", " ", "the", " ", "status", " ", "of", " ", "the", " ", "user", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sender_", "=_", "self_", "._", "request_", "._", "get_", "(_", "'", "from", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "im", "\\u", "from_", "=_", "datast", "ore", "\\u", "types_", "._", "IM", "_", "(_", "'", "xmpp", "'_", ",_", "bare", "\\u", "jid_", "(_", "sender_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "suspend", "_", "=_", "(_", "status_", "==_", "'", "unava", "ilab", "le", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "Question_", "._", "query_", "(_", "Question_", "._", "ask", "er_", "==_", "im", "\\u", "from_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Question_", "._", "answer_", "==_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Question_", "._", "suspended", "_", "==_", "(_", "not_", "suspend", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "question_", "=_", "query_", "._", "get_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "question_", ":_", "\\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, 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 ]
Unused import
enthought/pyface/examples/dock/dock_test2.py
[ { "content": "#-------------------------------------------------------------------------------\n#\n# Test the DockWindow.\n#\n# Written by: David C. Morrill\n#\n# Date: 10/20/2005\n#\n# (c) Copyright 2005 by Enthought, Inc.\n#\n#-------------------------------------------------------------------------------\n\n#-------------------------------------------------------------------------------\n# Imports:\n#-------------------------------------------------------------------------------\n\nimport sys\n\nfrom traits.api \\\n import *\n\nfrom traitsui.api \\\n import *\n\nfrom traitsui.menu \\\n import *\n\n#-------------------------------------------------------------------------------\n# 'TestDock' class:\n#-------------------------------------------------------------------------------\n\n\n#-------------------------------------------------------------------------------\n# Run the test program:\n#-------------------------------------------------------------------------------\n\nif __name__ == '__main__':\n TestDock().configure_traits()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class TestDock ( HasPrivateTraits ):\n\n #---------------------------------------------------------------------------\n # Trait definitions:\n #---------------------------------------------------------------------------\n\n button1 = Button\n button2 = Button\n button3 = Button\n button4 = Button\n button5 = Button\n button6 = Button\n\n #---------------------------------------------------------------------------\n # Traits view definitions:\n #---------------------------------------------------------------------------\n\n view = View( [ 'button1' ],\n [ 'button2' ],\n [ 'button3' ],\n [ 'button4' ],\n [ 'button5' ],\n [ 'button6' ],\n title = 'DockWindow Test',\n resizable = True,\n width = 0.5,\n height = 0.5,\n buttons = NoButtons )", "metadata": "root.TestDock", "header": "['module', '___EOS___']", "index": 31 } ]
[ { "span": "import sys", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 10 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "--------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Test", " ", "the", " ", "Dock", "Window", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Writ", "ten", " ", "by", ":", " ", "Dav", "id", " ", "C", ".", " ", "Mor", "rill", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Date", ":", " ", "10", "/", "20", "/", "2005", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "(", "c", ")", " ", "Copy", "right", " ", "2005", " ", "by", " ", "Ent", "hou", "ght", ",", " ", "Inc", "._", "\\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_", "#", " ", " ", "Imports", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "--------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "traits_", "._", "api_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "traits", "ui_", "._", "api_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "traits", "ui_", "._", "menu_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "--------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "'", "Test", "Dock", "'", " ", "class", ":_", "\\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_", "#", " ", " ", "Run", " ", "the", " ", "test", " ", "program", ":_", "\\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 ", " _", "Test", "Dock", "_", "(_", ")_", "._", "configur", "e\\u", "traits_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Test", "Dock", "_", "(_", "Has", "Priva", "te", "Trait", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Trait", " ", "definit", "ion", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "button", "1_", "=_", "Button_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "button", "2_", "=_", "Button_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "button", "3_", "=_", "Button_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "button", "4_", "=_", "Button_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "button", "5_", "=_", "Button_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "button", "6_", "=_", "Button_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Trait", "s", " ", "view", " ", "definit", "ion", "s", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "view_", "=_", "View_", "(_", "[_", "'", "button", "1", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'", "button", "2", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'", "button", "3", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'", "button", "4", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'", "button", "5", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'", "button", "6", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "title_", "=_", "'", "Dock", "Window", " ", "Test", "'_", ",_",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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 ]
Wrong number of arguments in a call
openstack/bandit/examples/random_module.py
[ { "content": "import random\nimport os\nimport somelib\n\nbad = random.random()\nbad = random.randrange()\nbad = random.randint()\nbad = random.choice()\nbad = random.uniform()\nbad = random.triangular()\n\ngood = os.urandom()\ngood = random.SystemRandom()\n\nunknown = random()\nunknown = somelib.a.random()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "random.randrange()", "start_line": 5, "start_column": 6, "end_line": 5, "end_column": 24 }, { "span": "random.randint()", "start_line": 6, "start_column": 6, "end_line": 6, "end_column": 22 }, { "span": "random.choice()", "start_line": 7, "start_column": 6, "end_line": 7, "end_column": 21 }, { "span": "random.uniform()", "start_line": 8, "start_column": 6, "end_line": 8, "end_column": 22 } ]
[]
1
false
[ "[CLS]_", "Wro", "ng_", "number_", "of_", "arguments_", "in_", "a_", "call_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "random_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "some", "lib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bad_", "=_", "random_", "._", "random_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bad_", "=_", "random_", "._", "randrange_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bad_", "=_", "random_", "._", "randint_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bad_", "=_", "random_", "._", "choice_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bad_", "=_", "random_", "._", "uniform_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bad_", "=_", "random_", "._", "triangular", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "good_", "=_", "os_", "._", "urandom_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "good_", "=_", "random_", "._", "System", "Random_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "unknown_", "=_", "random_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unknown_", "=_", "some", "lib_", "._", "a_", "._", "random_", "(_", ")_" ]
[ 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, 0, 1, 1, 1, 1, 2, 2, 2, 0, 1, 1, 1, 1, 2, 2, 2, 0, 1, 1, 1, 1, 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 ]
Unused local variable
TheSriram/MLT4Trading/Project 3/testlearner.py
[ { "content": "def get_graph_two_plots(x_series,y_series,y1_series,xlabel,ylabel,name_file):\n plt.clf()\n plt.xlabel(xlabel)\n plt.ylabel(ylabel)\n first = plt.plot(x_series,y_series,color='r')\n second = plt.plot(x_series,y1_series,color='b')\n plt.legend([\"Ypredict\",\"Yactual\"])\n plt.savefig(name_file)", "metadata": "root.get_graph_two_plots", "header": "['module', '___EOS___']", "index": 9 }, { "content": "def all_feature_graph(y1,y2,y3,y4,y5,x,xlabel,ylabel,name_file):\n plt.clf()\n plt.xlabel(xlabel)\n plt.ylabel(ylabel)\n first = plt.plot(x,y1)\n second = plt.plot(x,y2)\n third = plt.plot(x,y3)\n fourth = plt.plot(x,y4)\n fifth = plt.plot(x,y5)\n plt.legend([\"mean\",\"stddev\",\"rsi\",\"roc\",\"slope\"])\n plt.savefig(name_file)", "metadata": "root.all_feature_graph", "header": "['module', '___EOS___']", "index": 35 } ]
[ { "span": "first ", "start_line": 13, "start_column": 4, "end_line": 13, "end_column": 9 }, { "span": "second ", "start_line": 14, "start_column": 4, "end_line": 14, "end_column": 10 }, { "span": "first ", "start_line": 39, "start_column": 4, "end_line": 39, "end_column": 9 }, { "span": "second ", "start_line": 40, "start_column": 4, "end_line": 40, "end_column": 10 }, { "span": "third ", "start_line": 41, "start_column": 4, "end_line": 41, "end_column": 9 }, { "span": "fourth ", "start_line": 42, "start_column": 4, "end_line": 42, "end_column": 10 }, { "span": "fifth ", "start_line": 43, "start_column": 4, "end_line": 43, "end_column": 9 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "\\u", "graph", "\\u", "two", "\\u", "plots_", "(_", "x", "\\u", "series_", ",_", "y", "\\u", "series_", ",_", "y1", "\\u", "series_", ",_", "xlabel_", ",_", "ylabel_", ",_", "name", "\\u", "file_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plt_", "._", "clf_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlabel_", "(_", "xlabel_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "ylabel_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first_", "=_", "plt_", "._", "plot_", "(_", "x", "\\u", "series_", ",_", "y", "\\u", "series_", ",_", "color_", "=_", "'", "r", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "second_", "=_", "plt_", "._", "plot_", "(_", "x", "\\u", "series_", ",_", "y1", "\\u", "series_", ",_", "color_", "=_", "'", "b", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "legend_", "(_", "[_", "\"", "Yp", "red", "ict", "\"_", ",_", "\"", "Ya", "ctu", "al", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "savefig_", "(_", "name", "\\u", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "all", "\\u", "feature", "\\u", "graph_", "(_", "y1_", ",_", "y2_", ",_", "y3_", ",_", "y", "4_", ",_", "y", "5_", ",_", "x_", ",_", "xlabel_", ",_", "ylabel_", ",_", "name", "\\u", "file_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plt_", "._", "clf_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "xlabel_", "(_", "xlabel_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "ylabel_", "(_", "ylabel_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "first_", "=_", "plt_", "._", "plot_", "(_", "x_", ",_", "y1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "second_", "=_", "plt_", "._", "plot_", "(_", "x_", ",_", "y2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "third_", "=_", "plt_", "._", "plot_", "(_", "x_", ",_", "y3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fourth", "_", "=_", "plt_", "._", "plot_", "(_", "x_", ",_", "y", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fift", "h_", "=_", "plt_", "._", "plot_", "(_", "x_", ",_", "y", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "legend_", "(_", "[_", "\"", "mean", "\"_", ",_", "\"", "stddev", "\"_", ",_", "\"", "rsi", "\"_", ",_", "\"", "roc", "\"_", ",_", "\"", "slope", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "savefig_", "(_", "name", "\\u", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 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 ]
Unused local variable
kdart/pycopia/core/pycopia/md5lib.py
[ { "content": "def check_md5sums(root=None, failure_cb=_default_failure, progress_cb=None):\n # opens the text file as produced by the md5sum program\n if root is None:\n savedir = root = os.getcwd()\n else:\n savedir = os.getcwd()\n os.chdir(root)\n try:\n try:\n sumfile = SumFile(\"md5sums.txt\")\n except IOError:\n if progress_cb: # verbose...\n print >>sys.stderr, \"No md5sums.txt file found in %r\" % (os.getcwd(),)\n return # skip directories that don't have an md5sums.txt file\n for chash, mode, fname in sumfile.read_records():\n try:\n disp = compare_md5(fname, chash, mode)\n except IOError, err:\n failure_cb(\"%s: %s\" % (fname, err))\n continue\n\n if progress_cb:\n progress_cb(fname, disp)\n if not disp:\n failure_cb(fname)\n finally:\n os.chdir(savedir)", "metadata": "root.check_md5sums", "header": "['module', '___EOS___']", "index": 104 } ]
[ { "span": "root ", "start_line": 107, "start_column": 18, "end_line": 107, "end_column": 22 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "\\u", "md5sum", "s_", "(_", "root_", "=_", "None_", ",_", "fail", "ure", "\\u", "cb_", "=_", "\\u", "default", "\\u", "failure_", ",_", "progress", "\\u", "cb_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "opens", " ", "the", " ", "text", " ", "file", " ", "as", " ", "produce", "d", " ", "by", " ", "the", " ", "md5sum", " ", "program_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "root_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "saved", "ir_", "=_", "root_", "=_", "os_", "._", "getcwd_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "saved", "ir_", "=_", "os_", "._", "getcwd_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "chdir_", "(_", "root_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sum", "file_", "=_", "Sum", "File_", "(_", "\"", "md5sum", "s", ".", "txt", "\"_", ")_", "\\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 ", " _", "if_", "progress", "\\u", "cb_", ":_", "#", " ", "verbo", "se", "..._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", ">>_", "sys_", "._", "stderr_", ",_", "\"", "No", " ", "md5sum", "s", ".", "txt", " ", "file", " ", "found", " ", "in", " ", "%", "r", "\"_", "%_", "(_", "os_", "._", "getcwd_", "(_", ")_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "#", " ", "skip", " ", "director", "ies", " ", "tha", "t", " ", "don", "'", "t", " ", "have", " ", "an", " ", "md5sum", "s", ".", "txt", " ", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "chas", "h_", ",_", "mode_", ",_", "fname_", "in_", "sum", "file_", "._", "read", "\\u", "records_", "(_", ")_", ":_", "\\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 ", " _", "disp_", "=_", "compare", "\\u", "md5_", "(_", "fname_", ",_", "chas", "h_", ",_", "mode_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "IO", "Error_", ",_", "err_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fail", "ure", "\\u", "cb_", "(_", "\"%", "s", ":", " ", "%", "s", "\"_", "%_", "(_", "fname_", ",_", "err_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "progress", "\\u", "cb_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "progress", "\\u", "cb_", "(_", "fname_", ",_", "disp_", ")_", "\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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 ]
Unused import
projectatomic/atomic-reactor/tests/test_tasker.py
[ { "content": "\"\"\"\nCopyright (c) 2015 Red Hat, Inc\nAll rights reserved.\n\nThis software may be modified and distributed under the terms\nof the BSD license. See the LICENSE file for details.\n\"\"\"\n\nfrom __future__ import print_function, unicode_literals\n\nfrom tests.fixtures import temp_image_name\n\nfrom atomic_reactor.core import DockerTasker\nfrom atomic_reactor.util import ImageName, clone_git_repo\nfrom tests.constants import LOCALHOST_REGISTRY, INPUT_IMAGE, DOCKERFILE_GIT, MOCK, COMMAND\nfrom tests.util import requires_internet\n\nimport docker, docker.errors\n\nfrom flexmock import flexmock\nimport pytest\n\nif MOCK:\n from tests.docker_mock import mock_docker\n\ninput_image_name = ImageName.parse(INPUT_IMAGE)\n\n# TEST-SUITE SETUP\n\n\n\n\n\n# TESTS\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def setup_module(module):\n if MOCK:\n return\n d = docker.Client()\n try:\n d.inspect_image(INPUT_IMAGE)\n setattr(module, 'HAS_IMAGE', True)\n except docker.errors.APIError:\n _ = [x for x in d.pull(INPUT_IMAGE, stream=True)]\n setattr(module, 'HAS_IMAGE', False)", "metadata": "root.setup_module", "header": "['module', '___EOS___']", "index": 29 }, { "content": "def teardown_module(module):\n if MOCK:\n return\n if not getattr(module, 'HAS_IMAGE', False):\n d = docker.Client()\n d.remove_image(INPUT_IMAGE)", "metadata": "root.teardown_module", "header": "['module', '___EOS___']", "index": 41 }, { "content": "def test_run():\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n container_id = t.run(input_image_name, command=\"id\")\n try:\n t.wait(container_id)\n finally:\n t.remove_container(container_id)", "metadata": "root.test_run", "header": "['module', '___EOS___']", "index": 51 }, { "content": "def test_run_invalid_command():\n if MOCK:\n mock_docker(should_raise_error={'start': []})\n\n t = DockerTasker()\n try:\n with pytest.raises(docker.errors.APIError):\n t.run(input_image_name, command=COMMAND)\n finally:\n # remove the container\n containers = t.d.containers(all=True)\n container_id = [c for c in containers if c[\"Command\"] == COMMAND][0]['Id']\n t.remove_container(container_id)", "metadata": "root.test_run_invalid_command", "header": "['module', '___EOS___']", "index": 63 }, { "content": "def test_image_exists():\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n assert t.image_exists(input_image_name) is True", "metadata": "root.test_image_exists", "header": "['module', '___EOS___']", "index": 78 }, { "content": "def test_image_doesnt_exist():\n image = \"lerknglekrnglekrnglekrnglekrng\"\n if MOCK:\n mock_docker(should_raise_error={'inspect_image': [image]})\n\n t = DockerTasker()\n assert t.image_exists(image) is False", "metadata": "root.test_image_doesnt_exist", "header": "['module', '___EOS___']", "index": 86 }, { "content": "def test_logs():\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n container_id = t.run(input_image_name, command=\"id\")\n try:\n t.wait(container_id)\n output = t.logs(container_id, stderr=True, stream=False)\n assert \"\\n\".join(output).startswith(\"uid=\")\n finally:\n t.remove_container(container_id)", "metadata": "root.test_logs", "header": "['module', '___EOS___']", "index": 95 }, { "content": "def test_remove_container():\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n container_id = t.run(input_image_name, command=\"id\")\n try:\n t.wait(container_id)\n finally:\n t.remove_container(container_id)", "metadata": "root.test_remove_container", "header": "['module', '___EOS___']", "index": 109 }, { "content": "def test_remove_image(temp_image_name):\n if MOCK:\n mock_docker(inspect_should_fail=True)\n\n t = DockerTasker()\n container_id = t.run(input_image_name, command=\"id\")\n t.wait(container_id)\n image_id = t.commit_container(container_id, image=temp_image_name)\n try:\n t.remove_container(container_id)\n finally:\n t.remove_image(image_id)\n assert not t.image_exists(temp_image_name)", "metadata": "root.test_remove_image", "header": "['module', '___EOS___']", "index": 121 }, { "content": "def test_commit_container(temp_image_name):\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n container_id = t.run(INPUT_IMAGE, command=\"id\")\n t.wait(container_id)\n image_id = t.commit_container(container_id, message=\"test message\", image=temp_image_name)\n try:\n assert t.image_exists(image_id)\n finally:\n t.remove_container(container_id)\n t.remove_image(image_id)", "metadata": "root.test_commit_container", "header": "['module', '___EOS___']", "index": 136 }, { "content": "def test_inspect_image():\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n inspect_data = t.inspect_image(input_image_name)\n assert isinstance(inspect_data, dict)", "metadata": "root.test_inspect_image", "header": "['module', '___EOS___']", "index": 151 }, { "content": "def test_tag_image(temp_image_name):\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n temp_image_name.registry = \"somewhere.example.com\"\n temp_image_name.tag = \"1\"\n img = t.tag_image(INPUT_IMAGE, temp_image_name)\n try:\n assert t.image_exists(temp_image_name)\n assert img == temp_image_name.to_str()\n finally:\n t.remove_image(temp_image_name)", "metadata": "root.test_tag_image", "header": "['module', '___EOS___']", "index": 160 }, { "content": "def test_tag_image_same_name(temp_image_name):\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n temp_image_name.registry = \"somewhere.example.com\"\n temp_image_name.tag = \"1\"\n flexmock(t.d).should_receive('tag').never()\n img = t.tag_image(temp_image_name, temp_image_name.copy())", "metadata": "root.test_tag_image_same_name", "header": "['module', '___EOS___']", "index": 175 }, { "content": "@pytest.mark.parametrize(('should_fail',), [\n (True, ),\n (False, ),\n])\ndef test_push_image(temp_image_name, should_fail):\n if MOCK:\n mock_docker(push_should_fail=should_fail)\n\n t = DockerTasker()\n temp_image_name.registry = LOCALHOST_REGISTRY\n temp_image_name.tag = \"1\"\n t.tag_image(INPUT_IMAGE, temp_image_name)\n if should_fail:\n with pytest.raises(RuntimeError) as exc:\n output = t.push_image(temp_image_name, insecure=True)\n assert \"Failed to push image\" in str(exc)\n else:\n output = t.push_image(temp_image_name, insecure=True)\n assert output is not None\n t.remove_image(temp_image_name)", "metadata": "root.test_push_image", "header": "['module', '___EOS___']", "index": 186 }, { "content": "def test_tag_and_push(temp_image_name):\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n temp_image_name.registry = LOCALHOST_REGISTRY\n temp_image_name.tag = \"1\"\n output = t.tag_and_push_image(INPUT_IMAGE, temp_image_name, insecure=True)\n assert output is not None\n assert t.image_exists(temp_image_name)\n t.remove_image(temp_image_name)", "metadata": "root.test_tag_and_push", "header": "['module', '___EOS___']", "index": 208 }, { "content": "def test_pull_image():\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n local_img = input_image_name\n remote_img = local_img.copy()\n remote_img.registry = LOCALHOST_REGISTRY\n t.tag_and_push_image(local_img, remote_img, insecure=True)\n got_image = t.pull_image(remote_img, insecure=True)\n assert remote_img.to_str() == got_image\n assert len(t.last_logs) > 0\n t.remove_image(remote_img)", "metadata": "root.test_pull_image", "header": "['module', '___EOS___']", "index": 221 }, { "content": "def test_get_image_info_by_id_nonexistent():\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n response = t.get_image_info_by_image_id(\"asd\")\n assert response is None", "metadata": "root.test_get_image_info_by_id_nonexistent", "header": "['module', '___EOS___']", "index": 236 }, { "content": "def test_get_image_info_by_id():\n if MOCK:\n mock_docker(provided_image_repotags=input_image_name.to_str())\n\n t = DockerTasker()\n image_id = t.get_image_info_by_image_name(input_image_name)[0]['Id']\n response = t.get_image_info_by_image_id(image_id)\n assert isinstance(response, dict)", "metadata": "root.test_get_image_info_by_id", "header": "['module', '___EOS___']", "index": 245 }, { "content": "def test_get_image_info_by_name_tag_in_name():\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n response = t.get_image_info_by_image_name(input_image_name)\n assert len(response) == 1", "metadata": "root.test_get_image_info_by_name_tag_in_name", "header": "['module', '___EOS___']", "index": 255 }, { "content": "def test_get_image_info_by_name_tag_in_name_nonexisten(temp_image_name):\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n response = t.get_image_info_by_image_name(temp_image_name)\n assert len(response) == 0", "metadata": "root.test_get_image_info_by_name_tag_in_name_nonexisten", "header": "['module', '___EOS___']", "index": 264 }, { "content": "@requires_internet\ndef test_build_image_from_path(tmpdir, temp_image_name):\n if MOCK:\n mock_docker()\n\n tmpdir_path = str(tmpdir.realpath())\n clone_git_repo(DOCKERFILE_GIT, tmpdir_path)\n df = tmpdir.join(\"Dockerfile\")\n assert df.check()\n t = DockerTasker()\n response = t.build_image_from_path(tmpdir_path, temp_image_name, use_cache=True)\n list(response)\n assert response is not None\n assert t.image_exists(temp_image_name)\n t.remove_image(temp_image_name)", "metadata": "root.test_build_image_from_path", "header": "['module', '___EOS___']", "index": 273 }, { "content": "@requires_internet\ndef test_build_image_from_git(temp_image_name):\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n response = t.build_image_from_git(DOCKERFILE_GIT, temp_image_name, use_cache=True)\n list(response)\n assert response is not None\n assert t.image_exists(temp_image_name)\n t.remove_image(temp_image_name)", "metadata": "root.test_build_image_from_git", "header": "['module', '___EOS___']", "index": 290 }, { "content": "def test_get_info():\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n response = t.get_info()\n assert isinstance(response, dict)", "metadata": "root.test_get_info", "header": "['module', '___EOS___']", "index": 303 }, { "content": "def test_get_version():\n if MOCK:\n mock_docker()\n\n t = DockerTasker()\n response = t.get_info()\n assert isinstance(response, dict)", "metadata": "root.test_get_version", "header": "['module', '___EOS___']", "index": 312 }, { "content": "@pytest.mark.parametrize(('timeout', 'expected_timeout'), [\n (None, 120),\n (60, 60),\n])\ndef test_timeout(timeout, expected_timeout):\n (flexmock(docker.Client)\n .should_receive('__init__')\n .with_args(version=str, timeout=expected_timeout))\n\n kwargs = {}\n if timeout is not None:\n kwargs['timeout'] = timeout\n\n t = DockerTasker(**kwargs)", "metadata": "root.test_timeout", "header": "['module', '___EOS___']", "index": 321 } ]
[ { "span": "from tests.fixtures import temp_image_name", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 42 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Copy", "right", " ", "(", "c", ")", " ", "201", "5", " ", "Red", " ", "Hat", ",", " ", "Inc", "\\", "10", ";", "All", " ", "rights", " ", "reserve", "d", ".", "\\", "10", ";", "\\", "10", ";", "Thi", "s", " ", "software", " ", "may", " ", "be", " ", "modifi", "ed", " ", "and", " ", "distributed", " ", "under", " ", "the", " ", "term", "s", "\\", "10", ";", "of", " ", "the", " ", "BS", "D", " ", "license", ".", " ", "See", " ", "the", " ", "LICENSE", " ", "file", " ", "for", " ", "deta", "il", "s", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "print", "\\u", "function_", ",_", "unicode", "\\u", "literals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "tests_", "._", "fixtures_", "import_", "temp", "\\u", "image", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "atomi", "c\\u", "reactor_", "._", "core_", "import_", "Docke", "r", "Task", "er_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "atomi", "c\\u", "reactor_", "._", "util_", "import_", "Image", "Name_", ",_", "clone", "\\u", "git", "\\u", "repo_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tests_", "._", "constants_", "import_", "LOCAL", "HOST", "\\u", "REGISTRY", "_", ",_", "INPUT", "\\u", "IMAGE_", ",_", "DOCKER", "FILE", "\\u", "GIT", "_", ",_", "MOC", "K_", ",_", "COMMAND_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tests_", "._", "util_", "import_", "require", "s", "\\u", "internet_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "docker_", ",_", "docker_", "._", "errors_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "flex", "mock_", "import_", "flex", "mock_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pytest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "tests_", "._", "docker", "\\u", "mock_", "import_", "mock", "\\u", "docker_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "input", "\\u", "image", "\\u", "name_", "=_", "Image", "Name_", "._", "parse_", "(_", "INPUT", "\\u", "IMAGE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TEST", "-", "SUITE", " ", "SETUP", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TESTS_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "setup", "\\u", "module_", "(_", "module_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\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_", "d_", "=_", "docker_", "._", "Client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d_", "._", "inspect", "\\u", "image_", "(_", "INPUT", "\\u", "IMAGE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "setattr_", "(_", "module_", ",_", "'", "HAS", "\\u", "IMA", "GE", "'_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "docker_", "._", "errors_", "._", "API", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u_", "=_", "[_", "x_", "for_", "x_", "in_", "d_", "._", "pull_", "(_", "INPUT", "\\u", "IMAGE_", ",_", "stream_", "=_", "True_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "setattr_", "(_", "module_", ",_", "'", "HAS", "\\u", "IMA", "GE", "'_", ",_", "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_", "tear", "down", "\\u", "module_", "(_", "module_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "getattr_", "(_", "module_", ",_", "'", "HAS", "\\u", "IMA", "GE", "'_", ",_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d_", "=_", "docker_", "._", "Client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "._", "remove", "\\u", "image_", "(_", "INPUT", "\\u", "IMAGE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\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", "run_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "container", "\\u", "id_", "=_", "t_", "._", "run_", "(_", "input", "\\u", "image", "\\u", "name_", ",_", "command_", "=_", "\"", "id", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "._", "wait_", "(_", "container", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "._", "remove", "\\u", "container_", "(_", "container", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "run", "\\u", "invalid", "\\u", "command_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", "shou", "ld", "\\u", "raise", "\\u", "error_", "=_", "{_", "'", "start", "'_", ":_", "[_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "pytest_", "._", "raises_", "(_", "docker_", "._", "errors_", "._", "API", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "._", "run_", "(_", "input", "\\u", "image", "\\u", "name_", ",_", "command_", "=_", "COMMAND_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "remove", " ", "the", " ", "container_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "containers_", "=_", "t_", "._", "d_", "._", "containers_", "(_", "all_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "container", "\\u", "id_", "=_", "[_", "c_", "for_", "c_", "in_", "containers_", "if_", "c_", "[_", "\"", "Command", "\"_", "]_", "==_", "COMMAND_", "]_", "[_", "0_", "]_", "[_", "'", "Id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "remove", "\\u", "container_", "(_", "container", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "image", "\\u", "exists_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "t_", "._", "image", "\\u", "exists_", "(_", "input", "\\u", "image", "\\u", "name_", ")_", "is_", "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_", "test\\u", "image", "\\u", "doesnt", "\\u", "exist_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image_", "=_", "\"", "ler", "kn", "gle", "kr", "ngle", "kr", "ngle", "kr", "ngle", "kr", "ng", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", "shou", "ld", "\\u", "raise", "\\u", "error_", "=_", "{_", "'", "inspect", "\\u", "image", "'_", ":_", "[_", "image_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "t_", "._", "image", "\\u", "exists_", "(_", "image_", ")_", "is_", "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_", "test\\u", "logs_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "container", "\\u", "id_", "=_", "t_", "._", "run_", "(_", "input", "\\u", "image", "\\u", "name_", ",_", "command_", "=_", "\"", "id", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "._", "wait_", "(_", "container", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "=_", "t_", "._", "logs_", "(_", "container", "\\u", "id_", ",_", "stderr_", "=_", "True_", ",_", "stream_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"\\\\", "n", "\"_", "._", "join_", "(_", "output_", ")_", "._", "startswith_", "(_", "\"", "uid", "=\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "._", "remove", "\\u", "container_", "(_", "container", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "remove", "\\u", "container_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "container", "\\u", "id_", "=_", "t_", "._", "run_", "(_", "input", "\\u", "image", "\\u", "name_", ",_", "command_", "=_", "\"", "id", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "._", "wait_", "(_", "container", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "._", "remove", "\\u", "container_", "(_", "container", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "remove", "\\u", "image_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", "inspect", "\\u", "shou", "ld", "\\u", "fail_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "container", "\\u", "id_", "=_", "t_", "._", "run_", "(_", "input", "\\u", "image", "\\u", "name_", ",_", "command_", "=_", "\"", "id", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "wait_", "(_", "container", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image", "\\u", "id_", "=_", "t_", "._", "commit", "\\u", "container_", "(_", "container", "\\u", "id_", ",_", "image_", "=_", "temp", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "._", "remove", "\\u", "container_", "(_", "container", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "._", "remove", "\\u", "image_", "(_", "image", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert_", "not_", "t_", "._", "image", "\\u", "exists_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "commit", "\\u", "container_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "container", "\\u", "id_", "=_", "t_", "._", "run_", "(_", "INPUT", "\\u", "IMAGE_", ",_", "command_", "=_", "\"", "id", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "wait_", "(_", "container", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image", "\\u", "id_", "=_", "t_", "._", "commit", "\\u", "container_", "(_", "container", "\\u", "id_", ",_", "message_", "=_", "\"", "test", " ", "message", "\"_", ",_", "image_", "=_", "temp", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "t_", "._", "image", "\\u", "exists_", "(_", "image", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "._", "remove", "\\u", "container_", "(_", "container", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "remove", "\\u", "image_", "(_", "image", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "inspect", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inspect", "\\u", "data_", "=_", "t_", "._", "inspect", "\\u", "image_", "(_", "input", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "isinstance_", "(_", "inspect", "\\u", "data_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "tag", "\\u", "image_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "\\u", "image", "\\u", "name_", "._", "registry_", "=_", "\"", "some", "where", ".", "example", ".", "com", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "\\u", "image", "\\u", "name_", "._", "tag_", "=_", "\"", "1", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "img_", "=_", "t_", "._", "tag", "\\u", "image_", "(_", "INPUT", "\\u", "IMAGE_", ",_", "temp", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "t_", "._", "image", "\\u", "exists_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "img_", "==_", "temp", "\\u", "image", "\\u", "name_", "._", "to", "\\u", "str_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "t_", "._", "remove", "\\u", "image_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "tag", "\\u", "image", "\\u", "same", "\\u", "name_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "\\u", "image", "\\u", "name_", "._", "registry_", "=_", "\"", "some", "where", ".", "example", ".", "com", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "\\u", "image", "\\u", "name_", "._", "tag_", "=_", "\"", "1", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "flex", "mock_", "(_", "t_", "._", "d_", ")_", "._", "shou", "ld", "\\u", "receive_", "(_", "'", "tag", "'_", ")_", "._", "neve", "r_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "img_", "=_", "t_", "._", "tag", "\\u", "image_", "(_", "temp", "\\u", "image", "\\u", "name_", ",_", "temp", "\\u", "image", "\\u", "name_", "._", "copy_", "(_", ")_", ")_", "\\u\\u\\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_", "._", "parametrize_", "(_", "(_", "'", "shou", "ld", "\\u", "fail", "'_", ",_", ")_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "True_", ",_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "False_", ",_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "push", "\\u", "image_", "(_", "temp", "\\u", "image", "\\u", "name_", ",_", "shou", "ld", "\\u", "fail_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", "push", "\\u", "shou", "ld", "\\u", "fail_", "=_", "shou", "ld", "\\u", "fail_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "\\u", "image", "\\u", "name_", "._", "registry_", "=_", "LOCAL", "HOST", "\\u", "REGISTRY", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "\\u", "image", "\\u", "name_", "._", "tag_", "=_", "\"", "1", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "tag", "\\u", "image_", "(_", "INPUT", "\\u", "IMAGE_", ",_", "temp", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "shou", "ld", "\\u", "fail_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "pytest_", "._", "raises_", "(_", "Run", "time", "Error_", ")_", "as_", "exc_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "t_", "._", "push", "\\u", "image_", "(_", "temp", "\\u", "image", "\\u", "name_", ",_", "insecure", "_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert_", "\"", "Fail", "ed", " ", "to", " ", "push", " ", "image", "\"_", "in_", "str_", "(_", "exc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "t_", "._", "push", "\\u", "image_", "(_", "temp", "\\u", "image", "\\u", "name_", ",_", "insecure", "_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "output_", "is_", "not_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "._", "remove", "\\u", "image_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "tag", "\\u", "and", "\\u", "push_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "\\u", "image", "\\u", "name_", "._", "registry_", "=_", "LOCAL", "HOST", "\\u", "REGISTRY", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "temp", "\\u", "image", "\\u", "name_", "._", "tag_", "=_", "\"", "1", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "=_", "t_", "._", "tag", "\\u", "and", "\\u", "push", "\\u", "image_", "(_", "INPUT", "\\u", "IMAGE_", ",_", "temp", "\\u", "image", "\\u", "name_", ",_", "insecure", "_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "output_", "is_", "not_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "t_", "._", "image", "\\u", "exists_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "remove", "\\u", "image_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "pull", "\\u", "image_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "local", "\\u", "img_", "=_", "input", "\\u", "image", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remote", "\\u", "img_", "=_", "local", "\\u", "img_", "._", "copy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remote", "\\u", "img_", "._", "registry_", "=_", "LOCAL", "HOST", "\\u", "REGISTRY", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "tag", "\\u", "and", "\\u", "push", "\\u", "image_", "(_", "local", "\\u", "img_", ",_", "remote", "\\u", "img_", ",_", "insecure", "_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "got", "\\u", "image_", "=_", "t_", "._", "pull", "\\u", "image_", "(_", "remote", "\\u", "img_", ",_", "insecure", "_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "remote", "\\u", "img_", "._", "to", "\\u", "str_", "(_", ")_", "==_", "got", "\\u", "image_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "t_", "._", "last", "\\u", "logs_", ")_", ">_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "remove", "\\u", "image_", "(_", "remote", "\\u", "img_", ")_", "\\u\\u\\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", "get", "\\u", "image", "\\u", "info", "\\u", "by", "\\u", "id", "\\u", "nonexist", "ent_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "t_", "._", "get", "\\u", "image", "\\u", "info", "\\u", "by", "\\u", "image", "\\u", "id_", "(_", "\"", "asd", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "response_", "is_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "image", "\\u", "info", "\\u", "by", "\\u", "id_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", "provided", "\\u", "image", "\\u", "repo", "tags_", "=_", "input", "\\u", "image", "\\u", "name_", "._", "to", "\\u", "str_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "image", "\\u", "id_", "=_", "t_", "._", "get", "\\u", "image", "\\u", "info", "\\u", "by", "\\u", "image", "\\u", "name_", "(_", "input", "\\u", "image", "\\u", "name_", ")_", "[_", "0_", "]_", "[_", "'", "Id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "t_", "._", "get", "\\u", "image", "\\u", "info", "\\u", "by", "\\u", "image", "\\u", "id_", "(_", "image", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "isinstance_", "(_", "response_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "image", "\\u", "info", "\\u", "by", "\\u", "name", "\\u", "tag", "\\u", "in", "\\u", "name_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "t_", "._", "get", "\\u", "image", "\\u", "info", "\\u", "by", "\\u", "image", "\\u", "name_", "(_", "input", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "response_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "image", "\\u", "info", "\\u", "by", "\\u", "name", "\\u", "tag", "\\u", "in", "\\u", "name", "\\u", "nonexist", "en_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "t_", "._", "get", "\\u", "image", "\\u", "info", "\\u", "by", "\\u", "image", "\\u", "name_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "response_", ")_", "==_", "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_", "@_", "require", "s", "\\u", "internet_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "build", "\\u", "image", "\\u", "from", "\\u", "path_", "(_", "tmpdir_", ",_", "temp", "\\u", "image", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tmpdir", "\\u", "path_", "=_", "str_", "(_", "tmpdir_", "._", "realpath_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clone", "\\u", "git", "\\u", "repo_", "(_", "DOCKER", "FILE", "\\u", "GIT", "_", ",_", "tmpdir", "\\u", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "df_", "=_", "tmpdir_", "._", "join_", "(_", "\"", "Docke", "rfil", "e", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "df_", "._", "check_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "t_", "._", "build", "\\u", "image", "\\u", "from", "\\u", "path_", "(_", "tmpdir", "\\u", "path_", ",_", "temp", "\\u", "image", "\\u", "name_", ",_", "use", "\\u", "cache_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "list_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "response_", "is_", "not_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "t_", "._", "image", "\\u", "exists_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "remove", "\\u", "image_", "(_", "temp", "\\u", "image", "\\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_", "@_", "require", "s", "\\u", "internet_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "build", "\\u", "image", "\\u", "from", "\\u", "git_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "t_", "._", "build", "\\u", "image", "\\u", "from", "\\u", "git_", "(_", "DOCKER", "FILE", "\\u", "GIT", "_", ",_", "temp", "\\u", "image", "\\u", "name_", ",_", "use", "\\u", "cache_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "list_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "response_", "is_", "not_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "t_", "._", "image", "\\u", "exists_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "remove", "\\u", "image_", "(_", "temp", "\\u", "image", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "info_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "t_", "._", "get", "\\u", "info_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "isinstance_", "(_", "response_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "get", "\\u", "version_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "MOC", "K_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "mock", "\\u", "docker_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "t_", "._", "get", "\\u", "info_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "isinstance_", "(_", "response_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "pytest_", "._", "mark_", "._", "parametrize_", "(_", "(_", "'", "timeo", "ut", "'_", ",_", "'", "expected", "\\u", "timeo", "ut", "'_", ")_", ",_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "None_", ",_", "120_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "60_", ",_", "60_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "timeout_", "(_", "timeout_", ",_", "expected", "\\u", "timeout_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "(_", "flex", "mock_", "(_", "docker_", "._", "Client_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "shou", "ld", "\\u", "receive_", "(_", "'\\u", "\\u", "init", "\\u\\u'_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "._", "with", "\\u", "args_", "(_", "version_", "=_", "str_", ",_", "timeout_", "=_", "expected", "\\u", "timeout_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kwargs_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "timeout_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "[_", "'", "timeo", "ut", "'_", "]_", "=_", "timeout_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "Docke", "r", "Task", "er_", "(_", "**_", "kwargs_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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 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 ]
Unused import
NikolayRag/typeTodo/dbFile.py
[ { "content": "# coding= utf-8\n\nimport re, os, time, codecs, sys, _strptime\n\nif sys.version < '3':\n from task import *\n from c import *\nelse:\n from .task import *\n from .c import *\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class TodoDbFile():\n name= 'File'\n\n dbOk= True\n\n lastId= None\n maxId= 0\n maxIdSaved= 0\n\n settings= None\n parentDB= False\n dbId= None\n\n\n\n#public#\n\n\n\n\n\n# newId() is suited to be called in a short sequence, to iplement lowcost retrying.\n# .lastId holds reserved Id and is cached out if matches _wantedId.\n# Id is initially reserved if _wantedId=0, thich is case on every sequence start.\n#\n# return actually reserved new Id\n#\n# Same is true for other engines.\n\n\n \n\n# decrease stored maxid if it is same as current\n\n\n\n\n\n# fetch all tasks from file\n# also set .maxId from tasks and from '.maxid' file\n", "metadata": "root.TodoDbFile", "header": "['module', '___EOS___']", "index": 11 }, { "content": " def __init__(self, _parentDB, _settings, _dbId):\n self.settings= _settings\n self.parentDB= _parentDB\n self.dbId= _dbId", "metadata": "root.TodoDbFile.__init__", "header": "['class', 'TodoDbFile', '(', ')', ':', '___EOS___']", "index": 24 }, { "content": " def flush(self):\n if not self.parentDB.todoAInited:\n return True\n \n if not self.dbOk:\n print(\"TypeTodo: 'file' db was not properly inited. Saving disabled.\")\n return False\n\n dirty= False\n for iT in self.parentDB.todoA:\n curTodo= self.parentDB.todoA[iT]\n if curTodo.savePending(self.dbId):\n dirty= True\n\n if dirty or self.maxIdSaved!=self.maxId:\n try:\n with codecs.open(self.settings.file, 'w+', 'UTF-8') as f:\n f.write(self.settings.head)\n f.write(\"\\n\")\n\n for iT in sorted(self.parentDB.todoA):\n curTodo= self.parentDB.todoA[iT]\n if curTodo.initial:\n continue\n\n stateSign= curTodo.state\n if stateSign=='': stateSign='-'\n\n lvl= curTodo.lvl\n if curTodo.lvl>=0: lvl= '+' +str(curTodo.lvl)\n\n #runtime GMT time to local\n gmtTime= time.localtime(curTodo.stamp)\n\n f.write(stateSign +', '.join(curTodo.tagsA) +' ' +str(curTodo.id)+ ': ' +' '.join([str(lvl), '\"'+curTodo.fileName+'\"', curTodo.editor, time.strftime('%y/%m/%d %H:%M:%S', gmtTime)]) +\"\\n\\t\" +curTodo.comment +\"\\n\\n\")\n\n f.write('\\nReserved: %d' % self.maxId)\n\n\n except Exception as e:\n print(\"TypeTodo: 'file' db experienced error while flushing\")\n print(e)\n\n return False\n\n\n for iT in self.parentDB.todoA:\n self.parentDB.todoA[iT].setSaved(SAVE_STATES.IDLE, self.dbId)\n\n self.maxIdSaved= self.maxId\n\n return True", "metadata": "root.TodoDbFile.flush", "header": "['class', 'TodoDbFile', '(', ')', ':', '___EOS___']", "index": 32 }, { "content": " def newId(self, _wantedId=0):\n if _wantedId==self.lastId:\n return self.lastId\n\n self.fetch()\n\n self.maxId+= 1\n if _wantedId>self.maxId:\n self.maxId= _wantedId\n \n self.flush()\n\n self.lastId= self.maxId\n\n return self.lastId", "metadata": "root.TodoDbFile.newId", "header": "['class', 'TodoDbFile', '(', ')', ':', '___EOS___']", "index": 96 }, { "content": " def releaseId(self, _atExit=False):\n self.fetch()\n \n if self.lastId==self.maxId:\n if _atExit:\n self.maxId-= 1\n self.flush()\n else:\n self.maxId= 0\n\n self.lastId= None\n\n return True", "metadata": "root.TodoDbFile.releaseId", "header": "['class', 'TodoDbFile', '(', ')', ':', '___EOS___']", "index": 116 }, { "content": " def fetch(self, _id=False):\n if not os.path.isfile(self.settings.file):\n print(\"TypeTodo: 'file' db does not exist, should be created.\")\n return False\n\n\n todoA= {}\n try:\n with codecs.open(self.settings.file, 'r', 'UTF-8') as f:\n ctxTodo= None\n for ln in f:\n ln= ln.splitlines()[0]\n matchParse= RE_TODO_STORED.match(ln)\n if matchParse:\n cId= int(matchParse.group('id'))\n\n if _id and _id!=cId: #pick one\n continue\n\n #file holds local time, need to convert to GMT for runtime\n rxEDate= matchParse.group('editdate')\n rxETime= matchParse.group('edittime')\n rxESecs= matchParse.group('editsecs') or ':00'\n gmtTime= time.mktime (time.strptime('%s %s%s' % (rxEDate, rxETime, rxESecs), '%y/%m/%d %H:%M:%S'))\n\n if cId not in todoA:\n todoA[cId]= TodoTask(cId, self.parentDB.config.projectName, self.parentDB)\n ctxTodo= matchParse\n\n if cId > self.maxId: \n self.maxIdSaved= self.maxId= cId\n continue\n\n if ctxTodo:\n __state= ctxTodo.group('prefix')\n if ctxTodo.group(1)=='-': __state= ''\n matchComment= RE_TODO_STORED_COMMENT.match(ln)\n todoA[int(ctxTodo.group('id'))].set(__state, ctxTodo.group('tags').split(','), int(ctxTodo.group('priority')), ctxTodo.group('context'), matchComment.group('comment'), ctxTodo.group('editor'), gmtTime)\n ctxTodo= None\n continue\n\n\n maxIdParse= RE_TODO_FILE_MAXID.match(ln)\n if maxIdParse:\n cId= int(maxIdParse.group('maxid'))\n if cId > self.maxId:\n self.maxIdSaved= self.maxId= cId\n continue\n\n\n except Exception as e:\n print(\"TypeTodo: 'file' db experienced error while fetching\")\n print(e)\n\n self.dbOk= False\n return False\n\n\n return todoA", "metadata": "root.TodoDbFile.fetch", "header": "['class', 'TodoDbFile', '(', ')', ':', '___EOS___']", "index": 136 } ]
[ { "span": "import re, os, time, codecs, sys, _strptime", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 43 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "codi", "ng", "=", " ", "utf", "-", "8_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "re_", ",_", "os_", ",_", "time_", ",_", "codecs_", ",_", "sys_", ",_", "\\u", "strptime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "sys_", "._", "version_", "<_", "'", "3", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "task_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "c_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "._", "task_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "c_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Todo", "Db", "File_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "'", "File", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "db", "Ok_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "last", "Id_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "Id_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "Id", "Save", "d_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "settings_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent", "DB_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db", "Id_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "public", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "#", " ", " ", " ", "new", "Id", "()", " ", "is", " ", "suit", "ed", " ", "to", " ", "be", " ", "call", "ed", " ", "in", " ", "a", " ", "short", " ", "sequence", ",", " ", "to", " ", "ipl", "ement", " ", "low", "cost", " ", "retrying", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", ".", "last", "Id", " ", "hold", "s", " ", "reserve", "d", " ", "Id", " ", "and", " ", "is", " ", "cache", "d", " ", "out", " ", "if", " ", "matche", "s", " ", "\\u", "want", "ed", "Id", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Id", " ", "is", " ", "initially", " ", "reserve", "d", " ", "if", " ", "\\u", "want", "ed", "Id", "=", "0", ",", " ", "thi", "ch", " ", "is", " ", "case", " ", "on", " ", "every", " ", "sequence", " ", "start", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "return", " ", "actual", "ly", " ", "reserve", "d", " ", "new", " ", "Id_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "Sam", "e", " ", "is", " ", "true", " ", "for", " ", "other", " ", "engines", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "#", " ", " ", " ", "decrease", " ", "store", "d", " ", "maxi", "d", " ", "if", " ", "it", " ", "is", " ", "same", " ", "as", " ", "current_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "#", " ", " ", " ", "fetch", " ", "all", " ", "task", "s", " ", "from", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "als", "o", " ", "set", " ", ".", "max", "Id", " ", "from", " ", "task", "s", " ", "and", " ", "from", " ", "'.", "maxi", "d", "'", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Todo", "Db", "File_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "\\u", "parent", "DB_", ",_", "\\u", "settings_", ",_", "\\u", "db", "Id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "settings_", "=_", "\\u", "settings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parent", "DB_", "=_", "\\u", "parent", "DB_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "db", "Id_", "=_", "\\u", "db", "Id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Todo", "Db", "File_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "flush_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "parent", "DB_", "._", "todo", "AI", "nite", "d_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "db", "Ok_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Type", "Todo", ":", " ", "'", "file", "'", " ", "db", " ", "was", " ", "not", " ", "proper", "ly", " ", "init", "ed", ".", " ", "Sav", "ing", " ", "disable", "d", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "dirty_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i", "T_", "in_", "self_", "._", "parent", "DB_", "._", "todo", "A_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cur", "Todo", "_", "=_", "self_", "._", "parent", "DB_", "._", "todo", "A_", "[_", "i", "T_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "cur", "Todo", "_", "._", "save", "Pend", "ing_", "(_", "self_", "._", "db", "Id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dirty_", "=_", "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_", "dirty_", "or_", "self_", "._", "max", "Id", "Save", "d_", "!=_", "self_", "._", "max", "Id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "codecs_", "._", "open_", "(_", "self_", "._", "settings_", "._", "file_", ",_", "'", "w", "+'_", ",_", "'", "UT", "F", "-", "8", "'_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "f_", "._", "write_", "(_", "self_", "._", "settings_", "._", "head_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f_", "._", "write_", "(_", "\"\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i", "T_", "in_", "sorted_", "(_", "self_", "._", "parent", "DB_", "._", "todo", "A_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "cur", "Todo", "_", "=_", "self_", "._", "parent", "DB_", "._", "todo", "A_", "[_", "i", "T_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "cur", "Todo", "_", "._", "initial_", ":_", "\\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_", "state", "Sign_", "=_", "cur", "Todo", "_", "._", "state_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "state", "Sign_", "==_", "''_", ":_", "state", "Sign_", "=_", "'-'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lvl_", "=_", "cur", "Todo", "_", "._", "lvl_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "cur", "Todo", "_", "._", "lvl_", ">=_", "0_", ":_", "lvl_", "=_", "'+'_", "+_", "str_", "(_", "cur", "Todo", "_", "._", "lvl_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "runt", "ime", " ", "GM", "T", " ", "time", " ", "to", " ", "local_", "\\u\\u\\uNL\\u\\u\\u_", "gmt", "Time_", "=_", "time_", "._", "localtime_", "(_", "cur", "Todo", "_", "._", "stamp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "f_", "._", "write_", "(_", "state", "Sign_", "+_", "',", " ", "'_", "._", "join_", "(_", "cur", "Todo", "_", "._", "tags", "A_", ")_", "+_", "'", " ", "'_", "+_", "str_", "(_", "cur", "Todo", "_", "._", "id_", ")_", "+_", "':", " ", "'_", "+_", "'", " ", "'_", "._", "join_", "(_", "[_", "str_", "(_", "lvl_", ")_", ",_", "'\"'_", "+_", "cur", "Todo", "_", "._", "file", "Name_", "+_", "'\"'_", ",_", "cur", "Todo", "_", "._", "editor_", ",_", "time_", "._", "strftime_", "(_", "'%", "y", "/", "%", "m", "/", "%", "d", " ", "%", "H", ":", "%", "M", ":", "%", "S", "'_", ",_", "gmt", "Time_", ")_", "]_", ")_", "+_", "\"\\\\", "n", "\\\\", "t", "\"_", "+_", "cur", "Todo", "_", "._", "comment_", "+_", "\"\\\\", "n", "\\\\", "n", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f_", "._", "write_", "(_", "'\\\\", "n", "Reserve", "d", ":", " ", "%", "d", "'_", "%_", "self_", "._", "max", "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_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Type", "Todo", ":", " ", "'", "file", "'", " ", "db", " ", "experience", "d", " ", "error", " ", "whi", "le", " ", "flush", "ing", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i", "T_", "in_", "self_", "._", "parent", "DB_", "._", "todo", "A_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "parent", "DB_", "._", "todo", "A_", "[_", "i", "T_", "]_", "._", "set", "Save", "d_", "(_", "SAVE", "\\u", "STATES_", "._", "IDLE", "_", ",_", "self_", "._", "db", "Id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "max", "Id", "Save", "d_", "=_", "self_", "._", "max", "Id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Todo", "Db", "File_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "new", "Id_", "(_", "self_", ",_", "\\u", "want", "ed", "Id_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "\\u", "want", "ed", "Id_", "==_", "self_", "._", "last", "Id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "last", "Id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "fetch_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "max", "Id_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "\\u", "want", "ed", "Id_", ">_", "self_", "._", "max", "Id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "max", "Id_", "=_", "\\u", "want", "ed", "Id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "flush_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "last", "Id_", "=_", "self_", "._", "max", "Id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "self_", "._", "last", "Id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Todo", "Db", "File_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "release", "Id_", "(_", "self_", ",_", "\\u", "at", "Exit_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fetch_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "last", "Id_", "==_", "self_", "._", "max", "Id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "\\u", "at", "Exit_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "max", "Id_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "flush_", "(_", ")_", "\\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_", "._", "max", "Id_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "last", "Id_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Todo", "Db", "File_", "(_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "fetch_", "(_", "self_", ",_", "\\u", "id_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "os_", "._", "path_", "._", "isfile_", "(_", "self_", "._", "settings_", "._", "file_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Type", "Todo", ":", " ", "'", "file", "'", " ", "db", " ", "doe", "s", " ", "not", " ", "exist", ",", " ", "shou", "ld", " ", "be", " ", "created", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "todo", "A_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "codecs_", "._", "open_", "(_", "self_", "._", "settings_", "._", "file_", ",_", "'", "r", "'_", ",_", "'", "UT", "F", "-", "8", "'_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ctx", "Todo", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "ln_", "in_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "ln_", "=_", "ln_", "._", "splitlines_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "match", "Parse_", "=_", "RE", "\\u", "TOD", "O", "\\u", "STORE", "D_", "._", "match_", "(_", "ln_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match", "Parse_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "c", "Id_", "=_", "int_", "(_", "match", "Parse_", "._", "group_", "(_", "'", "id", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "\\u", "id_", "and_", "\\u", "id_", "!=_", "c", "Id_", ":_", "#", "pick", " ", "one_", "\\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_", "#", "file", " ", "hold", "s", " ", "local", " ", "time", ",", " ", "need", " ", "to", " ", "convert", " ", "to", " ", "GM", "T", " ", "for", " ", "runtime_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rx", "ED", "ate_", "=_", "match", "Parse_", "._", "group_", "(_", "'", "edit", "date", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rx", "ET", "ime_", "=_", "match", "Parse_", "._", "group_", "(_", "'", "edit", "time", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rx", "ES", "ecs_", "=_", "match", "Parse_", "._", "group_", "(_", "'", "edits", "ecs", "'_", ")_", "or_", "':", "00", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gmt", "Time_", "=_", "time_", "._", "mktime_", "(_", "time_", "._", "strptime_", "(_", "'%", "s", " ", "%", "s", "%", "s", "'_", "%_", "(_", "rx", "ED", "ate_", ",_", "rx", "ET", "ime_", ",_", "rx", "ES", "ecs_", ")_", ",_", "'%", "y", "/", "%", "m", "/", "%", "d", " ", "%", "H", ":", "%", "M", ":", "%", "S", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "c", "Id_", "not_", "in_", "todo", "A_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "todo", "A_", "[_", "c", "Id_", "]_", "=_", "Todo", "Task_", "(_", "c", "Id_", ",_", "self_", "._", "parent", "DB_", "._", "config_", "._", "project", "Name_", ",_", "self_", "._", "parent", "DB_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ctx", "Todo", "_", "=_", "match", "Parse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "c", "Id_", ">_", "self_", "._", "max", "Id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "max", "Id", "Save", "d_", "=_", "self_", "._", "max", "Id_", "=_", "c", "Id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ctx", "Todo", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "\\u\\u", "state_", "=_", "ctx", "Todo", "_", "._", "group_", "(_", "'", "prefix", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ctx", "Todo", "_", "._", "group_", "(_", "1_", ")_", "==_", "'-'_", ":_", "\\u\\u", "state_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "match", "Comment_", "=_", "RE", "\\u", "TOD", "O", "\\u", "STORE", "D", "\\u", "COMMENT_", "._", "match_", "(_", "ln_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "todo", "A_", "[_", "int_", "(_", "ctx", "Todo", "_", "._", "group_", "(_", "'", "id", "'_", ")_", ")_", "]_", "._", "set_", "(_", "\\u\\u", "state_", ",_", "ctx", "Todo", "_", "._", "group_", "(_", "'", "tags", "'_", ")_", "._", "split_", "(_", "','_", ")_", ",_", "int_", "(_", "ctx", "Todo", "_", "._", "group_", "(_", "'", "priorit", "y", "'_", ")_", ")_", ",_", "ctx", "Todo", "_", "._", "group_", "(_", "'", "context", "'_", ")_", ",_", "match", "Comment_", "._", "group_", "(_", "'", "comment", "'_", ")_", ",_", "ctx", "Todo", "_", "._", "group_", "(_", "'", "editor", "'_", ")_", ",_", "gmt", "Time_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctx", "Todo", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "max", "Id", "Parse_", "=_", "RE", "\\u", "TOD", "O", "\\u", "FILE", "\\u", "MAXI", "D_", "._", "match_", "(_", "ln_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "max", "Id", "Parse_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "c", "Id_", "=_", "int_", "(_", "max", "Id", "Parse_", "._", "group_", "(_", "'", "maxi", "d", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "c", "Id_", ">_", "self_", "._", "max", "Id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "max", "Id", "Save", "d_", "=_", "self_", "._", "max", "Id_", "=_", "c", "Id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Type", "Todo", ":", " ", "'", "file", "'", " ", "db", " ", "experience", "d", " ", "error", " ", "whi", "le", " ", "fetch", "ing", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "e_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "db", "Ok_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\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_", "todo", "A_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Except block handles 'BaseException'
monokrome/django-webbugger/webbugger/views.py
[ { "content": "def trigger(request, target_type, target_id, source_type=None, source_id=None, \n entity_type=None, entity_id=None, ignore_errors=False, pixel=False):\n \"\"\" Takes a set of beaconing criteria and creates a beacon from the current\n request. \"\"\"\n\n target = None\n entity = None\n beacon = None\n source = None\n\n if pixel == False and (target_type is not None and target_id is not None):\n target = get_object_or_404(target_type, pk=target_id)\n\n # If we were passed a valid beacon source, we need to make use of it.\n if source_type is not None and source_id is not None:\n try:\n source = source_type.objects.get(pk=source_id)\n except:\n if ignore_errors is False:\n raise Http404('The specified source could not be retreived.')\n\n # If we were asked to use an entity, do that too.\n if entity_type is not None:\n # The system attempts to use preexisting entities when possible\n if entity_id is not None:\n entity, created = entity_type.objects.get_or_create(pk=entity_id)\n else:\n entity = entity_type()\n\n # TODO: Find a better name for beacon_update. update is too generic.\n if hasattr(entity, 'beacon_update') and callable(entity.beacon_update):\n entity.beacon_update(request)\n\n entity.save()\n\n # Generate an argument list for unpacking into our class constructor later\n beacon_arguments = {}\n\n # If we need to supply a target for this tracking instance, supply it.\n if target is not None:\n beacon_arguments.update({\n 'target_type': ContentType.objects.get_for_model(target_type),\n 'target_id': target.pk,\n })\n\n # Sometimes people want a bug and they don't need to link it to a source.\n if source is not None:\n beacon_arguments.update({\n 'source_type': ContentType.objects.get_for_model(source_type),\n 'source_id': source.pk,\n })\n\n # Sometimes a more descript entity isn't needed to webbug our entity\n if entity is not None:\n beacon_arguments.update({\n 'entity_type': ContentType.objects.get_for_model(entity_type),\n 'entity_id': entity.pk,\n })\n\n try:\n beacon = Beacon(**beacon_arguments)\n beacon.save()\n except:\n if ignore_errors is False:\n raise Http404('The requested beacon could not be created.')\n\n try:\n if pixel:\n return HttpResponse(base64.decodestring(transparent_gif_contents), mimetype='image/gif')\n else:\n beacon_final_url = beacon.get_absolute_url()\n\n # This will attempt to detect whether or not this URL is part of the current system.\n # If it is part of the current system, we don't need to redirect at all :)\n if getattr(settings, 'IGNORE_LOCAL_REDIRECTS', True):\n resolve_match = resolve(beacon_final_url)\n\n if resolve_match:\n return resolve_match.func(request, *match.args, **match.kwargs)\n\n return HttpResponseRedirect(beacon_final_url)\n except:\n try:\n # Attempt to redirect to the target if the beacon had issues\n return HttpResponseRedirect(target.get_absolute_url())\n except:\n # We can't ignore this error, because we have no valid target\n raise Http404('The specified target was not found.')", "metadata": "root.trigger", "header": "['module', '___EOS___']", "index": 11 } ]
[ { "span": "except:", "start_line": 28, "start_column": 8, "end_line": 28, "end_column": 15 }, { "span": "except:", "start_line": 73, "start_column": 4, "end_line": 73, "end_column": 11 }, { "span": "except:", "start_line": 92, "start_column": 4, "end_line": 92, "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_", "trigger_", "(_", "request_", ",_", "target", "\\u", "type_", ",_", "target", "\\u", "id_", ",_", "source", "\\u", "type_", "=_", "None_", ",_", "source", "\\u", "id_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "entity", "\\u", "type_", "=_", "None_", ",_", "entity", "\\u", "id_", "=_", "None_", ",_", "ignore", "\\u", "errors_", "=_", "False_", ",_", "pixel_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Tak", "es", " ", "a", " ", "set", " ", "of", " ", "beacon", "ing", " ", "crite", "ria", " ", "and", " ", "create", "s", " ", "a", " ", "beacon", " ", "from", " ", "the", " ", "current", "\\", "10", ";", " ", " ", " ", " ", "request", ".", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "target_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "beacon", "_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "source_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "pixel_", "==_", "False_", "and_", "(_", "target", "\\u", "type_", "is_", "not_", "None_", "and_", "target", "\\u", "id_", "is_", "not_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "target_", "=_", "get", "\\u", "object\\u", "or", "\\u", "404_", "(_", "target", "\\u", "type_", ",_", "pk_", "=_", "target", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "we", " ", "wer", "e", " ", "pass", "ed", " ", "a", " ", "valid", " ", "beacon", " ", "source", ",", " ", "we", " ", "need", " ", "to", " ", "make", " ", "use", " ", "of", " ", "it", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "source", "\\u", "type_", "is_", "not_", "None_", "and_", "source", "\\u", "id_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "source_", "=_", "source", "\\u", "type_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "source", "\\u", "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 ", " _", "if_", "ignore", "\\u", "errors_", "is_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", "'", "The", " ", "specified", " ", "source", " ", "coul", "d", " ", "not", " ", "be", " ", "retr", "eive", "d", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "we", " ", "wer", "e", " ", "ask", "ed", " ", "to", " ", "use", " ", "an", " ", "entity", ",", " ", "do", " ", "tha", "t", " ", "too", "._", "\\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_", "entity", "\\u", "type_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "system", " ", "atte", "mpt", "s", " ", "to", " ", "use", " ", "pree", "xist", "ing", " ", "entit", "ies", " ", "whe", "n", " ", "possible_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "entity", "\\u", "id_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "entity_", ",_", "created_", "=_", "entity", "\\u", "type_", "._", "objects_", "._", "get", "\\u", "or", "\\u", "create_", "(_", "pk_", "=_", "entity", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "entity_", "=_", "entity", "\\u", "type_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "Fin", "d", " ", "a", " ", "bett", "er", " ", "name", " ", "for", " ", "beacon", "\\u", "update", ".", " ", "update", " ", "is", " ", "too", " ", "gener", "ic", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "hasattr_", "(_", "entity_", ",_", "'", "beacon", "\\u", "update", "'_", ")_", "and_", "callable_", "(_", "entity_", "._", "beacon", "\\u", "update_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "entity_", "._", "beacon", "\\u", "update_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "entity_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Generate", " ", "an", " ", "argu", "ment", " ", "list", " ", "for", " ", "unpack", "ing", " ", "int", "o", " ", "our", " ", "class", " ", "construct", "or", " ", "later_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "beacon", "\\u", "arguments_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "we", " ", "need", " ", "to", " ", "supply", " ", "a", " ", "target", " ", "for", " ", "this", " ", "track", "ing", " ", "instance", ",", " ", "supply", " ", "it", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "target_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "beacon", "\\u", "arguments_", "._", "update_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "target", "\\u", "type", "'_", ":_", "Conten", "t", "Type_", "._", "objects_", "._", "get", "\\u", "for", "\\u", "model_", "(_", "target", "\\u", "type_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "target", "\\u", "id", "'_", ":_", "target_", "._", "pk_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Some", "times", " ", "people", " ", "want", " ", "a", " ", "bug", " ", "and", " ", "the", "y", " ", "don", "'", "t", " ", "need", " ", "to", " ", "link", " ", "it", " ", "to", " ", "a", " ", "source", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "source_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "beacon", "\\u", "arguments_", "._", "update_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "source", "\\u", "type", "'_", ":_", "Conten", "t", "Type_", "._", "objects_", "._", "get", "\\u", "for", "\\u", "model_", "(_", "source", "\\u", "type_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "source", "\\u", "id", "'_", ":_", "source_", "._", "pk_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Some", "times", " ", "a", " ", "more", " ", "descrip", "t", " ", "entity", " ", "isn", "'", "t", " ", "need", "ed", " ", "to", " ", "web", "bug", " ", "our", " ", "entity_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "entity_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "beacon", "\\u", "arguments_", "._", "update_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "entity", "\\u", "type", "'_", ":_", "Conten", "t", "Type_", "._", "objects_", "._", "get", "\\u", "for", "\\u", "model_", "(_", "entity", "\\u", "type_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "entity", "\\u", "id", "'_", ":_", "entity_", "._", "pk_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "beacon", "_", "=_", "Bea", "con_", "(_", "**_", "beacon", "\\u", "arguments_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "beacon", "_", "._", "save_", "(_", ")_", "\\u\\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_", "ignore", "\\u", "errors_", "is_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", "'", "The", " ", "request", "ed", " ", "beacon", " ", "coul", "d", " ", "not", " ", "be", " ", "created", ".'_", ")_", "\\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 ", " _", "if_", "pixel_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Response_", "(_", "base64_", "._", "decode", "string_", "(_", "transp", "arent", "\\u", "gif", "\\u", "contents_", ")_", ",_", "mimetype_", "=_", "'", "image", "/", "gif", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "beacon", "\\u", "final", "\\u", "url_", "=_", "beacon", "_", "._", "get", "\\u", "abs", "olute", "\\u", "url_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "will", " ", "atte", "mpt", " ", "to", " ", "detect", " ", "whe", "ther", " ", "or", " ", "not", " ", "this", " ", "URL", " ", "is", " ", "part", " ", "of", " ", "the", " ", "current", " ", "system", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "it", " ", "is", " ", "part", " ", "of", " ", "the", " ", "current", " ", "system", ",", " ", "we", " ", "don", "'", "t", " ", "need", " ", "to", " ", "redirec", "t", " ", "at", " ", "all", " ", ":)", "_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "getattr_", "(_", "settings_", ",_", "'", "IGNORE", "\\u", "LOCAL", "\\u", "REDIRECT", "S", "'_", ",_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "resolve", "\\u", "match_", "=_", "resolve_", "(_", "beacon", "\\u", "final", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "resolve", "\\u", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "return_", "resolve", "\\u", "match_", "._", "func_", "(_", "request_", ",_", "*_", "match_", "._", "args_", ",_", "**_", "match_", "._", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Respons", "e", "Redirect_", "(_", "beacon", "\\u", "final", "\\u", "url_", ")_", "\\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 ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Atte", "mpt", " ", "to", " ", "redirec", "t", " ", "to", " ", "the", " ", "target", " ", "if", " ", "the", " ", "beacon", " ", "had", " ", "issues_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Redirect_", "(_", "target_", "._", "get", "\\u", "abs", "olute", "\\u", "url_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "We", " ", "can", "'", "t", " ", "ignore", " ", "this", " ", "error", ",", " ", "bec", "aus", "e", " ", "we", " ", "have", " ", "no", " ", "valid", " ", "target_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Http404_", "(_", "'", "The", " ", "specified", " ", "target", " ", "was", " ", "not", " ", "found", ".'_", ")_" ]
[ 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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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
gulopine/steel/steel/bits/base.py
[ { "content": "import sys\n\nfrom steel import base, fields\n\n__all__ = ['Structure']\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Structure(base.Structure):\n\n", "metadata": "root.Structure", "header": "['module', '___EOS___']", "index": 7 }, { "content": " def __init__(self, *args, **kwargs):\n super(Structure, self).__init__(*args, **kwargs)\n self._bits_left = 0\n self._bit_buffer = 0", "metadata": "root.Structure.__init__", "header": "['class', 'Structure', '(', 'base', '.', 'Structure', ')', ':', '___EOS___']", "index": 8 }, { "content": " def read(self, size=None):\n bit_buffer = self._bit_buffer\n if size > self._bits_left:\n # Read more bytes from the file\n read_size = int(((size - self._bits_left) + 7) / 8)\n field = fields.Integer(size=read_size)\n bytes = self._file.read(read_size)\n value = field.decode(bytes)\n bit_buffer = (bit_buffer << (read_size * 8)) | value\n self._bits_left += read_size * 8\n self._bits_left -= size\n bits = bit_buffer >> self._bits_left\n self._bit_buffer = bit_buffer & (1 << self._bits_left) - 1\n return bits", "metadata": "root.Structure.read", "header": "['class', 'Structure', '(', 'base', '.', 'Structure', ')', ':', '___EOS___']", "index": 13 }, { "content": " def get_raw_bytes(self):\n output = bytearray()\n bits_read = 0\n byte = 0\n for name, field in self.__class__._fields.items():\n if name not in self._raw_values:\n setattr(self, name, getattr(self, name))\n bits_read += field.size\n bits = self._raw_values[name]\n byte = (byte << field.size) + bits\n while bits_read >= 8:\n byte >>= 8\n output.append(byte & 0xFF)\n bits_read -= 8\n return bytes(output)", "metadata": "root.Structure.get_raw_bytes", "header": "['class', 'Structure', '(', 'base', '.', 'Structure', ')', ':', '___EOS___']", "index": 28 } ]
[ { "span": "import sys", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 10 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "steel", "_", "import_", "base_", ",_", "fields_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "all\\u\\u_", "=_", "[_", "'", "Structur", "e", "'_", "]_", "\\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_", "Structure_", "(_", "base_", "._", "Structure_", ")_", ":_", "\\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_", "Structure_", "(_", "base_", "._", "Structure_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Structure_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "bits", "\\u", "left_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "bit", "\\u", "buffer_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Structure_", "(_", "base_", "._", "Structure_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", "self_", ",_", "size_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bit", "\\u", "buffer_", "=_", "self_", "._", "\\u", "bit", "\\u", "buffer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "size_", ">_", "self_", "._", "\\u", "bits", "\\u", "left_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Read", " ", "more", " ", "bytes", " ", "from", " ", "the", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "read", "\\u", "size_", "=_", "int_", "(_", "(_", "(_", "size_", "-_", "self_", "._", "\\u", "bits", "\\u", "left_", ")_", "+_", "7_", ")_", "/_", "8_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "field_", "=_", "fields_", "._", "Integer_", "(_", "size_", "=_", "read", "\\u", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bytes_", "=_", "self_", "._", "\\u", "file_", "._", "read_", "(_", "read", "\\u", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "value_", "=_", "field_", "._", "decode_", "(_", "bytes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bit", "\\u", "buffer_", "=_", "(_", "bit", "\\u", "buffer_", "<<_", "(_", "read", "\\u", "size_", "*_", "8_", ")_", ")_", "|_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "bits", "\\u", "left_", "+=_", "read", "\\u", "size_", "*_", "8_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "bits", "\\u", "left_", "-=_", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bits_", "=_", "bit", "\\u", "buffer_", ">>_", "self_", "._", "\\u", "bits", "\\u", "left_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "bit", "\\u", "buffer_", "=_", "bit", "\\u", "buffer_", "&_", "(_", "1_", "<<_", "self_", "._", "\\u", "bits", "\\u", "left_", ")_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "bits_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Structure_", "(_", "base_", "._", "Structure_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "raw", "\\u", "bytes_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "bytearray_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bits", "\\u", "read_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "byte_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "name_", ",_", "field_", "in_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u", "fields_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "name_", "not_", "in_", "self_", "._", "\\u", "raw", "\\u", "values_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "setattr_", "(_", "self_", ",_", "name_", ",_", "getattr_", "(_", "self_", ",_", "name_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "bits", "\\u", "read_", "+=_", "field_", "._", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bits_", "=_", "self_", "._", "\\u", "raw", "\\u", "values_", "[_", "name_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "byte_", "=_", "(_", "byte_", "<<_", "field_", "._", "size_", ")_", "+_", "bits_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "bits", "\\u", "read_", ">=_", "8_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "byte_", ">>", "=_", "8_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "._", "append_", "(_", "byte_", "&_", "0xFF_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bits", "\\u", "read_", "-=_", "8_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "bytes_", "(_", "output_", ")_" ]
[ 4, 4, 4, 4, 4, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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14-ssl/anglepy/BNModel.py
[ { "content": "import numpy as np\nimport theano\nimport theano.tensor as T\nimport math\nimport theano.compile\nimport anglepy.ndict as ndict\nfrom anglepy.misc import lazytheanofunc\nimport anglepy.logpdfs\nimport inspect\n\n# Model\n ", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class BNModel(object):\n \n \n # NOTE: IT IS ESSENTIAL THAT DICTIONARIES OF SYMBOLIC VARS AND RESPECTIVE NUMPY VALUES HAVE THE SAME KEYS\n # (OTHERWISE FUNCTION ARGUMENTS ARE IN INCORRECT ORDER)\n \n \n # Prediction\n #def distribution(self, w, x, z, name):\n # x, z = self.xz_to_theano(x, z)\n # w, x, z = ndict.ordereddicts((w, x, z))\n # A = self.get_A(x)\n # allvars = w.values() + x.values() + z.values() + [A]\n # return self.f_dists[name](*allvars)\n \n # Numpy <-> Theano var conversion\n \n # A = np.ones((1, n_batch))\n \n # Likelihood: logp(x,z|w)\n \n # Gradient of logp(x,z|w) w.r.t. parameters and latent variables\n \n '''\n # Gradient of logp(x,z|w) w.r.t. parameters\n def dlogpxz_dw(self, w, z, x):\n w, z, x = ndict.ordereddicts((w, z, x))\n r = self.f_dlogpxz_dw(*(w.values() + z.values() + x.values()))\n return r[0], dict(zip(w.keys(), r[1:]))\n \n # Gradient of logp(x,z|w) w.r.t. latent variables\n def dlogpxz_dz(self, w, z, x):\n w, z, x = ndict.ordereddicts((w, z, x))\n r = self.f_dlogpxz_dz(*(w.values() + z.values() + x.values()))\n return r[0], dict(zip(z.keys(), r[1:]))\n '''\n \n # Hessian of logpxz wrt z (works best with n_batch=1)\n\n # Prior: logp(w)\n \n # Gradient of the prior: logp(w)\n \n # MC likelihood: logp(x|w)\n \n # Gradient of MC likelihood logp(x|w) w.r.t. parameters\n \n # Gradient w.r.t. the Fisher divergence\n \n # Helper function that creates tiled version of datapoint 'x' (* n_batch)", "metadata": "root.BNModel", "header": "['module', '___EOS___']", "index": 11 }, { "content": " def __init__(self, theano_warning='raise', hessian=True):\n \n theanofunction = lazytheanofunc('warn', mode='FAST_RUN')\n theanofunction_silent = lazytheanofunc('ignore', mode='FAST_RUN')\n \n # Create theano expressions\n w, x, z = ndict.ordereddicts(self.variables())\n self.var_w, self.var_x, self.var_z, = w, x, z\n \n # Helper variables\n A = T.dmatrix('A')\n self.var_A = A\n \n # Get gradient symbols\n self.allvars = w.values() + x.values() + z.values() + [A] # note: '+' concatenates lists\n self.allvars_keys = w.keys() + x.keys() + z.keys() + ['A']\n \n if False:\n # Put test values\n # needs fully implemented gen_xz(), which is not always the case\n # Also, the FD has no test values\n theano.config.compute_test_value = 'raise'\n _w = self.init_w()\n for i in _w: w[i].tag.test_value = _w[i]\n _x, _z, _ = self.gen_xz(_w, {}, {}, 10)\n _x, _z = self.xz_to_theano(_x, _z)\n for i in _x: x[i].tag.test_value = _x[i]\n for i in _z: z[i].tag.test_value = _z[i]\n \n # TODO: more beautiful/standardized way of setting distributions\n # (should be even simpler then this) \n self.dist_px = {}\n self.dist_pz = {}\n \n logpw, logpx, logpz = self.factors(w, x, z, A)\n self.var_logpw, self.var_logpx, self.var_logpz = logpw, logpx, logpz\n \n # Complete-data likelihood estimate\n logpxz = logpx.sum() + logpz.sum()\n self.f_logpxz = theanofunction(self.allvars, [logpx, logpz])\n \n dlogpxz_dwz = T.grad(logpxz, w.values() + z.values())\n self.f_dlogpxz_dwz = theanofunction(self.allvars, [logpx, logpz] + dlogpxz_dwz)\n #self.f_dlogpxz_dw = theanofunction(allvars, [logpxz] + dlogpxz_dw)\n #self.f_dlogpxz_dz = theanofunction(allvars, [logpxz] + dlogpxz_dz)\n \n # prior\n dlogpw_dw = T.grad(logpw, w.values(), disconnected_inputs='ignore')\n self.f_logpw = theanofunction(w.values(), logpw)\n self.f_dlogpw_dw = theanofunction(w.values(), [logpw] + dlogpw_dw)\n \n if False:\n # MC-LIKELIHOOD\n logpx_max = logpx.max()\n logpxmc = T.log(T.exp(logpx - logpx_max).mean()) + logpx_max\n self.f_logpxmc = theanofunction(self.allvars, logpxmc)\n dlogpxmc_dw = T.grad(logpxmc, w.values(), disconnected_inputs=theano_warning)\n self.f_dlogpxmc_dw = theanofunction(self.allvars, [logpxmc] + dlogpxmc_dw)\n \n if True and len(z) > 0:\n # Fisher divergence (FD)\n gz = T.grad(logpxz, z.values())\n gz2 = [T.dmatrix() for _ in gz]\n fd = 0\n for i in range(len(gz)):\n fd += T.sum((gz[i]-gz2[i])**2)\n dfd_dw = T.grad(fd, w.values())\n self.f_dfd_dw = theanofunction(self.allvars + gz2, [logpx, logpz, fd] + dfd_dw)\n \n if False and hessian:\n # Hessian of logpxz wrt z (works best with n_batch=1)\n hessian_z = theano.gradient.hessian(logpxz, z_concat)\n self.f_hessian_z = theanofunction(self.allvars, hessian_z)", "metadata": "root.BNModel.__init__", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 13 }, { "content": " def variables(self): raise NotImplementedError()", "metadata": "root.BNModel.variables", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 90 }, { "content": " def factors(self): raise NotImplementedError()", "metadata": "root.BNModel.factors", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 91 }, { "content": " def gen_xz(self): raise NotImplementedError()", "metadata": "root.BNModel.gen_xz", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 92 }, { "content": " def init_w(self): raise NotImplementedError()", "metadata": "root.BNModel.init_w", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 93 }, { "content": " def xz_to_theano(self, x, z): return x, z", "metadata": "root.BNModel.xz_to_theano", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 104 }, { "content": " def gwgz_to_numpy(self, gw, gz): return gw, gz", "metadata": "root.BNModel.gwgz_to_numpy", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 105 }, { "content": " def get_A(self, x): return np.ones((1, x.itervalues().next().shape[1]))", "metadata": "root.BNModel.get_A", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 108 }, { "content": " def logpxz(self, w, x, z):\n x, z = self.xz_to_theano(x, z)\n w, z, x = ndict.ordereddicts((w, z, x))\n A = self.get_A(x)\n allvars = w.values() + x.values() + z.values() + [A]\n logpx, logpz = self.f_logpxz(*allvars)\n if np.isnan(logpx).any() or np.isnan(logpz).any():\n print 'v: ', logpx, logpz\n print 'Values:'\n ndict.p(w)\n ndict.p(z)\n raise Exception(\"dlogpxz_dwz(): NaN found in gradients\")\n \n return logpx, logpz", "metadata": "root.BNModel.logpxz", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 111 }, { "content": " def dlogpxz_dwz(self, w, x, z):\n \n x, z = self.xz_to_theano(x, z)\n w, z, x = ndict.ordereddicts((w, z, x))\n A = self.get_A(x)\n allvars = w.values() + x.values() + z.values() + [A]\n \n # Check if keys are correct\n keys = w.keys() + x.keys() + z.keys() + ['A']\n for i in range(len(keys)):\n if keys[i] != self.allvars_keys[i]:\n \"Input values are incorrect!\"\n print 'Input:', keys\n print 'Should be:', self.allvars_keys\n raise Exception()\n \n r = self.f_dlogpxz_dwz(*allvars)\n logpx, logpz, gw, gz = r[0], r[1], dict(zip(w.keys(), r[2:2+len(w)])), dict(zip(z.keys(), r[2+len(w):]))\n \n if ndict.hasNaN(gw) or ndict.hasNaN(gz):\n if True:\n print 'NaN detected in gradients'\n raise Exception()\n for i in gw: gw[i][np.isnan(gw[i])] = 0\n for i in gz: gz[i][np.isnan(gz[i])] = 0\n else:\n print 'logpx: ', logpx\n print 'logpz: ', logpz\n print 'Values:'\n ndict.p(w)\n ndict.p(z)\n print 'Gradients:'\n ndict.p(gw)\n ndict.p(gz)\n raise Exception(\"dlogpxz_dwz(): NaN found in gradients\")\n \n gw, gz = self.gwgz_to_numpy(gw, gz)\n return logpx, logpz, gw, gz", "metadata": "root.BNModel.dlogpxz_dwz", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 127 }, { "content": " def hessian_z(self, w, z, x):\n x, z = self.xz_to_theano(x, z)\n A = self.get_A(x)\n return self.f_hessian_z(*ndict.orderedvals((w, x, z))+[A])", "metadata": "root.BNModel.hessian_z", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 181 }, { "content": " def logpw(self, w):\n logpw = self.f_logpw(*ndict.orderedvals((w,)))\n return logpw", "metadata": "root.BNModel.logpw", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 187 }, { "content": " def dlogpw_dw(self, w):\n w = ndict.ordered(w)\n r = self.f_dlogpw_dw(*(w.values()))\n return r[0], dict(zip(w.keys(), r[1:]))", "metadata": "root.BNModel.dlogpw_dw", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 192 }, { "content": " def logpxmc(self, w, x, n_batch):\n x = self.tiled_x(x, n_batch)\n x, z, _ = self.gen_xz(w, x, {}, n_batch=n_batch)\n x, z = self.xz_to_theano(x, z)\n A = self.get_A(x)\n logpxmc = self.f_logpxmc(*ndict.orderedvals((w, x, z))+[A])\n return logpxmc", "metadata": "root.BNModel.logpxmc", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 198 }, { "content": " def dlogpxmc_dw(self, w, x, n_batch):\n x = self.tiled_x(x, n_batch) \n x, z, _ = self.gen_xz(w, x, {}, n_batch=n_batch)\n x, z = self.xz_to_theano(x, z)\n A = self.get_A(x)\n r = self.f_dlogpxmc_dw(*ndict.orderedvals((w, x, z))+[A])\n return r[0], dict(zip(ndict.ordered(w).keys(), r[1:]))", "metadata": "root.BNModel.dlogpxmc_dw", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 207 }, { "content": " def dfd_dw(self, w, x, z, gz2):\n x, z = self.xz_to_theano(x, z)\n w, z, x, gz2 = ndict.ordereddicts((w, z, x, gz2))\n A = self.get_A(x)\n r = self.f_dfd_dw(*(w.values() + x.values() + z.values() + [A] + gz2.values()))\n logpx, logpz, fd, gw = r[0], r[1], r[2], dict(zip(w.keys(), r[3:3+len(w)]))\n \n if ndict.hasNaN(gw):\n if True:\n print 'NaN detected in gradients'\n raise Exception()\n for i in gw: gw[i][np.isnan(gw[i])] = 0\n else:\n \n print 'fd: ', fd\n print 'Values:'\n ndict.p(w)\n ndict.p(z)\n print 'Gradients:'\n ndict.p(gw)\n raise Exception(\"dfd_dw(): NaN found in gradients\")\n \n gw, _ = self.gwgz_to_numpy(gw, {})\n return logpx, logpz, fd, gw", "metadata": "root.BNModel.dfd_dw", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 216 }, { "content": " def tiled_x(self, x, n_batch):\n x_tiled = {}\n for i in x:\n if (x[i].shape[1] != 1):\n raise Exception(\"{} {} {} \".format(x[i].shape[0], x[i].shape[1], n_batch))\n x_tiled[i] = np.dot(x[i], np.ones((1, n_batch)))\n return x_tiled", "metadata": "root.BNModel.tiled_x", "header": "['class', 'BNModel', '(', 'object', ')', ':', '___EOS___']", "index": 242 } ]
[ { "span": "import math", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 11 }, { "span": "import anglepy.logpdfs", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 22 }, { "span": "import inspect", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 14 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "numpy_", "as_", "np_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "theano_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "theano_", "._", "tensor_", "as_", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "math_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "theano_", "._", "compile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "angle", "py_", "._", "ndi", "ct_", "as_", "ndi", "ct_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "angle", "py_", "._", "misc_", "import_", "lazy", "theano", "func_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "angle", "py_", "._", "logp", "dfs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "inspect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Model_", "\\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_", "BN", "Model_", "(_", "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_", "#", " ", "NOTE", ":", " ", "IT", " ", "IS", " ", "ESS", "ENTI", "AL", " ", "THA", "T", " ", "DICT", "ION", "ARI", "ES", " ", "OF", " ", "SYMBOL", "IC", " ", "VARS", " ", "AND", " ", "RESP", "ECTI", "VE", " ", "NUMP", "Y", " ", "VALU", "ES", " ", "HA", "VE", " ", "THE", " ", "SAM", "E", " ", "KEYS_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "OTHER", "WI", "SE", " ", "FUNC", "TIO", "N", " ", "ARGUMENT", "S", " ", "ARE", " ", "IN", " ", "INC", "OR", "RECT", " ", "ORDE", "R", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Prediction", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "def", " ", "distribu", "tion", "(", "self", ",", " ", "w", ",", " ", "x", ",", " ", "z", ",", " ", "name", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "x", ",", " ", "z", " ", "=", " ", "self", ".", "xz", "\\u", "to", "\\u", "theano", "(", "x", ",", " ", "z", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "w", ",", " ", "x", ",", " ", "z", " ", "=", " ", "ndi", "ct", ".", "order", "eddi", "ct", "s", "((", "w", ",", " ", "x", ",", " ", "z", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "A", " ", "=", " ", "self", ".", "get", "\\u", "A", "(", "x", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "all", "vars", " ", "=", " ", "w", ".", "values", "()", " ", "+", " ", "x", ".", "values", "()", " ", "+", " ", "z", ".", "values", "()", " ", "+", " ", "[", "A", "]_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "return", " ", "self", ".", "f", "\\u", "dists", "[", "name", "](", "*", "all", "vars", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Num", "py", " ", "<-", ">", " ", "The", "ano", " ", "var", " ", "conversion_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "A", " ", "=", " ", "np", ".", "ones", "((", "1", ",", " ", "n", "\\u", "batch", "))", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Likelihood", ":", " ", "logp", "(", "x", ",", "z", "|", "w", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Grad", "ient", " ", "of", " ", "logp", "(", "x", ",", "z", "|", "w", ")", " ", "w", ".", "r", ".", "t", ".", " ", "parameter", "s", " ", "and", " ", "latent", " ", "variables_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "'''", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "Grad", "ient", " ", "of", " ", "logp", "(", "x", ",", "z", "|", "w", ")", " ", "w", ".", "r", ".", "t", ".", " ", "parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "dlo", "gpx", "z", "\\u", "dw", "(", "self", ",", " ", "w", ",", " ", "z", ",", " ", "x", "):", "\\", "10", ";", " ", " ", " ", " ", "w", ",", " ", "z", ",", " ", "x", " ", "=", " ", "ndi", "ct", ".", "order", "eddi", "ct", "s", "((", "w", ",", " ", "z", ",", " ", "x", "))\\", "10", ";", " ", " ", " ", " ", "r", " ", "=", " ", "self", ".", "f", "\\u", "dlo", "gpx", "z", "\\u", "dw", "(*", "(", "w", ".", "values", "()", " ", "+", " ", "z", ".", "values", "()", " ", "+", " ", "x", ".", "values", "())", ")", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "r", "[", "0", "],", " ", "dict", "(", "zip", "(", "w", ".", "keys", "()", ",", " ", "r", "[", "1", ":]", "))\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "Grad", "ient", " ", "of", " ", "logp", "(", "x", ",", "z", "|", "w", ")", " ", "w", ".", "r", ".", "t", ".", " ", "latent", " ", "variab", "les", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "dlo", "gpx", "z", "\\u", "dz", "(", "self", ",", " ", "w", ",", " ", "z", ",", " ", "x", "):", "\\", "10", ";", " ", " ", " ", " ", "w", ",", " ", "z", ",", " ", "x", " ", "=", " ", "ndi", "ct", ".", "order", "eddi", "ct", "s", "((", "w", ",", " ", "z", ",", " ", "x", "))\\", "10", ";", " ", " ", " ", " ", "r", " ", "=", " ", "self", ".", "f", "\\u", "dlo", "gpx", "z", "\\u", "dz", "(*", "(", "w", ".", "values", "()", " ", "+", " ", "z", ".", "values", "()", " ", "+", " ", "x", ".", "values", "())", ")", "\\", "10", ";", " ", " ", " ", " ", "return", " ", "r", "[", "0", "],", " ", "dict", "(", "zip", "(", "z", ".", "keys", "()", ",", " ", "r", "[", "1", ":]", "))\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Hes", "sia", "n", " ", "of", " ", "logp", "xz", " ", "wrt", " ", "z", " ", "(", "works", " ", "best", " ", "with", " ", "n", "\\u", "batch", "=", "1", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Prior", ":", " ", "logp", "(", "w", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Grad", "ient", " ", "of", " ", "the", " ", "prior", ":", " ", "logp", "(", "w", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "MC", " ", "likelihood", ":", " ", "logp", "(", "x", "|", "w", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Grad", "ient", " ", "of", " ", "MC", " ", "likelihood", " ", "logp", "(", "x", "|", "w", ")", " ", "w", ".", "r", ".", "t", ".", " ", "parameters_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Grad", "ient", " ", "w", ".", "r", ".", "t", ".", " ", "the", " ", "Fish", "er", " ", "divergence", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Help", "er", " ", "function", " ", "tha", "t", " ", "create", "s", " ", "tiled", " ", "version", " ", "of", " ", "datapoint", " ", "'", "x", "'", " ", "(*", " ", "n", "\\u", "batch", ")_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "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_", ",_", "theano", "\\u", "warning_", "=_", "'", "raise", "'_", ",_", "hessian", "_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "theano", "function_", "=_", "lazy", "theano", "func_", "(_", "'", "warn", "'_", ",_", "mode_", "=_", "'", "FAST", "\\u", "RUN", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "theano", "function", "\\u", "silent_", "=_", "lazy", "theano", "func_", "(_", "'", "ignore", "'_", ",_", "mode_", "=_", "'", "FAST", "\\u", "RUN", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "theano", " ", "expressions_", "\\u\\u\\uNL\\u\\u\\u_", "w_", ",_", "x_", ",_", "z_", "=_", "ndi", "ct_", "._", "order", "eddi", "cts_", "(_", "self_", "._", "variables_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "var", "\\u", "w_", ",_", "self_", "._", "var", "\\u", "x_", ",_", "self_", "._", "var", "\\u", "z_", ",_", "=_", "w_", ",_", "x_", ",_", "z_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Help", "er", " ", "variables_", "\\u\\u\\uNL\\u\\u\\u_", "A_", "=_", "T_", "._", "dma", "trix_", "(_", "'", "A", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "var", "\\u", "A_", "=_", "A_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "gradi", "ent", " ", "symbols_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "all", "vars_", "=_", "w_", "._", "values_", "(_", ")_", "+_", "x_", "._", "values_", "(_", ")_", "+_", "z_", "._", "values_", "(_", ")_", "+_", "[_", "A_", "]_", "#", " ", "note", ":", " ", "'+", "'", " ", "concatenate", "s", " ", "lists_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "all", "vars", "\\u", "keys_", "=_", "w_", "._", "keys_", "(_", ")_", "+_", "x_", "._", "keys_", "(_", ")_", "+_", "z_", "._", "keys_", "(_", ")_", "+_", "[_", "'", "A", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Put", " ", "test", " ", "values_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "need", "s", " ", "full", "y", " ", "implemented", " ", "gen", "\\u", "xz", "()", ",", " ", "whi", "ch", " ", "is", " ", "not", " ", "alw", "ay", "s", " ", "the", " ", "case_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Al", "so", ",", " ", "the", " ", "FD", " ", "has", " ", "no", " ", "test", " ", "values_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "theano_", "._", "config_", "._", "compute", "\\u", "test\\u", "value_", "=_", "'", "raise", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "w_", "=_", "self_", "._", "init", "\\u", "w_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "\\u", "w_", ":_", "w_", "[_", "i_", "]_", "._", "tag_", "._", "test\\u", "value_", "=_", "\\u", "w_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "x_", ",_", "\\u", "z_", ",_", "\\u_", "=_", "self_", "._", "gen", "\\u", "xz", "_", "(_", "\\u", "w_", ",_", "{_", "}_", ",_", "{_", "}_", ",_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "x_", ",_", "\\u", "z_", "=_", "self_", "._", "xz", "\\u", "to", "\\u", "theano_", "(_", "\\u", "x_", ",_", "\\u", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "\\u", "x_", ":_", "x_", "[_", "i_", "]_", "._", "tag_", "._", "test\\u", "value_", "=_", "\\u", "x_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "\\u", "z_", ":_", "z_", "[_", "i_", "]_", "._", "tag_", "._", "test\\u", "value_", "=_", "\\u", "z_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TOD", "O", ":", " ", "more", " ", "beautif", "ul", "/", "standardize", "d", " ", "way", " ", "of", " ", "setti", "ng", " ", "distributions_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "(", "shou", "ld", " ", "be", " ", "even", " ", "simple", "r", " ", "then", " ", "this", ")", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "dist", "\\u", "px_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "dist", "\\u", "pz", "_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "logp", "w_", ",_", "logp", "x_", ",_", "logp", "z_", "=_", "self_", "._", "factors_", "(_", "w_", ",_", "x_", ",_", "z_", ",_", "A_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "var", "\\u", "logp", "w_", ",_", "self_", "._", "var", "\\u", "logp", "x_", ",_", "self_", "._", "var", "\\u", "logp", "z_", "=_", "logp", "w_", ",_", "logp", "x_", ",_", "logp", "z_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Complete", "-", "data", " ", "likelihood", " ", "estimate_", "\\u\\u\\uNL\\u\\u\\u_", "logp", "xz", "_", "=_", "logp", "x_", "._", "sum_", "(_", ")_", "+_", "logp", "z_", "._", "sum_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "f", "\\u", "logp", "xz", "_", "=_", "theano", "function_", "(_", "self_", "._", "all", "vars_", ",_", "[_", "logp", "x_", ",_", "logp", "z_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "dlo", "gpx", "z", "\\u", "dw", "z_", "=_", "T_", "._", "grad_", "(_", "logp", "xz", "_", ",_", "w_", "._", "values_", "(_", ")_", "+_", "z_", "._", "values_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "f", "\\u", "dlo", "gpx", "z", "\\u", "dw", "z_", "=_", "theano", "function_", "(_", "self_", "._", "all", "vars_", ",_", "[_", "logp", "x_", ",_", "logp", "z_", "]_", "+_", "dlo", "gpx", "z", "\\u", "dw", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "f", "\\u", "dlo", "gpx", "z", "\\u", "dw", " ", "=", " ", "theano", "function", "(", "all", "vars", ",", " ", "[", "logp", "xz", "]", " ", "+", " ", "dlo", "gpx", "z", "\\u", "dw", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "self", ".", "f", "\\u", "dlo", "gpx", "z", "\\u", "dz", " ", "=", " ", "theano", "function", "(", "all", "vars", ",", " ", "[", "logp", "xz", "]", " ", "+", " ", "dlo", "gpx", "z", "\\u", "dz", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "prior_", "\\u\\u\\uNL\\u\\u\\u_", "dlo", "gp", "w", "\\u", "dw_", "=_", "T_", "._", "grad_", "(_", "logp", "w_", ",_", "w_", "._", "values_", "(_", ")_", ",_", "disconnected", "\\u", "inputs_", "=_", "'", "ignore", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "f", "\\u", "logp", "w_", "=_", "theano", "function_", "(_", "w_", "._", "values_", "(_", ")_", ",_", "logp", "w_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "f", "\\u", "dlo", "gp", "w", "\\u", "dw_", "=_", "theano", "function_", "(_", "w_", "._", "values_", "(_", ")_", ",_", "[_", "logp", "w_", "]_", "+_", "dlo", "gp", "w", "\\u", "dw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "MC", "-", "LI", "KE", "LI", "HO", "OD_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logp", "x", "\\u", "max_", "=_", "logp", "x_", "._", "max_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logp", "xm", "c_", "=_", "T_", "._", "log_", "(_", "T_", "._", "exp_", "(_", "logp", "x_", "-_", "logp", "x", "\\u", "max_", ")_", "._", "mean_", "(_", ")_", ")_", "+_", "logp", "x", "\\u", "max_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "f", "\\u", "logp", "xm", "c_", "=_", "theano", "function_", "(_", "self_", "._", "all", "vars_", ",_", "logp", "xm", "c_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dlo", "gpx", "mc", "\\u", "dw_", "=_", "T_", "._", "grad_", "(_", "logp", "xm", "c_", ",_", "w_", "._", "values_", "(_", ")_", ",_", "disconnected", "\\u", "inputs_", "=_", "theano", "\\u", "warning_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "f", "\\u", "dlo", "gpx", "mc", "\\u", "dw_", "=_", "theano", "function_", "(_", "self_", "._", "all", "vars_", ",_", "[_", "logp", "xm", "c_", "]_", "+_", "dlo", "gpx", "mc", "\\u", "dw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "True_", "and_", "len_", "(_", "z_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Fish", "er", " ", "divergence", " ", "(", "FD", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "gz_", "=_", "T_", "._", "grad_", "(_", "logp", "xz", "_", ",_", "z_", "._", "values_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gz", "2_", "=_", "[_", "T_", "._", "dma", "trix_", "(_", ")_", "for_", "\\u_", "in_", "gz_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fd_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "gz_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fd_", "+=_", "T_", "._", "sum_", "(_", "(_", "gz_", "[_", "i_", "]_", "-_", "gz", "2_", "[_", "i_", "]_", ")_", "**_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "dfd", "\\u", "dw_", "=_", "T_", "._", "grad_", "(_", "fd_", ",_", "w_", "._", "values_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "f", "\\u", "dfd", "\\u", "dw_", "=_", "theano", "function_", "(_", "self_", "._", "all", "vars_", "+_", "gz", "2_", ",_", "[_", "logp", "x_", ",_", "logp", "z_", ",_", "fd_", "]_", "+_", "dfd", "\\u", "dw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "False_", "and_", "hessian", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Hes", "sia", "n", " ", "of", " ", "logp", "xz", " ", "wrt", " ", "z", " ", "(", "works", " ", "best", " ", "with", " ", "n", "\\u", "batch", "=", "1", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hessian", "\\u", "z_", "=_", "theano_", "._", "gradient_", "._", "hessian", "_", "(_", "logp", "xz", "_", ",_", "z", "\\u", "concat_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "f", "\\u", "hessian", "\\u", "z_", "=_", "theano", "function_", "(_", "self_", "._", "all", "vars_", ",_", "hessian", "\\u", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "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_", "variables_", "(_", "self_", ")_", ":_", "raise_", "Not", "Impl", "ement", "ed", "Error_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "factors_", "(_", "self_", ")_", ":_", "raise_", "Not", "Impl", "ement", "ed", "Error_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "gen", "\\u", "xz", "_", "(_", "self_", ")_", ":_", "raise_", "Not", "Impl", "ement", "ed", "Error_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "init", "\\u", "w_", "(_", "self_", ")_", ":_", "raise_", "Not", "Impl", "ement", "ed", "Error_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "xz", "\\u", "to", "\\u", "theano_", "(_", "self_", ",_", "x_", ",_", "z_", ")_", ":_", "return_", "x_", ",_", "z_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "gw", "gz", "\\u", "to", "\\u", "numpy_", "(_", "self_", ",_", "gw_", ",_", "gz_", ")_", ":_", "return_", "gw_", ",_", "gz_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "\\u", "A_", "(_", "self_", ",_", "x_", ")_", ":_", "return_", "np_", "._", "ones_", "(_", "(_", "1_", ",_", "x_", "._", "itervalues_", "(_", ")_", "._", "next_", "(_", ")_", "._", "shape_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "logp", "xz", "_", "(_", "self_", ",_", "w_", ",_", "x_", ",_", "z_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", ",_", "z_", "=_", "self_", "._", "xz", "\\u", "to", "\\u", "theano_", "(_", "x_", ",_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w_", ",_", "z_", ",_", "x_", "=_", "ndi", "ct_", "._", "order", "eddi", "cts_", "(_", "(_", "w_", ",_", "z_", ",_", "x_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "A_", "=_", "self_", "._", "get", "\\u", "A_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "all", "vars_", "=_", "w_", "._", "values_", "(_", ")_", "+_", "x_", "._", "values_", "(_", ")_", "+_", "z_", "._", "values_", "(_", ")_", "+_", "[_", "A_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logp", "x_", ",_", "logp", "z_", "=_", "self_", "._", "f", "\\u", "logp", "xz", "_", "(_", "*_", "all", "vars_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "np_", "._", "isnan_", "(_", "logp", "x_", ")_", "._", "any_", "(_", ")_", "or_", "np_", "._", "isnan_", "(_", "logp", "z_", ")_", "._", "any_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "v", ":", " ", "'_", ",_", "logp", "x_", ",_", "logp", "z_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Value", "s", ":'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ndi", "ct_", "._", "p_", "(_", "w_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ndi", "ct_", "._", "p_", "(_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Exception_", "(_", "\"", "dlo", "gpx", "z", "\\u", "dw", "z", "():", " ", "Na", "N", " ", "found", " ", "in", " ", "gradi", "ents", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "logp", "x_", ",_", "logp", "z_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "dlo", "gpx", "z", "\\u", "dw", "z_", "(_", "self_", ",_", "w_", ",_", "x_", ",_", "z_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", ",_", "z_", "=_", "self_", "._", "xz", "\\u", "to", "\\u", "theano_", "(_", "x_", ",_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w_", ",_", "z_", ",_", "x_", "=_", "ndi", "ct_", "._", "order", "eddi", "cts_", "(_", "(_", "w_", ",_", "z_", ",_", "x_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "A_", "=_", "self_", "._", "get", "\\u", "A_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "all", "vars_", "=_", "w_", "._", "values_", "(_", ")_", "+_", "x_", "._", "values_", "(_", ")_", "+_", "z_", "._", "values_", "(_", ")_", "+_", "[_", "A_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "keys", " ", "are", " ", "correct_", "\\u\\u\\uNL\\u\\u\\u_", "keys_", "=_", "w_", "._", "keys_", "(_", ")_", "+_", "x_", "._", "keys_", "(_", ")_", "+_", "z_", "._", "keys_", "(_", ")_", "+_", "[_", "'", "A", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "len_", "(_", "keys_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "keys_", "[_", "i_", "]_", "!=_", "self_", "._", "all", "vars", "\\u", "keys_", "[_", "i_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Inp", "ut", " ", "values", " ", "are", " ", "incorrect", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Inp", "ut", ":'_", ",_", "keys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Sho", "ul", "d", " ", "be", ":'_", ",_", "self_", "._", "all", "vars", "\\u", "keys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Exception_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "r_", "=_", "self_", "._", "f", "\\u", "dlo", "gpx", "z", "\\u", "dw", "z_", "(_", "*_", "all", "vars_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logp", "x_", ",_", "logp", "z_", ",_", "gw_", ",_", "gz_", "=_", "r_", "[_", "0_", "]_", ",_", "r_", "[_", "1_", "]_", ",_", "dict_", "(_", "zip_", "(_", "w_", "._", "keys_", "(_", ")_", ",_", "r_", "[_", "2_", ":_", "2_", "+_", "len_", "(_", "w_", ")_", "]_", ")_", ")_", ",_", "dict_", "(_", "zip_", "(_", "z_", "._", "keys_", "(_", ")_", ",_", "r_", "[_", "2_", "+_", "len_", "(_", "w_", ")_", ":_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "ndi", "ct_", "._", "has", "Na", "N_", "(_", "gw_", ")_", "or_", "ndi", "ct_", "._", "has", "Na", "N_", "(_", "gz_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "Na", "N", " ", "detect", "ed", " ", "in", " ", "gradi", "ents", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Exception_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "gw_", ":_", "gw_", "[_", "i_", "]_", "[_", "np_", "._", "isnan_", "(_", "gw_", "[_", "i_", "]_", ")_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "gz_", ":_", "gz_", "[_", "i_", "]_", "[_", "np_", "._", "isnan_", "(_", "gz_", "[_", "i_", "]_", ")_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "logp", "x", ":", " ", "'_", ",_", "logp", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "logp", "z", ":", " ", "'_", ",_", "logp", "z_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Value", "s", ":'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ndi", "ct_", "._", "p_", "(_", "w_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ndi", "ct_", "._", "p_", "(_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Grad", "ients", ":'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ndi", "ct_", "._", "p_", "(_", "gw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ndi", "ct_", "._", "p_", "(_", "gz_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Exception_", "(_", "\"", "dlo", "gpx", "z", "\\u", "dw", "z", "():", " ", "Na", "N", " ", "found", " ", "in", " ", "gradi", "ents", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "gw_", ",_", "gz_", "=_", "self_", "._", "gw", "gz", "\\u", "to", "\\u", "numpy_", "(_", "gw_", ",_", "gz_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "logp", "x_", ",_", "logp", "z_", ",_", "gw_", ",_", "gz_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "hessian", "\\u", "z_", "(_", "self_", ",_", "w_", ",_", "z_", ",_", "x_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", ",_", "z_", "=_", "self_", "._", "xz", "\\u", "to", "\\u", "theano_", "(_", "x_", ",_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "A_", "=_", "self_", "._", "get", "\\u", "A_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "f", "\\u", "hessian", "\\u", "z_", "(_", "*_", "ndi", "ct_", "._", "order", "ed", "vals_", "(_", "(_", "w_", ",_", "x_", ",_", "z_", ")_", ")_", "+_", "[_", "A_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "logp", "w_", "(_", "self_", ",_", "w_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logp", "w_", "=_", "self_", "._", "f", "\\u", "logp", "w_", "(_", "*_", "ndi", "ct_", "._", "order", "ed", "vals_", "(_", "(_", "w_", ",_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "logp", "w_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "dlo", "gp", "w", "\\u", "dw_", "(_", "self_", ",_", "w_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "w_", "=_", "ndi", "ct_", "._", "ordered_", "(_", "w_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "self_", "._", "f", "\\u", "dlo", "gp", "w", "\\u", "dw_", "(_", "*_", "(_", "w_", "._", "values_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "r_", "[_", "0_", "]_", ",_", "dict_", "(_", "zip_", "(_", "w_", "._", "keys_", "(_", ")_", ",_", "r_", "[_", "1_", ":_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "logp", "xm", "c_", "(_", "self_", ",_", "w_", ",_", "x_", ",_", "n", "\\u", "batch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "self_", "._", "tiled", "\\u", "x_", "(_", "x_", ",_", "n", "\\u", "batch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", ",_", "z_", ",_", "\\u_", "=_", "self_", "._", "gen", "\\u", "xz", "_", "(_", "w_", ",_", "x_", ",_", "{_", "}_", ",_", "n", "\\u", "batch_", "=_", "n", "\\u", "batch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", ",_", "z_", "=_", "self_", "._", "xz", "\\u", "to", "\\u", "theano_", "(_", "x_", ",_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "A_", "=_", "self_", "._", "get", "\\u", "A_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logp", "xm", "c_", "=_", "self_", "._", "f", "\\u", "logp", "xm", "c_", "(_", "*_", "ndi", "ct_", "._", "order", "ed", "vals_", "(_", "(_", "w_", ",_", "x_", ",_", "z_", ")_", ")_", "+_", "[_", "A_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "logp", "xm", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "dlo", "gpx", "mc", "\\u", "dw_", "(_", "self_", ",_", "w_", ",_", "x_", ",_", "n", "\\u", "batch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", "=_", "self_", "._", "tiled", "\\u", "x_", "(_", "x_", ",_", "n", "\\u", "batch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", ",_", "z_", ",_", "\\u_", "=_", "self_", "._", "gen", "\\u", "xz", "_", "(_", "w_", ",_", "x_", ",_", "{_", "}_", ",_", "n", "\\u", "batch_", "=_", "n", "\\u", "batch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", ",_", "z_", "=_", "self_", "._", "xz", "\\u", "to", "\\u", "theano_", "(_", "x_", ",_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "A_", "=_", "self_", "._", "get", "\\u", "A_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "self_", "._", "f", "\\u", "dlo", "gpx", "mc", "\\u", "dw_", "(_", "*_", "ndi", "ct_", "._", "order", "ed", "vals_", "(_", "(_", "w_", ",_", "x_", ",_", "z_", ")_", ")_", "+_", "[_", "A_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "r_", "[_", "0_", "]_", ",_", "dict_", "(_", "zip_", "(_", "ndi", "ct_", "._", "ordered_", "(_", "w_", ")_", "._", "keys_", "(_", ")_", ",_", "r_", "[_", "1_", ":_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "dfd", "\\u", "dw_", "(_", "self_", ",_", "w_", ",_", "x_", ",_", "z_", ",_", "gz", "2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x_", ",_", "z_", "=_", "self_", "._", "xz", "\\u", "to", "\\u", "theano_", "(_", "x_", ",_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "w_", ",_", "z_", ",_", "x_", ",_", "gz", "2_", "=_", "ndi", "ct_", "._", "order", "eddi", "cts_", "(_", "(_", "w_", ",_", "z_", ",_", "x_", ",_", "gz", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "A_", "=_", "self_", "._", "get", "\\u", "A_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "self_", "._", "f", "\\u", "dfd", "\\u", "dw_", "(_", "*_", "(_", "w_", "._", "values_", "(_", ")_", "+_", "x_", "._", "values_", "(_", ")_", "+_", "z_", "._", "values_", "(_", ")_", "+_", "[_", "A_", "]_", "+_", "gz", "2_", "._", "values_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logp", "x_", ",_", "logp", "z_", ",_", "fd_", ",_", "gw_", "=_", "r_", "[_", "0_", "]_", ",_", "r_", "[_", "1_", "]_", ",_", "r_", "[_", "2_", "]_", ",_", "dict_", "(_", "zip_", "(_", "w_", "._", "keys_", "(_", ")_", ",_", "r_", "[_", "3_", ":_", "3_", "+_", "len_", "(_", "w_", ")_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "ndi", "ct_", "._", "has", "Na", "N_", "(_", "gw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "Na", "N", " ", "detect", "ed", " ", "in", " ", "gradi", "ents", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Exception_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "gw_", ":_", "gw_", "[_", "i_", "]_", "[_", "np_", "._", "isnan_", "(_", "gw_", "[_", "i_", "]_", ")_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "fd", ":", " ", "'_", ",_", "fd_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Value", "s", ":'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ndi", "ct_", "._", "p_", "(_", "w_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ndi", "ct_", "._", "p_", "(_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Grad", "ients", ":'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ndi", "ct_", "._", "p_", "(_", "gw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Exception_", "(_", "\"", "dfd", "\\u", "dw", "():", " ", "Na", "N", " ", "found", " ", "in", " ", "gradi", "ents", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "gw_", ",_", "\\u_", "=_", "self_", "._", "gw", "gz", "\\u", "to", "\\u", "numpy_", "(_", "gw_", ",_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "logp", "x_", ",_", "logp", "z_", ",_", "fd_", ",_", "gw_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "BN", "Model_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "tiled", "\\u", "x_", "(_", "self_", ",_", "x_", ",_", "n", "\\u", "batch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "x", "\\u", "tiled", "_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "x_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "x_", "[_", "i_", "]_", "._", "shape_", "[_", "1_", "]_", "!=_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Exception_", "(_", "\"{}", " ", "{}", " ", "{}", " ", "\"_", "._", "format_", "(_", "x_", "[_", "i_", "]_", "._", "shape_", "[_", "0_", "]_", ",_", "x_", "[_", "i_", "]_", "._", "shape_", "[_", "1_", "]_", ",_", "n", "\\u", "batch_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "x", "\\u", "tiled", "_", "[_", "i_", "]_", "=_", "np_", "._", "dot_", "(_", "x_", "[_", "i_", "]_", ",_", "np_", "._", "ones_", "(_", "(_", "1_", ",_", "n", "\\u", "batch_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "x", "\\u", "tiled", "_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
pallets/werkzeug/examples/cupoftee/application.py
[ { "content": " def update_master(self):\n wait = self.interval\n while 1:\n if self.master.sync():\n wait = self.interval\n else:\n wait = self.interval // 2\n time.sleep(wait)", "metadata": "root.Cup.update_master", "header": "['class', 'Cup', '(', 'object', ')', ':', '___EOS___']", "index": 84 } ]
[ { "span": "wait ", "start_line": 85, "start_column": 8, "end_line": 85, "end_column": 12 } ]
[ { "span": "wait ", "start_line": 88, "start_column": 16, "end_line": 88, "end_column": 20 }, { "span": "wait ", "start_line": 90, "start_column": 16, "end_line": 90, "end_column": 20 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "class_", "Cu", "p_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "\\u", "master_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wait_", "=_", "self_", "._", "interval_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "master_", "._", "sync_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wait_", "=_", "self_", "._", "interval_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wait_", "=_", "self_", "._", "interval_", "//_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "time_", "._", "sleep_", "(_", "wait_", ")_", "\\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, 0, 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, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
django-bmf/django-bmf/djangobmf/currency/EUR/migrations/0001_initial.py
[ { "content": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Migration(migrations.Migration):\n\n dependencies = [\n ]\n\n operations = [\n ]", "metadata": "root.Migration", "header": "['module', '___EOS___']", "index": 6 } ]
[ { "span": "from django.db import models, migrations", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 40 } ]
[]
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_", "\\u\\u", "future\\u\\u_", "import_", "unicode", "\\u", "literals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "models_", ",_", "migrations_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Migration_", "(_", "migrations_", "._", "Migration_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dependencies_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "operations_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "]_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
binhex/moviegrabber/lib/site-packages/Cheetah/FileUtils.py
[ { "content": "\nfrom glob import glob\nimport os\nfrom os import listdir\nimport os.path\nimport re\nfrom tempfile import mktemp\n\n\n \n\n\n\n##################################################\n## CLASSES\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def _escapeRegexChars(txt,\n escapeRE=re.compile(r'([\\$\\^\\*\\+\\.\\?\\{\\}\\[\\]\\(\\)\\|\\\\])')):\n return escapeRE.sub(r'\\\\\\1', txt)", "metadata": "root._escapeRegexChars", "header": "['module', '___EOS___']", "index": 8 }, { "content": "def findFiles(*args, **kw):\n \"\"\"Recursively find all the files matching a glob pattern.\n\n This function is a wrapper around the FileFinder class. See its docstring\n for details about the accepted arguments, etc.\"\"\"\n \n return FileFinder(*args, **kw).files()", "metadata": "root.findFiles", "header": "['module', '___EOS___']", "index": 12 }, { "content": "def replaceStrInFiles(files, theStr, repl):\n\n \"\"\"Replace all instances of 'theStr' with 'repl' for each file in the 'files'\n list. Returns a dictionary with data about the matches found.\n\n This is like string.replace() on a multi-file basis.\n\n This function is a wrapper around the FindAndReplace class. See its\n docstring for more details.\"\"\"\n \n pattern = _escapeRegexChars(theStr)\n return FindAndReplace(files, pattern, repl).results()", "metadata": "root.replaceStrInFiles", "header": "['module', '___EOS___']", "index": 20 }, { "content": "def replaceRegexInFiles(files, pattern, repl):\n\n \"\"\"Replace all instances of regex 'pattern' with 'repl' for each file in the\n 'files' list. Returns a dictionary with data about the matches found.\n\n This is like re.sub on a multi-file basis.\n\n This function is a wrapper around the FindAndReplace class. See its\n docstring for more details.\"\"\"\n\n return FindAndReplace(files, pattern, repl).results()", "metadata": "root.replaceRegexInFiles", "header": "['module', '___EOS___']", "index": 33 }, { "content": "class FileFinder:\n \n \"\"\"Traverses a directory tree and finds all files in it that match one of\n the specified glob patterns.\"\"\"\n \n \n\n \n ", "metadata": "root.FileFinder", "header": "['module', '___EOS___']", "index": 49 }, { "content": " def __init__(self, rootPath,\n globPatterns=('*',),\n ignoreBasenames=('CVS', '.svn'),\n ignoreDirs=(),\n ):\n \n self._rootPath = rootPath\n self._globPatterns = globPatterns\n self._ignoreBasenames = ignoreBasenames\n self._ignoreDirs = ignoreDirs\n self._files = []\n \n self.walkDirTree(rootPath)", "metadata": "root.FileFinder.__init__", "header": "['class', 'FileFinder', ':', '___EOS___']", "index": 54 }, { "content": " def walkDirTree(self, dir='.',\n \n listdir=os.listdir,\n isdir=os.path.isdir,\n join=os.path.join,\n ):\n\n \"\"\"Recursively walk through a directory tree and find matching files.\"\"\"\n processDir = self.processDir\n filterDir = self.filterDir\n \n pendingDirs = [dir]\n addDir = pendingDirs.append\n getDir = pendingDirs.pop\n \n while pendingDirs:\n dir = getDir()\n ## process this dir\n processDir(dir)\n \n ## and add sub-dirs \n for baseName in listdir(dir):\n fullPath = join(dir, baseName)\n if isdir(fullPath):\n if filterDir(baseName, fullPath):\n addDir( fullPath )", "metadata": "root.FileFinder.walkDirTree", "header": "['class', 'FileFinder', ':', '___EOS___']", "index": 68 }, { "content": " def filterDir(self, baseName, fullPath):\n \n \"\"\"A hook for filtering out certain dirs. \"\"\"\n \n return not (baseName in self._ignoreBasenames or \n fullPath in self._ignoreDirs)", "metadata": "root.FileFinder.filterDir", "header": "['class', 'FileFinder', ':', '___EOS___']", "index": 95 }, { "content": " def processDir(self, dir, glob=glob):\n extend = self._files.extend\n for pattern in self._globPatterns:\n extend( glob(os.path.join(dir, pattern)) )", "metadata": "root.FileFinder.processDir", "header": "['class', 'FileFinder', ':', '___EOS___']", "index": 102 }, { "content": " def files(self):\n return self._files", "metadata": "root.FileFinder.files", "header": "['class', 'FileFinder', ':', '___EOS___']", "index": 107 }, { "content": "class _GenSubberFunc:\n\n \"\"\"Converts a 'sub' string in the form that one feeds to re.sub (backrefs,\n groups, etc.) into a function that can be used to do the substitutions in\n the FindAndReplace class.\"\"\"\n \n backrefRE = re.compile(r'\\\\([1-9][0-9]*)')\n groupRE = re.compile(r'\\\\g<([a-zA-Z_][a-zA-Z_]*)>')\n \n\n \n \n\n\n\n\n ## match and get methods\n \n\n \n\n\n ## main parse loop and the eat methods\n \n \n \n\n \n\n ## code wrapping methods\n\n\n ", "metadata": "root._GenSubberFunc", "header": "['module', '___EOS___']", "index": 110 }, { "content": " def __init__(self, replaceStr):\n self._src = replaceStr\n self._pos = 0\n self._codeChunks = []\n self.parse()", "metadata": "root._GenSubberFunc.__init__", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 119 }, { "content": " def src(self):\n return self._src", "metadata": "root._GenSubberFunc.src", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 125 }, { "content": " def pos(self):\n return self._pos", "metadata": "root._GenSubberFunc.pos", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 128 }, { "content": " def setPos(self, pos):\n self._pos = pos", "metadata": "root._GenSubberFunc.setPos", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 131 }, { "content": " def atEnd(self):\n return self._pos >= len(self._src)", "metadata": "root._GenSubberFunc.atEnd", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 134 }, { "content": " def advance(self, offset=1):\n self._pos += offset", "metadata": "root._GenSubberFunc.advance", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 137 }, { "content": " def readTo(self, to, start=None):\n if start == None:\n start = self._pos\n self._pos = to\n if self.atEnd():\n return self._src[start:]\n else:\n return self._src[start:to]", "metadata": "root._GenSubberFunc.readTo", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 140 }, { "content": " def matchBackref(self):\n return self.backrefRE.match(self.src(), self.pos())", "metadata": "root._GenSubberFunc.matchBackref", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 151 }, { "content": " def getBackref(self):\n m = self.matchBackref()\n self.setPos(m.end())\n return m.group(1)", "metadata": "root._GenSubberFunc.getBackref", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 154 }, { "content": " def matchGroup(self):\n return self.groupRE.match(self.src(), self.pos())", "metadata": "root._GenSubberFunc.matchGroup", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 159 }, { "content": " def getGroup(self):\n m = self.matchGroup()\n self.setPos(m.end())\n return m.group(1)", "metadata": "root._GenSubberFunc.getGroup", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 162 }, { "content": " def parse(self):\n while not self.atEnd():\n if self.matchBackref():\n self.eatBackref()\n elif self.matchGroup():\n self.eatGroup()\n else:\n self.eatStrConst()", "metadata": "root._GenSubberFunc.parse", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 169 }, { "content": " def eatStrConst(self):\n startPos = self.pos()\n while not self.atEnd():\n if self.matchBackref() or self.matchGroup():\n break\n else:\n self.advance()\n strConst = self.readTo(self.pos(), start=startPos)\n self.addChunk(repr(strConst))", "metadata": "root._GenSubberFunc.eatStrConst", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 178 }, { "content": " def eatBackref(self):\n self.addChunk( 'm.group(' + self.getBackref() + ')' )", "metadata": "root._GenSubberFunc.eatBackref", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 188 }, { "content": " def eatGroup(self):\n self.addChunk( 'm.group(\"' + self.getGroup() + '\")' )", "metadata": "root._GenSubberFunc.eatGroup", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 191 }, { "content": " def addChunk(self, chunk):\n self._codeChunks.append(chunk)", "metadata": "root._GenSubberFunc.addChunk", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 194 }, { "content": " def codeBody(self):\n return ', '.join(self._codeChunks)", "metadata": "root._GenSubberFunc.codeBody", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 199 }, { "content": " def code(self):\n return \"def subber(m):\\n\\treturn ''.join([%s])\\n\" % (self.codeBody())", "metadata": "root._GenSubberFunc.code", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 202 }, { "content": " def subberFunc(self):\n exec(self.code())\n return subber", "metadata": "root._GenSubberFunc.subberFunc", "header": "['class', '_GenSubberFunc', ':', '___EOS___']", "index": 205 }, { "content": "class FindAndReplace:\n \n \"\"\"Find and replace all instances of 'patternOrRE' with 'replacement' for\n each file in the 'files' list. This is a multi-file version of re.sub().\n\n 'patternOrRE' can be a raw regex pattern or\n a regex object as generated by the re module. 'replacement' can be any\n string that would work with patternOrRE.sub(replacement, fileContents).\n \"\"\"\n \n\n \n", "metadata": "root.FindAndReplace", "header": "['module', '___EOS___']", "index": 210 }, { "content": " def __init__(self, files, patternOrRE, replacement,\n recordResults=True):\n\n \n if isinstance(patternOrRE, basestring):\n self._regex = re.compile(patternOrRE)\n else:\n self._regex = patternOrRE\n if isinstance(replacement, basestring):\n self._subber = _GenSubberFunc(replacement).subberFunc()\n else:\n self._subber = replacement\n\n self._pattern = pattern = self._regex.pattern\n self._files = files\n self._results = {}\n self._recordResults = recordResults\n\n ## see if we should use pgrep to do the file matching\n self._usePgrep = False\n if (os.popen3('pgrep')[2].read()).startswith('Usage:'):\n ## now check to make sure pgrep understands the pattern\n tmpFile = mktemp()\n open(tmpFile, 'w').write('#')\n if not (os.popen3('pgrep \"' + pattern + '\" ' + tmpFile)[2].read()):\n # it didn't print an error msg so we're ok\n self._usePgrep = True\n os.remove(tmpFile)\n\n self._run()", "metadata": "root.FindAndReplace.__init__", "header": "['class', 'FindAndReplace', ':', '___EOS___']", "index": 220 }, { "content": " def results(self):\n return self._results", "metadata": "root.FindAndReplace.results", "header": "['class', 'FindAndReplace', ':', '___EOS___']", "index": 251 }, { "content": " def _run(self):\n regex = self._regex\n subber = self._subDispatcher\n usePgrep = self._usePgrep\n pattern = self._pattern\n for file in self._files:\n if not os.path.isfile(file):\n continue # skip dirs etc.\n \n self._currFile = file\n found = False\n if 'orig' in locals():\n del orig\n if self._usePgrep:\n if os.popen('pgrep \"' + pattern + '\" ' + file ).read():\n found = True\n else:\n orig = open(file).read()\n if regex.search(orig):\n found = True\n if found:\n if 'orig' not in locals():\n orig = open(file).read()\n new = regex.sub(subber, orig)\n open(file, 'w').write(new)", "metadata": "root.FindAndReplace._run", "header": "['class', 'FindAndReplace', ':', '___EOS___']", "index": 254 }, { "content": " def _subDispatcher(self, match):\n if self._recordResults:\n if self._currFile not in self._results:\n res = self._results[self._currFile] = {}\n res['count'] = 0\n res['matches'] = []\n else:\n res = self._results[self._currFile]\n res['count'] += 1\n res['matches'].append({'contents': match.group(),\n 'start': match.start(),\n 'end': match.end(),\n }\n )\n return self._subber(match)", "metadata": "root.FindAndReplace._subDispatcher", "header": "['class', 'FindAndReplace', ':', '___EOS___']", "index": 280 }, { "content": "class SourceFileStats:\n\n \"\"\"\n \"\"\"\n \n _fileStats = None\n \n\n\n \n", "metadata": "root.SourceFileStats", "header": "['module', '___EOS___']", "index": 297 }, { "content": " def __init__(self, files):\n self._fileStats = stats = {}\n for file in files:\n stats[file] = self.getFileStats(file)", "metadata": "root.SourceFileStats.__init__", "header": "['class', 'SourceFileStats', ':', '___EOS___']", "index": 304 }, { "content": " def rawStats(self):\n return self._fileStats", "metadata": "root.SourceFileStats.rawStats", "header": "['class', 'SourceFileStats', ':', '___EOS___']", "index": 309 }, { "content": " def summary(self):\n codeLines = 0\n blankLines = 0\n commentLines = 0\n totalLines = 0\n for fileStats in self.rawStats().values():\n codeLines += fileStats['codeLines']\n blankLines += fileStats['blankLines']\n commentLines += fileStats['commentLines']\n totalLines += fileStats['totalLines']\n \n stats = {'codeLines': codeLines,\n 'blankLines': blankLines,\n 'commentLines': commentLines,\n 'totalLines': totalLines,\n }\n return stats", "metadata": "root.SourceFileStats.summary", "header": "['class', 'SourceFileStats', ':', '___EOS___']", "index": 312 }, { "content": " def printStats(self):\n pass", "metadata": "root.SourceFileStats.printStats", "header": "['class', 'SourceFileStats', ':', '___EOS___']", "index": 330 }, { "content": " def getFileStats(self, fileName):\n codeLines = 0\n blankLines = 0\n commentLines = 0 \n commentLineRe = re.compile(r'\\s#.*$')\n blankLineRe = re.compile('\\s$')\n lines = open(fileName).read().splitlines()\n totalLines = len(lines)\n \n for line in lines:\n if commentLineRe.match(line):\n commentLines += 1\n elif blankLineRe.match(line):\n blankLines += 1\n else:\n codeLines += 1\n\n stats = {'codeLines': codeLines,\n 'blankLines': blankLines,\n 'commentLines': commentLines,\n 'totalLines': totalLines,\n }\n \n return stats", "metadata": "root.SourceFileStats.getFileStats", "header": "['class', 'SourceFileStats', ':', '___EOS___']", "index": 333 } ]
[ { "span": "from os import listdir", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 22 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "glob_", "import_", "glob_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "os_", "import_", "listdir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "._", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "tempfile_", "import_", "mktemp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "##", " ", "CLASSES_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "escape", "Rege", "x", "Chars_", "(_", "txt_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "escape", "RE_", "=_", "re_", "._", "compile_", "(_", "r", "'([\\", "\\", "$", "\\\\", "^", "\\\\*", "\\\\+", "\\\\.\\\\", "?\\\\", "{\\\\", "}\\\\", "[\\\\", "]\\\\", "(\\\\", ")\\\\", "|\\\\\\\\", "])'_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "escape", "RE_", "._", "sub_", "(_", "r", "'\\\\\\\\", "\\\\", "1", "'_", ",_", "txt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "find", "Files_", "(_", "*_", "args_", ",_", "**_", "kw_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Recursive", "ly", " ", "find", " ", "all", " ", "the", " ", "files", " ", "matchi", "ng", " ", "a", " ", "glob", " ", "pattern", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "is", " ", "a", " ", "wrapp", "er", " ", "aro", "und", " ", "the", " ", "File", "Fin", "der", " ", "class", ".", " ", " ", "See", " ", "its", " ", "docstr", "ing", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "deta", "il", "s", " ", "abo", "ut", " ", "the", " ", "accept", "ed", " ", "argu", "ment", "s", ",", " ", "etc", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "File", "Finder_", "(_", "*_", "args_", ",_", "**_", "kw_", ")_", "._", "files_", "(_", ")_", "\\u\\u\\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_", "replace", "Str", "In", "Files_", "(_", "files_", ",_", "the", "Str_", ",_", "repl_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Replace", " ", "all", " ", "instance", "s", " ", "of", " ", "'", "the", "Str", "'", " ", "with", " ", "'", "repl", "'", " ", "for", " ", "each", " ", "file", " ", "in", " ", "the", " ", "'", "files", "'", "\\", "10", ";", " ", " ", " ", " ", "list", ".", " ", "Return", "s", " ", "a", " ", "dictionar", "y", " ", "with", " ", "data", " ", "abo", "ut", " ", "the", " ", "matche", "s", " ", "found", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "like", " ", "string", ".", "replace", "()", " ", "on", " ", "a", " ", "multi", "-", "file", " ", "basi", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "is", " ", "a", " ", "wrapp", "er", " ", "aro", "und", " ", "the", " ", "Fin", "d", "And", "Replace", " ", "class", ".", " ", "See", " ", "its", "\\", "10", ";", " ", " ", " ", " ", "docstr", "ing", " ", "for", " ", "more", " ", "deta", "il", "s", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pattern_", "=_", "\\u", "escape", "Rege", "x", "Chars_", "(_", "the", "Str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Fin", "d", "And", "Replace", "_", "(_", "files_", ",_", "pattern_", ",_", "repl_", ")_", "._", "results_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "replace", "Rege", "x", "In", "Files_", "(_", "files_", ",_", "pattern_", ",_", "repl_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Replace", " ", "all", " ", "instance", "s", " ", "of", " ", "regex", " ", "'", "pattern", "'", " ", "with", " ", "'", "repl", "'", " ", "for", " ", "each", " ", "file", " ", "in", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "'", "files", "'", " ", "list", ".", " ", "Return", "s", " ", "a", " ", "dictionar", "y", " ", "with", " ", "data", " ", "abo", "ut", " ", "the", " ", "matche", "s", " ", "found", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "is", " ", "like", " ", "re", ".", "sub", " ", "on", " ", "a", " ", "multi", "-", "file", " ", "basi", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "is", " ", "a", " ", "wrapp", "er", " ", "aro", "und", " ", "the", " ", "Fin", "d", "And", "Replace", " ", "class", ".", " ", "See", " ", "its", "\\", "10", ";", " ", " ", " ", " ", "docstr", "ing", " ", "for", " ", "more", " ", "deta", "il", "s", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "Fin", "d", "And", "Replace", "_", "(_", "files_", ",_", "pattern_", ",_", "repl_", ")_", "._", "results_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "File", "Finder_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Travers", "es", " ", "a", " ", "director", "y", " ", "tree", " ", "and", " ", "find", "s", " ", "all", " ", "files", " ", "in", " ", "it", " ", "tha", "t", " ", "match", " ", "one", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "specified", " ", "glob", " ", "pattern", "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_", "[SEP]_", "class_", "File", "Finder_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "root", "Path_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "glob", "Patterns", "_", "=_", "(_", "'*'_", ",_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ignore", "Base", "names_", "=_", "(_", "'", "CV", "S", "'_", ",_", "'.", "svn", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ignore", "Dirs_", "=_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "root", "Path_", "=_", "root", "Path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "glob", "Patterns", "_", "=_", "glob", "Patterns", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "ignore", "Base", "names_", "=_", "ignore", "Base", "names_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "ignore", "Dirs_", "=_", "ignore", "Dirs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "files_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "walk", "Dir", "Tree_", "(_", "root", "Path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "File", "Finder_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "walk", "Dir", "Tree_", "(_", "self_", ",_", "dir_", "=_", "'.'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "listdir_", "=_", "os_", "._", "listdir_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "isdir_", "=_", "os_", "._", "path_", "._", "isdir_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "join_", "=_", "os_", "._", "path_", "._", "join_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Recursive", "ly", " ", "walk", " ", "through", " ", "a", " ", "director", "y", " ", "tree", " ", "and", " ", "find", " ", "matchi", "ng", " ", "files", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "process", "Dir_", "=_", "self_", "._", "process", "Dir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filter", "Dir_", "=_", "self_", "._", "filter", "Dir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pend", "ing", "Dirs_", "=_", "[_", "dir_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "add", "Dir_", "=_", "pend", "ing", "Dirs_", "._", "append_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "get", "Dir_", "=_", "pend", "ing", "Dirs_", "._", "pop_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "pend", "ing", "Dirs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "dir_", "=_", "get", "Dir_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", " ", " ", "process", " ", "this", " ", "dir_", "\\u\\u\\uNL\\u\\u\\u_", "process", "Dir_", "(_", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "and", " ", "add", " ", "sub", "-", "dirs", " _", "\\u\\u\\uNL\\u\\u\\u_", "for_", "base", "Name_", "in_", "listdir_", "(_", "dir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "full", "Path_", "=_", "join_", "(_", "dir_", ",_", "base", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isdir_", "(_", "full", "Path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "filter", "Dir_", "(_", "base", "Name_", ",_", "full", "Path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "add", "Dir_", "(_", "full", "Path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "File", "Finder_", ":_", "\\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_", "filter", "Dir_", "(_", "self_", ",_", "base", "Name_", ",_", "full", "Path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "A", " ", "hook", " ", "for", " ", "filtering", " ", "out", " ", "cert", "ain", " ", "dirs", ".", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "not_", "(_", "base", "Name_", "in_", "self_", "._", "\\u", "ignore", "Base", "names_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "full", "Path_", "in_", "self_", "._", "\\u", "ignore", "Dirs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "File", "Finder_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "process", "Dir_", "(_", "self_", ",_", "dir_", ",_", "glob_", "=_", "glob_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extend_", "=_", "self_", "._", "\\u", "files_", "._", "extend_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "pattern_", "in_", "self_", "._", "\\u", "glob", "Patterns", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "extend_", "(_", "glob_", "(_", "os_", "._", "path_", "._", "join_", "(_", "dir_", ",_", "pattern_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "File", "Finder_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "files_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "files_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Convert", "s", " ", "a", " ", "'", "sub", "'", " ", "string", " ", "in", " ", "the", " ", "form", " ", "tha", "t", " ", "one", " ", "feed", "s", " ", "to", " ", "re", ".", "sub", " ", "(", "back", "refs", ",", "\\", "10", ";", " ", " ", " ", " ", "group", "s", ",", " ", "etc", ".)", " ", "int", "o", " ", "a", " ", "function", " ", "tha", "t", " ", "can", " ", "be", " ", "used", " ", "to", " ", "do", " ", "the", " ", "substitution", "s", " ", "in", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "Fin", "d", "And", "Replace", " ", "class", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "back", "ref", "RE_", "=_", "re_", "._", "compile_", "(_", "r", "'\\\\\\\\", "([", "1", "-", "9", "][", "0", "-", "9", "]*)", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "group", "RE_", "=_", "re_", "._", "compile_", "(_", "r", "'\\\\\\\\", "g", "<", "([", "a", "-", "z", "A", "-", "Z", "\\u]", "[", "a", "-", "z", "A", "-", "Z", "\\u]*", ")>", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "match", " ", "and", " ", "get", " ", "methods_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "main", " ", "parse", " ", "loop", " ", "and", " ", "the", " ", "eat", " ", "methods_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "code", " ", "wrapp", "ing", " ", "methods_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "replace", "Str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "src_", "=_", "replace", "Str_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "pos_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "code", "Chunk", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "parse_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "src_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "src_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "pos_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "pos_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Pos_", "(_", "self_", ",_", "pos_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "pos_", "=_", "pos_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "at", "End_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "pos_", ">=_", "len_", "(_", "self_", "._", "\\u", "src_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "advance_", "(_", "self_", ",_", "offset_", "=_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "pos_", "+=_", "offset_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read", "To_", "(_", "self_", ",_", "to_", ",_", "start_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "start_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "start_", "=_", "self_", "._", "\\u", "pos_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "pos_", "=_", "to_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "at", "End_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "src_", "[_", "start_", ":_", "]_", "\\u\\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", "src_", "[_", "start_", ":_", "to_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "match", "Back", "ref_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "back", "ref", "RE_", "._", "match_", "(_", "self_", "._", "src_", "(_", ")_", ",_", "self_", "._", "pos_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Back", "ref_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", "=_", "self_", "._", "match", "Back", "ref_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Pos_", "(_", "m_", "._", "end_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "m_", "._", "group_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "match", "Group_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "group", "RE_", "._", "match_", "(_", "self_", "._", "src_", "(_", ")_", ",_", "self_", "._", "pos_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Group_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", "=_", "self_", "._", "match", "Group_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Pos_", "(_", "m_", "._", "end_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "m_", "._", "group_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "parse_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "while_", "not_", "self_", "._", "at", "End_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "match", "Back", "ref_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "eat", "Back", "ref_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "match", "Group_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "eat", "Group_", "(_", ")_", "\\u\\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_", "._", "eat", "Str", "Const_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\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_", "eat", "Str", "Const_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "start", "Pos_", "=_", "self_", "._", "pos_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "not_", "self_", "._", "at", "End_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "match", "Back", "ref_", "(_", ")_", "or_", "self_", "._", "match", "Group_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "advance_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "str", "Const_", "=_", "self_", "._", "read", "To_", "(_", "self_", "._", "pos_", "(_", ")_", ",_", "start_", "=_", "start", "Pos_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "add", "Chunk_", "(_", "repr_", "(_", "str", "Const_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "eat", "Back", "ref_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "add", "Chunk_", "(_", "'", "m", ".", "group", "('_", "+_", "self_", "._", "get", "Back", "ref_", "(_", ")_", "+_", "')'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "eat", "Group_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "add", "Chunk_", "(_", "'", "m", ".", "group", "(\"", "'_", "+_", "self_", "._", "get", "Group_", "(_", ")_", "+_", "'\"", ")'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "Chunk_", "(_", "self_", ",_", "chunk_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "code", "Chunk", "s_", "._", "append_", "(_", "chunk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "code", "Body_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "',", " ", "'_", "._", "join_", "(_", "self_", "._", "\\u", "code", "Chunk", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "code_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "def", " ", "subb", "er", "(", "m", "):", "\\\\", "n", "\\\\", "tre", "turn", " ", "''", ".", "join", "([", "%", "s", "])\\\\", "n", "\"_", "%_", "(_", "self_", "._", "code", "Body_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "\\u", "Gen", "Sub", "ber", "Func_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "subb", "er", "Func_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "exec_", "(_", "self_", "._", "code_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "subb", "er_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "Fin", "d", "And", "Replace", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Fin", "d", " ", "and", " ", "replace", " ", "all", " ", "instance", "s", " ", "of", " ", "'", "pattern", "Or", "RE", "'", " ", "with", " ", "'", "replace", "ment", "'", " ", "for", "\\", "10", ";", " ", " ", " ", " ", "each", " ", "file", " ", "in", " ", "the", " ", "'", "files", "'", " ", "list", ".", " ", "Thi", "s", " ", "is", " ", "a", " ", "multi", "-", "file", " ", "version", " ", "of", " ", "re", ".", "sub", "()", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "'", "pattern", "Or", "RE", "'", " ", "can", " ", "be", " ", "a", " ", "raw", " ", "regex", " ", "pattern", " ", "or", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "regex", " ", "object", " ", "as", " ", "generat", "ed", " ", "by", " ", "the", " ", "re", " ", "module", ".", " ", "'", "replace", "ment", "'", " ", "can", " ", "be", " ", "any", "\\", "10", ";", " ", " ", " ", " ", "string", " ", "tha", "t", " ", "wou", "ld", " ", "work", " ", "with", " ", "pattern", "Or", "RE", ".", "sub", "(", "replace", "ment", ",", " ", "file", "Conten", "ts", ").", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Fin", "d", "And", "Replace", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "files_", ",_", "pattern", "Or", "RE_", ",_", "replacement_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "record", "Results_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "pattern", "Or", "RE_", ",_", "basestring_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "regex_", "=_", "re_", "._", "compile_", "(_", "pattern", "Or", "RE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "regex_", "=_", "pattern", "Or", "RE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "replacement_", ",_", "basestring_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "subb", "er_", "=_", "\\u", "Gen", "Sub", "ber", "Func_", "(_", "replacement_", ")_", "._", "subb", "er", "Func_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "subb", "er_", "=_", "replacement_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "pattern_", "=_", "pattern_", "=_", "self_", "._", "\\u", "regex_", "._", "pattern_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "files_", "=_", "files_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "results_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "record", "Results_", "=_", "record", "Results_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", " ", "see", " ", "if", " ", "we", " ", "shou", "ld", " ", "use", " ", "pgr", "ep", " ", "to", " ", "do", " ", "the", " ", "file", " ", "matching_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "use", "Pg", "rep_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "os_", "._", "popen", "3_", "(_", "'", "pgr", "ep", "'_", ")_", "[_", "2_", "]_", "._", "read_", "(_", ")_", ")_", "._", "startswith_", "(_", "'", "Us", "age", ":'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "##", " ", "now", " ", "check", " ", "to", " ", "make", " ", "sure", " ", "pgr", "ep", " ", "underst", "ands", " ", "the", " ", "pattern_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tmp", "File_", "=_", "mktemp_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "open_", "(_", "tmp", "File_", ",_", "'", "w", "'_", ")_", "._", "write_", "(_", "'#'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "(_", "os_", "._", "popen", "3_", "(_", "'", "pgr", "ep", " ", "\"'_", "+_", "pattern_", "+_", "'\"", " ", "'_", "+_", "tmp", "File_", ")_", "[_", "2_", "]_", "._", "read_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "it", " ", "did", "n", "'", "t", " ", "print", " ", "an", " ", "error", " ", "msg", " ", "so", " ", "we", "'", "re", " ", "ok_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "use", "Pg", "rep_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "os_", "._", "remove_", "(_", "tmp", "File_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Fin", "d", "And", "Replace", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "results_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "results_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Fin", "d", "And", "Replace", "_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "regex_", "=_", "self_", "._", "\\u", "regex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subb", "er_", "=_", "self_", "._", "\\u", "sub", "Dispatcher_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "use", "Pg", "rep_", "=_", "self_", "._", "\\u", "use", "Pg", "rep_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pattern_", "=_", "self_", "._", "\\u", "pattern_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "file_", "in_", "self_", "._", "\\u", "files_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "os_", "._", "path_", "._", "isfile_", "(_", "file_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "#", " ", "skip", " ", "dirs", " ", "etc", "._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "curr", "File_", "=_", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "found_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "orig", "'_", "in_", "locals_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "orig_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "\\u", "use", "Pg", "rep_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "os_", "._", "popen_", "(_", "'", "pgr", "ep", " ", "\"'_", "+_", "pattern_", "+_", "'\"", " ", "'_", "+_", "file_", ")_", "._", "read_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "found_", "=_", "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 ", " _", "orig_", "=_", "open_", "(_", "file_", ")_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "regex_", "._", "search_", "(_", "orig_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "found_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "found_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "orig", "'_", "not_", "in_", "locals_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "orig_", "=_", "open_", "(_", "file_", ")_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new_", "=_", "regex_", "._", "sub_", "(_", "subb", "er_", ",_", "orig_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "open_", "(_", "file_", ",_", "'", "w", "'_", ")_", "._", "write_", "(_", "new_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Fin", "d", "And", "Replace", "_", ":_", "\\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", "sub", "Dispatcher_", "(_", "self_", ",_", "match_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "record", "Results_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "curr", "File_", "not_", "in_", "self_", "._", "\\u", "results_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "self_", "._", "\\u", "results_", "[_", "self_", "._", "\\u", "curr", "File_", "]_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "[_", "'", "count", "'_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "[_", "'", "matche", "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 ", " _", "res_", "=_", "self_", "._", "\\u", "results_", "[_", "self_", "._", "\\u", "curr", "File_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "res_", "[_", "'", "count", "'_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "res_", "[_", "'", "matche", "s", "'_", "]_", "._", "append_", "(_", "{_", "'", "content", "s", "'_", ":_", "match_", "._", "group_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "start", "'_", ":_", "match_", "._", "start_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "end", "'_", ":_", "match_", "._", "end_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "\\u", "subb", "er_", "(_", "match_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "Sou", "rce", "File", "Stats_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "file", "Stats_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Sou", "rce", "File", "Stats_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "files_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "file", "Stats_", "=_", "stats_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "file_", "in_", "files_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stats_", "[_", "file_", "]_", "=_", "self_", "._", "get", "File", "Stats_", "(_", "file_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sou", "rce", "File", "Stats_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "raw", "Stats_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "file", "Stats_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sou", "rce", "File", "Stats_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "summary_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "code", "Lines_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blank", "Lines_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "comment", "Lines_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total", "Lines_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "file", "Stats_", "in_", "self_", "._", "raw", "Stats_", "(_", ")_", "._", "values_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "code", "Lines_", "+=_", "file", "Stats_", "[_", "'", "code", "Line", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blank", "Lines_", "+=_", "file", "Stats_", "[_", "'", "blank", "Line", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "comment", "Lines_", "+=_", "file", "Stats_", "[_", "'", "comment", "Line", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total", "Lines_", "+=_", "file", "Stats_", "[_", "'", "total", "Line", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "stats_", "=_", "{_", "'", "code", "Line", "s", "'_", ":_", "code", "Lines_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "blank", "Line", "s", "'_", ":_", "blank", "Lines_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "Line", "s", "'_", ":_", "comment", "Lines_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "total", "Line", "s", "'_", ":_", "total", "Lines_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "stats_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sou", "rce", "File", "Stats_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "print", "Stats_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sou", "rce", "File", "Stats_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "File", "Stats_", "(_", "self_", ",_", "file", "Name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "code", "Lines_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blank", "Lines_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "comment", "Lines_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "comment", "Line", "Re_", "=_", "re_", "._", "compile_", "(_", "r", "'\\\\", "s", "#.", "*$'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blank", "Line", "Re_", "=_", "re_", "._", "compile_", "(_", "'\\\\", "s", "$'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lines_", "=_", "open_", "(_", "file", "Name_", ")_", "._", "read_", "(_", ")_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total", "Lines_", "=_", "len_", "(_", "lines_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "line_", "in_", "lines_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "comment", "Line", "Re_", "._", "match_", "(_", "line_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "comment", "Lines_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "blank", "Line", "Re_", "._", "match_", "(_", "line_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "blank", "Lines_", "+=_", "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 ", " _", "code", "Lines_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "stats_", "=_", "{_", "'", "code", "Line", "s", "'_", ":_", "code", "Lines_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "blank", "Line", "s", "'_", ":_", "blank", "Lines_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "comment", "Line", "s", "'_", ":_", "comment", "Lines_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "total", "Line", "s", "'_", ":_", "total", "Lines_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "stats_" ]
[ 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
rcbops/glance-buildpackage/glance/tests/functional/test_cache_middleware.py
[ { "content": " @skip_if_disabled\n def test_cache_middleware_transparent(self):\n \"\"\"\n We test that putting the cache middleware into the\n application pipeline gives us transparent image caching\n \"\"\"\n self.cleanup()\n self.start_servers(**self.__dict__.copy())\n\n api_port = self.api_port\n registry_port = self.registry_port\n\n # Add an image and verify a 200 OK is returned\n image_data = \"*\" * FIVE_KB\n headers = {'Content-Type': 'application/octet-stream',\n 'X-Image-Meta-Name': 'Image1',\n 'X-Image-Meta-Is-Public': 'True'}\n path = \"http://%s:%d/v1/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'POST', headers=headers,\n body=image_data)\n self.assertEqual(response.status, 201)\n data = json.loads(content)\n self.assertEqual(data['image']['checksum'],\n hashlib.md5(image_data).hexdigest())\n self.assertEqual(data['image']['size'], FIVE_KB)\n self.assertEqual(data['image']['name'], \"Image1\")\n self.assertEqual(data['image']['is_public'], True)\n\n image_id = data['image']['id']\n\n # Verify image not in cache\n image_cached_path = os.path.join(self.api_server.image_cache_dir,\n image_id)\n self.assertFalse(os.path.exists(image_cached_path))\n\n # Grab the image\n path = \"http://%s:%d/v1/images/%s\" % (\"0.0.0.0\", self.api_port,\n image_id)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n\n # Verify image now in cache\n image_cached_path = os.path.join(self.api_server.image_cache_dir,\n image_id)\n\n # You might wonder why the heck this is here... well, it's here\n # because it took me forever to figure out that the disk write\n # cache in Linux was causing random failures of the os.path.exists\n # assert directly below this. Basically, since the cache is writing\n # the image file to disk in a different process, the write buffers\n # don't flush the cache file during an os.rename() properly, resulting\n # in a false negative on the file existence check below. This little\n # loop pauses the execution of this process for no more than 1.5\n # seconds. If after that time the cached image file still doesn't\n # appear on disk, something really is wrong, and the assert should\n # trigger...\n i = 0\n while not os.path.exists(image_cached_path) and i < 30:\n time.sleep(0.05)\n i = i + 1\n\n self.assertTrue(os.path.exists(image_cached_path))\n\n # Now, we delete the image from the server and verify that\n # the image cache no longer contains the deleted image\n path = \"http://%s:%d/v1/images/%s\" % (\"0.0.0.0\", self.api_port,\n image_id)\n http = httplib2.Http()\n response, content = http.request(path, 'DELETE')\n self.assertEqual(response.status, 200)\n\n self.assertFalse(os.path.exists(image_cached_path))\n\n self.stop_servers()", "metadata": "root.BaseCacheMiddlewareTest.test_cache_middleware_transparent", "header": "['class', 'BaseCacheMiddlewareTest', '(', 'object', ')', ':', '___EOS___']", "index": 78 }, { "content": " @skip_if_disabled\n def test_cache_remote_image(self):\n \"\"\"\n We test that caching is no longer broken for remote images\n \"\"\"\n self.cleanup()\n self.start_servers(**self.__dict__.copy())\n\n api_port = self.api_port\n registry_port = self.registry_port\n\n # set up \"remote\" image server\n server_class = BaseHTTPServer.HTTPServer\n remote_server = server_class(('127.0.0.1', 0), RemoteImageHandler)\n remote_ip, remote_port = remote_server.server_address\n\n def serve_requests(httpd):\n httpd.serve_forever()\n\n thread.start_new_thread(serve_requests, (remote_server,))\n\n # Add a remote image and verify a 201 Created is returned\n remote_uri = 'http://%s:%d/images/2' % (remote_ip, remote_port)\n headers = {'X-Image-Meta-Name': 'Image2',\n 'X-Image-Meta-Is-Public': 'True',\n 'X-Image-Meta-Location': remote_uri}\n path = \"http://%s:%d/v1/images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'POST', headers=headers)\n self.assertEqual(response.status, 201)\n data = json.loads(content)\n self.assertEqual(data['image']['size'], FIVE_KB)\n\n image_id = data['image']['id']\n path = \"http://%s:%d/v1/images/%s\" % (\"0.0.0.0\", self.api_port,\n image_id)\n\n # Grab the image\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n\n # Grab the image again to ensure it can be served out from\n # cache with the correct size\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n self.assertEqual(int(response['content-length']), FIVE_KB)\n\n remote_server.shutdown()\n\n self.stop_servers()", "metadata": "root.BaseCacheMiddlewareTest.test_cache_remote_image", "header": "['class', 'BaseCacheMiddlewareTest', '(', 'object', ')', ':', '___EOS___']", "index": 155 }, { "content": " @skip_if_disabled\n def test_cache_manage_get_cached_images(self):\n \"\"\"\n Tests that cached images are queryable\n \"\"\"\n self.cleanup()\n self.start_servers(**self.__dict__.copy())\n\n api_port = self.api_port\n registry_port = self.registry_port\n\n self.verify_no_images()\n\n image_id = self.add_image(\"Image1\")\n\n # Verify image does not yet show up in cache (we haven't \"hit\"\n # it yet using a GET /images/1 ...\n self.verify_no_cached_images()\n\n # Grab the image\n path = \"http://%s:%d/v1/images/%s\" % (\"0.0.0.0\", self.api_port,\n image_id)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n\n # Verify image now in cache\n path = \"http://%s:%d/v1/cached_images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n\n data = json.loads(content)\n self.assertTrue('cached_images' in data)\n\n cached_images = data['cached_images']\n self.assertEqual(1, len(cached_images))\n self.assertEqual(image_id, cached_images[0]['image_id'])\n self.assertEqual(0, cached_images[0]['hits'])\n\n # Hit the image\n path = \"http://%s:%d/v1/images/%s\" % (\"0.0.0.0\", self.api_port,\n image_id)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n\n # Verify image hits increased in output of manage GET\n path = \"http://%s:%d/v1/cached_images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n\n data = json.loads(content)\n self.assertTrue('cached_images' in data)\n\n cached_images = data['cached_images']\n self.assertEqual(1, len(cached_images))\n self.assertEqual(image_id, cached_images[0]['image_id'])\n self.assertEqual(1, cached_images[0]['hits'])\n\n self.stop_servers()", "metadata": "root.BaseCacheManageMiddlewareTest.test_cache_manage_get_cached_images", "header": "['class', 'BaseCacheManageMiddlewareTest', '(', 'object', ')', ':', '___EOS___']", "index": 257 }, { "content": " @skip_if_disabled\n def test_cache_manage_delete_cached_images(self):\n \"\"\"\n Tests that cached images may be deleted\n \"\"\"\n self.cleanup()\n self.start_servers(**self.__dict__.copy())\n\n api_port = self.api_port\n registry_port = self.registry_port\n\n self.verify_no_images()\n\n ids = {}\n\n # Add a bunch of images...\n for x in xrange(0, 4):\n ids[x] = self.add_image(\"Image%s\" % str(x))\n\n # Verify no images in cached_images because no image has been hit\n # yet using a GET /images/<IMAGE_ID> ...\n self.verify_no_cached_images()\n\n # Grab the images, essentially caching them...\n for x in xrange(0, 4):\n path = \"http://%s:%d/v1/images/%s\" % (\"0.0.0.0\", self.api_port,\n ids[x])\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200,\n \"Failed to find image %s\" % ids[x])\n\n # Verify images now in cache\n path = \"http://%s:%d/v1/cached_images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n\n data = json.loads(content)\n self.assertTrue('cached_images' in data)\n\n cached_images = data['cached_images']\n self.assertEqual(4, len(cached_images))\n\n for x in xrange(4, 0): # Cached images returned last modified order\n self.assertEqual(ids[x], cached_images[x]['image_id'])\n self.assertEqual(0, cached_images[x]['hits'])\n\n # Delete third image of the cached images and verify no longer in cache\n path = \"http://%s:%d/v1/cached_images/%s\" % (\"0.0.0.0\", self.api_port,\n ids[2])\n http = httplib2.Http()\n response, content = http.request(path, 'DELETE')\n self.assertEqual(response.status, 200)\n\n path = \"http://%s:%d/v1/cached_images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n\n data = json.loads(content)\n self.assertTrue('cached_images' in data)\n\n cached_images = data['cached_images']\n self.assertEqual(3, len(cached_images))\n self.assertTrue(ids[2] not in [x['image_id'] for x in cached_images])\n\n # Delete all cached images and verify nothing in cache\n path = \"http://%s:%d/v1/cached_images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'DELETE')\n self.assertEqual(response.status, 200)\n\n path = \"http://%s:%d/v1/cached_images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n\n data = json.loads(content)\n self.assertTrue('cached_images' in data)\n\n cached_images = data['cached_images']\n self.assertEqual(0, len(cached_images))\n\n self.stop_servers()", "metadata": "root.BaseCacheManageMiddlewareTest.test_cache_manage_delete_cached_images", "header": "['class', 'BaseCacheManageMiddlewareTest', '(', 'object', ')', ':', '___EOS___']", "index": 320 }, { "content": " @skip_if_disabled\n def test_queue_and_prefetch(self):\n \"\"\"\n Tests that images may be queued and prefetched\n \"\"\"\n self.cleanup()\n self.start_servers(**self.__dict__.copy())\n\n api_port = self.api_port\n registry_port = self.registry_port\n\n cache_config_filepath = os.path.join(self.test_dir, 'etc',\n 'glance-cache.conf')\n cache_file_options = {\n 'image_cache_dir': self.api_server.image_cache_dir,\n 'image_cache_driver': self.image_cache_driver,\n 'registry_port': self.api_server.registry_port,\n 'log_file': os.path.join(self.test_dir, 'cache.log'),\n 'metadata_encryption_key': \"012345678901234567890123456789ab\"\n }\n with open(cache_config_filepath, 'w') as cache_file:\n cache_file.write(\"\"\"[DEFAULT]\ndebug = True\nverbose = True\nimage_cache_dir = %(image_cache_dir)s\nimage_cache_driver = %(image_cache_driver)s\nregistry_host = 0.0.0.0\nregistry_port = %(registry_port)s\nmetadata_encryption_key = %(metadata_encryption_key)s\nlog_file = %(log_file)s\n\"\"\" % cache_file_options)\n\n with open(cache_config_filepath.replace(\".conf\", \"-paste.ini\"),\n 'w') as paste_file:\n paste_file.write(\"\"\"[app:glance-pruner]\npaste.app_factory = glance.common.wsgi:app_factory\nglance.app_factory = glance.image_cache.pruner:Pruner\n\n[app:glance-prefetcher]\npaste.app_factory = glance.common.wsgi:app_factory\nglance.app_factory = glance.image_cache.prefetcher:Prefetcher\n\n[app:glance-cleaner]\npaste.app_factory = glance.common.wsgi:app_factory\nglance.app_factory = glance.image_cache.cleaner:Cleaner\n\n[app:glance-queue-image]\npaste.app_factory = glance.common.wsgi:app_factory\nglance.app_factory = glance.image_cache.queue_image:Queuer\n\"\"\")\n\n self.verify_no_images()\n\n ids = {}\n\n # Add a bunch of images...\n for x in xrange(0, 4):\n ids[x] = self.add_image(\"Image%s\" % str(x))\n\n # Queue the first image, verify no images still in cache after queueing\n # then run the prefetcher and verify that the image is then in the\n # cache\n path = \"http://%s:%d/v1/queued_images/%s\" % (\"0.0.0.0\", self.api_port,\n ids[0])\n http = httplib2.Http()\n response, content = http.request(path, 'PUT')\n self.assertEqual(response.status, 200)\n\n self.verify_no_cached_images()\n\n cmd = \"bin/glance-cache-prefetcher --config-file %s\" % \\\n cache_config_filepath\n\n exitcode, out, err = execute(cmd)\n\n self.assertEqual(0, exitcode)\n self.assertEqual('', out.strip(), out)\n\n # Verify first image now in cache\n path = \"http://%s:%d/v1/cached_images\" % (\"0.0.0.0\", self.api_port)\n http = httplib2.Http()\n response, content = http.request(path, 'GET')\n self.assertEqual(response.status, 200)\n\n data = json.loads(content)\n self.assertTrue('cached_images' in data)\n\n cached_images = data['cached_images']\n self.assertEqual(1, len(cached_images))\n self.assertTrue(ids[0] in [r['image_id']\n for r in data['cached_images']])\n\n self.stop_servers()", "metadata": "root.BaseCacheManageMiddlewareTest.test_queue_and_prefetch", "header": "['class', 'BaseCacheManageMiddlewareTest', '(', 'object', ')', ':', '___EOS___']", "index": 406 } ]
[ { "span": "api_port ", "start_line": 87, "start_column": 8, "end_line": 87, "end_column": 16 }, { "span": "registry_port ", "start_line": 88, "start_column": 8, "end_line": 88, "end_column": 21 }, { "span": "api_port ", "start_line": 163, "start_column": 8, "end_line": 163, "end_column": 16 }, { "span": "registry_port ", "start_line": 164, "start_column": 8, "end_line": 164, "end_column": 21 }, { "span": "api_port ", "start_line": 265, "start_column": 8, "end_line": 265, "end_column": 16 }, { "span": "registry_port ", "start_line": 266, "start_column": 8, "end_line": 266, "end_column": 21 }, { "span": "api_port ", "start_line": 328, "start_column": 8, "end_line": 328, "end_column": 16 }, { "span": "registry_port ", "start_line": 329, "start_column": 8, "end_line": 329, "end_column": 21 }, { "span": "api_port ", "start_line": 414, "start_column": 8, "end_line": 414, "end_column": 16 }, { "span": "registry_port ", "start_line": 415, "start_column": 8, "end_line": 415, "end_column": 21 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Base", "Cache", "Mid", "dle", "ware", "Test_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "@_", "skip", "\\u", "if", "\\u", "disabled_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "cache", "\\u", "middle", "ware", "\\u", "transparent_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "We", " ", "test", " ", "tha", "t", " ", "put", "ting", " ", "the", " ", "cache", " ", "middle", "ware", " ", "int", "o", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "applica", "tion", " ", "pipeline", " ", "give", "s", " ", "us", " ", "transp", "arent", " ", "image", " ", "caching", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cleanup_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start", "\\u", "servers_", "(_", "**_", "self_", "._", "\\u\\u", "dict\\u\\u_", "._", "copy_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "api", "\\u", "port_", "=_", "self_", "._", "api", "\\u", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "registr", "y", "\\u", "port_", "=_", "self_", "._", "registr", "y", "\\u", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "an", " ", "image", " ", "and", " ", "verify", " ", "a", " ", "200", " ", "OK", " ", "is", " ", "returned_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "data_", "=_", "\"*\"_", "*_", "FI", "VE", "\\u", "KB", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headers_", "=_", "{_", "'", "Conten", "t", "-", "Type", "'_", ":_", "'", "applica", "tion", "/", "oct", "et", "-", "stream", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Name", "'_", ":_", "'", "Image", "1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Is", "-", "Public", "'_", ":_", "'", "Tru", "e", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "POST", "'_", ",_", "headers_", "=_", "headers_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "body_", "=_", "image", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "201_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "checks", "um", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "hashlib_", "._", "md5_", "(_", "image", "\\u", "data_", ")_", "._", "hexdigest_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "size", "'_", "]_", ",_", "FI", "VE", "\\u", "KB", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "name", "'_", "]_", ",_", "\"", "Image", "1", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "is", "\\u", "public", "'_", "]_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "id_", "=_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "image", " ", "not", " ", "in", " ", "cache_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "cache", "d\\u", "path_", "=_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "api", "\\u", "server_", "._", "image", "\\u", "cache", "\\u", "dir_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "os_", "._", "path_", "._", "exists_", "(_", "image", "\\u", "cache", "d\\u", "path_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Grab", " ", "the", " ", "image_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "/", "%", "s", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "image", " ", "now", " ", "in", " ", "cache_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "cache", "d\\u", "path_", "=_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "api", "\\u", "server_", "._", "image", "\\u", "cache", "\\u", "dir_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "You", " ", "mig", "ht", " ", "won", "der", " ", "wh", "y", " ", "the", " ", "heck", " ", "this", " ", "is", " ", "here", "...", " ", "well", ",", " ", "it", "'", "s", " ", "here_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "bec", "aus", "e", " ", "it", " ", "too", "k", " ", "me", " ", "forever", " ", "to", " ", "figure", " ", "out", " ", "tha", "t", " ", "the", " ", "disk", " ", "write_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "cache", " ", "in", " ", "Lin", "ux", " ", "was", " ", "caus", "ing", " ", "random", " ", "fail", "ure", "s", " ", "of", " ", "the", " ", "os", ".", "path", ".", "exists_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "assert", " ", "direct", "ly", " ", "belo", "w", " ", "this", ".", " ", "Basic", "ally", ",", " ", "sinc", "e", " ", "the", " ", "cache", " ", "is", " ", "writ", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "image", " ", "file", " ", "to", " ", "disk", " ", "in", " ", "a", " ", "different", " ", "process", ",", " ", "the", " ", "write", " ", "buffers_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "don", "'", "t", " ", "flush", " ", "the", " ", "cache", " ", "file", " ", "dur", "ing", " ", "an", " ", "os", ".", "rename", "()", " ", "proper", "ly", ",", " ", "result", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "a", " ", "fal", "se", " ", "negati", "ve", " ", "on", " ", "the", " ", "file", " ", "existence", " ", "check", " ", "belo", "w", ".", " ", "Thi", "s", " ", "litt", "le_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "loop", " ", "paus", "es", " ", "the", " ", "executi", "on", " ", "of", " ", "this", " ", "process", " ", "for", " ", "no", " ", "more", " ", "than", " ", "1.5_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "second", "s", ".", " ", "If", " ", "after", " ", "tha", "t", " ", "time", " ", "the", " ", "cache", "d", " ", "image", " ", "file", " ", "still", " ", "doe", "sn", "'", "t_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "appear", " ", "on", " ", "disk", ",", " ", "somet", "hing", " ", "reall", "y", " ", "is", " ", "wrong", ",", " ", "and", " ", "the", " ", "assert", " ", "should_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "trigger", "..._", "\\u\\u\\uNL\\u\\u\\u_", "i_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "image", "\\u", "cache", "d\\u", "path_", ")_", "and_", "i_", "<_", "30_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "time_", "._", "sleep_", "(_", "0.05_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "i_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "os_", "._", "path_", "._", "exists_", "(_", "image", "\\u", "cache", "d\\u", "path_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "No", "w", ",", " ", "we", " ", "delete", " ", "the", " ", "image", " ", "from", " ", "the", " ", "server", " ", "and", " ", "verify", " ", "that_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "image", " ", "cache", " ", "no", " ", "long", "er", " ", "contain", "s", " ", "the", " ", "delete", "d", " ", "image_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "/", "%", "s", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "DELET", "E", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "os_", "._", "path_", "._", "exists_", "(_", "image", "\\u", "cache", "d\\u", "path_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "stop", "\\u", "servers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Cache", "Mid", "dle", "ware", "Test_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skip", "\\u", "if", "\\u", "disabled_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "cache", "\\u", "remote", "\\u", "image_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "We", " ", "test", " ", "tha", "t", " ", "caching", " ", "is", " ", "no", " ", "long", "er", " ", "broken", " ", "for", " ", "remote", " ", "images", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cleanup_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start", "\\u", "servers_", "(_", "**_", "self_", "._", "\\u\\u", "dict\\u\\u_", "._", "copy_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "api", "\\u", "port_", "=_", "self_", "._", "api", "\\u", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "registr", "y", "\\u", "port_", "=_", "self_", "._", "registr", "y", "\\u", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "set", " ", "up", " ", "\"", "remote", "\"", " ", "image", " ", "server_", "\\u\\u\\uNL\\u\\u\\u_", "server", "\\u", "class_", "=_", "Base", "HTTP", "Server_", "._", "HTTP", "Server_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remote", "\\u", "server_", "=_", "server", "\\u", "class_", "(_", "(_", "'", "127", ".0", ".0", ".1", "'_", ",_", "0_", ")_", ",_", "Remo", "te", "Image", "Handler_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remote", "\\u", "ip_", ",_", "remote", "\\u", "port_", "=_", "remote", "\\u", "server_", "._", "server", "\\u", "address_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "serve", "\\u", "requests_", "(_", "httpd_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "httpd_", "._", "serve", "\\u", "forever_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "thread_", "._", "start", "\\u", "new", "\\u", "thread_", "(_", "serve", "\\u", "requests_", ",_", "(_", "remote", "\\u", "server_", ",_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "a", " ", "remote", " ", "image", " ", "and", " ", "verify", " ", "a", " ", "201", " ", "Creat", "ed", " ", "is", " ", "returned_", "\\u\\u\\uNL\\u\\u\\u_", "remote", "\\u", "uri_", "=_", "'", "http", "://", "%", "s", ":", "%", "d", "/", "images", "/", "2", "'_", "%_", "(_", "remote", "\\u", "ip_", ",_", "remote", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headers_", "=_", "{_", "'", "X", "-", "Image", "-", "Meta", "-", "Name", "'_", ":_", "'", "Image", "2", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Is", "-", "Public", "'_", ":_", "'", "Tru", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "X", "-", "Image", "-", "Meta", "-", "Locat", "ion", "'_", ":_", "remote", "\\u", "uri_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "POST", "'_", ",_", "headers_", "=_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "201_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "size", "'_", "]_", ",_", "FI", "VE", "\\u", "KB", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "id_", "=_", "data_", "[_", "'", "image", "'_", "]_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "/", "%", "s", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Grab", " ", "the", " ", "image_", "\\u\\u\\uNL\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Grab", " ", "the", " ", "image", " ", "again", " ", "to", " ", "ensure", " ", "it", " ", "can", " ", "be", " ", "serve", "d", " ", "out", " ", "from_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "cache", " ", "with", " ", "the", " ", "correct", " ", "size_", "\\u\\u\\uNL\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "int_", "(_", "response_", "[_", "'", "content", "-", "length", "'_", "]_", ")_", ",_", "FI", "VE", "\\u", "KB", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "remote", "\\u", "server_", "._", "shutdown_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "stop", "\\u", "servers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Cache", "Manage", "Mid", "dle", "ware", "Test_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skip", "\\u", "if", "\\u", "disabled_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "cache", "\\u", "manage", "\\u", "get", "\\u", "cache", "d\\u", "images_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "tha", "t", " ", "cache", "d", " ", "images", " ", "are", " ", "query", "able", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cleanup_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start", "\\u", "servers_", "(_", "**_", "self_", "._", "\\u\\u", "dict\\u\\u_", "._", "copy_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "api", "\\u", "port_", "=_", "self_", "._", "api", "\\u", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "registr", "y", "\\u", "port_", "=_", "self_", "._", "registr", "y", "\\u", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "verify", "\\u", "no", "\\u", "images_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "id_", "=_", "self_", "._", "add", "\\u", "image_", "(_", "\"", "Image", "1", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "image", " ", "doe", "s", " ", "not", " ", "ye", "t", " ", "show", " ", "up", " ", "in", " ", "cache", " ", "(", "we", " ", "have", "n", "'", "t", " ", "\"", "hit", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "it", " ", "ye", "t", " ", "usi", "ng", " ", "a", " ", "GET", " ", "/", "images", "/", "1", " ", "..._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "verify", "\\u", "no", "\\u", "cache", "d\\u", "images_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Grab", " ", "the", " ", "image_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "/", "%", "s", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "image", " ", "now", " ", "in", " ", "cache_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "cache", "d\\u", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "cache", "d\\u", "images", "'_", "in_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cache", "d\\u", "images_", "=_", "data_", "[_", "'", "cache", "d\\u", "images", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "1_", ",_", "len_", "(_", "cache", "d\\u", "images_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "image", "\\u", "id_", ",_", "cache", "d\\u", "images_", "[_", "0_", "]_", "[_", "'", "image", "\\u", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "0_", ",_", "cache", "d\\u", "images_", "[_", "0_", "]_", "[_", "'", "hits", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Hit", " ", "the", " ", "image_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "/", "%", "s", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "image", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "image", " ", "hits", " ", "increase", "d", " ", "in", " ", "output", " ", "of", " ", "manage", " ", "GET_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "cache", "d\\u", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "cache", "d\\u", "images", "'_", "in_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cache", "d\\u", "images_", "=_", "data_", "[_", "'", "cache", "d\\u", "images", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "1_", ",_", "len_", "(_", "cache", "d\\u", "images_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "image", "\\u", "id_", ",_", "cache", "d\\u", "images_", "[_", "0_", "]_", "[_", "'", "image", "\\u", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "1_", ",_", "cache", "d\\u", "images_", "[_", "0_", "]_", "[_", "'", "hits", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "stop", "\\u", "servers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Cache", "Manage", "Mid", "dle", "ware", "Test_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skip", "\\u", "if", "\\u", "disabled_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "cache", "\\u", "manage", "\\u", "delete", "\\u", "cache", "d\\u", "images_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "tha", "t", " ", "cache", "d", " ", "images", " ", "may", " ", "be", " ", "delete", "d", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cleanup_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start", "\\u", "servers_", "(_", "**_", "self_", "._", "\\u\\u", "dict\\u\\u_", "._", "copy_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "api", "\\u", "port_", "=_", "self_", "._", "api", "\\u", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "registr", "y", "\\u", "port_", "=_", "self_", "._", "registr", "y", "\\u", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "verify", "\\u", "no", "\\u", "images_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ids_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "a", " ", "bunch", " ", "of", " ", "images", "..._", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "xrange_", "(_", "0_", ",_", "4_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ids_", "[_", "x_", "]_", "=_", "self_", "._", "add", "\\u", "image_", "(_", "\"", "Image", "%", "s", "\"_", "%_", "str_", "(_", "x_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "no", " ", "images", " ", "in", " ", "cache", "d\\u", "images", " ", "bec", "aus", "e", " ", "no", " ", "image", " ", "has", " ", "bee", "n", " ", "hit_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ye", "t", " ", "usi", "ng", " ", "a", " ", "GET", " ", "/", "images", "/", "<", "IMA", "GE", "\\u", "ID", ">", " ", "..._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "verify", "\\u", "no", "\\u", "cache", "d\\u", "images_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Grab", " ", "the", " ", "images", ",", " ", "essential", "ly", " ", "caching", " ", "them", "..._", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "xrange_", "(_", "0_", ",_", "4_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "images", "/", "%", "s", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ids_", "[_", "x_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Fail", "ed", " ", "to", " ", "find", " ", "image", " ", "%", "s", "\"_", "%_", "ids_", "[_", "x_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "images", " ", "now", " ", "in", " ", "cache_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "cache", "d\\u", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "cache", "d\\u", "images", "'_", "in_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cache", "d\\u", "images_", "=_", "data_", "[_", "'", "cache", "d\\u", "images", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "4_", ",_", "len_", "(_", "cache", "d\\u", "images_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "xrange_", "(_", "4_", ",_", "0_", ")_", ":_", "#", " ", "Cache", "d", " ", "images", " ", "return", "ed", " ", "last", " ", "modifi", "ed", " ", "order_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "ids_", "[_", "x_", "]_", ",_", "cache", "d\\u", "images_", "[_", "x_", "]_", "[_", "'", "image", "\\u", "id", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "0_", ",_", "cache", "d\\u", "images_", "[_", "x_", "]_", "[_", "'", "hits", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Delete", " ", "third", " ", "image", " ", "of", " ", "the", " ", "cache", "d", " ", "images", " ", "and", " ", "verify", " ", "no", " ", "long", "er", " ", "in", " ", "cache_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "cache", "d\\u", "images", "/", "%", "s", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ids_", "[_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "DELET", "E", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "cache", "d\\u", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "cache", "d\\u", "images", "'_", "in_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cache", "d\\u", "images_", "=_", "data_", "[_", "'", "cache", "d\\u", "images", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "3_", ",_", "len_", "(_", "cache", "d\\u", "images_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ids_", "[_", "2_", "]_", "not_", "in_", "[_", "x_", "[_", "'", "image", "\\u", "id", "'_", "]_", "for_", "x_", "in_", "cache", "d\\u", "images_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Delete", " ", "all", " ", "cache", "d", " ", "images", " ", "and", " ", "verify", " ", "not", "hing", " ", "in", " ", "cache_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "cache", "d\\u", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "DELET", "E", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "cache", "d\\u", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "cache", "d\\u", "images", "'_", "in_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cache", "d\\u", "images_", "=_", "data_", "[_", "'", "cache", "d\\u", "images", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "0_", ",_", "len_", "(_", "cache", "d\\u", "images_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "stop", "\\u", "servers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Cache", "Manage", "Mid", "dle", "ware", "Test_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skip", "\\u", "if", "\\u", "disabled_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "queue", "\\u", "and", "\\u", "prefetch", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "tha", "t", " ", "images", " ", "may", " ", "be", " ", "queue", "d", " ", "and", " ", "prefetch", "ed", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cleanup_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start", "\\u", "servers_", "(_", "**_", "self_", "._", "\\u\\u", "dict\\u\\u_", "._", "copy_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "api", "\\u", "port_", "=_", "self_", "._", "api", "\\u", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "registr", "y", "\\u", "port_", "=_", "self_", "._", "registr", "y", "\\u", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cache", "\\u", "config", "\\u", "filepath_", "=_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "test\\u", "dir_", ",_", "'", "etc", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "gla", "nce", "-", "cache", ".", "conf", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cache", "\\u", "file", "\\u", "options_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "image", "\\u", "cache", "\\u", "dir", "'_", ":_", "self_", "._", "api", "\\u", "server_", "._", "image", "\\u", "cache", "\\u", "dir_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "image", "\\u", "cache", "\\u", "driver", "'_", ":_", "self_", "._", "image", "\\u", "cache", "\\u", "driver_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "registr", "y", "\\u", "port", "'_", ":_", "self_", "._", "api", "\\u", "server_", "._", "registr", "y", "\\u", "port_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "log", "\\u", "file", "'_", ":_", "os_", "._", "path_", "._", "join_", "(_", "self_", "._", "test\\u", "dir_", ",_", "'", "cache", ".", "log", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "metadata", "\\u", "encrypt", "ion", "\\u", "key", "'_", ":_", "\"", "0123456", "7890", "123456789012", "3456", "789", "ab", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "cache", "\\u", "config", "\\u", "filepath_", ",_", "'", "w", "'_", ")_", "as_", "cache", "\\u", "file_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cache", "\\u", "file_", "._", "write_", "(_", "\"\"\"[", "DEF", "AUL", "T", "]", "\\", "10", ";", "debug", " ", "=", " ", "Tru", "e", "\\", "10", ";", "verbo", "se", " ", "=", " ", "Tru", "e", "\\", "10", ";", "image", "\\u", "cache", "\\u", "dir", " ", "=", " ", "%", "(", "image", "\\u", "cache", "\\u", "dir", ")", "s", "\\", "10", ";", "image", "\\u", "cache", "\\u", "driver", " ", "=", " ", "%", "(", "image", "\\u", "cache", "\\u", "driver", ")", "s", "\\", "10", ";", "registr", "y", "\\u", "host", " ", "=", " ", "0.", "0.", "0.", "0", "\\", "10", ";", "registr", "y", "\\u", "port", " ", "=", " ", "%", "(", "registr", "y", "\\u", "port", ")", "s", "\\", "10", ";", "metadata", "\\u", "encrypt", "ion", "\\u", "key", " ", "=", " ", "%", "(", "metadata", "\\u", "encrypt", "ion", "\\u", "key", ")", "s", "\\", "10", ";", "log", "\\u", "file", " ", "=", " ", "%", "(", "log", "\\u", "file", ")", "s", "\\", "10", ";\"\"\"_", "%_", "cache", "\\u", "file", "\\u", "options_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "with_", "open_", "(_", "cache", "\\u", "config", "\\u", "filepath_", "._", "replace_", "(_", "\".", "conf", "\"_", ",_", "\"-", "paste", ".", "ini", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "w", "'_", ")_", "as_", "paste", "\\u", "file_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "paste", "\\u", "file_", "._", "write_", "(_", "\"\"\"[", "app", ":", "gla", "nce", "-", "prune", "r", "]", "\\", "10", ";", "paste", ".", "app", "\\u", "factor", "y", " ", "=", " ", "gla", "nce", ".", "common", ".", "wsgi", ":", "app", "\\u", "factor", "y", "\\", "10", ";", "gla", "nce", ".", "app", "\\u", "factor", "y", " ", "=", " ", "gla", "nce", ".", "image", "\\u", "cache", ".", "prune", "r", ":", "Pru", "ner", "\\", "10", ";", "\\", "10", ";", "[", "app", ":", "gla", "nce", "-", "prefetch", "er", "]", "\\", "10", ";", "paste", ".", "app", "\\u", "factor", "y", " ", "=", " ", "gla", "nce", ".", "common", ".", "wsgi", ":", "app", "\\u", "factor", "y", "\\", "10", ";", "gla", "nce", ".", "app", "\\u", "factor", "y", " ", "=", " ", "gla", "nce", ".", "image", "\\u", "cache", ".", "prefetch", "er", ":", "Prefe", "tche", "r", "\\", "10", ";", "\\", "10", ";", "[", "app", ":", "gla", "nce", "-", "cleaner", "]", "\\", "10", ";", "paste", ".", "app", "\\u", "factor", "y", " ", "=", " ", "gla", "nce", ".", "common", ".", "wsgi", ":", "app", "\\u", "factor", "y", "\\", "10", ";", "gla", "nce", ".", "app", "\\u", "factor", "y", " ", "=", " ", "gla", "nce", ".", "image", "\\u", "cache", ".", "cleaner", ":", "Cleane", "r", "\\", "10", ";", "\\", "10", ";", "[", "app", ":", "gla", "nce", "-", "queue", "-", "image", "]", "\\", "10", ";", "paste", ".", "app", "\\u", "factor", "y", " ", "=", " ", "gla", "nce", ".", "common", ".", "wsgi", ":", "app", "\\u", "factor", "y", "\\", "10", ";", "gla", "nce", ".", "app", "\\u", "factor", "y", " ", "=", " ", "gla", "nce", ".", "image", "\\u", "cache", ".", "queue", "\\u", "image", ":", "Queue", "r", "\\", "10", ";\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "verify", "\\u", "no", "\\u", "images_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ids_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "a", " ", "bunch", " ", "of", " ", "images", "..._", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "xrange_", "(_", "0_", ",_", "4_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ids_", "[_", "x_", "]_", "=_", "self_", "._", "add", "\\u", "image_", "(_", "\"", "Image", "%", "s", "\"_", "%_", "str_", "(_", "x_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Queue", " ", "the", " ", "first", " ", "image", ",", " ", "verify", " ", "no", " ", "images", " ", "still", " ", "in", " ", "cache", " ", "after", " ", "queue", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "then", " ", "run", " ", "the", " ", "prefetch", "er", " ", "and", " ", "verify", " ", "tha", "t", " ", "the", " ", "image", " ", "is", " ", "then", " ", "in", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "cache_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "queue", "d\\u", "images", "/", "%", "s", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ids_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "PU", "T", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "verify", "\\u", "no", "\\u", "cache", "d\\u", "images_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "\"", "bin", "/", "gla", "nce", "-", "cache", "-", "prefetch", "er", " ", "--", "config", "-", "file", " ", "%", "s", "\"_", "%_", "cache", "\\u", "config", "\\u", "filepath_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "exitcode_", ",_", "out_", ",_", "err_", "=_", "execute_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "0_", ",_", "exitcode_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "''_", ",_", "out_", "._", "strip_", "(_", ")_", ",_", "out_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Verify", " ", "first", " ", "image", " ", "now", " ", "in", " ", "cache_", "\\u\\u\\uNL\\u\\u\\u_", "path_", "=_", "\"", "http", "://", "%", "s", ":", "%", "d", "/", "v1", "/", "cache", "d\\u", "images", "\"_", "%_", "(_", "\"", "0.", "0.", "0.", "0", "\"_", ",_", "self_", "._", "api", "\\u", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http_", "=_", "httplib2_", "._", "Http_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", ",_", "content_", "=_", "http_", "._", "request_", "(_", "path_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "json_", "._", "loads_", "(_", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "cache", "d\\u", "images", "'_", "in_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cache", "d\\u", "images_", "=_", "data_", "[_", "'", "cache", "d\\u", "images", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "1_", ",_", "len_", "(_", "cache", "d\\u", "images_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ids_", "[_", "0_", "]_", "in_", "[_", "r_", "[_", "'", "image", "\\u", "id", "'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "r_", "in_", "data_", "[_", "'", "cache", "d\\u", "images", "'_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "stop", "\\u", "servers_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 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,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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 ]
Unused import
agoragames/haigha/tests/unit/transports/gevent_transport_test.py
[ { "content": "'''\nCopyright (c) 2011-2015, Agora Games, LLC All rights reserved.\n\nhttps://github.com/agoragames/haigha/blob/master/LICENSE.txt\n'''\n\nfrom chai import Chai\nimport errno\nimport unittest\n\ntry:\n import gevent\n from gevent.coros import Semaphore\n from gevent import socket\n from gevent.pool import Pool\n\n from haigha.transports import gevent_transport\n from haigha.transports.gevent_transport import *\nexcept ImportError:\n import warnings\n warnings.warn('Failed to load gevent modules')\n gevent = None\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@unittest.skipIf(gevent is None, 'skipping gevent tests')\nclass GeventTransportTest(Chai):\n\n\n\n\n\n\n\n\n\n", "metadata": "root.GeventTransportTest", "header": "['module', '___EOS___']", "index": 23 }, { "content": " def setUp(self):\n super(GeventTransportTest, self).setUp()\n\n self.connection = mock()\n self.transport = GeventTransport(self.connection)\n self.transport._host = 'server:1234'", "metadata": "root.GeventTransportTest.setUp", "header": "['class', 'GeventTransportTest', '(', 'Chai', ')', ':', '___EOS___']", "index": 26 }, { "content": " def test_init(self):\n assert_equals(bytearray(), self.transport._buffer)\n assert_true(isinstance(self.transport._read_lock, Semaphore))\n assert_true(isinstance(self.transport._write_lock, Semaphore))", "metadata": "root.GeventTransportTest.test_init", "header": "['class', 'GeventTransportTest', '(', 'Chai', ')', ':', '___EOS___']", "index": 33 }, { "content": " def test_connect(self):\n with expect(mock(gevent_transport, 'super')).args(is_arg(GeventTransport), GeventTransport).returns(mock()) as parent:\n expect(parent.connect).args(\n ('host', 'port'), klass=is_arg(socket.socket)).returns('somedata')\n\n self.transport.connect(('host', 'port'))", "metadata": "root.GeventTransportTest.test_connect", "header": "['class', 'GeventTransportTest', '(', 'Chai', ')', ':', '___EOS___']", "index": 38 }, { "content": " def test_read(self):\n #self.transport._read_lock = mock()\n #expect( self.transport._read_lock.locked ).returns( False )\n expect(self.transport._read_lock.acquire)\n with expect(mock(gevent_transport, 'super')).args(is_arg(GeventTransport), GeventTransport).returns(mock()) as parent:\n expect(parent.read).args(timeout=None).returns('somedata')\n expect(self.transport._read_lock.release)\n expect(self.transport._read_wait.set)\n expect(self.transport._read_wait.clear)\n\n assert_equals('somedata', self.transport.read())", "metadata": "root.GeventTransportTest.test_read", "header": "['class', 'GeventTransportTest', '(', 'Chai', ')', ':', '___EOS___']", "index": 45 }, { "content": " def test_read_when_already_locked(self):\n expect(self.transport._read_lock.locked).returns(True)\n stub(self.transport._read_lock.acquire)\n stub(mock(gevent_transport, 'super'))\n stub(self.transport._read_lock.release)\n expect(self.transport._read_wait.wait)\n\n assert_equals(None, self.transport.read())", "metadata": "root.GeventTransportTest.test_read_when_already_locked", "header": "['class', 'GeventTransportTest', '(', 'Chai', ')', ':', '___EOS___']", "index": 57 }, { "content": " def test_read_when_raises_exception(self):\n #self.transport._read_lock = mock()\n expect(self.transport._read_lock.acquire)\n with expect(mock(gevent_transport, 'super')).args(is_arg(GeventTransport), GeventTransport).returns(mock()) as parent:\n expect(parent.read).args(timeout='5').raises(Exception('fail'))\n expect(self.transport._read_lock.release)\n\n assert_raises(Exception, self.transport.read, timeout='5')", "metadata": "root.GeventTransportTest.test_read_when_raises_exception", "header": "['class', 'GeventTransportTest', '(', 'Chai', ')', ':', '___EOS___']", "index": 66 }, { "content": " def test_buffer(self):\n #self.transport._read_lock = mock()\n expect(self.transport._read_lock.acquire)\n with expect(mock(gevent_transport, 'super')).args(is_arg(GeventTransport), GeventTransport).returns(mock()) as parent:\n expect(parent.buffer).args('datas')\n expect(self.transport._read_lock.release)\n\n self.transport.buffer('datas')", "metadata": "root.GeventTransportTest.test_buffer", "header": "['class', 'GeventTransportTest', '(', 'Chai', ')', ':', '___EOS___']", "index": 75 }, { "content": " def test_buffer_when_raises_exception(self):\n #self.transport._read_lock = mock()\n expect(self.transport._read_lock.acquire)\n with expect(mock(gevent_transport, 'super')).args(is_arg(GeventTransport), GeventTransport).returns(mock()) as parent:\n expect(parent.buffer).args('datas').raises(Exception('fail'))\n expect(self.transport._read_lock.release)\n\n assert_raises(Exception, self.transport.buffer, 'datas')", "metadata": "root.GeventTransportTest.test_buffer_when_raises_exception", "header": "['class', 'GeventTransportTest', '(', 'Chai', ')', ':', '___EOS___']", "index": 84 }, { "content": " def test_write(self):\n #self.transport._write_lock = mock()\n expect(self.transport._write_lock.acquire)\n with expect(mock(gevent_transport, 'super')).args(is_arg(GeventTransport), GeventTransport).returns(mock()) as parent:\n expect(parent.write).args('datas')\n expect(self.transport._write_lock.release)\n\n self.transport.write('datas')", "metadata": "root.GeventTransportTest.test_write", "header": "['class', 'GeventTransportTest', '(', 'Chai', ')', ':', '___EOS___']", "index": 93 }, { "content": " def test_write_when_raises_an_exception(self):\n #self.transport._write_lock = mock()\n expect(self.transport._write_lock.acquire)\n with expect(mock(gevent_transport, 'super')).args(is_arg(GeventTransport), GeventTransport).returns(mock()) as parent:\n expect(parent.write).args('datas').raises(Exception('fail'))\n expect(self.transport._write_lock.release)\n\n assert_raises(Exception, self.transport.write, 'datas')", "metadata": "root.GeventTransportTest.test_write_when_raises_an_exception", "header": "['class', 'GeventTransportTest', '(', 'Chai', ')', ':', '___EOS___']", "index": 102 }, { "content": "@unittest.skipIf(gevent is None, 'skipping gevent tests')\nclass GeventPoolTransportTest(Chai):\n\n\n", "metadata": "root.GeventPoolTransportTest", "header": "['module', '___EOS___']", "index": 111 }, { "content": " def setUp(self):\n super(GeventPoolTransportTest, self).setUp()\n\n self.connection = mock()\n self.transport = GeventPoolTransport(self.connection)\n self.transport._host = 'server:1234'", "metadata": "root.GeventPoolTransportTest.setUp", "header": "['class', 'GeventPoolTransportTest', '(', 'Chai', ')', ':', '___EOS___']", "index": 114 }, { "content": " def test_init(self):\n assert_equals(bytearray(), self.transport._buffer)\n assert_true(isinstance(self.transport._read_lock, Semaphore))\n assert_true(isinstance(self.transport.pool, Pool))\n\n trans = GeventPoolTransport(self.connection, pool='inground')\n assert_equals('inground', trans.pool)", "metadata": "root.GeventPoolTransportTest.test_init", "header": "['class', 'GeventPoolTransportTest', '(', 'Chai', ')', ':', '___EOS___']", "index": 121 }, { "content": " def test_process_channels(self):\n chs = [mock(), mock()]\n self.transport._pool = mock()\n\n expect(self.transport._pool.spawn).args(chs[0].process_frames)\n expect(self.transport._pool.spawn).args(chs[1].process_frames)\n\n self.transport.process_channels(chs)", "metadata": "root.GeventPoolTransportTest.test_process_channels", "header": "['class', 'GeventPoolTransportTest', '(', 'Chai', ')', ':', '___EOS___']", "index": 129 } ]
[ { "span": "import errno", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 12 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "'''", "\\", "10", ";", "Copy", "right", " ", "(", "c", ")", " ", "2011", "-", "201", "5", ",", " ", "Ag", "ora", " ", "Game", "s", ",", " ", "LLC", " ", "All", " ", "rights", " ", "reserve", "d", ".", "\\", "10", ";", "\\", "10", ";", "https", "://", "git", "hub", ".", "com", "/", "ago", "rag", "ames", "/", "hai", "gha", "/", "blob", "/", "master", "/", "LICENSE", ".", "txt", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "cha", "i_", "import_", "Cha", "i_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "errno_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "unittest_", "\\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_", "gevent_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gevent_", "._", "coros", "_", "import_", "Semaphore", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gevent_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gevent_", "._", "pool_", "import_", "Pool_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "hai", "gha", "_", "._", "transports_", "import_", "gev", "ent", "\\u", "transport_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "hai", "gha", "_", "._", "transports_", "._", "gev", "ent", "\\u", "transport_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "warnings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "warnings_", "._", "warn_", "(_", "'", "Fail", "ed", " ", "to", " ", "load", " ", "gev", "ent", " ", "module", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gevent_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "unittest_", "._", "skip", "If_", "(_", "gevent_", "is_", "None_", ",_", "'", "skip", "ping", " ", "gev", "ent", " ", "tests", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class_", "Ge", "vent", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Ge", "vent", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\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 ", " _", "super_", "(_", "Ge", "vent", "Transp", "ort", "Test_", ",_", "self_", ")_", "._", "set", "Up_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "connection_", "=_", "mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "transport_", "=_", "Ge", "vent", "Transport_", "(_", "self_", "._", "connection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "transport_", "._", "\\u", "host_", "=_", "'", "server", ":", "1234", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ge", "vent", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "init_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert", "\\u", "equals_", "(_", "bytearray_", "(_", ")_", ",_", "self_", "._", "transport_", "._", "\\u", "buffer_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "true_", "(_", "isinstance_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "lock_", ",_", "Semaphore", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "true_", "(_", "isinstance_", "(_", "self_", "._", "transport_", "._", "\\u", "write", "\\u", "lock_", ",_", "Semaphore", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ge", "vent", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "connect_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "expect_", "(_", "mock_", "(_", "gev", "ent", "\\u", "transport_", ",_", "'", "super", "'_", ")_", ")_", "._", "args_", "(_", "is", "\\u", "arg_", "(_", "Ge", "vent", "Transport_", ")_", ",_", "Ge", "vent", "Transport_", ")_", "._", "returns_", "(_", "mock_", "(_", ")_", ")_", "as_", "parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expect_", "(_", "parent_", "._", "connect_", ")_", "._", "args_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "host", "'_", ",_", "'", "port", "'_", ")_", ",_", "klass_", "=_", "is", "\\u", "arg_", "(_", "socket_", "._", "socket_", ")_", ")_", "._", "returns_", "(_", "'", "some", "data", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "transport_", "._", "connect_", "(_", "(_", "'", "host", "'_", ",_", "'", "port", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ge", "vent", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "read_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "transport", ".\\u", "read", "\\u", "lock", " ", "=", " ", "mock", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "expect", "(", " ", "self", ".", "transport", ".\\u", "read", "\\u", "lock", ".", "lock", "ed", " ", ").", "return", "s", "(", " ", "Fal", "se", " ", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "lock_", "._", "acquire_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "expect_", "(_", "mock_", "(_", "gev", "ent", "\\u", "transport_", ",_", "'", "super", "'_", ")_", ")_", "._", "args_", "(_", "is", "\\u", "arg_", "(_", "Ge", "vent", "Transport_", ")_", ",_", "Ge", "vent", "Transport_", ")_", "._", "returns_", "(_", "mock_", "(_", ")_", ")_", "as_", "parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expect_", "(_", "parent_", "._", "read_", ")_", "._", "args_", "(_", "timeout_", "=_", "None_", ")_", "._", "returns_", "(_", "'", "some", "data", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "lock_", "._", "release_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "wait_", "._", "set_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "wait_", "._", "clear_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "equals_", "(_", "'", "some", "data", "'_", ",_", "self_", "._", "transport_", "._", "read_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ge", "vent", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "read", "\\u", "whe", "n", "\\u", "alr", "ead", "y", "\\u", "locked_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "lock_", "._", "locked_", ")_", "._", "returns_", "(_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stub_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "lock_", "._", "acquire_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stub_", "(_", "mock_", "(_", "gev", "ent", "\\u", "transport_", ",_", "'", "super", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stub_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "lock_", "._", "release_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "wait_", "._", "wait_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "equals_", "(_", "None_", ",_", "self_", "._", "transport_", "._", "read_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ge", "vent", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "read", "\\u", "whe", "n", "\\u", "raise", "s", "\\u", "exception_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "transport", ".\\u", "read", "\\u", "lock", " ", "=", " ", "mock", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "lock_", "._", "acquire_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "expect_", "(_", "mock_", "(_", "gev", "ent", "\\u", "transport_", ",_", "'", "super", "'_", ")_", ")_", "._", "args_", "(_", "is", "\\u", "arg_", "(_", "Ge", "vent", "Transport_", ")_", ",_", "Ge", "vent", "Transport_", ")_", "._", "returns_", "(_", "mock_", "(_", ")_", ")_", "as_", "parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expect_", "(_", "parent_", "._", "read_", ")_", "._", "args_", "(_", "timeout_", "=_", "'", "5", "'_", ")_", "._", "raises_", "(_", "Exception_", "(_", "'", "fail", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "lock_", "._", "release_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "raises_", "(_", "Exception_", ",_", "self_", "._", "transport_", "._", "read_", ",_", "timeout_", "=_", "'", "5", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ge", "vent", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "buffer_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "transport", ".\\u", "read", "\\u", "lock", " ", "=", " ", "mock", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "lock_", "._", "acquire_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "expect_", "(_", "mock_", "(_", "gev", "ent", "\\u", "transport_", ",_", "'", "super", "'_", ")_", ")_", "._", "args_", "(_", "is", "\\u", "arg_", "(_", "Ge", "vent", "Transport_", ")_", ",_", "Ge", "vent", "Transport_", ")_", "._", "returns_", "(_", "mock_", "(_", ")_", ")_", "as_", "parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expect_", "(_", "parent_", "._", "buffer_", ")_", "._", "args_", "(_", "'", "datas", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "lock_", "._", "release_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "transport_", "._", "buffer_", "(_", "'", "datas", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ge", "vent", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "buffer", "\\u", "whe", "n", "\\u", "raise", "s", "\\u", "exception_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "transport", ".\\u", "read", "\\u", "lock", " ", "=", " ", "mock", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "lock_", "._", "acquire_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "expect_", "(_", "mock_", "(_", "gev", "ent", "\\u", "transport_", ",_", "'", "super", "'_", ")_", ")_", "._", "args_", "(_", "is", "\\u", "arg_", "(_", "Ge", "vent", "Transport_", ")_", ",_", "Ge", "vent", "Transport_", ")_", "._", "returns_", "(_", "mock_", "(_", ")_", ")_", "as_", "parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expect_", "(_", "parent_", "._", "buffer_", ")_", "._", "args_", "(_", "'", "datas", "'_", ")_", "._", "raises_", "(_", "Exception_", "(_", "'", "fail", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "lock_", "._", "release_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "raises_", "(_", "Exception_", ",_", "self_", "._", "transport_", "._", "buffer_", ",_", "'", "datas", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ge", "vent", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "write_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "transport", ".\\u", "write", "\\u", "lock", " ", "=", " ", "mock", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "write", "\\u", "lock_", "._", "acquire_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "expect_", "(_", "mock_", "(_", "gev", "ent", "\\u", "transport_", ",_", "'", "super", "'_", ")_", ")_", "._", "args_", "(_", "is", "\\u", "arg_", "(_", "Ge", "vent", "Transport_", ")_", ",_", "Ge", "vent", "Transport_", ")_", "._", "returns_", "(_", "mock_", "(_", ")_", ")_", "as_", "parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expect_", "(_", "parent_", "._", "write_", ")_", "._", "args_", "(_", "'", "datas", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "write", "\\u", "lock_", "._", "release_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "transport_", "._", "write_", "(_", "'", "datas", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ge", "vent", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "write", "\\u", "whe", "n", "\\u", "raise", "s", "\\u", "an", "\\u", "exception_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "self", ".", "transport", ".\\u", "write", "\\u", "lock", " ", "=", " ", "mock", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "write", "\\u", "lock_", "._", "acquire_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "expect_", "(_", "mock_", "(_", "gev", "ent", "\\u", "transport_", ",_", "'", "super", "'_", ")_", ")_", "._", "args_", "(_", "is", "\\u", "arg_", "(_", "Ge", "vent", "Transport_", ")_", ",_", "Ge", "vent", "Transport_", ")_", "._", "returns_", "(_", "mock_", "(_", ")_", ")_", "as_", "parent_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "expect_", "(_", "parent_", "._", "write_", ")_", "._", "args_", "(_", "'", "datas", "'_", ")_", "._", "raises_", "(_", "Exception_", "(_", "'", "fail", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "write", "\\u", "lock_", "._", "release_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert", "\\u", "raises_", "(_", "Exception_", ",_", "self_", "._", "transport_", "._", "write_", ",_", "'", "datas", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "unittest_", "._", "skip", "If_", "(_", "gevent_", "is_", "None_", ",_", "'", "skip", "ping", " ", "gev", "ent", " ", "tests", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class_", "Ge", "vent", "Poo", "l", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Ge", "vent", "Poo", "l", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\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 ", " _", "super_", "(_", "Ge", "vent", "Poo", "l", "Transp", "ort", "Test_", ",_", "self_", ")_", "._", "set", "Up_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "connection_", "=_", "mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "transport_", "=_", "Ge", "vent", "Poo", "l", "Transport_", "(_", "self_", "._", "connection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "transport_", "._", "\\u", "host_", "=_", "'", "server", ":", "1234", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ge", "vent", "Poo", "l", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "init_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert", "\\u", "equals_", "(_", "bytearray_", "(_", ")_", ",_", "self_", "._", "transport_", "._", "\\u", "buffer_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "true_", "(_", "isinstance_", "(_", "self_", "._", "transport_", "._", "\\u", "read", "\\u", "lock_", ",_", "Semaphore", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "true_", "(_", "isinstance_", "(_", "self_", "._", "transport_", "._", "pool_", ",_", "Pool_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "trans_", "=_", "Ge", "vent", "Poo", "l", "Transport_", "(_", "self_", "._", "connection_", ",_", "pool_", "=_", "'", "ingr", "ound", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert", "\\u", "equals_", "(_", "'", "ingr", "ound", "'_", ",_", "trans_", "._", "pool_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ge", "vent", "Poo", "l", "Transp", "ort", "Test_", "(_", "Cha", "i_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "process", "\\u", "channels_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chs", "_", "=_", "[_", "mock_", "(_", ")_", ",_", "mock_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "transport_", "._", "\\u", "pool_", "=_", "mock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "pool_", "._", "spawn_", ")_", "._", "args_", "(_", "chs", "_", "[_", "0_", "]_", "._", "process", "\\u", "frames_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expect_", "(_", "self_", "._", "transport_", "._", "\\u", "pool_", "._", "spawn_", ")_", "._", "args_", "(_", "chs", "_", "[_", "1_", "]_", "._", "process", "\\u", "frames_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "transport_", "._", "process", "\\u", "channels_", "(_", "chs", "_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
nltk/nltk/nltk/app/chartparser_app.py
[ { "content": " def mainloop(self, *args, **kwargs):\n return\n self._root.mainloop(*args, **kwargs)", "metadata": "root.ChartComparer.mainloop", "header": "['class', 'ChartComparer', '(', 'object', ')', ':', '___EOS___']", "index": 537 }, { "content": " def load_chart(self, *args):\n \"Load a chart from a pickle file\"\n filename = askopenfilename(filetypes=self.CHART_FILE_TYPES,\n defaultextension='.pickle')\n if not filename: return\n try:\n with open(filename, 'rb') as infile:\n chart = pickle.load(infile)\n self._chart = chart\n self._cv.update(chart)\n if self._matrix: self._matrix.set_chart(chart)\n if self._matrix: self._matrix.deselect_cell()\n if self._results: self._results.set_chart(chart)\n self._cp.set_chart(chart)\n except Exception as e:\n raise\n tkinter.messagebox.showerror('Error Loading Chart',\n 'Unable to open file: %r' % filename)", "metadata": "root.ChartParserApp.load_chart", "header": "['class', 'ChartParserApp', '(', 'object', ')', ':', '___EOS___']", "index": 1997 }, { "content": " def save_chart(self, *args):\n \"Save a chart to a pickle file\"\n filename = asksaveasfilename(filetypes=self.CHART_FILE_TYPES,\n defaultextension='.pickle')\n if not filename: return\n try:\n with open(filename, 'wb') as outfile:\n pickle.dump(self._chart, outfile)\n except Exception as e:\n raise\n tkinter.messagebox.showerror('Error Saving Chart',\n 'Unable to open file: %r' % filename)", "metadata": "root.ChartParserApp.save_chart", "header": "['class', 'ChartParserApp', '(', 'object', ')', ':', '___EOS___']", "index": 2016 } ]
[ { "span": "self._root.mainloop(*args, **kwargs)", "start_line": 539, "start_column": 8, "end_line": 539, "end_column": 44 }, { "span": "tkinter.messagebox.showerror('Error Loading Chart',\n 'Unable to open file: %r' % filename)", "start_line": 2013, "start_column": 12, "end_line": 2014, "end_column": 72 }, { "span": "tkinter.messagebox.showerror('Error Saving Chart',\n 'Unable to open file: %r' % filename)", "start_line": 2026, "start_column": 12, "end_line": 2027, "end_column": 72 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "class_", "Char", "t", "Compare", "r_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "mainloop_", "(_", "self_", ",_", "*_", "args_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "root_", "._", "mainloop_", "(_", "*_", "args_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Char", "t", "Parser", "App_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "load", "\\u", "chart_", "(_", "self_", ",_", "*_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Load", " ", "a", " ", "chart", " ", "from", " ", "a", " ", "pickle", " ", "file", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filename_", "=_", "ask", "openf", "ilename_", "(_", "filetypes_", "=_", "self_", "._", "CHAR", "T", "\\u", "FILE", "\\u", "TYPES_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "extension_", "=_", "'.", "pickle", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "filename_", ":_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "open_", "(_", "filename_", ",_", "'", "rb", "'_", ")_", "as_", "infile_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chart_", "=_", "pickle_", "._", "load_", "(_", "infile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "chart_", "=_", "chart_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "cv_", "._", "update_", "(_", "chart_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "matrix_", ":_", "self_", "._", "\\u", "matrix_", "._", "set\\u", "chart_", "(_", "chart_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "matrix_", ":_", "self_", "._", "\\u", "matrix_", "._", "deselect", "\\u", "cell_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "results_", ":_", "self_", "._", "\\u", "results_", "._", "set\\u", "chart_", "(_", "chart_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "cp_", "._", "set\\u", "chart_", "(_", "chart_", ")_", "\\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 ", " _", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tkinter_", "._", "messagebox_", "._", "shower", "ror_", "(_", "'", "Error", " ", "Load", "ing", " ", "Char", "t", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Una", "ble", " ", "to", " ", "open", " ", "file", ":", " ", "%", "r", "'_", "%_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Char", "t", "Parser", "App_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "save", "\\u", "chart_", "(_", "self_", ",_", "*_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "Save", " ", "a", " ", "chart", " ", "to", " ", "a", " ", "pickle", " ", "file", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "filename_", "=_", "asks", "ave", "asf", "ilename_", "(_", "filetypes_", "=_", "self_", "._", "CHAR", "T", "\\u", "FILE", "\\u", "TYPES_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default", "extension_", "=_", "'.", "pickle", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "filename_", ":_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "open_", "(_", "filename_", ",_", "'", "wb", "'_", ")_", "as_", "outfile_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pickle_", "._", "dump_", "(_", "self_", "._", "\\u", "chart_", ",_", "outfile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tkinter_", "._", "messagebox_", "._", "shower", "ror_", "(_", "'", "Error", " ", "Sav", "ing", " ", "Char", "t", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Una", "ble", " ", "to", " ", "open", " ", "file", ":", " ", "%", "r", "'_", "%_", "filename_", ")_", "\\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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused import
snowball-one/django-oscar-easyrec/run_tests.py
[ { "content": "#!/usr/bin/env python\nimport sys\n\nimport logging\nlogging.disable(logging.CRITICAL)\n\nfrom argparse import ArgumentParser\n\nimport tests.config\nfrom django_nose import NoseTestSuiteRunner\n\n\n\n\nif __name__ == '__main__':\n parser = ArgumentParser()\n parser.add_argument('-v', '--verbosity', dest='verbosity', default=1,\n type=int, help=\"Verbosity of output\")\n options, args = parser.parse_known_args()\n print 'Running tests'\n run_tests(options.verbosity)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def run_tests(verbosity):\n test_runner = NoseTestSuiteRunner(verbosity=verbosity)\n num_failures = test_runner.run_tests(['-s', '-x'])\n if num_failures:\n sys.exit(num_failures)", "metadata": "root.run_tests", "header": "['module', '___EOS___']", "index": 12 } ]
[ { "span": "import tests.config", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 19 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logging_", "._", "disable_", "(_", "logging_", "._", "CRITICAL_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "argparse_", "import_", "Arg", "ument", "Parser_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "tests_", "._", "config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django", "\\u", "nose_", "import_", "No", "se", "Test", "Suit", "e", "Runner_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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 ", " _", "parser_", "=_", "Arg", "ument", "Parser_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'-", "v", "'_", ",_", "'--", "verbo", "sity", "'_", ",_", "dest_", "=_", "'", "verbo", "sity", "'_", ",_", "default_", "=_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "type_", "=_", "int_", ",_", "help_", "=_", "\"", "Verbos", "it", "y", " ", "of", " ", "output", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "options_", ",_", "args_", "=_", "parser_", "._", "parse", "\\u", "know", "n", "\\u", "args_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Run", "ning", " ", "tests", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "run", "\\u", "tests_", "(_", "options_", "._", "verbosity_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "run", "\\u", "tests_", "(_", "verbosity_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test\\u", "runner_", "=_", "No", "se", "Test", "Suit", "e", "Runner_", "(_", "verbosity_", "=_", "verbosity_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "failures_", "=_", "test\\u", "runner_", "._", "run", "\\u", "tests_", "(_", "[_", "'-", "s", "'_", ",_", "'-", "x", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "num", "\\u", "failures_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sys_", "._", "exit_", "(_", "num", "\\u", "failures_", ")_", "\\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, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
dcramer/django-compositepks/django/contrib/gis/geos/prototypes/__init__.py
[ { "content": "\"\"\"\n This module contains all of the GEOS ctypes function prototypes. Each\n prototype handles the interaction between the GEOS library and Python\n via ctypes.\n\"\"\"\n\n# Coordinate sequence routines.\nfrom django.contrib.gis.geos.prototypes.coordseq import create_cs, get_cs, \\\n cs_clone, cs_getordinate, cs_setordinate, cs_getx, cs_gety, cs_getz, \\\n cs_setx, cs_sety, cs_setz, cs_getsize, cs_getdims\n\n# Geometry routines.\nfrom django.contrib.gis.geos.prototypes.geom import from_hex, from_wkb, from_wkt, \\\n create_point, create_linestring, create_linearring, create_polygon, create_collection, \\\n destroy_geom, get_extring, get_intring, get_nrings, get_geomn, geom_clone, \\\n geos_normalize, geos_type, geos_typeid, geos_get_srid, geos_set_srid, \\\n get_dims, get_num_coords, get_num_geoms, \\\n to_hex, to_wkb, to_wkt\n\n# Miscellaneous routines.\nfrom django.contrib.gis.geos.prototypes.misc import geos_area, geos_distance, geos_length\n\n# Predicates\nfrom django.contrib.gis.geos.prototypes.predicates import geos_hasz, geos_isempty, \\\n geos_isring, geos_issimple, geos_isvalid, geos_contains, geos_crosses, \\\n geos_disjoint, geos_equals, geos_equalsexact, geos_intersects, \\\n geos_intersects, geos_overlaps, geos_relatepattern, geos_touches, geos_within\n\n# Topology routines\nfrom django.contrib.gis.geos.prototypes.topology import \\\n geos_boundary, geos_buffer, geos_centroid, geos_convexhull, geos_difference, \\\n geos_envelope, geos_intersection, geos_pointonsurface, geos_preservesimplify, \\\n geos_simplify, geos_symdifference, geos_union, geos_relate\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from django.contrib.gis.geos.prototypes.coordseq import create_cs, get_cs, \\\n cs_clone, cs_getordinate, cs_setordinate, cs_getx, cs_gety, cs_getz, \\\n cs_setx, cs_sety, cs_setz, cs_getsize, cs_getdims", "start_line": 7, "start_column": 0, "end_line": 9, "end_column": 53 }, { "span": "from django.contrib.gis.geos.prototypes.geom import from_hex, from_wkb, from_wkt, \\\n create_point, create_linestring, create_linearring, create_polygon, create_collection, \\\n destroy_geom, get_extring, get_intring, get_nrings, get_geomn, geom_clone, \\\n geos_normalize, geos_type, geos_typeid, geos_get_srid, geos_set_srid, \\\n get_dims, get_num_coords, get_num_geoms, \\\n to_hex, to_wkb, to_wkt", "start_line": 12, "start_column": 0, "end_line": 17, "end_column": 26 }, { "span": "from django.contrib.gis.geos.prototypes.misc import geos_area, geos_distance, geos_length", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 89 }, { "span": "from django.contrib.gis.geos.prototypes.predicates import geos_hasz, geos_isempty, \\\n geos_isring, geos_issimple, geos_isvalid, geos_contains, geos_crosses, \\\n geos_disjoint, geos_equals, geos_equalsexact, geos_intersects, \\\n geos_intersects, geos_overlaps, geos_relatepattern, geos_touches, geos_within", "start_line": 23, "start_column": 0, "end_line": 26, "end_column": 81 }, { "span": "from django.contrib.gis.geos.prototypes.topology import \\\n geos_boundary, geos_buffer, geos_centroid, geos_convexhull, geos_difference, \\\n geos_envelope, geos_intersection, geos_pointonsurface, geos_preservesimplify, \\\n geos_simplify, geos_symdifference, geos_union, geos_relate", "start_line": 29, "start_column": 0, "end_line": 32, "end_column": 62 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", " ", "Thi", "s", " ", "module", " ", "contain", "s", " ", "all", " ", "of", " ", "the", " ", "GEO", "S", " ", "ctype", "s", " ", "function", " ", "protot", "ype", "s", ".", " ", "Ea", "ch", "\\", "10", ";", " ", "protot", "ype", " ", "handle", "s", " ", "the", " ", "interacti", "on", " ", "bet", "ween", " ", "the", " ", "GEO", "S", " ", "librar", "y", " ", "and", " ", "Pyth", "on", "\\", "10", ";", " ", "via", " ", "ctype", "s", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Coordinat", "e", " ", "sequence", " ", "routin", "es", "._", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "gis_", "._", "geos", "_", "._", "protot", "ypes_", "._", "coords", "eq_", "import_", "create", "\\u", "cs_", ",_", "get", "\\u", "cs_", ",_", "cs", "\\u", "clone_", ",_", "cs", "\\u", "geto", "rdin", "ate_", ",_", "cs", "\\u", "seto", "rdin", "ate_", ",_", "cs", "\\u", "get", "x_", ",_", "cs", "\\u", "get", "y_", ",_", "cs", "\\u", "get", "z_", ",_", "cs", "\\u", "set", "x_", ",_", "cs", "\\u", "set", "y_", ",_", "cs", "\\u", "set", "z_", ",_", "cs", "\\u", "getsize_", ",_", "cs", "\\u", "getd", "ims_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Geometr", "y", " ", "routin", "es", "._", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "gis_", "._", "geos", "_", "._", "protot", "ypes_", "._", "geom_", "import_", "from", "\\u", "hex_", ",_", "from", "\\u", "wk", "b_", ",_", "from", "\\u", "wkt_", ",_", "create", "\\u", "point_", ",_", "create", "\\u", "linest", "ring_", ",_", "create", "\\u", "linear", "ring_", ",_", "create", "\\u", "polygon_", ",_", "create", "\\u", "collection_", ",_", "destroy", "\\u", "geom_", ",_", "get", "\\u", "extr", "ing_", ",_", "get", "\\u", "intr", "ing_", ",_", "get", "\\u", "nr", "ings_", ",_", "get", "\\u", "geom", "n_", ",_", "geom", "\\u", "clone_", ",_", "geos", "\\u", "normalize_", ",_", "geos", "\\u", "type_", ",_", "geos", "\\u", "typeid", "_", ",_", "geos", "\\u", "get", "\\u", "srid_", ",_", "geos", "\\u", "set\\u", "srid_", ",_", "get", "\\u", "dims_", ",_", "get", "\\u", "num", "\\u", "coords_", ",_", "get", "\\u", "num", "\\u", "geom", "s_", ",_", "to", "\\u", "hex_", ",_", "to", "\\u", "wk", "b_", ",_", "to", "\\u", "wkt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Mis", "cell", "ane", "ous", " ", "routin", "es", "._", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "gis_", "._", "geos", "_", "._", "protot", "ypes_", "._", "misc_", "import_", "geos", "\\u", "area_", ",_", "geos", "\\u", "distance_", ",_", "geos", "\\u", "length_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Predicate", "s_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "gis_", "._", "geos", "_", "._", "protot", "ypes_", "._", "predicates_", "import_", "geos", "\\u", "has", "z_", ",_", "geos", "\\u", "ise", "mpty", "_", ",_", "geos", "\\u", "isr", "ing_", ",_", "geos", "\\u", "iss", "impl", "e_", ",_", "geos", "\\u", "is", "valid_", ",_", "geos", "\\u", "contains_", ",_", "geos", "\\u", "crosse", "s_", ",_", "geos", "\\u", "disj", "oint_", ",_", "geos", "\\u", "equals_", ",_", "geos", "\\u", "equals", "exact_", ",_", "geos", "\\u", "intersect", "s_", ",_", "geos", "\\u", "intersect", "s_", ",_", "geos", "\\u", "overlaps_", ",_", "geos", "\\u", "relate", "pattern_", ",_", "geos", "\\u", "touche", "s_", ",_", "geos", "\\u", "within", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Topology", " ", "routin", "es_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "django_", "._", "contrib_", "._", "gis_", "._", "geos", "_", "._", "protot", "ypes_", "._", "topology_", "import_", "geos", "\\u", "boundary_", ",_", "geos", "\\u", "buffer_", ",_", "geos", "\\u", "centroid_", ",_", "geos", "\\u", "convex", "hull", "_", ",_", "geos", "\\u", "difference_", ",_", "geos", "\\u", "envelope_", ",_", "geos", "\\u", "intersection_", ",_", "geos", "\\u", "point", "ons", "urf", "ace_", ",_", "geos", "\\u", "preserve", "simplify_", ",_", "geos", "\\u", "simplify_", ",_", "geos", "\\u", "sym", "difference_", ",_", "geos", "\\u", "union_", ",_", "geos", "\\u", "relate", "_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
`__init__` method calls overridden method
peterbrittain/asciimatics/asciimatics/particles.py
[ { "content": "class ParticleEffect(with_metaclass(ABCMeta, Effect)):\n \"\"\"\n An Effect that uses a :py:obj:`.ParticleEmitter` to create the animation.\n\n To define a new ParticleEffect, you must implement the reset() method to\n construct a chain of ParticleEmitter objects and append them to the internal\n _active_systems list.\n \"\"\"\n\n\n\n", "metadata": "root.ParticleEffect", "header": "['module', '___EOS___']", "index": 197 }, { "content": " def __init__(self, screen, x, y, life_time, **kwargs):\n \"\"\"\n :param screen: The Screen being used for the Scene.\n :param x: The column (x coordinate) for the origin of the effect.\n :param y: The line (y coordinate) for the origin of the effect.\n :param life_time: The life time of the effect.\n\n Also see the common keyword arguments in :py:obj:`.Effect`.\n \"\"\"\n super(ParticleEffect, self).__init__(**kwargs)\n self._screen = screen\n self._x = x\n self._y = y\n self._life_time = life_time\n self._active_systems = []\n self.reset()", "metadata": "root.ParticleEffect.__init__", "header": "['class', 'ParticleEffect', '(', 'with_metaclass', '(', 'ABCMeta', ',', 'Effect', ')', ')', ':', '___EOS___']", "index": 206 }, { "content": " @abstractmethod\n def reset(self):\n \"\"\"\n Reset the particle effect back to its initial state. This must be\n implemented by the child classes.\n \"\"\"", "metadata": "root.ParticleEffect.reset", "header": "['class', 'ParticleEffect', '(', 'with_metaclass', '(', 'ABCMeta', ',', 'Effect', ')', ')', ':', '___EOS___']", "index": 223 }, { "content": " def _update(self, frame_no):\n # Take a copy in case a new system is added to the list this iteration.\n for system in copy(self._active_systems):\n if len(system.particles) > 0 or system.time_left > 0:\n system.update()\n else:\n self._active_systems.remove(system)", "metadata": "root.ParticleEffect._update", "header": "['class', 'ParticleEffect', '(', 'with_metaclass', '(', 'ABCMeta', ',', 'Effect', ')', ')', ':', '___EOS___']", "index": 230 }, { "content": " @property\n def stop_frame(self):\n return self._stop_frame", "metadata": "root.ParticleEffect.stop_frame", "header": "['class', 'ParticleEffect', '(', 'with_metaclass', '(', 'ABCMeta', ',', 'Effect', ')', ')', ':', '___EOS___']", "index": 238 }, { "content": "class StarFirework(ParticleEffect):\n \"\"\"\n Classic rocket with star explosion.\n \"\"\"\n\n\n\n", "metadata": "root.StarFirework", "header": "['module', '___EOS___']", "index": 707 }, { "content": " def __init__(self, screen, x, y, life_time, **kwargs):\n \"\"\"\n See :py:obj:`.ParticleEffect` for details of the parameters.\n \"\"\"\n super(StarFirework, self).__init__(screen, x, y, life_time, **kwargs)", "metadata": "root.StarFirework.__init__", "header": "['class', 'StarFirework', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 712 }, { "content": " def reset(self):\n self._active_systems = []\n self._active_systems.append(\n Rocket(self._screen, self._x, self._y, 10, on_destroy=self._next))", "metadata": "root.StarFirework.reset", "header": "['class', 'StarFirework', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 718 }, { "content": " def _next(self, parent):\n self._active_systems.append(\n StarExplosion(\n self._screen, parent.x, parent.y, self._life_time - 10,\n randint(6, 20), on_each=self._trail))", "metadata": "root.StarFirework._next", "header": "['class', 'StarFirework', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 723 }, { "content": " def _trail(self, parent):\n if len(self._active_systems) < 150 and randint(0, 100) < 50:\n self._active_systems.insert(\n 0, StarTrail(self._screen,\n parent.x,\n parent.y,\n 10,\n parent.colours[0][0]))", "metadata": "root.StarFirework._trail", "header": "['class', 'StarFirework', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 729 }, { "content": "class RingFirework(ParticleEffect):\n \"\"\"\n Classic rocket with ring explosion.\n \"\"\"\n\n\n", "metadata": "root.RingFirework", "header": "['module', '___EOS___']", "index": 739 }, { "content": " def __init__(self, screen, x, y, life_time, **kwargs):\n \"\"\"\n See :py:obj:`.ParticleEffect` for details of the parameters.\n \"\"\"\n super(RingFirework, self).__init__(screen, x, y, life_time, **kwargs)", "metadata": "root.RingFirework.__init__", "header": "['class', 'RingFirework', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 744 }, { "content": " def reset(self):\n self._active_systems = []\n self._active_systems.append(\n Rocket(self._screen, self._x, self._y, 10, on_destroy=self._next))", "metadata": "root.RingFirework.reset", "header": "['class', 'RingFirework', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 750 }, { "content": " def _next(self, parent):\n self._active_systems.append(RingExplosion(\n self._screen, parent.x, parent.y, self._life_time - 10))", "metadata": "root.RingFirework._next", "header": "['class', 'RingFirework', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 755 }, { "content": "class SerpentFirework(ParticleEffect):\n \"\"\"\n A firework where each trail changes direction.\n \"\"\"\n\n\n", "metadata": "root.SerpentFirework", "header": "['module', '___EOS___']", "index": 760 }, { "content": " def __init__(self, screen, x, y, life_time, **kwargs):\n \"\"\"\n See :py:obj:`.ParticleEffect` for details of the parameters.\n \"\"\"\n super(SerpentFirework, self).__init__(screen, x, y, life_time, **kwargs)", "metadata": "root.SerpentFirework.__init__", "header": "['class', 'SerpentFirework', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 765 }, { "content": " def reset(self):\n self._active_systems = []\n self._active_systems.append(\n Rocket(self._screen, self._x, self._y, 10, on_destroy=self._next))", "metadata": "root.SerpentFirework.reset", "header": "['class', 'SerpentFirework', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 771 }, { "content": " def _next(self, parent):\n self._active_systems.append(SerpentExplosion(\n self._screen, parent.x, parent.y, self._life_time - 10))", "metadata": "root.SerpentFirework._next", "header": "['class', 'SerpentFirework', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 776 }, { "content": "class PalmFirework(ParticleEffect):\n \"\"\"\n Classic palm shaped firework.\n \"\"\"\n\n\n\n", "metadata": "root.PalmFirework", "header": "['module', '___EOS___']", "index": 781 }, { "content": " def __init__(self, screen, x, y, life_time, **kwargs):\n \"\"\"\n See :py:obj:`.ParticleEffect` for details of the parameters.\n \"\"\"\n super(PalmFirework, self).__init__(screen, x, y, life_time, **kwargs)", "metadata": "root.PalmFirework.__init__", "header": "['class', 'PalmFirework', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 786 }, { "content": " def reset(self):\n self._active_systems = []\n self._active_systems.append(\n Rocket(self._screen, self._x, self._y, 10, on_destroy=self._next))", "metadata": "root.PalmFirework.reset", "header": "['class', 'PalmFirework', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 792 }, { "content": " def _next(self, parent):\n self._active_systems.append(PalmExplosion(\n self._screen, parent.x, parent.y, self._life_time - 10,\n on_each=self._trail))", "metadata": "root.PalmFirework._next", "header": "['class', 'PalmFirework', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 797 }, { "content": " def _trail(self, parent):\n if len(self._active_systems) < 100 and randint(0, 100) < 80:\n self._active_systems.insert(\n 0, StarTrail(self._screen,\n parent.x,\n parent.y,\n 10,\n parent.colours[0][0]))", "metadata": "root.PalmFirework._trail", "header": "['class', 'PalmFirework', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 802 }, { "content": "class Explosion(ParticleEffect):\n \"\"\"\n An explosion effect.\n \"\"\"\n\n", "metadata": "root.Explosion", "header": "['module', '___EOS___']", "index": 812 }, { "content": " def __init__(self, screen, x, y, life_time, **kwargs):\n \"\"\"\n See :py:obj:`.ParticleEffect` for details of the parameters.\n \"\"\"\n super(Explosion, self).__init__(screen, x, y, life_time, **kwargs)", "metadata": "root.Explosion.__init__", "header": "['class', 'Explosion', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 817 }, { "content": " def reset(self):\n self._active_systems = []\n self._active_systems.append(\n ExplosionFlames(self._screen, self._x, self._y, self._life_time))", "metadata": "root.Explosion.reset", "header": "['class', 'Explosion', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 823 }, { "content": "class DropScreen(ParticleEffect):\n \"\"\"\n Drop all the text on the screen as if it was subject to gravity.\n \"\"\"\n\n", "metadata": "root.DropScreen", "header": "['module', '___EOS___']", "index": 829 }, { "content": " def __init__(self, screen, life_time, **kwargs):\n \"\"\"\n See :py:obj:`.ParticleEffect` for details of the parameters.\n \"\"\"\n # No need for an origin as this uses the whole screen.\n super(DropScreen, self).__init__(screen, 0, 0, life_time, **kwargs)", "metadata": "root.DropScreen.__init__", "header": "['class', 'DropScreen', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 834 }, { "content": " def reset(self):\n self._active_systems = []\n self._active_systems.append(\n DropEmitter(self._screen, self._life_time))", "metadata": "root.DropScreen.reset", "header": "['class', 'DropScreen', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 841 }, { "content": "class ShootScreen(ParticleEffect):\n \"\"\"\n Shoot the screen out like a massive gunshot.\n \"\"\"\n\n", "metadata": "root.ShootScreen", "header": "['module', '___EOS___']", "index": 847 }, { "content": " def __init__(self, screen, x, y, life_time, **kwargs):\n \"\"\"\n See :py:obj:`.ParticleEffect` for details of the parameters.\n \"\"\"\n # No need for an origin as this uses the whole screen.\n super(ShootScreen, self).__init__(screen, x, y, life_time, **kwargs)", "metadata": "root.ShootScreen.__init__", "header": "['class', 'ShootScreen', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 852 }, { "content": " def reset(self):\n self._active_systems = []\n self._active_systems.append(\n ShotEmitter(self._screen, self._x, self._y, self._life_time))", "metadata": "root.ShootScreen.reset", "header": "['class', 'ShootScreen', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 859 }, { "content": "class Rain(ParticleEffect):\n \"\"\"\n Rain storm effect.\n \"\"\"\n\n\n", "metadata": "root.Rain", "header": "['module', '___EOS___']", "index": 865 }, { "content": " def __init__(self, screen, life_time, **kwargs):\n \"\"\"\n See :py:obj:`.ParticleEffect` for details of the parameters.\n \"\"\"\n # No need for an origin as this uses the whole screen.\n super(Rain, self).__init__(screen, 0, 0, life_time, **kwargs)", "metadata": "root.Rain.__init__", "header": "['class', 'Rain', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 870 }, { "content": " def reset(self):\n self._active_systems = []\n self._active_systems.append(\n RainSource(self._screen, self._life_time, self._collision))", "metadata": "root.Rain.reset", "header": "['class', 'Rain', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 877 }, { "content": " def _collision(self, particle):\n # Already calculated new position, so go back in history\n _, x, y, _, _, _ = particle.last()\n\n # Note that dx = dy, so simply calculation of next point to check.\n current_char = None\n dx = 0\n for dx in range(min(1, int(particle.dx))):\n next_point = self._screen.get_from(int(x + dx), int(y + dx))\n if next_point is None:\n current_char = None\n break\n current_char = next_point[0]\n if current_char != 32:\n break\n\n # If there's a collision, kill this drop and make a splash.\n if (current_char not in [32, None, ord(\"`\"), ord(\"\\\\\"), ord(\"v\")] or\n particle.y + dx >= self._screen.height):\n particle.time = particle.life_time\n self._active_systems.append(\n Splash(self._screen, x + dx - 1, y + dx - 1))", "metadata": "root.Rain._collision", "header": "['class', 'Rain', '(', 'ParticleEffect', ')', ':', '___EOS___']", "index": 882 } ]
[ { "span": "self.reset()", "start_line": 221, "start_column": 8, "end_line": 221, "end_column": 20 } ]
[ { "span": "def reset(self):", "start_line": 224, "start_column": 4, "end_line": 224, "end_column": 20 }, { "span": "def reset(self):", "start_line": 718, "start_column": 4, "end_line": 718, "end_column": 20 }, { "span": "def reset(self):", "start_line": 750, "start_column": 4, "end_line": 750, "end_column": 20 }, { "span": "def reset(self):", "start_line": 771, "start_column": 4, "end_line": 771, "end_column": 20 }, { "span": "def reset(self):", "start_line": 792, "start_column": 4, "end_line": 792, "end_column": 20 }, { "span": "def reset(self):", "start_line": 823, "start_column": 4, "end_line": 823, "end_column": 20 }, { "span": "def reset(self):", "start_line": 841, "start_column": 4, "end_line": 841, "end_column": 20 }, { "span": "def reset(self):", "start_line": 859, "start_column": 4, "end_line": 859, "end_column": 20 }, { "span": "def reset(self):", "start_line": 877, "start_column": 4, "end_line": 877, "end_column": 20 } ]
1
false
[ "[CLS]_", "`_", "\\u\\u", "init\\u\\u_", "`_", "method_", "calls_", "overrid", "den_", "method_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Parti", "cle", "Effect_", "(_", "with", "\\u", "metaclass_", "(_", "ABC", "Meta_", ",_", "Effect_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "An", " ", "Effe", "ct", " ", "tha", "t", " ", "use", "s", " ", "a", " ", ":", "py", ":", "obj", ":`", ".", "Parti", "cle", "Emitte", "r", "`", " ", "to", " ", "create", " ", "the", " ", "animati", "on", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "To", " ", "defin", "e", " ", "a", " ", "new", " ", "Parti", "cle", "Effe", "ct", ",", " ", "you", " ", "must", " ", "implement", " ", "the", " ", "reset", "()", " ", "method", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "construct", " ", "a", " ", "chain", " ", "of", " ", "Parti", "cle", "Emitte", "r", " ", "object", "s", " ", "and", " ", "append", " ", "them", " ", "to", " ", "the", " ", "internal", "\\", "10", ";", " ", " ", " ", " ", "\\u", "active", "\\u", "system", "s", " ", "list", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Parti", "cle", "Effect_", "(_", "with", "\\u", "metaclass_", "(_", "ABC", "Meta_", ",_", "Effect_", ")_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "screen_", ",_", "x_", ",_", "y_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "screen", ":", " ", "The", " ", "Scr", "een", " ", "bei", "ng", " ", "used", " ", "for", " ", "the", " ", "Scen", "e", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "x", ":", " ", "The", " ", "column", " ", "(", "x", " ", "coordinate", ")", " ", "for", " ", "the", " ", "orig", "in", " ", "of", " ", "the", " ", "effect", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "y", ":", " ", "The", " ", "line", " ", "(", "y", " ", "coordinate", ")", " ", "for", " ", "the", " ", "orig", "in", " ", "of", " ", "the", " ", "effect", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "life", "\\u", "time", ":", " ", "The", " ", "life", " ", "time", " ", "of", " ", "the", " ", "effect", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Al", "so", " ", "see", " ", "the", " ", "common", " ", "keyw", "ord", " ", "argu", "ment", "s", " ", "in", " ", ":", "py", ":", "obj", ":`", ".", "Effe", "ct", "`.", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Parti", "cle", "Effect_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "screen_", "=_", "screen_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "x_", "=_", "x_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "y_", "=_", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "life", "\\u", "time_", "=_", "life", "\\u", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "active", "\\u", "systems_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "reset_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Parti", "cle", "Effect_", "(_", "with", "\\u", "metaclass_", "(_", "ABC", "Meta_", ",_", "Effect_", ")_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "abstractmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "reset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Reset", " ", "the", " ", "partic", "le", " ", "effect", " ", "back", " ", "to", " ", "its", " ", "initial", " ", "state", ".", " ", " ", "Thi", "s", " ", "must", " ", "be", "\\", "10", ";", " ", " ", " ", " ", "implemented", " ", "by", " ", "the", " ", "child", " ", "classe", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Parti", "cle", "Effect_", "(_", "with", "\\u", "metaclass_", "(_", "ABC", "Meta_", ",_", "Effect_", ")_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "update_", "(_", "self_", ",_", "frame", "\\u", "no_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Tak", "e", " ", "a", " ", "copy", " ", "in", " ", "case", " ", "a", " ", "new", " ", "system", " ", "is", " ", "adde", "d", " ", "to", " ", "the", " ", "list", " ", "this", " ", "iterati", "on", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "system_", "in_", "copy_", "(_", "self_", "._", "\\u", "active", "\\u", "systems_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "system_", "._", "particles_", ")_", ">_", "0_", "or_", "system_", "._", "time", "\\u", "left_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "system_", "._", "update_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "remove_", "(_", "system_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Parti", "cle", "Effect_", "(_", "with", "\\u", "metaclass_", "(_", "ABC", "Meta_", ",_", "Effect_", ")_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "property_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "stop", "\\u", "frame_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "stop", "\\u", "frame_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "Star", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Classic", " ", "rocket", " ", "with", " ", "star", " ", "explosi", "on", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Star", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "screen_", ",_", "x_", ",_", "y_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "See", " ", ":", "py", ":", "obj", ":`", ".", "Parti", "cle", "Effe", "ct", "`", " ", "for", " ", "deta", "il", "s", " ", "of", " ", "the", " ", "parameter", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Star", "Fire", "work_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "screen_", ",_", "x_", ",_", "y_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Star", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "append_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Rock", "et_", "(_", "self_", "._", "\\u", "screen_", ",_", "self_", "._", "\\u", "x_", ",_", "self_", "._", "\\u", "y_", ",_", "10_", ",_", "on", "\\u", "destroy_", "=_", "self_", "._", "\\u", "next_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Star", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "next_", "(_", "self_", ",_", "parent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "append_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Star", "Explo", "sion_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "screen_", ",_", "parent_", "._", "x_", ",_", "parent_", "._", "y_", ",_", "self_", "._", "\\u", "life", "\\u", "time_", "-_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "randint_", "(_", "6_", ",_", "20_", ")_", ",_", "on", "\\u", "each_", "=_", "self_", "._", "\\u", "trail_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Star", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "trail_", "(_", "self_", ",_", "parent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "self_", "._", "\\u", "active", "\\u", "systems_", ")_", "<_", "150_", "and_", "randint_", "(_", "0_", ",_", "100_", ")_", "<_", "50_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "insert_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "0_", ",_", "Star", "Trail", "_", "(_", "self_", "._", "\\u", "screen_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "parent_", "._", "x_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "parent_", "._", "y_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "parent_", "._", "colours_", "[_", "0_", "]_", "[_", "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_", "class_", "Ring", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Classic", " ", "rocket", " ", "with", " ", "ring", " ", "explosi", "on", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Ring", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "screen_", ",_", "x_", ",_", "y_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "See", " ", ":", "py", ":", "obj", ":`", ".", "Parti", "cle", "Effe", "ct", "`", " ", "for", " ", "deta", "il", "s", " ", "of", " ", "the", " ", "parameter", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Ring", "Fire", "work_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "screen_", ",_", "x_", ",_", "y_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ring", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "append_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Rock", "et_", "(_", "self_", "._", "\\u", "screen_", ",_", "self_", "._", "\\u", "x_", ",_", "self_", "._", "\\u", "y_", ",_", "10_", ",_", "on", "\\u", "destroy_", "=_", "self_", "._", "\\u", "next_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ring", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "next_", "(_", "self_", ",_", "parent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "append_", "(_", "Ring", "Explo", "sion_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "screen_", ",_", "parent_", "._", "x_", ",_", "parent_", "._", "y_", ",_", "self_", "._", "\\u", "life", "\\u", "time_", "-_", "10_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "Ser", "pent", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "firew", "ork", " ", "where", " ", "each", " ", "trail", " ", "change", "s", " ", "direction", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Ser", "pent", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "screen_", ",_", "x_", ",_", "y_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "See", " ", ":", "py", ":", "obj", ":`", ".", "Parti", "cle", "Effe", "ct", "`", " ", "for", " ", "deta", "il", "s", " ", "of", " ", "the", " ", "parameter", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Ser", "pent", "Fire", "work_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "screen_", ",_", "x_", ",_", "y_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ser", "pent", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "append_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Rock", "et_", "(_", "self_", "._", "\\u", "screen_", ",_", "self_", "._", "\\u", "x_", ",_", "self_", "._", "\\u", "y_", ",_", "10_", ",_", "on", "\\u", "destroy_", "=_", "self_", "._", "\\u", "next_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ser", "pent", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "next_", "(_", "self_", ",_", "parent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "append_", "(_", "Ser", "pent", "Explo", "sion_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "screen_", ",_", "parent_", "._", "x_", ",_", "parent_", "._", "y_", ",_", "self_", "._", "\\u", "life", "\\u", "time_", "-_", "10_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "Pal", "m", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Classic", " ", "pal", "m", " ", "shaped", " ", "firew", "ork", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Pal", "m", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "screen_", ",_", "x_", ",_", "y_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "See", " ", ":", "py", ":", "obj", ":`", ".", "Parti", "cle", "Effe", "ct", "`", " ", "for", " ", "deta", "il", "s", " ", "of", " ", "the", " ", "parameter", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Pal", "m", "Fire", "work_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "screen_", ",_", "x_", ",_", "y_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Pal", "m", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "append_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Rock", "et_", "(_", "self_", "._", "\\u", "screen_", ",_", "self_", "._", "\\u", "x_", ",_", "self_", "._", "\\u", "y_", ",_", "10_", ",_", "on", "\\u", "destroy_", "=_", "self_", "._", "\\u", "next_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Pal", "m", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "next_", "(_", "self_", ",_", "parent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "append_", "(_", "Pal", "m", "Explo", "sion_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "\\u", "screen_", ",_", "parent_", "._", "x_", ",_", "parent_", "._", "y_", ",_", "self_", "._", "\\u", "life", "\\u", "time_", "-_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "on", "\\u", "each_", "=_", "self_", "._", "\\u", "trail_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Pal", "m", "Fire", "work_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "trail_", "(_", "self_", ",_", "parent_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "self_", "._", "\\u", "active", "\\u", "systems_", ")_", "<_", "100_", "and_", "randint_", "(_", "0_", ",_", "100_", ")_", "<_", "80_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "insert_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "0_", ",_", "Star", "Trail", "_", "(_", "self_", "._", "\\u", "screen_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "parent_", "._", "x_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "parent_", "._", "y_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "parent_", "._", "colours_", "[_", "0_", "]_", "[_", "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_", "class_", "Explo", "sion_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "An", " ", "explosi", "on", " ", "effect", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Explo", "sion_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "screen_", ",_", "x_", ",_", "y_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "See", " ", ":", "py", ":", "obj", ":`", ".", "Parti", "cle", "Effe", "ct", "`", " ", "for", " ", "deta", "il", "s", " ", "of", " ", "the", " ", "parameter", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Explo", "sion_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "screen_", ",_", "x_", ",_", "y_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Explo", "sion_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "append_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Explo", "sion", "Fla", "mes_", "(_", "self_", "._", "\\u", "screen_", ",_", "self_", "._", "\\u", "x_", ",_", "self_", "._", "\\u", "y_", ",_", "self_", "._", "\\u", "life", "\\u", "time_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Drop", "Screen_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Drop", " ", "all", " ", "the", " ", "text", " ", "on", " ", "the", " ", "screen", " ", "as", " ", "if", " ", "it", " ", "was", " ", "subject", " ", "to", " ", "gravity", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Drop", "Screen_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "screen_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "See", " ", ":", "py", ":", "obj", ":`", ".", "Parti", "cle", "Effe", "ct", "`", " ", "for", " ", "deta", "il", "s", " ", "of", " ", "the", " ", "parameter", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "No", " ", "need", " ", "for", " ", "an", " ", "orig", "in", " ", "as", " ", "this", " ", "use", "s", " ", "the", " ", "whole", " ", "screen", "._", "\\u\\u\\uNL\\u\\u\\u_", "super_", "(_", "Drop", "Screen_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "screen_", ",_", "0_", ",_", "0_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Drop", "Screen_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "append_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Drop", "Emitte", "r_", "(_", "self_", "._", "\\u", "screen_", ",_", "self_", "._", "\\u", "life", "\\u", "time_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Sho", "ot", "Screen_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Sho", "ot", " ", "the", " ", "screen", " ", "out", " ", "like", " ", "a", " ", "mass", "ive", " ", "gun", "sho", "t", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Sho", "ot", "Screen_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "screen_", ",_", "x_", ",_", "y_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "See", " ", ":", "py", ":", "obj", ":`", ".", "Parti", "cle", "Effe", "ct", "`", " ", "for", " ", "deta", "il", "s", " ", "of", " ", "the", " ", "parameter", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "No", " ", "need", " ", "for", " ", "an", " ", "orig", "in", " ", "as", " ", "this", " ", "use", "s", " ", "the", " ", "whole", " ", "screen", "._", "\\u\\u\\uNL\\u\\u\\u_", "super_", "(_", "Sho", "ot", "Screen_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "screen_", ",_", "x_", ",_", "y_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sho", "ot", "Screen_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "append_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Shot", "Emitte", "r_", "(_", "self_", "._", "\\u", "screen_", ",_", "self_", "._", "\\u", "x_", ",_", "self_", "._", "\\u", "y_", ",_", "self_", "._", "\\u", "life", "\\u", "time_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Rain", "_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Rain", " ", "storm", " ", "effect", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Rain", "_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "screen_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "See", " ", ":", "py", ":", "obj", ":`", ".", "Parti", "cle", "Effe", "ct", "`", " ", "for", " ", "deta", "il", "s", " ", "of", " ", "the", " ", "parameter", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "No", " ", "need", " ", "for", " ", "an", " ", "orig", "in", " ", "as", " ", "this", " ", "use", "s", " ", "the", " ", "whole", " ", "screen", "._", "\\u\\u\\uNL\\u\\u\\u_", "super_", "(_", "Rain", "_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "screen_", ",_", "0_", ",_", "0_", ",_", "life", "\\u", "time_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Rain", "_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "active", "\\u", "systems_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "active", "\\u", "systems_", "._", "append_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Rain", "Source_", "(_", "self_", "._", "\\u", "screen_", ",_", "self_", "._", "\\u", "life", "\\u", "time_", ",_", "self_", "._", "\\u", "collision_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Rain", "_", "(_", "Parti", "cle", "Effect_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "collision_", "(_", "self_", ",_", "particle_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Al", "read", "y", " ", "calculated", " ", "new", " ", "position", ",", " ", "so", " ", "go", " ", "back", " ", "in", " ", "history_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u_", ",_", "x_", ",_", "y_", ",_", "\\u_", ",_", "\\u_", ",_", "\\u_", "=_", "particle_", "._", "last_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Not", "e", " ", "tha", "t", " ", "dx", " ", "=", " ", "dy", ",", " ", "so", " ", "simp", "ly", " ", "calculati", "on", " ", "of", " ", "next", " ", "point", " ", "to", " ", "check", "._", "\\u\\u\\uNL\\u\\u\\u_", "current", "\\u", "char_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dx_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "dx_", "in_", "range_", "(_", "min_", "(_", "1_", ",_", "int_", "(_", "particle_", "._", "dx_", ")_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "next", "\\u", "point_", "=_", "self_", "._", "\\u", "screen_", "._", "get", "\\u", "from_", "(_", "int_", "(_", "x_", "+_", "dx_", ")_", ",_", "int_", "(_", "y_", "+_", "dx_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "next", "\\u", "point_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "current", "\\u", "char_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "current", "\\u", "char_", "=_", "next", "\\u", "point_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "current", "\\u", "char_", "!=_", "32_", ":_", "\\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_", "#", " ", "If", " ", "there", "'", "s", " ", "a", " ", "colli", "sion", ",", " ", "kill", " ", "this", " ", "drop", " ", "and", " ", "make", " ", "a", " ", "splash", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "current", "\\u", "char_", "not_", "in_", "[_", "32_", ",_", "None_", ",_", "ord_", "(_", "\"`", "\"_", ")_", ",_", "ord_", "(_", "\"\\\\\\\\\"_", ")_", ",_", "ord_", "(_", "\"", "v", "\"_", ")_", "]_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "particle_", "._", "y_", "+_", "dx_", ">=_", "self_", "._", "\\u", "screen_", "._", "height_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "particle_", "._", "time_", "=_", "particle_", "._", "life", "\\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 ]
Variable defined multiple times
nextml/NEXT/next/api/tests/test_api_dueling_multiprocessing.py
[ { "content": "def run_all(assert_200):\n\n app_id = 'DuelingBanditsPureExploration'\n num_arms = 300\n true_means = numpy.array(range(num_arms))/float(num_arms)\n total_pulls_per_client = 10\n\n num_experiments = 1\n\n # clients run in simultaneous fashion using multiprocessing library\n num_clients = 500\n\n pool = Pool(processes=num_clients) \n\n\n # input test parameters\n n = num_arms\n delta = 0.05\n supported_alg_ids = ['BR_LilUCB_b2','BR_Random_b2','BR_Thompson_b2']\n\n alg_list = []\n for alg_id in supported_alg_ids:\n alg_item = {}\n alg_item['alg_id'] = alg_id\n alg_item['alg_label'] = alg_id\n alg_item['params'] = {}\n alg_list.append(alg_item)\n params = {}\n params['proportions'] = []\n for algorithm in alg_list:\n params['proportions'].append( { 'alg_label': algorithm['alg_label'] , 'proportion':1./len(alg_list) } )\n algorithm_management_settings = {}\n algorithm_management_settings['mode'] = 'fixed_proportions'\n algorithm_management_settings['params'] = params\n\n\n\n #################################################\n # Test POST Experiment\n #################################################\n initExp_args_dict = {}\n initExp_args_dict['args'] = {}\n initExp_args_dict['args']['n'] = n\n initExp_args_dict['args']['failure_probability'] = delta\n initExp_args_dict['args']['participant_to_algorithm_management'] = 'one_to_many' # 'one_to_one' #optional field\n initExp_args_dict['args']['algorithm_management_settings'] = algorithm_management_settings #optional field\n initExp_args_dict['args']['alg_list'] = alg_list #optional field\n initExp_args_dict['args']['instructions'] = 'You want instructions, here are your test instructions'\n initExp_args_dict['args']['debrief'] = 'You want a debrief, here is your test debrief'\n initExp_args_dict['args']['context_type'] = 'text'\n initExp_args_dict['args']['context'] = 'Boom baby dueling works'\n initExp_args_dict['app_id'] = app_id\n initExp_args_dict['site_id'] = 'replace this with working site id'\n initExp_args_dict['site_key'] = 'replace this with working site key'\n\n exp_info = []\n for ell in range(num_experiments):\n url = \"http://\"+HOSTNAME+\"/api/experiment\"\n response = requests.post(url, json.dumps(initExp_args_dict), headers={'content-type':'application/json'})\n print \"POST initExp response =\",response.text, response.status_code\n if assert_200: assert response.status_code is 200\n initExp_response_dict = json.loads(response.text)\n\n exp_uid = initExp_response_dict['exp_uid']\n exp_key = initExp_response_dict['exp_key']\n\n exp_info.append( {'exp_uid':exp_uid,'exp_key':exp_key} )\n\n #################################################\n # Test GET Experiment\n #################################################\n url = \"http://\"+HOSTNAME+\"/api/experiment/\"+exp_uid+\"/\"+exp_key\n response = requests.get(url)\n print \"GET experiment response =\",response.text, response.status_code\n if assert_200: assert response.status_code is 200\n initExp_response_dict = json.loads(response.text)\n\n\n\n ###################################\n # Generate participants\n ###################################\n\n participants = []\n pool_args = []\n for i in range(num_clients):\n participant_uid = '%030x' % random.randrange(16**30)\n participants.append(participant_uid)\n\n experiment = numpy.random.choice(exp_info)\n exp_uid = experiment['exp_uid']\n exp_key = experiment['exp_key']\n pool_args.append( (exp_uid,exp_key,participant_uid,total_pulls_per_client,true_means,assert_200) )\n\n results = pool.map(simulate_one_client, pool_args)\n\n for result in results:\n print result", "metadata": "root.run_all", "header": "['module', '___EOS___']", "index": 15 } ]
[ { "span": "initExp_response_dict ", "start_line": 90, "start_column": 4, "end_line": 90, "end_column": 25 } ]
[ { "span": "initExp_response_dict ", "start_line": 76, "start_column": 4, "end_line": 76, "end_column": 25 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "run", "\\u", "all_", "(_", "assert", "\\u", "200_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "app", "\\u", "id_", "=_", "'", "Du", "elin", "g", "Band", "its", "Pur", "e", "Explo", "ration", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "arms", "_", "=_", "300_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "true", "\\u", "means_", "=_", "numpy_", "._", "array_", "(_", "range_", "(_", "num", "\\u", "arms", "_", ")_", ")_", "/_", "float_", "(_", "num", "\\u", "arms", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total", "\\u", "pull", "s", "\\u", "per", "\\u", "client_", "=_", "10_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "experiments_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "clients", " ", "run", " ", "in", " ", "simultaneous", " ", "fas", "hio", "n", " ", "usi", "ng", " ", "multipro", "cess", "ing", " ", "library_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "clients_", "=_", "500_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pool_", "=_", "Pool_", "(_", "processes_", "=_", "num", "\\u", "clients_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "input", " ", "test", " ", "parameters_", "\\u\\u\\uNL\\u\\u\\u_", "n_", "=_", "num", "\\u", "arms", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "delta_", "=_", "0.05_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "support", "ed", "\\u", "alg", "\\u", "ids_", "=_", "[_", "'", "BR", "\\u", "Lil", "UC", "B", "\\u", "b2", "'_", ",_", "'", "BR", "\\u", "Random", "\\u", "b2", "'_", ",_", "'", "BR", "\\u", "Tho", "mps", "on", "\\u", "b2", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "alg", "\\u", "list_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "alg", "\\u", "id_", "in_", "support", "ed", "\\u", "alg", "\\u", "ids_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "alg", "\\u", "item_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "alg", "\\u", "item_", "[_", "'", "alg", "\\u", "id", "'_", "]_", "=_", "alg", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "alg", "\\u", "item_", "[_", "'", "alg", "\\u", "label", "'_", "]_", "=_", "alg", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "alg", "\\u", "item_", "[_", "'", "params", "'_", "]_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "alg", "\\u", "list_", "._", "append_", "(_", "alg", "\\u", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "params_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "params_", "[_", "'", "proportion", "s", "'_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "algorithm_", "in_", "alg", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "params_", "[_", "'", "proportion", "s", "'_", "]_", "._", "append_", "(_", "{_", "'", "alg", "\\u", "label", "'_", ":_", "algorithm_", "[_", "'", "alg", "\\u", "label", "'_", "]_", ",_", "'", "proportion", "'_", ":_", "1._", "/_", "len_", "(_", "alg", "\\u", "list_", ")_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "algo", "rit", "hm", "\\u", "manage", "ment", "\\u", "settings_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "algo", "rit", "hm", "\\u", "manage", "ment", "\\u", "settings_", "[_", "'", "mode", "'_", "]_", "=_", "'", "fixed", "\\u", "proportion", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "algo", "rit", "hm", "\\u", "manage", "ment", "\\u", "settings_", "[_", "'", "params", "'_", "]_", "=_", "params_", "\\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_", "#", " ", "Test", " ", "POST", " ", "Experiment_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "#####", "_", "\\u\\u\\uNL\\u\\u\\u_", "init", "Exp", "\\u", "args", "\\u", "dict_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "args", "\\u", "dict_", "[_", "'", "args", "'_", "]_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "args", "\\u", "dict_", "[_", "'", "args", "'_", "]_", "[_", "'", "n", "'_", "]_", "=_", "n_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "args", "\\u", "dict_", "[_", "'", "args", "'_", "]_", "[_", "'", "fail", "ure", "\\u", "probabilit", "y", "'_", "]_", "=_", "delta_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "args", "\\u", "dict_", "[_", "'", "args", "'_", "]_", "[_", "'", "participa", "nt", "\\u", "to", "\\u", "algo", "rit", "hm", "\\u", "manage", "ment", "'_", "]_", "=_", "'", "one", "\\u", "to", "\\u", "many", "'_", "#", " ", "'", "one", "\\u", "to", "\\u", "one", "'", " ", " ", "#", "option", "al", " ", "field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "args", "\\u", "dict_", "[_", "'", "args", "'_", "]_", "[_", "'", "algo", "rit", "hm", "\\u", "manage", "ment", "\\u", "settings", "'_", "]_", "=_", "algo", "rit", "hm", "\\u", "manage", "ment", "\\u", "settings_", "#", "option", "al", " ", "field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "args", "\\u", "dict_", "[_", "'", "args", "'_", "]_", "[_", "'", "alg", "\\u", "list", "'_", "]_", "=_", "alg", "\\u", "list_", "#", "option", "al", " ", "field_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "args", "\\u", "dict_", "[_", "'", "args", "'_", "]_", "[_", "'", "instruct", "ion", "s", "'_", "]_", "=_", "'", "You", " ", "want", " ", "instruct", "ion", "s", ",", " ", "here", " ", "are", " ", "your", " ", "test", " ", "instruct", "ion", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "args", "\\u", "dict_", "[_", "'", "args", "'_", "]_", "[_", "'", "deb", "rie", "f", "'_", "]_", "=_", "'", "You", " ", "want", " ", "a", " ", "deb", "rie", "f", ",", " ", "here", " ", "is", " ", "your", " ", "test", " ", "deb", "rie", "f", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "args", "\\u", "dict_", "[_", "'", "args", "'_", "]_", "[_", "'", "context", "\\u", "type", "'_", "]_", "=_", "'", "text", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "args", "\\u", "dict_", "[_", "'", "args", "'_", "]_", "[_", "'", "context", "'_", "]_", "=_", "'", "Boo", "m", " ", "baby", " ", "due", "ling", " ", "works", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "args", "\\u", "dict_", "[_", "'", "app", "\\u", "id", "'_", "]_", "=_", "app", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "args", "\\u", "dict_", "[_", "'", "site", "\\u", "id", "'_", "]_", "=_", "'", "replace", " ", "this", " ", "with", " ", "working", " ", "site", " ", "id", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "args", "\\u", "dict_", "[_", "'", "site", "\\u", "key", "'_", "]_", "=_", "'", "replace", " ", "this", " ", "with", " ", "working", " ", "site", " ", "key", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "exp", "\\u", "info_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "ell_", "in_", "range_", "(_", "num", "\\u", "experiments_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", "=_", "\"", "http", "://\"_", "+_", "HOSTNAME", "_", "+_", "\"/", "api", "/", "experiment", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "requests_", "._", "post_", "(_", "url_", ",_", "json_", "._", "dumps_", "(_", "init", "Exp", "\\u", "args", "\\u", "dict_", ")_", ",_", "headers_", "=_", "{_", "'", "content", "-", "type", "'_", ":_", "'", "applica", "tion", "/", "json", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "POST", " ", "init", "Exp", " ", "response", " ", "=\"_", ",_", "response_", "._", "text_", ",_", "response_", "._", "status", "\\u", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "assert", "\\u", "200_", ":_", "assert_", "response_", "._", "status", "\\u", "code_", "is_", "200_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "response", "\\u", "dict_", "=_", "json_", "._", "loads_", "(_", "response_", "._", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "exp", "\\u", "uid_", "=_", "init", "Exp", "\\u", "response", "\\u", "dict_", "[_", "'", "exp", "\\u", "uid", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exp", "\\u", "key_", "=_", "init", "Exp", "\\u", "response", "\\u", "dict_", "[_", "'", "exp", "\\u", "key", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "exp", "\\u", "info_", "._", "append_", "(_", "{_", "'", "exp", "\\u", "uid", "'_", ":_", "exp", "\\u", "uid_", ",_", "'", "exp", "\\u", "key", "'_", ":_", "exp", "\\u", "key_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "#####", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Test", " ", "GET", " ", "Experiment_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "#####", "_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "\"", "http", "://\"_", "+_", "HOSTNAME", "_", "+_", "\"/", "api", "/", "experiment", "/\"_", "+_", "exp", "\\u", "uid_", "+_", "\"/\"_", "+_", "exp", "\\u", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "requests_", "._", "get_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "\"", "GET", " ", "experiment", " ", "response", " ", "=\"_", ",_", "response_", "._", "text_", ",_", "response_", "._", "status", "\\u", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "assert", "\\u", "200_", ":_", "assert_", "response_", "._", "status", "\\u", "code_", "is_", "200_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "init", "Exp", "\\u", "response", "\\u", "dict_", "=_", "json_", "._", "loads_", "(_", "response_", "._", "text_", ")_", "\\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_", "#", " ", "Generate", " ", "participants_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "##", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "participants_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pool", "\\u", "args_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "num", "\\u", "clients_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "participa", "nt", "\\u", "uid_", "=_", "'%", "030", "x", "'_", "%_", "random_", "._", "randrange_", "(_", "16_", "**_", "30_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "participants_", "._", "append_", "(_", "participa", "nt", "\\u", "uid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "experiment_", "=_", "numpy_", "._", "random_", "._", "choice_", "(_", "exp", "\\u", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exp", "\\u", "uid_", "=_", "experiment_", "[_", "'", "exp", "\\u", "uid", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exp", "\\u", "key_", "=_", "experiment_", "[_", "'", "exp", "\\u", "key", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pool", "\\u", "args_", "._", "append_", "(_", "(_", "exp", "\\u", "uid_", ",_", "exp", "\\u", "key_", ",_", "participa", "nt", "\\u", "uid_", ",_", "total", "\\u", "pull", "s", "\\u", "per", "\\u", "client_", ",_", "true", "\\u", "means_", ",_", "assert", "\\u", "200_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "results_", "=_", "pool_", "._", "map_", "(_", "simulat", "e\\u", "one", "\\u", "client_", ",_", "pool", "\\u", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "result_", "in_", "results_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
saltstack/salt/salt/daemons/test/test_multimaster.py
[ { "content": "# -*- coding: utf-8 -*-\n'''\nTests of utilities that support multiple masters in Salt Raet\n\n'''\nfrom __future__ import absolute_import\n# pylint: skip-file\n# pylint: disable=C0103\nimport sys\nfrom salt.ext.six.moves import map\nif sys.version_info < (2, 7):\n import unittest2 as unittest\nelse:\n import unittest\n\nimport os\nimport stat\nimport time\nimport tempfile\nimport shutil\n\nfrom ioflo.aid.odicting import odict\nfrom ioflo.aid.timing import Timer, StoreTimer\nfrom ioflo.base import storing\nfrom ioflo.base.consoling import getConsole\nconsole = getConsole()\n\nfrom raet import raeting\n\nfrom salt.daemons import parse_hostname, extract_masters\n\n\n\n\n\n\n\n\n\nif __name__ == '__main__' and __package__ is None:\n\n #console.reinit(verbosity=console.Wordage.concise)\n\n #runAll() #run all unittests\n\n runSome()#only run some\n\n #runOne('testParseHostname')\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def setUpModule():\n console.reinit(verbosity=console.Wordage.concise)", "metadata": "root.setUpModule", "header": "['module', '___EOS___']", "index": 32 }, { "content": "def tearDownModule():\n pass", "metadata": "root.tearDownModule", "header": "['module', '___EOS___']", "index": 35 }, { "content": "class BasicTestCase(unittest.TestCase):\n \"\"\"\"\"\"\n\n\n\n\n\n\n\n\n", "metadata": "root.BasicTestCase", "header": "['module', '___EOS___']", "index": 38 }, { "content": " def setUp(self):\n self.store = storing.Store(stamp=0.0)\n self.timer = StoreTimer(store=self.store, duration=1.0)\n self.port = 4506\n self.opts = dict(master_port=self.port)", "metadata": "root.BasicTestCase.setUp", "header": "['class', 'BasicTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 41 }, { "content": " def tearDown(self):\n pass", "metadata": "root.BasicTestCase.tearDown", "header": "['class', 'BasicTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 47 }, { "content": " def testParseHostname(self):\n '''\n Test parsing hostname provided according to syntax for opts['master']\n '''\n console.terse(\"{0}\\n\".format(self.testParseHostname.__doc__))\n\n self.assertEquals(parse_hostname('localhost', self.port),\n ('localhost', 4506))\n self.assertEquals(parse_hostname('127.0.0.1', self.port),\n ('127.0.0.1', 4506))\n self.assertEquals(parse_hostname('10.0.2.100', self.port),\n ('10.0.2.100', 4506))\n self.assertEquals(parse_hostname('me.example.com', self.port),\n ('me.example.com', 4506))\n self.assertEquals(parse_hostname(\n '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa',\n self.port),\n ('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa',\n 4506))\n self.assertEquals(parse_hostname('fe80::1%lo0', self.port),\n ('fe80::1%lo0', 4506))\n\n self.assertEquals(parse_hostname(' localhost ', self.port),\n ('localhost', 4506))\n self.assertEquals(parse_hostname(' 127.0.0.1 ', self.port),\n ('127.0.0.1', 4506))\n self.assertEquals(parse_hostname(' 10.0.2.100 ', self.port),\n ('10.0.2.100', 4506))\n self.assertEquals(parse_hostname(' me.example.com ', self.port),\n ('me.example.com', 4506))\n self.assertEquals(parse_hostname(\n ' 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa ',\n self.port),\n ('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa',\n 4506))\n self.assertEquals(parse_hostname(' fe80::1%lo0 ', self.port),\n ('fe80::1%lo0', 4506))\n\n\n self.assertEquals(parse_hostname('localhost 4510', self.port),\n ('localhost', 4510))\n self.assertEquals(parse_hostname('127.0.0.1 4510', self.port),\n ('127.0.0.1', 4510))\n self.assertEquals(parse_hostname('10.0.2.100 4510', self.port),\n ('10.0.2.100', 4510))\n self.assertEquals(parse_hostname('me.example.com 4510', self.port),\n ('me.example.com', 4510))\n self.assertEquals(parse_hostname(\n '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa 4510',\n self.port),\n ('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa',\n 4510))\n self.assertEquals(parse_hostname('fe80::1%lo0 4510', self.port),\n ('fe80::1%lo0', 4510))\n\n\n self.assertEquals(parse_hostname(' localhost 4510 ', self.port),\n ('localhost', 4510))\n self.assertEquals(parse_hostname(' 127.0.0.1 4510 ', self.port),\n ('127.0.0.1', 4510))\n self.assertEquals(parse_hostname(' 10.0.2.100 4510 ', self.port),\n ('10.0.2.100', 4510))\n self.assertEquals(parse_hostname(' me.example.com 4510 ', self.port),\n ('me.example.com', 4510))\n self.assertEquals(parse_hostname(\n ' 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa 4510 ',\n self.port),\n ('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa',\n 4510))\n self.assertEquals(parse_hostname(' fe80::1%lo0 4510 ', self.port),\n ('fe80::1%lo0', 4510))\n\n\n self.assertEquals(parse_hostname('localhost abcde', self.port), None)\n self.assertEquals(parse_hostname('127.0.0.1 a4510', self.port), None)\n self.assertEquals(parse_hostname(list([1, 2, 3]), self.port), None)\n self.assertEquals(parse_hostname(list(), self.port), None)\n self.assertEquals(parse_hostname(dict(a=1), self.port), None)\n self.assertEquals(parse_hostname(dict(), self.port), None)\n self.assertEquals(parse_hostname(4510, self.port), None)\n self.assertEquals(parse_hostname(('localhost', 4510), self.port), None)\n\n self.assertEquals(parse_hostname('localhost:4510', self.port),\n ('localhost', 4510))\n self.assertEquals(parse_hostname('127.0.0.1:4510', self.port),\n ('127.0.0.1', 4510))\n self.assertEquals(parse_hostname('10.0.2.100:4510', self.port),\n ('10.0.2.100', 4510))\n self.assertEquals(parse_hostname('me.example.com:4510', self.port),\n ('me.example.com', 4510))\n self.assertEquals(parse_hostname(\n '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa:4510',\n self.port),\n ('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa',\n 4510))\n self.assertEquals(parse_hostname('fe80::1%lo0:4510', self.port),\n ('fe80::1%lo0:4510', 4506))\n self.assertEquals(parse_hostname('localhost::4510', self.port),\n ('localhost::4510', 4506))", "metadata": "root.BasicTestCase.testParseHostname", "header": "['class', 'BasicTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 52 }, { "content": " def testExtractMastersSingle(self):\n '''\n Test extracting from master provided according to syntax for opts['master']\n '''\n console.terse(\"{0}\\n\".format(self.testExtractMastersSingle.__doc__))\n\n master = 'localhost'\n self.opts.update(master=master)\n self.assertEquals(extract_masters(self.opts),\n [\n dict(external=('localhost', 4506),\n internal=None),\n ])\n\n master = '127.0.0.1'\n self.opts.update(master=master)\n self.assertEquals(extract_masters(self.opts),\n [\n dict(external=('127.0.0.1', 4506),\n internal=None),\n ])\n\n master = 'localhost 4510'\n self.opts.update(master=master)\n self.assertEquals(extract_masters(self.opts),\n [\n dict(external=('localhost', 4510),\n internal=None),\n ])\n\n master = '127.0.0.1 4510'\n self.opts.update(master=master)\n self.assertEquals(extract_masters(self.opts),\n [\n dict(external=('127.0.0.1', 4510),\n internal=None),\n ])\n\n\n master = '10.0.2.23'\n self.opts.update(master=master)\n self.assertEquals(extract_masters(self.opts),\n [\n dict(external=('10.0.2.23', 4506),\n internal=None),\n ])\n\n master = 'me.example.com'\n self.opts.update(master=master)\n self.assertEquals(extract_masters(self.opts),\n [\n dict(external=('me.example.com', 4506),\n internal=None),\n ])\n\n master = '10.0.2.23 4510'\n self.opts.update(master=master)\n self.assertEquals(extract_masters(self.opts),\n [\n dict(external=('10.0.2.23', 4510),\n internal=None),\n ])\n\n master = 'me.example.com 4510'\n self.opts.update(master=master)\n self.assertEquals(extract_masters(self.opts),\n [\n dict(external=('me.example.com', 4510),\n internal=None),\n ])\n\n master = dict(external='10.0.2.23 4510')\n self.opts.update(master=master)\n self.assertEquals(extract_masters(self.opts),\n [\n dict(external=('10.0.2.23', 4510),\n internal=None),\n ])\n\n master = dict(external='10.0.2.23 4510', internal='')\n self.opts.update(master=master)\n self.assertEquals(extract_masters(self.opts),\n [\n dict(external=('10.0.2.23', 4510),\n internal=None),\n ])\n\n master = dict(internal='10.0.2.23 4510')\n self.opts.update(master=master)\n self.assertEquals(extract_masters(self.opts),[])", "metadata": "root.BasicTestCase.testExtractMastersSingle", "header": "['class', 'BasicTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 153 }, { "content": " def testExtractMastersMultiple(self):\n '''\n Test extracting from master provided according to syntax for opts['master']\n '''\n console.terse(\"{0}\\n\".format(self.testExtractMastersMultiple.__doc__))\n\n master = [\n 'localhost',\n '10.0.2.23',\n 'me.example.com'\n ]\n self.opts.update(master=master)\n self.assertEquals(extract_masters(self.opts),\n [\n {\n 'external': ('localhost', 4506),\n 'internal': None\n },\n {\n 'external': ('10.0.2.23', 4506),\n 'internal': None\n },\n {\n 'external': ('me.example.com', 4506),\n 'internal': None\n },\n ])\n\n master = [\n 'localhost 4510',\n '10.0.2.23 4510',\n 'me.example.com 4510'\n ]\n self.opts.update(master=master)\n self.assertEquals(extract_masters(self.opts),\n [\n {\n 'external': ('localhost', 4510),\n 'internal': None\n },\n {\n 'external': ('10.0.2.23', 4510),\n 'internal': None\n },\n {\n 'external': ('me.example.com', 4510),\n 'internal': None\n },\n ])\n\n master = [\n {\n 'external': 'localhost 4510',\n 'internal': '',\n },\n {\n 'external': 'me.example.com 4510',\n 'internal': '10.0.2.23 4510',\n },\n {\n 'external': 'you.example.com 4509',\n }\n ]\n self.opts.update(master=master)\n self.assertEquals(extract_masters(self.opts),\n [\n {\n 'external': ('localhost', 4510),\n 'internal': None\n },\n {\n 'external': ('me.example.com', 4510),\n 'internal': ('10.0.2.23', 4510)\n },\n {\n 'external': ('you.example.com', 4509),\n 'internal': None\n },\n ])", "metadata": "root.BasicTestCase.testExtractMastersMultiple", "header": "['class', 'BasicTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 245 }, { "content": "def runOne(test):\n '''\n Unittest Runner\n '''\n test = BasicTestCase(test)\n suite = unittest.TestSuite([test])\n unittest.TextTestRunner(verbosity=2).run(suite)", "metadata": "root.runOne", "header": "['module', '___EOS___']", "index": 326 }, { "content": "def runSome():\n '''\n Unittest runner\n '''\n tests = []\n names = [\n 'testParseHostname',\n 'testExtractMastersSingle',\n 'testExtractMastersMultiple',\n ]\n\n tests.extend(list(list(map(BasicTestCase, names))))\n\n suite = unittest.TestSuite(tests)\n unittest.TextTestRunner(verbosity=2).run(suite)", "metadata": "root.runSome", "header": "['module', '___EOS___']", "index": 334 }, { "content": "def runAll():\n '''\n Unittest runner\n '''\n suite = unittest.TestSuite()\n suite.addTest(unittest.TestLoader().loadTestsFromTestCase(BasicTestCase))\n\n unittest.TextTestRunner(verbosity=2).run(suite)", "metadata": "root.runAll", "header": "['module', '___EOS___']", "index": 350 } ]
[ { "span": "import os", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 9 }, { "span": "import stat", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 11 }, { "span": "import time", "start_line": 17, "start_column": 0, "end_line": 17, "end_column": 11 }, { "span": "import tempfile", "start_line": 18, "start_column": 0, "end_line": 18, "end_column": 15 }, { "span": "import shutil", "start_line": 19, "start_column": 0, "end_line": 19, "end_column": 13 }, { "span": "from ioflo.aid.odicting import odict", "start_line": 21, "start_column": 0, "end_line": 21, "end_column": 36 }, { "span": "from ioflo.aid.timing import Timer, StoreTimer", "start_line": 22, "start_column": 0, "end_line": 22, "end_column": 46 }, { "span": "from raet import raeting", "start_line": 27, "start_column": 0, "end_line": 27, "end_column": 24 } ]
[]
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", ";", "Test", "s", " ", "of", " ", "util", "iti", "es", " ", "tha", "t", " ", "support", " ", "multiple", " ", "master", "s", " ", "in", " ", "Sal", "t", " ", "Ra", "et", "\\", "10", ";", "\\", "10", ";'", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "abs", "olute", "\\u", "import_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "pylint", ":", " ", "skip", "-", "file_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "pylint", ":", " ", "disable", "=", "C0", "103_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "salt_", "._", "ext_", "._", "six_", "._", "moves_", "import_", "map_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sys_", "._", "version", "\\u", "info_", "<_", "(_", "2_", ",_", "7_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "unittest2_", "as_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "stat_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "tempfile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "io", "flo", "_", "._", "aid_", "._", "odi", "cti", "ng_", "import_", "odict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "io", "flo", "_", "._", "aid_", "._", "timing_", "import_", "Timer_", ",_", "Stor", "e", "Timer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "io", "flo", "_", "._", "base_", "import_", "stor", "ing_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "io", "flo", "_", "._", "base_", "._", "conso", "ling_", "import_", "get", "Console_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "console_", "=_", "get", "Console_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "ra", "et_", "import_", "ra", "eti", "ng_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "salt_", "._", "daemon", "s_", "import_", "parse", "\\u", "hostname_", ",_", "extract", "\\u", "masters_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "\\u\\u", "name\\u\\u_", "==_", "'\\u", "\\u", "main", "\\u\\u'_", "and_", "\\u\\u", "package", "\\u\\u_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "console", ".", "reini", "t", "(", "verbo", "sity", "=", "console", ".", "Word", "age", ".", "conc", "ise", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "run", "All", "()", " ", "#", "run", " ", "all", " ", "unittest", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "run", "Some", "_", "(_", ")_", "#", "only", " ", "run", " ", "some", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "run", "One", "('", "test", "Pars", "e", "Host", "name", "')", "_", "\\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_", "set", "Up", "Module_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "console_", "._", "reini", "t_", "(_", "verbosity_", "=_", "console_", "._", "Word", "age_", "._", "conc", "ise_", ")_", "\\u\\u\\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_", "tear", "Down", "Module_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Basic", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Basic", "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 ", " _", "self_", "._", "store_", "=_", "stor", "ing_", "._", "Store_", "(_", "stamp_", "=_", "0.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "timer_", "=_", "Stor", "e", "Timer_", "(_", "store_", "=_", "self_", "._", "store_", ",_", "duration_", "=_", "1.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "port_", "=_", "450", "6_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "=_", "dict_", "(_", "master", "\\u", "port_", "=_", "self_", "._", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Basic", "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 ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Basic", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Pars", "e", "Host", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "pars", "ing", " ", "host", "name", " ", "provided", " ", "according", " ", "to", " ", "synta", "x", " ", "for", " ", "opts", "['", "master", "']", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "console_", "._", "ters", "e_", "(_", "\"{", "0", "}\\\\", "n", "\"_", "._", "format_", "(_", "self_", "._", "test", "Pars", "e", "Host", "name_", "._", "\\u\\u", "doc\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "local", "host", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "local", "host", "'_", ",_", "450", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "127", ".0", ".0", ".1", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "127", ".0", ".0", ".1", "'_", ",_", "450", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "10.", "0.", "2.1", "00", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "10.", "0.", "2.1", "00", "'_", ",_", "450", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "me", ".", "example", ".", "com", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "me", ".", "example", ".", "com", "'_", ",_", "450", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "1.0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".", "ip6", ".", "arp", "a", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "1.0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".", "ip6", ".", "arp", "a", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "450", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "fe", "80", "::", "1", "%", "lo", "0", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "fe", "80", "::", "1", "%", "lo", "0", "'_", ",_", "450", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", " ", " ", "local", "host", " ", " ", " ", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "local", "host", "'_", ",_", "450", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", " ", " ", "127", ".0", ".0", ".1", " ", " ", " ", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "127", ".0", ".0", ".1", "'_", ",_", "450", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", " ", " ", " ", "10.", "0.", "2.1", "00", " ", " ", " ", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "10.", "0.", "2.1", "00", "'_", ",_", "450", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", " ", " ", "me", ".", "example", ".", "com", " ", " ", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "me", ".", "example", ".", "com", "'_", ",_", "450", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", " ", "1.0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".", "ip6", ".", "arp", "a", " ", " ", " ", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "1.0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".", "ip6", ".", "arp", "a", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "450", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", " ", " ", "fe", "80", "::", "1", "%", "lo", "0", " ", " ", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "fe", "80", "::", "1", "%", "lo", "0", "'_", ",_", "450", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "local", "host", " ", "451", "0", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "local", "host", "'_", ",_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "127", ".0", ".0", ".1", " ", "451", "0", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "127", ".0", ".0", ".1", "'_", ",_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "10.", "0.", "2.1", "00", " ", "451", "0", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "10.", "0.", "2.1", "00", "'_", ",_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "me", ".", "example", ".", "com", " ", "451", "0", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "me", ".", "example", ".", "com", "'_", ",_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "1.0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".", "ip6", ".", "arp", "a", " ", "451", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "1.0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".", "ip6", ".", "arp", "a", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "fe", "80", "::", "1", "%", "lo", "0", " ", "451", "0", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "fe", "80", "::", "1", "%", "lo", "0", "'_", ",_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", " ", " ", "local", "host", " ", "451", "0", " ", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "local", "host", "'_", ",_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", " ", " ", " ", "127", ".0", ".0", ".1", " ", " ", " ", " ", "451", "0", " ", " ", " ", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "127", ".0", ".0", ".1", "'_", ",_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", " ", " ", " ", "10.", "0.", "2.1", "00", " ", " ", " ", "451", "0", " ", " ", " ", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "10.", "0.", "2.1", "00", "'_", ",_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", " ", " ", " ", "me", ".", "example", ".", "com", " ", " ", " ", " ", "451", "0", " ", " ", " ", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "me", ".", "example", ".", "com", "'_", ",_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", " ", " ", " ", "1.0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".", "ip6", ".", "arp", "a", " ", " ", " ", "451", "0", " ", " ", " ", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "1.0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".", "ip6", ".", "arp", "a", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", " ", " ", " ", "fe", "80", "::", "1", "%", "lo", "0", " ", " ", " ", "451", "0", " ", " ", " ", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "fe", "80", "::", "1", "%", "lo", "0", "'_", ",_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "local", "host", " ", "abcde", "'_", ",_", "self_", "._", "port_", ")_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "127", ".0", ".0", ".1", " ", "a4", "510", "'_", ",_", "self_", "._", "port_", ")_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "list_", "(_", "[_", "1_", ",_", "2_", ",_", "3_", "]_", ")_", ",_", "self_", "._", "port_", ")_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "list_", "(_", ")_", ",_", "self_", "._", "port_", ")_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "dict_", "(_", "a_", "=_", "1_", ")_", ",_", "self_", "._", "port_", ")_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "dict_", "(_", ")_", ",_", "self_", "._", "port_", ")_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "451", "0_", ",_", "self_", "._", "port_", ")_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "(_", "'", "local", "host", "'_", ",_", "451", "0_", ")_", ",_", "self_", "._", "port_", ")_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "local", "host", ":", "451", "0", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "local", "host", "'_", ",_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "127", ".0", ".0", ".1", ":", "451", "0", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "127", ".0", ".0", ".1", "'_", ",_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "10.", "0.", "2.1", "00", ":", "451", "0", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "10.", "0.", "2.1", "00", "'_", ",_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "me", ".", "example", ".", "com", ":", "451", "0", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "me", ".", "example", ".", "com", "'_", ",_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "1.0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".", "ip6", ".", "arp", "a", ":", "451", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "1.0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".0", ".", "ip6", ".", "arp", "a", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "451", "0_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "fe", "80", "::", "1", "%", "lo", "0", ":", "451", "0", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "fe", "80", "::", "1", "%", "lo", "0", ":", "451", "0", "'_", ",_", "450", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "parse", "\\u", "hostname_", "(_", "'", "local", "host", "::", "451", "0", "'_", ",_", "self_", "._", "port_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "local", "host", "::", "451", "0", "'_", ",_", "450", "6_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Basic", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Extract", "Master", "s", "Single_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "extracti", "ng", " ", "from", " ", "master", " ", "provided", " ", "according", " ", "to", " ", "synta", "x", " ", "for", " ", "opts", "['", "master", "']", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "console_", "._", "ters", "e_", "(_", "\"{", "0", "}\\\\", "n", "\"_", "._", "format_", "(_", "self_", "._", "test", "Extract", "Master", "s", "Single_", "._", "\\u\\u", "doc\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master_", "=_", "'", "local", "host", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "._", "update_", "(_", "master_", "=_", "master_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "extract", "\\u", "masters_", "(_", "self_", "._", "opts_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "dict_", "(_", "external_", "=_", "(_", "'", "local", "host", "'_", ",_", "450", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "internal_", "=_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master_", "=_", "'", "127", ".0", ".0", ".1", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "._", "update_", "(_", "master_", "=_", "master_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "extract", "\\u", "masters_", "(_", "self_", "._", "opts_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "dict_", "(_", "external_", "=_", "(_", "'", "127", ".0", ".0", ".1", "'_", ",_", "450", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "internal_", "=_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master_", "=_", "'", "local", "host", " ", "451", "0", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "._", "update_", "(_", "master_", "=_", "master_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "extract", "\\u", "masters_", "(_", "self_", "._", "opts_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "dict_", "(_", "external_", "=_", "(_", "'", "local", "host", "'_", ",_", "451", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "internal_", "=_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master_", "=_", "'", "127", ".0", ".0", ".1", " ", "451", "0", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "._", "update_", "(_", "master_", "=_", "master_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "extract", "\\u", "masters_", "(_", "self_", "._", "opts_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "dict_", "(_", "external_", "=_", "(_", "'", "127", ".0", ".0", ".1", "'_", ",_", "451", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "internal_", "=_", "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_", "master_", "=_", "'", "10.", "0.", "2.2", "3", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "._", "update_", "(_", "master_", "=_", "master_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "extract", "\\u", "masters_", "(_", "self_", "._", "opts_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "dict_", "(_", "external_", "=_", "(_", "'", "10.", "0.", "2.2", "3", "'_", ",_", "450", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "internal_", "=_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master_", "=_", "'", "me", ".", "example", ".", "com", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "._", "update_", "(_", "master_", "=_", "master_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "extract", "\\u", "masters_", "(_", "self_", "._", "opts_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "dict_", "(_", "external_", "=_", "(_", "'", "me", ".", "example", ".", "com", "'_", ",_", "450", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "internal_", "=_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master_", "=_", "'", "10.", "0.", "2.2", "3", " ", "451", "0", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "._", "update_", "(_", "master_", "=_", "master_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "extract", "\\u", "masters_", "(_", "self_", "._", "opts_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "dict_", "(_", "external_", "=_", "(_", "'", "10.", "0.", "2.2", "3", "'_", ",_", "451", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "internal_", "=_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master_", "=_", "'", "me", ".", "example", ".", "com", " ", "451", "0", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "._", "update_", "(_", "master_", "=_", "master_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "extract", "\\u", "masters_", "(_", "self_", "._", "opts_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "dict_", "(_", "external_", "=_", "(_", "'", "me", ".", "example", ".", "com", "'_", ",_", "451", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "internal_", "=_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master_", "=_", "dict_", "(_", "external_", "=_", "'", "10.", "0.", "2.2", "3", " ", "451", "0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "._", "update_", "(_", "master_", "=_", "master_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "extract", "\\u", "masters_", "(_", "self_", "._", "opts_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "dict_", "(_", "external_", "=_", "(_", "'", "10.", "0.", "2.2", "3", "'_", ",_", "451", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "internal_", "=_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master_", "=_", "dict_", "(_", "external_", "=_", "'", "10.", "0.", "2.2", "3", " ", "451", "0", "'_", ",_", "internal_", "=_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "._", "update_", "(_", "master_", "=_", "master_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "extract", "\\u", "masters_", "(_", "self_", "._", "opts_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "dict_", "(_", "external_", "=_", "(_", "'", "10.", "0.", "2.2", "3", "'_", ",_", "451", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "internal_", "=_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master_", "=_", "dict_", "(_", "internal_", "=_", "'", "10.", "0.", "2.2", "3", " ", "451", "0", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "._", "update_", "(_", "master_", "=_", "master_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "extract", "\\u", "masters_", "(_", "self_", "._", "opts_", ")_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Basic", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Extract", "Master", "s", "Multiple_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Test", " ", "extracti", "ng", " ", "from", " ", "master", " ", "provided", " ", "according", " ", "to", " ", "synta", "x", " ", "for", " ", "opts", "['", "master", "']", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "console_", "._", "ters", "e_", "(_", "\"{", "0", "}\\\\", "n", "\"_", "._", "format_", "(_", "self_", "._", "test", "Extract", "Master", "s", "Multiple_", "._", "\\u\\u", "doc\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "local", "host", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "10.", "0.", "2.2", "3", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "me", ".", "example", ".", "com", "'_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "._", "update_", "(_", "master_", "=_", "master_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "extract", "\\u", "masters_", "(_", "self_", "._", "opts_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "external", "'_", ":_", "(_", "'", "local", "host", "'_", ",_", "450", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "internal", "'_", ":_", "None_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "external", "'_", ":_", "(_", "'", "10.", "0.", "2.2", "3", "'_", ",_", "450", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "internal", "'_", ":_", "None_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "external", "'_", ":_", "(_", "'", "me", ".", "example", ".", "com", "'_", ",_", "450", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "internal", "'_", ":_", "None_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "local", "host", " ", "451", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "10.", "0.", "2.2", "3", " ", "451", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "me", ".", "example", ".", "com", " ", "451", "0", "'_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "._", "update_", "(_", "master_", "=_", "master_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "extract", "\\u", "masters_", "(_", "self_", "._", "opts_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "external", "'_", ":_", "(_", "'", "local", "host", "'_", ",_", "451", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "internal", "'_", ":_", "None_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "external", "'_", ":_", "(_", "'", "10.", "0.", "2.2", "3", "'_", ",_", "451", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "internal", "'_", ":_", "None_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "external", "'_", ":_", "(_", "'", "me", ".", "example", ".", "com", "'_", ",_", "451", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "internal", "'_", ":_", "None_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "master_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "external", "'_", ":_", "'", "local", "host", " ", "451", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "internal", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "external", "'_", ":_", "'", "me", ".", "example", ".", "com", " ", "451", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "internal", "'_", ":_", "'", "10.", "0.", "2.2", "3", " ", "451", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "external", "'_", ":_", "'", "you", ".", "example", ".", "com", " ", "450", "9", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "opts_", "._", "update_", "(_", "master_", "=_", "master_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equals_", "(_", "extract", "\\u", "masters_", "(_", "self_", "._", "opts_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "external", "'_", ":_", "(_", "'", "local", "host", "'_", ",_", "451", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "internal", "'_", ":_", "None_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "external", "'_", ":_", "(_", "'", "me", ".", "example", ".", "com", "'_", ",_", "451", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "internal", "'_", ":_", "(_", "'", "10.", "0.", "2.2", "3", "'_", ",_", "451", "0_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "external", "'_", ":_", "(_", "'", "you", ".", "example", ".", "com", "'_", ",_", "450", "9_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "internal", "'_", ":_", "None_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\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_", "def_", "run", "One_", "(_", "test_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Unit", "test", " ", "Run", "ner", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test_", "=_", "Basic", "Test", "Case_", "(_", "test_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "suite_", "=_", "unittest_", "._", "Test", "Suite_", "(_", "[_", "test_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unittest_", "._", "Text", "Test", "Runner_", "(_", "verbosity_", "=_", "2_", ")_", "._", "run_", "(_", "suite_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run", "Some", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Unit", "test", " ", "runn", "er", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tests_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "names_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "test", "Pars", "e", "Host", "name", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "test", "Extract", "Master", "s", "Sing", "le", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "test", "Extract", "Master", "s", "Multipl", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tests_", "._", "extend_", "(_", "list_", "(_", "list_", "(_", "map_", "(_", "Basic", "Test", "Case_", ",_", "names_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "suite_", "=_", "unittest_", "._", "Test", "Suite_", "(_", "tests_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unittest_", "._", "Text", "Test", "Runner_", "(_", "verbosity_", "=_", "2_", ")_", "._", "run_", "(_", "suite_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run", "All_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", "Unit", "test", " ", "runn", "er", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "suite_", "=_", "unittest_", "._", "Test", "Suite_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "suite_", "._", "add", "Test_", "(_", "unittest_", "._", "Test", "Loader_", "(_", ")_", "._", "load", "Test", "s", "Fro", "m", "Test", "Case_", "(_", "Basic", "Test", "Case_", ")_", ")_", "\\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 ]
Unused local variable
OpenMDAO/OpenMDAO/openmdao/core/test/test_problem.py
[ { "content": " def test_check_promotes(self):\n # verify we get an error at setup time if we have promoted a var that doesn't exist\n\n # valid case, no error\n prob = Problem(Group())\n G = prob.root.add('G', Group())\n C = G.add('C', SimpleComp(), promotes=['x*', 'y'])\n # ignore warning about the unconnected param\n with warnings.catch_warnings(record=True) as w:\n warnings.simplefilter(\"ignore\")\n prob.setup(check=False)\n\n # promoting a non-existent variable should throw an error\n prob = Problem(Group())\n G = prob.root.add('G', Group())\n C = G.add('C', SimpleComp(), promotes=['spoon']) # there is no spoon\n try:\n prob.setup(check=False)\n except Exception as error:\n msg = \"'G.C' promotes 'spoon' but has no variables matching that specification\"\n self.assertEqual(text_type(error), msg)\n else:\n self.fail(\"Error expected\")\n\n # promoting a pattern with no matches should throw an error\n prob = Problem(Group())\n G = prob.root.add('G', Group())\n P = G.add('P', IndepVarComp('x', 5.), promotes=['a*']) # there is no match\n try:\n prob.setup(check=False)\n except Exception as error:\n msg = \"'G.P' promotes 'a*' but has no variables matching that specification\"\n self.assertEqual(text_type(error), msg)\n else:\n self.fail(\"Error expected\")", "metadata": "root.TestProblem.test_check_promotes", "header": "['class', 'TestProblem', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 59 }, { "content": " def test_unconnected_param_access(self):\n prob = Problem(root=Group())\n G1 = prob.root.add('G1', Group())\n G2 = G1.add('G2', Group())\n C1 = G2.add('C1', ExecComp(['y=2.0*x',\n 'z=x*x-2.0']))\n C2 = G2.add('C2', ExecComp(['y=2.0*x',\n 'z=x*x-2.0']))\n G2.connect('C1.y', 'C2.x')\n\n # ignore warning about the unconnected param\n with warnings.catch_warnings(record=True) as w:\n warnings.simplefilter(\"ignore\")\n prob.setup(check=False)\n\n prob.run()\n\n C1.params['x'] = 2.\n self.assertEqual(prob['G1.G2.C1.x'], 2.0)\n prob['G1.G2.C1.x'] = 99.\n self.assertEqual(C1.params['x'], 99.)", "metadata": "root.TestProblem.test_unconnected_param_access", "header": "['class', 'TestProblem', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 141 }, { "content": " def test_unconnected_param_access_with_promotes(self):\n prob = Problem(root=Group())\n G1 = prob.root.add('G1', Group())\n G2 = G1.add('G2', Group(), promotes=['x'])\n C1 = G2.add('C1', ExecComp(['y=2.0*x',\n 'z=x*x-2.0']), promotes=['x'])\n C2 = G2.add('C2', ExecComp(['y=2.0*x',\n 'z=x*x-2.0']))\n G2.connect('C1.y', 'C2.x')\n\n # ignore warning about the unconnected param\n with warnings.catch_warnings(record=True) as w:\n warnings.simplefilter(\"ignore\")\n prob.setup(check=False)\n\n prob.run()\n\n # still must use absolute naming to find params even if they're\n # promoted. Promoted names for params can refer to more than one param.\n C1.params['x'] = 2.\n self.assertEqual(prob['G1.x'], 2.0)\n self.assertEqual(prob.root.G1.G2.C1.params['x'], 2.0)\n prob['G1.x'] = 99.\n self.assertEqual(C1.params['x'], 99.)\n prob['G1.x'] = 12.\n self.assertEqual(C1.params['x'], 12.)\n\n prob['G1.x'] = 17.\n\n self.assertEqual(prob.root.G1.G2.C1.params['x'], 17.0)\n prob.run()", "metadata": "root.TestProblem.test_unconnected_param_access_with_promotes", "header": "['class', 'TestProblem', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 163 }, { "content": " def test_check_parallel_derivs(self):\n\n prob = Problem()\n root = prob.root = Group()\n\n root.add('p1', IndepVarComp('a', 1.0), promotes=['*'])\n root.add('p2', IndepVarComp('b', 1.0), promotes=['*'])\n sub1 = root.add('sub1', Group(), promotes=['*'])\n sub1.ln_solver = LinearGaussSeidel()\n sub2 = sub1.add('sub2', Group(), promotes=['*'])\n sub2.add('comp', ExecComp(['x = 2.0*a + 3.0*b', 'y=4.0*a - 1.0*b']), promotes=['*'])\n sub2.ln_solver = LinearGaussSeidel()\n\n root.ln_solver.options['mode'] = 'fwd'\n sub1.ln_solver.options['mode'] = 'fwd'\n sub2.ln_solver.options['mode'] = 'fwd'\n\n prob.setup(check=False)\n prob.run()\n\n root.ln_solver = LinearGaussSeidel()\n root.ln_solver.options['single_voi_relevance_reduction'] = True\n prob.driver.add_desvar('p1.a', 1.0)\n prob.driver.add_constraint('x', upper=0.0)\n prob.driver.add_constraint('y', upper=0.0)\n with warnings.catch_warnings(record=True) as w:\n if not MPI:\n # suppress warning about not running under MPI\n warnings.simplefilter(\"ignore\")\n prob.driver.parallel_derivs(['x','y'])\n\n root.ln_solver.options['mode'] = 'rev'\n sub1.ln_solver.options['mode'] = 'rev'\n\n prob._setup_errors = []\n mode = prob._check_for_parallel_derivs(['a'], ['x'], True, False)\n\n msg = \"Group 'sub2' has mode 'fwd' but the root group has mode 'rev'. Modes must match to use parallel derivative groups.\"\n self.assertTrue(msg in prob._setup_errors[0])\n\n\n sub1.ln_solver.options['mode'] = 'fwd'\n sub2.ln_solver.options['mode'] = 'rev'\n\n\n prob._setup_errors = []\n mode = prob._check_for_parallel_derivs(['a'], ['x'], True, False)\n\n msg = \"Group 'sub1' has mode 'fwd' but the root group has mode 'rev'. Modes must match to use parallel derivative groups.\"\n self.assertTrue(msg in prob._setup_errors[0])\n\n\n sub1.ln_solver.options['mode'] = 'rev'\n mode = prob._check_for_parallel_derivs(['a'], ['x'], True, False)", "metadata": "root.TestProblem.test_check_parallel_derivs", "header": "['class', 'TestProblem', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 779 }, { "content": " def test_out_of_order(self):\n prob = Problem(root=Group())\n root = prob.root\n\n G1 = root.add(\"G1\", Group())\n G2 = G1.add(\"G2\", Group())\n C1 = G2.add(\"C1\", ExecComp('y=x*2.0'))\n C2 = G2.add(\"C2\", ExecComp('y=x*2.0'))\n C3 = G2.add(\"C3\", ExecComp('y=x*2.0'))\n\n G2.connect(\"C1.y\", \"C3.x\")\n G2.connect(\"C3.y\", \"C2.x\")\n\n # force wrong order\n G2.set_order(['C1', 'C2', 'C3'])\n\n stream = cStringIO()\n checks = prob.setup(out_stream=stream)\n self.assertEqual(checks['out_of_order'], [('G1.G2',[('C2',['C3'])])])", "metadata": "root.TestCheckSetup.test_out_of_order", "header": "['class', 'TestCheckSetup', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 931 }, { "content": " def test_cycle(self):\n prob = Problem(root=Group())\n root = prob.root\n\n G1 = root.add(\"G1\", Group())\n G2 = G1.add(\"G2\", Group())\n G2.ln_solver = ScipyGMRES()\n\n C1 = G2.add(\"C1\", ExecComp('y=x*2.0'))\n C2 = G2.add(\"C2\", ExecComp('y=x*2.0'))\n C3 = G2.add(\"C3\", ExecComp('y=x*2.0'))\n\n G2.connect(\"C1.y\", \"C3.x\")\n G2.connect(\"C3.y\", \"C2.x\")\n G2.connect(\"C2.y\", \"C1.x\")\n\n # force wrong order\n G2.set_order(['C1', 'C2', 'C3'])\n\n stream = cStringIO()\n checks = prob.setup(out_stream=stream)\n auto, _ = G2.list_auto_order()\n self.assertTrue(auto==['C1', 'C3', 'C2'] or\n auto==['C3', 'C2', 'C1'] or\n auto==['C2', 'C1', 'C3'])\n self.assertTrue(\"Group 'G1.G2' has the following cycles: [['C1', 'C2', 'C3']]\" in\n stream.getvalue())\n\n oo = checks['out_of_order']\n self.assertEqual(oo[0][0], 'G1.G2')\n expected = {\n ('C2','C3'): 'C1',\n ('C3',): 'C2',\n ('C2',): 'C1',\n }\n\n for node, afters in oo[0][1]:\n self.assertEqual(node, expected[tuple(afters)])", "metadata": "root.TestCheckSetup.test_cycle", "header": "['class', 'TestCheckSetup', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 951 } ]
[ { "span": "C ", "start_line": 74, "start_column": 8, "end_line": 74, "end_column": 9 }, { "span": "P ", "start_line": 86, "start_column": 8, "end_line": 86, "end_column": 9 }, { "span": "C2 ", "start_line": 147, "start_column": 8, "end_line": 147, "end_column": 10 }, { "span": "C2 ", "start_line": 169, "start_column": 8, "end_line": 169, "end_column": 10 }, { "span": "mode ", "start_line": 832, "start_column": 8, "end_line": 832, "end_column": 12 }, { "span": "C1 ", "start_line": 937, "start_column": 8, "end_line": 937, "end_column": 10 }, { "span": "C2 ", "start_line": 938, "start_column": 8, "end_line": 938, "end_column": 10 }, { "span": "C3 ", "start_line": 939, "start_column": 8, "end_line": 939, "end_column": 10 }, { "span": "C1 ", "start_line": 959, "start_column": 8, "end_line": 959, "end_column": 10 }, { "span": "C2 ", "start_line": 960, "start_column": 8, "end_line": 960, "end_column": 10 }, { "span": "C3 ", "start_line": 961, "start_column": 8, "end_line": 961, "end_column": 10 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Test", "Problem_", "(_", "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", "check", "\\u", "promote", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "verify", " ", "we", " ", "get", " ", "an", " ", "error", " ", "at", " ", "setup", " ", "time", " ", "if", " ", "we", " ", "have", " ", "promote", "d", " ", "a", " ", "var", " ", "tha", "t", " ", "doe", "sn", "'", "t", " ", "exist_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "valid", " ", "case", ",", " ", "no", " ", "error_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prob_", "=_", "Problem_", "(_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G_", "=_", "prob_", "._", "root_", "._", "add_", "(_", "'", "G", "'_", ",_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C_", "=_", "G_", "._", "add_", "(_", "'", "C", "'_", ",_", "Simple", "Comp_", "(_", ")_", ",_", "promote", "s_", "=_", "[_", "'", "x", "*'_", ",_", "'", "y", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "ignore", " ", "warn", "ing", " ", "abo", "ut", " ", "the", " ", "uncon", "nect", "ed", " ", "param_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "warnings_", "._", "catch", "\\u", "warnings_", "(_", "record_", "=_", "True_", ")_", "as_", "w_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "warnings_", "._", "simplefilter_", "(_", "\"", "ignore", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prob_", "._", "setup_", "(_", "check_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "promo", "ting", " ", "a", " ", "non", "-", "existen", "t", " ", "variab", "le", " ", "shou", "ld", " ", "throw", " ", "an", " ", "error_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prob_", "=_", "Problem_", "(_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G_", "=_", "prob_", "._", "root_", "._", "add_", "(_", "'", "G", "'_", ",_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C_", "=_", "G_", "._", "add_", "(_", "'", "C", "'_", ",_", "Simple", "Comp_", "(_", ")_", ",_", "promote", "s_", "=_", "[_", "'", "spoo", "n", "'_", "]_", ")_", "#", " ", "there", " ", "is", " ", "no", " ", "spoo", "n_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prob_", "._", "setup_", "(_", "check_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "\"'", "G", ".", "C", "'", " ", "promote", "s", " ", "'", "spoo", "n", "'", " ", "but", " ", "has", " ", "no", " ", "variab", "les", " ", "matchi", "ng", " ", "tha", "t", " ", "specifica", "tion", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "text", "\\u", "type_", "(_", "error_", ")_", ",_", "msg_", ")_", "\\u\\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_", "(_", "\"", "Error", " ", "expected", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "promo", "ting", " ", "a", " ", "pattern", " ", "with", " ", "no", " ", "matche", "s", " ", "shou", "ld", " ", "throw", " ", "an", " ", "error_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prob_", "=_", "Problem_", "(_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G_", "=_", "prob_", "._", "root_", "._", "add_", "(_", "'", "G", "'_", ",_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "=_", "G_", "._", "add_", "(_", "'", "P", "'_", ",_", "Inde", "p", "Var", "Comp_", "(_", "'", "x", "'_", ",_", "5._", ")_", ",_", "promote", "s_", "=_", "[_", "'", "a", "*'_", "]_", ")_", "#", " ", "there", " ", "is", " ", "no", " ", "match_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prob_", "._", "setup_", "(_", "check_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "msg_", "=_", "\"'", "G", ".", "P", "'", " ", "promote", "s", " ", "'", "a", "*'", " ", "but", " ", "has", " ", "no", " ", "variab", "les", " ", "matchi", "ng", " ", "tha", "t", " ", "specifica", "tion", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "text", "\\u", "type_", "(_", "error_", ")_", ",_", "msg_", ")_", "\\u\\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_", "(_", "\"", "Error", " ", "expected", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Problem_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "uncon", "nect", "ed", "\\u", "param", "\\u", "access_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prob_", "=_", "Problem_", "(_", "root_", "=_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G1_", "=_", "prob_", "._", "root_", "._", "add_", "(_", "'", "G1", "'_", ",_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G2_", "=_", "G1_", "._", "add_", "(_", "'", "G2", "'_", ",_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C1_", "=_", "G2_", "._", "add_", "(_", "'", "C1", "'_", ",_", "Exe", "c", "Comp_", "(_", "[_", "'", "y", "=", "2.0", "*", "x", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "z", "=", "x", "*", "x", "-", "2.0", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C2_", "=_", "G2_", "._", "add_", "(_", "'", "C2", "'_", ",_", "Exe", "c", "Comp_", "(_", "[_", "'", "y", "=", "2.0", "*", "x", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "z", "=", "x", "*", "x", "-", "2.0", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G2_", "._", "connect_", "(_", "'", "C1", ".", "y", "'_", ",_", "'", "C2", ".", "x", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ignore", " ", "warn", "ing", " ", "abo", "ut", " ", "the", " ", "uncon", "nect", "ed", " ", "param_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "warnings_", "._", "catch", "\\u", "warnings_", "(_", "record_", "=_", "True_", ")_", "as_", "w_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "warnings_", "._", "simplefilter_", "(_", "\"", "ignore", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prob_", "._", "setup_", "(_", "check_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prob_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "C1_", "._", "params_", "[_", "'", "x", "'_", "]_", "=_", "2._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "prob_", "[_", "'", "G1", ".", "G2", ".", "C1", ".", "x", "'_", "]_", ",_", "2.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prob_", "[_", "'", "G1", ".", "G2", ".", "C1", ".", "x", "'_", "]_", "=_", "99.", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "C1_", "._", "params_", "[_", "'", "x", "'_", "]_", ",_", "99.", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Problem_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "uncon", "nect", "ed", "\\u", "param", "\\u", "access", "\\u", "with", "\\u", "promote", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prob_", "=_", "Problem_", "(_", "root_", "=_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G1_", "=_", "prob_", "._", "root_", "._", "add_", "(_", "'", "G1", "'_", ",_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G2_", "=_", "G1_", "._", "add_", "(_", "'", "G2", "'_", ",_", "Group_", "(_", ")_", ",_", "promote", "s_", "=_", "[_", "'", "x", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C1_", "=_", "G2_", "._", "add_", "(_", "'", "C1", "'_", ",_", "Exe", "c", "Comp_", "(_", "[_", "'", "y", "=", "2.0", "*", "x", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "z", "=", "x", "*", "x", "-", "2.0", "'_", "]_", ")_", ",_", "promote", "s_", "=_", "[_", "'", "x", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C2_", "=_", "G2_", "._", "add_", "(_", "'", "C2", "'_", ",_", "Exe", "c", "Comp_", "(_", "[_", "'", "y", "=", "2.0", "*", "x", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "z", "=", "x", "*", "x", "-", "2.0", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G2_", "._", "connect_", "(_", "'", "C1", ".", "y", "'_", ",_", "'", "C2", ".", "x", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ignore", " ", "warn", "ing", " ", "abo", "ut", " ", "the", " ", "uncon", "nect", "ed", " ", "param_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "warnings_", "._", "catch", "\\u", "warnings_", "(_", "record_", "=_", "True_", ")_", "as_", "w_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "warnings_", "._", "simplefilter_", "(_", "\"", "ignore", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prob_", "._", "setup_", "(_", "check_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prob_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "still", " ", "must", " ", "use", " ", "abs", "olute", " ", "nami", "ng", " ", "to", " ", "find", " ", "params", " ", "even", " ", "if", " ", "the", "y", "'", "re_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "promote", "d", ".", " ", " ", "Promot", "ed", " ", "names", " ", "for", " ", "params", " ", "can", " ", "refer", " ", "to", " ", "more", " ", "than", " ", "one", " ", "param", "._", "\\u\\u\\uNL\\u\\u\\u_", "C1_", "._", "params_", "[_", "'", "x", "'_", "]_", "=_", "2._", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "prob_", "[_", "'", "G1", ".", "x", "'_", "]_", ",_", "2.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "prob_", "._", "root_", "._", "G1_", "._", "G2_", "._", "C1_", "._", "params_", "[_", "'", "x", "'_", "]_", ",_", "2.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prob_", "[_", "'", "G1", ".", "x", "'_", "]_", "=_", "99.", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "C1_", "._", "params_", "[_", "'", "x", "'_", "]_", ",_", "99.", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prob_", "[_", "'", "G1", ".", "x", "'_", "]_", "=_", "12.", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "C1_", "._", "params_", "[_", "'", "x", "'_", "]_", ",_", "12.", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prob_", "[_", "'", "G1", ".", "x", "'_", "]_", "=_", "17.", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "prob_", "._", "root_", "._", "G1_", "._", "G2_", "._", "C1_", "._", "params_", "[_", "'", "x", "'_", "]_", ",_", "17.", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prob_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Problem_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "check", "\\u", "parall", "el", "\\u", "deriv", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prob_", "=_", "Problem_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root_", "=_", "prob_", "._", "root_", "=_", "Group_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "root_", "._", "add_", "(_", "'", "p1", "'_", ",_", "Inde", "p", "Var", "Comp_", "(_", "'", "a", "'_", ",_", "1.0_", ")_", ",_", "promote", "s_", "=_", "[_", "'*'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root_", "._", "add_", "(_", "'", "p2", "'_", ",_", "Inde", "p", "Var", "Comp_", "(_", "'", "b", "'_", ",_", "1.0_", ")_", ",_", "promote", "s_", "=_", "[_", "'*'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sub", "1_", "=_", "root_", "._", "add_", "(_", "'", "sub", "1", "'_", ",_", "Group_", "(_", ")_", ",_", "promote", "s_", "=_", "[_", "'*'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sub", "1_", "._", "ln", "\\u", "solver_", "=_", "Linea", "r", "Gau", "ss", "Sei", "del_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sub", "2_", "=_", "sub", "1_", "._", "add_", "(_", "'", "sub", "2", "'_", ",_", "Group_", "(_", ")_", ",_", "promote", "s_", "=_", "[_", "'*'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sub", "2_", "._", "add_", "(_", "'", "comp", "'_", ",_", "Exe", "c", "Comp_", "(_", "[_", "'", "x", " ", "=", " ", "2.0", "*", "a", " ", "+", " ", "3.0", "*", "b", "'_", ",_", "'", "y", "=", "4.0", "*", "a", " ", "-", " ", "1.0", "*", "b", "'_", "]_", ")_", ",_", "promote", "s_", "=_", "[_", "'*'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sub", "2_", "._", "ln", "\\u", "solver_", "=_", "Linea", "r", "Gau", "ss", "Sei", "del_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "root_", "._", "ln", "\\u", "solver_", "._", "options_", "[_", "'", "mode", "'_", "]_", "=_", "'", "fw", "d", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sub", "1_", "._", "ln", "\\u", "solver_", "._", "options_", "[_", "'", "mode", "'_", "]_", "=_", "'", "fw", "d", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sub", "2_", "._", "ln", "\\u", "solver_", "._", "options_", "[_", "'", "mode", "'_", "]_", "=_", "'", "fw", "d", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prob_", "._", "setup_", "(_", "check_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prob_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "root_", "._", "ln", "\\u", "solver_", "=_", "Linea", "r", "Gau", "ss", "Sei", "del_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root_", "._", "ln", "\\u", "solver_", "._", "options_", "[_", "'", "single", "\\u", "voi", "\\u", "relevance", "\\u", "reduc", "tion", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prob_", "._", "driver_", "._", "add", "\\u", "des", "var_", "(_", "'", "p1", ".", "a", "'_", ",_", "1.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prob_", "._", "driver_", "._", "add", "\\u", "constraint_", "(_", "'", "x", "'_", ",_", "upper_", "=_", "0.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "prob_", "._", "driver_", "._", "add", "\\u", "constraint_", "(_", "'", "y", "'_", ",_", "upper_", "=_", "0.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "warnings_", "._", "catch", "\\u", "warnings_", "(_", "record_", "=_", "True_", ")_", "as_", "w_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "MPI_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "suppress", " ", "warn", "ing", " ", "abo", "ut", " ", "not", " ", "runn", "ing", " ", "under", " ", "MPI_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "warnings_", "._", "simplefilter_", "(_", "\"", "ignore", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "prob_", "._", "driver_", "._", "parall", "el", "\\u", "deriv", "s_", "(_", "[_", "'", "x", "'_", ",_", "'", "y", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "root_", "._", "ln", "\\u", "solver_", "._", "options_", "[_", "'", "mode", "'_", "]_", "=_", "'", "rev", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sub", "1_", "._", "ln", "\\u", "solver_", "._", "options_", "[_", "'", "mode", "'_", "]_", "=_", "'", "rev", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prob_", "._", "\\u", "setup", "\\u", "errors_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mode_", "=_", "prob_", "._", "\\u", "check", "\\u", "for", "\\u", "parall", "el", "\\u", "deriv", "s_", "(_", "[_", "'", "a", "'_", "]_", ",_", "[_", "'", "x", "'_", "]_", ",_", "True_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "msg_", "=_", "\"", "Group", " ", "'", "sub", "2", "'", " ", "has", " ", "mode", " ", "'", "fw", "d", "'", " ", "but", " ", "the", " ", "root", " ", "group", " ", "has", " ", "mode", " ", "'", "rev", "'.", " ", "Mode", "s", " ", "must", " ", "match", " ", "to", " ", "use", " ", "parall", "el", " ", "deriv", "ative", " ", "group", "s", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "msg_", "in_", "prob_", "._", "\\u", "setup", "\\u", "errors_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sub", "1_", "._", "ln", "\\u", "solver_", "._", "options_", "[_", "'", "mode", "'_", "]_", "=_", "'", "fw", "d", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sub", "2_", "._", "ln", "\\u", "solver_", "._", "options_", "[_", "'", "mode", "'_", "]_", "=_", "'", "rev", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "prob_", "._", "\\u", "setup", "\\u", "errors_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mode_", "=_", "prob_", "._", "\\u", "check", "\\u", "for", "\\u", "parall", "el", "\\u", "deriv", "s_", "(_", "[_", "'", "a", "'_", "]_", ",_", "[_", "'", "x", "'_", "]_", ",_", "True_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "msg_", "=_", "\"", "Group", " ", "'", "sub", "1", "'", " ", "has", " ", "mode", " ", "'", "fw", "d", "'", " ", "but", " ", "the", " ", "root", " ", "group", " ", "has", " ", "mode", " ", "'", "rev", "'.", " ", "Mode", "s", " ", "must", " ", "match", " ", "to", " ", "use", " ", "parall", "el", " ", "deriv", "ative", " ", "group", "s", ".\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "msg_", "in_", "prob_", "._", "\\u", "setup", "\\u", "errors_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sub", "1_", "._", "ln", "\\u", "solver_", "._", "options_", "[_", "'", "mode", "'_", "]_", "=_", "'", "rev", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mode_", "=_", "prob_", "._", "\\u", "check", "\\u", "for", "\\u", "parall", "el", "\\u", "deriv", "s_", "(_", "[_", "'", "a", "'_", "]_", ",_", "[_", "'", "x", "'_", "]_", ",_", "True_", ",_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Check", "Setup_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "out", "\\u", "of", "\\u", "order_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prob_", "=_", "Problem_", "(_", "root_", "=_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root_", "=_", "prob_", "._", "root_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "G1_", "=_", "root_", "._", "add_", "(_", "\"", "G1", "\"_", ",_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G2_", "=_", "G1_", "._", "add_", "(_", "\"", "G2", "\"_", ",_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C1_", "=_", "G2_", "._", "add_", "(_", "\"", "C1", "\"_", ",_", "Exe", "c", "Comp_", "(_", "'", "y", "=", "x", "*", "2.0", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C2_", "=_", "G2_", "._", "add_", "(_", "\"", "C2", "\"_", ",_", "Exe", "c", "Comp_", "(_", "'", "y", "=", "x", "*", "2.0", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C3_", "=_", "G2_", "._", "add_", "(_", "\"", "C3", "\"_", ",_", "Exe", "c", "Comp_", "(_", "'", "y", "=", "x", "*", "2.0", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "G2_", "._", "connect_", "(_", "\"", "C1", ".", "y", "\"_", ",_", "\"", "C3", ".", "x", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G2_", "._", "connect_", "(_", "\"", "C3", ".", "y", "\"_", ",_", "\"", "C2", ".", "x", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "force", " ", "wrong", " ", "order_", "\\u\\u\\uNL\\u\\u\\u_", "G2_", "._", "set\\u", "order_", "(_", "[_", "'", "C1", "'_", ",_", "'", "C2", "'_", ",_", "'", "C3", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "stream_", "=_", "c", "String", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "checks_", "=_", "prob_", "._", "setup_", "(_", "out", "\\u", "stream_", "=_", "stream_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "checks_", "[_", "'", "out", "\\u", "of", "\\u", "order", "'_", "]_", ",_", "[_", "(_", "'", "G1", ".", "G2", "'_", ",_", "[_", "(_", "'", "C2", "'_", ",_", "[_", "'", "C3", "'_", "]_", ")_", "]_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Check", "Setup_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "cycle_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "prob_", "=_", "Problem_", "(_", "root_", "=_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "root_", "=_", "prob_", "._", "root_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "G1_", "=_", "root_", "._", "add_", "(_", "\"", "G1", "\"_", ",_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G2_", "=_", "G1_", "._", "add_", "(_", "\"", "G2", "\"_", ",_", "Group_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G2_", "._", "ln", "\\u", "solver_", "=_", "Sci", "py", "GM", "RES", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "C1_", "=_", "G2_", "._", "add_", "(_", "\"", "C1", "\"_", ",_", "Exe", "c", "Comp_", "(_", "'", "y", "=", "x", "*", "2.0", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C2_", "=_", "G2_", "._", "add_", "(_", "\"", "C2", "\"_", ",_", "Exe", "c", "Comp_", "(_", "'", "y", "=", "x", "*", "2.0", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C3_", "=_", "G2_", "._", "add_", "(_", "\"", "C3", "\"_", ",_", "Exe", "c", "Comp_", "(_", "'", "y", "=", "x", "*", "2.0", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "G2_", "._", "connect_", "(_", "\"", "C1", ".", "y", "\"_", ",_", "\"", "C3", ".", "x", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G2_", "._", "connect_", "(_", "\"", "C3", ".", "y", "\"_", ",_", "\"", "C2", ".", "x", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "G2_", "._", "connect_", "(_", "\"", "C2", ".", "y", "\"_", ",_", "\"", "C1", ".", "x", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "force", " ", "wrong", " ", "order_", "\\u\\u\\uNL\\u\\u\\u_", "G2_", "._", "set\\u", "order_", "(_", "[_", "'", "C1", "'_", ",_", "'", "C2", "'_", ",_", "'", "C3", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "stream_", "=_", "c", "String", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "checks_", "=_", "prob_", "._", "setup_", "(_", "out", "\\u", "stream_", "=_", "stream_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "auto_", ",_", "\\u_", "=_", "G2_", "._", "list", "\\u", "auto", "\\u", "order_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "auto_", "==_", "[_", "'", "C1", "'_", ",_", "'", "C3", "'_", ",_", "'", "C2", "'_", "]_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "auto_", "==_", "[_", "'", "C3", "'_", ",_", "'", "C2", "'_", ",_", "'", "C1", "'_", "]_", "or_", "\\u\\u\\uNL\\u\\u\\u_", "auto_", "==_", "[_", "'", "C2", "'_", ",_", "'", "C1", "'_", ",_", "'", "C3", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "Group", " ", "'", "G1", ".", "G2", "'", " ", "has", " ", "the", " ", "follow", "ing", " ", "cycle", "s", ":", " ", "[[", "'", "C1", "',", " ", "'", "C2", "',", " ", "'", "C3", "']]", "\"_", "in_", "\\u\\u\\uNL\\u\\u\\u_", "stream_", "._", "getvalue_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "oo_", "=_", "checks_", "[_", "'", "out", "\\u", "of", "\\u", "order", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "oo_", "[_", "0_", "]_", "[_", "0_", "]_", ",_", "'", "G1", ".", "G2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "C2", "'_", ",_", "'", "C3", "'_", ")_", ":_", "'", "C1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "C3", "'_", ",_", ")_", ":_", "'", "C2", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "C2", "'_", ",_", ")_", ":_", "'", "C1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "node_", ",_", "after", "s_", "in_", "oo_", "[_", "0_", "]_", "[_", "1_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "node_", ",_", "expected_", "[_", "tuple_", "(_", "after", "s_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Missing call to `__init__` during object initialization
PacketPerception/pychievements/pychievements/backends.py
[ { "content": " def __init__(self):\n self._tracked = {}", "metadata": "root.AchievementBackend.__init__", "header": "['class', 'AchievementBackend', '(', 'object', ')', ':', '___EOS___']", "index": 21 }, { "content": "class SQLiteAchievementBackend(AchievementBackend):\n \"\"\"\n Stores achievement data in a SQLite database.\n\n Arguments:\n\n dbfile\n The full path and file name to store the SQLite database\n\n To use, create the backend and then use the :py:func:`set_backend` method of the tracker.\n\n .. code-block:: python\n\n mybackend = SQLiteAchievementBackend('/some/db.file')\n tracker.set_backend(mybackend)\n \"\"\"\n\n\n\n\n", "metadata": "root.SQLiteAchievementBackend", "header": "['module', '___EOS___']", "index": 61 }, { "content": " def __init__(self, dbfile):\n self.conn = sqlite3.connect(dbfile)\n with self.conn:\n c = self.conn.cursor()\n c.execute('create table if not exists pychievements (tracked_id text, '\n 'achievement text, level integer)')", "metadata": "root.SQLiteAchievementBackend.__init__", "header": "['class', 'SQLiteAchievementBackend', '(', 'AchievementBackend', ')', ':', '___EOS___']", "index": 77 } ]
[ { "span": "class SQLiteAchievementBackend(AchievementBackend):", "start_line": 61, "start_column": 0, "end_line": 61, "end_column": 51 } ]
[ { "span": "def __init__(self):", "start_line": 21, "start_column": 4, "end_line": 21, "end_column": 23 }, { "span": "def __init__(self, dbfile):", "start_line": 77, "start_column": 4, "end_line": 77, "end_column": 31 } ]
1
false
[ "[CLS]_", "Missing", "_", "call_", "to_", " _", "`_", "\\u\\u", "init\\u\\u_", "`_", "dur", "ing_", "object_", "initialization", "_", "[SEP]_", "class_", "Ach", "ieve", "ment", "Backend_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "tracked", "_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "SQL", "ite", "Ach", "ieve", "ment", "Backend_", "(_", "Ach", "ieve", "ment", "Backend_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Stor", "es", " ", "achievement", " ", "data", " ", "in", " ", "a", " ", "SQL", "ite", " ", "databa", "se", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "ument", "s", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "dbf", "ile", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "full", " ", "path", " ", "and", " ", "file", " ", "name", " ", "to", " ", "store", " ", "the", " ", "SQL", "ite", " ", "databa", "se", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "To", " ", "use", ",", " ", "create", " ", "the", " ", "back", "end", " ", "and", " ", "then", " ", "use", " ", "the", " ", ":", "py", ":", "func", ":`", "set\\u", "back", "end", "`", " ", "method", " ", "of", " ", "the", " ", "track", "er", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "code", "-", "block", "::", " ", "python", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "myb", "acke", "nd", " ", "=", " ", "SQL", "ite", "Ach", "ieve", "ment", "Back", "end", "('", "/", "some", "/", "db", ".", "file", "')", "\\", "10", ";", " ", " ", " ", " ", "track", "er", ".", "set\\u", "back", "end", "(", "myb", "acke", "nd", ")", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "SQL", "ite", "Ach", "ieve", "ment", "Backend_", "(_", "Ach", "ieve", "ment", "Backend_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "dbfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "conn_", "=_", "sqlite3_", "._", "connect_", "(_", "dbfile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "self_", "._", "conn_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "c_", "=_", "self_", "._", "conn_", "._", "cursor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c_", "._", "execute_", "(_", "'", "create", " ", "table", " ", "if", " ", "not", " ", "exist", "s", " ", "pyc", "hi", "eve", "ment", "s", " ", "(", "tracked", "\\u", "id", " ", "text", ",", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "achievement", " ", "text", ",", " ", "level", " ", "integ", "er", ")'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
bfrog/whizzer/whizzer/test/test_defer.py
[ { "content": " def test_callback(self):\n self.deferred.add_callback(self.set_result)\n self.deferred.callback(5)\n self.assertTrue(self.result==5)", "metadata": "root.TestDeferred.test_callback", "header": "['class', 'TestDeferred', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 65 }, { "content": " def test_callback_chain(self):\n d = self.deferred\n d.add_callback(add, 1)\n d.add_callback(self.set_result)\n self.deferred.callback(5)\n self.assertTrue(self.result==6)", "metadata": "root.TestDeferred.test_callback_chain", "header": "['class', 'TestDeferred', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 70 }, { "content": " def test_callback_skips(self):\n \"\"\"When a callback raises an exception\n all callbacks without errbacks are skipped until the next\n errback is found.\n\n \"\"\"\n self.deferred.add_callback(throw_always)\n self.deferred.add_callback(one_always)\n self.deferred.add_callback(add, 2)\n self.deferred.add_errback(one_always)\n self.deferred.add_callback(self.set_result)\n self.deferred.callback(None)\n self.assertTrue(self.result==1)", "metadata": "root.TestDeferred.test_callback_skips", "header": "['class', 'TestDeferred', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 88 }, { "content": " def test_cancel_callback(self):\n self.deferred = Deferred(loop, cancelled_cb=self.set_result)\n self.deferred.cancel()\n self.assertTrue(self.result == self.deferred)", "metadata": "root.TestDeferred.test_cancel_callback", "header": "['class', 'TestDeferred', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 121 }, { "content": " def test_result_chain(self):\n self.deferred.callback(5)\n self.assertTrue(self.deferred.result()==5)\n self.deferred.add_callback(add, 2)\n self.assertTrue(self.deferred.result()==7)\n self.deferred.add_callback(throw_always)\n self.assertRaises(Exception, self.deferred.result)", "metadata": "root.TestDeferred.test_result_chain", "header": "['class', 'TestDeferred', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 126 }, { "content": " def test_result(self):\n self.deferred.callback(5)\n self.assertTrue(self.deferred.result()==5)", "metadata": "root.TestDeferred.test_result", "header": "['class', 'TestDeferred', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 134 }, { "content": " def test_delayed_result(self):\n now = time.time()\n t1 = self.call_later(0.5, self.deferred.callback, 5)\n self.assertTrue(self.deferred.result() == 5)\n self.assertTrue(time.time() - now > 0.4)", "metadata": "root.TestDeferred.test_delayed_result", "header": "['class', 'TestDeferred', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 142 }, { "content": " def test_delayed_result_chained(self):\n now = time.time()\n t1 = self.call_later(0.5, self.deferred.callback, 5)\n self.deferred.add_callback(add, 4)\n self.assertTrue(self.deferred.result() == 9)\n self.assertTrue(time.time() - now > 0.4)", "metadata": "root.TestDeferred.test_delayed_result_chained", "header": "['class', 'TestDeferred', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 148 } ]
[ { "span": "self.assertTrue(self.result==5)", "start_line": 68, "start_column": 8, "end_line": 68, "end_column": 39 }, { "span": "self.assertTrue(self.result==6)", "start_line": 75, "start_column": 8, "end_line": 75, "end_column": 39 }, { "span": "self.assertTrue(self.result==1)", "start_line": 100, "start_column": 8, "end_line": 100, "end_column": 39 }, { "span": "self.assertTrue(self.result == self.deferred)", "start_line": 124, "start_column": 8, "end_line": 124, "end_column": 53 }, { "span": "self.assertTrue(self.deferred.result()==5)", "start_line": 128, "start_column": 8, "end_line": 128, "end_column": 50 }, { "span": "self.assertTrue(self.deferred.result()==7)", "start_line": 130, "start_column": 8, "end_line": 130, "end_column": 50 }, { "span": "self.assertTrue(self.deferred.result()==5)", "start_line": 136, "start_column": 8, "end_line": 136, "end_column": 50 }, { "span": "self.assertTrue(self.deferred.result() == 5)", "start_line": 145, "start_column": 8, "end_line": 145, "end_column": 52 }, { "span": "self.assertTrue(time.time() - now > 0.4)", "start_line": 146, "start_column": 8, "end_line": 146, "end_column": 48 }, { "span": "self.assertTrue(self.deferred.result() == 9)", "start_line": 152, "start_column": 8, "end_line": 152, "end_column": 52 }, { "span": "self.assertTrue(time.time() - now > 0.4)", "start_line": 153, "start_column": 8, "end_line": 153, "end_column": 48 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "Deferred_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "callback_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "deferred_", "._", "add", "\\u", "callback_", "(_", "self_", "._", "set\\u", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "deferred_", "._", "callback_", "(_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "result_", "==_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Deferred_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "callback", "\\u", "chain_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d_", "=_", "self_", "._", "deferred_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "._", "add", "\\u", "callback_", "(_", "add_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "._", "add", "\\u", "callback_", "(_", "self_", "._", "set\\u", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "deferred_", "._", "callback_", "(_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "result_", "==_", "6_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Deferred_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "callback", "\\u", "skips", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Whe", "n", " ", "a", " ", "callback", " ", "raise", "s", " ", "an", " ", "exception", "\\", "10", ";", " ", " ", " ", " ", "all", " ", "callback", "s", " ", "with", "out", " ", "errback", "s", " ", "are", " ", "skip", "ped", " ", "unti", "l", " ", "the", " ", "next", "\\", "10", ";", " ", " ", " ", " ", "errback", " ", "is", " ", "found", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "deferred_", "._", "add", "\\u", "callback_", "(_", "throw", "\\u", "alw", "ays_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "deferred_", "._", "add", "\\u", "callback_", "(_", "one", "\\u", "alw", "ays_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "deferred_", "._", "add", "\\u", "callback_", "(_", "add_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "deferred_", "._", "add", "\\u", "errback", "_", "(_", "one", "\\u", "alw", "ays_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "deferred_", "._", "add", "\\u", "callback_", "(_", "self_", "._", "set\\u", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "deferred_", "._", "callback_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "result_", "==_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Deferred_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "cancel", "\\u", "callback_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "deferred_", "=_", "Deferred_", "(_", "loop_", ",_", "cancel", "led", "\\u", "cb_", "=_", "self_", "._", "set\\u", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "deferred_", "._", "cancel_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "result_", "==_", "self_", "._", "deferred_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Deferred_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "result", "\\u", "chain_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "deferred_", "._", "callback_", "(_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "deferred_", "._", "result_", "(_", ")_", "==_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "deferred_", "._", "add", "\\u", "callback_", "(_", "add_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "deferred_", "._", "result_", "(_", ")_", "==_", "7_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "deferred_", "._", "add", "\\u", "callback_", "(_", "throw", "\\u", "alw", "ays_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Exception_", ",_", "self_", "._", "deferred_", "._", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Deferred_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "result_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "deferred_", "._", "callback_", "(_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "deferred_", "._", "result_", "(_", ")_", "==_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Deferred_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delayed", "\\u", "result_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "now_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t1_", "=_", "self_", "._", "call", "\\u", "later_", "(_", "0.5_", ",_", "self_", "._", "deferred_", "._", "callback_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "deferred_", "._", "result_", "(_", ")_", "==_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "time_", "._", "time_", "(_", ")_", "-_", "now_", ">_", "0.4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Deferred_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delayed", "\\u", "result", "\\u", "chained", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "now_", "=_", "time_", "._", "time_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t1_", "=_", "self_", "._", "call", "\\u", "later_", "(_", "0.5_", ",_", "self_", "._", "deferred_", "._", "callback_", ",_", "5_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "deferred_", "._", "add", "\\u", "callback_", "(_", "add_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "self_", "._", "deferred_", "._", "result_", "(_", ")_", "==_", "9_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "time_", "._", "time_", "(_", ")_", "-_", "now_", ">_", "0.4_", ")_", "\\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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Module is imported with 'import' and 'import from'
tornadoweb/tornado/tornado/escape.py
[ { "content": "#!/usr/bin/env python\n#\n# Copyright 2009 Facebook\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\"\"\"Escaping/unescaping methods for HTML, JSON, URLs, and others.\n\nAlso includes a few other miscellaneous string manipulation functions that\nhave crept in over time.\n\"\"\"\n\nfrom __future__ import absolute_import, division, print_function, with_statement\n\nimport json\nimport re\n\nfrom tornado.util import PY3, unicode_type, basestring_type\n\nif PY3:\n from urllib.parse import parse_qs as _parse_qs\n import html.entities as htmlentitydefs\n import urllib.parse as urllib_parse\n unichr = chr\nelse:\n from urlparse import parse_qs as _parse_qs\n import htmlentitydefs\n import urllib as urllib_parse\n\ntry:\n import typing # noqa\nexcept ImportError:\n pass\n\n\n_XHTML_ESCAPE_RE = re.compile('[&<>\"\\']')\n_XHTML_ESCAPE_DICT = {'&': '&amp;', '<': '&lt;', '>': '&gt;', '\"': '&quot;',\n '\\'': '&#39;'}\n\n\n\n\n\n\n# The fact that json_encode wraps json.dumps is an implementation detail.\n# Please see https://github.com/tornadoweb/tornado/pull/706\n# before sending a pull request that adds **kwargs to this function.\n\n\n\n\n\n\n\n\n# python 3 changed things around enough that we need two separate\n# implementations of url_unescape. We also need our own implementation\n# of parse_qs since python 3's version insists on decoding everything.\nif not PY3:\n\n parse_qs_bytes = _parse_qs\nelse:\n\n\n\n_UTF8_TYPES = (bytes, type(None))\n\n\n\n_TO_UNICODE_TYPES = (unicode_type, type(None))\n\n\n\n# to_unicode was previously named _unicode not because it was private,\n# but to avoid conflicts with the built-in unicode() function/type\n_unicode = to_unicode\n\n# When dealing with the standard library across python 2 and 3 it is\n# sometimes useful to have a direct conversion to the native string type\nif str is unicode_type:\n native_str = to_unicode\nelse:\n native_str = utf8\n\n_BASESTRING_TYPES = (basestring_type, type(None))\n\n\n\n\n\n# I originally used the regex from\n# http://daringfireball.net/2010/07/improved_regex_for_matching_urls\n# but it gets all exponential on certain patterns (such as too many trailing\n# dots), causing the regex matcher to never return.\n# This regex should avoid those problems.\n# Use to_unicode instead of tornado.util.u - we don't want backslashes getting\n# processed as escapes.\n_URL_RE = re.compile(to_unicode(r\"\"\"\\b((?:([\\w-]+):(/{1,3})|www[.])(?:(?:(?:[^\\s&()]|&amp;|&quot;)*(?:[^!\"#$%&'()*+,.:;<=>?@\\[\\]^`{|}~\\s]))|(?:\\((?:[^\\s&()]|&amp;|&quot;)*\\)))+)\"\"\"))\n\n\n\n\n\n\n\n_HTML_UNICODE_MAP = _build_unicode_map()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "import urllib.parse as urllib_parse", "start_line": 32, "start_column": 4, "end_line": 32, "end_column": 39 } ]
[]
1
true
[ "[CLS]_", "Module_", "is_", "imported_", "with_", "'", "import", "'_", "and_", "'", "import", " ", "from", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "200", "9", " ", "Face", "book_", "\\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_", "\"\"\"", "Esc", "api", "ng", "/", "une", "scap", "ing", " ", "method", "s", " ", "for", " ", "HTM", "L", ",", " ", "JSO", "N", ",", " ", "URL", "s", ",", " ", "and", " ", "other", "s", ".", "\\", "10", ";", "\\", "10", ";", "Al", "so", " ", "include", "s", " ", "a", " ", "few", " ", "other", " ", "misc", "ella", "neous", " ", "string", " ", "manipulati", "on", " ", "function", "s", " ", "tha", "t", "\\", "10", ";", "have", " ", "cre", "pt", " ", "in", " ", "over", " ", "time", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "\\u\\u", "future\\u\\u_", "import_", "abs", "olute", "\\u", "import_", ",_", "division_", ",_", "print", "\\u", "function_", ",_", "with", "\\u", "statement_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "tornado_", "._", "util_", "import_", "PY", "3_", ",_", "unicode", "\\u", "type_", ",_", "basest", "ring", "\\u", "type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "PY", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "urllib_", "._", "parse_", "import_", "parse", "\\u", "qs_", "as_", "\\u", "parse", "\\u", "qs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "html_", "._", "entities_", "as_", "html", "entity", "defs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urllib_", "._", "parse_", "as_", "url", "lib", "\\u", "parse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unichr_", "=_", "chr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "urlparse_", "import_", "parse", "\\u", "qs_", "as_", "\\u", "parse", "\\u", "qs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "html", "entity", "defs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urllib_", "as_", "url", "lib", "\\u", "parse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "typing_", "#", " ", "no", "qa_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Import", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "XH", "TML", "\\u", "ESCAPE", "\\u", "RE_", "=_", "re_", "._", "compile_", "(_", "'[", "&", "<>", "\"\\\\'", "]'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "XH", "TML", "\\u", "ESCAPE", "\\u", "DICT_", "=_", "{_", "'&'_", ":_", "'&", "amp", ";'_", ",_", "'<'_", ":_", "'&", "lt", ";'_", ",_", "'>'_", ":_", "'&", "gt", ";'_", ",_", "'\"'_", ":_", "'&", "quot", ";'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'\\\\''_", ":_", "'&", "#", "3", "9", ";'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "fact", " ", "tha", "t", " ", "json", "\\u", "encode", " ", "wrap", "s", " ", "json", ".", "dump", "s", " ", "is", " ", "an", " ", "implementation", " ", "deta", "il", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ple", "ase", " ", "see", " ", "https", "://", "git", "hub", ".", "com", "/", "torn", "ado", "web", "/", "torn", "ado", "/", "pull", "/", "706", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "bef", "ore", " ", "sendin", "g", " ", "a", " ", "pull", " ", "request", " ", "tha", "t", " ", "adds", " ", "**", "kwarg", "s", " ", "to", " ", "this", " ", "function", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "python", " ", "3", " ", "change", "d", " ", "thing", "s", " ", "aro", "und", " ", "eno", "ugh", " ", "tha", "t", " ", "we", " ", "need", " ", "two", " ", "separate", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "implementation", "s", " ", "of", " ", "url", "\\u", "unescape", ".", " ", " ", "We", " ", "als", "o", " ", "need", " ", "our", " ", "own", " ", "implementation_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "parse", "\\u", "qs", " ", "sinc", "e", " ", "python", " ", "3", "'", "s", " ", "version", " ", "insi", "sts", " ", "on", " ", "deco", "ding", " ", "every", "thing", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "parse", "\\u", "qs", "\\u", "bytes_", "=_", "\\u", "parse", "\\u", "qs_", "\\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\\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", "UT", "F8", "\\u", "TYPES_", "=_", "(_", "bytes_", ",_", "type_", "(_", "None_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\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", "TO", "\\u", "UNICODE", "\\u", "TYPES_", "=_", "(_", "unicode", "\\u", "type_", ",_", "type_", "(_", "None_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", "\\u", "unicode", " ", "was", " ", "previ", "ously", " ", "named", " ", "\\u", "unicode", " ", "not", " ", "bec", "aus", "e", " ", "it", " ", "was", " ", "private", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "but", " ", "to", " ", "avoid", " ", "confl", "icts", " ", "with", " ", "the", " ", "bui", "lt", "-", "in", " ", "unicode", "()", " ", "function", "/", "type_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "unicode_", "=_", "to", "\\u", "unicode_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Whe", "n", " ", "deal", "ing", " ", "with", " ", "the", " ", "standard", " ", "librar", "y", " ", "acro", "ss", " ", "python", " ", "2", " ", "and", " ", "3", " ", "it", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "somet", "imes", " ", "usef", "ul", " ", "to", " ", "have", " ", "a", " ", "direct", " ", "conve", "rsi", "on", " ", "to", " ", "the", " ", "nativ", "e", " ", "string", " ", "type_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "str_", "is_", "unicode", "\\u", "type_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nativ", "e\\u", "str_", "=_", "to", "\\u", "unicode_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nativ", "e\\u", "str_", "=_", "utf8_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "BASE", "STRING", "\\u", "TYPES_", "=_", "(_", "basest", "ring", "\\u", "type_", ",_", "type_", "(_", "None_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "I", " ", "original", "ly", " ", "used", " ", "the", " ", "regex", " ", "from_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "http", "://", "dar", "ing", "fireba", "ll", ".", "net", "/", "2010", "/", "0", "7", "/", "improve", "d\\u", "regex", "\\u", "for", "\\u", "matchi", "ng", "\\u", "urls_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "but", " ", "it", " ", "gets", " ", "all", " ", "exponential", " ", "on", " ", "cert", "ain", " ", "pattern", "s", " ", "(", "suc", "h", " ", "as", " ", "too", " ", "many", " ", "trail", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "dot", "s", "),", " ", "caus", "ing", " ", "the", " ", "regex", " ", "matche", "r", " ", "to", " ", "neve", "r", " ", "return", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "regex", " ", "shou", "ld", " ", "avoid", " ", "tho", "se", " ", "problem", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Us", "e", " ", "to", "\\u", "unicode", " ", "inst", "ead", " ", "of", " ", "torn", "ado", ".", "util", ".", "u", " ", "-", " ", "we", " ", "don", "'", "t", " ", "want", " ", "backslash", "es", " ", "getti", "ng_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "process", "ed", " ", "as", " ", "escape", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "URL", "\\u", "RE_", "=_", "re_", "._", "compile_", "(_", "to", "\\u", "unicode_", "(_", "r", "\"\"\"", "\\\\", "b", "((", "?:", "([\\\\", "w", "-]+)", ":(", "/{", "1", ",", "3", "})", "|", "www", "[.", "])(", "?:", "(?:", "(?:[", "^", "\\\\", "s", "&(", ")]", "|", "&", "amp", ";", "|", "&", "quot", ";)", "*(", "?:[", "^", "!\"", "#$", "%&", "'(", ")*", "+,", ".:", ";<", "=>", "?", "@", "\\\\[", "\\\\]", "^", "`", "{", "|", "}", "~", "\\\\", "s", "]))", "|(?", ":\\\\", "((", "?:[", "^", "\\\\", "s", "&(", ")]", "|", "&", "amp", ";", "|", "&", "quot", ";)", "*\\\\", ")))", "+)", "\"\"\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\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", "HTM", "L", "\\u", "UNICODE", "\\u", "MAP_", "=_", "\\u", "build", "\\u", "unicode", "\\u", "map_", "(_", ")_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
dnanexus/dx-toolkit/src/python/dxpy/bindings/dxapp.py
[ { "content": " def update(self, **kwargs):\n '''\n :param applet: ID of the applet to replace the app's contents with\n :type applet: string\n :param details: Metadata to store with the app (optional)\n :type details: dict or list\n :param access: Access specification (optional)\n :type access: dict\n :param resources: Specifies what is to be put into the app's resources container. Must be a string containing a project ID, or a list containing object IDs. (optional)\n :type resources: string or list\n\n Updates the parameters of an existing app. See the API\n documentation for the `/app/update\n <https://wiki.dnanexus.com/API-Specification-v1.0.0/Apps#API-method%253A-%252Fapp-xxxx%255B%252Fyyyy%255D%252Fupdate>`_\n method for more info.\n\n The current user must be a developer of the app.\n\n '''\n updates = {}\n for field in 'applet', 'billing', 'access', 'resources', 'details':\n if field in kwargs:\n updates[field] = kwargs[field]\n del kwargs[field]\n\n if self._dxid is not None:\n resp = dxpy.api.app_update(self._dxid, input_params=updates, **kwargs)\n else:\n resp = dxpy.api.app_update('app-' + self._name, alias=self._alias,\n input_params=updates, **kwargs)", "metadata": "root.DXApp.update", "header": "['class', 'DXApp', '(', 'DXObject', ',', 'DXExecutable', ')', ':', '___EOS___']", "index": 222 } ]
[ { "span": "resp ", "start_line": 248, "start_column": 12, "end_line": 248, "end_column": 16 }, { "span": "resp ", "start_line": 250, "start_column": 12, "end_line": 250, "end_column": 16 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "DX", "App_", "(_", "DX", "Object_", ",_", "DX", "Executable", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update_", "(_", "self_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "applet", ":", " ", "ID", " ", "of", " ", "the", " ", "applet", " ", "to", " ", "replace", " ", "the", " ", "app", "'", "s", " ", "content", "s", " ", "with", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "applet", ":", " ", "string", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "deta", "il", "s", ":", " ", "Meta", "data", " ", "to", " ", "store", " ", "with", " ", "the", " ", "app", " ", "(", "option", "al", ")", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "deta", "il", "s", ":", " ", "dict", " ", "or", " ", "list", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "access", ":", " ", "Access", " ", "specifica", "tion", " ", "(", "option", "al", ")", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "access", ":", " ", "dict", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "resource", "s", ":", " ", "Specifie", "s", " ", "what", " ", "is", " ", "to", " ", "be", " ", "put", " ", "int", "o", " ", "the", " ", "app", "'", "s", " ", "resource", "s", " ", "container", ".", " ", "Mus", "t", " ", "be", " ", "a", " ", "string", " ", "contain", "ing", " ", "a", " ", "project", " ", "ID", ",", " ", "or", " ", "a", " ", "list", " ", "contain", "ing", " ", "object", " ", "ID", "s", ".", " ", "(", "option", "al", ")", "\\", "10", ";", " ", " ", " ", " ", ":", "type", " ", "resource", "s", ":", " ", "string", " ", "or", " ", "list", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Update", "s", " ", "the", " ", "parameter", "s", " ", "of", " ", "an", " ", "exist", "ing", " ", "app", ".", " ", "See", " ", "the", " ", "API", "\\", "10", ";", " ", " ", " ", " ", "documentation", " ", "for", " ", "the", " ", "`", "/", "app", "/", "update", "\\", "10", ";", " ", " ", " ", " ", "<", "https", "://", "wiki", ".", "dna", "nexus", ".", "com", "/", "API", "-", "Specification", "-", "v1", ".0", ".0", "/", "App", "s", "#", "API", "-", "method", "%", "253", "A", "-%", "252", "Fa", "pp", "-", "xxx", "x", "%", "255", "B", "%", "252", "Fy", "yyy", "%", "255", "D", "%", "252", "Fu", "pdat", "e", ">`\\u", "\\", "10", ";", " ", " ", " ", " ", "method", " ", "for", " ", "more", " ", "info", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "current", " ", "user", " ", "must", " ", "be", " ", "a", " ", "developer", " ", "of", " ", "the", " ", "app", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "updates_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "field_", "in_", "'", "applet", "'_", ",_", "'", "bill", "ing", "'_", ",_", "'", "access", "'_", ",_", "'", "resource", "s", "'_", ",_", "'", "deta", "il", "s", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "field_", "in_", "kwargs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "updates_", "[_", "field_", "]_", "=_", "kwargs_", "[_", "field_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "kwargs_", "[_", "field_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "\\u", "dx", "id_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "resp_", "=_", "dxp", "y_", "._", "api_", "._", "app", "\\u", "update_", "(_", "self_", "._", "\\u", "dx", "id_", ",_", "input", "\\u", "params_", "=_", "updates_", ",_", "**_", "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 ", " _", "resp_", "=_", "dxp", "y_", "._", "api_", "._", "app", "\\u", "update_", "(_", "'", "app", "-'_", "+_", "self_", "._", "\\u", "name_", ",_", "alias_", "=_", "self_", "._", "\\u", "alias_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "input", "\\u", "params_", "=_", "updates_", ",_", "**_", "kwargs_", ")_", "\\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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
OpenMDAO/OpenMDAO/openmdao/recorders/inmem_recorder.py
[ { "content": "\"\"\"\nClass definition for InMemoryRecorder, a recorder that records values\nin a memory resident object. Note that this is primarily for testing,\nand using it for real problems could use up large amounts of memory.\n\"\"\"\n\nimport sys\n\nfrom six import string_types, iteritems\n\nfrom openmdao.core.mpi_wrap import MPI\nfrom openmdao.recorders.base_recorder import BaseRecorder\nfrom openmdao.util.record_util import format_iteration_coordinate\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class InMemoryRecorder(BaseRecorder):\n \"\"\" Recorder that saves cases in memory. Note, this may take up large\n amounts of memory, so it is not recommended for large models or models\n with lots of iterations.\n\n Options\n -------\n options['record_metadata'] : bool(True)\n Tells recorder whether to record variable attribute metadata.\n options['record_unknowns'] : bool(True)\n Tells recorder whether to record the unknowns vector.\n options['record_params'] : bool(False)\n Tells recorder whether to record the params vector.\n options['record_resids'] : bool(False)\n Tells recorder whether to record the ressiduals vector.\n options['record_derivs'] : bool(True)\n Tells recorder whether to record derivatives that are requested by a `Driver`.\n options['includes'] : list of strings\n Patterns for variables to include in recording.\n options['excludes'] : list of strings\n Patterns for variables to exclude in recording (processed after includes).\n \"\"\"\n\n\n\n", "metadata": "root.InMemoryRecorder", "header": "['module', '___EOS___']", "index": 14 }, { "content": " def __init__(self):\n super(InMemoryRecorder, self).__init__()\n self._parallel = True\n\n self.iters = []\n self.deriv_iters = []\n self.meta = {}", "metadata": "root.InMemoryRecorder.__init__", "header": "['class', 'InMemoryRecorder', '(', 'BaseRecorder', ')', ':', '___EOS___']", "index": 37 }, { "content": " def record_iteration(self, params, unknowns, resids, metadata):\n \"\"\"Record the given run data in memory.\n\n Args\n ----\n params : `VecWrapper`\n `VecWrapper` containing parameters. (p)\n\n unknowns : `VecWrapper`\n `VecWrapper` containing outputs and states. (u)\n\n resids : `VecWrapper`\n `VecWrapper` containing residuals. (r)\n\n metadata : dict\n Dictionary containing execution metadata (e.g. iteration coordinate).\n \"\"\"\n\n data = {}\n iteration_coordinate = metadata['coord']\n\n data['timestamp'] = metadata['timestamp']\n data['iter'] = format_iteration_coordinate(iteration_coordinate)\n data['success'] = metadata['success']\n data['msg'] = metadata['msg']\n\n if self.options['record_params']:\n data['params'] = {p:v for p,v in\n iteritems(self._filter_vector(params,'p',\n iteration_coordinate))}\n\n if self.options['record_unknowns']:\n data['unknowns'] = {u:v for u,v in\n iteritems(self._filter_vector(unknowns,'u',\n iteration_coordinate))}\n\n if self.options['record_resids']:\n data['resids'] = {r:v for r,v in\n iteritems(self._filter_vector(resids,'r',\n iteration_coordinate))}\n\n self.iters.append(data)", "metadata": "root.InMemoryRecorder.record_iteration", "header": "['class', 'InMemoryRecorder', '(', 'BaseRecorder', ')', ':', '___EOS___']", "index": 45 }, { "content": " def record_metadata(self, group):\n \"\"\"Dump the metadata of the given group in a \"pretty\" form.\n\n Args\n ----\n group : `System`\n `System` containing vectors\n \"\"\"\n self.meta['unknowns'] = {n:m.copy() for n,m in iteritems(group.unknowns)}\n self.meta['params'] = {n:m.copy() for n,m in iteritems(group.params)}", "metadata": "root.InMemoryRecorder.record_metadata", "header": "['class', 'InMemoryRecorder', '(', 'BaseRecorder', ')', ':', '___EOS___']", "index": 88 }, { "content": " def record_derivatives(self, derivs, metadata):\n \"\"\"Writes the derivatives that were calculated for the driver.\n\n Args\n ----\n derivs : dict\n Dictionary containing derivatives\n\n metadata : dict, optional\n Dictionary containing execution metadata (e.g. iteration coordinate).\n \"\"\"\n\n data = {}\n iteration_coordinate = metadata['coord']\n timestamp = metadata['timestamp']\n\n data['timestamp'] = timestamp\n data['Derivatives'] = derivs\n\n self.deriv_iters.append(data)", "metadata": "root.InMemoryRecorder.record_derivatives", "header": "['class', 'InMemoryRecorder', '(', 'BaseRecorder', ')', ':', '___EOS___']", "index": 99 } ]
[ { "span": "import sys", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 10 }, { "span": "from six import string_types, iteritems", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 39 }, { "span": "from openmdao.core.mpi_wrap import MPI", "start_line": 10, "start_column": 0, "end_line": 10, "end_column": 38 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Class", " ", "definit", "ion", " ", "for", " ", "In", "Memo", "ry", "Recorder", ",", " ", "a", " ", "recorde", "r", " ", "tha", "t", " ", "record", "s", " ", "values", "\\", "10", ";", "in", " ", "a", " ", "memory", " ", "resident", " ", "object", ".", " ", " ", "Not", "e", " ", "tha", "t", " ", "this", " ", "is", " ", "prima", "ri", "ly", " ", "for", " ", "testi", "ng", ",", "\\", "10", ";", "and", " ", "usi", "ng", " ", "it", " ", "for", " ", "real", " ", "problem", "s", " ", "coul", "d", " ", "use", " ", "up", " ", "large", " ", "amounts", " ", "of", " ", "memory", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "six_", "import_", "string", "\\u", "types_", ",_", "iteritems_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "openm", "dao_", "._", "core_", "._", "mpi", "\\u", "wrap_", "import_", "MPI_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "openm", "dao_", "._", "recorde", "rs_", "._", "base", "\\u", "recorder_", "import_", "Base", "Recorder", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "openm", "dao_", "._", "util_", "._", "record", "\\u", "util_", "import_", "format\\u", "iterati", "on", "\\u", "coordinate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "In", "Memo", "ry", "Recorder", "_", "(_", "Base", "Recorder", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Recorder", " ", "tha", "t", " ", "save", "s", " ", "case", "s", " ", "in", " ", "memory", ".", " ", "Not", "e", ",", " ", "this", " ", "may", " ", "take", " ", "up", " ", "large", "\\", "10", ";", " ", " ", " ", " ", "amounts", " ", "of", " ", "memory", ",", " ", "so", " ", "it", " ", "is", " ", "not", " ", "recommende", "d", " ", "for", " ", "large", " ", "model", "s", " ", "or", " ", "model", "s", "\\", "10", ";", " ", " ", " ", " ", "with", " ", "lots", " ", "of", " ", "iterati", "ons", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Optio", "ns", "\\", "10", ";", " ", " ", " ", " ", "-------", "\\", "10", ";", " ", " ", " ", " ", "options", "['", "record", "\\u", "metadata", "']", " ", ":", " ", " ", "bool", "(", "Tru", "e", ")", "\\", "10", ";", " ", " ", " ", " ", "Tell", "s", " ", "recorde", "r", " ", "whe", "ther", " ", "to", " ", "record", " ", "variab", "le", " ", "attribute", " ", "metadata", ".", "\\", "10", ";", " ", " ", " ", " ", "options", "['", "record", "\\u", "unknown", "s", "']", " ", ":", " ", " ", "bool", "(", "Tru", "e", ")", "\\", "10", ";", " ", " ", " ", " ", "Tell", "s", " ", "recorde", "r", " ", "whe", "ther", " ", "to", " ", "record", " ", "the", " ", "unknown", "s", " ", "vector", ".", "\\", "10", ";", " ", " ", " ", " ", "options", "['", "record", "\\u", "params", "']", " ", ":", " ", " ", "bool", "(", "Fal", "se", ")", "\\", "10", ";", " ", " ", " ", " ", "Tell", "s", " ", "recorde", "r", " ", "whe", "ther", " ", "to", " ", "record", " ", "the", " ", "params", " ", "vector", ".", "\\", "10", ";", " ", " ", " ", " ", "options", "['", "record", "\\u", "resid", "s", "']", " ", ":", " ", " ", "bool", "(", "Fal", "se", ")", "\\", "10", ";", " ", " ", " ", " ", "Tell", "s", " ", "recorde", "r", " ", "whe", "ther", " ", "to", " ", "record", " ", "the", " ", "ressi", "dual", "s", " ", "vector", ".", "\\", "10", ";", " ", " ", " ", " ", "options", "['", "record", "\\u", "deriv", "s", "']", " ", ":", " ", " ", "bool", "(", "Tru", "e", ")", "\\", "10", ";", " ", " ", " ", " ", "Tell", "s", " ", "recorde", "r", " ", "whe", "ther", " ", "to", " ", "record", " ", "derivatives", " ", "tha", "t", " ", "are", " ", "request", "ed", " ", "by", " ", "a", " ", "`", "Drive", "r", "`.", "\\", "10", ";", " ", " ", " ", " ", "options", "['", "include", "s", "']", " ", ":", " ", " ", "list", " ", "of", " ", "string", "s", "\\", "10", ";", " ", " ", " ", " ", "Patterns", " ", "for", " ", "variab", "les", " ", "to", " ", "include", " ", "in", " ", "record", "ing", ".", "\\", "10", ";", " ", " ", " ", " ", "options", "['", "excludes", "']", " ", ":", " ", " ", "list", " ", "of", " ", "string", "s", "\\", "10", ";", " ", " ", " ", " ", "Patterns", " ", "for", " ", "variab", "les", " ", "to", " ", "exclu", "de", " ", "in", " ", "record", "ing", " ", "(", "process", "ed", " ", "after", " ", "include", "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_", "[SEP]_", "class_", "In", "Memo", "ry", "Recorder", "_", "(_", "Base", "Recorder", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "In", "Memo", "ry", "Recorder", "_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "parallel_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "iters_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "deriv", "\\u", "iters_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "meta_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "In", "Memo", "ry", "Recorder", "_", "(_", "Base", "Recorder", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "record", "\\u", "iteration_", "(_", "self_", ",_", "params_", ",_", "unknown", "s_", ",_", "resid", "s_", ",_", "metadata_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Record", " ", "the", " ", "give", "n", " ", "run", " ", "data", " ", "in", " ", "memory", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", "\\", "10", ";", " ", " ", " ", " ", "----", "\\", "10", ";", " ", " ", " ", " ", "params", " ", ":", " ", "`", "Vec", "Wrapper", "`", "\\", "10", ";", " ", " ", " ", " ", "`", "Vec", "Wrapper", "`", " ", "contain", "ing", " ", "parameter", "s", ".", " ", "(", "p", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "unknown", "s", " ", ":", " ", "`", "Vec", "Wrapper", "`", "\\", "10", ";", " ", " ", " ", " ", "`", "Vec", "Wrapper", "`", " ", "contain", "ing", " ", "output", "s", " ", "and", " ", "state", "s", ".", " ", "(", "u", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "resid", "s", " ", ":", " ", "`", "Vec", "Wrapper", "`", "\\", "10", ";", " ", " ", " ", " ", "`", "Vec", "Wrapper", "`", " ", "contain", "ing", " ", "residu", "als", ".", " ", "(", "r", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "metadata", " ", ":", " ", "dict", "\\", "10", ";", " ", " ", " ", " ", "Dict", "ionar", "y", " ", "contain", "ing", " ", "executi", "on", " ", "metadata", " ", "(", "e", ".", "g", ".", " ", "iterati", "on", " ", "coordinate", ").", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "iterati", "on", "\\u", "coordinate_", "=_", "metadata_", "[_", "'", "coord", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "[_", "'", "timestamp", "'_", "]_", "=_", "metadata_", "[_", "'", "timestamp", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "'", "iter", "'_", "]_", "=_", "format\\u", "iterati", "on", "\\u", "coordinate_", "(_", "iterati", "on", "\\u", "coordinate_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "'", "success", "'_", "]_", "=_", "metadata_", "[_", "'", "success", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "'", "msg", "'_", "]_", "=_", "metadata_", "[_", "'", "msg", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "options_", "[_", "'", "record", "\\u", "params", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "[_", "'", "params", "'_", "]_", "=_", "{_", "p_", ":_", "v_", "for_", "p_", ",_", "v_", "in_", "\\u\\u\\uNL\\u\\u\\u_", "iteritems_", "(_", "self_", "._", "\\u", "filter", "\\u", "vector_", "(_", "params_", ",_", "'", "p", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "iterati", "on", "\\u", "coordinate_", ")_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "options_", "[_", "'", "record", "\\u", "unknown", "s", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "[_", "'", "unknown", "s", "'_", "]_", "=_", "{_", "u_", ":_", "v_", "for_", "u_", ",_", "v_", "in_", "\\u\\u\\uNL\\u\\u\\u_", "iteritems_", "(_", "self_", "._", "\\u", "filter", "\\u", "vector_", "(_", "unknown", "s_", ",_", "'", "u", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "iterati", "on", "\\u", "coordinate_", ")_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "options_", "[_", "'", "record", "\\u", "resid", "s", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "[_", "'", "resid", "s", "'_", "]_", "=_", "{_", "r_", ":_", "v_", "for_", "r_", ",_", "v_", "in_", "\\u\\u\\uNL\\u\\u\\u_", "iteritems_", "(_", "self_", "._", "\\u", "filter", "\\u", "vector_", "(_", "resid", "s_", ",_", "'", "r", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "iterati", "on", "\\u", "coordinate_", ")_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "iters_", "._", "append_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "In", "Memo", "ry", "Recorder", "_", "(_", "Base", "Recorder", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "record", "\\u", "metadata_", "(_", "self_", ",_", "group_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Dump", " ", "the", " ", "metadata", " ", "of", " ", "the", " ", "give", "n", " ", "group", " ", "in", " ", "a", " ", "\"", "pretty", "\"", " ", "form", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", "\\", "10", ";", " ", " ", " ", " ", "----", "\\", "10", ";", " ", " ", " ", " ", "group", " ", ":", " ", "`", "System", "`", "\\", "10", ";", " ", " ", " ", " ", "`", "System", "`", " ", "contain", "ing", " ", "vector", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "meta_", "[_", "'", "unknown", "s", "'_", "]_", "=_", "{_", "n_", ":_", "m_", "._", "copy_", "(_", ")_", "for_", "n_", ",_", "m_", "in_", "iteritems_", "(_", "group_", "._", "unknown", "s_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "meta_", "[_", "'", "params", "'_", "]_", "=_", "{_", "n_", ":_", "m_", "._", "copy_", "(_", ")_", "for_", "n_", ",_", "m_", "in_", "iteritems_", "(_", "group_", "._", "params_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "In", "Memo", "ry", "Recorder", "_", "(_", "Base", "Recorder", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "record", "\\u", "derivatives", "_", "(_", "self_", ",_", "deriv", "s_", ",_", "metadata_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Write", "s", " ", "the", " ", "derivatives", " ", "tha", "t", " ", "wer", "e", " ", "calculated", " ", "for", " ", "the", " ", "driver", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Arg", "s", "\\", "10", ";", " ", " ", " ", " ", "----", "\\", "10", ";", " ", " ", " ", " ", "deriv", "s", " ", ":", " ", "dict", "\\", "10", ";", " ", " ", " ", " ", "Dict", "ionar", "y", " ", "contain", "ing", " ", "derivatives", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "metadata", " ", ":", " ", "dict", ",", " ", "option", "al", "\\", "10", ";", " ", " ", " ", " ", "Dict", "ionar", "y", " ", "contain", "ing", " ", "executi", "on", " ", "metadata", " ", "(", "e", ".", "g", ".", " ", "iterati", "on", " ", "coordinate", ").", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "iterati", "on", "\\u", "coordinate_", "=_", "metadata_", "[_", "'", "coord", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "timestamp_", "=_", "metadata_", "[_", "'", "timestamp", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "[_", "'", "timestamp", "'_", "]_", "=_", "timestamp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "[_", "'", "Derivati", "ves", "'_", "]_", "=_", "deriv", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "deriv", "\\u", "iters_", "._", "append_", "(_", "data_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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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 ]
Unused local variable
tyiannak/pyAudioAnalysis/audioFeatureExtraction.py
[ { "content": "def stHarmonic(frame, fs):\n \"\"\"\n Computes harmonic ratio and pitch\n \"\"\"\n M = numpy.round(0.016 * fs) - 1\n R = numpy.correlate(frame, frame, mode='full')\n\n g = R[len(frame)-1]\n R = R[len(frame):-1]\n\n # estimate m0 (as the first zero crossing of R)\n [a, ] = numpy.nonzero(numpy.diff(numpy.sign(R)))\n\n if len(a) == 0:\n m0 = len(R)-1\n else:\n m0 = a[0]\n if M > len(R):\n M = len(R) - 1\n\n Gamma = numpy.zeros((M), dtype=numpy.float64)\n CSum = numpy.cumsum(frame ** 2)\n Gamma[m0:M] = R[m0:M] / (numpy.sqrt((g * CSum[M:m0:-1])) + eps)\n\n ZCR = stZCR(Gamma)\n\n if ZCR > 0.15:\n HR = 0.0\n f0 = 0.0\n else:\n if len(Gamma) == 0:\n HR = 1.0\n blag = 0.0\n Gamma = numpy.zeros((M), dtype=numpy.float64)\n else:\n HR = numpy.max(Gamma)\n blag = numpy.argmax(Gamma)\n\n # Get fundamental frequency:\n f0 = fs / (blag + eps)\n if f0 > 5000:\n f0 = 0.0\n if HR < 0.1:\n f0 = 0.0\n\n return (HR, f0)", "metadata": "root.stHarmonic", "header": "['module', '___EOS___']", "index": 128 }, { "content": "def mfccInitFilterBanks(fs, nfft):\n \"\"\"\n Computes the triangular filterbank for MFCC computation (used in the stFeatureExtraction function before the stMFCC function call)\n This function is taken from the scikits.talkbox library (MIT Licence):\n https://pypi.python.org/pypi/scikits.talkbox\n \"\"\"\n\n # filter bank params:\n lowfreq = 133.33\n linsc = 200/3.\n logsc = 1.0711703\n numLinFiltTotal = 13\n numLogFilt = 27\n\n if fs < 8000:\n nlogfil = 5\n\n # Total number of filters\n nFiltTotal = numLinFiltTotal + numLogFilt\n\n # Compute frequency points of the triangle:\n freqs = numpy.zeros(nFiltTotal+2)\n freqs[:numLinFiltTotal] = lowfreq + numpy.arange(numLinFiltTotal) * linsc\n freqs[numLinFiltTotal:] = freqs[numLinFiltTotal-1] * logsc ** numpy.arange(1, numLogFilt + 3)\n heights = 2./(freqs[2:] - freqs[0:-2])\n\n # Compute filterbank coeff (in fft domain, in bins)\n fbank = numpy.zeros((nFiltTotal, nfft))\n nfreqs = numpy.arange(nfft) / (1. * nfft) * fs\n\n for i in range(nFiltTotal):\n lowTrFreq = freqs[i]\n cenTrFreq = freqs[i+1]\n highTrFreq = freqs[i+2]\n\n lid = numpy.arange(numpy.floor(lowTrFreq * nfft / fs) + 1, numpy.floor(cenTrFreq * nfft / fs) + 1, dtype=numpy.int)\n lslope = heights[i] / (cenTrFreq - lowTrFreq)\n rid = numpy.arange(numpy.floor(cenTrFreq * nfft / fs) + 1, numpy.floor(highTrFreq * nfft / fs) + 1, dtype=numpy.int)\n rslope = heights[i] / (highTrFreq - cenTrFreq)\n fbank[i][lid] = lslope * (nfreqs[lid] - lowTrFreq)\n fbank[i][rid] = rslope * (highTrFreq - nfreqs[rid])\n\n return fbank, freqs", "metadata": "root.mfccInitFilterBanks", "header": "['module', '___EOS___']", "index": 176 }, { "content": "def stChromagram(signal, Fs, Win, Step, PLOT=False):\n \"\"\"\n Short-term FFT mag for spectogram estimation:\n Returns:\n a numpy array (nFFT x numOfShortTermWindows)\n ARGUMENTS:\n signal: the input signal samples\n Fs: the sampling freq (in Hz)\n Win: the short-term window size (in samples)\n Step: the short-term window step (in samples)\n PLOT: flag, 1 if results are to be ploted\n RETURNS:\n \"\"\"\n Win = int(Win)\n Step = int(Step)\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 - DC)\n\n N = len(signal) # total number of signals\n curPos = 0\n countFrames = 0\n nfft = int(Win / 2)\n nChroma, nFreqsPerChroma = stChromaFeaturesInit(nfft, Fs)\n chromaGram = numpy.array([], dtype=numpy.float64)\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 chromaNames, C = stChromaFeatures(X, Fs, nChroma, nFreqsPerChroma)\n C = C[:, 0]\n if countFrames == 1:\n chromaGram = C.T\n else:\n chromaGram = numpy.vstack((chromaGram, C.T))\n FreqAxis = chromaNames\n TimeAxis = [(t * Step) / Fs for t in range(chromaGram.shape[0])]\n\n if (PLOT):\n fig, ax = plt.subplots()\n chromaGramToPlot = chromaGram.transpose()[::-1, :]\n Ratio = chromaGramToPlot.shape[1] / (3*chromaGramToPlot.shape[0])\n chromaGramToPlot = numpy.repeat(chromaGramToPlot, Ratio, axis=0)\n imgplot = plt.imshow(chromaGramToPlot)\n Fstep = int(nfft / 5.0)\n# FreqTicks = range(0, int(nfft) + Fstep, Fstep)\n# FreqTicksLabels = [str(Fs/2-int((f*Fs) / (2*nfft))) for f in FreqTicks]\n ax.set_yticks(range(Ratio / 2, len(FreqAxis) * Ratio, Ratio))\n ax.set_yticklabels(FreqAxis[::-1])\n TStep = countFrames / 3\n TimeTicks = range(0, countFrames, TStep)\n TimeTicksLabels = ['%.2f' % (float(t * Step) / Fs) for t in TimeTicks]\n ax.set_xticks(TimeTicks)\n ax.set_xticklabels(TimeTicksLabels)\n ax.set_xlabel('time (secs)')\n imgplot.set_cmap('jet')\n plt.colorbar()\n plt.show()\n\n return (chromaGram, TimeAxis, FreqAxis)", "metadata": "root.stChromagram", "header": "['module', '___EOS___']", "index": 291 }, { "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 }, { "content": "def dirWavFeatureExtractionNoAveraging(dirName, mtWin, mtStep, stWin, stStep):\n \"\"\"\n This function extracts the mid-term features of the WAVE files of a particular folder without averaging each file.\n\n ARGUMENTS:\n - dirName: the path of the WAVE directory\n - mtWin, mtStep: mid-term window and step (in seconds)\n - stWin, stStep: short-term window and step (in seconds)\n RETURNS:\n - X: A feature matrix\n - Y: A matrix of file labels\n - filenames:\n \"\"\"\n\n allMtFeatures = numpy.array([])\n signalIndices = numpy.array([])\n processingTimes = []\n\n types = ('*.wav', '*.aif', '*.aiff')\n wavFilesList = []\n for files in types:\n wavFilesList.extend(glob.glob(os.path.join(dirName, files)))\n\n wavFilesList = sorted(wavFilesList)\n\n for i, wavFile in enumerate(wavFilesList):\n [Fs, x] = audioBasicIO.readAudioFile(wavFile) # read file\n x = audioBasicIO.stereo2mono(x) # convert stereo to mono\n [MidTermFeatures, _] = mtFeatureExtraction(x, Fs, round(mtWin * Fs), round(mtStep * Fs), round(Fs * stWin), round(Fs * stStep)) # mid-term feature\n\n MidTermFeatures = numpy.transpose(MidTermFeatures)\n# MidTermFeatures = MidTermFeatures.mean(axis=0) # long term averaging of mid-term statistics\n if len(allMtFeatures) == 0: # append feature vector\n allMtFeatures = MidTermFeatures\n signalIndices = numpy.zeros((MidTermFeatures.shape[0], ))\n else:\n allMtFeatures = numpy.vstack((allMtFeatures, MidTermFeatures))\n signalIndices = numpy.append(signalIndices, i * numpy.ones((MidTermFeatures.shape[0], )))\n\n return (allMtFeatures, signalIndices, wavFilesList)", "metadata": "root.dirWavFeatureExtractionNoAveraging", "header": "['module', '___EOS___']", "index": 779 } ]
[ { "span": "Gamma ", "start_line": 161, "start_column": 12, "end_line": 161, "end_column": 17 }, { "span": "nlogfil ", "start_line": 191, "start_column": 8, "end_line": 191, "end_column": 15 }, { "span": "Fstep ", "start_line": 341, "start_column": 8, "end_line": 341, "end_column": 13 }, { "span": "nfil ", "start_line": 656, "start_column": 8, "end_line": 656, "end_column": 12 }, { "span": "totalNumOfFeatures ", "start_line": 664, "start_column": 4, "end_line": 664, "end_column": 22 }, { "span": "Ex ", "start_line": 675, "start_column": 8, "end_line": 675, "end_column": 10 }, { "span": "El ", "start_line": 676, "start_column": 8, "end_line": 676, "end_column": 10 }, { "span": "processingTimes ", "start_line": 795, "start_column": 4, "end_line": 795, "end_column": 19 } ]
[]
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_", "st", "Harm", "onic", "_", "(_", "frame_", ",_", "fs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Compute", "s", " ", "harmonic", " ", "ratio", " ", "and", " ", "pitch", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "M_", "=_", "numpy_", "._", "round_", "(_", "0.016", "_", "*_", "fs_", ")_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "=_", "numpy_", "._", "correlate", "_", "(_", "frame_", ",_", "frame_", ",_", "mode_", "=_", "'", "full", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "g_", "=_", "R_", "[_", "len_", "(_", "frame_", ")_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "R_", "=_", "R_", "[_", "len_", "(_", "frame_", ")_", ":_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "estimate", " ", "m", "0", " ", "(", "as", " ", "the", " ", "first", " ", "zero", " ", "crossing", " ", "of", " ", "R", ")_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "a_", ",_", "]_", "=_", "numpy_", "._", "nonzero_", "(_", "numpy_", "._", "diff_", "(_", "numpy_", "._", "sign_", "(_", "R_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "a_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m0_", "=_", "len_", "(_", "R_", ")_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m0_", "=_", "a_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "M_", ">_", "len_", "(_", "R_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "M_", "=_", "len_", "(_", "R_", ")_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Gamma", "_", "=_", "numpy_", "._", "zeros_", "(_", "(_", "M_", ")_", ",_", "dtype_", "=_", "numpy_", "._", "float64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "CS", "um_", "=_", "numpy_", "._", "cumsum_", "(_", "frame_", "**_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Gamma", "_", "[_", "m0_", ":_", "M_", "]_", "=_", "R_", "[_", "m0_", ":_", "M_", "]_", "/_", "(_", "numpy_", "._", "sqrt_", "(_", "(_", "g_", "*_", "CS", "um_", "[_", "M_", ":_", "m0_", ":_", "-_", "1_", "]_", ")_", ")_", "+_", "eps_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ZC", "R_", "=_", "st", "ZC", "R_", "(_", "Gamma", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "ZC", "R_", ">_", "0.15_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "HR", "_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "f0_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "len_", "(_", "Gamma", "_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "HR", "_", "=_", "1.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bla", "g_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Gamma", "_", "=_", "numpy_", "._", "zeros_", "(_", "(_", "M_", ")_", ",_", "dtype_", "=_", "numpy_", "._", "float64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "HR", "_", "=_", "numpy_", "._", "max_", "(_", "Gamma", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bla", "g_", "=_", "numpy_", "._", "argmax_", "(_", "Gamma", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "fund", "amental", " ", "freque", "nc", "y", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "f0_", "=_", "fs_", "/_", "(_", "bla", "g_", "+_", "eps_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "f0_", ">_", "5000_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f0_", "=_", "0.0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "HR", "_", "<_", "0.1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "f0_", "=_", "0.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_", "return_", "(_", "HR", "_", ",_", "f0_", ")_", "\\u\\u\\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_", "mfc", "c", "Ini", "t", "Filter", "Bank", "s_", "(_", "fs_", ",_", "nff", "t_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Compute", "s", " ", "the", " ", "triangular", " ", "filter", "bank", " ", "for", " ", "MF", "CC", " ", "computation", " ", "(", "used", " ", "in", " ", "the", " ", "st", "Feature", "Extraction", " ", "function", " ", "bef", "ore", " ", "the", " ", "st", "MF", "CC", " ", "function", " ", "call", ")", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "is", " ", "take", "n", " ", "from", " ", "the", " ", "scikit", "s", ".", "talk", "box", " ", "librar", "y", " ", "(", "MIT", " ", "Licen", "ce", "):", "\\", "10", ";", " ", " ", " ", " ", "https", "://", "pypi", ".", "python", ".", "org", "/", "pypi", "/", "scikit", "s", ".", "talk", "box", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "filter", " ", "bank", " ", "params", ":_", "\\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_", "num", "Lin", "Fil", "t", "Total_", "=_", "13_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "Log", "Fil", "t_", "=_", "27_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\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_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Total", " ", "number", " ", "of", " ", "filters_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "n", "Fil", "t", "Total_", "=_", "num", "Lin", "Fil", "t", "Total_", "+_", "num", "Log", "Fil", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Compute", " ", "freque", "nc", "y", " ", "points", " ", "of", " ", "the", " ", "triangle", ":_", "\\u\\u\\uNL\\u\\u\\u_", "freqs_", "=_", "numpy_", "._", "zeros_", "(_", "n", "Fil", "t", "Total_", "+_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "freqs_", "[_", ":_", "num", "Lin", "Fil", "t", "Total_", "]_", "=_", "low", "freq_", "+_", "numpy_", "._", "arange_", "(_", "num", "Lin", "Fil", "t", "Total_", ")_", "*_", "lins", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "freqs_", "[_", "num", "Lin", "Fil", "t", "Total_", ":_", "]_", "=_", "freqs_", "[_", "num", "Lin", "Fil", "t", "Total_", "-_", "1_", "]_", "*_", "logs", "c_", "**_", "numpy_", "._", "arange_", "(_", "1_", ",_", "num", "Log", "Fil", "t_", "+_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "heights_", "=_", "2._", "/_", "(_", "freqs_", "[_", "2_", ":_", "]_", "-_", "freqs_", "[_", "0_", ":_", "-_", "2_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Compute", " ", "filter", "bank", " ", "coef", "f", " ", "(", "in", " ", "fft", " ", "domain", ",", " ", "in", " ", "bins", ")_", "\\u\\u\\uNL\\u\\u\\u_", "fba", "nk_", "=_", "numpy_", "._", "zeros_", "(_", "(_", "n", "Fil", "t", "Total_", ",_", "nff", "t_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nfr", "eqs", "_", "=_", "numpy_", "._", "arange_", "(_", "nff", "t_", ")_", "/_", "(_", "1._", "*_", "nff", "t_", ")_", "*_", "fs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "n", "Fil", "t", "Total_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "low", "Tr", "Freq_", "=_", "freqs_", "[_", "i_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cen", "Tr", "Freq_", "=_", "freqs_", "[_", "i_", "+_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "high", "Tr", "Freq_", "=_", "freqs_", "[_", "i_", "+_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "lid_", "=_", "numpy_", "._", "arange_", "(_", "numpy_", "._", "floor_", "(_", "low", "Tr", "Freq_", "*_", "nff", "t_", "/_", "fs_", ")_", "+_", "1_", ",_", "numpy_", "._", "floor_", "(_", "cen", "Tr", "Freq_", "*_", "nff", "t_", "/_", "fs_", ")_", "+_", "1_", ",_", "dtype_", "=_", "numpy_", "._", "int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ls", "lop", "e_", "=_", "heights_", "[_", "i_", "]_", "/_", "(_", "cen", "Tr", "Freq_", "-_", "low", "Tr", "Freq_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rid_", "=_", "numpy_", "._", "arange_", "(_", "numpy_", "._", "floor_", "(_", "cen", "Tr", "Freq_", "*_", "nff", "t_", "/_", "fs_", ")_", "+_", "1_", ",_", "numpy_", "._", "floor_", "(_", "high", "Tr", "Freq_", "*_", "nff", "t_", "/_", "fs_", ")_", "+_", "1_", ",_", "dtype_", "=_", "numpy_", "._", "int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rsl", "ope", "_", "=_", "heights_", "[_", "i_", "]_", "/_", "(_", "high", "Tr", "Freq_", "-_", "cen", "Tr", "Freq_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fba", "nk_", "[_", "i_", "]_", "[_", "lid_", "]_", "=_", "ls", "lop", "e_", "*_", "(_", "nfr", "eqs", "_", "[_", "lid_", "]_", "-_", "low", "Tr", "Freq_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fba", "nk_", "[_", "i_", "]_", "[_", "rid_", "]_", "=_", "rsl", "ope", "_", "*_", "(_", "high", "Tr", "Freq_", "-_", "nfr", "eqs", "_", "[_", "rid_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "fba", "nk_", ",_", "freqs_", "\\u\\u\\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", "Chrom", "agr", "am_", "(_", "signal_", ",_", "Fs_", ",_", "Win_", ",_", "Step_", ",_", "PLOT", "_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Short", "-", "term", " ", "FFT", " ", "mag", " ", "for", " ", "spect", "ogram", " ", "estimati", "on", ":", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "nump", "y", " ", "array", " ", "(", "n", "FFT", " ", "x", " ", "num", "Of", "Short", "Term", "Window", "s", ")", "\\", "10", ";", " ", " ", " ", " ", "ARGUMENT", "S", ":", "\\", "10", ";", " ", " ", " ", " ", "signal", ":", " ", " ", "the", " ", "input", " ", "signal", " ", "samples", "\\", "10", ";", " ", " ", " ", " ", "Fs", ":", " ", " ", "the", " ", "samp", "ling", " ", "freq", " ", "(", "in", " ", "H", "z", ")", "\\", "10", ";", " ", " ", " ", " ", "Win", ":", " ", " ", " ", " ", " ", "the", " ", "short", "-", "term", " ", "window", " ", "size", " ", "(", "in", " ", "samples", ")", "\\", "10", ";", " ", " ", " ", " ", "Step", ":", " ", " ", " ", " ", "the", " ", "short", "-", "term", " ", "window", " ", "step", " ", "(", "in", " ", "samples", ")", "\\", "10", ";", " ", " ", " ", " ", "PLOT", ":", " ", " ", " ", " ", "flag", ",", " ", "1", " ", "if", " ", "results", " ", "are", " ", "to", " ", "be", " ", "plot", "ed", "\\", "10", ";", " ", " ", " ", " ", "RETURN", "S", ":", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Win_", "=_", "int_", "(_", "Win_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Step_", "=_", "int_", "(_", "Step_", ")_", "\\u\\u\\uNEWLINE\\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_", "-_", "DC_", ")_", "\\u\\u\\uNEWLINE\\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_", "nff", "t_", "=_", "int_", "(_", "Win_", "/_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "n", "Chrom", "a_", ",_", "n", "Freq", "s", "Per", "Chrom", "a_", "=_", "st", "Chrom", "a", "Feature", "s", "Init_", "(_", "nff", "t_", ",_", "Fs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "chroma", "Gram", "_", "=_", "numpy_", "._", "array_", "(_", "[_", "]_", ",_", "dtype_", "=_", "numpy_", "._", "float64_", ")_", "\\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_", "chroma", "Names_", ",_", "C_", "=_", "st", "Chrom", "a", "Features_", "(_", "X_", ",_", "Fs_", ",_", "n", "Chrom", "a_", ",_", "n", "Freq", "s", "Per", "Chrom", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "C_", "=_", "C_", "[_", ":_", ",_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "count", "Frames_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chroma", "Gram", "_", "=_", "C_", "._", "T_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "chroma", "Gram", "_", "=_", "numpy_", "._", "vstack_", "(_", "(_", "chroma", "Gram", "_", ",_", "C_", "._", "T_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Freq", "Axis_", "=_", "chroma", "Names_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Time", "Axis_", "=_", "[_", "(_", "t_", "*_", "Step_", ")_", "/_", "Fs_", "for_", "t_", "in_", "range_", "(_", "chroma", "Gram", "_", "._", "shape_", "[_", "0_", "]_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "(_", "PLOT", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fig_", ",_", "ax_", "=_", "plt_", "._", "subplots_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "chroma", "Gram", "To", "Plot_", "=_", "chroma", "Gram", "_", "._", "transpose_", "(_", ")_", "[_", ":_", ":_", "-_", "1_", ",_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Ratio_", "=_", "chroma", "Gram", "To", "Plot_", "._", "shape_", "[_", "1_", "]_", "/_", "(_", "3_", "*_", "chroma", "Gram", "To", "Plot_", "._", "shape_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "chroma", "Gram", "To", "Plot_", "=_", "numpy_", "._", "repeat_", "(_", "chroma", "Gram", "To", "Plot_", ",_", "Ratio_", ",_", "axis_", "=_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "img", "plot_", "=_", "plt_", "._", "imshow_", "(_", "chroma", "Gram", "To", "Plot_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Fs", "tep_", "=_", "int_", "(_", "nff", "t_", "/_", "5.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", " ", "Freq", "Ticks", " ", "=", " ", "range", "(", "0", ",", " ", "int", "(", "nff", "t", ")", " ", "+", " ", "Fs", "tep", ",", " ", "Fs", "tep", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "Freq", "Ticks", "Label", "s", " ", "=", " ", "[", "str", "(", "Fs", "/", "2", "-", "int", "((", "f", "*", "Fs", ")", " ", "/", " ", "(", "2", "*", "nff", "t", ")))", " ", "for", " ", "f", " ", "in", " ", "Freq", "Ticks", "]_", "\\u\\u\\uNL\\u\\u\\u_", "ax_", "._", "set\\u", "yticks_", "(_", "range_", "(_", "Ratio_", "/_", "2_", ",_", "len_", "(_", "Freq", "Axis_", ")_", "*_", "Ratio_", ",_", "Ratio_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "._", "set\\u", "yticklabels_", "(_", "Freq", "Axis_", "[_", ":_", ":_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "TS", "tep_", "=_", "count", "Frames_", "/_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Time", "Ticks", "_", "=_", "range_", "(_", "0_", ",_", "count", "Frames_", ",_", "TS", "tep_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Time", "Ticks", "Labels_", "=_", "[_", "'%", ".2", "f", "'_", "%_", "(_", "float_", "(_", "t_", "*_", "Step_", ")_", "/_", "Fs_", ")_", "for_", "t_", "in_", "Time", "Ticks", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "._", "set\\u", "xticks_", "(_", "Time", "Ticks", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "._", "set\\u", "xticklabels_", "(_", "Time", "Ticks", "Labels_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ax_", "._", "set\\u", "xlabel_", "(_", "'", "time", " ", "(", "secs", ")'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "img", "plot_", "._", "set\\u", "cmap_", "(_", "'", "jet", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "colorbar_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plt_", "._", "show_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "(_", "chroma", "Gram", "_", ",_", "Time", "Axis_", ",_", "Freq", "Axis_", ")_", "\\u\\u\\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_", "(_", "st", "Features_", ")_", "\\u\\u\\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_", "dir", "Wa", "v", "Feature", "Extraction", "No", "Ave", "rag", "ing_", "(_", "dir", "Name_", ",_", "mt", "Win_", ",_", "mt", "Step_", ",_", "st", "Win_", ",_", "st", "Step_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "function", " ", "extracts", " ", "the", " ", "mid", "-", "term", " ", "features", " ", "of", " ", "the", " ", "WAVE", " ", "files", " ", "of", " ", "a", " ", "partic", "ular", " ", "folder", " ", "with", "out", " ", "averag", "ing", " ", "each", " ", "file", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "ARGUMENT", "S", ":", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "dir", "Name", ":", " ", " ", "the", " ", "path", " ", "of", " ", "the", " ", "WAVE", " ", "director", "y", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "mt", "Win", ",", " ", "mt", "Step", ":", " ", " ", " ", " ", "mid", "-", "term", " ", "window", " ", "and", " ", "step", " ", "(", "in", " ", "second", "s", ")", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "st", "Win", ",", " ", "st", "Step", ":", " ", " ", " ", " ", "short", "-", "term", " ", "window", " ", "and", " ", "step", " ", "(", "in", " ", "second", "s", ")", "\\", "10", ";", " ", " ", " ", " ", "RETURN", "S", ":", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "X", ":", " ", " ", " ", " ", "A", " ", "feature", " ", "matrix", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "Y", ":", " ", " ", " ", " ", "A", " ", "matrix", " ", "of", " ", "file", " ", "labels", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "filename", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "all", "Mt", "Features_", "=_", "numpy_", "._", "array_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal", "Indices_", "=_", "numpy_", "._", "array_", "(_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "process", "ing", "Times_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "types_", "=_", "(_", "'*", ".", "wav", "'_", ",_", "'*", ".", "aif", "'_", ",_", "'*", ".", "aif", "f", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "wav", "Files", "List_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "files_", "in_", "types_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "wav", "Files", "List_", "._", "extend_", "(_", "glob_", "._", "glob_", "(_", "os_", "._", "path_", "._", "join_", "(_", "dir", "Name_", ",_", "files_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "wav", "Files", "List_", "=_", "sorted_", "(_", "wav", "Files", "List_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", ",_", "wav", "File_", "in_", "enumerate_", "(_", "wav", "Files", "List_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "[_", "Fs_", ",_", "x_", "]_", "=_", "audio", "Basic", "IO_", "._", "read", "Audi", "o", "File_", "(_", "wav", "File_", ")_", "#", " ", "read", " ", "file_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", "=_", "audio", "Basic", "IO_", "._", "stereo", "2m", "ono", "_", "(_", "x_", ")_", "#", " ", "convert", " ", "stereo", " ", "to", " ", "mono", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[_", "Mid", "Term", "Features_", ",_", "\\u_", "]_", "=_", "mt", "Feature", "Extraction", "_", "(_", "x_", ",_", "Fs_", ",_", "round_", "(_", "mt", "Win_", "*_", "Fs_", ")_", ",_", "round_", "(_", "mt", "Step_", "*_", "Fs_", ")_", ",_", "round_", "(_", "Fs_", "*_", "st", "Win_", ")_", ",_", "round_", "(_", "Fs_", "*_", "st", "Step_", ")_", ")_", "#", " ", "mid", "-", "term", " ", "feature_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Mid", "Term", "Features_", "=_", "numpy_", "._", "transpose_", "(_", "Mid", "Term", "Features_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", " ", " ", " ", "Mid", "Term", "Feature", "s", " ", "=", " ", "Mid", "Term", "Feature", "s", ".", "mean", "(", "axis", "=", "0", ")", " ", " ", " ", " ", "#", " ", "long", " ", "term", " ", "averag", "ing", " ", "of", " ", "mid", "-", "term", " ", "statistics_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "all", "Mt", "Features_", ")_", "==_", "0_", ":_", "#", " ", "append", " ", "feature", " ", "vector_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "all", "Mt", "Features_", "=_", "Mid", "Term", "Features_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal", "Indices_", "=_", "numpy_", "._", "zeros_", "(_", "(_", "Mid", "Term", "Features_", "._", "shape_", "[_", "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 ", " _", "all", "Mt", "Features_", "=_", "numpy_", "._", "vstack_", "(_", "(_", "all", "Mt", "Features_", ",_", "Mid", "Term", "Features_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "signal", "Indices_", "=_", "numpy_", "._", "append_", "(_", "signal", "Indices_", ",_", "i_", "*_", "numpy_", "._", "ones_", "(_", "(_", "Mid", "Term", "Features_", "._", "shape_", "[_", "0_", "]_", ",_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\u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 2, 2, 2, 2, 2 ]
Unused import
azoft-dev-team/imagrium/env/Lib/distutils/tests/test_install_headers.py
[ { "content": "\"\"\"Tests for distutils.command.install_headers.\"\"\"\nimport sys\nimport os\nimport unittest\nimport getpass\n\nfrom distutils.command.install_headers import install_headers\nfrom distutils.tests import support\nfrom test.test_support import run_unittest\n\n\n\nif __name__ == \"__main__\":\n run_unittest(test_suite())\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class InstallHeadersTestCase(support.TempdirManager,\n support.LoggingSilencer,\n support.EnvironGuard,\n unittest.TestCase):\n", "metadata": "root.InstallHeadersTestCase", "header": "['module', '___EOS___']", "index": 10 }, { "content": " def test_simple_run(self):\n # we have two headers\n header_list = self.mkdtemp()\n header1 = os.path.join(header_list, 'header1')\n header2 = os.path.join(header_list, 'header2')\n self.write_file(header1)\n self.write_file(header2)\n headers = [header1, header2]\n\n pkg_dir, dist = self.create_dist(headers=headers)\n cmd = install_headers(dist)\n self.assertEqual(cmd.get_inputs(), headers)\n\n # let's run the command\n cmd.install_dir = os.path.join(pkg_dir, 'inst')\n cmd.ensure_finalized()\n cmd.run()\n\n # let's check the results\n self.assertEqual(len(cmd.get_outputs()), 2)", "metadata": "root.InstallHeadersTestCase.test_simple_run", "header": "['class', 'InstallHeadersTestCase', '(', 'support', '.', 'TempdirManager', ',', '___NL___', 'support', '.', 'LoggingSilencer', ',', '___NL___', 'support', '.', 'EnvironGuard', ',', '___NL___', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 15 }, { "content": "def test_suite():\n return unittest.makeSuite(InstallHeadersTestCase)", "metadata": "root.test_suite", "header": "['module', '___EOS___']", "index": 36 } ]
[ { "span": "import sys", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 10 }, { "span": "import getpass", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 14 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "Test", "s", " ", "for", " ", "distutils", ".", "command", ".", "install", "\\u", "header", "s", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "getpass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "distutils_", "._", "command_", "._", "install", "\\u", "headers_", "import_", "install", "\\u", "headers_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "distutils_", "._", "tests_", "import_", "support_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "test_", "._", "test\\u", "support_", "import_", "run", "\\u", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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 ", " _", "run", "\\u", "unittest_", "(_", "test\\u", "suite_", "(_", ")_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Install", "Head", "ers", "Test", "Case_", "(_", "support_", "._", "Temp", "dir", "Manager_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "support_", "._", "Log", "ging", "Sile", "nce", "r_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "support_", "._", "Environ", "Guard", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Install", "Head", "ers", "Test", "Case_", "(_", "support_", "._", "Temp", "dir", "Manager_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "support_", "._", "Log", "ging", "Sile", "nce", "r_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "support_", "._", "Environ", "Guard", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "simple", "\\u", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "we", " ", "have", " ", "two", " ", "headers_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "header", "\\u", "list_", "=_", "self_", "._", "mkdtemp_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "header", "1_", "=_", "os_", "._", "path_", "._", "join_", "(_", "header", "\\u", "list_", ",_", "'", "header", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "header", "2_", "=_", "os_", "._", "path_", "._", "join_", "(_", "header", "\\u", "list_", ",_", "'", "header", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "write", "\\u", "file_", "(_", "header", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "write", "\\u", "file_", "(_", "header", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "headers_", "=_", "[_", "header", "1_", ",_", "header", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pkg", "\\u", "dir_", ",_", "dist_", "=_", "self_", "._", "create", "\\u", "dist_", "(_", "headers_", "=_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "install", "\\u", "headers_", "(_", "dist_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "cmd_", "._", "get", "\\u", "inputs_", "(_", ")_", ",_", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "let", "'", "s", " ", "run", " ", "the", " ", "command_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "._", "install", "\\u", "dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "pkg", "\\u", "dir_", ",_", "'", "inst", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "._", "ensure", "\\u", "finalize", "d_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "let", "'", "s", " ", "check", " ", "the", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "cmd_", "._", "get", "\\u", "outputs_", "(_", ")_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\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", "suite_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "unittest_", "._", "make", "Suite_", "(_", "Install", "Head", "ers", "Test", "Case_", ")_", "\\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, 0, 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, 4, 2, 2, 2, 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
stopstalk/stopstalk-deployment/controllers/default.py
[ { "content": "\"\"\"\n Copyright (c) 2015-2016 Raj Patel([email protected]), StopStalk\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.\n\"\"\"\n\nimport time\nimport datetime\nimport parsedatetime as pdt\nimport requests\nfrom operator import itemgetter\nimport utilities\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# END =========================================================================\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def index():\n \"\"\"\n The main controller which redirects depending\n on the login status of the user and does some\n extra pre-processing\n \"\"\"\n\n # If the user is logged in\n if session[\"auth\"]:\n session.flash = \"Welcome StopStalker!!\"\n redirect(URL(\"default\", \"submissions\", args=[1]))\n\n return dict()", "metadata": "root.index", "header": "['module', '___EOS___']", "index": 30 }, { "content": "@auth.requires_login()\ndef notifications():\n \"\"\"\n Check if any of the friends(includes CUSTOM) of\n the logged-in user is on a streak\n \"\"\"\n\n if session[\"user_id\"] is None:\n redirect(URL(\"default\", \"index\"))\n\n ftable = db.friends\n atable = db.auth_user\n cftable = db.custom_friend\n\n # Check for streak of friends on stopstalk\n query = (ftable.user_id == session[\"user_id\"])\n rows = db(query).select(atable.first_name,\n atable.last_name,\n atable.stopstalk_handle,\n join=ftable.on(ftable.friend_id == atable.id))\n\n # Will contain list of handles of all the friends along\n # with the Custom Users added by the logged-in user\n handles = []\n\n complete_dict = {}\n friends_stopstalk_handles = []\n for user in rows:\n complete_dict[user.stopstalk_handle] = []\n friends_stopstalk_handles.append(\"'\" + user.stopstalk_handle + \"'\")\n handles.append((user.stopstalk_handle,\n user.first_name + \" \" + user.last_name,\n user.stopstalk_handle))\n\n # Check for streak of custom friends\n query = (cftable.user_id == session[\"user_id\"])\n rows = db(query).select(cftable.first_name,\n cftable.last_name,\n cftable.duplicate_cu,\n cftable.stopstalk_handle)\n\n for user in rows:\n name = user.first_name + \" \" + user.last_name\n actual_handle = user.stopstalk_handle\n\n if user.duplicate_cu:\n stopstalk_handle = user.duplicate_cu.stopstalk_handle\n else:\n stopstalk_handle = user.stopstalk_handle\n\n handles.append((stopstalk_handle, name, actual_handle))\n complete_dict[stopstalk_handle] = []\n friends_stopstalk_handles.append(\"'\" + stopstalk_handle + \"'\")\n\n if friends_stopstalk_handles == []:\n friends_stopstalk_handles = [\"-1\"]\n\n # Build the complex SQL query\n sql_query = \"\"\"\n SELECT stopstalk_handle, DATE(time_stamp), COUNT(*) as cnt\n FROM submission\n WHERE stopstalk_handle in (%s)\n GROUP BY stopstalk_handle, DATE(submission.time_stamp)\n ORDER BY time_stamp;\n \"\"\" % (\", \".join(friends_stopstalk_handles))\n\n user_rows = db.executesql(sql_query)\n for user in user_rows:\n if complete_dict[user[0]] != []:\n complete_dict[user[0]].append((user[1], user[2]))\n else:\n complete_dict[user[0]] = [(user[1], user[2])]\n\n # List of users with non-zero streak\n users_on_day_streak = []\n users_on_submission_streak = []\n\n for handle in handles:\n curr_streak = utilities.get_max_streak(complete_dict[handle[0]])[2]\n curr_accepted_streak = utilities.get_accepted_streak(handle[0])\n\n # If streak is non-zero append to users_on_streak list\n if curr_streak:\n users_on_day_streak.append((handle, curr_streak))\n if curr_accepted_streak:\n users_on_submission_streak.append((handle, curr_accepted_streak))\n\n # Sort the users on streak by their streak\n users_on_day_streak.sort(key=lambda k: k[1], reverse=True)\n users_on_submission_streak.sort(key=lambda k: k[1], reverse=True)\n\n # The table containing users on streak(days)\n table1 = TABLE(THEAD(TR(TH(STRONG(\"User\")),\n TH(STRONG(\"Days\")))),\n _class=\"col offset-s3 s6 striped centered\")\n\n # The table containing users on streak(submissions)\n table2 = TABLE(THEAD(TR(TH(STRONG(\"User\")),\n TH(STRONG(\"Submissions\")))),\n _class=\"col offset-s3 s6 striped centered\")\n\n tbody1 = TBODY()\n tbody2 = TBODY()\n\n # Append all the users to the final table\n for users in users_on_day_streak:\n handle = users[0]\n curr_streak = users[1]\n tr = TR(TD((A(handle[1],\n _href=URL(\"user\", \"profile\", args=[handle[2]]),\n _target=\"_blank\"))),\n TD(str(curr_streak) + \" \",\n I(_class=\"fa fa-bolt\",\n _style=\"color:red\"),\n _class=\"center\"))\n tbody1.append(tr)\n\n table1.append(tbody1)\n if len(users_on_day_streak) == 0:\n table1 = H6(\"No friends on day streak\", _class=\"center\")\n\n # Append all the users to the final table\n for users in users_on_submission_streak:\n handle = users[0]\n curr_accepted_streak = users[1]\n tr = TR(TD((A(handle[1],\n _href=URL(\"user\", \"profile\", args=[handle[2]]),\n _target=\"_blank\"))),\n TD(str(curr_accepted_streak) + \" \",\n I(_class=\"fa fa-bolt\",\n _style=\"color:red\"),\n _class=\"center\"))\n tbody2.append(tr)\n\n table2.append(tbody2)\n if len(users_on_submission_streak) == 0:\n table2 = H6(\"No friends on submission streak\", _class=\"center\")\n\n return dict(table1=table1,\n table2=table2)", "metadata": "root.notifications", "header": "['module', '___EOS___']", "index": 45 }, { "content": "@auth.requires_login()\ndef unsubscribe():\n\n utable = db.unsubscriber\n utable.email.default = session.auth.user.email\n utable.email.writable = False\n already_unsubscribed = False\n\n query = (utable.email == session.auth.user.email)\n rows = db(query).select()\n if len(rows) != 0:\n already_unsubscribed = True\n form = SQLFORM(utable,\n submit_button=\"Subscribe\")\n if form.validate():\n for row in rows:\n row.delete_record()\n session.flash = \"Subscribed successfully!\"\n redirect(URL(\"default\", \"unsubscribe\"))\n elif form.errors:\n response.flash = \"Form has errors\"\n else:\n form = SQLFORM(utable,\n submit_button=\"Unsubscribe\")\n if form.process().accepted:\n response.flash = \"Successfully unsubscribed!\"\n redirect(URL(\"default\", \"unsubscribe\"))\n elif form.errors:\n response.flash = \"Form has errors\"\n\n return dict(form=form,\n already_unsubscribed=already_unsubscribed)", "metadata": "root.unsubscribe", "header": "['module', '___EOS___']", "index": 187 }, { "content": "@auth.requires_login()\ndef my_friends():\n \"\"\"\n Display the friends data\n \"\"\"\n\n ftable = db.friends\n\n rows = db(ftable.user_id == session.user_id).select(ftable.friend_id)\n table = TABLE(THEAD(TR(TH(\"Friend name\"),\n TH(\"Authentic user\"),\n TH(\"Institute friend\"),\n TH(\"Other friend\"),\n TH(\"Claimable\"))),\n _class=\"centered col offset-s3 s6\")\n\n tbody = TBODY()\n check = I(_class=\"fa fa-check\",\n _style=\"color: #0f0\")\n cross = I(_class=\"fa fa-close\",\n _style=\"color: #f00\")\n\n valid_friends = 0\n for row in rows:\n claimable = True\n thisfriend = row.friend_id\n name = thisfriend.first_name + \" \" + thisfriend.last_name\n tr = TR(TD(A(name, _href=URL(\"user\", \"profile\",\n args=thisfriend.stopstalk_handle))))\n claimable &= thisfriend.authentic\n if thisfriend.authentic:\n tr.append(check)\n else:\n tr.append(cross)\n\n query = (ftable.user_id == thisfriend)\n friends_of_friends = db(query).select(ftable.friend_id)\n institute_friends = 0\n for fof in friends_of_friends:\n if fof.friend_id.institute == thisfriend.institute and \\\n fof.friend_id.institute != \"Other\":\n institute_friends += 1\n if institute_friends > 1:\n tr.append(TD(check))\n tr.append(TD(check))\n else:\n if institute_friends == 0:\n claimable &= False\n tr.append(cross)\n if len(friends_of_friends) >= 2:\n tr.append(check)\n else:\n tr.append(cross)\n else:\n tr.append(check)\n if len(friends_of_friends) >= 3:\n claimable &= True\n tr.append(check)\n else:\n claimable &= False\n tr.append(cross)\n\n\n if claimable:\n valid_friends += 1\n tr.append(TD(I(_class=\"fa fa-thumbs-up\")))\n else:\n tr.append(TD())\n tbody.append(tr)\n\n table.append(tbody)\n\n claimable_stickers = valid_friends/3\n stickers = [claimable_stickers/3] * 3\n residue = claimable_stickers - (claimable_stickers/3) * 3\n i = 0\n while residue:\n stickers[i] += 1\n i += 1\n residue -= 1\n\n return dict(table=DIV(table, _class=\"row\"),\n claimable_stickers=claimable_stickers,\n stickers=stickers)", "metadata": "root.my_friends", "header": "['module', '___EOS___']", "index": 221 }, { "content": "def sort_contests(a, b):\n if a[\"has_started\"] and b[\"has_started\"]:\n return a[\"end\"] < b[\"end\"]\n elif a[\"has_started\"] and b[\"has_started\"] == False:\n return False\n elif a[\"has_started\"] == False and b[\"has_started\"]:\n return True\n else:\n return a[\"start\"] < b[\"start\"]", "metadata": "root.sort_contests", "header": "['module', '___EOS___']", "index": 307 }, { "content": "def contests():\n \"\"\"\n Show the upcoming contests\n \"\"\"\n\n today = datetime.datetime.today()\n today = datetime.datetime.strptime(str(today)[:-7],\n \"%Y-%m-%d %H:%M:%S\")\n\n start_date = today.date()\n end_date = start_date + datetime.timedelta(90)\n url = \"https://contesttrackerapi.herokuapp.com/\"\n response = requests.get(url)\n if response.status_code == 200:\n response = response.json()[\"result\"]\n else:\n # @todo: something better\n return dict()\n\n ongoing = response[\"ongoing\"]\n upcoming = response[\"upcoming\"]\n contests = []\n cal = pdt.Calendar()\n\n table = TABLE(_class=\"centered striped\")\n thead = THEAD(TR(TH(\"Contest Name\"),\n TH(\"Site\"),\n TH(\"Start\"),\n TH(\"Duration/Ending\"),\n TH(\"Link\"),\n TH(\"Add Reminder\")))\n table.append(thead)\n tbody = TBODY()\n\n for i in ongoing:\n\n if i[\"Platform\"] in (\"TOPCODER\", \"OTHER\"):\n continue\n\n try:\n endtime = datetime.datetime.strptime(i[\"EndTime\"],\n \"%a, %d %b %Y %H:%M\")\n except ValueError:\n continue\n tr = TR()\n span = SPAN(_class=\"green tooltipped\",\n data={\"position\": \"right\",\n \"delay\": \"50\",\n \"tooltip\": \"Live Contest\"},\n _style=\"cursor: pointer; \" + \\\n \"float:right; \" + \\\n \"height:10px; \" + \\\n \"width:10px; \" + \\\n \"border-radius: 50%;\")\n tr.append(TD(i[\"Name\"], span))\n tr.append(TD(i[\"Platform\"].capitalize()))\n tr.append(TD(\"-\"))\n tr.append(TD(str(endtime).replace(\"-\", \"/\"),\n _class=\"contest-end-time\"))\n tr.append(TD(A(I(_class=\"fa fa-external-link-square fa-lg\"),\n _class=\"btn-floating btn-small green accent-4 tooltipped\",\n _href=i[\"url\"],\n data={\"position\": \"left\",\n \"tooltip\": \"Contest Link\",\n \"delay\": \"50\"},\n _target=\"_blank\")))\n tr.append(TD(BUTTON(I(_class=\"fa fa-calendar-plus-o\"),\n _class=\"btn-floating btn-small orange accent-4 tooltipped disabled\",\n data={\"position\": \"left\",\n \"tooltip\": \"Already started!\",\n \"delay\": \"50\"})))\n tbody.append(tr)\n\n # This id is used for uniquely identifying\n # a particular contest in js\n button_id = 1\n for i in upcoming:\n\n if i[\"Platform\"] in (\"TOPCODER\", \"OTHER\"):\n continue\n\n start_time = datetime.datetime.strptime(i[\"StartTime\"],\n \"%a, %d %b %Y %H:%M\")\n tr = TR(_id=\"contest-\" + str(button_id))\n tr.append(TD(i[\"Name\"]))\n tr.append(TD(i[\"Platform\"].capitalize()))\n tr.append(TD(str(start_time)))\n\n duration = i[\"Duration\"]\n duration = duration.replace(\" days\", \"d\")\n duration = duration.replace(\" day\", \"d\")\n tr.append(TD(duration))\n tr.append(TD(A(I(_class=\"fa fa-external-link-square fa-lg\"),\n _class=\"btn-floating btn-small green accent-4 tooltipped\",\n _href=i[\"url\"],\n data={\"position\": \"left\",\n \"tooltip\": \"Contest Link\",\n \"delay\": \"50\"},\n _target=\"_blank\")))\n tr.append(TD(BUTTON(I(_class=\"fa fa-calendar-plus-o\"),\n _class=\"btn-floating btn-small orange accent-4 tooltipped\",\n data={\"position\": \"left\",\n \"tooltip\": \"Set Reminder to Google Calendar\",\n \"delay\": \"50\"},\n _id=\"set-reminder-\" + str(button_id))))\n tbody.append(tr)\n button_id += 1\n\n table.append(tbody)\n return dict(table=table, upcoming=upcoming)", "metadata": "root.contests", "header": "['module', '___EOS___']", "index": 318 }, { "content": "def leaderboard():\n \"\"\"\n Get a table with users sorted by rating\n \"\"\"\n\n specific_institute = False\n atable = db.auth_user\n cftable = db.custom_friend\n\n global_leaderboard = False\n if request.vars.has_key(\"global\"):\n if request.vars[\"global\"] == \"True\":\n global_leaderboard = True\n else:\n if session.user_id is None:\n response.flash = \"Login to see Friends Leaderboard\"\n global_leaderboard = True\n else:\n if session.user_id is None:\n global_leaderboard = True\n\n heading = \"Global Leaderboard\"\n afields = [\"first_name\", \"last_name\", \"stopstalk_handle\",\n \"institute\", \"per_day\", \"rating\"]\n cfields = afields + [\"duplicate_cu\"]\n\n aquery = (atable.id > 0)\n cquery = (cftable.id > 0)\n if global_leaderboard is False:\n if session.user_id:\n heading = \"Friends Leaderboard\"\n friends, cusfriends = utilities.get_friends(session.user_id)\n custom_friends = [x[0] for x in cusfriends]\n\n # Add logged-in user to leaderboard\n friends.append(session.user_id)\n aquery &= (atable.id.belongs(friends))\n cquery &= (cftable.id.belongs(custom_friends))\n else:\n aquery &= (1 == 0)\n cquery &= (1 == 0)\n\n if request.vars.has_key(\"q\"):\n heading = \"Institute Leaderboard\"\n institute = request.vars[\"q\"]\n\n if institute != \"\":\n specific_institute = True\n aquery &= (atable.institute == institute)\n cquery &= (cftable.institute == institute)\n reg_users = db(aquery).select(*afields)\n custom_users = db(cquery).select(*cfields)\n\n if specific_institute is False:\n reg_users = db(aquery).select(*afields)\n custom_users = db(cquery).select(*cfields)\n\n # Find the total solved problems(Lesser than total accepted)\n solved_count = {}\n sql = \"\"\"\n SELECT stopstalk_handle, COUNT(DISTINCT(problem_name))\n FROM submission\n WHERE status = 'AC'\n GROUP BY user_id, custom_user_id;\n \"\"\"\n tmplist = db.executesql(sql)\n for user in tmplist:\n solved_count[user[0]] = user[1]\n\n complete_dict = {}\n # Prepare a list of stopstalk_handles of the\n # users relevant to the requested leaderboard\n friends_stopstalk_handles = []\n for x in reg_users:\n friends_stopstalk_handles.append(\"'\" + x.stopstalk_handle + \"'\")\n complete_dict[x.stopstalk_handle] = []\n\n for custom_user in custom_users:\n stopstalk_handle = custom_user.stopstalk_handle\n if custom_user.duplicate_cu:\n stopstalk_handle = cftable(custom_user.duplicate_cu).stopstalk_handle\n friends_stopstalk_handles.append(\"'\" + stopstalk_handle + \"'\")\n complete_dict[stopstalk_handle] = []\n\n if friends_stopstalk_handles == []:\n friends_stopstalk_handles = [\"-1\"]\n\n # Build the complex SQL query\n sql_query = \"\"\"\n SELECT stopstalk_handle, DATE(time_stamp), COUNT(*) as cnt\n FROM submission\n WHERE stopstalk_handle in (%s)\n GROUP BY stopstalk_handle, DATE(submission.time_stamp)\n ORDER BY time_stamp;\n \"\"\" % (\", \".join(friends_stopstalk_handles))\n\n user_rows = db.executesql(sql_query)\n for user in user_rows:\n if complete_dict[user[0]] != []:\n complete_dict[user[0]].append((user[1], user[2]))\n else:\n complete_dict[user[0]] = [(user[1], user[2])]\n\n users = []\n for user in reg_users:\n try:\n solved = solved_count[user.stopstalk_handle]\n except KeyError:\n solved = 0\n\n tup = utilities.compute_row(user, complete_dict, solved)\n if tup is not ():\n users.append(tup)\n\n for user in custom_users:\n try:\n if user.duplicate_cu:\n orig_user = cftable(user.duplicate_cu)\n solved = solved_count[orig_user.stopstalk_handle]\n else:\n solved = solved_count[user.stopstalk_handle]\n except KeyError:\n solved = 0\n tup = utilities.compute_row(user, complete_dict, solved, True)\n if tup is not ():\n users.append(tup)\n\n # Sort users according to the rating\n users = sorted(users, key=lambda x: x[3], reverse=True)\n\n table = TABLE(_class=\"centered striped\")\n table.append(THEAD(TR(TH(\"Rank\"),\n TH(\"Name\"),\n TH(\"StopStalk Handle\"),\n TH(\"Institute\"),\n TH(\"StopStalk Rating\"),\n TH(\"Rating Changes\"),\n TH(\"Per Day Changes\"))))\n\n tbody = TBODY()\n rank = 1\n for i in users:\n\n if i[5]:\n span = SPAN(_class=\"orange tooltipped\",\n data={\"position\": \"right\",\n \"delay\": \"50\",\n \"tooltip\": \"Custom User\"},\n _style=\"cursor: pointer; \" + \\\n \"float:right; \" + \\\n \"height:10px; \" + \\\n \"width:10px; \" + \\\n \"border-radius: 50%;\")\n else:\n span = SPAN()\n\n tr = TR()\n tr.append(TD(str(rank) + \".\"))\n tr.append(TD(DIV(span, DIV(i[0]))))\n tr.append(TD(A(i[1],\n _href=URL(\"user\", \"profile\", args=[i[1]]),\n _target=\"_blank\")))\n tr.append(TD(A(i[2],\n _href=URL(\"default\",\n \"leaderboard\",\n vars={\"q\": i[2],\n \"global\": global_leaderboard}))))\n tr.append(TD(i[3]))\n if i[6] > 0:\n tr.append(TD(B(\"+%s\" % str(i[6])),\n _class=\"green-text text-darken-2\"))\n elif i[6] < 0:\n tr.append(TD(B(i[6]), _class=\"red-text text-darken-2\"))\n else:\n tr.append(TD(i[6], _class=\"blue-text text-darken-2\"))\n\n diff = \"{:1.5f}\".format(i[4])\n\n if float(diff) == 0.0:\n tr.append(TD(\"+\" + diff, \" \",\n I(_class=\"fa fa-minus\")))\n elif i[4] > 0:\n tr.append(TD(\"+\" + str(diff), \" \",\n I(_class=\"fa fa-chevron-circle-up\",\n _style=\"color: #0f0;\")))\n elif i[4] < 0:\n tr.append(TD(diff, \" \",\n I(_class=\"fa fa-chevron-circle-down\",\n _style=\"color: #f00;\")))\n\n tbody.append(tr)\n rank += 1\n\n table.append(tbody)\n switch = DIV(LABEL(H6(\"Friends' Submissions\",\n INPUT(_type=\"checkbox\", _id=\"submission-switch\"),\n SPAN(_class=\"lever pink accent-3\"),\n \"Global Submissions\")),\n _class=\"switch\")\n div = TAG[\"\"](switch, table)\n return dict(div=div,\n heading=heading,\n global_leaderboard=global_leaderboard)", "metadata": "root.leaderboard", "header": "['module', '___EOS___']", "index": 430 }, { "content": "def user():\n \"\"\"\n Use the standard auth for user\n \"\"\"\n return dict(form=auth())", "metadata": "root.user", "header": "['module', '___EOS___']", "index": 635 }, { "content": "@auth.requires_login()\ndef search():\n \"\"\"\n Search for a user\n \"\"\"\n\n return dict()", "metadata": "root.search", "header": "['module', '___EOS___']", "index": 642 }, { "content": "def filters():\n \"\"\"\n Apply multiple kind of filters on submissions\n \"\"\"\n\n stable = db.submission\n get_vars = request.get_vars\n if len(request.args) == 0:\n page = 1\n else:\n page = int(request.args[0])\n page -= 1\n\n all_languages = db(stable).select(stable.lang,\n distinct=True)\n languages = []\n for i in all_languages:\n languages.append(i[\"lang\"])\n\n table = None\n global_submissions = False\n if get_vars.has_key(\"global\"):\n if get_vars[\"global\"] == \"True\":\n global_submissions = True\n\n # If form is not submitted\n if get_vars == {}:\n return dict(languages=languages,\n div=DIV(),\n global_submissions=global_submissions)\n\n # If nothing is filled in the form\n # these fields should be passed in\n # the URL with empty value\n compulsary_keys = [\"pname\", \"name\", \"end_date\", \"start_date\"]\n if set(compulsary_keys).issubset(get_vars.keys()) is False:\n session.flash = \"Invalid URL parameters\"\n redirect(URL(\"default\", \"filters\"))\n\n # Form has been submitted\n cftable = db.custom_friend\n atable = db.auth_user\n ftable = db.friends\n duplicates = []\n\n switch = DIV(LABEL(H6(\"Friends' Submissions\",\n INPUT(_type=\"checkbox\", _id=\"submission-switch\"),\n SPAN(_class=\"lever pink accent-3\"),\n \"Global Submissions\")),\n _class=\"switch\")\n table = TABLE()\n div = TAG[\"\"](H4(\"Recent Submissions\"), switch, table)\n\n if global_submissions is False and session.user_id is None:\n session.flash = \"Login to view Friends' submissions\"\n new_vars = request.vars\n new_vars[\"global\"] = True\n redirect(URL(\"default\", \"filters\",\n vars=new_vars,\n args=request.args))\n\n query = True\n username = get_vars[\"name\"]\n if username != \"\":\n tmplist = username.split()\n for token in tmplist:\n query &= ((cftable.first_name.contains(token)) | \\\n (cftable.last_name.contains(token)))\n\n if global_submissions is False:\n # Retrieve all the custom users created by the logged-in user\n query = (cftable.user_id == session.user_id) & query\n cust_friends = db(query).select(cftable.id, cftable.duplicate_cu)\n\n # The Original IDs of duplicate custom_friends\n custom_friends = []\n for cus_id in cust_friends:\n if cus_id.duplicate_cu:\n duplicates.append((cus_id.id, cus_id.duplicate_cu))\n custom_friends.append(cus_id.duplicate_cu)\n else:\n custom_friends.append(cus_id.id)\n\n query = True\n # Get the friends of logged in user\n if username != \"\":\n tmplist = username.split()\n for token in tmplist:\n query &= ((atable.first_name.contains(token)) | \\\n (atable.last_name.contains(token)))\n\n # @ToDo: Anyway to use join instead of two such db calls\n possible_users = db(query).select(atable.id)\n possible_users = [x[\"id\"] for x in possible_users]\n friends = possible_users\n\n if global_submissions is False:\n query = (ftable.user_id == session.user_id) & \\\n (ftable.friend_id.belongs(possible_users))\n friend_ids = db(query).select(ftable.friend_id)\n friends = [x[\"friend_id\"] for x in friend_ids]\n\n if session.user_id in possible_users:\n # Show submissions of user also\n friends.append(session.user_id)\n\n # User in one of the friends\n query = (stable.user_id.belongs(friends))\n\n # User in one of the custom friends\n query |= (stable.custom_user_id.belongs(custom_friends))\n\n start_date = get_vars[\"start_date\"]\n end_date = get_vars[\"end_date\"]\n\n # Else part ensures that both the dates passed\n # are included in the range\n if start_date == \"\":\n # If start date is empty start from the INITIAL_DATE\n start_date = current.INITIAL_DATE\n else:\n # Else append starting time for that day\n start_date += \" 00:00:00\"\n\n if end_date == \"\":\n # If end date is empty retrieve all submissions till now(current timestamp)\n # Current date/time\n end_date = str(datetime.datetime.today())\n # Remove the last milliseconds from the timestamp\n end_date = end_date[:-7]\n else:\n # Else append the ending time for that day\n end_date += \" 23:59:59\"\n\n start_time = time.strptime(start_date, \"%Y-%m-%d %H:%M:%S\")\n end_time = time.strptime(end_date, \"%Y-%m-%d %H:%M:%S\")\n\n if end_time > start_time:\n # Submissions in the the range start_date to end_date\n query &= (stable.time_stamp >= start_date) & \\\n (stable.time_stamp <= end_date)\n else:\n session.flash = \"Start Date greater than End Date\"\n redirect(URL(\"default\", \"filters\"))\n\n pname = get_vars[\"pname\"]\n # Submissions with problem name containing pname\n if pname != \"\":\n pname = pname.split()\n for token in pname:\n query &= (stable.problem_name.contains(token))\n\n # Check if multiple parameters are passed\n def get_values_list(param_name):\n\n values_list = None\n if get_vars.has_key(param_name):\n values_list = get_vars[param_name]\n if isinstance(values_list, str):\n values_list = [values_list]\n elif get_vars.has_key(param_name + \"[]\"):\n values_list = get_vars[param_name + \"[]\"]\n if isinstance(values_list, str):\n values_list = [values_list]\n\n return values_list\n\n # Submissions from this site\n sites = get_values_list(\"site\")\n if sites:\n query &= (stable.site.belongs(sites))\n\n # Submissions with this language\n langs = get_values_list(\"language\")\n if langs:\n query &= (stable.lang.belongs(langs))\n\n # Submissions with this status\n statuses = get_values_list(\"status\")\n if statuses:\n query &= (stable.status.belongs(statuses))\n\n PER_PAGE = current.PER_PAGE\n # Apply the complex query and sort by time_stamp DESC\n filtered = db(query).select(limitby=(page * PER_PAGE,\n (page + 1) * PER_PAGE),\n orderby=~stable.time_stamp)\n\n total_problems = db(query).count()\n total_pages = total_problems / 100\n if total_problems % 100 == 0:\n total_pages += 1\n\n table = utilities.render_table(filtered, duplicates)\n switch = DIV(LABEL(H6(\"Friends' Submissions\",\n INPUT(_type=\"checkbox\", _id=\"submission-switch\"),\n SPAN(_class=\"lever pink accent-3\"),\n \"Global Submissions\")),\n _class=\"switch\")\n div = TAG[\"\"](switch, table)\n\n return dict(languages=languages,\n div=div,\n total_pages=total_pages,\n global_submissions=global_submissions)", "metadata": "root.filters", "header": "['module', '___EOS___']", "index": 651 }, { "content": "@auth.requires_login()\ndef mark_friend():\n \"\"\"\n Send a friend request\n \"\"\"\n\n if len(request.args) < 1:\n return \"Invalid URL\"\n\n frtable = db.friend_requests\n ftable = db.friends\n friend_id = long(request.args[0])\n\n if friend_id != session.user_id:\n query = (ftable.user_id == session.user_id) & \\\n (ftable.friend_id == friend_id)\n value = db(query).count()\n if value == 0:\n query = ((frtable.from_h == session.user_id) & \\\n (frtable.to_h == friend_id)) | \\\n ((frtable.from_h == friend_id) & \\\n (frtable.to_h == session.user_id))\n\n value = db(query).count()\n if value != 0:\n session.flash = \"Friend request pending...\"\n redirect(URL(\"default\", \"search\"))\n else:\n return \"Already friends !!\"\n else:\n return \"Invalid user argument!\"\n\n # Insert a tuple of users' id into the friend_requests table\n db.friend_requests.insert(from_h=session.user_id, to_h=friend_id)\n\n # Send the user an email notifying about the request\n atable = db.auth_user\n query = (atable.id == friend_id)\n row = db(query).select(atable.email,\n atable.stopstalk_handle).first()\n current.send_mail(to=row.email,\n subject=session.handle + \\\n \" wants to be a friend on StopStalk\",\n message=\"\"\"\n%s (%s) wants to connect on StopStalk\nTo view all friend requests go here - %s\n\nTo stop receiving mails - %s\n \"\"\" % (session.handle,\n URL(\"user\",\n \"profile\",\n args=[session.handle],\n scheme=True,\n host=True,\n extension=False),\n URL(\"user\",\n \"friend_requests\",\n scheme=True,\n host=True,\n extension=False),\n URL(\"default\", \"unsubscribe\",\n scheme=True,\n host=True,\n extension=False)))\n\n return \"Friend Request sent\"", "metadata": "root.mark_friend", "header": "['module', '___EOS___']", "index": 858 }, { "content": "@auth.requires_login()\ndef retrieve_users():\n \"\"\"\n Show the list of registered users\n \"\"\"\n\n atable = db.auth_user\n frtable = db.friend_requests\n ftable = db.friends\n q = request.get_vars.get(\"q\", None)\n\n query = (atable.first_name.contains(q)) | \\\n (atable.last_name.contains(q)) | \\\n (atable.stopstalk_handle.contains(q))\n\n for site in current.SITES:\n field_name = site.lower() + \"_handle\"\n query |= (atable[field_name].contains(q))\n\n # Don't show the logged in user in the search\n query &= (atable.id != session.user_id)\n\n # Don't show users who have sent friend requests\n # to the logged in user\n tmprows = db(frtable.to_h == session.user_id).select(frtable.from_h)\n for row in tmprows:\n query &= (atable.id != row.from_h)\n\n # Columns of auth_user to be retrieved\n columns = [atable.id,\n atable.first_name,\n atable.last_name,\n atable.stopstalk_handle]\n\n for site in current.SITES:\n columns.append(atable[site.lower() + \"_handle\"])\n\n rows = db(query).select(*columns)\n\n t = TABLE(_class=\"striped centered\")\n tr = TR(TH(\"Name\"),\n TH(\"StopStalk Handle\"))\n\n for site in current.SITES:\n tr.append(TH(site + \" Handle\"))\n\n tr.append(TH(\"Friendship Status\"))\n thead = THEAD()\n thead.append(tr)\n t.append(thead)\n\n tbody = TBODY()\n\n query = (ftable.user_id == session[\"user_id\"])\n friends = db(query).select(atable.id,\n join=ftable.on(ftable.friend_id == atable.id))\n friends = [x[\"id\"] for x in friends]\n\n for user in rows:\n\n tr = TR()\n tr.append(TD(A(user.first_name + \" \" + user.last_name,\n _href=URL(\"user\", \"profile\",\n args=[user.stopstalk_handle],\n extension=False),\n _target=\"_blank\")))\n tr.append(TD(user.stopstalk_handle))\n\n for site in current.SITES:\n tr.append(TD(user[site.lower() + \"_handle\"]))\n\n # Check if the current user is already a friend or not\n if user.id not in friends:\n r = db((frtable.from_h == session.user_id) &\n (frtable.to_h == user.id)).count()\n if r == 0:\n tr.append(TD(BUTTON(I(_class=\"fa fa-user-plus fa-3x\"),\n _class=\"tooltipped btn-floating btn-large waves-effect waves-light green\",\n data={\"position\": \"bottom\",\n \"delay\": \"50\",\n \"tooltip\": \"Send friend request\",\n \"user-id\": str(user.id),\n \"type\": \"add-friend\"})))\n else:\n tr.append(TD(BUTTON(I(_class=\"fa fa-user-plus fa-3x\"),\n _class=\"tooltipped btn-floating btn-large disabled\",\n data={\"position\": \"bottom\",\n \"delay\": \"50\",\n \"tooltip\": \"Send friend request\",\n \"type\": \"disabled\"})))\n else:\n tr.append(TD(BUTTON(I(_class=\"fa fa-user-times fa-3x\"),\n _class=\"tooltipped btn-floating btn-large waves-effect waves-light black\",\n data={\"position\": \"bottom\",\n \"delay\": \"50\",\n \"tooltip\": \"Friend request pending\",\n \"user-id\": str(user.id),\n \"type\": \"unfriend\"})))\n tbody.append(tr)\n\n t.append(tbody)\n return dict(t=t)", "metadata": "root.retrieve_users", "header": "['module', '___EOS___']", "index": 926 }, { "content": "@auth.requires_login()\ndef unfriend():\n \"\"\"\n Unfriend the user\n \"\"\"\n\n if len(request.args) != 1:\n return \"Please click on a button!\"\n else:\n friend_id = long(request.args[0])\n user_id = session[\"user_id\"]\n ftable = db.friends\n\n # Delete records in the friends table\n query = (ftable.user_id == user_id) & (ftable.friend_id == friend_id)\n value = db(query).count()\n if value == 0:\n return \"Invalid URL\"\n\n db(query).delete()\n query = (ftable.user_id == friend_id) & (ftable.friend_id == user_id)\n db(query).delete()\n\n # Send email to the friend notifying about the tragedy ;)\n atable = db.auth_user\n row = db(atable.id == friend_id).select(atable.email).first()\n current.send_mail(to=row.email,\n subject=\"A friend unfriended you on StopStalk\",\n message=\"\"\"\n%s (%s) unfriended you on StopStalk\n\nTo stop receiving mails - %s\n \"\"\" % (session.handle,\n URL(\"user\",\n \"profile\",\n args=[session.handle],\n scheme=True,\n host=True,\n extension=False),\n URL(\"default\", \"unsubscribe\",\n scheme=True,\n host=True,\n extension=False)))\n\n return \"Successfully unfriended\"", "metadata": "root.unfriend", "header": "['module', '___EOS___']", "index": 1030 }, { "content": "@auth.requires_login()\ndef submissions():\n \"\"\"\n Retrieve submissions of the logged-in user\n \"\"\"\n\n if len(request.args) == 0:\n active = \"1\"\n else:\n active = request.args[0]\n\n cftable = db.custom_friend\n ftable = db.friends\n stable = db.submission\n atable = db.auth_user\n\n # Get all the friends/custom friends of the logged-in user\n friends, cusfriends = utilities.get_friends(session[\"user_id\"])\n\n # The Original IDs of duplicate custom_friends\n custom_friends = []\n for cus_id in cusfriends:\n if cus_id[1] == None:\n custom_friends.append(cus_id[0])\n else:\n custom_friends.append(cus_id[1])\n\n query = (stable.user_id.belongs(friends)) | \\\n (stable.custom_user_id.belongs(custom_friends))\n total_count = db(query).count()\n\n PER_PAGE = current.PER_PAGE\n count = total_count / PER_PAGE\n if total_count % PER_PAGE:\n count += 1\n\n if request.extension == \"json\":\n return dict(count=count,\n total_rows=1)\n\n offset = PER_PAGE * (int(active) - 1)\n # Retrieve only some number of submissions from the offset\n rows = db(query).select(orderby=~db.submission.time_stamp,\n limitby=(offset, offset + PER_PAGE))\n\n table = utilities.render_table(rows, cusfriends)\n return dict(table=table,\n friends=friends,\n cusfriends=cusfriends,\n total_rows=len(rows))", "metadata": "root.submissions", "header": "['module', '___EOS___']", "index": 1077 }, { "content": "def faq():\n \"\"\"\n FAQ page\n \"\"\"\n\n div = DIV(_class=\"row\")\n ul = UL(_class=\"collapsible col offset-s3 s6\", data={\"collapsible\": \"expandable\"})\n\n faqs = db(db.faq).select()\n for i in xrange(len(faqs)):\n li = LI(DIV(B(str(i + 1) + \". \" + faqs[i].question),\n _class=\"collapsible-header\"),\n DIV(MARKMIN(faqs[i].answer),\n _class=\"collapsible-body\"))\n ul.append(li)\n\n div.append(ul)\n\n return dict(div=div)", "metadata": "root.faq", "header": "['module', '___EOS___']", "index": 1129 }, { "content": "def contact_us():\n \"\"\"\n Contact Us page\n \"\"\"\n\n ctable = db.contact_us\n\n if session[\"auth\"] and request.post_vars:\n if request.post_vars.stickers is not None:\n response.flash = \"Fill your address!\"\n user = session.auth.user\n stickers = eval(request.post_vars[\"stickers\"])\n if stickers[0] == 0:\n session.flash = \"No claimable stickers\"\n redirect(URL(\"default\", \"my_friends\"))\n ctable.email.default = user.email\n ctable.name.default = user.first_name + \" \" + user.last_name\n ctable.subject.default = \"Please send me stickers!\"\n ctable.text_message.default = \"My address is: \"\n\n form = SQLFORM(ctable)\n\n if session[\"auth\"]:\n user = session[\"auth\"][\"user\"]\n ctable.email.default = user[\"email\"]\n\n if form.process().accepted:\n session.flash = \"We will get back to you!\"\n current.send_mail(to=\"[email protected]\",\n subject=form.vars.subject,\n message=\"From: %s (%s - %s)\\n\" % \\\n (form.vars.name,\n form.vars.email,\n form.vars.phone_number) + \\\n \"Subject: %s\\n\" % form.vars.subject + \\\n \"Message: %s\\n\" % form.vars.text_message)\n redirect(URL(\"default\", \"index\"))\n elif form.errors:\n response.flash = \"Please fill all the fields!\"\n\n return dict(form=form)", "metadata": "root.contact_us", "header": "['module', '___EOS___']", "index": 1150 }, { "content": "def call():\n \"\"\"\n exposes services. for example:\n http://..../[app]/default/call/jsonrpc\n decorate with @services.jsonrpc the functions to expose\n supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv\n \"\"\"\n return service()", "metadata": "root.call", "header": "['module', '___EOS___']", "index": 1193 } ]
[ { "span": "from operator import itemgetter", "start_line": 26, "start_column": 0, "end_line": 26, "end_column": 31 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Copy", "right", " ", "(", "c", ")", " ", "201", "5", "-", "2016", " ", "Ra", "j", " ", "Pat", "el", "(", "raj", "454", "raj", "@", "gma", "il", ".", "com", "),", " ", "Sto", "p", "Sta", "lk", "\\", "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_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "parsed", "ate", "time_", "as_", "pd", "t_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "requests_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "operator_", "import_", "itemgetter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "utilities_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "--------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "--------------", "--------------", "--------------", "--------------", "--------------", "------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\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_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "index_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "main", " ", "controlle", "r", " ", "whi", "ch", " ", "redirec", "ts", " ", "depend", "ing", "\\", "10", ";", " ", " ", " ", " ", "on", " ", "the", " ", "login", " ", "status", " ", "of", " ", "the", " ", "user", " ", "and", " ", "doe", "s", " ", "some", "\\", "10", ";", " ", " ", " ", " ", "extra", " ", "pre", "-", "process", "ing", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "the", " ", "user", " ", "is", " ", "logged", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "session_", "[_", "\"", "auth", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "flash_", "=_", "\"", "Wel", "come", " ", "Sto", "p", "Sta", "lke", "r", "!!\"", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "redirect_", "(_", "URL_", "(_", "\"", "default", "\"_", ",_", "\"", "subm", "ission", "s", "\"_", ",_", "args_", "=_", "[_", "1_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "auth_", "._", "require", "s", "\\u", "login_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "notifications_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Check", " ", "if", " ", "any", " ", "of", " ", "the", " ", "friends", "(", "include", "s", " ", "CUSTOM", ")", " ", "of", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "logged", "-", "in", " ", "user", " ", "is", " ", "on", " ", "a", " ", "stre", "ak", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "session_", "[_", "\"", "user", "\\u", "id", "\"_", "]_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "redirect_", "(_", "URL_", "(_", "\"", "default", "\"_", ",_", "\"", "index", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fta", "ble_", "=_", "db_", "._", "friends_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "atab", "le_", "=_", "db_", "._", "auth", "\\u", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cf", "table_", "=_", "db_", "._", "custom", "\\u", "friend_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "for", " ", "stre", "ak", " ", "of", " ", "friends", " ", "on", " ", "stop", "stal", "k_", "\\u\\u\\uNL\\u\\u\\u_", "query_", "=_", "(_", "fta", "ble_", "._", "user", "\\u", "id_", "==_", "session_", "[_", "\"", "user", "\\u", "id", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rows_", "=_", "db_", "(_", "query_", ")_", "._", "select_", "(_", "atab", "le_", "._", "first", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "atab", "le_", "._", "last", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "atab", "le_", "._", "stop", "stal", "k", "\\u", "handle_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "join_", "=_", "fta", "ble_", "._", "on_", "(_", "fta", "ble_", "._", "frie", "nd", "\\u", "id_", "==_", "atab", "le_", "._", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Wil", "l", " ", "contain", " ", "list", " ", "of", " ", "handle", "s", " ", "of", " ", "all", " ", "the", " ", "friends", " ", "along", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "with", " ", "the", " ", "Custom", " ", "User", "s", " ", "adde", "d", " ", "by", " ", "the", " ", "logged", "-", "in", " ", "user_", "\\u\\u\\uNL\\u\\u\\u_", "handles_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "complete", "\\u", "dict_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "friends", "\\u", "stop", "stal", "k", "\\u", "handles_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "user_", "in_", "rows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "complete", "\\u", "dict_", "[_", "user_", "._", "stop", "stal", "k", "\\u", "handle_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "friends", "\\u", "stop", "stal", "k", "\\u", "handles_", "._", "append_", "(_", "\"'\"_", "+_", "user_", "._", "stop", "stal", "k", "\\u", "handle_", "+_", "\"'\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "handles_", "._", "append_", "(_", "(_", "user_", "._", "stop", "stal", "k", "\\u", "handle_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "._", "first", "\\u", "name_", "+_", "\"", " ", "\"_", "+_", "user_", "._", "last", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user_", "._", "stop", "stal", "k", "\\u", "handle_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "for", " ", "stre", "ak", " ", "of", " ", "custom", " ", "friends_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "query_", "=_", "(_", "cf", "table_", "._", "user", "\\u", "id_", "==_", "session_", "[_", "\"", "user", "\\u", "id", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rows_", "=_", "db_", "(_", "query_", ")_", "._", "select_", "(_", "cf", "table_", "._", "first", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cf", "table_", "._", "last", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cf", "table_", "._", "duplicat", "e\\u", "cu_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cf", "table_", "._", "stop", "stal", "k", "\\u", "handle_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "user_", "in_", "rows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "user_", "._", "first", "\\u", "name_", "+_", "\"", " ", "\"_", "+_", "user_", "._", "last", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "actual", "\\u", "handle_", "=_", "user_", "._", "stop", "stal", "k", "\\u", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "user_", "._", "duplicat", "e\\u", "cu_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stop", "stal", "k", "\\u", "handle_", "=_", "user_", "._", "duplicat", "e\\u", "cu_", "._", "stop", "stal", "k", "\\u", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stop", "stal", "k", "\\u", "handle_", "=_", "user_", "._", "stop", "stal", "k", "\\u", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "handles_", "._", "append_", "(_", "(_", "stop", "stal", "k", "\\u", "handle_", ",_", "name_", ",_", "actual", "\\u", "handle_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "complete", "\\u", "dict_", "[_", "stop", "stal", "k", "\\u", "handle_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "friends", "\\u", "stop", "stal", "k", "\\u", "handles_", "._", "append_", "(_", "\"'\"_", "+_", "stop", "stal", "k", "\\u", "handle_", "+_", "\"'\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "friends", "\\u", "stop", "stal", "k", "\\u", "handles_", "==_", "[_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "friends", "\\u", "stop", "stal", "k", "\\u", "handles_", "=_", "[_", "\"-", "1", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Build", " ", "the", " ", "complex", " ", "SQL", " ", "query_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sql", "\\u", "query_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", "SELECT", " ", "stop", "stal", "k", "\\u", "handle", ",", " ", "DAT", "E", "(", "time", "\\u", "stamp", "),", " ", "COUNT", "(*", ")", " ", "as", " ", "cnt", "\\", "10", ";", " ", " ", "FROM", " ", "subm", "ission", "\\", "10", ";", " ", " ", "WHE", "RE", " ", "stop", "stal", "k", "\\u", "handle", " ", "in", " ", "(%", "s", ")", "\\", "10", ";", " ", " ", "GROU", "P", " ", "BY", " ", "stop", "stal", "k", "\\u", "handle", ",", " ", "DAT", "E", "(", "subm", "ission", ".", "time", "\\u", "stamp", ")", "\\", "10", ";", " ", " ", "ORDE", "R", " ", "BY", " ", "time", "\\u", "stamp", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "%_", "(_", "\",", " ", "\"_", "._", "join_", "(_", "friends", "\\u", "stop", "stal", "k", "\\u", "handles_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "user", "\\u", "rows_", "=_", "db_", "._", "execute", "sql_", "(_", "sql", "\\u", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "user_", "in_", "user", "\\u", "rows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "complete", "\\u", "dict_", "[_", "user_", "[_", "0_", "]_", "]_", "!=_", "[_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "complete", "\\u", "dict_", "[_", "user_", "[_", "0_", "]_", "]_", "._", "append_", "(_", "(_", "user_", "[_", "1_", "]_", ",_", "user_", "[_", "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 ", " _", "complete", "\\u", "dict_", "[_", "user_", "[_", "0_", "]_", "]_", "=_", "[_", "(_", "user_", "[_", "1_", "]_", ",_", "user_", "[_", "2_", "]_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "List", " ", "of", " ", "users", " ", "with", " ", "non", "-", "zero", " ", "stre", "ak_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "users", "\\u", "on", "\\u", "day", "\\u", "stre", "ak_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "users", "\\u", "on", "\\u", "subm", "ission", "\\u", "stre", "ak_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "handle_", "in_", "handles_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "curr", "\\u", "stre", "ak_", "=_", "utilities_", "._", "get", "\\u", "max", "\\u", "stre", "ak_", "(_", "complete", "\\u", "dict_", "[_", "handle_", "[_", "0_", "]_", "]_", ")_", "[_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "curr", "\\u", "accept", "ed", "\\u", "stre", "ak_", "=_", "utilities_", "._", "get", "\\u", "accept", "ed", "\\u", "stre", "ak_", "(_", "handle_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "stre", "ak", " ", "is", " ", "non", "-", "zero", " ", "append", " ", "to", " ", "users", "\\u", "on", "\\u", "stre", "ak", " ", "list_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "curr", "\\u", "stre", "ak_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "users", "\\u", "on", "\\u", "day", "\\u", "stre", "ak_", "._", "append_", "(_", "(_", "handle_", ",_", "curr", "\\u", "stre", "ak_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "curr", "\\u", "accept", "ed", "\\u", "stre", "ak_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "users", "\\u", "on", "\\u", "subm", "ission", "\\u", "stre", "ak_", "._", "append_", "(_", "(_", "handle_", ",_", "curr", "\\u", "accept", "ed", "\\u", "stre", "ak_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sort", " ", "the", " ", "users", " ", "on", " ", "stre", "ak", " ", "by", " ", "thei", "r", " ", "stre", "ak_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "users", "\\u", "on", "\\u", "day", "\\u", "stre", "ak_", "._", "sort_", "(_", "key_", "=_", "lambda_", "k_", ":_", "k_", "[_", "1_", "]_", ",_", "reverse_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "users", "\\u", "on", "\\u", "subm", "ission", "\\u", "stre", "ak_", "._", "sort_", "(_", "key_", "=_", "lambda_", "k_", ":_", "k_", "[_", "1_", "]_", ",_", "reverse_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "table", " ", "contain", "ing", " ", "users", " ", "on", " ", "stre", "ak", "(", "day", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "table1_", "=_", "TABLE_", "(_", "THE", "AD_", "(_", "TR_", "(_", "TH_", "(_", "STR", "ONG", "_", "(_", "\"", "User", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "STR", "ONG", "_", "(_", "\"", "Day", "s", "\"_", ")_", ")_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "col", " ", "offset", "-", "s3", " ", "s", "6", " ", "strip", "ed", " ", "centered", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "table", " ", "contain", "ing", " ", "users", " ", "on", " ", "stre", "ak", "(", "subm", "ission", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "table2_", "=_", "TABLE_", "(_", "THE", "AD_", "(_", "TR_", "(_", "TH_", "(_", "STR", "ONG", "_", "(_", "\"", "User", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "STR", "ONG", "_", "(_", "\"", "Subm", "ission", "s", "\"_", ")_", ")_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "col", " ", "offset", "-", "s3", " ", "s", "6", " ", "strip", "ed", " ", "centered", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tbo", "dy", "1_", "=_", "TB", "OD", "Y_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tbo", "dy", "2_", "=_", "TB", "OD", "Y_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Append", " ", "all", " ", "the", " ", "users", " ", "to", " ", "the", " ", "final", " ", "table_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "users_", "in_", "users", "\\u", "on", "\\u", "day", "\\u", "stre", "ak_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handle_", "=_", "users_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "curr", "\\u", "stre", "ak_", "=_", "users_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "=_", "TR_", "(_", "TD_", "(_", "(_", "A_", "(_", "handle_", "[_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "href_", "=_", "URL_", "(_", "\"", "user", "\"_", ",_", "\"", "profile", "\"_", ",_", "args_", "=_", "[_", "handle_", "[_", "2_", "]_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "target_", "=_", "\"\\u", "blank", "\"_", ")_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TD_", "(_", "str_", "(_", "curr", "\\u", "stre", "ak_", ")_", "+_", "\"", " ", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "bolt", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "style_", "=_", "\"", "color", ":", "red", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "center", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tbo", "dy", "1_", "._", "append_", "(_", "tr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "table1_", "._", "append_", "(_", "tbo", "dy", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "users", "\\u", "on", "\\u", "day", "\\u", "stre", "ak_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "table1_", "=_", "H", "6_", "(_", "\"", "No", " ", "friends", " ", "on", " ", "day", " ", "stre", "ak", "\"_", ",_", "\\u", "class_", "=_", "\"", "center", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Append", " ", "all", " ", "the", " ", "users", " ", "to", " ", "the", " ", "final", " ", "table_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "users_", "in_", "users", "\\u", "on", "\\u", "subm", "ission", "\\u", "stre", "ak_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "handle_", "=_", "users_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "curr", "\\u", "accept", "ed", "\\u", "stre", "ak_", "=_", "users_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "=_", "TR_", "(_", "TD_", "(_", "(_", "A_", "(_", "handle_", "[_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "href_", "=_", "URL_", "(_", "\"", "user", "\"_", ",_", "\"", "profile", "\"_", ",_", "args_", "=_", "[_", "handle_", "[_", "2_", "]_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "target_", "=_", "\"\\u", "blank", "\"_", ")_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TD_", "(_", "str_", "(_", "curr", "\\u", "accept", "ed", "\\u", "stre", "ak_", ")_", "+_", "\"", " ", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "bolt", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "style_", "=_", "\"", "color", ":", "red", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "center", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tbo", "dy", "2_", "._", "append_", "(_", "tr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "table2_", "._", "append_", "(_", "tbo", "dy", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "users", "\\u", "on", "\\u", "subm", "ission", "\\u", "stre", "ak_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "table2_", "=_", "H", "6_", "(_", "\"", "No", " ", "friends", " ", "on", " ", "subm", "ission", " ", "stre", "ak", "\"_", ",_", "\\u", "class_", "=_", "\"", "center", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "dict_", "(_", "table1_", "=_", "table1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "table2_", "=_", "table2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "auth_", "._", "require", "s", "\\u", "login_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "unsubscribe_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "uta", "ble_", "=_", "db_", "._", "unsubscribe", "r_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uta", "ble_", "._", "email_", "._", "default_", "=_", "session_", "._", "auth_", "._", "user_", "._", "email_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uta", "ble_", "._", "email_", "._", "writable_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "alr", "ead", "y", "\\u", "unsubscribe", "d_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "query_", "=_", "(_", "uta", "ble_", "._", "email_", "==_", "session_", "._", "auth_", "._", "user_", "._", "email_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rows_", "=_", "db_", "(_", "query_", ")_", "._", "select_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "rows_", ")_", "!=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "alr", "ead", "y", "\\u", "unsubscribe", "d_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "form_", "=_", "SQL", "FORM", "_", "(_", "uta", "ble_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "submit", "\\u", "button_", "=_", "\"", "Subscrib", "e", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "validate_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "row_", "in_", "rows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "row_", "._", "delete", "\\u", "record_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "session_", "._", "flash_", "=_", "\"", "Subscrib", "ed", " ", "success", "full", "y", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "redirect_", "(_", "URL_", "(_", "\"", "default", "\"_", ",_", "\"", "unsubscribe", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "form_", "._", "errors_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "._", "flash_", "=_", "\"", "Form", " ", "has", " ", "error", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "SQL", "FORM", "_", "(_", "uta", "ble_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "submit", "\\u", "button_", "=_", "\"", "Unsu", "bsc", "ribe", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "form_", "._", "process_", "(_", ")_", "._", "accepted_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "._", "flash_", "=_", "\"", "Success", "full", "y", " ", "unsubscribe", "d", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "redirect_", "(_", "URL_", "(_", "\"", "default", "\"_", ",_", "\"", "unsubscribe", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "form_", "._", "errors_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "._", "flash_", "=_", "\"", "Form", " ", "has", " ", "error", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "dict_", "(_", "form_", "=_", "form_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "alr", "ead", "y", "\\u", "unsubscribe", "d_", "=_", "alr", "ead", "y", "\\u", "unsubscribe", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "auth_", "._", "require", "s", "\\u", "login_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "my", "\\u", "friends_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Display", " ", "the", " ", "friends", " ", "data", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "fta", "ble_", "=_", "db_", "._", "friends_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rows_", "=_", "db_", "(_", "fta", "ble_", "._", "user", "\\u", "id_", "==_", "session_", "._", "user", "\\u", "id_", ")_", "._", "select_", "(_", "fta", "ble_", "._", "frie", "nd", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "table_", "=_", "TABLE_", "(_", "THE", "AD_", "(_", "TR_", "(_", "TH_", "(_", "\"", "Friend", " ", "name", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Auth", "enti", "c", " ", "user", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Institut", "e", " ", "frie", "nd", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Ot", "her", " ", "frie", "nd", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Cla", "ima", "ble", "\"_", ")_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "centered", " ", "col", " ", "offset", "-", "s3", " ", "s", "6", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tbo", "dy_", "=_", "TB", "OD", "Y_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "check_", "=_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "check", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "style_", "=_", "\"", "color", ":", " ", "#", "0f", "0", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cross_", "=_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "close", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "style_", "=_", "\"", "color", ":", " ", "#", "f0", "0", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "valid", "\\u", "friends_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "row_", "in_", "rows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "claim", "able_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "this", "friend_", "=_", "row_", "._", "frie", "nd", "\\u", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "this", "friend_", "._", "first", "\\u", "name_", "+_", "\"", " ", "\"_", "+_", "this", "friend_", "._", "last", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "=_", "TR_", "(_", "TD_", "(_", "A_", "(_", "name_", ",_", "\\u", "href_", "=_", "URL_", "(_", "\"", "user", "\"_", ",_", "\"", "profile", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "this", "friend_", "._", "stop", "stal", "k", "\\u", "handle_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "claim", "able_", "&=_", "this", "friend_", "._", "authe", "ntic", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "this", "friend_", "._", "authe", "ntic", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tr_", "._", "append_", "(_", "check_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tr_", "._", "append_", "(_", "cross_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "query_", "=_", "(_", "fta", "ble_", "._", "user", "\\u", "id_", "==_", "this", "friend_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "friends", "\\u", "of", "\\u", "friends_", "=_", "db_", "(_", "query_", ")_", "._", "select_", "(_", "fta", "ble_", "._", "frie", "nd", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "institu", "te", "\\u", "friends_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "fo", "f_", "in_", "friends", "\\u", "of", "\\u", "friends_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "fo", "f_", "._", "frie", "nd", "\\u", "id_", "._", "institu", "te_", "==_", "this", "friend_", "._", "institu", "te_", "and_", "fo", "f_", "._", "frie", "nd", "\\u", "id_", "._", "institu", "te_", "!=_", "\"", "Ot", "her", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "institu", "te", "\\u", "friends_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "institu", "te", "\\u", "friends_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tr_", "._", "append_", "(_", "TD_", "(_", "check_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "check_", ")_", ")_", "\\u\\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_", "institu", "te", "\\u", "friends_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "claim", "able_", "&=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "cross_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "friends", "\\u", "of", "\\u", "friends_", ")_", ">=_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "tr_", "._", "append_", "(_", "check_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "tr_", "._", "append_", "(_", "cross_", ")_", "\\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 ", " _", "tr_", "._", "append_", "(_", "check_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "friends", "\\u", "of", "\\u", "friends_", ")_", ">=_", "3_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "claim", "able_", "&=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "check_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "claim", "able_", "&=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "cross_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "claim", "able_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "valid", "\\u", "friends_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "thumbs", "-", "up", "\"_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tr_", "._", "append_", "(_", "TD_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tbo", "dy_", "._", "append_", "(_", "tr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "table_", "._", "append_", "(_", "tbo", "dy_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "claim", "able", "\\u", "sticke", "rs_", "=_", "valid", "\\u", "friends_", "/_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sticke", "rs_", "=_", "[_", "claim", "able", "\\u", "sticke", "rs_", "/_", "3_", "]_", "*_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "residue_", "=_", "claim", "able", "\\u", "sticke", "rs_", "-_", "(_", "claim", "able", "\\u", "sticke", "rs_", "/_", "3_", ")_", "*_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "residue_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sticke", "rs_", "[_", "i_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "residue_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "dict_", "(_", "table_", "=_", "DIV_", "(_", "table_", ",_", "\\u", "class_", "=_", "\"", "row", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "claim", "able", "\\u", "sticke", "rs_", "=_", "claim", "able", "\\u", "sticke", "rs_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "sticke", "rs_", "=_", "sticke", "rs_", ")_", "\\u\\u\\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_", "sort", "\\u", "contest", "s_", "(_", "a_", ",_", "b_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "a_", "[_", "\"", "has", "\\u", "start", "ed", "\"_", "]_", "and_", "b_", "[_", "\"", "has", "\\u", "start", "ed", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "a_", "[_", "\"", "end", "\"_", "]_", "<_", "b_", "[_", "\"", "end", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "a_", "[_", "\"", "has", "\\u", "start", "ed", "\"_", "]_", "and_", "b_", "[_", "\"", "has", "\\u", "start", "ed", "\"_", "]_", "==_", "False_", ":_", "\\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_", "elif_", "a_", "[_", "\"", "has", "\\u", "start", "ed", "\"_", "]_", "==_", "False_", "and_", "b_", "[_", "\"", "has", "\\u", "start", "ed", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "a_", "[_", "\"", "start", "\"_", "]_", "<_", "b_", "[_", "\"", "start", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "contest", "s_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Show", " ", "the", " ", "upcom", "ing", " ", "contest", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "today_", "=_", "datetime_", "._", "datetime_", "._", "today_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "today_", "=_", "datetime_", "._", "datetime_", "._", "strptime_", "(_", "str_", "(_", "today_", ")_", "[_", ":_", "-_", "7_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"%", "Y", "-%", "m", "-%", "d", " ", "%", "H", ":", "%", "M", ":", "%", "S", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "start", "\\u", "date_", "=_", "today_", "._", "date_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "end", "\\u", "date_", "=_", "start", "\\u", "date_", "+_", "datetime_", "._", "timedelta_", "(_", "90_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "\"", "https", "://", "contest", "track", "era", "pi", ".", "hero", "ku", "app", ".", "com", "/\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "requests_", "._", "get_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "response_", "._", "status", "\\u", "code_", "==_", "200_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "=_", "response_", "._", "json_", "(_", ")_", "[_", "\"", "result", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "@", "todo", ":", " ", "somet", "hing", " ", "bett", "er_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ong", "oin", "g_", "=_", "response_", "[_", "\"", "ong", "oin", "g", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "upcom", "ing_", "=_", "response_", "[_", "\"", "upcom", "ing", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "contest", "s_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cal_", "=_", "pd", "t_", "._", "Calendar_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "table_", "=_", "TABLE_", "(_", "\\u", "class_", "=_", "\"", "centered", " ", "strip", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "thea", "d_", "=_", "THE", "AD_", "(_", "TR_", "(_", "TH_", "(_", "\"", "Contest", " ", "Name", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Site", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Start", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Dur", "ation", "/", "Endi", "ng", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Link", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Add", " ", "Remi", "nder", "\"_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "table_", "._", "append_", "(_", "thea", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tbo", "dy_", "=_", "TB", "OD", "Y_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "i_", "in_", "ong", "oin", "g_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "i_", "[_", "\"", "Plat", "form", "\"_", "]_", "in_", "(_", "\"", "TOP", "CODE", "R", "\"_", ",_", "\"", "OTHER", "\"_", ")_", ":_", "\\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_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "endtime_", "=_", "datetime_", "._", "datetime_", "._", "strptime_", "(_", "i_", "[_", "\"", "End", "Time", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"%", "a", ",", " ", "%", "d", " ", "%", "b", " ", "%", "Y", " ", "%", "H", ":", "%", "M", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tr_", "=_", "TR_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "span_", "=_", "SPAN", "_", "(_", "\\u", "class_", "=_", "\"", "green", " ", "toolt", "ipp", "ed", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "{_", "\"", "position", "\"_", ":_", "\"", "right", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "dela", "y", "\"_", ":_", "\"", "50", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "toolt", "ip", "\"_", ":_", "\"", "Live", " ", "Contest", "\"_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "style_", "=_", "\"", "cursor", ":", " ", "point", "er", ";", " ", "\"_", "+_", "\"", "float", ":", "right", ";", " ", "\"_", "+_", "\"", "height", ":", "10", "px", ";", " ", "\"_", "+_", "\"", "widt", "h", ":", "10", "px", ";", " ", "\"_", "+_", "\"", "border", "-", "radi", "us", ":", " ", "50", "%;", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "i_", "[_", "\"", "Name", "\"_", "]_", ",_", "span_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "i_", "[_", "\"", "Plat", "form", "\"_", "]_", "._", "capitalize_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "\"-\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "str_", "(_", "endtime_", ")_", "._", "replace_", "(_", "\"-\"_", ",_", "\"/\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "contest", "-", "end", "-", "time", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "A_", "(_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "external", "-", "link", "-", "square", " ", "fa", "-", "lg", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "btn", "-", "float", "ing", " ", "btn", "-", "small", " ", "green", " ", "accent", "-", "4", " ", "toolt", "ipp", "ed", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "href_", "=_", "i_", "[_", "\"", "url", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "{_", "\"", "position", "\"_", ":_", "\"", "left", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "toolt", "ip", "\"_", ":_", "\"", "Contest", " ", "Link", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "dela", "y", "\"_", ":_", "\"", "50", "\"_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "target_", "=_", "\"\\u", "blank", "\"_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "BUTTON_", "(_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "calendar", "-", "plus", "-", "o", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "btn", "-", "float", "ing", " ", "btn", "-", "small", " ", "orange", " ", "accent", "-", "4", " ", "toolt", "ipp", "ed", " ", "disable", "d", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "{_", "\"", "position", "\"_", ":_", "\"", "left", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "toolt", "ip", "\"_", ":_", "\"", "Al", "read", "y", " ", "start", "ed", "!\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "dela", "y", "\"_", ":_", "\"", "50", "\"_", "}_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tbo", "dy_", "._", "append_", "(_", "tr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "id", " ", "is", " ", "used", " ", "for", " ", "unique", "ly", " ", "identify", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "a", " ", "partic", "ular", " ", "contest", " ", "in", " ", "js_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "button", "\\u", "id_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "upcom", "ing_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "i_", "[_", "\"", "Plat", "form", "\"_", "]_", "in_", "(_", "\"", "TOP", "CODE", "R", "\"_", ",_", "\"", "OTHER", "\"_", ")_", ":_", "\\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_", "start", "\\u", "time_", "=_", "datetime_", "._", "datetime_", "._", "strptime_", "(_", "i_", "[_", "\"", "Start", "Time", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"%", "a", ",", " ", "%", "d", " ", "%", "b", " ", "%", "Y", " ", "%", "H", ":", "%", "M", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "=_", "TR_", "(_", "\\u", "id_", "=_", "\"", "contest", "-\"_", "+_", "str_", "(_", "button", "\\u", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "i_", "[_", "\"", "Name", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "i_", "[_", "\"", "Plat", "form", "\"_", "]_", "._", "capitalize_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "str_", "(_", "start", "\\u", "time_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "duration_", "=_", "i_", "[_", "\"", "Dur", "ation", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "duration_", "=_", "duration_", "._", "replace_", "(_", "\"", " ", "day", "s", "\"_", ",_", "\"", "d", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "duration_", "=_", "duration_", "._", "replace_", "(_", "\"", " ", "day", "\"_", ",_", "\"", "d", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "duration_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "A_", "(_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "external", "-", "link", "-", "square", " ", "fa", "-", "lg", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "btn", "-", "float", "ing", " ", "btn", "-", "small", " ", "green", " ", "accent", "-", "4", " ", "toolt", "ipp", "ed", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "href_", "=_", "i_", "[_", "\"", "url", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "{_", "\"", "position", "\"_", ":_", "\"", "left", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "toolt", "ip", "\"_", ":_", "\"", "Contest", " ", "Link", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "dela", "y", "\"_", ":_", "\"", "50", "\"_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "target_", "=_", "\"\\u", "blank", "\"_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "BUTTON_", "(_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "calendar", "-", "plus", "-", "o", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "btn", "-", "float", "ing", " ", "btn", "-", "small", " ", "orange", " ", "accent", "-", "4", " ", "toolt", "ipp", "ed", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "{_", "\"", "position", "\"_", ":_", "\"", "left", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "toolt", "ip", "\"_", ":_", "\"", "Set", " ", "Remi", "nder", " ", "to", " ", "Goo", "gle", " ", "Cal", "enda", "r", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "dela", "y", "\"_", ":_", "\"", "50", "\"_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "id_", "=_", "\"", "set", "-", "reminder", "-\"_", "+_", "str_", "(_", "button", "\\u", "id_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tbo", "dy_", "._", "append_", "(_", "tr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "button", "\\u", "id_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "table_", "._", "append_", "(_", "tbo", "dy_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "dict_", "(_", "table_", "=_", "table_", ",_", "upcom", "ing_", "=_", "upcom", "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_", "def_", "leader", "board_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Get", " ", "a", " ", "table", " ", "with", " ", "users", " ", "sorte", "d", " ", "by", " ", "rati", "ng", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "specific", "\\u", "institu", "te_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "atab", "le_", "=_", "db_", "._", "auth", "\\u", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cf", "table_", "=_", "db_", "._", "custom", "\\u", "friend_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "global", "\\u", "leader", "board_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "request_", "._", "vars_", "._", "has", "\\u", "key_", "(_", "\"", "global", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "request_", "._", "vars_", "[_", "\"", "global", "\"_", "]_", "==_", "\"", "Tru", "e", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "global", "\\u", "leader", "board_", "=_", "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 ", " _", "if_", "session_", "._", "user", "\\u", "id_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "._", "flash_", "=_", "\"", "Logi", "n", " ", "to", " ", "see", " ", "Friends", " ", "Leader", "board", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "global", "\\u", "leader", "board_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "session_", "._", "user", "\\u", "id_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "global", "\\u", "leader", "board_", "=_", "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_", "heading_", "=_", "\"", "Global", " ", "Leader", "board", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "afi", "elds", "_", "=_", "[_", "\"", "first", "\\u", "name", "\"_", ",_", "\"", "last", "\\u", "name", "\"_", ",_", "\"", "stop", "stal", "k", "\\u", "handle", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "institu", "te", "\"_", ",_", "\"", "per", "\\u", "day", "\"_", ",_", "\"", "rati", "ng", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cfi", "elds", "_", "=_", "afi", "elds", "_", "+_", "[_", "\"", "duplicat", "e\\u", "cu", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "aqu", "ery", "_", "=_", "(_", "atab", "le_", "._", "id_", ">_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cq", "uery_", "=_", "(_", "cf", "table_", "._", "id_", ">_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "global", "\\u", "leader", "board_", "is_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "session_", "._", "user", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "heading_", "=_", "\"", "Friends", " ", "Leader", "board", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "friends_", ",_", "cus", "friends_", "=_", "utilities_", "._", "get", "\\u", "friends_", "(_", "session_", "._", "user", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "custom", "\\u", "friends_", "=_", "[_", "x_", "[_", "0_", "]_", "for_", "x_", "in_", "cus", "friends_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Add", " ", "logged", "-", "in", " ", "user", " ", "to", " ", "leader", "board_", "\\u\\u\\uNL\\u\\u\\u_", "friends_", "._", "append_", "(_", "session_", "._", "user", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aqu", "ery", "_", "&=_", "(_", "atab", "le_", "._", "id_", "._", "belo", "ngs_", "(_", "friends_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cq", "uery_", "&=_", "(_", "cf", "table_", "._", "id_", "._", "belo", "ngs_", "(_", "custom", "\\u", "friends_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "aqu", "ery", "_", "&=_", "(_", "1_", "==_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cq", "uery_", "&=_", "(_", "1_", "==_", "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_", "request_", "._", "vars_", "._", "has", "\\u", "key_", "(_", "\"", "q", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "heading_", "=_", "\"", "Institut", "e", " ", "Leader", "board", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "institu", "te_", "=_", "request_", "._", "vars_", "[_", "\"", "q", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "institu", "te_", "!=_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "specific", "\\u", "institu", "te_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "aqu", "ery", "_", "&=_", "(_", "atab", "le_", "._", "institu", "te_", "==_", "institu", "te_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cq", "uery_", "&=_", "(_", "cf", "table_", "._", "institu", "te_", "==_", "institu", "te_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reg", "\\u", "users_", "=_", "db_", "(_", "aqu", "ery", "_", ")_", "._", "select_", "(_", "*_", "afi", "elds", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "custom", "\\u", "users_", "=_", "db_", "(_", "cq", "uery_", ")_", "._", "select_", "(_", "*_", "cfi", "elds", "_", ")_", "\\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_", "specific", "\\u", "institu", "te_", "is_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "reg", "\\u", "users_", "=_", "db_", "(_", "aqu", "ery", "_", ")_", "._", "select_", "(_", "*_", "afi", "elds", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "custom", "\\u", "users_", "=_", "db_", "(_", "cq", "uery_", ")_", "._", "select_", "(_", "*_", "cfi", "elds", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Fin", "d", " ", "the", " ", "total", " ", "solved", " ", "problem", "s", "(", "Less", "er", " ", "than", " ", "total", " ", "accept", "ed", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "solved", "\\u", "count_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sql_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", " ", "SELECT", " ", "stop", "stal", "k", "\\u", "handle", ",", " ", "COUNT", "(", "DIST", "INC", "T", "(", "problem", "\\u", "name", "))\\", "10", ";", " ", " ", " ", " ", " ", "FROM", " ", "subm", "ission", "\\", "10", ";", " ", " ", " ", " ", " ", "WHE", "RE", " ", "status", " ", "=", " ", "'", "AC", "'", "\\", "10", ";", " ", " ", " ", " ", " ", "GROU", "P", " ", "BY", " ", "user", "\\u", "id", ",", " ", "custom", "\\u", "user", "\\u", "id", ";", "\\", "10", ";", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tmpl", "ist_", "=_", "db_", "._", "execute", "sql_", "(_", "sql_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "user_", "in_", "tmpl", "ist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "solved", "\\u", "count_", "[_", "user_", "[_", "0_", "]_", "]_", "=_", "user_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "complete", "\\u", "dict_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Prepare", " ", "a", " ", "list", " ", "of", " ", "stop", "stal", "k", "\\u", "handle", "s", " ", "of", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "users", " ", "rele", "van", "t", " ", "to", " ", "the", " ", "request", "ed", " ", "leader", "board_", "\\u\\u\\uNL\\u\\u\\u_", "friends", "\\u", "stop", "stal", "k", "\\u", "handles_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "x_", "in_", "reg", "\\u", "users_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "friends", "\\u", "stop", "stal", "k", "\\u", "handles_", "._", "append_", "(_", "\"'\"_", "+_", "x_", "._", "stop", "stal", "k", "\\u", "handle_", "+_", "\"'\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "complete", "\\u", "dict_", "[_", "x_", "._", "stop", "stal", "k", "\\u", "handle_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "custom", "\\u", "user_", "in_", "custom", "\\u", "users_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stop", "stal", "k", "\\u", "handle_", "=_", "custom", "\\u", "user_", "._", "stop", "stal", "k", "\\u", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "custom", "\\u", "user_", "._", "duplicat", "e\\u", "cu_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stop", "stal", "k", "\\u", "handle_", "=_", "cf", "table_", "(_", "custom", "\\u", "user_", "._", "duplicat", "e\\u", "cu_", ")_", "._", "stop", "stal", "k", "\\u", "handle_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "friends", "\\u", "stop", "stal", "k", "\\u", "handles_", "._", "append_", "(_", "\"'\"_", "+_", "stop", "stal", "k", "\\u", "handle_", "+_", "\"'\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "complete", "\\u", "dict_", "[_", "stop", "stal", "k", "\\u", "handle_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "friends", "\\u", "stop", "stal", "k", "\\u", "handles_", "==_", "[_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "friends", "\\u", "stop", "stal", "k", "\\u", "handles_", "=_", "[_", "\"-", "1", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Build", " ", "the", " ", "complex", " ", "SQL", " ", "query_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sql", "\\u", "query_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", "SELECT", " ", "stop", "stal", "k", "\\u", "handle", ",", " ", "DAT", "E", "(", "time", "\\u", "stamp", "),", " ", "COUNT", "(*", ")", " ", "as", " ", "cnt", "\\", "10", ";", " ", " ", "FROM", " ", "subm", "ission", "\\", "10", ";", " ", " ", "WHE", "RE", " ", "stop", "stal", "k", "\\u", "handle", " ", "in", " ", "(%", "s", ")", "\\", "10", ";", " ", " ", "GROU", "P", " ", "BY", " ", "stop", "stal", "k", "\\u", "handle", ",", " ", "DAT", "E", "(", "subm", "ission", ".", "time", "\\u", "stamp", ")", "\\", "10", ";", " ", " ", "ORDE", "R", " ", "BY", " ", "time", "\\u", "stamp", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "%_", "(_", "\",", " ", "\"_", "._", "join_", "(_", "friends", "\\u", "stop", "stal", "k", "\\u", "handles_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "user", "\\u", "rows_", "=_", "db_", "._", "execute", "sql_", "(_", "sql", "\\u", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "user_", "in_", "user", "\\u", "rows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "complete", "\\u", "dict_", "[_", "user_", "[_", "0_", "]_", "]_", "!=_", "[_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "complete", "\\u", "dict_", "[_", "user_", "[_", "0_", "]_", "]_", "._", "append_", "(_", "(_", "user_", "[_", "1_", "]_", ",_", "user_", "[_", "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 ", " _", "complete", "\\u", "dict_", "[_", "user_", "[_", "0_", "]_", "]_", "=_", "[_", "(_", "user_", "[_", "1_", "]_", ",_", "user_", "[_", "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_", "users_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "user_", "in_", "reg", "\\u", "users_", ":_", "\\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 ", " _", "solved", "_", "=_", "solved", "\\u", "count_", "[_", "user_", "._", "stop", "stal", "k", "\\u", "handle_", "]_", "\\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 ", " _", "solved", "_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tup_", "=_", "utilities_", "._", "compute", "\\u", "row_", "(_", "user_", ",_", "complete", "\\u", "dict_", ",_", "solved", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "tup_", "is_", "not_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "users_", "._", "append_", "(_", "tup_", ")_", "\\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_", "user_", "in_", "custom", "\\u", "users_", ":_", "\\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_", "user_", "._", "duplicat", "e\\u", "cu_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "orig", "\\u", "user_", "=_", "cf", "table_", "(_", "user_", "._", "duplicat", "e\\u", "cu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "solved", "_", "=_", "solved", "\\u", "count_", "[_", "orig", "\\u", "user_", "._", "stop", "stal", "k", "\\u", "handle_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "solved", "_", "=_", "solved", "\\u", "count_", "[_", "user_", "._", "stop", "stal", "k", "\\u", "handle_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "solved", "_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tup_", "=_", "utilities_", "._", "compute", "\\u", "row_", "(_", "user_", ",_", "complete", "\\u", "dict_", ",_", "solved", "_", ",_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "tup_", "is_", "not_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "users_", "._", "append_", "(_", "tup_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sort", " ", "users", " ", "according", " ", "to", " ", "the", " ", "rating_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "users_", "=_", "sorted_", "(_", "users_", ",_", "key_", "=_", "lambda_", "x_", ":_", "x_", "[_", "3_", "]_", ",_", "reverse_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "table_", "=_", "TABLE_", "(_", "\\u", "class_", "=_", "\"", "centered", " ", "strip", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "table_", "._", "append_", "(_", "THE", "AD_", "(_", "TR_", "(_", "TH_", "(_", "\"", "Rank", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Name", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Sto", "p", "Sta", "lk", " ", "Handle", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Institut", "e", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Sto", "p", "Sta", "lk", " ", "Rati", "ng", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Rati", "ng", " ", "Change", "s", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Per", " ", "Day", " ", "Change", "s", "\"_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tbo", "dy_", "=_", "TB", "OD", "Y_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rank_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "users_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "i_", "[_", "5_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "span_", "=_", "SPAN", "_", "(_", "\\u", "class_", "=_", "\"", "orange", " ", "toolt", "ipp", "ed", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "{_", "\"", "position", "\"_", ":_", "\"", "right", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "dela", "y", "\"_", ":_", "\"", "50", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "toolt", "ip", "\"_", ":_", "\"", "Custom", " ", "User", "\"_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "style_", "=_", "\"", "cursor", ":", " ", "point", "er", ";", " ", "\"_", "+_", "\"", "float", ":", "right", ";", " ", "\"_", "+_", "\"", "height", ":", "10", "px", ";", " ", "\"_", "+_", "\"", "widt", "h", ":", "10", "px", ";", " ", "\"_", "+_", "\"", "border", "-", "radi", "us", ":", " ", "50", "%;", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "span_", "=_", "SPAN", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tr_", "=_", "TR_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "str_", "(_", "rank_", ")_", "+_", "\".\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "DIV_", "(_", "span_", ",_", "DIV_", "(_", "i_", "[_", "0_", "]_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "A_", "(_", "i_", "[_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "href_", "=_", "URL_", "(_", "\"", "user", "\"_", ",_", "\"", "profile", "\"_", ",_", "args_", "=_", "[_", "i_", "[_", "1_", "]_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "target_", "=_", "\"\\u", "blank", "\"_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "A_", "(_", "i_", "[_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "href_", "=_", "URL_", "(_", "\"", "default", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "leader", "board", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "vars_", "=_", "{_", "\"", "q", "\"_", ":_", "i_", "[_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "global", "\"_", ":_", "global", "\\u", "leader", "board_", "}_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "i_", "[_", "3_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "i_", "[_", "6_", "]_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tr_", "._", "append_", "(_", "TD_", "(_", "B_", "(_", "\"+", "%", "s", "\"_", "%_", "str_", "(_", "i_", "[_", "6_", "]_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "green", "-", "text", " ", "text", "-", "dark", "en", "-", "2", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "i_", "[_", "6_", "]_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tr_", "._", "append_", "(_", "TD_", "(_", "B_", "(_", "i_", "[_", "6_", "]_", ")_", ",_", "\\u", "class_", "=_", "\"", "red", "-", "text", " ", "text", "-", "dark", "en", "-", "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 ", " _", "tr_", "._", "append_", "(_", "TD_", "(_", "i_", "[_", "6_", "]_", ",_", "\\u", "class_", "=_", "\"", "blue", "-", "text", " ", "text", "-", "dark", "en", "-", "2", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "diff_", "=_", "\"{:", "1.5", "f", "}\"_", "._", "format_", "(_", "i_", "[_", "4_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "float_", "(_", "diff_", ")_", "==_", "0.0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tr_", "._", "append_", "(_", "TD_", "(_", "\"+\"_", "+_", "diff_", ",_", "\"", " ", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "minu", "s", "\"_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "i_", "[_", "4_", "]_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tr_", "._", "append_", "(_", "TD_", "(_", "\"+\"_", "+_", "str_", "(_", "diff_", ")_", ",_", "\"", " ", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "che", "vro", "n", "-", "circle", "-", "up", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "style_", "=_", "\"", "color", ":", " ", "#", "0f", "0", ";\"_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "i_", "[_", "4_", "]_", "<_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tr_", "._", "append_", "(_", "TD_", "(_", "diff_", ",_", "\"", " ", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "che", "vro", "n", "-", "circle", "-", "down", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "style_", "=_", "\"", "color", ":", " ", "#", "f0", "0", ";\"_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tbo", "dy_", "._", "append_", "(_", "tr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rank_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "table_", "._", "append_", "(_", "tbo", "dy_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "switch_", "=_", "DIV_", "(_", "LABEL_", "(_", "H", "6_", "(_", "\"", "Friends", "'", " ", "Subm", "ission", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "INPUT_", "(_", "\\u", "type_", "=_", "\"", "checkb", "ox", "\"_", ",_", "\\u", "id_", "=_", "\"", "subm", "ission", "-", "switch", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "SPAN", "_", "(_", "\\u", "class_", "=_", "\"", "leve", "r", " ", "pin", "k", " ", "accent", "-", "3", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Global", " ", "Subm", "ission", "s", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "switch", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "div_", "=_", "TAG_", "[_", "\"\"_", "]_", "(_", "switch_", ",_", "table_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "dict_", "(_", "div_", "=_", "div_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "heading_", "=_", "heading_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "global", "\\u", "leader", "board_", "=_", "global", "\\u", "leader", "board_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "user_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Us", "e", " ", "the", " ", "standard", " ", "auth", " ", "for", " ", "user", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "dict_", "(_", "form_", "=_", "auth_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "auth_", "._", "require", "s", "\\u", "login_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "search_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Sear", "ch", " ", "for", " ", "a", " ", "user", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "filters_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Apply", " ", "multiple", " ", "kind", " ", "of", " ", "filter", "s", " ", "on", " ", "subm", "ission", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "stable_", "=_", "db_", "._", "submission_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "get", "\\u", "vars_", "=_", "request_", "._", "get", "\\u", "vars_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "request_", "._", "args_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "page_", "=_", "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 ", " _", "page_", "=_", "int_", "(_", "request_", "._", "args_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "page_", "-=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "all", "\\u", "languages_", "=_", "db_", "(_", "stable_", ")_", "._", "select_", "(_", "stable_", "._", "lang_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "distinct_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "languages_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "all", "\\u", "languages_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "languages_", "._", "append_", "(_", "i_", "[_", "\"", "lang", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "table_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "global", "\\u", "submissions_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "get", "\\u", "vars_", "._", "has", "\\u", "key_", "(_", "\"", "global", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "get", "\\u", "vars_", "[_", "\"", "global", "\"_", "]_", "==_", "\"", "Tru", "e", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "global", "\\u", "submissions_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "form", " ", "is", " ", "not", " ", "submitted", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "get", "\\u", "vars_", "==_", "{_", "}_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "dict_", "(_", "languages_", "=_", "languages_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "div_", "=_", "DIV_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "global", "\\u", "submissions_", "=_", "global", "\\u", "submissions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "not", "hing", " ", "is", " ", "filled", " ", "in", " ", "the", " ", "form_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "these", " ", "fields", " ", "shou", "ld", " ", "be", " ", "pass", "ed", " ", "in_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "URL", " ", "with", " ", "empty", " ", "value_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "compu", "lsa", "ry", "\\u", "keys_", "=_", "[_", "\"", "pn", "ame", "\"_", ",_", "\"", "name", "\"_", ",_", "\"", "end", "\\u", "date", "\"_", ",_", "\"", "start", "\\u", "date", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "set_", "(_", "compu", "lsa", "ry", "\\u", "keys_", ")_", "._", "issubset_", "(_", "get", "\\u", "vars_", "._", "keys_", "(_", ")_", ")_", "is_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "flash_", "=_", "\"", "Inva", "lid", " ", "URL", " ", "parameter", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "redirect_", "(_", "URL_", "(_", "\"", "default", "\"_", ",_", "\"", "filter", "s", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Form", " ", "has", " ", "bee", "n", " ", "submitted", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cf", "table_", "=_", "db_", "._", "custom", "\\u", "friend_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "atab", "le_", "=_", "db_", "._", "auth", "\\u", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fta", "ble_", "=_", "db_", "._", "friends_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "duplicates_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "switch_", "=_", "DIV_", "(_", "LABEL_", "(_", "H", "6_", "(_", "\"", "Friends", "'", " ", "Subm", "ission", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "INPUT_", "(_", "\\u", "type_", "=_", "\"", "checkb", "ox", "\"_", ",_", "\\u", "id_", "=_", "\"", "subm", "ission", "-", "switch", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "SPAN", "_", "(_", "\\u", "class_", "=_", "\"", "leve", "r", " ", "pin", "k", " ", "accent", "-", "3", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Global", " ", "Subm", "ission", "s", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "switch", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "table_", "=_", "TABLE_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "div_", "=_", "TAG_", "[_", "\"\"_", "]_", "(_", "H", "4_", "(_", "\"", "Rece", "nt", " ", "Subm", "ission", "s", "\"_", ")_", ",_", "switch_", ",_", "table_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "global", "\\u", "submissions_", "is_", "False_", "and_", "session_", "._", "user", "\\u", "id_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "flash_", "=_", "\"", "Logi", "n", " ", "to", " ", "view", " ", "Friends", "'", " ", "subm", "ission", "s", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "vars_", "=_", "request_", "._", "vars_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "vars_", "[_", "\"", "global", "\"_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "redirect_", "(_", "URL_", "(_", "\"", "default", "\"_", ",_", "\"", "filter", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "vars_", "=_", "new", "\\u", "vars_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "request_", "._", "args_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "query_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "username_", "=_", "get", "\\u", "vars_", "[_", "\"", "name", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "username_", "!=_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tmpl", "ist_", "=_", "username_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "token_", "in_", "tmpl", "ist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "&=_", "(_", "(_", "cf", "table_", "._", "first", "\\u", "name_", "._", "contains_", "(_", "token_", ")_", ")_", "|_", "(_", "cf", "table_", "._", "last", "\\u", "name_", "._", "contains_", "(_", "token_", ")_", ")_", ")_", "\\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_", "global", "\\u", "submissions_", "is_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Retrieve", " ", "all", " ", "the", " ", "custom", " ", "users", " ", "created", " ", "by", " ", "the", " ", "logged", "-", "in", " ", "user_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "(_", "cf", "table_", "._", "user", "\\u", "id_", "==_", "session_", "._", "user", "\\u", "id_", ")_", "&_", "query_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cust", "\\u", "friends_", "=_", "db_", "(_", "query_", ")_", "._", "select_", "(_", "cf", "table_", "._", "id_", ",_", "cf", "table_", "._", "duplicat", "e\\u", "cu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "Origina", "l", " ", "ID", "s", " ", "of", " ", "duplicat", "e", " ", "custom", "\\u", "friends_", "\\u\\u\\uNL\\u\\u\\u_", "custom", "\\u", "friends_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "cus", "\\u", "id_", "in_", "cust", "\\u", "friends_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "cus", "\\u", "id_", "._", "duplicat", "e\\u", "cu_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "duplicates_", "._", "append_", "(_", "(_", "cus", "\\u", "id_", "._", "id_", ",_", "cus", "\\u", "id_", "._", "duplicat", "e\\u", "cu_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "custom", "\\u", "friends_", "._", "append_", "(_", "cus", "\\u", "id_", "._", "duplicat", "e\\u", "cu_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "custom", "\\u", "friends_", "._", "append_", "(_", "cus", "\\u", "id_", "._", "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_", "query_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "friends", " ", "of", " ", "logged", " ", "in", " ", "user_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "username_", "!=_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tmpl", "ist_", "=_", "username_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "token_", "in_", "tmpl", "ist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "&=_", "(_", "(_", "atab", "le_", "._", "first", "\\u", "name_", "._", "contains_", "(_", "token_", ")_", ")_", "|_", "(_", "atab", "le_", "._", "last", "\\u", "name_", "._", "contains_", "(_", "token_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "@", "To", "Do", ":", " ", "Any", "way", " ", "to", " ", "use", " ", "join", " ", "inst", "ead", " ", "of", " ", "two", " ", "suc", "h", " ", "db", " ", "calls_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "possib", "le", "\\u", "users_", "=_", "db_", "(_", "query_", ")_", "._", "select_", "(_", "atab", "le_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "possib", "le", "\\u", "users_", "=_", "[_", "x_", "[_", "\"", "id", "\"_", "]_", "for_", "x_", "in_", "possib", "le", "\\u", "users_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "friends_", "=_", "possib", "le", "\\u", "users_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "global", "\\u", "submissions_", "is_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "(_", "fta", "ble_", "._", "user", "\\u", "id_", "==_", "session_", "._", "user", "\\u", "id_", ")_", "&_", "(_", "fta", "ble_", "._", "frie", "nd", "\\u", "id_", "._", "belo", "ngs_", "(_", "possib", "le", "\\u", "users_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "frie", "nd", "\\u", "ids_", "=_", "db_", "(_", "query_", ")_", "._", "select_", "(_", "fta", "ble_", "._", "frie", "nd", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "friends_", "=_", "[_", "x_", "[_", "\"", "frie", "nd", "\\u", "id", "\"_", "]_", "for_", "x_", "in_", "frie", "nd", "\\u", "ids_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "session_", "._", "user", "\\u", "id_", "in_", "possib", "le", "\\u", "users_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Show", " ", "subm", "ission", "s", " ", "of", " ", "user", " ", "als", "o_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "friends_", "._", "append_", "(_", "session_", "._", "user", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "User", " ", "in", " ", "one", " ", "of", " ", "the", " ", "friends_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "query_", "=_", "(_", "stable_", "._", "user", "\\u", "id_", "._", "belo", "ngs_", "(_", "friends_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "User", " ", "in", " ", "one", " ", "of", " ", "the", " ", "custom", " ", "friends_", "\\u\\u\\uNL\\u\\u\\u_", "query_", "|=_", "(_", "stable_", "._", "custom", "\\u", "user", "\\u", "id_", "._", "belo", "ngs_", "(_", "custom", "\\u", "friends_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "start", "\\u", "date_", "=_", "get", "\\u", "vars_", "[_", "\"", "start", "\\u", "date", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "end", "\\u", "date_", "=_", "get", "\\u", "vars_", "[_", "\"", "end", "\\u", "date", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Else", " ", "part", " ", "ensure", "s", " ", "tha", "t", " ", "bot", "h", " ", "the", " ", "dates", " ", "passed_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "are", " ", "include", "d", " ", "in", " ", "the", " ", "range_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "start", "\\u", "date_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "start", " ", "date", " ", "is", " ", "empty", " ", "start", " ", "from", " ", "the", " ", "INITIAL", "\\u", "DATE_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "start", "\\u", "date_", "=_", "current_", "._", "INITIAL", "\\u", "DATE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Else", " ", "append", " ", "startin", "g", " ", "time", " ", "for", " ", "tha", "t", " ", "day_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "start", "\\u", "date_", "+=_", "\"", " ", "00", ":", "00", ":", "00", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "end", "\\u", "date_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "end", " ", "date", " ", "is", " ", "empty", " ", "retrieve", " ", "all", " ", "subm", "ission", "s", " ", "till", " ", "now", "(", "current", " ", "timestamp", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Curr", "ent", " ", "date", "/", "time_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "end", "\\u", "date_", "=_", "str_", "(_", "datetime_", "._", "datetime_", "._", "today_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Remove", " ", "the", " ", "last", " ", "milliseconds", " ", "from", " ", "the", " ", "timestamp_", "\\u\\u\\uNL\\u\\u\\u_", "end", "\\u", "date_", "=_", "end", "\\u", "date_", "[_", ":_", "-_", "7_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Else", " ", "append", " ", "the", " ", "ending", " ", "time", " ", "for", " ", "tha", "t", " ", "day_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "end", "\\u", "date_", "+=_", "\"", " ", "23", ":", "5", "9", ":", "5", "9", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "start", "\\u", "time_", "=_", "time_", "._", "strptime_", "(_", "start", "\\u", "date_", ",_", "\"%", "Y", "-%", "m", "-%", "d", " ", "%", "H", ":", "%", "M", ":", "%", "S", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "end", "\\u", "time_", "=_", "time_", "._", "strptime_", "(_", "end", "\\u", "date_", ",_", "\"%", "Y", "-%", "m", "-%", "d", " ", "%", "H", ":", "%", "M", ":", "%", "S", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "end", "\\u", "time_", ">_", "start", "\\u", "time_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Subm", "ission", "s", " ", "in", " ", "the", " ", "the", " ", "range", " ", "start", "\\u", "date", " ", "to", " ", "end", "\\u", "date_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "&=_", "(_", "stable_", "._", "time", "\\u", "stamp_", ">=_", "start", "\\u", "date_", ")_", "&_", "(_", "stable_", "._", "time", "\\u", "stamp_", "<=_", "end", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "flash_", "=_", "\"", "Start", " ", "Date", " ", "great", "er", " ", "than", " ", "End", " ", "Date", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "redirect_", "(_", "URL_", "(_", "\"", "default", "\"_", ",_", "\"", "filter", "s", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "pname_", "=_", "get", "\\u", "vars_", "[_", "\"", "pn", "ame", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Subm", "ission", "s", " ", "with", " ", "problem", " ", "name", " ", "contain", "ing", " ", "pname_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "pname_", "!=_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pname_", "=_", "pname_", "._", "split_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "token_", "in_", "pname_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "&=_", "(_", "stable_", "._", "problem", "\\u", "name_", "._", "contains_", "(_", "token_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "multiple", " ", "parameter", "s", " ", "are", " ", "passed_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "values", "\\u", "list_", "(_", "param", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values", "\\u", "list_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "get", "\\u", "vars_", "._", "has", "\\u", "key_", "(_", "param", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values", "\\u", "list_", "=_", "get", "\\u", "vars_", "[_", "param", "\\u", "name_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "values", "\\u", "list_", ",_", "str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values", "\\u", "list_", "=_", "[_", "values", "\\u", "list_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "get", "\\u", "vars_", "._", "has", "\\u", "key_", "(_", "param", "\\u", "name_", "+_", "\"[", "]\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values", "\\u", "list_", "=_", "get", "\\u", "vars_", "[_", "param", "\\u", "name_", "+_", "\"[", "]\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "values", "\\u", "list_", ",_", "str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "values", "\\u", "list_", "=_", "[_", "values", "\\u", "list_", "]_", "\\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_", "values", "\\u", "list_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Subm", "ission", "s", " ", "from", " ", "this", " ", "site_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sites_", "=_", "get", "\\u", "values", "\\u", "list_", "(_", "\"", "site", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sites_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "&=_", "(_", "stable_", "._", "site_", "._", "belo", "ngs_", "(_", "sites_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Subm", "ission", "s", " ", "with", " ", "this", " ", "language_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "langs_", "=_", "get", "\\u", "values", "\\u", "list_", "(_", "\"", "language", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "langs_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "&=_", "(_", "stable_", "._", "lang_", "._", "belo", "ngs_", "(_", "langs_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Subm", "ission", "s", " ", "with", " ", "this", " ", "status_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "statuses_", "=_", "get", "\\u", "values", "\\u", "list_", "(_", "\"", "status", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "statuses_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "&=_", "(_", "stable_", "._", "status_", "._", "belo", "ngs_", "(_", "statuses_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "PER", "\\u", "PAGE_", "=_", "current_", "._", "PER", "\\u", "PAGE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Apply", " ", "the", " ", "complex", " ", "query", " ", "and", " ", "sort", " ", "by", " ", "time", "\\u", "stamp", " ", "DESC_", "\\u\\u\\uNL\\u\\u\\u_", "filtered_", "=_", "db_", "(_", "query_", ")_", "._", "select_", "(_", "limit", "by_", "=_", "(_", "page_", "*_", "PER", "\\u", "PAGE_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "page_", "+_", "1_", ")_", "*_", "PER", "\\u", "PAGE_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "orderby_", "=_", "~_", "stable_", "._", "time", "\\u", "stamp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "total", "\\u", "problems_", "=_", "db_", "(_", "query_", ")_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total", "\\u", "pages_", "=_", "total", "\\u", "problems_", "/_", "100_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "total", "\\u", "problems_", "%_", "100_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "total", "\\u", "pages_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "table_", "=_", "utilities_", "._", "render", "\\u", "table_", "(_", "filtered_", ",_", "duplicates_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "switch_", "=_", "DIV_", "(_", "LABEL_", "(_", "H", "6_", "(_", "\"", "Friends", "'", " ", "Subm", "ission", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "INPUT_", "(_", "\\u", "type_", "=_", "\"", "checkb", "ox", "\"_", ",_", "\\u", "id_", "=_", "\"", "subm", "ission", "-", "switch", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "SPAN", "_", "(_", "\\u", "class_", "=_", "\"", "leve", "r", " ", "pin", "k", " ", "accent", "-", "3", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Global", " ", "Subm", "ission", "s", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "switch", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "div_", "=_", "TAG_", "[_", "\"\"_", "]_", "(_", "switch_", ",_", "table_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "dict_", "(_", "languages_", "=_", "languages_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "div_", "=_", "div_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "total", "\\u", "pages_", "=_", "total", "\\u", "pages_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "global", "\\u", "submissions_", "=_", "global", "\\u", "submissions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "auth_", "._", "require", "s", "\\u", "login_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "mark", "\\u", "friend_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Sen", "d", " ", "a", " ", "frie", "nd", " ", "request", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "request_", "._", "args_", ")_", "<_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "Inva", "lid", " ", "URL", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fr", "table_", "=_", "db_", "._", "frie", "nd", "\\u", "requests_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fta", "ble_", "=_", "db_", "._", "friends_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "frie", "nd", "\\u", "id_", "=_", "long_", "(_", "request_", "._", "args_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "frie", "nd", "\\u", "id_", "!=_", "session_", "._", "user", "\\u", "id_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "(_", "fta", "ble_", "._", "user", "\\u", "id_", "==_", "session_", "._", "user", "\\u", "id_", ")_", "&_", "(_", "fta", "ble_", "._", "frie", "nd", "\\u", "id_", "==_", "frie", "nd", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "value_", "=_", "db_", "(_", "query_", ")_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "value_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "=_", "(_", "(_", "fr", "table_", "._", "from", "\\u", "h_", "==_", "session_", "._", "user", "\\u", "id_", ")_", "&_", "(_", "fr", "table_", "._", "to", "\\u", "h_", "==_", "frie", "nd", "\\u", "id_", ")_", ")_", "|_", "(_", "(_", "fr", "table_", "._", "from", "\\u", "h_", "==_", "frie", "nd", "\\u", "id_", ")_", "&_", "(_", "fr", "table_", "._", "to", "\\u", "h_", "==_", "session_", "._", "user", "\\u", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "value_", "=_", "db_", "(_", "query_", ")_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "value_", "!=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "flash_", "=_", "\"", "Friend", " ", "request", " ", "pend", "ing", "...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "redirect_", "(_", "URL_", "(_", "\"", "default", "\"_", ",_", "\"", "search", "\"_", ")_", ")_", "\\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_", "\"", "Al", "read", "y", " ", "friends", " ", "!!\"", "_", "\\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_", "\"", "Inva", "lid", " ", "user", " ", "argu", "ment", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Insert", " ", "a", " ", "tuple", " ", "of", " ", "users", "'", " ", "id", " ", "int", "o", " ", "the", " ", "frie", "nd", "\\u", "request", "s", " ", "table_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "db_", "._", "frie", "nd", "\\u", "requests_", "._", "insert_", "(_", "from", "\\u", "h_", "=_", "session_", "._", "user", "\\u", "id_", ",_", "to", "\\u", "h_", "=_", "frie", "nd", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sen", "d", " ", "the", " ", "user", " ", "an", " ", "email", " ", "notif", "ying", " ", "abo", "ut", " ", "the", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "atab", "le_", "=_", "db_", "._", "auth", "\\u", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "(_", "atab", "le_", "._", "id_", "==_", "frie", "nd", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "=_", "db_", "(_", "query_", ")_", "._", "select_", "(_", "atab", "le_", "._", "email_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "atab", "le_", "._", "stop", "stal", "k", "\\u", "handle_", ")_", "._", "first_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "current_", "._", "send", "\\u", "mail_", "(_", "to_", "=_", "row_", "._", "email_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "subject_", "=_", "session_", "._", "handle_", "+_", "\"", " ", "want", "s", " ", "to", " ", "be", " ", "a", " ", "frie", "nd", " ", "on", " ", "Sto", "p", "Sta", "lk", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "message_", "=_", "\"\"\"", "\\", "10", ";", "%", "s", " ", "(%", "s", ")", " ", "want", "s", " ", "to", " ", "connect", " ", "on", " ", "Sto", "p", "Sta", "lk", "\\", "10", ";", "To", " ", "view", " ", "all", " ", "frie", "nd", " ", "request", "s", " ", "go", " ", "here", " ", "-", " ", "%", "s", "\\", "10", ";", "\\", "10", ";", "To", " ", "stop", " ", "receiv", "ing", " ", "mails", " ", "-", " ", "%", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "%_", "(_", "session_", "._", "handle_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "URL_", "(_", "\"", "user", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "profile", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "[_", "session_", "._", "handle_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "scheme_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "host_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extension_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "URL_", "(_", "\"", "user", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "frie", "nd", "\\u", "request", "s", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "scheme_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "host_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extension_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "URL_", "(_", "\"", "default", "\"_", ",_", "\"", "unsubscribe", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "scheme_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "host_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extension_", "=_", "False_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "\"", "Friend", " ", "Request", " ", "sent", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "auth_", "._", "require", "s", "\\u", "login_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "retrieve", "\\u", "users_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Show", " ", "the", " ", "list", " ", "of", " ", "register", "ed", " ", "users", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "atab", "le_", "=_", "db_", "._", "auth", "\\u", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fr", "table_", "=_", "db_", "._", "frie", "nd", "\\u", "requests_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fta", "ble_", "=_", "db_", "._", "friends_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "q_", "=_", "request_", "._", "get", "\\u", "vars_", "._", "get_", "(_", "\"", "q", "\"_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "query_", "=_", "(_", "atab", "le_", "._", "first", "\\u", "name_", "._", "contains_", "(_", "q_", ")_", ")_", "|_", "(_", "atab", "le_", "._", "last", "\\u", "name_", "._", "contains_", "(_", "q_", ")_", ")_", "|_", "(_", "atab", "le_", "._", "stop", "stal", "k", "\\u", "handle_", "._", "contains_", "(_", "q_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "site_", "in_", "current_", "._", "SITE", "S_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "field", "\\u", "name_", "=_", "site_", "._", "lower_", "(_", ")_", "+_", "\"\\u", "handle", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "|=_", "(_", "atab", "le_", "[_", "field", "\\u", "name_", "]_", "._", "contains_", "(_", "q_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Don", "'", "t", " ", "show", " ", "the", " ", "logged", " ", "in", " ", "user", " ", "in", " ", "the", " ", "search_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "query_", "&=_", "(_", "atab", "le_", "._", "id_", "!=_", "session_", "._", "user", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Don", "'", "t", " ", "show", " ", "users", " ", "who", " ", "have", " ", "sent", " ", "frie", "nd", " ", "requests_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "the", " ", "logged", " ", "in", " ", "user_", "\\u\\u\\uNL\\u\\u\\u_", "tmp", "rows_", "=_", "db_", "(_", "fr", "table_", "._", "to", "\\u", "h_", "==_", "session_", "._", "user", "\\u", "id_", ")_", "._", "select_", "(_", "fr", "table_", "._", "from", "\\u", "h_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "row_", "in_", "tmp", "rows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "query_", "&=_", "(_", "atab", "le_", "._", "id_", "!=_", "row_", "._", "from", "\\u", "h_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Colum", "ns", " ", "of", " ", "auth", "\\u", "user", " ", "to", " ", "be", " ", "retrieved", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "columns_", "=_", "[_", "atab", "le_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "atab", "le_", "._", "first", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "atab", "le_", "._", "last", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "atab", "le_", "._", "stop", "stal", "k", "\\u", "handle_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "site_", "in_", "current_", "._", "SITE", "S_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "columns_", "._", "append_", "(_", "atab", "le_", "[_", "site_", "._", "lower_", "(_", ")_", "+_", "\"\\u", "handle", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "rows_", "=_", "db_", "(_", "query_", ")_", "._", "select_", "(_", "*_", "columns_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "t_", "=_", "TABLE_", "(_", "\\u", "class_", "=_", "\"", "strip", "ed", " ", "centered", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "=_", "TR_", "(_", "TH_", "(_", "\"", "Name", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "TH_", "(_", "\"", "Sto", "p", "Sta", "lk", " ", "Handle", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "site_", "in_", "current_", "._", "SITE", "S_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tr_", "._", "append_", "(_", "TH_", "(_", "site_", "+_", "\"", " ", "Handle", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tr_", "._", "append_", "(_", "TH_", "(_", "\"", "Friends", "hip", " ", "Status", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "thea", "d_", "=_", "THE", "AD_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "thea", "d_", "._", "append_", "(_", "tr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "append_", "(_", "thea", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tbo", "dy_", "=_", "TB", "OD", "Y_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "query_", "=_", "(_", "fta", "ble_", "._", "user", "\\u", "id_", "==_", "session_", "[_", "\"", "user", "\\u", "id", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "friends_", "=_", "db_", "(_", "query_", ")_", "._", "select_", "(_", "atab", "le_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "join_", "=_", "fta", "ble_", "._", "on_", "(_", "fta", "ble_", "._", "frie", "nd", "\\u", "id_", "==_", "atab", "le_", "._", "id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "friends_", "=_", "[_", "x_", "[_", "\"", "id", "\"_", "]_", "for_", "x_", "in_", "friends_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "user_", "in_", "rows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tr_", "=_", "TR_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "A_", "(_", "user_", "._", "first", "\\u", "name_", "+_", "\"", " ", "\"_", "+_", "user_", "._", "last", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "href_", "=_", "URL_", "(_", "\"", "user", "\"_", ",_", "\"", "profile", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "[_", "user_", "._", "stop", "stal", "k", "\\u", "handle_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extension_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "target_", "=_", "\"\\u", "blank", "\"_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr_", "._", "append_", "(_", "TD_", "(_", "user_", "._", "stop", "stal", "k", "\\u", "handle_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "site_", "in_", "current_", "._", "SITE", "S_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tr_", "._", "append_", "(_", "TD_", "(_", "user_", "[_", "site_", "._", "lower_", "(_", ")_", "+_", "\"\\u", "handle", "\"_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "if", " ", "the", " ", "current", " ", "user", " ", "is", " ", "alr", "ead", "y", " ", "a", " ", "frie", "nd", " ", "or", " ", "not_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "user_", "._", "id_", "not_", "in_", "friends_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", "=_", "db_", "(_", "(_", "fr", "table_", "._", "from", "\\u", "h_", "==_", "session_", "._", "user", "\\u", "id_", ")_", "&_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "fr", "table_", "._", "to", "\\u", "h_", "==_", "user_", "._", "id_", ")_", ")_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "r_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tr_", "._", "append_", "(_", "TD_", "(_", "BUTTON_", "(_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "user", "-", "plus", " ", "fa", "-", "3x", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "toolt", "ipp", "ed", " ", "btn", "-", "float", "ing", " ", "btn", "-", "large", " ", "waves", "-", "effect", " ", "waves", "-", "light", " ", "green", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "{_", "\"", "position", "\"_", ":_", "\"", "bottom", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "dela", "y", "\"_", ":_", "\"", "50", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "toolt", "ip", "\"_", ":_", "\"", "Sen", "d", " ", "frie", "nd", " ", "request", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "user", "-", "id", "\"_", ":_", "str_", "(_", "user_", "._", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "type", "\"_", ":_", "\"", "add", "-", "frie", "nd", "\"_", "}_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tr_", "._", "append_", "(_", "TD_", "(_", "BUTTON_", "(_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "user", "-", "plus", " ", "fa", "-", "3x", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "toolt", "ipp", "ed", " ", "btn", "-", "float", "ing", " ", "btn", "-", "large", " ", "disable", "d", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "{_", "\"", "position", "\"_", ":_", "\"", "bottom", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "dela", "y", "\"_", ":_", "\"", "50", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "toolt", "ip", "\"_", ":_", "\"", "Sen", "d", " ", "frie", "nd", " ", "request", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "type", "\"_", ":_", "\"", "disable", "d", "\"_", "}_", ")_", ")_", ")_", "\\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 ", " _", "tr_", "._", "append_", "(_", "TD_", "(_", "BUTTON_", "(_", "I_", "(_", "\\u", "class_", "=_", "\"", "fa", " ", "fa", "-", "user", "-", "times", " ", "fa", "-", "3x", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "toolt", "ipp", "ed", " ", "btn", "-", "float", "ing", " ", "btn", "-", "large", " ", "waves", "-", "effect", " ", "waves", "-", "light", " ", "black", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "{_", "\"", "position", "\"_", ":_", "\"", "bottom", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "dela", "y", "\"_", ":_", "\"", "50", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "toolt", "ip", "\"_", ":_", "\"", "Friend", " ", "request", " ", "pend", "ing", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "user", "-", "id", "\"_", ":_", "str_", "(_", "user_", "._", "id_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "type", "\"_", ":_", "\"", "unf", "rien", "d", "\"_", "}_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tbo", "dy_", "._", "append_", "(_", "tr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "._", "append_", "(_", "tbo", "dy_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "dict_", "(_", "t_", "=_", "t_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "auth_", "._", "require", "s", "\\u", "login_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "unf", "rien", "d_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Unf", "rien", "d", " ", "the", " ", "user", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "request_", "._", "args_", ")_", "!=_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "Ple", "ase", " ", "click", " ", "on", " ", "a", " ", "button", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "frie", "nd", "\\u", "id_", "=_", "long_", "(_", "request_", "._", "args_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user", "\\u", "id_", "=_", "session_", "[_", "\"", "user", "\\u", "id", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fta", "ble_", "=_", "db_", "._", "friends_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Delete", " ", "record", "s", " ", "in", " ", "the", " ", "friends", " ", "table_", "\\u\\u\\uNL\\u\\u\\u_", "query_", "=_", "(_", "fta", "ble_", "._", "user", "\\u", "id_", "==_", "user", "\\u", "id_", ")_", "&_", "(_", "fta", "ble_", "._", "frie", "nd", "\\u", "id_", "==_", "frie", "nd", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "value_", "=_", "db_", "(_", "query_", ")_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "value_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"", "Inva", "lid", " ", "URL", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "db_", "(_", "query_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "query_", "=_", "(_", "fta", "ble_", "._", "user", "\\u", "id_", "==_", "frie", "nd", "\\u", "id_", ")_", "&_", "(_", "fta", "ble_", "._", "frie", "nd", "\\u", "id_", "==_", "user", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "(_", "query_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Sen", "d", " ", "email", " ", "to", " ", "the", " ", "frie", "nd", " ", "notif", "ying", " ", "abo", "ut", " ", "the", " ", "tra", "ged", "y", " ", ";)", "_", "\\u\\u\\uNL\\u\\u\\u_", "atab", "le_", "=_", "db_", "._", "auth", "\\u", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "=_", "db_", "(_", "atab", "le_", "._", "id_", "==_", "frie", "nd", "\\u", "id_", ")_", "._", "select_", "(_", "atab", "le_", "._", "email_", ")_", "._", "first_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "current_", "._", "send", "\\u", "mail_", "(_", "to_", "=_", "row_", "._", "email_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "subject_", "=_", "\"", "A", " ", "frie", "nd", " ", "unf", "rien", "ded", " ", "you", " ", "on", " ", "Sto", "p", "Sta", "lk", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "message_", "=_", "\"\"\"", "\\", "10", ";", "%", "s", " ", "(%", "s", ")", " ", "unf", "rien", "ded", " ", "you", " ", "on", " ", "Sto", "p", "Sta", "lk", "\\", "10", ";", "\\", "10", ";", "To", " ", "stop", " ", "receiv", "ing", " ", "mails", " ", "-", " ", "%", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "%_", "(_", "session_", "._", "handle_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "URL_", "(_", "\"", "user", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "profile", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "[_", "session_", "._", "handle_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "scheme_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "host_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extension_", "=_", "False_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "URL_", "(_", "\"", "default", "\"_", ",_", "\"", "unsubscribe", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "scheme_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "host_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extension_", "=_", "False_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "\"", "Success", "full", "y", " ", "unf", "rien", "ded", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "auth_", "._", "require", "s", "\\u", "login_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "submissions_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Retrieve", " ", "subm", "ission", "s", " ", "of", " ", "the", " ", "logged", "-", "in", " ", "user", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "request_", "._", "args_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "active_", "=_", "\"", "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 ", " _", "active_", "=_", "request_", "._", "args_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cf", "table_", "=_", "db_", "._", "custom", "\\u", "friend_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fta", "ble_", "=_", "db_", "._", "friends_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stable_", "=_", "db_", "._", "submission_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "atab", "le_", "=_", "db_", "._", "auth", "\\u", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "all", " ", "the", " ", "friends", "/", "custom", " ", "friends", " ", "of", " ", "the", " ", "logged", "-", "in", " ", "user_", "\\u\\u\\uNL\\u\\u\\u_", "friends_", ",_", "cus", "friends_", "=_", "utilities_", "._", "get", "\\u", "friends_", "(_", "session_", "[_", "\"", "user", "\\u", "id", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "Origina", "l", " ", "ID", "s", " ", "of", " ", "duplicat", "e", " ", "custom", "\\u", "friends_", "\\u\\u\\uNL\\u\\u\\u_", "custom", "\\u", "friends_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "cus", "\\u", "id_", "in_", "cus", "friends_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "cus", "\\u", "id_", "[_", "1_", "]_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "custom", "\\u", "friends_", "._", "append_", "(_", "cus", "\\u", "id_", "[_", "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 ", " _", "custom", "\\u", "friends_", "._", "append_", "(_", "cus", "\\u", "id_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "query_", "=_", "(_", "stable_", "._", "user", "\\u", "id_", "._", "belo", "ngs_", "(_", "friends_", ")_", ")_", "|_", "(_", "stable_", "._", "custom", "\\u", "user", "\\u", "id_", "._", "belo", "ngs_", "(_", "custom", "\\u", "friends_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total", "\\u", "count_", "=_", "db_", "(_", "query_", ")_", "._", "count_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "PER", "\\u", "PAGE_", "=_", "current_", "._", "PER", "\\u", "PAGE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count_", "=_", "total", "\\u", "count_", "/_", "PER", "\\u", "PAGE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "total", "\\u", "count_", "%_", "PER", "\\u", "PAGE_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "count_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "extension_", "==_", "\"", "json", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "dict_", "(_", "count_", "=_", "count_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "total", "\\u", "rows_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "offset_", "=_", "PER", "\\u", "PAGE_", "*_", "(_", "int_", "(_", "active_", ")_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Retrieve", " ", "only", " ", "some", " ", "number", " ", "of", " ", "subm", "ission", "s", " ", "from", " ", "the", " ", "offset_", "\\u\\u\\uNL\\u\\u\\u_", "rows_", "=_", "db_", "(_", "query_", ")_", "._", "select_", "(_", "orderby_", "=_", "~_", "db_", "._", "submission_", "._", "time", "\\u", "stamp_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "limit", "by_", "=_", "(_", "offset_", ",_", "offset_", "+_", "PER", "\\u", "PAGE_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "table_", "=_", "utilities_", "._", "render", "\\u", "table_", "(_", "rows_", ",_", "cus", "friends_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "dict_", "(_", "table_", "=_", "table_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "friends_", "=_", "friends_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cus", "friends_", "=_", "cus", "friends_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "total", "\\u", "rows_", "=_", "len_", "(_", "rows_", ")_", ")_", "\\u\\u\\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_", "faq", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "FA", "Q", " ", "page", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "div_", "=_", "DIV_", "(_", "\\u", "class_", "=_", "\"", "row", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ul_", "=_", "UL", "_", "(_", "\\u", "class_", "=_", "\"", "colla", "psi", "ble", " ", "col", " ", "offset", "-", "s3", " ", "s", "6", "\"_", ",_", "data_", "=_", "{_", "\"", "colla", "psi", "ble", "\"_", ":_", "\"", "expand", "able", "\"_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "faq", "s_", "=_", "db_", "(_", "db_", "._", "faq", "_", ")_", "._", "select_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "xrange_", "(_", "len_", "(_", "faq", "s_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "li_", "=_", "LI_", "(_", "DIV_", "(_", "B_", "(_", "str_", "(_", "i_", "+_", "1_", ")_", "+_", "\".", " ", "\"_", "+_", "faq", "s_", "[_", "i_", "]_", "._", "question_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "colla", "psi", "ble", "-", "header", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "DIV_", "(_", "MARK", "MIN_", "(_", "faq", "s_", "[_", "i_", "]_", "._", "answer_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "class_", "=_", "\"", "colla", "psi", "ble", "-", "body", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ul_", "._", "append_", "(_", "li_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "div_", "._", "append_", "(_", "ul_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "dict_", "(_", "div_", "=_", "div_", ")_", "\\u\\u\\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_", "contact", "\\u", "us_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Conta", "ct", " ", "Us", " ", "page", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ctab", "le_", "=_", "db_", "._", "contact", "\\u", "us_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "session_", "[_", "\"", "auth", "\"_", "]_", "and_", "request_", "._", "post", "\\u", "vars_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "request_", "._", "post", "\\u", "vars_", "._", "sticke", "rs_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "._", "flash_", "=_", "\"", "Fil", "l", " ", "your", " ", "address", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "user_", "=_", "session_", "._", "auth_", "._", "user_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sticke", "rs_", "=_", "eval_", "(_", "request_", "._", "post", "\\u", "vars_", "[_", "\"", "sticke", "rs", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "sticke", "rs_", "[_", "0_", "]_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "flash_", "=_", "\"", "No", " ", "claim", "able", " ", "sticke", "rs", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "redirect_", "(_", "URL_", "(_", "\"", "default", "\"_", ",_", "\"", "my", "\\u", "friends", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ctab", "le_", "._", "email_", "._", "default_", "=_", "user_", "._", "email_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctab", "le_", "._", "name_", "._", "default_", "=_", "user_", "._", "first", "\\u", "name_", "+_", "\"", " ", "\"_", "+_", "user_", "._", "last", "\\u", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctab", "le_", "._", "subject_", "._", "default_", "=_", "\"", "Ple", "ase", " ", "send", " ", "me", " ", "sticke", "rs", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctab", "le_", "._", "text", "\\u", "message_", "._", "default_", "=_", "\"", "My", " ", "address", " ", "is", ":", " ", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "form_", "=_", "SQL", "FORM", "_", "(_", "ctab", "le_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "session_", "[_", "\"", "auth", "\"_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user_", "=_", "session_", "[_", "\"", "auth", "\"_", "]_", "[_", "\"", "user", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctab", "le_", "._", "email_", "._", "default_", "=_", "user_", "[_", "\"", "email", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "form_", "._", "process_", "(_", ")_", "._", "accepted_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "flash_", "=_", "\"", "We", " ", "will", " ", "get", " ", "back", " ", "to", " ", "you", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "current_", "._", "send", "\\u", "mail_", "(_", "to_", "=_", "\"", "contact", "stop", "stal", "k", "@", "gma", "il", ".", "com", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "subject_", "=_", "form_", "._", "vars_", "._", "subject_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "message_", "=_", "\"", "Fro", "m", ":", " ", "%", "s", " ", "(%", "s", " ", "-", " ", "%", "s", ")\\\\", "n", "\"_", "%_", "(_", "form_", "._", "vars_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "form_", "._", "vars_", "._", "email_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "form_", "._", "vars_", "._", "phone", "\\u", "number_", ")_", "+_", "\"", "Sub", "ject", ":", " ", "%", "s", "\\\\", "n", "\"_", "%_", "form_", "._", "vars_", "._", "subject_", "+_", "\"", "Messag", "e", ":", " ", "%", "s", "\\\\", "n", "\"_", "%_", "form_", "._", "vars_", "._", "text", "\\u", "message_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "redirect_", "(_", "URL_", "(_", "\"", "default", "\"_", ",_", "\"", "index", "\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "form_", "._", "errors_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "response_", "._", "flash_", "=_", "\"", "Ple", "ase", " ", "fill", " ", "all", " ", "the", " ", "fields", "!\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "dict_", "(_", "form_", "=_", "form_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "call_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "expos", "es", " ", "service", "s", ".", " ", "for", " ", "example", ":", "\\", "10", ";", " ", " ", " ", " ", "http", "://", "....", "/", "[", "app", "]/", "default", "/", "call", "/", "jsonrpc", "\\", "10", ";", " ", " ", " ", " ", "decorate", " ", "with", " ", "@", "service", "s", ".", "jsonrpc", " ", "the", " ", "function", "s", " ", "to", " ", "expos", "e", "\\", "10", ";", " ", " ", " ", " ", "support", "s", " ", "xml", ",", " ", "json", ",", " ", "xmlrpc", ",", " ", "jsonrpc", ",", " ", "am", "fr", "pc", ",", " ", "rs", "s", ",", " ", "csv", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "service_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Except block handles 'BaseException'
dimagi/commcare-hq/corehq/apps/reports/standard/cases/data_sources.py
[ { "content": " def parse_date(self, date_string):\n try:\n return iso_string_to_datetime(date_string)\n except:\n try:\n date_obj = dateutil.parser.parse(date_string)\n if isinstance(date_obj, datetime.datetime):\n return date_obj.replace(tzinfo=None)\n else:\n return date_obj\n except:\n return date_string", "metadata": "root.CaseInfo.parse_date", "header": "['class', 'CaseInfo', '(', 'object', ')', ':', '___EOS___']", "index": 174 } ]
[ { "span": "except:", "start_line": 177, "start_column": 8, "end_line": 177, "end_column": 15 }, { "span": "except:", "start_line": 184, "start_column": 12, "end_line": 184, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Case", "Info_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "parse", "\\u", "date_", "(_", "self_", ",_", "date", "\\u", "string_", ")_", ":_", "\\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_", "iso", "\\u", "string", "\\u", "to", "\\u", "datetime_", "(_", "date", "\\u", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "date", "\\u", "obj_", "=_", "dateutil_", "._", "parser_", "._", "parse_", "(_", "date", "\\u", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isinstance_", "(_", "date", "\\u", "obj_", ",_", "datetime_", "._", "datetime_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "return_", "date", "\\u", "obj_", "._", "replace_", "(_", "tzinfo_", "=_", "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 ", " ", "_", "return_", "date", "\\u", "obj_", "\\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_", "date", "\\u", "string_", "\\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, 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, 1, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
nii-cloud/dodai-compute/nova/api/openstack/backup_schedules.py
[ { "content": "# vim: tabstop=4 shiftwidth=4 softtabstop=4\n\n# Copyright 2010 OpenStack LLC.\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\nimport time\n\nfrom webob import exc\n\nfrom nova.api.openstack import wsgi\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def _translate_keys(inst):\n \"\"\" Coerces the backup schedule into proper dictionary format \"\"\"\n return dict(backupSchedule=inst)", "metadata": "root._translate_keys", "header": "['module', '___EOS___']", "index": 24 }, { "content": "class Controller(object):\n \"\"\" The backup schedule API controller for the Openstack API \"\"\"\n\n\n\n\n", "metadata": "root.Controller", "header": "['module', '___EOS___']", "index": 29 }, { "content": " def __init__(self):\n pass", "metadata": "root.Controller.__init__", "header": "['class', 'Controller', '(', 'object', ')', ':', '___EOS___']", "index": 32 }, { "content": " def index(self, req, server_id, **kwargs):\n \"\"\" Returns the list of backup schedules for a given instance \"\"\"\n raise exc.HTTPNotImplemented()", "metadata": "root.Controller.index", "header": "['class', 'Controller', '(', 'object', ')', ':', '___EOS___']", "index": 35 }, { "content": " def show(self, req, server_id, id, **kwargs):\n \"\"\" Returns a single backup schedule for a given instance \"\"\"\n raise exc.HTTPNotImplemented()", "metadata": "root.Controller.show", "header": "['class', 'Controller', '(', 'object', ')', ':', '___EOS___']", "index": 39 }, { "content": " def create(self, req, server_id, **kwargs):\n \"\"\" No actual update method required, since the existing API allows\n both create and update through a POST \"\"\"\n raise exc.HTTPNotImplemented()", "metadata": "root.Controller.create", "header": "['class', 'Controller', '(', 'object', ')', ':', '___EOS___']", "index": 43 }, { "content": " def delete(self, req, server_id, id, **kwargs):\n \"\"\" Deletes an existing backup schedule \"\"\"\n raise exc.HTTPNotImplemented()", "metadata": "root.Controller.delete", "header": "['class', 'Controller', '(', 'object', ')', ':', '___EOS___']", "index": 48 }, { "content": "def create_resource():\n metadata = {\n 'attributes': {\n 'backupSchedule': [],\n },\n }\n\n body_serializers = {\n 'application/xml': wsgi.XMLDictSerializer(xmlns=wsgi.XMLNS_V10,\n metadata=metadata),\n }\n\n serializer = wsgi.ResponseSerializer(body_serializers)\n return wsgi.Resource(Controller(), serializer=serializer)", "metadata": "root.create_resource", "header": "['module', '___EOS___']", "index": 53 } ]
[ { "span": "import time", "start_line": 17, "start_column": 0, "end_line": 17, "end_column": 11 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", " ", "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", " ", "Open", "Stack", " ", "LLC", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "All", " ", "Rig", "hts", " ", "Reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "License", "d", " ", "under", " ", "the", " ", "Ap", "ache", " ", "License", ",", " ", "Version", " ", "2.0", " ", "(", "the", " ", "\"", "License", "\");", " ", "you", " ", "may", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", "not", " ", "use", " ", "this", " ", "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_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "webob_", "import_", "exc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "nova_", "._", "api_", "._", "openstack_", "import_", "wsgi_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u", "translat", "e\\u", "keys_", "(_", "inst_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Coe", "rce", "s", " ", "the", " ", "backup", " ", "schedule", " ", "int", "o", " ", "proper", " ", "dictionar", "y", " ", "format", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "dict_", "(_", "backup", "Schedule_", "=_", "inst_", ")_", "\\u\\u\\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_", "Controller_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "The", " ", "backup", " ", "schedule", " ", "API", " ", "controlle", "r", " ", "for", " ", "the", " ", "Opens", "tack", " ", "API", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Controller_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controller_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "index_", "(_", "self_", ",_", "req_", ",_", "server", "\\u", "id_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Return", "s", " ", "the", " ", "list", " ", "of", " ", "backup", " ", "schedules", " ", "for", " ", "a", " ", "give", "n", " ", "instance", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "exc_", "._", "HTTP", "Not", "Implemented_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controller_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "show_", "(_", "self_", ",_", "req_", ",_", "server", "\\u", "id_", ",_", "id_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Return", "s", " ", "a", " ", "single", " ", "backup", " ", "schedule", " ", "for", " ", "a", " ", "give", "n", " ", "instance", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "exc_", "._", "HTTP", "Not", "Implemented_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controller_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create_", "(_", "self_", ",_", "req_", ",_", "server", "\\u", "id_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "No", " ", "actual", " ", "update", " ", "method", " ", "require", "d", ",", " ", "sinc", "e", " ", "the", " ", "exist", "ing", " ", "API", " ", "allow", "s", "\\", "10", ";", " ", " ", " ", " ", "bot", "h", " ", "create", " ", "and", " ", "update", " ", "through", " ", "a", " ", "POST", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "exc_", "._", "HTTP", "Not", "Implemented_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Controller_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", "self_", ",_", "req_", ",_", "server", "\\u", "id_", ",_", "id_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "Delete", "s", " ", "an", " ", "exist", "ing", " ", "backup", " ", "schedule", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "exc_", "._", "HTTP", "Not", "Implemented_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create", "\\u", "resource_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "metadata_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "attribute", "s", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "backup", "Schedule", "'_", ":_", "[_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "body", "\\u", "serializers_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "applica", "tion", "/", "xml", "'_", ":_", "wsgi_", "._", "XML", "Dict", "Serializer_", "(_", "xmlns_", "=_", "wsgi_", "._", "XML", "NS", "\\u", "V1", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "metadata_", "=_", "metadata_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "serializer_", "=_", "wsgi_", "._", "Respons", "e", "Serializer_", "(_", "body", "\\u", "serializers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "wsgi_", "._", "Resource_", "(_", "Controller_", "(_", ")_", ",_", "serializer_", "=_", "serializer_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
mrknow/filmkodi/plugin.video.specto/resources/lib/sources/dizibox_tv.py
[ { "content": " def get_episode(self, url, imdb, tvdb, title, date, season, episode):\n try:\n if url == None: return\n\n url = urlparse.urljoin(self.base_link, url)\n\n season, episode = '%01d' % int(season), '%01d' % int(episode)\n\n result = client.source(url)\n\n if not season == '1':\n url = client.parseDOM(result, 'a', ret='href', attrs = {'class': 'season-.+?'})\n url = [i for i in url if '/%s-sezon-' % season in i][0]\n result = client.source(url)\n\n result = client.parseDOM(result, 'a', ret='href')\n result = [i for i in result if '%s-sezon-%s-bolum-' % (season, episode) in i][0]\n\n try: url = re.compile('//.+?(/.+)').findall(result)[0]\n except: url = result\n url = client.replaceHTMLCodes(url)\n url = url.encode('utf-8')\n return url\n except:\n return", "metadata": "root.source.get_episode", "header": "['class', 'source', ':', '___EOS___']", "index": 65 }, { "content": " def get_sources(self, url, hosthdDict, hostDict, locDict):\n try:\n sources = []\n\n if url == None: return sources\n\n sources_url = urlparse.urljoin(self.base_link, url)\n\n result = client.source(sources_url, close=False)\n result = re.sub(r'[^\\x00-\\x7F]+','', result)\n\n result = re.compile('(<option.*?</option>)', re.DOTALL).findall(result)\n result = [(client.parseDOM(i, 'option', ret='href'), client.parseDOM(i, 'option', ret='value'), client.parseDOM(i, 'option')) for i in result]\n result = [i[0] + i[1] for i in result if len(i[2]) > 0 and i[2][0] == 'Altyazsz'][0][0]\n\n url = urlparse.urljoin(self.base_link, result)\n\n result = client.source(url, close=False)\n\n url = client.parseDOM(result, 'span', attrs = {'class': 'object-wrapper'})[0]\n url = client.parseDOM(url, 'iframe', ret='src')[0]\n url = client.replaceHTMLCodes(url)\n\n result = client.source(url, close=False)\n\n try:\n r = re.compile('\"?file\"?\\s*:\\s*\"([^\"]+)\"\\s*,\\s*\"?label\"?\\s*:\\s*\"(\\d+)p?\"').findall(result)\n if r == []: raise Exception()\n r = [(i[0].replace('\\\\/', '/').replace('\\\\&', '&').decode('unicode_escape'), int(i[1])) for i in r]\n\n u = [('%s|User-Agent=%s&Referer=%s' % (i[0], urllib.quote_plus(client.agent()), urllib.quote_plus(sources_url)), i[1], 'Dizibox') for i in r if not 'google' in i[0]]\n u += [(i[0], i[1], 'GVideo') for i in r if 'google' in i[0]]\n\n try: sources.append({'source': [i[2] for i in u if i[1] >= 1080][0], 'quality': '1080p', 'provider': 'Dizibox', 'url': [i[0] for i in u if i[1] >= 1080][0]})\n except: pass\n try: sources.append({'source': [i[2] for i in u if 720 <= i[1] < 1080][0], 'quality': 'HD', 'provider': 'Dizibox', 'url': [i[0] for i in u if 720 <= i[1] < 1080][0]})\n except: pass\n try: sources.append({'source': [i[2] for i in u if i[1] < 720][0], 'quality': 'SD', 'provider': 'Dizibox', 'url': [i[0] for i in u if i[1] < 720][0]})\n except: pass\n\n return sources\n except:\n pass\n\n try:\n if '.dizibox.' in url: url = re.compile('location\\.href\\s*=\\s*\"(.+?)\"').findall(result)[0]\n\n host = urlparse.urlparse(url).netloc\n host = host.replace('mail.ru', 'mailru.ru').rsplit('.', 1)[0].split('.')[-1].lower()\n\n strm = resolvers.request(url)\n if strm == url or strm == None: raise Exception()\n\n if type(strm) == list:\n for i in strm: sources.append({'source': host, 'quality': i['quality'], 'provider': 'Dizibox', 'url': i['url']})\n else:\n sources.append({'source': host, 'quality': 'HD', 'provider': 'Dizibox', 'url': strm})\n\n return sources\n except:\n pass\n\n except:\n return sources", "metadata": "root.source.get_sources", "header": "['class', 'source', ':', '___EOS___']", "index": 92 } ]
[ { "span": "url == None:", "start_line": 67, "start_column": 15, "end_line": 67, "end_column": 26 }, { "span": "url == None:", "start_line": 96, "start_column": 15, "end_line": 96, "end_column": 26 }, { "span": "strm == None:", "start_line": 143, "start_column": 34, "end_line": 143, "end_column": 46 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "class_", "source_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "episode_", "(_", "self_", ",_", "url_", ",_", "imdb_", ",_", "tvdb", "_", ",_", "title_", ",_", "date_", ",_", "season_", ",_", "episode_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "url_", "==_", "None_", ":_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "urlparse_", "._", "urljoin_", "(_", "self_", "._", "base", "\\u", "link_", ",_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "season_", ",_", "episode_", "=_", "'%", "01", "d", "'_", "%_", "int_", "(_", "season_", ")_", ",_", "'%", "01", "d", "'_", "%_", "int_", "(_", "episode_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "client_", "._", "source_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "season_", "==_", "'", "1", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", "=_", "client_", "._", "parse", "DOM_", "(_", "result_", ",_", "'", "a", "'_", ",_", "ret_", "=_", "'", "href", "'_", ",_", "attrs_", "=_", "{_", "'", "class", "'_", ":_", "'", "season", "-.", "+?", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "[_", "i_", "for_", "i_", "in_", "url_", "if_", "'/", "%", "s", "-", "se", "zon", "-'_", "%_", "season_", "in_", "i_", "]_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "client_", "._", "source_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "=_", "client_", "._", "parse", "DOM_", "(_", "result_", ",_", "'", "a", "'_", ",_", "ret_", "=_", "'", "href", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "[_", "i_", "for_", "i_", "in_", "result_", "if_", "'%", "s", "-", "se", "zon", "-%", "s", "-", "bol", "um", "-'_", "%_", "(_", "season_", ",_", "episode_", ")_", "in_", "i_", "]_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "url_", "=_", "re_", "._", "compile_", "(_", "'//", ".+?", "(/", ".+)", "'_", ")_", "._", "findall_", "(_", "result_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "url_", "=_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "client_", "._", "replace", "HTM", "LC", "odes_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "url_", "._", "encode_", "(_", "'", "utf", "-", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\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]_", "class_", "source_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "sources_", "(_", "self_", ",_", "url_", ",_", "host", "hd", "Dict_", ",_", "host", "Dict_", ",_", "loc", "Dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sources_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "url_", "==_", "None_", ":_", "return_", "sources_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "source", "s", "\\u", "url_", "=_", "urlparse_", "._", "urljoin_", "(_", "self_", "._", "base", "\\u", "link_", ",_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "client_", "._", "source_", "(_", "source", "s", "\\u", "url_", ",_", "close_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "re_", "._", "sub_", "(_", "r", "'[", "^", "\\\\", "x0", "0", "-\\\\", "x", "7", "F", "]+'_", ",_", "''_", ",_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "re_", "._", "compile_", "(_", "'(", "<", "option", ".*?", "</", "option", ">)", "'_", ",_", "re_", "._", "DOTALL_", ")_", "._", "findall_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "[_", "(_", "client_", "._", "parse", "DOM_", "(_", "i_", ",_", "'", "option", "'_", ",_", "ret_", "=_", "'", "href", "'_", ")_", ",_", "client_", "._", "parse", "DOM_", "(_", "i_", ",_", "'", "option", "'_", ",_", "ret_", "=_", "'", "value", "'_", ")_", ",_", "client_", "._", "parse", "DOM_", "(_", "i_", ",_", "'", "option", "'_", ")_", ")_", "for_", "i_", "in_", "result_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "[_", "i_", "[_", "0_", "]_", "+_", "i_", "[_", "1_", "]_", "for_", "i_", "in_", "result_", "if_", "len_", "(_", "i_", "[_", "2_", "]_", ")_", ">_", "0_", "and_", "i_", "[_", "2_", "]_", "[_", "0_", "]_", "==_", "'", "Alt", "ya", "zs", "z", "'_", "]_", "[_", "0_", "]_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "urlparse_", "._", "urljoin_", "(_", "self_", "._", "base", "\\u", "link_", ",_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "client_", "._", "source_", "(_", "url_", ",_", "close_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "client_", "._", "parse", "DOM_", "(_", "result_", ",_", "'", "span", "'_", ",_", "attrs_", "=_", "{_", "'", "class", "'_", ":_", "'", "object", "-", "wrapp", "er", "'_", "}_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "client_", "._", "parse", "DOM_", "(_", "url_", ",_", "'", "iframe", "'_", ",_", "ret_", "=_", "'", "src", "'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "client_", "._", "replace", "HTM", "LC", "odes_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "client_", "._", "source_", "(_", "url_", ",_", "close_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", "=_", "re_", "._", "compile_", "(_", "'\"", "?", "file", "\"?", "\\\\", "s", "*:", "\\\\", "s", "*\"", "([", "^", "\"]+", ")\"", "\\\\", "s", "*", ",\\\\", "s", "*\"", "?", "label", "\"?", "\\\\", "s", "*:", "\\\\", "s", "*\"", "(\\\\", "d", "+)", "p", "?\"", "'_", ")_", "._", "findall_", "(_", "result_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "r_", "==_", "[_", "]_", ":_", "raise_", "Exception_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "r_", "=_", "[_", "(_", "i_", "[_", "0_", "]_", "._", "replace_", "(_", "'\\\\\\\\", "/'_", ",_", "'/'_", ")_", "._", "replace_", "(_", "'\\\\\\\\", "&'_", ",_", "'&'_", ")_", "._", "decode_", "(_", "'", "unicode", "\\u", "escape", "'_", ")_", ",_", "int_", "(_", "i_", "[_", "1_", "]_", ")_", ")_", "for_", "i_", "in_", "r_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "u_", "=_", "[_", "(_", "'%", "s", "|", "User", "-", "Agent", "=", "%", "s", "&", "Refer", "er", "=", "%", "s", "'_", "%_", "(_", "i_", "[_", "0_", "]_", ",_", "urllib_", "._", "quote", "\\u", "plus_", "(_", "client_", "._", "agent_", "(_", ")_", ")_", ",_", "urllib_", "._", "quote", "\\u", "plus_", "(_", "source", "s", "\\u", "url_", ")_", ")_", ",_", "i_", "[_", "1_", "]_", ",_", "'", "Di", "zi", "box", "'_", ")_", "for_", "i_", "in_", "r_", "if_", "not_", "'", "google", "'_", "in_", "i_", "[_", "0_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "u_", "+=_", "[_", "(_", "i_", "[_", "0_", "]_", ",_", "i_", "[_", "1_", "]_", ",_", "'", "GV", "ideo", "'_", ")_", "for_", "i_", "in_", "r_", "if_", "'", "google", "'_", "in_", "i_", "[_", "0_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "sources_", "._", "append_", "(_", "{_", "'", "source", "'_", ":_", "[_", "i_", "[_", "2_", "]_", "for_", "i_", "in_", "u_", "if_", "i_", "[_", "1_", "]_", ">=_", "1080", "_", "]_", "[_", "0_", "]_", ",_", "'", "quali", "ty", "'_", ":_", "'", "1080", "p", "'_", ",_", "'", "provide", "r", "'_", ":_", "'", "Di", "zi", "box", "'_", ",_", "'", "url", "'_", ":_", "[_", "i_", "[_", "0_", "]_", "for_", "i_", "in_", "u_", "if_", "i_", "[_", "1_", "]_", ">=_", "1080", "_", "]_", "[_", "0_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "sources_", "._", "append_", "(_", "{_", "'", "source", "'_", ":_", "[_", "i_", "[_", "2_", "]_", "for_", "i_", "in_", "u_", "if_", "720_", "<=_", "i_", "[_", "1_", "]_", "<_", "1080", "_", "]_", "[_", "0_", "]_", ",_", "'", "quali", "ty", "'_", ":_", "'", "HD", "'_", ",_", "'", "provide", "r", "'_", ":_", "'", "Di", "zi", "box", "'_", ",_", "'", "url", "'_", ":_", "[_", "i_", "[_", "0_", "]_", "for_", "i_", "in_", "u_", "if_", "720_", "<=_", "i_", "[_", "1_", "]_", "<_", "1080", "_", "]_", "[_", "0_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "sources_", "._", "append_", "(_", "{_", "'", "source", "'_", ":_", "[_", "i_", "[_", "2_", "]_", "for_", "i_", "in_", "u_", "if_", "i_", "[_", "1_", "]_", "<_", "720_", "]_", "[_", "0_", "]_", ",_", "'", "quali", "ty", "'_", ":_", "'", "SD", "'_", ",_", "'", "provide", "r", "'_", ":_", "'", "Di", "zi", "box", "'_", ",_", "'", "url", "'_", ":_", "[_", "i_", "[_", "0_", "]_", "for_", "i_", "in_", "u_", "if_", "i_", "[_", "1_", "]_", "<_", "720_", "]_", "[_", "0_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "except_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "sources_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'.", "di", "zi", "box", ".'_", "in_", "url_", ":_", "url_", "=_", "re_", "._", "compile_", "(_", "'", "location", "\\\\.", "href", "\\\\", "s", "*=", "\\\\", "s", "*\"", "(.+?)", "\"'_", ")_", "._", "findall_", "(_", "result_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "host_", "=_", "urlparse_", "._", "urlparse_", "(_", "url_", ")_", "._", "netloc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "host_", "=_", "host_", "._", "replace_", "(_", "'", "mail", ".", "ru", "'_", ",_", "'", "mail", "ru", ".", "ru", "'_", ")_", "._", "rsplit_", "(_", "'.'_", ",_", "1_", ")_", "[_", "0_", "]_", "._", "split_", "(_", "'.'_", ")_", "[_", "-_", "1_", "]_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "strm", "_", "=_", "resolver", "s_", "._", "request_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "strm", "_", "==_", "url_", "or_", "strm", "_", "==_", "None_", ":_", "raise_", "Exception_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "type_", "(_", "strm", "_", ")_", "==_", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "for_", "i_", "in_", "strm", "_", ":_", "sources_", "._", "append_", "(_", "{_", "'", "source", "'_", ":_", "host_", ",_", "'", "quali", "ty", "'_", ":_", "i_", "[_", "'", "quali", "ty", "'_", "]_", ",_", "'", "provide", "r", "'_", ":_", "'", "Di", "zi", "box", "'_", ",_", "'", "url", "'_", ":_", "i_", "[_", "'", "url", "'_", "]_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "sources_", "._", "append_", "(_", "{_", "'", "source", "'_", ":_", "host_", ",_", "'", "quali", "ty", "'_", ":_", "'", "HD", "'_", ",_", "'", "provide", "r", "'_", ":_", "'", "Di", "zi", "box", "'_", ",_", "'", "url", "'_", ":_", "strm", "_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "sources_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "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_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "sources_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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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, 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 ]
Testing equality to None
hgascon/pulsar/pulsar/core/sippy/SipURL.py
[ { "content": " def __init__(self, url = None, username = None, password = None, host = None, port = None, headers = None, \\\n usertype = None, transport = None, ttl = None, maddr = None, method = None, tag = None, other = None, \\\n userparams = None, lr = False):\n self.other = []\n self.userparams = []\n if url == None:\n self.username = username\n if userparams != None:\n self.userparams = userparams\n self.password = password\n if host == None:\n self.host = SipConf.my_address\n self.port = SipConf.my_port\n else:\n self.host = host\n self.port = port\n self.headers = headers\n self.usertype = usertype\n self.transport = transport\n self.ttl = ttl\n self.maddr = maddr\n self.method = method\n self.tag = tag\n if other != None:\n self.other = other\n self.lr = lr\n return\n if not url.lower().startswith('sip:'):\n raise ValueError('unsupported scheme: ' + url[:4])\n url = url[4:]\n ear = url.find('@') + 1\n parts = url[ear:].split(';')\n userdomain, params = url[0:ear] + parts[0], parts[1:]\n if len(params) == 0 and '?' in userdomain:\n self.headers = {}\n userdomain, headers = userdomain.split('?', 1)\n for header in headers.split('&'):\n k, v = header.split('=')\n self.headers[k.lower()] = unquote(v)\n udparts = userdomain.split('@', 1)\n if len(udparts) == 2:\n userpass, hostport = udparts\n upparts = userpass.split(':', 1)\n if len(upparts) > 1:\n self.password = upparts[1]\n uparts = upparts[0].split(';')\n if len(uparts) > 1:\n self.userparams = uparts[1:]\n self.username = unquote(uparts[0])\n else:\n hostport = udparts[0]\n if hostport[0] == '[':\n # IPv6 host\n hpparts = hostport.split(']', 1)\n self.host = hpparts[0] + ']'\n if len(hpparts[1]) > 0:\n hpparts = hpparts[1].split(':', 1)\n if len(hpparts) > 1:\n self.port = int(hpparts[1])\n else:\n # IPv4 host\n hpparts = hostport.split(':', 1)\n if len(hpparts) == 1:\n self.host = hpparts[0]\n else:\n self.host = hpparts[0]\n self.port = int(hpparts[1])\n for p in params:\n if p == params[-1] and '?' in p:\n self.headers = {}\n p, headers = p.split('?', 1)\n for header in headers.split('&'):\n k, v = header.split('=')\n self.headers[k.lower()] = unquote(v)\n nv = p.split('=', 1)\n if len(nv) == 1:\n if p == 'lr':\n self.lr = True\n else:\n self.other.append(p)\n continue\n name, value = nv\n if name == 'user':\n self.usertype = value\n elif name == 'transport':\n self.transport = value\n elif name == 'ttl':\n self.ttl = int(value)\n elif name == 'maddr':\n self.maddr = value\n elif name == 'method':\n self.method = value\n elif name == 'tag':\n self.tag = value\n elif name == 'lr':\n # RFC 3261 doesn't allow lr parameter to have a value,\n # but many stupid implementation do it anyway\n self.lr = True\n else:\n self.other.append(p)", "metadata": "root.SipURL.__init__", "header": "['class', 'SipURL', '(', 'object', ')', ':', '___EOS___']", "index": 43 } ]
[ { "span": "url == None:", "start_line": 48, "start_column": 11, "end_line": 48, "end_column": 22 }, { "span": "host == None:", "start_line": 53, "start_column": 15, "end_line": 53, "end_column": 27 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "class_", "Si", "p", "URL_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "url_", "=_", "None_", ",_", "username_", "=_", "None_", ",_", "password_", "=_", "None_", ",_", "host_", "=_", "None_", ",_", "port_", "=_", "None_", ",_", "headers_", "=_", "None_", ",_", "usert", "ype_", "=_", "None_", ",_", "transport_", "=_", "None_", ",_", "ttl_", "=_", "None_", ",_", "mad", "dr_", "=_", "None_", ",_", "method_", "=_", "None_", ",_", "tag_", "=_", "None_", ",_", "other_", "=_", "None_", ",_", "userp", "arams_", "=_", "None_", ",_", "lr_", "=_", "False_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "other_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "userp", "arams_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "url_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "username_", "=_", "username_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "userp", "arams_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "userp", "arams_", "=_", "userp", "arams_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "password_", "=_", "password_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "host_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "host_", "=_", "Si", "p", "Conf_", "._", "my", "\\u", "address_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "port_", "=_", "Si", "p", "Conf_", "._", "my", "\\u", "port_", "\\u\\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_", "._", "host_", "=_", "host_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "port_", "=_", "port_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "headers_", "=_", "headers_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "usert", "ype_", "=_", "usert", "ype_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "transport_", "=_", "transport_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "ttl_", "=_", "ttl_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "mad", "dr_", "=_", "mad", "dr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "method_", "=_", "method_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "tag_", "=_", "tag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "other_", "!=_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "other_", "=_", "other_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "lr_", "=_", "lr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "url_", "._", "lower_", "(_", ")_", "._", "startswith_", "(_", "'", "sip", ":'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'", "unsup", "porte", "d", " ", "sche", "me", ":", " ", "'_", "+_", "url_", "[_", ":_", "4_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "url_", "=_", "url_", "[_", "4_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ear_", "=_", "url_", "._", "find_", "(_", "'@'_", ")_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parts_", "=_", "url_", "[_", "ear_", ":_", "]_", "._", "split_", "(_", "';'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "userd", "omain", "_", ",_", "params_", "=_", "url_", "[_", "0_", ":_", "ear_", "]_", "+_", "parts_", "[_", "0_", "]_", ",_", "parts_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "params_", ")_", "==_", "0_", "and_", "'?'_", "in_", "userd", "omain", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "headers_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "userd", "omain", "_", ",_", "headers_", "=_", "userd", "omain", "_", "._", "split_", "(_", "'?'_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "header_", "in_", "headers_", "._", "split_", "(_", "'&'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "k_", ",_", "v_", "=_", "header_", "._", "split_", "(_", "'='_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "headers_", "[_", "k_", "._", "lower_", "(_", ")_", "]_", "=_", "unquote_", "(_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ud", "parts_", "=_", "userd", "omain", "_", "._", "split_", "(_", "'@'_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "ud", "parts_", ")_", "==_", "2_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "userp", "ass_", ",_", "hostp", "ort_", "=_", "ud", "parts_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "upp", "arts", "_", "=_", "userp", "ass_", "._", "split_", "(_", "':'_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "upp", "arts", "_", ")_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "password_", "=_", "upp", "arts", "_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "upa", "rts_", "=_", "upp", "arts", "_", "[_", "0_", "]_", "._", "split_", "(_", "';'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "upa", "rts_", ")_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "userp", "arams_", "=_", "upa", "rts_", "[_", "1_", ":_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "username_", "=_", "unquote_", "(_", "upa", "rts_", "[_", "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 ", " _", "hostp", "ort_", "=_", "ud", "parts_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "hostp", "ort_", "[_", "0_", "]_", "==_", "'['_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "IP", "v6", " ", "host_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hp", "parts_", "=_", "hostp", "ort_", "._", "split_", "(_", "']'_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "host_", "=_", "hp", "parts_", "[_", "0_", "]_", "+_", "']'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "hp", "parts_", "[_", "1_", "]_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hp", "parts_", "=_", "hp", "parts_", "[_", "1_", "]_", "._", "split_", "(_", "':'_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "hp", "parts_", ")_", ">_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "port_", "=_", "int_", "(_", "hp", "parts_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "IP", "v", "4", " ", "host_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hp", "parts_", "=_", "hostp", "ort_", "._", "split_", "(_", "':'_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "hp", "parts_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "host_", "=_", "hp", "parts_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "host_", "=_", "hp", "parts_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "port_", "=_", "int_", "(_", "hp", "parts_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "p_", "in_", "params_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "p_", "==_", "params_", "[_", "-_", "1_", "]_", "and_", "'?'_", "in_", "p_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "headers_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "p_", ",_", "headers_", "=_", "p_", "._", "split_", "(_", "'?'_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "header_", "in_", "headers_", "._", "split_", "(_", "'&'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "k_", ",_", "v_", "=_", "header_", "._", "split_", "(_", "'='_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "headers_", "[_", "k_", "._", "lower_", "(_", ")_", "]_", "=_", "unquote_", "(_", "v_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "nv_", "=_", "p_", "._", "split_", "(_", "'='_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "nv_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "p_", "==_", "'", "lr", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "lr_", "=_", "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 ", " ", "_", "self_", "._", "other_", "._", "append_", "(_", "p_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "name_", ",_", "value_", "=_", "nv_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "name_", "==_", "'", "user", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "usert", "ype_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "name_", "==_", "'", "transport", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "transport_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "name_", "==_", "'", "ttl", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ttl_", "=_", "int_", "(_", "value_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "name_", "==_", "'", "mad", "dr", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "mad", "dr_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "name_", "==_", "'", "method", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "method_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "name_", "==_", "'", "tag", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "tag_", "=_", "value_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "name_", "==_", "'", "lr", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "RF", "C", " ", "326", "1", " ", "doe", "sn", "'", "t", " ", "allow", " ", "lr", " ", "parameter", " ", "to", " ", "have", " ", "a", " ", "value", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "but", " ", "many", " ", "stu", "pid", " ", "implementation", " ", "do", " ", "it", " ", "anyway", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "lr_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
lisa-lab/pylearn2/pylearn2/sandbox/cuda_convnet/pool.py
[ { "content": "\"\"\"\n.. todo::\n\n WRITEME\n\"\"\"\nimport warnings\n\nfrom theano.gof import Apply\nfrom theano.sandbox.cuda import CudaNdarrayType\nfrom theano.sandbox.cuda.basic_ops import as_cuda_ndarray_variable\nfrom theano.sandbox.cuda.basic_ops import gpu_contiguous\nfrom theano.sandbox.cuda import GpuOp\nfrom theano.tensor import get_scalar_constant_value, NotScalarConstantError\n\nfrom pylearn2.sandbox.cuda_convnet.base_acts import UnimplementedError\nfrom pylearn2.sandbox.cuda_convnet.convnet_compile import convnet_available\nfrom pylearn2.sandbox.cuda_convnet.convnet_compile import cuda_convnet_loc\nfrom pylearn2.sandbox.cuda_convnet.shared_code import this_dir\n\nimport pylearn2.sandbox.cuda_convnet.pthreads\nfrom theano import config\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def max_pool_c01b(c01b, pool_shape, pool_stride, image_shape = None, start=0):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n assert pool_shape[0] == pool_shape[1]\n assert pool_shape[0] > 0\n assert pool_stride[0] > 0\n assert pool_stride[0] <= pool_shape[0]\n if pool_stride[0] != pool_stride[1]:\n raise ValueError(\"pool strides must match, but got \"+str(pool_stride))\n if image_shape is not None:\n warnings.warn(\"image_shape argument isn't needed anymore, quit passing it.\")\n op = MaxPool(pool_shape[0], pool_stride[0], start)\n c01b = gpu_contiguous(c01b)\n return op(c01b)", "metadata": "root.max_pool_c01b", "header": "['module', '___EOS___']", "index": 22 }, { "content": "class MaxPool(GpuOp):\n \"\"\"\n This op wrap Alex's MaxPool code on the GPU.\n The input are in the order (channel, image rows, image cols, batch)\n\n Works only on square images and the grad works only when\n channel % 16 == 0.\n\n Parameters\n ----------\n ds : int\n Defines the size of the pooling region in the x (equivalently, y)\n dimension. Squares of size (ds)2 get reduced to one value by\n this layer. There are no restrictions on the value of this\n parameter. It's fine for a pooling square to fall off the\n boundary of the image. Named SizeX in Alex's code.\n stride : int\n Defines the stride size between successive pooling squares.\n Setting this parameter smaller than sizeX produces overlapping\n pools. Setting it equal to sizeX gives the usual, non-overlapping\n pools. Values greater than sizeX are not allowed.\n start : int, optional\n Tells the net where in the input image to start the pooling\n (in x,y coordinates). In principle, you can start anywhere you\n want. Setting this to a positive number will cause the net to\n discard some pixels at the top and at the left of the image.\n Setting this to a negative number will cause it to include\n pixels that don't exist (which is fine). start=0 is the usual\n setting.\n outputs : int, optional\n Allows you to control how many output values in the x\n (equivalently, y) dimension this operation will produce. This\n parameter is analogous to the start parameter, in that it\n allows you to discard some portion of the image by setting it\n to a value small enough to leave part of the image uncovered.\n Setting it to zero instructs the net to produce as many outputs\n as is necessary to ensure that the whole image is covered.\n default 0\n \"\"\"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n # Make sure the cuda_convnet library is compiled and up-to-date", "metadata": "root.MaxPool", "header": "['module', '___EOS___']", "index": 41 }, { "content": " def __init__(self, ds, stride, start=0, outputs=0):\n self.ds = ds\n self.stride = stride\n self.start = start\n self.copy_non_contiguous = 0\n assert stride > 0 and stride <= ds, (stride, ds)\n assert ds > 0, ds # We check in the code if ds <= imgSizeX", "metadata": "root.MaxPool.__init__", "header": "['class', 'MaxPool', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 81 }, { "content": " def __eq__(self, other):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n #Dont put copy_non_contigous as this doesn't change the output\n return (type(self) == type(other) and\n self.ds == other.ds and\n self.stride == other.stride and\n self.start == other.start)", "metadata": "root.MaxPool.__eq__", "header": "['class', 'MaxPool', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 89 }, { "content": " def __hash__(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n #Dont put copy_non_contigous as this doesn't change the output\n return (hash(type(self)) ^ hash(self.ds) ^\n hash(self.stride) ^ hash(self.start))", "metadata": "root.MaxPool.__hash__", "header": "['class', 'MaxPool', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 101 }, { "content": " def c_header_dirs(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return [this_dir, config.pthreads.inc_dir] if config.pthreads.inc_dir else [this_dir]", "metadata": "root.MaxPool.c_header_dirs", "header": "['class', 'MaxPool', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 111 }, { "content": " def c_headers(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return ['nvmatrix.cuh', 'conv_util.cuh']", "metadata": "root.MaxPool.c_headers", "header": "['class', 'MaxPool', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 119 }, { "content": " def c_lib_dirs(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return [cuda_convnet_loc, config.pthreads.lib_dir] if config.pthreads.lib_dir else [cuda_convnet_loc]", "metadata": "root.MaxPool.c_lib_dirs", "header": "['class', 'MaxPool', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 127 }, { "content": " def c_libraries(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return ['cuda_convnet', config.pthreads.lib] if config.pthreads.lib else ['cuda_convnet']", "metadata": "root.MaxPool.c_libraries", "header": "['class', 'MaxPool', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 135 }, { "content": " def c_code_cache_version(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return (1,)", "metadata": "root.MaxPool.c_code_cache_version", "header": "['class', 'MaxPool', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 143 }, { "content": " def _argument_contiguity_check(self, arg_name):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return \"\"\"\n if (!CudaNdarray_is_c_contiguous(%%(%(arg_name)s)s))\n {\n if (!(%(class_name_caps)s_COPY_NON_CONTIGUOUS)) {\n PyErr_SetString(PyExc_ValueError,\n \"%(class)s: %(arg_name)s must be C contiguous\");\n %%(fail)s;\n }\n }\n \"\"\" % {\n 'class': self.__class__.__name__,\n 'arg_name': arg_name,\n 'class_name_caps': self.__class__.__name__.upper(),\n }", "metadata": "root.MaxPool._argument_contiguity_check", "header": "['class', 'MaxPool', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 151 }, { "content": " def make_node(self, images):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n images = as_cuda_ndarray_variable(images)\n\n assert images.ndim == 4\n\n channels_broadcastable = images.type.broadcastable[0]\n batch_broadcastable = images.type.broadcastable[3]\n\n rows_broadcastable = False\n cols_broadcastable = False\n\n targets_broadcastable = (channels_broadcastable, rows_broadcastable,\n cols_broadcastable, batch_broadcastable)\n targets_type = CudaNdarrayType(broadcastable=targets_broadcastable)\n targets = targets_type()\n\n return Apply(self, [images], [targets])", "metadata": "root.MaxPool.make_node", "header": "['class', 'MaxPool', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 172 }, { "content": " def c_code(self, node, name, inputs, outputs, sub):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n images, = inputs\n targets, = outputs\n fail = sub['fail']\n\n # The amount of braces that must be closed at the end\n num_braces = 0\n\n if self.copy_non_contiguous:\n raise UnimplementedError()\n else:\n basic_setup = \"#define MAXPOOL_COPY_NON_CONTIGUOUS 0\\n\"\n\n # Convert images in nv_images, an NVMatrix, for compatibility\n # with the cuda-convnet functions\n setup_nv_images = self._argument_contiguity_check(\"images\") + \"\"\"\n if (%(images)s->nd != 4)\n {\n PyErr_Format(PyExc_ValueError,\n \"images must have nd=4, got nd=%%i\", %(images)s->nd);\n %(fail)s;\n }\n\n { //setup_nv_images brace 1\n\n const int * images_dims = CudaNdarray_HOST_DIMS(%(images)s);\n const int img_channels = images_dims[0];\n const int imgSizeY = images_dims[1];\n const int imgSizeX = images_dims[2];\n const int batch_size = images_dims[3];\n\n if(imgSizeY != imgSizeX){\n PyErr_Format(PyExc_ValueError,\n \"images must be square(dims[1] == dims[2]). Shape (%%i,%%i,%%i,%%i)\",\n img_channels, imgSizeY, imgSizeX, batch_size);\n %(fail)s;\n }\n if(%(ds)s > imgSizeY){\n PyErr_Format(PyExc_ValueError,\n \"ds(%%d) must be <= imgSizeX(%%d) and imgSizeY(%%d).\",\n %(ds)s, imgSizeX, imgSizeY);\n %(fail)s;\n }\n if(%(start)s >= imgSizeX){\n PyErr_Format(PyExc_ValueError,\n \"start is %%d but must be smaller then the images size of %%d x %%d.\",\n %(start)s, imgSizeX, imgSizeY);\n %(fail)s;\n }\n\n NVMatrix nv_images(%(images)s, img_channels * imgSizeY * imgSizeX, batch_size,\n \"MaxPool:nv_images\");\n \"\"\"\n num_braces += 1\n\n setup_nv_targets = \"\"\"\n //int _outputsX = int(ceil((dic['imgSize'] - dic['start'] - dic['sizeX']) / float(dic['stride']))) + 1;\n int _outputsX = ((int)(ceil((imgSizeY - %(start)s - %(ds)s) / ((float)%(stride)s)))) + 1;\n\n int target_dims [] = {\n img_channels,\n _outputsX,\n _outputsX,\n batch_size };\n\n if (CudaNdarray_prep_output(& %(targets)s, 4, target_dims))\n {\n %(fail)s;\n }\n\n { // setup_nv_target brace # 1\n\n NVMatrix nv_targets(%(targets)s, target_dims[0] * target_dims[1] * target_dims[2],\n target_dims[3], \"MaxPool:nv_targets\");\n\n \"\"\"\n\n num_braces += 1\n\n do_pool = \"\"\"\n convLocalPool(nv_images, nv_targets, img_channels, %(ds)s,\n %(start)s, %(stride)s, _outputsX, MaxPooler());\n \"\"\"\n\n braces = '}' * num_braces\n\n rval = (basic_setup +\n setup_nv_images +\n setup_nv_targets +\n do_pool +\n braces)\n start = self.start\n stride = self.stride\n ds = self.ds\n rval = rval % locals()\n\n return rval", "metadata": "root.MaxPool.c_code", "header": "['class', 'MaxPool', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 195 }, { "content": " def R_op(self, inp, evals):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n x, = inp\n ev, = evals\n if ev is not None:\n ev = gpu_contiguous(ev)\n return [MaxPoolRop(self.ds, self.stride, self.start)(x, ev)]\n else:\n return [None]", "metadata": "root.MaxPool.R_op", "header": "['class', 'MaxPool', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 298 }, { "content": " def grad(self, inp, grads):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n x, = inp\n gz, = grads\n gz = gpu_contiguous(gz)\n maxout = self(x)\n return [MaxPoolGrad(self.ds, self.stride, self.start)(x, maxout, gz)]", "metadata": "root.MaxPool.grad", "header": "['class', 'MaxPool', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 313 }, { "content": " def make_thunk(self, node, storage_map, compute_map, no_recycling):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n if not convnet_available():\n raise RuntimeError('Could not compile cuda_convnet')\n\n return super(MaxPool, self).make_thunk(\n node, storage_map, compute_map, no_recycling)", "metadata": "root.MaxPool.make_thunk", "header": "['class', 'MaxPool', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 326 }, { "content": "class MaxPoolRop(GpuOp):\n \"\"\"\n This op wrap Alex's MaxPool code on the GPU.\n The input are in the order (channel, image rows, image cols, batch)\n\n Works only on square images and the grad works only when\n channel % 16 == 0.\n\n Parameters\n ----------\n ds : int\n Defines the size of the pooling region in the x (equivalently, y)\n dimension. Squares of size (ds)2 get reduced to one value by\n this layer. There are no restrictions on the value of this\n parameter. It's fine for a pooling square to fall off the\n boundary of the image. Named SizeX in Alex's code.\n stride : int\n Defines the stride size between successive pooling squares.\n Setting this parameter smaller than sizeX produces overlapping\n pools. Setting it equal to sizeX gives the usual, non-overlapping\n pools. Values greater than sizeX are not allowed.\n start : int, optional\n Tells the net where in the input image to start the pooling\n (in x,y coordinates). In principle, you can start anywhere you\n want. Setting this to a positive number will cause the net to\n discard some pixels at the top and at the left of the image.\n Setting this to a negative number will cause it to include\n pixels that don't exist (which is fine). start=0 is the usual\n setting.\n outputs : int, optional\n Allows you to control how many output values in the x\n (equivalently, y) dimension this operation will produce. This\n parameter is analogous to the start parameter, in that it\n allows you to discard some portion of the image by setting it\n to a value small enough to leave part of the image uncovered.\n Setting it to zero instructs the net to produce as many outputs\n as is necessary to ensure that the whole image is covered.\n default 0\n \"\"\"\n\n\n\n\n\n\n\n\n\n\n\n\n # Make sure the cuda_convnet library is compiled and up-to-date", "metadata": "root.MaxPoolRop", "header": "['module', '___EOS___']", "index": 339 }, { "content": " def __init__(self, ds, stride, start=0, outputs=0):\n self.ds = ds\n self.stride = stride\n self.start = start\n self.copy_non_contiguous = 0\n assert stride > 0 and stride <= ds, (stride, ds)\n assert ds > 0, ds # We check in the code if ds <= imgSizeX", "metadata": "root.MaxPoolRop.__init__", "header": "['class', 'MaxPoolRop', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 379 }, { "content": " def __eq__(self, other):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n #Dont put copy_non_contigous as this doesn't change the output\n return (type(self) == type(other) and\n self.ds == other.ds and\n self.stride == other.stride and\n self.start == other.start)", "metadata": "root.MaxPoolRop.__eq__", "header": "['class', 'MaxPoolRop', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 387 }, { "content": " def __hash__(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n #Dont put copy_non_contigous as this doesn't change the output\n return (hash(type(self)) ^ hash(self.ds) ^\n hash(self.stride) ^ hash(self.start))", "metadata": "root.MaxPoolRop.__hash__", "header": "['class', 'MaxPoolRop', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 399 }, { "content": " def c_header_dirs(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return [this_dir]", "metadata": "root.MaxPoolRop.c_header_dirs", "header": "['class', 'MaxPoolRop', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 409 }, { "content": " def c_headers(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return ['nvmatrix.cuh', 'conv_util.cuh', 'pool_rop.cuh']", "metadata": "root.MaxPoolRop.c_headers", "header": "['class', 'MaxPoolRop', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 417 }, { "content": " def c_lib_dirs(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return [cuda_convnet_loc]", "metadata": "root.MaxPoolRop.c_lib_dirs", "header": "['class', 'MaxPoolRop', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 425 }, { "content": " def c_libraries(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return ['cuda_convnet']", "metadata": "root.MaxPoolRop.c_libraries", "header": "['class', 'MaxPoolRop', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 433 }, { "content": " def c_code_cache_version(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return (1,)", "metadata": "root.MaxPoolRop.c_code_cache_version", "header": "['class', 'MaxPoolRop', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 441 }, { "content": " def _argument_contiguity_check(self, arg_name):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return \"\"\"\n if (!CudaNdarray_is_c_contiguous(%%(%(arg_name)s)s))\n {\n if (!(%(class_name_caps)s_COPY_NON_CONTIGUOUS)) {\n PyErr_SetString(PyExc_ValueError,\n \"%(class)s: %(arg_name)s must be C contiguous\");\n %%(fail)s;\n }\n }\n \"\"\" % {\n 'class': self.__class__.__name__,\n 'arg_name': arg_name,\n 'class_name_caps': self.__class__.__name__.upper(),\n }", "metadata": "root.MaxPoolRop._argument_contiguity_check", "header": "['class', 'MaxPoolRop', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 449 }, { "content": " def make_node(self, images, evals):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n images = as_cuda_ndarray_variable(images)\n evals = as_cuda_ndarray_variable(evals)\n\n assert images.ndim == 4\n assert evals.ndim == 4\n\n channels_broadcastable = images.type.broadcastable[0]\n batch_broadcastable = images.type.broadcastable[3]\n\n rows_broadcastable = False\n cols_broadcastable = False\n\n targets_broadcastable = (channels_broadcastable, rows_broadcastable,\n cols_broadcastable, batch_broadcastable)\n targets_type = CudaNdarrayType(broadcastable=targets_broadcastable)\n targets = targets_type()\n\n return Apply(self, [images, evals], [targets])", "metadata": "root.MaxPoolRop.make_node", "header": "['class', 'MaxPoolRop', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 470 }, { "content": " def c_code(self, node, name, inputs, outputs, sub):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n images,evals = inputs\n targets, = outputs\n fail = sub['fail']\n\n # The amount of braces that must be closed at the end\n num_braces = 0\n\n if self.copy_non_contiguous:\n raise UnimplementedError()\n else:\n basic_setup = \"#define MAXPOOLROP_COPY_NON_CONTIGUOUS 0\\n\"\n\n # Convert images in nv_images, an NVMatrix, for compatibility\n # with the cuda-convnet functions\n setup_nv_images = self._argument_contiguity_check(\"images\") + \"\"\"\n if (%(images)s->nd != 4)\n {\n PyErr_Format(PyExc_ValueError,\n \"images must have nd=4, got nd=%%i\", %(images)s->nd);\n %(fail)s;\n }\n\n { //setup_nv_images brace 1\n\n const int * images_dims = CudaNdarray_HOST_DIMS(%(images)s);\n const int img_channels = images_dims[0];\n const int imgSizeY = images_dims[1];\n const int imgSizeX = images_dims[2];\n const int batch_size = images_dims[3];\n\n if(imgSizeY != imgSizeX){\n PyErr_Format(PyExc_ValueError,\n \"images must be square(dims[1] == dims[2]). Shape (%%i,%%i,%%i,%%i)\",\n img_channels, imgSizeY, imgSizeX, batch_size);\n %(fail)s;\n }\n if(%(ds)s > imgSizeY){\n PyErr_Format(PyExc_ValueError,\n \"ds(%%d) must be <= imgSizeX(%%d) and imgSizeY(%%d).\",\n %(ds)s, imgSizeX, imgSizeY);\n %(fail)s;\n }\n if(%(start)s >= imgSizeX){\n PyErr_Format(PyExc_ValueError,\n \"start is %%d but must be smaller then the images size of %%d x %%d.\",\n %(start)s, imgSizeX, imgSizeY);\n %(fail)s;\n }\n\n NVMatrix nv_images(%(images)s, img_channels * imgSizeY * imgSizeX, batch_size,\n \"MaxPoolRop:nv_images\");\n NVMatrix nv_evals(%(evals)s, img_channels * imgSizeY * imgSizeX,\n batch_size, \"MaxPoolRop:nv_evals\");\n \"\"\"\n num_braces += 1\n\n setup_nv_targets = \"\"\"\n //int _outputsX = int(ceil((dic['imgSize'] - dic['start'] - dic['sizeX']) / float(dic['stride']))) + 1;\n int _outputsX = ((int)(ceil((imgSizeY - %(start)s - %(ds)s) / ((float)%(stride)s)))) + 1;\n\n int target_dims [] = {\n img_channels,\n _outputsX,\n _outputsX,\n batch_size };\n\n if (CudaNdarray_prep_output(& %(targets)s, 4, target_dims))\n {\n %(fail)s;\n }\n\n { // setup_nv_target brace # 1\n\n NVMatrix nv_targets(%(targets)s, target_dims[0] * target_dims[1] * target_dims[2],\n target_dims[3], \"MaxPoolRop:nv_targets\");\n\n \"\"\"\n\n num_braces += 1\n\n do_pool = \"\"\"\n convLocalPoolR(nv_images, nv_evals, nv_targets, img_channels, %(ds)s,\n %(start)s, %(stride)s, _outputsX, MaxPoolerR());\n \"\"\"\n\n braces = '}' * num_braces\n\n rval = (basic_setup +\n setup_nv_images +\n setup_nv_targets +\n do_pool +\n braces)\n start = self.start\n stride = self.stride\n ds = self.ds\n rval = rval % locals()\n\n return rval", "metadata": "root.MaxPoolRop.c_code", "header": "['class', 'MaxPoolRop', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 495 }, { "content": " def make_thunk(self, node, storage_map, compute_map, no_recycling):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n if not convnet_available():\n raise RuntimeError('Could not compile cuda_convnet')\n\n return super(MaxPoolRop, self).make_thunk(\n node, storage_map, storage_map, no_recycling)", "metadata": "root.MaxPoolRop.make_thunk", "header": "['class', 'MaxPoolRop', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 601 }, { "content": "class MaxPoolGrad(GpuOp):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n\n\n\n\n\n\n\n\n\n\n\n # Make sure the cuda_convnet library is compiled and up-to-date", "metadata": "root.MaxPoolGrad", "header": "['module', '___EOS___']", "index": 614 }, { "content": " def __init__(self, ds, stride, start):\n self.ds = ds\n self.stride = stride\n self.start = start\n self.copy_non_contiguous = 0\n assert stride > 0 and stride <= ds, (stride, ds)\n assert ds > 0, ds #We check in the code if ds <= imgSizeX", "metadata": "root.MaxPoolGrad.__init__", "header": "['class', 'MaxPoolGrad', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 620 }, { "content": " def __eq__(self, other):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n #Dont put copy_non_contigous as this doesn't change the output\n return (type(self) == type(other) and\n self.ds == other.ds and\n self.stride == other.stride and\n self.start == other.start)", "metadata": "root.MaxPoolGrad.__eq__", "header": "['class', 'MaxPoolGrad', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 628 }, { "content": " def __hash__(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n #Dont put copy_non_contigous as this doesn't change the output\n return (hash(type(self)) ^ hash(self.ds) ^\n hash(self.stride) ^ hash(self.start))", "metadata": "root.MaxPoolGrad.__hash__", "header": "['class', 'MaxPoolGrad', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 640 }, { "content": " def c_header_dirs(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return [this_dir, config.pthreads.inc_dir] if config.pthreads.inc_dir else [this_dir]", "metadata": "root.MaxPoolGrad.c_header_dirs", "header": "['class', 'MaxPoolGrad', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 650 }, { "content": " def c_headers(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return ['nvmatrix.cuh', 'conv_util.cuh']", "metadata": "root.MaxPoolGrad.c_headers", "header": "['class', 'MaxPoolGrad', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 658 }, { "content": " def c_lib_dirs(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return [cuda_convnet_loc, config.pthreads.lib_dir] if config.pthreads.lib_dir else [cuda_convnet_loc]", "metadata": "root.MaxPoolGrad.c_lib_dirs", "header": "['class', 'MaxPoolGrad', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 666 }, { "content": " def c_libraries(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return ['cuda_convnet', config.pthreads.lib] if config.pthreads.lib else ['cuda_convnet']", "metadata": "root.MaxPoolGrad.c_libraries", "header": "['class', 'MaxPoolGrad', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 674 }, { "content": " def c_code_cache_version(self):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n return (1,)", "metadata": "root.MaxPoolGrad.c_code_cache_version", "header": "['class', 'MaxPoolGrad', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 682 }, { "content": " def _argument_contiguity_check(self, arg_name):\n return \"\"\"\n if (!CudaNdarray_is_c_contiguous(%%(%(arg_name)s)s))\n {\n if (!(%(class_name_caps)s_COPY_NON_CONTIGUOUS)) {\n PyErr_SetString(PyExc_ValueError,\n \"%(class)s: %(arg_name)s must be C contiguous\");\n %%(fail)s;\n }\n }\n \"\"\" % {\n 'class': self.__class__.__name__,\n 'arg_name': arg_name,\n 'class_name_caps': self.__class__.__name__.upper(),\n }", "metadata": "root.MaxPoolGrad._argument_contiguity_check", "header": "['class', 'MaxPoolGrad', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 690 }, { "content": " def make_node(self, images, maxout, gz):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n images = as_cuda_ndarray_variable(images)\n maxout = as_cuda_ndarray_variable(maxout)\n gz = as_cuda_ndarray_variable(gz)\n\n assert images.ndim == 4\n assert maxout.ndim == 4\n assert gz.ndim == 4\n try:\n # Note : `get_scalar_constant_value` returns a ndarray not a\n # int\n nb_channel = int(get_scalar_constant_value(images.shape[0]))\n assert nb_channel % 16 == 0\n except NotScalarConstantError:\n pass\n return Apply(self, [images, maxout, gz], [images.type()])", "metadata": "root.MaxPoolGrad.make_node", "header": "['class', 'MaxPoolGrad', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 706 }, { "content": " def c_code(self, node, name, inputs, outputs, sub):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n images, maxout, gz = inputs\n targets, = outputs\n fail = sub['fail']\n\n # The amount of braces that must be closed at the end\n num_braces = 0\n\n if self.copy_non_contiguous:\n raise UnimplementedError()\n else:\n basic_setup = \"#define MAXPOOLGRAD_COPY_NON_CONTIGUOUS 0\\n\"\n\n # Convert images in nv_images, an NVMatrix, for compatibility\n # with the cuda-convnet functions\n setup_nv_images = self._argument_contiguity_check(\"images\") + \"\"\"\n if (%(images)s->nd != 4)\n {\n PyErr_Format(PyExc_ValueError,\n \"images must have nd=4, got nd=%%i\", %(images)s->nd);\n %(fail)s;\n }\n\n { //setup_nv_images brace 1\n\n const int * images_dims = CudaNdarray_HOST_DIMS(%(images)s);\n const int img_channels = images_dims[0];\n const int imgSizeY = images_dims[1];\n const int imgSizeX = images_dims[2];\n const int batch_size = images_dims[3];\n\n if(imgSizeY != imgSizeX){\n PyErr_Format(PyExc_ValueError,\n \"images must be square(dims[1] == dims[2]). Shape (%%i,%%i,%%i,%%i)\",\n img_channels, imgSizeY, imgSizeX, batch_size);\n %(fail)s;\n }\n if(%(ds)s > imgSizeY){\n PyErr_Format(PyExc_ValueError,\n \"ds(%%d) must be <= imgSizeX(%%d) and imgSizeY(%%d).\",\n %(ds)s, imgSizeX, imgSizeY);\n %(fail)s;\n }\n\n NVMatrix nv_images(%(images)s, img_channels * imgSizeY * imgSizeX, batch_size,\n \"MaxPool:nv_images\");\n \"\"\"\n num_braces += 1\n\n # Convert maxout in nv_maxout\n setup_nv_maxout = self._argument_contiguity_check(\"maxout\") + \"\"\"\n if (%(maxout)s->nd != 4)\n {\n PyErr_Format(PyExc_ValueError,\n \"maxout must have nd=4, got nd=%%i\", %(maxout)s->nd);\n %(fail)s;\n }\n\n { //setup_nv_maxout brace 1\n\n const int * maxout_dims = CudaNdarray_HOST_DIMS(%(maxout)s);\n const int maxout_channels = maxout_dims[0];\n const int maxoutSizeY = maxout_dims[1];\n const int maxoutSizeX = maxout_dims[2];\n\n if(maxoutSizeY != maxoutSizeX){\n PyErr_Format(PyExc_ValueError,\n \"maxout must be square(dims[1] == dims[2]).\"\n \" Shape (%%i,%%i,%%i,%%i)\",\n maxout_channels, maxoutSizeY, maxoutSizeX, batch_size);\n %(fail)s;\n }\n if(img_channels != maxout_channels){\n PyErr_Format(PyExc_ValueError,\n \"img_channels(%%d) should be equal to maxout_channels(%%d).\",\n img_channels, maxout_channels);\n %(fail)s;\n }\n if(maxout_dims[3] != batch_size){\n PyErr_Format(PyExc_ValueError,\n \"batch_size(%%d) should be equal to maxout_dims[3](%%d)\",\n batch_size, maxout_dims[3]);\n %(fail)s;\n }\n\n NVMatrix nv_maxout(%(maxout)s, img_channels * maxoutSizeY * maxoutSizeX,\n batch_size, \"MaxPool:nv_maxout\");\n \"\"\"\n num_braces += 1\n\n # Convert gz in nv_gz\n setup_nv_gz = self._argument_contiguity_check(\"gz\") + \"\"\"\n if (%(gz)s->nd != 4)\n {\n PyErr_Format(PyExc_ValueError,\n \"gz must have nd=4, got nd=%%i\", %(gz)s->nd);\n %(fail)s;\n }\n if (CudaNdarray_HOST_DIMS(%(gz)s)[0] %% 16 != 0)\n {\n PyErr_Format(PyExc_ValueError,\n \"gz must have a number of channels that is a multiple of 16. Got %%d\",\n CudaNdarray_HOST_DIMS(%(gz)s)[0]);\n %(fail)s;\n }\n\n { //setup_nv_gz brace 1\n\n const int * gz_dims = CudaNdarray_HOST_DIMS(%(gz)s);\n const int gz_channels = gz_dims[0];\n const int gzSizeY = gz_dims[1];\n const int gzSizeX = gz_dims[2];\n\n if(maxout_dims[0] != gz_dims[0] ||\n maxout_dims[1] != gz_dims[1] ||\n maxout_dims[2] != gz_dims[2] ||\n maxout_dims[3] != gz_dims[3]){\n PyErr_Format(PyExc_ValueError,\n \"gz shape(%%d, %%d, %%d, %%d) must be the same\"\n \" as maxout(%%d, %%d, %%d, %%d)\",\n maxout_dims[0], maxout_dims[1], maxout_dims[2], maxout_dims[3],\n gz_dims[0], gz_dims[1], gz_dims[2], gz_dims[3]);\n %(fail)s;\n }\n\n NVMatrix nv_gz(%(gz)s, img_channels * maxoutSizeY * maxoutSizeX,\n batch_size, \"MaxPool:nv_gz\");\n \"\"\"\n num_braces += 1\n\n setup_nv_targets = \"\"\"\n //int _outputsX = int(ceil((dic['imgSize'] - dic['start'] - dic['sizeX']) / float(dic['stride']))) + 1;\n int _outputsX = ((int)(ceil((imgSizeY - %(start)s - %(ds)s) / ((float)%(stride)s)))) + 1;\n\n int target_dims [] = {\n img_channels,\n imgSizeX,\n imgSizeY,\n batch_size };\n\n if (CudaNdarray_prep_output(& %(targets)s, 4, target_dims))\n {\n %(fail)s;\n }\n\n { // setup_nv_target brace # 1\n\n NVMatrix nv_targets(%(targets)s,\n target_dims[0] * target_dims[1] * target_dims[2],\n target_dims[3], \"MaxPool:nv_targets\");\n\n \"\"\"\n\n num_braces += 1\n\n undo_pool = \"\"\"\n convLocalMaxUndo(nv_images, nv_gz, nv_maxout, nv_targets,\n %(ds)s, %(start)s, %(stride)s, _outputsX, 0, 1);\n \"\"\"\n\n braces = '}' * num_braces\n\n rval = (basic_setup +\n setup_nv_images +\n setup_nv_maxout +\n setup_nv_gz +\n setup_nv_targets +\n undo_pool +\n braces)\n start = self.start\n stride = self.stride\n ds = self.ds\n rval = rval % locals()\n\n return rval", "metadata": "root.MaxPoolGrad.c_code", "header": "['class', 'MaxPoolGrad', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 728 }, { "content": " def make_thunk(self, node, storage_map, compute_map, no_recycling):\n \"\"\"\n .. todo::\n\n WRITEME\n \"\"\"\n if not convnet_available():\n raise RuntimeError('Could not compile cuda_convnet')\n\n return super(MaxPoolGrad, self).make_thunk(\n node, storage_map, compute_map, no_recycling)", "metadata": "root.MaxPoolGrad.make_thunk", "header": "['class', 'MaxPoolGrad', '(', 'GpuOp', ')', ':', '___EOS___']", "index": 910 } ]
[ { "span": "import pylearn2.sandbox.cuda_convnet.pthreads", "start_line": 19, "start_column": 0, "end_line": 19, "end_column": 45 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "warnings_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "theano_", "._", "gof", "_", "import_", "Apply", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "theano_", "._", "sandbox_", "._", "cuda_", "import_", "Cu", "da", "Nd", "array", "Type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "theano_", "._", "sandbox_", "._", "cuda_", "._", "basic", "\\u", "ops_", "import_", "as", "\\u", "cud", "a", "\\u", "ndar", "ray", "\\u", "variable_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "theano_", "._", "sandbox_", "._", "cuda_", "._", "basic", "\\u", "ops_", "import_", "gpu", "\\u", "contiguous", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "theano_", "._", "sandbox_", "._", "cuda_", "import_", "Gp", "u", "Op_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "theano_", "._", "tensor_", "import_", "get", "\\u", "scala", "r", "\\u", "constant", "\\u", "value_", ",_", "Not", "Scala", "r", "Const", "ant", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "pyl", "earn", "2_", "._", "sandbox_", "._", "cud", "a", "\\u", "conv", "net_", "._", "base", "\\u", "acts", "_", "import_", "Unimplemented", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyl", "earn", "2_", "._", "sandbox_", "._", "cud", "a", "\\u", "conv", "net_", "._", "conv", "net", "\\u", "compile_", "import_", "conv", "net", "\\u", "available_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyl", "earn", "2_", "._", "sandbox_", "._", "cud", "a", "\\u", "conv", "net_", "._", "conv", "net", "\\u", "compile_", "import_", "cud", "a", "\\u", "conv", "net", "\\u", "loc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyl", "earn", "2_", "._", "sandbox_", "._", "cud", "a", "\\u", "conv", "net_", "._", "shared", "\\u", "code_", "import_", "this", "\\u", "dir_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "pyl", "earn", "2_", "._", "sandbox_", "._", "cud", "a", "\\u", "conv", "net_", "._", "pthread", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "theano_", "import_", "config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "max", "\\u", "pool", "\\u", "c0", "1b", "_", "(_", "c0", "1b", "_", ",_", "pool", "\\u", "shape_", ",_", "pool", "\\u", "stride_", ",_", "image", "\\u", "shape_", "=_", "None_", ",_", "start_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "pool", "\\u", "shape_", "[_", "0_", "]_", "==_", "pool", "\\u", "shape_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "pool", "\\u", "shape_", "[_", "0_", "]_", ">_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "pool", "\\u", "stride_", "[_", "0_", "]_", ">_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "pool", "\\u", "stride_", "[_", "0_", "]_", "<=_", "pool", "\\u", "shape_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "pool", "\\u", "stride_", "[_", "0_", "]_", "!=_", "pool", "\\u", "stride_", "[_", "1_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "\"", "pool", " ", "stride", "s", " ", "must", " ", "match", ",", " ", "but", " ", "got", " ", "\"_", "+_", "str_", "(_", "pool", "\\u", "stride_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "image", "\\u", "shape_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "warnings_", "._", "warn_", "(_", "\"", "image", "\\u", "shape", " ", "argu", "ment", " ", "isn", "'", "t", " ", "need", "ed", " ", "any", "more", ",", " ", "quit", " ", "passi", "ng", " ", "it", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "op_", "=_", "Max", "Pool_", "(_", "pool", "\\u", "shape_", "[_", "0_", "]_", ",_", "pool", "\\u", "stride_", "[_", "0_", "]_", ",_", "start_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c0", "1b", "_", "=_", "gpu", "\\u", "contiguous", "_", "(_", "c0", "1b", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "op_", "(_", "c0", "1b", "_", ")_", "\\u\\u\\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_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "op", " ", "wrap", " ", "Alex", "'", "s", " ", "Max", "Poo", "l", " ", "code", " ", "on", " ", "the", " ", "GPU", ".", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "input", " ", "are", " ", "in", " ", "the", " ", "order", " ", "(", "channel", ",", " ", "image", " ", "rows", ",", " ", "image", " ", "cols", ",", " ", "batch", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Works", " ", "only", " ", "on", " ", "square", " ", "images", " ", "and", " ", "the", " ", "grad", " ", "works", " ", "only", " ", "whe", "n", "\\", "10", ";", " ", " ", " ", " ", "channel", " ", "%", " ", "16", " ", "==", " ", "0.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "----------", "\\", "10", ";", " ", " ", " ", " ", "ds", " ", ":", " ", "int", "\\", "10", ";", " ", " ", " ", " ", "Define", "s", " ", "the", " ", "size", " ", "of", " ", "the", " ", "pooling", " ", "region", " ", "in", " ", "the", " ", "x", " ", "(", "equivalent", "ly", ",", " ", "y", ")", "\\", "10", ";", " ", " ", " ", " ", "dimension", ".", " ", "Square", "s", " ", "of", " ", "size", " ", "(", "ds", ")", "2", " ", "get", " ", "reduce", "d", " ", "to", " ", "one", " ", "value", " ", "by", "\\", "10", ";", " ", " ", " ", " ", "this", " ", "layer", ".", " ", "There", " ", "are", " ", "no", " ", "restriction", "s", " ", "on", " ", "the", " ", "value", " ", "of", " ", "this", "\\", "10", ";", " ", " ", " ", " ", "parameter", ".", " ", "It", "'", "s", " ", "fine", " ", "for", " ", "a", " ", "pooling", " ", "square", " ", "to", " ", "fall", " ", "off", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "bound", "ary", " ", "of", " ", "the", " ", "image", ".", " ", "Name", "d", " ", "Size", "X", " ", "in", " ", "Alex", "'", "s", " ", "code", ".", "\\", "10", ";", " ", " ", " ", " ", "stride", " ", ":", " ", "int", "\\", "10", ";", " ", " ", " ", " ", "Define", "s", " ", "the", " ", "stride", " ", "size", " ", "bet", "ween", " ", "success", "ive", " ", "pooling", " ", "square", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "Sett", "ing", " ", "this", " ", "parameter", " ", "small", "er", " ", "than", " ", "size", "X", " ", "produce", "s", " ", "overlapping", "\\", "10", ";", " ", " ", " ", " ", "pools", ".", " ", "Sett", "ing", " ", "it", " ", "equal", " ", "to", " ", "size", "X", " ", "give", "s", " ", "the", " ", "usual", ",", " ", "non", "-", "overlapping", "\\", "10", ";", " ", " ", " ", " ", "pools", ".", " ", "Value", "s", " ", "great", "er", " ", "than", " ", "size", "X", " ", "are", " ", "not", " ", "allow", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "start", " ", ":", " ", "int", ",", " ", "option", "al", "\\", "10", ";", " ", " ", " ", " ", "Tell", "s", " ", "the", " ", "net", " ", "where", " ", "in", " ", "the", " ", "input", " ", "image", " ", "to", " ", "start", " ", "the", " ", "pooling", "\\", "10", ";", " ", " ", " ", " ", "(", "in", " ", "x", ",", "y", " ", "coordinate", "s", ").", " ", "In", " ", "princ", "ipl", "e", ",", " ", "you", " ", "can", " ", "start", " ", "any", "where", " ", "you", "\\", "10", ";", " ", " ", " ", " ", "want", ".", " ", "Sett", "ing", " ", "this", " ", "to", " ", "a", " ", "posit", "ive", " ", "number", " ", "will", " ", "caus", "e", " ", "the", " ", "net", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "discard", " ", "some", " ", "pixel", "s", " ", "at", " ", "the", " ", "top", " ", "and", " ", "at", " ", "the", " ", "left", " ", "of", " ", "the", " ", "image", ".", "\\", "10", ";", " ", " ", " ", " ", "Sett", "ing", " ", "this", " ", "to", " ", "a", " ", "negati", "ve", " ", "number", " ", "will", " ", "caus", "e", " ", "it", " ", "to", " ", "include", "\\", "10", ";", " ", " ", " ", " ", "pixel", "s", " ", "tha", "t", " ", "don", "'", "t", " ", "exist", " ", "(", "whi", "ch", " ", "is", " ", "fine", ").", " ", "start", "=", "0", " ", "is", " ", "the", " ", "usual", "\\", "10", ";", " ", " ", " ", " ", "setti", "ng", ".", "\\", "10", ";", " ", " ", " ", " ", "output", "s", " ", ":", " ", "int", ",", " ", "option", "al", "\\", "10", ";", " ", " ", " ", " ", "All", "ow", "s", " ", "you", " ", "to", " ", "control", " ", "how", " ", "many", " ", "output", " ", "values", " ", "in", " ", "the", " ", "x", "\\", "10", ";", " ", " ", " ", " ", "(", "equivalent", "ly", ",", " ", "y", ")", " ", "dimension", " ", "this", " ", "operati", "on", " ", "will", " ", "produce", ".", " ", "Thi", "s", "\\", "10", ";", " ", " ", " ", " ", "parameter", " ", "is", " ", "analog", "ous", " ", "to", " ", "the", " ", "start", " ", "parameter", ",", " ", "in", " ", "tha", "t", " ", "it", "\\", "10", ";", " ", " ", " ", " ", "allow", "s", " ", "you", " ", "to", " ", "discard", " ", "some", " ", "porti", "on", " ", "of", " ", "the", " ", "image", " ", "by", " ", "setti", "ng", " ", "it", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "a", " ", "value", " ", "small", " ", "eno", "ugh", " ", "to", " ", "lea", "ve", " ", "part", " ", "of", " ", "the", " ", "image", " ", "unco", "vere", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "Sett", "ing", " ", "it", " ", "to", " ", "zero", " ", "instruct", "s", " ", "the", " ", "net", " ", "to", " ", "produce", " ", "as", " ", "many", " ", "output", "s", "\\", "10", ";", " ", " ", " ", " ", "as", " ", "is", " ", "necessar", "y", " ", "to", " ", "ensure", " ", "tha", "t", " ", "the", " ", "whole", " ", "image", " ", "is", " ", "covered", ".", "\\", "10", ";", " ", " ", " ", " ", "default", " ", "0", "\\", "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\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "the", " ", "cud", "a", "\\u", "conv", "net", " ", "librar", "y", " ", "is", " ", "compile", "d", " ", "and", " ", "up", "-", "to", "-", "date_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "ds_", ",_", "stride_", ",_", "start_", "=_", "0_", ",_", "outputs_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ds_", "=_", "ds_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "stride_", "=_", "stride_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start_", "=_", "start_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "copy", "\\u", "non", "\\u", "contiguous", "_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "stride_", ">_", "0_", "and_", "stride_", "<=_", "ds_", ",_", "(_", "stride_", ",_", "ds_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "ds_", ">_", "0_", ",_", "ds_", "#", " ", "We", " ", "check", " ", "in", " ", "the", " ", "code", " ", "if", " ", "ds", " ", "<=", " ", "img", "Size", "X_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\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 ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Don", "t", " ", "put", " ", "copy", "\\u", "non", "\\u", "conti", "gou", "s", " ", "as", " ", "this", " ", "doe", "sn", "'", "t", " ", "change", " ", "the", " ", "output_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "(_", "type_", "(_", "self_", ")_", "==_", "type_", "(_", "other_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "ds_", "==_", "other_", "._", "ds_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "stride_", "==_", "other_", "._", "stride_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "start_", "==_", "other_", "._", "start_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\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 ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Don", "t", " ", "put", " ", "copy", "\\u", "non", "\\u", "conti", "gou", "s", " ", "as", " ", "this", " ", "doe", "sn", "'", "t", " ", "change", " ", "the", " ", "output_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "(_", "hash_", "(_", "type_", "(_", "self_", ")_", ")_", "^_", "hash_", "(_", "self_", "._", "ds_", ")_", "^_", "\\u\\u\\uNL\\u\\u\\u_", "hash_", "(_", "self_", "._", "stride_", ")_", "^_", "hash_", "(_", "self_", "._", "start_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "header", "\\u", "dirs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "this", "\\u", "dir_", ",_", "config_", "._", "pthread", "s_", "._", "inc", "\\u", "dir_", "]_", "if_", "config_", "._", "pthread", "s_", "._", "inc", "\\u", "dir_", "else_", "[_", "this", "\\u", "dir_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "headers_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "'", "nv", "matrix", ".", "cu", "h", "'_", ",_", "'", "conv", "\\u", "util", ".", "cu", "h", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "lib", "\\u", "dirs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "cud", "a", "\\u", "conv", "net", "\\u", "loc_", ",_", "config_", "._", "pthread", "s_", "._", "lib", "\\u", "dir_", "]_", "if_", "config_", "._", "pthread", "s_", "._", "lib", "\\u", "dir_", "else_", "[_", "cud", "a", "\\u", "conv", "net", "\\u", "loc_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "libraries_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "'", "cud", "a", "\\u", "conv", "net", "'_", ",_", "config_", "._", "pthread", "s_", "._", "lib_", "]_", "if_", "config_", "._", "pthread", "s_", "._", "lib_", "else_", "[_", "'", "cud", "a", "\\u", "conv", "net", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "code", "\\u", "cache", "\\u", "version_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "1_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "argu", "ment", "\\u", "conti", "guit", "y", "\\u", "check_", "(_", "self_", ",_", "arg", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(!", "Cu", "da", "Nd", "array", "\\u", "is", "\\u", "c\\u", "contiguous", "(%", "%", "(%", "(", "arg", "\\u", "name", ")", "s", ")", "s", "))\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(!", "(%", "(", "class", "\\u", "name", "\\u", "caps", ")", "s", "\\u", "COPY", "\\u", "NON", "\\u", "CONTI", "GU", "OUS", "))", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Set", "String", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", "\"%", "(", "class", ")", "s", ":", " ", "%", "(", "arg", "\\u", "name", ")", "s", " ", "must", " ", "be", " ", "C", " ", "contiguous", "\");", "\\", "10", ";", " ", " ", " ", " ", "%%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "%_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "class", "'_", ":_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "arg", "\\u", "name", "'_", ":_", "arg", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "class", "\\u", "name", "\\u", "caps", "'_", ":_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", "._", "upper_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "make", "\\u", "node_", "(_", "self_", ",_", "images_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "images_", "=_", "as", "\\u", "cud", "a", "\\u", "ndar", "ray", "\\u", "variable_", "(_", "images_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "images_", "._", "ndim_", "==_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "channel", "s", "\\u", "broadcast", "able_", "=_", "images_", "._", "type_", "._", "broadcast", "able_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "batch", "\\u", "broadcast", "able_", "=_", "images_", "._", "type_", "._", "broadcast", "able_", "[_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rows", "\\u", "broadcast", "able_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cols", "\\u", "broadcast", "able_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "target", "s", "\\u", "broadcast", "able_", "=_", "(_", "channel", "s", "\\u", "broadcast", "able_", ",_", "rows", "\\u", "broadcast", "able_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cols", "\\u", "broadcast", "able_", ",_", "batch", "\\u", "broadcast", "able_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "target", "s", "\\u", "type_", "=_", "Cu", "da", "Nd", "array", "Type_", "(_", "broadcast", "able_", "=_", "target", "s", "\\u", "broadcast", "able_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "targets_", "=_", "target", "s", "\\u", "type_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "Apply", "_", "(_", "self_", ",_", "[_", "images_", "]_", ",_", "[_", "targets_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "code_", "(_", "self_", ",_", "node_", ",_", "name_", ",_", "inputs_", ",_", "outputs_", ",_", "sub_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "images_", ",_", "=_", "inputs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "targets_", ",_", "=_", "outputs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fail_", "=_", "sub_", "[_", "'", "fail", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "amo", "unt", " ", "of", " ", "braces", " ", "tha", "t", " ", "must", " ", "be", " ", "close", "d", " ", "at", " ", "the", " ", "end_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "braces", "_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "copy", "\\u", "non", "\\u", "contiguous", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Unimplemented", "Error_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "basic", "\\u", "setup_", "=_", "\"#", "defin", "e", " ", "MAX", "POOL", "\\u", "COPY", "\\u", "NON", "\\u", "CONTI", "GU", "OUS", " ", "0", "\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Convert", " ", "images", " ", "in", " ", "nv", "\\u", "images", ",", " ", "an", " ", "NV", "Matrix", ",", " ", "for", " ", "compatibility", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "with", " ", "the", " ", "cud", "a", "-", "conv", "net", " ", "functions_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "images_", "=_", "self_", "._", "\\u", "argu", "ment", "\\u", "conti", "guit", "y", "\\u", "check_", "(_", "\"", "images", "\"_", ")_", "+_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(%", "(", "images", ")", "s", "->", "nd", " ", "!=", " ", "4", ")", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "images", " ", "must", " ", "have", " ", "nd", "=", "4", ",", " ", "got", " ", "nd", "=", "%%", "i", "\",", " ", "%", "(", "images", ")", "s", "->", "nd", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", " ", "//", "setup", "\\u", "nv", "\\u", "images", " ", "brace", " ", "1", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "*", " ", "images", "\\u", "dims", " ", "=", " ", "Cu", "da", "Nd", "array", "\\u", "HOST", "\\u", "DIM", "S", "(%", "(", "images", ")", "s", ");", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "img", "\\u", "channel", "s", " ", "=", " ", "images", "\\u", "dims", "[", "0", "];", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "img", "Size", "Y", " ", "=", " ", "images", "\\u", "dims", "[", "1", "];", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "img", "Size", "X", " ", "=", " ", "images", "\\u", "dims", "[", "2", "];", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "batch", "\\u", "size", " ", "=", " ", "images", "\\u", "dims", "[", "3", "];", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "if", "(", "img", "Size", "Y", " ", "!=", " ", "img", "Size", "X", "){", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "images", " ", "must", " ", "be", " ", "square", "(", "dims", "[", "1", "]", " ", "==", " ", "dims", "[", "2", "])", ".", " ", "Shape", " ", "(%", "%", "i", ",%", "%", "i", ",%", "%", "i", ",%", "%", "i", ")\"", ",", "\\", "10", ";", " ", " ", " ", " ", "img", "\\u", "channel", "s", ",", " ", "img", "Size", "Y", ",", " ", "img", "Size", "X", ",", " ", "batch", "\\u", "size", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "if", "(%", "(", "ds", ")", "s", " ", ">", " ", "img", "Size", "Y", "){", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "ds", "(%", "%", "d", ")", " ", "must", " ", "be", " ", "<=", " ", "img", "Size", "X", "(%", "%", "d", ")", " ", "and", " ", "img", "Size", "Y", "(%", "%", "d", ").", "\",", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "ds", ")", "s", ",", " ", "img", "Size", "X", ",", " ", "img", "Size", "Y", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "if", "(%", "(", "start", ")", "s", " ", ">=", " ", "img", "Size", "X", "){", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "start", " ", "is", " ", "%%", "d", " ", "but", " ", "must", " ", "be", " ", "small", "er", " ", "then", " ", "the", " ", "images", " ", "size", " ", "of", " ", "%%", "d", " ", "x", " ", "%%", "d", ".\",", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "start", ")", "s", ",", " ", "img", "Size", "X", ",", " ", "img", "Size", "Y", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "NV", "Matrix", " ", "nv", "\\u", "images", "(%", "(", "images", ")", "s", ",", " ", "img", "\\u", "channel", "s", " ", "*", " ", "img", "Size", "Y", " ", "*", " ", "img", "Size", "X", ",", " ", "batch", "\\u", "size", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "Max", "Poo", "l", ":", "nv", "\\u", "images", "\");", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "braces", "_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "targets_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "//", "int", " ", "\\u", "output", "s", "X", " ", "=", " ", "int", "(", "ceil", "((", "dic", "['", "img", "Size", "']", " ", "-", " ", "dic", "['", "start", "']", " ", "-", " ", "dic", "['", "size", "X", "'])", " ", "/", " ", "float", "(", "dic", "['", "stride", "'])", "))", " ", "+", " ", "1", ";", "\\", "10", ";", " ", " ", " ", " ", "int", " ", "\\u", "output", "s", "X", " ", "=", " ", "((", "int", ")(", "ceil", "((", "img", "Size", "Y", " ", "-", " ", "%", "(", "start", ")", "s", " ", "-", " ", "%", "(", "ds", ")", "s", ")", " ", "/", " ", "((", "float", ")%", "(", "stride", ")", "s", "))))", " ", "+", " ", "1", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "int", " ", "target", "\\u", "dims", " ", "[]", " ", "=", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "img", "\\u", "channel", "s", ",", "\\", "10", ";", " ", " ", " ", " ", "\\u", "output", "s", "X", ",", "\\", "10", ";", " ", " ", " ", " ", "\\u", "output", "s", "X", ",", "\\", "10", ";", " ", " ", " ", " ", "batch", "\\u", "size", " ", "};", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(", "Cu", "da", "Nd", "array", "\\u", "prep", "\\u", "output", "(", "&", " ", "%", "(", "target", "s", ")", "s", ",", " ", "4", ",", " ", "target", "\\u", "dims", "))\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", " ", "//", " ", "setup", "\\u", "nv", "\\u", "target", " ", "brace", " ", "#", " ", "1", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "NV", "Matrix", " ", "nv", "\\u", "target", "s", "(%", "(", "target", "s", ")", "s", ",", " ", "target", "\\u", "dims", "[", "0", "]", " ", "*", " ", "target", "\\u", "dims", "[", "1", "]", " ", "*", " ", "target", "\\u", "dims", "[", "2", "],", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "target", "\\u", "dims", "[", "3", "],", " ", "\"", "Max", "Poo", "l", ":", "nv", "\\u", "target", "s", "\");", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "braces", "_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "do", "\\u", "pool_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "conv", "Local", "Poo", "l", "(", "nv", "\\u", "images", ",", " ", "nv", "\\u", "target", "s", ",", " ", "img", "\\u", "channel", "s", ",", " ", "%", "(", "ds", ")", "s", ",", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "start", ")", "s", ",", " ", "%", "(", "stride", ")", "s", ",", " ", "\\u", "output", "s", "X", ",", " ", "Max", "Poo", "ler", "())", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "braces", "_", "=_", "'}'_", "*_", "num", "\\u", "braces", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rval_", "=_", "(_", "basic", "\\u", "setup_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "images_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "targets_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "do", "\\u", "pool_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "braces", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start_", "=_", "self_", "._", "start_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stride_", "=_", "self_", "._", "stride_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ds_", "=_", "self_", "._", "ds_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rval_", "=_", "rval_", "%_", "locals_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "rval_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "R", "\\u", "op_", "(_", "self_", ",_", "inp_", ",_", "evals_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", ",_", "=_", "inp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ev_", ",_", "=_", "evals_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "ev_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ev_", "=_", "gpu", "\\u", "contiguous", "_", "(_", "ev_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "Max", "Poo", "l", "Ro", "p_", "(_", "self_", "._", "ds_", ",_", "self_", "._", "stride_", ",_", "self_", "._", "start_", ")_", "(_", "x_", ",_", "ev_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "[_", "None_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "grad_", "(_", "self_", ",_", "inp_", ",_", "grads_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "x_", ",_", "=_", "inp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gz_", ",_", "=_", "grads_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gz_", "=_", "gpu", "\\u", "contiguous", "_", "(_", "gz_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "out_", "=_", "self_", "(_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "Max", "Poo", "l", "Grad", "_", "(_", "self_", "._", "ds_", ",_", "self_", "._", "stride_", ",_", "self_", "._", "start_", ")_", "(_", "x_", ",_", "max", "out_", ",_", "gz_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Pool_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "make", "\\u", "thu", "nk_", "(_", "self_", ",_", "node_", ",_", "storage", "\\u", "map_", ",_", "compute", "\\u", "map_", ",_", "no", "\\u", "recycl", "ing_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "conv", "net", "\\u", "available_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Run", "time", "Error_", "(_", "'", "Cou", "ld", " ", "not", " ", "compile", " ", "cud", "a", "\\u", "conv", "net", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "super_", "(_", "Max", "Pool_", ",_", "self_", ")_", "._", "make", "\\u", "thu", "nk_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "node_", ",_", "storage", "\\u", "map_", ",_", "compute", "\\u", "map_", ",_", "no", "\\u", "recycl", "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_", "class_", "Max", "Poo", "l", "Ro", "p_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "op", " ", "wrap", " ", "Alex", "'", "s", " ", "Max", "Poo", "l", " ", "code", " ", "on", " ", "the", " ", "GPU", ".", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "input", " ", "are", " ", "in", " ", "the", " ", "order", " ", "(", "channel", ",", " ", "image", " ", "rows", ",", " ", "image", " ", "cols", ",", " ", "batch", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Works", " ", "only", " ", "on", " ", "square", " ", "images", " ", "and", " ", "the", " ", "grad", " ", "works", " ", "only", " ", "whe", "n", "\\", "10", ";", " ", " ", " ", " ", "channel", " ", "%", " ", "16", " ", "==", " ", "0.", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", "\\", "10", ";", " ", " ", " ", " ", "----------", "\\", "10", ";", " ", " ", " ", " ", "ds", " ", ":", " ", "int", "\\", "10", ";", " ", " ", " ", " ", "Define", "s", " ", "the", " ", "size", " ", "of", " ", "the", " ", "pooling", " ", "region", " ", "in", " ", "the", " ", "x", " ", "(", "equivalent", "ly", ",", " ", "y", ")", "\\", "10", ";", " ", " ", " ", " ", "dimension", ".", " ", "Square", "s", " ", "of", " ", "size", " ", "(", "ds", ")", "2", " ", "get", " ", "reduce", "d", " ", "to", " ", "one", " ", "value", " ", "by", "\\", "10", ";", " ", " ", " ", " ", "this", " ", "layer", ".", " ", "There", " ", "are", " ", "no", " ", "restriction", "s", " ", "on", " ", "the", " ", "value", " ", "of", " ", "this", "\\", "10", ";", " ", " ", " ", " ", "parameter", ".", " ", "It", "'", "s", " ", "fine", " ", "for", " ", "a", " ", "pooling", " ", "square", " ", "to", " ", "fall", " ", "off", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "bound", "ary", " ", "of", " ", "the", " ", "image", ".", " ", "Name", "d", " ", "Size", "X", " ", "in", " ", "Alex", "'", "s", " ", "code", ".", "\\", "10", ";", " ", " ", " ", " ", "stride", " ", ":", " ", "int", "\\", "10", ";", " ", " ", " ", " ", "Define", "s", " ", "the", " ", "stride", " ", "size", " ", "bet", "ween", " ", "success", "ive", " ", "pooling", " ", "square", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "Sett", "ing", " ", "this", " ", "parameter", " ", "small", "er", " ", "than", " ", "size", "X", " ", "produce", "s", " ", "overlapping", "\\", "10", ";", " ", " ", " ", " ", "pools", ".", " ", "Sett", "ing", " ", "it", " ", "equal", " ", "to", " ", "size", "X", " ", "give", "s", " ", "the", " ", "usual", ",", " ", "non", "-", "overlapping", "\\", "10", ";", " ", " ", " ", " ", "pools", ".", " ", "Value", "s", " ", "great", "er", " ", "than", " ", "size", "X", " ", "are", " ", "not", " ", "allow", "ed", ".", "\\", "10", ";", " ", " ", " ", " ", "start", " ", ":", " ", "int", ",", " ", "option", "al", "\\", "10", ";", " ", " ", " ", " ", "Tell", "s", " ", "the", " ", "net", " ", "where", " ", "in", " ", "the", " ", "input", " ", "image", " ", "to", " ", "start", " ", "the", " ", "pooling", "\\", "10", ";", " ", " ", " ", " ", "(", "in", " ", "x", ",", "y", " ", "coordinate", "s", ").", " ", "In", " ", "princ", "ipl", "e", ",", " ", "you", " ", "can", " ", "start", " ", "any", "where", " ", "you", "\\", "10", ";", " ", " ", " ", " ", "want", ".", " ", "Sett", "ing", " ", "this", " ", "to", " ", "a", " ", "posit", "ive", " ", "number", " ", "will", " ", "caus", "e", " ", "the", " ", "net", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "discard", " ", "some", " ", "pixel", "s", " ", "at", " ", "the", " ", "top", " ", "and", " ", "at", " ", "the", " ", "left", " ", "of", " ", "the", " ", "image", ".", "\\", "10", ";", " ", " ", " ", " ", "Sett", "ing", " ", "this", " ", "to", " ", "a", " ", "negati", "ve", " ", "number", " ", "will", " ", "caus", "e", " ", "it", " ", "to", " ", "include", "\\", "10", ";", " ", " ", " ", " ", "pixel", "s", " ", "tha", "t", " ", "don", "'", "t", " ", "exist", " ", "(", "whi", "ch", " ", "is", " ", "fine", ").", " ", "start", "=", "0", " ", "is", " ", "the", " ", "usual", "\\", "10", ";", " ", " ", " ", " ", "setti", "ng", ".", "\\", "10", ";", " ", " ", " ", " ", "output", "s", " ", ":", " ", "int", ",", " ", "option", "al", "\\", "10", ";", " ", " ", " ", " ", "All", "ow", "s", " ", "you", " ", "to", " ", "control", " ", "how", " ", "many", " ", "output", " ", "values", " ", "in", " ", "the", " ", "x", "\\", "10", ";", " ", " ", " ", " ", "(", "equivalent", "ly", ",", " ", "y", ")", " ", "dimension", " ", "this", " ", "operati", "on", " ", "will", " ", "produce", ".", " ", "Thi", "s", "\\", "10", ";", " ", " ", " ", " ", "parameter", " ", "is", " ", "analog", "ous", " ", "to", " ", "the", " ", "start", " ", "parameter", ",", " ", "in", " ", "tha", "t", " ", "it", "\\", "10", ";", " ", " ", " ", " ", "allow", "s", " ", "you", " ", "to", " ", "discard", " ", "some", " ", "porti", "on", " ", "of", " ", "the", " ", "image", " ", "by", " ", "setti", "ng", " ", "it", "\\", "10", ";", " ", " ", " ", " ", "to", " ", "a", " ", "value", " ", "small", " ", "eno", "ugh", " ", "to", " ", "lea", "ve", " ", "part", " ", "of", " ", "the", " ", "image", " ", "unco", "vere", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "Sett", "ing", " ", "it", " ", "to", " ", "zero", " ", "instruct", "s", " ", "the", " ", "net", " ", "to", " ", "produce", " ", "as", " ", "many", " ", "output", "s", "\\", "10", ";", " ", " ", " ", " ", "as", " ", "is", " ", "necessar", "y", " ", "to", " ", "ensure", " ", "tha", "t", " ", "the", " ", "whole", " ", "image", " ", "is", " ", "covered", ".", "\\", "10", ";", " ", " ", " ", " ", "default", " ", "0", "\\", "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_", "#", " ", "Make", " ", "sure", " ", "the", " ", "cud", "a", "\\u", "conv", "net", " ", "librar", "y", " ", "is", " ", "compile", "d", " ", "and", " ", "up", "-", "to", "-", "date_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Ro", "p_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "ds_", ",_", "stride_", ",_", "start_", "=_", "0_", ",_", "outputs_", "=_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ds_", "=_", "ds_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "stride_", "=_", "stride_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start_", "=_", "start_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "copy", "\\u", "non", "\\u", "contiguous", "_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "stride_", ">_", "0_", "and_", "stride_", "<=_", "ds_", ",_", "(_", "stride_", ",_", "ds_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "ds_", ">_", "0_", ",_", "ds_", "#", " ", "We", " ", "check", " ", "in", " ", "the", " ", "code", " ", "if", " ", "ds", " ", "<=", " ", "img", "Size", "X_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Ro", "p_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\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 ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Don", "t", " ", "put", " ", "copy", "\\u", "non", "\\u", "conti", "gou", "s", " ", "as", " ", "this", " ", "doe", "sn", "'", "t", " ", "change", " ", "the", " ", "output_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "(_", "type_", "(_", "self_", ")_", "==_", "type_", "(_", "other_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "ds_", "==_", "other_", "._", "ds_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "stride_", "==_", "other_", "._", "stride_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "start_", "==_", "other_", "._", "start_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Ro", "p_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\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 ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Don", "t", " ", "put", " ", "copy", "\\u", "non", "\\u", "conti", "gou", "s", " ", "as", " ", "this", " ", "doe", "sn", "'", "t", " ", "change", " ", "the", " ", "output_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "(_", "hash_", "(_", "type_", "(_", "self_", ")_", ")_", "^_", "hash_", "(_", "self_", "._", "ds_", ")_", "^_", "\\u\\u\\uNL\\u\\u\\u_", "hash_", "(_", "self_", "._", "stride_", ")_", "^_", "hash_", "(_", "self_", "._", "start_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Ro", "p_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "header", "\\u", "dirs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "this", "\\u", "dir_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Ro", "p_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "headers_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "'", "nv", "matrix", ".", "cu", "h", "'_", ",_", "'", "conv", "\\u", "util", ".", "cu", "h", "'_", ",_", "'", "pool", "\\u", "rop", ".", "cu", "h", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Ro", "p_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "lib", "\\u", "dirs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "cud", "a", "\\u", "conv", "net", "\\u", "loc_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Ro", "p_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "libraries_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "'", "cud", "a", "\\u", "conv", "net", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Ro", "p_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "code", "\\u", "cache", "\\u", "version_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "1_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Ro", "p_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "argu", "ment", "\\u", "conti", "guit", "y", "\\u", "check_", "(_", "self_", ",_", "arg", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(!", "Cu", "da", "Nd", "array", "\\u", "is", "\\u", "c\\u", "contiguous", "(%", "%", "(%", "(", "arg", "\\u", "name", ")", "s", ")", "s", "))\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(!", "(%", "(", "class", "\\u", "name", "\\u", "caps", ")", "s", "\\u", "COPY", "\\u", "NON", "\\u", "CONTI", "GU", "OUS", "))", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Set", "String", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", "\"%", "(", "class", ")", "s", ":", " ", "%", "(", "arg", "\\u", "name", ")", "s", " ", "must", " ", "be", " ", "C", " ", "contiguous", "\");", "\\", "10", ";", " ", " ", " ", " ", "%%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "%_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "class", "'_", ":_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "arg", "\\u", "name", "'_", ":_", "arg", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "class", "\\u", "name", "\\u", "caps", "'_", ":_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", "._", "upper_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Ro", "p_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "make", "\\u", "node_", "(_", "self_", ",_", "images_", ",_", "evals_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "images_", "=_", "as", "\\u", "cud", "a", "\\u", "ndar", "ray", "\\u", "variable_", "(_", "images_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "evals_", "=_", "as", "\\u", "cud", "a", "\\u", "ndar", "ray", "\\u", "variable_", "(_", "evals_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "images_", "._", "ndim_", "==_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "evals_", "._", "ndim_", "==_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "channel", "s", "\\u", "broadcast", "able_", "=_", "images_", "._", "type_", "._", "broadcast", "able_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "batch", "\\u", "broadcast", "able_", "=_", "images_", "._", "type_", "._", "broadcast", "able_", "[_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rows", "\\u", "broadcast", "able_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cols", "\\u", "broadcast", "able_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "target", "s", "\\u", "broadcast", "able_", "=_", "(_", "channel", "s", "\\u", "broadcast", "able_", ",_", "rows", "\\u", "broadcast", "able_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cols", "\\u", "broadcast", "able_", ",_", "batch", "\\u", "broadcast", "able_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "target", "s", "\\u", "type_", "=_", "Cu", "da", "Nd", "array", "Type_", "(_", "broadcast", "able_", "=_", "target", "s", "\\u", "broadcast", "able_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "targets_", "=_", "target", "s", "\\u", "type_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "Apply", "_", "(_", "self_", ",_", "[_", "images_", ",_", "evals_", "]_", ",_", "[_", "targets_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Ro", "p_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "code_", "(_", "self_", ",_", "node_", ",_", "name_", ",_", "inputs_", ",_", "outputs_", ",_", "sub_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "images_", ",_", "evals_", "=_", "inputs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "targets_", ",_", "=_", "outputs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fail_", "=_", "sub_", "[_", "'", "fail", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "amo", "unt", " ", "of", " ", "braces", " ", "tha", "t", " ", "must", " ", "be", " ", "close", "d", " ", "at", " ", "the", " ", "end_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "braces", "_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "copy", "\\u", "non", "\\u", "contiguous", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Unimplemented", "Error_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "basic", "\\u", "setup_", "=_", "\"#", "defin", "e", " ", "MAX", "POOL", "ROP", "\\u", "COPY", "\\u", "NON", "\\u", "CONTI", "GU", "OUS", " ", "0", "\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Convert", " ", "images", " ", "in", " ", "nv", "\\u", "images", ",", " ", "an", " ", "NV", "Matrix", ",", " ", "for", " ", "compatibility", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "with", " ", "the", " ", "cud", "a", "-", "conv", "net", " ", "functions_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "images_", "=_", "self_", "._", "\\u", "argu", "ment", "\\u", "conti", "guit", "y", "\\u", "check_", "(_", "\"", "images", "\"_", ")_", "+_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(%", "(", "images", ")", "s", "->", "nd", " ", "!=", " ", "4", ")", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "images", " ", "must", " ", "have", " ", "nd", "=", "4", ",", " ", "got", " ", "nd", "=", "%%", "i", "\",", " ", "%", "(", "images", ")", "s", "->", "nd", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", " ", "//", "setup", "\\u", "nv", "\\u", "images", " ", "brace", " ", "1", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "*", " ", "images", "\\u", "dims", " ", "=", " ", "Cu", "da", "Nd", "array", "\\u", "HOST", "\\u", "DIM", "S", "(%", "(", "images", ")", "s", ");", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "img", "\\u", "channel", "s", " ", "=", " ", "images", "\\u", "dims", "[", "0", "];", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "img", "Size", "Y", " ", "=", " ", "images", "\\u", "dims", "[", "1", "];", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "img", "Size", "X", " ", "=", " ", "images", "\\u", "dims", "[", "2", "];", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "batch", "\\u", "size", " ", "=", " ", "images", "\\u", "dims", "[", "3", "];", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "if", "(", "img", "Size", "Y", " ", "!=", " ", "img", "Size", "X", "){", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "images", " ", "must", " ", "be", " ", "square", "(", "dims", "[", "1", "]", " ", "==", " ", "dims", "[", "2", "])", ".", " ", "Shape", " ", "(%", "%", "i", ",%", "%", "i", ",%", "%", "i", ",%", "%", "i", ")\"", ",", "\\", "10", ";", " ", " ", " ", " ", "img", "\\u", "channel", "s", ",", " ", "img", "Size", "Y", ",", " ", "img", "Size", "X", ",", " ", "batch", "\\u", "size", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "if", "(%", "(", "ds", ")", "s", " ", ">", " ", "img", "Size", "Y", "){", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "ds", "(%", "%", "d", ")", " ", "must", " ", "be", " ", "<=", " ", "img", "Size", "X", "(%", "%", "d", ")", " ", "and", " ", "img", "Size", "Y", "(%", "%", "d", ").", "\",", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "ds", ")", "s", ",", " ", "img", "Size", "X", ",", " ", "img", "Size", "Y", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "if", "(%", "(", "start", ")", "s", " ", ">=", " ", "img", "Size", "X", "){", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "start", " ", "is", " ", "%%", "d", " ", "but", " ", "must", " ", "be", " ", "small", "er", " ", "then", " ", "the", " ", "images", " ", "size", " ", "of", " ", "%%", "d", " ", "x", " ", "%%", "d", ".\",", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "start", ")", "s", ",", " ", "img", "Size", "X", ",", " ", "img", "Size", "Y", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "NV", "Matrix", " ", "nv", "\\u", "images", "(%", "(", "images", ")", "s", ",", " ", "img", "\\u", "channel", "s", " ", "*", " ", "img", "Size", "Y", " ", "*", " ", "img", "Size", "X", ",", " ", "batch", "\\u", "size", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "Max", "Poo", "l", "Ro", "p", ":", "nv", "\\u", "images", "\");", "\\", "10", ";", " ", " ", " ", " ", "NV", "Matrix", " ", "nv", "\\u", "eval", "s", "(%", "(", "eval", "s", ")", "s", ",", " ", "img", "\\u", "channel", "s", " ", "*", " ", "img", "Size", "Y", " ", "*", " ", "img", "Size", "X", ",", "\\", "10", ";", " ", " ", " ", " ", "batch", "\\u", "size", ",", " ", "\"", "Max", "Poo", "l", "Ro", "p", ":", "nv", "\\u", "eval", "s", "\");", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "braces", "_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "targets_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "//", "int", " ", "\\u", "output", "s", "X", " ", "=", " ", "int", "(", "ceil", "((", "dic", "['", "img", "Size", "']", " ", "-", " ", "dic", "['", "start", "']", " ", "-", " ", "dic", "['", "size", "X", "'])", " ", "/", " ", "float", "(", "dic", "['", "stride", "'])", "))", " ", "+", " ", "1", ";", "\\", "10", ";", " ", " ", " ", " ", "int", " ", "\\u", "output", "s", "X", " ", "=", " ", "((", "int", ")(", "ceil", "((", "img", "Size", "Y", " ", "-", " ", "%", "(", "start", ")", "s", " ", "-", " ", "%", "(", "ds", ")", "s", ")", " ", "/", " ", "((", "float", ")%", "(", "stride", ")", "s", "))))", " ", "+", " ", "1", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "int", " ", "target", "\\u", "dims", " ", "[]", " ", "=", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "img", "\\u", "channel", "s", ",", "\\", "10", ";", " ", " ", " ", " ", "\\u", "output", "s", "X", ",", "\\", "10", ";", " ", " ", " ", " ", "\\u", "output", "s", "X", ",", "\\", "10", ";", " ", " ", " ", " ", "batch", "\\u", "size", " ", "};", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(", "Cu", "da", "Nd", "array", "\\u", "prep", "\\u", "output", "(", "&", " ", "%", "(", "target", "s", ")", "s", ",", " ", "4", ",", " ", "target", "\\u", "dims", "))\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", " ", "//", " ", "setup", "\\u", "nv", "\\u", "target", " ", "brace", " ", "#", " ", "1", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "NV", "Matrix", " ", "nv", "\\u", "target", "s", "(%", "(", "target", "s", ")", "s", ",", " ", "target", "\\u", "dims", "[", "0", "]", " ", "*", " ", "target", "\\u", "dims", "[", "1", "]", " ", "*", " ", "target", "\\u", "dims", "[", "2", "],", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "target", "\\u", "dims", "[", "3", "],", " ", "\"", "Max", "Poo", "l", "Ro", "p", ":", "nv", "\\u", "target", "s", "\");", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "braces", "_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "do", "\\u", "pool_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "conv", "Local", "Poo", "l", "R", "(", "nv", "\\u", "images", ",", " ", "nv", "\\u", "eval", "s", ",", " ", "nv", "\\u", "target", "s", ",", " ", "img", "\\u", "channel", "s", ",", " ", "%", "(", "ds", ")", "s", ",", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "start", ")", "s", ",", " ", "%", "(", "stride", ")", "s", ",", " ", "\\u", "output", "s", "X", ",", " ", "Max", "Poo", "ler", "R", "())", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "braces", "_", "=_", "'}'_", "*_", "num", "\\u", "braces", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rval_", "=_", "(_", "basic", "\\u", "setup_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "images_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "targets_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "do", "\\u", "pool_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "braces", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start_", "=_", "self_", "._", "start_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stride_", "=_", "self_", "._", "stride_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ds_", "=_", "self_", "._", "ds_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rval_", "=_", "rval_", "%_", "locals_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "rval_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Ro", "p_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "make", "\\u", "thu", "nk_", "(_", "self_", ",_", "node_", ",_", "storage", "\\u", "map_", ",_", "compute", "\\u", "map_", ",_", "no", "\\u", "recycl", "ing_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "conv", "net", "\\u", "available_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Run", "time", "Error_", "(_", "'", "Cou", "ld", " ", "not", " ", "compile", " ", "cud", "a", "\\u", "conv", "net", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "super_", "(_", "Max", "Poo", "l", "Ro", "p_", ",_", "self_", ")_", "._", "make", "\\u", "thu", "nk_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "node_", ",_", "storage", "\\u", "map_", ",_", "storage", "\\u", "map_", ",_", "no", "\\u", "recycl", "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_", "class_", "Max", "Poo", "l", "Grad", "_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "the", " ", "cud", "a", "\\u", "conv", "net", " ", "librar", "y", " ", "is", " ", "compile", "d", " ", "and", " ", "up", "-", "to", "-", "date_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Grad", "_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "ds_", ",_", "stride_", ",_", "start_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "ds_", "=_", "ds_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "stride_", "=_", "stride_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "start_", "=_", "start_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "copy", "\\u", "non", "\\u", "contiguous", "_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "stride_", ">_", "0_", "and_", "stride_", "<=_", "ds_", ",_", "(_", "stride_", ",_", "ds_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "ds_", ">_", "0_", ",_", "ds_", "#", "We", " ", "check", " ", "in", " ", "the", " ", "code", " ", "if", " ", "ds", " ", "<=", " ", "img", "Size", "X_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Grad", "_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\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 ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Don", "t", " ", "put", " ", "copy", "\\u", "non", "\\u", "conti", "gou", "s", " ", "as", " ", "this", " ", "doe", "sn", "'", "t", " ", "change", " ", "the", " ", "output_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "(_", "type_", "(_", "self_", ")_", "==_", "type_", "(_", "other_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "ds_", "==_", "other_", "._", "ds_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "stride_", "==_", "other_", "._", "stride_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "start_", "==_", "other_", "._", "start_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Grad", "_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\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 ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Don", "t", " ", "put", " ", "copy", "\\u", "non", "\\u", "conti", "gou", "s", " ", "as", " ", "this", " ", "doe", "sn", "'", "t", " ", "change", " ", "the", " ", "output_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "(_", "hash_", "(_", "type_", "(_", "self_", ")_", ")_", "^_", "hash_", "(_", "self_", "._", "ds_", ")_", "^_", "\\u\\u\\uNL\\u\\u\\u_", "hash_", "(_", "self_", "._", "stride_", ")_", "^_", "hash_", "(_", "self_", "._", "start_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Grad", "_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "header", "\\u", "dirs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "this", "\\u", "dir_", ",_", "config_", "._", "pthread", "s_", "._", "inc", "\\u", "dir_", "]_", "if_", "config_", "._", "pthread", "s_", "._", "inc", "\\u", "dir_", "else_", "[_", "this", "\\u", "dir_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Grad", "_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "headers_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "'", "nv", "matrix", ".", "cu", "h", "'_", ",_", "'", "conv", "\\u", "util", ".", "cu", "h", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Grad", "_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "lib", "\\u", "dirs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "cud", "a", "\\u", "conv", "net", "\\u", "loc_", ",_", "config_", "._", "pthread", "s_", "._", "lib", "\\u", "dir_", "]_", "if_", "config_", "._", "pthread", "s_", "._", "lib", "\\u", "dir_", "else_", "[_", "cud", "a", "\\u", "conv", "net", "\\u", "loc_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Grad", "_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "libraries_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "[_", "'", "cud", "a", "\\u", "conv", "net", "'_", ",_", "config_", "._", "pthread", "s_", "._", "lib_", "]_", "if_", "config_", "._", "pthread", "s_", "._", "lib_", "else_", "[_", "'", "cud", "a", "\\u", "conv", "net", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Grad", "_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "code", "\\u", "cache", "\\u", "version_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "1_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Grad", "_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "argu", "ment", "\\u", "conti", "guit", "y", "\\u", "check_", "(_", "self_", ",_", "arg", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(!", "Cu", "da", "Nd", "array", "\\u", "is", "\\u", "c\\u", "contiguous", "(%", "%", "(%", "(", "arg", "\\u", "name", ")", "s", ")", "s", "))\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(!", "(%", "(", "class", "\\u", "name", "\\u", "caps", ")", "s", "\\u", "COPY", "\\u", "NON", "\\u", "CONTI", "GU", "OUS", "))", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Set", "String", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", "\"%", "(", "class", ")", "s", ":", " ", "%", "(", "arg", "\\u", "name", ")", "s", " ", "must", " ", "be", " ", "C", " ", "contiguous", "\");", "\\", "10", ";", " ", " ", " ", " ", "%%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "%_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "class", "'_", ":_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "arg", "\\u", "name", "'_", ":_", "arg", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "class", "\\u", "name", "\\u", "caps", "'_", ":_", "self_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", "._", "upper_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Grad", "_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "make", "\\u", "node_", "(_", "self_", ",_", "images_", ",_", "max", "out_", ",_", "gz_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "images_", "=_", "as", "\\u", "cud", "a", "\\u", "ndar", "ray", "\\u", "variable_", "(_", "images_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "out_", "=_", "as", "\\u", "cud", "a", "\\u", "ndar", "ray", "\\u", "variable_", "(_", "max", "out_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "gz_", "=_", "as", "\\u", "cud", "a", "\\u", "ndar", "ray", "\\u", "variable_", "(_", "gz_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "images_", "._", "ndim_", "==_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "max", "out_", "._", "ndim_", "==_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "gz_", "._", "ndim_", "==_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Not", "e", " ", ":", " ", "`", "get", "\\u", "scala", "r", "\\u", "constant", "\\u", "value", "`", " ", "return", "s", " ", "a", " ", "ndar", "ray", " ", "not", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "int_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nb", "\\u", "channel_", "=_", "int_", "(_", "get", "\\u", "scala", "r", "\\u", "constant", "\\u", "value_", "(_", "images_", "._", "shape_", "[_", "0_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "nb", "\\u", "channel_", "%_", "16_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Not", "Scala", "r", "Const", "ant", "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_", "Apply", "_", "(_", "self_", ",_", "[_", "images_", ",_", "max", "out_", ",_", "gz_", "]_", ",_", "[_", "images_", "._", "type_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Grad", "_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "c\\u", "code_", "(_", "self_", ",_", "node_", ",_", "name_", ",_", "inputs_", ",_", "outputs_", ",_", "sub_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "images_", ",_", "max", "out_", ",_", "gz_", "=_", "inputs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "targets_", ",_", "=_", "outputs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fail_", "=_", "sub_", "[_", "'", "fail", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "amo", "unt", " ", "of", " ", "braces", " ", "tha", "t", " ", "must", " ", "be", " ", "close", "d", " ", "at", " ", "the", " ", "end_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "braces", "_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "copy", "\\u", "non", "\\u", "contiguous", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Unimplemented", "Error_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "basic", "\\u", "setup_", "=_", "\"#", "defin", "e", " ", "MAX", "POOL", "GRAD", "\\u", "COPY", "\\u", "NON", "\\u", "CONTI", "GU", "OUS", " ", "0", "\\\\", "n", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Convert", " ", "images", " ", "in", " ", "nv", "\\u", "images", ",", " ", "an", " ", "NV", "Matrix", ",", " ", "for", " ", "compatibility", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "with", " ", "the", " ", "cud", "a", "-", "conv", "net", " ", "functions_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "images_", "=_", "self_", "._", "\\u", "argu", "ment", "\\u", "conti", "guit", "y", "\\u", "check_", "(_", "\"", "images", "\"_", ")_", "+_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(%", "(", "images", ")", "s", "->", "nd", " ", "!=", " ", "4", ")", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "images", " ", "must", " ", "have", " ", "nd", "=", "4", ",", " ", "got", " ", "nd", "=", "%%", "i", "\",", " ", "%", "(", "images", ")", "s", "->", "nd", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", " ", "//", "setup", "\\u", "nv", "\\u", "images", " ", "brace", " ", "1", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "*", " ", "images", "\\u", "dims", " ", "=", " ", "Cu", "da", "Nd", "array", "\\u", "HOST", "\\u", "DIM", "S", "(%", "(", "images", ")", "s", ");", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "img", "\\u", "channel", "s", " ", "=", " ", "images", "\\u", "dims", "[", "0", "];", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "img", "Size", "Y", " ", "=", " ", "images", "\\u", "dims", "[", "1", "];", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "img", "Size", "X", " ", "=", " ", "images", "\\u", "dims", "[", "2", "];", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "batch", "\\u", "size", " ", "=", " ", "images", "\\u", "dims", "[", "3", "];", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "if", "(", "img", "Size", "Y", " ", "!=", " ", "img", "Size", "X", "){", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "images", " ", "must", " ", "be", " ", "square", "(", "dims", "[", "1", "]", " ", "==", " ", "dims", "[", "2", "])", ".", " ", "Shape", " ", "(%", "%", "i", ",%", "%", "i", ",%", "%", "i", ",%", "%", "i", ")\"", ",", "\\", "10", ";", " ", " ", " ", " ", "img", "\\u", "channel", "s", ",", " ", "img", "Size", "Y", ",", " ", "img", "Size", "X", ",", " ", "batch", "\\u", "size", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "if", "(%", "(", "ds", ")", "s", " ", ">", " ", "img", "Size", "Y", "){", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "ds", "(%", "%", "d", ")", " ", "must", " ", "be", " ", "<=", " ", "img", "Size", "X", "(%", "%", "d", ")", " ", "and", " ", "img", "Size", "Y", "(%", "%", "d", ").", "\",", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "ds", ")", "s", ",", " ", "img", "Size", "X", ",", " ", "img", "Size", "Y", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "NV", "Matrix", " ", "nv", "\\u", "images", "(%", "(", "images", ")", "s", ",", " ", "img", "\\u", "channel", "s", " ", "*", " ", "img", "Size", "Y", " ", "*", " ", "img", "Size", "X", ",", " ", "batch", "\\u", "size", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "Max", "Poo", "l", ":", "nv", "\\u", "images", "\");", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "braces", "_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Convert", " ", "max", "out", " ", "in", " ", "nv", "\\u", "max", "out_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "max", "out_", "=_", "self_", "._", "\\u", "argu", "ment", "\\u", "conti", "guit", "y", "\\u", "check_", "(_", "\"", "max", "out", "\"_", ")_", "+_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(%", "(", "max", "out", ")", "s", "->", "nd", " ", "!=", " ", "4", ")", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "max", "out", " ", "must", " ", "have", " ", "nd", "=", "4", ",", " ", "got", " ", "nd", "=", "%%", "i", "\",", " ", "%", "(", "max", "out", ")", "s", "->", "nd", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", " ", "//", "setup", "\\u", "nv", "\\u", "max", "out", " ", "brace", " ", "1", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "*", " ", "max", "out", "\\u", "dims", " ", "=", " ", "Cu", "da", "Nd", "array", "\\u", "HOST", "\\u", "DIM", "S", "(%", "(", "max", "out", ")", "s", ");", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "max", "out", "\\u", "channel", "s", " ", "=", " ", "max", "out", "\\u", "dims", "[", "0", "];", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "max", "out", "Size", "Y", " ", "=", " ", "max", "out", "\\u", "dims", "[", "1", "];", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "max", "out", "Size", "X", " ", "=", " ", "max", "out", "\\u", "dims", "[", "2", "];", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "if", "(", "max", "out", "Size", "Y", " ", "!=", " ", "max", "out", "Size", "X", "){", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "max", "out", " ", "must", " ", "be", " ", "square", "(", "dims", "[", "1", "]", " ", "==", " ", "dims", "[", "2", "])", ".\"", "\\", "10", ";", " ", " ", " ", " ", "\"", " ", "Shape", " ", "(%", "%", "i", ",%", "%", "i", ",%", "%", "i", ",%", "%", "i", ")\"", ",", "\\", "10", ";", " ", " ", " ", " ", "max", "out", "\\u", "channel", "s", ",", " ", "max", "out", "Size", "Y", ",", " ", "max", "out", "Size", "X", ",", " ", "batch", "\\u", "size", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "if", "(", "img", "\\u", "channel", "s", " ", "!=", " ", "max", "out", "\\u", "channel", "s", "){", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "img", "\\u", "channel", "s", "(%", "%", "d", ")", " ", "shou", "ld", " ", "be", " ", "equal", " ", "to", " ", "max", "out", "\\u", "channel", "s", "(%", "%", "d", ").", "\",", "\\", "10", ";", " ", " ", " ", " ", "img", "\\u", "channel", "s", ",", " ", "max", "out", "\\u", "channel", "s", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "if", "(", "max", "out", "\\u", "dims", "[", "3", "]", " ", "!=", " ", "batch", "\\u", "size", "){", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "batch", "\\u", "size", "(%", "%", "d", ")", " ", "shou", "ld", " ", "be", " ", "equal", " ", "to", " ", "max", "out", "\\u", "dims", "[", "3", "](", "%%", "d", ")\"", ",", "\\", "10", ";", " ", " ", " ", " ", "batch", "\\u", "size", ",", " ", "max", "out", "\\u", "dims", "[", "3", "])", ";", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", "NV", "Matrix", " ", "nv", "\\u", "max", "out", "(%", "(", "max", "out", ")", "s", ",", " ", "img", "\\u", "channel", "s", " ", "*", " ", "max", "out", "Size", "Y", " ", "*", " ", "max", "out", "Size", "X", ",", "\\", "10", ";", " ", " ", " ", " ", "batch", "\\u", "size", ",", " ", "\"", "Max", "Poo", "l", ":", "nv", "\\u", "max", "out", "\");", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "braces", "_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Convert", " ", "gz", " ", "in", " ", "nv", "\\u", "gz_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "gz_", "=_", "self_", "._", "\\u", "argu", "ment", "\\u", "conti", "guit", "y", "\\u", "check_", "(_", "\"", "gz", "\"_", ")_", "+_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(%", "(", "gz", ")", "s", "->", "nd", " ", "!=", " ", "4", ")", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "gz", " ", "must", " ", "have", " ", "nd", "=", "4", ",", " ", "got", " ", "nd", "=", "%%", "i", "\",", " ", "%", "(", "gz", ")", "s", "->", "nd", ");", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(", "Cu", "da", "Nd", "array", "\\u", "HOST", "\\u", "DIM", "S", "(%", "(", "gz", ")", "s", ")[", "0", "]", " ", "%%", " ", "16", " ", "!=", " ", "0", ")", "\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "gz", " ", "must", " ", "have", " ", "a", " ", "number", " ", "of", " ", "channel", "s", " ", "tha", "t", " ", "is", " ", "a", " ", "multiple", " ", "of", " ", "16.", " ", "Got", " ", "%%", "d", "\",", "\\", "10", ";", " ", " ", " ", " ", "Cu", "da", "Nd", "array", "\\u", "HOST", "\\u", "DIM", "S", "(%", "(", "gz", ")", "s", ")[", "0", "])", ";", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", " ", "//", "setup", "\\u", "nv", "\\u", "gz", " ", "brace", " ", "1", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "*", " ", "gz", "\\u", "dims", " ", "=", " ", "Cu", "da", "Nd", "array", "\\u", "HOST", "\\u", "DIM", "S", "(%", "(", "gz", ")", "s", ");", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "gz", "\\u", "channel", "s", " ", "=", " ", "gz", "\\u", "dims", "[", "0", "];", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "gz", "Size", "Y", " ", "=", " ", "gz", "\\u", "dims", "[", "1", "];", "\\", "10", ";", " ", " ", " ", " ", "const", " ", "int", " ", "gz", "Size", "X", " ", "=", " ", "gz", "\\u", "dims", "[", "2", "];", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "if", "(", "max", "out", "\\u", "dims", "[", "0", "]", " ", "!=", " ", "gz", "\\u", "dims", "[", "0", "]", " ", "||", "\\", "10", ";", " ", " ", " ", "max", "out", "\\u", "dims", "[", "1", "]", " ", "!=", " ", "gz", "\\u", "dims", "[", "1", "]", " ", "||", "\\", "10", ";", " ", " ", " ", "max", "out", "\\u", "dims", "[", "2", "]", " ", "!=", " ", "gz", "\\u", "dims", "[", "2", "]", " ", "||", "\\", "10", ";", " ", " ", " ", "max", "out", "\\u", "dims", "[", "3", "]", " ", "!=", " ", "gz", "\\u", "dims", "[", "3", "])", "{", "\\", "10", ";", " ", " ", " ", " ", "Py", "Err", "\\u", "Format", "(", "Py", "Exc", "\\u", "Value", "Error", ",", "\\", "10", ";", " ", " ", " ", " ", "\"", "gz", " ", "shape", "(%", "%", "d", ",", " ", "%%", "d", ",", " ", "%%", "d", ",", " ", "%%", "d", ")", " ", "must", " ", "be", " ", "the", " ", "same", "\"", "\\", "10", ";", " ", " ", " ", " ", "\"", " ", "as", " ", "max", "out", "(%", "%", "d", ",", " ", "%%", "d", ",", " ", "%%", "d", ",", " ", "%%", "d", ")\"", ",", "\\", "10", ";", " ", " ", " ", " ", "max", "out", "\\u", "dims", "[", "0", "],", " ", "max", "out", "\\u", "dims", "[", "1", "],", " ", "max", "out", "\\u", "dims", "[", "2", "],", " ", "max", "out", "\\u", "dims", "[", "3", "],", "\\", "10", ";", " ", " ", " ", " ", "gz", "\\u", "dims", "[", "0", "],", " ", "gz", "\\u", "dims", "[", "1", "],", " ", "gz", "\\u", "dims", "[", "2", "],", " ", "gz", "\\u", "dims", "[", "3", "])", ";", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "NV", "Matrix", " ", "nv", "\\u", "gz", "(%", "(", "gz", ")", "s", ",", " ", "img", "\\u", "channel", "s", " ", "*", " ", "max", "out", "Size", "Y", " ", "*", " ", "max", "out", "Size", "X", ",", "\\", "10", ";", " ", " ", " ", " ", " ", "batch", "\\u", "size", ",", " ", "\"", "Max", "Poo", "l", ":", "nv", "\\u", "gz", "\");", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "braces", "_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "targets_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "//", "int", " ", "\\u", "output", "s", "X", " ", "=", " ", "int", "(", "ceil", "((", "dic", "['", "img", "Size", "']", " ", "-", " ", "dic", "['", "start", "']", " ", "-", " ", "dic", "['", "size", "X", "'])", " ", "/", " ", "float", "(", "dic", "['", "stride", "'])", "))", " ", "+", " ", "1", ";", "\\", "10", ";", " ", " ", " ", " ", "int", " ", "\\u", "output", "s", "X", " ", "=", " ", "((", "int", ")(", "ceil", "((", "img", "Size", "Y", " ", "-", " ", "%", "(", "start", ")", "s", " ", "-", " ", "%", "(", "ds", ")", "s", ")", " ", "/", " ", "((", "float", ")%", "(", "stride", ")", "s", "))))", " ", "+", " ", "1", ";", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "int", " ", "target", "\\u", "dims", " ", "[]", " ", "=", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "img", "\\u", "channel", "s", ",", "\\", "10", ";", " ", " ", " ", " ", "img", "Size", "X", ",", "\\", "10", ";", " ", " ", " ", " ", "img", "Size", "Y", ",", "\\", "10", ";", " ", " ", " ", " ", "batch", "\\u", "size", " ", "};", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "(", "Cu", "da", "Nd", "array", "\\u", "prep", "\\u", "output", "(", "&", " ", "%", "(", "target", "s", ")", "s", ",", " ", "4", ",", " ", "target", "\\u", "dims", "))\\", "10", ";", " ", " ", " ", " ", "{", "\\", "10", ";", " ", " ", " ", " ", "%", "(", "fail", ")", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "}", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "{", " ", "//", " ", "setup", "\\u", "nv", "\\u", "target", " ", "brace", " ", "#", " ", "1", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "NV", "Matrix", " ", "nv", "\\u", "target", "s", "(%", "(", "target", "s", ")", "s", ",", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "target", "\\u", "dims", "[", "0", "]", " ", "*", " ", "target", "\\u", "dims", "[", "1", "]", " ", "*", " ", "target", "\\u", "dims", "[", "2", "],", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "target", "\\u", "dims", "[", "3", "],", " ", "\"", "Max", "Poo", "l", ":", "nv", "\\u", "target", "s", "\");", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "braces", "_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "undo", "\\u", "pool_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "conv", "Local", "Max", "Und", "o", "(", "nv", "\\u", "images", ",", " ", "nv", "\\u", "gz", ",", " ", "nv", "\\u", "max", "out", ",", " ", "nv", "\\u", "target", "s", ",", "\\", "10", ";", " ", " ", " ", "%", "(", "ds", ")", "s", ",", " ", "%", "(", "start", ")", "s", ",", " ", "%", "(", "stride", ")", "s", ",", " ", "\\u", "output", "s", "X", ",", " ", "0", ",", " ", "1", ");", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "braces", "_", "=_", "'}'_", "*_", "num", "\\u", "braces", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rval_", "=_", "(_", "basic", "\\u", "setup_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "images_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "max", "out_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "gz_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "nv", "\\u", "targets_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "undo", "\\u", "pool_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "braces", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start_", "=_", "self_", "._", "start_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stride_", "=_", "self_", "._", "stride_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ds_", "=_", "self_", "._", "ds_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rval_", "=_", "rval_", "%_", "locals_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "rval_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Max", "Poo", "l", "Grad", "_", "(_", "Gp", "u", "Op_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "make", "\\u", "thu", "nk_", "(_", "self_", ",_", "node_", ",_", "storage", "\\u", "map_", ",_", "compute", "\\u", "map_", ",_", "no", "\\u", "recycl", "ing_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "..", " ", "todo", "::", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "WRITE", "ME", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "conv", "net", "\\u", "available_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Run", "time", "Error_", "(_", "'", "Cou", "ld", " ", "not", " ", "compile", " ", "cud", "a", "\\u", "conv", "net", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "super_", "(_", "Max", "Poo", "l", "Grad", "_", ",_", "self_", ")_", "._", "make", "\\u", "thu", "nk_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "node_", ",_", "storage", "\\u", "map_", ",_", "compute", "\\u", "map_", ",_", "no", "\\u", "recycl", "ing_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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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 ]
Except block handles 'BaseException'
enthought/envisage/envisage/ui/single_project/project_runnable.py
[ { "content": " def run(self, application):\n \"\"\"\n Run this runnable.\n\n Overridden here to: (a) ensure the UI service monitors for the\n closing of the application, and (b) restore the last opened\n project.\n\n \"\"\"\n\n # Ensure our UI service is listening for the application to close.\n # FIXME: This ugly hack (doing this here) is necessary only because\n # this plugin contributes to the workbench plugin and that means the\n # workbench insists on starting us first which means our UI service\n # can't directly reference the workbench service until after\n # everything has been started.\n ui_service = application.get_service(IPROJECT_UI)\n ui_service.listen_for_application_exit()\n\n # Load the project we were using when we last shutdown.\n model_service = application.get_service(IPROJECT_MODEL)\n location = model_service.preferences.get('project location',\n default=None)\n if location and len(location) > 0:\n logger.info(\"Opening last project from location [%s]\", location)\n\n try:\n project = model_service.factory.open(location)\n except:\n logger.exception('Error during opening of last project.')\n project = None\n\n if project is not None:\n model_service.project = project\n else:\n information(self._get_parent_window(application),\n 'Unable to open last project from location:\\t\\n'\n '\\t%s\\n' % (location) + '\\n\\n'\n 'The project may no longer exist.',\n 'Can Not Open Last Project',\n )\n\n else:\n logger.info('No previous project to open')\n\n return", "metadata": "root.ProjectRunnable.run", "header": "['class', 'ProjectRunnable', '(', 'Runnable', ')', ':', '___EOS___']", "index": 42 }, { "content": " def _get_parent_window(self, application):\n \"\"\"\n Find and return a reference to the application window.\n\n If one can not be found, then 'None' is returned.\n\n \"\"\"\n\n window = None\n try:\n workbench = application.get_service(IWORKBENCH)\n window = workbench.active_window.control\n except:\n logger.warn('Unable to retrieve application window reference.')\n\n return window", "metadata": "root.ProjectRunnable._get_parent_window", "header": "['class', 'ProjectRunnable', '(', 'Runnable', ')', ':', '___EOS___']", "index": 92 } ]
[ { "span": "except:", "start_line": 70, "start_column": 12, "end_line": 70, "end_column": 19 }, { "span": "except:", "start_line": 104, "start_column": 8, "end_line": 104, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Project", "Run", "nable", "_", "(_", "Run", "nable", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "run_", "(_", "self_", ",_", "application_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Run", " ", "this", " ", "runnable", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Over", "rid", "den", " ", "here", " ", "to", ":", " ", "(", "a", ")", " ", "ensure", " ", "the", " ", "UI", " ", "service", " ", "monit", "ors", " ", "for", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "clos", "ing", " ", "of", " ", "the", " ", "applica", "tion", ",", " ", "and", " ", "(", "b", ")", " ", "restore", " ", "the", " ", "last", " ", "opene", "d", "\\", "10", ";", " ", " ", " ", " ", "project", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Ensur", "e", " ", "our", " ", "UI", " ", "service", " ", "is", " ", "listen", "ing", " ", "for", " ", "the", " ", "applica", "tion", " ", "to", " ", "close", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "FIX", "ME", ":", " ", "Thi", "s", " ", "ug", "ly", " ", "hack", " ", "(", "doi", "ng", " ", "this", " ", "here", ")", " ", "is", " ", "necessar", "y", " ", "only", " ", "bec", "aus", "e_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "this", " ", "plugin", " ", "contribute", "s", " ", "to", " ", "the", " ", "work", "bench", " ", "plugin", " ", "and", " ", "tha", "t", " ", "means", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "work", "bench", " ", "insi", "sts", " ", "on", " ", "startin", "g", " ", "us", " ", "first", " ", "whi", "ch", " ", "means", " ", "our", " ", "UI", " ", "service_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "can", "'", "t", " ", "direct", "ly", " ", "reference", " ", "the", " ", "work", "bench", " ", "service", " ", "unti", "l", " ", "after_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "every", "thing", " ", "has", " ", "bee", "n", " ", "start", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "ui", "\\u", "service_", "=_", "application_", "._", "get", "\\u", "service_", "(_", "IP", "RO", "JE", "CT", "\\u", "UI_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ui", "\\u", "service_", "._", "listen", "\\u", "for", "\\u", "applica", "tion", "\\u", "exit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Load", " ", "the", " ", "project", " ", "we", " ", "wer", "e", " ", "usi", "ng", " ", "whe", "n", " ", "we", " ", "last", " ", "shut", "down", "._", "\\u\\u\\uNL\\u\\u\\u_", "model", "\\u", "service_", "=_", "application_", "._", "get", "\\u", "service_", "(_", "IP", "RO", "JE", "CT", "\\u", "MODEL_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "location_", "=_", "model", "\\u", "service_", "._", "preferences_", "._", "get_", "(_", "'", "project", " ", "location", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "location_", "and_", "len_", "(_", "location_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "info_", "(_", "\"", "Open", "ing", " ", "last", " ", "project", " ", "from", " ", "location", " ", "[", "%", "s", "]\"_", ",_", "location_", ")_", "\\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 ", " _", "project_", "=_", "model", "\\u", "service_", "._", "factory_", "._", "open_", "(_", "location_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "exception_", "(_", "'", "Error", " ", "dur", "ing", " ", "opening", " ", "of", " ", "last", " ", "project", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "project_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "project_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "model", "\\u", "service_", "._", "project_", "=_", "project_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "information_", "(_", "self_", "._", "\\u", "get", "\\u", "parent", "\\u", "window_", "(_", "application_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Una", "ble", " ", "to", " ", "open", " ", "last", " ", "project", " ", "from", " ", "location", ":\\\\", "t", "\\\\", "n", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'\\\\", "t", "%", "s", "\\\\", "n", "'_", "%_", "(_", "location_", ")_", "+_", "'\\\\", "n", "\\\\", "n", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "The", " ", "project", " ", "may", " ", "no", " ", "long", "er", " ", "exist", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Can", " ", "Not", " ", "Open", " ", "Las", "t", " ", "Project", "'_", ",_", "\\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 ", " _", "logger_", "._", "info_", "(_", "'", "No", " ", "previ", "ous", " ", "project", " ", "to", " ", "open", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Project", "Run", "nable", "_", "(_", "Run", "nable", "_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "get", "\\u", "parent", "\\u", "window_", "(_", "self_", ",_", "application_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Fin", "d", " ", "and", " ", "return", " ", "a", " ", "reference", " ", "to", " ", "the", " ", "applica", "tion", " ", "window", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "one", " ", "can", " ", "not", " ", "be", " ", "found", ",", " ", "then", " ", "'", "Non", "e", "'", " ", "is", " ", "return", "ed", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "window_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "work", "bench_", "=_", "application_", "._", "get", "\\u", "service_", "(_", "IW", "OR", "KB", "ENC", "H_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "window_", "=_", "work", "bench_", "._", "active", "\\u", "window_", "._", "control_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warn_", "(_", "'", "Una", "ble", " ", "to", " ", "retrieve", " ", "applica", "tion", " ", "window", " ", "reference", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "window_", "\\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,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"content": "import logging\n\nfrom pylons import request, response, session, tmpl_context as c\nfrom pylons.controllers.util import abort, redirect_to\n\nfrom anygit.lib import helpers\nfrom anygit.lib.base import BaseController, render\nfrom anygit import models\nfrom anygit.client import fetch\n\nlog = logging.getLogger(__name__)\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class IndexController(BaseController):\n\n", "metadata": "root.IndexController", "header": "['module', '___EOS___']", "index": 12 }, { "content": " def index(self):\n return render('index.mako', controller='index')", "metadata": "root.IndexController.index", "header": "['class', 'IndexController', '(', 'BaseController', ')', ':', '___EOS___']", "index": 13 }, { "content": " def about(self):\n return render('about.mako', controller='index')", "metadata": "root.IndexController.about", "header": "['class', 'IndexController', '(', 'BaseController', ')', ':', '___EOS___']", "index": 16 }, { "content": " def do_request(self):\n urls = request.params.get('url', '').strip()\n if not urls:\n helpers.error('You did not provide a URL.')\n \n for url in urls.split('\\n'):\n url = models.Repository.canonicalize(url.strip())\n if not url:\n continue\n \n if models.Repository.exists(url=url):\n repo = models.Repository.get_by_attributes(url=url)\n if repo.approved:\n helpers.flash('Someone has already requested indexing of %s, '\n 'so no worries.' % url)\n else:\n if not url.startswith('git://'):\n helpers.flash(\"That repo (%s) has been already requested. At the \"\n \"moment, anygit only supports git protocol (git://) \"\n \"repositories. Once we've added support for this \"\n \"repo's protocol, we'll index it.\" % url)\n elif not fetch.check_validity(repo):\n helpers.error(\"That's odd... someone already asked for %s, but it looks \"\n \"to us like we can't talk to that repo. Is there a typo \"\n \"in there? If not, please email [email protected].\" % url)\n else:\n repo.approved = True\n repo.save()\n helpers.flash(\"Someone had requested %s before but it was down then. \"\n \"Looks like it's back up now. We'll get right to it.\" % url)\n else:\n repo = models.Repository.create(url=url)\n if not url.startswith('git://'):\n helpers.flash('Successfully requested %s for future indexing. However, '\n 'please note that only git protocol (git://) '\n 'repositories are currently supported by anygit.' % url)\n # Make sure we can talk to it\n elif not fetch.check_validity(repo):\n helpers.error(\"Could not talk to %s; are you sure it's a valid URL?\" % url)\n else:\n repo.approved = True\n repo.save()\n helpers.flash('Successfully requested %s for indexing.' % url)\n \n models.flush()\n redirect_to('/')", "metadata": "root.IndexController.do_request", "header": "['class', 'IndexController', '(', 'BaseController', ')', ':', '___EOS___']", "index": 19 } ]
[ { "span": "from pylons import request, response, session, tmpl_context as c", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 64 }, { "span": "from pylons.controllers.util import abort, redirect_to", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 54 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "pylon", "s_", "import_", "request_", ",_", "response_", ",_", "session_", ",_", "tmpl", "\\u", "context_", "as_", "c_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pylon", "s_", "._", "controllers_", "._", "util_", "import_", "abort_", ",_", "redirec", "t", "\\u", "to_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "any", "git_", "._", "lib_", "import_", "helpers_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "any", "git_", "._", "lib_", "._", "base_", "import_", "Base", "Controller_", ",_", "render_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "any", "git_", "import_", "models_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "any", "git_", "._", "client_", "import_", "fetch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "log_", "=_", "logging_", "._", "get", "Logger_", "(_", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "Index", "Controller_", "(_", "Base", "Controller_", ")_", ":_", "\\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_", "Index", "Controller_", "(_", "Base", "Controller_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "index_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "render_", "(_", "'", "index", ".", "mak", "o", "'_", ",_", "controller_", "=_", "'", "index", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Index", "Controller_", "(_", "Base", "Controller_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "about_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "render_", "(_", "'", "abo", "ut", ".", "mak", "o", "'_", ",_", "controller_", "=_", "'", "index", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Index", "Controller_", "(_", "Base", "Controller_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "do", "\\u", "request_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "urls_", "=_", "request_", "._", "params_", "._", "get_", "(_", "'", "url", "'_", ",_", "''_", ")_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "urls_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "helpers_", "._", "error_", "(_", "'", "You", " ", "did", " ", "not", " ", "provide", " ", "a", " ", "URL", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "url_", "in_", "urls_", "._", "split_", "(_", "'\\\\", "n", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "url_", "=_", "models_", "._", "Repository_", "._", "canonicaliz", "e_", "(_", "url_", "._", "strip_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "url_", ":_", "\\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_", "if_", "models_", "._", "Repository_", "._", "exists_", "(_", "url_", "=_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "repo_", "=_", "models_", "._", "Repository_", "._", "get", "\\u", "by", "\\u", "attributes_", "(_", "url_", "=_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "repo_", "._", "approved", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "helpers_", "._", "flash_", "(_", "'", "Some", "one", " ", "has", " ", "alr", "ead", "y", " ", "request", "ed", " ", "indexing", " ", "of", " ", "%", "s", ",", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "so", " ", "no", " ", "wor", "rie", "s", ".'_", "%_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "not_", "url_", "._", "startswith_", "(_", "'", "git", "://'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "helpers_", "._", "flash_", "(_", "\"", "Tha", "t", " ", "repo", " ", "(%", "s", ")", " ", "has", " ", "bee", "n", " ", "alr", "ead", "y", " ", "request", "ed", ".", " ", " ", "At", " ", "the", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "moment", ",", " ", "any", "git", " ", "only", " ", "support", "s", " ", "git", " ", "protoc", "ol", " ", "(", "git", "://", ")", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "repos", "itori", "es", ".", " ", " ", "On", "ce", " ", "we", "'", "ve", " ", "adde", "d", " ", "support", " ", "for", " ", "this", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "repo", "'", "s", " ", "protoc", "ol", ",", " ", "we", "'", "ll", " ", "index", " ", "it", ".\"_", "%_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "fetch_", "._", "check", "\\u", "validity_", "(_", "repo_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "helpers_", "._", "error_", "(_", "\"", "Tha", "t", "'", "s", " ", "odd", "...", " ", "some", "one", " ", "alr", "ead", "y", " ", "ask", "ed", " ", "for", " ", "%", "s", ",", " ", "but", " ", "it", " ", "look", "s", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "to", " ", "us", " ", "like", " ", "we", " ", "can", "'", "t", " ", "talk", " ", "to", " ", "tha", "t", " ", "repo", ".", " ", " ", "Is", " ", "there", " ", "a", " ", "typo", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "in", " ", "there", "?", " ", " ", "If", " ", "not", ",", " ", "plea", "se", " ", "email", " ", "any", "git", "@", "mit", ".", "edu", ".\"_", "%_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "repo_", "._", "approved", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "repo_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "helpers_", "._", "flash_", "(_", "\"", "Some", "one", " ", "had", " ", "request", "ed", " ", "%", "s", " ", "bef", "ore", " ", "but", " ", "it", " ", "was", " ", "down", " ", "then", ".", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Look", "s", " ", "like", " ", "it", "'", "s", " ", "back", " ", "up", " ", "now", ".", " ", " ", "We", "'", "ll", " ", "get", " ", "right", " ", "to", " ", "it", ".\"_", "%_", "url_", ")_", "\\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 ", " _", "repo_", "=_", "models_", "._", "Repository_", "._", "create_", "(_", "url_", "=_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "url_", "._", "startswith_", "(_", "'", "git", "://'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "helpers_", "._", "flash_", "(_", "'", "Success", "full", "y", " ", "request", "ed", " ", "%", "s", " ", "for", " ", "future", " ", "indexing", ".", " ", " ", "Ho", "we", "ver", ",", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "plea", "se", " ", "note", " ", "tha", "t", " ", "only", " ", "git", " ", "protoc", "ol", " ", "(", "git", "://", ")", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "repos", "itori", "es", " ", "are", " ", "currentl", "y", " ", "support", "ed", " ", "by", " ", "any", "git", ".'_", "%_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "we", " ", "can", " ", "talk", " ", "to", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "not_", "fetch_", "._", "check", "\\u", "validity_", "(_", "repo_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "helpers_", "._", "error_", "(_", "\"", "Cou", "ld", " ", "not", " ", "talk", " ", "to", " ", "%", "s", ";", " ", "are", " ", "you", " ", "sure", " ", "it", "'", "s", " ", "a", " ", "valid", " ", "URL", "?\"_", "%_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "repo_", "._", "approved", "_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "repo_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "helpers_", "._", "flash_", "(_", "'", "Success", "full", "y", " ", "request", "ed", " ", "%", "s", " ", "for", " ", "indexing", ".'_", "%_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "models_", "._", "flush_", "(_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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
CGATOxford/cgat/obsolete/pipeline_prdm9.py
[ { "content": "@transform( alignToProfile\n , suffix( \".mali\")\n , \".import\" )\ndef importMaliStats( infile, outfile ):\n '''import stats.'''\n \n table = P.toTable( outfile ) + \"_info\" \n statement = '''\n python %(scriptsdir)s/csv2db.py %(csv2db_options)s\n --index=read_id \n --table=%(table)s \n < %(infile)s.info\n > %(outfile)s\n '''\n P.run()", "metadata": "root.importMaliStats", "header": "['module', '___EOS___']", "index": 289 }, { "content": "@transform( alignToProfile\n , suffix( \"_na.mali\")\n , \"_aa.mali\" )\ndef buildMalisCodon( infile, outfile ):\n '''build codon alignments\n\n The frame is given by the master multiple alignment.\n\n Sequences with indels that are not multiples of three\n are removed.\n\n Sequences with stop codons are removed.\n TODO\n '''\n \n statement = '''\n cat %(infile)s\n | python %(scriptsdir)s/fasta2fasta.py --method=translate \n | perl -p -e \"s/[a-z]/-/g unless (/^>/)\"\n | python %(scriptsdir)s/mali2mali.py --method=remove-all-gaps --log=%(outfile)s.log --allow-duplicates\n\n > %(outfile)s\n '''\n \n P.run()", "metadata": "root.buildMalisCodon", "header": "['module', '___EOS___']", "index": 305 }, { "content": "@transform( alignToProfile\n , suffix( \"_na.mali\")\n , \"_aa.mali\" )\ndef buildMalisAA( infile, outfile ):\n '''translate multiple alignments.\n\n The frame is given by the master multiple alignment.\n\n Indels in other sequences are ignored.\n '''\n \n statement = '''\n cat %(infile)s\n | perl -p -e \"s/[a-z]/-/g unless (/^>/)\"\n | python %(scriptsdir)s/mali2mali.py --method=remove-all-gaps --log=%(outfile)s.log --allow-duplicates\n | python %(scriptsdir)s/fasta2fasta.py --method=translate \n > %(outfile)s\n '''\n \n P.run()", "metadata": "root.buildMalisAA", "header": "['module', '___EOS___']", "index": 332 }, { "content": "@transform( alignToProfile\n , suffix( \"_na.mali\")\n , \"_na.columns\" )\ndef computeColumnStatsNA( infile, outfile ):\n '''compute stats per column.\n\n Only columns are counted that are non-insert with respect to\n the master alignment. The master alignment columns are\n later removed in order to count only sequences within \n a strain.\n '''\n \n statement = '''\n cat %(infile)s\n | perl -p -e \"s/[a-z]/-/g unless (/^>/)\"\n | python %(scriptsdir)s/mali2mali.py --method=remove-all-gaps --log=%(outfile)s.log --allow-duplicates\n | python %(scriptsdir)s/fasta2fasta.py --exclude=\"(^mouse)\" --log=%(outfile)s.log\n | python %(scriptsdir)s/mali2table.py --section=all --log=%(outfile)s.log --allow-duplicates\n > %(outfile)s\n '''\n \n P.run()", "metadata": "root.computeColumnStatsNA", "header": "['module', '___EOS___']", "index": 353 }, { "content": "@transform( buildMalisAA\n , suffix( \"_aa.mali\")\n , \"_aa.columns\" )\ndef computeColumnStatsAA( infile, outfile ):\n '''compute stats per column.\n\n Only columns are counted that are non-insert with respect to\n the master alignment. The master alignment columns are\n later removed.\n '''\n \n statement = '''\n cat %(infile)s\n | perl -p -e \"s/[X?]/-/g unless (/^>/)\"\n | python %(scriptsdir)s/fasta2fasta.py --exclude=\"(^mouse)\" --log=%(outfile)s.log\n | python %(scriptsdir)s/mali2table.py --section=all --log=%(outfile)s.log --allow-duplicates --alphabet=aa\n > %(outfile)s\n '''\n \n P.run()", "metadata": "root.computeColumnStatsAA", "header": "['module', '___EOS___']", "index": 376 }, { "content": "@transform( (computeColumnStatsNA, computeColumnStatsAA)\n , suffix( \".columns\")\n , \"_columns.import\" )\ndef importColumnStats( infile, outfile ):\n '''import stats.'''\n \n table = P.toTable( outfile ) \n statement = '''\n python %(scriptsdir)s/csv2db.py %(csv2db_options)s\n --index=column \n --table=%(table)s \n < %(infile)s\n > %(outfile)s\n '''\n P.run()", "metadata": "root.importColumnStats", "header": "['module', '___EOS___']", "index": 397 } ]
[ { "span": "table ", "start_line": 295, "start_column": 4, "end_line": 295, "end_column": 9 }, { "span": "statement ", "start_line": 296, "start_column": 4, "end_line": 296, "end_column": 13 }, { "span": "statement ", "start_line": 320, "start_column": 4, "end_line": 320, "end_column": 13 }, { "span": "statement ", "start_line": 343, "start_column": 4, "end_line": 343, "end_column": 13 }, { "span": "statement ", "start_line": 365, "start_column": 4, "end_line": 365, "end_column": 13 }, { "span": "statement ", "start_line": 387, "start_column": 4, "end_line": 387, "end_column": 13 }, { "span": "table ", "start_line": 403, "start_column": 4, "end_line": 403, "end_column": 9 }, { "span": "statement ", "start_line": 404, "start_column": 4, "end_line": 404, "end_column": 13 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "transform_", "(_", "align", "To", "Profile_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "suffix_", "(_", "\".", "mali", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "\".", "import", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "import", "Mal", "i", "Stats_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "import", " ", "stats", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "table_", "=_", "P_", "._", "to", "Table_", "(_", "outfile_", ")_", "+_", "\"\\u", "info", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "\\", "10", ";", " ", " ", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "csv", "2d", "b", ".", "py", " ", "%", "(", "csv", "2d", "b", "\\u", "options", ")", "s", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "--", "index", "=", "read", "\\u", "id", " ", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "--", "table", "=", "%", "(", "table", ")", "s", " ", "\\", "10", ";", " ", " ", " ", " ", "<", " ", "%", "(", "infile", ")", "s", ".", "info", "\\", "10", ";", " ", " ", " ", " ", ">", " ", "%", "(", "outfile", ")", "s", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "transform_", "(_", "align", "To", "Profile_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "suffix_", "(_", "\"\\u", "na", ".", "mali", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "\"\\u", "aa", ".", "mali", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "build", "Mal", "is", "Cod", "on_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "build", " ", "codon", " ", "alignme", "nts", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "frame", " ", "is", " ", "give", "n", " ", "by", " ", "the", " ", "master", " ", "multiple", " ", "alignme", "nt", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Sequences", " ", "with", " ", "indel", "s", " ", "tha", "t", " ", "are", " ", "not", " ", "multiple", "s", " ", "of", " ", "three", "\\", "10", ";", " ", " ", " ", " ", "are", " ", "remove", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Sequences", " ", "with", " ", "stop", " ", "codon", "s", " ", "are", " ", "remove", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "TOD", "O", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "statement_", "=_", "'''", "\\", "10", ";", " ", " ", " ", " ", "cat", " ", "%", "(", "infile", ")", "s", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "fasta", "2f", "asta", ".", "py", " ", "--", "method", "=", "translat", "e", " ", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "perl", " ", "-", "p", " ", "-", "e", " ", "\"", "s", "/", "[", "a", "-", "z", "]/", "-", "/", "g", " ", "unl", "ess", " ", "(/", "^", ">/", ")\"", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "mali", "2ma", "li", ".", "py", " ", "--", "method", "=", "remove", "-", "all", "-", "gap", "s", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "--", "allow", "-", "duplicat", "es", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ">", " ", "%", "(", "outfile", ")", "s", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "transform_", "(_", "align", "To", "Profile_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "suffix_", "(_", "\"\\u", "na", ".", "mali", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "\"\\u", "aa", ".", "mali", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "build", "Mal", "is", "AA_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "translat", "e", " ", "multiple", " ", "alignme", "nts", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "frame", " ", "is", " ", "give", "n", " ", "by", " ", "the", " ", "master", " ", "multiple", " ", "alignme", "nt", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Inde", "ls", " ", "in", " ", "other", " ", "sequence", "s", " ", "are", " ", "ignore", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "statement_", "=_", "'''", "\\", "10", ";", " ", " ", " ", " ", "cat", " ", "%", "(", "infile", ")", "s", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "perl", " ", "-", "p", " ", "-", "e", " ", "\"", "s", "/", "[", "a", "-", "z", "]/", "-", "/", "g", " ", "unl", "ess", " ", "(/", "^", ">/", ")\"", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "mali", "2ma", "li", ".", "py", " ", "--", "method", "=", "remove", "-", "all", "-", "gap", "s", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "--", "allow", "-", "duplicat", "es", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "fasta", "2f", "asta", ".", "py", " ", "--", "method", "=", "translat", "e", " ", "\\", "10", ";", " ", " ", " ", " ", ">", " ", "%", "(", "outfile", ")", "s", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "transform_", "(_", "align", "To", "Profile_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "suffix_", "(_", "\"\\u", "na", ".", "mali", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "\"\\u", "na", ".", "column", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "compute", "Colum", "n", "Stat", "s", "NA_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "compute", " ", "stats", " ", "per", " ", "column", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "On", "ly", " ", "column", "s", " ", "are", " ", "counted", " ", "tha", "t", " ", "are", " ", "non", "-", "insert", " ", "with", " ", "respec", "t", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "master", " ", "alignme", "nt", ".", " ", "The", " ", "master", " ", "alignme", "nt", " ", "column", "s", " ", "are", "\\", "10", ";", " ", " ", " ", " ", "late", "r", " ", "remove", "d", " ", "in", " ", "order", " ", "to", " ", "count", " ", "only", " ", "sequence", "s", " ", "within", " ", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "strain", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "statement_", "=_", "'''", "\\", "10", ";", " ", " ", " ", " ", "cat", " ", "%", "(", "infile", ")", "s", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "perl", " ", "-", "p", " ", "-", "e", " ", "\"", "s", "/", "[", "a", "-", "z", "]/", "-", "/", "g", " ", "unl", "ess", " ", "(/", "^", ">/", ")\"", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "mali", "2ma", "li", ".", "py", " ", "--", "method", "=", "remove", "-", "all", "-", "gap", "s", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "--", "allow", "-", "duplicat", "es", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "fasta", "2f", "asta", ".", "py", " ", "--", "exclu", "de", "=\"(", "^", "mouse", ")\"", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "mali", "2t", "able", ".", "py", " ", "--", "section", "=", "all", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "--", "allow", "-", "duplicat", "es", "\\", "10", ";", " ", " ", " ", " ", ">", " ", "%", "(", "outfile", ")", "s", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "transform_", "(_", "build", "Mal", "is", "AA_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "suffix_", "(_", "\"\\u", "aa", ".", "mali", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "\"\\u", "aa", ".", "column", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "compute", "Colum", "n", "Stat", "s", "AA_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "compute", " ", "stats", " ", "per", " ", "column", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "On", "ly", " ", "column", "s", " ", "are", " ", "counted", " ", "tha", "t", " ", "are", " ", "non", "-", "insert", " ", "with", " ", "respec", "t", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "master", " ", "alignme", "nt", ".", " ", "The", " ", "master", " ", "alignme", "nt", " ", "column", "s", " ", "are", "\\", "10", ";", " ", " ", " ", " ", "late", "r", " ", "remove", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "statement_", "=_", "'''", "\\", "10", ";", " ", " ", " ", " ", "cat", " ", "%", "(", "infile", ")", "s", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "perl", " ", "-", "p", " ", "-", "e", " ", "\"", "s", "/", "[", "X", "?]", "/-", "/", "g", " ", "unl", "ess", " ", "(/", "^", ">/", ")\"", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "fasta", "2f", "asta", ".", "py", " ", "--", "exclu", "de", "=\"(", "^", "mouse", ")\"", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", "\\", "10", ";", " ", " ", " ", " ", "|", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "mali", "2t", "able", ".", "py", " ", "--", "section", "=", "all", " ", "--", "log", "=", "%", "(", "outfile", ")", "s", ".", "log", " ", "--", "allow", "-", "duplicat", "es", " ", "--", "alpha", "bet", "=", "aa", "\\", "10", ";", " ", " ", " ", " ", ">", " ", "%", "(", "outfile", ")", "s", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "transform_", "(_", "(_", "compute", "Colum", "n", "Stat", "s", "NA_", ",_", "compute", "Colum", "n", "Stat", "s", "AA_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "suffix_", "(_", "\".", "column", "s", "\"_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ",_", "\"\\u", "column", "s", ".", "import", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "import", "Colum", "n", "Stats_", "(_", "infile_", ",_", "outfile_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "'''", "import", " ", "stats", ".'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "table_", "=_", "P_", "._", "to", "Table_", "(_", "outfile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "statement_", "=_", "'''", "\\", "10", ";", " ", " ", " ", "python", " ", "%", "(", "scripts", "dir", ")", "s", "/", "csv", "2d", "b", ".", "py", " ", "%", "(", "csv", "2d", "b", "\\u", "options", ")", "s", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "--", "index", "=", "column", " ", "\\", "10", ";", " ", " ", " ", " ", " ", " ", "--", "table", "=", "%", "(", "table", ")", "s", " ", "\\", "10", ";", " ", " ", " ", " ", "<", " ", "%", "(", "infile", ")", "s", "\\", "10", ";", " ", " ", " ", " ", ">", " ", "%", "(", "outfile", ")", "s", "\\", "10", ";", " ", " ", " ", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "P_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 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 ]
Imprecise assert
apache/libcloud/libcloud/test/compute/test_dimensiondata.py
[ { "content": " def test_server_states(self):\n DimensionDataMockHttp.type = None\n ret = self.driver.list_nodes()\n self.assertTrue(ret[0].state == 'running')\n self.assertTrue(ret[1].state == 'starting')\n self.assertTrue(ret[2].state == 'stopping')\n self.assertTrue(ret[3].state == 'reconfiguring')\n self.assertTrue(ret[4].state == 'running')\n self.assertTrue(ret[5].state == 'terminated')\n self.assertTrue(ret[6].state == 'stopped')\n self.assertEqual(len(ret), 7)", "metadata": "root.DimensionDataTests.test_server_states", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 87 }, { "content": " def test_reboot_node_response(self):\n node = Node(id='11', name=None, state=None,\n public_ips=None, private_ips=None, driver=self.driver)\n ret = node.reboot()\n self.assertTrue(ret is True)", "metadata": "root.DimensionDataTests.test_reboot_node_response", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 154 }, { "content": " def test_destroy_node_response(self):\n node = Node(id='11', name=None, state=None,\n public_ips=None, private_ips=None, driver=self.driver)\n ret = node.destroy()\n self.assertTrue(ret is True)", "metadata": "root.DimensionDataTests.test_destroy_node_response", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 167 }, { "content": " def test_clean_failed_deployment_response_with_node(self):\n node = Node(id='11', name=None, state=None,\n public_ips=None, private_ips=None, driver=self.driver)\n ret = self.driver.ex_clean_failed_deployment(node)\n self.assertTrue(ret is True)", "metadata": "root.DimensionDataTests.test_clean_failed_deployment_response_with_node", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 189 }, { "content": " def test_clean_failed_deployment_response_with_node_id(self):\n node = 'e75ead52-692f-4314-8725-c8a4f4d13a87'\n ret = self.driver.ex_clean_failed_deployment(node)\n self.assertTrue(ret is True)", "metadata": "root.DimensionDataTests.test_clean_failed_deployment_response_with_node_id", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 195 }, { "content": " def test_create_node_response_no_pass_random_gen(self):\n image = self.driver.list_images()[0]\n network = self.driver.ex_list_networks()[0]\n node = self.driver.create_node(name='test2', image=image, auth=None,\n ex_description='test2 node', ex_network=network,\n ex_is_started=False)\n self.assertEqual(node.id, 'e75ead52-692f-4314-8725-c8a4f4d13a87')\n self.assertEqual(node.extra['status'].action, 'DEPLOY_SERVER')\n self.assertTrue('password' in node.extra)", "metadata": "root.DimensionDataTests.test_create_node_response_no_pass_random_gen", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 219 }, { "content": " def test_create_node_response_no_pass_customer_windows(self):\n image = self.driver.ex_list_customer_images()[1]\n network = self.driver.ex_list_networks()[0]\n node = self.driver.create_node(name='test2', image=image, auth=None,\n ex_description='test2 node', ex_network=network,\n ex_is_started=False)\n self.assertEqual(node.id, 'e75ead52-692f-4314-8725-c8a4f4d13a87')\n self.assertEqual(node.extra['status'].action, 'DEPLOY_SERVER')\n self.assertTrue('password' in node.extra)", "metadata": "root.DimensionDataTests.test_create_node_response_no_pass_customer_windows", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 229 }, { "content": " def test_create_node_response_no_pass_customer_windows_STR(self):\n image = self.driver.ex_list_customer_images()[1].id\n network = self.driver.ex_list_networks()[0]\n node = self.driver.create_node(name='test2', image=image, auth=None,\n ex_description='test2 node', ex_network=network,\n ex_is_started=False)\n self.assertEqual(node.id, 'e75ead52-692f-4314-8725-c8a4f4d13a87')\n self.assertEqual(node.extra['status'].action, 'DEPLOY_SERVER')\n self.assertTrue('password' in node.extra)", "metadata": "root.DimensionDataTests.test_create_node_response_no_pass_customer_windows_STR", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 239 }, { "content": " def test_create_node_response_no_pass_customer_linux(self):\n image = self.driver.ex_list_customer_images()[0]\n network = self.driver.ex_list_networks()[0]\n node = self.driver.create_node(name='test2', image=image, auth=None,\n ex_description='test2 node', ex_network=network,\n ex_is_started=False)\n self.assertEqual(node.id, 'e75ead52-692f-4314-8725-c8a4f4d13a87')\n self.assertEqual(node.extra['status'].action, 'DEPLOY_SERVER')\n self.assertTrue('password' not in node.extra)", "metadata": "root.DimensionDataTests.test_create_node_response_no_pass_customer_linux", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 249 }, { "content": " def test_create_node_response_no_pass_customer_linux_STR(self):\n image = self.driver.ex_list_customer_images()[0].id\n network = self.driver.ex_list_networks()[0]\n node = self.driver.create_node(name='test2', image=image, auth=None,\n ex_description='test2 node', ex_network=network,\n ex_is_started=False)\n self.assertEqual(node.id, 'e75ead52-692f-4314-8725-c8a4f4d13a87')\n self.assertEqual(node.extra['status'].action, 'DEPLOY_SERVER')\n self.assertTrue('password' not in node.extra)", "metadata": "root.DimensionDataTests.test_create_node_response_no_pass_customer_linux_STR", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 259 }, { "content": " def test_ex_shutdown_graceful(self):\n node = Node(id='11', name=None, state=None,\n public_ips=None, private_ips=None, driver=self.driver)\n ret = self.driver.ex_shutdown_graceful(node)\n self.assertTrue(ret is True)", "metadata": "root.DimensionDataTests.test_ex_shutdown_graceful", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 434 }, { "content": " def test_ex_start_node(self):\n node = Node(id='11', name=None, state=None,\n public_ips=None, private_ips=None, driver=self.driver)\n ret = self.driver.ex_start_node(node)\n self.assertTrue(ret is True)", "metadata": "root.DimensionDataTests.test_ex_start_node", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 447 }, { "content": " def test_ex_power_off(self):\n node = Node(id='11', name=None, state=None,\n public_ips=None, private_ips=None, driver=self.driver)\n ret = self.driver.ex_power_off(node)\n self.assertTrue(ret is True)", "metadata": "root.DimensionDataTests.test_ex_power_off", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 460 }, { "content": " def test_ex_update_vm_tools(self):\n node = Node(id='11', name=None, state=None,\n public_ips=None, private_ips=None, driver=self.driver)\n ret = self.driver.ex_update_vm_tools(node)\n self.assertTrue(ret is True)", "metadata": "root.DimensionDataTests.test_ex_update_vm_tools", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 466 }, { "content": " def test_ex_reset(self):\n node = Node(id='11', name=None, state=None,\n public_ips=None, private_ips=None, driver=self.driver)\n ret = self.driver.ex_reset(node)\n self.assertTrue(ret is True)", "metadata": "root.DimensionDataTests.test_ex_reset", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 479 }, { "content": " def test_ex_attach_node_to_vlan(self):\n node = self.driver.ex_get_node_by_id('e75ead52-692f-4314-8725-c8a4f4d13a87')\n vlan = self.driver.ex_get_vlan('0e56433f-d808-4669-821d-812769517ff8')\n ret = self.driver.ex_attach_node_to_vlan(node, vlan)\n self.assertTrue(ret is True)", "metadata": "root.DimensionDataTests.test_ex_attach_node_to_vlan", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 485 }, { "content": " def test_ex_wait_for_state_FAIL(self):\n with self.assertRaises(DimensionDataAPIException) as context:\n self.driver.ex_wait_for_state('starting',\n self.driver.ex_get_node_by_id,\n id='e75ead52-692f-4314-8725-c8a4f4d13a87',\n timeout=2\n )\n self.assertEqual(context.exception.code, 'running')\n self.assertTrue('timed out' in context.exception.msg)", "metadata": "root.DimensionDataTests.test_ex_wait_for_state_FAIL", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 625 }, { "content": " def test_ex_list_tags(self):\n tags = self.driver.ex_list_tags()\n self.assertTrue(isinstance(tags, list))\n self.assertTrue(isinstance(tags[0], DimensionDataTag))\n self.assertTrue(len(tags) == 3)", "metadata": "root.DimensionDataTests.test_ex_list_tags", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 1077 }, { "content": " def test_ex_list_tags_ALLPARAMS(self):\n self.driver.connection._get_orgId()\n DimensionDataMockHttp.type = 'ALLPARAMS'\n tags = self.driver.ex_list_tags(asset_id='fake_asset_id', asset_type='fake_asset_type',\n location='fake_location', tag_key_name='fake_tag_key_name',\n tag_key_id='fake_tag_key_id', value='fake_value',\n value_required=False, display_on_report=False)\n self.assertTrue(isinstance(tags, list))\n self.assertTrue(isinstance(tags[0], DimensionDataTag))\n self.assertTrue(len(tags) == 3)", "metadata": "root.DimensionDataTests.test_ex_list_tags_ALLPARAMS", "header": "['class', 'DimensionDataTests', '(', 'unittest', '.', 'TestCase', ',', 'TestCaseMixin', ')', ':', '___EOS___']", "index": 1083 } ]
[ { "span": "self.assertTrue(ret[0].state == 'running')", "start_line": 90, "start_column": 8, "end_line": 90, "end_column": 50 }, { "span": "self.assertTrue(ret[1].state == 'starting')", "start_line": 91, "start_column": 8, "end_line": 91, "end_column": 51 }, { "span": "self.assertTrue(ret[2].state == 'stopping')", "start_line": 92, "start_column": 8, "end_line": 92, "end_column": 51 }, { "span": "self.assertTrue(ret[3].state == 'reconfiguring')", "start_line": 93, "start_column": 8, "end_line": 93, "end_column": 56 }, { "span": "self.assertTrue(ret[4].state == 'running')", "start_line": 94, "start_column": 8, "end_line": 94, "end_column": 50 }, { "span": "self.assertTrue(ret[5].state == 'terminated')", "start_line": 95, "start_column": 8, "end_line": 95, "end_column": 53 }, { "span": "self.assertTrue(ret[6].state == 'stopped')", "start_line": 96, "start_column": 8, "end_line": 96, "end_column": 50 }, { "span": "self.assertTrue(ret is True)", "start_line": 158, "start_column": 8, "end_line": 158, "end_column": 36 }, { "span": "self.assertTrue(ret is True)", "start_line": 171, "start_column": 8, "end_line": 171, "end_column": 36 }, { "span": "self.assertTrue(ret is True)", "start_line": 193, "start_column": 8, "end_line": 193, "end_column": 36 }, { "span": "self.assertTrue(ret is True)", "start_line": 198, "start_column": 8, "end_line": 198, "end_column": 36 }, { "span": "self.assertTrue('password' in node.extra)", "start_line": 227, "start_column": 8, "end_line": 227, "end_column": 49 }, { "span": "self.assertTrue('password' in node.extra)", "start_line": 237, "start_column": 8, "end_line": 237, "end_column": 49 }, { "span": "self.assertTrue('password' in node.extra)", "start_line": 247, "start_column": 8, "end_line": 247, "end_column": 49 }, { "span": "self.assertTrue('password' not in node.extra)", "start_line": 257, "start_column": 8, "end_line": 257, "end_column": 53 }, { "span": "self.assertTrue('password' not in node.extra)", "start_line": 267, "start_column": 8, "end_line": 267, "end_column": 53 }, { "span": "self.assertTrue(ret is True)", "start_line": 438, "start_column": 8, "end_line": 438, "end_column": 36 }, { "span": "self.assertTrue(ret is True)", "start_line": 451, "start_column": 8, "end_line": 451, "end_column": 36 }, { "span": "self.assertTrue(ret is True)", "start_line": 464, "start_column": 8, "end_line": 464, "end_column": 36 }, { "span": "self.assertTrue(ret is True)", "start_line": 470, "start_column": 8, "end_line": 470, "end_column": 36 }, { "span": "self.assertTrue(ret is True)", "start_line": 483, "start_column": 8, "end_line": 483, "end_column": 36 }, { "span": "self.assertTrue(ret is True)", "start_line": 489, "start_column": 8, "end_line": 489, "end_column": 36 }, { "span": "self.assertTrue('timed out' in context.exception.msg)", "start_line": 633, "start_column": 8, "end_line": 633, "end_column": 61 }, { "span": "self.assertTrue(len(tags) == 3)", "start_line": 1081, "start_column": 8, "end_line": 1081, "end_column": 39 }, { "span": "self.assertTrue(len(tags) == 3)", "start_line": 1092, "start_column": 8, "end_line": 1092, "end_column": 39 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "server", "\\u", "states_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Dimen", "sion", "Data", "Moc", "k", "Http_", "._", "type_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "self_", "._", "driver_", "._", "list", "\\u", "nodes_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "[_", "0_", "]_", "._", "state_", "==_", "'", "runn", "ing", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "[_", "1_", "]_", "._", "state_", "==_", "'", "startin", "g", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "[_", "2_", "]_", "._", "state_", "==_", "'", "stopping", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "[_", "3_", "]_", "._", "state_", "==_", "'", "reconfigur", "ing", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "[_", "4_", "]_", "._", "state_", "==_", "'", "runn", "ing", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "[_", "5_", "]_", "._", "state_", "==_", "'", "terminate", "d", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "[_", "6_", "]_", "._", "state_", "==_", "'", "stopp", "ed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "ret_", ")_", ",_", "7_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "rebo", "ot", "\\u", "node", "\\u", "response_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "Node_", "(_", "id_", "=_", "'", "11", "'_", ",_", "name_", "=_", "None_", ",_", "state_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "public", "\\u", "ips_", "=_", "None_", ",_", "private", "\\u", "ips_", "=_", "None_", ",_", "driver_", "=_", "self_", "._", "driver_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "node_", "._", "reboot_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "is_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "destroy", "\\u", "node", "\\u", "response_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "Node_", "(_", "id_", "=_", "'", "11", "'_", ",_", "name_", "=_", "None_", ",_", "state_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "public", "\\u", "ips_", "=_", "None_", ",_", "private", "\\u", "ips_", "=_", "None_", ",_", "driver_", "=_", "self_", "._", "driver_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "node_", "._", "destroy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "is_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "clean", "\\u", "fail", "ed", "\\u", "deploy", "ment", "\\u", "response", "\\u", "with", "\\u", "node_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "Node_", "(_", "id_", "=_", "'", "11", "'_", ",_", "name_", "=_", "None_", ",_", "state_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "public", "\\u", "ips_", "=_", "None_", ",_", "private", "\\u", "ips_", "=_", "None_", ",_", "driver_", "=_", "self_", "._", "driver_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "clean", "\\u", "fail", "ed", "\\u", "deployment_", "(_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "is_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "clean", "\\u", "fail", "ed", "\\u", "deploy", "ment", "\\u", "response", "\\u", "with", "\\u", "node", "\\u", "id_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "'", "e7", "5e", "ad", "5", "2", "-", "692", "f", "-", "431", "4", "-", "872", "5", "-", "c8", "a4", "f4", "d1", "3a", "87", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "clean", "\\u", "fail", "ed", "\\u", "deployment_", "(_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "is_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "create", "\\u", "node", "\\u", "response", "\\u", "no", "\\u", "pass", "\\u", "random", "\\u", "gen_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image_", "=_", "self_", "._", "driver_", "._", "list", "\\u", "images_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "network_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "list", "\\u", "networks_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "=_", "self_", "._", "driver_", "._", "create", "\\u", "node_", "(_", "name_", "=_", "'", "test", "2", "'_", ",_", "image_", "=_", "image_", ",_", "auth_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ex", "\\u", "description_", "=_", "'", "test", "2", " ", "node", "'_", ",_", "ex", "\\u", "network_", "=_", "network_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ex", "\\u", "is", "\\u", "started_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "node_", "._", "id_", ",_", "'", "e7", "5e", "ad", "5", "2", "-", "692", "f", "-", "431", "4", "-", "872", "5", "-", "c8", "a4", "f4", "d1", "3a", "87", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "node_", "._", "extra_", "[_", "'", "status", "'_", "]_", "._", "action_", ",_", "'", "DEPLOY", "\\u", "SERVER", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "password", "'_", "in_", "node_", "._", "extra_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "create", "\\u", "node", "\\u", "response", "\\u", "no", "\\u", "pass", "\\u", "customer", "\\u", "windows_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "list", "\\u", "customer", "\\u", "images_", "(_", ")_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "network_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "list", "\\u", "networks_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "=_", "self_", "._", "driver_", "._", "create", "\\u", "node_", "(_", "name_", "=_", "'", "test", "2", "'_", ",_", "image_", "=_", "image_", ",_", "auth_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ex", "\\u", "description_", "=_", "'", "test", "2", " ", "node", "'_", ",_", "ex", "\\u", "network_", "=_", "network_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ex", "\\u", "is", "\\u", "started_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "node_", "._", "id_", ",_", "'", "e7", "5e", "ad", "5", "2", "-", "692", "f", "-", "431", "4", "-", "872", "5", "-", "c8", "a4", "f4", "d1", "3a", "87", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "node_", "._", "extra_", "[_", "'", "status", "'_", "]_", "._", "action_", ",_", "'", "DEPLOY", "\\u", "SERVER", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "password", "'_", "in_", "node_", "._", "extra_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "create", "\\u", "node", "\\u", "response", "\\u", "no", "\\u", "pass", "\\u", "customer", "\\u", "windows", "\\u", "STR_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "list", "\\u", "customer", "\\u", "images_", "(_", ")_", "[_", "1_", "]_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "network_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "list", "\\u", "networks_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "=_", "self_", "._", "driver_", "._", "create", "\\u", "node_", "(_", "name_", "=_", "'", "test", "2", "'_", ",_", "image_", "=_", "image_", ",_", "auth_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ex", "\\u", "description_", "=_", "'", "test", "2", " ", "node", "'_", ",_", "ex", "\\u", "network_", "=_", "network_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ex", "\\u", "is", "\\u", "started_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "node_", "._", "id_", ",_", "'", "e7", "5e", "ad", "5", "2", "-", "692", "f", "-", "431", "4", "-", "872", "5", "-", "c8", "a4", "f4", "d1", "3a", "87", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "node_", "._", "extra_", "[_", "'", "status", "'_", "]_", "._", "action_", ",_", "'", "DEPLOY", "\\u", "SERVER", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "password", "'_", "in_", "node_", "._", "extra_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "create", "\\u", "node", "\\u", "response", "\\u", "no", "\\u", "pass", "\\u", "customer", "\\u", "linux_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "list", "\\u", "customer", "\\u", "images_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "network_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "list", "\\u", "networks_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "=_", "self_", "._", "driver_", "._", "create", "\\u", "node_", "(_", "name_", "=_", "'", "test", "2", "'_", ",_", "image_", "=_", "image_", ",_", "auth_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ex", "\\u", "description_", "=_", "'", "test", "2", " ", "node", "'_", ",_", "ex", "\\u", "network_", "=_", "network_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ex", "\\u", "is", "\\u", "started_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "node_", "._", "id_", ",_", "'", "e7", "5e", "ad", "5", "2", "-", "692", "f", "-", "431", "4", "-", "872", "5", "-", "c8", "a4", "f4", "d1", "3a", "87", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "node_", "._", "extra_", "[_", "'", "status", "'_", "]_", "._", "action_", ",_", "'", "DEPLOY", "\\u", "SERVER", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "password", "'_", "not_", "in_", "node_", "._", "extra_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "create", "\\u", "node", "\\u", "response", "\\u", "no", "\\u", "pass", "\\u", "customer", "\\u", "linux", "\\u", "STR_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "image_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "list", "\\u", "customer", "\\u", "images_", "(_", ")_", "[_", "0_", "]_", "._", "id_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "network_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "list", "\\u", "networks_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "node_", "=_", "self_", "._", "driver_", "._", "create", "\\u", "node_", "(_", "name_", "=_", "'", "test", "2", "'_", ",_", "image_", "=_", "image_", ",_", "auth_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ex", "\\u", "description_", "=_", "'", "test", "2", " ", "node", "'_", ",_", "ex", "\\u", "network_", "=_", "network_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ex", "\\u", "is", "\\u", "started_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "node_", "._", "id_", ",_", "'", "e7", "5e", "ad", "5", "2", "-", "692", "f", "-", "431", "4", "-", "872", "5", "-", "c8", "a4", "f4", "d1", "3a", "87", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "node_", "._", "extra_", "[_", "'", "status", "'_", "]_", "._", "action_", ",_", "'", "DEPLOY", "\\u", "SERVER", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "password", "'_", "not_", "in_", "node_", "._", "extra_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ex", "\\u", "shut", "down", "\\u", "graceful", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "Node_", "(_", "id_", "=_", "'", "11", "'_", ",_", "name_", "=_", "None_", ",_", "state_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "public", "\\u", "ips_", "=_", "None_", ",_", "private", "\\u", "ips_", "=_", "None_", ",_", "driver_", "=_", "self_", "._", "driver_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "shut", "down", "\\u", "graceful", "_", "(_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "is_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ex", "\\u", "start", "\\u", "node_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "Node_", "(_", "id_", "=_", "'", "11", "'_", ",_", "name_", "=_", "None_", ",_", "state_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "public", "\\u", "ips_", "=_", "None_", ",_", "private", "\\u", "ips_", "=_", "None_", ",_", "driver_", "=_", "self_", "._", "driver_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "start", "\\u", "node_", "(_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "is_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ex", "\\u", "power", "\\u", "off_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "Node_", "(_", "id_", "=_", "'", "11", "'_", ",_", "name_", "=_", "None_", ",_", "state_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "public", "\\u", "ips_", "=_", "None_", ",_", "private", "\\u", "ips_", "=_", "None_", ",_", "driver_", "=_", "self_", "._", "driver_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "power", "\\u", "off_", "(_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "is_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ex", "\\u", "update", "\\u", "vm", "\\u", "tools_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "Node_", "(_", "id_", "=_", "'", "11", "'_", ",_", "name_", "=_", "None_", ",_", "state_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "public", "\\u", "ips_", "=_", "None_", ",_", "private", "\\u", "ips_", "=_", "None_", ",_", "driver_", "=_", "self_", "._", "driver_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "update", "\\u", "vm", "\\u", "tools_", "(_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "is_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ex", "\\u", "reset_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "Node_", "(_", "id_", "=_", "'", "11", "'_", ",_", "name_", "=_", "None_", ",_", "state_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "public", "\\u", "ips_", "=_", "None_", ",_", "private", "\\u", "ips_", "=_", "None_", ",_", "driver_", "=_", "self_", "._", "driver_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "reset_", "(_", "node_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "is_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ex", "\\u", "attach", "\\u", "node", "\\u", "to", "\\u", "vlan_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "node_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "get", "\\u", "node", "\\u", "by", "\\u", "id_", "(_", "'", "e7", "5e", "ad", "5", "2", "-", "692", "f", "-", "431", "4", "-", "872", "5", "-", "c8", "a4", "f4", "d1", "3a", "87", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vlan_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "get", "\\u", "vlan_", "(_", "'", "0e", "564", "3", "3f", "-", "d8", "0", "8", "-", "466", "9", "-", "821", "d", "-", "812", "769", "517", "ff", "8", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "attach", "\\u", "node", "\\u", "to", "\\u", "vlan_", "(_", "node_", ",_", "vlan_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "ret_", "is_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ex", "\\u", "wait", "\\u", "for", "\\u", "state", "\\u", "FAIL_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "with_", "self_", "._", "assert", "Raises_", "(_", "Dimen", "sion", "Data", "API", "Exception_", ")_", "as_", "context_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "driver_", "._", "ex", "\\u", "wait", "\\u", "for", "\\u", "state_", "(_", "'", "startin", "g", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "driver_", "._", "ex", "\\u", "get", "\\u", "node", "\\u", "by", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "id_", "=_", "'", "e7", "5e", "ad", "5", "2", "-", "692", "f", "-", "431", "4", "-", "872", "5", "-", "c8", "a4", "f4", "d1", "3a", "87", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "timeout_", "=_", "2_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "context_", "._", "exception_", "._", "code_", ",_", "'", "runn", "ing", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "timed", " ", "out", "'_", "in_", "context_", "._", "exception_", "._", "msg_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ex", "\\u", "list", "\\u", "tags_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tags_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "list", "\\u", "tags_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "tags_", ",_", "list_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "tags_", "[_", "0_", "]_", ",_", "Dimen", "sion", "Data", "Tag_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "len_", "(_", "tags_", ")_", "==_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Dimen", "sion", "Data", "Tests_", "(_", "unittest_", "._", "Test", "Case_", ",_", "Test", "Case", "Mixin_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ex", "\\u", "list", "\\u", "tags", "\\u", "ALL", "PARAMS_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "driver_", "._", "connection_", "._", "\\u", "get", "\\u", "org", "Id_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Dimen", "sion", "Data", "Moc", "k", "Http_", "._", "type_", "=_", "'", "ALL", "PARAM", "S", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tags_", "=_", "self_", "._", "driver_", "._", "ex", "\\u", "list", "\\u", "tags_", "(_", "asset", "\\u", "id_", "=_", "'", "fake", "\\u", "asset", "\\u", "id", "'_", ",_", "asset", "\\u", "type_", "=_", "'", "fake", "\\u", "asset", "\\u", "type", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "location_", "=_", "'", "fake", "\\u", "location", "'_", ",_", "tag", "\\u", "key", "\\u", "name_", "=_", "'", "fake", "\\u", "tag", "\\u", "key", "\\u", "name", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tag", "\\u", "key", "\\u", "id_", "=_", "'", "fake", "\\u", "tag", "\\u", "key", "\\u", "id", "'_", ",_", "value_", "=_", "'", "fake", "\\u", "value", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "value", "\\u", "required_", "=_", "False_", ",_", "display", "\\u", "on", "\\u", "report_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "tags_", ",_", "list_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "tags_", "[_", "0_", "]_", ",_", "Dimen", "sion", "Data", "Tag_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "len_", "(_", "tags_", ")_", "==_", "3_", ")_", "\\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, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Unused import
plotly/plotly.py/plotly/tests/test_core/test_tools/test_figure_factory.py
[ { "content": "import math\nfrom unittest import TestCase\n\nimport datetime\nfrom nose.tools import raises\nimport plotly.tools as tls\nfrom plotly.exceptions import PlotlyError\nfrom plotly.graph_objs import graph_objs\n\n\n\n\n\n\n\n\n\n\n# class TestDistplot(TestCase):\n\n# def test_scipy_import_error(self):\n\n# # make sure Import Error is raised when _scipy_imported = False\n\n# hist_data = [[1.1, 1.1, 2.5, 3.0, 3.5,\n# 3.5, 4.1, 4.4, 4.5, 4.5,\n# 5.0, 5.0, 5.2, 5.5, 5.5,\n# 5.5, 5.5, 5.5, 6.1, 7.0]]\n\n# group_labels = ['distplot example']\n\n# self.assertRaisesRegexp(ImportError,\n# \"FigureFactory.create_distplot requires scipy\",\n# tls.FigureFactory.create_distplot,\n# hist_data, group_labels)\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class TestQuiver(TestCase):\n\n\n\n\n", "metadata": "root.TestQuiver", "header": "['module', '___EOS___']", "index": 10 }, { "content": " def test_unequal_xy_length(self):\n\n # check: PlotlyError if x and y are not the same length\n\n kwargs = {'x': [1, 2], 'y': [1], 'u': [1, 2], 'v': [1, 2]}\n self.assertRaises(PlotlyError, tls.FigureFactory.create_quiver,\n **kwargs)", "metadata": "root.TestQuiver.test_unequal_xy_length", "header": "['class', 'TestQuiver', '(', 'TestCase', ')', ':', '___EOS___']", "index": 12 }, { "content": " def test_wrong_scale(self):\n\n # check: ValueError if scale is <= 0\n\n kwargs = {'x': [1, 2], 'y': [1, 2],\n 'u': [1, 2], 'v': [1, 2],\n 'scale': -1}\n self.assertRaises(ValueError, tls.FigureFactory.create_quiver,\n **kwargs)\n\n kwargs = {'x': [1, 2], 'y': [1, 2],\n 'u': [1, 2], 'v': [1, 2],\n 'scale': 0}\n self.assertRaises(ValueError, tls.FigureFactory.create_quiver,\n **kwargs)", "metadata": "root.TestQuiver.test_wrong_scale", "header": "['class', 'TestQuiver', '(', 'TestCase', ')', ':', '___EOS___']", "index": 20 }, { "content": " def test_wrong_arrow_scale(self):\n\n # check: ValueError if arrow_scale is <= 0\n\n kwargs = {'x': [1, 2], 'y': [1, 2],\n 'u': [1, 2], 'v': [1, 2],\n 'arrow_scale': -1}\n self.assertRaises(ValueError, tls.FigureFactory.create_quiver,\n **kwargs)\n\n kwargs = {'x': [1, 2], 'y': [1, 2],\n 'u': [1, 2], 'v': [1, 2],\n 'arrow_scale': 0}\n self.assertRaises(ValueError, tls.FigureFactory.create_quiver,\n **kwargs)", "metadata": "root.TestQuiver.test_wrong_arrow_scale", "header": "['class', 'TestQuiver', '(', 'TestCase', ')', ':', '___EOS___']", "index": 36 }, { "content": " def test_one_arrow(self):\n\n # we should be able to create a single arrow using create_quiver\n\n quiver = tls.FigureFactory.create_quiver(x=[1], y=[1],\n u=[1], v=[1],\n scale=1)\n expected_quiver = {\n 'data': [{'mode': 'lines',\n 'type': u'scatter',\n 'x': [1, 2, None, 1.820698256761928, 2,\n 1.615486170766527, None],\n 'y': [1, 2, None, 1.615486170766527, 2,\n 1.820698256761928, None]}],\n 'layout': {'hovermode': 'closest'}}\n self.assertEqual(quiver, expected_quiver)", "metadata": "root.TestQuiver.test_one_arrow", "header": "['class', 'TestQuiver', '(', 'TestCase', ')', ':', '___EOS___']", "index": 52 }, { "content": " def test_more_kwargs(self):\n\n # we should be able to create 2 arrows and change the arrow_scale,\n # angle, and arrow using create_quiver\n\n quiver = tls.FigureFactory.create_quiver(x=[1, 2],\n y=[1, 2],\n u=[math.cos(1),\n math.cos(2)],\n v=[math.sin(1),\n math.sin(2)],\n arrow_scale=.4,\n angle=math.pi / 6,\n line=graph_objs.Line(color='purple',\n width=3))\n expected_quiver = {'data': [{'line': {'color': 'purple', 'width': 3},\n 'mode': 'lines',\n 'type': u'scatter',\n 'x': [1,\n 1.0540302305868139,\n None,\n 2,\n 1.9583853163452858,\n None,\n 1.052143029378767,\n 1.0540302305868139,\n 1.0184841899864512,\n None,\n 1.9909870141679737,\n 1.9583853163452858,\n 1.9546151170949464,\n None],\n 'y': [1,\n 1.0841470984807897,\n None,\n 2,\n 2.0909297426825684,\n None,\n 1.044191642387781,\n 1.0841470984807897,\n 1.0658037346225067,\n None,\n 2.0677536925644366,\n 2.0909297426825684,\n 2.051107819102551,\n None]}],\n 'layout': {'hovermode': 'closest'}}\n self.assertEqual(quiver, expected_quiver)", "metadata": "root.TestQuiver.test_more_kwargs", "header": "['class', 'TestQuiver', '(', 'TestCase', ')', ':', '___EOS___']", "index": 69 }, { "content": "class TestFinanceCharts(TestCase):\n\n\n\n\n\n\n\n\n # TO-DO: put expected fig in a different file and then call to compare\n\n", "metadata": "root.TestFinanceCharts", "header": "['module', '___EOS___']", "index": 119 }, { "content": " def test_unequal_ohlc_length(self):\n\n # check: PlotlyError if open, high, low, close are not the same length\n # for TraceFactory.create_ohlc and TraceFactory.create_candlestick\n\n kwargs = {'open': [1], 'high': [1, 3],\n 'low': [1, 2], 'close': [1, 2],\n 'direction': ['increasing']}\n self.assertRaises(PlotlyError, tls.FigureFactory.create_ohlc, **kwargs)\n self.assertRaises(PlotlyError, tls.FigureFactory.create_candlestick,\n **kwargs)\n\n kwargs = {'open': [1, 2], 'high': [1, 2, 3],\n 'low': [1, 2], 'close': [1, 2],\n 'direction': ['decreasing']}\n self.assertRaises(PlotlyError, tls.FigureFactory.create_ohlc, **kwargs)\n self.assertRaises(PlotlyError, tls.FigureFactory.create_candlestick,\n **kwargs)\n\n kwargs = {'open': [1, 2], 'high': [2, 3],\n 'low': [0], 'close': [1, 3]}\n self.assertRaises(PlotlyError, tls.FigureFactory.create_ohlc, **kwargs)\n self.assertRaises(PlotlyError, tls.FigureFactory.create_candlestick,\n **kwargs)\n\n kwargs = {'open': [1, 2], 'high': [2, 3],\n 'low': [1, 2], 'close': [1]}\n self.assertRaises(PlotlyError, tls.FigureFactory.create_ohlc, **kwargs)\n self.assertRaises(PlotlyError, tls.FigureFactory.create_candlestick,\n **kwargs)", "metadata": "root.TestFinanceCharts.test_unequal_ohlc_length", "header": "['class', 'TestFinanceCharts', '(', 'TestCase', ')', ':', '___EOS___']", "index": 121 }, { "content": " def test_direction_arg(self):\n\n # check: PlotlyError if direction is not defined as \"increasing\" or\n # \"decreasing\" for TraceFactory.create_ohlc and\n # TraceFactory.create_candlestick\n\n kwargs = {'open': [1, 4], 'high': [1, 5],\n 'low': [1, 2], 'close': [1, 2],\n 'direction': ['inc']}\n self.assertRaisesRegexp(PlotlyError,\n \"direction must be defined as \"\n \"'increasing', 'decreasing', or 'both'\",\n tls.FigureFactory.create_ohlc, **kwargs)\n self.assertRaisesRegexp(PlotlyError,\n \"direction must be defined as \"\n \"'increasing', 'decreasing', or 'both'\",\n tls.FigureFactory.create_candlestick, **kwargs)\n\n kwargs = {'open': [1, 2], 'high': [1, 3],\n 'low': [1, 2], 'close': [1, 2],\n 'direction': ['d']}\n self.assertRaisesRegexp(PlotlyError,\n \"direction must be defined as \"\n \"'increasing', 'decreasing', or 'both'\",\n tls.FigureFactory.create_ohlc, **kwargs)\n self.assertRaisesRegexp(PlotlyError,\n \"direction must be defined as \"\n \"'increasing', 'decreasing', or 'both'\",\n tls.FigureFactory.create_candlestick, **kwargs)", "metadata": "root.TestFinanceCharts.test_direction_arg", "header": "['class', 'TestFinanceCharts', '(', 'TestCase', ')', ':', '___EOS___']", "index": 152 }, { "content": " def test_high_highest_value(self):\n\n # check: PlotlyError if the \"high\" value is less than the corresponding\n # open, low, or close value because if the \"high\" value is not the\n # highest (or equal) then the data may have been entered incorrectly.\n\n kwargs = {'open': [2, 3], 'high': [4, 2],\n 'low': [1, 1], 'close': [1, 2]}\n self.assertRaisesRegexp(PlotlyError, \"Oops! Looks like some of \"\n \"your high values are less \"\n \"the corresponding open, \"\n \"low, or close values. \"\n \"Double check that your data \"\n \"is entered in O-H-L-C order\",\n tls.FigureFactory.create_ohlc,\n **kwargs)\n self.assertRaisesRegexp(PlotlyError, \"Oops! Looks like some of \"\n \"your high values are less \"\n \"the corresponding open, \"\n \"low, or close values. \"\n \"Double check that your data \"\n \"is entered in O-H-L-C order\",\n tls.FigureFactory.create_candlestick,\n **kwargs)", "metadata": "root.TestFinanceCharts.test_high_highest_value", "header": "['class', 'TestFinanceCharts', '(', 'TestCase', ')', ':', '___EOS___']", "index": 182 }, { "content": " def test_low_lowest_value(self):\n\n # check: PlotlyError if the \"low\" value is greater than the\n # corresponding open, high, or close value because if the \"low\" value\n # is not the lowest (or equal) then the data may have been entered\n # incorrectly.\n\n # create_ohlc_increase\n kwargs = {'open': [2, 3], 'high': [4, 6],\n 'low': [3, 1], 'close': [1, 2]}\n self.assertRaisesRegexp(PlotlyError,\n \"Oops! Looks like some of \"\n \"your low values are greater \"\n \"than the corresponding high\"\n \", open, or close values. \"\n \"Double check that your data \"\n \"is entered in O-H-L-C order\",\n tls.FigureFactory.create_ohlc,\n **kwargs)\n self.assertRaisesRegexp(PlotlyError,\n \"Oops! Looks like some of \"\n \"your low values are greater \"\n \"than the corresponding high\"\n \", open, or close values. \"\n \"Double check that your data \"\n \"is entered in O-H-L-C order\",\n tls.FigureFactory.create_candlestick,\n **kwargs)", "metadata": "root.TestFinanceCharts.test_low_lowest_value", "header": "['class', 'TestFinanceCharts', '(', 'TestCase', ')', ':', '___EOS___']", "index": 207 }, { "content": " def test_one_ohlc(self):\n\n # This should create one \"increase\" (i.e. close > open) ohlc stick\n\n ohlc = tls.FigureFactory.create_ohlc(open=[33.0],\n high=[33.2],\n low=[32.7],\n close=[33.1])\n\n expected_ohlc = {'layout': {'hovermode': 'closest',\n 'xaxis': {'zeroline': False}},\n 'data': [{'y': [33.0, 33.0, 33.2, 32.7,\n 33.1, 33.1, None],\n 'line': {'width': 1,\n 'color': '#3D9970'},\n 'showlegend': False,\n 'name': 'Increasing',\n 'text': ('Open', 'Open', 'High', 'Low',\n 'Close', 'Close', ''),\n 'mode': 'lines', 'type': 'scatter',\n 'x': [-0.2, 0, 0, 0, 0, 0.2, None]},\n {'y': [], 'line': {'width': 1,\n 'color': '#FF4136'},\n 'showlegend': False,\n 'name': 'Decreasing', 'text': (),\n 'mode': 'lines', 'type': 'scatter',\n 'x': []}]}\n\n self.assertEqual(ohlc, expected_ohlc)", "metadata": "root.TestFinanceCharts.test_one_ohlc", "header": "['class', 'TestFinanceCharts', '(', 'TestCase', ')', ':', '___EOS___']", "index": 236 }, { "content": " def test_one_ohlc_increase(self):\n\n # This should create one \"increase\" (i.e. close > open) ohlc stick\n\n ohlc_incr = tls.FigureFactory.create_ohlc(open=[33.0],\n high=[33.2],\n low=[32.7],\n close=[33.1],\n direction=\"increasing\")\n\n expected_ohlc_incr = {'data': [{'line': {'color': '#3D9970',\n 'width': 1},\n 'mode': 'lines',\n 'name': 'Increasing',\n 'showlegend': False,\n 'text': ('Open', 'Open', 'High',\n 'Low', 'Close', 'Close', ''),\n 'type': 'scatter',\n 'x': [-0.2, 0, 0, 0, 0, 0.2, None],\n 'y': [33.0, 33.0, 33.2, 32.7, 33.1,\n 33.1, None]}],\n 'layout': {'hovermode': 'closest',\n 'xaxis': {'zeroline': False}}}\n self.assertEqual(ohlc_incr, expected_ohlc_incr)", "metadata": "root.TestFinanceCharts.test_one_ohlc_increase", "header": "['class', 'TestFinanceCharts', '(', 'TestCase', ')', ':', '___EOS___']", "index": 266 }, { "content": " def test_one_ohlc_decrease(self):\n\n # This should create one \"increase\" (i.e. close > open) ohlc stick\n\n ohlc_decr = tls.FigureFactory.create_ohlc(open=[33.0],\n high=[33.2],\n low=[30.7],\n close=[31.1],\n direction=\"decreasing\")\n\n expected_ohlc_decr = {'data': [{'line': {'color': '#FF4136',\n 'width': 1},\n 'mode': 'lines',\n 'name': 'Decreasing',\n 'showlegend': False,\n 'text': ('Open', 'Open', 'High', 'Low',\n 'Close', 'Close', ''),\n 'type': 'scatter',\n 'x': [-0.2, 0, 0, 0, 0, 0.2, None],\n 'y': [33.0, 33.0, 33.2, 30.7, 31.1,\n 31.1, None]}],\n 'layout': {'hovermode': 'closest',\n 'xaxis': {'zeroline': False}}}\n self.assertEqual(ohlc_decr, expected_ohlc_decr)", "metadata": "root.TestFinanceCharts.test_one_ohlc_decrease", "header": "['class', 'TestFinanceCharts', '(', 'TestCase', ')', ':', '___EOS___']", "index": 291 }, { "content": " def test_one_candlestick(self):\n\n # This should create one \"increase\" (i.e. close > open) candlestick\n\n can_inc = tls.FigureFactory.create_candlestick(open=[33.0],\n high=[33.2],\n low=[32.7],\n close=[33.1])\n\n exp_can_inc = {'data': [{'boxpoints': False,\n 'fillcolor': '#3D9970',\n 'line': {'color': '#3D9970'},\n 'name': 'Increasing',\n 'showlegend': False,\n 'type': 'box',\n 'whiskerwidth': 0,\n 'x': [0, 0, 0, 0, 0, 0],\n 'y': [32.7, 33.0, 33.1, 33.1, 33.1, 33.2]},\n {'boxpoints': False,\n 'fillcolor': '#FF4136',\n 'line': {'color': '#FF4136'},\n 'name': 'Decreasing',\n 'showlegend': False,\n 'type': 'box',\n 'whiskerwidth': 0,\n 'x': [],\n 'y': []}],\n 'layout': {}}\n\n self.assertEqual(can_inc, exp_can_inc)", "metadata": "root.TestFinanceCharts.test_one_candlestick", "header": "['class', 'TestFinanceCharts', '(', 'TestCase', ')', ':', '___EOS___']", "index": 317 }, { "content": " def test_datetime_ohlc(self):\n\n # Check expected outcome for ohlc chart with datetime xaxis\n\n high_data = [34.20, 34.37, 33.62, 34.25, 35.18, 33.25, 35.37, 34.62]\n low_data = [31.70, 30.75, 32.87, 31.62, 30.81, 32.75, 32.75, 32.87]\n close_data = [34.10, 31.93, 33.37, 33.18, 31.18, 33.10, 32.93, 33.70]\n open_data = [33.01, 33.31, 33.50, 32.06, 34.12, 33.05, 33.31, 33.50]\n\n x = [datetime.datetime(year=2013, month=3, day=4),\n datetime.datetime(year=2013, month=6, day=5),\n datetime.datetime(year=2013, month=9, day=6),\n datetime.datetime(year=2013, month=12, day=4),\n datetime.datetime(year=2014, month=3, day=5),\n datetime.datetime(year=2014, month=6, day=6),\n datetime.datetime(year=2014, month=9, day=4),\n datetime.datetime(year=2014, month=12, day=5)]\n\n ohlc_d = tls.FigureFactory.create_ohlc(open_data, high_data,\n low_data, close_data,\n dates=x)\n\n ex_ohlc_d = {'data': [{'line': {'color': '#3D9970', 'width': 1},\n 'mode': 'lines',\n 'name': 'Increasing',\n 'showlegend': False,\n 'text': ('Open',\n 'Open',\n 'High',\n 'Low',\n 'Close',\n 'Close',\n '',\n 'Open',\n 'Open',\n 'High',\n 'Low',\n 'Close',\n 'Close',\n '',\n 'Open',\n 'Open',\n 'High',\n 'Low',\n 'Close',\n 'Close',\n '',\n 'Open',\n 'Open',\n 'High',\n 'Low',\n 'Close',\n 'Close',\n ''),\n 'type': 'scatter',\n 'x': [datetime.datetime(2013, 2, 14, 4, 48),\n datetime.datetime(2013, 3, 4, 0, 0),\n datetime.datetime(2013, 3, 4, 0, 0),\n datetime.datetime(2013, 3, 4, 0, 0),\n datetime.datetime(2013, 3, 4, 0, 0),\n datetime.datetime(2013, 3, 21, 19, 12),\n None,\n datetime.datetime(2013, 11, 16, 4, 48),\n datetime.datetime(2013, 12, 4, 0, 0),\n datetime.datetime(2013, 12, 4, 0, 0),\n datetime.datetime(2013, 12, 4, 0, 0),\n datetime.datetime(2013, 12, 4, 0, 0),\n datetime.datetime(2013, 12, 21, 19, 12),\n None,\n datetime.datetime(2014, 5, 19, 4, 48),\n datetime.datetime(2014, 6, 6, 0, 0),\n datetime.datetime(2014, 6, 6, 0, 0),\n datetime.datetime(2014, 6, 6, 0, 0),\n datetime.datetime(2014, 6, 6, 0, 0),\n datetime.datetime(2014, 6, 23, 19, 12),\n None,\n datetime.datetime(2014, 11, 17, 4, 48),\n datetime.datetime(2014, 12, 5, 0, 0),\n datetime.datetime(2014, 12, 5, 0, 0),\n datetime.datetime(2014, 12, 5, 0, 0),\n datetime.datetime(2014, 12, 5, 0, 0),\n datetime.datetime(2014, 12, 22, 19, 12),\n None],\n 'y': [33.01,\n 33.01,\n 34.2,\n 31.7,\n 34.1,\n 34.1,\n None,\n 32.06,\n 32.06,\n 34.25,\n 31.62,\n 33.18,\n 33.18,\n None,\n 33.05,\n 33.05,\n 33.25,\n 32.75,\n 33.1,\n 33.1,\n None,\n 33.5,\n 33.5,\n 34.62,\n 32.87,\n 33.7,\n 33.7,\n None]},\n {'line': {'color': '#FF4136', 'width': 1},\n 'mode': 'lines',\n 'name': 'Decreasing',\n 'showlegend': False,\n 'text': ('Open',\n 'Open',\n 'High',\n 'Low',\n 'Close',\n 'Close',\n '',\n 'Open',\n 'Open',\n 'High',\n 'Low',\n 'Close',\n 'Close',\n '',\n 'Open',\n 'Open',\n 'High',\n 'Low',\n 'Close',\n 'Close',\n '',\n 'Open',\n 'Open',\n 'High',\n 'Low',\n 'Close',\n 'Close',\n ''),\n 'type': 'scatter',\n 'x': [datetime.datetime(2013, 5, 18, 4, 48),\n datetime.datetime(2013, 6, 5, 0, 0),\n datetime.datetime(2013, 6, 5, 0, 0),\n datetime.datetime(2013, 6, 5, 0, 0),\n datetime.datetime(2013, 6, 5, 0, 0),\n datetime.datetime(2013, 6, 22, 19, 12),\n None,\n datetime.datetime(2013, 8, 19, 4, 48),\n datetime.datetime(2013, 9, 6, 0, 0),\n datetime.datetime(2013, 9, 6, 0, 0),\n datetime.datetime(2013, 9, 6, 0, 0),\n datetime.datetime(2013, 9, 6, 0, 0),\n datetime.datetime(2013, 9, 23, 19, 12),\n None,\n datetime.datetime(2014, 2, 15, 4, 48),\n datetime.datetime(2014, 3, 5, 0, 0),\n datetime.datetime(2014, 3, 5, 0, 0),\n datetime.datetime(2014, 3, 5, 0, 0),\n datetime.datetime(2014, 3, 5, 0, 0),\n datetime.datetime(2014, 3, 22, 19, 12),\n None,\n datetime.datetime(2014, 8, 17, 4, 48),\n datetime.datetime(2014, 9, 4, 0, 0),\n datetime.datetime(2014, 9, 4, 0, 0),\n datetime.datetime(2014, 9, 4, 0, 0),\n datetime.datetime(2014, 9, 4, 0, 0),\n datetime.datetime(2014, 9, 21, 19, 12),\n None],\n 'y': [33.31,\n 33.31,\n 34.37,\n 30.75,\n 31.93,\n 31.93,\n None,\n 33.5,\n 33.5,\n 33.62,\n 32.87,\n 33.37,\n 33.37,\n None,\n 34.12,\n 34.12,\n 35.18,\n 30.81,\n 31.18,\n 31.18,\n None,\n 33.31,\n 33.31,\n 35.37,\n 32.75,\n 32.93,\n 32.93,\n None]}],\n 'layout': {'hovermode': 'closest',\n 'xaxis': {'zeroline': False}}}\n self.assertEqual(ohlc_d, ex_ohlc_d)", "metadata": "root.TestFinanceCharts.test_datetime_ohlc", "header": "['class', 'TestFinanceCharts', '(', 'TestCase', ')', ':', '___EOS___']", "index": 348 }, { "content": " def test_datetime_candlestick(self):\n\n # Check expected outcome for candlestick chart with datetime xaxis\n\n high_data = [34.20, 34.37, 33.62, 34.25, 35.18, 33.25, 35.37, 34.62]\n low_data = [31.70, 30.75, 32.87, 31.62, 30.81, 32.75, 32.75, 32.87]\n close_data = [34.10, 31.93, 33.37, 33.18, 31.18, 33.10, 32.93, 33.70]\n open_data = [33.01, 33.31, 33.50, 32.06, 34.12, 33.05, 33.31, 33.50]\n\n x = [datetime.datetime(year=2013, month=3, day=4),\n datetime.datetime(year=2013, month=6, day=5),\n datetime.datetime(year=2013, month=9, day=6),\n datetime.datetime(year=2013, month=12, day=4),\n datetime.datetime(year=2014, month=3, day=5),\n datetime.datetime(year=2014, month=6, day=6),\n datetime.datetime(year=2014, month=9, day=4),\n datetime.datetime(year=2014, month=12, day=5)]\n\n candle = tls.FigureFactory.create_candlestick(open_data, high_data,\n low_data, close_data,\n dates=x)\n exp_candle = {'data': [{'boxpoints': False,\n 'fillcolor': '#3D9970',\n 'line': {'color': '#3D9970'},\n 'name': 'Increasing',\n 'showlegend': False,\n 'type': 'box',\n 'whiskerwidth': 0,\n 'x': [datetime.datetime(2013, 3, 4, 0, 0),\n datetime.datetime(2013, 3, 4, 0, 0),\n datetime.datetime(2013, 3, 4, 0, 0),\n datetime.datetime(2013, 3, 4, 0, 0),\n datetime.datetime(2013, 3, 4, 0, 0),\n datetime.datetime(2013, 3, 4, 0, 0),\n datetime.datetime(2013, 12, 4, 0, 0),\n datetime.datetime(2013, 12, 4, 0, 0),\n datetime.datetime(2013, 12, 4, 0, 0),\n datetime.datetime(2013, 12, 4, 0, 0),\n datetime.datetime(2013, 12, 4, 0, 0),\n datetime.datetime(2013, 12, 4, 0, 0),\n datetime.datetime(2014, 6, 6, 0, 0),\n datetime.datetime(2014, 6, 6, 0, 0),\n datetime.datetime(2014, 6, 6, 0, 0),\n datetime.datetime(2014, 6, 6, 0, 0),\n datetime.datetime(2014, 6, 6, 0, 0),\n datetime.datetime(2014, 6, 6, 0, 0),\n datetime.datetime(2014, 12, 5, 0, 0),\n datetime.datetime(2014, 12, 5, 0, 0),\n datetime.datetime(2014, 12, 5, 0, 0),\n datetime.datetime(2014, 12, 5, 0, 0),\n datetime.datetime(2014, 12, 5, 0, 0),\n datetime.datetime(2014, 12, 5, 0, 0)],\n 'y': [31.7,\n 33.01,\n 34.1,\n 34.1,\n 34.1,\n 34.2,\n 31.62,\n 32.06,\n 33.18,\n 33.18,\n 33.18,\n 34.25,\n 32.75,\n 33.05,\n 33.1,\n 33.1,\n 33.1,\n 33.25,\n 32.87,\n 33.5,\n 33.7,\n 33.7,\n 33.7,\n 34.62]},\n {'boxpoints': False,\n 'fillcolor': '#FF4136',\n 'line': {'color': '#FF4136'},\n 'name': 'Decreasing',\n 'showlegend': False,\n 'type': 'box',\n 'whiskerwidth': 0,\n 'x': [datetime.datetime(2013, 6, 5, 0, 0),\n datetime.datetime(2013, 6, 5, 0, 0),\n datetime.datetime(2013, 6, 5, 0, 0),\n datetime.datetime(2013, 6, 5, 0, 0),\n datetime.datetime(2013, 6, 5, 0, 0),\n datetime.datetime(2013, 6, 5, 0, 0),\n datetime.datetime(2013, 9, 6, 0, 0),\n datetime.datetime(2013, 9, 6, 0, 0),\n datetime.datetime(2013, 9, 6, 0, 0),\n datetime.datetime(2013, 9, 6, 0, 0),\n datetime.datetime(2013, 9, 6, 0, 0),\n datetime.datetime(2013, 9, 6, 0, 0),\n datetime.datetime(2014, 3, 5, 0, 0),\n datetime.datetime(2014, 3, 5, 0, 0),\n datetime.datetime(2014, 3, 5, 0, 0),\n datetime.datetime(2014, 3, 5, 0, 0),\n datetime.datetime(2014, 3, 5, 0, 0),\n datetime.datetime(2014, 3, 5, 0, 0),\n datetime.datetime(2014, 9, 4, 0, 0),\n datetime.datetime(2014, 9, 4, 0, 0),\n datetime.datetime(2014, 9, 4, 0, 0),\n datetime.datetime(2014, 9, 4, 0, 0),\n datetime.datetime(2014, 9, 4, 0, 0),\n datetime.datetime(2014, 9, 4, 0, 0)],\n 'y': [30.75,\n 33.31,\n 31.93,\n 31.93,\n 31.93,\n 34.37,\n 32.87,\n 33.5,\n 33.37,\n 33.37,\n 33.37,\n 33.62,\n 30.81,\n 34.12,\n 31.18,\n 31.18,\n 31.18,\n 35.18,\n 32.75,\n 33.31,\n 32.93,\n 32.93,\n 32.93,\n 35.37]}],\n 'layout': {}}\n\n self.assertEqual(candle, exp_candle)", "metadata": "root.TestFinanceCharts.test_datetime_candlestick", "header": "['class', 'TestFinanceCharts', '(', 'TestCase', ')', ':', '___EOS___']", "index": 552 }, { "content": "class TestAnnotatedHeatmap(TestCase):\n\n\n\n\n", "metadata": "root.TestAnnotatedHeatmap", "header": "['module', '___EOS___']", "index": 688 }, { "content": " def test_unequal_z_text_size(self):\n\n # check: PlotlyError if z and text are not the same dimensions\n\n kwargs = {'z': [[1, 2], [1, 2]], 'annotation_text': [[1, 2, 3], [1]]}\n self.assertRaises(PlotlyError,\n tls.FigureFactory.create_annotated_heatmap,\n **kwargs)\n\n kwargs = {'z': [[1], [1]], 'annotation_text': [[1], [1], [1]]}\n self.assertRaises(PlotlyError,\n tls.FigureFactory.create_annotated_heatmap,\n **kwargs)", "metadata": "root.TestAnnotatedHeatmap.test_unequal_z_text_size", "header": "['class', 'TestAnnotatedHeatmap', '(', 'TestCase', ')', ':', '___EOS___']", "index": 690 }, { "content": " def test_incorrect_x_size(self):\n\n # check: PlotlyError if x is the wrong size\n\n kwargs = {'z': [[1, 2], [1, 2]], 'x': ['A']}\n self.assertRaises(PlotlyError,\n tls.FigureFactory.create_annotated_heatmap,\n **kwargs)", "metadata": "root.TestAnnotatedHeatmap.test_incorrect_x_size", "header": "['class', 'TestAnnotatedHeatmap', '(', 'TestCase', ')', ':', '___EOS___']", "index": 704 }, { "content": " def test_incorrect_y_size(self):\n\n # check: PlotlyError if y is the wrong size\n\n kwargs = {'z': [[1, 2], [1, 2]], 'y': [1, 2, 3]}\n self.assertRaises(PlotlyError,\n tls.FigureFactory.create_annotated_heatmap,\n **kwargs)", "metadata": "root.TestAnnotatedHeatmap.test_incorrect_y_size", "header": "['class', 'TestAnnotatedHeatmap', '(', 'TestCase', ')', ':', '___EOS___']", "index": 713 }, { "content": " def test_simple_annotated_heatmap(self):\n\n # we should be able to create a heatmap with annotated values with a\n # logical text color\n\n z = [[1, 0, .5], [.25, .75, .45]]\n a_heat = tls.FigureFactory.create_annotated_heatmap(z)\n expected_a_heat = {\n 'data': [{'colorscale': 'RdBu',\n 'showscale': False,\n 'type': 'heatmap',\n 'z': [[1, 0, 0.5], [0.25, 0.75, 0.45]]}],\n 'layout': {'annotations': [{'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': '1',\n 'x': 0,\n 'xref': 'x1',\n 'y': 0,\n 'yref': 'y1'},\n {'font': {'color': '#FFFFFF'},\n 'showarrow': False,\n 'text': '0',\n 'x': 1,\n 'xref': 'x1',\n 'y': 0,\n 'yref': 'y1'},\n {'font': {'color': '#FFFFFF'},\n 'showarrow': False,\n 'text': '0.5',\n 'x': 2,\n 'xref': 'x1',\n 'y': 0,\n 'yref': 'y1'},\n {'font': {'color': '#FFFFFF'},\n 'showarrow': False,\n 'text': '0.25',\n 'x': 0,\n 'xref': 'x1',\n 'y': 1,\n 'yref': 'y1'},\n {'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': '0.75',\n 'x': 1,\n 'xref': 'x1',\n 'y': 1,\n 'yref': 'y1'},\n {'font': {'color': '#FFFFFF'},\n 'showarrow': False,\n 'text': '0.45',\n 'x': 2,\n 'xref': 'x1',\n 'y': 1,\n 'yref': 'y1'}],\n 'xaxis': {'gridcolor': 'rgb(0, 0, 0)',\n 'showticklabels': False,\n 'side': 'top',\n 'ticks': ''},\n 'yaxis': {'showticklabels': False, 'ticks': '',\n 'ticksuffix': ' '}}}\n self.assertEqual(a_heat, expected_a_heat)", "metadata": "root.TestAnnotatedHeatmap.test_simple_annotated_heatmap", "header": "['class', 'TestAnnotatedHeatmap', '(', 'TestCase', ')', ':', '___EOS___']", "index": 722 }, { "content": " def test_annotated_heatmap_kwargs(self):\n\n # we should be able to create an annotated heatmap with x and y axes\n # lables, a defined colorscale, and supplied text.\n\n z = [[1, 0], [.25, .75], [.45, .5]]\n text = [['first', 'second'], ['third', 'fourth'], ['fifth', 'sixth']]\n a = tls.FigureFactory.create_annotated_heatmap(z, x=['A', 'B'],\n y=['One', 'Two',\n 'Three'],\n annotation_text=text,\n colorscale=[[0,\n '#ffffff'],\n [1,\n '#e6005a']]\n )\n expected_a = {'data': [{'colorscale': [[0, '#ffffff'], [1, '#e6005a']],\n 'showscale': False,\n 'type': 'heatmap',\n 'x': ['A', 'B'],\n 'y': ['One', 'Two', 'Three'],\n 'z': [[1, 0], [0.25, 0.75], [0.45, 0.5]]}],\n 'layout': {'annotations': [{'font': {'color': '#FFFFFF'},\n 'showarrow': False,\n 'text': 'first',\n 'x': 'A',\n 'xref': 'x1',\n 'y': 'One',\n 'yref': 'y1'},\n {'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': 'second',\n 'x': 'B',\n 'xref': 'x1',\n 'y': 'One',\n 'yref': 'y1'},\n {'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': 'third',\n 'x': 'A',\n 'xref': 'x1',\n 'y': 'Two',\n 'yref': 'y1'},\n {'font': {'color': '#FFFFFF'},\n 'showarrow': False,\n 'text': 'fourth',\n 'x': 'B',\n 'xref': 'x1',\n 'y': 'Two',\n 'yref': 'y1'},\n {'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': 'fifth',\n 'x': 'A',\n 'xref': 'x1',\n 'y': 'Three',\n 'yref': 'y1'},\n {'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': 'sixth',\n 'x': 'B',\n 'xref': 'x1',\n 'y': 'Three',\n 'yref': 'y1'}],\n 'xaxis': {'dtick': 1,\n 'gridcolor': 'rgb(0, 0, 0)',\n 'side': 'top',\n 'ticks': ''},\n 'yaxis': {'dtick': 1, 'ticks': '',\n 'ticksuffix': ' '}}}\n self.assertEqual(a, expected_a)", "metadata": "root.TestAnnotatedHeatmap.test_annotated_heatmap_kwargs", "header": "['class', 'TestAnnotatedHeatmap', '(', 'TestCase', ')', ':', '___EOS___']", "index": 784 }, { "content": "class TestTable(TestCase):\n\n\n", "metadata": "root.TestTable", "header": "['module', '___EOS___']", "index": 857 }, { "content": " def test_fontcolor_input(self):\n\n # check: PlotlyError if fontcolor input is incorrect\n\n kwargs = {'table_text': [['one', 'two'], [1, 2], [1, 2], [1, 2]],\n 'fontcolor': '#000000'}\n self.assertRaises(PlotlyError,\n tls.FigureFactory.create_table, **kwargs)\n\n kwargs = {'table_text': [['one', 'two'], [1, 2], [1, 2], [1, 2]],\n 'fontcolor': ['red', 'blue']}\n self.assertRaises(PlotlyError,\n tls.FigureFactory.create_table, **kwargs)", "metadata": "root.TestTable.test_fontcolor_input", "header": "['class', 'TestTable', '(', 'TestCase', ')', ':', '___EOS___']", "index": 859 }, { "content": " def test_simple_table(self):\n\n # we should be able to create a striped table by suppling a text matrix\n\n text = [['Country', 'Year', 'Population'], ['US', 2000, 282200000],\n ['Canada', 2000, 27790000], ['US', 1980, 226500000]]\n table = tls.FigureFactory.create_table(text)\n expected_table = {'data': [{'colorscale': [[0, '#00083e'],\n [0.5, '#ededee'],\n [1, '#ffffff']],\n 'hoverinfo': 'none',\n 'opacity': 0.75,\n 'showscale': False,\n 'type': 'heatmap',\n 'z': [[0, 0, 0], [0.5, 0.5, 0.5],\n [1, 1, 1], [0.5, 0.5, 0.5]]}],\n 'layout': {'annotations': [{'align': 'left',\n 'font': {'color': '#ffffff'},\n 'showarrow': False,\n 'text': '<b>Country</b>',\n 'x': -0.45,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 0,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#ffffff'},\n 'showarrow': False,\n 'text': '<b>Year</b>',\n 'x': 0.55,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 0,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#ffffff'},\n 'showarrow': False,\n 'text': '<b>Population</b>',\n 'x': 1.55,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 0,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': 'US',\n 'x': -0.45,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 1,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': '2000',\n 'x': 0.55,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 1,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': '282200000',\n 'x': 1.55,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 1,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': 'Canada',\n 'x': -0.45,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 2,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': '2000',\n 'x': 0.55,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 2,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': '27790000',\n 'x': 1.55,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 2,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': 'US',\n 'x': -0.45,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 3,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': '1980',\n 'x': 0.55,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 3,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': '226500000',\n 'x': 1.55,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 3,\n 'yref': 'y1'}],\n 'height': 170,\n 'margin': {'b': 0, 'l': 0, 'r': 0, 't': 0},\n 'xaxis': {'dtick': 1,\n 'gridwidth': 2,\n 'showticklabels': False,\n 'tick0': -0.5,\n 'ticks': '',\n 'zeroline': False},\n 'yaxis': {'autorange': 'reversed',\n 'dtick': 1,\n 'gridwidth': 2,\n 'showticklabels': False,\n 'tick0': 0.5,\n 'ticks': '',\n 'zeroline': False}}}\n self.assertEqual(table, expected_table)", "metadata": "root.TestTable.test_simple_table", "header": "['class', 'TestTable', '(', 'TestCase', ')', ':', '___EOS___']", "index": 873 }, { "content": " def test_table_with_index(self):\n\n # we should be able to create a striped table where the first column\n # matches the coloring of the header\n\n text = [['Country', 'Year', 'Population'], ['US', 2000, 282200000],\n ['Canada', 2000, 27790000]]\n index_table = tls.FigureFactory.create_table(text, index=True,\n index_title='Title')\n exp_index_table = {'data': [{'colorscale': [[0, '#00083e'], [0.5, '#ededee'], [1, '#ffffff']],\n 'hoverinfo': 'none',\n 'opacity': 0.75,\n 'showscale': False,\n 'type': 'heatmap',\n 'z': [[0, 0, 0], [0, 0.5, 0.5], [0, 1, 1]]}],\n 'layout': {'annotations': [{'align': 'left',\n 'font': {'color': '#ffffff'},\n 'showarrow': False,\n 'text': '<b>Country</b>',\n 'x': -0.45,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 0,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#ffffff'},\n 'showarrow': False,\n 'text': '<b>Year</b>',\n 'x': 0.55,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 0,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#ffffff'},\n 'showarrow': False,\n 'text': '<b>Population</b>',\n 'x': 1.55,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 0,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#ffffff'},\n 'showarrow': False,\n 'text': '<b>US</b>',\n 'x': -0.45,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 1,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': '2000',\n 'x': 0.55,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 1,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': '282200000',\n 'x': 1.55,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 1,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#ffffff'},\n 'showarrow': False,\n 'text': '<b>Canada</b>',\n 'x': -0.45,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 2,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': '2000',\n 'x': 0.55,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 2,\n 'yref': 'y1'},\n {'align': 'left',\n 'font': {'color': '#000000'},\n 'showarrow': False,\n 'text': '27790000',\n 'x': 1.55,\n 'xanchor': 'left',\n 'xref': 'x1',\n 'y': 2,\n 'yref': 'y1'}],\n 'height': 140,\n 'margin': {'b': 0, 'l': 0, 'r': 0, 't': 0},\n 'xaxis': {'dtick': 1,\n 'gridwidth': 2,\n 'showticklabels': False,\n 'tick0': -0.5,\n 'ticks': '',\n 'zeroline': False},\n 'yaxis': {'autorange': 'reversed',\n 'dtick': 1,\n 'gridwidth': 2,\n 'showticklabels': False,\n 'tick0': 0.5,\n 'ticks': '',\n 'zeroline': False}}}\n self.assertEqual(index_table, exp_index_table)", "metadata": "root.TestTable.test_table_with_index", "header": "['class', 'TestTable', '(', 'TestCase', ')', ':', '___EOS___']", "index": 1014 } ]
[ { "span": "from nose.tools import raises", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 29 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "math_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "unittest_", "import_", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "nose_", "._", "tools_", "import_", "raises_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "plotly", "_", "._", "tools_", "as_", "tls_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "plotly", "_", "._", "exceptions_", "import_", "Plot", "ly", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "plotly", "_", "._", "graph", "\\u", "objs_", "import_", "graph", "\\u", "objs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "class", " ", "Test", "Dist", "plot", "(", "Test", "Case", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "def", " ", "test\\u", "sci", "py", "\\u", "import", "\\u", "error", "(", "self", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "#", " ", "make", " ", "sure", " ", "Import", " ", "Error", " ", "is", " ", "raise", "d", " ", "whe", "n", " ", "\\u", "sci", "py", "\\u", "import", "ed", " ", "=", " ", "False_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "hist", "\\u", "data", " ", "=", " ", "[[", "1.1", ",", " ", "1.1", ",", " ", "2.5", ",", " ", "3.0", ",", " ", "3.5", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "3.5", ",", " ", "4.1", ",", " ", "4.4", ",", " ", "4.5", ",", " ", "4.5", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "5.0", ",", " ", "5.0", ",", " ", "5.2", ",", " ", "5.5", ",", " ", "5.5", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "5.5", ",", " ", "5.5", ",", " ", "5.5", ",", " ", "6.1", ",", " ", "7.0", "]]", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "group", "\\u", "labels", " ", "=", " ", "['", "dist", "plot", " ", "example", "']", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", "self", ".", "assert", "Rai", "ses", "Rege", "xp", "(", "Import", "Error", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", " ", " ", "\"", "Fig", "ure", "Factor", "y", ".", "create", "\\u", "dist", "plot", " ", "require", "s", " ", "sci", "py", "\",", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", " ", " ", "tls", ".", "Fig", "ure", "Factor", "y", ".", "create", "\\u", "dist", "plot", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", " ", " ", " ", " ", "hist", "\\u", "data", ",", " ", "group", "\\u", "labels", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Test", "Qui", "ver_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Test", "Qui", "ver_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "une", "qual", "\\u", "xy", "\\u", "length_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", ":", " ", "Plot", "ly", "Error", " ", "if", " ", "x", " ", "and", " ", "y", " ", "are", " ", "not", " ", "the", " ", "same", " ", "length_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "x", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "y", "'_", ":_", "[_", "1_", "]_", ",_", "'", "u", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "v", "'_", ":_", "[_", "1_", ",_", "2_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "quiv", "er_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Qui", "ver_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "wrong", "\\u", "scale_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", ":", " ", "Value", "Error", " ", "if", " ", "scale", " ", "is", " ", "<=", " ", "0_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "x", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "y", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "u", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "v", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "scale", "'_", ":_", "-_", "1_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Value", "Error_", ",_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "quiv", "er_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kwargs_", "=_", "{_", "'", "x", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "y", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "u", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "v", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "scale", "'_", ":_", "0_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Value", "Error_", ",_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "quiv", "er_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Qui", "ver_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "wrong", "\\u", "arrow", "\\u", "scale_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", ":", " ", "Value", "Error", " ", "if", " ", "arrow", "\\u", "scale", " ", "is", " ", "<=", " ", "0_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "x", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "y", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "u", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "v", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "arrow", "\\u", "scale", "'_", ":_", "-_", "1_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Value", "Error_", ",_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "quiv", "er_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kwargs_", "=_", "{_", "'", "x", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "y", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "u", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "v", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "arrow", "\\u", "scale", "'_", ":_", "0_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Value", "Error_", ",_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "quiv", "er_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Qui", "ver_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "one", "\\u", "arrow_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "shou", "ld", " ", "be", " ", "able", " ", "to", " ", "create", " ", "a", " ", "single", " ", "arrow", " ", "usi", "ng", " ", "create", "\\u", "quiv", "er_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "quiv", "er_", "=_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "quiv", "er_", "(_", "x_", "=_", "[_", "1_", "]_", ",_", "y_", "=_", "[_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u_", "=_", "[_", "1_", "]_", ",_", "v_", "=_", "[_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "scale_", "=_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "quiv", "er_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "data", "'_", ":_", "[_", "{_", "'", "mode", "'_", ":_", "'", "lines", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "u", "'", "scatter", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "[_", "1_", ",_", "2_", ",_", "None_", ",_", "1.8", "206", "982", "567", "619", "28_", ",_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1.6", "154", "8617", "076", "652", "7_", ",_", "None_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "[_", "1_", ",_", "2_", ",_", "None_", ",_", "1.6", "154", "8617", "076", "652", "7_", ",_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1.8", "206", "982", "567", "619", "28_", ",_", "None_", "]_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "layout", "'_", ":_", "{_", "'", "hover", "mode", "'_", ":_", "'", "closest", "'_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "quiv", "er_", ",_", "expected", "\\u", "quiv", "er_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Qui", "ver_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "more", "\\u", "kwargs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "shou", "ld", " ", "be", " ", "able", " ", "to", " ", "create", " ", "2", " ", "arrows", " ", "and", " ", "change", " ", "the", " ", "arrow", "\\u", "scale", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "angle", ",", " ", "and", " ", "arrow", " ", "usi", "ng", " ", "create", "\\u", "quiv", "er_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "quiv", "er_", "=_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "quiv", "er_", "(_", "x_", "=_", "[_", "1_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "y_", "=_", "[_", "1_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "u_", "=_", "[_", "math_", "._", "cos_", "(_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "math_", "._", "cos_", "(_", "2_", ")_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "v_", "=_", "[_", "math_", "._", "sin_", "(_", "1_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "math_", "._", "sin_", "(_", "2_", ")_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "arrow", "\\u", "scale_", "=_", ".4_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "angle_", "=_", "math_", "._", "pi_", "/_", "6_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "line_", "=_", "graph", "\\u", "objs_", "._", "Line_", "(_", "color_", "=_", "'", "pur", "ple", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "width_", "=_", "3_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "quiv", "er_", "=_", "{_", "'", "data", "'_", ":_", "[_", "{_", "'", "line", "'_", ":_", "{_", "'", "color", "'_", ":_", "'", "pur", "ple", "'_", ",_", "'", "widt", "h", "'_", ":_", "3_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mode", "'_", ":_", "'", "lines", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "u", "'", "scatter", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "[_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1.0", "540", "302", "305", "868", "139_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1.9", "583", "853", "163", "452", "858", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1.0", "521", "430", "293", "787", "67_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1.0", "540", "302", "305", "868", "139_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1.01", "848", "418", "998", "645", "12_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1.9", "909", "870", "141", "679", "737", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1.9", "583", "853", "163", "452", "858", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1.9", "546", "151", "170", "949", "464", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "[_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1.0", "841", "470", "984", "807", "897", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "2.0", "909", "297", "426", "825", "684", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1.0", "441", "916", "423", "877", "81_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1.0", "841", "470", "984", "807", "897", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "1.0", "658", "037", "346", "225", "067", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "2.0", "677", "536", "925", "644", "366", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "2.0", "909", "297", "426", "825", "684", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "2.0", "511", "078", "191", "025", "51_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", "]_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "layout", "'_", ":_", "{_", "'", "hover", "mode", "'_", ":_", "'", "closest", "'_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "quiv", "er_", ",_", "expected", "\\u", "quiv", "er_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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", "Financ", "e", "Char", "ts_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "TO", "-", "DO", ":", " ", "put", " ", "expected", " ", "fig", " ", "in", " ", "a", " ", "different", " ", "file", " ", "and", " ", "then", " ", "call", " ", "to", " ", "compare_", "\\u\\u\\uNL\\u\\u\\u_", "\\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", "Financ", "e", "Char", "ts_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "une", "qual", "\\u", "oh", "lc", "\\u", "length_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", ":", " ", "Plot", "ly", "Error", " ", "if", " ", "open", ",", " ", "high", ",", " ", "low", ",", " ", "close", " ", "are", " ", "not", " ", "the", " ", "same", " ", "length_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "for", " ", "Trace", "Factor", "y", ".", "create", "\\u", "oh", "lc", " ", "and", " ", "Trace", "Factor", "y", ".", "create", "\\u", "candle", "stick", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "open", "'_", ":_", "[_", "1_", "]_", ",_", "'", "high", "'_", ":_", "[_", "1_", ",_", "3_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "low", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "close", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "direction", "'_", ":_", "[_", "'", "incr", "easi", "ng", "'_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "oh", "lc_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "candle", "stick", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kwargs_", "=_", "{_", "'", "open", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "high", "'_", ":_", "[_", "1_", ",_", "2_", ",_", "3_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "low", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "close", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "direction", "'_", ":_", "[_", "'", "decre", "asin", "g", "'_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "oh", "lc_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "candle", "stick", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kwargs_", "=_", "{_", "'", "open", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "high", "'_", ":_", "[_", "2_", ",_", "3_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "low", "'_", ":_", "[_", "0_", "]_", ",_", "'", "close", "'_", ":_", "[_", "1_", ",_", "3_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "oh", "lc_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "candle", "stick", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kwargs_", "=_", "{_", "'", "open", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "high", "'_", ":_", "[_", "2_", ",_", "3_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "low", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "close", "'_", ":_", "[_", "1_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "oh", "lc_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "candle", "stick", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Financ", "e", "Char", "ts_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "direction", "\\u", "arg_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", ":", " ", "Plot", "ly", "Error", " ", "if", " ", "direction", " ", "is", " ", "not", " ", "defin", "ed", " ", "as", " ", "\"", "incr", "easi", "ng", "\"", " ", "or_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "\"", "decre", "asin", "g", "\"", " ", "for", " ", "Trace", "Factor", "y", ".", "create", "\\u", "oh", "lc", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Trace", "Factor", "y", ".", "create", "\\u", "candle", "stick", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "open", "'_", ":_", "[_", "1_", ",_", "4_", "]_", ",_", "'", "high", "'_", ":_", "[_", "1_", ",_", "5_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "low", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "close", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "direction", "'_", ":_", "[_", "'", "inc", "'_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Rai", "ses", "Regexp_", "(_", "Plot", "ly", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "direction", " ", "must", " ", "be", " ", "defin", "ed", " ", "as", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"'", "incr", "easi", "ng", "',", " ", "'", "decre", "asin", "g", "',", " ", "or", " ", "'", "bot", "h", "'\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "oh", "lc_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Rai", "ses", "Regexp_", "(_", "Plot", "ly", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "direction", " ", "must", " ", "be", " ", "defin", "ed", " ", "as", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"'", "incr", "easi", "ng", "',", " ", "'", "decre", "asin", "g", "',", " ", "or", " ", "'", "bot", "h", "'\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "candle", "stick", "_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kwargs_", "=_", "{_", "'", "open", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "high", "'_", ":_", "[_", "1_", ",_", "3_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "low", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "'", "close", "'_", ":_", "[_", "1_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "direction", "'_", ":_", "[_", "'", "d", "'_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Rai", "ses", "Regexp_", "(_", "Plot", "ly", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "direction", " ", "must", " ", "be", " ", "defin", "ed", " ", "as", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"'", "incr", "easi", "ng", "',", " ", "'", "decre", "asin", "g", "',", " ", "or", " ", "'", "bot", "h", "'\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "oh", "lc_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Rai", "ses", "Regexp_", "(_", "Plot", "ly", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "direction", " ", "must", " ", "be", " ", "defin", "ed", " ", "as", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"'", "incr", "easi", "ng", "',", " ", "'", "decre", "asin", "g", "',", " ", "or", " ", "'", "bot", "h", "'\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "candle", "stick", "_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Financ", "e", "Char", "ts_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "high", "\\u", "high", "est", "\\u", "value_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", ":", " ", "Plot", "ly", "Error", " ", "if", " ", "the", " ", "\"", "high", "\"", " ", "value", " ", "is", " ", "less", " ", "than", " ", "the", " ", "correspond", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "open", ",", " ", "low", ",", " ", "or", " ", "close", " ", "value", " ", "bec", "aus", "e", " ", "if", " ", "the", " ", "\"", "high", "\"", " ", "value", " ", "is", " ", "not", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "high", "est", " ", "(", "or", " ", "equal", ")", " ", "then", " ", "the", " ", "data", " ", "may", " ", "have", " ", "bee", "n", " ", "enter", "ed", " ", "incorrect", "ly", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "open", "'_", ":_", "[_", "2_", ",_", "3_", "]_", ",_", "'", "high", "'_", ":_", "[_", "4_", ",_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "low", "'_", ":_", "[_", "1_", ",_", "1_", "]_", ",_", "'", "close", "'_", ":_", "[_", "1_", ",_", "2_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Rai", "ses", "Regexp_", "(_", "Plot", "ly", "Error_", ",_", "\"", "Oo", "ps", "!", " ", "Look", "s", " ", "like", " ", "some", " ", "of", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "your", " ", "high", " ", "values", " ", "are", " ", "less", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "the", " ", "correspond", "ing", " ", "open", ",", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "low", ",", " ", "or", " ", "close", " ", "values", ".", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Doub", "le", " ", "check", " ", "tha", "t", " ", "your", " ", "data", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "is", " ", "enter", "ed", " ", "in", " ", "O", "-", "H", "-", "L", "-", "C", " ", "order", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "oh", "lc_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Rai", "ses", "Regexp_", "(_", "Plot", "ly", "Error_", ",_", "\"", "Oo", "ps", "!", " ", "Look", "s", " ", "like", " ", "some", " ", "of", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "your", " ", "high", " ", "values", " ", "are", " ", "less", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "the", " ", "correspond", "ing", " ", "open", ",", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "low", ",", " ", "or", " ", "close", " ", "values", ".", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Doub", "le", " ", "check", " ", "tha", "t", " ", "your", " ", "data", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "is", " ", "enter", "ed", " ", "in", " ", "O", "-", "H", "-", "L", "-", "C", " ", "order", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "candle", "stick", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Financ", "e", "Char", "ts_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "low", "\\u", "lowe", "st", "\\u", "value_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", ":", " ", "Plot", "ly", "Error", " ", "if", " ", "the", " ", "\"", "low", "\"", " ", "value", " ", "is", " ", "great", "er", " ", "than", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "correspond", "ing", " ", "open", ",", " ", "high", ",", " ", "or", " ", "close", " ", "value", " ", "bec", "aus", "e", " ", "if", " ", "the", " ", "\"", "low", "\"", " ", "value_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "is", " ", "not", " ", "the", " ", "lowe", "st", " ", "(", "or", " ", "equal", ")", " ", "then", " ", "the", " ", "data", " ", "may", " ", "have", " ", "bee", "n", " ", "enter", "ed_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "incorrect", "ly", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "create", "\\u", "oh", "lc", "\\u", "increase", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "open", "'_", ":_", "[_", "2_", ",_", "3_", "]_", ",_", "'", "high", "'_", ":_", "[_", "4_", ",_", "6_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "low", "'_", ":_", "[_", "3_", ",_", "1_", "]_", ",_", "'", "close", "'_", ":_", "[_", "1_", ",_", "2_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Rai", "ses", "Regexp_", "(_", "Plot", "ly", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Oo", "ps", "!", " ", "Look", "s", " ", "like", " ", "some", " ", "of", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "your", " ", "low", " ", "values", " ", "are", " ", "great", "er", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "than", " ", "the", " ", "correspond", "ing", " ", "high", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\",", " ", "open", ",", " ", "or", " ", "close", " ", "values", ".", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Doub", "le", " ", "check", " ", "tha", "t", " ", "your", " ", "data", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "is", " ", "enter", "ed", " ", "in", " ", "O", "-", "H", "-", "L", "-", "C", " ", "order", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "oh", "lc_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Rai", "ses", "Regexp_", "(_", "Plot", "ly", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Oo", "ps", "!", " ", "Look", "s", " ", "like", " ", "some", " ", "of", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "your", " ", "low", " ", "values", " ", "are", " ", "great", "er", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "than", " ", "the", " ", "correspond", "ing", " ", "high", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\",", " ", "open", ",", " ", "or", " ", "close", " ", "values", ".", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Doub", "le", " ", "check", " ", "tha", "t", " ", "your", " ", "data", " ", "\"_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "is", " ", "enter", "ed", " ", "in", " ", "O", "-", "H", "-", "L", "-", "C", " ", "order", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "candle", "stick", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Financ", "e", "Char", "ts_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "one", "\\u", "oh", "lc_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "shou", "ld", " ", "create", " ", "one", " ", "\"", "increase", "\"", " ", "(", "i", ".", "e", ".", " ", "close", " ", ">", " ", "open", ")", " ", "oh", "lc", " ", "stick", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oh", "lc_", "=_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "oh", "lc_", "(_", "open_", "=_", "[_", "33.", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "high_", "=_", "[_", "33.", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "low_", "=_", "[_", "32.", "7_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "close_", "=_", "[_", "33.", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "expected", "\\u", "oh", "lc_", "=_", "{_", "'", "layout", "'_", ":_", "{_", "'", "hover", "mode", "'_", ":_", "'", "closest", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xaxis", "'_", ":_", "{_", "'", "zero", "line", "'_", ":_", "False_", "}_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "data", "'_", ":_", "[_", "{_", "'", "y", "'_", ":_", "[_", "33.", "0_", ",_", "33.", "0_", ",_", "33.", "2_", ",_", "32.", "7_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "1_", ",_", "33.", "1_", ",_", "None_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "line", "'_", ":_", "{_", "'", "widt", "h", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "color", "'_", ":_", "'#", "3", "D", "997", "0", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "legend", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "Inc", "rea", "sing", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "(_", "'", "Open", "'_", ",_", "'", "Open", "'_", ",_", "'", "Hig", "h", "'_", ",_", "'", "Lo", "w", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "'", "Clos", "e", "'_", ",_", "''_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mode", "'_", ":_", "'", "lines", "'_", ",_", "'", "type", "'_", ":_", "'", "scatter", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "[_", "-_", "0.2_", ",_", "0_", ",_", "0_", ",_", "0_", ",_", "0_", ",_", "0.2_", ",_", "None_", "]_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "y", "'_", ":_", "[_", "]_", ",_", "'", "line", "'_", ":_", "{_", "'", "widt", "h", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "color", "'_", ":_", "'#", "FF", "413", "6", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "legend", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "Decre", "asin", "g", "'_", ",_", "'", "text", "'_", ":_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mode", "'_", ":_", "'", "lines", "'_", ",_", "'", "type", "'_", ":_", "'", "scatter", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "[_", "]_", "}_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "oh", "lc_", ",_", "expected", "\\u", "oh", "lc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Financ", "e", "Char", "ts_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "one", "\\u", "oh", "lc", "\\u", "increase", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "shou", "ld", " ", "create", " ", "one", " ", "\"", "increase", "\"", " ", "(", "i", ".", "e", ".", " ", "close", " ", ">", " ", "open", ")", " ", "oh", "lc", " ", "stick", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oh", "lc", "\\u", "incr_", "=_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "oh", "lc_", "(_", "open_", "=_", "[_", "33.", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "high_", "=_", "[_", "33.", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "low_", "=_", "[_", "32.", "7_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "close_", "=_", "[_", "33.", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "direction_", "=_", "\"", "incr", "easi", "ng", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "expected", "\\u", "oh", "lc", "\\u", "incr_", "=_", "{_", "'", "data", "'_", ":_", "[_", "{_", "'", "line", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "3", "D", "997", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "widt", "h", "'_", ":_", "1_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mode", "'_", ":_", "'", "lines", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "Inc", "rea", "sing", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "legend", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "(_", "'", "Open", "'_", ",_", "'", "Open", "'_", ",_", "'", "Hig", "h", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Lo", "w", "'_", ",_", "'", "Clos", "e", "'_", ",_", "'", "Clos", "e", "'_", ",_", "''_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "scatter", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "[_", "-_", "0.2_", ",_", "0_", ",_", "0_", ",_", "0_", ",_", "0_", ",_", "0.2_", ",_", "None_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "[_", "33.", "0_", ",_", "33.", "0_", ",_", "33.", "2_", ",_", "32.", "7_", ",_", "33.", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "1_", ",_", "None_", "]_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "layout", "'_", ":_", "{_", "'", "hover", "mode", "'_", ":_", "'", "closest", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xaxis", "'_", ":_", "{_", "'", "zero", "line", "'_", ":_", "False_", "}_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "oh", "lc", "\\u", "incr_", ",_", "expected", "\\u", "oh", "lc", "\\u", "incr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Financ", "e", "Char", "ts_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "one", "\\u", "oh", "lc", "\\u", "decrease", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "shou", "ld", " ", "create", " ", "one", " ", "\"", "increase", "\"", " ", "(", "i", ".", "e", ".", " ", "close", " ", ">", " ", "open", ")", " ", "oh", "lc", " ", "stick", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "oh", "lc", "\\u", "dec", "r_", "=_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "oh", "lc_", "(_", "open_", "=_", "[_", "33.", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "high_", "=_", "[_", "33.", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "low_", "=_", "[_", "30.", "7_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "close_", "=_", "[_", "31.", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "direction_", "=_", "\"", "decre", "asin", "g", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "expected", "\\u", "oh", "lc", "\\u", "dec", "r_", "=_", "{_", "'", "data", "'_", ":_", "[_", "{_", "'", "line", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "FF", "413", "6", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "widt", "h", "'_", ":_", "1_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mode", "'_", ":_", "'", "lines", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "Decre", "asin", "g", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "legend", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "(_", "'", "Open", "'_", ",_", "'", "Open", "'_", ",_", "'", "Hig", "h", "'_", ",_", "'", "Lo", "w", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "'", "Clos", "e", "'_", ",_", "''_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "scatter", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "[_", "-_", "0.2_", ",_", "0_", ",_", "0_", ",_", "0_", ",_", "0_", ",_", "0.2_", ",_", "None_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "[_", "33.", "0_", ",_", "33.", "0_", ",_", "33.", "2_", ",_", "30.", "7_", ",_", "31.", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "31.", "1_", ",_", "None_", "]_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "layout", "'_", ":_", "{_", "'", "hover", "mode", "'_", ":_", "'", "closest", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xaxis", "'_", ":_", "{_", "'", "zero", "line", "'_", ":_", "False_", "}_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "oh", "lc", "\\u", "dec", "r_", ",_", "expected", "\\u", "oh", "lc", "\\u", "dec", "r_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Financ", "e", "Char", "ts_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "one", "\\u", "candle", "stick", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "shou", "ld", " ", "create", " ", "one", " ", "\"", "increase", "\"", " ", "(", "i", ".", "e", ".", " ", "close", " ", ">", " ", "open", ")", " ", "candle", "stick", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "can", "\\u", "inc_", "=_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "candle", "stick", "_", "(_", "open_", "=_", "[_", "33.", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "high_", "=_", "[_", "33.", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "low_", "=_", "[_", "32.", "7_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "close_", "=_", "[_", "33.", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "exp", "\\u", "can", "\\u", "inc_", "=_", "{_", "'", "data", "'_", ":_", "[_", "{_", "'", "box", "points", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "fillc", "olor", "'_", ":_", "'#", "3", "D", "997", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "line", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "3", "D", "997", "0", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "Inc", "rea", "sing", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "legend", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "box", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "whis", "ker", "widt", "h", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "[_", "0_", ",_", "0_", ",_", "0_", ",_", "0_", ",_", "0_", ",_", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "[_", "32.", "7_", ",_", "33.", "0_", ",_", "33.", "1_", ",_", "33.", "1_", ",_", "33.", "1_", ",_", "33.", "2_", "]_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "box", "points", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "fillc", "olor", "'_", ":_", "'#", "FF", "413", "6", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "line", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "FF", "413", "6", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "Decre", "asin", "g", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "legend", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "box", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "whis", "ker", "widt", "h", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "[_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "[_", "]_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "layout", "'_", ":_", "{_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "can", "\\u", "inc_", ",_", "exp", "\\u", "can", "\\u", "inc_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Financ", "e", "Char", "ts_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "datetime", "\\u", "oh", "lc_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "expected", " ", "outco", "me", " ", "for", " ", "oh", "lc", " ", "chart", " ", "with", " ", "datetime", " ", "xaxis_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "high", "\\u", "data_", "=_", "[_", "34.", "20_", ",_", "34.", "37_", ",_", "33.", "62_", ",_", "34.", "25_", ",_", "35.", "18_", ",_", "33.", "25_", ",_", "35.", "37_", ",_", "34.", "62_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "low", "\\u", "data_", "=_", "[_", "31.", "70_", ",_", "30.", "75_", ",_", "32.", "87_", ",_", "31.", "62_", ",_", "30.", "81_", ",_", "32.", "75_", ",_", "32.", "75_", ",_", "32.", "87_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "close", "\\u", "data_", "=_", "[_", "34.", "10_", ",_", "31.", "93_", ",_", "33.", "37_", ",_", "33.", "18_", ",_", "31.", "18_", ",_", "33.", "10_", ",_", "32.", "93_", ",_", "33.", "70_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "open", "\\u", "data_", "=_", "[_", "33.", "01_", ",_", "33.", "31_", ",_", "33.", "50_", ",_", "32.", "06_", ",_", "34.", "12_", ",_", "33.", "05_", ",_", "33.", "31_", ",_", "33.", "50_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "x_", "=_", "[_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2013_", ",_", "month_", "=_", "3_", ",_", "day_", "=_", "4_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2013_", ",_", "month_", "=_", "6_", ",_", "day_", "=_", "5_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2013_", ",_", "month_", "=_", "9_", ",_", "day_", "=_", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2013_", ",_", "month_", "=_", "12_", ",_", "day_", "=_", "4_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2014_", ",_", "month_", "=_", "3_", ",_", "day_", "=_", "5_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2014_", ",_", "month_", "=_", "6_", ",_", "day_", "=_", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2014_", ",_", "month_", "=_", "9_", ",_", "day_", "=_", "4_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2014_", ",_", "month_", "=_", "12_", ",_", "day_", "=_", "5_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "oh", "lc", "\\u", "d_", "=_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "oh", "lc_", "(_", "open", "\\u", "data_", ",_", "high", "\\u", "data_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "low", "\\u", "data_", ",_", "close", "\\u", "data_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dates_", "=_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ex", "\\u", "oh", "lc", "\\u", "d_", "=_", "{_", "'", "data", "'_", ":_", "[_", "{_", "'", "line", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "3", "D", "997", "0", "'_", ",_", "'", "widt", "h", "'_", ":_", "1_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mode", "'_", ":_", "'", "lines", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "Inc", "rea", "sing", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "legend", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "(_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Hig", "h", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Lo", "w", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Hig", "h", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Lo", "w", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Hig", "h", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Lo", "w", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Hig", "h", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Lo", "w", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "''_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "scatter", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "[_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "2_", ",_", "14_", ",_", "4_", ",_", "48_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "3_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "3_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "3_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "3_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "3_", ",_", "21_", ",_", "19_", ",_", "12_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "11_", ",_", "16_", ",_", "4_", ",_", "48_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "12_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "12_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "12_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "12_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "12_", ",_", "21_", ",_", "19_", ",_", "12_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "5_", ",_", "19_", ",_", "4_", ",_", "48_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "6_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "6_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "6_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "6_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "6_", ",_", "23_", ",_", "19_", ",_", "12_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "11_", ",_", "17_", ",_", "4_", ",_", "48_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "12_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "12_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "12_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "12_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "12_", ",_", "22_", ",_", "19_", ",_", "12_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "[_", "33.", "01_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "01_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "31.", "7_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "06_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "06_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "25_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "31.", "62_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "18_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "18_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "05_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "05_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "25_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "75_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "62_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "87_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "7_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "7_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", "]_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "line", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "FF", "413", "6", "'_", ",_", "'", "widt", "h", "'_", ":_", "1_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mode", "'_", ":_", "'", "lines", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "Decre", "asin", "g", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "legend", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "(_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Hig", "h", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Lo", "w", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Hig", "h", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Lo", "w", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Hig", "h", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Lo", "w", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Open", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Hig", "h", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Lo", "w", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Clos", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "''_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "scatter", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "[_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "5_", ",_", "18_", ",_", "4_", ",_", "48_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "6_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "6_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "6_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "6_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "6_", ",_", "22_", ",_", "19_", ",_", "12_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "8_", ",_", "19_", ",_", "4_", ",_", "48_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "9_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "9_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "9_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "9_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "9_", ",_", "23_", ",_", "19_", ",_", "12_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "2_", ",_", "15_", ",_", "4_", ",_", "48_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "3_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "3_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "3_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "3_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "3_", ",_", "22_", ",_", "19_", ",_", "12_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "8_", ",_", "17_", ",_", "4_", ",_", "48_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "9_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "9_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "9_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "9_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "9_", ",_", "21_", ",_", "19_", ",_", "12_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "[_", "33.", "31_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "31_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "37_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "30.", "75_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "31.", "93_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "31.", "93_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "62_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "87_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "37_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "37_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "12_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "12_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "35.", "18_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "30.", "81_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "31.", "18_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "31.", "18_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "31_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "31_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "35.", "37_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "75_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "93_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "93_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", "]_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "layout", "'_", ":_", "{_", "'", "hover", "mode", "'_", ":_", "'", "closest", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xaxis", "'_", ":_", "{_", "'", "zero", "line", "'_", ":_", "False_", "}_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "oh", "lc", "\\u", "d_", ",_", "ex", "\\u", "oh", "lc", "\\u", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Financ", "e", "Char", "ts_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "datetime", "\\u", "candle", "stick", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "expected", " ", "outco", "me", " ", "for", " ", "candle", "stick", " ", "chart", " ", "with", " ", "datetime", " ", "xaxis_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "high", "\\u", "data_", "=_", "[_", "34.", "20_", ",_", "34.", "37_", ",_", "33.", "62_", ",_", "34.", "25_", ",_", "35.", "18_", ",_", "33.", "25_", ",_", "35.", "37_", ",_", "34.", "62_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "low", "\\u", "data_", "=_", "[_", "31.", "70_", ",_", "30.", "75_", ",_", "32.", "87_", ",_", "31.", "62_", ",_", "30.", "81_", ",_", "32.", "75_", ",_", "32.", "75_", ",_", "32.", "87_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "close", "\\u", "data_", "=_", "[_", "34.", "10_", ",_", "31.", "93_", ",_", "33.", "37_", ",_", "33.", "18_", ",_", "31.", "18_", ",_", "33.", "10_", ",_", "32.", "93_", ",_", "33.", "70_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "open", "\\u", "data_", "=_", "[_", "33.", "01_", ",_", "33.", "31_", ",_", "33.", "50_", ",_", "32.", "06_", ",_", "34.", "12_", ",_", "33.", "05_", ",_", "33.", "31_", ",_", "33.", "50_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "x_", "=_", "[_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2013_", ",_", "month_", "=_", "3_", ",_", "day_", "=_", "4_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2013_", ",_", "month_", "=_", "6_", ",_", "day_", "=_", "5_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2013_", ",_", "month_", "=_", "9_", ",_", "day_", "=_", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2013_", ",_", "month_", "=_", "12_", ",_", "day_", "=_", "4_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2014_", ",_", "month_", "=_", "3_", ",_", "day_", "=_", "5_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2014_", ",_", "month_", "=_", "6_", ",_", "day_", "=_", "6_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2014_", ",_", "month_", "=_", "9_", ",_", "day_", "=_", "4_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "year_", "=_", "2014_", ",_", "month_", "=_", "12_", ",_", "day_", "=_", "5_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "candle", "_", "=_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "candle", "stick", "_", "(_", "open", "\\u", "data_", ",_", "high", "\\u", "data_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "low", "\\u", "data_", ",_", "close", "\\u", "data_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "dates_", "=_", "x_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exp", "\\u", "candle", "_", "=_", "{_", "'", "data", "'_", ":_", "[_", "{_", "'", "box", "points", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "fillc", "olor", "'_", ":_", "'#", "3", "D", "997", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "line", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "3", "D", "997", "0", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "Inc", "rea", "sing", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "legend", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "box", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "whis", "ker", "widt", "h", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "[_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "3_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "3_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "3_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "3_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "3_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "3_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "12_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "12_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "12_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "12_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "12_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "12_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "6_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "6_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "6_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "6_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "6_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "6_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "12_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "12_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "12_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "12_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "12_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "12_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "[_", "31.", "7_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "01_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "31.", "62_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "06_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "18_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "18_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "18_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "25_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "75_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "05_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "25_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "87_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "7_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "7_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "7_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "62_", "]_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "box", "points", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "fillc", "olor", "'_", ":_", "'#", "FF", "413", "6", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "line", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "FF", "413", "6", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "Decre", "asin", "g", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "legend", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "box", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "whis", "ker", "widt", "h", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "[_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "6_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "6_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "6_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "6_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "6_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "6_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "9_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "9_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "9_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "9_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "9_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2013_", ",_", "9_", ",_", "6_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "3_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "3_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "3_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "3_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "3_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "3_", ",_", "5_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "9_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "9_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "9_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "9_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "9_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "datetime_", "._", "datetime_", "(_", "2014_", ",_", "9_", ",_", "4_", ",_", "0_", ",_", "0_", ")_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "[_", "30.", "75_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "31_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "31.", "93_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "31.", "93_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "31.", "93_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "37_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "87_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "37_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "37_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "37_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "62_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "30.", "81_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "34.", "12_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "31.", "18_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "31.", "18_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "31.", "18_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "35.", "18_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "75_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "33.", "31_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "93_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "93_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "32.", "93_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "35.", "37_", "]_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "layout", "'_", ":_", "{_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "candle", "_", ",_", "exp", "\\u", "candle", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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", "Annotate", "d", "Heat", "map_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Test", "Annotate", "d", "Heat", "map_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "une", "qual", "\\u", "z", "\\u", "text", "\\u", "size_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", ":", " ", "Plot", "ly", "Error", " ", "if", " ", "z", " ", "and", " ", "text", " ", "are", " ", "not", " ", "the", " ", "same", " ", "dimensions_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "z", "'_", ":_", "[_", "[_", "1_", ",_", "2_", "]_", ",_", "[_", "1_", ",_", "2_", "]_", "]_", ",_", "'", "annot", "ation", "\\u", "text", "'_", ":_", "[_", "[_", "1_", ",_", "2_", ",_", "3_", "]_", ",_", "[_", "1_", "]_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "annotated", "\\u", "heatmap", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kwargs_", "=_", "{_", "'", "z", "'_", ":_", "[_", "[_", "1_", "]_", ",_", "[_", "1_", "]_", "]_", ",_", "'", "annot", "ation", "\\u", "text", "'_", ":_", "[_", "[_", "1_", "]_", ",_", "[_", "1_", "]_", ",_", "[_", "1_", "]_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "annotated", "\\u", "heatmap", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Annotate", "d", "Heat", "map_", "(_", "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", "x", "\\u", "size_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", ":", " ", "Plot", "ly", "Error", " ", "if", " ", "x", " ", "is", " ", "the", " ", "wrong", " ", "size_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "z", "'_", ":_", "[_", "[_", "1_", ",_", "2_", "]_", ",_", "[_", "1_", ",_", "2_", "]_", "]_", ",_", "'", "x", "'_", ":_", "[_", "'", "A", "'_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "annotated", "\\u", "heatmap", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Annotate", "d", "Heat", "map_", "(_", "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", "y", "\\u", "size_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", ":", " ", "Plot", "ly", "Error", " ", "if", " ", "y", " ", "is", " ", "the", " ", "wrong", " ", "size_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "z", "'_", ":_", "[_", "[_", "1_", ",_", "2_", "]_", ",_", "[_", "1_", ",_", "2_", "]_", "]_", ",_", "'", "y", "'_", ":_", "[_", "1_", ",_", "2_", ",_", "3_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "annotated", "\\u", "heatmap", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Annotate", "d", "Heat", "map_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "simple", "\\u", "annotated", "\\u", "heatmap", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "shou", "ld", " ", "be", " ", "able", " ", "to", " ", "create", " ", "a", " ", "heatmap", " ", "with", " ", "annotated", " ", "values", " ", "with", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "logical", " ", "text", " ", "color_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "[_", "[_", "1_", ",_", "0_", ",_", ".5_", "]_", ",_", "[_", ".25_", ",_", ".75", "_", ",_", ".4", "5_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a", "\\u", "heat_", "=_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "annotated", "\\u", "heatmap", "_", "(_", "z_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "a", "\\u", "heat_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "data", "'_", ":_", "[_", "{_", "'", "colors", "cale", "'_", ":_", "'", "Rd", "Bu", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "scale", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "heatmap", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "z", "'_", ":_", "[_", "[_", "1_", ",_", "0_", ",_", "0.5_", "]_", ",_", "[_", "0.25_", ",_", "0.75_", ",_", "0.45_", "]_", "]_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "layout", "'_", ":_", "{_", "'", "annot", "ation", "s", "'_", ":_", "[_", "{_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "FFFF", "FF", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "FFFF", "FF", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "0.", "5", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "FFFF", "FF", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "0.25", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "0.75", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "FFFF", "FF", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "0.45", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xaxis", "'_", ":_", "{_", "'", "grid", "color", "'_", ":_", "'", "rgb", "(", "0", ",", " ", "0", ",", " ", "0", ")'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "showt", "ick", "labels", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "side", "'_", ":_", "'", "top", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tick", "s", "'_", ":_", "''_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yax", "is", "'_", ":_", "{_", "'", "showt", "ick", "labels", "'_", ":_", "False_", ",_", "'", "tick", "s", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tick", "suff", "ix", "'_", ":_", "'", " ", " ", "'_", "}_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "a", "\\u", "heat_", ",_", "expected", "\\u", "a", "\\u", "heat_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Annotate", "d", "Heat", "map_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "annotated", "\\u", "heatmap", "\\u", "kwargs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "shou", "ld", " ", "be", " ", "able", " ", "to", " ", "create", " ", "an", " ", "annotated", " ", "heatmap", " ", "with", " ", "x", " ", "and", " ", "y", " ", "axes_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "lable", "s", ",", " ", "a", " ", "defin", "ed", " ", "colors", "cale", ",", " ", "and", " ", "supplie", "d", " ", "text", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "z_", "=_", "[_", "[_", "1_", ",_", "0_", "]_", ",_", "[_", ".25_", ",_", ".75", "_", "]_", ",_", "[_", ".4", "5_", ",_", ".5_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "text_", "=_", "[_", "[_", "'", "first", "'_", ",_", "'", "second", "'_", "]_", ",_", "[_", "'", "third", "'_", ",_", "'", "fourth", "'_", "]_", ",_", "[_", "'", "fift", "h", "'_", ",_", "'", "sixt", "h", "'_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "a_", "=_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "annotated", "\\u", "heatmap", "_", "(_", "z_", ",_", "x_", "=_", "[_", "'", "A", "'_", ",_", "'", "B", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "y_", "=_", "[_", "'", "One", "'_", ",_", "'", "Tw", "o", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Thre", "e", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "annot", "ation", "\\u", "text_", "=_", "text_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "colors", "cale_", "=_", "[_", "[_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'#", "ffffff", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'#", "e", "600", "5a", "'_", "]_", "]_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "a_", "=_", "{_", "'", "data", "'_", ":_", "[_", "{_", "'", "colors", "cale", "'_", ":_", "[_", "[_", "0_", ",_", "'#", "ffffff", "'_", "]_", ",_", "[_", "1_", ",_", "'#", "e", "600", "5a", "'_", "]_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "scale", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "heatmap", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "[_", "'", "A", "'_", ",_", "'", "B", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "[_", "'", "One", "'_", ",_", "'", "Tw", "o", "'_", ",_", "'", "Thre", "e", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "z", "'_", ":_", "[_", "[_", "1_", ",_", "0_", "]_", ",_", "[_", "0.25_", ",_", "0.75_", "]_", ",_", "[_", "0.45_", ",_", "0.5_", "]_", "]_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "layout", "'_", ":_", "{_", "'", "annot", "ation", "s", "'_", ":_", "[_", "{_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "FFFF", "FF", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "first", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "'", "A", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "'", "One", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "second", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "'", "B", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "'", "One", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "third", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "'", "A", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "'", "Tw", "o", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "FFFF", "FF", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "fourth", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "'", "B", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "'", "Tw", "o", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "fift", "h", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "'", "A", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "'", "Thre", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "sixt", "h", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "'", "B", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "'", "Thre", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xaxis", "'_", ":_", "{_", "'", "dt", "ick", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "grid", "color", "'_", ":_", "'", "rgb", "(", "0", ",", " ", "0", ",", " ", "0", ")'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "side", "'_", ":_", "'", "top", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tick", "s", "'_", ":_", "''_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yax", "is", "'_", ":_", "{_", "'", "dt", "ick", "'_", ":_", "1_", ",_", "'", "tick", "s", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tick", "suff", "ix", "'_", ":_", "'", " ", " ", "'_", "}_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "a_", ",_", "expected", "\\u", "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_", "class_", "Test", "Table_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Test", "Table_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test\\u", "font", "color", "\\u", "input_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "check", ":", " ", "Plot", "ly", "Error", " ", "if", " ", "font", "color", " ", "input", " ", "is", " ", "incorrect", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kwargs_", "=_", "{_", "'", "table", "\\u", "text", "'_", ":_", "[_", "[_", "'", "one", "'_", ",_", "'", "two", "'_", "]_", ",_", "[_", "1_", ",_", "2_", "]_", ",_", "[_", "1_", ",_", "2_", "]_", ",_", "[_", "1_", ",_", "2_", "]_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "color", "'_", ":_", "'#", "000000", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "table_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kwargs_", "=_", "{_", "'", "table", "\\u", "text", "'_", ":_", "[_", "[_", "'", "one", "'_", ",_", "'", "two", "'_", "]_", ",_", "[_", "1_", ",_", "2_", "]_", ",_", "[_", "1_", ",_", "2_", "]_", ",_", "[_", "1_", ",_", "2_", "]_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "color", "'_", ":_", "[_", "'", "red", "'_", ",_", "'", "blue", "'_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Raises_", "(_", "Plot", "ly", "Error_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "table_", ",_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Table_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "simple", "\\u", "table_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "shou", "ld", " ", "be", " ", "able", " ", "to", " ", "create", " ", "a", " ", "strip", "ed", " ", "table", " ", "by", " ", "suppl", "ing", " ", "a", " ", "text", " ", "matrix_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "text_", "=_", "[_", "[_", "'", "Count", "ry", "'_", ",_", "'", "Year", "'_", ",_", "'", "Popula", "tion", "'_", "]_", ",_", "[_", "'", "US", "'_", ",_", "2000_", ",_", "282", "200000", "_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'", "Cana", "da", "'_", ",_", "2000_", ",_", "277", "9000", "0_", "]_", ",_", "[_", "'", "US", "'_", ",_", "1980", "_", ",_", "226", "500000", "_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "table_", "=_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "table_", "(_", "text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "table_", "=_", "{_", "'", "data", "'_", ":_", "[_", "{_", "'", "colors", "cale", "'_", ":_", "[_", "[_", "0_", ",_", "'#", "0008", "3e", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "0.5_", ",_", "'#", "eded", "ee", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "1_", ",_", "'#", "ffffff", "'_", "]_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "hover", "info", "'_", ":_", "'", "none", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "opa", "city", "'_", ":_", "0.75_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "scale", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "heatmap", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "z", "'_", ":_", "[_", "[_", "0_", ",_", "0_", ",_", "0_", "]_", ",_", "[_", "0.5_", ",_", "0.5_", ",_", "0.5_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "1_", ",_", "1_", ",_", "1_", "]_", ",_", "[_", "0.5_", ",_", "0.5_", ",_", "0.5_", "]_", "]_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "layout", "'_", ":_", "{_", "'", "annot", "ation", "s", "'_", ":_", "[_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "ffffff", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'<", "b", ">", "Count", "ry", "</", "b", ">'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "-_", "0.45_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "ffffff", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'<", "b", ">", "Year", "</", "b", ">'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "0.55", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "ffffff", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'<", "b", ">", "Popula", "tion", "</", "b", ">'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "1.5", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "US", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "-_", "0.45_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "2000", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "0.55", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "282", "200000", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "1.5", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "Cana", "da", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "-_", "0.45_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "2000", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "0.55", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "277", "9000", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "1.5", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "US", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "-_", "0.45_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "1980", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "0.55", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "226", "500000", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "1.5", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "3_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "height", "'_", ":_", "170_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "marg", "in", "'_", ":_", "{_", "'", "b", "'_", ":_", "0_", ",_", "'", "l", "'_", ":_", "0_", ",_", "'", "r", "'_", ":_", "0_", ",_", "'", "t", "'_", ":_", "0_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xaxis", "'_", ":_", "{_", "'", "dt", "ick", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "grid", "widt", "h", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "showt", "ick", "labels", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tick", "0", "'_", ":_", "-_", "0.5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tick", "s", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zero", "line", "'_", ":_", "False_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yax", "is", "'_", ":_", "{_", "'", "autor", "ange", "'_", ":_", "'", "reverse", "d", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "dt", "ick", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "grid", "widt", "h", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "showt", "ick", "labels", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tick", "0", "'_", ":_", "0.5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tick", "s", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zero", "line", "'_", ":_", "False_", "}_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "table_", ",_", "expected", "\\u", "table_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Table_", "(_", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "table", "\\u", "with", "\\u", "index_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "shou", "ld", " ", "be", " ", "able", " ", "to", " ", "create", " ", "a", " ", "strip", "ed", " ", "table", " ", "where", " ", "the", " ", "first", " ", "column_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "matche", "s", " ", "the", " ", "colori", "ng", " ", "of", " ", "the", " ", "header_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "text_", "=_", "[_", "[_", "'", "Count", "ry", "'_", ",_", "'", "Year", "'_", ",_", "'", "Popula", "tion", "'_", "]_", ",_", "[_", "'", "US", "'_", ",_", "2000_", ",_", "282", "200000", "_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'", "Cana", "da", "'_", ",_", "2000_", ",_", "277", "9000", "0_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index", "\\u", "table_", "=_", "tls_", "._", "Fig", "ure", "Factory_", "._", "create", "\\u", "table_", "(_", "text_", ",_", "index_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "index", "\\u", "title_", "=_", "'", "Tit", "le", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "exp", "\\u", "index", "\\u", "table_", "=_", "{_", "'", "data", "'_", ":_", "[_", "{_", "'", "colors", "cale", "'_", ":_", "[_", "[_", "0_", ",_", "'#", "0008", "3e", "'_", "]_", ",_", "[_", "0.5_", ",_", "'#", "eded", "ee", "'_", "]_", ",_", "[_", "1_", ",_", "'#", "ffffff", "'_", "]_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "hover", "info", "'_", ":_", "'", "none", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "opa", "city", "'_", ":_", "0.75_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "scale", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "heatmap", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "z", "'_", ":_", "[_", "[_", "0_", ",_", "0_", ",_", "0_", "]_", ",_", "[_", "0_", ",_", "0.5_", ",_", "0.5_", "]_", ",_", "[_", "0_", ",_", "1_", ",_", "1_", "]_", "]_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "layout", "'_", ":_", "{_", "'", "annot", "ation", "s", "'_", ":_", "[_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "ffffff", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'<", "b", ">", "Count", "ry", "</", "b", ">'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "-_", "0.45_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "ffffff", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'<", "b", ">", "Year", "</", "b", ">'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "0.55", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "ffffff", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'<", "b", ">", "Popula", "tion", "</", "b", ">'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "1.5", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "ffffff", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'<", "b", ">", "US", "</", "b", ">'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "-_", "0.45_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "2000", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "0.55", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "282", "200000", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "1.5", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "ffffff", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'<", "b", ">", "Cana", "da", "</", "b", ">'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "-_", "0.45_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "2000", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "0.55", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "align", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "font", "'_", ":_", "{_", "'", "color", "'_", ":_", "'#", "000000", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "show", "arrow", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "'", "277", "9000", "0", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "x", "'_", ":_", "1.5", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xa", "nch", "or", "'_", ":_", "'", "left", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xref", "'_", ":_", "'", "x1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "y", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yre", "f", "'_", ":_", "'", "y1", "'_", "}_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "height", "'_", ":_", "140_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "marg", "in", "'_", ":_", "{_", "'", "b", "'_", ":_", "0_", ",_", "'", "l", "'_", ":_", "0_", ",_", "'", "r", "'_", ":_", "0_", ",_", "'", "t", "'_", ":_", "0_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "xaxis", "'_", ":_", "{_", "'", "dt", "ick", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "grid", "widt", "h", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "showt", "ick", "labels", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tick", "0", "'_", ":_", "-_", "0.5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tick", "s", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zero", "line", "'_", ":_", "False_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "yax", "is", "'_", ":_", "{_", "'", "autor", "ange", "'_", ":_", "'", "reverse", "d", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "dt", "ick", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "grid", "widt", "h", "'_", ":_", "2_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "showt", "ick", "labels", "'_", ":_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tick", "0", "'_", ":_", "0.5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tick", "s", "'_", ":_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "zero", "line", "'_", ":_", "False_", "}_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "index", "\\u", "table_", ",_", "exp", "\\u", "index", "\\u", "table_", ")_", "\\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, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Unused import
fp7-ofelia/ocf/vt_manager/src/python/vt_manager/models/VTServer.py
[ { "content": "from django.db import models\nfrom django.contrib import auth\nfrom threading import Lock \nimport re\nimport uuid\nimport inspect \nfrom django.core.exceptions import ValidationError\nfrom vt_manager.models.NetworkInterface import NetworkInterface\nfrom vt_manager.communication.XmlRpcClient import XmlRpcClient\nfrom vt_manager.models.utils.Choices import VirtTechClass, OSDistClass, OSVersionClass, OSTypeClass\nfrom vt_manager.utils.MutexStore import MutexStore\nfrom vt_manager.models.MacRange import MacRange\nfrom vt_manager.models.Ip4Range import Ip4Range\nfrom vt_manager.common.utils import validators\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def validateAgentURLwrapper(url):\n\tVTServer.validateAgentURL(url)", "metadata": "root.validateAgentURLwrapper", "header": "['module', '___EOS___']", "index": 15 }, { "content": "class VTServer(models.Model):\n\t\"\"\"Virtualization Server class\"\"\"\n\n\tclass Meta:\n\t\t\"\"\"Meta Class for your model.\"\"\"\n\t\tapp_label = 'vt_manager'\n#\t\tabstract = True\n\n\n\t__childClasses = (\n\t\t'XenServer',\n\t )\n\n\n\t''' General attributes '''\n\tavailable = models.BooleanField(default=1, verbose_name = \"Available\", editable = False)\n\tenabled = models.BooleanField(default=1, verbose_name = \"Enabled\", editable = True)\n\tname = models.CharField(max_length = 511, default=\"\", verbose_name = \"Name\", validators=[validators.resourceNameValidator])\n\tuuid = models.CharField(max_length = 1024, default = uuid.uuid4(), editable = False)\n\n\t''' OS '''\n\toperatingSystemType = models.CharField(choices = OSTypeClass.OS_TYPE_CHOICES,max_length = 512, verbose_name = \"OS Type\",validators=[OSTypeClass.validateOSType])\n\toperatingSystemDistribution = models.CharField(choices = OSDistClass.OS_DIST_CHOICES,max_length = 512, verbose_name = \"OS Distribution\",validators=[OSDistClass.validateOSDist])\n\toperatingSystemVersion = models.CharField(choices = OSVersionClass.OS_VERSION_CHOICES,max_length = 512, verbose_name = \"OS Version\",validators=[OSVersionClass.validateOSVersion])\n\t\n\t''' Virtualization technology '''\n\tvirtTech = models.CharField(choices = VirtTechClass.VIRT_TECH_CHOICES, max_length = 512, verbose_name = \"Virtualization Technology\",validators=[VirtTechClass.validateVirtTech])\n\t\n\t''' Hardware '''\n\tnumberOfCPUs = models.IntegerField(blank = True, null=True, verbose_name = \"Number of CPUs\")\n\tCPUFrequency = models.IntegerField(blank = True, null=True, verbose_name = \"CPU frequency (GB)\")\n\tmemory = models.IntegerField(blank = True, null=True, verbose_name = \"Memory (GB)\")\n\tdiscSpaceGB = models.FloatField(blank = True, null=True, verbose_name = \"Size (GB)\")\n\n\t''' Agent fields'''\n\tagentURL = models.URLField(verify_exists = False, verbose_name = \"URL of the Server Agent\", validators=[validateAgentURLwrapper], help_text=\"URL of the agent daemon running in the server. It should be https://DOMAIN_OR_IP:9229\")\n\tagentPassword = models.CharField(blank=True,null=True,max_length=128, verbose_name=\"Agent password\", validators=[validators.resourceNameValidator])\n\n\turl = models.URLField(verify_exists = False, verbose_name = \"URL of the Server\", editable = False, blank = True)\n\t\n\t''' Network interfaces'''\n\tnetworkInterfaces = models.ManyToManyField('NetworkInterface', blank = True, null = False, editable = False)\n\t\n\t''' Other networking parameters '''\n\tsubscribedMacRanges = models.ManyToManyField('MacRange', blank = True, null = True, editable = False)\n\tsubscribedIp4Ranges = models.ManyToManyField('Ip4Range', blank = True, null = True, editable = False)\n\t\n\t''' Mutex over the instance '''\n\t#Mutex\n\tmutex = None \n\n\t'''Defines soft or hard state of the Server'''\t\n\tdoSave = True\n\n\n\t#Stats of memory cpu and disk\n\t#TODO: Add here ManyToMany relation to statistics objects\n\n\n\t##Private methods\n\n\t\n\t\n\t\n \n\t##Public methods\n\n\t''' Getters and setters '''\n\n\t\t\n\n\t#Destroy\n\t''' Ranges '''\n\n\t\t\n\n\n\n\t\n\t\n\t\n\n\t\n\t''' VM interfaces and VM creation methods '''\n\t\n\n\t\t\t\n\t''' Server interfaces '''\n\t#Network mgmt bridges\n\t\n\t#Network data bridges\n\n\n\n", "metadata": "root.VTServer", "header": "['module', '___EOS___']", "index": 18 }, { "content": "\tdef getChildObject(self):\n\t\tfor childClass in self.__childClasses:\n\t \t\ttry:\n\t\t\t\treturn self.__getattribute__(childClass.lower())\n\t \t\texcept Exception:\n\t \t\t#except eval(childClass).DoesNotExist:\n\t\t\t\tpass\n\t\t\t\t#return self", "metadata": "root.VTServer.getChildObject", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 79 }, { "content": "\tdef __tupleContainsKey(tu,key):\n\t\tfor val in tu:\n\t\t\tif val[0] == key:\n\t\t\t\treturn True\n\t\treturn False", "metadata": "root.VTServer.__tupleContainsKey", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 88 }, { "content": "\tdef autoSave(self):\n\t\tif self.doSave:\n\t\t\tself.save()", "metadata": "root.VTServer.autoSave", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 94 }, { "content": "\tdef getLockIdentifier(self):\n\t\t#Uniquely identifies object by a key\n\t\treturn inspect.currentframe().f_code.co_filename+str(self)+str(self.id)", "metadata": "root.VTServer.getLockIdentifier", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 98 }, { "content": "\tdef setName(self, name):\n\t\tself.name = name\n\t\tself.autoSave()", "metadata": "root.VTServer.setName", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 105 }, { "content": "\tdef getName(self):\n\t\treturn self.name", "metadata": "root.VTServer.getName", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 108 }, { "content": "\tdef setUUID(self, uuid):\n\t\t#XXX\t\n\t\tself.uuid = uuid\n\t\tself.autoSave()", "metadata": "root.VTServer.setUUID", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 110 }, { "content": "\tdef getUUID(self):\n\t\treturn self.uuid", "metadata": "root.VTServer.getUUID", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 114 }, { "content": "\tdef setNumberOfCPUs(self, cpus):\n\t\tself.numberOfCPUs = cpus\n\t\tself.autoSave()", "metadata": "root.VTServer.setNumberOfCPUs", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 116 }, { "content": "\tdef getNumberOfCPUs(self):\n\t\treturn self.numberOfCPUs", "metadata": "root.VTServer.getNumberOfCPUs", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 119 }, { "content": "\tdef setMemory(self, memory):\n\t\tself.memory = memory\n\t\tself.autoSave()", "metadata": "root.VTServer.setMemory", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 121 }, { "content": "\tdef getCPUFrequency(self):\n\t\treturn self.CPUFrequency", "metadata": "root.VTServer.getCPUFrequency", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 124 }, { "content": "\tdef setCPUFrequency(self, frequency):\n\t\tself.CPUFrequency = frequency\n\t\tself.autoSave()", "metadata": "root.VTServer.setCPUFrequency", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 126 }, { "content": "\tdef getMemory(self):\n\t\treturn self.memory", "metadata": "root.VTServer.getMemory", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 129 }, { "content": "\tdef setDiscSpaceGB(self, space):\n\t\tself.discSpaceGB = space\n\t\tself.autoSave()", "metadata": "root.VTServer.setDiscSpaceGB", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 131 }, { "content": "\tdef getDiscSpaceGB(self):\n\t\treturn self.discSpaceGB", "metadata": "root.VTServer.getDiscSpaceGB", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 134 }, { "content": "\t@staticmethod\n\tdef validateAgentURL(url):\n\t\t\t#Hard lookup; make sure that Agent is running and at the same time URL is correct:\n\t\t\tif url == \"\":\n\t\t\t\treturn\n\t\t\ttry:\n\t\t\t\tXmlRpcClient.callRPCMethod(url,\"ping\",\"testing\")\n\t\t\texcept Exception as e:\n\t\t\t\traise ValidationError(\"Cannot communicate with Agent. Nested exception is: \" + str(e))", "metadata": "root.VTServer.validateAgentURL", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 137 }, { "content": "\tdef setAgentURL(self, url):\n\t\twith MutexStore.getObjectLock(self.getLockIdentifier()):\n\t\t\tVTServer.validateAgentURL(url)\n\t\t\tself.agentURL = url\n\t\t\tself.autoSave()", "metadata": "root.VTServer.setAgentURL", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 147 }, { "content": "\tdef getAgentURL(self):\n\t\treturn self.agentURL", "metadata": "root.VTServer.getAgentURL", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 152 }, { "content": "\tdef setURL(self, url):\n\t\tself.url = url\n\t\tself.autoSave()", "metadata": "root.VTServer.setURL", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 154 }, { "content": "\tdef getURL(self):\n\t\treturn self.url", "metadata": "root.VTServer.getURL", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 157 }, { "content": "\tdef setVirtTech(self, virtTech):\n\t\tVirtTechClass.validateVirtTech(virtTech)\n\t\tself.virtTech = virtTech\n\t\tself.autoSave()", "metadata": "root.VTServer.setVirtTech", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 159 }, { "content": "\tdef getVirtTech(self):\n\t\treturn self.virtTech", "metadata": "root.VTServer.getVirtTech", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 163 }, { "content": "\tdef setOSType(self, osType):\n\t\tOSTypeClass.validateOSType(osType)\t\n\t\tself.operatingSystemType = osType\n\t\tself.autoSave()", "metadata": "root.VTServer.setOSType", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 165 }, { "content": "\tdef getOSType(self):\n\t\treturn self.operatingSystemType", "metadata": "root.VTServer.getOSType", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 169 }, { "content": "\tdef setOSVersion(self, version):\n\t\tOSVersionClass.validateOSVersion(version)\n\t\tself.operatingSystemVersion = version\n\t\tself.autoSave()", "metadata": "root.VTServer.setOSVersion", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 171 }, { "content": "\tdef getOSVersion(self):\n\t\treturn self.operatingSystemVersion", "metadata": "root.VTServer.getOSVersion", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 175 }, { "content": "\tdef setOSDistribution(self, dist):\n\t\tOSDistClass.validateOSDist(dist)\n\t\tself.operatingSystemDistribution = dist\n\t\tself.autoSave()", "metadata": "root.VTServer.setOSDistribution", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 177 }, { "content": "\tdef getOSDistribution(self):\n\t\treturn self.operatingSystemDistribution", "metadata": "root.VTServer.getOSDistribution", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 181 }, { "content": "\tdef setAvailable(self,av):\n\t\tself.available = av\n\t\tself.autoSave()", "metadata": "root.VTServer.setAvailable", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 183 }, { "content": "\tdef getAvailable(self):\n\t\treturn self.available", "metadata": "root.VTServer.getAvailable", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 186 }, { "content": " \tdef setEnabled(self,en):\n\t\tself.enabled = en\n\t\tself.autoSave()", "metadata": "root.VTServer.setEnabled", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 188 }, { "content": "\tdef getEnabled(self):\n\t\treturn self.enabled", "metadata": "root.VTServer.getEnabled", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 191 }, { "content": "\tdef getAgentPassword(self):\n\t\treturn self.agentPassword", "metadata": "root.VTServer.getAgentPassword", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 193 }, { "content": "\tdef setAgentPassword(self, password):\n\t\tself.agentPassword = password\n\t\tself.autoSave()", "metadata": "root.VTServer.setAgentPassword", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 195 }, { "content": "\tdef destroy(self):\n\t\twith MutexStore.getObjectLock(self.getLockIdentifier()):\n\n\t\t\tif self.vms.all().count()>0:\n\t\t\t\traise Exception(\"Cannot destroy a server which hosts VMs. Delete VMs first\")\n\t\t\t\n\t\t\t#Delete associated interfaces\n\t\t\tfor interface in self.networkInterfaces.all():\n\t\t\t\tinterface.destroy()\n\n\t\t\t#Delete instance\n\t\t\tself.delete()", "metadata": "root.VTServer.destroy", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 200 }, { "content": "\tdef subscribeToMacRange(self,newRange):\n\t\tif not isinstance(newRange,MacRange):\n\t\t\traise Exception(\"Invalid instance type on subscribeToMacRange; must be MacRange\")\n\t\tif newRange in self.subscribedMacRanges.all():\n\t\t\traise Exception(\"Server is already subscribed to this range\")\n\t\t\t\n\t\tself.subscribedMacRanges.add(newRange)\n\t\tself.autoSave()", "metadata": "root.VTServer.subscribeToMacRange", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 213 }, { "content": "\tdef unsubscribeToMacRange(self,oRange):\n\t\tif not isinstance(oRange,MacRange):\n\t\t\traise Exception(\"Invalid instance type on unsubscribeToMacRange; must be MacRange\")\n\t\n\t\tself.subscribedMacRanges.remove(oRange)\n\t\tself.autoSave()", "metadata": "root.VTServer.unsubscribeToMacRange", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 222 }, { "content": "\tdef getSubscribedMacRangesNoGlobal(self):\n\t\treturn self.subscribedMacRanges.all()", "metadata": "root.VTServer.getSubscribedMacRangesNoGlobal", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 229 }, { "content": "\tdef getSubscribedMacRanges(self):\n\t\tif self.subscribedMacRanges.all().count() > 0:\n\t\t\treturn self.subscribedMacRanges.all()\n\t\telse:\n\t\t\t#Return global (all) ranges\n\t\t\treturn MacRange.objects.filter(isGlobal=True)", "metadata": "root.VTServer.getSubscribedMacRanges", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 232 }, { "content": "\tdef subscribeToIp4Range(self,newRange):\n\t\tif not isinstance(newRange,Ip4Range):\n\t\t\traise Exception(\"Invalid instance type on subscribeToIpRange; must be Ip4Range\")\n\t\tif newRange in self.subscribedIp4Ranges.all():\n\t\t\traise Exception(\"Server is already subscribed to this range\")\n\t\t\t\n\t\tself.subscribedIp4Ranges.add(newRange)\n\t\tself.autoSave()", "metadata": "root.VTServer.subscribeToIp4Range", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 239 }, { "content": "\tdef unsubscribeToIp4Range(self,oRange):\n\t\tif not isinstance(oRange,Ip4Range):\n\t\t\traise Exception(\"Invalid instance type on unsubscribeToIpRange; must be Ip4Range\")\n\t\n\t\tself.subscribedIp4Ranges.remove(oRange)\n\t\tself.autoSave()", "metadata": "root.VTServer.unsubscribeToIp4Range", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 248 }, { "content": "\tdef getSubscribedIp4RangesNoGlobal(self):\n\t\treturn self.subscribedIp4Ranges.all()", "metadata": "root.VTServer.getSubscribedIp4RangesNoGlobal", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 255 }, { "content": "\tdef getSubscribedIp4Ranges(self):\n\t\tif self.subscribedIp4Ranges.all().count() > 0:\n\t\t\treturn self.subscribedIp4Ranges.all()\n\t\telse:\n\t\t\t#Return global (all) ranges\n\t\t\treturn Ip4Range.objects.filter(isGlobal=True)", "metadata": "root.VTServer.getSubscribedIp4Ranges", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 258 }, { "content": "\tdef __allocateMacFromSubscribedRanges(self):\n\t\tmacObj = None\n\t\t#Allocate Mac\n\t\tfor macRange in self.getSubscribedMacRanges():\n\t\t\ttry:\n\t\t\t\tmacObj = macRange.allocateMac() \n\t\t\texcept Exception as e:\n\t\t\t\tcontinue\n\t\t\tbreak\n\n\t\tif macObj == None:\n\t\t\traise Exception(\"Could not allocate Mac address for the VM over subscribed ranges\")\n\t\n\t\treturn macObj", "metadata": "root.VTServer.__allocateMacFromSubscribedRanges", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 265 }, { "content": "\tdef __allocateIpFromSubscribedRanges(self):\n\t\tipObj = None \n\t\t\n\t\t#Allocate Ip\n\t\tfor ipRange in self.getSubscribedIp4Ranges():\n\t\t\ttry:\n\t\t\t\tipObj = ipRange.allocateIp() \n\t\t\texcept Exception as e:\n\t\t\t\tcontinue\n\t\t\tbreak\n\t\tif ipObj == None:\n\t\t\traise Exception(\"Could not allocate Ip4 address for the VM over subscribed ranges\")\n\t\n\t\treturn ipObj", "metadata": "root.VTServer.__allocateIpFromSubscribedRanges", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 280 }, { "content": "\tdef __createEnslavedDataVMNetworkInterface(self,serverInterface):\n\t\t#Obtain \n\t\tmacObj = self.__allocateMacFromSubscribedRanges() \n\t\t\n\t\tinterface = NetworkInterface.createVMDataInterface(serverInterface.getName()+\"-slave\",macObj) \n\t\t\n\t\t#Enslave it\t\n\t\tserverInterface.attachInterfaceToBridge(interface)\t\n\t\treturn interface", "metadata": "root.VTServer.__createEnslavedDataVMNetworkInterface", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 296 }, { "content": "\tdef __createEnslavedMgmtVMNetworkInterface(self,serverInterface):\n\t\t#Obtain \n\t\tmacObj = self.__allocateMacFromSubscribedRanges() \n\t\tipObj = self.__allocateIpFromSubscribedRanges()\n\t\t\n\t\tinterface = NetworkInterface.createVMMgmtInterface(serverInterface.getName()+\"-slave\",macObj,ipObj) \n\t\t\n\t\t#Enslave it\t\n\t\tserverInterface.attachInterfaceToBridge(interface)\t\n\t\treturn interface", "metadata": "root.VTServer.__createEnslavedMgmtVMNetworkInterface", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 306 }, { "content": "\tdef createEnslavedVMInterfaces(self):\n\t\tvmInterfaces = set()\t\n\t\ttry:\n\t\t\t#Allocate one interface for each Server's interface \n\t\t\tfor serverInterface in self.networkInterfaces.all():\n\t\t\t\tif serverInterface.isMgmt:\n\t\t\t\t\tvmInterfaces.add(self.__createEnslavedMgmtVMNetworkInterface(serverInterface))\n\t\t\t\telse: \t\t\n\t\t\t\t\tvmInterfaces.add(self.__createEnslavedDataVMNetworkInterface(serverInterface))\n\t\texcept Exception as e:\n\t\t\tfor interface in vmInterfaces:\n\t\t\t\tinterface.destroy()\n\t\t\traise e\n\t\treturn vmInterfaces ", "metadata": "root.VTServer.createEnslavedVMInterfaces", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 317 }, { "content": "\tdef setMgmtBridge(self,name,macStr):\n\t\twith MutexStore.getObjectLock(self.getLockIdentifier()):\n\t\t\tnInter = self.networkInterfaces.filter(isMgmt=True,isBridge=True)\n\t\t\tif nInter.count() == 1:\n\t\t\t\tmgmt = nInter.get()\n\t\t\t\tmgmt.setName(name)\n\t\t\t\tmgmt.setMacStr(macStr)\n\n\t\t\telif nInter.count() == 0:\n\t\t\t\tmgmt = NetworkInterface.createServerMgmtBridge(name,macStr)\n\t\t\t\tself.networkInterfaces.add(mgmt)\n\t\t\telse:\n\t\t\t\traise Exception(\"Unexpected length of managment NetworkInterface query\")\n\t\t\tself.autoSave()", "metadata": "root.VTServer.setMgmtBridge", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 334 }, { "content": "\tdef addDataBridge(self,name,macStr,switchId,port):\n\t\twith MutexStore.getObjectLock(self.getLockIdentifier()):\t\n\t\t\tif self.networkInterfaces.filter(name=name, isBridge=True).count()> 0:\n\t\t\t\traise Exception(\"Another data bridge with the same name already exists in this Server\") \n\t\t\t\t\n\t\t\tnetInt = NetworkInterface.createServerDataBridge(name,macStr,switchId,port)\n\t\t\tself.networkInterfaces.add(netInt)\n\t\t\tself.autoSave()", "metadata": "root.VTServer.addDataBridge", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 350 }, { "content": "\tdef updateDataBridge(self,interface):\n\t\twith MutexStore.getObjectLock(self.getLockIdentifier()):\n\t\t\tif self.networkInterfaces.filter(id = interface.id).count()!= 1:\n\t\t\t\traise Exception(\"Can not update bridge interface because it does not exist or id is duplicated\") \n\t\t\t\t\n\t\t\tNetworkInterface.updateServerDataBridge(interface.id,interface.getName(),interface.getMacStr(),interface.getSwitchID(),interface.getPort())", "metadata": "root.VTServer.updateDataBridge", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 359 }, { "content": "\tdef deleteDataBridge(self,netInt):\n\t\twith MutexStore.getObjectLock(self.getLockIdentifier()):\n\t\t\tif not isinstance(netInt,NetworkInterface):\n\t\t\t\traise Exception(\"Can only delete Data Bridge that are instances of NetworkInterace\")\n\t\t\t\n\t\t\t#TODO: delete interfaces from VMs, for the moment forbid\n\t\t\tif netInt.getNumberOfConnections() > 0:\n\t\t\t\traise Exception(\"Cannot delete a Data bridge from a server if this bridge has VM's interfaces ensalved.\")\t\n\n\t\t\tself.networkInterfaces.remove(netInt)\n\t\t\tnetInt.destroy()\n\t\t\tself.autoSave()", "metadata": "root.VTServer.deleteDataBridge", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 366 }, { "content": "\tdef getNetworkInterfaces(self):\n\t\treturn self.networkInterfaces.all().order_by('-isMgmt','id')", "metadata": "root.VTServer.getNetworkInterfaces", "header": "['class', 'VTServer', '(', 'models', '.', 'Model', ')', ':', '___EOS___']", "index": 380 } ]
[ { "span": "from django.contrib import auth", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 31 }, { "span": "from threading import Lock ", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 26 }, { "span": "import re", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 9 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "django_", "._", "db_", "import_", "models_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "contrib_", "import_", "auth_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "threading_", "import_", "Lock_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "uuid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "inspect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "django_", "._", "core_", "._", "exceptions_", "import_", "Validat", "ion", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vt", "\\u", "manager_", "._", "models_", "._", "Network", "Interface_", "import_", "Network", "Interface_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vt", "\\u", "manager_", "._", "communication", "_", "._", "Xm", "l", "Rp", "c", "Client_", "import_", "Xm", "l", "Rp", "c", "Client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vt", "\\u", "manager_", "._", "models_", "._", "utils_", "._", "Choices_", "import_", "Virt", "Te", "ch", "Class_", ",_", "OS", "Dist", "Class_", ",_", "OS", "Version", "Class_", ",_", "OST", "ype", "Class_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vt", "\\u", "manager_", "._", "utils_", "._", "Mute", "x", "Store_", "import_", "Mute", "x", "Store_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vt", "\\u", "manager_", "._", "models_", "._", "Mac", "Range_", "import_", "Mac", "Range_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vt", "\\u", "manager_", "._", "models_", "._", "Ip", "4", "Range_", "import_", "Ip", "4", "Range_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "vt", "\\u", "manager_", "._", "common_", "._", "utils_", "import_", "validators_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "validat", "e", "Agent", "URL", "wrapper_", "(_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "VT", "Server_", "._", "validat", "e", "Agent", "URL_", "(_", "url_", ")_", "\\u\\u\\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_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "_", "\"\"\"", "Virt", "uali", "zatio", "n", " ", "Server", " ", "class", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "\"\"\"", "Meta", " ", "Class", " ", "for", " ", "your", " ", "model", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app", "\\u", "label_", "=_", "'", "vt", "\\u", "manage", "r", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "\t", "\t", "abstract", " ", "=", " ", "True_", "\\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", "child", "Classes_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Xen", "Server", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", " ", "General", " ", "attribute", "s", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "available_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "1_", ",_", "verbo", "se", "\\u", "name_", "=_", "\"", "Avail", "able", "\"_", ",_", "editable_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "enabled_", "=_", "models_", "._", "Boo", "lean", "Field_", "(_", "default_", "=_", "1_", ",_", "verbo", "se", "\\u", "name_", "=_", "\"", "Enable", "d", "\"_", ",_", "editable_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "511", "_", ",_", "default_", "=_", "\"\"_", ",_", "verbo", "se", "\\u", "name_", "=_", "\"", "Name", "\"_", ",_", "validators_", "=_", "[_", "validators_", "._", "resource", "Name", "Validator_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "uuid_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "1024_", ",_", "default_", "=_", "uuid_", "._", "uuid4_", "(_", ")_", ",_", "editable_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", " ", "OS", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "operati", "ng", "System", "Type_", "=_", "models_", "._", "Char", "Field_", "(_", "choices_", "=_", "OST", "ype", "Class_", "._", "OS", "\\u", "TYPE", "\\u", "CHOICES_", ",_", "max", "\\u", "length_", "=_", "512_", ",_", "verbo", "se", "\\u", "name_", "=_", "\"", "OS", " ", "Type", "\"_", ",_", "validators_", "=_", "[_", "OST", "ype", "Class_", "._", "validat", "e", "OST", "ype_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "operati", "ng", "System", "Distribution_", "=_", "models_", "._", "Char", "Field_", "(_", "choices_", "=_", "OS", "Dist", "Class_", "._", "OS", "\\u", "DIST", "\\u", "CHOICES_", ",_", "max", "\\u", "length_", "=_", "512_", ",_", "verbo", "se", "\\u", "name_", "=_", "\"", "OS", " ", "Distribut", "ion", "\"_", ",_", "validators_", "=_", "[_", "OS", "Dist", "Class_", "._", "validat", "e", "OS", "Dist_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "operati", "ng", "System", "Version_", "=_", "models_", "._", "Char", "Field_", "(_", "choices_", "=_", "OS", "Version", "Class_", "._", "OS", "\\u", "VERSI", "ON", "\\u", "CHOICES_", ",_", "max", "\\u", "length_", "=_", "512_", ",_", "verbo", "se", "\\u", "name_", "=_", "\"", "OS", " ", "Version", "\"_", ",_", "validators_", "=_", "[_", "OS", "Version", "Class_", "._", "validat", "e", "OS", "Version_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", " ", "Virt", "uali", "zatio", "n", " ", "technology", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "virt", "Te", "ch_", "=_", "models_", "._", "Char", "Field_", "(_", "choices_", "=_", "Virt", "Te", "ch", "Class_", "._", "VIR", "T", "\\u", "TECH", "\\u", "CHOICES_", ",_", "max", "\\u", "length_", "=_", "512_", ",_", "verbo", "se", "\\u", "name_", "=_", "\"", "Virt", "uali", "zatio", "n", " ", "Techno", "log", "y", "\"_", ",_", "validators_", "=_", "[_", "Virt", "Te", "ch", "Class_", "._", "validat", "e", "Virt", "Te", "ch_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", " ", "Hard", "ware", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "number", "Of", "CPU", "s_", "=_", "models_", "._", "Integer", "Field_", "(_", "blank_", "=_", "True_", ",_", "null_", "=_", "True_", ",_", "verbo", "se", "\\u", "name_", "=_", "\"", "Number", " ", "of", " ", "CPU", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "CPU", "Frequency_", "=_", "models_", "._", "Integer", "Field_", "(_", "blank_", "=_", "True_", ",_", "null_", "=_", "True_", ",_", "verbo", "se", "\\u", "name_", "=_", "\"", "CPU", " ", "freque", "nc", "y", " ", "(", "GB", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "memory_", "=_", "models_", "._", "Integer", "Field_", "(_", "blank_", "=_", "True_", ",_", "null_", "=_", "True_", ",_", "verbo", "se", "\\u", "name_", "=_", "\"", "Memo", "ry", " ", "(", "GB", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "disc", "Spac", "e", "GB", "_", "=_", "models_", "._", "Float", "Field_", "(_", "blank_", "=_", "True_", ",_", "null_", "=_", "True_", ",_", "verbo", "se", "\\u", "name_", "=_", "\"", "Size", " ", "(", "GB", ")\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", " ", "Agent", " ", "fields", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "agent", "URL_", "=_", "models_", "._", "URL", "Field_", "(_", "verify", "\\u", "exists_", "=_", "False_", ",_", "verbo", "se", "\\u", "name_", "=_", "\"", "URL", " ", "of", " ", "the", " ", "Server", " ", "Agent", "\"_", ",_", "validators_", "=_", "[_", "validat", "e", "Agent", "URL", "wrapper_", "]_", ",_", "help", "\\u", "text_", "=_", "\"", "URL", " ", "of", " ", "the", " ", "agent", " ", "daemon", " ", "runn", "ing", " ", "in", " ", "the", " ", "server", ".", " ", "It", " ", "shou", "ld", " ", "be", " ", "https", "://", "DOM", "AIN", "\\u", "OR", "\\u", "IP", ":", "922", "9", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "agent", "Password_", "=_", "models_", "._", "Char", "Field_", "(_", "blank_", "=_", "True_", ",_", "null_", "=_", "True_", ",_", "max", "\\u", "length_", "=_", "128_", ",_", "verbo", "se", "\\u", "name_", "=_", "\"", "Agent", " ", "password", "\"_", ",_", "validators_", "=_", "[_", "validators_", "._", "resource", "Name", "Validator_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "models_", "._", "URL", "Field_", "(_", "verify", "\\u", "exists_", "=_", "False_", ",_", "verbo", "se", "\\u", "name_", "=_", "\"", "URL", " ", "of", " ", "the", " ", "Server", "\"_", ",_", "editable_", "=_", "False_", ",_", "blank_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", " ", "Network", " ", "interface", "s", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "network", "Interface", "s_", "=_", "models_", "._", "Many", "To", "Many", "Field_", "(_", "'", "Network", "Interface", "'_", ",_", "blank_", "=_", "True_", ",_", "null_", "=_", "False_", ",_", "editable_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", " ", "Ot", "her", " ", "networking", " ", "parameter", "s", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subscribed", "Mac", "Ranges_", "=_", "models_", "._", "Many", "To", "Many", "Field_", "(_", "'", "Mac", "Range", "'_", ",_", "blank_", "=_", "True_", ",_", "null_", "=_", "True_", ",_", "editable_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "subscribed", "Ip", "4", "Ranges_", "=_", "models_", "._", "Many", "To", "Many", "Field_", "(_", "'", "Ip", "4", "Range", "'_", ",_", "blank_", "=_", "True_", ",_", "null_", "=_", "True_", ",_", "editable_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", " ", "Mute", "x", " ", "over", " ", "the", " ", "instance", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Mute", "x_", "\\u\\u\\uNL\\u\\u\\u_", "mutex_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "'''", "Define", "s", " ", "soft", " ", "or", " ", "hard", " ", "state", " ", "of", " ", "the", " ", "Server", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "do", "Save_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Stat", "s", " ", "of", " ", "memory", " ", "cpu", " ", "and", " ", "disk_", "\\u\\u\\uNL\\u\\u\\u_", "#", "TOD", "O", ":", " ", "Add", " ", "here", " ", "Many", "To", "Many", " ", "relation", " ", "to", " ", "statistic", "s", " ", "objects_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", "Priva", "te", " ", "methods_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "##", "Public", " ", "methods_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "'''", " ", "Getter", "s", " ", "and", " ", "sette", "rs", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Destroy_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "'''", " ", "Range", "s", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "'''", " ", "VM", " ", "interface", "s", " ", "and", " ", "VM", " ", "creati", "on", " ", "method", "s", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "'''", " ", "Server", " ", "interface", "s", " ", "'''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Network", " ", "mg", "mt", " ", "bridge", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Network", " ", "data", " ", "bridge", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "Chil", "d", "Object_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "for_", "child", "Class_", "in_", "self_", "._", "\\u\\u", "child", "Classes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", " ", " \t\t", "_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "return_", "self_", "._", "\\u\\u", "getattribute\\u\\u_", "(_", "child", "Class_", "._", "lower_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "except", " ", "eval", "(", "child", "Class", ").", "Do", "es", "Not", "Exist", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "return", " ", "self_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "tuple", "Contain", "s", "Key_", "(_", "tu_", ",_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "for_", "val_", "in_", "tu_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "if_", "val_", "[_", "0_", "]_", "==_", "key_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "auto", "Save_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "if_", "self_", "._", "do", "Save_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "self_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Lock", "Identifier_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Unique", "ly", " ", "identifi", "es", " ", "object", " ", "by", " ", "a", " ", "key_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "inspect_", "._", "currentframe_", "(_", ")_", "._", "f", "\\u", "code_", "._", "co", "\\u", "filename_", "+_", "str_", "(_", "self_", ")_", "+_", "str_", "(_", "self_", "._", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "set", "Name_", "(_", "self_", ",_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "UUID_", "(_", "self_", ",_", "uuid_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "XX", "X", "\t_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "self_", "._", "uuid_", "=_", "uuid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "UUID_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "uuid_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Number", "Of", "CPU", "s_", "(_", "self_", ",_", "cpus_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "self_", "._", "number", "Of", "CPU", "s_", "=_", "cpus_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Number", "Of", "CPU", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "number", "Of", "CPU", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Memory_", "(_", "self_", ",_", "memory_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "self_", "._", "memory_", "=_", "memory_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "CPU", "Frequency_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "CPU", "Frequency_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "CPU", "Frequency_", "(_", "self_", ",_", "frequency_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "self_", "._", "CPU", "Frequency_", "=_", "frequency_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Memory_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "memory_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Disc", "Spac", "e", "GB", "_", "(_", "self_", ",_", "space_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "self_", "._", "disc", "Spac", "e", "GB", "_", "=_", "space_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Disc", "Spac", "e", "GB", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "disc", "Spac", "e", "GB", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "staticmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "validat", "e", "Agent", "URL_", "(_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Hard", " ", "look", "up", ";", " ", "make", " ", "sure", " ", "tha", "t", " ", "Agent", " ", "is", " ", "runn", "ing", " ", "and", " ", "at", " ", "the", " ", "same", " ", "time", " ", "URL", " ", "is", " ", "correct", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "if_", "url_", "==_", "\"\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "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\t", "\t\t\t_", "Xm", "l", "Rp", "c", "Client_", "._", "call", "RP", "CM", "ethod", "_", "(_", "url_", ",_", "\"", "ping", "\"_", ",_", "\"", "testi", "ng", "\"_", ")_", "\\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\t", "\t\t\t_", "raise_", "Validat", "ion", "Error_", "(_", "\"", "Cann", "ot", " ", "communi", "cate", " ", "with", " ", "Agent", ".", " ", "Nest", "ed", " ", "exception", " ", "is", ":", " ", "\"_", "+_", "str_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Agent", "URL_", "(_", "self_", ",_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "with_", "Mute", "x", "Store_", "._", "get", "Object", "Lock_", "(_", "self_", "._", "get", "Lock", "Identifier_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "VT", "Server_", "._", "validat", "e", "Agent", "URL_", "(_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "agent", "URL_", "=_", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\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_", "get", "Agent", "URL_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "agent", "URL_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "URL_", "(_", "self_", ",_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "self_", "._", "url_", "=_", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "URL_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Virt", "Te", "ch_", "(_", "self_", ",_", "virt", "Te", "ch_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "Virt", "Te", "ch", "Class_", "._", "validat", "e", "Virt", "Te", "ch_", "(_", "virt", "Te", "ch_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "virt", "Te", "ch_", "=_", "virt", "Te", "ch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Virt", "Te", "ch_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "virt", "Te", "ch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "OST", "ype_", "(_", "self_", ",_", "os", "Type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "OST", "ype", "Class_", "._", "validat", "e", "OST", "ype_", "(_", "os", "Type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "operati", "ng", "System", "Type_", "=_", "os", "Type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "OST", "ype_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "operati", "ng", "System", "Type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "OS", "Version_", "(_", "self_", ",_", "version_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "OS", "Version", "Class_", "._", "validat", "e", "OS", "Version_", "(_", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "operati", "ng", "System", "Version_", "=_", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "OS", "Version_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "operati", "ng", "System", "Version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "OS", "Distribution_", "(_", "self_", ",_", "dist_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "OS", "Dist", "Class_", "._", "validat", "e", "OS", "Dist_", "(_", "dist_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "operati", "ng", "System", "Distribution_", "=_", "dist_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "OS", "Distribution_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "operati", "ng", "System", "Distribution_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Available_", "(_", "self_", ",_", "av_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "self_", "._", "available_", "=_", "av_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Available_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "available_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Enabled_", "(_", "self_", ",_", "en_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "self_", "._", "enabled_", "=_", "en_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Enabled_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "enabled_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Agent", "Password_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "agent", "Password_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set", "Agent", "Password_", "(_", "self_", ",_", "password_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "self_", "._", "agent", "Password_", "=_", "password_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "destroy_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "with_", "Mute", "x", "Store_", "._", "get", "Object", "Lock_", "(_", "self_", "._", "get", "Lock", "Identifier_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "if_", "self_", "._", "vms_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "raise_", "Exception_", "(_", "\"", "Cann", "ot", " ", "destroy", " ", "a", " ", "server", " ", "whi", "ch", " ", "host", "s", " ", "VM", "s", ".", " ", "Delete", " ", "VM", "s", " ", "first", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Delete", " ", "associate", "d", " ", "interfaces_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "interface_", "in_", "self_", "._", "network", "Interface", "s_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "interface_", "._", "destroy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Delete", " ", "instance_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "subscribe", "To", "Mac", "Range_", "(_", "self_", ",_", "new", "Range_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "if_", "not_", "isinstance_", "(_", "new", "Range_", ",_", "Mac", "Range_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "raise_", "Exception_", "(_", "\"", "Inva", "lid", " ", "instance", " ", "type", " ", "on", " ", "subscribe", "To", "Mac", "Range", ";", " ", "must", " ", "be", " ", "Mac", "Range", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "new", "Range_", "in_", "self_", "._", "subscribed", "Mac", "Ranges_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "raise_", "Exception_", "(_", "\"", "Server", " ", "is", " ", "alr", "ead", "y", " ", "subscribed", " ", "to", " ", "this", " ", "range", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "subscribed", "Mac", "Ranges_", "._", "add_", "(_", "new", "Range_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "unsubscribe", "To", "Mac", "Range_", "(_", "self_", ",_", "o", "Range_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "if_", "not_", "isinstance_", "(_", "o", "Range_", ",_", "Mac", "Range_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "raise_", "Exception_", "(_", "\"", "Inva", "lid", " ", "instance", " ", "type", " ", "on", " ", "unsubscribe", "To", "Mac", "Range", ";", " ", "must", " ", "be", " ", "Mac", "Range", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "subscribed", "Mac", "Ranges_", "._", "remove_", "(_", "o", "Range_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Subscrib", "ed", "Mac", "Range", "s", "No", "Global_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "subscribed", "Mac", "Ranges_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Subscrib", "ed", "Mac", "Ranges_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "if_", "self_", "._", "subscribed", "Mac", "Ranges_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "return_", "self_", "._", "subscribed", "Mac", "Ranges_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Return", " ", "global", " ", "(", "all", ")", " ", "ranges_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "return_", "Mac", "Range_", "._", "objects_", "._", "filter_", "(_", "is", "Global_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "subscribe", "To", "Ip", "4", "Range_", "(_", "self_", ",_", "new", "Range_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "if_", "not_", "isinstance_", "(_", "new", "Range_", ",_", "Ip", "4", "Range_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "raise_", "Exception_", "(_", "\"", "Inva", "lid", " ", "instance", " ", "type", " ", "on", " ", "subscribe", "To", "Ip", "Range", ";", " ", "must", " ", "be", " ", "Ip", "4", "Range", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "new", "Range_", "in_", "self_", "._", "subscribed", "Ip", "4", "Ranges_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "raise_", "Exception_", "(_", "\"", "Server", " ", "is", " ", "alr", "ead", "y", " ", "subscribed", " ", "to", " ", "this", " ", "range", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "subscribed", "Ip", "4", "Ranges_", "._", "add_", "(_", "new", "Range_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "unsubscribe", "To", "Ip", "4", "Range_", "(_", "self_", ",_", "o", "Range_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "if_", "not_", "isinstance_", "(_", "o", "Range_", ",_", "Ip", "4", "Range_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "raise_", "Exception_", "(_", "\"", "Inva", "lid", " ", "instance", " ", "type", " ", "on", " ", "unsubscribe", "To", "Ip", "Range", ";", " ", "must", " ", "be", " ", "Ip", "4", "Range", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "subscribed", "Ip", "4", "Ranges_", "._", "remove_", "(_", "o", "Range_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Subscrib", "ed", "Ip", "4", "Range", "s", "No", "Global_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "subscribed", "Ip", "4", "Ranges_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Subscrib", "ed", "Ip", "4", "Ranges_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "if_", "self_", "._", "subscribed", "Ip", "4", "Ranges_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "return_", "self_", "._", "subscribed", "Ip", "4", "Ranges_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Return", " ", "global", " ", "(", "all", ")", " ", "ranges_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "return_", "Ip", "4", "Range_", "._", "objects_", "._", "filter_", "(_", "is", "Global_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "allocate", "Mac", "Fro", "m", "Subscrib", "ed", "Ranges_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "mac", "Obj_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Allocate", " ", "Mac", "_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "mac", "Range_", "in_", "self_", "._", "get", "Subscrib", "ed", "Mac", "Ranges_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "mac", "Obj_", "=_", "mac", "Range_", "._", "allocate", "Mac", "_", "(_", ")_", "\\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\t", "\t\t\t_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "mac", "Obj_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "raise_", "Exception_", "(_", "\"", "Cou", "ld", " ", "not", " ", "allocate", " ", "Mac", " ", "address", " ", "for", " ", "the", " ", "VM", " ", "over", " ", "subscribed", " ", "ranges", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "mac", "Obj_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "allocate", "Ip", "Fro", "m", "Subscrib", "ed", "Ranges_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "ip", "Obj_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Allocate", " ", "Ip_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "ip", "Range_", "in_", "self_", "._", "get", "Subscrib", "ed", "Ip", "4", "Ranges_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "ip", "Obj_", "=_", "ip", "Range_", "._", "allocate", "Ip_", "(_", ")_", "\\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\t", "\t\t\t_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "ip", "Obj_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "raise_", "Exception_", "(_", "\"", "Cou", "ld", " ", "not", " ", "allocate", " ", "Ip", "4", " ", "address", " ", "for", " ", "the", " ", "VM", " ", "over", " ", "subscribed", " ", "ranges", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "ip", "Obj_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "create", "Ens", "lav", "ed", "Data", "VM", "Network", "Interface_", "(_", "self_", ",_", "server", "Interface_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Obtain", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "mac", "Obj_", "=_", "self_", "._", "\\u\\u", "allocate", "Mac", "Fro", "m", "Subscrib", "ed", "Ranges_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "interface_", "=_", "Network", "Interface_", "._", "create", "VM", "Data", "Interface_", "(_", "server", "Interface_", "._", "get", "Name_", "(_", ")_", "+_", "\"-", "slave", "\"_", ",_", "mac", "Obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Ens", "lav", "e", " ", "it", "\t_", "\\u\\u\\uNL\\u\\u\\u_", "server", "Interface_", "._", "attach", "Interface", "To", "Bridge", "_", "(_", "interface_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "interface_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "create", "Ens", "lav", "ed", "Mgmt", "VM", "Network", "Interface_", "(_", "self_", ",_", "server", "Interface_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Obtain", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "mac", "Obj_", "=_", "self_", "._", "\\u\\u", "allocate", "Mac", "Fro", "m", "Subscrib", "ed", "Ranges_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ip", "Obj_", "=_", "self_", "._", "\\u\\u", "allocate", "Ip", "Fro", "m", "Subscrib", "ed", "Ranges_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "interface_", "=_", "Network", "Interface_", "._", "create", "VM", "Mgmt", "Interface_", "(_", "server", "Interface_", "._", "get", "Name_", "(_", ")_", "+_", "\"-", "slave", "\"_", ",_", "mac", "Obj_", ",_", "ip", "Obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "Ens", "lav", "e", " ", "it", "\t_", "\\u\\u\\uNL\\u\\u\\u_", "server", "Interface_", "._", "attach", "Interface", "To", "Bridge", "_", "(_", "interface_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "interface_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create", "Ens", "lav", "ed", "VM", "Interface", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "vm", "Interface", "s_", "=_", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "Allocate", " ", "one", " ", "interface", " ", "for", " ", "each", " ", "Server", "'", "s", " ", "interface", " _", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "for_", "server", "Interface_", "in_", "self_", "._", "network", "Interface", "s_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "if_", "server", "Interface_", "._", "is", "Mgmt", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "vm", "Interface", "s_", "._", "add_", "(_", "self_", "._", "\\u\\u", "create", "Ens", "lav", "ed", "Mgmt", "VM", "Network", "Interface_", "(_", "server", "Interface_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t\t_", "vm", "Interface", "s_", "._", "add_", "(_", "self_", "._", "\\u\\u", "create", "Ens", "lav", "ed", "Data", "VM", "Network", "Interface_", "(_", "server", "Interface_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "for_", "interface_", "in_", "vm", "Interface", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "interface_", "._", "destroy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "raise_", "e_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "vm", "Interface", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "set", "Mgmt", "Bridge", "_", "(_", "self_", ",_", "name_", ",_", "mac", "Str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "with_", "Mute", "x", "Store_", "._", "get", "Object", "Lock_", "(_", "self_", "._", "get", "Lock", "Identifier_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "n", "Inter", "_", "=_", "self_", "._", "network", "Interface", "s_", "._", "filter_", "(_", "is", "Mgmt", "_", "=_", "True_", ",_", "is", "Bridge", "_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "n", "Inter", "_", "._", "count_", "(_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "mgmt_", "=_", "n", "Inter", "_", "._", "get_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mgmt_", "._", "set", "Name_", "(_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mgmt_", "._", "set", "Mac", "Str_", "(_", "mac", "Str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "n", "Inter", "_", "._", "count_", "(_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "mgmt_", "=_", "Network", "Interface_", "._", "create", "Server", "Mgmt", "Bridge", "_", "(_", "name_", ",_", "mac", "Str_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "network", "Interface", "s_", "._", "add_", "(_", "mgmt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "raise_", "Exception_", "(_", "\"", "Une", "xpe", "cte", "d", " ", "length", " ", "of", " ", "mana", "gment", " ", "Network", "Interface", " ", "query", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "Data", "Bridge", "_", "(_", "self_", ",_", "name_", ",_", "mac", "Str_", ",_", "switch", "Id_", ",_", "port_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "with_", "Mute", "x", "Store_", "._", "get", "Object", "Lock_", "(_", "self_", "._", "get", "Lock", "Identifier_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "if_", "self_", "._", "network", "Interface", "s_", "._", "filter_", "(_", "name_", "=_", "name_", ",_", "is", "Bridge", "_", "=_", "True_", ")_", "._", "count_", "(_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "raise_", "Exception_", "(_", "\"", "Ano", "ther", " ", "data", " ", "bridge", " ", "with", " ", "the", " ", "same", " ", "name", " ", "alr", "ead", "y", " ", "exist", "s", " ", "in", " ", "this", " ", "Server", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "net", "Int_", "=_", "Network", "Interface_", "._", "create", "Server", "Data", "Bridge", "_", "(_", "name_", ",_", "mac", "Str_", ",_", "switch", "Id_", ",_", "port_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "network", "Interface", "s_", "._", "add_", "(_", "net", "Int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update", "Data", "Bridge", "_", "(_", "self_", ",_", "interface_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "with_", "Mute", "x", "Store_", "._", "get", "Object", "Lock_", "(_", "self_", "._", "get", "Lock", "Identifier_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "if_", "self_", "._", "network", "Interface", "s_", "._", "filter_", "(_", "id_", "=_", "interface_", "._", "id_", ")_", "._", "count_", "(_", ")_", "!=_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "raise_", "Exception_", "(_", "\"", "Can", " ", "not", " ", "update", " ", "bridge", " ", "interface", " ", "bec", "aus", "e", " ", "it", " ", "doe", "s", " ", "not", " ", "exist", " ", "or", " ", "id", " ", "is", " ", "duplicated", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Network", "Interface_", "._", "update", "Server", "Data", "Bridge", "_", "(_", "interface_", "._", "id_", ",_", "interface_", "._", "get", "Name_", "(_", ")_", ",_", "interface_", "._", "get", "Mac", "Str_", "(_", ")_", ",_", "interface_", "._", "get", "Switch", "ID_", "(_", ")_", ",_", "interface_", "._", "get", "Port_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete", "Data", "Bridge", "_", "(_", "self_", ",_", "net", "Int_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "with_", "Mute", "x", "Store_", "._", "get", "Object", "Lock_", "(_", "self_", "._", "get", "Lock", "Identifier_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t_", "if_", "not_", "isinstance_", "(_", "net", "Int_", ",_", "Network", "Interface_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "raise_", "Exception_", "(_", "\"", "Can", " ", "only", " ", "delete", " ", "Data", " ", "Bridge", " ", "tha", "t", " ", "are", " ", "instance", "s", " ", "of", " ", "Network", "Inter", "ace", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "TOD", "O", ":", " ", "delete", " ", "interface", "s", " ", "from", " ", "VM", "s", ",", " ", "for", " ", "the", " ", "moment", " ", "for", "bid_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "net", "Int_", "._", "get", "Number", "Of", "Connections_", "(_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t\t\t_", "raise_", "Exception_", "(_", "\"", "Cann", "ot", " ", "delete", " ", "a", " ", "Data", " ", "bridge", " ", "from", " ", "a", " ", "server", " ", "if", " ", "this", " ", "bridge", " ", "has", " ", "VM", "'", "s", " ", "interface", "s", " ", "ensa", "lve", "d", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "network", "Interface", "s_", "._", "remove_", "(_", "net", "Int_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "net", "Int_", "._", "destroy_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "auto", "Save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "VT", "Server_", "(_", "models_", "._", "Model_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Network", "Interface", "s_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u\t", "\t_", "return_", "self_", "._", "network", "Interface", "s_", "._", "all_", "(_", ")_", "._", "order", "\\u", "by_", "(_", "'-", "is", "Mgmt", "'_", ",_", "'", "id", "'_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 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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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
codysoyland/surlex/src/surlex/grammar.py
[ { "content": "import re\nfrom surlex.exceptions import MalformedSurlex\nfrom surlex.macros import MacroRegistry, DefaultMacroRegistry\n\n# Define the next function for python 2 and 3 compatibility\ntry:\n if next:\n pass\nexcept NameError:\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": " def next(iterable):\n return iterable.next()", "metadata": "root.next", "header": "['module', '___EOS___']", "index": 9 }, { "content": "class Node(object):\n pass", "metadata": "root.Node", "header": "['module', '___EOS___']", "index": 12 }, { "content": "class TextNode(Node):\n\n", "metadata": "root.TextNode", "header": "['module', '___EOS___']", "index": 15 }, { "content": " def __init__(self, token):\n self.token = token", "metadata": "root.TextNode.__init__", "header": "['class', 'TextNode', '(', 'Node', ')', ':', '___EOS___']", "index": 16 }, { "content": " def __eq__(self, other):\n return (self.__class__ == other.__class__ and\n self.token == other.token)", "metadata": "root.TextNode.__eq__", "header": "['class', 'TextNode', '(', 'Node', ')', ':', '___EOS___']", "index": 19 }, { "content": " def __repr__(self):\n return '<TextNode \"%s\">' % self.token", "metadata": "root.TextNode.__repr__", "header": "['class', 'TextNode', '(', 'Node', ')', ':', '___EOS___']", "index": 23 }, { "content": "class WildcardNode(Node):\n", "metadata": "root.WildcardNode", "header": "['module', '___EOS___']", "index": 26 }, { "content": " def __init__(self):\n pass", "metadata": "root.WildcardNode.__init__", "header": "['class', 'WildcardNode', '(', 'Node', ')', ':', '___EOS___']", "index": 27 }, { "content": " def __eq__(self, other):\n return self.__class__ == other.__class__", "metadata": "root.WildcardNode.__eq__", "header": "['class', 'WildcardNode', '(', 'Node', ')', ':', '___EOS___']", "index": 29 }, { "content": " def __repr__(self):\n return '<WildcardNode>'", "metadata": "root.WildcardNode.__repr__", "header": "['class', 'WildcardNode', '(', 'Node', ')', ':', '___EOS___']", "index": 32 }, { "content": "class BlockNode(Node):\n", "metadata": "root.BlockNode", "header": "['module', '___EOS___']", "index": 35 }, { "content": " def __init__(self, node_list):\n self.node_list = node_list", "metadata": "root.BlockNode.__init__", "header": "['class', 'BlockNode', '(', 'Node', ')', ':', '___EOS___']", "index": 36 }, { "content": " def __eq__(self, other):\n return (self.__class__ == other.__class__ and\n self.node_list == other.node_list)", "metadata": "root.BlockNode.__eq__", "header": "['class', 'BlockNode', '(', 'Node', ')', ':', '___EOS___']", "index": 39 }, { "content": "class OptionalNode(BlockNode):", "metadata": "root.OptionalNode", "header": "['module', '___EOS___']", "index": 43 }, { "content": " def __repr__(self):\n return '<OptionalNode: %s>' % self.node_list", "metadata": "root.OptionalNode.__repr__", "header": "['class', 'OptionalNode', '(', 'BlockNode', ')', ':', '___EOS___']", "index": 44 }, { "content": "class TagNode(Node):\n\n", "metadata": "root.TagNode", "header": "['module', '___EOS___']", "index": 47 }, { "content": " def __init__(self, name):\n self.name = name", "metadata": "root.TagNode.__init__", "header": "['class', 'TagNode', '(', 'Node', ')', ':', '___EOS___']", "index": 48 }, { "content": " def __eq__(self, other):\n return (self.__class__ == other.__class__ and\n self.name == other.name)", "metadata": "root.TagNode.__eq__", "header": "['class', 'TagNode', '(', 'Node', ')', ':', '___EOS___']", "index": 51 }, { "content": " def __repr__(self):\n return '<TagNode: %s>' % self.name", "metadata": "root.TagNode.__repr__", "header": "['class', 'TagNode', '(', 'Node', ')', ':', '___EOS___']", "index": 55 }, { "content": "class RegexTagNode(TagNode):\n\n", "metadata": "root.RegexTagNode", "header": "['module', '___EOS___']", "index": 58 }, { "content": " def __init__(self, name, regex):\n self.name = name\n self.regex = regex", "metadata": "root.RegexTagNode.__init__", "header": "['class', 'RegexTagNode', '(', 'TagNode', ')', ':', '___EOS___']", "index": 59 }, { "content": " def __eq__(self, other):\n return (self.__class__ == other.__class__ and\n self.name == other.name and\n self.regex == other.regex)", "metadata": "root.RegexTagNode.__eq__", "header": "['class', 'RegexTagNode', '(', 'TagNode', ')', ':', '___EOS___']", "index": 63 }, { "content": " def __repr__(self):\n return '<RegexTagNode %s: %s>' % (self.name, self.regex)", "metadata": "root.RegexTagNode.__repr__", "header": "['class', 'RegexTagNode', '(', 'TagNode', ')', ':', '___EOS___']", "index": 68 }, { "content": "class MacroTagNode(TagNode):\n\n", "metadata": "root.MacroTagNode", "header": "['module', '___EOS___']", "index": 71 }, { "content": " def __init__(self, name, macro):\n self.name = name\n self.macro = macro", "metadata": "root.MacroTagNode.__init__", "header": "['class', 'MacroTagNode', '(', 'TagNode', ')', ':', '___EOS___']", "index": 72 }, { "content": " def __eq__(self, other):\n return (self.__class__ == other.__class__ and\n self.name == other.name and\n self.macro == other.macro)", "metadata": "root.MacroTagNode.__eq__", "header": "['class', 'MacroTagNode', '(', 'TagNode', ')', ':', '___EOS___']", "index": 76 }, { "content": " def __repr__(self):\n return '<MacroTagNode %s: %s>' % (self.name, self.macro)", "metadata": "root.MacroTagNode.__repr__", "header": "['class', 'MacroTagNode', '(', 'TagNode', ')', ':', '___EOS___']", "index": 81 }, { "content": "class Parser(object):\n\n\n", "metadata": "root.Parser", "header": "['module', '___EOS___']", "index": 84 }, { "content": " def __init__(self, surlex):\n self.surlex = surlex\n self.chars = iter(surlex)", "metadata": "root.Parser.__init__", "header": "['class', 'Parser', '(', 'object', ')', ':', '___EOS___']", "index": 85 }, { "content": " def get_node_list(self):\n return list(self.parse(self.chars))", "metadata": "root.Parser.get_node_list", "header": "['class', 'Parser', '(', 'object', ')', ':', '___EOS___']", "index": 89 }, { "content": " def read_until(self, chars, char):\n try:\n next_char = next(chars)\n except StopIteration:\n raise MalformedSurlex('Malformed surlex. Expected %s.' % char)\n if next_char == char:\n return ''\n if next_char == '\\\\':\n # only escape what we are looking for\n escaped_char = next(chars)\n if escaped_char == char:\n return escaped_char + self.read_until(chars, char)\n else:\n return '\\\\' + escaped_char + self.read_until(chars, char)\n else:\n return next_char + self.read_until(chars, char)", "metadata": "root.Parser.read_until", "header": "['class', 'Parser', '(', 'object', ')', ':', '___EOS___']", "index": 92 }, { "content": " def parse(self, chars):\n token = ''\n for char in chars:\n if char in '<*(':\n if token:\n yield TextNode(token)\n token = ''\n if char == '\\\\':\n # escape with backslash\n token += next(chars)\n elif char == '<':\n tag_content = self.read_until(chars, '>')\n name = ''\n regex = None\n macro = None\n for char in tag_content:\n if char == '=':\n name, regex = tag_content.split('=', 1)\n break\n if char == ':':\n name, macro = tag_content.split(':', 1)\n break\n if regex:\n yield RegexTagNode(name, regex)\n elif macro:\n yield MacroTagNode(name, macro)\n else:\n yield TagNode(tag_content)\n elif char == '*':\n # wildcard\n yield WildcardNode()\n elif char == '(':\n yield OptionalNode(list(self.parse(chars)))\n elif char == ')':\n # end of node list, stop parsing\n break\n else:\n # literal output\n token += char\n if token:\n yield TextNode(token)", "metadata": "root.Parser.parse", "header": "['class', 'Parser', '(', 'object', ')', ':', '___EOS___']", "index": 109 }, { "content": "class RegexScribe(object):\n", "metadata": "root.RegexScribe", "header": "['module', '___EOS___']", "index": 151 }, { "content": " def __init__(self, node_list, macro_registry=DefaultMacroRegistry()):\n self.node_list = node_list\n self.macro_registry = macro_registry", "metadata": "root.RegexScribe.__init__", "header": "['class', 'RegexScribe', '(', 'object', ')', ':', '___EOS___']", "index": 152 }, { "content": " def translate(self):\n output = ''\n for node in self.node_list:\n if isinstance(node, TextNode):\n output += node.token.replace('.', '\\.')\n elif isinstance(node, WildcardNode):\n output += '.*'\n elif isinstance(node, OptionalNode):\n output += '(' + RegexScribe(node.node_list).translate() + ')?'\n elif isinstance(node, TagNode):\n if isinstance(node, MacroTagNode):\n regex = self.macro_registry.get(node.macro)\n elif isinstance(node, RegexTagNode):\n regex = node.regex\n else:\n regex = '.+'\n if node.name:\n output += '(?P<%s>%s)' % (node.name, regex)\n else:\n output += regex\n return output", "metadata": "root.RegexScribe.translate", "header": "['class', 'RegexScribe', '(', 'object', ')', ':', '___EOS___']", "index": 156 }, { "content": "def get_all_nodes(node_list):\n for node in node_list:\n if isinstance(node, BlockNode):\n for node in get_all_nodes(node.node_list):\n yield node\n else:\n yield node", "metadata": "root.get_all_nodes", "header": "['module', '___EOS___']", "index": 178 } ]
[ { "span": "import re", "start_line": 0, "start_column": 0, "end_line": 0, "end_column": 9 }, { "span": "from surlex.macros import MacroRegistry, DefaultMacroRegistry", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 61 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "re_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sur", "lex_", "._", "exceptions_", "import_", "Mal", "formed", "Sur", "lex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "sur", "lex_", "._", "macros_", "import_", "Macro", "Registry_", ",_", "Default", "Macro", "Registry_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Define", " ", "the", " ", "next", " ", "function", " ", "for", " ", "python", " ", "2", " ", "and", " ", "3", " ", "compatibility", "_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "next_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Name", "Error_", ":_", "\\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\\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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "next_", "(_", "iterable_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "iterable_", "._", "next_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Node_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Text", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Text", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "token_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "token_", "=_", "token_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Text", "Node_", "(_", "Node_", ")_", ":_", "\\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_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "==_", "other_", "._", "\\u\\u", "class\\u\\u_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "token_", "==_", "other_", "._", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Text", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'<", "Text", "Node", " ", "\"%", "s", "\">'_", "%_", "self_", "._", "token_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "Wildcard", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Wildcard", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Wildcard", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\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_", "self_", "._", "\\u\\u", "class\\u\\u_", "==_", "other_", "._", "\\u\\u", "class\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Wildcard", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'<", "Wildcard", "Node", ">'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Block", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Block", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "node", "\\u", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "node", "\\u", "list_", "=_", "node", "\\u", "list_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Block", "Node_", "(_", "Node_", ")_", ":_", "\\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_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "==_", "other_", "._", "\\u\\u", "class\\u\\u_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "node", "\\u", "list_", "==_", "other_", "._", "node", "\\u", "list_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Optio", "nal", "Node_", "(_", "Block", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Optio", "nal", "Node_", "(_", "Block", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'<", "Optio", "nal", "Node", ":", " ", "%", "s", ">'_", "%_", "self_", "._", "node", "\\u", "list_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Ta", "g", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Ta", "g", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ta", "g", "Node_", "(_", "Node_", ")_", ":_", "\\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_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "==_", "other_", "._", "\\u\\u", "class\\u\\u_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "name_", "==_", "other_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Ta", "g", "Node_", "(_", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'<", "Ta", "g", "Node", ":", " ", "%", "s", ">'_", "%_", "self_", "._", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Rege", "x", "Ta", "g", "Node_", "(_", "Ta", "g", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Rege", "x", "Ta", "g", "Node_", "(_", "Ta", "g", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "name_", ",_", "regex_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "regex_", "=_", "regex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Rege", "x", "Ta", "g", "Node_", "(_", "Ta", "g", "Node_", ")_", ":_", "\\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_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "==_", "other_", "._", "\\u\\u", "class\\u\\u_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "name_", "==_", "other_", "._", "name_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "regex_", "==_", "other_", "._", "regex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Rege", "x", "Ta", "g", "Node_", "(_", "Ta", "g", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'<", "Rege", "x", "Ta", "g", "Node", " ", "%", "s", ":", " ", "%", "s", ">'_", "%_", "(_", "self_", "._", "name_", ",_", "self_", "._", "regex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Macro", "Ta", "g", "Node_", "(_", "Ta", "g", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Macro", "Ta", "g", "Node_", "(_", "Ta", "g", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "name_", ",_", "macro_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "macro_", "=_", "macro_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Macro", "Ta", "g", "Node_", "(_", "Ta", "g", "Node_", ")_", ":_", "\\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_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "==_", "other_", "._", "\\u\\u", "class\\u\\u_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "name_", "==_", "other_", "._", "name_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "macro_", "==_", "other_", "._", "macro_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Macro", "Ta", "g", "Node_", "(_", "Ta", "g", "Node_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "repr\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "'<", "Macro", "Ta", "g", "Node", " ", "%", "s", ":", " ", "%", "s", ">'_", "%_", "(_", "self_", "._", "name_", ",_", "self_", "._", "macro_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "Parser_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Parser_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "sur", "lex_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "sur", "lex_", "=_", "sur", "lex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "chars_", "=_", "iter_", "(_", "sur", "lex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Parser_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "node", "\\u", "list_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "list_", "(_", "self_", "._", "parse_", "(_", "self_", "._", "chars_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Parser_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read", "\\u", "until_", "(_", "self_", ",_", "chars_", ",_", "char_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "next", "\\u", "char_", "=_", "next_", "(_", "chars_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Sto", "p", "Iteration_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Mal", "formed", "Sur", "lex_", "(_", "'", "Mal", "formed", " ", "sur", "lex", ".", " ", "Expect", "ed", " ", "%", "s", ".'_", "%_", "char_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "next", "\\u", "char_", "==_", "char_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "next", "\\u", "char_", "==_", "'\\\\\\\\'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "only", " ", "escape", " ", "what", " ", "we", " ", "are", " ", "look", "ing", " ", "for_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "escaped", "\\u", "char_", "=_", "next_", "(_", "chars_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "escaped", "\\u", "char_", "==_", "char_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "escaped", "\\u", "char_", "+_", "self_", "._", "read", "\\u", "until_", "(_", "chars_", ",_", "char_", ")_", "\\u\\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_", "'\\\\\\\\'_", "+_", "escaped", "\\u", "char_", "+_", "self_", "._", "read", "\\u", "until_", "(_", "chars_", ",_", "char_", ")_", "\\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_", "next", "\\u", "char_", "+_", "self_", "._", "read", "\\u", "until_", "(_", "chars_", ",_", "char_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Parser_", "(_", "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_", "parse_", "(_", "self_", ",_", "chars_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "token_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "char_", "in_", "chars_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "char_", "in_", "'<", "*(", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "token_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "yield_", "Text", "Node_", "(_", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "token_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "char_", "==_", "'\\\\\\\\'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "escape", " ", "with", " ", "backslash", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "token_", "+=_", "next_", "(_", "chars_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "char_", "==_", "'<'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tag", "\\u", "content_", "=_", "self_", "._", "read", "\\u", "until_", "(_", "chars_", ",_", "'>'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "name_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "regex_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "macro_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "char_", "in_", "tag", "\\u", "content_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "char_", "==_", "'='_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "name_", ",_", "regex_", "=_", "tag", "\\u", "content_", "._", "split_", "(_", "'='_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "char_", "==_", "':'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "name_", ",_", "macro_", "=_", "tag", "\\u", "content_", "._", "split_", "(_", "':'_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "regex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "yield_", "Rege", "x", "Ta", "g", "Node_", "(_", "name_", ",_", "regex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "macro_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "yield_", "Macro", "Ta", "g", "Node_", "(_", "name_", ",_", "macro_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "yield_", "Ta", "g", "Node_", "(_", "tag", "\\u", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "char_", "==_", "'*'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "wildcard_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "Wildcard", "Node_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "char_", "==_", "'('_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "Optio", "nal", "Node_", "(_", "list_", "(_", "self_", "._", "parse_", "(_", "chars_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "char_", "==_", "')'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "end", " ", "of", " ", "node", " ", "list", ",", " ", "stop", " ", "parsing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "literal", " ", "output_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "token_", "+=_", "char_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "token_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "Text", "Node_", "(_", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "Rege", "x", "Scr", "ibe", "_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Rege", "x", "Scr", "ibe", "_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "node", "\\u", "list_", ",_", "macro", "\\u", "registry_", "=_", "Default", "Macro", "Registry_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "node", "\\u", "list_", "=_", "node", "\\u", "list_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "macro", "\\u", "registry_", "=_", "macro", "\\u", "registry_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Rege", "x", "Scr", "ibe", "_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "translate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "node_", "in_", "self_", "._", "node", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "node_", ",_", "Text", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "+=_", "node_", "._", "token_", "._", "replace_", "(_", "'.'_", ",_", "'\\\\.", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "node_", ",_", "Wildcard", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "+=_", "'.*'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "node_", ",_", "Optio", "nal", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "output_", "+=_", "'('_", "+_", "Rege", "x", "Scr", "ibe", "_", "(_", "node_", "._", "node", "\\u", "list_", ")_", "._", "translate_", "(_", ")_", "+_", "')", "?'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "node_", ",_", "Ta", "g", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "node_", ",_", "Macro", "Ta", "g", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "regex_", "=_", "self_", "._", "macro", "\\u", "registry_", "._", "get_", "(_", "node_", "._", "macro_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "isinstance_", "(_", "node_", ",_", "Rege", "x", "Ta", "g", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "regex_", "=_", "node_", "._", "regex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "regex_", "=_", "'.", "+'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "node_", "._", "name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "output_", "+=_", "'(", "?", "P", "<", "%", "s", ">", "%", "s", ")'_", "%_", "(_", "node_", "._", "name_", ",_", "regex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "output_", "+=_", "regex_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "output_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\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", "all", "\\u", "nodes_", "(_", "node", "\\u", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "node_", "in_", "node", "\\u", "list_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "node_", ",_", "Block", "Node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "node_", "in_", "get", "\\u", "all", "\\u", "nodes_", "(_", "node_", "._", "node", "\\u", "list_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "node_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "node_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 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, 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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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Redundant assignment
openstack/taskflow/taskflow/states.py
[ { "content": "# -*- coding: utf-8 -*-\n\n# Copyright (C) 2012-2013 Yahoo! Inc. 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\nfrom taskflow import exceptions as exc\n\n# Job states.\nCLAIMED = 'CLAIMED'\nCOMPLETE = 'COMPLETE'\nUNCLAIMED = 'UNCLAIMED'\n\n# Flow states.\nFAILURE = 'FAILURE'\nPENDING = 'PENDING'\nREVERTING = 'REVERTING'\nREVERTED = 'REVERTED'\nRUNNING = 'RUNNING'\nSUCCESS = 'SUCCESS'\nSUSPENDING = 'SUSPENDING'\nSUSPENDED = 'SUSPENDED'\nRESUMING = 'RESUMING'\n\n# Task states (mainly a subset of the flow states).\nFAILURE = FAILURE\nPENDING = PENDING\nREVERTED = REVERTED\nREVERTING = REVERTING\nSUCCESS = SUCCESS\nRUNNING = RUNNING\nRETRYING = 'RETRYING'\nIGNORE = 'IGNORE'\nREVERT_FAILURE = 'REVERT_FAILURE'\n\n# Atom intentions.\nEXECUTE = 'EXECUTE'\nIGNORE = IGNORE\nREVERT = 'REVERT'\nRETRY = 'RETRY'\nINTENTIONS = (EXECUTE, IGNORE, REVERT, RETRY)\n\n# Additional engine states\nSCHEDULING = 'SCHEDULING'\nWAITING = 'WAITING'\nANALYZING = 'ANALYZING'\n\n# Job state transitions\n# See: http://docs.openstack.org/developer/taskflow/states.html\n\n_ALLOWED_JOB_TRANSITIONS = frozenset((\n # Job is being claimed.\n (UNCLAIMED, CLAIMED),\n\n # Job has been lost (or manually unclaimed/abandoned).\n (CLAIMED, UNCLAIMED),\n\n # Job has been finished.\n (CLAIMED, COMPLETE),\n))\n\n\n\n\n# Flow state transitions\n# See: http://docs.openstack.org/developer/taskflow/states.html#flow\n\n_ALLOWED_FLOW_TRANSITIONS = frozenset((\n (PENDING, RUNNING), # run it!\n\n (RUNNING, SUCCESS), # all tasks finished successfully\n (RUNNING, FAILURE), # some of task failed\n (RUNNING, REVERTED), # some of task failed and flow has been reverted\n (RUNNING, SUSPENDING), # engine.suspend was called\n (RUNNING, RESUMING), # resuming from a previous running\n\n (SUCCESS, RUNNING), # see note below\n\n (FAILURE, RUNNING), # see note below\n\n (REVERTED, PENDING), # try again\n (SUCCESS, PENDING), # run it again\n\n (SUSPENDING, SUSPENDED), # suspend finished\n (SUSPENDING, SUCCESS), # all tasks finished while we were waiting\n (SUSPENDING, FAILURE), # some tasks failed while we were waiting\n (SUSPENDING, REVERTED), # all tasks were reverted while we were waiting\n (SUSPENDING, RESUMING), # resuming from a previous suspending\n\n (SUSPENDED, RUNNING), # restart from suspended\n\n (RESUMING, SUSPENDED), # after flow resumed, it is suspended\n))\n\n\n# NOTE(imelnikov) SUCCESS->RUNNING and FAILURE->RUNNING transitions are\n# useful when flow or flowdetails backing it were altered after the flow\n# was finished; then, client code may want to run through flow again\n# to ensure all tasks from updated flow had a chance to run.\n\n\n# NOTE(imelnikov): Engine cannot transition flow from SUSPENDING to\n# SUSPENDED while some tasks from the flow are running and some results\n# from them are not retrieved and saved properly, so while flow is\n# in SUSPENDING state it may wait for some of the tasks to stop. Then,\n# flow can go to SUSPENDED, SUCCESS, FAILURE or REVERTED state depending\n# of actual state of the tasks -- e.g. if all tasks were finished\n# successfully while we were waiting, flow can be transitioned from\n# SUSPENDING to SUCCESS state.\n\n_IGNORED_FLOW_TRANSITIONS = frozenset(\n (a, b)\n for a in (PENDING, FAILURE, SUCCESS, SUSPENDED, REVERTED)\n for b in (SUSPENDING, SUSPENDED, RESUMING)\n if a != b\n)\n\n\n\n\n# Task state transitions\n# See: http://docs.openstack.org/developer/taskflow/states.html#task\n\n_ALLOWED_TASK_TRANSITIONS = frozenset((\n (PENDING, RUNNING), # run it!\n (PENDING, IGNORE), # skip it!\n\n (RUNNING, SUCCESS), # the task executed successfully\n (RUNNING, FAILURE), # the task execution failed\n\n (FAILURE, REVERTING), # task execution failed, try reverting...\n (SUCCESS, REVERTING), # some other task failed, try reverting...\n\n (REVERTING, REVERTED), # the task reverted successfully\n (REVERTING, REVERT_FAILURE), # the task failed reverting (terminal!)\n\n (REVERTED, PENDING), # try again\n (IGNORE, PENDING), # try again\n))\n\n\n\n\n# Retry state transitions\n# See: http://docs.openstack.org/developer/taskflow/states.html#retry\n\n_ALLOWED_RETRY_TRANSITIONS = list(_ALLOWED_TASK_TRANSITIONS)\n_ALLOWED_RETRY_TRANSITIONS.extend([\n (SUCCESS, RETRYING), # retrying retry controller\n (RETRYING, RUNNING), # run retry controller that has been retrying\n])\n_ALLOWED_RETRY_TRANSITIONS = frozenset(_ALLOWED_RETRY_TRANSITIONS)\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "FAILURE = FAILURE", "start_line": 35, "start_column": 0, "end_line": 35, "end_column": 17 }, { "span": "PENDING = PENDING", "start_line": 36, "start_column": 0, "end_line": 36, "end_column": 17 }, { "span": "REVERTED = REVERTED", "start_line": 37, "start_column": 0, "end_line": 37, "end_column": 19 }, { "span": "REVERTING = REVERTING", "start_line": 38, "start_column": 0, "end_line": 38, "end_column": 21 }, { "span": "SUCCESS = SUCCESS", "start_line": 39, "start_column": 0, "end_line": 39, "end_column": 17 }, { "span": "RUNNING = RUNNING", "start_line": 40, "start_column": 0, "end_line": 40, "end_column": 17 }, { "span": "IGNORE = IGNORE", "start_line": 47, "start_column": 0, "end_line": 47, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Redu", "ndan", "t_", "assignment_", "[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", ")", " ", "2012", "-", "2013", " ", "Ya", "hoo", "!", " ", "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", "\");", " ", "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_", "from_", "task", "flow_", "import_", "exceptions_", "as_", "exc_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Jo", "b", " ", "state", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "CLA", "IME", "D_", "=_", "'", "CLA", "IME", "D", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "COMPLETE_", "=_", "'", "COMPLET", "E", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "UNC", "LAI", "MED", "_", "=_", "'", "UNC", "LAI", "MED", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Flow", " ", "state", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "FAILURE_", "=_", "'", "FAIL", "URE", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "PENDING_", "=_", "'", "PEND", "ING", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "REV", "ERT", "ING_", "=_", "'", "REV", "ERT", "ING", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "REV", "ERT", "ED_", "=_", "'", "REV", "ERT", "ED", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "RUNNING_", "=_", "'", "RUNN", "ING", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SUCCESS_", "=_", "'", "SUCCESS", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SUS", "PENDING_", "=_", "'", "SUS", "PEND", "ING", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SUS", "PEND", "ED_", "=_", "'", "SUS", "PEND", "ED", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "RESU", "MIN", "G_", "=_", "'", "RESU", "MIN", "G", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Task", " ", "state", "s", " ", "(", "mainl", "y", " ", "a", " ", "subse", "t", " ", "of", " ", "the", " ", "flow", " ", "state", "s", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "FAILURE_", "=_", "FAILURE_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "PENDING_", "=_", "PENDING_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "REV", "ERT", "ED_", "=_", "REV", "ERT", "ED_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "REV", "ERT", "ING_", "=_", "REV", "ERT", "ING_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "SUCCESS_", "=_", "SUCCESS_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "RUNNING_", "=_", "RUNNING_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "RETRY", "ING_", "=_", "'", "RETRY", "ING", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "IGNORE", "_", "=_", "'", "IGNORE", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "REV", "ERT", "\\u", "FAILURE_", "=_", "'", "REV", "ERT", "\\u", "FAIL", "URE", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Atom", " ", "intent", "ion", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "EXECUTE", "_", "=_", "'", "EXECUTE", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "IGNORE", "_", "=_", "IGNORE", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "REV", "ERT", "_", "=_", "'", "REV", "ERT", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "RETRY", "_", "=_", "'", "RETRY", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "INTEN", "TIONS", "_", "=_", "(_", "EXECUTE", "_", ",_", "IGNORE", "_", ",_", "REV", "ERT", "_", ",_", "RETRY", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Addition", "al", " ", "eng", "ine", " ", "states_", "\\u\\u\\uNL\\u\\u\\u_", "SCHE", "DU", "LING", "_", "=_", "'", "SCHE", "DU", "LING", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "WAIT", "ING_", "=_", "'", "WAIT", "ING", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ANALY", "ZI", "NG_", "=_", "'", "ANALY", "ZI", "NG", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Jo", "b", " ", "state", " ", "transitions_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", ":", " ", "http", "://", "docs", ".", "openst", "ack", ".", "org", "/", "developer", "/", "task", "flow", "/", "state", "s", ".", "html_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "ALLOWED", "\\u", "JOB", "\\u", "TRANS", "ITION", "S_", "=_", "frozenset_", "(_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Jo", "b", " ", "is", " ", "bei", "ng", " ", "claimed", "._", "\\u\\u\\uNL\\u\\u\\u_", "(_", "UNC", "LAI", "MED", "_", ",_", "CLA", "IME", "D_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Jo", "b", " ", "has", " ", "bee", "n", " ", "lost", " ", "(", "or", " ", "manu", "ally", " ", "uncl", "aime", "d", "/", "aband", "oned", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "CLA", "IME", "D_", ",_", "UNC", "LAI", "MED", "_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Jo", "b", " ", "has", " ", "bee", "n", " ", "finish", "ed", "._", "\\u\\u\\uNL\\u\\u\\u_", "(_", "CLA", "IME", "D_", ",_", "COMPLETE_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Flow", " ", "state", " ", "transitions_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", ":", " ", "http", "://", "docs", ".", "openst", "ack", ".", "org", "/", "developer", "/", "task", "flow", "/", "state", "s", ".", "html", "#", "flow_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "ALLOWED", "\\u", "FLOW", "\\u", "TRANS", "ITION", "S_", "=_", "frozenset_", "(_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "PENDING_", ",_", "RUNNING_", ")_", ",_", "#", " ", "run", " ", "it", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "RUNNING_", ",_", "SUCCESS_", ")_", ",_", "#", " ", "all", " ", "task", "s", " ", "finish", "ed", " ", "success", "full", "y_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "RUNNING_", ",_", "FAILURE_", ")_", ",_", "#", " ", "some", " ", "of", " ", "task", " ", "failed_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "RUNNING_", ",_", "REV", "ERT", "ED_", ")_", ",_", "#", " ", "some", " ", "of", " ", "task", " ", "fail", "ed", " ", "and", " ", "flow", " ", "has", " ", "bee", "n", " ", "revert", "ed_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "RUNNING_", ",_", "SUS", "PENDING_", ")_", ",_", "#", " ", "eng", "ine", ".", "suspend", " ", "was", " ", "called_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "RUNNING_", ",_", "RESU", "MIN", "G_", ")_", ",_", "#", " ", "resum", "ing", " ", "from", " ", "a", " ", "previ", "ous", " ", "running_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SUCCESS_", ",_", "RUNNING_", ")_", ",_", "#", " ", "see", " ", "note", " ", "below_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "FAILURE_", ",_", "RUNNING_", ")_", ",_", "#", " ", "see", " ", "note", " ", "below_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "REV", "ERT", "ED_", ",_", "PENDING_", ")_", ",_", "#", " ", "try", " ", "again", "_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SUCCESS_", ",_", "PENDING_", ")_", ",_", "#", " ", "run", " ", "it", " ", "again", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SUS", "PENDING_", ",_", "SUS", "PEND", "ED_", ")_", ",_", "#", " ", "suspend", " ", "finished_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SUS", "PENDING_", ",_", "SUCCESS_", ")_", ",_", "#", " ", "all", " ", "task", "s", " ", "finish", "ed", " ", "whi", "le", " ", "we", " ", "wer", "e", " ", "waiting_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SUS", "PENDING_", ",_", "FAILURE_", ")_", ",_", "#", " ", "some", " ", "task", "s", " ", "fail", "ed", " ", "whi", "le", " ", "we", " ", "wer", "e", " ", "waiting_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SUS", "PENDING_", ",_", "REV", "ERT", "ED_", ")_", ",_", "#", " ", "all", " ", "task", "s", " ", "wer", "e", " ", "revert", "ed", " ", "whi", "le", " ", "we", " ", "wer", "e", " ", "waiting_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SUS", "PENDING_", ",_", "RESU", "MIN", "G_", ")_", ",_", "#", " ", "resum", "ing", " ", "from", " ", "a", " ", "previ", "ous", " ", "suspend", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SUS", "PEND", "ED_", ",_", "RUNNING_", ")_", ",_", "#", " ", "restart", " ", "from", " ", "suspended", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "RESU", "MIN", "G_", ",_", "SUS", "PEND", "ED_", ")_", ",_", "#", " ", "after", " ", "flow", " ", "resum", "ed", ",", " ", "it", " ", "is", " ", "suspended", "_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "NOTE", "(", "ime", "ln", "iko", "v", ")", " ", "SUCCESS", "->", "RUNN", "ING", " ", "and", " ", "FAIL", "URE", "->", "RUNN", "ING", " ", "transiti", "ons", " ", "are", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "usef", "ul", " ", "whe", "n", " ", "flow", " ", "or", " ", "flow", "deta", "il", "s", " ", "backing", " ", "it", " ", "wer", "e", " ", "alter", "ed", " ", "after", " ", "the", " ", "flow_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "was", " ", "finish", "ed", ";", " ", "then", ",", " ", "client", " ", "code", " ", "may", " ", "want", " ", "to", " ", "run", " ", "through", " ", "flow", " ", "again", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", " ", "ensure", " ", "all", " ", "task", "s", " ", "from", " ", "update", "d", " ", "flow", " ", "had", " ", "a", " ", "chan", "ce", " ", "to", " ", "run", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "NOTE", "(", "ime", "ln", "iko", "v", "):", " ", "Engine", " ", "cann", "ot", " ", "transiti", "on", " ", "flow", " ", "from", " ", "SUS", "PEND", "ING", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "SUS", "PEND", "ED", " ", "whi", "le", " ", "some", " ", "task", "s", " ", "from", " ", "the", " ", "flow", " ", "are", " ", "runn", "ing", " ", "and", " ", "some", " ", "results_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "from", " ", "them", " ", "are", " ", "not", " ", "retrieved", " ", "and", " ", "saved", " ", "proper", "ly", ",", " ", "so", " ", "whi", "le", " ", "flow", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "in", " ", "SUS", "PEND", "ING", " ", "state", " ", "it", " ", "may", " ", "wait", " ", "for", " ", "some", " ", "of", " ", "the", " ", "task", "s", " ", "to", " ", "stop", ".", " ", "The", "n", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "flow", " ", "can", " ", "go", " ", "to", " ", "SUS", "PEND", "ED", ",", " ", "SUCCESS", ",", " ", "FAIL", "URE", " ", "or", " ", "REV", "ERT", "ED", " ", "state", " ", "depend", "ing_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "actual", " ", "state", " ", "of", " ", "the", " ", "task", "s", " ", "--", " ", "e", ".", "g", ".", " ", "if", " ", "all", " ", "task", "s", " ", "wer", "e", " ", "finished_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "success", "full", "y", " ", "whi", "le", " ", "we", " ", "wer", "e", " ", "wait", "ing", ",", " ", "flow", " ", "can", " ", "be", " ", "transiti", "oned", " ", "from_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "SUS", "PEND", "ING", " ", "to", " ", "SUCCESS", " ", "state", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "IGNORE", "D", "\\u", "FLOW", "\\u", "TRANS", "ITION", "S_", "=_", "frozenset_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "a_", ",_", "b_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "a_", "in_", "(_", "PENDING_", ",_", "FAILURE_", ",_", "SUCCESS_", ",_", "SUS", "PEND", "ED_", ",_", "REV", "ERT", "ED_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "b_", "in_", "(_", "SUS", "PENDING_", ",_", "SUS", "PEND", "ED_", ",_", "RESU", "MIN", "G_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "a_", "!=_", "b_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Task", " ", "state", " ", "transitions_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", ":", " ", "http", "://", "docs", ".", "openst", "ack", ".", "org", "/", "developer", "/", "task", "flow", "/", "state", "s", ".", "html", "#", "task_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "ALLOWED", "\\u", "TASK", "\\u", "TRANS", "ITION", "S_", "=_", "frozenset_", "(_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "PENDING_", ",_", "RUNNING_", ")_", ",_", "#", " ", "run", " ", "it", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "PENDING_", ",_", "IGNORE", "_", ")_", ",_", "#", " ", "skip", " ", "it", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "RUNNING_", ",_", "SUCCESS_", ")_", ",_", "#", " ", "the", " ", "task", " ", "executed", " ", "success", "full", "y_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "RUNNING_", ",_", "FAILURE_", ")_", ",_", "#", " ", "the", " ", "task", " ", "executi", "on", " ", "failed_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "FAILURE_", ",_", "REV", "ERT", "ING_", ")_", ",_", "#", " ", "task", " ", "executi", "on", " ", "fail", "ed", ",", " ", "try", " ", "revert", "ing", "..._", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SUCCESS_", ",_", "REV", "ERT", "ING_", ")_", ",_", "#", " ", "some", " ", "other", " ", "task", " ", "fail", "ed", ",", " ", "try", " ", "revert", "ing", "..._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "REV", "ERT", "ING_", ",_", "REV", "ERT", "ED_", ")_", ",_", "#", " ", "the", " ", "task", " ", "revert", "ed", " ", "success", "full", "y_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "REV", "ERT", "ING_", ",_", "REV", "ERT", "\\u", "FAILURE_", ")_", ",_", "#", " ", "the", " ", "task", " ", "fail", "ed", " ", "revert", "ing", " ", "(", "termina", "l", "!)", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "REV", "ERT", "ED_", ",_", "PENDING_", ")_", ",_", "#", " ", "try", " ", "again", "_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "IGNORE", "_", ",_", "PENDING_", ")_", ",_", "#", " ", "try", " ", "again", "_", "\\u\\u\\uNL\\u\\u\\u_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Retr", "y", " ", "state", " ", "transitions_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "See", ":", " ", "http", "://", "docs", ".", "openst", "ack", ".", "org", "/", "developer", "/", "task", "flow", "/", "state", "s", ".", "html", "#", "retry_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u", "ALLOWED", "\\u", "RETRY", "\\u", "TRANS", "ITION", "S_", "=_", "list_", "(_", "\\u", "ALLOWED", "\\u", "TASK", "\\u", "TRANS", "ITION", "S_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "ALLOWED", "\\u", "RETRY", "\\u", "TRANS", "ITION", "S_", "._", "extend_", "(_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "SUCCESS_", ",_", "RETRY", "ING_", ")_", ",_", "#", " ", "retrying", " ", "retr", "y", " ", "controller_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "RETRY", "ING_", ",_", "RUNNING_", ")_", ",_", "#", " ", "run", " ", "retr", "y", " ", "controlle", "r", " ", "tha", "t", " ", "has", " ", "bee", "n", " ", "retrying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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 ]
`__eq__` not overridden when adding attributes
sassoftware/conary/conary/streams.py
[ { "content": "class InfoStream(object):\n\n __slots__ = ()\n\n\n\n\n\n\n", "metadata": "root.InfoStream", "header": "['module', '___EOS___']", "index": 48 }, { "content": " def __deepcopy__(self, mem):\n return self.__class__(self.freeze())", "metadata": "root.InfoStream.__deepcopy__", "header": "['class', 'InfoStream', '(', 'object', ')', ':', '___EOS___']", "index": 52 }, { "content": " def copy(self):\n return self.__class__(self.freeze())", "metadata": "root.InfoStream.copy", "header": "['class', 'InfoStream', '(', 'object', ')', ':', '___EOS___']", "index": 55 }, { "content": " def freeze(self, skipSet = None):\n raise NotImplementedError", "metadata": "root.InfoStream.freeze", "header": "['class', 'InfoStream', '(', 'object', ')', ':', '___EOS___']", "index": 58 }, { "content": " def diff(self, them):\n \"\"\"\n Return the diff twm needs to convert them into self. Return None\n if the two items are identical.\n \"\"\"\n raise NotImplementedError", "metadata": "root.InfoStream.diff", "header": "['class', 'InfoStream', '(', 'object', ')', ':', '___EOS___']", "index": 61 }, { "content": " def twm(self, diff, base):\n \"\"\"\n Performs a three way merge. Base is the original information,\n diff is one of the changes, and self is the (already changed)\n object. Returns a boolean saying whether or not the merge failed\n \"\"\"\n raise NotImplementedError", "metadata": "root.InfoStream.twm", "header": "['class', 'InfoStream', '(', 'object', ')', ':', '___EOS___']", "index": 68 }, { "content": " def __eq__(self, them, skipSet = None):\n raise NotImplementedError", "metadata": "root.InfoStream.__eq__", "header": "['class', 'InfoStream', '(', 'object', ')', ':', '___EOS___']", "index": 76 }, { "content": " def __ne__(self, them):\n return not self.__eq__(them)", "metadata": "root.InfoStream.__ne__", "header": "['class', 'InfoStream', '(', 'object', ')', ':', '___EOS___']", "index": 79 }, { "content": "class BaseDependenciesStream(InfoStream):\n \"\"\"\n Abstract Class. Doesn't work without a mixin.\n\n Stores list of strings; used for requires/provides lists\n \"\"\"\n deps = DepsAttr()\n\n\n\n", "metadata": "root.BaseDependenciesStream", "header": "['module', '___EOS___']", "index": 259 }, { "content": " def __call__(self):\n return self", "metadata": "root.BaseDependenciesStream.__call__", "header": "['class', 'BaseDependenciesStream', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 267 }, { "content": " def set(self, val):\n assert(val is not None)\n self._members = val._members\n self.hash = None", "metadata": "root.BaseDependenciesStream.set", "header": "['class', 'BaseDependenciesStream', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 270 }, { "content": " def diff(self, them):\n if self != them:\n return self.freeze()\n\n return None", "metadata": "root.BaseDependenciesStream.diff", "header": "['class', 'BaseDependenciesStream', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 275 }, { "content": " def twm(self, diff, base):\n self.thaw(diff)\n return False", "metadata": "root.BaseDependenciesStream.twm", "header": "['class', 'BaseDependenciesStream', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 281 }, { "content": "class StreamCollection(InfoStream):\n\n \"\"\"\n streamDict needs to be defined as an index of small ints to\n Stream class types.\n \"\"\"\n\n ignoreSkipSet = False\n __slots__ = ( '_data', '_items', 'streamDict', '_thawedItems' )\n\n\n _items = property(getItems)\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root.StreamCollection", "header": "['module', '___EOS___']", "index": 450 }, { "content": " def getItems(self):\n if self._data is not None:\n self._thaw()\n\n return self._thawedItems", "metadata": "root.StreamCollection.getItems", "header": "['class', 'StreamCollection', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 460 }, { "content": " def __eq__(self, other, skipSet = {}):\n assert(self.__class__ == other.__class__)\n\n if self._data is not None and other._data is not None:\n return self._data == other._data\n\n return self._items == other._items", "metadata": "root.StreamCollection.__eq__", "header": "['class', 'StreamCollection', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 468 }, { "content": " def __ne__(self, other):\n return not self.__eq__(other)", "metadata": "root.StreamCollection.__ne__", "header": "['class', 'StreamCollection', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 476 }, { "content": " def freeze(self, skipSet = {}):\n if self._data is not None:\n if self.ignoreSkipSet or not skipSet:\n return self._data\n else:\n self._thaw()\n\n l = []\n for typeId, itemDict in sorted(self._items.iteritems()):\n itemList = sorted(itemDict)\n if itemList and not hasattr(itemList[0], '__cmp__'):\n raise AssertionError('Programming Error: %s type object '\n 'does not have a __cmp__ method - '\n 'sorting will be unstable'\n % itemList[0].__class__.__name__)\n\n for item in sorted(itemDict):\n s = item.freeze()\n if len(s) >= (1 << 16):\n raise OverflowError\n l.append(pack.pack(\"!BSH\", typeId, s))\n\n return \"\".join(l)", "metadata": "root.StreamCollection.freeze", "header": "['class', 'StreamCollection', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 479 }, { "content": " def thaw(self, data):\n data = intern(data)\n self._data = data", "metadata": "root.StreamCollection.thaw", "header": "['class', 'StreamCollection', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 503 }, { "content": " def _thaw(self):\n i = 0\n self._thawedItems = dict([ (x, {}) for x in self.streamDict ])\n\n while (i < len(self._data)):\n i, (typeId, s) = pack.unpack(\"!BSH\", i, self._data)\n item = self.streamDict[typeId](s)\n self._thawedItems[typeId][item] = True\n\n assert(i == len(self._data))\n self._data = None", "metadata": "root.StreamCollection._thaw", "header": "['class', 'StreamCollection', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 507 }, { "content": " def addStream(self, typeId, item):\n assert(item.__class__ == self.streamDict[typeId])\n self._items[typeId][item] = True", "metadata": "root.StreamCollection.addStream", "header": "['class', 'StreamCollection', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 519 }, { "content": " def delStream(self, typeId, item):\n del self._items[typeId][item]", "metadata": "root.StreamCollection.delStream", "header": "['class', 'StreamCollection', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 523 }, { "content": " def getStreams(self, typeId):\n return self._items[typeId]", "metadata": "root.StreamCollection.getStreams", "header": "['class', 'StreamCollection', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 526 }, { "content": " def iterAll(self):\n for typeId, itemDict in self._items.iteritems():\n for item in itemDict:\n yield (typeId, item)", "metadata": "root.StreamCollection.iterAll", "header": "['class', 'StreamCollection', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 529 }, { "content": " def diff(self, other):\n assert(self.__class__ == other.__class__)\n if self._data is not None and self._data == other._data:\n return None\n\n us = set(self.iterAll())\n them = set(other.iterAll())\n added = us - them\n removed = them - us\n\n if not added and not removed:\n return None\n\n l = []\n if len(removed) >= (1 << 16):\n raise OverflowError\n if len(added) >= (1 << 16):\n raise OverflowError\n l.append(struct.pack(\"!HH\", len(removed), len(added)))\n\n for typeId, item in itertools.chain(removed, added):\n s = item.freeze()\n if len(s) >= (1 << 16):\n raise OverflowError\n l.append(struct.pack(\"!BH\", typeId, len(s)))\n l.append(s)\n\n return \"\".join(l)", "metadata": "root.StreamCollection.diff", "header": "['class', 'StreamCollection', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 534 }, { "content": " def twm(self, diff, base):\n assert(self == base)\n numRemoved, numAdded = struct.unpack(\"!HH\", diff[0:4])\n i = 4\n\n for x in xrange(numRemoved + numAdded):\n typeId, length = struct.unpack(\"!BH\", diff[i : i + 3])\n i += 3\n item = self.streamDict[typeId](diff[i:i + length])\n i += length\n\n if x < numRemoved:\n del self._items[typeId][item]\n else:\n self._items[typeId][item] = True", "metadata": "root.StreamCollection.twm", "header": "['class', 'StreamCollection', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 563 }, { "content": " def __init__(self, data = None):\n if data is not None:\n self.thaw(data)\n else:\n self.thaw('')", "metadata": "root.StreamCollection.__init__", "header": "['class', 'StreamCollection', '(', 'InfoStream', ')', ':', '___EOS___']", "index": 579 }, { "content": "class OrderedStreamCollection(StreamCollection):\n # same as StreamCollection, but ordered and can holder bigger stuff\n __slots__ = ()\n\n\n\n\n\n\n\n\n\n", "metadata": "root.OrderedStreamCollection", "header": "['module', '___EOS___']", "index": 585 }, { "content": " def freeze(self, skipSet = {}):\n if self._data is not None:\n if not skipSet:\n return self._data\n else:\n self._thaw()\n\n l = []\n for typeId, itemList in (self._items.iteritems()):\n for item in itemList:\n s = item.freeze(skipSet = skipSet)\n l.append(struct.pack('!B', typeId))\n l.append(pack.dynamicSize(len(s)))\n l.append(s)\n\n return \"\".join(l)", "metadata": "root.OrderedStreamCollection.freeze", "header": "['class', 'OrderedStreamCollection', '(', 'StreamCollection', ')', ':', '___NEWLINE___', '# same as StreamCollection, but ordered and can holder bigger stuff', '___NL___', '___EOS___']", "index": 589 }, { "content": " def _thaw(self):\n i = 0\n self._thawedItems = dict([ (x, []) for x in self.streamDict ])\n\n while (i < len(self._data)):\n i, (typeId, s) = pack.unpack('!BD', i, self._data)\n item = self.streamDict[typeId](s)\n self._thawedItems[typeId].append(item)\n\n assert(i == len(self._data))\n self._data = None", "metadata": "root.OrderedStreamCollection._thaw", "header": "['class', 'OrderedStreamCollection', '(', 'StreamCollection', ')', ':', '___NEWLINE___', '# same as StreamCollection, but ordered and can holder bigger stuff', '___NL___', '___EOS___']", "index": 606 }, { "content": " def addStream(self, typeId, item):\n assert(item.__class__ == self.streamDict[typeId])\n self._items[typeId].append(item)", "metadata": "root.OrderedStreamCollection.addStream", "header": "['class', 'OrderedStreamCollection', '(', 'StreamCollection', ')', ':', '___NEWLINE___', '# same as StreamCollection, but ordered and can holder bigger stuff', '___NL___', '___EOS___']", "index": 618 }, { "content": " def delStream(self, typeId, item):\n l = self._items[typeId]\n del l[l.index(item)]", "metadata": "root.OrderedStreamCollection.delStream", "header": "['class', 'OrderedStreamCollection', '(', 'StreamCollection', ')', ':', '___NEWLINE___', '# same as StreamCollection, but ordered and can holder bigger stuff', '___NL___', '___EOS___']", "index": 622 }, { "content": " def getStreams(self, typeId):\n return self._items[typeId]", "metadata": "root.OrderedStreamCollection.getStreams", "header": "['class', 'OrderedStreamCollection', '(', 'StreamCollection', ')', ':', '___NEWLINE___', '# same as StreamCollection, but ordered and can holder bigger stuff', '___NL___', '___EOS___']", "index": 626 }, { "content": " def iterAll(self):\n for typeId, l in self._items.iteritems():\n for item in l:\n yield (typeId, item)", "metadata": "root.OrderedStreamCollection.iterAll", "header": "['class', 'OrderedStreamCollection', '(', 'StreamCollection', ')', ':', '___NEWLINE___', '# same as StreamCollection, but ordered and can holder bigger stuff', '___NL___', '___EOS___']", "index": 629 }, { "content": " def count(self, typeId):\n return len(self._items[typeId])", "metadata": "root.OrderedStreamCollection.count", "header": "['class', 'OrderedStreamCollection', '(', 'StreamCollection', ')', ':', '___NEWLINE___', '# same as StreamCollection, but ordered and can holder bigger stuff', '___NL___', '___EOS___']", "index": 634 }, { "content": " def diff(self, other):\n assert(self.__class__ == other.__class__)\n us = set(self.iterAll())\n them = set(other.iterAll())\n added = us - them\n removed = them - us\n\n if not added and not removed:\n return None\n\n l = []\n if len(removed) >= (1 << 16):\n raise OverflowError\n if len(added) >= (1 << 16):\n raise OverflowError\n l.append(struct.pack(\"!HH\", len(removed), len(added)))\n\n for typeId, item in removed:\n s = item.freeze()\n l.append(struct.pack('!B', typeId))\n l.append(pack.dynamicSize(len(s)))\n l.append(s)\n\n # make sure the additions are ordered\n for typeId, item in self.iterAll():\n if (typeId, item) in added:\n s = item.freeze()\n l.append(struct.pack('!B', typeId))\n l.append(pack.dynamicSize(len(s)))\n l.append(s)\n\n return \"\".join(l)", "metadata": "root.OrderedStreamCollection.diff", "header": "['class', 'OrderedStreamCollection', '(', 'StreamCollection', ')', ':', '___NEWLINE___', '# same as StreamCollection, but ordered and can holder bigger stuff', '___NL___', '___EOS___']", "index": 637 }, { "content": " def twm(self, diff, base):\n assert(self == base)\n numRemoved, numAdded = struct.unpack(\"!HH\", diff[0:4])\n i = 4\n\n for x in xrange(numRemoved + numAdded):\n i, (typeId, s) = pack.unpack(\"!BD\", i, diff)\n item = self.streamDict[typeId](s)\n if x < numRemoved:\n l = self._items[typeId]\n del l[l.index(item)]\n else:\n self._items[typeId].append(item)", "metadata": "root.OrderedStreamCollection.twm", "header": "['class', 'OrderedStreamCollection', '(', 'StreamCollection', ')', ':', '___NEWLINE___', '# same as StreamCollection, but ordered and can holder bigger stuff', '___NL___', '___EOS___']", "index": 670 }, { "content": " def __init__(self, data = None):\n if data is not None:\n self.thaw(data)\n else:\n self._data = None\n self._thawedItems = dict([ (x, []) for x in self.streamDict ])", "metadata": "root.OrderedStreamCollection.__init__", "header": "['class', 'OrderedStreamCollection', '(', 'StreamCollection', ')', ':', '___NEWLINE___', '# same as StreamCollection, but ordered and can holder bigger stuff', '___NL___', '___EOS___']", "index": 684 } ]
[ { "span": "class BaseDependenciesStream(InfoStream):", "start_line": 259, "start_column": 0, "end_line": 259, "end_column": 41 }, { "span": "class OrderedStreamCollection(StreamCollection):", "start_line": 585, "start_column": 0, "end_line": 585, "end_column": 48 } ]
[ { "span": "def __eq__(self, them, skipSet = None):", "start_line": 76, "start_column": 4, "end_line": 76, "end_column": 43 }, { "span": "self._members ", "start_line": 272, "start_column": 8, "end_line": 272, "end_column": 21 }, { "span": "self.hash ", "start_line": 273, "start_column": 8, "end_line": 273, "end_column": 17 }, { "span": "def __eq__(self, other, skipSet = {}):", "start_line": 468, "start_column": 4, "end_line": 468, "end_column": 42 }, { "span": "self._thawedItems ", "start_line": 608, "start_column": 8, "end_line": 608, "end_column": 25 }, { "span": "self._thawedItems ", "start_line": 689, "start_column": 12, "end_line": 689, "end_column": 29 } ]
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_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u\\u", "slots\\u\\u_", "=_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "deepc", "opy", "\\u\\u_", "(_", "self_", ",_", "mem_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "self_", "._", "freeze_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "copy_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u\\u", "class\\u\\u_", "(_", "self_", "._", "freeze_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "freeze_", "(_", "self_", ",_", "skip", "Set_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Impl", "ement", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "diff_", "(_", "self_", ",_", "them", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", " ", "the", " ", "diff", " ", "tw", "m", " ", "need", "s", " ", "to", " ", "convert", " ", "them", " ", "int", "o", " ", "self", ".", " ", "Return", " ", "Non", "e", "\\", "10", ";", " ", " ", " ", " ", "if", " ", "the", " ", "two", " ", "items", " ", "are", " ", "identi", "cal", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "tw", "m_", "(_", "self_", ",_", "diff_", ",_", "base_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Perform", "s", " ", "a", " ", "three", " ", "way", " ", "merge", ".", " ", "Base", " ", "is", " ", "the", " ", "original", " ", "informati", "on", ",", "\\", "10", ";", " ", " ", " ", " ", "diff", " ", "is", " ", "one", " ", "of", " ", "the", " ", "change", "s", ",", " ", "and", " ", "self", " ", "is", " ", "the", " ", "(", "alr", "ead", "y", " ", "change", "d", ")", "\\", "10", ";", " ", " ", " ", " ", "object", ".", " ", "Return", "s", " ", "a", " ", "boolean", " ", "say", "ing", " ", "whe", "ther", " ", "or", " ", "not", " ", "the", " ", "merge", " ", "fail", "ed", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Not", "Impl", "ement", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "eq\\u\\u_", "(_", "self_", ",_", "them", "_", ",_", "skip", "Set_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Not", "Impl", "ement", "ed", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Info", "Stream_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "ne\\u\\u_", "(_", "self_", ",_", "them", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "not_", "self_", "._", "\\u\\u", "eq\\u\\u_", "(_", "them", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Base", "Dependenc", "ies", "Stream_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Abstract", " ", "Class", ".", " ", "Do", "esn", "'", "t", " ", "work", " ", "with", "out", " ", "a", " ", "mix", "in", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Stor", "es", " ", "list", " ", "of", " ", "string", "s", ";", " ", "used", " ", "for", " ", "require", "s", "/", "provide", "s", " ", "lists", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "deps_", "=_", "Deps", "Attr_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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", "Dependenc", "ies", "Stream_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "call\\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_", "Base", "Dependenc", "ies", "Stream_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set_", "(_", "self_", ",_", "val_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "(_", "val_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "members_", "=_", "val_", "._", "\\u", "members_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "hash_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Dependenc", "ies", "Stream_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "diff_", "(_", "self_", ",_", "them", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "!=_", "them", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "freeze_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Dependenc", "ies", "Stream_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "tw", "m_", "(_", "self_", ",_", "diff_", ",_", "base_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "tha", "w_", "(_", "diff_", ")_", "\\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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Stream", "Collection_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "stream", "Dict", " ", "need", "s", " ", "to", " ", "be", " ", "defin", "ed", " ", "as", " ", "an", " ", "index", " ", "of", " ", "small", " ", "ints", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "Stream", " ", "class", " ", "types", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ignore", "Ski", "p", "Set_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "slots\\u\\u_", "=_", "(_", "'\\u", "data", "'_", ",_", "'\\u", "items", "'_", ",_", "'", "stream", "Dict", "'_", ",_", "'\\u", "tha", "wed", "Item", "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\\uDEDENT\\u\\u\\u_", "\\u", "items_", "=_", "property_", "(_", "get", "Items_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Stream", "Collection_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "Items_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "data_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "tha", "w_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "\\u", "tha", "wed", "Items_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stream", "Collection_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "eq\\u\\u_", "(_", "self_", ",_", "other_", ",_", "skip", "Set_", "=_", "{_", "}_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "==_", "other_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "self_", "._", "\\u", "data_", "is_", "not_", "None_", "and_", "other_", "._", "\\u", "data_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "data_", "==_", "other_", "._", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "self_", "._", "\\u", "items_", "==_", "other_", "._", "\\u", "items_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stream", "Collection_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "ne\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "not_", "self_", "._", "\\u\\u", "eq\\u\\u_", "(_", "other_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stream", "Collection_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "freeze_", "(_", "self_", ",_", "skip", "Set_", "=_", "{_", "}_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "data_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "ignore", "Ski", "p", "Set_", "or_", "not_", "skip", "Set_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "tha", "w_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "l_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "type", "Id_", ",_", "item", "Dict_", "in_", "sorted_", "(_", "self_", "._", "\\u", "items_", "._", "iteritems_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "item", "List_", "=_", "sorted_", "(_", "item", "Dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "item", "List_", "and_", "not_", "hasattr_", "(_", "item", "List_", "[_", "0_", "]_", ",_", "'\\u", "\\u", "cmp", "\\u\\u'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Assert", "ion", "Error_", "(_", "'", "Programm", "ing", " ", "Error", ":", " ", "%", "s", " ", "type", " ", "object", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "doe", "s", " ", "not", " ", "have", " ", "a", " ", "\\u\\u", "cmp", "\\u\\u", " ", "method", " ", "-", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "sorting", " ", "will", " ", "be", " ", "unstable", "'_", "\\u\\u\\uNL\\u\\u\\u_", "%_", "item", "List_", "[_", "0_", "]_", "._", "\\u\\u", "class\\u\\u_", "._", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "item_", "in_", "sorted_", "(_", "item", "Dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "item_", "._", "freeze_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "s_", ")_", ">=_", "(_", "1_", "<<_", "16_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "raise_", "Over", "flow", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "l_", "._", "append_", "(_", "pack_", "._", "pack_", "(_", "\"!", "BS", "H", "\"_", ",_", "type", "Id_", ",_", "s_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\"\"_", "._", "join_", "(_", "l_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stream", "Collection_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "tha", "w_", "(_", "self_", ",_", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "intern", "_", "(_", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "data_", "=_", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stream", "Collection_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "tha", "w_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "tha", "wed", "Items_", "=_", "dict_", "(_", "[_", "(_", "x_", ",_", "{_", "}_", ")_", "for_", "x_", "in_", "self_", "._", "stream", "Dict_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "(_", "i_", "<_", "len_", "(_", "self_", "._", "\\u", "data_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", ",_", "(_", "type", "Id_", ",_", "s_", ")_", "=_", "pack_", "._", "unpack_", "(_", "\"!", "BS", "H", "\"_", ",_", "i_", ",_", "self_", "._", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "item_", "=_", "self_", "._", "stream", "Dict_", "[_", "type", "Id_", "]_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "tha", "wed", "Items_", "[_", "type", "Id_", "]_", "[_", "item_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert_", "(_", "i_", "==_", "len_", "(_", "self_", "._", "\\u", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "data_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stream", "Collection_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "add", "Stream_", "(_", "self_", ",_", "type", "Id_", ",_", "item_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "(_", "item_", "._", "\\u\\u", "class\\u\\u_", "==_", "self_", "._", "stream", "Dict_", "[_", "type", "Id_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "items_", "[_", "type", "Id_", "]_", "[_", "item_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stream", "Collection_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "del", "Stream_", "(_", "self_", ",_", "type", "Id_", ",_", "item_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "\\u", "items_", "[_", "type", "Id_", "]_", "[_", "item_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stream", "Collection_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Stream", "s_", "(_", "self_", ",_", "type", "Id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "items_", "[_", "type", "Id_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stream", "Collection_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "iter", "All_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "type", "Id_", ",_", "item", "Dict_", "in_", "self_", "._", "\\u", "items_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "item", "Dict_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "(_", "type", "Id_", ",_", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stream", "Collection_", "(_", "Info", "Stream_", ")_", ":_", "\\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_", "diff_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "==_", "other_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "\\u", "data_", "is_", "not_", "None_", "and_", "self_", "._", "\\u", "data_", "==_", "other_", "._", "\\u", "data_", ":_", "\\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_", "us_", "=_", "set_", "(_", "self_", "._", "iter", "All_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "them", "_", "=_", "set_", "(_", "other_", "._", "iter", "All_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "added_", "=_", "us_", "-_", "them", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "removed_", "=_", "them", "_", "-_", "us_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "added_", "and_", "not_", "removed_", ":_", "\\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_", "l_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "removed_", ")_", ">=_", "(_", "1_", "<<_", "16_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Over", "flow", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "added_", ")_", ">=_", "(_", "1_", "<<_", "16_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Over", "flow", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "l_", "._", "append_", "(_", "struct_", "._", "pack_", "(_", "\"!", "HH", "\"_", ",_", "len_", "(_", "removed_", ")_", ",_", "len_", "(_", "added_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "type", "Id_", ",_", "item_", "in_", "itertools_", "._", "chain_", "(_", "removed_", ",_", "added_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "item_", "._", "freeze_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "s_", ")_", ">=_", "(_", "1_", "<<_", "16_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Over", "flow", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "l_", "._", "append_", "(_", "struct_", "._", "pack_", "(_", "\"!", "BH", "\"_", ",_", "type", "Id_", ",_", "len_", "(_", "s_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "._", "append_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\"\"_", "._", "join_", "(_", "l_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stream", "Collection_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "tw", "m_", "(_", "self_", ",_", "diff_", ",_", "base_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "(_", "self_", "==_", "base_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "Remove", "d_", ",_", "num", "Added", "_", "=_", "struct_", "._", "unpack_", "(_", "\"!", "HH", "\"_", ",_", "diff_", "[_", "0_", ":_", "4_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "xrange_", "(_", "num", "Remove", "d_", "+_", "num", "Added", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "type", "Id_", ",_", "length_", "=_", "struct_", "._", "unpack_", "(_", "\"!", "BH", "\"_", ",_", "diff_", "[_", "i_", ":_", "i_", "+_", "3_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "+=_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "item_", "=_", "self_", "._", "stream", "Dict_", "[_", "type", "Id_", "]_", "(_", "diff_", "[_", "i_", ":_", "i_", "+_", "length_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "+=_", "length_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "x_", "<_", "num", "Remove", "d_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "del_", "self_", "._", "\\u", "items_", "[_", "type", "Id_", "]_", "[_", "item_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "items_", "[_", "type", "Id_", "]_", "[_", "item_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Stream", "Collection_", "(_", "Info", "Stream_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "data_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "data_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "tha", "w_", "(_", "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 ", " _", "self_", "._", "tha", "w_", "(_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Order", "ed", "Stream", "Collection_", "(_", "Stream", "Collection_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "same", " ", "as", " ", "Stream", "Collecti", "on", ",", " ", "but", " ", "order", "ed", " ", "and", " ", "can", " ", "holder", " ", "bigger", " ", "stuff_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u\\u", "slots\\u\\u_", "=_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Order", "ed", "Stream", "Collection_", "(_", "Stream", "Collection_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "same", " ", "as", " ", "Stream", "Collecti", "on", ",", " ", "but", " ", "order", "ed", " ", "and", " ", "can", " ", "holder", " ", "bigger", " ", "stuff_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "freeze_", "(_", "self_", ",_", "skip", "Set_", "=_", "{_", "}_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "\\u", "data_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "skip", "Set_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "data_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "tha", "w_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "l_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "type", "Id_", ",_", "item", "List_", "in_", "(_", "self_", "._", "\\u", "items_", "._", "iteritems_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "item", "List_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "item_", "._", "freeze_", "(_", "skip", "Set_", "=_", "skip", "Set_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "._", "append_", "(_", "struct_", "._", "pack_", "(_", "'!", "B", "'_", ",_", "type", "Id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "._", "append_", "(_", "pack_", "._", "dynami", "c", "Size_", "(_", "len_", "(_", "s_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "._", "append_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\"\"_", "._", "join_", "(_", "l_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Order", "ed", "Stream", "Collection_", "(_", "Stream", "Collection_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "same", " ", "as", " ", "Stream", "Collecti", "on", ",", " ", "but", " ", "order", "ed", " ", "and", " ", "can", " ", "holder", " ", "bigger", " ", "stuff_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "tha", "w_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "tha", "wed", "Items_", "=_", "dict_", "(_", "[_", "(_", "x_", ",_", "[_", "]_", ")_", "for_", "x_", "in_", "self_", "._", "stream", "Dict_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "while_", "(_", "i_", "<_", "len_", "(_", "self_", "._", "\\u", "data_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", ",_", "(_", "type", "Id_", ",_", "s_", ")_", "=_", "pack_", "._", "unpack_", "(_", "'!", "BD", "'_", ",_", "i_", ",_", "self_", "._", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "item_", "=_", "self_", "._", "stream", "Dict_", "[_", "type", "Id_", "]_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "tha", "wed", "Items_", "[_", "type", "Id_", "]_", "._", "append_", "(_", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "assert_", "(_", "i_", "==_", "len_", "(_", "self_", "._", "\\u", "data_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "data_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Order", "ed", "Stream", "Collection_", "(_", "Stream", "Collection_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "same", " ", "as", " ", "Stream", "Collecti", "on", ",", " ", "but", " ", "order", "ed", " ", "and", " ", "can", " ", "holder", " ", "bigger", " ", "stuff_", "\\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_", "add", "Stream_", "(_", "self_", ",_", "type", "Id_", ",_", "item_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "(_", "item_", "._", "\\u\\u", "class\\u\\u_", "==_", "self_", "._", "stream", "Dict_", "[_", "type", "Id_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "items_", "[_", "type", "Id_", "]_", "._", "append_", "(_", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Order", "ed", "Stream", "Collection_", "(_", "Stream", "Collection_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "same", " ", "as", " ", "Stream", "Collecti", "on", ",", " ", "but", " ", "order", "ed", " ", "and", " ", "can", " ", "holder", " ", "bigger", " ", "stuff_", "\\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_", "del", "Stream_", "(_", "self_", ",_", "type", "Id_", ",_", "item_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l_", "=_", "self_", "._", "\\u", "items_", "[_", "type", "Id_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "l_", "[_", "l_", "._", "index_", "(_", "item_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Order", "ed", "Stream", "Collection_", "(_", "Stream", "Collection_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "same", " ", "as", " ", "Stream", "Collecti", "on", ",", " ", "but", " ", "order", "ed", " ", "and", " ", "can", " ", "holder", " ", "bigger", " ", "stuff_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "Stream", "s_", "(_", "self_", ",_", "type", "Id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u", "items_", "[_", "type", "Id_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Order", "ed", "Stream", "Collection_", "(_", "Stream", "Collection_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "same", " ", "as", " ", "Stream", "Collecti", "on", ",", " ", "but", " ", "order", "ed", " ", "and", " ", "can", " ", "holder", " ", "bigger", " ", "stuff_", "\\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_", "iter", "All_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "type", "Id_", ",_", "l_", "in_", "self_", "._", "\\u", "items_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "item_", "in_", "l_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "(_", "type", "Id_", ",_", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Order", "ed", "Stream", "Collection_", "(_", "Stream", "Collection_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "same", " ", "as", " ", "Stream", "Collecti", "on", ",", " ", "but", " ", "order", "ed", " ", "and", " ", "can", " ", "holder", " ", "bigger", " ", "stuff_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "count_", "(_", "self_", ",_", "type", "Id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "len_", "(_", "self_", "._", "\\u", "items_", "[_", "type", "Id_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Order", "ed", "Stream", "Collection_", "(_", "Stream", "Collection_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "same", " ", "as", " ", "Stream", "Collecti", "on", ",", " ", "but", " ", "order", "ed", " ", "and", " ", "can", " ", "holder", " ", "bigger", " ", "stuff_", "\\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_", "diff_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "(_", "self_", "._", "\\u\\u", "class\\u\\u_", "==_", "other_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "us_", "=_", "set_", "(_", "self_", "._", "iter", "All_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "them", "_", "=_", "set_", "(_", "other_", "._", "iter", "All_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "added_", "=_", "us_", "-_", "them", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "removed_", "=_", "them", "_", "-_", "us_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "added_", "and_", "not_", "removed_", ":_", "\\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_", "l_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "removed_", ")_", ">=_", "(_", "1_", "<<_", "16_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Over", "flow", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "added_", ")_", ">=_", "(_", "1_", "<<_", "16_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Over", "flow", "Error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "l_", "._", "append_", "(_", "struct_", "._", "pack_", "(_", "\"!", "HH", "\"_", ",_", "len_", "(_", "removed_", ")_", ",_", "len_", "(_", "added_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "type", "Id_", ",_", "item_", "in_", "removed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "item_", "._", "freeze_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "._", "append_", "(_", "struct_", "._", "pack_", "(_", "'!", "B", "'_", ",_", "type", "Id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "._", "append_", "(_", "pack_", "._", "dynami", "c", "Size_", "(_", "len_", "(_", "s_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "._", "append_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "make", " ", "sure", " ", "the", " ", "additions", " ", "are", " ", "ordered_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "type", "Id_", ",_", "item_", "in_", "self_", "._", "iter", "All_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "type", "Id_", ",_", "item_", ")_", "in_", "added_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "item_", "._", "freeze_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "._", "append_", "(_", "struct_", "._", "pack_", "(_", "'!", "B", "'_", ",_", "type", "Id_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "._", "append_", "(_", "pack_", "._", "dynami", "c", "Size_", "(_", "len_", "(_", "s_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l_", "._", "append_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "\"\"_", "._", "join_", "(_", "l_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Order", "ed", "Stream", "Collection_", "(_", "Stream", "Collection_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "same", " ", "as", " ", "Stream", "Collecti", "on", ",", " ", "but", " ", "order", "ed", " ", "and", " ", "can", " ", "holder", " ", "bigger", " ", "stuff_", "\\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_", "tw", "m_", "(_", "self_", ",_", "diff_", ",_", "base_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "(_", "self_", "==_", "base_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "Remove", "d_", ",_", "num", "Added", "_", "=_", "struct_", "._", "unpack_", "(_", "\"!", "HH", "\"_", ",_", "diff_", "[_", "0_", ":_", "4_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "i_", "=_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "x_", "in_", "xrange_", "(_", "num", "Remove", "d_", "+_", "num", "Added", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "i_", ",_", "(_", "type", "Id_", ",_", "s_", ")_", "=_", "pack_", "._", "unpack_", "(_", "\"!", "BD", "\"_", ",_", "i_", ",_", "diff_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "item_", "=_", "self_", "._", "stream", "Dict_", "[_", "type", "Id_", "]_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "x_", "<_", "num", "Remove", "d_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "l_", "=_", "self_", "._", "\\u", "items_", "[_", "type", "Id_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "del_", "l_", "[_", "l_", "._", "index_", "(_", "item_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "items_", "[_", "type", "Id_", "]_", "._", "append_", "(_", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Order", "ed", "Stream", "Collection_", "(_", "Stream", "Collection_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "same", " ", "as", " ", "Stream", "Collecti", "on", ",", " ", "but", " ", "order", "ed", " ", "and", " ", "can", " ", "holder", " ", "bigger", " ", "stuff_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "data_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "data_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "tha", "w_", "(_", "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 ", " _", "self_", "._", "\\u", "data_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "tha", "wed", "Items_", "=_", "dict_", "(_", "[_", "(_", "x_", ",_", "[_", "]_", ")_", "for_", "x_", "in_", "self_", "._", "stream", "Dict_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 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,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2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
asterisk/ari-py/ari/__init__.py
[ { "content": "#\n# Copyright (c) 2013, Digium, Inc.\n#\n\n\"\"\"ARI client library\n\"\"\"\n\nimport ari.client\nimport swaggerpy.http_client\nimport urlparse\n\nClient = client.Client\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def connect(base_url, username, password):\n \"\"\"Helper method for easily connecting to ARI.\n\n :param base_url: Base URL for Asterisk HTTP server (http://localhost:8088/)\n :param username: ARI username\n :param password: ARI password.\n :return:\n \"\"\"\n split = urlparse.urlsplit(base_url)\n http_client = swaggerpy.http_client.SynchronousHttpClient()\n http_client.set_basic_auth(split.hostname, username, password)\n return Client(base_url, http_client)", "metadata": "root.connect", "header": "['module', '___EOS___']", "index": 14 } ]
[ { "span": "import ari.client", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 17 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Copy", "right", " ", "(", "c", ")", " ", "2013", ",", " ", "Dig", "ium", ",", " ", "Inc", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "ARI", " ", "client", " ", "librar", "y", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "ari", "_", "._", "client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "swa", "gger", "py_", "._", "http", "\\u", "client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "urlparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Client_", "=_", "client_", "._", "Client_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "connect_", "(_", "base", "\\u", "url_", ",_", "username_", ",_", "password_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Help", "er", " ", "method", " ", "for", " ", "easi", "ly", " ", "connecti", "ng", " ", "to", " ", "ARI", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "base", "\\u", "url", ":", " ", "Base", " ", "URL", " ", "for", " ", "Ast", "eris", "k", " ", "HTTP", " ", "server", " ", "(", "http", "://", "local", "host", ":", "808", "8", "/)", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "user", "name", ":", " ", "ARI", " ", "user", "name", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "password", ":", " ", "ARI", " ", "password", ".", "\\", "10", ";", " ", " ", " ", " ", ":", "return", ":", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "split_", "=_", "urlparse_", "._", "urlsplit_", "(_", "base", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http", "\\u", "client_", "=_", "swa", "gger", "py_", "._", "http", "\\u", "client_", "._", "Synchro", "nous", "Http", "Client_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "http", "\\u", "client_", "._", "set\\u", "basic", "\\u", "auth_", "(_", "split_", "._", "hostname_", ",_", "username_", ",_", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Client_", "(_", "base", "\\u", "url_", ",_", "http", "\\u", "client_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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'
srob650/pytvmaze/pytvmaze/tvmaze.py
[ { "content": "def _query_endpoint(url):\n try:\n data = urlopen(url).read()\n except HTTPError as e:\n if e.code in [404, 422]:\n return None\n elif e.code == 400:\n raise BadRequest(e.reason + ' ' + str(e.code) + ' ' + e.url)\n except URLError as e:\n raise ConnectionError(repr(e))\n\n try:\n results = json.loads(data)\n except:\n results = json.loads(data.decode('utf8'))\n\n if results:\n return results\n else:\n return None", "metadata": "root._query_endpoint", "header": "['module', '___EOS___']", "index": 360 } ]
[ { "span": "except:", "start_line": 373, "start_column": 4, "end_line": 373, "end_column": 11 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "query", "\\u", "endpoint_", "(_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", "=_", "urlopen_", "(_", "url_", ")_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "HTTP", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "e_", "._", "code_", "in_", "[_", "404_", ",_", "422_", "]_", ":_", "\\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_", "elif_", "e_", "._", "code_", "==_", "400_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Ba", "d", "Request_", "(_", "e_", "._", "reason_", "+_", "'", " ", "'_", "+_", "str_", "(_", "e_", "._", "code_", ")_", "+_", "'", " ", "'_", "+_", "e_", "._", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "URL", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Connect", "ion", "Error_", "(_", "repr_", "(_", "e_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "results_", "=_", "json_", "._", "loads_", "(_", "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 ", " _", "results_", "=_", "json_", "._", "loads_", "(_", "data_", "._", "decode_", "(_", "'", "utf", "8", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "results_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "results_", "\\u\\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_" ]
[ 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, 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 ]
Unused import
roglew/pappy-proxy/pappyproxy/schema/schema_6.py
[ { "content": "import time\nimport datetime\nfrom pappyproxy import http\nfrom twisted.internet import defer\n\n\"\"\"\nSchema v6\n\nDescription:\nReplaces the string representation of times with unix times so that we can select\nby most recent first. Also deletes old tag column.\n\"\"\"\n\nupdate_queries = [\n \"\"\"\n CREATE TABLE requests_new (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n full_request BLOB NOT NULL,\n submitted INTEGER NOT NULL,\n response_id INTEGER REFERENCES responses(id),\n unmangled_id INTEGER REFERENCES requests(id),\n port INTEGER,\n is_ssl INTEGER,\n host TEXT,\n plugin_data TEXT,\n start_datetime REAL,\n end_datetime REAL\n );\n \"\"\",\n\n \"\"\"\n INSERT INTO requests_new (id, full_request, submitted, response_id, unmangled_id, port, is_ssl, host, plugin_data) SELECT id, full_request, submitted, response_id, unmangled_id, port, is_ssl, host, plugin_data FROM requests;\n \"\"\",\n]\n\ndrop_queries = [\n \"\"\"\n DROP TABLE requests;\n \"\"\",\n\n \"\"\"\n ALTER TABLE requests_new RENAME TO requests;\n \"\"\"\n]\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "@defer.inlineCallbacks\ndef update(dbpool):\n for query in update_queries:\n yield dbpool.runQuery(query)\n reqrows = yield dbpool.runQuery(\n \"\"\"\n SELECT id, start_datetime, end_datetime\n FROM requests;\n \"\"\",\n )\n\n new_times = []\n \n for row in reqrows:\n reqid = row[0]\n if row[1]:\n start_datetime = datetime.datetime.strptime(row[1], \"%Y-%m-%dT%H:%M:%S.%f\")\n start_unix_time = time.mktime(start_datetime.timetuple())\n else:\n start_unix_time = None\n if row[2]:\n end_datetime = datetime.datetime.strptime(row[2], \"%Y-%m-%dT%H:%M:%S.%f\")\n end_unix_time = time.mktime(end_datetime.timetuple())\n else:\n end_unix_time = None\n new_times.append((reqid, start_unix_time, end_unix_time))\n\n for reqid, start_unix_time, end_unix_time in new_times:\n yield dbpool.runQuery(\n \"\"\"\n UPDATE requests_new SET start_datetime=?, end_datetime=? WHERE id=?;\n \"\"\", (start_unix_time, end_unix_time, reqid)\n )\n\n for query in drop_queries:\n yield dbpool.runQuery(query)\n\n yield dbpool.runQuery(\n \"\"\"\n UPDATE schema_meta SET version=6;\n \"\"\"\n )", "metadata": "root.update", "header": "['module', '___EOS___']", "index": 45 } ]
[ { "span": "from pappyproxy import http", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 27 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pap", "pypr", "oxy", "_", "import_", "http_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "twisted_", "._", "internet_", "import_", "defer_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Schema", " ", "v6", "\\", "10", ";", "\\", "10", ";", "Descripti", "on", ":", "\\", "10", ";", "Replace", "s", " ", "the", " ", "string", " ", "represent", "ation", " ", "of", " ", "times", " ", "with", " ", "unix", " ", "times", " ", "so", " ", "tha", "t", " ", "we", " ", "can", " ", "select", "\\", "10", ";", "by", " ", "most", " ", "recent", " ", "first", ".", " ", "Al", "so", " ", "delete", "s", " ", "old", " ", "tag", " ", "column", ".", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "update", "\\u", "queries_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "CREATE", " ", "TAB", "LE", " ", "request", "s", "\\u", "new", " ", "(", "\\", "10", ";", " ", " ", " ", " ", "id", " ", " ", " ", " ", "INTEG", "ER", " ", " ", " ", "PRIMA", "RY", " ", "KEY", " ", " ", "AUTO", "INCREMENT", ",", "\\", "10", ";", " ", " ", " ", " ", "full", "\\u", "request", " ", " ", "BLOB", " ", " ", "NOT", " ", "NULL", ",", "\\", "10", ";", " ", " ", " ", " ", "submitted", " ", " ", " ", " ", " ", "INTEG", "ER", " ", " ", " ", "NOT", " ", "NULL", ",", "\\", "10", ";", " ", " ", " ", " ", "response", "\\u", "id", " ", " ", " ", "INTEG", "ER", " ", " ", " ", "REFERENCE", "S", " ", "response", "s", "(", "id", "),", "\\", "10", ";", " ", " ", " ", " ", "unma", "ngle", "d\\u", "id", " ", " ", "INTEG", "ER", " ", " ", " ", "REFERENCE", "S", " ", "request", "s", "(", "id", "),", "\\", "10", ";", " ", " ", " ", " ", "port", " ", " ", " ", " ", " ", " ", "INTEG", "ER", ",", "\\", "10", ";", " ", " ", " ", " ", "is", "\\u", "ssl", " ", " ", " ", " ", "INTEG", "ER", ",", "\\", "10", ";", " ", " ", " ", " ", "host", " ", " ", " ", " ", " ", " ", "TEXT", ",", "\\", "10", ";", " ", " ", " ", " ", "plugin", "\\u", "data", " ", " ", " ", "TEXT", ",", "\\", "10", ";", " ", " ", " ", " ", "start", "\\u", "datetime", " ", " ", " ", " ", "REAL", ",", "\\", "10", ";", " ", " ", " ", " ", "end", "\\u", "datetime", " ", " ", "REAL", "\\", "10", ";", " ", " ", " ", " ", ");", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "INSERT", " ", "INT", "O", " ", "request", "s", "\\u", "new", " ", "(", "id", ",", " ", "full", "\\u", "request", ",", " ", "submitted", ",", " ", "response", "\\u", "id", ",", " ", "unma", "ngle", "d\\u", "id", ",", " ", "port", ",", " ", "is", "\\u", "ssl", ",", " ", "host", ",", " ", "plugin", "\\u", "data", ")", " ", "SELECT", " ", "id", ",", " ", "full", "\\u", "request", ",", " ", "submitted", ",", " ", "response", "\\u", "id", ",", " ", "unma", "ngle", "d\\u", "id", ",", " ", "port", ",", " ", "is", "\\u", "ssl", ",", " ", "host", ",", " ", "plugin", "\\u", "data", " ", "FROM", " ", "request", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "drop", "\\u", "queries_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "DROP", " ", "TAB", "LE", " ", "request", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "ALT", "ER", " ", "TAB", "LE", " ", "request", "s", "\\u", "new", " ", "RENA", "ME", " ", "TO", " ", "request", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\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_", "@_", "defer_", "._", "inline", "Callbacks_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "update_", "(_", "dbp", "ool_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "query_", "in_", "update", "\\u", "queries_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "dbp", "ool_", "._", "run", "Query_", "(_", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "req", "rows_", "=_", "yield_", "dbp", "ool_", "._", "run", "Query_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "SELECT", " ", "id", ",", " ", "start", "\\u", "datetime", ",", " ", "end", "\\u", "datetime", "\\", "10", ";", " ", " ", " ", " ", "FROM", " ", "request", "s", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "new", "\\u", "times_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "row_", "in_", "req", "rows_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "req", "id_", "=_", "row_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "row_", "[_", "1_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "start", "\\u", "datetime_", "=_", "datetime_", "._", "datetime_", "._", "strptime_", "(_", "row_", "[_", "1_", "]_", ",_", "\"%", "Y", "-%", "m", "-%", "d", "T", "%", "H", ":", "%", "M", ":", "%", "S", ".", "%", "f", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start", "\\u", "unix", "\\u", "time_", "=_", "time_", "._", "mktime_", "(_", "start", "\\u", "datetime_", "._", "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 ", " _", "start", "\\u", "unix", "\\u", "time_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "row_", "[_", "2_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "end", "\\u", "datetime_", "=_", "datetime_", "._", "datetime_", "._", "strptime_", "(_", "row_", "[_", "2_", "]_", ",_", "\"%", "Y", "-%", "m", "-%", "d", "T", "%", "H", ":", "%", "M", ":", "%", "S", ".", "%", "f", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "end", "\\u", "unix", "\\u", "time_", "=_", "time_", "._", "mktime_", "(_", "end", "\\u", "datetime_", "._", "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 ", " _", "end", "\\u", "unix", "\\u", "time_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new", "\\u", "times_", "._", "append_", "(_", "(_", "req", "id_", ",_", "start", "\\u", "unix", "\\u", "time_", ",_", "end", "\\u", "unix", "\\u", "time_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "req", "id_", ",_", "start", "\\u", "unix", "\\u", "time_", ",_", "end", "\\u", "unix", "\\u", "time_", "in_", "new", "\\u", "times_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "dbp", "ool_", "._", "run", "Query_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "UPDATE", " ", "request", "s", "\\u", "new", " ", "SET", " ", "start", "\\u", "datetime", "=?", ",", " ", "end", "\\u", "datetime", "=?", " ", "WHE", "RE", " ", "id", "=?", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", ",_", "(_", "start", "\\u", "unix", "\\u", "time_", ",_", "end", "\\u", "unix", "\\u", "time_", ",_", "req", "id_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "query_", "in_", "drop", "\\u", "queries_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "yield_", "dbp", "ool_", "._", "run", "Query_", "(_", "query_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "yield_", "dbp", "ool_", "._", "run", "Query_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "UPDATE", " ", "schema", "\\u", "meta", " ", "SET", " ", "version", "=", "6", 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
glue-viz/glue/glue/core/qt/data_collection_model.py
[ { "content": " def set_selected_layers(self, layers):\n sm = self.selectionModel()\n idxs = self._model.to_indices(layers)\n self.select_indices(*idxs)", "metadata": "root.DataCollectionView.set_selected_layers", "header": "['class', 'DataCollectionView', '(', 'QtGui', '.', 'QTreeView', ')', ':', '___EOS___']", "index": 479 } ]
[ { "span": "sm ", "start_line": 480, "start_column": 8, "end_line": 480, "end_column": 10 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Data", "Collecti", "on", "View_", "(_", "Qt", "Gui_", "._", "QT", "ree", "View_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "set\\u", "selecte", "d\\u", "layers_", "(_", "self_", ",_", "layers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sm_", "=_", "self_", "._", "selection", "Model_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "idxs_", "=_", "self_", "._", "\\u", "model_", "._", "to", "\\u", "indices_", "(_", "layers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "select", "\\u", "indices_", "(_", "*_", "idxs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
pingali/dgit/dgitcore/datasets/common.py
[ { "content": "#!/usr/bin/env python\n\"\"\"\nThis is the core module for manipulating the dataset metadata\n\"\"\"\nimport os, sys, copy, fnmatch, re, shutil\nimport yaml, json, tempfile, mimetypes\nimport webbrowser, traceback, collections\nimport subprocess, string, random, pipes\nfrom collections import OrderedDict\nimport shelve, getpass\nfrom datetime import datetime\nfrom hashlib import sha256\nimport mimetypes\nimport platform\nimport uuid, shutil\nimport boto3, glob2\nimport subprocess\nfrom dateutil import parser\ntry:\n from urllib.parse import urlparse\nexcept:\n from urlparse import urlparse\nfrom ..config import get_config\nfrom ..plugins.common import plugins_get_mgr\nfrom ..helper import bcolors, clean_str, cd, compute_sha256, run, clean_name, log_repo_action \nfrom ..exceptions import *\nfrom .history import get_history, get_diffs\nfrom .validation import validate\n\n#####################################################\n# Exports\n#####################################################\n\n__all__ = [\n 'lookup',\n 'list_repos',\n 'shellcmd',\n 'log', 'show', 'push', 'pull', 'commit',\n 'stash', 'drop', 'status', 'post',\n 'clone', 'init', 'diff',\n 'remote', 'delete'\n]\n\n#####################################################\n# Repo independent commands...\n#####################################################\n\n\n\n#####################################################\n# Repo specific generic commands\n#####################################################\n\n\n\n#####################################################\n# Repo specific simple commands\n#####################################################\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n#####################################################\n# Initialize a repo\n#####################################################\n\n\n\n\n\n###########################################################\n# Post metadata to a server\n###########################################################\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def annotate_metadata_action(repo):\n \"\"\"\n Update metadata with the action history \n \"\"\"\n package = repo.package \n\n print(\"Including history of actions\")\n with cd(repo.rootdir): \n filename = \".dgit/log.json\" \n if os.path.exists(filename): \n history = open(filename).readlines() \n actions = []\n for a in history: \n try: \n a = json.loads(a)\n for x in ['code']: \n if x not in a or a[x] == None: \n a[x] = \"...\"\n actions.append(a)\n except:\n pass \n package['actions'] = actions", "metadata": "root.annotate_metadata_action", "header": "['module', '___EOS___']", "index": 516 }, { "content": "def annotate_metadata_dependencies(repo):\n \"\"\"\n Collect information from the dependent repo's\n \"\"\"\n\n options = repo.options\n\n if 'dependencies' not in options:\n print(\"No dependencies\")\n return []\n\n repos = []\n dependent_repos = options['dependencies']\n for d in dependent_repos:\n if \"/\" not in d:\n print(\"Invalid dependency specification\")\n (username, reponame) = d.split(\"/\")\n try:\n repos.append(repo.manager.lookup(username, reponame))\n except:\n print(\"Repository does not exist. Please create one\", d)\n\n package = repo.package\n package['dependencies'] = []\n for r in repos:\n package['dependencies'].append({\n 'username': r.username,\n 'reponame': r.reponame,\n })", "metadata": "root.annotate_metadata_dependencies", "header": "['module', '___EOS___']", "index": 573 } ]
[ { "span": "except:", "start_line": 20, "start_column": 0, "end_line": 20, "end_column": 7 }, { "span": "except:", "start_line": 535, "start_column": 16, "end_line": 535, "end_column": 23 }, { "span": "except:", "start_line": 592, "start_column": 8, "end_line": 592, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "\\", "10", ";", "Thi", "s", " ", "is", " ", "the", " ", "core", " ", "module", " ", "for", " ", "manipulati", "ng", " ", "the", " ", "dataset", " ", "metadata", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", ",_", "sys_", ",_", "copy_", ",_", "fnmatch_", ",_", "re_", ",_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "yaml_", ",_", "json_", ",_", "tempfile_", ",_", "mimetypes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "webbrowser_", ",_", "traceback_", ",_", "collections_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "subprocess_", ",_", "string_", ",_", "random_", ",_", "pipes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "collections_", "import_", "Order", "ed", "Dict_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "shelve", "_", ",_", "getpass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "datetime_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "hashlib_", "import_", "sha256_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "mimetypes_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "platform_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "uuid_", ",_", "shutil_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "boto3_", ",_", "glob", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "subprocess_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "dateutil_", "import_", "parser_", "\\u\\u\\uNEWLINE\\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_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "urlparse_", "import_", "urlparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "._", "._", "config_", "import_", "get", "\\u", "config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "._", "plugins_", "._", "common_", "import_", "plugin", "s", "\\u", "get", "\\u", "mgr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "._", "helper_", "import_", "bcolors_", ",_", "clean", "\\u", "str_", ",_", "cd_", ",_", "compute", "\\u", "sha256_", ",_", "run_", ",_", "clean", "\\u", "name_", ",_", "log", "\\u", "repo", "\\u", "action_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "._", "exceptions_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "history_", "import_", "get", "\\u", "history_", ",_", "get", "\\u", "diffs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "._", "validation_", "import_", "validate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "#########", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Export", "s_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "#########", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "all\\u\\u_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "look", "up", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "list", "\\u", "repos", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "shellc", "md", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "log", "'_", ",_", "'", "show", "'_", ",_", "'", "push", "'_", ",_", "'", "pull", "'_", ",_", "'", "commit", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "stash", "'_", ",_", "'", "drop", "'_", ",_", "'", "status", "'_", ",_", "'", "post", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "clone", "'_", ",_", "'", "init", "'_", ",_", "'", "diff", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "remote", "'_", ",_", "'", "delete", "'_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "#########", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Rep", "o", " ", "independent", " ", "command", "s", "..._", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "#########", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "#########", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Rep", "o", " ", "specific", " ", "gener", "ic", " ", "commands_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "#########", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "#########", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Rep", "o", " ", "specific", " ", "simple", " ", "commands_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "#########", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "#########", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Initializ", "e", " ", "a", " ", "repo_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "#########", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "###########", "###########", "###########", "###########", "###########", "###", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Post", " ", "metadata", " ", "to", " ", "a", " ", "server_", "\\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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "annot", "ate", "\\u", "metadata", "\\u", "action_", "(_", "repo_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Update", " ", "metadata", " ", "with", " ", "the", " ", "action", " ", "histo", "ry", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "package_", "=_", "repo_", "._", "package_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Includi", "ng", " ", "histo", "ry", " ", "of", " ", "action", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "cd_", "(_", "repo_", "._", "rootdir_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "filename_", "=_", "\".", "dg", "it", "/", "log", ".", "json", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "filename_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "history_", "=_", "open_", "(_", "filename_", ")_", "._", "readlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "actions_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "a_", "in_", "history_", ":_", "\\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 ", " ", "_", "a_", "=_", "json_", "._", "loads_", "(_", "a_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "x_", "in_", "[_", "'", "code", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "if_", "x_", "not_", "in_", "a_", "or_", "a_", "[_", "x_", "]_", "==_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "a_", "[_", "x_", "]_", "=_", "\"...\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "actions_", "._", "append_", "(_", "a_", ")_", "\\u\\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_", "package_", "[_", "'", "action", "s", "'_", "]_", "=_", "actions_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "annot", "ate", "\\u", "metadata", "\\u", "dependencies_", "(_", "repo_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Collect", " ", "informati", "on", " ", "from", " ", "the", " ", "dependent", " ", "repo", "'", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "options_", "=_", "repo_", "._", "options_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "dependen", "cies", "'_", "not_", "in_", "options_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "No", " ", "dependen", "cies", "\"_", ")_", "\\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_", "repos_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dependent", "\\u", "repos_", "=_", "options_", "[_", "'", "dependen", "cies", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "d_", "in_", "dependent", "\\u", "repos_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "\"/\"_", "not_", "in_", "d_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "(_", "\"", "Inva", "lid", " ", "dependen", "cy", " ", "specifica", "tion", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "(_", "username_", ",_", "repon", "ame_", ")_", "=_", "d_", "._", "split_", "(_", "\"/\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "repos_", "._", "append_", "(_", "repo_", "._", "manager_", "._", "lookup_", "(_", "username_", ",_", "repon", "ame_", ")_", ")_", "\\u\\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_", "(_", "\"", "Repos", "itor", "y", " ", "doe", "s", " ", "not", " ", "exist", ".", " ", "Ple", "ase", " ", "create", " ", "one", "\"_", ",_", "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_", "package_", "=_", "repo_", "._", "package_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "package_", "[_", "'", "dependen", "cies", "'_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "r_", "in_", "repos_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "package_", "[_", "'", "dependen", "cies", "'_", "]_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "user", "name", "'_", ":_", "r_", "._", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "repon", "ame", "'_", ":_", "r_", "._", "repon", "ame_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\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, 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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, 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 ]
Unused import
enthought/traitsui/traitsui/tests/editors/test_tree_editor.py
[ { "content": "#------------------------------------------------------------------------------\n#\n# Copyright (c) 2012, Enthought, Inc.\n# All rights reserved.\n#\n# This software is provided without warranty under the terms of the BSD\n# license included in enthought/LICENSE.txt and may be redistributed only\n# under the conditions described in the aforementioned license. The license\n# is also available online at http://www.enthought.com/licenses/BSD.txt\n#\n# Author: Pietro Berkes\n# Date: Dec 2012\n#\n#------------------------------------------------------------------------------\n\n\nfrom traits.api import Bool, HasTraits, Instance, Int, List\nfrom traitsui.api import Item, TreeEditor, TreeNode, View\n\nfrom traitsui.tests._tools import *\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class Bogus(HasTraits):\n \"\"\" A bogus class representing a bogus tree. \"\"\"\n\n bogus_list = List", "metadata": "root.Bogus", "header": "['module', '___EOS___']", "index": 22 }, { "content": "class BogusTreeView(HasTraits):\n \"\"\" A traitsui view visualizing Bogus objects as trees. \"\"\"\n\n bogus = Instance(Bogus)\n\n hide_root = Bool\n", "metadata": "root.BogusTreeView", "header": "['module', '___EOS___']", "index": 28 }, { "content": " def default_traits_view(self):\n nodes = [\n TreeNode(node_for=[Bogus], children='bogus_list', label='=Bogus'),\n ]\n\n tree_editor = TreeEditor(\n nodes=nodes, hide_root=self.hide_root, editable=False\n )\n\n traits_view = View(\n Item(name='bogus', id='engine', editor=tree_editor),\n buttons = ['OK'],\n )\n\n return traits_view", "metadata": "root.BogusTreeView.default_traits_view", "header": "['class', 'BogusTreeView', '(', 'HasTraits', ')', ':', '___EOS___']", "index": 35 }, { "content": "def _test_tree_editor_releases_listeners(hide_root):\n \"\"\" The TreeEditor should release the listener to the root node's children\n when it's disposed of.\n \"\"\"\n\n with store_exceptions_on_all_threads():\n bogus = Bogus(bogus_list=[Bogus()])\n tree_editor_view = BogusTreeView(bogus=bogus, hide_root=hide_root)\n ui = tree_editor_view.edit_traits()\n\n # The TreeEditor sets a listener on the bogus object's children list\n notifiers_list = bogus.trait('bogus_list')._notifiers(False)\n nose.tools.assert_equal(1, len(notifiers_list))\n\n # Manually close the UI\n press_ok_button(ui)\n\n # The listener should be removed after the UI has been closed\n notifiers_list = bogus.trait('bogus_list')._notifiers(False)\n nose.tools.assert_equal(0, len(notifiers_list))", "metadata": "root._test_tree_editor_releases_listeners", "header": "['module', '___EOS___']", "index": 52 }, { "content": "@skip_if_null\ndef test_tree_editor_listeners_with_shown_root():\n _test_tree_editor_releases_listeners(hide_root=False)", "metadata": "root.test_tree_editor_listeners_with_shown_root", "header": "['module', '___EOS___']", "index": 74 }, { "content": "@skip_if_null\ndef test_tree_editor_listeners_with_hidden_root():\n _test_tree_editor_releases_listeners(hide_root=True)", "metadata": "root.test_tree_editor_listeners_with_hidden_root", "header": "['module', '___EOS___']", "index": 79 } ]
[ { "span": "from traits.api import Bool, HasTraits, Instance, Int, List", "start_line": 16, "start_column": 0, "end_line": 16, "end_column": 59 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "-------", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Copy", "right", " ", "(", "c", ")", " ", "2012", ",", " ", "Ent", "hou", "ght", ",", " ", "Inc", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "All", " ", "rights", " ", "reserve", "d", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Thi", "s", " ", "software", " ", "is", " ", "provided", " ", "with", "out", " ", "warr", "ant", "y", " ", "under", " ", "the", " ", "term", "s", " ", "of", " ", "the", " ", "BS", "D_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "license", " ", "include", "d", " ", "in", " ", "enth", "ou", "ght", "/", "LICENSE", ".", "txt", " ", "and", " ", "may", " ", "be", " ", "redis", "tribut", "ed", " ", "only_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "under", " ", "the", " ", "condition", "s", " ", "descri", "bed", " ", "in", " ", "the", " ", "af", "ore", "mentioned", " ", "license", ".", " ", " ", "The", " ", "license_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "is", " ", "als", "o", " ", "avail", "able", " ", "onli", "ne", " ", "at", " ", "http", "://", "www", ".", "enth", "ou", "ght", ".", "com", "/", "license", "s", "/", "BS", "D", ".", "txt_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Author", ":", " ", "Pie", "tro", " ", "Ber", "kes", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", "Date", ":", " ", " ", " ", "De", "c", " ", "2012_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#-", "--------------", "--------------", "--------------", "--------------", "--------------", "-------", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "traits_", "._", "api_", "import_", "Bool_", ",_", "Has", "Trait", "s_", ",_", "Instance_", ",_", "Int_", ",_", "List_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "traits", "ui_", "._", "api_", "import_", "Item_", ",_", "Tree", "Editor_", ",_", "Tree", "Node_", ",_", "View_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "traits", "ui_", "._", "tests_", "._", "\\u", "tools_", "import_", "*_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "Bo", "gus", "_", "(_", "Has", "Trait", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "A", " ", "bog", "us", " ", "class", " ", "represent", "ing", " ", "a", " ", "bog", "us", " ", "tree", ".", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bog", "us", "\\u", "list_", "=_", "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_", "class_", "Bo", "gus", "Tree", "View_", "(_", "Has", "Trait", "s_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "A", " ", "traits", "ui", " ", "view", " ", "visuali", "zin", "g", " ", "Bo", "gus", " ", "object", "s", " ", "as", " ", "trees", ".", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bog", "us_", "=_", "Instance_", "(_", "Bo", "gus", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "hide", "\\u", "root_", "=_", "Bool_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Bo", "gus", "Tree", "View_", "(_", "Has", "Trait", "s_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "default", "\\u", "traits", "\\u", "view_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "nodes_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "Tree", "Node_", "(_", "node", "\\u", "for_", "=_", "[_", "Bo", "gus", "_", "]_", ",_", "children_", "=_", "'", "bog", "us", "\\u", "list", "'_", ",_", "label_", "=_", "'=", "Bo", "gus", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "tree", "\\u", "editor_", "=_", "Tree", "Editor_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "nodes_", "=_", "nodes_", ",_", "hide", "\\u", "root_", "=_", "self_", "._", "hide", "\\u", "root_", ",_", "editable_", "=_", "False_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "traits", "\\u", "view_", "=_", "View_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Item_", "(_", "name_", "=_", "'", "bog", "us", "'_", ",_", "id_", "=_", "'", "eng", "ine", "'_", ",_", "editor_", "=_", "tree", "\\u", "editor_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "buttons_", "=_", "[_", "'", "OK", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "traits", "\\u", "view_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\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", "test\\u", "tree", "\\u", "editor", "\\u", "release", "s", "\\u", "listeners_", "(_", "hide", "\\u", "root_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "The", " ", "Tree", "Edit", "or", " ", "shou", "ld", " ", "release", " ", "the", " ", "listen", "er", " ", "to", " ", "the", " ", "root", " ", "node", "'", "s", " ", "child", "ren", "\\", "10", ";", " ", " ", " ", " ", "whe", "n", " ", "it", "'", "s", " ", "dispose", "d", " ", "of", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "with_", "store", "\\u", "exception", "s", "\\u", "on", "\\u", "all", "\\u", "threads_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bog", "us_", "=_", "Bo", "gus", "_", "(_", "bog", "us", "\\u", "list_", "=_", "[_", "Bo", "gus", "_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tree", "\\u", "editor", "\\u", "view_", "=_", "Bo", "gus", "Tree", "View_", "(_", "bog", "us_", "=_", "bog", "us_", ",_", "hide", "\\u", "root_", "=_", "hide", "\\u", "root_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ui_", "=_", "tree", "\\u", "editor", "\\u", "view_", "._", "edit", "\\u", "traits_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "Tree", "Edit", "or", " ", "sets", " ", "a", " ", "listen", "er", " ", "on", " ", "the", " ", "bog", "us", " ", "object", "'", "s", " ", "child", "ren", " ", "list_", "\\u\\u\\uNL\\u\\u\\u_", "notifier", "s", "\\u", "list_", "=_", "bog", "us_", "._", "trait_", "(_", "'", "bog", "us", "\\u", "list", "'_", ")_", "._", "\\u", "notifier", "s_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nose_", "._", "tools_", "._", "assert", "\\u", "equal_", "(_", "1_", ",_", "len_", "(_", "notifier", "s", "\\u", "list_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Manu", "ally", " ", "close", " ", "the", " ", "UI_", "\\u\\u\\uNL\\u\\u\\u_", "press", "\\u", "ok", "\\u", "button_", "(_", "ui_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "listen", "er", " ", "shou", "ld", " ", "be", " ", "remove", "d", " ", "after", " ", "the", " ", "UI", " ", "has", " ", "bee", "n", " ", "closed_", "\\u\\u\\uNL\\u\\u\\u_", "notifier", "s", "\\u", "list_", "=_", "bog", "us_", "._", "trait_", "(_", "'", "bog", "us", "\\u", "list", "'_", ")_", "._", "\\u", "notifier", "s_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nose_", "._", "tools_", "._", "assert", "\\u", "equal_", "(_", "0_", ",_", "len_", "(_", "notifier", "s", "\\u", "list_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "skip", "\\u", "if", "\\u", "null_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "tree", "\\u", "editor", "\\u", "listeners", "\\u", "with", "\\u", "shown", "\\u", "root_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "test\\u", "tree", "\\u", "editor", "\\u", "release", "s", "\\u", "listeners_", "(_", "hide", "\\u", "root_", "=_", "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_", "@_", "skip", "\\u", "if", "\\u", "null_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "tree", "\\u", "editor", "\\u", "listeners", "\\u", "with", "\\u", "hidden", "\\u", "root_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "test\\u", "tree", "\\u", "editor", "\\u", "release", "s", "\\u", "listeners_", "(_", "hide", "\\u", "root_", "=_", "True_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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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2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Module is imported more than once
codeupstudio/chipincode/controllers/appadmin.py
[ { "content": "# -*- coding: utf-8 -*-\n\n# ##########################################################\n# ## make sure administrator is on localhost\n# ###########################################################\n\nimport os\nimport socket\nimport datetime\nimport copy\nimport gluon.contenttype\nimport gluon.fileutils\n\nresponse.subtitle = 'Database Administration (appadmin)'\n\n# ## critical --- make a copy of the environment\n\nglobal_env = copy.copy(globals())\nglobal_env['datetime'] = datetime\n\nhttp_host = request.env.http_host.split(':')[0]\nremote_addr = request.env.remote_addr\ntry:\n hosts = (http_host, socket.gethostname(),\n socket.gethostbyname(http_host),\n '::1', '127.0.0.1', '::ffff:127.0.0.1')\nexcept:\n hosts = (http_host, )\n\nif request.env.http_x_forwarded_for or request.is_https:\n session.secure()\nelif (remote_addr not in hosts) and (remote_addr != \"127.0.0.1\"):\n raise HTTP(200, T('appadmin is disabled because insecure channel'))\n\nif (request.application == 'admin' and not session.authorized) or \\\n (request.application != 'admin' and not gluon.fileutils.check_credentials(request)):\n redirect(URL('admin', 'default', 'index',\n vars=dict(send=URL(args=request.args, vars=request.vars))))\n\nignore_rw = True\nresponse.view = 'appadmin.html'\nresponse.menu = [[T('design'), False, URL('admin', 'default', 'design',\n args=[request.application])], [T('db'), False,\n URL('index')], [T('state'), False,\n URL('state')], [T('cache'), False,\n URL('ccache')]]\n\n# ##########################################################\n# ## auxiliary functions\n# ###########################################################\n\n\n\n\ndatabases = get_databases(None)\n\n\n\n\n\n\n\n\n\n\n\n\n# ##########################################################\n# ## list all databases and tables\n# ###########################################################\n\n\n# ##########################################################\n# ## insert a new record\n# ###########################################################\n\n\n\n\n# ##########################################################\n# ## list all records in table and insert new record\n# ###########################################################\n\n\n\n\n\n\n\n\n\n\n# ##########################################################\n# ## edit delete one record\n# ###########################################################\n\n\n\n\n# ##########################################################\n# ## get global variables\n# ###########################################################\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def download():\n import os\n db = get_database(request)\n return response.download(request, db)", "metadata": "root.download", "header": "['module', '___EOS___']", "index": 136 }, { "content": "def ccache():\n form = FORM(\n P(TAG.BUTTON(\n T(\"Clear CACHE?\"), _type=\"submit\", _name=\"yes\", _value=\"yes\")),\n P(TAG.BUTTON(\n T(\"Clear RAM\"), _type=\"submit\", _name=\"ram\", _value=\"ram\")),\n P(TAG.BUTTON(\n T(\"Clear DISK\"), _type=\"submit\", _name=\"disk\", _value=\"disk\")),\n )\n\n if form.accepts(request.vars, session):\n clear_ram = False\n clear_disk = False\n session.flash = \"\"\n if request.vars.yes:\n clear_ram = clear_disk = True\n if request.vars.ram:\n clear_ram = True\n if request.vars.disk:\n clear_disk = True\n\n if clear_ram:\n cache.ram.clear()\n session.flash += T(\"Ram Cleared\")\n if clear_disk:\n cache.disk.clear()\n session.flash += T(\"Disk Cleared\")\n\n redirect(URL(r=request))\n\n try:\n from guppy import hpy\n hp = hpy()\n except ImportError:\n hp = False\n\n import shelve\n import os\n import copy\n import time\n import math\n from gluon import portalocker\n\n ram = {\n 'entries': 0,\n 'bytes': 0,\n 'objects': 0,\n 'hits': 0,\n 'misses': 0,\n 'ratio': 0,\n 'oldest': time.time(),\n 'keys': []\n }\n disk = copy.copy(ram)\n total = copy.copy(ram)\n disk['keys'] = []\n total['keys'] = []\n\n def GetInHMS(seconds):\n hours = math.floor(seconds / 3600)\n seconds -= hours * 3600\n minutes = math.floor(seconds / 60)\n seconds -= minutes * 60\n seconds = math.floor(seconds)\n\n return (hours, minutes, seconds)\n\n for key, value in cache.ram.storage.items():\n if isinstance(value, dict):\n ram['hits'] = value['hit_total'] - value['misses']\n ram['misses'] = value['misses']\n try:\n ram['ratio'] = ram['hits'] * 100 / value['hit_total']\n except (KeyError, ZeroDivisionError):\n ram['ratio'] = 0\n else:\n if hp:\n ram['bytes'] += hp.iso(value[1]).size\n ram['objects'] += hp.iso(value[1]).count\n ram['entries'] += 1\n if value[0] < ram['oldest']:\n ram['oldest'] = value[0]\n ram['keys'].append((key, GetInHMS(time.time() - value[0])))\n folder = os.path.join(request.folder,'cache')\n if not os.path.exists(folder):\n os.mkdir(folder)\n locker = open(os.path.join(folder, 'cache.lock'), 'a')\n portalocker.lock(locker, portalocker.LOCK_EX)\n disk_storage = shelve.open(\n os.path.join(folder, 'cache.shelve'))\n try:\n for key, value in disk_storage.items():\n if isinstance(value, dict):\n disk['hits'] = value['hit_total'] - value['misses']\n disk['misses'] = value['misses']\n try:\n disk['ratio'] = disk['hits'] * 100 / value['hit_total']\n except (KeyError, ZeroDivisionError):\n disk['ratio'] = 0\n else:\n if hp:\n disk['bytes'] += hp.iso(value[1]).size\n disk['objects'] += hp.iso(value[1]).count\n disk['entries'] += 1\n if value[0] < disk['oldest']:\n disk['oldest'] = value[0]\n disk['keys'].append((key, GetInHMS(time.time() - value[0])))\n\n finally:\n portalocker.unlock(locker)\n locker.close()\n disk_storage.close()\n\n total['entries'] = ram['entries'] + disk['entries']\n total['bytes'] = ram['bytes'] + disk['bytes']\n total['objects'] = ram['objects'] + disk['objects']\n total['hits'] = ram['hits'] + disk['hits']\n total['misses'] = ram['misses'] + disk['misses']\n total['keys'] = ram['keys'] + disk['keys']\n try:\n total['ratio'] = total['hits'] * 100 / (total['hits'] +\n total['misses'])\n except (KeyError, ZeroDivisionError):\n total['ratio'] = 0\n\n if disk['oldest'] < ram['oldest']:\n total['oldest'] = disk['oldest']\n else:\n total['oldest'] = ram['oldest']\n\n ram['oldest'] = GetInHMS(time.time() - ram['oldest'])\n disk['oldest'] = GetInHMS(time.time() - disk['oldest'])\n total['oldest'] = GetInHMS(time.time() - total['oldest'])\n\n def key_table(keys):\n return TABLE(\n TR(TD(B(T('Key'))), TD(B(T('Time in Cache (h:m:s)')))),\n *[TR(TD(k[0]), TD('%02d:%02d:%02d' % k[1])) for k in keys],\n **dict(_class='cache-keys',\n _style=\"border-collapse: separate; border-spacing: .5em;\"))\n\n ram['keys'] = key_table(ram['keys'])\n disk['keys'] = key_table(disk['keys'])\n total['keys'] = key_table(total['keys'])\n\n return dict(form=form, total=total,\n ram=ram, disk=disk, object_stats=hp != False)", "metadata": "root.ccache", "header": "['module', '___EOS___']", "index": 315 } ]
[ { "span": "import os", "start_line": 137, "start_column": 4, "end_line": 137, "end_column": 13 }, { "span": "import os", "start_line": 352, "start_column": 4, "end_line": 352, "end_column": 13 }, { "span": "import copy", "start_line": 353, "start_column": 4, "end_line": 353, "end_column": 15 } ]
[ { "span": "import os", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 9 }, { "span": "import copy", "start_line": 9, "start_column": 0, "end_line": 9, "end_column": 11 } ]
1
true
[ "[CLS]_", "Module_", "is_", "imported_", "more_", "than_", "once_", "[SEP]_", "module_", "\\u\\u\\uEOS\\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_", "#", " ", "##", " ", "make", " ", "sure", " ", "administrat", "or", " ", "is", " ", "on", " ", "local", "host_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "###########", "###########", "###########", "###########", "###########", "###", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "socket_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "copy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "gluon_", "._", "contenttype", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "gluon_", "._", "fileu", "tils_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "response_", "._", "subtitle_", "=_", "'", "Databa", "se", " ", "Administrati", "on", " ", "(", "appa", "dmin", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "##", " ", "critic", "al", " ", "---", " ", "make", " ", "a", " ", "copy", " ", "of", " ", "the", " ", "environment_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "global", "\\u", "env_", "=_", "copy_", "._", "copy_", "(_", "globals_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "global", "\\u", "env_", "[_", "'", "datetime", "'_", "]_", "=_", "datetime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "http", "\\u", "host_", "=_", "request_", "._", "env_", "._", "http", "\\u", "host_", "._", "split_", "(_", "':'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remote", "\\u", "addr_", "=_", "request_", "._", "env_", "._", "remote", "\\u", "addr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hosts_", "=_", "(_", "http", "\\u", "host_", ",_", "socket_", "._", "gethostname_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "socket_", "._", "gethostbyname", "_", "(_", "http", "\\u", "host_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "':", ":", "1", "'_", ",_", "'", "127", ".0", ".0", ".1", "'_", ",_", "':", ":", "fff", "f", ":", "127", ".0", ".0", ".1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hosts_", "=_", "(_", "http", "\\u", "host_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "env_", "._", "http", "\\u", "x", "\\u", "forwarded", "\\u", "for_", "or_", "request_", "._", "is", "\\u", "https_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "secure_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "(_", "remote", "\\u", "addr_", "not_", "in_", "hosts_", ")_", "and_", "(_", "remote", "\\u", "addr_", "!=_", "\"", "127", ".0", ".0", ".1", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "HTTP_", "(_", "200_", ",_", "T_", "(_", "'", "appa", "dmin", " ", "is", " ", "disable", "d", " ", "bec", "aus", "e", " ", "insecure", " ", "channel", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "(_", "request_", "._", "application_", "==_", "'", "admin", "'_", "and_", "not_", "session_", "._", "authorized_", ")_", "or_", "(_", "request_", "._", "application_", "!=_", "'", "admin", "'_", "and_", "not_", "gluon_", "._", "fileu", "tils_", "._", "check", "\\u", "credentials_", "(_", "request_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "redirect_", "(_", "URL_", "(_", "'", "admin", "'_", ",_", "'", "default", "'_", ",_", "'", "index", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "vars_", "=_", "dict_", "(_", "send_", "=_", "URL_", "(_", "args_", "=_", "request_", "._", "args_", ",_", "vars_", "=_", "request_", "._", "vars_", ")_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ignore", "\\u", "rw_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "._", "view_", "=_", "'", "appa", "dmin", ".", "html", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "._", "menu_", "=_", "[_", "[_", "T_", "(_", "'", "design", "'_", ")_", ",_", "False_", ",_", "URL_", "(_", "'", "admin", "'_", ",_", "'", "default", "'_", ",_", "'", "design", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "[_", "request_", "._", "application_", "]_", ")_", "]_", ",_", "[_", "T_", "(_", "'", "db", "'_", ")_", ",_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "URL_", "(_", "'", "index", "'_", ")_", "]_", ",_", "[_", "T_", "(_", "'", "state", "'_", ")_", ",_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "URL_", "(_", "'", "state", "'_", ")_", "]_", ",_", "[_", "T_", "(_", "'", "cache", "'_", ")_", ",_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "URL_", "(_", "'", "cca", "che", "'_", ")_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "###########", "###########", "###########", "###########", "###########", "###", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "##", " ", "auxiliary", " ", "functions_", "\\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\\uDEDENT\\u\\u\\u_", "databases_", "=_", "get", "\\u", "databases_", "(_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "#", " ", "##", " ", "list", " ", "all", " ", "databa", "ses", " ", "and", " ", "tables_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "###########", "###########", "###########", "###########", "###########", "###", "#", "_", "\\u\\u\\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_", "#", " ", "##", " ", "insert", " ", "a", " ", "new", " ", "record_", "\\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_", "#", " ", "##", " ", "list", " ", "all", " ", "record", "s", " ", "in", " ", "table", " ", "and", " ", "insert", " ", "new", " ", "record_", "\\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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "#", " ", "##", " ", "edit", " ", "delete", " ", "one", " ", "record_", "\\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_", "#", " ", "##", " ", "get", " ", "global", " ", "variables_", "\\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\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "download_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "db_", "=_", "get", "\\u", "database_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "response_", "._", "download_", "(_", "request_", ",_", "db_", ")_", "\\u\\u\\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_", "cca", "che_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "form_", "=_", "FORM", "_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "P_", "(_", "TAG_", "._", "BUTTON_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "T_", "(_", "\"", "Clear", " ", "CACHE", "?\"_", ")_", ",_", "\\u", "type_", "=_", "\"", "submit", "\"_", ",_", "\\u", "name_", "=_", "\"", "ye", "s", "\"_", ",_", "\\u", "value_", "=_", "\"", "ye", "s", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "P_", "(_", "TAG_", "._", "BUTTON_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "T_", "(_", "\"", "Clear", " ", "RAM", "\"_", ")_", ",_", "\\u", "type_", "=_", "\"", "submit", "\"_", ",_", "\\u", "name_", "=_", "\"", "ram", "\"_", ",_", "\\u", "value_", "=_", "\"", "ram", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "P_", "(_", "TAG_", "._", "BUTTON_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "T_", "(_", "\"", "Clear", " ", "DISK", "\"_", ")_", ",_", "\\u", "type_", "=_", "\"", "submit", "\"_", ",_", "\\u", "name_", "=_", "\"", "disk", "\"_", ",_", "\\u", "value_", "=_", "\"", "disk", "\"_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "form_", "._", "accepts", "_", "(_", "request_", "._", "vars_", ",_", "session_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "clear", "\\u", "ram_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "clear", "\\u", "disk_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "session_", "._", "flash_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "request_", "._", "vars_", "._", "yes_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "clear", "\\u", "ram_", "=_", "clear", "\\u", "disk_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "vars_", "._", "ram_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "clear", "\\u", "ram_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "vars_", "._", "disk_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "clear", "\\u", "disk_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "clear", "\\u", "ram_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cache_", "._", "ram_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "session_", "._", "flash_", "+=_", "T_", "(_", "\"", "Ram", " ", "Clear", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "clear", "\\u", "disk_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cache_", "._", "disk_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "session_", "._", "flash_", "+=_", "T_", "(_", "\"", "Disk", " ", "Clear", "ed", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "redirect_", "(_", "URL_", "(_", "r_", "=_", "request_", ")_", ")_", "\\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_", "gu", "ppy", "_", "import_", "hp", "y_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hp_", "=_", "hp", "y_", "(_", ")_", "\\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 ", " _", "hp_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "import_", "shelve", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "copy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "math_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gluon_", "import_", "portal", "ock", "er_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ram_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "entri", "es", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "bytes", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "object", "s", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "hits", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "misses", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ratio", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "oldest", "'_", ":_", "time_", "._", "time_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "keys", "'_", ":_", "[_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "disk_", "=_", "copy_", "._", "copy_", "(_", "ram_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total_", "=_", "copy_", "._", "copy_", "(_", "ram_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "disk_", "[_", "'", "keys", "'_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total_", "[_", "'", "keys", "'_", "]_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "Get", "In", "HM", "S_", "(_", "seconds_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "hours_", "=_", "math_", "._", "floor_", "(_", "seconds_", "/_", "3600_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "seconds_", "-=_", "hours_", "*_", "3600_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "minutes_", "=_", "math_", "._", "floor_", "(_", "seconds_", "/_", "60_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "seconds_", "-=_", "minutes_", "*_", "60_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "seconds_", "=_", "math_", "._", "floor_", "(_", "seconds_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "(_", "hours_", ",_", "minutes_", ",_", "seconds_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "key_", ",_", "value_", "in_", "cache_", "._", "ram_", "._", "storage_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "value_", ",_", "dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ram_", "[_", "'", "hits", "'_", "]_", "=_", "value_", "[_", "'", "hit", "\\u", "total", "'_", "]_", "-_", "value_", "[_", "'", "misses", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ram_", "[_", "'", "misses", "'_", "]_", "=_", "value_", "[_", "'", "misses", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ram_", "[_", "'", "ratio", "'_", "]_", "=_", "ram_", "[_", "'", "hits", "'_", "]_", "*_", "100_", "/_", "value_", "[_", "'", "hit", "\\u", "total", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Key", "Error_", ",_", "Zero", "Divis", "ion", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ram_", "[_", "'", "ratio", "'_", "]_", "=_", "0_", "\\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_", "hp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ram_", "[_", "'", "bytes", "'_", "]_", "+=_", "hp_", "._", "iso_", "(_", "value_", "[_", "1_", "]_", ")_", "._", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ram_", "[_", "'", "object", "s", "'_", "]_", "+=_", "hp_", "._", "iso_", "(_", "value_", "[_", "1_", "]_", ")_", "._", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ram_", "[_", "'", "entri", "es", "'_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "value_", "[_", "0_", "]_", "<_", "ram_", "[_", "'", "oldest", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ram_", "[_", "'", "oldest", "'_", "]_", "=_", "value_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ram_", "[_", "'", "keys", "'_", "]_", "._", "append_", "(_", "(_", "key_", ",_", "Get", "In", "HM", "S_", "(_", "time_", "._", "time_", "(_", ")_", "-_", "value_", "[_", "0_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "folder_", "=_", "os_", "._", "path_", "._", "join_", "(_", "request_", "._", "folder_", ",_", "'", "cache", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "folder_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "mkdir_", "(_", "folder_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "lock", "er_", "=_", "open_", "(_", "os_", "._", "path_", "._", "join_", "(_", "folder_", ",_", "'", "cache", ".", "lock", "'_", ")_", ",_", "'", "a", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "portal", "ock", "er_", "._", "lock_", "(_", "lock", "er_", ",_", "portal", "ock", "er_", "._", "LOCK", "\\u", "EX_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "disk", "\\u", "storage_", "=_", "shelve", "_", "._", "open_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "os_", "._", "path_", "._", "join_", "(_", "folder_", ",_", "'", "cache", ".", "shelve", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "key_", ",_", "value_", "in_", "disk", "\\u", "storage_", "._", "items_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "isinstance_", "(_", "value_", ",_", "dict_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "disk_", "[_", "'", "hits", "'_", "]_", "=_", "value_", "[_", "'", "hit", "\\u", "total", "'_", "]_", "-_", "value_", "[_", "'", "misses", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "disk_", "[_", "'", "misses", "'_", "]_", "=_", "value_", "[_", "'", "misses", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "disk_", "[_", "'", "ratio", "'_", "]_", "=_", "disk_", "[_", "'", "hits", "'_", "]_", "*_", "100_", "/_", "value_", "[_", "'", "hit", "\\u", "total", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Key", "Error_", ",_", "Zero", "Divis", "ion", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "disk_", "[_", "'", "ratio", "'_", "]_", "=_", "0_", "\\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_", "hp_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "disk_", "[_", "'", "bytes", "'_", "]_", "+=_", "hp_", "._", "iso_", "(_", "value_", "[_", "1_", "]_", ")_", "._", "size_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "disk_", "[_", "'", "object", "s", "'_", "]_", "+=_", "hp_", "._", "iso_", "(_", "value_", "[_", "1_", "]_", ")_", "._", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "disk_", "[_", "'", "entri", "es", "'_", "]_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "value_", "[_", "0_", "]_", "<_", "disk_", "[_", "'", "oldest", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "disk_", "[_", "'", "oldest", "'_", "]_", "=_", "value_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "disk_", "[_", "'", "keys", "'_", "]_", "._", "append_", "(_", "(_", "key_", ",_", "Get", "In", "HM", "S_", "(_", "time_", "._", "time_", "(_", ")_", "-_", "value_", "[_", "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_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "portal", "ock", "er_", "._", "unlock_", "(_", "lock", "er_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lock", "er_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "disk", "\\u", "storage_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "total_", "[_", "'", "entri", "es", "'_", "]_", "=_", "ram_", "[_", "'", "entri", "es", "'_", "]_", "+_", "disk_", "[_", "'", "entri", "es", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total_", "[_", "'", "bytes", "'_", "]_", "=_", "ram_", "[_", "'", "bytes", "'_", "]_", "+_", "disk_", "[_", "'", "bytes", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total_", "[_", "'", "object", "s", "'_", "]_", "=_", "ram_", "[_", "'", "object", "s", "'_", "]_", "+_", "disk_", "[_", "'", "object", "s", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total_", "[_", "'", "hits", "'_", "]_", "=_", "ram_", "[_", "'", "hits", "'_", "]_", "+_", "disk_", "[_", "'", "hits", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total_", "[_", "'", "misses", "'_", "]_", "=_", "ram_", "[_", "'", "misses", "'_", "]_", "+_", "disk_", "[_", "'", "misses", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total_", "[_", "'", "keys", "'_", "]_", "=_", "ram_", "[_", "'", "keys", "'_", "]_", "+_", "disk_", "[_", "'", "keys", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "total_", "[_", "'", "ratio", "'_", "]_", "=_", "total_", "[_", "'", "hits", "'_", "]_", "*_", "100_", "/_", "(_", "total_", "[_", "'", "hits", "'_", "]_", "+_", "\\u\\u\\uNL\\u\\u\\u_", "total_", "[_", "'", "misses", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "(_", "Key", "Error_", ",_", "Zero", "Divis", "ion", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "total_", "[_", "'", "ratio", "'_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "disk_", "[_", "'", "oldest", "'_", "]_", "<_", "ram_", "[_", "'", "oldest", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "total_", "[_", "'", "oldest", "'_", "]_", "=_", "disk_", "[_", "'", "oldest", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "total_", "[_", "'", "oldest", "'_", "]_", "=_", "ram_", "[_", "'", "oldest", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ram_", "[_", "'", "oldest", "'_", "]_", "=_", "Get", "In", "HM", "S_", "(_", "time_", "._", "time_", "(_", ")_", "-_", "ram_", "[_", "'", "oldest", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "disk_", "[_", "'", "oldest", "'_", "]_", "=_", "Get", "In", "HM", "S_", "(_", "time_", "._", "time_", "(_", ")_", "-_", "disk_", "[_", "'", "oldest", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total_", "[_", "'", "oldest", "'_", "]_", "=_", "Get", "In", "HM", "S_", "(_", "time_", "._", "time_", "(_", ")_", "-_", "total_", "[_", "'", "oldest", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "key", "\\u", "table_", "(_", "keys_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "TABLE_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "TR_", "(_", "TD_", "(_", "B_", "(_", "T_", "(_", "'", "Key", "'_", ")_", ")_", ")_", ",_", "TD_", "(_", "B_", "(_", "T_", "(_", "'", "Time", " ", "in", " ", "Cache", " ", "(", "h", ":", "m", ":", "s", ")'_", ")_", ")_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "*_", "[_", "TR_", "(_", "TD_", "(_", "k_", "[_", "0_", "]_", ")_", ",_", "TD_", "(_", "'%", "02", "d", ":", "%", "02", "d", ":", "%", "02", "d", "'_", "%_", "k_", "[_", "1_", "]_", ")_", ")_", "for_", "k_", "in_", "keys_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "**_", "dict_", "(_", "\\u", "class_", "=_", "'", "cache", "-", "keys", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u", "style_", "=_", "\"", "border", "-", "collapse", ":", " ", "separate", ";", " ", "border", "-", "spaci", "ng", ":", " ", ".5", "em", ";\"_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "ram_", "[_", "'", "keys", "'_", "]_", "=_", "key", "\\u", "table_", "(_", "ram_", "[_", "'", "keys", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "disk_", "[_", "'", "keys", "'_", "]_", "=_", "key", "\\u", "table_", "(_", "disk_", "[_", "'", "keys", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "total_", "[_", "'", "keys", "'_", "]_", "=_", "key", "\\u", "table_", "(_", "total_", "[_", "'", "keys", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "dict_", "(_", "form_", "=_", "form_", ",_", "total_", "=_", "total_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "ram_", "=_", "ram_", ",_", "disk_", "=_", "disk_", ",_", "object\\u", "stats_", "=_", "hp_", "!=_", "False_", ")_" ]
[ 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, 3, 1, 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, 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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 ]
Variable defined multiple times
sassoftware/conary/conary/build/derive.py
[ { "content": "def derive(repos, cfg, targetLabel, troveSpec, checkoutDir=None,\n extract=False, info=False, callback=None):\n \"\"\"\n Performs all the commands necessary to create a derived recipe.\n First it shadows the package, then it creates a checkout of the shadow\n and converts the checkout to a derived recipe package.\n\n Finally if extract = True, it installs an version of the binary\n package into a root.\n\n @param repos: trovesource to search for and derive packages from\n @param cfg: configuration to use when deriving the package\n @type cfg: ConaryConfiguration object\n @param targetLabel: label to derive from\n @type targetLabel: versions.Label\n @param checkoutDir: directory to create the checkout in. If None,\n defaults to currentDir + packageName.\n @param extract: If True, creates a subdirectory of the checkout named\n _ROOT_ with the contents of the binary of the derived\n package.\n @param info: If true, only display the information about the shadow\n that would be performed if the derive command were\n completed.\n @param callback:\n \"\"\"\n\n origDir = os.getcwd()\n try:\n if callback is None:\n callback = DeriveCallback()\n\n if isinstance(troveSpec, tuple):\n troveName, versionSpec, flavor = troveSpec\n versionSpec = str(versionSpec)\n troveSpec = cmdline.toTroveSpec(troveName, versionSpec, flavor)\n else:\n troveName, versionSpec, flavor = cmdline.parseTroveSpec(troveSpec)\n\n if isinstance(targetLabel, str):\n targetLabel = Label(targetLabel)\n\n troveName, versionSpec, flavor = cmdline.parseTroveSpec(troveSpec)\n result = repos.findTrove(cfg.buildLabel,\n (troveName, versionSpec, flavor),\n cfg.flavor)\n # findTrove shouldn't return multiple items for one package anymore\n # when a flavor is specified.\n troveToDerive, = result\n # displaying output along the screen allows there to be a record\n # of what operations were performed. Since this command is\n # an aggregate of several commands I think that is appropriate,\n # rather than simply using a progress callback.\n log.info('Shadowing %s=%s[%s] onto %s' % (troveToDerive[0],\n troveToDerive[1],\n troveToDerive[2],\n targetLabel))\n if info:\n cfg.interactive = False\n\n error = branch.branch(repos, cfg, str(targetLabel),\n ['%s=%s[%s]'%troveToDerive],\n makeShadow=True, sourceOnly=True,\n binaryOnly=False, allowEmptyShadow=True,\n info=info)\n if info or error:\n return\n shadowedVersion = troveToDerive[1].createShadow(targetLabel)\n shadowedVersion = shadowedVersion.getSourceVersion(False)\n troveName = troveName.split(':')[0]\n\n checkoutDir = checkoutDir or troveName\n checkin.checkout(repos, cfg, checkoutDir,\n [\"%s=%s\" % (troveName, shadowedVersion)],\n callback=callback)\n os.chdir(checkoutDir)\n\n nvfs = repos.getTrovesBySource(troveToDerive[0]+':source',\n troveToDerive[1].getSourceVersion())\n trvs = repos.getTroves(nvfs)\n hasCapsule = [ x for x in trvs if x.troveInfo.capsule.type() ]\n if hasCapsule:\n derivedRecipeType = 'DerivedCapsuleRecipe'\n removeText = ''\n else:\n derivedRecipeType = 'DerivedPackageRecipe'\n removeText = \\\n\"\"\"\n # This appliance uses PHP as a command interpreter but does\n # not include a web server, so remove the file that creates\n # a dependency on the web server\n r.Remove('/etc/httpd/conf.d/php.conf')\n\"\"\"\n\n log.info('Rewriting recipe file')\n recipeName = troveName + '.recipe'\n className = util.convertPackageNameToClassName(troveName)\n\n derivedRecipe = \"\"\"\nclass %(className)sRecipe(%(recipeBaseClass)s):\n name = '%(name)s'\n version = '%(version)s'\n\n def setup(r):\n '''\n In this recipe, you can make modifications to the package.\n\n Examples:\n\n # This appliance has high-memory-use PHP scripts\n r.Replace('memory_limit = 8M', 'memory_limit = 32M', '/etc/php.ini')\n%(removeText)s\n # This appliance requires that a few binaries be replaced\n # with binaries built from a custom archive that includes\n # a Makefile that honors the DESTDIR variable for its\n # install target.\n r.addArchive('foo.tar.gz')\n r.Make()\n r.MakeInstall()\n\n # This appliance requires an extra configuration file\n r.Create('/etc/myconfigfile', contents='some data')\n '''\n\"\"\" % dict(className=className,\n name=troveName,\n version=shadowedVersion.trailingRevision().getVersion(),\n recipeBaseClass=derivedRecipeType,\n removeText=removeText)\n\n open(recipeName, 'w').write(derivedRecipe)\n\n log.info('Removing extra files from checkout')\n\n conaryState = state.ConaryStateFromFile('CONARY', repos)\n sourceState = conaryState.getSourceState()\n # clear the factory since we don't care about how the parent trove was\n # created\n sourceState.setFactory('')\n\n addRecipe=True\n for (pathId, path, fileId, version) in list(sourceState.iterFileList()):\n if path == recipeName:\n addRecipe = False\n continue\n sourceState.removeFile(pathId)\n if util.exists(path):\n statInfo = os.lstat(path)\n try:\n if statInfo.st_mode & stat.S_IFDIR:\n os.rmdir(path)\n else:\n os.unlink(path)\n except OSError, e:\n log.warning(\"cannot remove %s: %s\" % (path, e.strerror))\n\n conaryState.write('CONARY')\n\n if addRecipe:\n checkin.addFiles([recipeName])\n\n if extract:\n log.info('extracting files from %s=%s[%s]' % (troveToDerive))\n # extract to _ROOT_\n extractDir = os.path.join(os.getcwd(), '_ROOT_')\n ts = [ (troveToDerive[0], (None, None),\n (troveToDerive[1], troveToDerive[2]), True) ]\n cs = repos.createChangeSet(ts, recurse = True)\n ChangesetExploder(cs, extractDir)\n # extract to _OLD_ROOT_\n secondDir = os.path.join(os.getcwd(), '_OLD_ROOT_')\n cs = repos.createChangeSet(ts, recurse = True)\n ChangesetExploder(cs, secondDir)\n\n finally:\n # restore the original directory before we started\n os.chdir(origDir)", "metadata": "root.derive", "header": "['module', '___EOS___']", "index": 38 } ]
[ { "span": "troveName,", "start_line": 74, "start_column": 12, "end_line": 74, "end_column": 21 }, { "span": "versionSpec,", "start_line": 74, "start_column": 23, "end_line": 74, "end_column": 34 }, { "span": "flavor ", "start_line": 74, "start_column": 36, "end_line": 74, "end_column": 42 } ]
[ { "span": "troveName,", "start_line": 79, "start_column": 8, "end_line": 79, "end_column": 17 }, { "span": "versionSpec,", "start_line": 79, "start_column": 19, "end_line": 79, "end_column": 30 }, { "span": "flavor ", "start_line": 79, "start_column": 32, "end_line": 79, "end_column": 38 } ]
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_", "derive", "_", "(_", "repos_", ",_", "cfg_", ",_", "target", "Label_", ",_", "trove", "Spec_", ",_", "check", "out", "Dir_", "=_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extract_", "=_", "False_", ",_", "info_", "=_", "False_", ",_", "callback_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Perform", "s", " ", "all", " ", "the", " ", "command", "s", " ", "necessar", "y", " ", "to", " ", "create", " ", "a", " ", "derive", "d", " ", "recip", "e", ".", "\\", "10", ";", " ", " ", " ", " ", "Fi", "rst", " ", "it", " ", "shadow", "s", " ", "the", " ", "package", ",", " ", "then", " ", "it", " ", "create", "s", " ", "a", " ", "check", "out", " ", "of", " ", "the", " ", "shadow", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "convert", "s", " ", "the", " ", "check", "out", " ", "to", " ", "a", " ", "derive", "d", " ", "recip", "e", " ", "package", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Final", "ly", " ", "if", " ", "extract", " ", "=", " ", "Tru", "e", ",", " ", "it", " ", "install", "s", " ", "an", " ", "version", " ", "of", " ", "the", " ", "binar", "y", "\\", "10", ";", " ", " ", " ", " ", "package", " ", "int", "o", " ", "a", " ", "root", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "repos", ":", " ", "trove", "source", " ", "to", " ", "search", " ", "for", " ", "and", " ", "derive", " ", "package", "s", " ", "from", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "cfg", ":", " ", "configura", "tion", " ", "to", " ", "use", " ", "whe", "n", " ", "deriv", "ing", " ", "the", " ", "package", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "cfg", ":", " ", "Con", "ary", "Configura", "tion", " ", "object", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "target", "Label", ":", " ", "label", " ", "to", " ", "derive", " ", "from", "\\", "10", ";", " ", " ", " ", " ", "@", "type", " ", "target", "Label", ":", " ", "version", "s", ".", "Label", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "check", "out", "Dir", ":", " ", "director", "y", " ", "to", " ", "create", " ", "the", " ", "check", "out", " ", "in", ".", " ", " ", "If", " ", "Non", "e", ",", "\\", "10", ";", " ", " ", " ", "default", "s", " ", "to", " ", "current", "Dir", " ", "+", " ", "package", "Name", ".", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "extract", ":", " ", "If", " ", "Tru", "e", ",", " ", "create", "s", " ", "a", " ", "subdirectory", " ", "of", " ", "the", " ", "check", "out", " ", "named", "\\", "10", ";", " ", " ", " ", "\\u", "ROO", "T", "\\u", " ", "with", " ", "the", " ", "content", "s", " ", "of", " ", "the", " ", "binar", "y", " ", "of", " ", "the", " ", "derive", "d", "\\", "10", ";", " ", " ", " ", "package", ".", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "info", ":", " ", "If", " ", "true", ",", " ", "only", " ", "display", " ", "the", " ", "informati", "on", " ", "abo", "ut", " ", "the", " ", "shadow", "\\", "10", ";", " ", " ", " ", " ", "tha", "t", " ", "wou", "ld", " ", "be", " ", "perform", "ed", " ", "if", " ", "the", " ", "derive", " ", "command", " ", "wer", "e", "\\", "10", ";", " ", " ", " ", " ", "complete", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "@", "param", " ", "callback", ":", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "orig", "Dir_", "=_", "os_", "._", "getcwd_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "callback_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "callback_", "=_", "Derive", "Callback_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "trove", "Spec_", ",_", "tuple_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "trove", "Name_", ",_", "version", "Spec_", ",_", "flavor_", "=_", "trove", "Spec_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version", "Spec_", "=_", "str_", "(_", "version", "Spec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trove", "Spec_", "=_", "cmdline_", "._", "to", "Trove", "Spec_", "(_", "trove", "Name_", ",_", "version", "Spec_", ",_", "flavor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "trove", "Name_", ",_", "version", "Spec_", ",_", "flavor_", "=_", "cmdline_", "._", "parse", "Trove", "Spec_", "(_", "trove", "Spec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "isinstance_", "(_", "target", "Label_", ",_", "str_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "target", "Label_", "=_", "Label_", "(_", "target", "Label_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "trove", "Name_", ",_", "version", "Spec_", ",_", "flavor_", "=_", "cmdline_", "._", "parse", "Trove", "Spec_", "(_", "trove", "Spec_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "repos_", "._", "find", "Trove", "_", "(_", "cfg_", "._", "build", "Label_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "trove", "Name_", ",_", "version", "Spec_", ",_", "flavor_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "cfg_", "._", "flavor_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "find", "Trove", " ", "shou", "ld", "n", "'", "t", " ", "return", " ", "multiple", " ", "items", " ", "for", " ", "one", " ", "package", " ", "any", "more_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "whe", "n", " ", "a", " ", "flavor", " ", "is", " ", "specified", "._", "\\u\\u\\uNL\\u\\u\\u_", "trove", "To", "Derive", "_", ",_", "=_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "display", "ing", " ", "output", " ", "along", " ", "the", " ", "screen", " ", "allow", "s", " ", "there", " ", "to", " ", "be", " ", "a", " ", "record_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "what", " ", "operati", "ons", " ", "wer", "e", " ", "perform", "ed", ".", " ", " ", "Sin", "ce", " ", "this", " ", "command", " ", "is_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "an", " ", "aggre", "gate", " ", "of", " ", "sever", "al", " ", "command", "s", " ", "I", " ", "think", " ", "tha", "t", " ", "is", " ", "appropr", "iate", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "rat", "her", " ", "than", " ", "simp", "ly", " ", "usi", "ng", " ", "a", " ", "progress", " ", "callback", "._", "\\u\\u\\uNL\\u\\u\\u_", "log_", "._", "info_", "(_", "'", "Shad", "owi", "ng", " ", "%", "s", "=", "%", "s", "[", "%", "s", "]", " ", "onto", " ", "%", "s", "'_", "%_", "(_", "trove", "To", "Derive", "_", "[_", "0_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "trove", "To", "Derive", "_", "[_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "trove", "To", "Derive", "_", "[_", "2_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "target", "Label_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "info_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cfg_", "._", "interactive_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "error_", "=_", "branch_", "._", "branch_", "(_", "repos_", ",_", "cfg_", ",_", "str_", "(_", "target", "Label_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "'%", "s", "=", "%", "s", "[", "%", "s", "]'_", "%_", "trove", "To", "Derive", "_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "make", "Shadow_", "=_", "True_", ",_", "source", "Only_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "binar", "y", "Only_", "=_", "False_", ",_", "allow", "Emp", "ty", "Shadow_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "info_", "=_", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "info_", "or_", "error_", ":_", "\\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_", "shadow", "ed", "Version_", "=_", "trove", "To", "Derive", "_", "[_", "1_", "]_", "._", "create", "Shadow_", "(_", "target", "Label_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "shadow", "ed", "Version_", "=_", "shadow", "ed", "Version_", "._", "get", "Sou", "rce", "Version_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trove", "Name_", "=_", "trove", "Name_", "._", "split_", "(_", "':'_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "check", "out", "Dir_", "=_", "check", "out", "Dir_", "or_", "trove", "Name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "checkin", "_", "._", "checkout_", "(_", "repos_", ",_", "cfg_", ",_", "check", "out", "Dir_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "[_", "\"%", "s", "=", "%", "s", "\"_", "%_", "(_", "trove", "Name_", ",_", "shadow", "ed", "Version_", ")_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "callback_", "=_", "callback_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "chdir_", "(_", "check", "out", "Dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "nv", "fs_", "=_", "repos_", "._", "get", "Trove", "s", "By", "Source_", "(_", "trove", "To", "Derive", "_", "[_", "0_", "]_", "+_", "':", "source", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "trove", "To", "Derive", "_", "[_", "1_", "]_", "._", "get", "Sou", "rce", "Version_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tr", "vs_", "=_", "repos_", "._", "get", "Trove", "s_", "(_", "nv", "fs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "has", "Caps", "ule_", "=_", "[_", "x_", "for_", "x_", "in_", "tr", "vs_", "if_", "x_", "._", "trove", "Info_", "._", "capsule", "_", "._", "type_", "(_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "has", "Caps", "ule_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "derive", "d", "Recip", "e", "Type_", "=_", "'", "Derive", "d", "Caps", "ule", "Recip", "e", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remove", "Text_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "derive", "d", "Recip", "e", "Type_", "=_", "'", "Derive", "d", "Packa", "ge", "Recip", "e", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "remove", "Text_", "=_", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "Thi", "s", " ", "appliance", " ", "use", "s", " ", "PH", "P", " ", "as", " ", "a", " ", "command", " ", "interprete", "r", " ", "but", " ", "doe", "s", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "not", " ", "include", " ", "a", " ", "web", " ", "server", ",", " ", "so", " ", "remove", " ", "the", " ", "file", " ", "tha", "t", " ", "create", "s", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "a", " ", "dependen", "cy", " ", "on", " ", "the", " ", "web", " ", "server", "\\", "10", ";", " ", " ", " ", " ", "r", ".", "Remove", "('", "/", "etc", "/", "http", "d", "/", "conf", ".", "d", "/", "php", ".", "conf", "')", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "log_", "._", "info_", "(_", "'", "Re", "writ", "ing", " ", "recip", "e", " ", "file", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "recip", "e", "Name_", "=_", "trove", "Name_", "+_", "'.", "recip", "e", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "class", "Name_", "=_", "util_", "._", "convert", "Packa", "ge", "Name", "To", "Class", "Name_", "(_", "trove", "Name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "derive", "d", "Recipe_", "=_", "\"\"\"", "\\", "10", ";", "class", " ", "%", "(", "class", "Name", ")", "s", "Recip", "e", "(%", "(", "recip", "e", "Base", "Class", ")", "s", "):", "\\", "10", ";", " ", " ", " ", " ", "name", " ", "=", " ", "'%", "(", "name", ")", "s", "'", "\\", "10", ";", " ", " ", " ", " ", "version", " ", "=", " ", "'%", "(", "version", ")", "s", "'", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "def", " ", "setup", "(", "r", "):", "\\", "10", ";", " ", " ", " ", " ", "'''", "\\", "10", ";", " ", " ", " ", " ", "In", " ", "this", " ", "recip", "e", ",", " ", "you", " ", "can", " ", "make", " ", "modification", "s", " ", "to", " ", "the", " ", "package", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Exam", "ples", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "Thi", "s", " ", "appliance", " ", "has", " ", "high", "-", "memory", "-", "use", " ", "PH", "P", " ", "scripts", "\\", "10", ";", " ", " ", " ", " ", "r", ".", "Replace", "('", "memory", "\\u", "limit", " ", "=", " ", "8", "M", "',", " ", "'", "memory", "\\u", "limit", " ", "=", " ", "32", "M", "',", " ", "'/", "etc", "/", "php", ".", "ini", "')", "\\", "10", ";", "%", "(", "remove", "Text", ")", "s", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "Thi", "s", " ", "appliance", " ", "require", "s", " ", "tha", "t", " ", "a", " ", "few", " ", "binaries", " ", "be", " ", "replaced", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "with", " ", "binaries", " ", "bui", "lt", " ", "from", " ", "a", " ", "custom", " ", "archive", " ", "tha", "t", " ", "include", "s", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "a", " ", "Make", "file", " ", "tha", "t", " ", "honor", "s", " ", "the", " ", "DEST", "DIR", " ", "variab", "le", " ", "for", " ", "its", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "install", " ", "target", ".", "\\", "10", ";", " ", " ", " ", " ", "r", ".", "add", "Archive", "('", "foo", ".", "tar", ".", "gz", "')", "\\", "10", ";", " ", " ", " ", " ", "r", ".", "Make", "()", "\\", "10", ";", " ", " ", " ", " ", "r", ".", "Make", "Install", "()", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "#", " ", "Thi", "s", " ", "appliance", " ", "require", "s", " ", "an", " ", "extra", " ", "configura", "tion", " ", "file", "\\", "10", ";", " ", " ", " ", " ", "r", ".", "Creat", "e", "('", "/", "etc", "/", "myco", "nfig", "file", "',", " ", "content", "s", "='", "some", " ", "data", "')", "\\", "10", ";", " ", " ", " ", " ", "'''", "\\", "10", ";\"\"\"_", "%_", "dict_", "(_", "class", "Name_", "=_", "class", "Name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "trove", "Name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "shadow", "ed", "Version_", "._", "trail", "ing", "Revision_", "(_", ")_", "._", "get", "Version_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "recip", "e", "Base", "Class_", "=_", "derive", "d", "Recip", "e", "Type_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "remove", "Text_", "=_", "remove", "Text_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "open_", "(_", "recip", "e", "Name_", ",_", "'", "w", "'_", ")_", "._", "write_", "(_", "derive", "d", "Recipe_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "log_", "._", "info_", "(_", "'", "Remo", "ving", " ", "extra", " ", "files", " ", "from", " ", "check", "out", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cona", "ry", "State_", "=_", "state_", "._", "Con", "ary", "State", "Fro", "m", "File_", "(_", "'", "CON", "ARY", "'_", ",_", "repos_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "source", "State_", "=_", "cona", "ry", "State_", "._", "get", "Sou", "rce", "State_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "clear", " ", "the", " ", "factor", "y", " ", "sinc", "e", " ", "we", " ", "don", "'", "t", " ", "care", " ", "abo", "ut", " ", "how", " ", "the", " ", "parent", " ", "trove", " ", "was", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "created_", "\\u\\u\\uNL\\u\\u\\u_", "source", "State_", "._", "set", "Factory_", "(_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "add", "Recipe_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "(_", "path", "Id_", ",_", "path_", ",_", "file", "Id_", ",_", "version_", ")_", "in_", "list_", "(_", "source", "State_", "._", "iter", "File", "List_", "(_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "path_", "==_", "recip", "e", "Name_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "add", "Recipe_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "source", "State_", "._", "remove", "File_", "(_", "path", "Id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "util_", "._", "exists_", "(_", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stat", "Info_", "=_", "os_", "._", "lsta", "t_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "stat", "Info_", "._", "st", "\\u", "mode_", "&_", "stat_", "._", "S", "\\u", "IF", "DIR_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "os_", "._", "rmdir_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "os_", "._", "unlink_", "(_", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\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 ", " ", "_", "log_", "._", "warning_", "(_", "\"", "cann", "ot", " ", "remove", " ", "%", "s", ":", " ", "%", "s", "\"_", "%_", "(_", "path_", ",_", "e_", "._", "strerror_", ")_", ")_", "\\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_", "cona", "ry", "State_", "._", "write_", "(_", "'", "CON", "ARY", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "add", "Recipe_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "checkin", "_", "._", "add", "Files_", "(_", "[_", "recip", "e", "Name_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "extract_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "info_", "(_", "'", "extracti", "ng", " ", "files", " ", "from", " ", "%", "s", "=", "%", "s", "[", "%", "s", "]'_", "%_", "(_", "trove", "To", "Derive", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "extract", " ", "to", " ", "\\u", "ROO", "T", "\\u_", "\\u\\u\\uNL\\u\\u\\u_", "extract", "Dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "getcwd_", "(_", ")_", ",_", "'\\u", "ROO", "T", "\\u'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ts_", "=_", "[_", "(_", "trove", "To", "Derive", "_", "[_", "0_", "]_", ",_", "(_", "None_", ",_", "None_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "trove", "To", "Derive", "_", "[_", "1_", "]_", ",_", "trove", "To", "Derive", "_", "[_", "2_", "]_", ")_", ",_", "True_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cs_", "=_", "repos_", "._", "create", "Change", "Set_", "(_", "ts_", ",_", "recurse_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Change", "set", "Explo", "der_", "(_", "cs_", ",_", "extract", "Dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "extract", " ", "to", " ", "\\u", "OLD", "\\u", "ROO", "T", "\\u_", "\\u\\u\\uNL\\u\\u\\u_", "second", "Dir_", "=_", "os_", "._", "path_", "._", "join_", "(_", "os_", "._", "getcwd_", "(_", ")_", ",_", "'\\u", "OLD", "\\u", "ROO", "T", "\\u'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cs_", "=_", "repos_", "._", "create", "Change", "Set_", "(_", "ts_", ",_", "recurse_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Change", "set", "Explo", "der_", "(_", "cs_", ",_", "second", "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_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "restore", " ", "the", " ", "original", " ", "director", "y", " ", "bef", "ore", " ", "we", " ", "started_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "os_", "._", "chdir_", "(_", "orig", "Dir_", ")_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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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 ]
Special method has incorrect signature
wiki-ai/revscoring/revscoring/score_processor.py
[ { "content": " def __exit__(self):\n self.scores_executor.shutdown()\n self.process_executor.shutdown()", "metadata": "root.ScoreProcessor.__exit__", "header": "['class', 'ScoreProcessor', ':', '___EOS___']", "index": 47 } ]
[ { "span": "def __exit__(self):", "start_line": 47, "start_column": 4, "end_line": 47, "end_column": 23 } ]
[]
1
true
[ "[CLS]_", "Special", "_", "method_", "has_", "incorrect", "_", "signature_", "[SEP]_", "class_", "Score", "Processor_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "exit\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "score", "s", "\\u", "executor_", "._", "shutdown_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "process", "\\u", "executor_", "._", "shutdown_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
getsentry/freight/tests/notifiers/test_sentry.py
[ { "content": " @responses.activate\n def test_send_finished_task(self):\n responses.add(responses.POST, 'http://example.com/')\n\n config = {'webhook_url': 'http://example.com/'}\n\n self.notifier.send_deploy(self.deploy, self.task, config, NotifierEvent.TASK_FINISHED)\n\n call = responses.calls[0]\n assert len(responses.calls) == 1\n assert responses.calls[0].request.url == 'http://example.com/'\n body = responses.calls[0].request.body\n payload = json.loads(body)\n assert payload", "metadata": "root.SentryNotifierTest.test_send_finished_task", "header": "['class', 'SentryNotifierTest', '(', 'SentryNotifierBase', ')', ':', '___EOS___']", "index": 30 }, { "content": " @responses.activate\n def test_send_started_task(self):\n responses.add(responses.POST, 'http://example.com/')\n\n config = {'webhook_url': 'http://example.com/'}\n\n self.notifier.send_deploy(self.deploy, self.task, config, NotifierEvent.TASK_STARTED)\n\n call = responses.calls[0]\n assert len(responses.calls) == 1\n assert responses.calls[0].request.url == 'http://example.com/'\n body = responses.calls[0].request.body\n payload = json.loads(body)\n assert payload", "metadata": "root.SentryNotifierTest.test_send_started_task", "header": "['class', 'SentryNotifierTest', '(', 'SentryNotifierBase', ')', ':', '___EOS___']", "index": 45 } ]
[ { "span": "call ", "start_line": 38, "start_column": 8, "end_line": 38, "end_column": 12 }, { "span": "call ", "start_line": 53, "start_column": 8, "end_line": 53, "end_column": 12 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Sent", "ry", "Notifi", "er", "Test_", "(_", "Sent", "ry", "Notifi", "er", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "@_", "responses_", "._", "activate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "send", "\\u", "finish", "ed", "\\u", "task_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "responses_", "._", "add_", "(_", "responses_", "._", "POST_", ",_", "'", "http", "://", "example", ".", "com", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "config_", "=_", "{_", "'", "webho", "ok", "\\u", "url", "'_", ":_", "'", "http", "://", "example", ".", "com", "/'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "notifier_", "._", "send", "\\u", "deploy_", "(_", "self_", "._", "deploy_", ",_", "self_", "._", "task_", ",_", "config_", ",_", "Notifi", "er", "Event_", "._", "TASK", "\\u", "FINISH", "ED_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "call_", "=_", "responses_", "._", "calls_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "responses_", "._", "calls_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "responses_", "._", "calls_", "[_", "0_", "]_", "._", "request_", "._", "url_", "==_", "'", "http", "://", "example", ".", "com", "/'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body_", "=_", "responses_", "._", "calls_", "[_", "0_", "]_", "._", "request_", "._", "body_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "payload_", "=_", "json_", "._", "loads_", "(_", "body_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "payload_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Sent", "ry", "Notifi", "er", "Test_", "(_", "Sent", "ry", "Notifi", "er", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "responses_", "._", "activate_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "test\\u", "send", "\\u", "start", "ed", "\\u", "task_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "responses_", "._", "add_", "(_", "responses_", "._", "POST_", ",_", "'", "http", "://", "example", ".", "com", "/'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "config_", "=_", "{_", "'", "webho", "ok", "\\u", "url", "'_", ":_", "'", "http", "://", "example", ".", "com", "/'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "notifier_", "._", "send", "\\u", "deploy_", "(_", "self_", "._", "deploy_", ",_", "self_", "._", "task_", ",_", "config_", ",_", "Notifi", "er", "Event_", "._", "TASK", "\\u", "STARTED_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "call_", "=_", "responses_", "._", "calls_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "responses_", "._", "calls_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "responses_", "._", "calls_", "[_", "0_", "]_", "._", "request_", "._", "url_", "==_", "'", "http", "://", "example", ".", "com", "/'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body_", "=_", "responses_", "._", "calls_", "[_", "0_", "]_", "._", "request_", "._", "body_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "payload_", "=_", "json_", "._", "loads_", "(_", "body_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "payload_" ]
[ 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, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
abhik/pebl/src/pebl/learner/exhaustive.py
[ { "content": "\"\"\"Classes and functions for doing exhaustive learning.\"\"\"\n\nfrom pebl import prior, config, evaluator, result, network\nfrom pebl.learner.base import Learner\nfrom pebl.taskcontroller.base import Task\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class ListLearner(Learner):\n #\n # Parameter\n #\n _params = (\n config.StringParameter(\n 'listlearner.networks',\n \"\"\"List of networks, one per line, in network.Network.as_string()\n format.\"\"\", \n default=''\n )\n )\n\n\n \n", "metadata": "root.ListLearner", "header": "['module', '___EOS___']", "index": 7 }, { "content": " def __init__(self, data_=None, prior_=None, networks=None):\n \"\"\"Create a ListLearner learner.\n\n networks should be a list of networks (as network.Network instances). \n\n \"\"\"\n\n super(ListLearner, self).__init__(data_, prior_)\n self.networks = networks\n if not networks:\n variables = self.data.variables\n _net = lambda netstr: network.Network(variables, netstr)\n netstrings = config.get('listlearner.networks').splitlines()\n self.networks = (_net(s) for s in netstrings if s)", "metadata": "root.ListLearner.__init__", "header": "['class', 'ListLearner', '(', 'Learner', ')', ':', '___NEWLINE___', '#', '___NL___', '# Parameter', '___NL___', '#', '___NL___', '___EOS___']", "index": 20 }, { "content": " def run(self):\n self.result = result.LearnerResult(self)\n self.evaluator = evaluator.fromconfig(self.data, prior_=self.prior)\n\n self.result.start_run()\n for net in self.networks:\n self.result.add_network(net, self.evaluator.score_network(net))\n self.result.stop_run()\n return self.result", "metadata": "root.ListLearner.run", "header": "['class', 'ListLearner', '(', 'Learner', ')', ':', '___NEWLINE___', '#', '___NL___', '# Parameter', '___NL___', '#', '___NL___', '___EOS___']", "index": 35 }, { "content": " def split(self, count):\n \"\"\"Split the learner into multiple learners.\n\n Splits self.networks into `count` parts. This is similar to MPI's\n scatter functionality.\n \n \"\"\"\n\n nets = list(self.networks)\n numnets = len(nets)\n netspertask = numnets/count\n\n # divide list into parts\n indices = [[i,i+netspertask] for i in xrange(0,numnets,netspertask)]\n if len(indices) > count:\n indices.pop(-1)\n indices[-1][1] = numnets-1\n\n return [ListLearner(self.data, self.prior, nets[i:j])for i,j in indices]", "metadata": "root.ListLearner.split", "header": "['class', 'ListLearner', '(', 'Learner', ')', ':', '___NEWLINE___', '#', '___NL___', '# Parameter', '___NL___', '#', '___NL___', '___EOS___']", "index": 45 }, { "content": " def __getstate__(self):\n # convert self.network from iterators or generators to a list\n d = self.__dict__\n d['networks'] = list(d['networks'])\n return d", "metadata": "root.ListLearner.__getstate__", "header": "['class', 'ListLearner', '(', 'Learner', ')', ':', '___NEWLINE___', '#', '___NL___', '# Parameter', '___NL___', '#', '___NL___', '___EOS___']", "index": 65 } ]
[ { "span": "from pebl import prior, config, evaluator, result, network", "start_line": 2, "start_column": 0, "end_line": 2, "end_column": 58 }, { "span": "from pebl.taskcontroller.base import Task", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 41 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\"\"\"", "Class", "es", " ", "and", " ", "function", "s", " ", "for", " ", "doi", "ng", " ", "exhaust", "ive", " ", "learn", "ing", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "pe", "bl_", "import_", "prior_", ",_", "config_", ",_", "evaluator_", ",_", "result_", ",_", "network_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pe", "bl_", "._", "learner_", "._", "base_", "import_", "Learner", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pe", "bl_", "._", "task", "controller_", "._", "base_", "import_", "Task_", "\\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_", "List", "Learner", "_", "(_", "Learner", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Parameter_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u", "params_", "=_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "config_", "._", "String", "Parameter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "list", "learner", ".", "network", "s", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"\"\"", "List", " ", "of", " ", "network", "s", ",", " ", "one", " ", "per", " ", "line", ",", " ", "in", " ", "network", ".", "Network", ".", "as", "\\u", "string", "()", "\\", "10", ";", " ", " ", " ", " ", "format", ".\"\"\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "''_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "List", "Learner", "_", "(_", "Learner", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Parameter_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "data\\u", "_", "=_", "None_", ",_", "prior", "\\u_", "=_", "None_", ",_", "networks_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Creat", "e", " ", "a", " ", "List", "Learner", " ", "learner", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "network", "s", " ", "shou", "ld", " ", "be", " ", "a", " ", "list", " ", "of", " ", "network", "s", " ", "(", "as", " ", "network", ".", "Network", " ", "instance", "s", ").", " ", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "super_", "(_", "List", "Learner", "_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "data\\u", "_", ",_", "prior", "\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "networks_", "=_", "networks_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "networks_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "variables_", "=_", "self_", "._", "data_", "._", "variables_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u", "net_", "=_", "lambda_", "nets", "tr_", ":_", "network_", "._", "Network_", "(_", "variables_", ",_", "nets", "tr_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nets", "tring", "s_", "=_", "config_", "._", "get_", "(_", "'", "list", "learner", ".", "network", "s", "'_", ")_", "._", "splitlines_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "networks_", "=_", "(_", "\\u", "net_", "(_", "s_", ")_", "for_", "s_", "in_", "nets", "tring", "s_", "if_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "List", "Learner", "_", "(_", "Learner", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Parameter_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "run_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "result_", "=_", "result_", "._", "Learner", "Result_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "evaluator_", "=_", "evaluator_", "._", "from", "config_", "(_", "self_", "._", "data_", ",_", "prior", "\\u_", "=_", "self_", "._", "prior_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "result_", "._", "start", "\\u", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "net_", "in_", "self_", "._", "networks_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "result_", "._", "add", "\\u", "network_", "(_", "net_", ",_", "self_", "._", "evaluator_", "._", "score", "\\u", "network_", "(_", "net_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "result_", "._", "stop", "\\u", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "List", "Learner", "_", "(_", "Learner", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Parameter_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "split_", "(_", "self_", ",_", "count_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Split", " ", "the", " ", "learner", " ", "int", "o", " ", "multiple", " ", "learner", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Split", "s", " ", "self", ".", "network", "s", " ", "int", "o", " ", "`", "count", "`", " ", "part", "s", ".", " ", "Thi", "s", " ", "is", " ", "similar", " ", "to", " ", "MPI", "'", "s", "\\", "10", ";", " ", " ", " ", " ", "scatter", " ", "functional", "it", "y", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "nets_", "=_", "list_", "(_", "self_", "._", "networks_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "nets_", "=_", "len_", "(_", "nets_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "nets", "pert", "ask_", "=_", "num", "nets_", "/_", "count_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "divide", " ", "list", " ", "int", "o", " ", "parts_", "\\u\\u\\uNL\\u\\u\\u_", "indices_", "=_", "[_", "[_", "i_", ",_", "i_", "+_", "nets", "pert", "ask_", "]_", "for_", "i_", "in_", "xrange_", "(_", "0_", ",_", "num", "nets_", ",_", "nets", "pert", "ask_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "indices_", ")_", ">_", "count_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "indices_", "._", "pop_", "(_", "-_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "indices_", "[_", "-_", "1_", "]_", "[_", "1_", "]_", "=_", "num", "nets_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "[_", "List", "Learner", "_", "(_", "self_", "._", "data_", ",_", "self_", "._", "prior_", ",_", "nets_", "[_", "i_", ":_", "j_", "]_", ")_", "for_", "i_", ",_", "j_", "in_", "indices_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "List", "Learner", "_", "(_", "Learner", "_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Parameter_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "getstate", "\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "convert", " ", "self", ".", "network", " ", "from", " ", "iterators", " ", "or", " ", "generat", "ors", " ", "to", " ", "a", " ", "list_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "d_", "=_", "self_", "._", "\\u\\u", "dict\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "[_", "'", "network", "s", "'_", "]_", "=_", "list_", "(_", "d_", "[_", "'", "network", "s", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "d_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 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, 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, 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 ]
Imprecise assert
anandology/pyjamas/examples/libtest/BuiltinTest.py
[ { "content": " def testType(self):\n try:\n self.assertTrue(type(object) is type)\n except NotImplementedError, why:\n self.fail(\"Bug #229\" + str(why))\n self.assertTrue(type([]) is type([]))\n self.assertTrue(type([]) is list)\n try:\n self.assertTrue(type([]) == list)\n except:\n self.fail(\"Bug #515\")\n self.assertTrue(type(\"\") is str, \"str\")\n self.assertTrue(type(True) is bool, \"bool\")\n self.assertTrue(type(1) is int, \"int\")\n self.assertTrue(type(1L) is long, \"long\")\n self.assertTrue(type(1.1) is float, \"float 1.1\")\n self.assertTrue(type(1.0) is float, \"float 1.0 issue #524\")", "metadata": "root.BuiltinTest.testType", "header": "['class', 'BuiltinTest', '(', 'UnitTest', ')', ':', '___EOS___']", "index": 509 }, { "content": " def testSlice(self):\n # repr()\n self.assertEqual(repr(slice(1, 2, 3)), \"slice(1, 2, 3)\", \"slice() is mis-used, issue #582\")\n # cmp, partial\n s1 = slice(1, 2, 3)\n s2 = slice(1, 2, 3)\n s3 = slice(1, 2, 4)\n self.assertEqual(s1, s2)\n self.assertNotEqual(s1, s3, \"slice() is mis-used, issue #582\")\n # members\n try:\n s = slice(1)\n except Exception, e:\n self.fail(\"slice() is mis-used, issue #582\")\n return False\n self.assertEqual(s.start, None)\n self.assertEqual(s.stop, 1)\n self.assertEqual(s.step, None)\n\n s = slice(1, 2)\n self.assertEqual(s.start, 1)\n self.assertEqual(s.stop, 2)\n self.assertEqual(s.step, None)\n\n s = slice(1, 2, 3)\n self.assertEqual(s.start, 1)\n self.assertEqual(s.stop, 2)\n self.assertEqual(s.step, 3)\n\n class AnyClass:\n pass\n\n obj = AnyClass()\n s = slice(obj)\n self.assertTrue(s.stop is obj)\n # indices\n self.assertEqual(slice(None ).indices(10), (0, 10, 1))\n self.assertEqual(slice(None, None, 2).indices(10), (0, 10, 2))\n self.assertEqual(slice(1, None, 2).indices(10), (1, 10, 2))\n self.assertEqual(slice(None, None, -1).indices(10), (9, -1, -1))\n self.assertEqual(slice(None, None, -2).indices(10), (9, -1, -2))\n self.assertEqual(slice(3, None, -2).indices(10), (3, -1, -2))\n self.assertEqual(slice(None, -9).indices(10), (0, 1, 1))\n self.assertEqual(slice(None, -10).indices(10), (0, 0, 1))\n self.assertEqual(slice(None, -11).indices(10), (0, 0, 1))\n self.assertEqual(slice(None, -10, -1).indices(10), (9, 0, -1))\n self.assertEqual(slice(None, -11, -1).indices(10), (9, -1, -1))\n self.assertEqual(slice(None, -12, -1).indices(10), (9, -1, -1))\n self.assertEqual(slice(None, 9).indices(10), (0, 9, 1))\n self.assertEqual(slice(None, 10).indices(10), (0, 10, 1))\n self.assertEqual(slice(None, 11).indices(10), (0, 10, 1))\n self.assertEqual(slice(None, 8, -1).indices(10), (9, 8, -1))\n self.assertEqual(slice(None, 9, -1).indices(10), (9, 9, -1))\n self.assertEqual(slice(None, 10, -1).indices(10), (9, 9, -1))\n\n self.assertEqual(\n slice(-100, 100 ).indices(10),\n slice(None).indices(10)\n )\n self.assertEqual(\n slice(100, -100, -1).indices(10),\n slice(None, None, -1).indices(10)\n )\n self.assertEqual(slice(-100L, 100L, 2L).indices(10), (0, 10, 2))", "metadata": "root.BuiltinTest.testSlice", "header": "['class', 'BuiltinTest', '(', 'UnitTest', ')', ':', '___EOS___']", "index": 566 } ]
[ { "span": "self.assertTrue(type(object) is type)", "start_line": 511, "start_column": 12, "end_line": 511, "end_column": 49 }, { "span": "self.assertTrue(type([]) is type([]))", "start_line": 514, "start_column": 8, "end_line": 514, "end_column": 45 }, { "span": "self.assertTrue(type([]) is list)", "start_line": 515, "start_column": 8, "end_line": 515, "end_column": 41 }, { "span": "self.assertTrue(type([]) == list)", "start_line": 517, "start_column": 12, "end_line": 517, "end_column": 45 }, { "span": "self.assertTrue(s.stop is obj)", "start_line": 600, "start_column": 8, "end_line": 600, "end_column": 38 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Bu", "ilt", "in", "Test_", "(_", "Unit", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Type_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "type_", "(_", "object_", ")_", "is_", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Not", "Impl", "ement", "ed", "Error_", ",_", "why_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "\"", "Bug", " ", "#", "229", "\"_", "+_", "str_", "(_", "why_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "[_", "]_", ")_", "is_", "type_", "(_", "[_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "[_", "]_", ")_", "is_", "list_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "type_", "(_", "[_", "]_", ")_", "==_", "list_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "\"", "Bug", " ", "#", "515", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "\"\"_", ")_", "is_", "str_", ",_", "\"", "str", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "True_", ")_", "is_", "bool_", ",_", "\"", "bool", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "1_", ")_", "is_", "int_", ",_", "\"", "int", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "1_", "L_", ")_", "is_", "long_", ",_", "\"", "long", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "1.1_", ")_", "is_", "float_", ",_", "\"", "float", " ", "1.1", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "type_", "(_", "1.0_", ")_", "is_", "float_", ",_", "\"", "float", " ", "1.0", " ", "issue", " ", "#", "524", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Bu", "ilt", "in", "Test_", "(_", "Unit", "Test_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Slice_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "repr", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "Equal_", "(_", "repr_", "(_", "slice_", "(_", "1_", ",_", "2_", ",_", "3_", ")_", ")_", ",_", "\"", "slice", "(", "1", ",", " ", "2", ",", " ", "3", ")\"_", ",_", "\"", "slice", "()", " ", "is", " ", "mis", "-", "used", ",", " ", "issue", " ", "#", "582", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "cmp", ",", " ", "partial_", "\\u\\u\\uNL\\u\\u\\u_", "s1_", "=_", "slice_", "(_", "1_", ",_", "2_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s2_", "=_", "slice_", "(_", "1_", ",_", "2_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s3_", "=_", "slice_", "(_", "1_", ",_", "2_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s1_", ",_", "s2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Not", "Equal_", "(_", "s1_", ",_", "s3_", ",_", "\"", "slice", "()", " ", "is", " ", "mis", "-", "used", ",", " ", "issue", " ", "#", "582", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "members_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "slice_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "\"", "slice", "()", " ", "is", " ", "mis", "-", "used", ",", " ", "issue", " ", "#", "582", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "._", "start_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "._", "stop_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "._", "step_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "=_", "slice_", "(_", "1_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "._", "start_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "._", "stop_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "._", "step_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "s_", "=_", "slice_", "(_", "1_", ",_", "2_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "._", "start_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "._", "stop_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", "._", "step_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Any", "Class_", ":_", "\\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_", "obj_", "=_", "Any", "Class_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "slice_", "(_", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "s_", "._", "stop_", "is_", "obj_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "indices_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "0_", ",_", "10_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "None_", ",_", "2_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "0_", ",_", "10_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "1_", ",_", "None_", ",_", "2_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "1_", ",_", "10_", ",_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "None_", ",_", "-_", "1_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "9_", ",_", "-_", "1_", ",_", "-_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "None_", ",_", "-_", "2_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "9_", ",_", "-_", "1_", ",_", "-_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "3_", ",_", "None_", ",_", "-_", "2_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "3_", ",_", "-_", "1_", ",_", "-_", "2_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "-_", "9_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "0_", ",_", "1_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "-_", "10_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "0_", ",_", "0_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "-_", "11_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "0_", ",_", "0_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "-_", "10_", ",_", "-_", "1_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "9_", ",_", "0_", ",_", "-_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "-_", "11_", ",_", "-_", "1_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "9_", ",_", "-_", "1_", ",_", "-_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "-_", "12_", ",_", "-_", "1_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "9_", ",_", "-_", "1_", ",_", "-_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "9_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "0_", ",_", "9_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "10_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "0_", ",_", "10_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "11_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "0_", ",_", "10_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "8_", ",_", "-_", "1_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "9_", ",_", "8_", ",_", "-_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "9_", ",_", "-_", "1_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "9_", ",_", "9_", ",_", "-_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "None_", ",_", "10_", ",_", "-_", "1_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "9_", ",_", "9_", ",_", "-_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "slice_", "(_", "-_", "100_", ",_", "100_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "slice_", "(_", "None_", ")_", "._", "indices_", "(_", "10_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "slice_", "(_", "100_", ",_", "-_", "100_", ",_", "-_", "1_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "slice_", "(_", "None_", ",_", "None_", ",_", "-_", "1_", ")_", "._", "indices_", "(_", "10_", ")_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "slice_", "(_", "-_", "100_", "L_", ",_", "100_", "L_", ",_", "2_", "L_", ")_", "._", "indices_", "(_", "10_", ")_", ",_", "(_", "0_", ",_", "10_", ",_", "2_", ")_", ")_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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"content": " def __init__(self, container, message, *args):\n self.container = container\n self.message = message\n super(OrchestrationException, self).__init__(message, args)", "metadata": "root.ContainerOrchestrationException.__init__", "header": "['class', 'ContainerOrchestrationException', '(', 'OrchestrationException', ')', ':', '___EOS___']", "index": 50 } ]
[ { "span": "super(OrchestrationException, self).", "start_line": 53, "start_column": 8, "end_line": 53, "end_column": 43 } ]
[]
1
true
[ "[CLS]_", "First_", "argument_", "to_", "super_", "(_", ")_", "is_", "not_", "encl", "osin", "g_", "class_", "[SEP]_", "class_", "Containe", "r", "Orc", "hes", "trat", "ion", "Exception_", "(_", "Orc", "hes", "trat", "ion", "Exception_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "container_", ",_", "message_", ",_", "*_", "args_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "container_", "=_", "container_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "message_", "=_", "message_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Orc", "hes", "trat", "ion", "Exception_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "message_", ",_", "args_", ")_", "\\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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused local variable
CollabQ/CollabQ/.google_appengine/google/appengine/ext/admin/__init__.py
[ { "content": " def post(self):\n kind = self.request.get('kind')\n\n keys = []\n index = 0\n num_keys = int(self.request.get('numkeys'))\n for i in xrange(1, num_keys+1):\n key = self.request.get('key%d' % i)\n if key:\n keys.append(key)\n\n if self.request.get('action') == 'Delete':\n num_deleted = 0\n for key in keys:\n datastore.Delete(datastore.Key(key))\n num_deleted = num_deleted + 1\n message = '%d entit%s deleted.' % (\n num_deleted, ('ies', 'y')[num_deleted == 1])\n self.redirect(\n '%s&msg=%s' % (self.request.get('next'), urllib.quote_plus(message)))\n return\n\n self.error(404)", "metadata": "root.DatastoreBatchEditHandler.post", "header": "['class', 'DatastoreBatchEditHandler', '(', 'DatastoreRequestHandler', ')', ':', '___EOS___']", "index": 751 }, { "content": " def get(self):\n entity_key = self.request.get('key')\n if entity_key:\n key_instance = datastore.Key(entity_key)\n entity_key_name = key_instance.name()\n entity_key_id = key_instance.id()\n parent_key = key_instance.parent()\n kind = key_instance.kind()\n entity = datastore.Get(key_instance)\n sample_entities = [entity]\n else:\n kind = self.request.get('kind')\n sample_entities = self.execute_query()[0]\n\n if len(sample_entities) < 1:\n next_uri = self.request.get('next')\n kind_param = 'kind=%s' % kind\n if not kind_param in next_uri:\n if '?' in next_uri:\n next_uri += '&' + kind_param\n else:\n next_uri += '?' + kind_param\n self.redirect(next_uri)\n return\n\n if not entity_key:\n key_instance = None\n entity_key_name = None\n entity_key_id = None\n parent_key = None\n entity = None\n\n if parent_key:\n parent_kind = parent_key.kind()\n parent_key_string = PseudoBreadcrumbs(parent_key)\n else:\n parent_kind = None\n parent_key_string = None\n\n fields = []\n key_values = self.get_key_values(sample_entities)\n for key, sample_values in key_values.iteritems():\n if entity and entity.has_key(key):\n data_type = DataType.get(entity[key])\n else:\n data_type = DataType.get(sample_values[0])\n name = data_type.name() + \"|\" + key\n if entity and entity.has_key(key):\n value = entity[key]\n else:\n value = None\n field = data_type.input_field(name, value, sample_values)\n fields.append((key, data_type.name(), field))\n\n self.generate('datastore_edit.html', {\n 'kind': kind,\n 'key': entity_key,\n 'key_name': entity_key_name,\n 'key_id': entity_key_id,\n 'fields': fields,\n 'focus': self.request.get('focus'),\n 'next': self.request.get('next'),\n 'parent_key': parent_key,\n 'parent_kind': parent_kind,\n 'parent_key_string': parent_key_string,\n })", "metadata": "root.DatastoreEditHandler.get", "header": "['class', 'DatastoreEditHandler', '(', 'DatastoreRequestHandler', ')', ':', '___EOS___']", "index": 787 } ]
[ { "span": "kind ", "start_line": 752, "start_column": 4, "end_line": 752, "end_column": 8 }, { "span": "index ", "start_line": 755, "start_column": 4, "end_line": 755, "end_column": 9 }, { "span": "key_instance ", "start_line": 813, "start_column": 6, "end_line": 813, "end_column": 18 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "Datas", "tore", "Bat", "ch", "Edit", "Handler_", "(_", "Datas", "tore", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "post_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kind_", "=_", "self_", "._", "request_", "._", "get_", "(_", "'", "kind", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "keys_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "keys_", "=_", "int_", "(_", "self_", "._", "request_", "._", "get_", "(_", "'", "num", "keys", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "xrange_", "(_", "1_", ",_", "num", "\\u", "keys_", "+_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "key_", "=_", "self_", "._", "request_", "._", "get_", "(_", "'", "key", "%", "d", "'_", "%_", "i_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "key_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "keys_", "._", "append_", "(_", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "request_", "._", "get_", "(_", "'", "action", "'_", ")_", "==_", "'", "Delete", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "num", "\\u", "deleted_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", "in_", "keys_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "datastore_", "._", "Delete_", "(_", "datastore_", "._", "Key_", "(_", "key_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "num", "\\u", "deleted_", "=_", "num", "\\u", "deleted_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "message_", "=_", "'%", "d", " ", "entit", "%", "s", " ", "delete", "d", ".'_", "%_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "num", "\\u", "deleted_", ",_", "(_", "'", "ies", "'_", ",_", "'", "y", "'_", ")_", "[_", "num", "\\u", "deleted_", "==_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "redirect_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'%", "s", "&", "msg", "=", "%", "s", "'_", "%_", "(_", "self_", "._", "request_", "._", "get_", "(_", "'", "next", "'_", ")_", ",_", "urllib_", "._", "quote", "\\u", "plus_", "(_", "message_", ")_", ")_", ")_", "\\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_", "self_", "._", "error_", "(_", "404_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Datas", "tore", "Edit", "Handler_", "(_", "Datas", "tore", "Request", "Handler_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "entity", "\\u", "key_", "=_", "self_", "._", "request_", "._", "get_", "(_", "'", "key", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "entity", "\\u", "key_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "key", "\\u", "instance_", "=_", "datastore_", "._", "Key_", "(_", "entity", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity", "\\u", "key", "\\u", "name_", "=_", "key", "\\u", "instance_", "._", "name_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity", "\\u", "key", "\\u", "id_", "=_", "key", "\\u", "instance_", "._", "id_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent", "\\u", "key_", "=_", "key", "\\u", "instance_", "._", "parent_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kind_", "=_", "key", "\\u", "instance_", "._", "kind_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity_", "=_", "datastore_", "._", "Get_", "(_", "key", "\\u", "instance_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sample", "\\u", "entities_", "=_", "[_", "entity_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kind_", "=_", "self_", "._", "request_", "._", "get_", "(_", "'", "kind", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sample", "\\u", "entities_", "=_", "self_", "._", "execute", "\\u", "query_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "sample", "\\u", "entities_", ")_", "<_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "next", "\\u", "uri_", "=_", "self_", "._", "request_", "._", "get_", "(_", "'", "next", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kind", "\\u", "param_", "=_", "'", "kind", "=", "%", "s", "'_", "%_", "kind_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "kind", "\\u", "param_", "in_", "next", "\\u", "uri_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'?'_", "in_", "next", "\\u", "uri_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "next", "\\u", "uri_", "+=_", "'&'_", "+_", "kind", "\\u", "param_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "next", "\\u", "uri_", "+=_", "'?'_", "+_", "kind", "\\u", "param_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "redirect_", "(_", "next", "\\u", "uri_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "entity", "\\u", "key_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "key", "\\u", "instance_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity", "\\u", "key", "\\u", "name_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity", "\\u", "key", "\\u", "id_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent", "\\u", "key_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entity_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "parent", "\\u", "key_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parent", "\\u", "kind_", "=_", "parent", "\\u", "key_", "._", "kind_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent", "\\u", "key", "\\u", "string_", "=_", "Pse", "udo", "Bre", "adc", "rum", "bs_", "(_", "parent", "\\u", "key_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "parent", "\\u", "kind_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parent", "\\u", "key", "\\u", "string_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fields_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "key", "\\u", "values_", "=_", "self_", "._", "get", "\\u", "key", "\\u", "values_", "(_", "sample", "\\u", "entities_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "key_", ",_", "sample", "\\u", "values_", "in_", "key", "\\u", "values_", "._", "iteritems_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "entity_", "and_", "entity_", "._", "has", "\\u", "key_", "(_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data\\u", "type_", "=_", "Data", "Type_", "._", "get_", "(_", "entity_", "[_", "key_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data\\u", "type_", "=_", "Data", "Type_", "._", "get_", "(_", "sample", "\\u", "values_", "[_", "0_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "name_", "=_", "data\\u", "type_", "._", "name_", "(_", ")_", "+_", "\"|\"_", "+_", "key_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "entity_", "and_", "entity_", "._", "has", "\\u", "key_", "(_", "key_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "entity_", "[_", "key_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "value_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "field_", "=_", "data\\u", "type_", "._", "input", "\\u", "field_", "(_", "name_", ",_", "value_", ",_", "sample", "\\u", "values_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fields_", "._", "append_", "(_", "(_", "key_", ",_", "data\\u", "type_", "._", "name_", "(_", ")_", ",_", "field_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "generate_", "(_", "'", "datast", "ore", "\\u", "edit", ".", "html", "'_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "kind", "'_", ":_", "kind_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "entity", "\\u", "key_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "\\u", "name", "'_", ":_", "entity", "\\u", "key", "\\u", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "\\u", "id", "'_", ":_", "entity", "\\u", "key", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "fields", "'_", ":_", "fields_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "foc", "us", "'_", ":_", "self_", "._", "request_", "._", "get_", "(_", "'", "foc", "us", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "next", "'_", ":_", "self_", "._", "request_", "._", "get_", "(_", "'", "next", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "parent", "\\u", "key", "'_", ":_", "parent", "\\u", "key_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "parent", "\\u", "kind", "'_", ":_", "parent", "\\u", "kind_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "parent", "\\u", "key", "\\u", "string", "'_", ":_", "parent", "\\u", "key", "\\u", "string_", ",_", "\\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, 0, 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 ]
Conflicting attributes in base classes
OpenCobolIDE/OpenCobolIDE/open_cobol_ide/extlibs/future/backports/socketserver.py
[ { "content": "class BaseServer(object):\n\n \"\"\"Base class for server classes.\n\n Methods for the caller:\n\n - __init__(server_address, RequestHandlerClass)\n - serve_forever(poll_interval=0.5)\n - shutdown()\n - handle_request() # if you do not use serve_forever()\n - fileno() -> int # for select()\n\n Methods that may be overridden:\n\n - server_bind()\n - server_activate()\n - get_request() -> request, client_address\n - handle_timeout()\n - verify_request(request, client_address)\n - server_close()\n - process_request(request, client_address)\n - shutdown_request(request)\n - close_request(request)\n - service_actions()\n - handle_error()\n\n Methods for derived classes:\n\n - finish_request(request, client_address)\n\n Class variables that may be overridden by derived classes or\n instances:\n\n - timeout\n - address_family\n - socket_type\n - allow_reuse_address\n\n Instance variables:\n\n - RequestHandlerClass\n - socket\n\n \"\"\"\n\n timeout = None\n\n\n\n\n\n\n # The distinction between handling, getting, processing and\n # finishing a request is fairly arbitrary. Remember:\n #\n # - handle_request() is the top-level call. It calls\n # select, get_request(), verify_request() and process_request()\n # - get_request() is different for stream or datagram sockets\n # - process_request() is the place that may fork a new process\n # or create a new thread to finish the request\n # - finish_request() instantiates the request handler class;\n # this constructor will handle the request all by itself\n\n\n\n\n\n\n\n\n\n", "metadata": "root.BaseServer", "header": "['module', '___EOS___']", "index": 161 }, { "content": " def __init__(self, server_address, RequestHandlerClass):\n \"\"\"Constructor. May be extended, do not override.\"\"\"\n self.server_address = server_address\n self.RequestHandlerClass = RequestHandlerClass\n self.__is_shut_down = threading.Event()\n self.__shutdown_request = False", "metadata": "root.BaseServer.__init__", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 208 }, { "content": " def server_activate(self):\n \"\"\"Called by constructor to activate the server.\n\n May be overridden.\n\n \"\"\"\n pass", "metadata": "root.BaseServer.server_activate", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 215 }, { "content": " def serve_forever(self, poll_interval=0.5):\n \"\"\"Handle one request at a time until shutdown.\n\n Polls for shutdown every poll_interval seconds. Ignores\n self.timeout. If you need to do periodic tasks, do them in\n another thread.\n \"\"\"\n self.__is_shut_down.clear()\n try:\n while not self.__shutdown_request:\n # XXX: Consider using another file descriptor or\n # connecting to the socket to wake this up instead of\n # polling. Polling reduces our responsiveness to a\n # shutdown request and wastes cpu at all other times.\n r, w, e = _eintr_retry(select.select, [self], [], [],\n poll_interval)\n if self in r:\n self._handle_request_noblock()\n\n self.service_actions()\n finally:\n self.__shutdown_request = False\n self.__is_shut_down.set()", "metadata": "root.BaseServer.serve_forever", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 223 }, { "content": " def shutdown(self):\n \"\"\"Stops the serve_forever loop.\n\n Blocks until the loop has finished. This must be called while\n serve_forever() is running in another thread, or it will\n deadlock.\n \"\"\"\n self.__shutdown_request = True\n self.__is_shut_down.wait()", "metadata": "root.BaseServer.shutdown", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 247 }, { "content": " def service_actions(self):\n \"\"\"Called by the serve_forever() loop.\n\n May be overridden by a subclass / Mixin to implement any code that\n needs to be run during the loop.\n \"\"\"\n pass", "metadata": "root.BaseServer.service_actions", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 257 }, { "content": " def handle_request(self):\n \"\"\"Handle one request, possibly blocking.\n\n Respects self.timeout.\n \"\"\"\n # Support people who used socket.settimeout() to escape\n # handle_request before self.timeout was available.\n timeout = self.socket.gettimeout()\n if timeout is None:\n timeout = self.timeout\n elif self.timeout is not None:\n timeout = min(timeout, self.timeout)\n fd_sets = _eintr_retry(select.select, [self], [], [], timeout)\n if not fd_sets[0]:\n self.handle_timeout()\n return\n self._handle_request_noblock()", "metadata": "root.BaseServer.handle_request", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 276 }, { "content": " def _handle_request_noblock(self):\n \"\"\"Handle one request, without blocking.\n\n I assume that select.select has returned that the socket is\n readable before this function was called, so there should be\n no risk of blocking in get_request().\n \"\"\"\n try:\n request, client_address = self.get_request()\n except socket.error:\n return\n if self.verify_request(request, client_address):\n try:\n self.process_request(request, client_address)\n except:\n self.handle_error(request, client_address)\n self.shutdown_request(request)", "metadata": "root.BaseServer._handle_request_noblock", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 294 }, { "content": " def handle_timeout(self):\n \"\"\"Called if no new request arrives within self.timeout.\n\n Overridden by ForkingMixIn.\n \"\"\"\n pass", "metadata": "root.BaseServer.handle_timeout", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 312 }, { "content": " def verify_request(self, request, client_address):\n \"\"\"Verify the request. May be overridden.\n\n Return True if we should proceed with this request.\n\n \"\"\"\n return True", "metadata": "root.BaseServer.verify_request", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 319 }, { "content": " def process_request(self, request, client_address):\n \"\"\"Call finish_request.\n\n Overridden by ForkingMixIn and ThreadingMixIn.\n\n \"\"\"\n self.finish_request(request, client_address)\n self.shutdown_request(request)", "metadata": "root.BaseServer.process_request", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 327 }, { "content": " def server_close(self):\n \"\"\"Called to clean-up the server.\n\n May be overridden.\n\n \"\"\"\n pass", "metadata": "root.BaseServer.server_close", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 336 }, { "content": " def finish_request(self, request, client_address):\n \"\"\"Finish one request by instantiating RequestHandlerClass.\"\"\"\n self.RequestHandlerClass(request, client_address, self)", "metadata": "root.BaseServer.finish_request", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 344 }, { "content": " def shutdown_request(self, request):\n \"\"\"Called to shutdown and close an individual request.\"\"\"\n self.close_request(request)", "metadata": "root.BaseServer.shutdown_request", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 348 }, { "content": " def close_request(self, request):\n \"\"\"Called to clean up an individual request.\"\"\"\n pass", "metadata": "root.BaseServer.close_request", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 352 }, { "content": " def handle_error(self, request, client_address):\n \"\"\"Handle an error gracefully. May be overridden.\n\n The default is to print a traceback and continue.\n\n \"\"\"\n print('-'*40)\n print('Exception happened during processing of request from', end=' ')\n print(client_address)\n import traceback\n traceback.print_exc() # XXX But this goes to stderr!\n print('-'*40)", "metadata": "root.BaseServer.handle_error", "header": "['class', 'BaseServer', '(', 'object', ')', ':', '___EOS___']", "index": 356 }, { "content": "class TCPServer(BaseServer):\n\n \"\"\"Base class for various socket-based server classes.\n\n Defaults to synchronous IP stream (i.e., TCP).\n\n Methods for the caller:\n\n - __init__(server_address, RequestHandlerClass, bind_and_activate=True)\n - serve_forever(poll_interval=0.5)\n - shutdown()\n - handle_request() # if you don't use serve_forever()\n - fileno() -> int # for select()\n\n Methods that may be overridden:\n\n - server_bind()\n - server_activate()\n - get_request() -> request, client_address\n - handle_timeout()\n - verify_request(request, client_address)\n - process_request(request, client_address)\n - shutdown_request(request)\n - close_request(request)\n - handle_error()\n\n Methods for derived classes:\n\n - finish_request(request, client_address)\n\n Class variables that may be overridden by derived classes or\n instances:\n\n - timeout\n - address_family\n - socket_type\n - request_queue_size (only for stream sockets)\n - allow_reuse_address\n\n Instance variables:\n\n - server_address\n - RequestHandlerClass\n - socket\n\n \"\"\"\n\n address_family = socket.AF_INET\n\n socket_type = socket.SOCK_STREAM\n\n request_queue_size = 5\n\n allow_reuse_address = False\n\n\n\n\n\n\n\n", "metadata": "root.TCPServer", "header": "['module', '___EOS___']", "index": 370 }, { "content": " def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True):\n \"\"\"Constructor. May be extended, do not override.\"\"\"\n BaseServer.__init__(self, server_address, RequestHandlerClass)\n self.socket = socket.socket(self.address_family,\n self.socket_type)\n if bind_and_activate:\n self.server_bind()\n self.server_activate()", "metadata": "root.TCPServer.__init__", "header": "['class', 'TCPServer', '(', 'BaseServer', ')', ':', '___EOS___']", "index": 425 }, { "content": " def server_bind(self):\n \"\"\"Called by constructor to bind the socket.\n\n May be overridden.\n\n \"\"\"\n if self.allow_reuse_address:\n self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n self.socket.bind(self.server_address)\n self.server_address = self.socket.getsockname()", "metadata": "root.TCPServer.server_bind", "header": "['class', 'TCPServer', '(', 'BaseServer', ')', ':', '___EOS___']", "index": 434 }, { "content": " def server_activate(self):\n \"\"\"Called by constructor to activate the server.\n\n May be overridden.\n\n \"\"\"\n self.socket.listen(self.request_queue_size)", "metadata": "root.TCPServer.server_activate", "header": "['class', 'TCPServer', '(', 'BaseServer', ')', ':', '___EOS___']", "index": 445 }, { "content": " def server_close(self):\n \"\"\"Called to clean-up the server.\n\n May be overridden.\n\n \"\"\"\n self.socket.close()", "metadata": "root.TCPServer.server_close", "header": "['class', 'TCPServer', '(', 'BaseServer', ')', ':', '___EOS___']", "index": 453 }, { "content": " def fileno(self):\n \"\"\"Return socket file number.\n\n Interface required by select().\n\n \"\"\"\n return self.socket.fileno()", "metadata": "root.TCPServer.fileno", "header": "['class', 'TCPServer', '(', 'BaseServer', ')', ':', '___EOS___']", "index": 461 }, { "content": " def get_request(self):\n \"\"\"Get the request and client address from the socket.\n\n May be overridden.\n\n \"\"\"\n return self.socket.accept()", "metadata": "root.TCPServer.get_request", "header": "['class', 'TCPServer', '(', 'BaseServer', ')', ':', '___EOS___']", "index": 469 }, { "content": " def shutdown_request(self, request):\n \"\"\"Called to shutdown and close an individual request.\"\"\"\n try:\n #explicitly shutdown. socket.close() merely releases\n #the socket and waits for GC to perform the actual close.\n request.shutdown(socket.SHUT_WR)\n except socket.error:\n pass #some platforms may raise ENOTCONN here\n self.close_request(request)", "metadata": "root.TCPServer.shutdown_request", "header": "['class', 'TCPServer', '(', 'BaseServer', ')', ':', '___EOS___']", "index": 477 }, { "content": " def close_request(self, request):\n \"\"\"Called to clean up an individual request.\"\"\"\n request.close()", "metadata": "root.TCPServer.close_request", "header": "['class', 'TCPServer', '(', 'BaseServer', ')', ':', '___EOS___']", "index": 487 }, { "content": "class UDPServer(TCPServer):\n\n \"\"\"UDP server class.\"\"\"\n\n allow_reuse_address = False\n\n socket_type = socket.SOCK_DGRAM\n\n max_packet_size = 8192\n\n\n\n", "metadata": "root.UDPServer", "header": "['module', '___EOS___']", "index": 492 }, { "content": " def get_request(self):\n data, client_addr = self.socket.recvfrom(self.max_packet_size)\n return (data, self.socket), client_addr", "metadata": "root.UDPServer.get_request", "header": "['class', 'UDPServer', '(', 'TCPServer', ')', ':', '___EOS___']", "index": 502 }, { "content": " def server_activate(self):\n # No need to call listen() for UDP.\n pass", "metadata": "root.UDPServer.server_activate", "header": "['class', 'UDPServer', '(', 'TCPServer', ')', ':', '___EOS___']", "index": 506 }, { "content": " def shutdown_request(self, request):\n # No need to shutdown anything.\n self.close_request(request)", "metadata": "root.UDPServer.shutdown_request", "header": "['class', 'UDPServer', '(', 'TCPServer', ')', ':', '___EOS___']", "index": 510 }, { "content": " def close_request(self, request):\n # No need to close anything.\n pass", "metadata": "root.UDPServer.close_request", "header": "['class', 'UDPServer', '(', 'TCPServer', ')', ':', '___EOS___']", "index": 514 }, { "content": "class ForkingMixIn(object):\n\n \"\"\"Mix-in class to handle each request in a new process.\"\"\"\n\n timeout = 300\n active_children = None\n max_children = 40\n\n\n\n", "metadata": "root.ForkingMixIn", "header": "['module', '___EOS___']", "index": 518 }, { "content": " def collect_children(self):\n \"\"\"Internal routine to wait for children that have exited.\"\"\"\n if self.active_children is None: return\n while len(self.active_children) >= self.max_children:\n # XXX: This will wait for any child process, not just ones\n # spawned by this library. This could confuse other\n # libraries that expect to be able to wait for their own\n # children.\n try:\n pid, status = os.waitpid(0, 0)\n except os.error:\n pid = None\n if pid not in self.active_children: continue\n self.active_children.remove(pid)\n\n # XXX: This loop runs more system calls than it ought\n # to. There should be a way to put the active_children into a\n # process group and then use os.waitpid(-pgid) to wait for any\n # of that set, but I couldn't find a way to allocate pgids\n # that couldn't collide.\n for child in self.active_children:\n try:\n pid, status = os.waitpid(child, os.WNOHANG)\n except os.error:\n pid = None\n if not pid: continue\n try:\n self.active_children.remove(pid)\n except ValueError as e:\n raise ValueError('%s. x=%d and list=%r' % (e.message, pid,\n self.active_children))", "metadata": "root.ForkingMixIn.collect_children", "header": "['class', 'ForkingMixIn', '(', 'object', ')', ':', '___EOS___']", "index": 526 }, { "content": " def handle_timeout(self):\n \"\"\"Wait for zombies after self.timeout seconds of inactivity.\n\n May be extended, do not override.\n \"\"\"\n self.collect_children()", "metadata": "root.ForkingMixIn.handle_timeout", "header": "['class', 'ForkingMixIn', '(', 'object', ')', ':', '___EOS___']", "index": 558 }, { "content": " def service_actions(self):\n \"\"\"Collect the zombie child processes regularly in the ForkingMixIn.\n\n service_actions is called in the BaseServer's serve_forver loop.\n \"\"\"\n self.collect_children()", "metadata": "root.ForkingMixIn.service_actions", "header": "['class', 'ForkingMixIn', '(', 'object', ')', ':', '___EOS___']", "index": 565 }, { "content": " def process_request(self, request, client_address):\n \"\"\"Fork a new subprocess to process the request.\"\"\"\n pid = os.fork()\n if pid:\n # Parent process\n if self.active_children is None:\n self.active_children = []\n self.active_children.append(pid)\n self.close_request(request)\n return\n else:\n # Child process.\n # This must never return, hence os._exit()!\n try:\n self.finish_request(request, client_address)\n self.shutdown_request(request)\n os._exit(0)\n except:\n try:\n self.handle_error(request, client_address)\n self.shutdown_request(request)\n finally:\n os._exit(1)", "metadata": "root.ForkingMixIn.process_request", "header": "['class', 'ForkingMixIn', '(', 'object', ')', ':', '___EOS___']", "index": 572 }, { "content": "class ForkingUDPServer(ForkingMixIn, UDPServer): pass", "metadata": "root.ForkingUDPServer", "header": "['module', '___EOS___']", "index": 625 }, { "content": "class ForkingTCPServer(ForkingMixIn, TCPServer): pass", "metadata": "root.ForkingTCPServer", "header": "['module', '___EOS___']", "index": 626 } ]
[ { "span": "class ForkingUDPServer(ForkingMixIn, UDPServer): ", "start_line": 625, "start_column": 0, "end_line": 625, "end_column": 48 }, { "span": "class ForkingTCPServer(ForkingMixIn, TCPServer): ", "start_line": 626, "start_column": 0, "end_line": 626, "end_column": 48 } ]
[]
1
false
[ "[CLS]_", "Confl", "ict", "ing_", "attributes_", "in_", "base_", "classes_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Base", "Server_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Base", " ", "class", " ", "for", " ", "server", " ", "classe", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Meth", "ods", " ", "for", " ", "the", " ", "caller", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "\\u\\u", "init", "\\u\\u", "(", "server", "\\u", "address", ",", " ", "Request", "Handle", "r", "Class", ")", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "serve", "\\u", "forever", "(", "poll", "\\u", "interval", "=", "0.", "5", ")", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "shut", "down", "()", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "handle", "\\u", "request", "()", " ", " ", "#", " ", "if", " ", "you", " ", "do", " ", "not", " ", "use", " ", "serve", "\\u", "forever", "()", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "filen", "o", "()", " ", "->", " ", "int", " ", " ", " ", "#", " ", "for", " ", "select", "()", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Meth", "ods", " ", "tha", "t", " ", "may", " ", "be", " ", "overrid", "den", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "server", "\\u", "bind", "()", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "server", "\\u", "activat", "e", "()", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "get", "\\u", "request", "()", " ", "->", " ", "request", ",", " ", "client", "\\u", "address", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "handle", "\\u", "timeo", "ut", "()", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "verify", "\\u", "request", "(", "request", ",", " ", "client", "\\u", "address", ")", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "server", "\\u", "close", "()", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "process", "\\u", "request", "(", "request", ",", " ", "client", "\\u", "address", ")", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "shut", "down", "\\u", "request", "(", "request", ")", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "close", "\\u", "request", "(", "request", ")", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "service", "\\u", "action", "s", "()", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "handle", "\\u", "error", "()", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Meth", "ods", " ", "for", " ", "derive", "d", " ", "classe", "s", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "finish", "\\u", "request", "(", "request", ",", " ", "client", "\\u", "address", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Class", " ", "variab", "les", " ", "tha", "t", " ", "may", " ", "be", " ", "overrid", "den", " ", "by", " ", "derive", "d", " ", "classe", "s", " ", "or", "\\", "10", ";", " ", " ", " ", " ", "instance", "s", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "timeo", "ut", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "address", "\\u", "famil", "y", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "socket", "\\u", "type", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "allow", "\\u", "reus", "e\\u", "address", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Insta", "nce", " ", "variab", "les", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "Request", "Handle", "r", "Class", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "socket", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "timeout_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "distinct", "ion", " ", "bet", "ween", " ", "handling", ",", " ", "getti", "ng", ",", " ", "process", "ing", " ", "and_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "finish", "ing", " ", "a", " ", "request", " ", "is", " ", "fair", "ly", " ", "arbitra", "ry", ".", " ", " ", "Reme", "mber", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-", " ", "handle", "\\u", "request", "()", " ", "is", " ", "the", " ", "top", "-", "level", " ", "call", ".", " ", " ", "It", " ", "calls_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "select", ",", " ", "get", "\\u", "request", "()", ",", " ", "verify", "\\u", "request", "()", " ", "and", " ", "process", "\\u", "request", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-", " ", "get", "\\u", "request", "()", " ", "is", " ", "different", " ", "for", " ", "stream", " ", "or", " ", "datagram", " ", "sockets_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-", " ", "process", "\\u", "request", "()", " ", "is", " ", "the", " ", "place", " ", "tha", "t", " ", "may", " ", "fork", " ", "a", " ", "new", " ", "process_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "or", " ", "create", " ", "a", " ", "new", " ", "thread", " ", "to", " ", "finish", " ", "the", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-", " ", "finish", "\\u", "request", "()", " ", "instantiate", "s", " ", "the", " ", "request", " ", "handler", " ", "class", ";_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", " ", " ", "this", " ", "construct", "or", " ", "will", " ", "handle", " ", "the", " ", "request", " ", "all", " ", "by", " ", "its", "elf_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "server", "\\u", "address_", ",_", "Request", "Handle", "r", "Class_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Constructor", ".", " ", " ", "Ma", "y", " ", "be", " ", "extend", "ed", ",", " ", "do", " ", "not", " ", "override", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "server", "\\u", "address_", "=_", "server", "\\u", "address_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Request", "Handle", "r", "Class_", "=_", "Request", "Handle", "r", "Class_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u\\u", "is", "\\u", "shut", "\\u", "down_", "=_", "threading_", "._", "Event_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u\\u", "shut", "down", "\\u", "request_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "server", "\\u", "activate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Call", "ed", " ", "by", " ", "construct", "or", " ", "to", " ", "activat", "e", " ", "the", " ", "server", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Ma", "y", " ", "be", " ", "overrid", "den", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "serve", "\\u", "forever_", "(_", "self_", ",_", "poll", "\\u", "interval_", "=_", "0.5_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Handle", " ", "one", " ", "request", " ", "at", " ", "a", " ", "time", " ", "unti", "l", " ", "shut", "down", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Poll", "s", " ", "for", " ", "shut", "down", " ", "every", " ", "poll", "\\u", "interval", " ", "second", "s", ".", " ", "Ignor", "es", "\\", "10", ";", " ", " ", " ", " ", "self", ".", "timeo", "ut", ".", " ", "If", " ", "you", " ", "need", " ", "to", " ", "do", " ", "periodic", " ", "task", "s", ",", " ", "do", " ", "them", " ", "in", "\\", "10", ";", " ", " ", " ", " ", "anot", "her", " ", "thread", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u\\u", "is", "\\u", "shut", "\\u", "down_", "._", "clear_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "while_", "not_", "self_", "._", "\\u\\u", "shut", "down", "\\u", "request_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "XX", "X", ":", " ", "Consider", " ", "usi", "ng", " ", "anot", "her", " ", "file", " ", "descrip", "tor", " ", "or_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "connecti", "ng", " ", "to", " ", "the", " ", "socket", " ", "to", " ", "wake", " ", "this", " ", "up", " ", "inst", "ead", " ", "of_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "polling", ".", " ", "Poll", "ing", " ", "reduce", "s", " ", "our", " ", "respons", "ive", "ness", " ", "to", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "shut", "down", " ", "request", " ", "and", " ", "wast", "es", " ", "cpu", " ", "at", " ", "all", " ", "other", " ", "times", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "r_", ",_", "w_", ",_", "e_", "=_", "\\u", "ein", "tr", "\\u", "retry_", "(_", "select_", "._", "select_", ",_", "[_", "self_", "]_", ",_", "[_", "]_", ",_", "[_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "poll", "\\u", "interval_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "in_", "r_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "\\u", "handle", "\\u", "request", "\\u", "nob", "lock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "service", "\\u", "actions_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "finally_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u\\u", "shut", "down", "\\u", "request_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u\\u", "is", "\\u", "shut", "\\u", "down_", "._", "set_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "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_", "shutdown_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Stops", " ", "the", " ", "serve", "\\u", "forever", " ", "loop", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Block", "s", " ", "unti", "l", " ", "the", " ", "loop", " ", "has", " ", "finish", "ed", ".", " ", "Thi", "s", " ", "must", " ", "be", " ", "call", "ed", " ", "whi", "le", "\\", "10", ";", " ", " ", " ", " ", "serve", "\\u", "forever", "()", " ", "is", " ", "runn", "ing", " ", "in", " ", "anot", "her", " ", "thread", ",", " ", "or", " ", "it", " ", "will", "\\", "10", ";", " ", " ", " ", " ", "deadl", "ock", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u\\u", "shut", "down", "\\u", "request_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u\\u", "is", "\\u", "shut", "\\u", "down_", "._", "wait_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "service", "\\u", "actions_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Call", "ed", " ", "by", " ", "the", " ", "serve", "\\u", "forever", "()", " ", "loop", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Ma", "y", " ", "be", " ", "overrid", "den", " ", "by", " ", "a", " ", "subclass", " ", "/", " ", "Mix", "in", " ", "to", " ", "implement", " ", "any", " ", "code", " ", "tha", "t", "\\", "10", ";", " ", " ", " ", " ", "need", "s", " ", "to", " ", "be", " ", "run", " ", "dur", "ing", " ", "the", " ", "loop", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "handle", "\\u", "request_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Handle", " ", "one", " ", "request", ",", " ", "possib", "ly", " ", "blockin", "g", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Resp", "ect", "s", " ", "self", ".", "timeo", "ut", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Supp", "ort", " ", "people", " ", "who", " ", "used", " ", "socket", ".", "setti", "meo", "ut", "()", " ", "to", " ", "escape_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "handle", "\\u", "request", " ", "bef", "ore", " ", "self", ".", "timeo", "ut", " ", "was", " ", "avail", "able", "._", "\\u\\u\\uNL\\u\\u\\u_", "timeout_", "=_", "self_", "._", "socket_", "._", "getti", "meo", "ut_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "timeout_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "timeout_", "=_", "self_", "._", "timeout_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "self_", "._", "timeout_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "timeout_", "=_", "min_", "(_", "timeout_", ",_", "self_", "._", "timeout_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fd", "\\u", "sets_", "=_", "\\u", "ein", "tr", "\\u", "retry_", "(_", "select_", "._", "select_", ",_", "[_", "self_", "]_", ",_", "[_", "]_", ",_", "[_", "]_", ",_", "timeout_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "fd", "\\u", "sets_", "[_", "0_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "handle", "\\u", "timeout_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "\\u", "handle", "\\u", "request", "\\u", "nob", "lock_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "handle", "\\u", "request", "\\u", "nob", "lock_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Handle", " ", "one", " ", "request", ",", " ", "with", "out", " ", "blockin", "g", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "I", " ", "assume", " ", "tha", "t", " ", "select", ".", "select", " ", "has", " ", "return", "ed", " ", "tha", "t", " ", "the", " ", "socket", " ", "is", "\\", "10", ";", " ", " ", " ", " ", "reada", "ble", " ", "bef", "ore", " ", "this", " ", "function", " ", "was", " ", "call", "ed", ",", " ", "so", " ", "there", " ", "shou", "ld", " ", "be", "\\", "10", ";", " ", " ", " ", " ", "no", " ", "risk", " ", "of", " ", "blockin", "g", " ", "in", " ", "get", "\\u", "request", "()", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request_", ",_", "client", "\\u", "address_", "=_", "self_", "._", "get", "\\u", "request_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "socket_", "._", "error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "self_", "._", "verify", "\\u", "request_", "(_", "request_", ",_", "client", "\\u", "address_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "process", "\\u", "request_", "(_", "request_", ",_", "client", "\\u", "address_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "handle", "\\u", "error_", "(_", "request_", ",_", "client", "\\u", "address_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "shut", "down", "\\u", "request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "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_", "handle", "\\u", "timeout_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Call", "ed", " ", "if", " ", "no", " ", "new", " ", "request", " ", "arrive", "s", " ", "within", " ", "self", ".", "timeo", "ut", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Over", "rid", "den", " ", "by", " ", "For", "king", "Mix", "In", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "verify", "\\u", "request_", "(_", "self_", ",_", "request_", ",_", "client", "\\u", "address_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Verify", " ", "the", " ", "request", ".", " ", " ", "Ma", "y", " ", "be", " ", "overrid", "den", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", " ", "Tru", "e", " ", "if", " ", "we", " ", "shou", "ld", " ", "proceed", " ", "with", " ", "this", " ", "request", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "process", "\\u", "request_", "(_", "self_", ",_", "request_", ",_", "client", "\\u", "address_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Call", " ", "finish", "\\u", "request", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Over", "rid", "den", " ", "by", " ", "For", "king", "Mix", "In", " ", "and", " ", "Thread", "ing", "Mix", "In", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "finish", "\\u", "request_", "(_", "request_", ",_", "client", "\\u", "address_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "shut", "down", "\\u", "request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "server", "\\u", "close_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Call", "ed", " ", "to", " ", "clean", "-", "up", " ", "the", " ", "server", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Ma", "y", " ", "be", " ", "overrid", "den", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "finish", "\\u", "request_", "(_", "self_", ",_", "request_", ",_", "client", "\\u", "address_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Finish", " ", "one", " ", "request", " ", "by", " ", "instant", "iati", "ng", " ", "Request", "Handle", "r", "Class", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "Request", "Handle", "r", "Class_", "(_", "request_", ",_", "client", "\\u", "address_", ",_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "shut", "down", "\\u", "request_", "(_", "self_", ",_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Call", "ed", " ", "to", " ", "shut", "down", " ", "and", " ", "close", " ", "an", " ", "individual", " ", "request", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "close", "\\u", "request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "close", "\\u", "request_", "(_", "self_", ",_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Call", "ed", " ", "to", " ", "clean", " ", "up", " ", "an", " ", "individual", " ", "request", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Base", "Server_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "handle", "\\u", "error_", "(_", "self_", ",_", "request_", ",_", "client", "\\u", "address_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Handle", " ", "an", " ", "error", " ", "graceful", "ly", ".", " ", " ", "Ma", "y", " ", "be", " ", "overrid", "den", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "default", " ", "is", " ", "to", " ", "print", " ", "a", " ", "traceback", " ", "and", " ", "continue", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'-'_", "*_", "40_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "Except", "ion", " ", "happ", "ened", " ", "dur", "ing", " ", "process", "ing", " ", "of", " ", "request", " ", "from", "'_", ",_", "end_", "=_", "'", " ", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "client", "\\u", "address_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "traceback_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "traceback_", "._", "print", "\\u", "exc_", "(_", ")_", "#", " ", "XX", "X", " ", "Bu", "t", " ", "this", " ", "go", "es", " ", "to", " ", "std", "err", "!", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'-'_", "*_", "40_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "TC", "PS", "erver_", "(_", "Base", "Server_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Base", " ", "class", " ", "for", " ", "vari", "ous", " ", "socket", "-", "based", " ", "server", " ", "classe", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Default", "s", " ", "to", " ", "synchron", "ous", " ", "IP", " ", "stream", " ", "(", "i", ".", "e", ".,", " ", "TC", "P", ").", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Meth", "ods", " ", "for", " ", "the", " ", "caller", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "\\u\\u", "init", "\\u\\u", "(", "server", "\\u", "address", ",", " ", "Request", "Handle", "r", "Class", ",", " ", "bind", "\\u", "and", "\\u", "activat", "e", "=", "Tru", "e", ")", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "serve", "\\u", "forever", "(", "poll", "\\u", "interval", "=", "0.", "5", ")", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "shut", "down", "()", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "handle", "\\u", "request", "()", " ", " ", "#", " ", "if", " ", "you", " ", "don", "'", "t", " ", "use", " ", "serve", "\\u", "forever", "()", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "filen", "o", "()", " ", "->", " ", "int", " ", " ", " ", "#", " ", "for", " ", "select", "()", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Meth", "ods", " ", "tha", "t", " ", "may", " ", "be", " ", "overrid", "den", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "server", "\\u", "bind", "()", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "server", "\\u", "activat", "e", "()", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "get", "\\u", "request", "()", " ", "->", " ", "request", ",", " ", "client", "\\u", "address", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "handle", "\\u", "timeo", "ut", "()", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "verify", "\\u", "request", "(", "request", ",", " ", "client", "\\u", "address", ")", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "process", "\\u", "request", "(", "request", ",", " ", "client", "\\u", "address", ")", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "shut", "down", "\\u", "request", "(", "request", ")", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "close", "\\u", "request", "(", "request", ")", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "handle", "\\u", "error", "()", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Meth", "ods", " ", "for", " ", "derive", "d", " ", "classe", "s", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "finish", "\\u", "request", "(", "request", ",", " ", "client", "\\u", "address", ")", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Class", " ", "variab", "les", " ", "tha", "t", " ", "may", " ", "be", " ", "overrid", "den", " ", "by", " ", "derive", "d", " ", "classe", "s", " ", "or", "\\", "10", ";", " ", " ", " ", " ", "instance", "s", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "timeo", "ut", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "address", "\\u", "famil", "y", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "socket", "\\u", "type", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "request", "\\u", "queue", "\\u", "size", " ", "(", "only", " ", "for", " ", "stream", " ", "socket", "s", ")", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "allow", "\\u", "reus", "e\\u", "address", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Insta", "nce", " ", "variab", "les", ":", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "server", "\\u", "address", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "Request", "Handle", "r", "Class", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "socket", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "address", "\\u", "family_", "=_", "socket_", "._", "AF", "\\u", "INET_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "socket", "\\u", "type_", "=_", "socket_", "._", "SOCK", "\\u", "STREAM_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "request", "\\u", "queue", "\\u", "size_", "=_", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "allow", "\\u", "reus", "e\\u", "address_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "TC", "PS", "erver_", "(_", "Base", "Server_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "server", "\\u", "address_", ",_", "Request", "Handle", "r", "Class_", ",_", "bind", "\\u", "and", "\\u", "activate_", "=_", "True_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Constructor", ".", " ", " ", "Ma", "y", " ", "be", " ", "extend", "ed", ",", " ", "do", " ", "not", " ", "override", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Base", "Server_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "server", "\\u", "address_", ",_", "Request", "Handle", "r", "Class_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "socket_", "=_", "socket_", "._", "socket_", "(_", "self_", "._", "address", "\\u", "family_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "socket", "\\u", "type_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "bind", "\\u", "and", "\\u", "activate_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "server", "\\u", "bind_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "server", "\\u", "activate_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "TC", "PS", "erver_", "(_", "Base", "Server_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "server", "\\u", "bind_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Call", "ed", " ", "by", " ", "construct", "or", " ", "to", " ", "bind", " ", "the", " ", "socket", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Ma", "y", " ", "be", " ", "overrid", "den", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "allow", "\\u", "reus", "e\\u", "address_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "socket_", "._", "setsockopt_", "(_", "socket_", "._", "SOL", "\\u", "SOCKET_", ",_", "socket_", "._", "SO", "\\u", "REUSE", "ADDR_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "socket_", "._", "bind_", "(_", "self_", "._", "server", "\\u", "address_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "server", "\\u", "address_", "=_", "self_", "._", "socket_", "._", "getsockname", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "TC", "PS", "erver_", "(_", "Base", "Server_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "server", "\\u", "activate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Call", "ed", " ", "by", " ", "construct", "or", " ", "to", " ", "activat", "e", " ", "the", " ", "server", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Ma", "y", " ", "be", " ", "overrid", "den", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "socket_", "._", "listen_", "(_", "self_", "._", "request", "\\u", "queue", "\\u", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "TC", "PS", "erver_", "(_", "Base", "Server_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "server", "\\u", "close_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Call", "ed", " ", "to", " ", "clean", "-", "up", " ", "the", " ", "server", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Ma", "y", " ", "be", " ", "overrid", "den", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "socket_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "TC", "PS", "erver_", "(_", "Base", "Server_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "fileno_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Return", " ", "socket", " ", "file", " ", "number", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Interface", " ", "require", "d", " ", "by", " ", "select", "()", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "socket_", "._", "fileno_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "TC", "PS", "erver_", "(_", "Base", "Server_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "request_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Get", " ", "the", " ", "request", " ", "and", " ", "client", " ", "address", " ", "from", " ", "the", " ", "socket", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Ma", "y", " ", "be", " ", "overrid", "den", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "self_", "._", "socket_", "._", "accept_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "TC", "PS", "erver_", "(_", "Base", "Server_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "shut", "down", "\\u", "request_", "(_", "self_", ",_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Call", "ed", " ", "to", " ", "shut", "down", " ", "and", " ", "close", " ", "an", " ", "individual", " ", "request", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "explicit", "ly", " ", "shut", "down", ".", " ", " ", "socket", ".", "close", "()", " ", "mer", "el", "y", " ", "releases_", "\\u\\u\\uNL\\u\\u\\u_", "#", "the", " ", "socket", " ", "and", " ", "waits", " ", "for", " ", "GC", " ", "to", " ", "perform", " ", "the", " ", "actual", " ", "close", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "request_", "._", "shutdown_", "(_", "socket_", "._", "SHU", "T", "\\u", "WR", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "socket_", "._", "error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "#", "some", " ", "platform", "s", " ", "may", " ", "raise", " ", "ENO", "TC", "ON", "N", " ", "here_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "close", "\\u", "request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "TC", "PS", "erver_", "(_", "Base", "Server_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "close", "\\u", "request_", "(_", "self_", ",_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Call", "ed", " ", "to", " ", "clean", " ", "up", " ", "an", " ", "individual", " ", "request", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "request_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "UD", "PS", "erver_", "(_", "TC", "PS", "erver_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "UD", "P", " ", "server", " ", "class", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "allow", "\\u", "reus", "e\\u", "address_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "socket", "\\u", "type_", "=_", "socket_", "._", "SOCK", "\\u", "DGRAM_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "max", "\\u", "packet", "\\u", "size_", "=_", "8192_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "UD", "PS", "erver_", "(_", "TC", "PS", "erver_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "get", "\\u", "request_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "data_", ",_", "client", "\\u", "addr_", "=_", "self_", "._", "socket_", "._", "recv", "from_", "(_", "self_", "._", "max", "\\u", "packet", "\\u", "size_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "(_", "data_", ",_", "self_", "._", "socket_", ")_", ",_", "client", "\\u", "addr_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "UD", "PS", "erver_", "(_", "TC", "PS", "erver_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "server", "\\u", "activate_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "No", " ", "need", " ", "to", " ", "call", " ", "listen", "()", " ", "for", " ", "UD", "P", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "UD", "PS", "erver_", "(_", "TC", "PS", "erver_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "shut", "down", "\\u", "request_", "(_", "self_", ",_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "No", " ", "need", " ", "to", " ", "shut", "down", " ", "anyt", "hing", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "close", "\\u", "request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "UD", "PS", "erver_", "(_", "TC", "PS", "erver_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "close", "\\u", "request_", "(_", "self_", ",_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "No", " ", "need", " ", "to", " ", "close", " ", "anyt", "hing", "._", "\\u\\u\\uNL\\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_", "For", "king", "Mix", "In_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Mix", "-", "in", " ", "class", " ", "to", " ", "handle", " ", "each", " ", "request", " ", "in", " ", "a", " ", "new", " ", "process", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "timeout_", "=_", "300_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "active", "\\u", "children_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "\\u", "children_", "=_", "40_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "For", "king", "Mix", "In_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "collect", "\\u", "children_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Intern", "al", " ", "routin", "e", " ", "to", " ", "wait", " ", "for", " ", "child", "ren", " ", "tha", "t", " ", "have", " ", "exit", "ed", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "self_", "._", "active", "\\u", "children_", "is_", "None_", ":_", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "len_", "(_", "self_", "._", "active", "\\u", "children_", ")_", ">=_", "self_", "._", "max", "\\u", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "XX", "X", ":", " ", "Thi", "s", " ", "will", " ", "wait", " ", "for", " ", "any", " ", "child", " ", "process", ",", " ", "not", " ", "just", " ", "ones_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "spawne", "d", " ", "by", " ", "this", " ", "librar", "y", ".", " ", "Thi", "s", " ", "coul", "d", " ", "conf", "use", " ", "other_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "librar", "ies", " ", "tha", "t", " ", "expect", " ", "to", " ", "be", " ", "able", " ", "to", " ", "wait", " ", "for", " ", "thei", "r", " ", "own_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "child", "ren", "._", "\\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 ", " _", "pid_", ",_", "status_", "=_", "os_", "._", "wait", "pid_", "(_", "0_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "os_", "._", "error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pid_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "pid_", "not_", "in_", "self_", "._", "active", "\\u", "children_", ":_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "active", "\\u", "children_", "._", "remove_", "(_", "pid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "XX", "X", ":", " ", "Thi", "s", " ", "loop", " ", "runs", " ", "more", " ", "system", " ", "calls", " ", "than", " ", "it", " ", "ou", "ght_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "to", ".", " ", "There", " ", "shou", "ld", " ", "be", " ", "a", " ", "way", " ", "to", " ", "put", " ", "the", " ", "active", "\\u", "child", "ren", " ", "int", "o", " ", "a_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "process", " ", "group", " ", "and", " ", "then", " ", "use", " ", "os", ".", "wait", "pid", "(-", "pg", "id", ")", " ", "to", " ", "wait", " ", "for", " ", "any_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "of", " ", "tha", "t", " ", "set", ",", " ", "but", " ", "I", " ", "coul", "dn", "'", "t", " ", "find", " ", "a", " ", "way", " ", "to", " ", "allocate", " ", "pg", "ids_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tha", "t", " ", "coul", "dn", "'", "t", " ", "collide", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "child_", "in_", "self_", "._", "active", "\\u", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pid_", ",_", "status_", "=_", "os_", "._", "wait", "pid_", "(_", "child_", ",_", "os_", "._", "WN", "OH", "ANG", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "os_", "._", "error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pid_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "pid_", ":_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "active", "\\u", "children_", "._", "remove_", "(_", "pid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Value", "Error_", "as_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "'%", "s", ".", " ", "x", "=", "%", "d", " ", "and", " ", "list", "=", "%", "r", "'_", "%_", "(_", "e_", "._", "message_", ",_", "pid_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "active", "\\u", "children_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "For", "king", "Mix", "In_", "(_", "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_", "handle", "\\u", "timeout_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Wait", " ", "for", " ", "zombie", "s", " ", "after", " ", "self", ".", "timeo", "ut", " ", "second", "s", " ", "of", " ", "inact", "ivity", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Ma", "y", " ", "be", " ", "extend", "ed", ",", " ", "do", " ", "not", " ", "override", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "collect", "\\u", "children_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "For", "king", "Mix", "In_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "service", "\\u", "actions_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Collect", " ", "the", " ", "zombie", " ", "child", " ", "process", "es", " ", "regular", "ly", " ", "in", " ", "the", " ", "For", "king", "Mix", "In", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "service", "\\u", "action", "s", " ", "is", " ", "call", "ed", " ", "in", " ", "the", " ", "Base", "Server", "'", "s", " ", "serve", "\\u", "for", "ver", " ", "loop", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "collect", "\\u", "children_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "For", "king", "Mix", "In_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "process", "\\u", "request_", "(_", "self_", ",_", "request_", ",_", "client", "\\u", "address_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "For", "k", " ", "a", " ", "new", " ", "subproc", "ess", " ", "to", " ", "process", " ", "the", " ", "request", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pid_", "=_", "os_", "._", "fork_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "pid_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Parent", " ", "process_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "active", "\\u", "children_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "active", "\\u", "children_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "active", "\\u", "children_", "._", "append_", "(_", "pid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "close", "\\u", "request_", "(_", "request_", ")_", "\\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_", "#", " ", "Chil", "d", " ", "process", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Thi", "s", " ", "must", " ", "neve", "r", " ", "return", ",", " ", "hen", "ce", " ", "os", ".\\u", "exit", "()", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "finish", "\\u", "request_", "(_", "request_", ",_", "client", "\\u", "address_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "shut", "down", "\\u", "request_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "os_", "._", "\\u", "exit_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "handle", "\\u", "error_", "(_", "request_", ",_", "client", "\\u", "address_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "shut", "down", "\\u", "request_", "(_", "request_", ")_", "\\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 ", " ", "_", "os_", "._", "\\u", "exit_", "(_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "For", "king", "UD", "PS", "erver_", "(_", "For", "king", "Mix", "In_", ",_", "UD", "PS", "erver_", ")_", ":_", "pass_", "\\u\\u\\uNEWLINE\\u\\u\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2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]
Nested loops with same variable
RoseOu/flasky/venv/lib/python2.7/site-packages/mako/exceptions.py
[ { "content": " def _init(self, trcback):\n \"\"\"format a traceback from sys.exc_info() into 7-item tuples,\n containing the regular four traceback tuple items, plus the original\n template filename, the line number adjusted relative to the template\n source, and code line from that line number of the template.\"\"\"\n\n import mako.template\n mods = {}\n rawrecords = traceback.extract_tb(trcback)\n new_trcback = []\n for filename, lineno, function, line in rawrecords:\n if not line:\n line = ''\n try:\n (line_map, template_lines) = mods[filename]\n except KeyError:\n try:\n info = mako.template._get_module_info(filename)\n module_source = info.code\n template_source = info.source\n template_filename = info.template_filename or filename\n except KeyError:\n # A normal .py file (not a Template)\n if not compat.py3k:\n try:\n fp = open(filename, 'rb')\n encoding = util.parse_encoding(fp)\n fp.close()\n except IOError:\n encoding = None\n if encoding:\n line = line.decode(encoding)\n else:\n line = line.decode('ascii', 'replace')\n new_trcback.append((filename, lineno, function, line,\n None, None, None, None))\n continue\n\n template_ln = module_ln = 1\n line_map = {}\n for line in module_source.split(\"\\n\"):\n match = re.match(r'\\s*# SOURCE LINE (\\d+)', line)\n if match:\n template_ln = int(match.group(1))\n module_ln += 1\n line_map[module_ln] = template_ln\n template_lines = [line for line in\n template_source.split(\"\\n\")]\n mods[filename] = (line_map, template_lines)\n\n template_ln = line_map[lineno]\n if template_ln <= len(template_lines):\n template_line = template_lines[template_ln - 1]\n else:\n template_line = None\n new_trcback.append((filename, lineno, function,\n line, template_filename, template_ln,\n template_line, template_source))\n if not self.source:\n for l in range(len(new_trcback)-1, 0, -1):\n if new_trcback[l][5]:\n self.source = new_trcback[l][7]\n self.lineno = new_trcback[l][5]\n break\n else:\n if new_trcback:\n try:\n # A normal .py file (not a Template)\n fp = open(new_trcback[-1][0], 'rb')\n encoding = util.parse_encoding(fp)\n fp.seek(0)\n self.source = fp.read()\n fp.close()\n if encoding:\n self.source = self.source.decode(encoding)\n except IOError:\n self.source = ''\n self.lineno = new_trcback[-1][1]\n return new_trcback", "metadata": "root.RichTraceback._init", "header": "['class', 'RichTraceback', '(', 'object', ')', ':', '___EOS___']", "index": 131 } ]
[ { "span": "for line in module_source.split(\"\\n\"):", "start_line": 171, "start_column": 16, "end_line": 171, "end_column": 54 } ]
[ { "span": "for filename, lineno, function, line in rawrecords:", "start_line": 141, "start_column": 8, "end_line": 141, "end_column": 59 } ]
1
true
[ "[CLS]_", "Nest", "ed_", "loops_", "with_", "same_", "variable_", "[SEP]_", "class_", "Rich", "Trace", "back_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u", "init_", "(_", "self_", ",_", "trc", "back_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "format", " ", "a", " ", "traceback", " ", "from", " ", "sys", ".", "exc", "\\u", "info", "()", " ", "int", "o", " ", "7", "-", "item", " ", "tuple", "s", ",", "\\", "10", ";", " ", " ", " ", " ", "contain", "ing", " ", "the", " ", "regular", " ", "four", " ", "traceback", " ", "tuple", " ", "items", ",", " ", "plus", " ", "the", " ", "original", "\\", "10", ";", " ", " ", " ", " ", "template", " ", "filename", ",", " ", "the", " ", "line", " ", "number", " ", "adjusted", " ", "relative", " ", "to", " ", "the", " ", "template", "\\", "10", ";", " ", " ", " ", " ", "source", ",", " ", "and", " ", "code", " ", "line", " ", "from", " ", "tha", "t", " ", "line", " ", "number", " ", "of", " ", "the", " ", "template", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "mak", "o_", "._", "template_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mods_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raw", "records_", "=_", "traceback_", "._", "extract", "\\u", "tb_", "(_", "trc", "back_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "trc", "back_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "filename_", ",_", "lineno_", ",_", "function_", ",_", "line_", "in_", "raw", "records_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "line_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "line_", "=_", "''_", "\\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 ", " _", "(_", "line", "\\u", "map_", ",_", "template", "\\u", "lines_", ")_", "=_", "mods_", "[_", "filename_", "]_", "\\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 ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "info_", "=_", "mak", "o_", "._", "template_", "._", "\\u", "get", "\\u", "module", "\\u", "info_", "(_", "filename_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "module", "\\u", "source_", "=_", "info_", "._", "code_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template", "\\u", "source_", "=_", "info_", "._", "source_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "template", "\\u", "filename_", "=_", "info_", "._", "template", "\\u", "filename_", "or_", "filename_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Key", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "A", " ", "normal", " ", ".", "py", " ", "file", " ", "(", "not", " ", "a", " ", "Templa", "te", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "not_", "compat_", "._", "py3", "k_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "fp_", "=_", "open_", "(_", "filename_", ",_", "'", "rb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "encoding_", "=_", "util_", "._", "parse", "\\u", "encoding_", "(_", "fp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fp_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "IO", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "encoding_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "encoding_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "line_", "=_", "line_", "._", "decode_", "(_", "encoding_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "line_", "=_", "line_", "._", "decode_", "(_", "'", "ascii", "'_", ",_", "'", "replace", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new", "\\u", "trc", "back_", "._", "append_", "(_", "(_", "filename_", ",_", "lineno_", ",_", "function_", ",_", "line_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "None_", ",_", "None_", ",_", "None_", ",_", "None_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "template", "\\u", "ln_", "=_", "module", "\\u", "ln_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "line", "\\u", "map_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "line_", "in_", "module", "\\u", "source_", "._", "split_", "(_", "\"\\\\", "n", "\"_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "match_", "=_", "re_", "._", "match_", "(_", "r", "'\\\\", "s", "*#", " ", "SOU", "RC", "E", " ", "LINE", " ", "(\\\\", "d", "+)'_", ",_", "line_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "match_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "template", "\\u", "ln_", "=_", "int_", "(_", "match_", "._", "group_", "(_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "module", "\\u", "ln_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "line", "\\u", "map_", "[_", "module", "\\u", "ln_", "]_", "=_", "template", "\\u", "ln_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "template", "\\u", "lines_", "=_", "[_", "line_", "for_", "line_", "in_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "source_", "._", "split_", "(_", "\"\\\\", "n", "\"_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "mods_", "[_", "filename_", "]_", "=_", "(_", "line", "\\u", "map_", ",_", "template", "\\u", "lines_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "template", "\\u", "ln_", "=_", "line", "\\u", "map_", "[_", "lineno_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "template", "\\u", "ln_", "<=_", "len_", "(_", "template", "\\u", "lines_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "template", "\\u", "line_", "=_", "template", "\\u", "lines_", "[_", "template", "\\u", "ln_", "-_", "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 ", " _", "template", "\\u", "line_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "new", "\\u", "trc", "back_", "._", "append_", "(_", "(_", "filename_", ",_", "lineno_", ",_", "function_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "line_", ",_", "template", "\\u", "filename_", ",_", "template", "\\u", "ln_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "template", "\\u", "line_", ",_", "template", "\\u", "source_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "self_", "._", "source_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "l_", "in_", "range_", "(_", "len_", "(_", "new", "\\u", "trc", "back_", ")_", "-_", "1_", ",_", "0_", ",_", "-_", "1_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "new", "\\u", "trc", "back_", "[_", "l_", "]_", "[_", "5_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "self_", "._", "source_", "=_", "new", "\\u", "trc", "back_", "[_", "l_", "]_", "[_", "7_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "lineno_", "=_", "new", "\\u", "trc", "back_", "[_", "l_", "]_", "[_", "5_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "new", "\\u", "trc", "back_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "A", " ", "normal", " ", ".", "py", " ", "file", " ", "(", "not", " ", "a", " ", "Templa", "te", ")_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "fp_", "=_", "open_", "(_", "new", "\\u", "trc", "back_", "[_", "-_", "1_", "]_", "[_", "0_", "]_", ",_", "'", "rb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "encoding_", "=_", "util_", "._", "parse", "\\u", "encoding_", "(_", "fp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fp_", "._", "seek_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "source_", "=_", "fp_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fp_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "encoding_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "source_", "=_", "self_", "._", "source_", "._", "decode_", "(_", "encoding_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "IO", "Error_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "self_", "._", "source_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "lineno_", "=_", "new", "\\u", "trc", "back_", "[_", "-_", "1_", "]_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "new", "\\u", "trc", "back_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 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 ]
Unused local variable
byt3bl33d3r/pth-toolkit/lib/python2.7/site-packages/samba/netcmd/sites.py
[ { "content": " def run(self, sitename, sambaopts=None, credopts=None, versionopts=None):\n lp = sambaopts.get_loadparm()\n creds = credopts.get_credentials(lp, fallback_machine=True)\n url = lp.private_path(\"sam.ldb\")\n\n if not os.path.exists(url):\n raise CommandError(\"secret database not found at %s \" % url)\n samdb = SamDB(url=url, session_info=system_session(),\n credentials=creds, lp=lp)\n\n samdb.transaction_start()\n try:\n ok = sites.create_site(samdb, samdb.get_config_basedn(), sitename)\n samdb.transaction_commit()\n except sites.SiteAlreadyExistsException, e:\n samdb.transaction_cancel()\n raise CommandError(\"Error while creating site %s, error: %s\" % (sitename, str(e)))\n\n self.outf.write(\"Site %s created !\\n\" % sitename)", "metadata": "root.cmd_sites_create.run", "header": "['class', 'cmd_sites_create', '(', 'Command', ')', ':', '___EOS___']", "index": 43 }, { "content": " def run(self, sitename, sambaopts=None, credopts=None, versionopts=None):\n lp = sambaopts.get_loadparm()\n creds = credopts.get_credentials(lp, fallback_machine=True)\n url = lp.private_path(\"sam.ldb\")\n\n if not os.path.exists(url):\n raise CommandError(\"secret database not found at %s \" % url)\n samdb = SamDB(url=url, session_info=system_session(),\n credentials=creds, lp=lp)\n\n samdb.transaction_start()\n try:\n ok = sites.delete_site(samdb, samdb.get_config_basedn(), sitename)\n samdb.transaction_commit()\n except sites.SiteException, e:\n samdb.transaction_cancel()\n raise CommandError(\n \"Error while removing site %s, error: %s\" % (sitename, str(e)))\n\n self.outf.write(\"Site %s removed!\\n\" % sitename)", "metadata": "root.cmd_sites_delete.run", "header": "['class', 'cmd_sites_delete', '(', 'Command', ')', ':', '___EOS___']", "index": 76 } ]
[ { "span": "ok ", "start_line": 55, "start_column": 12, "end_line": 55, "end_column": 14 }, { "span": "ok ", "start_line": 88, "start_column": 12, "end_line": 88, "end_column": 14 } ]
[]
1
true
[ "[CLS]_", "Un", "used_", "local_", "variable_", "[SEP]_", "class_", "cmd", "\\u", "sites", "\\u", "create_", "(_", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "run_", "(_", "self_", ",_", "site", "name_", ",_", "samba", "opts_", "=_", "None_", ",_", "cred", "opts_", "=_", "None_", ",_", "version", "opts_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lp_", "=_", "samba", "opts_", "._", "get", "\\u", "load", "parm_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "creds_", "=_", "cred", "opts_", "._", "get", "\\u", "credentials_", "(_", "lp_", ",_", "fall", "back", "\\u", "machine_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "lp_", "._", "private", "\\u", "path_", "(_", "\"", "sam", ".", "ldb", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Command", "Error_", "(_", "\"", "secret", " ", "databa", "se", " ", "not", " ", "found", " ", "at", " ", "%", "s", " ", "\"_", "%_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sam", "db_", "=_", "Sam", "DB_", "(_", "url_", "=_", "url_", ",_", "session", "\\u", "info_", "=_", "system", "\\u", "session_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "credentials_", "=_", "creds_", ",_", "lp_", "=_", "lp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sam", "db_", "._", "transaction", "\\u", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ok_", "=_", "sites_", "._", "create", "\\u", "site_", "(_", "sam", "db_", ",_", "sam", "db_", "._", "get", "\\u", "config", "\\u", "based", "n_", "(_", ")_", ",_", "site", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sam", "db_", "._", "transaction", "\\u", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "sites_", "._", "Site", "Al", "read", "y", "Exist", "s", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sam", "db_", "._", "transaction", "\\u", "cancel_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Command", "Error_", "(_", "\"", "Error", " ", "whi", "le", " ", "creati", "ng", " ", "site", " ", "%", "s", ",", " ", "error", ":", " ", "%", "s", "\"_", "%_", "(_", "site", "name_", ",_", "str_", "(_", "e_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "outf_", "._", "write_", "(_", "\"", "Site", " ", "%", "s", " ", "created", " ", "!\\\\", "n", "\"_", "%_", "site", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "cmd", "\\u", "sites", "\\u", "delete_", "(_", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "run_", "(_", "self_", ",_", "site", "name_", ",_", "samba", "opts_", "=_", "None_", ",_", "cred", "opts_", "=_", "None_", ",_", "version", "opts_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lp_", "=_", "samba", "opts_", "._", "get", "\\u", "load", "parm_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "creds_", "=_", "cred", "opts_", "._", "get", "\\u", "credentials_", "(_", "lp_", ",_", "fall", "back", "\\u", "machine_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "url_", "=_", "lp_", "._", "private", "\\u", "path_", "(_", "\"", "sam", ".", "ldb", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "os_", "._", "path_", "._", "exists_", "(_", "url_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Command", "Error_", "(_", "\"", "secret", " ", "databa", "se", " ", "not", " ", "found", " ", "at", " ", "%", "s", " ", "\"_", "%_", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sam", "db_", "=_", "Sam", "DB_", "(_", "url_", "=_", "url_", ",_", "session", "\\u", "info_", "=_", "system", "\\u", "session_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "credentials_", "=_", "creds_", ",_", "lp_", "=_", "lp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sam", "db_", "._", "transaction", "\\u", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ok_", "=_", "sites_", "._", "delete", "\\u", "site_", "(_", "sam", "db_", ",_", "sam", "db_", "._", "get", "\\u", "config", "\\u", "based", "n_", "(_", ")_", ",_", "site", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sam", "db_", "._", "transaction", "\\u", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "sites_", "._", "Site", "Exception_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sam", "db_", "._", "transaction", "\\u", "cancel_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "raise_", "Command", "Error_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Error", " ", "whi", "le", " ", "remo", "ving", " ", "site", " ", "%", "s", ",", " ", "error", ":", " ", "%", "s", "\"_", "%_", "(_", "site", "name_", ",_", "str_", "(_", "e_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "outf_", "._", "write_", "(_", "\"", "Site", " ", "%", "s", " ", "remove", "d", "!\\\\", "n", "\"_", "%_", "site", "name_", ")_", "\\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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 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
benoitc/gaffer/test/test_controller.py
[ { "content": "# -*- coding: utf-8 -\n#\n# This file is part of gaffer. See the NOTICE for more information.\nimport signal\nimport time\n\nimport pyuv\n\nfrom gaffer.error import ProcessError, CommandError, CommandNotFound\nfrom gaffer.controller import Controller, Command\nfrom gaffer.manager import Manager\nfrom gaffer.process import ProcessConfig\n\nfrom test_manager import dummy_cmd\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class TestCommand(Command):\n\n\n", "metadata": "root.TestCommand", "header": "['module', '___EOS___']", "index": 15 }, { "content": " def __init__(self, name, args=None, kwargs=None):\n super(TestCommand, self).__init__(name, args=args, kwargs=kwargs)\n self.result = None\n self.error = None", "metadata": "root.TestCommand.__init__", "header": "['class', 'TestCommand', '(', 'Command', ')', ':', '___EOS___']", "index": 17 }, { "content": " def reply(self, result):\n self.result = result", "metadata": "root.TestCommand.reply", "header": "['class', 'TestCommand', '(', 'Command', ')', ':', '___EOS___']", "index": 22 }, { "content": " def reply_error(self, error):\n self.error = error", "metadata": "root.TestCommand.reply_error", "header": "['class', 'TestCommand', '(', 'Command', ')', ':', '___EOS___']", "index": 25 }, { "content": "def init():\n m = Manager()\n m.start()\n ctl = Controller(m)\n testfile, cmd, args, wdir = dummy_cmd()\n config = ProcessConfig(\"dummy\", cmd, args=args, cwd=wdir)\n return m, ctl, config", "metadata": "root.init", "header": "['module', '___EOS___']", "index": 28 }, { "content": "def init1():\n m = Manager()\n m.start()\n ctl = Controller(m)\n testfile, cmd, args, wdir = dummy_cmd()\n config = ProcessConfig(\"dummy\", cmd, args=args, cwd=wdir)\n return m, ctl, testfile, config", "metadata": "root.init1", "header": "['module', '___EOS___']", "index": 36 }, { "content": "def test_basic():\n m, ctl, conf = init()\n\n config = conf.to_dict()\n cmd = TestCommand(\"load\", [config], {\"start\": False})\n ctl.process_command(cmd)\n\n state = m._get_locked_state(\"dummy\")\n\n assert state.numprocesses == 1\n assert state.name == \"default.dummy\"\n assert state.cmd == config['cmd']\n assert state.config['args'] == config['args']\n assert state.config['cwd'] == config['cwd']\n\n cmd1 = TestCommand(\"unload\", [\"dummy\"])\n ctl.process_command(cmd1)\n\n assert m.jobs() == []\n\n m.stop()\n m.run()\n\n assert cmd.error == None\n assert cmd.result == {\"ok\": True}\n assert cmd1.error == None\n assert cmd1.result == {\"ok\": True}", "metadata": "root.test_basic", "header": "['module', '___EOS___']", "index": 44 }, { "content": "def test_basic_error():\n m, ctl, config = init()\n\n cmd = TestCommand(\"info\", [\"dummy\"])\n ctl.process_command(cmd)\n\n m.stop()\n m.run()\n\n assert cmd.result == None\n assert cmd.error == {\"errno\": 404, \"reason\": \"not_found\"}", "metadata": "root.test_basic_error", "header": "['module', '___EOS___']", "index": 72 }, { "content": "def test_command_not_found():\n m, ctl, config = init()\n\n cmd = TestCommand(\"nocommand\")\n ctl.process_command(cmd)\n\n m.stop()\n m.run()\n\n assert cmd.result == None\n assert cmd.error == {\"errno\": 404, \"reason\": \"command_not_found\"}", "metadata": "root.test_command_not_found", "header": "['module', '___EOS___']", "index": 84 }, { "content": "def test_bad_command():\n m, ctl, config = init()\n\n cmd = TestCommand(\"load\")\n ctl.process_command(cmd)\n\n m.stop()\n m.run()\n\n assert cmd.result == None\n assert cmd.error['errno'] == 400", "metadata": "root.test_bad_command", "header": "['module', '___EOS___']", "index": 96 }, { "content": "def test_jobs():\n m, ctl, config = init()\n m.load(config)\n cmd = TestCommand(\"jobs\")\n ctl.process_command(cmd)\n\n cmd1 = TestCommand(\"jobs\", [\"default\"])\n ctl.process_command(cmd1)\n\n m.stop()\n m.run()\n\n assert isinstance(cmd.result, dict)\n assert \"jobs\" in cmd.result\n assert cmd.result['jobs'] == [\"default.dummy\"]\n assert isinstance(cmd1.result, dict)\n assert \"jobs\" in cmd1.result\n assert cmd1.result['jobs'] == [\"default.dummy\"]", "metadata": "root.test_jobs", "header": "['module', '___EOS___']", "index": 108 }, { "content": "def test_sessions():\n m, ctl, config = init()\n m.load(config)\n cmd = TestCommand(\"sessions\")\n ctl.process_command(cmd)\n m.stop()\n m.run()\n\n assert isinstance(cmd.result, dict)\n assert \"sessions\" in cmd.result\n assert cmd.result['sessions'] == [\"default\"]", "metadata": "root.test_sessions", "header": "['module', '___EOS___']", "index": 127 }, { "content": "def test_pids():\n m, ctl, config = init()\n m.load(config)\n cmd = TestCommand(\"pids\")\n ctl.process_command(cmd)\n m.stop()\n m.run()\n\n assert isinstance(cmd.result, dict)\n assert \"pids\" in cmd.result\n assert cmd.result['pids'] == [1]", "metadata": "root.test_pids", "header": "['module', '___EOS___']", "index": 139 }, { "content": "def test_reload():\n m, ctl, config = init()\n m.load(config)\n\n pids = m.pids()\n cmd = TestCommand(\"reload\", [\"dummy\"])\n ctl.process_command(cmd)\n\n pids1 = m.pids()\n jobs = m.jobs()\n m.stop()\n m.run()\n\n assert isinstance(cmd.result, dict)\n assert cmd.result == {\"ok\": True}\n assert pids != pids1\n assert \"default.dummy\" in jobs", "metadata": "root.test_reload", "header": "['module', '___EOS___']", "index": 151 }, { "content": "def test_update():\n m, ctl, config = init()\n m.load(config)\n\n pids = m.pids()\n config['numprocesses'] = 2\n cmd = TestCommand(\"update\", [config.to_dict()])\n ctl.process_command(cmd)\n m.manage(\"dummy\")\n pids1 = m.pids()\n jobs = m.jobs()\n m.stop()\n m.run()\n\n assert isinstance(cmd.result, dict)\n assert cmd.result == {\"ok\": True}\n assert pids != pids1\n assert \"default.dummy\" in jobs\n assert len(pids) == 1\n assert len(pids1) == 2", "metadata": "root.test_update", "header": "['module', '___EOS___']", "index": 169 }, { "content": "def test_start_job():\n m, ctl, config = init()\n m.load(config, start=False)\n pids = m.pids()\n\n cmd = TestCommand(\"start_job\", [\"dummy\"])\n ctl.process_command(cmd)\n pids1 = m.pids()\n\n m.stop()\n m.run()\n\n assert isinstance(cmd.result, dict)\n assert cmd.result == {\"ok\": True}\n assert pids != pids1\n assert len(pids) == 0\n assert len(pids1) == 1", "metadata": "root.test_start_job", "header": "['module', '___EOS___']", "index": 190 }, { "content": "def test_stop_job():\n m, ctl, config = init()\n m.load(config)\n pids = m.pids()\n\n cmd = TestCommand(\"stop_job\", [\"dummy\"])\n ctl.process_command(cmd)\n pids1 = m.pids()\n\n m.stop()\n m.run()\n\n assert isinstance(cmd.result, dict)\n assert cmd.result == {\"ok\": True}\n assert pids != pids1\n assert len(pids) == 1\n assert len(pids1) == 0", "metadata": "root.test_stop_job", "header": "['module', '___EOS___']", "index": 209 }, { "content": "def test_scale():\n m, ctl, config = init()\n m.load(config)\n pids = m.pids()\n\n cmd = TestCommand(\"scale\", [\"dummy\", 1])\n ctl.process_command(cmd)\n time.sleep(0.1)\n\n pids1 = m.pids()\n\n\n cmd = TestCommand(\"scale\", [\"dummy\", -1])\n ctl.process_command(cmd)\n time.sleep(0.1)\n\n pids2 = m.pids()\n\n\n cmd = TestCommand(\"scale\", [\"dummy\", \"+4\"])\n ctl.process_command(cmd)\n time.sleep(0.1)\n\n pids3 = m.pids()\n\n cmd = TestCommand(\"scale\", [\"dummy\", \"-1\"])\n ctl.process_command(cmd)\n time.sleep(0.1)\n\n pids4 = m.pids()\n\n\n cmd = TestCommand(\"scale\", [\"dummy\", \"=1\"])\n ctl.process_command(cmd)\n time.sleep(0.1)\n\n pids5 = m.pids()\n\n\n m.stop()\n m.run()\n\n assert len(pids) == 1\n assert len(pids1) == 2\n assert len(pids2) == 1\n assert len(pids3) == 5\n assert len(pids4) == 4\n assert len(pids5) == 1", "metadata": "root.test_scale", "header": "['module', '___EOS___']", "index": 227 }, { "content": "def test_info():\n m, ctl, config = init()\n m.load(config)\n\n cmd = TestCommand(\"info\", [\"dummy\"])\n ctl.process_command(cmd)\n\n m.scale(\"dummy\", 2)\n time.sleep(0.1)\n\n cmd1 = TestCommand(\"info\", [\"dummy\"])\n ctl.process_command(cmd1)\n\n m.stop()\n m.run()\n\n assert isinstance(cmd.result, dict)\n assert \"info\" in cmd.result\n info = cmd.result['info']\n assert info['name'] == \"default.dummy\"\n assert info['active'] == True\n assert info['running'] == 1\n assert info['max_processes'] == 1\n assert \"config\" in info\n assert info['config'] == config.to_dict()\n\n assert isinstance(cmd1.result, dict)\n assert \"info\" in cmd1.result\n info1 = cmd1.result['info']\n assert info1['name'] == \"default.dummy\"\n assert info1['running'] == 3\n assert info1['config'] == config.to_dict()", "metadata": "root.test_info", "header": "['module', '___EOS___']", "index": 277 }, { "content": "def test_stats():\n m, ctl, config = init()\n m.load(config)\n\n cmd = TestCommand(\"stats\", [\"dummy\"])\n ctl.process_command(cmd)\n\n m.scale(\"dummy\", 2)\n time.sleep(0.1)\n\n cmd1 = TestCommand(\"stats\", [\"dummy\"])\n ctl.process_command(cmd1)\n\n m.stop()\n m.run()\n\n assert isinstance(cmd.result, dict)\n assert \"stats\" in cmd.result\n stats = cmd.result['stats']\n assert isinstance(stats, dict)\n assert stats['name'] == \"default.dummy\"\n assert \"stats\" in stats\n assert len(stats['stats']) == 1\n assert stats['stats'][0]['pid'] == 1\n\n assert isinstance(cmd1.result, dict)\n stats = cmd1.result['stats']\n assert isinstance(stats, dict)\n assert stats['name'] == \"default.dummy\"\n assert \"stats\" in stats\n assert len(stats['stats']) == 3", "metadata": "root.test_stats", "header": "['module', '___EOS___']", "index": 310 }, { "content": "def test_stopall():\n m, ctl, config = init()\n m.load(config)\n\n pids = m.pids()\n\n cmd = TestCommand(\"stopall\", [\"dummy\"])\n ctl.process_command(cmd)\n\n jobs = m.jobs()\n pids1 = m.pids()\n\n m.stop()\n m.run()\n\n assert len(pids) == 1\n assert jobs == ['default.dummy']\n assert len(pids1) == 0", "metadata": "root.test_stopall", "header": "['module', '___EOS___']", "index": 342 }, { "content": "def test_killall():\n m, ctl, testfile, config = init1()\n m.load(config)\n\n time.sleep(0.1)\n cmd = TestCommand(\"killall\", [\"dummy\", signal.SIGHUP])\n ctl.process_command(cmd)\n time.sleep(0.2)\n\n m.stop_job(\"dummy\")\n time.sleep(0.1)\n\n m.stop()\n m.run()\n\n assert cmd.result == {\"ok\": True}\n with open(testfile, 'r') as f:\n res = f.read()\n assert res == 'STARTHUPQUITSTOP'", "metadata": "root.test_killall", "header": "['module', '___EOS___']", "index": 361 }, { "content": "def test_process_info():\n m, ctl, config = init()\n m.load(config)\n\n cmd = TestCommand(\"process_info\", [1])\n ctl.process_command(cmd)\n\n m.stop()\n m.run()\n\n assert isinstance(cmd.result, dict)\n assert \"info\" in cmd.result\n info = cmd.result['info']\n assert info['name'] == \"default.dummy\"\n assert info['active'] == True\n assert info['pid'] == 1\n assert info['cmd'] == config['cmd']\n assert info['args'] == config['args']", "metadata": "root.test_process_info", "header": "['module', '___EOS___']", "index": 381 }, { "content": "def test_process_stats():\n m, ctl, config = init()\n m.load(config)\n\n cmd = TestCommand(\"process_stats\", [1])\n ctl.process_command(cmd)\n\n m.stop()\n m.run()\n\n assert isinstance(cmd.result, dict)\n assert \"stats\" in cmd.result\n stats = cmd.result['stats']\n assert \"cpu\" in stats", "metadata": "root.test_process_stats", "header": "['module', '___EOS___']", "index": 400 }, { "content": "def test_stop_process():\n m, ctl, config = init()\n m.load(config)\n\n pids = m.pids()\n\n cmd = TestCommand(\"stop_process\", [1])\n ctl.process_command(cmd)\n\n result = []\n def wait(h):\n result.append((m.jobs(), m.pids()))\n m.stop()\n\n t = pyuv.Timer(m.loop)\n t.start(wait, 0.2, 0.0)\n\n m.run()\n\n assert len(result) == 1\n jobs, pids1 = result[0]\n\n assert len(pids) == 1\n assert jobs == ['default.dummy']\n assert pids != pids1\n assert len(pids1) == 1", "metadata": "root.test_stop_process", "header": "['module', '___EOS___']", "index": 415 }, { "content": "def test_kill_process():\n m, ctl, testfile, config = init1()\n m.load(config)\n\n time.sleep(0.1)\n cmd = TestCommand(\"kill\", [1, signal.SIGHUP])\n ctl.process_command(cmd)\n time.sleep(0.2)\n\n m.stop_job(\"dummy\")\n\n t = pyuv.Timer(m.loop)\n t.start(lambda h: m.stop(), 0.2, 0.0)\n m.run()\n\n assert cmd.result == {\"ok\": True}\n with open(testfile, 'r') as f:\n res = f.read()\n assert res == 'STARTHUPQUITSTOP'", "metadata": "root.test_kill_process", "header": "['module', '___EOS___']", "index": 442 }, { "content": "def test_process_commit():\n m, ctl, config = init()\n config['numprocesses'] = 0\n m.load(config, start=False)\n cmd = TestCommand(\"commit\", [\"dummy\"])\n ctl.process_command(cmd)\n time.sleep(0.1)\n\n state = m._get_locked_state(\"dummy\")\n assert len(state.running) == 0\n assert state.numprocesses == 0\n assert len(state.running_out) == 1\n assert m.pids() == [1]\n\n m.stop()\n m.run()\n\n assert cmd.result[\"pid\"] == 1", "metadata": "root.test_process_commit", "header": "['module', '___EOS___']", "index": 462 } ]
[ { "span": "from gaffer.error import ProcessError, CommandError, CommandNotFound", "start_line": 8, "start_column": 0, "end_line": 8, "end_column": 68 } ]
[]
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_", "#", " ", "Thi", "s", " ", "file", " ", "is", " ", "part", " ", "of", " ", "ga", "ffer", ".", " ", "See", " ", "the", " ", "NOTICE", " ", "for", " ", "more", " ", "informati", "on", "._", "\\u\\u\\uNL\\u\\u\\u_", "import_", "signal_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "pyu", "v_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "ga", "ffer", "_", "._", "error_", "import_", "Process", "Error_", ",_", "Command", "Error_", ",_", "Command", "Not", "Found_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ga", "ffer", "_", "._", "controller_", "import_", "Controller_", ",_", "Command_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ga", "ffer", "_", "._", "manager_", "import_", "Manager_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "ga", "ffer", "_", "._", "process_", "import_", "Process", "Config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "test\\u", "manager_", "import_", "dummy", "\\u", "cmd_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "Test", "Command_", "(_", "Command_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command_", "(_", "Command_", ")_", ":_", "\\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_", ",_", "name_", ",_", "args_", "=_", "None_", ",_", "kwargs_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "super_", "(_", "Test", "Command_", ",_", "self_", ")_", "._", "\\u\\u", "init\\u\\u_", "(_", "name_", ",_", "args_", "=_", "args_", ",_", "kwargs_", "=_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "result_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "error_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command_", "(_", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "reply_", "(_", "self_", ",_", "result_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "result_", "=_", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Command_", "(_", "Command_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "repl", "y", "\\u", "error_", "(_", "self_", ",_", "error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "error_", "=_", "error_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "init_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", "=_", "Manager_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "=_", "Controller_", "(_", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "testfile_", ",_", "cmd_", ",_", "args_", ",_", "wdi", "r_", "=_", "dummy", "\\u", "cmd_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config_", "=_", "Process", "Config_", "(_", "\"", "dummy", "\"_", ",_", "cmd_", ",_", "args_", "=_", "args_", ",_", "cwd_", "=_", "wdi", "r_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "m_", ",_", "ctl_", ",_", "config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "init", "1_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", "=_", "Manager_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "start_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "=_", "Controller_", "(_", "m_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "testfile_", ",_", "cmd_", ",_", "args_", ",_", "wdi", "r_", "=_", "dummy", "\\u", "cmd_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config_", "=_", "Process", "Config_", "(_", "\"", "dummy", "\"_", ",_", "cmd_", ",_", "args_", "=_", "args_", ",_", "cwd_", "=_", "wdi", "r_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "m_", ",_", "ctl_", ",_", "testfile_", ",_", "config_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "basic_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "conf_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "config_", "=_", "conf_", "._", "to", "\\u", "dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "load", "\"_", ",_", "[_", "config_", "]_", ",_", "{_", "\"", "start", "\"_", ":_", "False_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "state_", "=_", "m_", "._", "\\u", "get", "\\u", "lock", "ed", "\\u", "state_", "(_", "\"", "dummy", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "state_", "._", "nump", "rocess", "es_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "state_", "._", "name_", "==_", "\"", "default", ".", "dummy", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "state_", "._", "cmd_", "==_", "config_", "[_", "'", "cmd", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "state_", "._", "config_", "[_", "'", "args", "'_", "]_", "==_", "config_", "[_", "'", "args", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "state_", "._", "config_", "[_", "'", "cw", "d", "'_", "]_", "==_", "config_", "[_", "'", "cw", "d", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd", "1_", "=_", "Test", "Command_", "(_", "\"", "unload", "\"_", ",_", "[_", "\"", "dummy", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "m_", "._", "jobs_", "(_", ")_", "==_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "cmd_", "._", "error_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "cmd_", "._", "result_", "==_", "{_", "\"", "ok", "\"_", ":_", "True_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "cmd", "1_", "._", "error_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "cmd", "1_", "._", "result_", "==_", "{_", "\"", "ok", "\"_", ":_", "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_", "test\\u", "basic", "\\u", "error_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "info", "\"_", ",_", "[_", "\"", "dummy", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "cmd_", "._", "result_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "cmd_", "._", "error_", "==_", "{_", "\"", "errno", "\"_", ":_", "404_", ",_", "\"", "reason", "\"_", ":_", "\"", "not", "\\u", "found", "\"_", "}_", "\\u\\u\\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", "command", "\\u", "not", "\\u", "found_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "noco", "mmand", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "cmd_", "._", "result_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "cmd_", "._", "error_", "==_", "{_", "\"", "errno", "\"_", ":_", "404_", ",_", "\"", "reason", "\"_", ":_", "\"", "command", "\\u", "not", "\\u", "found", "\"_", "}_", "\\u\\u\\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", "bad", "\\u", "command_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "load", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "cmd_", "._", "result_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "cmd_", "._", "error_", "[_", "'", "errno", "'_", "]_", "==_", "400_", "\\u\\u\\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", "jobs_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "jobs", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd", "1_", "=_", "Test", "Command_", "(_", "\"", "jobs", "\"_", ",_", "[_", "\"", "default", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "isinstance_", "(_", "cmd_", "._", "result_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "jobs", "\"_", "in_", "cmd_", "._", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "cmd_", "._", "result_", "[_", "'", "jobs", "'_", "]_", "==_", "[_", "\"", "default", ".", "dummy", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "isinstance_", "(_", "cmd", "1_", "._", "result_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "jobs", "\"_", "in_", "cmd", "1_", "._", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "cmd", "1_", "._", "result_", "[_", "'", "jobs", "'_", "]_", "==_", "[_", "\"", "default", ".", "dummy", "\"_", "]_", "\\u\\u\\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", "sessions_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "session", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "isinstance_", "(_", "cmd_", "._", "result_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "session", "s", "\"_", "in_", "cmd_", "._", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "cmd_", "._", "result_", "[_", "'", "session", "s", "'_", "]_", "==_", "[_", "\"", "default", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "pids_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "pid", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "isinstance_", "(_", "cmd_", "._", "result_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "pid", "s", "\"_", "in_", "cmd_", "._", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "cmd_", "._", "result_", "[_", "'", "pid", "s", "'_", "]_", "==_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "reload_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pids_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "relo", "ad", "\"_", ",_", "[_", "\"", "dummy", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pid", "s1_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "jobs_", "=_", "m_", "._", "jobs_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "isinstance_", "(_", "cmd_", "._", "result_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "cmd_", "._", "result_", "==_", "{_", "\"", "ok", "\"_", ":_", "True_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "pids_", "!=_", "pid", "s1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "default", ".", "dummy", "\"_", "in_", "jobs_", "\\u\\u\\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", "update_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pids_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config_", "[_", "'", "nump", "rocess", "es", "'_", "]_", "=_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "update", "\"_", ",_", "[_", "config_", "._", "to", "\\u", "dict_", "(_", ")_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "manage_", "(_", "\"", "dummy", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pid", "s1_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "jobs_", "=_", "m_", "._", "jobs_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "isinstance_", "(_", "cmd_", "._", "result_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "cmd_", "._", "result_", "==_", "{_", "\"", "ok", "\"_", ":_", "True_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "pids_", "!=_", "pid", "s1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "default", ".", "dummy", "\"_", "in_", "jobs_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "pids_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "pid", "s1_", ")_", "==_", "2_", "\\u\\u\\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", "start", "\\u", "job_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ",_", "start_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pids_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "start", "\\u", "job", "\"_", ",_", "[_", "\"", "dummy", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pid", "s1_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "isinstance_", "(_", "cmd_", "._", "result_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "cmd_", "._", "result_", "==_", "{_", "\"", "ok", "\"_", ":_", "True_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "pids_", "!=_", "pid", "s1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "pids_", ")_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "pid", "s1_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "stop", "\\u", "job_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pids_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "stop", "\\u", "job", "\"_", ",_", "[_", "\"", "dummy", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pid", "s1_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "isinstance_", "(_", "cmd_", "._", "result_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "cmd_", "._", "result_", "==_", "{_", "\"", "ok", "\"_", ":_", "True_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "pids_", "!=_", "pid", "s1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "pids_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "pid", "s1_", ")_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "scale_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pids_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "scale", "\"_", ",_", "[_", "\"", "dummy", "\"_", ",_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pid", "s1_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "scale", "\"_", ",_", "[_", "\"", "dummy", "\"_", ",_", "-_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pid", "s2_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "scale", "\"_", ",_", "[_", "\"", "dummy", "\"_", ",_", "\"+", "4", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pid", "s3_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "scale", "\"_", ",_", "[_", "\"", "dummy", "\"_", ",_", "\"-", "1", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pid", "s4_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "scale", "\"_", ",_", "[_", "\"", "dummy", "\"_", ",_", "\"=", "1", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pid", "s5", "_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "len_", "(_", "pids_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "pid", "s1_", ")_", "==_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "pid", "s2_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "pid", "s3_", ")_", "==_", "5_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "pid", "s4_", ")_", "==_", "4_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "pid", "s5", "_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "info_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "info", "\"_", ",_", "[_", "\"", "dummy", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "scale_", "(_", "\"", "dummy", "\"_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd", "1_", "=_", "Test", "Command_", "(_", "\"", "info", "\"_", ",_", "[_", "\"", "dummy", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "isinstance_", "(_", "cmd_", "._", "result_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "info", "\"_", "in_", "cmd_", "._", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "info_", "=_", "cmd_", "._", "result_", "[_", "'", "info", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "info_", "[_", "'", "name", "'_", "]_", "==_", "\"", "default", ".", "dummy", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "info_", "[_", "'", "active", "'_", "]_", "==_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "info_", "[_", "'", "runn", "ing", "'_", "]_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "info_", "[_", "'", "max", "\\u", "process", "es", "'_", "]_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "config", "\"_", "in_", "info_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "info_", "[_", "'", "config", "'_", "]_", "==_", "config_", "._", "to", "\\u", "dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "isinstance_", "(_", "cmd", "1_", "._", "result_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "info", "\"_", "in_", "cmd", "1_", "._", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "info", "1_", "=_", "cmd", "1_", "._", "result_", "[_", "'", "info", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "info", "1_", "[_", "'", "name", "'_", "]_", "==_", "\"", "default", ".", "dummy", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "info", "1_", "[_", "'", "runn", "ing", "'_", "]_", "==_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "info", "1_", "[_", "'", "config", "'_", "]_", "==_", "config_", "._", "to", "\\u", "dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "stats_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "stats", "\"_", ",_", "[_", "\"", "dummy", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "scale_", "(_", "\"", "dummy", "\"_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd", "1_", "=_", "Test", "Command_", "(_", "\"", "stats", "\"_", ",_", "[_", "\"", "dummy", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "isinstance_", "(_", "cmd_", "._", "result_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "stats", "\"_", "in_", "cmd_", "._", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stats_", "=_", "cmd_", "._", "result_", "[_", "'", "stats", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "isinstance_", "(_", "stats_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "stats_", "[_", "'", "name", "'_", "]_", "==_", "\"", "default", ".", "dummy", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "stats", "\"_", "in_", "stats_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "stats_", "[_", "'", "stats", "'_", "]_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "stats_", "[_", "'", "stats", "'_", "]_", "[_", "0_", "]_", "[_", "'", "pid", "'_", "]_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "isinstance_", "(_", "cmd", "1_", "._", "result_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stats_", "=_", "cmd", "1_", "._", "result_", "[_", "'", "stats", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "isinstance_", "(_", "stats_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "stats_", "[_", "'", "name", "'_", "]_", "==_", "\"", "default", ".", "dummy", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "stats", "\"_", "in_", "stats_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "stats_", "[_", "'", "stats", "'_", "]_", ")_", "==_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "stop", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pids_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "stop", "all", "\"_", ",_", "[_", "\"", "dummy", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "jobs_", "=_", "m_", "._", "jobs_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pid", "s1_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "len_", "(_", "pids_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "jobs_", "==_", "[_", "'", "default", ".", "dummy", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "pid", "s1_", ")_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "kill", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "testfile_", ",_", "config_", "=_", "init", "1_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "kill", "all", "\"_", ",_", "[_", "\"", "dummy", "\"_", ",_", "signal_", "._", "SIG", "HU", "P_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop", "\\u", "job_", "(_", "\"", "dummy", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "cmd_", "._", "result_", "==_", "{_", "\"", "ok", "\"_", ":_", "True_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "testfile_", ",_", "'", "r", "'_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "f_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "res_", "==_", "'", "START", "HU", "PQ", "UI", "TST", "OP", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\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", "process", "\\u", "info_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "process", "\\u", "info", "\"_", ",_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "isinstance_", "(_", "cmd_", "._", "result_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "info", "\"_", "in_", "cmd_", "._", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "info_", "=_", "cmd_", "._", "result_", "[_", "'", "info", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "info_", "[_", "'", "name", "'_", "]_", "==_", "\"", "default", ".", "dummy", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "info_", "[_", "'", "active", "'_", "]_", "==_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "info_", "[_", "'", "pid", "'_", "]_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "info_", "[_", "'", "cmd", "'_", "]_", "==_", "config_", "[_", "'", "cmd", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "info_", "[_", "'", "args", "'_", "]_", "==_", "config_", "[_", "'", "args", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "process", "\\u", "stats_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "process", "\\u", "stats", "\"_", ",_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "isinstance_", "(_", "cmd_", "._", "result_", ",_", "dict_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "stats", "\"_", "in_", "cmd_", "._", "result_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stats_", "=_", "cmd_", "._", "result_", "[_", "'", "stats", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "\"", "cpu", "\"_", "in_", "stats_", "\\u\\u\\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", "stop", "\\u", "process_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pids_", "=_", "m_", "._", "pids_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "stop", "\\u", "process", "\"_", ",_", "[_", "1_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "result_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "wait_", "(_", "h_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "._", "append_", "(_", "(_", "m_", "._", "jobs_", "(_", ")_", ",_", "m_", "._", "pids_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "stop_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "t_", "=_", "pyu", "v_", "._", "Timer_", "(_", "m_", "._", "loop_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "start_", "(_", "wait_", ",_", "0.2_", ",_", "0.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "len_", "(_", "result_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "jobs_", ",_", "pid", "s1_", "=_", "result_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "len_", "(_", "pids_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "jobs_", "==_", "[_", "'", "default", ".", "dummy", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "pids_", "!=_", "pid", "s1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "pid", "s1_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "kill", "\\u", "process_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "testfile_", ",_", "config_", "=_", "init", "1_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "kill", "\"_", ",_", "[_", "1_", ",_", "signal_", "._", "SIG", "HU", "P_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "m_", "._", "stop", "\\u", "job_", "(_", "\"", "dummy", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "t_", "=_", "pyu", "v_", "._", "Timer_", "(_", "m_", "._", "loop_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "t_", "._", "start_", "(_", "lambda_", "h_", ":_", "m_", "._", "stop_", "(_", ")_", ",_", "0.2_", ",_", "0.0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "run_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "cmd_", "._", "result_", "==_", "{_", "\"", "ok", "\"_", ":_", "True_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "open_", "(_", "testfile_", ",_", "'", "r", "'_", ")_", "as_", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "res_", "=_", "f_", "._", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "res_", "==_", "'", "START", "HU", "PQ", "UI", "TST", "OP", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\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", "process", "\\u", "commit_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "m_", ",_", "ctl_", ",_", "config_", "=_", "init_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "config_", "[_", "'", "nump", "rocess", "es", "'_", "]_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "m_", "._", "load_", "(_", "config_", ",_", "start_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cmd_", "=_", "Test", "Command_", "(_", "\"", "commit", "\"_", ",_", "[_", "\"", "dummy", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ctl_", "._", "process", "\\u", "command_", "(_", "cmd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "time_", "._", "sleep_", "(_", "0.1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "state_", "=_", "m_", "._", "\\u", "get", "\\u", "lock", "ed", "\\u", "state_", "(_", "\"", "dummy", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "state_", "._", "running_", ")_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "state_", "._", "nump", "rocess", "es_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "len_", "(_", "state_", "._", "runn", "ing", "\\u", "out_", ")_", "==_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "m_", "._", "pids_", "(_", ")_", "==_", "[_", "1_", "]_", "\\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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
lsaffre/lino/lino/modlib/eid_jslib/beid/__init__.py
[ { "content": " def card2client(cls, data):\n \"does the actual conversion\"\n\n self = cls\n\n from lino.utils import ssin\n from lino.api import dd, rt\n from lino.mixins.beid import BeIdCardTypes\n from lino.utils import join_words\n from lino.utils import IncompleteDate\n from lino.modlib.contacts.utils import street2kw\n\n countries = dd.resolve_app('countries', strict=True)\n\n kw = dict()\n #~ def func(fldname,qname):\n #~ kw[fldname] = data[qname]\n kw.update(national_id=ssin.format_ssin(data['nationalNumber']))\n kw.update(first_name=join_words(\n data['firstName1'],\n data['firstName2'],\n data['firstName3']))\n #~ func('first_name','firstName1')\n kw.update(last_name=data['surname'])\n\n card_number = data['cardNumber']\n\n if 'picture' in data:\n fn = self.card_number_to_picture_file(card_number)\n if os.path.exists(fn):\n logger.warning(\"Overwriting existing image file %s.\", fn)\n fp = file(fn, 'wb')\n fp.write(base64.b64decode(data['picture']))\n fp.close()\n #~ print 20121117, repr(data['picture'])\n #~ kw.update(picture_data_encoded=data['picture'])\n\n #~ func('card_valid_from','validityBeginDate')\n #~ func('card_valid_until','validityEndDate')\n #~ func('birth_date','birthDate')\n kw.update(birth_date=IncompleteDate(\n *settings.SITE.parse_date(data['birthDate'])))\n kw.update(card_valid_from=datetime.date(\n *settings.SITE.parse_date(data['validityBeginDate'])))\n kw.update(card_valid_until=datetime.date(\n *settings.SITE.parse_date(data['validityEndDate'])))\n kw.update(card_number=card_number)\n kw.update(card_issuer=data['issuingMunicipality'])\n kw.update(noble_condition=data['nobleCondition'])\n kw.update(street=data['street'])\n kw.update(street_no=data['streetNumber'])\n kw.update(street_box=data['boxNumber'])\n if kw['street'] and not (kw['street_no'] or kw['street_box']):\n kw = street2kw(kw['street'], **kw)\n kw.update(zip_code=data['zipCode'])\n kw.update(birth_place=data['birthLocation'])\n pk = data['country'].upper()\n\n msg1 = \"BeIdReadCardToClientAction %s\" % kw.get('national_id')\n\n #~ try:\n country = countries.Country.objects.get(isocode=pk)\n kw.update(country=country)\n #~ except countries.Country.DoesNotExist,e:\n #~ except Exception,e:\n #~ logger.warning(\"%s : no country with code %r\",msg1,pk)\n #~ BE = countries.Country.objects.get(isocode='BE')\n #~ fld = countries.Place._meta.get_field()\n kw.update(city=countries.Place.lookup_or_create(\n 'name', data['municipality'], country=country))\n\n def sex2gender(sex):\n if sex == 'M':\n return dd.Genders.male\n if sex in 'FVW':\n return dd.Genders.female\n logger.warning(\"%s : invalid gender code %r\", msg1, sex)\n kw.update(gender=sex2gender(data['sex']))\n\n if False:\n def nationality2country(nationality):\n try:\n return countries.Country.objects.get(\n nationalities__icontains=nationality)\n except countries.Country.DoesNotExist, e:\n logger.warning(\"%s : no country for nationality %r\",\n msg1, nationality)\n except MultipleObjectsReturned, e:\n logger.warning(\n \"%s : found more than one country for nationality %r\",\n msg1, nationality)\n kw.update(nationality=nationality2country(data['nationality']))\n\n def doctype2cardtype(dt):\n #~ logger.info(\"20130103 documentType is %r\",dt)\n #~ if dt == 1: return BeIdCardTypes.get_by_value(\"1\")\n return BeIdCardTypes.get_by_value(str(dt))\n kw.update(card_type=doctype2cardtype(data['documentType']))\n\n #~ unused = dict()\n #~ unused.update(country=country)\n #~ kw.update(sex=data['sex'])\n #~ unused.update(documentType=data['documentType'])\n #~ logger.info(\"Unused data: %r\", unused)\n return kw", "metadata": "root.Plugin.card2client", "header": "['class', 'Plugin', '(', 'BeIdPlugin', ')', ':', '# was: use_eid_jslib', '___NEWLINE___', '# deprecated, not tested', '___NL___', '___EOS___']", "index": 69 } ]
[ { "span": "def nationality2country(nationality):", "start_line": 149, "start_column": 12, "end_line": 149, "end_column": 49 } ]
[]
1
true
[ "[CLS]_", "Unrea", "chab", "le_", "code_", "[SEP]_", "class_", "Plugin_", "(_", "Be", "Id", "Plugin_", ")_", ":_", "#", " ", "was", ":", " ", "use", "\\u", "eid", "\\u", "js", "lib_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "depre", "cated", ",", " ", "not", " ", "tested", "_", "\\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_", "card", "2c", "lient_", "(_", "cls_", ",_", "data_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"", "doe", "s", " ", "the", " ", "actual", " ", "conve", "rsi", "on", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "=_", "cls_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "lino", "_", "._", "utils_", "import_", "ssi", "n_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "lino", "_", "._", "api_", "import_", "dd_", ",_", "rt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "lino", "_", "._", "mixins_", "._", "bei", "d_", "import_", "Be", "Id", "Card", "Types_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "lino", "_", "._", "utils_", "import_", "join", "\\u", "words_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "lino", "_", "._", "utils_", "import_", "Incomp", "lete", "Date_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "lino", "_", "._", "modl", "ib_", "._", "contacts_", "._", "utils_", "import_", "street", "2", "kw_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "countries_", "=_", "dd_", "._", "resolve", "\\u", "app_", "(_", "'", "countr", "ies", "'_", ",_", "strict_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "kw_", "=_", "dict_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "def", " ", "func", "(", "fld", "name", ",", "qna", "me", "):", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "kw", "[", "fld", "name", "]", " ", "=", " ", "data", "[", "qna", "me", "]_", "\\u\\u\\uNL\\u\\u\\u_", "kw_", "._", "update_", "(_", "national", "\\u", "id_", "=_", "ssi", "n_", "._", "format\\u", "ssi", "n_", "(_", "data_", "[_", "'", "national", "Number", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "._", "update_", "(_", "first", "\\u", "name_", "=_", "join", "\\u", "words_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "[_", "'", "first", "Name", "1", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "[_", "'", "first", "Name", "2", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "[_", "'", "first", "Name", "3", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "func", "('", "first", "\\u", "name", "','", "first", "Name", "1", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "kw_", "._", "update_", "(_", "last", "\\u", "name_", "=_", "data_", "[_", "'", "sur", "name", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "card", "\\u", "number_", "=_", "data_", "[_", "'", "card", "Number", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "pic", "ture", "'_", "in_", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "fn_", "=_", "self_", "._", "card", "\\u", "number", "\\u", "to", "\\u", "pic", "ture", "\\u", "file_", "(_", "card", "\\u", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "exists_", "(_", "fn_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warning_", "(_", "\"", "Over", "writ", "ing", " ", "exist", "ing", " ", "image", " ", "file", " ", "%", "s", ".\"_", ",_", "fn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "fp_", "=_", "file_", "(_", "fn_", ",_", "'", "wb", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fp_", "._", "write_", "(_", "base64_", "._", "b64decode_", "(_", "data_", "[_", "'", "pic", "ture", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fp_", "._", "close_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "print", " ", "2012", "111", "7", ",", " ", "repr", "(", "data", "['", "pic", "ture", "'])", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "kw", ".", "update", "(", "pic", "ture", "\\u", "data\\u", "encode", "d", "=", "data", "['", "pic", "ture", "'])", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "func", "('", "card", "\\u", "valid", "\\u", "from", "','", "valid", "it", "y", "Begin", "Date", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "func", "('", "card", "\\u", "valid", "\\u", "unti", "l", "','", "valid", "it", "y", "End", "Date", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "func", "('", "birth", "\\u", "date", "','", "birth", "Date", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "kw_", "._", "update_", "(_", "birth", "\\u", "date_", "=_", "Incomp", "lete", "Date_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "*_", "settings_", "._", "SITE", "_", "._", "parse", "\\u", "date_", "(_", "data_", "[_", "'", "birth", "Date", "'_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "._", "update_", "(_", "card", "\\u", "valid", "\\u", "from_", "=_", "datetime_", "._", "date_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "*_", "settings_", "._", "SITE", "_", "._", "parse", "\\u", "date_", "(_", "data_", "[_", "'", "valid", "it", "y", "Begin", "Date", "'_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "._", "update_", "(_", "card", "\\u", "valid", "\\u", "until_", "=_", "datetime_", "._", "date_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "*_", "settings_", "._", "SITE", "_", "._", "parse", "\\u", "date_", "(_", "data_", "[_", "'", "valid", "it", "y", "End", "Date", "'_", "]_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "._", "update_", "(_", "card", "\\u", "number_", "=_", "card", "\\u", "number_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "._", "update_", "(_", "card", "\\u", "issuer_", "=_", "data_", "[_", "'", "issu", "ing", "Muni", "cipa", "lit", "y", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "._", "update_", "(_", "nob", "le", "\\u", "condition_", "=_", "data_", "[_", "'", "nob", "le", "Cond", "ition", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "._", "update_", "(_", "street_", "=_", "data_", "[_", "'", "street", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "._", "update_", "(_", "street", "\\u", "no_", "=_", "data_", "[_", "'", "street", "Number", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "._", "update_", "(_", "street", "\\u", "box_", "=_", "data_", "[_", "'", "box", "Number", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "kw_", "[_", "'", "street", "'_", "]_", "and_", "not_", "(_", "kw_", "[_", "'", "street", "\\u", "no", "'_", "]_", "or_", "kw_", "[_", "'", "street", "\\u", "box", "'_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "kw_", "=_", "street", "2", "kw_", "(_", "kw_", "[_", "'", "street", "'_", "]_", ",_", "**_", "kw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "kw_", "._", "update_", "(_", "zip", "\\u", "code_", "=_", "data_", "[_", "'", "zip", "Code", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "._", "update_", "(_", "birth", "\\u", "place_", "=_", "data_", "[_", "'", "birth", "Locat", "ion", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pk_", "=_", "data_", "[_", "'", "countr", "y", "'_", "]_", "._", "upper_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "msg", "1_", "=_", "\"", "Be", "Id", "Read", "Card", "To", "Client", "Action", " ", "%", "s", "\"_", "%_", "kw_", "._", "get_", "(_", "'", "national", "\\u", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "try", ":_", "\\u\\u\\uNL\\u\\u\\u_", "country_", "=_", "countries_", "._", "Country_", "._", "objects_", "._", "get_", "(_", "iso", "code_", "=_", "pk_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", "._", "update_", "(_", "country_", "=_", "country_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "except", " ", "countr", "ies", ".", "Count", "ry", ".", "Do", "es", "Not", "Exist", ",", "e", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "except", " ", "Except", "ion", ",", "e", ":_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "logg", "er", ".", "warn", "ing", "(\"", "%", "s", " ", ":", " ", "no", " ", "countr", "y", " ", "with", " ", "code", " ", "%", "r", "\",", "msg", "1", ",", "pk", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "BE", " ", "=", " ", "countr", "ies", ".", "Count", "ry", ".", "object", "s", ".", "get", "(", "iso", "code", "='", "BE", "')", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "fld", " ", "=", " ", "countr", "ies", ".", "Place", ".\\u", "meta", ".", "get", "\\u", "field", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "kw_", "._", "update_", "(_", "city_", "=_", "countries_", "._", "Place_", "._", "look", "up", "\\u", "or", "\\u", "create_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ",_", "data_", "[_", "'", "municip", "ality", "'_", "]_", ",_", "country_", "=_", "country_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "sex", "2g", "ender", "_", "(_", "sex_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "sex_", "==_", "'", "M", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "dd_", "._", "Gen", "ders", "_", "._", "male", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "sex_", "in_", "'", "FV", "W", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "dd_", "._", "Gen", "ders", "_", "._", "female", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "logger_", "._", "warning_", "(_", "\"%", "s", " ", ":", " ", "invalid", " ", "gender", " ", "code", " ", "%", "r", "\"_", ",_", "msg", "1_", ",_", "sex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "kw_", "._", "update_", "(_", "gender_", "=_", "sex", "2g", "ender", "_", "(_", "data_", "[_", "'", "sex", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "False_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "national", "it", "y2", "country_", "(_", "national", "ity_", ")_", ":_", "\\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_", "countries_", "._", "Country_", "._", "objects_", "._", "get_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "national", "iti", "es", "\\u\\u", "icontains_", "=_", "national", "ity_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "countries_", "._", "Country_", "._", "Do", "es", "Not", "Exist_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "logger_", "._", "warning_", "(_", "\"%", "s", " ", ":", " ", "no", " ", "countr", "y", " ", "for", " ", "national", "it", "y", " ", "%", "r", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "msg", "1_", ",_", "national", "ity_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Multipl", "e", "Object", "s", "Return", "ed_", ",_", "e_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "logger_", "._", "warning_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"%", "s", " ", ":", " ", "found", " ", "more", " ", "than", " ", "one", " ", "countr", "y", " ", "for", " ", "national", "it", "y", " ", "%", "r", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "msg", "1_", ",_", "national", "ity_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "kw_", "._", "update_", "(_", "national", "ity_", "=_", "national", "it", "y2", "country_", "(_", "data_", "[_", "'", "national", "it", "y", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "doct", "ype", "2c", "ard", "type_", "(_", "dt_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "~", " ", "logg", "er", ".", "info", "(\"", "20130", "103", " ", "document", "Type", " ", "is", " ", "%", "r", "\",", "dt", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "if", " ", "dt", " ", "==", " ", "1", ":", " ", "return", " ", "Be", "Id", "Card", "Type", "s", ".", "get", "\\u", "by", "\\u", "value", "(\"", "1", "\")", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Be", "Id", "Card", "Types_", "._", "get", "\\u", "by", "\\u", "value_", "(_", "str_", "(_", "dt_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "kw_", "._", "update_", "(_", "card", "\\u", "type_", "=_", "doct", "ype", "2c", "ard", "type_", "(_", "data_", "[_", "'", "document", "Type", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "unu", "sed", " ", "=", " ", "dict", "()", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "unu", "sed", ".", "update", "(", "countr", "y", "=", "countr", "y", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "kw", ".", "update", "(", "sex", "=", "data", "['", "sex", "'])", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "unu", "sed", ".", "update", "(", "document", "Type", "=", "data", "['", "document", "Type", "'])", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "~", " ", "logg", "er", ".", "info", "(\"", "Un", "used", " ", "data", ":", " ", "%", "r", "\",", " ", "unu", "sed", ")_", "\\u\\u\\uNL\\u\\u\\u_", "return_", "kw_" ]
[ 4, 4, 4, 4, 4, 4, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
anandology/pyjamas/examples/timesheet/view/components/PreferencesDlg.py
[ { "content": "\n# vim: set ts=4 sw=4 expandtab:\n\nfrom ApplicationConstants import Notification\n\nfrom pyjamas.ui.HorizontalPanel import HorizontalPanel\nfrom pyjamas.ui.VerticalPanel import VerticalPanel\nfrom pyjamas.ui.Label import Label\nfrom pyjamas.ui.Button import Button\nfrom pyjamas.ui.DialogBox import DialogBox\nfrom pyjamas.ui.FlexTable import FlexTable\nfrom pyjamas.ui.HTML import HTML\nfrom pyjamas.ui.TextBox import TextBox\nfrom pyjamas.Cookies import setCookie, getCookie\n\nfrom pyjamas.Window import alert\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class PreferencesDlg(DialogBox):\n\n fileLocation = None\n\n\n\n\n\n\n\n", "metadata": "root.PreferencesDlg", "header": "['module', '___EOS___']", "index": 17 }, { "content": " def __init__(self, left = 50, top = 50):\n DialogBox.__init__(self, modal = False)\n\n self.setPopupPosition(left, top)\n self.setText(\"Preferences\")\n ftable = FlexTable()\n ftableFormatter = ftable.getFlexCellFormatter()\n row = 0\n\n try:\n self.fileLocation = getCookie(\"fileLocation\")\n except:\n self.fileLocation = None\n\n row += 1\n ftable.setWidget(row, 0, Label(\"Sheet loaded on startup\", wordWrap=False))\n self.fileLocationInput = TextBox()\n self.fileLocationInput.addChangeListener(self.checkValid)\n self.fileLocationInput.addKeyboardListener(self)\n self.fileLocationInput.setVisibleLength(30)\n self.fileLocationInput.setText(self.fileLocation)\n ftable.setWidget(row, 1, self.fileLocationInput)\n\n row += 1\n hpanel = HorizontalPanel()\n self.saveBtn = Button(\"Save\", self.onSave)\n self.saveBtn.setEnabled(False)\n hpanel.add(self.saveBtn)\n self.cancelBtn = Button(\"Cancel\", self.onCancel)\n hpanel.add(self.cancelBtn)\n ftable.setWidget(row, 0, hpanel)\n ftableFormatter.setColSpan(row, 0, 2)\n\n self.setWidget(ftable)", "metadata": "root.PreferencesDlg.__init__", "header": "['class', 'PreferencesDlg', '(', 'DialogBox', ')', ':', '___EOS___']", "index": 21 }, { "content": " def onCancel(self, sender):\n self.hide()", "metadata": "root.PreferencesDlg.onCancel", "header": "['class', 'PreferencesDlg', '(', 'DialogBox', ')', ':', '___EOS___']", "index": 56 }, { "content": " def onSave(self, sender):\n try:\n setCookie(\"fileLocation\", self.fileLocationInput.getText(), 1000000000)\n except:\n pass\n self.hide()", "metadata": "root.PreferencesDlg.onSave", "header": "['class', 'PreferencesDlg', '(', 'DialogBox', ')', ':', '___EOS___']", "index": 59 }, { "content": " def checkValid(self, evt=None):\n if self.fileLocation != self.fileLocationInput.getText():\n self.saveBtn.setEnabled(True)\n else:\n self.saveBtn.setEnabled(False)", "metadata": "root.PreferencesDlg.checkValid", "header": "['class', 'PreferencesDlg', '(', 'DialogBox', ')', ':', '___EOS___']", "index": 66 }, { "content": " def onClick(self, sender):\n pass", "metadata": "root.PreferencesDlg.onClick", "header": "['class', 'PreferencesDlg', '(', 'DialogBox', ')', ':', '___EOS___']", "index": 72 }, { "content": " def onKeyUp(self, sender, keyCode, modifiers):\n self.checkValid()", "metadata": "root.PreferencesDlg.onKeyUp", "header": "['class', 'PreferencesDlg', '(', 'DialogBox', ')', ':', '___EOS___']", "index": 75 }, { "content": " def onKeyDown(self, sender, keyCode, modifiers):\n pass", "metadata": "root.PreferencesDlg.onKeyDown", "header": "['class', 'PreferencesDlg', '(', 'DialogBox', ')', ':', '___EOS___']", "index": 78 }, { "content": " def onKeyPress(self, sender, keyCode, modifiers):\n pass", "metadata": "root.PreferencesDlg.onKeyPress", "header": "['class', 'PreferencesDlg', '(', 'DialogBox', ')', ':', '___EOS___']", "index": 81 } ]
[ { "span": "from ApplicationConstants import Notification", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 45 }, { "span": "from pyjamas.ui.VerticalPanel import VerticalPanel", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 50 }, { "span": "from pyjamas.ui.HTML import HTML", "start_line": 11, "start_column": 0, "end_line": 11, "end_column": 32 }, { "span": "from pyjamas.Window import alert", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 32 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "vim", ":", " ", "set", " ", "ts", "=", "4", " ", "sw", "=", "4", " ", "expand", "tab", ":_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "Applica", "tion", "Constants_", "import_", "Notification_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "._", "Horiz", "onta", "l", "Panel_", "import_", "Horiz", "onta", "l", "Panel_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "._", "Vertica", "l", "Panel_", "import_", "Vertica", "l", "Panel_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "._", "Label_", "import_", "Label_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "._", "Button_", "import_", "Button_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "._", "Dialog", "Box_", "import_", "Dialog", "Box_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "._", "Fle", "x", "Table_", "import_", "Fle", "x", "Table_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "._", "HTML_", "import_", "HTML_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "._", "Text", "Box_", "import_", "Text", "Box_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "Cooki", "es_", "import_", "set", "Cookie_", ",_", "get", "Cookie_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "Window_", "import_", "alert_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Preference", "s", "Dlg_", "(_", "Dialog", "Box_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "file", "Location_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Preference", "s", "Dlg_", "(_", "Dialog", "Box_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "left_", "=_", "50_", ",_", "top_", "=_", "50_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "Dialog", "Box_", "._", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "modal_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "set", "Pop", "up", "Position_", "(_", "left_", ",_", "top_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "set", "Text_", "(_", "\"", "Preference", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fta", "ble_", "=_", "Fle", "x", "Table_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fta", "ble", "Formatter_", "=_", "fta", "ble_", "._", "get", "Fle", "x", "Cel", "l", "Formatter_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "row_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "file", "Location_", "=_", "get", "Cookie_", "(_", "\"", "file", "Locat", "ion", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "file", "Location_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "row_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fta", "ble_", "._", "set", "Widget_", "(_", "row_", ",_", "0_", ",_", "Label_", "(_", "\"", "She", "et", " ", "load", "ed", " ", "on", " ", "start", "up", "\"_", ",_", "word", "Wrap_", "=_", "False_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "file", "Locat", "ion", "Input_", "=_", "Text", "Box_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "file", "Locat", "ion", "Input_", "._", "add", "Change", "Listener_", "(_", "self_", "._", "check", "Valid_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "file", "Locat", "ion", "Input_", "._", "add", "Key", "board", "Listener_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "file", "Locat", "ion", "Input_", "._", "set", "Vis", "ibl", "e", "Length_", "(_", "30_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "file", "Locat", "ion", "Input_", "._", "set", "Text_", "(_", "self_", "._", "file", "Location_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fta", "ble_", "._", "set", "Widget_", "(_", "row_", ",_", "1_", ",_", "self_", "._", "file", "Locat", "ion", "Input_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "row_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hpa", "nel_", "=_", "Horiz", "onta", "l", "Panel_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "save", "Btn_", "=_", "Button_", "(_", "\"", "Save", "\"_", ",_", "self_", "._", "on", "Save_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "save", "Btn_", "._", "set", "Enabled_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hpa", "nel_", "._", "add_", "(_", "self_", "._", "save", "Btn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "cancel", "Btn_", "=_", "Button_", "(_", "\"", "Cancel", "\"_", ",_", "self_", "._", "on", "Cancel_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "hpa", "nel_", "._", "add_", "(_", "self_", "._", "cancel", "Btn_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fta", "ble_", "._", "set", "Widget_", "(_", "row_", ",_", "0_", ",_", "hpa", "nel_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "fta", "ble", "Formatter_", "._", "set", "Col", "Span_", "(_", "row_", ",_", "0_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "set", "Widget_", "(_", "fta", "ble_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Preference", "s", "Dlg_", "(_", "Dialog", "Box_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "on", "Cancel_", "(_", "self_", ",_", "sender_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "hide_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Preference", "s", "Dlg_", "(_", "Dialog", "Box_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "on", "Save_", "(_", "self_", ",_", "sender_", ")_", ":_", "\\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 ", " _", "set", "Cookie_", "(_", "\"", "file", "Locat", "ion", "\"_", ",_", "self_", "._", "file", "Locat", "ion", "Input_", "._", "get", "Text_", "(_", ")_", ",_", "1000000000", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "hide_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Preference", "s", "Dlg_", "(_", "Dialog", "Box_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "check", "Valid_", "(_", "self_", ",_", "evt_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "file", "Location_", "!=_", "self_", "._", "file", "Locat", "ion", "Input_", "._", "get", "Text_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "save", "Btn_", "._", "set", "Enabled_", "(_", "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 ", " _", "self_", "._", "save", "Btn_", "._", "set", "Enabled_", "(_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Preference", "s", "Dlg_", "(_", "Dialog", "Box_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "on", "Click_", "(_", "self_", ",_", "sender_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Preference", "s", "Dlg_", "(_", "Dialog", "Box_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "on", "Key", "Up_", "(_", "self_", ",_", "sender_", ",_", "key", "Code_", ",_", "modifiers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "check", "Valid_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Preference", "s", "Dlg_", "(_", "Dialog", "Box_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "on", "Key", "Down_", "(_", "self_", ",_", "sender_", ",_", "key", "Code_", ",_", "modifiers_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Preference", "s", "Dlg_", "(_", "Dialog", "Box_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "on", "Key", "Press_", "(_", "self_", ",_", "sender_", ",_", "key", "Code_", ",_", "modifiers_", ")_", ":_", "\\u\\u\\uNEW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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 4, 2, 2, 2, 2, 2, 2, 2, 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'
PublicMapping/DistrictBuilder/django/publicmapping/redistricting/views.py
[ { "content": "@login_required\n@unique_session_or_json_redirect\ndef scoreplan(request, planid):\n \"\"\"\n Validate a plan to allow for it to be shown in the leaderboard\n\n Parameters:\n request -- The HttpRequest, which includes the user.\n planid -- The plan to score.\n\n Returns:\n A JSON HttpResponse which includes a status, and if applicable,\n a reason why the plan couldn't be validated\n \"\"\"\n note_session_activity(request)\n status = { 'success': False }\n plan = Plan.objects.get(pk=planid)\n\n criterion = ValidationCriteria.objects.filter(legislative_body=plan.legislative_body)\n status['success'] = True\n for criteria in criterion:\n try:\n score = ComputedPlanScore.compute(criteria.function, plan)\n except:\n logger.debug(traceback.format_exc())\n\n if not score or not score['value']:\n status['success'] = False\n status['message'] = '<p>%s</p><p>%s</p>' % (criteria.get_short_label(), criteria.get_long_description() or criteria.function.get_long_description())\n break\n\n if status['success']:\n status['success'] = True\n status['message'] = _(\"Validation successful\")\n\n # Set is_valid status on the plan\n plan.is_valid = True\n plan.save()\n\n return HttpResponse(json.dumps(status),mimetype='application/json')", "metadata": "root.scoreplan", "header": "['module', '___EOS___']", "index": 297 }, { "content": "def commonplan(request, planid):\n \"\"\"\n A common method that gets the same data structures for viewing\n and editing. This method is called by the viewplan and editplan \n views.\n \n Parameters:\n request -- An HttpRequest\n planid -- The plan ID to fetch.\n \n Returns:\n A python dict with common plan attributes set to the plan's values.\n \"\"\"\n note_session_activity(request)\n\n plan = Plan.objects.filter(id=planid)\n if plan.count() == 1:\n plan = plan[0] \n plan.edited = getutc(plan.edited)\n levels = plan.legislative_body.get_geolevels()\n districts = plan.get_districts_at_version(plan.version,include_geom=False)\n editable = can_edit(request.user, plan)\n default_demo = plan.legislative_body.get_default_subject()\n max_dists = plan.legislative_body.max_districts\n body_member_short_label = plan.legislative_body.get_short_label()\n body_member_long_label = plan.legislative_body.get_label()\n body_members = plan.legislative_body.get_members_label()\n reporting_template = 'bard_%s.html' % plan.legislative_body.name if not plan.is_community() else None\n \n index = body_member_short_label.find('%(district_id)s')\n if index >= 0:\n body_member_short_label = body_member_short_label[0:index]\n index = body_member_long_label.find('%(district_id)s')\n if index >= 0:\n body_member_long_label = body_member_long_label[0:index]\n if not editable and not can_view(request.user, plan):\n plan = {}\n tags = []\n calculator_reports = []\n else:\n tags = Tag.objects.filter(name__startswith='type=').order_by('id').values_list('name',flat=True)\n tags = map(lambda x:x[5:], tags)\n\n # Reports defined with calculators (Score Displays, Panels, and Functions)\n # result is a map of relevant panels to score functions with labels and ids,\n # used for generating groups of checkboxes on the evaluate tab.\n calculator_reports = []\n if settings.REPORTS_ENABLED == 'CALC':\n report_displays = ScoreDisplay.objects.filter(name=\"%s_reports\" % plan.legislative_body.name)\n if len(report_displays) > 0:\n calculator_reports = map(lambda p: {\n 'title': p.__unicode__(),\n 'functions': map(lambda f: {\n 'label': f.get_label(),\n 'id': f.id\n }, p.score_functions.all().filter(selectable_bodies=plan.legislative_body))\n }, report_displays[0].scorepanel_set.all().order_by('position'))\n \n else:\n # If said plan doesn't exist, use an empty plan & district list.\n plan = {}\n levels = list()\n districts = {}\n editable = False\n default_demo = None\n max_dists = 0\n body_member_short_label = ''\n body_member_long_label = _('District') + ' '\n body_members = _n('district','districts',2)\n reporting_template = None\n tags = []\n calculator_reports = []\n demos = Subject.objects.all().order_by('sort_key')[0:3]\n layers = []\n snaplayers = []\n\n if len(levels) > 0:\n study_area_extent = list(levels[0].geounit_set.extent(field_name='simple'))\n else:\n # The geolevels with higher indexes are larger geography\n # Cycle through legislative bodies, since they may be in different regions\n for lb in LegislativeBody.objects.all():\n biglevel = lb.get_geolevels()[0]\n if biglevel.geounit_set.count() > 0:\n study_area_extent = biglevel.geounit_set.extent(field_name='simple')\n break\n\n for level in levels:\n # i18n-ize name here, not in js\n snaplayers.append({\n 'geolevel': level.id,\n 'level': level.name,\n 'layer': 'simple_' + level.name, \n 'long_description': level.get_long_description(),\n 'min_zoom': level.min_zoom\n })\n default_selected = False\n for demo in demos:\n isdefault = str((not default_demo is None) and (demo.id == default_demo.id)).lower()\n if isdefault == 'true':\n default_selected = True\n # i18n-ize name & short_display here, not in js\n layers.append({\n 'id':demo.id,\n 'text':demo.get_short_label(),\n 'value':demo.name, \n 'isdefault':isdefault, \n 'isdisplayed':str(demo.is_displayed).lower()\n })\n # If the default demo was not selected among the first three, we'll still need it for the dropdown menus\n if default_demo and not default_selected:\n layers.insert( 0, {\n 'id':default_demo.id,\n 'text':default_demo.get_short_label(),\n 'value':default_demo.name, \n 'isdefault':str(True).lower(), \n 'isdisplayed':str(default_demo.is_displayed).lower()\n })\n\n # Try to get the mapserver protocol from the settings module.\n # Set it to an empty string if the setting isn't defined so the \n # front-end Javascript will set a reasonable default (currently\n # the same protocol as the request to the webserver).\n if 'MAP_SERVER_PROTOCOL' in settings.__members__:\n mapserver_protocol = settings.MAP_SERVER_PROTOCOL\n else:\n mapserver_protocol = ''\n\n short_label = body_member_short_label.strip().lower()\n long_label = body_member_long_label.strip().lower()\n\n has_regions = Region.objects.all().count() > 1\n bodies = LegislativeBody.objects.all().order_by('region__sort_key','sort_key')\n l_bodies = [b for b in bodies if b in [sd.legislative_body for sd in ScoreDisplay.objects.filter(is_page=True)]]\n\n try:\n loader.get_template(reporting_template)\n except:\n reporting_template = None\n\n return RequestContext(request, {\n 'bodies': bodies,\n 'has_regions': has_regions,\n 'leaderboard_bodies': l_bodies,\n 'plan': plan,\n 'districts': districts,\n 'mapserver': settings.MAP_SERVER,\n 'mapserver_protocol': mapserver_protocol,\n 'basemaps': settings.BASE_MAPS,\n 'namespace': settings.MAP_SERVER_NS,\n 'ns_href': settings.MAP_SERVER_NSHREF,\n 'feature_limit': settings.FEATURE_LIMIT,\n 'adjacency': settings.ADJACENCY,\n 'convexchoropleth': settings.CONVEX_CHOROPLETH,\n 'demographics': layers,\n 'snaplayers': snaplayers,\n 'unassigned_id': UNASSIGNED_DISTRICT_ID,\n 'is_registered': request.user.username != 'anonymous' and request.user.username != '',\n 'debugging_staff': settings.DEBUG and request.user.is_staff,\n 'userinfo': get_user_info(request.user),\n 'is_editable': editable,\n 'max_dists': max_dists + 1,\n 'ga_account': settings.GA_ACCOUNT,\n 'ga_domain': settings.GA_DOMAIN,\n 'body_member_short_label': short_label, \n 'body_member_long_label': long_label,\n 'body_members': body_members,\n 'reporting_template': reporting_template,\n 'study_area_extent': study_area_extent,\n 'has_leaderboard' : len(ScoreDisplay.objects.filter(is_page=True)) > 0,\n 'calculator_reports' : json.dumps(calculator_reports),\n 'allow_email_submissions': ('EMAIL_SUBMISSION' in settings.__members__),\n 'tags': tags,\n 'site': Site.objects.get_current(),\n 'plan_text': _(\"community map\") if (plan and plan.is_community()) else _(\"plan\"),\n 'language_code': translation.get_language(),\n 'LANGUAGES': settings.LANGUAGES # needed (as CAPS) for language chooser\n })", "metadata": "root.commonplan", "header": "['module', '___EOS___']", "index": 364 }, { "content": "@login_required\n@unique_session_or_json_redirect\ndef createplan(request):\n \"\"\"\n Create a plan.\n\n Create a plan from a POST request. This plan will be 'blank', and will\n contain only the Unassigned district initially.\n\n Parameters:\n request -- An HttpRequest, which contains the current user.\n\n Returns:\n A JSON HttpResponse, including the new plan's information, or an\n error describing why the plan could not be created.\n \"\"\"\n note_session_activity(request)\n\n status = { 'success': False }\n if request.method == \"POST\":\n name = request.POST['name'][0:200]\n body = LegislativeBody.objects.get(id=int(request.POST['legislativeBody']))\n plan = Plan(name=name, owner=request.user, legislative_body=body, processing_state=ProcessingState.READY)\n try:\n plan.save()\n status = serializers.serialize(\"json\", [ plan ])\n except:\n status = { 'success': False, 'message': _(\"Couldn't save new plan\") }\n return HttpResponse(json.dumps(status),mimetype='application/json')", "metadata": "root.createplan", "header": "['module', '___EOS___']", "index": 749 }, { "content": "@unique_session_or_json_redirect\ndef getreport(request, planid):\n \"\"\"\n Get a BARD report.\n\n This view will write out an HTML-formatted BARD report to the directory\n given in the settings.\n \n Parameters:\n request -- An HttpRequest\n planid -- The plan to be reported.\n \n Returns:\n The HTML for use as a preview in the web application, along with \n the web address of the BARD report.\n \"\"\"\n note_session_activity(request)\n\n status = { 'success': False }\n try:\n plan = Plan.objects.get(pk=planid)\n except:\n status['message'] = _('No plan with the given id')\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n if not can_view(request.user, plan):\n status['message'] = _(\"User can't view the given plan\")\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n if not settings.REPORTS_ENABLED is None:\n status['message'] = _('Reports functionality is turned off.')\n return HttpResponse(json.dumps(status),mimetype='application/json')\n \n # Get the variables from the request\n if request.method != 'POST':\n status['message'] = _(\"Information for report wasn't sent via POST\")\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n stamp = request.POST.get('stamp', generate_report_hash(request.POST))\n\n rptstatus = PlanReport.checkreport(planid, stamp)\n if rptstatus == 'ready':\n status = {\n 'success': True,\n 'url': PlanReport.getreport(planid, stamp),\n 'retry': 0,\n 'message': _('Plan report is ready.'),\n 'stamp': stamp\n }\n elif rptstatus == 'busy':\n status = {\n 'success': True,\n 'url': reverse(getreport, args=[planid]),\n 'retry': 10,\n 'message': _('Report is building.'),\n 'stamp': stamp\n }\n elif rptstatus == 'free':\n status = {\n 'success': True,\n 'url': reverse(getreport, args=[planid]),\n 'retry': 10,\n 'message': _('Report generation started.'),\n 'stamp': stamp\n }\n\n req = {\n 'popVar': request.POST.get('popVar', ''),\n 'popVarExtra': request.POST.get('popVarExtra', ''),\n 'ratioVars[]': request.POST.getlist('ratioVars[]'),\n 'splitVars': request.POST.get('splitVars', ''),\n 'blockLabelVar': request.POST.get('blockLabelVar', 'CTID'),\n 'repComp': request.POST.get('repCompactness', ''),\n 'repCompExtra': request.POST.get('repCompactnessExtra', ''),\n 'repSpatial': request.POST.get('repSpatial', ''),\n 'repSpatialExtra': request.POST.get('repSpatialExtra', '')\n }\n\n PlanReport.markpending(planid, stamp)\n PlanReport.createreport.delay(planid, stamp, req, language=translation.get_language())\n else:\n status['message'] = _(\n 'Unrecognized status when checking report status.')\n\n return HttpResponse(json.dumps(status),mimetype='application/json')", "metadata": "root.getreport", "header": "['module', '___EOS___']", "index": 862 }, { "content": "@unique_session_or_json_redirect\ndef getcalculatorreport(request, planid):\n \"\"\"\n Get a report which is generated by using calculators.\n\n This view will write out an HTML-formatted report to the directory\n given in the settings.\n \n Parameters:\n request -- An HttpRequest\n planid -- The plan to be reported.\n \n Returns:\n The HTML for use as a preview in the web application, along with \n the web address of the report.\n \"\"\"\n note_session_activity(request)\n\n status = { 'success': False }\n try:\n plan = Plan.objects.get(pk=planid)\n except:\n status['message'] = _('No plan with the given id')\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n if not can_view(request.user, plan):\n status['message'] = _(\"User can't view the given plan\")\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n if request.method != 'POST':\n status['message'] = _(\"Information for report wasn't sent via POST\")\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n # extract the function ids from the POST\n function_ids = request.POST.get('functionIds', '')\n \n # generate a hash of the function ids\n sha = hashlib.sha1()\n sha.update(function_ids)\n stamp = request.POST.get('stamp', sha.hexdigest())\n\n rptstatus = CalculatorReport.checkreport(planid, stamp)\n if rptstatus == 'ready':\n status = {\n 'success': True,\n 'url': CalculatorReport.getreport(planid, stamp),\n 'retry': 0,\n 'message': _('Plan report is ready.'),\n 'stamp': stamp\n }\n elif rptstatus == 'busy':\n status = {\n 'success': True,\n 'url': reverse(getcalculatorreport, args=[planid]),\n 'retry': 5,\n 'message': _('Report is building.'),\n 'stamp': stamp\n }\n elif rptstatus == 'free':\n status = {\n 'success': True,\n 'url': reverse(getcalculatorreport, args=[planid]),\n 'retry': 5,\n 'message': _('Report generation started.'),\n 'stamp': stamp\n }\n\n req = { 'functionIds': function_ids }\n CalculatorReport.markpending(planid, stamp)\n CalculatorReport.createcalculatorreport.delay(planid, stamp, req, language=translation.get_language())\n else:\n status['message'] = _(\n 'Unrecognized status when checking report status.')\n\n return HttpResponse(json.dumps(status),mimetype='application/json')", "metadata": "root.getcalculatorreport", "header": "['module', '___EOS___']", "index": 948 }, { "content": "@login_required\n@unique_session_or_json_redirect\[email protected]_manually\ndef add_districts_to_plan(request, planid):\n \"\"\"\n This handler is used to paste existing districts from one\n plan into another plan\n \n Parameters:\n request -- An HttpRequest object including a list of districtids and\n a version\n planid -- The plan into which to paste the districts\n\n Returns:\n Some JSON explaining the success or failure of the paste operation\n \"\"\"\n\n status = { 'success': False }\n\n # Make sure we can edit the given plan\n try:\n plan = Plan.objects.get(pk=planid)\n except:\n status['message'] = _('No plan with the given id')\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n if not can_edit(request.user, plan):\n status['message'] = _(\"User can't edit the given plan\")\n return HttpResponse(json.dumps(status),mimetype='application/json')\n \n # Get the districts we want to merge\n district_list = request.POST.getlist('districts[]')\n if len(district_list) == 0:\n status['message'] = _(\"No districts selected to add to the given plan\")\n return HttpResponse(json.dumps(status),mimetype='application/json')\n else:\n districts = District.objects.filter(id__in=district_list)\n version = int(request.POST.get('version', None))\n status['message'] = _('Going to merge %(number_of_merged_districts)d' \\\n ' districts') % {'number_of_merged_districts': len(districts)}\n \n # Check to see if we have enough room to add these districts without\n # going over MAX_DISTRICTS for the legislative_body\n allowed_districts = plan.get_available_districts(version=version)\n \n if len(districts) > allowed_districts:\n status['message'] = _('Tried to merge too many districts; ' \\\n '%(allowed_districts)d slots left') % {'allowed_districts': allowed_districts}\n\n # Everything checks out, let's paste those districts\n try:\n results = plan.paste_districts(districts, version=version)\n transaction.commit()\n status['success'] = True\n status['message'] = _('Merged %(num_merged_districts)d districts') % {'num_merged_districts': len(results)}\n status['version'] = plan.version\n except Exception as ex:\n transaction.rollback()\n status['message'] = str(ex)\n status['exception'] = traceback.format_exc()\n\n return HttpResponse(json.dumps(status),mimetype='application/json')", "metadata": "root.add_districts_to_plan", "header": "['module', '___EOS___']", "index": 1130 }, { "content": "@login_required\n@unique_session_or_json_redirect\[email protected]_manually\ndef assign_district_members(request, planid):\n \"\"\"\n This handler is used to assign members to districts\n \n Parameters:\n request -- An HttpRequest object including a version,\n and a mapping of districtids to num_members\n planid -- The plan into which to assign district members\n\n Returns:\n Some JSON explaining the success or failure of the paste operation\n \"\"\"\n\n status = { 'success': False }\n\n # Make sure we can edit the given plan\n try:\n plan = Plan.objects.get(pk=planid)\n except:\n status['message'] = _('No plan with the given id')\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n if not can_edit(request.user, plan):\n status['message'] = _(\"User can't edit the given plan\")\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n # Make sure this district allows multi-member assignment\n leg_bod = plan.legislative_body\n if (not leg_bod.multi_members_allowed):\n status['message'] = _(\n 'Multi-members not allowed for this legislative body')\n return HttpResponse(json.dumps(status),mimetype='application/json')\n \n # Get the districts we want to assign members to\n districts = request.POST.getlist('districts[]')\n counts = request.POST.getlist('counts[]')\n version = int(request.POST.get('version', None)) \n\n # Assign the district members and return status\n try:\n changed = 0\n for i in range(0, len(districts)):\n id = int(districts[i])\n count = int(counts[i])\n district = District.objects.filter(plan=plan,district_id=id,version__lte=version).order_by('version').reverse()[0]\n\n if district.num_members != count:\n if (changed == 0):\n # If there is at least one change, update the plan\n if version != plan.version:\n plan.purge(after=version)\n\n plan.version = plan.version + 1\n plan.save()\n\n plan.update_num_members(district, count)\n changed += 1\n\n transaction.commit()\n status['success'] = True\n status['version'] = plan.version\n status['modified'] = changed\n status['message'] = _('Modified members for %(num_districts)d '\n 'districts') % {'num_districts': changed}\n except Exception, ex:\n transaction.rollback()\n status['message'] = str(ex)\n status['exception'] = traceback.format_exc()\n logger.warn('Could not assign district members')\n logger.debug('Reason: %s', ex)\n\n return HttpResponse(json.dumps(status),mimetype='application/json')", "metadata": "root.assign_district_members", "header": "['module', '___EOS___']", "index": 1193 }, { "content": "@login_required\n@unique_session_or_json_redirect\ndef combine_districts(request, planid):\n \"\"\"\n Take the contents of one district and add them to another districts\n \"\"\"\n \n status = { 'success': False }\n\n # Make sure we can edit the given plan\n try:\n plan = Plan.objects.get(pk=planid)\n except:\n status['message'] = _('No plan with the given id')\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n if not can_edit(request.user, plan):\n status['message'] = _(\"User can't edit the given plan\")\n return HttpResponse(json.dumps(status),mimetype='application/json')\n \n # Get the districts we want to merge\n version = int(request.POST.get('version', plan.version))\n from_id = int(request.POST.get('from_district_id', -1))\n to_id = int(request.POST.get('to_district_id', None))\n\n try:\n all_districts = plan.get_districts_at_version(version, include_geom=True)\n \n from_districts = filter(lambda d: True if d.district_id == from_id else False, all_districts)\n to_district = filter(lambda d: True if d.district_id == to_id else False, all_districts)[0]\n\n locked = to_district.is_locked\n for district in from_districts:\n if district.is_locked:\n locked = True\n\n if locked:\n status['message'] = _(\"Can't combine locked districts\")\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n result = plan.combine_districts(to_district, from_districts, version=version)\n\n if result[0] == True:\n status['success'] = True\n status['message'] = _('Successfully combined districts')\n status['version'] = result[1]\n except Exception, ex:\n status['message'] = _('Could not combine districts')\n status['exception'] = traceback.format_exc()\n logger.warn('Could not combine districts')\n logger.debug('Reason: %s', ex)\n return HttpResponse(json.dumps(status),mimetype='application/json')", "metadata": "root.combine_districts", "header": "['module', '___EOS___']", "index": 1269 }, { "content": "@login_required\n@unique_session_or_json_redirect\ndef fix_unassigned(request, planid):\n \"\"\"\n Assign unassigned base geounits that are fully contained\n or adjacent to another district\n \"\"\"\n \n status = { 'success': False }\n\n try:\n plan = Plan.objects.get(pk=planid)\n except:\n status['message'] = _('No plan with the given id')\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n if not can_edit(request.user, plan):\n status['message'] = _(\"User can't edit the given plan\")\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n try:\n version = int(request.POST.get('version', plan.version))\n result = plan.fix_unassigned(version)\n status['success'] = result[0]\n status['message'] = result[1]\n status['version'] = plan.version\n except Exception, ex:\n status['message'] = _('Could not fix unassigned')\n status['exception'] = traceback.format_exc()\n logger.warn('Could not fix unassigned')\n logger.debug('Reason: %s', ex)\n return HttpResponse(json.dumps(status),mimetype='application/json')", "metadata": "root.fix_unassigned", "header": "['module', '___EOS___']", "index": 1322 }, { "content": "@unique_session_or_json_redirect\ndef get_splits(request, planid, otherid, othertype):\n \"\"\"\n Find all splits between this plan and another plan\n\n Parameters:\n request -- An HttpRequest optionally containing version and/or otherversion\n planid -- The plan ID\n otherid -- The plan ID or geolevel ID to find splits with\n othertype -- One of: 'plan' or 'geolevel'. For specifying otherid\n\n Returns:\n A JSON HttpResponse that contains an array of splits, given as arrays,\n where the first item is the district_id of the district in this plan\n which causes the split, and the second item is the district_id of the\n district in the other plan or geolevel. When a geolevel is specified,\n the portable_id will be used, rather than the district_id.\n \"\"\"\n\n otherid = int(otherid)\n status = { 'success': False }\n\n try:\n plan = Plan.objects.get(pk=planid)\n except:\n status['message'] = _('No plan with the given id')\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n if not can_view(request.user, plan):\n status['message'] = _(\"User can't view the given plan\")\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n version = int(request.REQUEST['version'] if 'version' in request.REQUEST else plan.version)\n try:\n if othertype == 'plan':\n try:\n otherplan = Plan.objects.get(pk=otherid)\n except:\n status['message'] = _('No other plan with the given id')\n return HttpResponse(json.dumps(status),mimetype='application/json')\n if not can_view(request.user, otherplan):\n status['message'] = _(\"User can't view the given plan\")\n return HttpResponse(json.dumps(status),mimetype='application/json')\n \n otherversion = int(request.REQUEST['otherversion'] if 'otherversion' in request.REQUEST else otherplan.version)\n splits = plan.find_plan_splits(otherplan, version, otherversion)\n elif othertype == 'geolevel':\n splits = plan.find_geolevel_splits(otherid, version)\n else:\n status['message'] = _('othertype not supported: %(other)s') % { 'other': othertype }\n return HttpResponse(json.dumps(status),mimetype='application/json')\n\n split_word = _('split') if len(splits) == 1 else inflect.engine().plural(_('split'))\n\n status['success'] = True\n status['message'] = _('Found %(num_splits)d %(split_word)s') % \\\n {'num_splits': len(splits), 'split_word': split_word}\n status['splits'] = splits\n status['above_ids'] = list(set([i[0] for i in splits]))\n status['below_ids'] = list(set([i[1] for i in splits]))\n except Exception, ex:\n status['message'] = _('Could not query for splits')\n status['exception'] = traceback.format_exc()\n logger.warn('Could not query for splits')\n logger.debug('Reason: %s', ex)\n return HttpResponse(json.dumps(status),mimetype='application/json')", "metadata": "root.get_splits", "header": "['module', '___EOS___']", "index": 1356 }, { "content": "def get_splits_report(request, planid):\n \"\"\"\n Get the rendered splits report\n \"\"\"\n note_session_activity(request)\n\n try:\n plan = Plan.objects.get(pk=planid)\n except:\n return HttpResponse(_('Plan does not exist.'), mimetype='text/plain')\n\n if not using_unique_session(request.user) or not can_view(request.user, plan):\n return HttpResponseForbidden()\n\n version = int(request.REQUEST['version'] if 'version' in request.REQUEST else plan.version)\n inverse = request.REQUEST['inverse'] == 'true' if 'inverse' in request.REQUEST else False\n extended = request.REQUEST['extended'] == 'true' if 'extended' in request.REQUEST else False\n layers = request.REQUEST.getlist('layers[]')\n if len(layers) == 0:\n return HttpResponse(_('No layers were provided.'), mimetype='text/plain')\n\n try :\n report = loader.get_template('split_report.html')\n html = ''\n for layer in layers:\n my_context = {'extended': extended}\n my_context.update(plan.compute_splits(layer, version = version, inverse = inverse, extended = extended))\n last_item = layer is layers[-1]\n community_info = plan.get_community_type_info(layer, version = version, inverse = inverse, include_counts=last_item)\n if community_info is not None:\n my_context.update(community_info)\n calc_context = DjangoContext(my_context)\n html += report.render(calc_context)\n if not last_item:\n html += '<hr />'\n return HttpResponse(html, mimetype='text/html')\n except Exception, ex:\n logger.warn('Could not produce split report')\n logger.debug('Reason: %s', ex)\n return HttpResponse(str(ex), mimetype='text/plain')", "metadata": "root.get_splits_report", "header": "['module', '___EOS___']", "index": 1441 }, { "content": "@login_required\n@unique_session_or_json_redirect\ndef addtodistrict(request, planid, districtid):\n \"\"\"\n Add geounits to a district.\n\n This method requires both \"geolevel\" and \"geounits\" URL parameters. \n The geolevel must be a valid geolevel name and the geounits parameters \n should be a pipe-separated list of geounit ids.\n\n Parameters:\n request -- An HttpRequest, with the current user, the geolevel, and\n the pipe-separated geounit list.\n planid -- The plan ID that contains the district.\n districtid -- The district ID to which the geounits will be added.\n\n Returns:\n A JSON HttpResponse that contains the number of districts modified,\n or an error message if adding fails.\n \"\"\"\n note_session_activity(request)\n\n status = { 'success': False }\n\n if len(request.REQUEST.items()) >= 2:\n try:\n geolevel = request.REQUEST[\"geolevel\"]\n geounit_ids = string.split(request.REQUEST[\"geounits\"], \"|\")\n plan = Plan.objects.get(pk=planid,owner=request.user)\n except:\n status['exception'] = traceback.format_exc()\n status['message'] = _('Could not add units to district.')\n\n # get the version from the request or the plan\n if 'version' in request.REQUEST:\n version = request.REQUEST['version']\n else:\n version = plan.version\n\n try:\n fixed = plan.add_geounits(districtid, geounit_ids, geolevel, version)\n status['success'] = True;\n status['message'] = _('Updated %(num_fixed_districts)d districts') \\\n % {'num_fixed_districts': fixed}\n status['updated'] = fixed\n plan = Plan.objects.get(pk=planid,owner=request.user)\n status['edited'] = getutc(plan.edited).isoformat()\n status['version'] = plan.version\n except Exception, ex: \n status['exception'] = traceback.format_exc()\n status['message'] = _('Could not add units to district.')\n logger.warn('Could not add units to district')\n logger.debug('Reason: %s', ex)\n\n else:\n status['message'] = _(\"Geounits weren't found in a district.\")\n\n return HttpResponse(json.dumps(status),mimetype='application/json')", "metadata": "root.addtodistrict", "header": "['module', '___EOS___']", "index": 1483 }, { "content": "@unique_session_or_json_redirect\ndef get_statistics(request, planid):\n note_session_activity(request)\n\n status = { 'success': False }\n try:\n plan = Plan.objects.get(pk=planid)\n except:\n status['message'] = _(\n \"Couldn't get geography info from the server. No plan with the given id.\")\n return HttpResponse( json.dumps(status), mimetype='application/json', status=500)\n\n if 'version' in request.REQUEST:\n try:\n version = int(request.REQUEST['version'])\n except:\n version = plan.version\n else:\n version = plan.version\n\n try:\n display = ScoreDisplay.objects.get(legislative_body=plan.legislative_body, name=\"%s_sidebar_demo\" % plan.legislative_body.name)\n except:\n status['message'] = _('Unable to get Demographics ScoreDisplay')\n status['exception'] = traceback.format_exc()\n \n if 'displayId' in request.REQUEST:\n try:\n display = ScoreDisplay.objects.get(pk=request.POST['displayId'])\n except:\n status['message'] = _('Unable to get Personalized ScoreDisplay')\n status['exception'] = traceback.format_exc()\n\n else:\n logger.warn('No displayId in request.')\n logger.warn(str(request.POST))\n \n try :\n html = display.render(plan, request, version=version)\n return HttpResponse(html, mimetype='text/html')\n except Exception, ex:\n status['message'] = _(\"Couldn't render display tab.\")\n status['exception'] = traceback.format_exc()\n logger.warn(\"Couldn't render display tab\")\n logger.debug('Reason: %s', ex)\n return HttpResponse( json.dumps(status), mimetype='application/json', status=500)", "metadata": "root.get_statistics", "header": "['module', '___EOS___']", "index": 1814 }, { "content": "def getleaderboarddisplay(leg_body, owner_filter):\n \"\"\"\n Returns the leaderboard ScoreDisplay given a legislative body and owner\n \"\"\"\n try:\n return ScoreDisplay.objects.get(name=\"%s_leader_%s\" % (leg_body.name, owner_filter))\n except:\n return None", "metadata": "root.getleaderboarddisplay", "header": "['module', '___EOS___']", "index": 1955 }, { "content": "def get_shared_districts(request, planid):\n \"\"\"\n Get the shared districts in a given plan and return the\n data in a format readable by the jqgrid\n \"\"\"\n note_session_activity(request)\n\n if not using_unique_session(request.user):\n return HttpResponseForbidden()\n\n if request.method == 'POST':\n page = int(request.POST.get('page', 1))\n rows = int(request.POST.get('rows', 10))\n else:\n return HttpResponseForbidden()\n\n end = page * rows\n start = end - rows\n \n try:\n plan = Plan.objects.get(pk=planid)\n if not can_copy(request.user, plan):\n return HttpResponseForbidden()\n\n all_districts = plan.get_districts_at_version(plan.version, include_geom=False)\n except:\n plan = None\n all_districts = () \n\n if len(all_districts) > 0:\n total_pages = math.ceil(len(all_districts) / float(rows))\n else:\n total_pages = 1\n\n districts = all_districts[start:end]\n # Create the objects that will be serialized for presentation in the plan chooser\n districts_list = list()\n for district in districts:\n if not district.is_unassigned:\n districts_list.append({\n 'pk': district.id, \n 'fields': { \n 'short_label': district.short_label,\n 'long_label': district.long_label,\n 'district_id': district.district_id,\n }\n })\n\n json_response = \"{ \\\"total\\\":\\\"%d\\\", \\\"page\\\":\\\"%d\\\", \\\"records\\\":\\\"%d\\\", \\\"rows\\\":%s }\" % (total_pages, page, len(all_districts), json.dumps(districts_list))\n return HttpResponse(json_response,mimetype='application/json') ", "metadata": "root.get_shared_districts", "header": "['module', '___EOS___']", "index": 2133 }, { "content": "def get_health(request):\n def num_users(minutes):\n users = 0\n for session in Session.objects.all():\n try:\n decoded = session.get_decoded()\n except:\n #There's a problem with this session, remove it\n session.delete()\n continue\n \n if 'activity_time' in decoded:\n activity_delta = decoded['activity_time'] - timedelta(0,0,0,0,settings.SESSION_TIMEOUT)\n if activity_delta > (datetime.now() - timedelta(0,0,0,0,minutes)):\n users += 1\n return users\n\n try:\n result = _('Health retrieved at %(time)s\\n') % {'time': datetime.now()}\n result += _('%(plan_count)d plans in database\\n') % \\\n {'plan_count': Plan.objects.all().count()}\n result += _('%(session_count)d sessions in use out of %(session_limit)s\\n') % \\\n {'session_count': Session.objects.all().count(),\n 'session_limit': settings.CONCURRENT_SESSIONS}\n result += _('%(num_users)d active users over the last 10 minutes\\n') % \\\n {'num_users': num_users(10)}\n space = os.statvfs('/projects/PublicMapping')\n result += _('%(mb_free)s MB of disk space free\\n') % \\\n {'mb_free': ((space.f_bsize * space.f_bavail) / (1024*1024))}\n result += _('Memory Usage:\\n%(mem_free)s\\n') % \\\n {'mem_free': commands.getoutput('free -m')}\n return HttpResponse(result, mimetype='text/plain')\n except:\n return HttpResponse(_(\"ERROR! Couldn't get health:\\n%s\") % traceback.format_exc())", "metadata": "root.get_health", "header": "['module', '___EOS___']", "index": 2293 }, { "content": "def statistics_sets(request, planid):\n result = { 'success': False }\n\n plan = Plan.objects.filter(id=planid)\n if plan.count() == 0:\n result['message'] = _('No plan with that ID exists.')\n return HttpResponse(json.dumps(result),mimetype='application/json')\n else:\n plan = plan[0]\n\n if request.method == 'GET':\n sets = []\n scorefunctions = []\n \n # Get the functions available for the users\n user_functions = ScoreFunction.objects.filter(selectable_bodies=plan.legislative_body).order_by('name')\n for f in user_functions:\n if 'report' not in f.name.lower() and 'comments' not in f.name.lower():\n scorefunctions.append({ 'id': f.id, 'name': force_escape(f.get_label()) })\n result['functions'] = scorefunctions\n\n \n admin_display_names = [\n \"%s_sidebar_demo\" % plan.legislative_body.name,\n ]\n\n if plan.legislative_body.is_community:\n admin_display_names.append(\"%s_sidebar_comments\" %\n plan.legislative_body.name)\n else:\n admin_display_names.append(\"%s_sidebar_basic\" %\n plan.legislative_body.name)\n # Get the admin displays\n admin_displays = ScoreDisplay.objects.filter(\n owner__is_superuser=True,\n legislative_body=plan.legislative_body,\n name__in=admin_display_names\n )\n\n for admin_display in admin_displays:\n sets.append({ \n 'id': admin_display.id,\n 'name': force_escape(admin_display.get_label()),\n 'functions': [],\n 'mine':False\n })\n\n try:\n user_displays = ScoreDisplay.objects.filter(\n owner=request.user, \n legislative_body=plan.legislative_body,\n is_page=False).order_by('title')\n result['displays_count'] = len(user_displays)\n for display in user_displays:\n functions = []\n for panel in display.scorepanel_set.all():\n if panel.type == 'district':\n functions = map(lambda x: x.id, panel.score_functions.all())\n if len(functions) == 0:\n result['message'] = _(\"No functions for %(panel)s\") % \\\n {'panel_name': panel}\n sets.append({ 'id': display.id, 'name': force_escape(display.__unicode__()), 'functions': functions, 'mine': display.owner==request.user })\n except Exception, ex:\n result['message'] = _('No user displays for %(user)s') % \\\n {'user': request.user}\n logger.warn('Error fetching ScoreDisplays for user')\n logger.debug('Reason: %s', ex)\n\n result['sets'] = sets\n result['success'] = True\n # Delete the requested ScoreDisplay to make some room\n elif request.method == 'POST' and 'delete' in request.POST:\n try:\n display = ScoreDisplay.objects.get(pk=request.REQUEST.get('id', -1))\n result['set'] = {'name':force_escape(display.__unicode__()), 'id':display.id}\n qset = display.scorepanel_set.all()\n for panel in qset:\n if panel.displays.count() == 1:\n panel.delete()\n display.delete()\n result['success'] = True\n except Exception, ex:\n result['message'] = _(\"Couldn't delete personalized scoredisplay\")\n result['exception'] = traceback.format_exc()\n logger.warn(\"Couldn't delete personalized ScoreDisplay\")\n logger.debug('Reason: %s', ex)\n \n # If it's a post, edit or create the ScoreDisplay and return \n # the id and name as usual\n elif request.method == 'POST':\n # If we're adding a new display, we should make sure they only have 3\n def validate_num(user, limit=3):\n return ScoreDisplay.objects.filter(owner=user, legislative_body=plan.legislative_body, is_page=False).count() < limit\n\n if 'functions[]' in request.POST:\n functions = request.POST.getlist('functions[]')\n functions = map(lambda x: int(x), functions)\n try:\n display = ScoreDisplay.objects.get(title=request.POST.get('name'), owner=request.user)\n display = display.copy_from(display=display, functions=functions)\n except:\n limit = 3\n if validate_num(request.user, limit):\n demo = ScoreDisplay.objects.filter(\n owner__is_superuser=True,\n legislative_body=plan.legislative_body,\n is_page=False,\n\t\t\ttitle=\"Demographics\"\n )\n # DO NOT select the ScoreDisplay that contains\n # the comment calculator\n for disp in demo:\n has_comments = False\n for pnl in disp.scorepanel_set.all():\n for fn in pnl.score_functions.all():\n has_comments = has_comments or fn.calculator.endswith('.Comments')\n if not has_comments:\n demo = disp\n break\n\n display = ScoreDisplay()\n display = display.copy_from(display=demo, title=request.POST.get('name'), owner=request.user, functions=functions)\n result['newRecord'] = True\n else:\n result['message'] = _('Each user is limited to %(limit)d '\n 'statistics sets. Please delete one or edit '\n 'an existing set.') % { 'limit': limit }\n result['error'] = 'limit'\n return HttpResponse(json.dumps(result),mimetype='application/json')\n\n result['set'] = {'name':force_escape(display.__unicode__()), 'id':display.id, 'functions':functions, 'mine': display.owner==request.user}\n result['success'] = True\n\n else:\n result['message'] = _(\"Didn't get functions in POST parameter\")\n\n return HttpResponse(json.dumps(result),mimetype='application/json')", "metadata": "root.statistics_sets", "header": "['module', '___EOS___']", "index": 2329 }, { "content": "@unique_session_or_json_redirect\ndef district_info(request, planid, district_id):\n \"\"\"\n Get the comments that are attached to a district.\n\n Parameters:\n request -- An HttpRequest\n planid -- The plan ID\n district_id -- The district ID, this is the district number in a plan, and NOT the id of a district.\n \"\"\"\n status = { 'success': False }\n plan = Plan.objects.filter(id=planid)\n if plan.count() == 0:\n status['message'] = _('No plan with that ID was found.')\n else:\n plan = plan[0]\n\n version = plan.version\n if 'version' in request.REQUEST:\n try:\n version = int(request.REQUEST['version'])\n version = min(plan.version, int(version))\n except:\n pass\n\n district_id = int(district_id)\n district = plan.get_districts_at_version(version, include_geom=False)\n district = filter(lambda d:d.district_id==district_id, district)\n\n if request.method == 'POST':\n district = plan.district_set.get(id=request.POST['object_pk'])\n district.short_label = request.POST['district_short'][0:10]\n district.long_label = request.POST['district_long'][0:256]\n\n\n if district.version < version:\n # The district version may lag behind the cursor \n # version if there were no edits for a while. If this \n # is the case the district must be copied to the \n # currently edited version.\n district_copy = copy.copy(district)\n district_copy.id = None\n district_copy.version = version\n\n district_copy.save()\n\n # clone the characteristics, comments, and tags from \n # the original district to the copy \n district_copy.clone_relations_from(district)\n district = district_copy\n else:\n # save the changes to the district -- maybe name change\n district.save()\n\n has_comment = 'comment' in request.POST and request.POST['comment'] != '' \n if has_comment:\n # Don't thread comments, keep only the latest and greatest\n ct = ContentType.objects.get(app_label='redistricting',model='district')\n Comment.objects.filter(object_pk = district.id, content_type=ct).delete()\n comment = Comment(\n object_pk=district.id, \n content_type=ct, \n site_id=Site.objects.get_current().id, \n user_name=request.user.username, \n user_email=request.user.email, \n comment=request.POST['comment'])\n comment.save()\n else:\n # save this if the label changed\n district.save()\n\n # Get the tags on this object of this type.\n tset = Tag.objects.get_for_object(district).filter(name__startswith='type')\n\n # Purge the tags of this same type off the object\n TaggedItem.objects.filter(tag__in=tset, object_id=district.id).delete()\n\n purge_plan_clear_cache(district, version)\n\n if len(request.REQUEST.getlist('type[]')) > 0:\n strtags = request.REQUEST.getlist('type[]')\n for strtag in strtags:\n if strtag == '':\n continue\n if strtag.count(' ') > 0:\n strtag = '\"type=%s\"' % strtag\n else:\n strtag = 'type=%s' % strtag\n Tag.objects.add_tag(district, strtag)\n\n status['version'] = version\n status['success'] = True\n\n return HttpResponse(json.dumps(status), mimetype='application/json')", "metadata": "root.district_info", "header": "['module', '___EOS___']", "index": 2483 } ]
[ { "span": "except:", "start_line": 320, "start_column": 8, "end_line": 320, "end_column": 15 }, { "span": "except:", "start_line": 501, "start_column": 4, "end_line": 501, "end_column": 11 }, { "span": "except:", "start_line": 775, "start_column": 8, "end_line": 775, "end_column": 15 }, { "span": "except:", "start_line": 883, "start_column": 4, "end_line": 883, "end_column": 11 }, { "span": "except:", "start_line": 969, "start_column": 4, "end_line": 969, "end_column": 11 }, { "span": "except:", "start_line": 1152, "start_column": 4, "end_line": 1152, "end_column": 11 }, { "span": "except:", "start_line": 1214, "start_column": 4, "end_line": 1214, "end_column": 11 }, { "span": "except:", "start_line": 1281, "start_column": 4, "end_line": 1281, "end_column": 11 }, { "span": "except:", "start_line": 1334, "start_column": 4, "end_line": 1334, "end_column": 11 }, { "span": "except:", "start_line": 1380, "start_column": 4, "end_line": 1380, "end_column": 11 }, { "span": "except:", "start_line": 1393, "start_column": 12, "end_line": 1393, "end_column": 19 }, { "span": "except:", "start_line": 1449, "start_column": 4, "end_line": 1449, "end_column": 11 }, { "span": "except:", "start_line": 1512, "start_column": 8, "end_line": 1512, "end_column": 15 }, { "span": "except:", "start_line": 1821, "start_column": 4, "end_line": 1821, "end_column": 11 }, { "span": "except:", "start_line": 1829, "start_column": 8, "end_line": 1829, "end_column": 15 }, { "span": "except:", "start_line": 1836, "start_column": 4, "end_line": 1836, "end_column": 11 }, { "span": "except:", "start_line": 1843, "start_column": 8, "end_line": 1843, "end_column": 15 }, { "span": "except:", "start_line": 1961, "start_column": 4, "end_line": 1961, "end_column": 11 }, { "span": "except:", "start_line": 2158, "start_column": 4, "end_line": 2158, "end_column": 11 }, { "span": "except:", "start_line": 2299, "start_column": 12, "end_line": 2299, "end_column": 19 }, { "span": "except:", "start_line": 2325, "start_column": 4, "end_line": 2325, "end_column": 11 }, { "span": "except:", "start_line": 2429, "start_column": 12, "end_line": 2429, "end_column": 19 }, { "span": "except:", "start_line": 2505, "start_column": 12, "end_line": 2505, "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_", "@_", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "unique", "\\u", "session", "\\u", "or", "\\u", "json", "\\u", "redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "score", "plan_", "(_", "request_", ",_", "plan", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Validate", " ", "a", " ", "plan", " ", "to", " ", "allow", " ", "for", " ", "it", " ", "to", " ", "be", " ", "shown", " ", "in", " ", "the", " ", "leader", "board", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "request", " ", "--", " ", "The", " ", "Http", "Request", ",", " ", "whi", "ch", " ", "include", "s", " ", "the", " ", "user", ".", "\\", "10", ";", " ", " ", " ", " ", "plan", "id", " ", "--", " ", "The", " ", "plan", " ", "to", " ", "score", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "JSO", "N", " ", "Http", "Respons", "e", " ", "whi", "ch", " ", "include", "s", " ", "a", " ", "status", ",", " ", "and", " ", "if", " ", "applica", "ble", ",", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "reason", " ", "wh", "y", " ", "the", " ", "plan", " ", "coul", "dn", "'", "t", " ", "be", " ", "validat", "ed", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "session", "\\u", "activity_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "=_", "{_", "'", "success", "'_", ":_", "False_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plan_", "=_", "Plan_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "plan", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "criterion_", "=_", "Validat", "ion", "Criteria", "_", "._", "objects_", "._", "filter_", "(_", "legislat", "ive", "\\u", "body_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "success", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "criteria_", "in_", "criterion_", ":_", "\\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 ", " _", "score_", "=_", "Computed", "Plan", "Score_", "._", "compute_", "(_", "criteria_", "._", "function_", ",_", "plan_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "debug_", "(_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "score_", "or_", "not_", "score_", "[_", "'", "value", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "success", "'_", "]_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "message", "'_", "]_", "=_", "'<", "p", ">", "%", "s", "</", "p", "><", "p", ">", "%", "s", "</", "p", ">'_", "%_", "(_", "criteria_", "._", "get", "\\u", "short", "\\u", "label_", "(_", ")_", ",_", "criteria_", "._", "get", "\\u", "long", "\\u", "description_", "(_", ")_", "or_", "criteria_", "._", "function_", "._", "get", "\\u", "long", "\\u", "description_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "status_", "[_", "'", "success", "'_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "success", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "Validat", "ion", " ", "success", "ful", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Set", " ", "is", "\\u", "valid", " ", "status", " ", "on", " ", "the", " ", "plan_", "\\u\\u\\uNL\\u\\u\\u_", "plan_", "._", "is", "\\u", "valid_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plan_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\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_", "common", "plan_", "(_", "request_", ",_", "plan", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "common", " ", "method", " ", "tha", "t", " ", "gets", " ", "the", " ", "same", " ", "data", " ", "structure", "s", " ", "for", " ", "viewin", "g", "\\", "10", ";", " ", " ", " ", " ", "and", " ", "editin", "g", ".", " ", "Thi", "s", " ", "method", " ", "is", " ", "call", "ed", " ", "by", " ", "the", " ", "view", "plan", " ", "and", " ", "edit", "plan", " ", "\\", "10", ";", " ", " ", " ", " ", "views", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "request", " ", "--", " ", "An", " ", "Http", "Request", "\\", "10", ";", " ", " ", " ", " ", "plan", "id", " ", "--", " ", "The", " ", "plan", " ", "ID", " ", "to", " ", "fetch", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "python", " ", "dict", " ", "with", " ", "common", " ", "plan", " ", "attribute", "s", " ", "set", " ", "to", " ", "the", " ", "plan", "'", "s", " ", "values", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "session", "\\u", "activity_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plan_", "=_", "Plan_", "._", "objects_", "._", "filter_", "(_", "id_", "=_", "plan", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "plan_", "._", "count_", "(_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plan_", "=_", "plan_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plan_", "._", "edited", "_", "=_", "getu", "tc_", "(_", "plan_", "._", "edited", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "levels_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", "._", "get", "\\u", "geo", "levels_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "district", "s_", "=_", "plan_", "._", "get", "\\u", "district", "s", "\\u", "at", "\\u", "version_", "(_", "plan_", "._", "version_", ",_", "include", "\\u", "geom_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "editable_", "=_", "can", "\\u", "edit_", "(_", "request_", "._", "user_", ",_", "plan_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "\\u", "demo_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", "._", "get", "\\u", "default", "\\u", "subject_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "\\u", "dists_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", "._", "max", "\\u", "district", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body", "\\u", "member", "\\u", "short", "\\u", "label_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", "._", "get", "\\u", "short", "\\u", "label_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body", "\\u", "member", "\\u", "long", "\\u", "label_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", "._", "get", "\\u", "label_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body", "\\u", "members_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", "._", "get", "\\u", "member", "s", "\\u", "label_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reporting", "\\u", "template_", "=_", "'", "bar", "d\\u", "%", "s", ".", "html", "'_", "%_", "plan_", "._", "legislat", "ive", "\\u", "body_", "._", "name_", "if_", "not_", "plan_", "._", "is", "\\u", "community_", "(_", ")_", "else_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "index_", "=_", "body", "\\u", "member", "\\u", "short", "\\u", "label_", "._", "find_", "(_", "'%", "(", "district", "\\u", "id", ")", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "index_", ">=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body", "\\u", "member", "\\u", "short", "\\u", "label_", "=_", "body", "\\u", "member", "\\u", "short", "\\u", "label_", "[_", "0_", ":_", "index_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "index_", "=_", "body", "\\u", "member", "\\u", "long", "\\u", "label_", "._", "find_", "(_", "'%", "(", "district", "\\u", "id", ")", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "index_", ">=_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body", "\\u", "member", "\\u", "long", "\\u", "label_", "=_", "body", "\\u", "member", "\\u", "long", "\\u", "label_", "[_", "0_", ":_", "index_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "editable_", "and_", "not_", "can", "\\u", "view_", "(_", "request_", "._", "user_", ",_", "plan_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plan_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tags_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "calculator", "\\u", "reports_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "tags_", "=_", "Tag_", "._", "objects_", "._", "filter_", "(_", "name", "\\u\\u", "startswith_", "=_", "'", "type", "='_", ")_", "._", "order", "\\u", "by_", "(_", "'", "id", "'_", ")_", "._", "values", "\\u", "list_", "(_", "'", "name", "'_", ",_", "flat_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tags_", "=_", "map_", "(_", "lambda_", "x_", ":_", "x_", "[_", "5_", ":_", "]_", ",_", "tags_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Report", "s", " ", "defin", "ed", " ", "with", " ", "calculator", "s", " ", "(", "Score", " ", "Display", "s", ",", " ", "Pane", "ls", ",", " ", "and", " ", "Function", "s", ")_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "result", " ", "is", " ", "a", " ", "map", " ", "of", " ", "rele", "van", "t", " ", "panel", "s", " ", "to", " ", "score", " ", "function", "s", " ", "with", " ", "labels", " ", "and", " ", "ids", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "used", " ", "for", " ", "generat", "ing", " ", "group", "s", " ", "of", " ", "checkb", "oxe", "s", " ", "on", " ", "the", " ", "evaluate", " ", "tab", "._", "\\u\\u\\uNL\\u\\u\\u_", "calculator", "\\u", "reports_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "settings_", "._", "REPORT", "S", "\\u", "ENABLED_", "==_", "'", "CAL", "C", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "report", "\\u", "display", "s_", "=_", "Score", "Display_", "._", "objects_", "._", "filter_", "(_", "name_", "=_", "\"%", "s", "\\u", "report", "s", "\"_", "%_", "plan_", "._", "legislat", "ive", "\\u", "body_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "report", "\\u", "display", "s_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "calculator", "\\u", "reports_", "=_", "map_", "(_", "lambda_", "p_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "title", "'_", ":_", "p_", "._", "\\u\\u", "unicode\\u\\u_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "function", "s", "'_", ":_", "map_", "(_", "lambda_", "f_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "label", "'_", ":_", "f_", "._", "get", "\\u", "label_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "f_", "._", "id_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "p_", "._", "score", "\\u", "functions_", "._", "all_", "(_", ")_", "._", "filter_", "(_", "selectable", "\\u", "bodies_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", ")_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "report", "\\u", "display", "s_", "[_", "0_", "]_", "._", "score", "panel", "\\u", "set_", "._", "all_", "(_", ")_", "._", "order", "\\u", "by_", "(_", "'", "position", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "sai", "d", " ", "plan", " ", "doe", "sn", "'", "t", " ", "exist", ",", " ", "use", " ", "an", " ", "empty", " ", "plan", " ", "&", " ", "district", " ", "list", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plan_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "levels_", "=_", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "district", "s_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "editable_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "default", "\\u", "demo_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "max", "\\u", "dists_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body", "\\u", "member", "\\u", "short", "\\u", "label_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body", "\\u", "member", "\\u", "long", "\\u", "label_", "=_", "\\u_", "(_", "'", "Distr", "ict", "'_", ")_", "+_", "'", " ", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body", "\\u", "members_", "=_", "\\u", "n_", "(_", "'", "district", "'_", ",_", "'", "district", "s", "'_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "reporting", "\\u", "template_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tags_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "calculator", "\\u", "reports_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "demo", "s_", "=_", "Subject_", "._", "objects_", "._", "all_", "(_", ")_", "._", "order", "\\u", "by_", "(_", "'", "sort", "\\u", "key", "'_", ")_", "[_", "0_", ":_", "3_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "layers_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "snap", "layers_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "levels_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stud", "y", "\\u", "area", "\\u", "extent_", "=_", "list_", "(_", "levels_", "[_", "0_", "]_", "._", "geo", "unit", "\\u", "set_", "._", "extent_", "(_", "field", "\\u", "name_", "=_", "'", "simple", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "geo", "level", "s", " ", "with", " ", "higher", " ", "indexe", "s", " ", "are", " ", "large", "r", " ", "geogr", "aph", "y_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Cycle", " ", "through", " ", "legislat", "ive", " ", "bodi", "es", ",", " ", "sinc", "e", " ", "the", "y", " ", "may", " ", "be", " ", "in", " ", "different", " ", "regions_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "for_", "lb_", "in_", "Legi", "slat", "ive", "Body_", "._", "objects_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "big", "level_", "=_", "lb_", "._", "get", "\\u", "geo", "levels_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "big", "level_", "._", "geo", "unit", "\\u", "set_", "._", "count_", "(_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "stud", "y", "\\u", "area", "\\u", "extent_", "=_", "big", "level_", "._", "geo", "unit", "\\u", "set_", "._", "extent_", "(_", "field", "\\u", "name_", "=_", "'", "simple", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "level_", "in_", "levels_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "i18n", "-", "ize", " ", "name", " ", "here", ",", " ", "not", " ", "in", " ", "js_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "snap", "layers_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "geo", "level", "'_", ":_", "level_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "level", "'_", ":_", "level_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "layer", "'_", ":_", "'", "simple", "\\u'_", "+_", "level_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "long", "\\u", "description", "'_", ":_", "level_", "._", "get", "\\u", "long", "\\u", "description_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "min", "\\u", "zoom", "'_", ":_", "level_", "._", "min", "\\u", "zoom_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "default", "\\u", "selected_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "demo_", "in_", "demo", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "isd", "efa", "ult_", "=_", "str_", "(_", "(_", "not_", "default", "\\u", "demo_", "is_", "None_", ")_", "and_", "(_", "demo_", "._", "id_", "==_", "default", "\\u", "demo_", "._", "id_", ")_", ")_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "isd", "efa", "ult_", "==_", "'", "true", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "default", "\\u", "selected_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "i18n", "-", "ize", " ", "name", " ", "&", " ", "short", "\\u", "display", " ", "here", ",", " ", "not", " ", "in", " ", "js_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "layers_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "demo_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "demo_", "._", "get", "\\u", "short", "\\u", "label_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "value", "'_", ":_", "demo_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "isd", "efa", "ult", "'_", ":_", "isd", "efa", "ult_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "isdi", "spla", "yed", "'_", ":_", "str_", "(_", "demo_", "._", "is", "\\u", "displayed_", ")_", "._", "lower_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "the", " ", "default", " ", "demo", " ", "was", " ", "not", " ", "selecte", "d", " ", "amo", "ng", " ", "the", " ", "first", " ", "three", ",", " ", "we", "'", "ll", " ", "still", " ", "need", " ", "it", " ", "for", " ", "the", " ", "dropdown", " ", "menus_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "default", "\\u", "demo_", "and_", "not_", "default", "\\u", "selected_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "layers_", "._", "insert_", "(_", "0_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "default", "\\u", "demo_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "text", "'_", ":_", "default", "\\u", "demo_", "._", "get", "\\u", "short", "\\u", "label_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "value", "'_", ":_", "default", "\\u", "demo_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "isd", "efa", "ult", "'_", ":_", "str_", "(_", "True_", ")_", "._", "lower_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "isdi", "spla", "yed", "'_", ":_", "str_", "(_", "default", "\\u", "demo_", "._", "is", "\\u", "displayed_", ")_", "._", "lower_", "(_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Tr", "y", " ", "to", " ", "get", " ", "the", " ", "maps", "erver", " ", "protoc", "ol", " ", "from", " ", "the", " ", "settings", " ", "module", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Set", " ", "it", " ", "to", " ", "an", " ", "empty", " ", "string", " ", "if", " ", "the", " ", "setti", "ng", " ", "isn", "'", "t", " ", "defin", "ed", " ", "so", " ", "the", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "front", "-", "end", " ", "Javascript", " ", "will", " ", "set", " ", "a", " ", "reason", "able", " ", "default", " ", "(", "currentl", "y_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "same", " ", "protoc", "ol", " ", "as", " ", "the", " ", "request", " ", "to", " ", "the", " ", "webse", "rver", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "MAP", "\\u", "SERVER", "\\u", "PROTOCOL", "'_", "in_", "settings_", "._", "\\u\\u", "member", "s\\u\\u_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "maps", "erver", "\\u", "protocol_", "=_", "settings_", "._", "MAP", "\\u", "SERVER", "\\u", "PROTOCOL_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "maps", "erver", "\\u", "protocol_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "short", "\\u", "label_", "=_", "body", "\\u", "member", "\\u", "short", "\\u", "label_", "._", "strip_", "(_", ")_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "long", "\\u", "label_", "=_", "body", "\\u", "member", "\\u", "long", "\\u", "label_", "._", "strip_", "(_", ")_", "._", "lower_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "has", "\\u", "regions_", "=_", "Region_", "._", "objects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ">_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bodies_", "=_", "Legi", "slat", "ive", "Body_", "._", "objects_", "._", "all_", "(_", ")_", "._", "order", "\\u", "by_", "(_", "'", "region", "\\u\\u", "sort", "\\u", "key", "'_", ",_", "'", "sort", "\\u", "key", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "l\\u", "bodies_", "=_", "[_", "b_", "for_", "b_", "in_", "bodies_", "if_", "b_", "in_", "[_", "sd_", "._", "legislat", "ive", "\\u", "body_", "for_", "sd_", "in_", "Score", "Display_", "._", "objects_", "._", "filter_", "(_", "is", "\\u", "page_", "=_", "True_", ")_", "]_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "loader_", "._", "get", "\\u", "template_", "(_", "reporting", "\\u", "template_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "reporting", "\\u", "template_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Request", "Context_", "(_", "request_", ",_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "bodi", "es", "'_", ":_", "bodies_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "has", "\\u", "regions", "'_", ":_", "has", "\\u", "regions_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "leader", "board", "\\u", "bodi", "es", "'_", ":_", "l\\u", "bodies_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "plan", "'_", ":_", "plan_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "district", "s", "'_", ":_", "district", "s_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "maps", "erver", "'_", ":_", "settings_", "._", "MAP", "\\u", "SERVER_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "maps", "erver", "\\u", "protoc", "ol", "'_", ":_", "maps", "erver", "\\u", "protocol_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "basem", "aps", "'_", ":_", "settings_", "._", "BASE", "\\u", "MAP", "S_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "namespace", "'_", ":_", "settings_", "._", "MAP", "\\u", "SERVER", "\\u", "NS_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ns", "\\u", "href", "'_", ":_", "settings_", "._", "MAP", "\\u", "SERVER", "\\u", "NS", "HRE", "F_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "feature", "\\u", "limit", "'_", ":_", "settings_", "._", "FEATURE", "\\u", "LIMIT_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "adjacency", "'_", ":_", "settings_", "._", "ADJ", "ACE", "NCY", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "convex", "chor", "opl", "eth", "'_", ":_", "settings_", "._", "CONVE", "X", "\\u", "CHO", "ROP", "LET", "H_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "demo", "graphic", "s", "'_", ":_", "layers_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "snap", "layer", "s", "'_", ":_", "snap", "layers_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "unassign", "ed", "\\u", "id", "'_", ":_", "UNA", "SSI", "GN", "ED", "\\u", "DISTRI", "CT", "\\u", "ID_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "register", "ed", "'_", ":_", "request_", "._", "user_", "._", "username_", "!=_", "'", "anonym", "ous", "'_", "and_", "request_", "._", "user_", "._", "username_", "!=_", "''_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "debugg", "ing", "\\u", "sta", "ff", "'_", ":_", "settings_", "._", "DEBUG_", "and_", "request_", "._", "user_", "._", "is", "\\u", "staff_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "userin", "fo", "'_", ":_", "get", "\\u", "user", "\\u", "info_", "(_", "request_", "._", "user_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "is", "\\u", "edita", "ble", "'_", ":_", "editable_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "max", "\\u", "dists", "'_", ":_", "max", "\\u", "dists_", "+_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ga", "\\u", "account", "'_", ":_", "settings_", "._", "GA", "\\u", "ACCOUNT", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ga", "\\u", "domain", "'_", ":_", "settings_", "._", "GA", "\\u", "DOMAIN_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "body", "\\u", "member", "\\u", "short", "\\u", "label", "'_", ":_", "short", "\\u", "label_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "body", "\\u", "member", "\\u", "long", "\\u", "label", "'_", ":_", "long", "\\u", "label_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "body", "\\u", "member", "s", "'_", ":_", "body", "\\u", "members_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "reporting", "\\u", "template", "'_", ":_", "reporting", "\\u", "template_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "stud", "y", "\\u", "area", "\\u", "extent", "'_", ":_", "stud", "y", "\\u", "area", "\\u", "extent_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "has", "\\u", "leader", "board", "'_", ":_", "len_", "(_", "Score", "Display_", "._", "objects_", "._", "filter_", "(_", "is", "\\u", "page_", "=_", "True_", ")_", ")_", ">_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "calculator", "\\u", "report", "s", "'_", ":_", "json_", "._", "dumps_", "(_", "calculator", "\\u", "reports_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "allow", "\\u", "email", "\\u", "subm", "ission", "s", "'_", ":_", "(_", "'", "EMA", "IL", "\\u", "SUB", "MISSI", "ON", "'_", "in_", "settings_", "._", "\\u\\u", "member", "s\\u\\u_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "tags", "'_", ":_", "tags_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "site", "'_", ":_", "Site_", "._", "objects_", "._", "get", "\\u", "current_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "plan", "\\u", "text", "'_", ":_", "\\u_", "(_", "\"", "communi", "ty", " ", "map", "\"_", ")_", "if_", "(_", "plan_", "and_", "plan_", "._", "is", "\\u", "community_", "(_", ")_", ")_", "else_", "\\u_", "(_", "\"", "plan", "\"_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "language", "\\u", "code", "'_", ":_", "translation_", "._", "get", "\\u", "language_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "LANGUAGE", "S", "'_", ":_", "settings_", "._", "LANGUAGES_", "#", " ", "need", "ed", " ", "(", "as", " ", "CAPS", ")", " ", "for", " ", "language", " ", "chooser_", "\\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_", "@_", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "unique", "\\u", "session", "\\u", "or", "\\u", "json", "\\u", "redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "create", "plan_", "(_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Creat", "e", " ", "a", " ", "plan", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Creat", "e", " ", "a", " ", "plan", " ", "from", " ", "a", " ", "POST", " ", "request", ".", " ", "Thi", "s", " ", "plan", " ", "will", " ", "be", " ", "'", "blank", "',", " ", "and", " ", "will", "\\", "10", ";", " ", " ", " ", " ", "contain", " ", "only", " ", "the", " ", "Una", "ssi", "gned", " ", "district", " ", "initially", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "request", " ", "--", " ", "An", " ", "Http", "Request", ",", " ", "whi", "ch", " ", "contain", "s", " ", "the", " ", "current", " ", "user", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "JSO", "N", " ", "Http", "Respons", "e", ",", " ", "inclu", "ding", " ", "the", " ", "new", " ", "plan", "'", "s", " ", "informati", "on", ",", " ", "or", " ", "an", "\\", "10", ";", " ", " ", " ", " ", "error", " ", "descri", "bing", " ", "wh", "y", " ", "the", " ", "plan", " ", "coul", "d", " ", "not", " ", "be", " ", "created", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "session", "\\u", "activity_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "status_", "=_", "{_", "'", "success", "'_", ":_", "False_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "\"", "POST", "\"_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "request_", "._", "POST_", "[_", "'", "name", "'_", "]_", "[_", "0_", ":_", "200_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body_", "=_", "Legi", "slat", "ive", "Body_", "._", "objects_", "._", "get_", "(_", "id_", "=_", "int_", "(_", "request_", "._", "POST_", "[_", "'", "legislat", "ive", "Bod", "y", "'_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plan_", "=_", "Plan_", "(_", "name_", "=_", "name_", ",_", "owner_", "=_", "request_", "._", "user_", ",_", "legislat", "ive", "\\u", "body_", "=_", "body_", ",_", "process", "ing", "\\u", "state_", "=_", "Process", "ing", "State_", "._", "READY", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plan_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "=_", "serializers_", "._", "serialize_", "(_", "\"", "json", "\"_", ",_", "[_", "plan_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "=_", "{_", "'", "success", "'_", ":_", "False_", ",_", "'", "message", "'_", ":_", "\\u_", "(_", "\"", "Cou", "ld", "n", "'", "t", " ", "save", " ", "new", " ", "plan", "\"_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "unique", "\\u", "session", "\\u", "or", "\\u", "json", "\\u", "redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "getre", "port_", "(_", "request_", ",_", "plan", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Get", " ", "a", " ", "BAR", "D", " ", "report", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "view", " ", "will", " ", "write", " ", "out", " ", "an", " ", "HTM", "L", "-", "format", "ted", " ", "BAR", "D", " ", "report", " ", "to", " ", "the", " ", "director", "y", "\\", "10", ";", " ", " ", " ", " ", "give", "n", " ", "in", " ", "the", " ", "settings", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "request", " ", "--", " ", "An", " ", "Http", "Request", "\\", "10", ";", " ", " ", " ", " ", "plan", "id", " ", "--", " ", "The", " ", "plan", " ", "to", " ", "be", " ", "reporte", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "HTM", "L", " ", "for", " ", "use", " ", "as", " ", "a", " ", "previe", "w", " ", "in", " ", "the", " ", "web", " ", "applica", "tion", ",", " ", "along", " ", "with", " ", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "web", " ", "address", " ", "of", " ", "the", " ", "BAR", "D", " ", "report", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "session", "\\u", "activity_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "status_", "=_", "{_", "'", "success", "'_", ":_", "False_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plan_", "=_", "Plan_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "plan", "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 ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "No", " ", "plan", " ", "with", " ", "the", " ", "give", "n", " ", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "can", "\\u", "view_", "(_", "request_", "._", "user_", ",_", "plan_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "User", " ", "can", "'", "t", " ", "view", " ", "the", " ", "give", "n", " ", "plan", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "settings_", "._", "REPORT", "S", "\\u", "ENABLED_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Report", "s", " ", "functional", "it", "y", " ", "is", " ", "turn", "ed", " ", "off", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "variab", "les", " ", "from", " ", "the", " ", "request_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "request_", "._", "method_", "!=_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "Information", " ", "for", " ", "report", " ", "was", "n", "'", "t", " ", "sent", " ", "via", " ", "POST", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "stamp_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "'", "stamp", "'_", ",_", "generat", "e\\u", "report", "\\u", "hash_", "(_", "request_", "._", "POST_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rpt", "status_", "=_", "Plan", "Report_", "._", "check", "report_", "(_", "plan", "id_", ",_", "stamp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "rpt", "status_", "==_", "'", "read", "y", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "success", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "Plan", "Report_", "._", "getre", "port_", "(_", "plan", "id_", ",_", "stamp_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "retr", "y", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "'_", ":_", "\\u_", "(_", "'", "Plan", " ", "report", " ", "is", " ", "read", "y", ".'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "stamp", "'_", ":_", "stamp_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "rpt", "status_", "==_", "'", "bus", "y", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "success", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "reverse_", "(_", "getre", "port_", ",_", "args_", "=_", "[_", "plan", "id_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "retr", "y", "'_", ":_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "'_", ":_", "\\u_", "(_", "'", "Report", " ", "is", " ", "buildi", "ng", ".'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "stamp", "'_", ":_", "stamp_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "rpt", "status_", "==_", "'", "free", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "success", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "reverse_", "(_", "getre", "port_", ",_", "args_", "=_", "[_", "plan", "id_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "retr", "y", "'_", ":_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "'_", ":_", "\\u_", "(_", "'", "Report", " ", "generat", "ion", " ", "start", "ed", ".'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "stamp", "'_", ":_", "stamp_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "req_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "pop", "Var", "'_", ":_", "request_", "._", "POST_", "._", "get_", "(_", "'", "pop", "Var", "'_", ",_", "''_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "pop", "Var", "Extra", "'_", ":_", "request_", "._", "POST_", "._", "get_", "(_", "'", "pop", "Var", "Extra", "'_", ",_", "''_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ratio", "Var", "s", "[]'_", ":_", "request_", "._", "POST_", "._", "getlist_", "(_", "'", "ratio", "Var", "s", "[]'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "split", "Var", "s", "'_", ":_", "request_", "._", "POST_", "._", "get_", "(_", "'", "split", "Var", "s", "'_", ",_", "''_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "block", "Label", "Var", "'_", ":_", "request_", "._", "POST_", "._", "get_", "(_", "'", "block", "Label", "Var", "'_", ",_", "'", "CT", "ID", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rep", "Comp", "'_", ":_", "request_", "._", "POST_", "._", "get_", "(_", "'", "rep", "Compact", "ness", "'_", ",_", "''_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rep", "Comp", "Extra", "'_", ":_", "request_", "._", "POST_", "._", "get_", "(_", "'", "rep", "Compact", "ness", "Extra", "'_", ",_", "''_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rep", "Spa", "tial", "'_", ":_", "request_", "._", "POST_", "._", "get_", "(_", "'", "rep", "Spa", "tial", "'_", ",_", "''_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rep", "Spa", "tial", "Extra", "'_", ":_", "request_", "._", "POST_", "._", "get_", "(_", "'", "rep", "Spa", "tial", "Extra", "'_", ",_", "''_", ")_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Plan", "Report_", "._", "mark", "pending_", "(_", "plan", "id_", ",_", "stamp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Plan", "Report_", "._", "create", "report_", "._", "delay_", "(_", "plan", "id_", ",_", "stamp_", ",_", "req_", ",_", "language_", "=_", "translation_", "._", "get", "\\u", "language_", "(_", ")_", ")_", "\\u\\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_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Unre", "cogni", "zed", " ", "status", " ", "whe", "n", " ", "checking", " ", "report", " ", "status", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "unique", "\\u", "session", "\\u", "or", "\\u", "json", "\\u", "redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "getc", "alc", "ulator", "report_", "(_", "request_", ",_", "plan", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Get", " ", "a", " ", "report", " ", "whi", "ch", " ", "is", " ", "generat", "ed", " ", "by", " ", "usi", "ng", " ", "calculator", "s", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "view", " ", "will", " ", "write", " ", "out", " ", "an", " ", "HTM", "L", "-", "format", "ted", " ", "report", " ", "to", " ", "the", " ", "director", "y", "\\", "10", ";", " ", " ", " ", " ", "give", "n", " ", "in", " ", "the", " ", "settings", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "request", " ", "--", " ", "An", " ", "Http", "Request", "\\", "10", ";", " ", " ", " ", " ", "plan", "id", " ", "--", " ", "The", " ", "plan", " ", "to", " ", "be", " ", "reporte", "d", ".", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "HTM", "L", " ", "for", " ", "use", " ", "as", " ", "a", " ", "previe", "w", " ", "in", " ", "the", " ", "web", " ", "applica", "tion", ",", " ", "along", " ", "with", " ", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "web", " ", "address", " ", "of", " ", "the", " ", "report", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "session", "\\u", "activity_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "status_", "=_", "{_", "'", "success", "'_", ":_", "False_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plan_", "=_", "Plan_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "plan", "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 ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "No", " ", "plan", " ", "with", " ", "the", " ", "give", "n", " ", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "can", "\\u", "view_", "(_", "request_", "._", "user_", ",_", "plan_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "User", " ", "can", "'", "t", " ", "view", " ", "the", " ", "give", "n", " ", "plan", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\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 ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "Information", " ", "for", " ", "report", " ", "was", "n", "'", "t", " ", "sent", " ", "via", " ", "POST", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "extract", " ", "the", " ", "function", " ", "ids", " ", "from", " ", "the", " ", "POST_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "function", "\\u", "ids_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "'", "function", "Id", "s", "'_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "generat", "e", " ", "a", " ", "hash", " ", "of", " ", "the", " ", "function", " ", "ids_", "\\u\\u\\uNL\\u\\u\\u_", "sha_", "=_", "hashlib_", "._", "sha1_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "sha_", "._", "update_", "(_", "function", "\\u", "ids_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "stamp_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "'", "stamp", "'_", ",_", "sha_", "._", "hexdigest_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "rpt", "status_", "=_", "Calculat", "or", "Report_", "._", "check", "report_", "(_", "plan", "id_", ",_", "stamp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "rpt", "status_", "==_", "'", "read", "y", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "success", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "Calculat", "or", "Report_", "._", "getre", "port_", "(_", "plan", "id_", ",_", "stamp_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "retr", "y", "'_", ":_", "0_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "'_", ":_", "\\u_", "(_", "'", "Plan", " ", "report", " ", "is", " ", "read", "y", ".'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "stamp", "'_", ":_", "stamp_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "rpt", "status_", "==_", "'", "bus", "y", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "success", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "reverse_", "(_", "getc", "alc", "ulator", "report_", ",_", "args_", "=_", "[_", "plan", "id_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "retr", "y", "'_", ":_", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "'_", ":_", "\\u_", "(_", "'", "Report", " ", "is", " ", "buildi", "ng", ".'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "stamp", "'_", ":_", "stamp_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "rpt", "status_", "==_", "'", "free", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "success", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "reverse_", "(_", "getc", "alc", "ulator", "report_", ",_", "args_", "=_", "[_", "plan", "id_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "retr", "y", "'_", ":_", "5_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "message", "'_", ":_", "\\u_", "(_", "'", "Report", " ", "generat", "ion", " ", "start", "ed", ".'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "stamp", "'_", ":_", "stamp_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "req_", "=_", "{_", "'", "function", "Id", "s", "'_", ":_", "function", "\\u", "ids_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Calculat", "or", "Report_", "._", "mark", "pending_", "(_", "plan", "id_", ",_", "stamp_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Calculat", "or", "Report_", "._", "create", "calculator", "report_", "._", "delay_", "(_", "plan", "id_", ",_", "stamp_", ",_", "req_", ",_", "language_", "=_", "translation_", "._", "get", "\\u", "language_", "(_", ")_", ")_", "\\u\\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_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Unre", "cogni", "zed", " ", "status", " ", "whe", "n", " ", "checking", " ", "report", " ", "status", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "unique", "\\u", "session", "\\u", "or", "\\u", "json", "\\u", "redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "transaction_", "._", "commit", "\\u", "manu", "ally", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "add", "\\u", "district", "s", "\\u", "to", "\\u", "plan_", "(_", "request_", ",_", "plan", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "handler", " ", "is", " ", "used", " ", "to", " ", "paste", " ", "exist", "ing", " ", "district", "s", " ", "from", " ", "one", "\\", "10", ";", " ", " ", " ", " ", "plan", " ", "int", "o", " ", "anot", "her", " ", "plan", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "request", " ", "--", " ", "An", " ", "Http", "Request", " ", "object", " ", "inclu", "ding", " ", "a", " ", "list", " ", "of", " ", "district", "ids", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "version", "\\", "10", ";", " ", " ", " ", " ", "plan", "id", " ", "--", " ", "The", " ", "plan", " ", "int", "o", " ", "whi", "ch", " ", "to", " ", "paste", " ", "the", " ", "district", "s", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "Some", " ", "JSO", "N", " ", "explain", "ing", " ", "the", " ", "success", " ", "or", " ", "fail", "ure", " ", "of", " ", "the", " ", "paste", " ", "operati", "on", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "status_", "=_", "{_", "'", "success", "'_", ":_", "False_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "we", " ", "can", " ", "edit", " ", "the", " ", "give", "n", " ", "plan_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plan_", "=_", "Plan_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "plan", "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 ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "No", " ", "plan", " ", "with", " ", "the", " ", "give", "n", " ", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "can", "\\u", "edit_", "(_", "request_", "._", "user_", ",_", "plan_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "User", " ", "can", "'", "t", " ", "edit", " ", "the", " ", "give", "n", " ", "plan", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "district", "s", " ", "we", " ", "want", " ", "to", " ", "merge_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "district", "\\u", "list_", "=_", "request_", "._", "POST_", "._", "getlist_", "(_", "'", "district", "s", "[]'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "district", "\\u", "list_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "No", " ", "district", "s", " ", "selecte", "d", " ", "to", " ", "add", " ", "to", " ", "the", " ", "give", "n", " ", "plan", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "district", "s_", "=_", "Distr", "ict_", "._", "objects_", "._", "filter_", "(_", "id", "\\u\\u", "in_", "=_", "district", "\\u", "list_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version_", "=_", "int_", "(_", "request_", "._", "POST_", "._", "get_", "(_", "'", "version", "'_", ",_", "None_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Go", "ing", " ", "to", " ", "merge", " ", "%", "(", "number", "\\u", "of", "\\u", "merge", "d\\u", "district", "s", ")", "d", "'_", "'", " ", "district", "s", "'_", ")_", "%_", "{_", "'", "number", "\\u", "of", "\\u", "merge", "d\\u", "district", "s", "'_", ":_", "len_", "(_", "district", "s_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Check", " ", "to", " ", "see", " ", "if", " ", "we", " ", "have", " ", "eno", "ugh", " ", "room", " ", "to", " ", "add", " ", "these", " ", "district", "s", " ", "with", "out_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "goi", "ng", " ", "over", " ", "MAX", "\\u", "DISTRI", "CT", "S", " ", "for", " ", "the", " ", "legislat", "ive", "\\u", "body_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "allow", "ed", "\\u", "district", "s_", "=_", "plan_", "._", "get", "\\u", "avail", "able", "\\u", "district", "s_", "(_", "version_", "=_", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "district", "s_", ")_", ">_", "allow", "ed", "\\u", "district", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Trie", "d", " ", "to", " ", "merge", " ", "too", " ", "many", " ", "district", "s", ";", " ", "'_", "'%", "(", "allow", "ed", "\\u", "district", "s", ")", "d", " ", "slot", "s", " ", "left", "'_", ")_", "%_", "{_", "'", "allow", "ed", "\\u", "district", "s", "'_", ":_", "allow", "ed", "\\u", "district", "s_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Every", "thing", " ", "checks", " ", "out", ",", " ", "let", "'", "s", " ", "paste", " ", "tho", "se", " ", "district", "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 ", " _", "results_", "=_", "plan_", "._", "paste", "\\u", "district", "s_", "(_", "district", "s_", ",_", "version_", "=_", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "transaction_", "._", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "success", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Merged", " ", "%", "(", "num", "\\u", "merge", "d\\u", "district", "s", ")", "d", " ", "district", "s", "'_", ")_", "%_", "{_", "'", "num", "\\u", "merge", "d\\u", "district", "s", "'_", ":_", "len_", "(_", "results_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "version", "'_", "]_", "=_", "plan_", "._", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", "as_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "transaction_", "._", "rollback_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "message", "'_", "]_", "=_", "str_", "(_", "ex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "exception", "'_", "]_", "=_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "unique", "\\u", "session", "\\u", "or", "\\u", "json", "\\u", "redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "transaction_", "._", "commit", "\\u", "manu", "ally", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "assign", "\\u", "district", "\\u", "members_", "(_", "request_", ",_", "plan", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "handler", " ", "is", " ", "used", " ", "to", " ", "assign", " ", "member", "s", " ", "to", " ", "district", "s", "\\", "10", ";", " ", " ", " ", " ", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "request", " ", "--", " ", "An", " ", "Http", "Request", " ", "object", " ", "inclu", "ding", " ", "a", " ", "version", ",", "\\", "10", ";", " ", "and", " ", "a", " ", "mapping", " ", "of", " ", "district", "ids", " ", "to", " ", "num", "\\u", "member", "s", "\\", "10", ";", " ", " ", " ", " ", "plan", "id", " ", "--", " ", "The", " ", "plan", " ", "int", "o", " ", "whi", "ch", " ", "to", " ", "assign", " ", "district", " ", "member", "s", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "Some", " ", "JSO", "N", " ", "explain", "ing", " ", "the", " ", "success", " ", "or", " ", "fail", "ure", " ", "of", " ", "the", " ", "paste", " ", "operati", "on", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "status_", "=_", "{_", "'", "success", "'_", ":_", "False_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "we", " ", "can", " ", "edit", " ", "the", " ", "give", "n", " ", "plan_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plan_", "=_", "Plan_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "plan", "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 ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "No", " ", "plan", " ", "with", " ", "the", " ", "give", "n", " ", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "can", "\\u", "edit_", "(_", "request_", "._", "user_", ",_", "plan_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "User", " ", "can", "'", "t", " ", "edit", " ", "the", " ", "give", "n", " ", "plan", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "this", " ", "district", " ", "allow", "s", " ", "multi", "-", "member", " ", "assignment_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "leg", "\\u", "bo", "d_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "(_", "not_", "leg", "\\u", "bo", "d_", "._", "multi", "\\u", "member", "s", "\\u", "allowed_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Multi", "-", "member", "s", " ", "not", " ", "allow", "ed", " ", "for", " ", "this", " ", "legislat", "ive", " ", "body", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "district", "s", " ", "we", " ", "want", " ", "to", " ", "assign", " ", "member", "s", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "district", "s_", "=_", "request_", "._", "POST_", "._", "getlist_", "(_", "'", "district", "s", "[]'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "counts_", "=_", "request_", "._", "POST_", "._", "getlist_", "(_", "'", "count", "s", "[]'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version_", "=_", "int_", "(_", "request_", "._", "POST_", "._", "get_", "(_", "'", "version", "'_", ",_", "None_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Assign", " ", "the", " ", "district", " ", "member", "s", " ", "and", " ", "return", " ", "status_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "changed_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "0_", ",_", "len_", "(_", "district", "s_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "id_", "=_", "int_", "(_", "district", "s_", "[_", "i_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "count_", "=_", "int_", "(_", "counts_", "[_", "i_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "district_", "=_", "Distr", "ict_", "._", "objects_", "._", "filter_", "(_", "plan_", "=_", "plan_", ",_", "district", "\\u", "id_", "=_", "id_", ",_", "version", "\\u\\u", "lte_", "=_", "version_", ")_", "._", "order", "\\u", "by_", "(_", "'", "version", "'_", ")_", "._", "reverse_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "district_", "._", "num", "\\u", "members_", "!=_", "count_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "(_", "changed_", "==_", "0_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "there", " ", "is", " ", "at", " ", "leas", "t", " ", "one", " ", "change", ",", " ", "update", " ", "the", " ", "plan_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "version_", "!=_", "plan_", "._", "version_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "plan_", "._", "purge_", "(_", "after_", "=_", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "plan_", "._", "version_", "=_", "plan_", "._", "version_", "+_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plan_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "plan_", "._", "update", "\\u", "num", "\\u", "members_", "(_", "district_", ",_", "count_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "changed_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "transaction_", "._", "commit_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "success", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "version", "'_", "]_", "=_", "plan_", "._", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "modifi", "ed", "'_", "]_", "=_", "changed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Modifie", "d", " ", "member", "s", " ", "for", " ", "%", "(", "num", "\\u", "district", "s", ")", "d", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "district", "s", "'_", ")_", "%_", "{_", "'", "num", "\\u", "district", "s", "'_", ":_", "changed_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "transaction_", "._", "rollback_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "message", "'_", "]_", "=_", "str_", "(_", "ex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "exception", "'_", "]_", "=_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "warn_", "(_", "'", "Cou", "ld", " ", "not", " ", "assign", " ", "district", " ", "member", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "debug_", "(_", "'", "Rea", "son", ":", " ", "%", "s", "'_", ",_", "ex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "unique", "\\u", "session", "\\u", "or", "\\u", "json", "\\u", "redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "combin", "e\\u", "district", "s_", "(_", "request_", ",_", "plan", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Tak", "e", " ", "the", " ", "content", "s", " ", "of", " ", "one", " ", "district", " ", "and", " ", "add", " ", "them", " ", "to", " ", "anot", "her", " ", "district", "s", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "status_", "=_", "{_", "'", "success", "'_", ":_", "False_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "we", " ", "can", " ", "edit", " ", "the", " ", "give", "n", " ", "plan_", "\\u\\u\\uNL\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plan_", "=_", "Plan_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "plan", "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 ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "No", " ", "plan", " ", "with", " ", "the", " ", "give", "n", " ", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "can", "\\u", "edit_", "(_", "request_", "._", "user_", ",_", "plan_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "User", " ", "can", "'", "t", " ", "edit", " ", "the", " ", "give", "n", " ", "plan", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "district", "s", " ", "we", " ", "want", " ", "to", " ", "merge_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "version_", "=_", "int_", "(_", "request_", "._", "POST_", "._", "get_", "(_", "'", "version", "'_", ",_", "plan_", "._", "version_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from", "\\u", "id_", "=_", "int_", "(_", "request_", "._", "POST_", "._", "get_", "(_", "'", "from", "\\u", "district", "\\u", "id", "'_", ",_", "-_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "to", "\\u", "id_", "=_", "int_", "(_", "request_", "._", "POST_", "._", "get_", "(_", "'", "to", "\\u", "district", "\\u", "id", "'_", ",_", "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 ", " _", "all", "\\u", "district", "s_", "=_", "plan_", "._", "get", "\\u", "district", "s", "\\u", "at", "\\u", "version_", "(_", "version_", ",_", "include", "\\u", "geom_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from", "\\u", "district", "s_", "=_", "filter_", "(_", "lambda_", "d_", ":_", "True_", "if_", "d_", "._", "district", "\\u", "id_", "==_", "from", "\\u", "id_", "else_", "False_", ",_", "all", "\\u", "district", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "to", "\\u", "district_", "=_", "filter_", "(_", "lambda_", "d_", ":_", "True_", "if_", "d_", "._", "district", "\\u", "id_", "==_", "to", "\\u", "id_", "else_", "False_", ",_", "all", "\\u", "district", "s_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "locked_", "=_", "to", "\\u", "district_", "._", "is", "\\u", "locked_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "district_", "in_", "from", "\\u", "district", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "district_", "._", "is", "\\u", "locked_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "locked_", "=_", "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_", "locked_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "Can", "'", "t", " ", "combin", "e", " ", "lock", "ed", " ", "district", "s", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "=_", "plan_", "._", "combin", "e\\u", "district", "s_", "(_", "to", "\\u", "district_", ",_", "from", "\\u", "district", "s_", ",_", "version_", "=_", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "result_", "[_", "0_", "]_", "==_", "True_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "success", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Success", "full", "y", " ", "combin", "ed", " ", "district", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "version", "'_", "]_", "=_", "result_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Cou", "ld", " ", "not", " ", "combin", "e", " ", "district", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "exception", "'_", "]_", "=_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "warn_", "(_", "'", "Cou", "ld", " ", "not", " ", "combin", "e", " ", "district", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "debug_", "(_", "'", "Rea", "son", ":", " ", "%", "s", "'_", ",_", "ex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "unique", "\\u", "session", "\\u", "or", "\\u", "json", "\\u", "redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "fix", "\\u", "unassign", "ed_", "(_", "request_", ",_", "plan", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Assign", " ", "unassign", "ed", " ", "base", " ", "geo", "unit", "s", " ", "tha", "t", " ", "are", " ", "full", "y", " ", "contain", "ed", "\\", "10", ";", " ", " ", " ", " ", "or", " ", "adjacent", " ", "to", " ", "anot", "her", " ", "district", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "status_", "=_", "{_", "'", "success", "'_", ":_", "False_", "}_", "\\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 ", " _", "plan_", "=_", "Plan_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "plan", "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 ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "No", " ", "plan", " ", "with", " ", "the", " ", "give", "n", " ", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "can", "\\u", "edit_", "(_", "request_", "._", "user_", ",_", "plan_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "User", " ", "can", "'", "t", " ", "edit", " ", "the", " ", "give", "n", " ", "plan", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\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 ", " _", "version_", "=_", "int_", "(_", "request_", "._", "POST_", "._", "get_", "(_", "'", "version", "'_", ",_", "plan_", "._", "version_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "plan_", "._", "fix", "\\u", "unassign", "ed_", "(_", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "success", "'_", "]_", "=_", "result_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "message", "'_", "]_", "=_", "result_", "[_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "version", "'_", "]_", "=_", "plan_", "._", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Cou", "ld", " ", "not", " ", "fix", " ", "unassign", "ed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "exception", "'_", "]_", "=_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "warn_", "(_", "'", "Cou", "ld", " ", "not", " ", "fix", " ", "unassign", "ed", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "debug_", "(_", "'", "Rea", "son", ":", " ", "%", "s", "'_", ",_", "ex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "unique", "\\u", "session", "\\u", "or", "\\u", "json", "\\u", "redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "splits_", "(_", "request_", ",_", "plan", "id_", ",_", "other", "id_", ",_", "other", "type_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Fin", "d", " ", "all", " ", "split", "s", " ", "bet", "ween", " ", "this", " ", "plan", " ", "and", " ", "anot", "her", " ", "plan", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "request", " ", "--", " ", "An", " ", "Http", "Request", " ", "option", "ally", " ", "contain", "ing", " ", "version", " ", "and", "/", "or", " ", "other", "version", "\\", "10", ";", " ", " ", " ", " ", "plan", "id", " ", "--", " ", "The", " ", "plan", " ", "ID", "\\", "10", ";", " ", " ", " ", " ", "other", "id", " ", "--", " ", "The", " ", "plan", " ", "ID", " ", "or", " ", "geo", "level", " ", "ID", " ", "to", " ", "find", " ", "split", "s", " ", "with", "\\", "10", ";", " ", " ", " ", " ", "other", "type", " ", "--", " ", "One", " ", "of", ":", " ", "'", "plan", "'", " ", "or", " ", "'", "geo", "level", "'.", " ", "For", " ", "speci", "fy", "ing", " ", "other", "id", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "JSO", "N", " ", "Http", "Respons", "e", " ", "tha", "t", " ", "contain", "s", " ", "an", " ", "array", " ", "of", " ", "split", "s", ",", " ", "give", "n", " ", "as", " ", "arrays", ",", "\\", "10", ";", " ", " ", " ", " ", "where", " ", "the", " ", "first", " ", "item", " ", "is", " ", "the", " ", "district", "\\u", "id", " ", "of", " ", "the", " ", "district", " ", "in", " ", "this", " ", "plan", "\\", "10", ";", " ", " ", " ", " ", "whi", "ch", " ", "caus", "es", " ", "the", " ", "split", ",", " ", "and", " ", "the", " ", "second", " ", "item", " ", "is", " ", "the", " ", "district", "\\u", "id", " ", "of", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "district", " ", "in", " ", "the", " ", "other", " ", "plan", " ", "or", " ", "geo", "level", ".", " ", "Whe", "n", " ", "a", " ", "geo", "level", " ", "is", " ", "specified", ",", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "portab", "le", "\\u", "id", " ", "will", " ", "be", " ", "used", ",", " ", "rat", "her", " ", "than", " ", "the", " ", "district", "\\u", "id", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "other", "id_", "=_", "int_", "(_", "other", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "=_", "{_", "'", "success", "'_", ":_", "False_", "}_", "\\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 ", " _", "plan_", "=_", "Plan_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "plan", "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 ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "No", " ", "plan", " ", "with", " ", "the", " ", "give", "n", " ", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "can", "\\u", "view_", "(_", "request_", "._", "user_", ",_", "plan_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "User", " ", "can", "'", "t", " ", "view", " ", "the", " ", "give", "n", " ", "plan", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "version_", "=_", "int_", "(_", "request_", "._", "REQUEST_", "[_", "'", "version", "'_", "]_", "if_", "'", "version", "'_", "in_", "request_", "._", "REQUEST_", "else_", "plan_", "._", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "other", "type_", "==_", "'", "plan", "'_", ":_", "\\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 ", " _", "other", "plan_", "=_", "Plan_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "other", "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 ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "No", " ", "other", " ", "plan", " ", "with", " ", "the", " ", "give", "n", " ", "id", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "can", "\\u", "view_", "(_", "request_", "._", "user_", ",_", "other", "plan_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "User", " ", "can", "'", "t", " ", "view", " ", "the", " ", "give", "n", " ", "plan", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "other", "version_", "=_", "int_", "(_", "request_", "._", "REQUEST_", "[_", "'", "other", "version", "'_", "]_", "if_", "'", "other", "version", "'_", "in_", "request_", "._", "REQUEST_", "else_", "other", "plan_", "._", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "splits_", "=_", "plan_", "._", "find", "\\u", "plan", "\\u", "splits_", "(_", "other", "plan_", ",_", "version_", ",_", "other", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "other", "type_", "==_", "'", "geo", "level", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "splits_", "=_", "plan_", "._", "find", "\\u", "geo", "level", "\\u", "splits_", "(_", "other", "id_", ",_", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "other", "type", " ", "not", " ", "support", "ed", ":", " ", "%", "(", "other", ")", "s", "'_", ")_", "%_", "{_", "'", "other", "'_", ":_", "other", "type_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "split", "\\u", "word_", "=_", "\\u_", "(_", "'", "split", "'_", ")_", "if_", "len_", "(_", "splits_", ")_", "==_", "1_", "else_", "infl", "ect_", "._", "engine_", "(_", ")_", "._", "plural_", "(_", "\\u_", "(_", "'", "split", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "status_", "[_", "'", "success", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Foun", "d", " ", "%", "(", "num", "\\u", "split", "s", ")", "d", " ", "%", "(", "split", "\\u", "word", ")", "s", "'_", ")_", "%_", "{_", "'", "num", "\\u", "split", "s", "'_", ":_", "len_", "(_", "splits_", ")_", ",_", "'", "split", "\\u", "word", "'_", ":_", "split", "\\u", "word_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "split", "s", "'_", "]_", "=_", "splits_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "above", "\\u", "ids", "'_", "]_", "=_", "list_", "(_", "set_", "(_", "[_", "i_", "[_", "0_", "]_", "for_", "i_", "in_", "splits_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "belo", "w", "\\u", "ids", "'_", "]_", "=_", "list_", "(_", "set_", "(_", "[_", "i_", "[_", "1_", "]_", "for_", "i_", "in_", "splits_", "]_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Cou", "ld", " ", "not", " ", "query", " ", "for", " ", "split", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "exception", "'_", "]_", "=_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "warn_", "(_", "'", "Cou", "ld", " ", "not", " ", "query", " ", "for", " ", "split", "s", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "debug_", "(_", "'", "Rea", "son", ":", " ", "%", "s", "'_", ",_", "ex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\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", "split", "s", "\\u", "report_", "(_", "request_", ",_", "plan", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Get", " ", "the", " ", "render", "ed", " ", "split", "s", " ", "report", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "session", "\\u", "activity_", "(_", "request_", ")_", "\\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 ", " _", "plan_", "=_", "Plan_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "plan", "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_", "Http", "Response_", "(_", "\\u_", "(_", "'", "Plan", " ", "doe", "s", " ", "not", " ", "exist", ".'_", ")_", ",_", "mimetype_", "=_", "'", "text", "/", "plain", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "usi", "ng", "\\u", "unique", "\\u", "session_", "(_", "request_", "._", "user_", ")_", "or_", "not_", "can", "\\u", "view_", "(_", "request_", "._", "user_", ",_", "plan_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Forbidden_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "version_", "=_", "int_", "(_", "request_", "._", "REQUEST_", "[_", "'", "version", "'_", "]_", "if_", "'", "version", "'_", "in_", "request_", "._", "REQUEST_", "else_", "plan_", "._", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inverse_", "=_", "request_", "._", "REQUEST_", "[_", "'", "inv", "erse", "'_", "]_", "==_", "'", "true", "'_", "if_", "'", "inv", "erse", "'_", "in_", "request_", "._", "REQUEST_", "else_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "extended_", "=_", "request_", "._", "REQUEST_", "[_", "'", "extend", "ed", "'_", "]_", "==_", "'", "true", "'_", "if_", "'", "extend", "ed", "'_", "in_", "request_", "._", "REQUEST_", "else_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "layers_", "=_", "request_", "._", "REQUEST_", "._", "getlist_", "(_", "'", "layer", "s", "[]'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "layers_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Response_", "(_", "\\u_", "(_", "'", "No", " ", "layer", "s", " ", "wer", "e", " ", "provided", ".'_", ")_", ",_", "mimetype_", "=_", "'", "text", "/", "plain", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "report_", "=_", "loader_", "._", "get", "\\u", "template_", "(_", "'", "split", "\\u", "report", ".", "html", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "html_", "=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "layer_", "in_", "layers_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "my", "\\u", "context_", "=_", "{_", "'", "extend", "ed", "'_", ":_", "extended_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "my", "\\u", "context_", "._", "update_", "(_", "plan_", "._", "compute", "\\u", "splits_", "(_", "layer_", ",_", "version_", "=_", "version_", ",_", "inverse_", "=_", "inverse_", ",_", "extended_", "=_", "extended_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "last", "\\u", "item_", "=_", "layer_", "is_", "layers_", "[_", "-_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "communi", "ty", "\\u", "info_", "=_", "plan_", "._", "get", "\\u", "communi", "ty", "\\u", "type", "\\u", "info_", "(_", "layer_", ",_", "version_", "=_", "version_", ",_", "inverse_", "=_", "inverse_", ",_", "include", "\\u", "counts_", "=_", "last", "\\u", "item_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "communi", "ty", "\\u", "info_", "is_", "not_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "my", "\\u", "context_", "._", "update_", "(_", "communi", "ty", "\\u", "info_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "calc", "\\u", "context_", "=_", "Dj", "ang", "o", "Context_", "(_", "my", "\\u", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "html_", "+=_", "report_", "._", "render_", "(_", "calc", "\\u", "context_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "last", "\\u", "item_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "html_", "+=_", "'<", "hr", " ", "/>'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Response_", "(_", "html_", ",_", "mimetype_", "=_", "'", "text", "/", "html", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warn_", "(_", "'", "Cou", "ld", " ", "not", " ", "produce", " ", "split", " ", "report", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "debug_", "(_", "'", "Rea", "son", ":", " ", "%", "s", "'_", ",_", "ex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "str_", "(_", "ex_", ")_", ",_", "mimetype_", "=_", "'", "text", "/", "plain", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "login", "\\u", "required_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "@_", "unique", "\\u", "session", "\\u", "or", "\\u", "json", "\\u", "redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "addt", "odi", "strict_", "(_", "request_", ",_", "plan", "id_", ",_", "district", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Add", " ", "geo", "unit", "s", " ", "to", " ", "a", " ", "district", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Thi", "s", " ", "method", " ", "require", "s", " ", "bot", "h", " ", "\"", "geo", "level", "\"", " ", "and", " ", "\"", "geo", "unit", "s", "\"", " ", "URL", " ", "parameter", "s", ".", " ", "\\", "10", ";", " ", " ", " ", " ", "The", " ", "geo", "level", " ", "must", " ", "be", " ", "a", " ", "valid", " ", "geo", "level", " ", "name", " ", "and", " ", "the", " ", "geo", "unit", "s", " ", "parameter", "s", " ", "\\", "10", ";", " ", " ", " ", " ", "shou", "ld", " ", "be", " ", "a", " ", "pipe", "-", "separate", "d", " ", "list", " ", "of", " ", "geo", "unit", " ", "ids", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "request", " ", "--", " ", "An", " ", "Http", "Request", ",", " ", "with", " ", "the", " ", "current", " ", "user", ",", " ", "the", " ", "geo", "level", ",", " ", "and", "\\", "10", ";", " ", " ", " ", " ", "the", " ", "pipe", "-", "separate", "d", " ", "geo", "unit", " ", "list", ".", "\\", "10", ";", " ", " ", " ", " ", "plan", "id", " ", "--", " ", "The", " ", "plan", " ", "ID", " ", "tha", "t", " ", "contain", "s", " ", "the", " ", "district", ".", "\\", "10", ";", " ", " ", " ", " ", "district", "id", " ", "--", " ", "The", " ", "district", " ", "ID", " ", "to", " ", "whi", "ch", " ", "the", " ", "geo", "unit", "s", " ", "will", " ", "be", " ", "adde", "d", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "A", " ", "JSO", "N", " ", "Http", "Respons", "e", " ", "tha", "t", " ", "contain", "s", " ", "the", " ", "number", " ", "of", " ", "district", "s", " ", "modifi", "ed", ",", "\\", "10", ";", " ", " ", " ", " ", "or", " ", "an", " ", "error", " ", "message", " ", "if", " ", "addin", "g", " ", "fail", "s", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "session", "\\u", "activity_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "status_", "=_", "{_", "'", "success", "'_", ":_", "False_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "request_", "._", "REQUEST_", "._", "items_", "(_", ")_", ")_", ">=_", "2_", ":_", "\\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 ", " _", "geo", "level_", "=_", "request_", "._", "REQUEST_", "[_", "\"", "geo", "level", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "geo", "unit", "\\u", "ids_", "=_", "string_", "._", "split_", "(_", "request_", "._", "REQUEST_", "[_", "\"", "geo", "unit", "s", "\"_", "]_", ",_", "\"|\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plan_", "=_", "Plan_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "plan", "id_", ",_", "owner_", "=_", "request_", "._", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "exception", "'_", "]_", "=_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Cou", "ld", " ", "not", " ", "add", " ", "unit", "s", " ", "to", " ", "district", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "the", " ", "version", " ", "from", " ", "the", " ", "request", " ", "or", " ", "the", " ", "plan_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "version", "'_", "in_", "request_", "._", "REQUEST_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "version_", "=_", "request_", "._", "REQUEST_", "[_", "'", "version", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "version_", "=_", "plan_", "._", "version_", "\\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 ", " _", "fixed_", "=_", "plan_", "._", "add", "\\u", "geo", "units_", "(_", "district", "id_", ",_", "geo", "unit", "\\u", "ids_", ",_", "geo", "level_", ",_", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "success", "'_", "]_", "=_", "True_", ";_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Update", "d", " ", "%", "(", "num", "\\u", "fixed", "\\u", "district", "s", ")", "d", " ", "district", "s", "'_", ")_", "%_", "{_", "'", "num", "\\u", "fixed", "\\u", "district", "s", "'_", ":_", "fixed_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "update", "d", "'_", "]_", "=_", "fixed_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plan_", "=_", "Plan_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "plan", "id_", ",_", "owner_", "=_", "request_", "._", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "edited", "'_", "]_", "=_", "getu", "tc_", "(_", "plan_", "._", "edited", "_", ")_", "._", "isoformat_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "version", "'_", "]_", "=_", "plan_", "._", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "exception", "'_", "]_", "=_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Cou", "ld", " ", "not", " ", "add", " ", "unit", "s", " ", "to", " ", "district", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "warn_", "(_", "'", "Cou", "ld", " ", "not", " ", "add", " ", "unit", "s", " ", "to", " ", "district", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "debug_", "(_", "'", "Rea", "son", ":", " ", "%", "s", "'_", ",_", "ex_", ")_", "\\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 ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "Geo", "unit", "s", " ", "wer", "en", "'", "t", " ", "found", " ", "in", " ", "a", " ", "district", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "unique", "\\u", "session", "\\u", "or", "\\u", "json", "\\u", "redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "get", "\\u", "statistics_", "(_", "request_", ",_", "plan", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "note", "\\u", "session", "\\u", "activity_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "status_", "=_", "{_", "'", "success", "'_", ":_", "False_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plan_", "=_", "Plan_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "plan", "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 ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "Cou", "ld", "n", "'", "t", " ", "get", " ", "geogr", "aph", "y", " ", "info", " ", "from", " ", "the", " ", "server", ".", " ", "No", " ", "plan", " ", "with", " ", "the", " ", "give", "n", " ", "id", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ",_", "status_", "=_", "500_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "version", "'_", "in_", "request_", "._", "REQUEST_", ":_", "\\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_", "=_", "int_", "(_", "request_", "._", "REQUEST_", "[_", "'", "version", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "version_", "=_", "plan_", "._", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "version_", "=_", "plan_", "._", "version_", "\\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 ", " _", "display_", "=_", "Score", "Display_", "._", "objects_", "._", "get_", "(_", "legislat", "ive", "\\u", "body_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", ",_", "name_", "=_", "\"%", "s", "\\u", "sidebar", "\\u", "demo", "\"_", "%_", "plan_", "._", "legislat", "ive", "\\u", "body_", "._", "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 ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Una", "ble", " ", "to", " ", "get", " ", "Demo", "graphic", "s", " ", "Score", "Display", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "exception", "'_", "]_", "=_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "display", "Id", "'_", "in_", "request_", "._", "REQUEST_", ":_", "\\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 ", " _", "display_", "=_", "Score", "Display_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "request_", "._", "POST_", "[_", "'", "display", "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 ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Una", "ble", " ", "to", " ", "get", " ", "Persona", "lize", "d", " ", "Score", "Display", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "exception", "'_", "]_", "=_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "logger_", "._", "warn_", "(_", "'", "No", " ", "display", "Id", " ", "in", " ", "request", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "warn_", "(_", "str_", "(_", "request_", "._", "POST_", ")_", ")_", "\\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 ", " _", "html_", "=_", "display_", "._", "render_", "(_", "plan_", ",_", "request_", ",_", "version_", "=_", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "html_", ",_", "mimetype_", "=_", "'", "text", "/", "html", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "Cou", "ld", "n", "'", "t", " ", "render", " ", "display", " ", "tab", ".\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "exception", "'_", "]_", "=_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "warn_", "(_", "\"", "Cou", "ld", "n", "'", "t", " ", "render", " ", "display", " ", "tab", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "debug_", "(_", "'", "Rea", "son", ":", " ", "%", "s", "'_", ",_", "ex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ",_", "status_", "=_", "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_", "def_", "getl", "eader", "board", "display_", "(_", "leg", "\\u", "body_", ",_", "owner", "\\u", "filter_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Return", "s", " ", "the", " ", "leader", "board", " ", "Score", "Display", " ", "give", "n", " ", "a", " ", "legislat", "ive", " ", "body", " ", "and", " ", "owner", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Score", "Display_", "._", "objects_", "._", "get_", "(_", "name_", "=_", "\"%", "s", "\\u", "leader", "\\u", "%", "s", "\"_", "%_", "(_", "leg", "\\u", "body_", "._", "name_", ",_", "owner", "\\u", "filter_", ")_", ")_", "\\u\\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_", "def_", "get", "\\u", "shared", "\\u", "district", "s_", "(_", "request_", ",_", "plan", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Get", " ", "the", " ", "shared", " ", "district", "s", " ", "in", " ", "a", " ", "give", "n", " ", "plan", " ", "and", " ", "return", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "data", " ", "in", " ", "a", " ", "format", " ", "reada", "ble", " ", "by", " ", "the", " ", "jq", "grid", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "note", "\\u", "session", "\\u", "activity_", "(_", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "usi", "ng", "\\u", "unique", "\\u", "session_", "(_", "request_", "._", "user_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Forbidden_", "(_", ")_", "\\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 ", " _", "page_", "=_", "int_", "(_", "request_", "._", "POST_", "._", "get_", "(_", "'", "page", "'_", ",_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rows_", "=_", "int_", "(_", "request_", "._", "POST_", "._", "get_", "(_", "'", "rows", "'_", ",_", "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 ", " _", "return_", "Http", "Respons", "e", "Forbidden_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "end_", "=_", "page_", "*_", "rows_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "start_", "=_", "end_", "-_", "rows_", "\\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 ", " _", "plan_", "=_", "Plan_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "plan", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "not_", "can", "\\u", "copy_", "(_", "request_", "._", "user_", ",_", "plan_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Http", "Respons", "e", "Forbidden_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "all", "\\u", "district", "s_", "=_", "plan_", "._", "get", "\\u", "district", "s", "\\u", "at", "\\u", "version_", "(_", "plan_", "._", "version_", ",_", "include", "\\u", "geom_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plan_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "all", "\\u", "district", "s_", "=_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "len_", "(_", "all", "\\u", "district", "s_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "total", "\\u", "pages_", "=_", "math_", "._", "ceil_", "(_", "len_", "(_", "all", "\\u", "district", "s_", ")_", "/_", "float_", "(_", "rows_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "total", "\\u", "pages_", "=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "district", "s_", "=_", "all", "\\u", "district", "s_", "[_", "start_", ":_", "end_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Creat", "e", " ", "the", " ", "object", "s", " ", "tha", "t", " ", "will", " ", "be", " ", "serialize", "d", " ", "for", " ", "presentation", " ", "in", " ", "the", " ", "plan", " ", "chooser_", "\\u\\u\\uNL\\u\\u\\u_", "district", "s", "\\u", "list_", "=_", "list_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "district_", "in_", "district", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "district_", "._", "is", "\\u", "unassign", "ed_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "district", "s", "\\u", "list_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "pk", "'_", ":_", "district_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "fields", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "short", "\\u", "label", "'_", ":_", "district_", "._", "short", "\\u", "label_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "long", "\\u", "label", "'_", ":_", "district_", "._", "long", "\\u", "label_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "district", "\\u", "id", "'_", ":_", "district_", "._", "district", "\\u", "id_", ",_", "\\u\\u\\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_", "json", "\\u", "response_", "=_", "\"{", " ", "\\\\\"", "total", "\\\\\":", "\\\\\"", "%", "d", "\\\\\",", " ", "\\\\\"", "page", "\\\\\":", "\\\\\"", "%", "d", "\\\\\",", " ", "\\\\\"", "record", "s", "\\\\\":", "\\\\\"", "%", "d", "\\\\\",", " ", "\\\\\"", "rows", "\\\\\":", "%", "s", " ", "}\"_", "%_", "(_", "total", "\\u", "pages_", ",_", "page_", ",_", "len_", "(_", "all", "\\u", "district", "s_", ")_", ",_", "json_", "._", "dumps_", "(_", "district", "s", "\\u", "list_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json", "\\u", "response_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\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", "health_", "(_", "request_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "num", "\\u", "users_", "(_", "minutes_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "users_", "=_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "session_", "in_", "Session_", "._", "objects_", "._", "all_", "(_", ")_", ":_", "\\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 ", " _", "decoded_", "=_", "session_", "._", "get", "\\u", "decoded_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", "There", "'", "s", " ", "a", " ", "problem", " ", "with", " ", "this", " ", "session", ",", " ", "remove", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "session_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "continue_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "activit", "y", "\\u", "time", "'_", "in_", "decoded_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "activit", "y", "\\u", "delta_", "=_", "decoded_", "[_", "'", "activit", "y", "\\u", "time", "'_", "]_", "-_", "timedelta_", "(_", "0_", ",_", "0_", ",_", "0_", ",_", "0_", ",_", "settings_", "._", "SES", "SION", "\\u", "TIMEOUT_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "activit", "y", "\\u", "delta_", ">_", "(_", "datetime_", "._", "now_", "(_", ")_", "-_", "timedelta_", "(_", "0_", ",_", "0_", ",_", "0_", ",_", "0_", ",_", "minutes_", ")_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "users_", "+=_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "users_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "\\u_", "(_", "'", "Health", " ", "retrieved", " ", "at", " ", "%", "(", "time", ")", "s", "\\\\", "n", "'_", ")_", "%_", "{_", "'", "time", "'_", ":_", "datetime_", "._", "now_", "(_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "+=_", "\\u_", "(_", "'%", "(", "plan", "\\u", "count", ")", "d", " ", "plans", " ", "in", " ", "databa", "se", "\\\\", "n", "'_", ")_", "%_", "{_", "'", "plan", "\\u", "count", "'_", ":_", "Plan_", "._", "objects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "+=_", "\\u_", "(_", "'%", "(", "session", "\\u", "count", ")", "d", " ", "session", "s", " ", "in", " ", "use", " ", "out", " ", "of", " ", "%", "(", "session", "\\u", "limit", ")", "s", "\\\\", "n", "'_", ")_", "%_", "{_", "'", "session", "\\u", "count", "'_", ":_", "Session_", "._", "objects_", "._", "all_", "(_", ")_", "._", "count_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "session", "\\u", "limit", "'_", ":_", "settings_", "._", "CONC", "URRE", "NT", "\\u", "SES", "SION", "S_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "+=_", "\\u_", "(_", "'%", "(", "num", "\\u", "users", ")", "d", " ", "active", " ", "users", " ", "over", " ", "the", " ", "last", " ", "10", " ", "minute", "s", "\\\\", "n", "'_", ")_", "%_", "{_", "'", "num", "\\u", "users", "'_", ":_", "num", "\\u", "users_", "(_", "10_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "space_", "=_", "os_", "._", "stat", "vfs_", "(_", "'/", "project", "s", "/", "Public", "Map", "ping", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "+=_", "\\u_", "(_", "'%", "(", "mb", "\\u", "free", ")", "s", " ", "MB", " ", "of", " ", "disk", " ", "space", " ", "free", "\\\\", "n", "'_", ")_", "%_", "{_", "'", "mb", "\\u", "free", "'_", ":_", "(_", "(_", "space_", "._", "f", "\\u", "bsi", "ze_", "*_", "space_", "._", "f", "\\u", "ba", "vail", "_", ")_", "/_", "(_", "1024_", "*_", "1024_", ")_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "+=_", "\\u_", "(_", "'", "Memo", "ry", " ", "Us", "age", ":\\\\", "n", "%", "(", "mem", "\\u", "free", ")", "s", "\\\\", "n", "'_", ")_", "%_", "{_", "'", "mem", "\\u", "free", "'_", ":_", "commands_", "._", "getoutput_", "(_", "'", "free", " ", "-", "m", "'_", ")_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "result_", ",_", "mimetype_", "=_", "'", "text", "/", "plain", "'_", ")_", "\\u\\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_", "Http", "Response_", "(_", "\\u_", "(_", "\"", "ERROR", "!", " ", "Cou", "ld", "n", "'", "t", " ", "get", " ", "health", ":\\\\", "n", "%", "s", "\"_", ")_", "%_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "statistic", "s", "\\u", "sets_", "(_", "request_", ",_", "plan", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "=_", "{_", "'", "success", "'_", ":_", "False_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "plan_", "=_", "Plan_", "._", "objects_", "._", "filter_", "(_", "id_", "=_", "plan", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "plan_", "._", "count_", "(_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "No", " ", "plan", " ", "with", " ", "tha", "t", " ", "ID", " ", "exist", "s", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "result_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plan_", "=_", "plan_", "[_", "0_", "]_", "\\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 ", " _", "sets_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "score", "functions_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "function", "s", " ", "avail", "able", " ", "for", " ", "the", " ", "users_", "\\u\\u\\uNL\\u\\u\\u_", "user", "\\u", "functions_", "=_", "Score", "Function_", "._", "objects_", "._", "filter_", "(_", "selectable", "\\u", "bodies_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", ")_", "._", "order", "\\u", "by_", "(_", "'", "name", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "f_", "in_", "user", "\\u", "functions_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "'", "report", "'_", "not_", "in_", "f_", "._", "name_", "._", "lower_", "(_", ")_", "and_", "'", "comment", "s", "'_", "not_", "in_", "f_", "._", "name_", "._", "lower_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "score", "functions_", "._", "append_", "(_", "{_", "'", "id", "'_", ":_", "f_", "._", "id_", ",_", "'", "name", "'_", ":_", "force", "\\u", "escape_", "(_", "f_", "._", "get", "\\u", "label_", "(_", ")_", ")_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "[_", "'", "function", "s", "'_", "]_", "=_", "score", "functions_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "admin", "\\u", "display", "\\u", "names_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "\"%", "s", "\\u", "sidebar", "\\u", "demo", "\"_", "%_", "plan_", "._", "legislat", "ive", "\\u", "body_", "._", "name_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "plan_", "._", "legislat", "ive", "\\u", "body_", "._", "is", "\\u", "community_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "admin", "\\u", "display", "\\u", "names_", "._", "append_", "(_", "\"%", "s", "\\u", "sidebar", "\\u", "comment", "s", "\"_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "plan_", "._", "legislat", "ive", "\\u", "body_", "._", "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 ", " _", "admin", "\\u", "display", "\\u", "names_", "._", "append_", "(_", "\"%", "s", "\\u", "sidebar", "\\u", "basic", "\"_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "plan_", "._", "legislat", "ive", "\\u", "body_", "._", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "admin", " ", "display", "s_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "admin", "\\u", "display", "s_", "=_", "Score", "Display_", "._", "objects_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "owner", "\\u\\u", "is", "\\u", "superuser_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "legislat", "ive", "\\u", "body_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "name", "\\u\\u", "in_", "=_", "admin", "\\u", "display", "\\u", "names_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "admin", "\\u", "display_", "in_", "admin", "\\u", "display", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "sets_", "._", "append_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "id", "'_", ":_", "admin", "\\u", "display_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "force", "\\u", "escape_", "(_", "admin", "\\u", "display_", "._", "get", "\\u", "label_", "(_", ")_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "function", "s", "'_", ":_", "[_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mine", "'_", ":_", "False_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "user", "\\u", "display", "s_", "=_", "Score", "Display_", "._", "objects_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "owner_", "=_", "request_", "._", "user_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "legislat", "ive", "\\u", "body_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "is", "\\u", "page_", "=_", "False_", ")_", "._", "order", "\\u", "by_", "(_", "'", "title", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "[_", "'", "display", "s", "\\u", "count", "'_", "]_", "=_", "len_", "(_", "user", "\\u", "display", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "display_", "in_", "user", "\\u", "display", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "functions_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "panel_", "in_", "display_", "._", "score", "panel", "\\u", "set_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "panel_", "._", "type_", "==_", "'", "district", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "functions_", "=_", "map_", "(_", "lambda_", "x_", ":_", "x_", "._", "id_", ",_", "panel_", "._", "score", "\\u", "functions_", "._", "all_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "len_", "(_", "functions_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "result_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "No", " ", "function", "s", " ", "for", " ", "%", "(", "panel", ")", "s", "\"_", ")_", "%_", "{_", "'", "panel", "\\u", "name", "'_", ":_", "panel_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "sets_", "._", "append_", "(_", "{_", "'", "id", "'_", ":_", "display_", "._", "id_", ",_", "'", "name", "'_", ":_", "force", "\\u", "escape_", "(_", "display_", "._", "\\u\\u", "unicode\\u\\u_", "(_", ")_", ")_", ",_", "'", "function", "s", "'_", ":_", "functions_", ",_", "'", "mine", "'_", ":_", "display_", "._", "owner_", "==_", "request_", "._", "user_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "No", " ", "user", " ", "display", "s", " ", "for", " ", "%", "(", "user", ")", "s", "'_", ")_", "%_", "{_", "'", "user", "'_", ":_", "request_", "._", "user_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "warn_", "(_", "'", "Error", " ", "fetch", "ing", " ", "Score", "Display", "s", " ", "for", " ", "user", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "debug_", "(_", "'", "Rea", "son", ":", " ", "%", "s", "'_", ",_", "ex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "result_", "[_", "'", "sets", "'_", "]_", "=_", "sets_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "[_", "'", "success", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Delete", " ", "the", " ", "request", "ed", " ", "Score", "Display", " ", "to", " ", "make", " ", "some", " ", "room_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "request_", "._", "method_", "==_", "'", "POST", "'_", "and_", "'", "delete", "'_", "in_", "request_", "._", "POST_", ":_", "\\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 ", " _", "display_", "=_", "Score", "Display_", "._", "objects_", "._", "get_", "(_", "pk_", "=_", "request_", "._", "REQUEST_", "._", "get_", "(_", "'", "id", "'_", ",_", "-_", "1_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "[_", "'", "set", "'_", "]_", "=_", "{_", "'", "name", "'_", ":_", "force", "\\u", "escape_", "(_", "display_", "._", "\\u\\u", "unicode\\u\\u_", "(_", ")_", ")_", ",_", "'", "id", "'_", ":_", "display_", "._", "id_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "qse", "t_", "=_", "display_", "._", "score", "panel", "\\u", "set_", "._", "all_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "panel_", "in_", "qse", "t_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "panel_", "._", "display", "s_", "._", "count_", "(_", ")_", "==_", "1_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "panel_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "display_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "[_", "'", "success", "'_", "]_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "Exception_", ",_", "ex_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "result_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "Cou", "ld", "n", "'", "t", " ", "delete", " ", "personali", "zed", " ", "scored", "isp", "lay", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "[_", "'", "exception", "'_", "]_", "=_", "traceback_", "._", "format\\u", "exc_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "warn_", "(_", "\"", "Cou", "ld", "n", "'", "t", " ", "delete", " ", "personali", "zed", " ", "Score", "Display", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "._", "debug_", "(_", "'", "Rea", "son", ":", " ", "%", "s", "'_", ",_", "ex_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "If", " ", "it", "'", "s", " ", "a", " ", "post", ",", " ", "edit", " ", "or", " ", "create", " ", "the", " ", "Score", "Display", " ", "and", " ", "return", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "id", " ", "and", " ", "name", " ", "as", " ", "usual", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "elif_", "request_", "._", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "we", "'", "re", " ", "addin", "g", " ", "a", " ", "new", " ", "display", ",", " ", "we", " ", "shou", "ld", " ", "make", " ", "sure", " ", "the", "y", " ", "only", " ", "have", " ", "3_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "validat", "e\\u", "num_", "(_", "user_", ",_", "limit_", "=_", "3_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "Score", "Display_", "._", "objects_", "._", "filter_", "(_", "owner_", "=_", "user_", ",_", "legislat", "ive", "\\u", "body_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", ",_", "is", "\\u", "page_", "=_", "False_", ")_", "._", "count_", "(_", ")_", "<_", "limit_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "'", "function", "s", "[]'_", "in_", "request_", "._", "POST_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "functions_", "=_", "request_", "._", "POST_", "._", "getlist_", "(_", "'", "function", "s", "[]'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "functions_", "=_", "map_", "(_", "lambda_", "x_", ":_", "int_", "(_", "x_", ")_", ",_", "functions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "display_", "=_", "Score", "Display_", "._", "objects_", "._", "get_", "(_", "title_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "'", "name", "'_", ")_", ",_", "owner_", "=_", "request_", "._", "user_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "display_", "=_", "display_", "._", "copy", "\\u", "from_", "(_", "display_", "=_", "display_", ",_", "functions_", "=_", "functions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "limit_", "=_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "validat", "e\\u", "num_", "(_", "request_", "._", "user_", ",_", "limit_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "demo_", "=_", "Score", "Display_", "._", "objects_", "._", "filter_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "owner", "\\u\\u", "is", "\\u", "superuser_", "=_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "legislat", "ive", "\\u", "body_", "=_", "plan_", "._", "legislat", "ive", "\\u", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "is", "\\u", "page_", "=_", "False_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "title_", "=_", "\"", "Demo", "graphic", "s", "\"_", "\\u\\u\\uNL\\u\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "DO", " ", "NOT", " ", "select", " ", "the", " ", "Score", "Display", " ", "tha", "t", " ", "contains_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "comment", " ", "calculator_", "\\u\\u\\uNL\\u\\u\\u_", "for_", "disp_", "in_", "demo_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "has", "\\u", "comments_", "=_", "False_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "pnl_", "in_", "disp_", "._", "score", "panel", "\\u", "set_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "for_", "fn_", "in_", "pnl_", "._", "score", "\\u", "functions_", "._", "all_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "has", "\\u", "comments_", "=_", "has", "\\u", "comments_", "or_", "fn_", "._", "calculator_", "._", "endswith_", "(_", "'.", "Comme", "nts", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "not_", "has", "\\u", "comments_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "demo_", "=_", "disp_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "display_", "=_", "Score", "Display_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "display_", "=_", "display_", "._", "copy", "\\u", "from_", "(_", "display_", "=_", "demo_", ",_", "title_", "=_", "request_", "._", "POST_", "._", "get_", "(_", "'", "name", "'_", ")_", ",_", "owner_", "=_", "request_", "._", "user_", ",_", "functions_", "=_", "functions_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "[_", "'", "new", "Record", "'_", "]_", "=_", "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 ", " ", "_", "result_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "Ea", "ch", " ", "user", " ", "is", " ", "limited", " ", "to", " ", "%", "(", "limit", ")", "d", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "statistic", "s", " ", "sets", ".", " ", "Ple", "ase", " ", "delete", " ", "one", " ", "or", " ", "edit", " ", "'_", "\\u\\u\\uNL\\u\\u\\u_", "'", "an", " ", "exist", "ing", " ", "set", ".'_", ")_", "%_", "{_", "'", "limit", "'_", ":_", "limit_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "[_", "'", "error", "'_", "]_", "=_", "'", "limit", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "result_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\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_", "[_", "'", "set", "'_", "]_", "=_", "{_", "'", "name", "'_", ":_", "force", "\\u", "escape_", "(_", "display_", "._", "\\u\\u", "unicode\\u\\u_", "(_", ")_", ")_", ",_", "'", "id", "'_", ":_", "display_", "._", "id_", ",_", "'", "function", "s", "'_", ":_", "functions_", ",_", "'", "mine", "'_", ":_", "display_", "._", "owner_", "==_", "request_", "._", "user_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "[_", "'", "success", "'_", "]_", "=_", "True_", "\\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 ", " _", "result_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "\"", "Di", "dn", "'", "t", " ", "get", " ", "function", "s", " ", "in", " ", "POST", " ", "parameter", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "result_", ")_", ",_", "mimetype_", "=_", "'", "applica", "tion", "/", "json", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "unique", "\\u", "session", "\\u", "or", "\\u", "json", "\\u", "redirect_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "district", "\\u", "info_", "(_", "request_", ",_", "plan", "id_", ",_", "district", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Get", " ", "the", " ", "comment", "s", " ", "tha", "t", " ", "are", " ", "attache", "d", " ", "to", " ", "a", " ", "district", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Parameter", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "request", " ", "--", " ", "An", " ", "Http", "Request", "\\", "10", ";", " ", " ", " ", " ", "plan", "id", " ", "--", " ", "The", " ", "plan", " ", "ID", "\\", "10", ";", " ", " ", " ", " ", "district", "\\u", "id", " ", "--", " ", "The", " ", "district", " ", "ID", ",", " ", "this", " ", "is", " ", "the", " ", "district", " ", "number", " ", "in", " ", "a", " ", "plan", ",", " ", "and", " ", "NOT", " ", "the", " ", "id", " ", "of", " ", "a", " ", "district", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "=_", "{_", "'", "success", "'_", ":_", "False_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "plan_", "=_", "Plan_", "._", "objects_", "._", "filter_", "(_", "id_", "=_", "plan", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "plan_", "._", "count_", "(_", ")_", "==_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "status_", "[_", "'", "message", "'_", "]_", "=_", "\\u_", "(_", "'", "No", " ", "plan", " ", "with", " ", "tha", "t", " ", "ID", " ", "was", " ", "found", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "plan_", "=_", "plan_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "plan_", "._", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "version", "'_", "in_", "request_", "._", "REQUEST_", ":_", "\\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_", "=_", "int_", "(_", "request_", "._", "REQUEST_", "[_", "'", "version", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "version_", "=_", "min_", "(_", "plan_", "._", "version_", ",_", "int_", "(_", "version_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "district", "\\u", "id_", "=_", "int_", "(_", "district", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "district_", "=_", "plan_", "._", "get", "\\u", "district", "s", "\\u", "at", "\\u", "version_", "(_", "version_", ",_", "include", "\\u", "geom_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "district_", "=_", "filter_", "(_", "lambda_", "d_", ":_", "d_", "._", "district", "\\u", "id_", "==_", "district", "\\u", "id_", ",_", "district_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "request_", "._", "method_", "==_", "'", "POST", "'_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "district_", "=_", "plan_", "._", "district", "\\u", "set_", "._", "get_", "(_", "id_", "=_", "request_", "._", "POST_", "[_", "'", "object\\u", "pk", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "district_", "._", "short", "\\u", "label_", "=_", "request_", "._", "POST_", "[_", "'", "district", "\\u", "short", "'_", "]_", "[_", "0_", ":_", "10_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "district_", "._", "long", "\\u", "label_", "=_", "request_", "._", "POST_", "[_", "'", "district", "\\u", "long", "'_", "]_", "[_", "0_", ":_", "256_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "district_", "._", "version_", "<_", "version_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "The", " ", "district", " ", "version", " ", "may", " ", "lag", " ", "beh", "ind", " ", "the", " ", "cursor", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "version", " ", "if", " ", "there", " ", "wer", "e", " ", "no", " ", "edits", " ", "for", " ", "a", " ", "whi", "le", ".", " ", "If", " ", "this", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "is", " ", "the", " ", "case", " ", "the", " ", "district", " ", "must", " ", "be", " ", "copie", "d", " ", "to", " ", "the", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "currentl", "y", " ", "edited", " ", "version", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "district", "\\u", "copy_", "=_", "copy_", "._", "copy_", "(_", "district_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "district", "\\u", "copy_", "._", "id_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "district", "\\u", "copy_", "._", "version_", "=_", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "district", "\\u", "copy_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "clone", " ", "the", " ", "characteristics", ",", " ", "comment", "s", ",", " ", "and", " ", "tags", " ", "from", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "original", " ", "district", " ", "to", " ", "the", " ", "copy", " _", "\\u\\u\\uNL\\u\\u\\u_", "district", "\\u", "copy_", "._", "clone", "\\u", "relation", "s", "\\u", "from_", "(_", "district_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "district_", "=_", "district", "\\u", "copy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "save", " ", "the", " ", "change", "s", " ", "to", " ", "the", " ", "district", " ", "--", " ", "may", "be", " ", "name", " ", "change_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "district_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "has", "\\u", "comment_", "=_", "'", "comment", "'_", "in_", "request_", "._", "POST_", "and_", "request_", "._", "POST_", "[_", "'", "comment", "'_", "]_", "!=_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "has", "\\u", "comment_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Don", "'", "t", " ", "thread", " ", "comment", "s", ",", " ", "keep", " ", "only", " ", "the", " ", "late", "st", " ", "and", " ", "great", "est_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "ct_", "=_", "Conten", "t", "Type_", "._", "objects_", "._", "get_", "(_", "app", "\\u", "label_", "=_", "'", "redis", "tric", "ting", "'_", ",_", "model_", "=_", "'", "district", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Comment_", "._", "objects_", "._", "filter_", "(_", "object\\u", "pk_", "=_", "district_", "._", "id_", ",_", "content", "\\u", "type_", "=_", "ct_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "comment_", "=_", "Comment_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "object\\u", "pk_", "=_", "district_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "ct_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "site", "\\u", "id_", "=_", "Site_", "._", "objects_", "._", "get", "\\u", "current_", "(_", ")_", "._", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user", "\\u", "name_", "=_", "request_", "._", "user_", "._", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "user", "\\u", "email_", "=_", "request_", "._", "user_", "._", "email_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "comment_", "=_", "request_", "._", "POST_", "[_", "'", "comment", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "comment_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "save", " ", "this", " ", "if", " ", "the", " ", "label", " ", "changed_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "district_", "._", "save_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Get", " ", "the", " ", "tags", " ", "on", " ", "this", " ", "object", " ", "of", " ", "this", " ", "type", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "tse", "t_", "=_", "Tag_", "._", "objects_", "._", "get", "\\u", "for", "\\u", "object_", "(_", "district_", ")_", "._", "filter_", "(_", "name", "\\u\\u", "startswith_", "=_", "'", "type", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Purg", "e", " ", "the", " ", "tags", " ", "of", " ", "this", " ", "same", " ", "type", " ", "off", " ", "the", " ", "object_", "\\u\\u\\uNL\\u\\u\\u_", "Tagg", "ed", "Item_", "._", "objects_", "._", "filter_", "(_", "tag", "\\u\\u", "in_", "=_", "tse", "t_", ",_", "object\\u", "id_", "=_", "district_", "._", "id_", ")_", "._", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "pur", "ge", "\\u", "plan", "\\u", "clear", "\\u", "cache_", "(_", "district_", ",_", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "len_", "(_", "request_", "._", "REQUEST_", "._", "getlist_", "(_", "'", "type", "[]'_", ")_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "strt", "ags_", "=_", "request_", "._", "REQUEST_", "._", "getlist_", "(_", "'", "type", "[]'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "strt", "ag_", "in_", "strt", "ags_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", "_", "if_", "strt", "ag_", "==_", "''_", ":_", "\\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_", "strt", "ag_", "._", "count_", "(_", "'", " ", "'_", ")_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "strt", "ag_", "=_", "'\"", "type", "=", "%", "s", "\"'_", "%_", "strt", "ag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " ", " _", "strt", "ag_", "=_", "'", "type", "=", "%", "s", "'_", "%_", "strt", "ag_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "Tag_", "._", "objects_", "._", "add", "\\u", "tag_", "(_", "district_", ",_", "strt", "ag_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "status_", "[_", "'", "version", "'_", "]_", "=_", "version_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "status_", "[_", "'", "success", "'_", "]_", "=_", "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_", "Http", "Response_", "(_", "json_", "._", "dumps_", "(_", "status_", ")_", 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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 ]
Unused import
dansanderson/picotool/tests/pico8/util_test.py
[ { "content": "#!/usr/bin/env python3\n\nimport io\nimport sys\nimport unittest\nfrom unittest.mock import Mock\nfrom unittest.mock import patch\n\nfrom pico8 import util\n\n\n \n\n\n\n\n \nif __name__ == '__main__':\n unittest.main()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class TestUtil(unittest.TestCase):\n \n\n\n\n\n\n ", "metadata": "root.TestUtil", "header": "['module', '___EOS___']", "index": 11 }, { "content": " def setUp(self):\n self.orig_write_stream = util._write_stream\n self.orig_error_stream = util._error_stream\n util._write_stream = io.StringIO()\n util._error_stream = io.StringIO()", "metadata": "root.TestUtil.setUp", "header": "['class', 'TestUtil', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 12 }, { "content": " def tearDown(self):\n util._verbosity = util.VERBOSITY_NORMAL\n util._write_stream = self.orig_write_stream\n util._error_stream = self.orig_error_stream", "metadata": "root.TestUtil.tearDown", "header": "['class', 'TestUtil', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 18 }, { "content": " def testWrite(self):\n s = 'test1'\n util.write(s)\n self.assertEqual(s, util._write_stream.getvalue())", "metadata": "root.TestUtil.testWrite", "header": "['class', 'TestUtil', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 23 }, { "content": " def testWriteQuiet(self):\n util.set_verbosity(util.VERBOSITY_QUIET)\n s = 'test2'\n util.write(s)\n self.assertEqual('', util._write_stream.getvalue())", "metadata": "root.TestUtil.testWriteQuiet", "header": "['class', 'TestUtil', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 28 }, { "content": " def testError(self):\n s = 'test3'\n util.error(s)\n self.assertEqual(s, util._error_stream.getvalue())", "metadata": "root.TestUtil.testError", "header": "['class', 'TestUtil', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 34 }, { "content": " def testErrorQuiet(self):\n s = 'test4'\n util.set_verbosity(util.VERBOSITY_QUIET)\n util.error(s)\n self.assertEqual(s, util._error_stream.getvalue())", "metadata": "root.TestUtil.testErrorQuiet", "header": "['class', 'TestUtil', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 39 }, { "content": " def testDebug(self):\n s = 'test5'\n util.debug(s)\n self.assertEqual('', util._write_stream.getvalue())", "metadata": "root.TestUtil.testDebug", "header": "['class', 'TestUtil', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 45 }, { "content": " def testDebugVerbose(self):\n s = 'test6'\n util.set_verbosity(util.VERBOSITY_DEBUG)\n util.debug(s)\n self.assertEqual(s, util._write_stream.getvalue())", "metadata": "root.TestUtil.testDebugVerbose", "header": "['class', 'TestUtil', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 50 }, { "content": "class DummySection(util.BaseSection):\n HEX_LINE_LENGTH_BYTES = 3", "metadata": "root.DummySection", "header": "['module', '___EOS___']", "index": 57 }, { "content": "class TestBaseSection(unittest.TestCase):\n\n\n", "metadata": "root.TestBaseSection", "header": "['module', '___EOS___']", "index": 61 }, { "content": " def testInit(self):\n s = DummySection(b'abcdefgh', 4)\n self.assertEqual(b'abcdefgh', s._data)\n self.assertEqual(4, s._version)", "metadata": "root.TestBaseSection.testInit", "header": "['class', 'TestBaseSection', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 62 }, { "content": " def testFromLines(self):\n lines = ['616263\\n', '646566\\n', '6768\\n']\n s = DummySection.from_lines(lines, 4)\n self.assertEqual(b'abcdefgh', s._data)\n self.assertEqual(4, s._version)", "metadata": "root.TestBaseSection.testFromLines", "header": "['class', 'TestBaseSection', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 67 }, { "content": " def testFromBytes(self):\n s = DummySection.from_bytes(b'abcdefgh', 4)\n self.assertEqual(b'abcdefgh', s._data)\n self.assertEqual(4, s._version)", "metadata": "root.TestBaseSection.testFromBytes", "header": "['class', 'TestBaseSection', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 73 }, { "content": " def testToLines(self):\n s = DummySection.from_bytes(b'abcdefgh', 4)\n lines = list(s.to_lines())\n self.assertEqual(['616263\\n', '646566\\n', '6768\\n'], lines)", "metadata": "root.TestBaseSection.testToLines", "header": "['class', 'TestBaseSection', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 78 } ]
[ { "span": "import sys", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 10 }, { "span": "from unittest.mock import Mock", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 30 }, { "span": "from unittest.mock import patch", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 31 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python", "3_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "io_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "unittest_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "unittest_", "._", "mock_", "import_", "Mock_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "unittest_", "._", "mock_", "import_", "patch_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "pico", "8_", "import_", "util_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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 ", " _", "unittest_", "._", "main_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Test", "Util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Test", "Util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "set", "Up_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "orig", "\\u", "write", "\\u", "stream_", "=_", "util_", "._", "\\u", "write", "\\u", "stream_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "orig", "\\u", "error", "\\u", "stream_", "=_", "util_", "._", "\\u", "error", "\\u", "stream_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "util_", "._", "\\u", "write", "\\u", "stream_", "=_", "io_", "._", "String", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "util_", "._", "\\u", "error", "\\u", "stream_", "=_", "io_", "._", "String", "IO_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Util_", "(_", "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 ", " _", "util_", "._", "\\u", "verbosity_", "=_", "util_", "._", "VERBOS", "IT", "Y", "\\u", "NORMAL_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "util_", "._", "\\u", "write", "\\u", "stream_", "=_", "self_", "._", "orig", "\\u", "write", "\\u", "stream_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "util_", "._", "\\u", "error", "\\u", "stream_", "=_", "self_", "._", "orig", "\\u", "error", "\\u", "stream_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Write_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "'", "test", "1", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "util_", "._", "write_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", ",_", "util_", "._", "\\u", "write", "\\u", "stream_", "._", "getvalue_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Write", "Qui", "et_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "util_", "._", "set\\u", "verbosity_", "(_", "util_", "._", "VERBOS", "IT", "Y", "\\u", "QUI", "ET_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "'", "test", "2", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "util_", "._", "write_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "''_", ",_", "util_", "._", "\\u", "write", "\\u", "stream_", "._", "getvalue_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Error_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "'", "test", "3", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "util_", "._", "error_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", ",_", "util_", "._", "\\u", "error", "\\u", "stream_", "._", "getvalue_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Error", "Qui", "et_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "'", "test", "4", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "util_", "._", "set\\u", "verbosity_", "(_", "util_", "._", "VERBOS", "IT", "Y", "\\u", "QUI", "ET_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "util_", "._", "error_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", ",_", "util_", "._", "\\u", "error", "\\u", "stream_", "._", "getvalue_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Debug_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "'", "test", "5", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "util_", "._", "debug_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "''_", ",_", "util_", "._", "\\u", "write", "\\u", "stream_", "._", "getvalue_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Util_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Deb", "ug", "Verbos", "e_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "'", "test", "6", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "util_", "._", "set\\u", "verbosity_", "(_", "util_", "._", "VERBOS", "IT", "Y", "\\u", "DEBUG_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "util_", "._", "debug_", "(_", "s_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "s_", ",_", "util_", "._", "\\u", "write", "\\u", "stream_", "._", "getvalue_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "Du", "mm", "y", "Section_", "(_", "util_", "._", "Base", "Section_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "HEX", "\\u", "LINE", "\\u", "LENGTH", "\\u", "BYTES_", "=_", "3_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Test", "Base", "Section_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Test", "Base", "Section_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "test", "Init_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "Du", "mm", "y", "Section_", "(_", "b", "'", "abcdefg", "h", "'_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "b", "'", "abcdefg", "h", "'_", ",_", "s_", "._", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "4_", ",_", "s_", "._", "\\u", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Base", "Section_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Fro", "m", "Lines_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "lines_", "=_", "[_", "'", "616", "263", "\\\\", "n", "'_", ",_", "'", "646", "566", "\\\\", "n", "'_", ",_", "'", "676", "8", "\\\\", "n", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "s_", "=_", "Du", "mm", "y", "Section_", "._", "from", "\\u", "lines_", "(_", "lines_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "b", "'", "abcdefg", "h", "'_", ",_", "s_", "._", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "4_", ",_", "s_", "._", "\\u", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Base", "Section_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "Fro", "m", "Bytes_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "Du", "mm", "y", "Section_", "._", "from", "\\u", "bytes_", "(_", "b", "'", "abcdefg", "h", "'_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "b", "'", "abcdefg", "h", "'_", ",_", "s_", "._", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "4_", ",_", "s_", "._", "\\u", "version_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Base", "Section_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test", "To", "Lines_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "s_", "=_", "Du", "mm", "y", "Section_", "._", "from", "\\u", "bytes_", "(_", "b", "'", "abcdefg", "h", "'_", ",_", "4_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "lines_", "=_", "list_", "(_", "s_", "._", "to", "\\u", "lines_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "[_", "'", "616", "263", "\\\\", "n", "'_", ",_", "'", "646", "566", "\\\\", "n", "'_", ",_", "'", "676", "8", "\\\\", "n", "'_", "]_", ",_", "lines_", ")_", "\\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, 2, 2, 2, 2, 0, 1, 1, 1, 1, 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, 4, 2, 2, 2, 2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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
anandology/pyjamas/library/pyjamas/Canvas/ColorStop.py
[ { "content": "from gwt.Canvas.ColorStop import (\n Color,\n ColorStop,\n)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from gwt.Canvas.ColorStop import (\n Color,\n ColorStop,\n)", "start_line": 0, "start_column": 0, "end_line": 3, "end_column": 1 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "gw", "t_", "._", "Canvas_", "._", "Color", "Stop_", "import_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "Color_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Color", "Stop_", ",_", "\\u\\u\\uNL\\u\\u\\u_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Unused import
mrjoes/tornadio2/tornadio2/__init__.py
[ { "content": "# -*- coding: utf-8 -*-\n#\n# Copyright: (c) 2011 by the Serge S. Koval, see AUTHORS for more details.\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\"\"\"\n tornadio2\n ~~~~~~~~~\n\"\"\"\n\n__version__ = (0, 0, 3)\n\nfrom tornadio2.conn import SocketConnection, event\nfrom tornadio2.router import TornadioRouter\nfrom tornadio2.server import SocketServer\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from tornadio2.conn import SocketConnection, event", "start_line": 23, "start_column": 0, "end_line": 23, "end_column": 50 }, { "span": "from tornadio2.router import TornadioRouter", "start_line": 24, "start_column": 0, "end_line": 24, "end_column": 43 }, { "span": "from tornadio2.server import SocketServer", "start_line": 25, "start_column": 0, "end_line": 25, "end_column": 41 } ]
[]
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", ")", " ", "2011", " ", "by", " ", "the", " ", "Ser", "ge", " ", "S", ".", " ", "Ko", "val", ",", " ", "see", " ", "AUTHOR", "S", " ", "for", " ", "more", " ", "deta", "il", "s", "._", "\\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", ";", " ", " ", " ", " ", "torn", "adio", "2", "\\", "10", ";", " ", " ", " ", " ", "~~~~~", "~~~", "~", "\\", "10", ";\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "version\\u\\u_", "=_", "(_", "0_", ",_", "0_", ",_", "3_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "torn", "adio", "2_", "._", "conn_", "import_", "Sock", "et", "Connection_", ",_", "event_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "torn", "adio", "2_", "._", "router_", "import_", "Tor", "nad", "io", "Router_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "torn", "adio", "2_", "._", "server_", "import_", "Sock", "et", "Server_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Unused local variable
PythonCharmers/python-future/src/libfuturize/fixes/fix_metaclass.py
[ { "content": "def fixup_parse_tree(cls_node):\n \"\"\" one-line classes don't get a suite in the parse tree so we add\n one to normalize the tree\n \"\"\"\n for node in cls_node.children:\n if node.type == syms.suite:\n # already in the preferred format, do nothing\n return\n\n # !%@#! oneliners have no suite node, we have to fake one up\n for i, node in enumerate(cls_node.children):\n if node.type == token.COLON:\n break\n else:\n raise ValueError(\"No class suite and no ':'!\")\n\n # move everything into a suite node\n suite = Node(syms.suite, [])\n while cls_node.children[i+1:]:\n move_node = cls_node.children[i+1]\n suite.append_child(move_node.clone())\n move_node.remove()\n cls_node.append_child(suite)\n node = suite", "metadata": "root.fixup_parse_tree", "header": "['module', '___EOS___']", "index": 56 } ]
[ { "span": "node ", "start_line": 79, "start_column": 4, "end_line": 79, "end_column": 8 } ]
[]
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_", "fixup", "\\u", "parse", "\\u", "tree_", "(_", "cls", "\\u", "node_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", " ", "one", "-", "line", " ", "classe", "s", " ", "don", "'", "t", " ", "get", " ", "a", " ", "suit", "e", " ", "in", " ", "the", " ", "parse", " ", "tree", " ", "so", " ", "we", " ", "add", "\\", "10", ";", " ", " ", " ", " ", "one", " ", "to", " ", "normali", "ze", " ", "the", " ", "tree", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "node_", "in_", "cls", "\\u", "node_", "._", "children_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "node_", "._", "type_", "==_", "syms_", "._", "suite_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "alr", "ead", "y", " ", "in", " ", "the", " ", "prefer", "red", " ", "format", ",", " ", "do", " ", "nothing_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "!%", "@#", "!", " ", "one", "line", "rs", " ", "have", " ", "no", " ", "suit", "e", " ", "node", ",", " ", "we", " ", "have", " ", "to", " ", "fake", " ", "one", " ", "up_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "i_", ",_", "node_", "in_", "enumerate_", "(_", "cls", "\\u", "node_", "._", "children_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "node_", "._", "type_", "==_", "token_", "._", "COLON", "_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "break_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Value", "Error_", "(_", "\"", "No", " ", "class", " ", "suit", "e", " ", "and", " ", "no", " ", "':", "'!", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "move", " ", "every", "thing", " ", "int", "o", " ", "a", " ", "suit", "e", " ", "node_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "suite_", "=_", "Node_", "(_", "syms_", "._", "suite_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "while_", "cls", "\\u", "node_", "._", "children_", "[_", "i_", "+_", "1_", ":_", "]_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "move", "\\u", "node_", "=_", "cls", "\\u", "node_", "._", "children_", "[_", "i_", "+_", "1_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "suite_", "._", "append", "\\u", "child_", "(_", "move", "\\u", "node_", "._", "clone_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "move", "\\u", "node_", "._", "remove_", "(_",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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2 ]
Module is imported more than once
emccode/heliosburn/heliosburn/django/hbproject/api/tests.py
[ { "content": "from django.test import TestCase\nimport json\napi_url = \"http://127.0.0.1:8000/api\"\nadmin_username = 'admin'\nadmin_password = 'admin'\ntest1_username = 'test1'\ntest1_password = 'test1'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": " def test_crud(self):\n \"\"\"\n Tests CRUD for session model.\n \"\"\"\n import json\n\n def create():\n self.login(admin_username, admin_password)\n body = json.dumps({\n 'name': 'CRUD test',\n 'description': 'CRUD test',\n 'upstreamHost': '127.0.0.1',\n 'upstreamPort': 8080,\n })\n\n response = self.client.post(path=api_url + \"/session/\",\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n self.assertIn(\"location\", response._headers)\n in_json = json.loads(response.content)\n self.assertIn(\"id\", in_json)\n self.session_id = in_json['id']\n\n def read():\n self.login(admin_username, admin_password)\n response = self.client.get(api_url + \"/session/\" + self.session_id, HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n self.login('test1', 'test1')\n response = self.client.get(api_url + \"/session/\" + self.session_id, HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 403)\n\n def update():\n self.login(admin_username, admin_password)\n body = json.dumps({'name': 'CRUD test updated'})\n response = self.client.put(path=api_url + \"/session/\" + self.session_id,\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n self.login(test1_username, test1_password)\n response = self.client.put(path=api_url + \"/session/\" + self.session_id,\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 403)\n\n def delete():\n self.login(test1_username, test1_password)\n response = self.client.delete(path=api_url + \"/session/\" + self.session_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 403)\n\n self.login(admin_username, admin_password)\n response = self.client.delete(path=api_url + \"/session/\" + self.session_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n def linked_crud():\n # Create a testplan\n self.login(admin_username, admin_password)\n body = json.dumps({\"name\": \"crud testplan\"})\n response = self.client.post(path=api_url + \"/testplan/\",\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n testplan_id = json.loads(response.content)['id']\n\n # Create a session linked to testplan\n body = json.dumps({\n 'name': 'crud session',\n 'description': 'crud session description',\n 'testplan': testplan_id,\n \"upstreamHost\": \"127.0.0.1\",\n \"upstreamPort\": 8080\n })\n response = self.client.post(path=api_url + \"/session\",\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n session_id = json.loads(response.content)['id']\n\n # Delete session and testplan\n self.client.delete(path=api_url + \"/session/\" + session_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n self.client.delete(path=api_url + \"/testplan/\" + testplan_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n print(\"Testing CREATE in %s\" % self.__class__)\n create()\n\n print(\"Testing READ in %s\" % self.__class__)\n read()\n\n print(\"Testing UPDATE in %s\" % self.__class__)\n update()\n\n print(\"Testing DELETE in %s\" % self.__class__)\n delete()\n\n print(\"Testing CRUD specific to a linked testplan in %s\" % self.__class__)\n linked_crud()", "metadata": "root.SessionViewTestCase.test_crud", "header": "['class', 'SessionViewTestCase', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 49 }, { "content": " def test_crud(self):\n \"\"\"\n Tests CRUD for testplan model.\n \"\"\"\n import json\n\n def create():\n body = json.dumps({\n \"name\": \"CRUD test with rule\",\n \"rules\": [\n {\n 'ruleType': 'request',\n 'name': 'test_rule_3',\n 'enabled': True,\n 'filter': {\n 'httpProtocol': 'HTTP/1.1',\n 'method': 'GET',\n 'headers': [\n {'key': 'foo'},\n {'key': 'fizz', 'value': 'buzz'},\n ],\n },\n 'action': {\n 'type': 'modify',\n 'method': 'PUT',\n 'url': 'www.newurl.com/foo/bar',\n 'setHeaders': [\n {\n 'key': 'zaphod', 'value': 'beeblebrox',\n },\n ],\n 'deleteHeaders': [\n {\n 'key': 'foo',\n },\n ],\n }\n },\n ],\n })\n\n self.login(admin_username, admin_password)\n response = self.client.post(path=api_url + \"/testplan/\",\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n self.assertIn(\"location\", response._headers)\n in_json = json.loads(response.content)\n self.assertIn(\"id\", in_json)\n self.testplan_id = in_json['id']\n\n def read():\n self.login(admin_username, admin_password)\n response = self.client.get(path=api_url + \"/testplan/\" + self.testplan_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n def update():\n body = json.dumps({\n \"name\": \"CRUD test with rule, name updated\",\n \"rules\": [\n {\n 'ruleType': 'request',\n 'filter': {\n 'httpProtocol': 'HTTP/1.1',\n 'method': 'GET',\n 'headers': [\n {'key': 'paul bunyon'},\n {'key': 'companion', 'value': 'blue oxe'},\n ],\n },\n 'action': {\n 'type': 'newResponse',\n 'httpProtocol': 'CARRIERPIGEON/1.1',\n 'statusCode': 403,\n 'statusDescription': 'TOO RIDICULOUS',\n 'headers': [\n {\n 'key': 'User-Agent',\n 'value': 'Broken Telescope 1.9'\n },\n ],\n 'payload': 'The answer to life, the universe, and everything...is 42.',\n }\n },\n ],\n })\n\n self.login(admin_username, admin_password)\n response = self.client.put(path=api_url + \"/testplan/\" + self.testplan_id,\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n def delete():\n self.login(admin_username, admin_password)\n response = self.client.delete(path=api_url + \"/testplan/\" + self.testplan_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n print(\"Testing CREATE in %s\" % self.__class__)\n create()\n\n print(\"Testing READ in %s\" % self.__class__)\n read()\n\n print(\"Testing UPDATE in %s\" % self.__class__)\n update()\n\n print(\"Testing DELETE in %s\" % self.__class__)\n delete()", "metadata": "root.TestplanViewTestCase.test_crud", "header": "['class', 'TestplanViewTestCase', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 165 }, { "content": " def test_crud(self):\n \"\"\"\n Tests CRUD for user model.\n \"\"\"\n import json\n\n def create():\n self.login(admin_username, admin_password)\n self.username = \"crudtest\"\n body = json.dumps({\n \"username\": self.username,\n \"password\": \"CRUD test\",\n \"email\": \"test@test\",\n })\n response = self.client.post(path=api_url + \"/user/\",\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n self.assertIn(\"location\", response._headers)\n\n self.login(test1_username, test1_password)\n response = self.client.post(path=api_url + \"/user/\",\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 403)\n\n def read():\n self.login(admin_username, admin_password)\n response = self.client.get(path=api_url + \"/user/\" + self.username,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n response = self.client.get(path=api_url + \"/user/\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n self.login(test1_username, test1_password)\n response = self.client.get(path=api_url + \"/user/\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 403)\n\n def update():\n self.login(admin_username, admin_password)\n body = json.dumps({\"email\": \"test1@test1\"})\n response = self.client.put(path=api_url + \"/user/\" + self.username,\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n self.login(test1_username, test1_password)\n response = self.client.put(path=api_url + \"/user/\" + self.username,\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 403)\n\n def delete():\n self.login(test1_username, test1_password)\n response = self.client.delete(path=api_url + \"/user/\" + self.username,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 403)\n\n self.login(admin_username, admin_password)\n response = self.client.delete(path=api_url + \"/user/\" + self.username,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n\n print(\"Testing CREATE in %s\" % self.__class__)\n create()\n\n print(\"Testing READ in %s\" % self.__class__)\n read()\n\n print(\"Testing UPDATE in %s\" % self.__class__)\n update()\n\n print(\"Testing DELETE in %s\" % self.__class__)\n delete()", "metadata": "root.UserViewTestCase.test_crud", "header": "['class', 'UserViewTestCase', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 285 }, { "content": " def test_crud(self):\n \"\"\"\n Tests CRUD for rule model.\n \"\"\"\n import json\n\n def create():\n body = json.dumps({\n 'ruleType': 'request',\n 'name': 'test_rule_2',\n 'enabled': True,\n 'filter': {\n 'httpProtocol': 'HTTP/1.1',\n 'method': 'GET',\n 'headers': [\n {'key': 'foo'},\n {'key': 'fizz', 'value': 'buzz'},\n ],\n },\n 'action': {\n 'type': 'modify',\n 'method': 'PUT',\n 'url': 'www.newurl.com/foo/bar',\n 'setHeaders': [\n {\n 'key': 'zaphod', 'value': 'beeblebrox',\n },\n ],\n 'deleteHeaders': [\n {\n 'key': 'foo',\n },\n ],\n }\n })\n self.login(admin_username, admin_password)\n response = self.client.post(path=api_url + \"/rule/\",\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n self.assertIn(\"location\", response._headers)\n in_json = json.loads(response.content)\n self.assertIn(\"id\", in_json)\n self.rule_id = in_json['id']\n\n def read():\n self.login(admin_username, admin_password)\n response = self.client.get(path=api_url + \"/rule/\" + self.rule_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n def update():\n body = json.dumps({\n 'ruleType': 'request',\n 'enabled': True,\n 'name': 'test_rule_4',\n 'filter': {\n 'httpProtocol': 'HTTP/1.1',\n 'method': 'GET',\n 'headers': [\n {'key': 'paul bunyon'},\n {'key': 'companion', 'value': 'blue oxe'},\n ],\n },\n 'action': {\n 'type': 'newResponse',\n 'httpProtocol': 'CARRIERPIGEON/1.1',\n 'statusCode': 403,\n 'statusDescription': 'TOO RIDICULOUS',\n 'headers': [\n {\n 'key': 'User-Agent',\n 'value': 'Broken Telescope 1.9'\n },\n ],\n 'payload': 'The answer to life, the universe, and everything...is 42.',\n },\n })\n self.login(admin_username, admin_password)\n response = self.client.put(path=api_url + \"/rule/\" + self.rule_id,\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n def delete():\n self.login(admin_username, admin_password)\n response = self.client.delete(path=api_url + \"/rule/\" + self.rule_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n\n print(\"Testing CREATE in %s\" % self.__class__)\n create()\n\n print(\"Testing READ in %s\" % self.__class__)\n read()\n\n print(\"Testing UPDATE in %s\" % self.__class__)\n update()\n\n print(\"Testing DELETE in %s\" % self.__class__)\n delete()", "metadata": "root.RuleViewTestCase.test_crud", "header": "['class', 'RuleViewTestCase', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 407 }, { "content": " def test_crud(self):\n \"\"\"\n Tests CRUD for testplan model.\n \"\"\"\n import json\n\n def create_testplan():\n self.login(admin_username, admin_password)\n body = json.dumps({\"name\": \"CRUD test for testplan_rule\"})\n response = self.client.post(path=api_url + \"/testplan/\",\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n self.assertIn(\"location\", response._headers)\n in_json = json.loads(response.content)\n self.assertIn(\"id\", in_json)\n self.testplan_id = in_json['id']\n\n def delete_testplan():\n self.login(admin_username, admin_password)\n response = self.client.delete(path=api_url + \"/testplan/\" + self.testplan_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n def create():\n body = json.dumps({\n 'ruleType': 'request',\n 'enabled': True,\n 'name': 'test_rule_1',\n 'filter': {\n 'httpProtocol': 'HTTP/1.1',\n 'method': 'GET',\n 'headers': [\n {'key': 'foo'},\n {'key': 'fizz', 'value': 'buzz'},\n ],\n },\n 'action': {\n 'type': 'modify',\n 'method': 'PUT',\n 'url': 'www.newurl.com/foo/bar',\n 'setHeaders': [\n {\n 'key': 'zaphod', 'value': 'beeblebrox',\n },\n ],\n 'deleteHeaders': [\n {\n 'key': 'foo',\n },\n ],\n }\n })\n self.login(admin_username, admin_password)\n response = self.client.post(path=api_url + \"/testplan/\" + self.testplan_id + \"/rule/\",\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n self.assertIn(\"location\", response._headers)\n in_json = json.loads(response.content)\n self.assertIn(\"id\", in_json)\n return in_json['id']\n\n def read(rule_id):\n self.login(admin_username, admin_password)\n response = self.client.get(path=api_url + \"/testplan/\" + self.testplan_id + \"/rule/\" + rule_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n def update(rule_id):\n body = json.dumps({\n 'ruleType': 'request',\n 'enabled': True,\n 'name': 'test_rule_4',\n 'filter': {\n 'httpProtocol': 'HTTP/1.1',\n 'method': 'GET',\n 'headers': [\n {'key': 'folk hero'},\n {'key': 'instrument', 'value': 'violin'},\n ],\n },\n 'action': {\n 'type': 'newResponse',\n 'httpProtocol': 'CARRIERFLAMINGO/1.1',\n 'statusCode': 403,\n 'statusDescription': 'TOO FEATHERY',\n 'headers': [\n {\n 'key': 'User-Agent',\n 'value': 'Broken Looking Glass 1.9'\n },\n ],\n 'payload': 'The answer to life, the universe, and everything...is----NO CARRIER.',\n }\n\n })\n self.login(admin_username, admin_password)\n response = self.client.put(path=api_url + \"/testplan/\" + self.testplan_id + \"/rule/\" + rule_id,\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n def delete(rule_id):\n self.login(admin_username, admin_password)\n response = self.client.delete(path=api_url + \"/testplan/\" + self.testplan_id + \"/rule/\" + rule_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n print(\"Creating temporary testplan for use within %s\" % self.__class__)\n create_testplan()\n\n print(\"Testing CREATE #1 in %s\" % self.__class__)\n rule1_id = create()\n\n print(\"Testing CREATE #2 in %s\" % self.__class__)\n rule2_id = create()\n\n print(\"Testing READ in %s\" % self.__class__)\n read(rule1_id)\n\n print(\"Testing UPDATE in %s\" % self.__class__)\n update(rule1_id)\n\n print(\"Testing DELETE #1 in %s\" % self.__class__)\n delete(rule1_id)\n\n print(\"Testing DELETE #2 in %s\" % self.__class__)\n delete(rule2_id)\n\n print(\"Removing temporary testplan for use within %s\" % self.__class__)\n delete_testplan()", "metadata": "root.TestplanRuleViewTestCase.test_crud", "header": "['class', 'TestplanRuleViewTestCase', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 518 }, { "content": " def test_crud(self):\n \"\"\"\n Tests CRUD for recording model.\n \"\"\"\n import json\n\n def create():\n body = json.dumps({\n \"name\": \"CRUD test for recording\",\n })\n self.login(admin_username, admin_password)\n response = self.client.post(path=api_url + \"/recording/\",\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n\n self.assertEqual(response.status_code, 200)\n self.assertIn(\"location\", response._headers)\n in_json = json.loads(response.content)\n self.assertIn(\"id\", in_json)\n self.recording_id = in_json['id']\n\n def read():\n self.login(admin_username, admin_password)\n response = self.client.get(path=api_url + \"/recording/\" + self.recording_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n def update():\n body = json.dumps({\n \"name\": \"CRUD test for recording, updated\",\n \"description\": \"description...\",\n })\n self.login(admin_username, admin_password)\n response = self.client.put(path=api_url + \"/recording/\" + self.recording_id,\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n def delete():\n self.login(admin_username, admin_password)\n response = self.client.delete(path=api_url + \"/recording/\" + self.recording_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n print(\"Testing CREATE in %s\" % self.__class__)\n create()\n\n print(\"Testing READ in %s\" % self.__class__)\n read()\n\n print(\"Testing UPDATE in %s\" % self.__class__)\n update()\n\n print(\"Testing DELETE in %s\" % self.__class__)\n delete()", "metadata": "root.RecordingViewTestCase.test_crud", "header": "['class', 'RecordingViewTestCase', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 660 }, { "content": " def test_crud(self):\n \"\"\"\n Tests CRUD for qos model.\n \"\"\"\n import json\n\n def create():\n body = json.dumps({\n \"latency\": 100,\n \"name\": \"test QOS profile\",\n \"description\": \"unit test QOS profile\",\n \"jitter\": {\n \"min\": 10,\n \"max\": 50\n },\n \"trafficLoss\": 0.1\n })\n self.login(admin_username, admin_password)\n response = self.client.post(path=api_url + \"/qos/\",\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n\n self.assertEqual(response.status_code, 200)\n self.assertIn(\"location\", response._headers)\n in_json = json.loads(response.content)\n self.assertIn(\"id\", in_json)\n self.qos_id = in_json['id']\n\n def read():\n self.login(admin_username, admin_password)\n response = self.client.get(path=api_url + \"/qos/\" + self.qos_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n def update():\n body = json.dumps({\n \"name\": \"renamed unit test QOS profile\",\n \"latency\": 500\n })\n self.login(admin_username, admin_password)\n response = self.client.put(path=api_url + \"/qos/\" + self.qos_id,\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n def delete():\n self.login(admin_username, admin_password)\n response = self.client.delete(path=api_url + \"/qos/\" + self.qos_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n print(\"Testing CREATE in %s\" % self.__class__)\n create()\n\n print(\"Testing READ in %s\" % self.__class__)\n read()\n\n print(\"Testing UPDATE in %s\" % self.__class__)\n update()\n\n print(\"Testing DELETE in %s\" % self.__class__)\n delete()", "metadata": "root.QOSViewTestCase.test_crud", "header": "['class', 'QOSViewTestCase', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 723 }, { "content": " def test_crud(self):\n \"\"\"\n Tests CRUD for server overload model.\n \"\"\"\n import json\n\n def create():\n self.profile = {\n 'name': 'test profile',\n 'description': 'test description',\n 'function': {\n 'type': 'test type',\n 'expValue': 1,\n 'growthRate': 1,\n },\n 'response_triggers': [\n {\n 'fromLoad': 1,\n 'toLoad': 1,\n 'actions': [\n {\n 'type': 'response',\n 'value': '503',\n 'percentage': 0.3,\n },\n ],\n },\n ],\n }\n body = json.dumps(self.profile)\n self.login(admin_username, admin_password)\n response = self.client.post(path=api_url + \"/serveroverload/\",\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n\n self.assertEqual(response.status_code, 200)\n self.assertIn(\"location\", response._headers)\n in_json = json.loads(response.content)\n self.assertIn(\"id\", in_json)\n self.serveroverload_id = in_json['id']\n\n def read():\n self.login(admin_username, admin_password)\n response = self.client.get(path=api_url + \"/serveroverload/\" + self.serveroverload_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n def update():\n self.profile['name'] = 'updated name'\n body = json.dumps(self.profile)\n self.login(admin_username, admin_password)\n response = self.client.put(path=api_url + \"/serveroverload/\" + self.serveroverload_id,\n data=body,\n content_type=\"application/json\",\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n def delete():\n self.login(admin_username, admin_password)\n response = self.client.delete(path=api_url + \"/serveroverload/\" + self.serveroverload_id,\n HTTP_X_AUTH_TOKEN=self.x_auth_token)\n self.assertEqual(response.status_code, 200)\n\n print(\"Testing CREATE in %s\" % self.__class__)\n create()\n\n print(\"Testing READ in %s\" % self.__class__)\n read()\n\n print(\"Testing UPDATE in %s\" % self.__class__)\n update()\n\n print(\"Testing DELETE in %s\" % self.__class__)\n delete()", "metadata": "root.ServerOverloadViewTestCase.test_crud", "header": "['class', 'ServerOverloadViewTestCase', '(', 'APITestCase', ')', ':', '___EOS___']", "index": 794 } ]
[ { "span": "import json", "start_line": 53, "start_column": 8, "end_line": 53, "end_column": 19 }, { "span": "import json", "start_line": 169, "start_column": 8, "end_line": 169, "end_column": 19 }, { "span": "import json", "start_line": 289, "start_column": 8, "end_line": 289, "end_column": 19 }, { "span": "import json", "start_line": 411, "start_column": 8, "end_line": 411, "end_column": 19 }, { "span": "import json", "start_line": 522, "start_column": 8, "end_line": 522, "end_column": 19 }, { "span": "import json", "start_line": 664, "start_column": 8, "end_line": 664, "end_column": 19 }, { "span": "import json", "start_line": 727, "start_column": 8, "end_line": 727, "end_column": 19 }, { "span": "import json", "start_line": 798, "start_column": 8, "end_line": 798, "end_column": 19 } ]
[ { "span": "import json", "start_line": 1, "start_column": 0, "end_line": 1, "end_column": 11 } ]
1
true
[ "[CLS]_", "Module_", "is_", "imported_", "more_", "than_", "once_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "django_", "._", "test_", "import_", "Test", "Case_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "api", "\\u", "url_", "=_", "\"", "http", "://", "127", ".0", ".0", ".1", ":", "800", "0", "/", "api", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "admin", "\\u", "username_", "=_", "'", "admin", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "admin", "\\u", "password_", "=_", "'", "admin", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test", "1", "\\u", "username_", "=_", "'", "test", "1", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "test", "1", "\\u", "password_", "=_", "'", "test", "1", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "class_", "Sess", "ion", "View", "Test", "Case_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "crud", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "CRUD", " ", "for", " ", "session", " ", "model", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "create_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "CRUD", " ", "test", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "description", "'_", ":_", "'", "CRUD", " ", "test", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ups", "tream", "Host", "'_", ":_", "'", "127", ".0", ".0", ".1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ups", "tream", "Port", "'_", ":_", "8080_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "session", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "location", "\"_", ",_", "response_", "._", "\\u", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "\\u", "json_", "=_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "id", "\"_", ",_", "in", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "session", "\\u", "id_", "=_", "in", "\\u", "json_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "api", "\\u", "url_", "+_", "\"/", "session", "/\"_", "+_", "self_", "._", "session", "\\u", "id_", ",_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "login_", "(_", "'", "test", "1", "'_", ",_", "'", "test", "1", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "api", "\\u", "url_", "+_", "\"/", "session", "/\"_", "+_", "self_", "._", "session", "\\u", "id_", ",_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "403_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "'", "name", "'_", ":_", "'", "CRUD", " ", "test", " ", "update", "d", "'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "put_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "session", "/\"_", "+_", "self_", "._", "session", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "login_", "(_", "test", "1", "\\u", "username_", ",_", "test", "1", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "put_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "session", "/\"_", "+_", "self_", "._", "session", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "403_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "test", "1", "\\u", "username_", ",_", "test", "1", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "delete_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "session", "/\"_", "+_", "self_", "._", "session", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "403_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "delete_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "session", "/\"_", "+_", "self_", "._", "session", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "linked", "\\u", "crud", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Creat", "e", " ", "a", " ", "testp", "lan", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\"", "name", "\"_", ":_", "\"", "crud", " ", "testp", "lan", "\"_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "testp", "lan", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "testp", "lan", "\\u", "id_", "=_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Creat", "e", " ", "a", " ", "session", " ", "linked", " ", "to", " ", "testp", "lan", "_", "\\u\\u\\uNL\\u\\u\\u_", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "crud", " ", "session", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "description", "'_", ":_", "'", "crud", " ", "session", " ", "description", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "testp", "lan", "'_", ":_", "testp", "lan", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "ups", "tream", "Host", "\"_", ":_", "\"", "127", ".0", ".0", ".1", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "ups", "tream", "Port", "\"_", ":_", "8080_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "session", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "session", "\\u", "id_", "=_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Delete", " ", "session", " ", "and", " ", "testp", "lan", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "client_", "._", "delete_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "session", "/\"_", "+_", "session", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "client_", "._", "delete_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "testp", "lan", "/\"_", "+_", "testp", "lan", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "CREATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "create_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "READ", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "UPDATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "DELET", "E", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "CRUD", " ", "specific", " ", "to", " ", "a", " ", "linked", " ", "testp", "lan", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "linked", "\\u", "crud", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "plan", "View", "Test", "Case_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "crud", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "CRUD", " ", "for", " ", "testp", "lan", " ", "model", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "create_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "name", "\"_", ":_", "\"", "CRUD", " ", "test", " ", "with", " ", "rule", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "rule", "s", "\"_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rule", "Type", "'_", ":_", "'", "request", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "test\\u", "rule", "\\u", "3", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "enable", "d", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "filter", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "http", "Proto", "col", "'_", ":_", "'", "HTTP", "/", "1.1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "'", "GET", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "header", "s", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "key", "'_", ":_", "'", "foo", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "key", "'_", ":_", "'", "fi", "zz", "'_", ",_", "'", "value", "'_", ":_", "'", "buzz", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "action", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "modif", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "'", "PU", "T", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "'", "www", ".", "newu", "rl", ".", "com", "/", "foo", "/", "bar", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "set", "Head", "ers", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "zap", "hod", "'_", ",_", "'", "value", "'_", ":_", "'", "bee", "ble", "bro", "x", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "delete", "Head", "ers", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "foo", "'_", ",_", "\\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_", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "testp", "lan", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "location", "\"_", ",_", "response_", "._", "\\u", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "\\u", "json_", "=_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "id", "\"_", ",_", "in", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "testp", "lan", "\\u", "id_", "=_", "in", "\\u", "json_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "testp", "lan", "/\"_", "+_", "self_", "._", "testp", "lan", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "name", "\"_", ":_", "\"", "CRUD", " ", "test", " ", "with", " ", "rule", ",", " ", "name", " ", "update", "d", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "rule", "s", "\"_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rule", "Type", "'_", ":_", "'", "request", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "filter", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "http", "Proto", "col", "'_", ":_", "'", "HTTP", "/", "1.1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "'", "GET", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "header", "s", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "key", "'_", ":_", "'", "paul", " ", "bun", "yon", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "key", "'_", ":_", "'", "compan", "ion", "'_", ",_", "'", "value", "'_", ":_", "'", "blue", " ", "oxe", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "action", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "new", "Respons", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "http", "Proto", "col", "'_", ":_", "'", "CAR", "RIE", "RP", "IG", "EO", "N", "/", "1.1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "status", "Code", "'_", ":_", "403_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "status", "Descripti", "on", "'_", ":_", "'", "TOO", " ", "RID", "IC", "UL", "OUS", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "header", "s", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "User", "-", "Agent", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "value", "'_", ":_", "'", "Bro", "ken", " ", "Tele", "scope", " ", "1.9", "'_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "payload", "'_", ":_", "'", "The", " ", "answer", " ", "to", " ", "life", ",", " ", "the", " ", "univ", "erse", ",", " ", "and", " ", "every", "thing", "...", "is", " ", "42.", "'_", ",_", "\\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_", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "put_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "testp", "lan", "/\"_", "+_", "self_", "._", "testp", "lan", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "delete_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "testp", "lan", "/\"_", "+_", "self_", "._", "testp", "lan", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "CREATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "create_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "READ", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "UPDATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "DELET", "E", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "User", "View", "Test", "Case_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "crud", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "CRUD", " ", "for", " ", "user", " ", "model", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "create_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "username_", "=_", "\"", "crud", "test", "\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "user", "name", "\"_", ":_", "self_", "._", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "password", "\"_", ":_", "\"", "CRUD", " ", "test", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "email", "\"_", ":_", "\"", "test", "@", "test", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "user", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "location", "\"_", ",_", "response_", "._", "\\u", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "login_", "(_", "test", "1", "\\u", "username_", ",_", "test", "1", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "user", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "403_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "user", "/\"_", "+_", "self_", "._", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "user", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "login_", "(_", "test", "1", "\\u", "username_", ",_", "test", "1", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "user", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "403_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\"", "email", "\"_", ":_", "\"", "test", "1", "@", "test", "1", "\"_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "put_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "user", "/\"_", "+_", "self_", "._", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "login_", "(_", "test", "1", "\\u", "username_", ",_", "test", "1", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "put_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "user", "/\"_", "+_", "self_", "._", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "403_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "test", "1", "\\u", "username_", ",_", "test", "1", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "delete_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "user", "/\"_", "+_", "self_", "._", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "403_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "delete_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "user", "/\"_", "+_", "self_", "._", "username_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "CREATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "create_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "READ", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "UPDATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "DELET", "E", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Rule", "View", "Test", "Case_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "crud", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "CRUD", " ", "for", " ", "rule", " ", "model", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "create_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rule", "Type", "'_", ":_", "'", "request", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "test\\u", "rule", "\\u", "2", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "enable", "d", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "filter", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "http", "Proto", "col", "'_", ":_", "'", "HTTP", "/", "1.1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "'", "GET", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "header", "s", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "key", "'_", ":_", "'", "foo", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "key", "'_", ":_", "'", "fi", "zz", "'_", ",_", "'", "value", "'_", ":_", "'", "buzz", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "action", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "modif", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "'", "PU", "T", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "'", "www", ".", "newu", "rl", ".", "com", "/", "foo", "/", "bar", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "set", "Head", "ers", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "zap", "hod", "'_", ",_", "'", "value", "'_", ":_", "'", "bee", "ble", "bro", "x", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "delete", "Head", "ers", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "foo", "'_", ",_", "\\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_", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "rule", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "location", "\"_", ",_", "response_", "._", "\\u", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "\\u", "json_", "=_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "id", "\"_", ",_", "in", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "rule", "\\u", "id_", "=_", "in", "\\u", "json_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "rule", "/\"_", "+_", "self_", "._", "rule", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rule", "Type", "'_", ":_", "'", "request", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "enable", "d", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "test\\u", "rule", "\\u", "4", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "filter", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "http", "Proto", "col", "'_", ":_", "'", "HTTP", "/", "1.1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "'", "GET", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "header", "s", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "key", "'_", ":_", "'", "paul", " ", "bun", "yon", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "key", "'_", ":_", "'", "compan", "ion", "'_", ",_", "'", "value", "'_", ":_", "'", "blue", " ", "oxe", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "action", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "new", "Respons", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "http", "Proto", "col", "'_", ":_", "'", "CAR", "RIE", "RP", "IG", "EO", "N", "/", "1.1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "status", "Code", "'_", ":_", "403_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "status", "Descripti", "on", "'_", ":_", "'", "TOO", " ", "RID", "IC", "UL", "OUS", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "header", "s", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "User", "-", "Agent", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "value", "'_", ":_", "'", "Bro", "ken", " ", "Tele", "scope", " ", "1.9", "'_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "payload", "'_", ":_", "'", "The", " ", "answer", " ", "to", " ", "life", ",", " ", "the", " ", "univ", "erse", ",", " ", "and", " ", "every", "thing", "...", "is", " ", "42.", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "put_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "rule", "/\"_", "+_", "self_", "._", "rule", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "delete_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "rule", "/\"_", "+_", "self_", "._", "rule", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "CREATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "create_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "READ", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "UPDATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "DELET", "E", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "plan", "Rule", "View", "Test", "Case_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "crud", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "CRUD", " ", "for", " ", "testp", "lan", " ", "model", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "create", "\\u", "testp", "lan", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\"", "name", "\"_", ":_", "\"", "CRUD", " ", "test", " ", "for", " ", "testp", "lan", "\\u", "rule", "\"_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "testp", "lan", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "location", "\"_", ",_", "response_", "._", "\\u", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "\\u", "json_", "=_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "id", "\"_", ",_", "in", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "testp", "lan", "\\u", "id_", "=_", "in", "\\u", "json_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete", "\\u", "testp", "lan", "_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "delete_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "testp", "lan", "/\"_", "+_", "self_", "._", "testp", "lan", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "create_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rule", "Type", "'_", ":_", "'", "request", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "enable", "d", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "test\\u", "rule", "\\u", "1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "filter", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "http", "Proto", "col", "'_", ":_", "'", "HTTP", "/", "1.1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "'", "GET", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "header", "s", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "key", "'_", ":_", "'", "foo", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "key", "'_", ":_", "'", "fi", "zz", "'_", ",_", "'", "value", "'_", ":_", "'", "buzz", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "action", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "modif", "y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "'", "PU", "T", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "url", "'_", ":_", "'", "www", ".", "newu", "rl", ".", "com", "/", "foo", "/", "bar", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "set", "Head", "ers", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "zap", "hod", "'_", ",_", "'", "value", "'_", ":_", "'", "bee", "ble", "bro", "x", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "delete", "Head", "ers", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "foo", "'_", ",_", "\\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_", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "testp", "lan", "/\"_", "+_", "self_", "._", "testp", "lan", "\\u", "id_", "+_", "\"/", "rule", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "location", "\"_", ",_", "response_", "._", "\\u", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "\\u", "json_", "=_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "id", "\"_", ",_", "in", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "in", "\\u", "json_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", "rule", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "testp", "lan", "/\"_", "+_", "self_", "._", "testp", "lan", "\\u", "id_", "+_", "\"/", "rule", "/\"_", "+_", "rule", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update_", "(_", "rule", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "rule", "Type", "'_", ":_", "'", "request", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "enable", "d", "'_", ":_", "True_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "test\\u", "rule", "\\u", "4", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "filter", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "http", "Proto", "col", "'_", ":_", "'", "HTTP", "/", "1.1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "'", "GET", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "header", "s", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "key", "'_", ":_", "'", "fol", "k", " ", "hero", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "key", "'_", ":_", "'", "instrument", "'_", ",_", "'", "value", "'_", ":_", "'", "viol", "in", "'_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "action", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "new", "Respons", "e", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "http", "Proto", "col", "'_", ":_", "'", "CAR", "RIE", "RF", "LAM", "ING", "O", "/", "1.1", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "status", "Code", "'_", ":_", "403_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "status", "Descripti", "on", "'_", ":_", "'", "TOO", " ", "FE", "ATH", "ER", "Y", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "header", "s", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "key", "'_", ":_", "'", "User", "-", "Agent", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "value", "'_", ":_", "'", "Bro", "ken", " ", "Look", "ing", " ", "Gla", "ss", " ", "1.9", "'_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "payload", "'_", ":_", "'", "The", " ", "answer", " ", "to", " ", "life", ",", " ", "the", " ", "univ", "erse", ",", " ", "and", " ", "every", "thing", "...", "is", "----", "NO", " ", "CAR", "RIE", "R", ".'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "put_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "testp", "lan", "/\"_", "+_", "self_", "._", "testp", "lan", "\\u", "id_", "+_", "\"/", "rule", "/\"_", "+_", "rule", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", "rule", "\\u", "id_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "delete_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "testp", "lan", "/\"_", "+_", "self_", "._", "testp", "lan", "\\u", "id_", "+_", "\"/", "rule", "/\"_", "+_", "rule", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", "Creat", "ing", " ", "temporar", "y", " ", "testp", "lan", " ", "for", " ", "use", " ", "within", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "create", "\\u", "testp", "lan", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "CREATE", " ", "#", "1", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rule", "1", "\\u", "id_", "=_", "create_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "CREATE", " ", "#", "2", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rule", "2", "\\u", "id_", "=_", "create_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "READ", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read_", "(_", "rule", "1", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "UPDATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update_", "(_", "rule", "1", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "DELET", "E", " ", "#", "1", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "delete_", "(_", "rule", "1", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "DELET", "E", " ", "#", "2", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "delete_", "(_", "rule", "2", "\\u", "id_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Remo", "ving", " ", "temporar", "y", " ", "testp", "lan", " ", "for", " ", "use", " ", "within", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "delete", "\\u", "testp", "lan", "_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Record", "ing", "View", "Test", "Case_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "crud", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "CRUD", " ", "for", " ", "record", "ing", " ", "model", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "create_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "name", "\"_", ":_", "\"", "CRUD", " ", "test", " ", "for", " ", "record", "ing", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "record", "ing", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "location", "\"_", ",_", "response_", "._", "\\u", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "\\u", "json_", "=_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "id", "\"_", ",_", "in", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "record", "ing", "\\u", "id_", "=_", "in", "\\u", "json_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "record", "ing", "/\"_", "+_", "self_", "._", "record", "ing", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "name", "\"_", ":_", "\"", "CRUD", " ", "test", " ", "for", " ", "record", "ing", ",", " ", "update", "d", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "description", "\"_", ":_", "\"", "description", "...\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "put_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "record", "ing", "/\"_", "+_", "self_", "._", "record", "ing", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "delete_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "record", "ing", "/\"_", "+_", "self_", "._", "record", "ing", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "CREATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "create_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "READ", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "UPDATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "DELET", "E", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "QO", "SV", "iew", "Test", "Case_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "crud", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "CRUD", " ", "for", " ", "qo", "s", " ", "model", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "create_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "latenc", "y", "\"_", ":_", "100_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "name", "\"_", ":_", "\"", "test", " ", "QO", "S", " ", "profile", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "description", "\"_", ":_", "\"", "unit", " ", "test", " ", "QO", "S", " ", "profile", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "jitter", "\"_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "min", "\"_", ":_", "10_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "max", "\"_", ":_", "50_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "traffic", "Lo", "ss", "\"_", ":_", "0.1_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "qo", "s", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "location", "\"_", ",_", "response_", "._", "\\u", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "\\u", "json_", "=_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "id", "\"_", ",_", "in", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "qo", "s", "\\u", "id_", "=_", "in", "\\u", "json_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "qo", "s", "/\"_", "+_", "self_", "._", "qo", "s", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "body_", "=_", "json_", "._", "dumps_", "(_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "name", "\"_", ":_", "\"", "renamed", " ", "unit", " ", "test", " ", "QO", "S", " ", "profile", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\"", "latenc", "y", "\"_", ":_", "500_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "put_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "qo", "s", "/\"_", "+_", "self_", "._", "qo", "s", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "delete_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "qo", "s", "/\"_", "+_", "self_", "._", "qo", "s", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "CREATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "create_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "READ", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "UPDATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "DELET", "E", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "delete_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Server", "Over", "load", "View", "Test", "Case_", "(_", "API", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test\\u", "crud", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Test", "s", " ", "CRUD", " ", "for", " ", "server", " ", "overload", " ", "model", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "create_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "profile_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "name", "'_", ":_", "'", "test", " ", "profile", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "description", "'_", ":_", "'", "test", " ", "description", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "function", "'_", ":_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "test", " ", "type", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "exp", "Value", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "growth", "Rat", "e", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "response", "\\u", "trigger", "s", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "from", "Load", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "to", "Load", "'_", ":_", "1_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "action", "s", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "type", "'_", ":_", "'", "response", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "value", "'_", ":_", "'", "503", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "percentage", "'_", ":_", "0.3_", ",_", "\\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_", "body_", "=_", "json_", "._", "dumps_", "(_", "self_", "._", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "post_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "server", "overload", "/\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "location", "\"_", ",_", "response_", "._", "\\u", "headers_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "in", "\\u", "json_", "=_", "json_", "._", "loads_", "(_", "response_", "._", "content_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "In_", "(_", "\"", "id", "\"_", ",_", "in", "\\u", "json_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "server", "overload", "\\u", "id_", "=_", "in", "\\u", "json_", "[_", "'", "id", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "read_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "get_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "server", "overload", "/\"_", "+_", "self_", "._", "server", "overload", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "update_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "profile_", "[_", "'", "name", "'_", "]_", "=_", "'", "update", "d", " ", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "body_", "=_", "json_", "._", "dumps_", "(_", "self_", "._", "profile_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "put_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "server", "overload", "/\"_", "+_", "self_", "._", "server", "overload", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "data_", "=_", "body_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "content", "\\u", "type_", "=_", "\"", "applica", "tion", "/", "json", "\"_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "login_", "(_", "admin", "\\u", "username_", ",_", "admin", "\\u", "password_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "self_", "._", "client_", "._", "delete_", "(_", "path_", "=_", "api", "\\u", "url_", "+_", "\"/", "server", "overload", "/\"_", "+_", "self_", "._", "server", "overload", "\\u", "id_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "HTTP", "\\u", "X", "\\u", "AUTH", "\\u", "TOKEN_", "=_", "self_", "._", "x", "\\u", "auth", "\\u", "token_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "response_", "._", "status", "\\u", "code_", ",_", "200_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "CREATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "create_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "READ", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "read_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "(_", "\"", "Test", "ing", " ", "UPDATE", " ", "in", " ", "%", "s", "\"_", "%_", "self_", "._", "\\u\\u", "class\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "update_", "(_", ")_", "\\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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unnecessary 'else' clause in loop
floooh/fips/mod/config.py
[ { "content": "def get_toolchain(fips_dir, proj_dir, cfg) :\n \"\"\"get the toolchain path location for a config, this first checks\n for a 'cmake-toolchain' attribute, and if this does not exist, builds\n a xxx.toolchain.cmake file from the platform name (only for cross-\n compiling platforms). Toolchain files are searched in the\n following locations:\n - a fips-toolchains subdirectory in the project directory\n - a fips-toolchains subdirectory in all imported projects\n - finally in the cmake-toolchains subdirectory of the fips directory\n\n :param fips_dir: absolute path to fips\n :param plat: the target platform name\n :returns: path to toolchain file or None for non-cross-compiling\n \"\"\"\n\n # ignore native target platforms\n if 'platform' in cfg :\n if cfg['platform'] in native_platforms :\n return None\n else :\n log.error(\"config has no 'platform' attribute!'\")\n\n # build toolchain file name\n toolchain = None\n if 'cmake-toolchain' in cfg :\n toolchain = cfg['cmake-toolchain']\n else :\n toolchain = '{}.toolchain.cmake'.format(cfg['platform'])\n \n # look for toolchain file in current project directory\n toolchain_path = '{}/fips-toolchains/{}'.format(proj_dir, toolchain)\n if os.path.isfile(toolchain_path) :\n return toolchain_path\n else :\n # look for toolchain in all imported directories\n _, imported_projs = dep.get_all_imports_exports(fips_dir, proj_dir)\n for imported_proj_name in imported_projs :\n imported_proj_dir = util.get_project_dir(fips_dir, imported_proj_name)\n toolchain_path = '{}/fips-toolchains/{}'.format(imported_proj_dir, toolchain)\n if os.path.isfile(toolchain_path) :\n return toolchain_path\n else :\n # toolchain is not in current project or imported projects, \n # try the fips directory\n toolchain_path = '{}/cmake-toolchains/{}'.format(fips_dir, toolchain)\n if os.path.isfile(toolchain_path) :\n return toolchain_path\n # fallthrough: no toolchain file found\n return None", "metadata": "root.get_toolchain", "header": "['module', '___EOS___']", "index": 97 } ]
[ { "span": "for imported_proj_name in imported_projs :", "start_line": 133, "start_column": 8, "end_line": 133, "end_column": 50 } ]
[]
1
true
[ "[CLS]_", "Un", "necessar", "y_", "'", "else", "'_", "clause_", "in_", "loop_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "get", "\\u", "toolchain_", "(_", "fips", "\\u", "dir_", ",_", "proj", "\\u", "dir_", ",_", "cfg_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "get", " ", "the", " ", "toolchain", " ", "path", " ", "location", " ", "for", " ", "a", " ", "config", ",", " ", "this", " ", "first", " ", "checks", "\\", "10", ";", " ", " ", " ", " ", "for", " ", "a", " ", "'", "cma", "ke", "-", "toolchain", "'", " ", "attribute", ",", " ", "and", " ", "if", " ", "this", " ", "doe", "s", " ", "not", " ", "exist", ",", " ", "builds", "\\", "10", ";", " ", " ", " ", " ", "a", " ", "xxx", ".", "toolchain", ".", "cma", "ke", " ", "file", " ", "from", " ", "the", " ", "platform", " ", "name", " ", "(", "only", " ", "for", " ", "cross", "-", "\\", "10", ";", " ", " ", " ", " ", "compil", "ing", " ", "platform", "s", ").", " ", "Tool", "chain", " ", "files", " ", "are", " ", "searche", "d", " ", "in", " ", "the", "\\", "10", ";", " ", " ", " ", " ", "follow", "ing", " ", "location", "s", ":", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "a", " ", "fips", "-", "toolchain", "s", " ", "subdirectory", " ", "in", " ", "the", " ", "project", " ", "director", "y", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "a", " ", "fips", "-", "toolchain", "s", " ", "subdirectory", " ", "in", " ", "all", " ", "import", "ed", " ", "project", "s", "\\", "10", ";", " ", " ", " ", " ", "-", " ", "final", "ly", " ", "in", " ", "the", " ", "cma", "ke", "-", "toolchain", "s", " ", "subdirectory", " ", "of", " ", "the", " ", "fips", " ", "director", "y", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "fips", "\\u", "dir", ":", " ", " ", " ", " ", "abs", "olute", " ", "path", " ", "to", " ", "fips", "\\", "10", ";", " ", " ", " ", " ", ":", "param", " ", "plat", ":", " ", " ", " ", " ", "the", " ", "target", " ", "platform", " ", "name", "\\", "10", ";", " ", " ", " ", " ", ":", "return", "s", ":", " ", " ", " ", "path", " ", "to", " ", "toolchain", " ", "file", " ", "or", " ", "Non", "e", " ", "for", " ", "non", "-", "cross", "-", "compil", "ing", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "ignore", " ", "nativ", "e", " ", "target", " ", "platforms_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "'", "platform", "'_", "in_", "cfg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "cfg_", "[_", "'", "platform", "'_", "]_", "in_", "nativ", "e\\u", "platforms_", ":_", "\\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_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "log_", "._", "error_", "(_", "\"", "config", " ", "has", " ", "no", " ", "'", "platform", "'", " ", "attribute", "!'", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "build", " ", "toolchain", " ", "file", " ", "name_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "toolchain_", "=_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "'", "cma", "ke", "-", "toolchain", "'_", "in_", "cfg_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "toolchain_", "=_", "cfg_", "[_", "'", "cma", "ke", "-", "toolchain", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "toolchain_", "=_", "'{}", ".", "toolchain", ".", "cma", "ke", "'_", "._", "format_", "(_", "cfg_", "[_", "'", "platform", "'_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "look", " ", "for", " ", "toolchain", " ", "file", " ", "in", " ", "current", " ", "project", " ", "directory_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "toolchain", "\\u", "path_", "=_", "'{}/", "fips", "-", "toolchain", "s", "/{}'_", "._", "format_", "(_", "proj", "\\u", "dir_", ",_", "toolchain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "isfile_", "(_", "toolchain", "\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "toolchain", "\\u", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "look", " ", "for", " ", "toolchain", " ", "in", " ", "all", " ", "import", "ed", " ", "directories_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\\u_", ",_", "import", "ed", "\\u", "proj", "s_", "=_", "dep_", "._", "get", "\\u", "all", "\\u", "import", "s", "\\u", "exports_", "(_", "fips", "\\u", "dir_", ",_", "proj", "\\u", "dir_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "import", "ed", "\\u", "proj", "\\u", "name_", "in_", "import", "ed", "\\u", "proj", "s_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import", "ed", "\\u", "proj", "\\u", "dir_", "=_", "util_", "._", "get", "\\u", "project", "\\u", "dir_", "(_", "fips", "\\u", "dir_", ",_", "import", "ed", "\\u", "proj", "\\u", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "toolchain", "\\u", "path_", "=_", "'{}/", "fips", "-", "toolchain", "s", "/{}'_", "._", "format_", "(_", "import", "ed", "\\u", "proj", "\\u", "dir_", ",_", "toolchain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "isfile_", "(_", "toolchain", "\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "toolchain", "\\u", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "toolchain", " ", "is", " ", "not", " ", "in", " ", "current", " ", "project", " ", "or", " ", "import", "ed", " ", "project", "s", ",", " _", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "try", " ", "the", " ", "fips", " ", "directory_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "toolchain", "\\u", "path_", "=_", "'{}/", "cma", "ke", "-", "toolchain", "s", "/{}'_", "._", "format_", "(_", "fips", "\\u", "dir_", ",_", "toolchain_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "os_", "._", "path_", "._", "isfile_", "(_", "toolchain", "\\u", "path_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "toolchain", "\\u", "path_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "fall", "through", ":", " ", "no", " ", "toolchain", " ", "file", " ", "found_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "None_", "\\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 ]
Except block handles 'BaseException'
gdanezis/petlib/examples/tormedian.py
[ { "content": "from array import array\nfrom struct import pack\nfrom hashlib import sha512\nfrom copy import copy\nimport time\n\nimport math\n\nfrom petlib.ec import EcGroup, EcPt\nfrom petlib.bn import Bn\n\n# Make a cached decryption table\n\n_table, _n_table = _make_table()\n\n\n\n\n\n\n\n\n\n#### ------------- TESTS ------------------\n\nfrom random import gauss\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n\n import argparse\n\n parser = argparse.ArgumentParser(description='Test and time the Tor median statistics.')\n parser.add_argument('--time', action='store_true', help='Run timing tests')\n parser.add_argument('--quality', action='store_true', help='Run DP quality tests')\n parser.add_argument('--size', action='store_true', help='Run size tests')\n parser.add_argument('--lprof', action='store_true', help='Run the line profiler')\n parser.add_argument('--cprof', action='store_true', help='Run the c profiler')\n parser.add_argument('--data', action='store_true', help='Analysis on csv data')\n\n args = parser.parse_args()\n\n if args.data:\n # Read the csv file\n # Data currated from http://data.london.gov.uk/dataset/ward-profiles-and-atlas\n # Under UK Open Government Licence (http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/)\n import pandas as pd\n data = pd.read_csv('LondonData.csv' , thousands=\",\")\n # print data.shape\n\n\n num = -1\n d = []\n for i in range(3, data.shape[1]):\n try:\n vals = sorted([float(f) for f in data.iloc[0:num, i]])\n med_gt = vals[len(vals)/2]\n \n MX = 100\n vmin = min(vals) - 10\n vmax = max(vals) + 10\n xvals = [MX * (v - vmin) / (vmax - vmin) for v in vals]\n\n xmed = do_median(xvals, err=0.25, vrange=[0, MX], verbose=True)\n med1 = xmed * (vmax - vmin) / MX + vmin\n err1 = abs(med1 - med_gt) / float(med_gt)\n\n xmed = do_median(xvals, err=0.05, vrange=[0, MX], verbose=True)\n med2 = xmed * (vmax - vmin) / MX + vmin\n err2 = abs(med2 - med_gt) / float(med_gt)\n\n print data.columns.values[i], med1, err1* 100, med2, err2* 100, med_gt \n d += [(data.columns.values[i], [med1, err1* 100, med2, err2* 100, med_gt])]\n\n except:\n pass \n # print data.iloc[0:num, i]\n\n frame = pd.DataFrame.from_items(d, orient=\"index\", columns=[\"Median (0.25)\", \"Error (%)\", \"Median (0.05)\", \"Error (%)\", \"Truth\"])\n print frame.to_latex(float_format=(lambda x: u\"%1.1f\" % x))\n\n if args.time:\n test_median()\n\n if args.size:\n size_vs_error()\n \n if args.quality:\n no_test_DP_median()\n\n\n if args.cprof:\n import cProfile\n cProfile.run(\"test_median()\", sort=\"tottime\")\n \n\n if args.lprof:\n from line_profiler import LineProfiler\n\n profile = LineProfiler(test_median, CountSketchCt.estimate, CountSketchCt.aggregate,\n Ct.__add__, EcPt.__add__, EcPt.__neg__, EcPt.__copy__,)\n profile.run(\"test_median()\")\n profile.print_stats()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "except:", "start_line": 674, "start_column": 12, "end_line": 674, "end_column": 19 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "from_", "array_", "import_", "array_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "struct_", "import_", "pack_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "hashlib_", "import_", "sha512", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "copy_", "import_", "copy_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "time_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "math_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "pet", "lib_", "._", "ec_", "import_", "Ec", "Group_", ",_", "Ec", "Pt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pet", "lib_", "._", "bn_", "import_", "Bn", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "a", " ", "cache", "d", " ", "decrypt", "ion", " ", "table_", "\\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", "table_", ",_", "\\u", "n", "\\u", "table_", "=_", "\\u", "make", "\\u", "table_", "(_", ")_", "\\u\\u\\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_", "###", "#", " ", "-------------", " ", "TESTS", " ", "--------------", "----", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "from_", "random_", "import_", "gauss_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "argparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "parser_", "=_", "argparse_", "._", "Arg", "ument", "Parser_", "(_", "description_", "=_", "'", "Test", " ", "and", " ", "time", " ", "the", " ", "Tor", " ", "median", " ", "statistic", "s", ".'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "time", "'_", ",_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "help_", "=_", "'", "Run", " ", "tim", "ing", " ", "tests", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "quali", "ty", "'_", ",_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "help_", "=_", "'", "Run", " ", "DP", " ", "quali", "ty", " ", "tests", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "size", "'_", ",_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "help_", "=_", "'", "Run", " ", "size", " ", "tests", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "lpr", "of", "'_", ",_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "help_", "=_", "'", "Run", " ", "the", " ", "line", " ", "profiler", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "cpro", "f", "'_", ",_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "help_", "=_", "'", "Run", " ", "the", " ", "c", " ", "profiler", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "data", "'_", ",_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "help_", "=_", "'", "Analy", "sis", " ", "on", " ", "csv", " ", "data", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "parser_", "._", "parse", "\\u", "args_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "if_", "args_", "._", "data_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Read", " ", "the", " ", "csv", " ", "file_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Data", " ", "curr", "ated", " ", "from", " ", "http", "://", "data", ".", "lon", "don", ".", "gov", ".", "uk", "/", "dataset", "/", "ward", "-", "profile", "s", "-", "and", "-", "atlas", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Under", " ", "UK", " ", "Open", " ", "Gov", "ern", "ment", " ", "Licen", "ce", " ", "(", "http", "://", "www", ".", "national", "archives", ".", "gov", ".", "uk", "/", "doc", "/", "open", "-", "govern", "ment", "-", "licence", "/", "version", "/", "3", "/)", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "pandas_", "as_", "pd_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "data_", "=_", "pd_", "._", "read", "\\u", "csv_", "(_", "'", "Lon", "don", "Data", ".", "csv", "'_", ",_", "thousand", "s_", "=_", "\",\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "print", " ", "data", ".", "shape_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "num_", "=_", "-_", "1_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "3_", ",_", "data_", "._", "shape_", "[_", "1_", "]_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "vals_", "=_", "sorted_", "(_", "[_", "float_", "(_", "f_", ")_", "for_", "f_", "in_", "data_", "._", "iloc_", "[_", "0_", ":_", "num_", ",_", "i_", "]_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "med", "\\u", "gt_", "=_", "vals_", "[_", "len_", "(_", "vals_", ")_", "/_", "2_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "MX", "_", "=_", "100_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vmin_", "=_", "min_", "(_", "vals_", ")_", "-_", "10_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "vmax_", "=_", "max_", "(_", "vals_", ")_", "+_", "10_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "xval", "s_", "=_", "[_", "MX", "_", "*_", "(_", "v_", "-_", "vmin_", ")_", "/_", "(_", "vmax_", "-_", "vmin_", ")_", "for_", "v_", "in_", "vals_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "xm", "ed_", "=_", "do", "\\u", "median_", "(_", "xval", "s_", ",_", "err_", "=_", "0.25_", ",_", "vra", "nge_", "=_", "[_", "0_", ",_", "MX", "_", "]_", ",_", "verbose_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "med", "1_", "=_", "xm", "ed_", "*_", "(_", "vmax_", "-_", "vmin_", ")_", "/_", "MX", "_", "+_", "vmin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "err", "1_", "=_", "abs_", "(_", "med", "1_", "-_", "med", "\\u", "gt_", ")_", "/_", "float_", "(_", "med", "\\u", "gt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "xm", "ed_", "=_", "do", "\\u", "median_", "(_", "xval", "s_", ",_", "err_", "=_", "0.05_", ",_", "vra", "nge_", "=_", "[_", "0_", ",_", "MX", "_", "]_", ",_", "verbose_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "med", "2_", "=_", "xm", "ed_", "*_", "(_", "vmax_", "-_", "vmin_", ")_", "/_", "MX", "_", "+_", "vmin_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "err", "2_", "=_", "abs_", "(_", "med", "2_", "-_", "med", "\\u", "gt_", ")_", "/_", "float_", "(_", "med", "\\u", "gt_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "print_", "data_", "._", "columns_", "._", "values_", "[_", "i_", "]_", ",_", "med", "1_", ",_", "err", "1_", "*_", "100_", ",_", "med", "2_", ",_", "err", "2_", "*_", "100_", ",_", "med", "\\u", "gt_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "d_", "+=_", "[_", "(_", "data_", "._", "columns_", "._", "values_", "[_", "i_", "]_", ",_", "[_", "med", "1_", ",_", "err", "1_", "*_", "100_", ",_", "med", "2_", ",_", "err", "2_", "*_", "100_", ",_", "med", "\\u", "gt_", "]_", ")_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "pass_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "print", " ", "data", ".", "ilo", "c", "[", "0", ":", "num", ",", " ", "i", "]_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "frame_", "=_", "pd_", "._", "Data", "Frame_", "._", "from", "\\u", "items_", "(_", "d_", ",_", "orient_", "=_", "\"", "index", "\"_", ",_", "columns_", "=_", "[_", "\"", "Media", "n", " ", "(", "0.25", ")\"_", ",_", "\"", "Error", " ", "(%", ")\"_", ",_", "\"", "Media", "n", " ", "(", "0.05", ")\"_", ",_", "\"", "Error", " ", "(%", ")\"_", ",_", "\"", "Tru", "th", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "frame_", "._", "to", "\\u", "latex_", "(_", "float", "\\u", "format_", "=_", "(_", "lambda_", "x_", ":_", "u", "\"%", "1.1", "f", "\"_", "%_", "x_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "args_", "._", "time_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "test\\u", "median_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "args_", "._", "size_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "size", "\\u", "vs", "\\u", "error_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "args_", "._", "quality_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "no", "\\u", "test\\u", "DP", "\\u", "median_", "(_", ")_", "\\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_", "args_", "._", "cpro", "f_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "import_", "c", "Profile_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "c", "Profile_", "._", "run_", "(_", "\"", "test\\u", "median", "()\"_", ",_", "sort_", "=_", "\"", "tot", "time", "\"_", ")_", "\\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_", "args_", "._", "lpr", "of_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "line", "\\u", "profiler_", "import_", "Line", "Profiler", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "profile_", "=_", "Line", "Profiler", "_", "(_", "test\\u", "median_", ",_", "Count", "Sketch", "Ct", "_", "._", "estimate_", ",_", "Count", "Sketch", "Ct", "_", "._", "aggregate_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "Ct", "_", "._", "\\u\\u", "add\\u\\u_", ",_", "Ec", "Pt_", "._", "\\u\\u", "add\\u\\u_", ",_", "Ec", "Pt_", "._", "\\u\\u", "neg", "\\u\\u_", ",_", "Ec", "Pt_", "._", "\\u\\u", "copy", "\\u\\u_", ",_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "profile_", "._", "run_", "(_", "\"", "test\\u", "median", "()\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "profile_", "._", "print", "\\u", "stats_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Unused import
tienfuc/gdcmdtools/gdabout.py
[ { "content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport sys\nimport os\nfrom time import localtime, strftime\n\nimport argparse\nfrom argparse import RawTextHelpFormatter\n\nfrom gdcmdtools.about import GDAbout\n\nfrom gdcmdtools.base import BASE_INFO\nfrom gdcmdtools.base import DEBUG_LEVEL\nfrom gdcmdtools.perm import help_permission_text\n\nimport csv\nimport pprint\n\n__THIS_APP = 'gdabout'\n__THIS_DESCRIPTION = 'Tool to get metadata of file/folder on Google Drive'\n__THIS_VERSION = BASE_INFO[\"version\"]\n\nimport logging\nlogger = logging.getLogger(__THIS_APP)\n\n\n\nif __name__ == '__main__':\n arg_parser = argparse.ArgumentParser(\n description='%s v%s - %s - %s (%s)' %\n (__THIS_APP,\n __THIS_VERSION,\n __THIS_DESCRIPTION,\n BASE_INFO[\"app\"],\n BASE_INFO[\"description\"]),\n formatter_class=RawTextHelpFormatter)\n\n arg_parser.add_argument(\n '--no_print_id',\n action='store_true',\n help='set if you like not to print the folder id after folder being created')\n\n arg_parser.add_argument('--debug',\n choices=DEBUG_LEVEL,\n default=DEBUG_LEVEL[-1],\n help='define the debug level')\n\n args = arg_parser.parse_args()\n\n # set debug devel\n logger.setLevel(getattr(logging, args.debug.upper()))\n\n logger.debug(args)\n\n about = GDAbout(args)\n\n try:\n response = about.run()\n except:\n raise\n\n logger.debug(pprint.pformat(response))\n\n sys.exit(0)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "def test():\n assert True", "metadata": "root.test", "header": "['module', '___EOS___']", "index": 26 } ]
[ { "span": "import os", "start_line": 3, "start_column": 0, "end_line": 3, "end_column": 9 }, { "span": "from time import localtime, strftime", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 36 }, { "span": "from gdcmdtools.perm import help_permission_text", "start_line": 13, "start_column": 0, "end_line": 13, "end_column": 48 }, { "span": "import csv", "start_line": 15, "start_column": 0, "end_line": 15, "end_column": 10 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "#!", "/", "usr", "/", "bin", "/", "env", " ", "python_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "-*-", " ", "codi", "ng", ":", " ", "utf", "-", "8", " ", "-*-", "_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "sys_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "os_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "time_", "import_", "localtime_", ",_", "strftime_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "argparse_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "argparse_", "import_", "Ra", "w", "Text", "Help", "Formatter_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "gd", "cmd", "tools_", "._", "about_", "import_", "GDA", "bout", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "gd", "cmd", "tools_", "._", "base_", "import_", "BASE", "\\u", "INFO_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gd", "cmd", "tools_", "._", "base_", "import_", "DEBU", "G", "\\u", "LEVEL_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "gd", "cmd", "tools_", "._", "perm_", "import_", "help", "\\u", "permissi", "on", "\\u", "text_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "csv_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "import_", "pprint_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "THIS", "\\u", "APP_", "=_", "'", "gda", "bout", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "THIS", "\\u", "DESCRIPTION_", "=_", "'", "Tool", " ", "to", " ", "get", " ", "metadata", " ", "of", " ", "file", "/", "folder", " ", "on", " ", "Goo", "gle", " ", "Drive", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u", "THIS", "\\u", "VERSION_", "=_", "BASE", "\\u", "INFO_", "[_", "\"", "version", "\"_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "import_", "logging_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "logger_", "=_", "logging_", "._", "get", "Logger_", "(_", "\\u\\u", "THIS", "\\u", "APP_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\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 ", " _", "arg", "\\u", "parser_", "=_", "argparse_", "._", "Arg", "ument", "Parser_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "description_", "=_", "'%", "s", " ", "v", "%", "s", " ", "-", " ", "%", "s", " ", "-", " ", "%", "s", " ", "(%", "s", ")'_", "%_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "\\u\\u", "THIS", "\\u", "APP_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "THIS", "\\u", "VERSION_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u", "THIS", "\\u", "DESCRIPTION_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "BASE", "\\u", "INFO_", "[_", "\"", "app", "\"_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "BASE", "\\u", "INFO_", "[_", "\"", "description", "\"_", "]_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "formatter", "\\u", "class_", "=_", "Ra", "w", "Text", "Help", "Formatter_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "arg", "\\u", "parser_", "._", "add", "\\u", "argument_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "'--", "no", "\\u", "print", "\\u", "id", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "action_", "=_", "'", "store", "\\u", "true", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "set", " ", "if", " ", "you", " ", "like", " ", "not", " ", "to", " ", "print", " ", "the", " ", "folder", " ", "id", " ", "after", " ", "folder", " ", "bei", "ng", " ", "created", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "arg", "\\u", "parser_", "._", "add", "\\u", "argument_", "(_", "'--", "debug", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "choices_", "=_", "DEBU", "G", "\\u", "LEVEL_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "default_", "=_", "DEBU", "G", "\\u", "LEVEL_", "[_", "-_", "1_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "help_", "=_", "'", "defin", "e", " ", "the", " ", "debug", " ", "level", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "args_", "=_", "arg", "\\u", "parser_", "._", "parse", "\\u", "args_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "set", " ", "debug", " ", "deve", "l_", "\\u\\u\\uNL\\u\\u\\u_", "logger_", "._", "set", "Level_", "(_", "getattr_", "(_", "logging_", ",_", "args_", "._", "debug_", "._", "upper_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "logger_", "._", "debug_", "(_", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "about_", "=_", "GDA", "bout", "_", "(_", "args_", ")_", "\\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 ", " _", "response_", "=_", "about_", "._", "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 ", " _", "raise_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "logger_", "._", "debug_", "(_", "pprint_", "._", "pformat_", "(_", "response_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "sys_", "._", "exit_", "(_", "0_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "test_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "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, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Except block handles 'BaseException'
spantaleev/sijax-python/tests/sijax_tests.py
[ { "content": " def test_executing_regular_callbacks_works(self):\n\n calls_history = []\n call_args_history = []\n\n def event_before(obj_response):\n self.assertTrue(isinstance(obj_response, BaseResponse))\n calls_history.append(\"before\")\n\n obj_response.script(\"javascript here..\")\n\n def event_after(obj_response):\n self.assertTrue(isinstance(obj_response, BaseResponse))\n calls_history.append(\"after\")\n\n obj_response.css(\"#element\", \"backgroundColor\", \"red\")\n\n def callback_main(obj_response, arg1, arg2):\n self.assertTrue(isinstance(obj_response, BaseResponse))\n\n calls_history.append(\"main\")\n call_args_history.append(arg1)\n call_args_history.append(arg2)\n\n obj_response.alert(\"alert from main\")\n\n inst = Sijax()\n cls = inst.__class__\n inst.register_event(cls.EVENT_BEFORE_PROCESSING, event_before)\n inst.register_event(cls.EVENT_AFTER_PROCESSING, event_after)\n\n call_args = [\"arg1\", 15]\n response = inst.execute_callback(call_args, callback=callback_main)\n\n self.assertEqual([\"before\", \"main\", \"after\"], calls_history)\n self.assertEqual(call_args, call_args_history)\n\n # the response should be a string for regular functions\n # streaming functions return generators instead..\n self.assertTrue(isinstance(response, string_types))\n\n from sijax.helper import json\n try:\n commands = json.loads(response)\n except:\n self.fail(\"Invalid JSON response!\")\n else:\n self.assertTrue(isinstance(commands, list))\n\n commands_history = []\n for cmd_params in commands:\n self.assertTrue(isinstance(cmd_params, dict))\n self.assertTrue(\"type\" in cmd_params, \"Unknown command type!\")\n commands_history.append(cmd_params[\"type\"])\n\n self.assertEqual([\"script\", \"alert\", \"css\"], commands_history)", "metadata": "root.SijaxMainTestCase.test_executing_regular_callbacks_works", "header": "['class', 'SijaxMainTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 111 }, { "content": " def test_process_request_calls_invalid_request_event_for_invalid_requests(self):\n from sijax.helper import json\n\n # An invalid request is a request for a function that's not registered,\n # meaning the request is invalid as far as sijax is concerned\n inst = Sijax()\n cls = inst.__class__\n inst.set_data({cls.PARAM_REQUEST: \"my_func\", cls.PARAM_ARGS: '[\"arg1\", 12]'})\n self.assertTrue(inst.is_sijax_request)\n self.assertEqual(\"my_func\", inst.requested_function)\n self.assertEqual([\"arg1\", 12], inst.request_args)\n\n response = inst.process_request()\n self.assertTrue(isinstance(response, string_types))\n\n try:\n commands = json.loads(response)\n except:\n self.fail(\"Invalid JSON generated!\")\n else:\n self.assertTrue(isinstance(commands, list))\n\n # we expect the default \"Invalid request\" alert\n self.assertEqual(1, len(commands))\n command_data = commands.pop(0)\n self.assertTrue(\"type\" in command_data)\n self.assertEqual(\"alert\", command_data[\"type\"])", "metadata": "root.SijaxMainTestCase.test_process_request_calls_invalid_request_event_for_invalid_requests", "header": "['class', 'SijaxMainTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 208 }, { "content": " def test_process_request_calls_invalid_call_event_for_invalid_calls(self):\n from types import FunctionType\n from sijax.helper import json\n\n # An invalid call is a call to a function that appears valid.\n # The function is registered (known), but calling fails, because\n # the function expects another number of arguments\n\n call_history = []\n\n def my_callback(obj_response, arg1, arg2):\n call_history.append(\"call ok\")\n\n def my_callback_with_defaults(obj_response, arg1=138, arg2=15):\n call_history.append(\"defaults ok\")\n\n def my_callback_raising_TypeError(obj_response):\n raise TypeError('this should be re-raised by Sijax')\n\n def my_callback_raising_TypeError2(obj_response):\n def inner():\n raise TypeError('this should be re-raised by Sijax')\n inner()\n\n def invalid_call(obj_response, failed_callback):\n self.assertTrue(isinstance(failed_callback, FunctionType))\n call_history.append(\"invalid %s\" % failed_callback.__name__)\n\n inst = Sijax()\n cls = inst.__class__\n inst.register_callback(\"my_func\", my_callback)\n\n # Make a valid call that would succeed\n inst.set_data({cls.PARAM_REQUEST: \"my_func\", cls.PARAM_ARGS: '[\"arg1\", 12]'})\n self.assertTrue(inst.is_sijax_request)\n self.assertEqual(\"my_func\", inst.requested_function)\n self.assertEqual([\"arg1\", 12], inst.request_args)\n response = inst.process_request()\n self.assertTrue(isinstance(response, string_types))\n\n\n # Make a call with a wrong number of arguments, and a default\n # event handler for invalid calls\n inst.set_data({cls.PARAM_REQUEST: \"my_func\", cls.PARAM_ARGS: '[\"arg1\"]'})\n self.assertTrue(inst.is_sijax_request)\n self.assertEqual(\"my_func\", inst.requested_function)\n self.assertEqual([\"arg1\"], inst.request_args)\n response = inst.process_request()\n self.assertTrue(isinstance(response, string_types))\n try:\n commands = json.loads(response)\n except:\n self.fail(\"Invalid JSON generated!\")\n else:\n self.assertTrue(isinstance(commands, list))\n # we expect the default \"Action performed in a wrong way\" alert\n self.assertEqual(1, len(commands))\n command_data = commands.pop(0)\n self.assertTrue(\"type\" in command_data)\n self.assertEqual(\"alert\", command_data[\"type\"])\n\n # Make an invalid call with a custom event handler function\n inst.register_event(cls.EVENT_INVALID_CALL, invalid_call)\n inst.set_data({cls.PARAM_REQUEST: \"my_func\", cls.PARAM_ARGS: '[]'})\n self.assertEqual(\"my_func\", inst.requested_function)\n self.assertEqual([], inst.request_args)\n response = inst.process_request()\n self.assertTrue(isinstance(response, string_types))\n\n # let's see if calling works with default arguments\n inst.register_callback(\"my_func\", my_callback_with_defaults)\n response = inst.process_request()\n self.assertTrue(isinstance(response, string_types))\n\n # let's ensure that raising a TypeError from within a handler,\n # is not mistaken for an invalid call (EVENT_INVALID_CALL),\n # and re-raises the exception\n inst.register_callback(\"my_func\", my_callback_raising_TypeError)\n try:\n inst.process_request()\n except TypeError:\n call_history.append('TypeError')\n\n inst.register_callback(\"my_func\", my_callback_raising_TypeError2)\n try:\n inst.process_request()\n except TypeError:\n call_history.append('TypeError2')\n\n expected = ['call ok', 'invalid my_callback', 'defaults ok',\n 'TypeError', 'TypeError2']\n self.assertEqual(expected, call_history)", "metadata": "root.SijaxMainTestCase.test_process_request_calls_invalid_call_event_for_invalid_calls", "header": "['class', 'SijaxMainTestCase', '(', 'unittest', '.', 'TestCase', ')', ':', '___EOS___']", "index": 236 } ]
[ { "span": "except:", "start_line": 155, "start_column": 8, "end_line": 155, "end_column": 15 }, { "span": "except:", "start_line": 225, "start_column": 8, "end_line": 225, "end_column": 15 }, { "span": "except:", "start_line": 287, "start_column": 8, "end_line": 287, "end_column": 15 } ]
[]
1
true
[ "[CLS]_", "Except", "_", "block_", "handles_", "'", "Base", "Except", "ion", "'_", "[SEP]_", "class_", "Si", "jax", "Main", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "executi", "ng", "\\u", "regular", "\\u", "callback", "s", "\\u", "works_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "calls", "\\u", "history_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call", "\\u", "args", "\\u", "history_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "event", "\\u", "before_", "(_", "obj", "\\u", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "obj", "\\u", "response_", ",_", "Base", "Response_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "calls", "\\u", "history_", "._", "append_", "(_", "\"", "bef", "ore", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "obj", "\\u", "response_", "._", "script_", "(_", "\"", "javascript", " ", "here", "..\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "event", "\\u", "after_", "(_", "obj", "\\u", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "obj", "\\u", "response_", ",_", "Base", "Response_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "calls", "\\u", "history_", "._", "append_", "(_", "\"", "after", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "obj", "\\u", "response_", "._", "css_", "(_", "\"#", "element", "\"_", ",_", "\"", "background", "Color", "\"_", ",_", "\"", "red", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "callback", "\\u", "main_", "(_", "obj", "\\u", "response_", ",_", "arg1_", ",_", "arg2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "obj", "\\u", "response_", ",_", "Base", "Response_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "calls", "\\u", "history_", "._", "append_", "(_", "\"", "main", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call", "\\u", "args", "\\u", "history_", "._", "append_", "(_", "arg1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call", "\\u", "args", "\\u", "history_", "._", "append_", "(_", "arg2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "obj", "\\u", "response_", "._", "alert_", "(_", "\"", "alert", " ", "from", " ", "main", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "inst_", "=_", "Si", "jax_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cls_", "=_", "inst_", "._", "\\u\\u", "class\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inst_", "._", "register", "\\u", "event_", "(_", "cls_", "._", "EVENT", "\\u", "BEFORE", "\\u", "PROCESS", "ING_", ",_", "event", "\\u", "before_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inst_", "._", "register", "\\u", "event_", "(_", "cls_", "._", "EVENT", "\\u", "AFTER", "\\u", "PROCESS", "ING_", ",_", "event", "\\u", "after_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "call", "\\u", "args_", "=_", "[_", "\"", "arg", "1", "\"_", ",_", "15_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "inst_", "._", "execute", "\\u", "callback_", "(_", "call", "\\u", "args_", ",_", "callback_", "=_", "callback", "\\u", "main_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "[_", "\"", "bef", "ore", "\"_", ",_", "\"", "main", "\"_", ",_", "\"", "after", "\"_", "]_", ",_", "calls", "\\u", "history_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "call", "\\u", "args_", ",_", "call", "\\u", "args", "\\u", "history_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "response", " ", "shou", "ld", " ", "be", " ", "a", " ", "string", " ", "for", " ", "regular", " ", "functions_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "stream", "ing", " ", "function", "s", " ", "return", " ", "generat", "ors", " ", "inst", "ead", "..", "_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "response_", ",_", "string", "\\u", "types_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "si", "jax_", "._", "helper_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "commands_", "=_", "json_", "._", "loads_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "\"", "Inva", "lid", " ", "JSO", "N", " ", "response", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "commands_", ",_", "list_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "command", "s", "\\u", "history_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "cmd", "\\u", "params_", "in_", "commands_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "cmd", "\\u", "params_", ",_", "dict_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "type", "\"_", "in_", "cmd", "\\u", "params_", ",_", "\"", "Un", "know", "n", " ", "command", " ", "type", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command", "s", "\\u", "history_", "._", "append_", "(_", "cmd", "\\u", "params_", "[_", "\"", "type", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "[_", "\"", "script", "\"_", ",_", "\"", "alert", "\"_", ",_", "\"", "css", "\"_", "]_", ",_", "command", "s", "\\u", "history_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Si", "jax", "Main", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "process", "\\u", "request", "\\u", "calls", "\\u", "invalid", "\\u", "request", "\\u", "event", "\\u", "for", "\\u", "invalid", "\\u", "requests_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "si", "jax_", "._", "helper_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "An", " ", "invalid", " ", "request", " ", "is", " ", "a", " ", "request", " ", "for", " ", "a", " ", "function", " ", "tha", "t", "'", "s", " ", "not", " ", "register", "ed", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "meaning", " ", "the", " ", "request", " ", "is", " ", "invalid", " ", "as", " ", "far", " ", "as", " ", "si", "jax", " ", "is", " ", "concern", "ed_", "\\u\\u\\uNL\\u\\u\\u_", "inst_", "=_", "Si", "jax_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cls_", "=_", "inst_", "._", "\\u\\u", "class\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inst_", "._", "set\\u", "data_", "(_", "{_", "cls_", "._", "PARAM", "\\u", "REQUEST_", ":_", "\"", "my", "\\u", "func", "\"_", ",_", "cls_", "._", "PARAM", "\\u", "ARGS_", ":_", "'[", "\"", "arg", "1", "\",", " ", "1", "2", "]'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "inst_", "._", "is", "\\u", "si", "jax", "\\u", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"", "my", "\\u", "func", "\"_", ",_", "inst_", "._", "request", "ed", "\\u", "function_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "[_", "\"", "arg", "1", "\"_", ",_", "12_", "]_", ",_", "inst_", "._", "request", "\\u", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "response_", "=_", "inst_", "._", "process", "\\u", "request_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "response_", ",_", "string", "\\u", "types_", ")_", ")_", "\\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 ", " _", "commands_", "=_", "json_", "._", "loads_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "\"", "Inva", "lid", " ", "JSO", "N", " ", "generat", "ed", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "commands_", ",_", "list_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "expect", " ", "the", " ", "default", " ", "\"", "Inva", "lid", " ", "request", "\"", " ", "alert_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "1_", ",_", "len_", "(_", "commands_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command", "\\u", "data_", "=_", "commands_", "._", "pop_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "type", "\"_", "in_", "command", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"", "alert", "\"_", ",_", "command", "\\u", "data_", "[_", "\"", "type", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Si", "jax", "Main", "Test", "Case_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "process", "\\u", "request", "\\u", "calls", "\\u", "invalid", "\\u", "call", "\\u", "event", "\\u", "for", "\\u", "invalid", "\\u", "calls_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "types_", "import_", "Function", "Type_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "si", "jax_", "._", "helper_", "import_", "json_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "An", " ", "invalid", " ", "call", " ", "is", " ", "a", " ", "call", " ", "to", " ", "a", " ", "function", " ", "tha", "t", " ", "appear", "s", " ", "valid", "._", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "function", " ", "is", " ", "register", "ed", " ", "(", "know", "n", "),", " ", "but", " ", "calling", " ", "fail", "s", ",", " ", "bec", "aus", "e_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "function", " ", "expect", "s", " ", "anot", "her", " ", "number", " ", "of", " ", "arguments_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "call", "\\u", "history_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "def_", "my", "\\u", "callback_", "(_", "obj", "\\u", "response_", ",_", "arg1_", ",_", "arg2_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "call", "\\u", "history_", "._", "append_", "(_", "\"", "call", " ", "ok", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "my", "\\u", "callback", "\\u", "with", "\\u", "defaults_", "(_", "obj", "\\u", "response_", ",_", "arg1_", "=_", "138_", ",_", "arg2_", "=_", "15_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "call", "\\u", "history_", "._", "append_", "(_", "\"", "default", "s", " ", "ok", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "my", "\\u", "callback", "\\u", "rais", "ing", "\\u", "Type", "Error_", "(_", "obj", "\\u", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Type", "Error_", "(_", "'", "this", " ", "shou", "ld", " ", "be", " ", "re", "-", "raise", "d", " ", "by", " ", "Si", "jax", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "my", "\\u", "callback", "\\u", "rais", "ing", "\\u", "Type", "Error", "2_", "(_", "obj", "\\u", "response_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "inner_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "raise_", "Type", "Error_", "(_", "'", "this", " ", "shou", "ld", " ", "be", " ", "re", "-", "raise", "d", " ", "by", " ", "Si", "jax", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "inner_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "invalid", "\\u", "call_", "(_", "obj", "\\u", "response_", ",_", "fail", "ed", "\\u", "callback_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "fail", "ed", "\\u", "callback_", ",_", "Function", "Type_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "call", "\\u", "history_", "._", "append_", "(_", "\"", "invalid", " ", "%", "s", "\"_", "%_", "fail", "ed", "\\u", "callback_", "._", "\\u\\u", "name\\u\\u_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "inst_", "=_", "Si", "jax_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cls_", "=_", "inst_", "._", "\\u\\u", "class\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inst_", "._", "register", "\\u", "callback_", "(_", "\"", "my", "\\u", "func", "\"_", ",_", "my", "\\u", "callback_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "a", " ", "valid", " ", "call", " ", "tha", "t", " ", "wou", "ld", " ", "succeed_", "\\u\\u\\uNL\\u\\u\\u_", "inst_", "._", "set\\u", "data_", "(_", "{_", "cls_", "._", "PARAM", "\\u", "REQUEST_", ":_", "\"", "my", "\\u", "func", "\"_", ",_", "cls_", "._", "PARAM", "\\u", "ARGS_", ":_", "'[", "\"", "arg", "1", "\",", " ", "1", "2", "]'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "inst_", "._", "is", "\\u", "si", "jax", "\\u", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"", "my", "\\u", "func", "\"_", ",_", "inst_", "._", "request", "ed", "\\u", "function_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "[_", "\"", "arg", "1", "\"_", ",_", "12_", "]_", ",_", "inst_", "._", "request", "\\u", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "inst_", "._", "process", "\\u", "request_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "response_", ",_", "string", "\\u", "types_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "a", " ", "call", " ", "with", " ", "a", " ", "wrong", " ", "number", " ", "of", " ", "argu", "ment", "s", ",", " ", "and", " ", "a", " ", "default_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "event", " ", "handler", " ", "for", " ", "invalid", " ", "calls_", "\\u\\u\\uNL\\u\\u\\u_", "inst_", "._", "set\\u", "data_", "(_", "{_", "cls_", "._", "PARAM", "\\u", "REQUEST_", ":_", "\"", "my", "\\u", "func", "\"_", ",_", "cls_", "._", "PARAM", "\\u", "ARGS_", ":_", "'[", "\"", "arg", "1", "\"]'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "inst_", "._", "is", "\\u", "si", "jax", "\\u", "request_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"", "my", "\\u", "func", "\"_", ",_", "inst_", "._", "request", "ed", "\\u", "function_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "[_", "\"", "arg", "1", "\"_", "]_", ",_", "inst_", "._", "request", "\\u", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "inst_", "._", "process", "\\u", "request_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "response_", ",_", "string", "\\u", "types_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "commands_", "=_", "json_", "._", "loads_", "(_", "response_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "fail_", "(_", "\"", "Inva", "lid", " ", "JSO", "N", " ", "generat", "ed", "!\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "else_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "commands_", ",_", "list_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "we", " ", "expect", " ", "the", " ", "default", " ", "\"", "Action", " ", "perform", "ed", " ", "in", " ", "a", " ", "wrong", " ", "way", "\"", " ", "alert_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "1_", ",_", "len_", "(_", "commands_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "command", "\\u", "data_", "=_", "commands_", "._", "pop_", "(_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "\"", "type", "\"_", "in_", "command", "\\u", "data_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"", "alert", "\"_", ",_", "command", "\\u", "data_", "[_", "\"", "type", "\"_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Make", " ", "an", " ", "invalid", " ", "call", " ", "with", " ", "a", " ", "custom", " ", "event", " ", "handler", " ", "function_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "inst_", "._", "register", "\\u", "event_", "(_", "cls_", "._", "EVENT", "\\u", "INVALID", "\\u", "CALL_", ",_", "invalid", "\\u", "call_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "inst_", "._", "set\\u", "data_", "(_", "{_", "cls_", "._", "PARAM", "\\u", "REQUEST_", ":_", "\"", "my", "\\u", "func", "\"_", ",_", "cls_", "._", "PARAM", "\\u", "ARGS_", ":_", "'[]'_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "\"", "my", "\\u", "func", "\"_", ",_", "inst_", "._", "request", "ed", "\\u", "function_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "[_", "]_", ",_", "inst_", "._", "request", "\\u", "args_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "inst_", "._", "process", "\\u", "request_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "response_", ",_", "string", "\\u", "types_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "let", "'", "s", " ", "see", " ", "if", " ", "calling", " ", "works", " ", "with", " ", "default", " ", "arguments_", "\\u\\u\\uNL\\u\\u\\u_", "inst_", "._", "register", "\\u", "callback_", "(_", "\"", "my", "\\u", "func", "\"_", ",_", "my", "\\u", "callback", "\\u", "with", "\\u", "defaults_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "response_", "=_", "inst_", "._", "process", "\\u", "request_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "response_", ",_", "string", "\\u", "types_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "let", "'", "s", " ", "ensure", " ", "tha", "t", " ", "rais", "ing", " ", "a", " ", "Type", "Error", " ", "from", " ", "within", " ", "a", " ", "handler", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "is", " ", "not", " ", "mist", "ake", "n", " ", "for", " ", "an", " ", "invalid", " ", "call", " ", "(", "EVENT", "\\u", "INVALID", "\\u", "CALL", "),", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "re", "-", "raise", "s", " ", "the", " ", "exception_", "\\u\\u\\uNL\\u\\u\\u_", "inst_", "._", "register", "\\u", "callback_", "(_", "\"", "my", "\\u", "func", "\"_", ",_", "my", "\\u", "callback", "\\u", "rais", "ing", "\\u", "Type", "Error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "inst_", "._", "process", "\\u", "request_", "(_", ")_", "\\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 ", " _", "call", "\\u", "history_", "._", "append_", "(_", "'", "Type", "Error", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "inst_", "._", "register", "\\u", "callback_", "(_", "\"", "my", "\\u", "func", "\"_", ",_", "my", "\\u", "callback", "\\u", "rais", "ing", "\\u", "Type", "Error", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "inst_", "._", "process", "\\u", "request_", "(_", ")_", "\\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 ", " _", "call", "\\u", "history_", "._", "append_", "(_", "'", "Type", "Error", "2", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "expected_", "=_", "[_", "'", "call", " ", "ok", "'_", ",_", "'", "invalid", " ", "my", "\\u", "callback", "'_", ",_", "'", "default", "s", " ", "ok", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Type", "Error", "'_", ",_", "'", "Type", "Error", "2", "'_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "expected_", ",_", "call", "\\u", "history_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
`__eq__` not overridden when adding attributes
mozilla/addons-server/src/olympia/translations/models.py
[ { "content": "class Translation(ModelBase):\n \"\"\"\n Translation model.\n\n Use :class:`translations.fields.TranslatedField` instead of a plain foreign\n key to this model.\n \"\"\"\n\n autoid = models.AutoField(primary_key=True)\n id = models.IntegerField()\n locale = models.CharField(max_length=10)\n localized_string = models.TextField(null=True)\n localized_string_clean = models.TextField(null=True)\n\n objects = TranslationManager()\n\n class Meta:\n db_table = 'translations'\n unique_together = ('id', 'locale')\n\n\n\n\n\n\n\n\n delete.alters_data = True\n\n", "metadata": "root.Translation", "header": "['module', '___EOS___']", "index": 26 }, { "content": " def __unicode__(self):\n return self.localized_string and unicode(self.localized_string) or ''", "metadata": "root.Translation.__unicode__", "header": "['class', 'Translation', '(', 'ModelBase', ')', ':', '___EOS___']", "index": 46 }, { "content": " def __nonzero__(self):\n # __nonzero__ is called to evaluate an object in a boolean context. We\n # want Translations to be falsy if their string is empty.\n return (bool(self.localized_string) and\n bool(self.localized_string.strip()))", "metadata": "root.Translation.__nonzero__", "header": "['class', 'Translation', '(', 'ModelBase', ')', ':', '___EOS___']", "index": 49 }, { "content": " def __eq__(self, other):\n # Django implements an __eq__ that only checks pks. We need to check\n # the strings if we're dealing with existing vs. unsaved Translations.\n return self.__cmp__(other) == 0", "metadata": "root.Translation.__eq__", "header": "['class', 'Translation', '(', 'ModelBase', ')', ':', '___EOS___']", "index": 55 }, { "content": " def __cmp__(self, other):\n if hasattr(other, 'localized_string'):\n return cmp(self.localized_string, other.localized_string)\n else:\n return cmp(self.localized_string, other)", "metadata": "root.Translation.__cmp__", "header": "['class', 'Translation', '(', 'ModelBase', ')', ':', '___EOS___']", "index": 60 }, { "content": " def clean(self):\n if self.localized_string:\n self.localized_string = self.localized_string.strip()", "metadata": "root.Translation.clean", "header": "['class', 'Translation', '(', 'ModelBase', ')', ':', '___EOS___']", "index": 66 }, { "content": " def save(self, **kwargs):\n self.clean()\n return super(Translation, self).save(**kwargs)", "metadata": "root.Translation.save", "header": "['class', 'Translation', '(', 'ModelBase', ')', ':', '___EOS___']", "index": 70 }, { "content": " def delete(self, using=None):\n # FIXME: if the Translation is the one used as default/fallback,\n # then deleting it will mean the corresponding field on the related\n # model will stay empty even if there are translations in other\n # languages!\n cls = self.__class__\n using = using or router.db_for_write(cls, instance=self)\n # Look for all translations for the same string (id=self.id) except the\n # current one (autoid=self.autoid).\n qs = cls.objects.filter(id=self.id).exclude(autoid=self.autoid)\n if qs.using(using).exists():\n # If other Translations for the same id exist, we just need to\n # delete this one and *only* this one, without letting Django\n # collect dependencies (it'd remove the others, which we want to\n # keep).\n assert self._get_pk_val() is not None\n collector = Collector(using=using)\n collector.collect([self], collect_related=False)\n # In addition, because we have FK pointing to a non-unique column,\n # we need to force MySQL to ignore constraints because it's dumb\n # and would otherwise complain even if there are remaining rows\n # that matches the FK.\n with connections[using].constraint_checks_disabled():\n collector.delete()\n else:\n # If no other Translations with that id exist, then we should let\n # django behave normally. It should find the related model and set\n # the FKs to NULL.\n return super(Translation, self).delete(using=using)", "metadata": "root.Translation.delete", "header": "['class', 'Translation', '(', 'ModelBase', ')', ':', '___EOS___']", "index": 74 }, { "content": " @classmethod\n def _cache_key(cls, pk, db):\n # Hard-coding the class name here so that subclasses don't try to cache\n # themselves under something like \"o:translations.purifiedtranslation\".\n #\n # Like in ModelBase, we avoid putting the real db in the key because it\n # does us more harm than good.\n key_parts = ('o', 'translations.translation', pk, 'default')\n return ':'.join(map(encoding.smart_unicode, key_parts))", "metadata": "root.Translation._cache_key", "header": "['class', 'Translation', '(', 'ModelBase', ')', ':', '___EOS___']", "index": 106 }, { "content": " @classmethod\n def new(cls, string, locale, id=None):\n \"\"\"\n Jumps through all the right hoops to create a new translation.\n\n If ``id`` is not given a new id will be created using\n ``translations_seq``. Otherwise, the id will be used to add strings to\n an existing translation.\n\n To increment IDs we use a setting on MySQL. This is to support multiple\n database masters -- it's just crazy enough to work! See bug 756242.\n \"\"\"\n if id is None:\n # Get a sequence key for the new translation.\n cursor = connections['default'].cursor()\n cursor.execute(\"\"\"UPDATE translations_seq\n SET id=LAST_INSERT_ID(\n id + @@global.auto_increment_increment)\"\"\")\n\n # The sequence table should never be empty. But alas, if it is,\n # let's fix it.\n if not cursor.rowcount > 0:\n cursor.execute(\"\"\"INSERT INTO translations_seq (id)\n VALUES(LAST_INSERT_ID(\n id + @@global.auto_increment_increment)\n )\"\"\")\n\n cursor.execute('SELECT LAST_INSERT_ID()')\n id = cursor.fetchone()[0]\n\n # Update if one exists, otherwise create a new one.\n q = {'id': id, 'locale': locale}\n try:\n trans = cls.objects.get(**q)\n trans.localized_string = string\n except cls.DoesNotExist:\n trans = cls(localized_string=string, **q)\n\n return trans", "metadata": "root.Translation.new", "header": "['class', 'Translation', '(', 'ModelBase', ')', ':', '___EOS___']", "index": 116 }, { "content": "class PurifiedTranslation(Translation):\n \"\"\"Run the string through bleach to get a safe version.\"\"\"\n allowed_tags = [\n 'a',\n 'abbr',\n 'acronym',\n 'b',\n 'blockquote',\n 'code',\n 'em',\n 'i',\n 'li',\n 'ol',\n 'strong',\n 'ul',\n ]\n allowed_attributes = {\n 'a': ['href', 'title', 'rel'],\n 'abbr': ['title'],\n 'acronym': ['title'],\n }\n\n class Meta:\n proxy = True\n\n\n\n\n", "metadata": "root.PurifiedTranslation", "header": "['module', '___EOS___']", "index": 157 }, { "content": " def __unicode__(self):\n if not self.localized_string_clean:\n self.clean()\n return unicode(self.localized_string_clean)", "metadata": "root.PurifiedTranslation.__unicode__", "header": "['class', 'PurifiedTranslation', '(', 'Translation', ')', ':', '___EOS___']", "index": 182 }, { "content": " def __html__(self):\n return unicode(self)", "metadata": "root.PurifiedTranslation.__html__", "header": "['class', 'PurifiedTranslation', '(', 'Translation', ')', ':', '___EOS___']", "index": 187 }, { "content": " def __truncate__(self, length, killwords, end):\n return utils.truncate(unicode(self), length, killwords, end)", "metadata": "root.PurifiedTranslation.__truncate__", "header": "['class', 'PurifiedTranslation', '(', 'Translation', ')', ':', '___EOS___']", "index": 190 }, { "content": " def clean(self):\n from olympia.amo.utils import clean_nl\n super(PurifiedTranslation, self).clean()\n cleaned = self.clean_localized_string()\n self.localized_string_clean = clean_nl(cleaned).strip()", "metadata": "root.PurifiedTranslation.clean", "header": "['class', 'PurifiedTranslation', '(', 'Translation', ')', ':', '___EOS___']", "index": 193 }, { "content": " def clean_localized_string(self):\n # All links (text and markup) are normalized.\n linkified = urlresolvers.linkify_with_outgoing(self.localized_string)\n # Keep only the allowed tags and attributes, escape the rest.\n return bleach.clean(linkified, tags=self.allowed_tags,\n attributes=self.allowed_attributes)", "metadata": "root.PurifiedTranslation.clean_localized_string", "header": "['class', 'PurifiedTranslation', '(', 'Translation', ')', ':', '___EOS___']", "index": 199 } ]
[ { "span": "class PurifiedTranslation(Translation):", "start_line": 157, "start_column": 0, "end_line": 157, "end_column": 39 } ]
[ { "span": "def __eq__(self, other):", "start_line": 55, "start_column": 4, "end_line": 55, "end_column": 28 }, { "span": "self.localized_string_clean ", "start_line": 197, "start_column": 8, "end_line": 197, "end_column": 35 } ]
1
false
[ "[CLS]_", "`_", "\\u\\u", "eq\\u\\u_", "`_", "not_", "overrid", "den_", "when_", "addin", "g_", "attributes_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "class_", "Translation_", "(_", "Model", "Base_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Translat", "ion", " ", "model", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "Us", "e", " ", ":", "class", ":`", "translatio", "ns", ".", "fields", ".", "Translate", "d", "Field", "`", " ", "inst", "ead", " ", "of", " ", "a", " ", "plain", " ", "foreign", "\\", "10", ";", " ", " ", " ", " ", "key", " ", "to", " ", "this", " ", "model", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "autoi", "d_", "=_", "models_", "._", "Auto", "Field_", "(_", "primary", "\\u", "key_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "id_", "=_", "models_", "._", "Integer", "Field_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "locale_", "=_", "models_", "._", "Char", "Field_", "(_", "max", "\\u", "length_", "=_", "10_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "localized", "\\u", "string_", "=_", "models_", "._", "Text", "Field_", "(_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "localized", "\\u", "string", "\\u", "clean_", "=_", "models_", "._", "Text", "Field_", "(_", "null_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "objects_", "=_", "Translat", "ion", "Manager_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "db", "\\u", "table_", "=_", "'", "translatio", "ns", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "unique", "\\u", "together_", "=_", "(_", "'", "id", "'_", ",_", "'", "locale", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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_", "delete_", "._", "alter", "s", "\\u", "data_", "=_", "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_", "Translation_", "(_", "Model", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "unicode\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "localized", "\\u", "string_", "and_", "unicode_", "(_", "self_", "._", "localized", "\\u", "string_", ")_", "or_", "''_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Translation_", "(_", "Model", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "nonzero\\u", "\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "\\u\\u", "nonzero\\u", "\\u", " ", "is", " ", "call", "ed", " ", "to", " ", "evaluate", " ", "an", " ", "object", " ", "in", " ", "a", " ", "boolean", " ", "context", ".", " ", " ", "We", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "want", " ", "Translat", "ion", "s", " ", "to", " ", "be", " ", "fal", "sy", " ", "if", " ", "thei", "r", " ", "string", " ", "is", " ", "empty", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "(_", "bool_", "(_", "self_", "._", "localized", "\\u", "string_", ")_", "and_", "\\u\\u\\uNL\\u\\u\\u_", "bool_", "(_", "self_", "._", "localized", "\\u", "string_", "._", "strip_", "(_", ")_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Translation_", "(_", "Model", "Base_", ")_", ":_", "\\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_", "#", " ", "Dj", "ang", "o", " ", "implement", "s", " ", "an", " ", "\\u\\u", "eq", "\\u\\u", " ", "tha", "t", " ", "only", " ", "checks", " ", "pks", ".", " ", " ", "We", " ", "need", " ", "to", " ", "check_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "string", "s", " ", "if", " ", "we", "'", "re", " ", "deal", "ing", " ", "with", " ", "exist", "ing", " ", "vs", ".", " ", "unsa", "ved", " ", "Translat", "ion", "s", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "self_", "._", "\\u\\u", "cmp", "\\u\\u_", "(_", "other_", ")_", "==_", "0_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Translation_", "(_", "Model", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "cmp", "\\u\\u_", "(_", "self_", ",_", "other_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "hasattr_", "(_", "other_", ",_", "'", "localized", "\\u", "string", "'_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "cmp_", "(_", "self_", "._", "localized", "\\u", "string_", ",_", "other_", "._", "localized", "\\u", "string_", ")_", "\\u\\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_", "cmp_", "(_", "self_", "._", "localized", "\\u", "string_", ",_", "other_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Translation_", "(_", "Model", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "clean_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "self_", "._", "localized", "\\u", "string_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "localized", "\\u", "string_", "=_", "self_", "._", "localized", "\\u", "string_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Translation_", "(_", "Model", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "save_", "(_", "self_", ",_", "**_", "kwargs_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "clean_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "super_", "(_", "Translation_", ",_", "self_", ")_", "._", "save_", "(_", "**_", "kwargs_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Translation_", "(_", "Model", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", "self_", ",_", "using_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "FIX", "ME", ":", " ", "if", " ", "the", " ", "Translat", "ion", " ", "is", " ", "the", " ", "one", " ", "used", " ", "as", " ", "default", "/", "fall", "back", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "then", " ", "delet", "ing", " ", "it", " ", "will", " ", "mean", " ", "the", " ", "correspond", "ing", " ", "field", " ", "on", " ", "the", " ", "related_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "model", " ", "will", " ", "stay", " ", "empty", " ", "even", " ", "if", " ", "there", " ", "are", " ", "translatio", "ns", " ", "in", " ", "other_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "language", "s", "!", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cls_", "=_", "self_", "._", "\\u\\u", "class\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "using_", "=_", "using_", "or_", "router_", "._", "db", "\\u", "for", "\\u", "write_", "(_", "cls_", ",_", "instance_", "=_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Look", " ", "for", " ", "all", " ", "translatio", "ns", " ", "for", " ", "the", " ", "same", " ", "string", " ", "(", "id", "=", "self", ".", "id", ")", " ", "except", " ", "the_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "current", " ", "one", " ", "(", "autoi", "d", "=", "self", ".", "autoi", "d", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "qs_", "=_", "cls_", "._", "objects_", "._", "filter_", "(_", "id_", "=_", "self_", "._", "id_", ")_", "._", "exclude_", "(_", "autoi", "d_", "=_", "self_", "._", "autoi", "d_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "qs_", "._", "using_", "(_", "using_", ")_", "._", "exists_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "If", " ", "other", " ", "Translat", "ion", "s", " ", "for", " ", "the", " ", "same", " ", "id", " ", "exist", ",", " ", "we", " ", "just", " ", "need", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "delete", " ", "this", " ", "one", " ", "and", " ", "*", "only", "*", " ", "this", " ", "one", ",", " ", "with", "out", " ", "lett", "ing", " ", "Dj", "ang", "o_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "collect", " ", "dependen", "cies", " ", "(", "it", "'", "d", " ", "remove", " ", "the", " ", "other", "s", ",", " ", "whi", "ch", " ", "we", " ", "want", " ", "to_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "keep", ").", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "assert_", "self_", "._", "\\u", "get", "\\u", "pk", "\\u", "val_", "(_", ")_", "is_", "not_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "collector_", "=_", "Collector_", "(_", "using_", "=_", "using_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "collector_", "._", "collect_", "(_", "[_", "self_", "]_", ",_", "collect", "\\u", "related_", "=_", "False_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "In", " ", "addition", ",", " ", "bec", "aus", "e", " ", "we", " ", "have", " ", "FK", " ", "pointi", "ng", " ", "to", " ", "a", " ", "non", "-", "unique", " ", "column", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "we", " ", "need", " ", "to", " ", "force", " ", "My", "SQL", " ", "to", " ", "ignore", " ", "constraint", "s", " ", "bec", "aus", "e", " ", "it", "'", "s", " ", "dumb", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "and", " ", "wou", "ld", " ", "other", "wis", "e", " ", "compl", "ain", " ", "even", " ", "if", " ", "there", " ", "are", " ", "rema", "inin", "g", " ", "rows_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "tha", "t", " ", "matche", "s", " ", "the", " ", "FK", "._", "\\u\\u\\uNL\\u\\u\\u_", "with_", "connections_", "[_", "using_", "]_", "._", "constraint", "\\u", "checks", "\\u", "disabled_", "(_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "collector_", "._", "delete_", "(_", ")_", "\\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_", "#", " ", "If", " ", "no", " ", "other", " ", "Translat", "ion", "s", " ", "with", " ", "tha", "t", " ", "id", " ", "exist", ",", " ", "then", " ", "we", " ", "shou", "ld", " ", "let_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "django", " ", "behave", " ", "normal", "ly", ".", " ", "It", " ", "shou", "ld", " ", "find", " ", "the", " ", "relate", "d", " ", "model", " ", "and", " ", "set_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "the", " ", "FK", "s", " ", "to", " ", "NULL", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "super_", "(_", "Translation_", ",_", "self_", ")_", "._", "delete_", "(_", "using_", "=_", "using_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Translation_", "(_", "Model", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "\\u", "cache", "\\u", "key_", "(_", "cls_", ",_", "pk_", ",_", "db_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Hard", "-", "codi", "ng", " ", "the", " ", "class", " ", "name", " ", "here", " ", "so", " ", "tha", "t", " ", "subclasses", " ", "don", "'", "t", " ", "try", " ", "to", " ", "cache_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "them", "sel", "ves", " ", "under", " ", "somet", "hing", " ", "like", " ", "\"", "o", ":", "translatio", "ns", ".", "pur", "ified", "translatio", "n", "\".", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", "_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Lik", "e", " ", "in", " ", "Model", "Base", ",", " ", "we", " ", "avoid", " ", "put", "ting", " ", "the", " ", "real", " ", "db", " ", "in", " ", "the", " ", "key", " ", "bec", "aus", "e", " ", "it_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "doe", "s", " ", "us", " ", "more", " ", "harm", " ", "than", " ", "good", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "key", "\\u", "parts_", "=_", "(_", "'", "o", "'_", ",_", "'", "translatio", "ns", ".", "translatio", "n", "'_", ",_", "pk_", ",_", "'", "default", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "return_", "':'_", "._", "join_", "(_", "map_", "(_", "encoding_", "._", "smart", "\\u", "unicode_", ",_", "key", "\\u", "parts_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Translation_", "(_", "Model", "Base_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "@_", "classmethod_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "def_", "new_", "(_", "cls_", ",_", "string_", ",_", "locale_", ",_", "id_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "\\", "10", ";", " ", " ", " ", " ", "Jum", "ps", " ", "through", " ", "all", " ", "the", " ", "right", " ", "hoo", "ps", " ", "to", " ", "create", " ", "a", " ", "new", " ", "translatio", "n", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "If", " ", "``", "id", "``", " ", "is", " ", "not", " ", "give", "n", " ", "a", " ", "new", " ", "id", " ", "will", " ", "be", " ", "created", " ", "usi", "ng", "\\", "10", ";", " ", " ", " ", " ", "``", "translatio", "ns", "\\u", "seq", "``.", " ", " ", "Ot", "her", "wis", "e", ",", " ", "the", " ", "id", " ", "will", " ", "be", " ", "used", " ", "to", " ", "add", " ", "string", "s", " ", "to", "\\", "10", ";", " ", " ", " ", " ", "an", " ", "exist", "ing", " ", "translatio", "n", ".", "\\", "10", ";", "\\", "10", ";", " ", " ", " ", " ", "To", " ", "increment", " ", "ID", "s", " ", "we", " ", "use", " ", "a", " ", "setti", "ng", " ", "on", " ", "My", "SQL", ".", " ", "Thi", "s", " ", "is", " ", "to", " ", "support", " ", "multiple", "\\", "10", ";", " ", " ", " ", " ", "databa", "se", " ", "master", "s", " ", "--", " ", "it", "'", "s", " ", "just", " ", "cra", "zy", " ", "eno", "ugh", " ", "to", " ", "work", "!", " ", "See", " ", "bug", " ", "756", "242", ".", "\\", "10", ";", " ", " ", " ", " ", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "id_", "is_", "None_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Get", " ", "a", " ", "sequence", " ", "key", " ", "for", " ", "the", " ", "new", " ", "translatio", "n", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cursor_", "=_", "connections_", "[_", "'", "default", "'_", "]_", "._", "cursor_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cursor_", "._", "execute_", "(_", "\"\"\"", "UPDATE", " ", "translatio", "ns", "\\u", "seq", "\\", "10", ";", " ", " ", " ", " ", "SET", " ", "id", "=", "LAS", "T", "\\u", "INSERT", "\\u", "ID", "(", "\\", "10", ";", " ", " ", " ", " ", "id", " ", "+", " ", "@@", "global", ".", "auto", "\\u", "increment", "\\u", "increment", ")\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "The", " ", "sequence", " ", "table", " ", "shou", "ld", " ", "neve", "r", " ", "be", " ", "empty", ".", " ", "Bu", "t", " ", "ala", "s", ",", " ", "if", " ", "it", " ", "is", ",_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "let", "'", "s", " ", "fix", " ", "it", "._", "\\u\\u\\uNL\\u\\u\\u_", "if_", "not_", "cursor_", "._", "rowcount_", ">_", "0_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "cursor_", "._", "execute_", "(_", "\"\"\"", "INSERT", " ", "INT", "O", " ", "translatio", "ns", "\\u", "seq", " ", "(", "id", ")", "\\", "10", ";", " ", " ", " ", " ", "VALU", "ES", "(", "LAS", "T", "\\u", "INSERT", "\\u", "ID", "(", "\\", "10", ";", " ", " ", " ", " ", " ", " ", " ", "id", " ", "+", " ", "@@", "global", ".", "auto", "\\u", "increment", "\\u", "increment", ")", "\\", "10", ";", " ", " ", " ", " ", ")\"\"\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "cursor_", "._", "execute_", "(_", "'", "SELECT", " ", "LAS", "T", "\\u", "INSERT", "\\u", "ID", "()'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "id_", "=_", "cursor_", "._", "fetchone_", "(_", ")_", "[_", "0_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "Update", " ", "if", " ", "one", " ", "exist", "s", ",", " ", "other", "wis", "e", " ", "create", " ", "a", " ", "new", " ", "one", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "q_", "=_", "{_", "'", "id", "'_", ":_", "id_", ",_", "'", "locale", "'_", ":_", "locale_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "trans_", "=_", "cls_", "._", "objects_", "._", "get_", "(_", "**_", "q_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "trans_", "._", "localized", "\\u", "string_", "=_", "string_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "except_", "cls_", "._", "Do", "es", "Not", "Exist_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "trans_", "=_", "cls_", "(_", "localized", "\\u", "string_", "=_", "string_", ",_", "**_", "q_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "trans_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "module_", "\\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_", "Pur", "ified", "Translation_", "(_", "Translation_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "Run", " ", "the", " ", "string", " ", "through", " ", "ble", "ach", " ", "to", " ", "get", " ", "a", " ", "safe", " ", "version", ".\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "allow", "ed", "\\u", "tags_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "a", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "abb", "r", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "acronym", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "b", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "block", "quote", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "code", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "em", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "i", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "li", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ol", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "strong", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "ul", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "allow", "ed", "\\u", "attributes_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "a", "'_", ":_", "[_", "'", "href", "'_", ",_", "'", "title", "'_", ",_", "'", "rel", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "abb", "r", "'_", ":_", "[_", "'", "title", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "acronym", "'_", ":_", "[_", "'", "title", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Meta_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "proxy_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\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_", "Pur", "ified", "Translation_", "(_", "Translation_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "unicode\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "if_", "not_", "self_", "._", "localized", "\\u", "string", "\\u", "clean_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "clean_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "return_", "unicode_", "(_", "self_", "._", "localized", "\\u", "string", "\\u", "clean_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Pur", "ified", "Translation_", "(_", "Translation_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "html", "\\u\\u_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "unicode_", "(_", "self_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Pur", "ified", "Translation_", "(_", "Translation_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "\\u\\u", "truncat", "e\\u", "\\u_", "(_", "self_", ",_", "length_", ",_", "kill", "words_", ",_", "end_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "return_", "utils_", "._", "truncate_", "(_", "unicode_", "(_", "self_", ")_", ",_", "length_", ",_", "kill", "words_", ",_", "end_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Pur", "ified", "Translation_", "(_", "Translation_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "clean_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "oly", "mpi", "a_", "._", "amo", "_", "._", "utils_", "import_", "clean", "\\u", "nl_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "super_", "(_", "Pur", "ified", "Translation_", ",_", "self_", ")_", "._", "clean_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "cleaned_", "=_", "self_", "._", "clean", "\\u", "localized", "\\u", "string_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "localized", "\\u", "string", "\\u", "clean_", "=_", "clean", "\\u", "nl_", "(_", "cleaned_", ")_", "._", "strip_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Pur", "ified", "Translation_", "(_", "Translation_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "clean", "\\u", "localized", "\\u", "string_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "All", " ", "link", "s", " ", "(", "text", " ", "and", " ", "markup", ")", " ", "are", " ", "normali", "zed", "._", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "link", "ified", "_", "=_", "urlresolvers_", "._", "link", "if", "y", "\\u", "with", "\\u", "outgoing", "_", "(_", "self_", "._", "localized", "\\u", "string_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Keep", " ", "only", " ", "the", " ", "allow", "ed", " ", "tags", " ", "and", " ", "attribute", "s", ",", " ", "escape", " ", "the", " ", "rest", "._", "\\u\\u\\uNL\\u\\u\\u_", "return_", "ble", "ach", "_", "._", "clean_", "(_", "link", "ified", "_", ",_", "tags_", "=_", "self_", "._", "allow", "ed", "\\u", "tags_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "attributes_", "=_", "self_", "._", "allow", "ed", "\\u", "attributes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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 ]
Imprecise assert
GoogleCloudPlatform/gcloud-python/gcloud/storage/test_bucket.py
[ { "content": " def test_ctor(self):\n connection = _Connection()\n client = _Client(connection)\n bucket = _Bucket()\n iterator = self._makeOne(bucket, client=client)\n self.assertTrue(iterator.bucket is bucket)\n self.assertTrue(iterator.client is client)\n self.assertEqual(iterator.path, '%s/o' % bucket.path)\n self.assertEqual(iterator.page_number, 0)\n self.assertEqual(iterator.next_page_token, None)\n self.assertEqual(iterator.prefixes, set())", "metadata": "root.Test__BlobIterator.test_ctor", "header": "['class', 'Test__BlobIterator', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 26 }, { "content": " def test_ctor(self):\n NAME = 'name'\n properties = {'key': 'value'}\n bucket = self._makeOne(name=NAME, properties=properties)\n self.assertEqual(bucket.name, NAME)\n self.assertEqual(bucket._properties, properties)\n self.assertFalse(bucket._acl.loaded)\n self.assertTrue(bucket._acl.bucket is bucket)\n self.assertFalse(bucket._default_object_acl.loaded)\n self.assertTrue(bucket._default_object_acl.bucket is bucket)", "metadata": "root.Test_Bucket.test_ctor", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 98 }, { "content": " def test_blob(self):\n from gcloud.storage.blob import Blob\n\n BUCKET_NAME = 'BUCKET_NAME'\n BLOB_NAME = 'BLOB_NAME'\n CHUNK_SIZE = 1024 * 1024\n\n bucket = self._makeOne(name=BUCKET_NAME)\n blob = bucket.blob(BLOB_NAME, chunk_size=CHUNK_SIZE)\n self.assertTrue(isinstance(blob, Blob))\n self.assertTrue(blob.bucket is bucket)\n self.assertTrue(blob.client is bucket.client)\n self.assertEqual(blob.name, BLOB_NAME)\n self.assertEqual(blob.chunk_size, CHUNK_SIZE)", "metadata": "root.Test_Bucket.test_blob", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 109 }, { "content": " def test_acl_property(self):\n from gcloud.storage.acl import BucketACL\n bucket = self._makeOne()\n acl = bucket.acl\n self.assertTrue(isinstance(acl, BucketACL))\n self.assertTrue(acl is bucket._acl)", "metadata": "root.Test_Bucket.test_acl_property", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 231 }, { "content": " def test_default_object_acl_property(self):\n from gcloud.storage.acl import DefaultObjectACL\n bucket = self._makeOne()\n acl = bucket.default_object_acl\n self.assertTrue(isinstance(acl, DefaultObjectACL))\n self.assertTrue(acl is bucket._default_object_acl)", "metadata": "root.Test_Bucket.test_default_object_acl_property", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 238 }, { "content": " def test_get_blob_miss(self):\n NAME = 'name'\n NONESUCH = 'nonesuch'\n connection = _Connection()\n client = _Client(connection)\n bucket = self._makeOne(name=NAME)\n result = bucket.get_blob(NONESUCH, client=client)\n self.assertTrue(result is None)\n kw, = connection._requested\n self.assertEqual(kw['method'], 'GET')\n self.assertEqual(kw['path'], '/b/%s/o/%s' % (NAME, NONESUCH))", "metadata": "root.Test_Bucket.test_get_blob_miss", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 254 }, { "content": " def test_get_blob_hit(self):\n NAME = 'name'\n BLOB_NAME = 'blob-name'\n connection = _Connection({'name': BLOB_NAME})\n client = _Client(connection)\n bucket = self._makeOne(name=NAME)\n blob = bucket.get_blob(BLOB_NAME, client=client)\n self.assertTrue(blob.bucket is bucket)\n self.assertEqual(blob.name, BLOB_NAME)\n kw, = connection._requested\n self.assertEqual(kw['method'], 'GET')\n self.assertEqual(kw['path'], '/b/%s/o/%s' % (NAME, BLOB_NAME))", "metadata": "root.Test_Bucket.test_get_blob_hit", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 266 }, { "content": " def test_delete_hit(self):\n NAME = 'name'\n GET_BLOBS_RESP = {'items': []}\n connection = _Connection(GET_BLOBS_RESP)\n connection._delete_bucket = True\n client = _Client(connection)\n bucket = self._makeOne(client=client, name=NAME)\n result = bucket.delete(force=True)\n self.assertTrue(result is None)\n expected_cw = [{\n 'method': 'DELETE',\n 'path': bucket.path,\n '_target_object': None,\n }]\n self.assertEqual(connection._deleted_buckets, expected_cw)", "metadata": "root.Test_Bucket.test_delete_hit", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 357 }, { "content": " def test_delete_force_delete_blobs(self):\n NAME = 'name'\n BLOB_NAME1 = 'blob-name1'\n BLOB_NAME2 = 'blob-name2'\n GET_BLOBS_RESP = {\n 'items': [\n {'name': BLOB_NAME1},\n {'name': BLOB_NAME2},\n ],\n }\n DELETE_BLOB1_RESP = DELETE_BLOB2_RESP = {}\n connection = _Connection(GET_BLOBS_RESP, DELETE_BLOB1_RESP,\n DELETE_BLOB2_RESP)\n connection._delete_bucket = True\n client = _Client(connection)\n bucket = self._makeOne(client=client, name=NAME)\n result = bucket.delete(force=True)\n self.assertTrue(result is None)\n expected_cw = [{\n 'method': 'DELETE',\n 'path': bucket.path,\n '_target_object': None,\n }]\n self.assertEqual(connection._deleted_buckets, expected_cw)", "metadata": "root.Test_Bucket.test_delete_force_delete_blobs", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 373 }, { "content": " def test_delete_force_miss_blobs(self):\n NAME = 'name'\n BLOB_NAME = 'blob-name1'\n GET_BLOBS_RESP = {'items': [{'name': BLOB_NAME}]}\n # Note the connection does not have a response for the blob.\n connection = _Connection(GET_BLOBS_RESP)\n connection._delete_bucket = True\n client = _Client(connection)\n bucket = self._makeOne(client=client, name=NAME)\n result = bucket.delete(force=True)\n self.assertTrue(result is None)\n expected_cw = [{\n 'method': 'DELETE',\n 'path': bucket.path,\n '_target_object': None,\n }]\n self.assertEqual(connection._deleted_buckets, expected_cw)", "metadata": "root.Test_Bucket.test_delete_force_miss_blobs", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 398 }, { "content": " def test_delete_blob_hit(self):\n NAME = 'name'\n BLOB_NAME = 'blob-name'\n connection = _Connection({})\n client = _Client(connection)\n bucket = self._makeOne(client=client, name=NAME)\n result = bucket.delete_blob(BLOB_NAME)\n self.assertTrue(result is None)\n kw, = connection._requested\n self.assertEqual(kw['method'], 'DELETE')\n self.assertEqual(kw['path'], '/b/%s/o/%s' % (NAME, BLOB_NAME))", "metadata": "root.Test_Bucket.test_delete_blob_hit", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 448 }, { "content": " def test_copy_blobs_wo_name(self):\n SOURCE = 'source'\n DEST = 'dest'\n BLOB_NAME = 'blob-name'\n\n class _Blob(object):\n name = BLOB_NAME\n path = '/b/%s/o/%s' % (SOURCE, BLOB_NAME)\n\n connection = _Connection({})\n client = _Client(connection)\n source = self._makeOne(client=client, name=SOURCE)\n dest = self._makeOne(client=client, name=DEST)\n blob = _Blob()\n new_blob = source.copy_blob(blob, dest)\n self.assertTrue(new_blob.bucket is dest)\n self.assertEqual(new_blob.name, BLOB_NAME)\n kw, = connection._requested\n COPY_PATH = '/b/%s/o/%s/copyTo/b/%s/o/%s' % (SOURCE, BLOB_NAME,\n DEST, BLOB_NAME)\n self.assertEqual(kw['method'], 'POST')\n self.assertEqual(kw['path'], COPY_PATH)", "metadata": "root.Test_Bucket.test_copy_blobs_wo_name", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 513 }, { "content": " def test_copy_blobs_w_name(self):\n SOURCE = 'source'\n DEST = 'dest'\n BLOB_NAME = 'blob-name'\n NEW_NAME = 'new_name'\n\n class _Blob(object):\n name = BLOB_NAME\n path = '/b/%s/o/%s' % (SOURCE, BLOB_NAME)\n\n connection = _Connection({})\n client = _Client(connection)\n source = self._makeOne(client=client, name=SOURCE)\n dest = self._makeOne(client=client, name=DEST)\n blob = _Blob()\n new_blob = source.copy_blob(blob, dest, NEW_NAME)\n self.assertTrue(new_blob.bucket is dest)\n self.assertEqual(new_blob.name, NEW_NAME)\n kw, = connection._requested\n COPY_PATH = '/b/%s/o/%s/copyTo/b/%s/o/%s' % (SOURCE, BLOB_NAME,\n DEST, NEW_NAME)\n self.assertEqual(kw['method'], 'POST')\n self.assertEqual(kw['path'], COPY_PATH)", "metadata": "root.Test_Bucket.test_copy_blobs_w_name", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 536 }, { "content": " def test_rename_blob(self):\n BUCKET_NAME = 'BUCKET_NAME'\n BLOB_NAME = 'blob-name'\n NEW_BLOB_NAME = 'new-blob-name'\n\n DATA = {'name': NEW_BLOB_NAME}\n connection = _Connection(DATA)\n client = _Client(connection)\n bucket = self._makeOne(client=client, name=BUCKET_NAME)\n\n class _Blob(object):\n\n def __init__(self, name, bucket_name):\n self.name = name\n self.path = '/b/%s/o/%s' % (bucket_name, name)\n self._deleted = []\n\n def delete(self, client=None):\n self._deleted.append(client)\n\n blob = _Blob(BLOB_NAME, BUCKET_NAME)\n renamed_blob = bucket.rename_blob(blob, NEW_BLOB_NAME, client=client)\n self.assertTrue(renamed_blob.bucket is bucket)\n self.assertEqual(renamed_blob.name, NEW_BLOB_NAME)\n self.assertEqual(blob._deleted, [client])", "metadata": "root.Test_Bucket.test_rename_blob", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 560 }, { "content": " def test_location_setter(self):\n NAME = 'name'\n bucket = self._makeOne(name=NAME)\n self.assertEqual(bucket.location, None)\n bucket.location = 'AS'\n self.assertEqual(bucket.location, 'AS')\n self.assertTrue('location' in bucket._changes)", "metadata": "root.Test_Bucket.test_location_setter", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 604 }, { "content": " def test_lifecycle_rules_getter(self):\n NAME = 'name'\n LC_RULE = {'action': {'type': 'Delete'}, 'condition': {'age': 42}}\n rules = [LC_RULE]\n properties = {'lifecycle': {'rule': rules}}\n bucket = self._makeOne(name=NAME, properties=properties)\n self.assertEqual(bucket.lifecycle_rules, rules)\n # Make sure it's a copy\n self.assertFalse(bucket.lifecycle_rules is rules)", "metadata": "root.Test_Bucket.test_lifecycle_rules_getter", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 612 }, { "content": " def test_lifecycle_rules_setter(self):\n NAME = 'name'\n LC_RULE = {'action': {'type': 'Delete'}, 'condition': {'age': 42}}\n rules = [LC_RULE]\n bucket = self._makeOne(name=NAME)\n self.assertEqual(bucket.lifecycle_rules, [])\n bucket.lifecycle_rules = rules\n self.assertEqual(bucket.lifecycle_rules, rules)\n self.assertTrue('lifecycle' in bucket._changes)", "metadata": "root.Test_Bucket.test_lifecycle_rules_setter", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 622 }, { "content": " def test_cors_getter(self):\n NAME = 'name'\n CORS_ENTRY = {\n 'maxAgeSeconds': 1234,\n 'method': ['OPTIONS', 'GET'],\n 'origin': ['127.0.0.1'],\n 'responseHeader': ['Content-Type'],\n }\n properties = {'cors': [CORS_ENTRY, {}]}\n bucket = self._makeOne(name=NAME, properties=properties)\n entries = bucket.cors\n self.assertEqual(len(entries), 2)\n self.assertEqual(entries[0], CORS_ENTRY)\n self.assertEqual(entries[1], {})\n # Make sure it was a copy, not the same object.\n self.assertFalse(entries[0] is CORS_ENTRY)", "metadata": "root.Test_Bucket.test_cors_getter", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 632 }, { "content": " def test_cors_setter(self):\n NAME = 'name'\n CORS_ENTRY = {\n 'maxAgeSeconds': 1234,\n 'method': ['OPTIONS', 'GET'],\n 'origin': ['127.0.0.1'],\n 'responseHeader': ['Content-Type'],\n }\n bucket = self._makeOne(name=NAME)\n\n self.assertEqual(bucket.cors, [])\n bucket.cors = [CORS_ENTRY]\n self.assertEqual(bucket.cors, [CORS_ENTRY])\n self.assertTrue('cors' in bucket._changes)", "metadata": "root.Test_Bucket.test_cors_setter", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 649 }, { "content": " def test_enable_logging_defaults(self):\n NAME = 'name'\n LOG_BUCKET = 'logs'\n before = {'logging': None}\n bucket = self._makeOne(name=NAME, properties=before)\n self.assertTrue(bucket.get_logging() is None)\n bucket.enable_logging(LOG_BUCKET)\n info = bucket.get_logging()\n self.assertEqual(info['logBucket'], LOG_BUCKET)\n self.assertEqual(info['logObjectPrefix'], '')", "metadata": "root.Test_Bucket.test_enable_logging_defaults", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 679 }, { "content": " def test_enable_logging(self):\n NAME = 'name'\n LOG_BUCKET = 'logs'\n LOG_PFX = 'pfx'\n before = {'logging': None}\n bucket = self._makeOne(name=NAME, properties=before)\n self.assertTrue(bucket.get_logging() is None)\n bucket.enable_logging(LOG_BUCKET, LOG_PFX)\n info = bucket.get_logging()\n self.assertEqual(info['logBucket'], LOG_BUCKET)\n self.assertEqual(info['logObjectPrefix'], LOG_PFX)", "metadata": "root.Test_Bucket.test_enable_logging", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 690 }, { "content": " def test_disable_logging(self):\n NAME = 'name'\n before = {'logging': {'logBucket': 'logs', 'logObjectPrefix': 'pfx'}}\n bucket = self._makeOne(name=NAME, properties=before)\n self.assertTrue(bucket.get_logging() is not None)\n bucket.disable_logging()\n self.assertTrue(bucket.get_logging() is None)", "metadata": "root.Test_Bucket.test_disable_logging", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 702 }, { "content": " def test_storage_class_setter_invalid(self):\n NAME = 'name'\n bucket = self._makeOne(name=NAME)\n with self.assertRaises(ValueError):\n bucket.storage_class = 'BOGUS'\n self.assertFalse('storageClass' in bucket._changes)", "metadata": "root.Test_Bucket.test_storage_class_setter_invalid", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 762 }, { "content": " def test_storage_class_setter_STANDARD(self):\n NAME = 'name'\n bucket = self._makeOne(name=NAME)\n bucket.storage_class = 'STANDARD'\n self.assertEqual(bucket.storage_class, 'STANDARD')\n self.assertTrue('storageClass' in bucket._changes)", "metadata": "root.Test_Bucket.test_storage_class_setter_STANDARD", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 769 }, { "content": " def test_storage_class_setter_NEARLINE(self):\n NAME = 'name'\n bucket = self._makeOne(name=NAME)\n bucket.storage_class = 'NEARLINE'\n self.assertEqual(bucket.storage_class, 'NEARLINE')\n self.assertTrue('storageClass' in bucket._changes)", "metadata": "root.Test_Bucket.test_storage_class_setter_NEARLINE", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 776 }, { "content": " def test_storage_class_setter_DURABLE_REDUCED_AVAILABILITY(self):\n NAME = 'name'\n bucket = self._makeOne(name=NAME)\n bucket.storage_class = 'DURABLE_REDUCED_AVAILABILITY'\n self.assertEqual(bucket.storage_class, 'DURABLE_REDUCED_AVAILABILITY')\n self.assertTrue('storageClass' in bucket._changes)", "metadata": "root.Test_Bucket.test_storage_class_setter_DURABLE_REDUCED_AVAILABILITY", "header": "['class', 'Test_Bucket', '(', 'unittest2', '.', 'TestCase', ')', ':', '___EOS___']", "index": 783 } ]
[ { "span": "self.assertTrue(iterator.bucket is bucket)", "start_line": 31, "start_column": 8, "end_line": 31, "end_column": 50 }, { "span": "self.assertTrue(iterator.client is client)", "start_line": 32, "start_column": 8, "end_line": 32, "end_column": 50 }, { "span": "self.assertTrue(bucket._acl.bucket is bucket)", "start_line": 105, "start_column": 8, "end_line": 105, "end_column": 53 }, { "span": "self.assertTrue(bucket._default_object_acl.bucket is bucket)", "start_line": 107, "start_column": 8, "end_line": 107, "end_column": 68 }, { "span": "self.assertTrue(blob.bucket is bucket)", "start_line": 119, "start_column": 8, "end_line": 119, "end_column": 46 }, { "span": "self.assertTrue(blob.client is bucket.client)", "start_line": 120, "start_column": 8, "end_line": 120, "end_column": 53 }, { "span": "self.assertTrue(acl is bucket._acl)", "start_line": 236, "start_column": 8, "end_line": 236, "end_column": 43 }, { "span": "self.assertTrue(acl is bucket._default_object_acl)", "start_line": 243, "start_column": 8, "end_line": 243, "end_column": 58 }, { "span": "self.assertTrue(result is None)", "start_line": 261, "start_column": 8, "end_line": 261, "end_column": 39 }, { "span": "self.assertTrue(blob.bucket is bucket)", "start_line": 273, "start_column": 8, "end_line": 273, "end_column": 46 }, { "span": "self.assertTrue(result is None)", "start_line": 365, "start_column": 8, "end_line": 365, "end_column": 39 }, { "span": "self.assertTrue(result is None)", "start_line": 390, "start_column": 8, "end_line": 390, "end_column": 39 }, { "span": "self.assertTrue(result is None)", "start_line": 408, "start_column": 8, "end_line": 408, "end_column": 39 }, { "span": "self.assertTrue(result is None)", "start_line": 455, "start_column": 8, "end_line": 455, "end_column": 39 }, { "span": "self.assertTrue(new_blob.bucket is dest)", "start_line": 528, "start_column": 8, "end_line": 528, "end_column": 48 }, { "span": "self.assertTrue(new_blob.bucket is dest)", "start_line": 552, "start_column": 8, "end_line": 552, "end_column": 48 }, { "span": "self.assertTrue(renamed_blob.bucket is bucket)", "start_line": 582, "start_column": 8, "end_line": 582, "end_column": 54 }, { "span": "self.assertTrue('location' in bucket._changes)", "start_line": 610, "start_column": 8, "end_line": 610, "end_column": 54 }, { "span": "self.assertFalse(bucket.lifecycle_rules is rules)", "start_line": 620, "start_column": 8, "end_line": 620, "end_column": 57 }, { "span": "self.assertTrue('lifecycle' in bucket._changes)", "start_line": 630, "start_column": 8, "end_line": 630, "end_column": 55 }, { "span": "self.assertFalse(entries[0] is CORS_ENTRY)", "start_line": 647, "start_column": 8, "end_line": 647, "end_column": 50 }, { "span": "self.assertTrue('cors' in bucket._changes)", "start_line": 662, "start_column": 8, "end_line": 662, "end_column": 50 }, { "span": "self.assertTrue(bucket.get_logging() is None)", "start_line": 684, "start_column": 8, "end_line": 684, "end_column": 53 }, { "span": "self.assertTrue(bucket.get_logging() is None)", "start_line": 696, "start_column": 8, "end_line": 696, "end_column": 53 }, { "span": "self.assertTrue(bucket.get_logging() is not None)", "start_line": 706, "start_column": 8, "end_line": 706, "end_column": 57 }, { "span": "self.assertTrue(bucket.get_logging() is None)", "start_line": 708, "start_column": 8, "end_line": 708, "end_column": 53 }, { "span": "self.assertFalse('storageClass' in bucket._changes)", "start_line": 767, "start_column": 8, "end_line": 767, "end_column": 59 }, { "span": "self.assertTrue('storageClass' in bucket._changes)", "start_line": 774, "start_column": 8, "end_line": 774, "end_column": 58 }, { "span": "self.assertTrue('storageClass' in bucket._changes)", "start_line": 781, "start_column": 8, "end_line": 781, "end_column": 58 }, { "span": "self.assertTrue('storageClass' in bucket._changes)", "start_line": 788, "start_column": 8, "end_line": 788, "end_column": 58 } ]
[]
1
true
[ "[CLS]_", "Imp", "reci", "se_", "assert_", "[SEP]_", "class_", "Test", "\\u\\u", "Blo", "b", "Iterator_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ctor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "connection_", "=_", "\\u", "Connection_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u", "Client_", "(_", "connection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "\\u", "Bucket_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "iterator_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "bucket_", ",_", "client_", "=_", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "iterator_", "._", "bucket_", "is_", "bucket_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "iterator_", "._", "client_", "is_", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "iterator_", "._", "path_", ",_", "'%", "s", "/", "o", "'_", "%_", "bucket_", "._", "path_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "iterator_", "._", "page", "\\u", "number_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "iterator_", "._", "next", "\\u", "page", "\\u", "token_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "iterator_", "._", "prefixes_", ",_", "set_", "(_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "ctor_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "properties_", "=_", "{_", "'", "key", "'_", ":_", "'", "value", "'_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ",_", "properties_", "=_", "properties_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "bucket_", "._", "name_", ",_", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "bucket_", "._", "\\u", "properties_", ",_", "properties_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "bucket_", "._", "\\u", "acl_", "._", "loaded_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "bucket_", "._", "\\u", "acl_", "._", "bucket_", "is_", "bucket_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "bucket_", "._", "\\u", "default", "\\u", "object\\u", "acl_", "._", "loaded_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "bucket_", "._", "\\u", "default", "\\u", "object\\u", "acl_", "._", "bucket_", "is_", "bucket_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "blob_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "gcloud", "_", "._", "storage_", "._", "blob_", "import_", "Blob_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "BUCKET", "\\u", "NAME_", "=_", "'", "BUCKET", "\\u", "NAME", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "BLOB", "\\u", "NAME_", "=_", "'", "BLOB", "\\u", "NAME", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "CHUNK", "\\u", "SIZE_", "=_", "1024_", "*_", "1024_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "BUCKET", "\\u", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blob_", "=_", "bucket_", "._", "blob_", "(_", "BLOB", "\\u", "NAME_", ",_", "chunk", "\\u", "size_", "=_", "CHUNK", "\\u", "SIZE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "blob_", ",_", "Blob_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "blob_", "._", "bucket_", "is_", "bucket_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "blob_", "._", "client_", "is_", "bucket_", "._", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "blob_", "._", "name_", ",_", "BLOB", "\\u", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "blob_", "._", "chunk", "\\u", "size_", ",_", "CHUNK", "\\u", "SIZE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "acl", "\\u", "property_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "gcloud", "_", "._", "storage_", "._", "acl_", "import_", "Buck", "et", "ACL", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "acl_", "=_", "bucket_", "._", "acl_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "acl_", ",_", "Buck", "et", "ACL", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "acl_", "is_", "bucket_", "._", "\\u", "acl_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "default", "\\u", "object\\u", "acl", "\\u", "property_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "gcloud", "_", "._", "storage_", "._", "acl_", "import_", "Default", "Object", "ACL", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "acl_", "=_", "bucket_", "._", "default", "\\u", "object\\u", "acl_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "isinstance_", "(_", "acl_", ",_", "Default", "Object", "ACL", "_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "acl_", "is_", "bucket_", "._", "\\u", "default", "\\u", "object\\u", "acl_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "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", "blob", "\\u", "miss", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "NON", "ES", "UC", "H_", "=_", "'", "none", "suc", "h", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "connection_", "=_", "\\u", "Connection_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u", "Client_", "(_", "connection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "bucket_", "._", "get", "\\u", "blob_", "(_", "NON", "ES", "UC", "H_", ",_", "client_", "=_", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "result_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", ",_", "=_", "connection_", "._", "\\u", "requested_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "kw_", "[_", "'", "method", "'_", "]_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "kw_", "[_", "'", "path", "'_", "]_", ",_", "'/", "b", "/", "%", "s", "/", "o", "/", "%", "s", "'_", "%_", "(_", "NAME_", ",_", "NON", "ES", "UC", "H_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "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", "blob", "\\u", "hit_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "BLOB", "\\u", "NAME_", "=_", "'", "blob", "-", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "connection_", "=_", "\\u", "Connection_", "(_", "{_", "'", "name", "'_", ":_", "BLOB", "\\u", "NAME_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u", "Client_", "(_", "connection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blob_", "=_", "bucket_", "._", "get", "\\u", "blob_", "(_", "BLOB", "\\u", "NAME_", ",_", "client_", "=_", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "blob_", "._", "bucket_", "is_", "bucket_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "blob_", "._", "name_", ",_", "BLOB", "\\u", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", ",_", "=_", "connection_", "._", "\\u", "requested_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "kw_", "[_", "'", "method", "'_", "]_", ",_", "'", "GET", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "kw_", "[_", "'", "path", "'_", "]_", ",_", "'/", "b", "/", "%", "s", "/", "o", "/", "%", "s", "'_", "%_", "(_", "NAME_", ",_", "BLOB", "\\u", "NAME_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "hit_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "GET", "\\u", "BLOB", "S", "\\u", "RESP", "_", "=_", "{_", "'", "items", "'_", ":_", "[_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "connection_", "=_", "\\u", "Connection_", "(_", "GET", "\\u", "BLOB", "S", "\\u", "RESP", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "connection_", "._", "\\u", "delete", "\\u", "bucket_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u", "Client_", "(_", "connection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "client_", "=_", "client_", ",_", "name_", "=_", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "bucket_", "._", "delete_", "(_", "force_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "result_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "cw_", "=_", "[_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "'", "DELET", "E", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "path", "'_", ":_", "bucket_", "._", "path_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'\\u", "target", "\\u", "object", "'_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "connection_", "._", "\\u", "delete", "d\\u", "buckets_", ",_", "expected", "\\u", "cw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "force", "\\u", "delete", "\\u", "blobs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "BLOB", "\\u", "NAME", "1_", "=_", "'", "blob", "-", "name", "1", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "BLOB", "\\u", "NAME", "2_", "=_", "'", "blob", "-", "name2", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "GET", "\\u", "BLOB", "S", "\\u", "RESP", "_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "items", "'_", ":_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "name", "'_", ":_", "BLOB", "\\u", "NAME", "1_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "{_", "'", "name", "'_", ":_", "BLOB", "\\u", "NAME", "2_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "DELET", "E", "\\u", "BLOB", "1", "\\u", "RESP", "_", "=_", "DELET", "E", "\\u", "BLOB", "2", "\\u", "RESP", "_", "=_", "{_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "connection_", "=_", "\\u", "Connection_", "(_", "GET", "\\u", "BLOB", "S", "\\u", "RESP", "_", ",_", "DELET", "E", "\\u", "BLOB", "1", "\\u", "RESP", "_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "DELET", "E", "\\u", "BLOB", "2", "\\u", "RESP", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "connection_", "._", "\\u", "delete", "\\u", "bucket_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u", "Client_", "(_", "connection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "client_", "=_", "client_", ",_", "name_", "=_", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "bucket_", "._", "delete_", "(_", "force_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "result_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "cw_", "=_", "[_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "'", "DELET", "E", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "path", "'_", ":_", "bucket_", "._", "path_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'\\u", "target", "\\u", "object", "'_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "connection_", "._", "\\u", "delete", "d\\u", "buckets_", ",_", "expected", "\\u", "cw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "force", "\\u", "miss", "\\u", "blobs_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "BLOB", "\\u", "NAME_", "=_", "'", "blob", "-", "name", "1", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "GET", "\\u", "BLOB", "S", "\\u", "RESP", "_", "=_", "{_", "'", "items", "'_", ":_", "[_", "{_", "'", "name", "'_", ":_", "BLOB", "\\u", "NAME_", "}_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Not", "e", " ", "the", " ", "connecti", "on", " ", "doe", "s", " ", "not", " ", "have", " ", "a", " ", "response", " ", "for", " ", "the", " ", "blob", "._", "\\u\\u\\uNL\\u\\u\\u_", "connection_", "=_", "\\u", "Connection_", "(_", "GET", "\\u", "BLOB", "S", "\\u", "RESP", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "connection_", "._", "\\u", "delete", "\\u", "bucket_", "=_", "True_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u", "Client_", "(_", "connection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "client_", "=_", "client_", ",_", "name_", "=_", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "bucket_", "._", "delete_", "(_", "force_", "=_", "True_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "result_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "expected", "\\u", "cw_", "=_", "[_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "'", "DELET", "E", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "path", "'_", ":_", "bucket_", "._", "path_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'\\u", "target", "\\u", "object", "'_", ":_", "None_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "connection_", "._", "\\u", "delete", "d\\u", "buckets_", ",_", "expected", "\\u", "cw_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "delete", "\\u", "blob", "\\u", "hit_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "BLOB", "\\u", "NAME_", "=_", "'", "blob", "-", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "connection_", "=_", "\\u", "Connection_", "(_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u", "Client_", "(_", "connection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "client_", "=_", "client_", ",_", "name_", "=_", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "result_", "=_", "bucket_", "._", "delete", "\\u", "blob_", "(_", "BLOB", "\\u", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "result_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", ",_", "=_", "connection_", "._", "\\u", "requested_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "kw_", "[_", "'", "method", "'_", "]_", ",_", "'", "DELET", "E", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "kw_", "[_", "'", "path", "'_", "]_", ",_", "'/", "b", "/", "%", "s", "/", "o", "/", "%", "s", "'_", "%_", "(_", "NAME_", ",_", "BLOB", "\\u", "NAME_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "copy", "\\u", "blobs", "\\u", "wo", "\\u", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "SOURCE_", "=_", "'", "source", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "DEST", "_", "=_", "'", "dest", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "BLOB", "\\u", "NAME_", "=_", "'", "blob", "-", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "\\u", "Blob_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "BLOB", "\\u", "NAME_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "'/", "b", "/", "%", "s", "/", "o", "/", "%", "s", "'_", "%_", "(_", "SOURCE_", ",_", "BLOB", "\\u", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "connection_", "=_", "\\u", "Connection_", "(_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u", "Client_", "(_", "connection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "source_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "client_", "=_", "client_", ",_", "name_", "=_", "SOURCE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dest_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "client_", "=_", "client_", ",_", "name_", "=_", "DEST", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blob_", "=_", "\\u", "Blob_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "blob_", "=_", "source_", "._", "copy", "\\u", "blob_", "(_", "blob_", ",_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "new", "\\u", "blob_", "._", "bucket_", "is_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "new", "\\u", "blob_", "._", "name_", ",_", "BLOB", "\\u", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", ",_", "=_", "connection_", "._", "\\u", "requested_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "COPY", "\\u", "PATH_", "=_", "'/", "b", "/", "%", "s", "/", "o", "/", "%", "s", "/", "copy", "To", "/", "b", "/", "%", "s", "/", "o", "/", "%", "s", "'_", "%_", "(_", "SOURCE_", ",_", "BLOB", "\\u", "NAME_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "DEST", "_", ",_", "BLOB", "\\u", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "kw_", "[_", "'", "method", "'_", "]_", ",_", "'", "POST", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "kw_", "[_", "'", "path", "'_", "]_", ",_", "COPY", "\\u", "PATH_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "copy", "\\u", "blobs", "\\u", "w", "\\u", "name_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "SOURCE_", "=_", "'", "source", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "DEST", "_", "=_", "'", "dest", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "BLOB", "\\u", "NAME_", "=_", "'", "blob", "-", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "NEW", "\\u", "NAME_", "=_", "'", "new", "\\u", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "\\u", "Blob_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "name_", "=_", "BLOB", "\\u", "NAME_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "path_", "=_", "'/", "b", "/", "%", "s", "/", "o", "/", "%", "s", "'_", "%_", "(_", "SOURCE_", ",_", "BLOB", "\\u", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "connection_", "=_", "\\u", "Connection_", "(_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u", "Client_", "(_", "connection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "source_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "client_", "=_", "client_", ",_", "name_", "=_", "SOURCE_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "dest_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "client_", "=_", "client_", ",_", "name_", "=_", "DEST", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "blob_", "=_", "\\u", "Blob_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "new", "\\u", "blob_", "=_", "source_", "._", "copy", "\\u", "blob_", "(_", "blob_", ",_", "dest_", ",_", "NEW", "\\u", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "new", "\\u", "blob_", "._", "bucket_", "is_", "dest_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "new", "\\u", "blob_", "._", "name_", ",_", "NEW", "\\u", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "kw_", ",_", "=_", "connection_", "._", "\\u", "requested_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "COPY", "\\u", "PATH_", "=_", "'/", "b", "/", "%", "s", "/", "o", "/", "%", "s", "/", "copy", "To", "/", "b", "/", "%", "s", "/", "o", "/", "%", "s", "'_", "%_", "(_", "SOURCE_", ",_", "BLOB", "\\u", "NAME_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "DEST", "_", ",_", "NEW", "\\u", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "kw_", "[_", "'", "method", "'_", "]_", ",_", "'", "POST", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "kw_", "[_", "'", "path", "'_", "]_", ",_", "COPY", "\\u", "PATH_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "rename", "\\u", "blob_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "BUCKET", "\\u", "NAME_", "=_", "'", "BUCKET", "\\u", "NAME", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "BLOB", "\\u", "NAME_", "=_", "'", "blob", "-", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "NEW", "\\u", "BLOB", "\\u", "NAME_", "=_", "'", "new", "-", "blob", "-", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "DATA_", "=_", "{_", "'", "name", "'_", ":_", "NEW", "\\u", "BLOB", "\\u", "NAME_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "connection_", "=_", "\\u", "Connection_", "(_", "DATA_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "client_", "=_", "\\u", "Client_", "(_", "connection_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "client_", "=_", "client_", ",_", "name_", "=_", "BUCKET", "\\u", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "\\u", "Blob_", "(_", "object_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "\\u\\u", "init\\u\\u_", "(_", "self_", ",_", "name_", ",_", "bucket", "\\u", "name_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "name_", "=_", "name_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "path_", "=_", "'/", "b", "/", "%", "s", "/", "o", "/", "%", "s", "'_", "%_", "(_", "bucket", "\\u", "name_", ",_", "name_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "\\u", "deleted_", "=_", "[_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "delete_", "(_", "self_", ",_", "client_", "=_", "None_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "\\u", "deleted_", "._", "append_", "(_", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "blob_", "=_", "\\u", "Blob_", "(_", "BLOB", "\\u", "NAME_", ",_", "BUCKET", "\\u", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "renamed", "\\u", "blob_", "=_", "bucket_", "._", "rename", "\\u", "blob_", "(_", "blob_", ",_", "NEW", "\\u", "BLOB", "\\u", "NAME_", ",_", "client_", "=_", "client_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "renamed", "\\u", "blob_", "._", "bucket_", "is_", "bucket_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "renamed", "\\u", "blob_", "._", "name_", ",_", "NEW", "\\u", "BLOB", "\\u", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "blob_", "._", "\\u", "deleted_", ",_", "[_", "client_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "location", "\\u", "setter_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "bucket_", "._", "location_", ",_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "._", "location_", "=_", "'", "AS", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "bucket_", "._", "location_", ",_", "'", "AS", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "location", "'_", "in_", "bucket_", "._", "\\u", "changes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "lifecycle", "\\u", "rule", "s", "\\u", "getter_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "LC", "\\u", "RULE", "_", "=_", "{_", "'", "action", "'_", ":_", "{_", "'", "type", "'_", ":_", "'", "Delete", "'_", "}_", ",_", "'", "condition", "'_", ":_", "{_", "'", "age", "'_", ":_", "42_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rules_", "=_", "[_", "LC", "\\u", "RULE", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "properties_", "=_", "{_", "'", "lifecycle", "'_", ":_", "{_", "'", "rule", "'_", ":_", "rules_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ",_", "properties_", "=_", "properties_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "bucket_", "._", "lifecycle", "\\u", "rules_", ",_", "rules_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "it", "'", "s", " ", "a", " ", "copy_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "bucket_", "._", "lifecycle", "\\u", "rules_", "is_", "rules_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "lifecycle", "\\u", "rule", "s", "\\u", "setter_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "LC", "\\u", "RULE", "_", "=_", "{_", "'", "action", "'_", ":_", "{_", "'", "type", "'_", ":_", "'", "Delete", "'_", "}_", ",_", "'", "condition", "'_", ":_", "{_", "'", "age", "'_", ":_", "42_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "rules_", "=_", "[_", "LC", "\\u", "RULE", "_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "bucket_", "._", "lifecycle", "\\u", "rules_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "._", "lifecycle", "\\u", "rules_", "=_", "rules_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "bucket_", "._", "lifecycle", "\\u", "rules_", ",_", "rules_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "lifecycle", "'_", "in_", "bucket_", "._", "\\u", "changes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "cors", "\\u", "getter_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "CORS", "\\u", "ENTRY_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "max", "Age", "Second", "s", "'_", ":_", "1234_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "[_", "'", "OPTION", "S", "'_", ",_", "'", "GET", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "orig", "in", "'_", ":_", "[_", "'", "127", ".0", ".0", ".1", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "response", "Head", "er", "'_", ":_", "[_", "'", "Conten", "t", "-", "Type", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "properties_", "=_", "{_", "'", "cors", "'_", ":_", "[_", "CORS", "\\u", "ENTRY_", ",_", "{_", "}_", "]_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ",_", "properties_", "=_", "properties_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "entries_", "=_", "bucket_", "._", "cors", "_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "len_", "(_", "entries_", ")_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "entries_", "[_", "0_", "]_", ",_", "CORS", "\\u", "ENTRY_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "entries_", "[_", "1_", "]_", ",_", "{_", "}_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "Make", " ", "sure", " ", "it", " ", "was", " ", "a", " ", "copy", ",", " ", "not", " ", "the", " ", "same", " ", "object", "._", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "entries_", "[_", "0_", "]_", "is_", "CORS", "\\u", "ENTRY_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "cors", "\\u", "setter_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "CORS", "\\u", "ENTRY_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "max", "Age", "Second", "s", "'_", ":_", "1234_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "method", "'_", ":_", "[_", "'", "OPTION", "S", "'_", ",_", "'", "GET", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "orig", "in", "'_", ":_", "[_", "'", "127", ".0", ".0", ".1", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "response", "Head", "er", "'_", ":_", "[_", "'", "Conten", "t", "-", "Type", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "bucket_", "._", "cors", "_", ",_", "[_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "._", "cors", "_", "=_", "[_", "CORS", "\\u", "ENTRY_", "]_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "bucket_", "._", "cors", "_", ",_", "[_", "CORS", "\\u", "ENTRY_", "]_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "cors", "'_", "in_", "bucket_", "._", "\\u", "changes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "enable", "\\u", "logg", "ing", "\\u", "defaults_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "LOG", "\\u", "BUCKET", "_", "=_", "'", "logs", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "before_", "=_", "{_", "'", "logg", "ing", "'_", ":_", "None_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ",_", "properties_", "=_", "before_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "bucket_", "._", "get", "\\u", "logging_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "._", "enable", "\\u", "logging_", "(_", "LOG", "\\u", "BUCKET", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "info_", "=_", "bucket_", "._", "get", "\\u", "logging_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "info_", "[_", "'", "log", "Buck", "et", "'_", "]_", ",_", "LOG", "\\u", "BUCKET", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "info_", "[_", "'", "log", "Object", "Pref", "ix", "'_", "]_", ",_", "''_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "enable", "\\u", "logging_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "LOG", "\\u", "BUCKET", "_", "=_", "'", "logs", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "LOG", "\\u", "PF", "X_", "=_", "'", "pfx", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "before_", "=_", "{_", "'", "logg", "ing", "'_", ":_", "None_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ",_", "properties_", "=_", "before_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "bucket_", "._", "get", "\\u", "logging_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "._", "enable", "\\u", "logging_", "(_", "LOG", "\\u", "BUCKET", "_", ",_", "LOG", "\\u", "PF", "X_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "info_", "=_", "bucket_", "._", "get", "\\u", "logging_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "info_", "[_", "'", "log", "Buck", "et", "'_", "]_", ",_", "LOG", "\\u", "BUCKET", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "info_", "[_", "'", "log", "Object", "Pref", "ix", "'_", "]_", ",_", "LOG", "\\u", "PF", "X_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "disable", "\\u", "logging_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "before_", "=_", "{_", "'", "logg", "ing", "'_", ":_", "{_", "'", "log", "Buck", "et", "'_", ":_", "'", "logs", "'_", ",_", "'", "log", "Object", "Pref", "ix", "'_", ":_", "'", "pfx", "'_", "}_", "}_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ",_", "properties_", "=_", "before_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "bucket_", "._", "get", "\\u", "logging_", "(_", ")_", "is_", "not_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "._", "disable", "\\u", "logging_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "bucket_", "._", "get", "\\u", "logging_", "(_", ")_", "is_", "None_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "storage", "\\u", "class", "\\u", "sette", "r", "\\u", "invalid_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "with_", "self_", "._", "assert", "Raises_", "(_", "Value", "Error_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "bucket_", "._", "storage", "\\u", "class_", "=_", "'", "BO", "GU", "S", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "assert", "False_", "(_", "'", "storage", "Class", "'_", "in_", "bucket_", "._", "\\u", "changes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "storage", "\\u", "class", "\\u", "sette", "r", "\\u", "STANDARD", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "._", "storage", "\\u", "class_", "=_", "'", "STANDARD", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "bucket_", "._", "storage", "\\u", "class_", ",_", "'", "STANDARD", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "storage", "Class", "'_", "in_", "bucket_", "._", "\\u", "changes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "storage", "\\u", "class", "\\u", "sette", "r", "\\u", "NEA", "RL", "INE", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "._", "storage", "\\u", "class_", "=_", "'", "NEA", "RL", "INE", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "bucket_", "._", "storage", "\\u", "class_", ",_", "'", "NEA", "RL", "INE", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "storage", "Class", "'_", "in_", "bucket_", "._", "\\u", "changes_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "\\u", "Bucket_", "(_", "unittest2_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "storage", "\\u", "class", "\\u", "sette", "r", "\\u", "DU", "RA", "BL", "E", "\\u", "RED", "UCE", "D", "\\u", "AVA", "ILA", "BILITY", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "NAME_", "=_", "'", "name", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "=_", "self_", "._", "\\u", "make", "One_", "(_", "name_", "=_", "NAME_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "bucket_", "._", "storage", "\\u", "class_", "=_", "'", "DU", "RA", "BL", "E", "\\u", "RED", "UCE", "D", "\\u", "AVA", "ILA", "BILITY", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "bucket_", "._", "storage", "\\u", "class_", ",_", "'", "DU", "RA", "BL", "E", "\\u", "RED", "UCE", "D", "\\u", "AVA", "ILA", "BILITY", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "True_", "(_", "'", "storage", "Class", "'_", "in_", "bucket_", "._", "\\u",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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, 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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 ]
Testing equality to None
datalyze-solutions/pandas-qt/tests/test_CustomDTypeModel.py
[ { "content": " def test_headerData(self):\n model = ColumnDtypeModel()\n\n ret = model.headerData(0, Qt.Horizontal)\n assert ret == 'column'\n ret = model.headerData(1, Qt.Horizontal)\n assert ret == 'data type'\n ret = model.headerData(2, Qt.Horizontal)\n assert ret == None\n ret = model.headerData(0, Qt.Horizontal, Qt.EditRole)\n assert ret == None\n ret = model.headerData(0, Qt.Vertical)\n assert ret == None", "metadata": "root.TestColumnDType.test_headerData", "header": "['class', 'TestColumnDType', '(', 'object', ')', ':', '___EOS___']", "index": 45 }, { "content": " def test_data(self, dataframe):\n model = ColumnDtypeModel(dataFrame=dataframe)\n index = model.index(0, 0)\n\n # get data for display role\n ret = index.data()\n assert ret == 'Foo'\n\n # edit role does the same as display role\n ret = index.data(Qt.EditRole)\n assert ret == 'Foo'\n\n # datatype only defined for column 1\n ret = index.data(DTYPE_ROLE)\n assert ret == None\n\n # datatype column\n index = index.sibling(0, 1)\n ret = index.data(DTYPE_ROLE)\n assert ret == numpy.dtype(numpy.int64)\n # check translation / display text\n assert index.data() == 'integer (64 bit)' == SupportedDtypes.description(ret)\n\n # column not defined\n index = index.sibling(0, 2)\n assert index.data(DTYPE_ROLE) == None\n\n # invalid index\n index = QtCore.QModelIndex()\n assert model.data(index) == None\n\n index = model.index(2, 0)\n\n # get data for display role\n ret = index.data()\n assert ret == 'Spam'", "metadata": "root.TestColumnDType.test_data", "header": "['class', 'TestColumnDType', '(', 'object', ')', ':', '___EOS___']", "index": 59 } ]
[ { "span": "ret == None", "start_line": 53, "start_column": 15, "end_line": 53, "end_column": 26 }, { "span": "ret == None", "start_line": 55, "start_column": 15, "end_line": 55, "end_column": 26 }, { "span": "ret == None", "start_line": 57, "start_column": 15, "end_line": 57, "end_column": 26 }, { "span": "ret == None", "start_line": 73, "start_column": 15, "end_line": 73, "end_column": 26 }, { "span": "index.data(DTYPE_ROLE) == None", "start_line": 84, "start_column": 15, "end_line": 84, "end_column": 45 }, { "span": "model.data(index) == None", "start_line": 88, "start_column": 15, "end_line": 88, "end_column": 40 } ]
[]
1
true
[ "[CLS]_", "Test", "ing_", "equality", "_", "to_", "None_", "[SEP]_", "class_", "Test", "Colum", "n", "DT", "ype_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "header", "Data_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "model_", "=_", "Colum", "n", "Dt", "ype", "Model_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "ret_", "=_", "model_", "._", "header", "Data_", "(_", "0_", ",_", "Qt_", "._", "Horizontal_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "ret_", "==_", "'", "column", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "model_", "._", "header", "Data_", "(_", "1_", ",_", "Qt_", "._", "Horizontal_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "ret_", "==_", "'", "data", " ", "type", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "model_", "._", "header", "Data_", "(_", "2_", ",_", "Qt_", "._", "Horizontal_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "ret_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "model_", "._", "header", "Data_", "(_", "0_", ",_", "Qt_", "._", "Horizontal_", ",_", "Qt_", "._", "Edit", "Role_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "ret_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "model_", "._", "header", "Data_", "(_", "0_", ",_", "Qt_", "._", "Vertica", "l_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "ret_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Colum", "n", "DT", "ype_", "(_", "object_", ")_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "data_", "(_", "self_", ",_", "dataframe_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "model_", "=_", "Colum", "n", "Dt", "ype", "Model_", "(_", "data", "Frame_", "=_", "dataframe_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "index_", "=_", "model_", "._", "index_", "(_", "0_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "data", " ", "for", " ", "display", " ", "role_", "\\u\\u\\uNL\\u\\u\\u_", "ret_", "=_", "index_", "._", "data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "ret_", "==_", "'", "Foo", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "edit", " ", "role", " ", "doe", "s", " ", "the", " ", "same", " ", "as", " ", "display", " ", "role_", "\\u\\u\\uNL\\u\\u\\u_", "ret_", "=_", "index_", "._", "data_", "(_", "Qt_", "._", "Edit", "Role_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "ret_", "==_", "'", "Foo", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "datatype", " ", "only", " ", "defin", "ed", " ", "for", " ", "column", " ", "1_", "\\u\\u\\uNL\\u\\u\\u_", "ret_", "=_", "index_", "._", "data_", "(_", "DTY", "PE", "\\u", "ROLE", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "ret_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "datatype", " ", "column_", "\\u\\u\\uNL\\u\\u\\u_", "index_", "=_", "index_", "._", "sibling_", "(_", "0_", ",_", "1_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "ret_", "=_", "index_", "._", "data_", "(_", "DTY", "PE", "\\u", "ROLE", "_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "ret_", "==_", "numpy_", "._", "dtype_", "(_", "numpy_", "._", "int64_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "#", " ", "check", " ", "translatio", "n", " ", "/", " ", "display", " ", "text_", "\\u\\u\\uNL\\u\\u\\u_", "assert_", "index_", "._", "data_", "(_", ")_", "==_", "'", "integ", "er", " ", "(", "64", " ", "bit", ")'_", "==_", "Supp", "orte", "d", "Dt", "ypes_", "._", "description_", "(_", "ret_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "column", " ", "not", " ", "defined_", "\\u\\u\\uNL\\u\\u\\u_", "index_", "=_", "index_", "._", "sibling_", "(_", "0_", ",_", "2_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "index_", "._", "data_", "(_", "DTY", "PE", "\\u", "ROLE", "_", ")_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "invalid", " ", "index_", "\\u\\u\\uNL\\u\\u\\u_", "index_", "=_", "Qt", "Core_", "._", "QM", "odel", "Index_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "model_", "._", "data_", "(_", "index_", ")_", "==_", "None_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "index_", "=_", "model_", "._", "index_", "(_", "2_", ",_", "0_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "get", " ", "data", " ", "for", " ", "display", " ", "role_", "\\u\\u\\uNL\\u\\u\\u_", "ret_", "=_", "index_", "._", "data_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "ret_", "==_", "'", "Spam", "'_", "\\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,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 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 ]
Unused import
anandology/pyjamas/examples/splitpanel/SplitPanel.py
[ { "content": "import pyjd # dummy in pyjs\n\nfrom pyjamas.ui.RootPanel import RootPanel\nfrom pyjamas.ui.HTML import HTML\nfrom pyjamas.ui.Label import Label\nfrom pyjamas.ui import HasAlignment\nfrom pyjamas.ui.Button import Button\nfrom pyjamas import Window\n\nfrom pyjamas.ui.VerticalSplitPanel import VerticalSplitPanel\nfrom pyjamas.ui.HorizontalSplitPanel import HorizontalSplitPanel\n\n\n\n\nif __name__ == '__main__':\n pyjd.setup(\"./public/SplitPanel.html\")\n app = SplitPanel()\n app.onModuleLoad()\n pyjd.run()\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 }, { "content": "class SplitPanel:\n", "metadata": "root.SplitPanel", "header": "['module', '___EOS___']", "index": 13 }, { "content": " def onModuleLoad(self):\n self.vertpanel = VerticalSplitPanel()\n self.vertpanel.setSize(\"500px\", \"350px\")\n self.vertpanel.setSplitPosition(\"30%\")\n self.vertpanel.setStyleAttribute(\"background\", \"red\")\n\n self.horzpanel = HorizontalSplitPanel()\n self.horzpanel.setSize(\"500px\", \"350px\")\n self.horzpanel.setSplitPosition(\"50%\")\n self.horzpanel.setStyleAttribute(\"background\", \"yellow\")\n\n randomText = \"\"\n for i in range(200):\n randomText += \"hello %d \" % i\n\n self.vertpanel.setTopWidget(HTML(randomText))\n self.vertpanel.setBottomWidget(HTML(randomText))\n\n self.horzpanel.setLeftWidget(HTML(randomText))\n self.horzpanel.setRightWidget(HTML(randomText))\n\n RootPanel().add(self.vertpanel)\n RootPanel().add(self.horzpanel)", "metadata": "root.SplitPanel.onModuleLoad", "header": "['class', 'SplitPanel', ':', '___EOS___']", "index": 15 } ]
[ { "span": "from pyjamas.ui.Label import Label", "start_line": 4, "start_column": 0, "end_line": 4, "end_column": 34 }, { "span": "from pyjamas.ui import HasAlignment", "start_line": 5, "start_column": 0, "end_line": 5, "end_column": 35 }, { "span": "from pyjamas.ui.Button import Button", "start_line": 6, "start_column": 0, "end_line": 6, "end_column": 36 }, { "span": "from pyjamas import Window", "start_line": 7, "start_column": 0, "end_line": 7, "end_column": 26 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "import_", "pyj", "d_", "#", " ", "dummy", " ", "in", " ", "pyj", "s_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "._", "Roo", "t", "Panel_", "import_", "Roo", "t", "Panel_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "._", "HTML_", "import_", "HTML_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "._", "Label_", "import_", "Label_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "import_", "Has", "Alignment_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "._", "Button_", "import_", "Button_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyj", "ama", "s_", "import_", "Window_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "._", "Vertica", "l", "Split", "Panel_", "import_", "Vertica", "l", "Split", "Panel_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "pyj", "ama", "s_", "._", "ui_", "._", "Horiz", "onta", "l", "Split", "Panel_", "import_", "Horiz", "onta", "l", "Split", "Panel_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\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 ", " _", "pyj", "d_", "._", "setup_", "(_", "\"./", "public", "/", "Split", "Pane", "l", ".", "html", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "=_", "Split", "Panel_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "app_", "._", "on", "Modul", "e", "Load_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "pyj", "d_", "._", "run_", "(_", ")_", "\\u\\u\\uDEDENT\\u\\u\\u_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "class_", "Split", "Panel_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "[SEP]_", "class_", "Split", "Panel_", ":_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "def_", "on", "Modul", "e", "Load_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "self_", "._", "vert", "panel_", "=_", "Vertica", "l", "Split", "Panel_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "vert", "panel_", "._", "set", "Size_", "(_", "\"", "500", "px", "\"_", ",_", "\"", "350", "px", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "vert", "panel_", "._", "set", "Split", "Position_", "(_", "\"", "30", "%\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "vert", "panel_", "._", "set", "Style", "Attribute_", "(_", "\"", "background", "\"_", ",_", "\"", "red", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "hor", "zp", "ane", "l_", "=_", "Horiz", "onta", "l", "Split", "Panel_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "hor", "zp", "ane", "l_", "._", "set", "Size_", "(_", "\"", "500", "px", "\"_", ",_", "\"", "350", "px", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "hor", "zp", "ane", "l_", "._", "set", "Split", "Position_", "(_", "\"", "50", "%\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "hor", "zp", "ane", "l_", "._", "set", "Style", "Attribute_", "(_", "\"", "background", "\"_", ",_", "\"", "yell", "ow", "\"_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "random", "Text_", "=_", "\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "i_", "in_", "range_", "(_", "200_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "random", "Text_", "+=_", "\"", "hell", "o", " ", "%", "d", " ", "\"_", "%_", "i_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "self_", "._", "vert", "panel_", "._", "set", "Top", "Widget_", "(_", "HTML_", "(_", "random", "Text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "vert", "panel_", "._", "set", "Bott", "om", "Widget_", "(_", "HTML_", "(_", "random", "Text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "self_", "._", "hor", "zp", "ane", "l_", "._", "set", "Le", "ft", "Widget_", "(_", "HTML_", "(_", "random", "Text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "hor", "zp", "ane", "l_", "._", "set", "Rig", "ht", "Widget_", "(_", "HTML_", "(_", "random", "Text_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "Roo", "t", "Panel_", "(_", ")_", "._", "add_", "(_", "self_", "._", "vert", "panel_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "Roo", "t", "Panel_", "(_", ")_", "._", "add_", "(_", "self_", "._", "hor", "zp", "ane", "l_", ")_", "\\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, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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,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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
Variable defined multiple times
nasa-gibs/onearth/src/test/test_mod_onearth.py
[ { "content": " def test_snapping_3c(self):\n layer_name = 'snap_test_3c'\n tests = (('1990-01-01', '1990-01-01'),\n ('1990-05-20', '1990-01-01'),\n ('2000-01-01', '2000-01-01'),\n ('2000-05-20', '2000-01-01'),\n ('2005-12-31', '2005-01-01'),\n ('2017-01-01', 'black'),\n ('1989-12-31', 'black'))\n for request_date, expected_date in tests:\n req_url = self.snap_test_url_template.format(layer_name, request_date)\n if DEBUG:\n print '\\nTesting Date Snapping: Regular Multi-day date snapping (e.g. consistent 8-day, monthly, yearly cadence)'\n print 'Time Period 3c: 1990-01-01/2016-01-01/P1Y'\n for request_date, expected_date in tests:\n req_url = self.snap_test_url_template.format(layer_name, request_date)\n if DEBUG:\n print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)\n print 'URL: ' + req_url\n response_date = test_snap_request(self.tile_hashes, req_url)\n error = 'Snapping test 3c requested date {0}, expected {1}, but got {2}. \\nURL: {3}'.format(request_date, expected_date, response_date, req_url)\n self.assertEqual(expected_date, response_date, error)", "metadata": "root.TestModOnEarth.test_snapping_3c", "header": "['class', 'TestModOnEarth', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '___NL___', '# SETUP', '___NL___', '___EOS___']", "index": 603 }, { "content": " def test_snapping_3d(self):\n layer_name = 'snap_test_3d'\n tests = (('2010-01-01', '2010-01-01'),\n ('2010-01-04', '2010-01-01'),\n ('2010-01-10', '2010-01-09'),\n ('2012-03-11', '2012-03-11'),\n ('2012-03-14', '2012-03-11'),\n ('2012-03-19', 'black'),\n ('2009-12-31', 'black'))\n for request_date, expected_date in tests:\n req_url = self.snap_test_url_template.format(layer_name, request_date)\n if DEBUG:\n print '\\nTesting Date Snapping: Regular Multi-day date snapping (e.g. consistent 8-day, monthly, yearly cadence)'\n print 'Time Period 3d: 1990-01-01/2016-01-01/P1Y'\n for request_date, expected_date in tests:\n req_url = self.snap_test_url_template.format(layer_name, request_date)\n if DEBUG:\n print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)\n print 'URL: ' + req_url\n response_date = test_snap_request(self.tile_hashes, req_url)\n error = 'Snapping test 3d requested date {0}, expected {1}, but got {2}. \\nURL: {3}'.format(request_date, expected_date, response_date, req_url)\n self.assertEqual(expected_date, response_date, error)", "metadata": "root.TestModOnEarth.test_snapping_3d", "header": "['class', 'TestModOnEarth', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '___NL___', '# SETUP', '___NL___', '___EOS___']", "index": 626 }, { "content": " def test_snapping_4a(self):\n layer_name = 'snap_test_4a'\n tests = (('2000-01-01', '2000-01-01'),\n ('2000-01-20', '2000-01-01'),\n ('2000-06-10', '2000-06-01'),\n ('2000-07-01', 'black'),\n ('2000-07-02', 'black'),\n ('2000-07-03', '2000-07-03'),\n ('2000-07-20', '2000-07-03'),\n ('2000-08-01', '2000-08-01'),\n ('2000-08-10', '2000-08-01'),\n ('2000-12-31', '2000-12-01'),\n ('1999-12-31', 'black'),\n ('2001-01-01', 'black'))\n for request_date, expected_date in tests:\n req_url = self.snap_test_url_template.format(layer_name, request_date)\n if DEBUG:\n print '\\nTesting Irregular Multi-day date snapping (e.g. irregular periods intermixed with consistent periods'\n print 'Time Period 4a: 2000-01-01/2000-06-01/P1M,2000-07-03/2000-07-03/P1M,2000-08-01/2000-12-01/P1M'\n for request_date, expected_date in tests:\n req_url = self.snap_test_url_template.format(layer_name, request_date)\n if DEBUG:\n print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)\n print 'URL: ' + req_url\n response_date = test_snap_request(self.tile_hashes, req_url)\n error = 'Snapping test 4a requested date {0}, expected {1}, but got {2}. \\nURL: {3}'.format(request_date, expected_date, response_date, req_url)\n self.assertEqual(expected_date, response_date, error)", "metadata": "root.TestModOnEarth.test_snapping_4a", "header": "['class', 'TestModOnEarth', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '___NL___', '# SETUP', '___NL___', '___EOS___']", "index": 649 }, { "content": " def test_snapping_4b(self):\n layer_name = 'snap_test_4b'\n tests = (('2001-01-01', '2001-01-01'),\n ('2001-01-05', '2001-01-01'),\n ('2001-05-14', '2001-05-09'),\n ('2002-01-01', '2002-01-01'),\n ('2000-12-31', 'black'),\n ('2003-01-01', '2002-12-27'),\n ('2003-01-04', 'black'))\n for request_date, expected_date in tests:\n req_url = self.snap_test_url_template.format(layer_name, request_date)\n if DEBUG:\n print '\\nTesting Irregular Multi-day date snapping (e.g. irregular periods intermixed with consistent periods'\n print 'Time Period 4b: 2001-01-01/2001-12-27/P8D, 2002-01-01/2002-12-27/P8D'\n for request_date, expected_date in tests:\n req_url = self.snap_test_url_template.format(layer_name, request_date)\n if DEBUG:\n print 'Requesting {0}, expecting {1}'.format(request_date, expected_date)\n print 'URL: ' + req_url\n response_date = test_snap_request(self.tile_hashes, req_url)\n error = 'Snapping test 4b requested date {0}, expected {1}, but got {2}. \\nURL: {3}'.format(request_date, expected_date, response_date, req_url)\n self.assertEqual(expected_date, response_date, error)", "metadata": "root.TestModOnEarth.test_snapping_4b", "header": "['class', 'TestModOnEarth', '(', 'unittest', '.', 'TestCase', ')', ':', '___NEWLINE___', '___NL___', '# SETUP', '___NL___', '___EOS___']", "index": 677 } ]
[ { "span": "req_url ", "start_line": 613, "start_column": 12, "end_line": 613, "end_column": 19 }, { "span": "req_url ", "start_line": 636, "start_column": 12, "end_line": 636, "end_column": 19 }, { "span": "req_url ", "start_line": 664, "start_column": 12, "end_line": 664, "end_column": 19 }, { "span": "req_url ", "start_line": 687, "start_column": 12, "end_line": 687, "end_column": 19 } ]
[ { "span": "req_url ", "start_line": 618, "start_column": 12, "end_line": 618, "end_column": 19 }, { "span": "req_url ", "start_line": 641, "start_column": 12, "end_line": 641, "end_column": 19 }, { "span": "req_url ", "start_line": 669, "start_column": 12, "end_line": 669, "end_column": 19 }, { "span": "req_url ", "start_line": 692, "start_column": 12, "end_line": 692, "end_column": 19 } ]
1
true
[ "[CLS]_", "Variable_", "defined_", "multiple_", "times_", "[SEP]_", "class_", "Test", "Mod", "On", "Ear", "th_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "SETUP", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "snapp", "ing", "\\u", "3c", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "layer", "\\u", "name_", "=_", "'", "snap", "\\u", "test\\u", "3c", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tests_", "=_", "(_", "(_", "'", "1990", "-0", "1", "-0", "1", "'_", ",_", "'", "1990", "-0", "1", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "1990", "-0", "5", "-", "20", "'_", ",_", "'", "1990", "-0", "1", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2000", "-0", "1", "-0", "1", "'_", ",_", "'", "2000", "-0", "1", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2000", "-0", "5", "-", "20", "'_", ",_", "'", "2000", "-0", "1", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2005", "-1", "2", "-", "3", "1", "'_", ",_", "'", "2005", "-0", "1", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2017", "-0", "1", "-0", "1", "'_", ",_", "'", "black", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "1989", "-1", "2", "-", "3", "1", "'_", ",_", "'", "black", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", "in_", "tests_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "req", "\\u", "url_", "=_", "self_", "._", "snap", "\\u", "test\\u", "url", "\\u", "template_", "._", "format_", "(_", "layer", "\\u", "name_", ",_", "request", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "DEBUG_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'\\\\", "n", "Test", "ing", " ", "Date", " ", "Snap", "ping", ":", " ", "Regula", "r", " ", "Multi", "-", "day", " ", "date", " ", "snapp", "ing", " ", "(", "e", ".", "g", ".", " ", "consistent", " ", "8", "-", "day", ",", " ", "month", "ly", ",", " ", "year", "ly", " ", "cade", "nce", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Time", " ", "Period", " ", "3c", ":", " ", "1990", "-0", "1", "-0", "1", "/", "2016", "-0", "1", "-0", "1", "/", "P1", "Y", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", "in_", "tests_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "req", "\\u", "url_", "=_", "self_", "._", "snap", "\\u", "test\\u", "url", "\\u", "template_", "._", "format_", "(_", "layer", "\\u", "name_", ",_", "request", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "DEBUG_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "Request", "ing", " ", "{", "0", "},", " ", "expect", "ing", " ", "{", "1", "}'_", "._", "format_", "(_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "URL", ":", " ", "'_", "+_", "req", "\\u", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response", "\\u", "date_", "=_", "test\\u", "snap", "\\u", "request_", "(_", "self_", "._", "tile", "\\u", "hashes_", ",_", "req", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "error_", "=_", "'", "Snap", "ping", " ", "test", " ", "3c", " ", "request", "ed", " ", "date", " ", "{", "0", "},", " ", "expected", " ", "{", "1", "},", " ", "but", " ", "got", " ", "{", "2", "}.", " ", "\\\\", "n", "URL", ":", " ", "{", "3", "}'_", "._", "format_", "(_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", ",_", "response", "\\u", "date_", ",_", "req", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "expected", "\\u", "date_", ",_", "response", "\\u", "date_", ",_", "error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Mod", "On", "Ear", "th_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "SETUP", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "snapp", "ing", "\\u", "3d_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "layer", "\\u", "name_", "=_", "'", "snap", "\\u", "test\\u", "3d", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tests_", "=_", "(_", "(_", "'", "2010", "-0", "1", "-0", "1", "'_", ",_", "'", "2010", "-0", "1", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2010", "-0", "1", "-0", "4", "'_", ",_", "'", "2010", "-0", "1", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2010", "-0", "1", "-1", "0", "'_", ",_", "'", "2010", "-0", "1", "-0", "9", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2012", "-0", "3", "-1", "1", "'_", ",_", "'", "2012", "-0", "3", "-1", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2012", "-0", "3", "-1", "4", "'_", ",_", "'", "2012", "-0", "3", "-1", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2012", "-0", "3", "-1", "9", "'_", ",_", "'", "black", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "200", "9", "-1", "2", "-", "3", "1", "'_", ",_", "'", "black", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", "in_", "tests_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "req", "\\u", "url_", "=_", "self_", "._", "snap", "\\u", "test\\u", "url", "\\u", "template_", "._", "format_", "(_", "layer", "\\u", "name_", ",_", "request", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "DEBUG_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'\\\\", "n", "Test", "ing", " ", "Date", " ", "Snap", "ping", ":", " ", "Regula", "r", " ", "Multi", "-", "day", " ", "date", " ", "snapp", "ing", " ", "(", "e", ".", "g", ".", " ", "consistent", " ", "8", "-", "day", ",", " ", "month", "ly", ",", " ", "year", "ly", " ", "cade", "nce", ")'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Time", " ", "Period", " ", "3d", ":", " ", "1990", "-0", "1", "-0", "1", "/", "2016", "-0", "1", "-0", "1", "/", "P1", "Y", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", "in_", "tests_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "req", "\\u", "url_", "=_", "self_", "._", "snap", "\\u", "test\\u", "url", "\\u", "template_", "._", "format_", "(_", "layer", "\\u", "name_", ",_", "request", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "DEBUG_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "Request", "ing", " ", "{", "0", "},", " ", "expect", "ing", " ", "{", "1", "}'_", "._", "format_", "(_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "URL", ":", " ", "'_", "+_", "req", "\\u", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response", "\\u", "date_", "=_", "test\\u", "snap", "\\u", "request_", "(_", "self_", "._", "tile", "\\u", "hashes_", ",_", "req", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "error_", "=_", "'", "Snap", "ping", " ", "test", " ", "3d", " ", "request", "ed", " ", "date", " ", "{", "0", "},", " ", "expected", " ", "{", "1", "},", " ", "but", " ", "got", " ", "{", "2", "}.", " ", "\\\\", "n", "URL", ":", " ", "{", "3", "}'_", "._", "format_", "(_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", ",_", "response", "\\u", "date_", ",_", "req", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "expected", "\\u", "date_", ",_", "response", "\\u", "date_", ",_", "error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Mod", "On", "Ear", "th_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "SETUP", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "snapp", "ing", "\\u", "4a", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "layer", "\\u", "name_", "=_", "'", "snap", "\\u", "test\\u", "4a", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tests_", "=_", "(_", "(_", "'", "2000", "-0", "1", "-0", "1", "'_", ",_", "'", "2000", "-0", "1", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2000", "-0", "1", "-", "20", "'_", ",_", "'", "2000", "-0", "1", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2000", "-0", "6", "-1", "0", "'_", ",_", "'", "2000", "-0", "6", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2000", "-0", "7", "-0", "1", "'_", ",_", "'", "black", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2000", "-0", "7", "-0", "2", "'_", ",_", "'", "black", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2000", "-0", "7", "-0", "3", "'_", ",_", "'", "2000", "-0", "7", "-0", "3", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2000", "-0", "7", "-", "20", "'_", ",_", "'", "2000", "-0", "7", "-0", "3", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2000", "-0", "8", "-0", "1", "'_", ",_", "'", "2000", "-0", "8", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2000", "-0", "8", "-1", "0", "'_", ",_", "'", "2000", "-0", "8", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2000", "-1", "2", "-", "3", "1", "'_", ",_", "'", "2000", "-1", "2", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "1999", "-1", "2", "-", "3", "1", "'_", ",_", "'", "black", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "200", "1", "-0", "1", "-0", "1", "'_", ",_", "'", "black", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", "in_", "tests_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "req", "\\u", "url_", "=_", "self_", "._", "snap", "\\u", "test\\u", "url", "\\u", "template_", "._", "format_", "(_", "layer", "\\u", "name_", ",_", "request", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "DEBUG_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'\\\\", "n", "Test", "ing", " ", "Ir", "regular", " ", "Multi", "-", "day", " ", "date", " ", "snapp", "ing", " ", "(", "e", ".", "g", ".", " ", "irre", "gul", "ar", " ", "period", "s", " ", "interm", "ix", "ed", " ", "with", " ", "consistent", " ", "period", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Time", " ", "Period", " ", "4a", ":", " ", "2000", "-0", "1", "-0", "1", "/", "2000", "-0", "6", "-0", "1", "/", "P1", "M", ",", "2000", "-0", "7", "-0", "3", "/", "2000", "-0", "7", "-0", "3", "/", "P1", "M", ",", "2000", "-0", "8", "-0", "1", "/", "2000", "-1", "2", "-0", "1", "/", "P1", "M", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", "in_", "tests_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "req", "\\u", "url_", "=_", "self_", "._", "snap", "\\u", "test\\u", "url", "\\u", "template_", "._", "format_", "(_", "layer", "\\u", "name_", ",_", "request", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "DEBUG_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "Request", "ing", " ", "{", "0", "},", " ", "expect", "ing", " ", "{", "1", "}'_", "._", "format_", "(_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "URL", ":", " ", "'_", "+_", "req", "\\u", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response", "\\u", "date_", "=_", "test\\u", "snap", "\\u", "request_", "(_", "self_", "._", "tile", "\\u", "hashes_", ",_", "req", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "error_", "=_", "'", "Snap", "ping", " ", "test", " ", "4a", " ", "request", "ed", " ", "date", " ", "{", "0", "},", " ", "expected", " ", "{", "1", "},", " ", "but", " ", "got", " ", "{", "2", "}.", " ", "\\\\", "n", "URL", ":", " ", "{", "3", "}'_", "._", "format_", "(_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", ",_", "response", "\\u", "date_", ",_", "req", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "expected", "\\u", "date_", ",_", "response", "\\u", "date_", ",_", "error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "[SEP]_", "class_", "Test", "Mod", "On", "Ear", "th_", "(_", "unittest_", "._", "Test", "Case_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "#", " ", "SETUP", "_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uEOS\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "def_", "test\\u", "snapp", "ing", "\\u", "4b", "_", "(_", "self_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "layer", "\\u", "name_", "=_", "'", "snap", "\\u", "test\\u", "4b", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tests_", "=_", "(_", "(_", "'", "200", "1", "-0", "1", "-0", "1", "'_", ",_", "'", "200", "1", "-0", "1", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "200", "1", "-0", "1", "-0", "5", "'_", ",_", "'", "200", "1", "-0", "1", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "200", "1", "-0", "5", "-1", "4", "'_", ",_", "'", "200", "1", "-0", "5", "-0", "9", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2002", "-0", "1", "-0", "1", "'_", ",_", "'", "2002", "-0", "1", "-0", "1", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2000", "-1", "2", "-", "3", "1", "'_", ",_", "'", "black", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2003", "-0", "1", "-0", "1", "'_", ",_", "'", "2002", "-1", "2", "-", "2", "7", "'_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "(_", "'", "2003", "-0", "1", "-0", "4", "'_", ",_", "'", "black", "'_", ")_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "for_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", "in_", "tests_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "req", "\\u", "url_", "=_", "self_", "._", "snap", "\\u", "test\\u", "url", "\\u", "template_", "._", "format_", "(_", "layer", "\\u", "name_", ",_", "request", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "if_", "DEBUG_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'\\\\", "n", "Test", "ing", " ", "Ir", "regular", " ", "Multi", "-", "day", " ", "date", " ", "snapp", "ing", " ", "(", "e", ".", "g", ".", " ", "irre", "gul", "ar", " ", "period", "s", " ", "interm", "ix", "ed", " ", "with", " ", "consistent", " ", "period", "s", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "Time", " ", "Period", " ", "4b", ":", " ", "200", "1", "-0", "1", "-0", "1", "/", "200", "1", "-1", "2", "-", "2", "7", "/", "P", "8", "D", ",", " ", "2002", "-0", "1", "-0", "1", "/", "2002", "-1", "2", "-", "2", "7", "/", "P", "8", "D", "'_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "for_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", "in_", "tests_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "req", "\\u", "url_", "=_", "self_", "._", "snap", "\\u", "test\\u", "url", "\\u", "template_", "._", "format_", "(_", "layer", "\\u", "name_", ",_", "request", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "if_", "DEBUG_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "print_", "'", "Request", "ing", " ", "{", "0", "},", " ", "expect", "ing", " ", "{", "1", "}'_", "._", "format_", "(_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "'", "URL", ":", " ", "'_", "+_", "req", "\\u", "url_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "response", "\\u", "date_", "=_", "test\\u", "snap", "\\u", "request_", "(_", "self_", "._", "tile", "\\u", "hashes_", ",_", "req", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "error_", "=_", "'", "Snap", "ping", " ", "test", " ", "4b", " ", "request", "ed", " ", "date", " ", "{", "0", "},", " ", "expected", " ", "{", "1", "},", " ", "but", " ", "got", " ", "{", "2", "}.", " ", "\\\\", "n", "URL", ":", " ", "{", "3", "}'_", "._", "format_", "(_", "request", "\\u", "date_", ",_", "expected", "\\u", "date_", ",_", "response", "\\u", "date_", ",_", "req", "\\u", "url_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "self_", "._", "assert", "Equal_", "(_", "expected", "\\u", "date_", ",_", "response", "\\u", "date_", ",_", "error_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
An assert statement has a side-effect
Yelp/dumb-init/tests/tty_test.py
[ { "content": "def _test(fd):\n \"\"\"write to tac via the pty and verify its output\"\"\"\n ttyflags(fd)\n from os import write\n assert write(fd, b'1\\n2\\n3\\n') == 6\n assert write(fd, EOF * 2) == 2\n output = readall(fd)\n assert output == b'3\\n2\\n1\\n', repr(output)\n print('PASS')", "metadata": "root._test", "header": "['module', '___EOS___']", "index": 32 } ]
[ { "span": "assert write(fd, b'1\\n2\\n3\\n') == 6", "start_line": 36, "start_column": 4, "end_line": 36, "end_column": 39 }, { "span": "assert write(fd, EOF * 2) == 2", "start_line": 37, "start_column": 4, "end_line": 37, "end_column": 34 } ]
[]
1
true
[ "[CLS]_", "An", "_", "assert_", "statement_", "has_", "a_", "side_", "-_", "effect_", "[SEP]_", "module_", "\\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", "test_", "(_", "fd_", ")_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "\"\"\"", "write", " ", "to", " ", "tac", " ", "via", " ", "the", " ", "pty", " ", "and", " ", "verify", " ", "its", " ", "output", "\"\"\"_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "tt", "yf", "lags_", "(_", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "os_", "import_", "write_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "write_", "(_", "fd_", ",_", "b", "'", "1", "\\\\", "n2", "\\\\", "n", "3", "\\\\", "n", "'_", ")_", "==_", "6_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "write_", "(_", "fd_", ",_", "EOF_", "*_", "2_", ")_", "==_", "2_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "output_", "=_", "reada", "ll_", "(_", "fd_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "assert_", "output_", "==_", "b", "'", "3", "\\\\", "n2", "\\\\", "n1", "\\\\", "n", "'_", ",_", "repr_", "(_", "output_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "print_", "(_", "'", "PASS", "'_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 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
freshbooks/refreshbooks/setup.py
[ { "content": "try:\n from setuptools import setup, find_packages\nexcept ImportError:\n from ez_setup import use_setuptools\n use_setuptools()\n from setuptools import setup, find_packages\n\nsetup(\n name='refreshbooks',\n version='2.1.dev',\n author='Owen Jacobson',\n author_email='[email protected]',\n url='http://github.com/freshbooks/refreshbooks',\n download_url='http://pypi.python.org/pypi/refreshbooks/',\n description='A client library for the FreshBooks API',\n \n long_description=open(\"README.rst\").read(),\n \n classifiers=[\n 'Development Status :: 4 - Beta',\n 'Intended Audience :: Developers',\n 'License :: OSI Approved :: MIT License',\n 'Operating System :: OS Independent',\n 'Topic :: Software Development :: Libraries :: Python Modules'\n ],\n \n packages=[\n 'refreshbooks', 'refreshbooks.transports', 'refreshbooks.optional'\n ],\n \n setup_requires=[\n 'setuptools-git',\n 'nose'\n ],\n tests_require=[\n 'nose',\n 'mock'\n ],\n install_requires=[\n 'lxml',\n ],\n extras_require={\n 'oauth': ['oauth'],\n 'httplib2': ['httplib2 >= 0.7.2'],\n 'requests': ['requests >= 0.11.1']\n },\n \n test_suite = 'nose.collector'\n)\n", "metadata": "root", "header": "['module', '___EOS___']", "index": 0 } ]
[ { "span": "from setuptools import setup, find_packages", "start_line": 1, "start_column": 4, "end_line": 1, "end_column": 47 }, { "span": "from setuptools import setup, find_packages", "start_line": 5, "start_column": 4, "end_line": 5, "end_column": 47 } ]
[]
1
false
[ "[CLS]_", "Un", "used_", "import_", "[SEP]_", "module_", "\\u\\u\\uEOS\\u\\u\\u_", "try_", ":_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uINDENT\\u\\u\\u ", " _", "from_", "setuptools_", "import_", "setup_", ",_", "find", "\\u", "packages_", "\\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_", "ez", "\\u", "setup_", "import_", "use", "\\u", "setuptools_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "use", "\\u", "setuptools_", "(_", ")_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "from_", "setuptools_", "import_", "setup_", ",_", "find", "\\u", "packages_", "\\u\\u\\uNEWLINE\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uDEDENT\\u\\u\\u_", "setup_", "(_", "\\u\\u\\uNL\\u\\u\\u_", "name_", "=_", "'", "refre", "sh", "books", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "version_", "=_", "'", "2.1", ".", "dev", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "author_", "=_", "'", "Ow", "en", " ", "Jacob", "son", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "author", "\\u", "email_", "=_", "'", "api", "@", "fresh", "books", ".", "com", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "url_", "=_", "'", "http", "://", "git", "hub", ".", "com", "/", "fresh", "books", "/", "refre", "sh", "books", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "download", "\\u", "url_", "=_", "'", "http", "://", "pypi", ".", "python", ".", "org", "/", "pypi", "/", "refre", "sh", "books", "/'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "description_", "=_", "'", "A", " ", "client", " ", "librar", "y", " ", "for", " ", "the", " ", "Fre", "sh", "Books", " ", "API", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "long", "\\u", "description_", "=_", "open_", "(_", "\"", "READ", "ME", ".", "rst", "\"_", ")_", "._", "read_", "(_", ")_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "classifiers_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Dev", "elo", "pme", "nt", " ", "Status", " ", "::", " ", "4", " ", "-", " ", "Beta", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Inten", "ded", " ", "Audi", "ence", " ", "::", " ", "Dev", "elope", "rs", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "License", " ", "::", " ", "OSI", " ", "Appro", "ved", " ", "::", " ", "MIT", " ", "License", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Opera", "ting", " ", "System", " ", "::", " ", "OS", " ", "Inde", "pend", "ent", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "Topic", " ", "::", " ", "Sof", "twa", "re", " ", "Dev", "elo", "pme", "nt", " ", "::", " ", "Libr", "aries", " ", "::", " ", "Pyth", "on", " ", "Modul", "es", "'_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "packages_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "refre", "sh", "books", "'_", ",_", "'", "refre", "sh", "books", ".", "transport", "s", "'_", ",_", "'", "refre", "sh", "books", ".", "option", "al", "'_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "setup", "\\u", "requires_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "setup", "tool", "s", "-", "git", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "nose", "'_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "tests", "\\u", "require_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "nose", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "mock", "'_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "install", "\\u", "requires_", "=_", "[_", "\\u\\u\\uNL\\u\\u\\u_", "'", "lx", "ml", "'_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "extra", "s", "\\u", "require_", "=_", "{_", "\\u\\u\\uNL\\u\\u\\u_", "'", "oauth", "'_", ":_", "[_", "'", "oauth", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "http", "lib", "2", "'_", ":_", "[_", "'", "http", "lib", "2", " ", ">=", " ", "0.", "7.2", "'_", "]_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "'", "request", "s", "'_", ":_", "[_", "'", "request", "s", " ", ">=", " ", "0.11", ".1", "'_", "]_", "\\u\\u\\uNL\\u\\u\\u_", "}_", ",_", "\\u\\u\\uNL\\u\\u\\u_", "\\u\\u\\uNL\\u\\u\\u_", "test\\u", "suite_", "=_", "'", "nose", ".", "collect", "or", "'_", "\\u\\u\\uNL\\u\\u\\u_", ")_" ]
[ 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0,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