lines
sequencelengths 1
383
| raw_lines
sequencelengths 1
383
| label
sequencelengths 1
383
| type
sequencelengths 1
383
|
---|---|---|---|
[
"@app.route('/cached.gif')...\n",
"VAR_13 = request.base_url.replace('/cached.gif', '/')\n",
"VAR_9 = request.path.replace('/cached.gif', '/')\n",
"VAR_6 = request.url_root\n",
"VAR_45 = pluginManager.get_implementations(octoprint.plugin.UiPlugin,\n sorting_context='UiPlugin.on_ui_render')\n",
"for VAR_130 in VAR_45:\n",
"VAR_44 = make_response(bytes(base64.b64decode(\n 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7')))\n",
"if VAR_130.will_handle_ui(request):\n",
"VAR_0.exception(\n f'Error while calling plugin {VAR_130._identifier}, skipping it', extra\n ={'plugin': plugin._identifier})\n",
"VAR_44.headers['Content-Type'] = 'image/gif'\n",
"VAR_12 = VAR_130._identifier\n",
"if VAR_100 or not preemptiveCache.has_record(VAR_10, root=path):\n",
"VAR_8 = FUNC_2(VAR_130._identifier, VAR_13=url, VAR_15=plugin.\n get_ui_additional_key_data_for_cache)\n",
"VAR_0.info(\n 'Preemptive cache not active for path {}, ui {} and data {!r}, signaling as cached'\n .format(VAR_9, VAR_12, VAR_10))\n",
"if util.flask.is_in_cache(VAR_8):\n",
"VAR_100 = FUNC_0(VAR_13, VAR_7=plugin.\n get_ui_preemptive_caching_additional_unless)\n",
"return VAR_44\n",
"VAR_0.info(f'Found path {VAR_9} in cache (key: {VAR_8}), signaling as cached')\n",
"if util.flask.is_cache_bypassed(VAR_8):\n",
"VAR_10 = FUNC_1(VAR_130._identifier, VAR_9=path, VAR_6=base_url, VAR_10=\n plugin.get_ui_data_for_preemptive_caching, VAR_11=plugin.\n get_ui_additional_request_data_for_preemptive_caching)\n",
"return VAR_44\n",
"VAR_0.info('Path {} was bypassed from cache (key: {}), signaling as cached'\n .format(VAR_9, VAR_8))\n",
"VAR_0.debug(f'Path {VAR_9} not yet cached (key: {VAR_8}), signaling as missing'\n )\n",
"return VAR_44\n",
"return abort(404)\n"
] | [
"@app.route('/cached.gif')...\n",
"url = request.base_url.replace('/cached.gif', '/')\n",
"path = request.path.replace('/cached.gif', '/')\n",
"base_url = request.url_root\n",
"ui_plugins = pluginManager.get_implementations(octoprint.plugin.UiPlugin,\n sorting_context='UiPlugin.on_ui_render')\n",
"for plugin in ui_plugins:\n",
"response = make_response(bytes(base64.b64decode(\n 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7')))\n",
"if plugin.will_handle_ui(request):\n",
"_logger.exception(\n f'Error while calling plugin {plugin._identifier}, skipping it', extra=\n {'plugin': plugin._identifier})\n",
"response.headers['Content-Type'] = 'image/gif'\n",
"ui = plugin._identifier\n",
"if unless or not preemptiveCache.has_record(data, root=path):\n",
"key = _cache_key(plugin._identifier, url=url, additional_key_data=plugin.\n get_ui_additional_key_data_for_cache)\n",
"_logger.info(\n 'Preemptive cache not active for path {}, ui {} and data {!r}, signaling as cached'\n .format(path, ui, data))\n",
"if util.flask.is_in_cache(key):\n",
"unless = _preemptive_unless(url, additional_unless=plugin.\n get_ui_preemptive_caching_additional_unless)\n",
"return response\n",
"_logger.info(f'Found path {path} in cache (key: {key}), signaling as cached')\n",
"if util.flask.is_cache_bypassed(key):\n",
"data = _preemptive_data(plugin._identifier, path=path, base_url=base_url,\n data=plugin.get_ui_data_for_preemptive_caching, additional_request_data\n =plugin.get_ui_additional_request_data_for_preemptive_caching)\n",
"return response\n",
"_logger.info('Path {} was bypassed from cache (key: {}), signaling as cached'\n .format(path, key))\n",
"_logger.debug(f'Path {path} not yet cached (key: {key}), signaling as missing')\n",
"return response\n",
"return abort(404)\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",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Return'",
"Expr'",
"Condition",
"Assign'",
"Return'",
"Expr'",
"Expr'",
"Return'",
"Return'"
] |
[
"def FUNC_6(self, VAR_3, VAR_4):...\n",
"return django.forms.DecimalField(**options)\n"
] | [
"def create_number_field(self, field, options):...\n",
"return django.forms.DecimalField(**options)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"import contextlib\n",
"import errno\n",
"import fnmatch\n",
"import json\n",
"import hashlib\n",
"import hmac\n",
"import pathlib\n",
"import typing\n",
"import flask\n",
"VAR_0 = flask.Flask('xmpp-http-upload')\n",
"VAR_0.config.from_envvar('XMPP_HTTP_UPLOAD_CONFIG')\n",
"VAR_1 = VAR_0\n",
"if VAR_0.config['ENABLE_CORS']:\n",
"from flask_cors import CORS\n",
"def FUNC_0(VAR_2: str, VAR_3: pathlib.Path) ->pathlib.Path:...\n",
"CORS(VAR_0)\n",
"VAR_12 = (VAR_3 / VAR_2).absolute()\n",
"if not str(VAR_12).startswith(str(VAR_3) + '/'):\n",
"return VAR_12\n"
] | [
"import contextlib\n",
"import errno\n",
"import fnmatch\n",
"import json\n",
"import hashlib\n",
"import hmac\n",
"import pathlib\n",
"import typing\n",
"import flask\n",
"app = flask.Flask('xmpp-http-upload')\n",
"app.config.from_envvar('XMPP_HTTP_UPLOAD_CONFIG')\n",
"application = app\n",
"if app.config['ENABLE_CORS']:\n",
"from flask_cors import CORS\n",
"def sanitized_join(path: str, root: pathlib.Path) ->pathlib.Path:...\n",
"CORS(app)\n",
"result = (root / path).absolute()\n",
"if not str(result).startswith(str(root) + '/'):\n",
"return result\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1
] | [
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"ImportFrom'",
"FunctionDef'",
"Expr'",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_13(self, VAR_44):...\n",
"VAR_46 = VAR_44.group(2)\n",
"self.tokens.append({'type': 'list_start', 'ordered': '.' in VAR_46})\n",
"VAR_45 = VAR_44.group(0)\n",
"self._process_list_item(VAR_45, VAR_46)\n",
"self.tokens.append({'type': 'list_end'})\n"
] | [
"def parse_list_block(self, m):...\n",
"bull = m.group(2)\n",
"self.tokens.append({'type': 'list_start', 'ordered': '.' in bull})\n",
"cap = m.group(0)\n",
"self._process_list_item(cap, bull)\n",
"self.tokens.append({'type': 'list_end'})\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_5(VAR_6):...\n",
"\"\"\"docstring\"\"\"\n",
"if salt.utils.is_windows():\n",
"return True\n",
"if VAR_6 == salt.utils.get_user():\n",
"return True\n",
"import pwd\n",
"VAR_45 = pwd.getpwnam(VAR_6)\n",
"VAR_32 = 'User not found: \"{0}\"'.format(VAR_6)\n",
"return True\n",
"if hasattr(VAR_54, 'initgroups'):\n",
"VAR_32 = 'Salt configured to run as user \"{0}\" but unable to switch.'\n",
"if is_console_configured():\n",
"VAR_54.initgroups(VAR_6, VAR_45.pw_gid)\n",
"VAR_54.setgroups(salt.utils.get_gid_list(VAR_6, include_default=False))\n",
"VAR_32 = VAR_32.format(VAR_6)\n",
"VAR_0.critical(VAR_32)\n",
"sys.stderr.write('CRITICAL: {0}\\n'.format(VAR_32))\n",
"VAR_54.setgid(VAR_45.pw_gid)\n",
"if is_console_configured():\n",
"return False\n",
"VAR_54.setuid(VAR_45.pw_uid)\n",
"VAR_0.critical(VAR_32)\n",
"sys.stderr.write('CRITICAL: {0}\\n'.format(VAR_32))\n",
"if 'HOME' in VAR_54.environ:\n",
"return False\n",
"VAR_54.environ['HOME'] = VAR_45.pw_dir\n",
"if 'SHELL' in VAR_54.environ:\n",
"VAR_54.environ['SHELL'] = VAR_45.pw_shell\n",
"for VAR_56 in ('USER', 'LOGNAME'):\n",
"if VAR_56 in VAR_54.environ:\n",
"VAR_54.environ[VAR_56] = VAR_45.pw_name\n"
] | [
"def check_user(user):...\n",
"\"\"\"docstring\"\"\"\n",
"if salt.utils.is_windows():\n",
"return True\n",
"if user == salt.utils.get_user():\n",
"return True\n",
"import pwd\n",
"pwuser = pwd.getpwnam(user)\n",
"msg = 'User not found: \"{0}\"'.format(user)\n",
"return True\n",
"if hasattr(os, 'initgroups'):\n",
"msg = 'Salt configured to run as user \"{0}\" but unable to switch.'\n",
"if is_console_configured():\n",
"os.initgroups(user, pwuser.pw_gid)\n",
"os.setgroups(salt.utils.get_gid_list(user, include_default=False))\n",
"msg = msg.format(user)\n",
"log.critical(msg)\n",
"sys.stderr.write('CRITICAL: {0}\\n'.format(msg))\n",
"os.setgid(pwuser.pw_gid)\n",
"if is_console_configured():\n",
"return False\n",
"os.setuid(pwuser.pw_uid)\n",
"log.critical(msg)\n",
"sys.stderr.write('CRITICAL: {0}\\n'.format(msg))\n",
"if 'HOME' in os.environ:\n",
"return False\n",
"os.environ['HOME'] = pwuser.pw_dir\n",
"if 'SHELL' in os.environ:\n",
"os.environ['SHELL'] = pwuser.pw_shell\n",
"for envvar in ('USER', 'LOGNAME'):\n",
"if envvar in os.environ:\n",
"os.environ[envvar] = pwuser.pw_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,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Condition",
"Return'",
"Import'",
"Assign'",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Return'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"For",
"Condition",
"Assign'"
] |
[
"def FUNC_7(self):...\n",
""
] | [
"def getUserId(self):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"@wraps(VAR_4)...\n",
"if VAR_87.role_download():\n",
"return VAR_4(*VAR_49, **kwargs)\n",
"abort(403)\n"
] | [
"@wraps(f)...\n",
"if current_user.role_download():\n",
"return f(*args, **kwargs)\n",
"abort(403)\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Return'",
"Expr'"
] |
[
"def FUNC_35(self):...\n",
"self.parser = saved_model_cli.create_parser()\n",
"VAR_9 = test.test_src_dir_path(VAR_0)\n",
"VAR_10 = self.parser.parse_args(['scan', '--dir', VAR_9, '--tag_set', 'serve'])\n",
"VAR_48 = saved_model_cli._OP_DENYLIST\n",
"saved_model_cli._OP_DENYLIST = set(['VariableV2'])\n",
"saved_model_cli.scan(VAR_10)\n",
"saved_model_cli._OP_DENYLIST = VAR_48\n",
"VAR_11 = out.getvalue().strip()\n",
"self.assertTrue(\"'VariableV2'\" in VAR_11)\n"
] | [
"def testScanCommandFoundDenylistedOp(self):...\n",
"self.parser = saved_model_cli.create_parser()\n",
"base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n",
"args = self.parser.parse_args(['scan', '--dir', base_path, '--tag_set',\n 'serve'])\n",
"op_denylist = saved_model_cli._OP_DENYLIST\n",
"saved_model_cli._OP_DENYLIST = set(['VariableV2'])\n",
"saved_model_cli.scan(args)\n",
"saved_model_cli._OP_DENYLIST = op_denylist\n",
"output = out.getvalue().strip()\n",
"self.assertTrue(\"'VariableV2'\" in output)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_20(self) ->bool:...\n",
"\"\"\"docstring\"\"\"\n",
"return self.force_training or self.core\n"
] | [
"def should_retrain_core(self) ->bool:...\n",
"\"\"\"docstring\"\"\"\n",
"return self.force_training or self.core\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"@VAR_8.route('/api/queue/push/', methods=['POST'])...\n",
"VAR_64 = request.json['data']\n",
"VAR_67 = request.json['action']\n",
"VAR_68, VAR_69 = queue.push({'data': VAR_64}, VAR_67)\n",
"return {'hash': VAR_68, 'queue_position': VAR_69}\n"
] | [
"@app.route('/api/queue/push/', methods=['POST'])...\n",
"data = request.json['data']\n",
"action = request.json['action']\n",
"job_hash, queue_position = queue.push({'data': data}, action)\n",
"return {'hash': job_hash, 'queue_position': queue_position}\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"VAR_9 = test.test_src_dir_path(VAR_0)\n",
"self.parser = saved_model_cli.create_parser()\n",
"VAR_10 = self.parser.parse_args(['show', '--dir', VAR_9, '--tag_set', 'serve'])\n",
"saved_model_cli.show(VAR_10)\n",
"VAR_11 = out.getvalue().strip()\n",
"VAR_15 = (\n 'The given SavedModel MetaGraphDef contains SignatureDefs with the following keys:'\n )\n",
"VAR_16 = 'SignatureDef key: '\n",
"VAR_17 = ['\"classify_x2_to_y3\"', '\"classify_x_to_y\"', '\"regress_x2_to_y3\"',\n '\"regress_x_to_y\"', '\"regress_x_to_y2\"', '\"serving_default\"']\n",
"self.assertMultiLineEqual(VAR_11, '\\n'.join([VAR_15] + [(VAR_16 + exp_key) for\n exp_key in VAR_17]))\n",
"self.assertEqual(err.getvalue().strip(), '')\n"
] | [
"def testShowCommandSignature(self):...\n",
"base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n",
"self.parser = saved_model_cli.create_parser()\n",
"args = self.parser.parse_args(['show', '--dir', base_path, '--tag_set',\n 'serve'])\n",
"saved_model_cli.show(args)\n",
"output = out.getvalue().strip()\n",
"exp_header = (\n 'The given SavedModel MetaGraphDef contains SignatureDefs with the following keys:'\n )\n",
"exp_start = 'SignatureDef key: '\n",
"exp_keys = ['\"classify_x2_to_y3\"', '\"classify_x_to_y\"',\n '\"regress_x2_to_y3\"', '\"regress_x_to_y\"', '\"regress_x_to_y2\"',\n '\"serving_default\"']\n",
"self.assertMultiLineEqual(output, '\\n'.join([exp_header] + [(exp_start +\n exp_key) for exp_key in exp_keys]))\n",
"self.assertEqual(err.getvalue().strip(), '')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_6(self, VAR_12):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_15 = {rq for rq in VAR_12 if not rq.key_ready.called}\n",
"async def FUNC_14():...\n",
"for f in self._key_fetchers:\n",
"VAR_0.error('Unexpected error in _get_server_verify_keys: %s', err)\n",
"run_in_background(FUNC_14)\n",
"if not VAR_15:\n",
"while VAR_15:\n",
"for VAR_1 in VAR_15:\n",
"return\n",
"await self._attempt_key_fetches_with_fetcher(f, VAR_15)\n",
"VAR_1 = VAR_15.pop()\n",
"if not VAR_1.key_ready.called:\n",
"VAR_60 = 'VerifyJsonRequest(server=%s, key_ids=%s, min_valid=%i)' % (VAR_1.\n server_name, VAR_1.key_ids, VAR_1.minimum_valid_until_ts)\n",
"VAR_1.key_ready.errback(err)\n",
"self.clock.call_later(0, VAR_1.key_ready.errback, SynapseError(401, \n 'Failed to find any key to satisfy %s' % (VAR_60,), Codes.UNAUTHORIZED))\n"
] | [
"def _get_server_verify_keys(self, verify_requests):...\n",
"\"\"\"docstring\"\"\"\n",
"remaining_requests = {rq for rq in verify_requests if not rq.key_ready.called}\n",
"async def do_iterations():...\n",
"for f in self._key_fetchers:\n",
"logger.error('Unexpected error in _get_server_verify_keys: %s', err)\n",
"run_in_background(do_iterations)\n",
"if not remaining_requests:\n",
"while remaining_requests:\n",
"for verify_request in remaining_requests:\n",
"return\n",
"await self._attempt_key_fetches_with_fetcher(f, remaining_requests)\n",
"verify_request = remaining_requests.pop()\n",
"if not verify_request.key_ready.called:\n",
"rq_str = 'VerifyJsonRequest(server=%s, key_ids=%s, min_valid=%i)' % (\n verify_request.server_name, verify_request.key_ids, verify_request.\n minimum_valid_until_ts)\n",
"verify_request.key_ready.errback(err)\n",
"self.clock.call_later(0, verify_request.key_ready.errback, SynapseError(401,\n 'Failed to find any key to satisfy %s' % (rq_str,), Codes.UNAUTHORIZED))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"AsyncFunctionDef'",
"For",
"Expr'",
"Expr'",
"Condition",
"Condition",
"For",
"Return'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_14(self, VAR_1):...\n",
"VAR_5 = VAR_1.MagicMock()\n",
"VAR_26 = VAR_1.MagicMock()\n",
"VAR_23 = oai.Schema(type='array')\n",
"from openapi_python_client.parser.properties import property_from_data\n",
"VAR_4 = property_from_data(VAR_5=name, VAR_26=required, VAR_23=data)\n",
"assert VAR_4 == PropertyError(VAR_23=data, detail=\n 'type array must have items defined')\n"
] | [
"def test_property_from_data_array_no_items(self, mocker):...\n",
"name = mocker.MagicMock()\n",
"required = mocker.MagicMock()\n",
"data = oai.Schema(type='array')\n",
"from openapi_python_client.parser.properties import property_from_data\n",
"p = property_from_data(name=name, required=required, data=data)\n",
"assert p == PropertyError(data=data, detail=\n 'type array must have items defined')\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"ImportFrom'",
"Assign'",
"Assert'"
] |
[
"def FUNC_1(self, **VAR_4):...\n",
"VAR_15 = super(CLASS_0, self).get_context_data(**kwargs)\n",
"VAR_15['layout'] = self.layout\n",
"VAR_15['csrf_token_str'] = get_token(self.request)\n",
"VAR_15['current_cell_coords'] = self.current_cell_coords\n",
"VAR_15['current_cell'] = self.current_cell\n",
"VAR_15['form'] = self.form\n",
"VAR_15['changed'] = self.changed\n",
"VAR_15['cell_limit'] = VAR_0\n",
"return VAR_15\n"
] | [
"def get_context_data(self, **kwargs):...\n",
"ctx = super(EditorView, self).get_context_data(**kwargs)\n",
"ctx['layout'] = self.layout\n",
"ctx['csrf_token_str'] = get_token(self.request)\n",
"ctx['current_cell_coords'] = self.current_cell_coords\n",
"ctx['current_cell'] = self.current_cell\n",
"ctx['form'] = self.form\n",
"ctx['changed'] = self.changed\n",
"ctx['cell_limit'] = ROW_CELL_LIMIT\n",
"return ctx\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_2(self, VAR_14):...\n",
"\"\"\"docstring\"\"\"\n",
"return VAR_19(VAR_14)\n"
] | [
"def escape(self, text):...\n",
"\"\"\"docstring\"\"\"\n",
"return escape(text)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"from __future__ import unicode_literals\n",
"import frappe\n",
"import json, datetime\n",
"from frappe import _, scrub\n",
"import frappe.desk.query_report\n",
"from frappe.utils import cint, cstr\n",
"from frappe.model.document import Document\n",
"from frappe.modules.export_file import export_to_files\n",
"from frappe.modules import make_boilerplate\n",
"from frappe.core.doctype.page.page import delete_custom_role\n",
"from frappe.core.doctype.custom_role.custom_role import get_custom_allowed_roles\n",
"from frappe.desk.reportview import append_totals_row\n",
"from six import iteritems\n",
"from frappe.utils.safe_exec import safe_exec\n",
"def FUNC_4(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.module:\n",
"self.module = frappe.db.get_value('DocType', self.ref_doctype, 'module')\n",
"if not self.is_standard:\n",
"self.is_standard = 'No'\n",
"if self.is_standard == 'No':\n",
"if frappe.session.user == 'Administrator' and getattr(frappe.local.conf,\n",
"if self.report_type != 'Report Builder':\n",
"if self.is_standard == 'Yes' and frappe.session.user != 'Administrator':\n",
"self.is_standard = 'Yes'\n",
"frappe.only_for('Script Manager', True)\n",
"if frappe.db.get_value('Report', self.name, 'is_standard') == 'Yes':\n",
"frappe.throw(_(\n 'Only Administrator can save a standard report. Please rename and save.'))\n",
"if self.report_type == 'Report Builder':\n",
"frappe.throw(_(\n 'Cannot edit a standard report. Please duplicate and create a new report'))\n",
"self.update_report_json()\n",
"def FUNC_5(self):...\n",
"self.set_doctype_roles()\n",
"def FUNC_6(self):...\n",
"self.export_doc()\n",
"def FUNC_7(self):...\n",
"if self.is_standard == 'Yes' and not cint(getattr(frappe.local.conf,\n",
"frappe.throw(_('You are not allowed to delete Standard Report'))\n",
"delete_custom_role('report', self.name)\n",
"def FUNC_8(self):...\n",
"return [d.as_dict(no_default_fields=True) for d in self.columns]\n"
] | [
"from __future__ import unicode_literals\n",
"import frappe\n",
"import json, datetime\n",
"from frappe import _, scrub\n",
"import frappe.desk.query_report\n",
"from frappe.utils import cint, cstr\n",
"from frappe.model.document import Document\n",
"from frappe.modules.export_file import export_to_files\n",
"from frappe.modules import make_boilerplate\n",
"from frappe.core.doctype.page.page import delete_custom_role\n",
"from frappe.core.doctype.custom_role.custom_role import get_custom_allowed_roles\n",
"from frappe.desk.reportview import append_totals_row\n",
"from six import iteritems\n",
"from frappe.utils.safe_exec import safe_exec\n",
"def validate(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.module:\n",
"self.module = frappe.db.get_value('DocType', self.ref_doctype, 'module')\n",
"if not self.is_standard:\n",
"self.is_standard = 'No'\n",
"if self.is_standard == 'No':\n",
"if frappe.session.user == 'Administrator' and getattr(frappe.local.conf,\n",
"if self.report_type != 'Report Builder':\n",
"if self.is_standard == 'Yes' and frappe.session.user != 'Administrator':\n",
"self.is_standard = 'Yes'\n",
"frappe.only_for('Script Manager', True)\n",
"if frappe.db.get_value('Report', self.name, 'is_standard') == 'Yes':\n",
"frappe.throw(_(\n 'Only Administrator can save a standard report. Please rename and save.'))\n",
"if self.report_type == 'Report Builder':\n",
"frappe.throw(_(\n 'Cannot edit a standard report. Please duplicate and create a new report'))\n",
"self.update_report_json()\n",
"def before_insert(self):...\n",
"self.set_doctype_roles()\n",
"def on_update(self):...\n",
"self.export_doc()\n",
"def on_trash(self):...\n",
"if self.is_standard == 'Yes' and not cint(getattr(frappe.local.conf,\n",
"frappe.throw(_('You are not allowed to delete Standard Report'))\n",
"delete_custom_role('report', self.name)\n",
"def get_columns(self):...\n",
"return [d.as_dict(no_default_fields=True) for d in self.columns]\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
] | [
"ImportFrom'",
"Import'",
"Import'",
"ImportFrom'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Condition",
"Expr'",
"Expr'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_23(VAR_27):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_27.is_valid:\n",
"return HttpResponseBadRequest(_('This invoice is already active.'))\n",
"VAR_27.is_valid = True\n",
"VAR_27.save()\n",
"VAR_74 = _('The registration codes for invoice {0} have been re-activated.'\n ).format(VAR_27.id)\n",
"return JsonResponse({'message': VAR_74})\n"
] | [
"def re_validate_invoice(obj_invoice):...\n",
"\"\"\"docstring\"\"\"\n",
"if obj_invoice.is_valid:\n",
"return HttpResponseBadRequest(_('This invoice is already active.'))\n",
"obj_invoice.is_valid = True\n",
"obj_invoice.save()\n",
"message = _('The registration codes for invoice {0} have been re-activated.'\n ).format(obj_invoice.id)\n",
"return JsonResponse({'message': message})\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_9(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return u'%(color)s[%(levelname)1.1s %(asctime)s.%(msecs).03d %(name)s]%(end_color)s %(message)s'\n"
] | [
"def _log_format_default(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return u'%(color)s[%(levelname)1.1s %(asctime)s.%(msecs).03d %(name)s]%(end_color)s %(message)s'\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"@VAR_0.route('/admin/book/convert/<int:book_id>', methods=['POST'])...\n",
"VAR_77 = VAR_33.form.get('book_format_from', None)\n",
"VAR_78 = VAR_33.form.get('book_format_to', None)\n",
"if VAR_77 is None or VAR_78 is None:\n",
"flash(_(u'Source or destination format for conversion missing'), category=\n 'error')\n",
"VAR_1.info('converting: book id: %s from: %s to: %s', VAR_14, VAR_77, VAR_78)\n",
"return redirect(url_for('editbook.edit_book', VAR_14=book_id))\n",
"VAR_79 = helper.convert_book_format(VAR_14, config.config_calibre_dir,\n VAR_77.upper(), VAR_78.upper(), current_user.name)\n",
"if VAR_79 is None:\n",
"flash(_(u'Book successfully queued for converting to %(book_format)s',\n VAR_15=book_format_to), category='success')\n",
"flash(_(u'There was an error converting this book: %(res)s', res=rtn),\n category='error')\n",
"return redirect(url_for('editbook.edit_book', VAR_14=book_id))\n"
] | [
"@editbook.route('/admin/book/convert/<int:book_id>', methods=['POST'])...\n",
"book_format_from = request.form.get('book_format_from', None)\n",
"book_format_to = request.form.get('book_format_to', None)\n",
"if book_format_from is None or book_format_to is None:\n",
"flash(_(u'Source or destination format for conversion missing'), category=\n 'error')\n",
"log.info('converting: book id: %s from: %s to: %s', book_id,\n book_format_from, book_format_to)\n",
"return redirect(url_for('editbook.edit_book', book_id=book_id))\n",
"rtn = helper.convert_book_format(book_id, config.config_calibre_dir,\n book_format_from.upper(), book_format_to.upper(), current_user.name)\n",
"if rtn is None:\n",
"flash(_(u'Book successfully queued for converting to %(book_format)s',\n book_format=book_format_to), category='success')\n",
"flash(_(u'There was an error converting this book: %(res)s', res=rtn),\n category='error')\n",
"return redirect(url_for('editbook.edit_book', book_id=book_id))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Return'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Return'"
] |
[
"@VAR_2.route('/ajax/domainlist/<int:allow>')...\n",
"VAR_64 = ub.session.query(ub.Registration).filter(ub.Registration.allow ==\n VAR_7).all()\n",
"VAR_67 = json.dumps([{'domain': r.domain.replace('%', '*').replace('_', '?'\n ), 'id': r.id} for r in VAR_64])\n",
"VAR_68 = json.dumps(VAR_67.replace('\"', \"'\")).lstrip('\"').strip('\"')\n",
"VAR_52 = make_response(VAR_68.replace(\"'\", '\"'))\n",
"VAR_52.headers['Content-Type'] = 'application/json; charset=utf-8'\n",
"return VAR_52\n"
] | [
"@admi.route('/ajax/domainlist/<int:allow>')...\n",
"answer = ub.session.query(ub.Registration).filter(ub.Registration.allow ==\n allow).all()\n",
"json_dumps = json.dumps([{'domain': r.domain.replace('%', '*').replace('_',\n '?'), 'id': r.id} for r in answer])\n",
"js = json.dumps(json_dumps.replace('\"', \"'\")).lstrip('\"').strip('\"')\n",
"response = make_response(js.replace(\"'\", '\"'))\n",
"response.headers['Content-Type'] = 'application/json; charset=utf-8'\n",
"return response\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@VAR_0.route('/api/jobs/<int:job_id>/subjobs/<int:subjob_id>', methods=['GET'])...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_104 = FUNC_58(f'/internal/jobs/{VAR_9}/subjobs/{VAR_11}', 'get')\n",
"return jsonify({'success': False, 'message': str(err)}), 400\n",
"return jsonify(VAR_104)\n"
] | [
"@gui.route('/api/jobs/<int:job_id>/subjobs/<int:subjob_id>', methods=['GET'])...\n",
"\"\"\"docstring\"\"\"\n",
"subjob_info = query_internal_api(f'/internal/jobs/{job_id}/subjobs/{subjob_id}'\n , 'get')\n",
"return jsonify({'success': False, 'message': str(err)}), 400\n",
"return jsonify(subjob_info)\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'",
"Return'"
] |
[
"def FUNC_3(self, VAR_3, VAR_4):...\n",
"return django.forms.DateTimeField(**options)\n"
] | [
"def create_datetime_field(self, field, options):...\n",
"return django.forms.DateTimeField(**options)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"VAR_8 = self.register_user('kermit', 'test')\n",
"VAR_9 = self.login('kermit', 'test')\n",
"VAR_6 = self.helper.create_room_as(room_creator=user_id, VAR_9=tok)\n",
"VAR_10 = 'sometoken'\n",
"self.helper.send_state(VAR_6=room_id, event_type=EventTypes.\n ThirdPartyInvite, state_key=invite_token, body={}, VAR_9=tok)\n",
"VAR_11 = self.handler.on_exchange_third_party_invite_request(event_dict={\n 'type': EventTypes.Member, 'room_id': room_id, 'sender': user_id,\n 'state_key': '@someone:example.org', 'content': {'membership': 'invite',\n 'third_party_invite': {'display_name': 'alice', 'signed': {'mxid':\n '@alice:localhost', 'token': invite_token, 'signatures': {\n 'magic.forest': {'ed25519:3':\n 'fQpGIW1Snz+pwLZu6sTy2aHy/DYWWTspTJRPyNp0PKkymfIsNffysMl6ObMMFdIJhk6g6pwlIqZ54rxo8SLmAg'\n }}}}}})\n",
"VAR_12 = self.get_failure(VAR_11, AuthError).value\n",
"self.assertEqual(VAR_12.code, 403, VAR_12)\n",
"self.assertEqual(VAR_12.errcode, Codes.FORBIDDEN, VAR_12)\n",
"self.assertEqual(VAR_12.msg, 'You are not invited to this room.')\n"
] | [
"def test_exchange_revoked_invite(self):...\n",
"user_id = self.register_user('kermit', 'test')\n",
"tok = self.login('kermit', 'test')\n",
"room_id = self.helper.create_room_as(room_creator=user_id, tok=tok)\n",
"invite_token = 'sometoken'\n",
"self.helper.send_state(room_id=room_id, event_type=EventTypes.\n ThirdPartyInvite, state_key=invite_token, body={}, tok=tok)\n",
"d = self.handler.on_exchange_third_party_invite_request(event_dict={'type':\n EventTypes.Member, 'room_id': room_id, 'sender': user_id, 'state_key':\n '@someone:example.org', 'content': {'membership': 'invite',\n 'third_party_invite': {'display_name': 'alice', 'signed': {'mxid':\n '@alice:localhost', 'token': invite_token, 'signatures': {\n 'magic.forest': {'ed25519:3':\n 'fQpGIW1Snz+pwLZu6sTy2aHy/DYWWTspTJRPyNp0PKkymfIsNffysMl6ObMMFdIJhk6g6pwlIqZ54rxo8SLmAg'\n }}}}}})\n",
"failure = self.get_failure(d, AuthError).value\n",
"self.assertEqual(failure.code, 403, failure)\n",
"self.assertEqual(failure.errcode, Codes.FORBIDDEN, failure)\n",
"self.assertEqual(failure.msg, 'You are not invited to this room.')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_30(VAR_27):...\n",
"print(VAR_26 + VAR_27)\n"
] | [
"def in_print(s):...\n",
"print(indent_str + s)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@pyqtSlot('QNetworkReply*', 'QAuthenticator*')...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_30 = False\n",
"if not self.netrc_used:\n",
"self.netrc_used = True\n",
"if not VAR_30:\n",
"VAR_30 = shared.netrc_authentication(VAR_16.url(), VAR_19)\n",
"VAR_28 = self._get_abort_signals(VAR_16)\n",
"shared.authentication_required(VAR_16.url(), VAR_19, VAR_28=abort_on)\n"
] | [
"@pyqtSlot('QNetworkReply*', 'QAuthenticator*')...\n",
"\"\"\"docstring\"\"\"\n",
"netrc_success = False\n",
"if not self.netrc_used:\n",
"self.netrc_used = True\n",
"if not netrc_success:\n",
"netrc_success = shared.netrc_authentication(reply.url(), authenticator)\n",
"abort_on = self._get_abort_signals(reply)\n",
"shared.authentication_required(reply.url(), authenticator, abort_on=abort_on)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'"
] |
[
"@contextlib.contextmanager...\n",
""
] | [
"@contextlib.contextmanager...\n",
""
] | [
0,
0
] | [
"Condition",
"Condition"
] |
[
"@VAR_0.route('/api/jobs/create', methods=['POST'])...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_13 = {'template_id': request.json.get('template_id'), 'job_name':\n request.json.get('job_name')}\n",
"VAR_98 = FUNC_58('/internal/jobs/create', 'post', json=data)\n",
"return jsonify({'success': False, 'message': str(err)}), 400\n",
"return jsonify(VAR_98)\n"
] | [
"@gui.route('/api/jobs/create', methods=['POST'])...\n",
"\"\"\"docstring\"\"\"\n",
"data = {'template_id': request.json.get('template_id'), 'job_name': request\n .json.get('job_name')}\n",
"response_info = query_internal_api('/internal/jobs/create', 'post', json=data)\n",
"return jsonify({'success': False, 'message': str(err)}), 400\n",
"return jsonify(response_info)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Return'",
"Return'"
] |
[
"def FUNC_32(self):...\n",
"self.login()\n",
"VAR_3 = self.client.post('/password_change/', {'old_password': 'password',\n 'new_password1': 'password1', 'new_password2': 'password1'})\n",
"self.assertEqual(VAR_3.status_code, 302)\n",
"self.assertURLEqual(VAR_3.url, '/password_change/done/')\n"
] | [
"def test_password_change_done_succeeds(self):...\n",
"self.login()\n",
"response = self.client.post('/password_change/', {'old_password':\n 'password', 'new_password1': 'password1', 'new_password2': 'password1'})\n",
"self.assertEqual(response.status_code, 302)\n",
"self.assertURLEqual(response.url, '/password_change/done/')\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"import logging\n",
"from prometheus_client import Counter\n",
"from twisted.internet.error import AlreadyCalled, AlreadyCancelled\n",
"from synapse.api.constants import EventTypes\n",
"from synapse.logging import opentracing\n",
"from synapse.metrics.background_process_metrics import run_as_background_process\n",
"from synapse.push import PusherConfigException\n",
"from synapse.types import RoomStreamToken\n",
"from . import push_rule_evaluator, push_tools\n",
"VAR_0 = logging.getLogger(__name__)\n",
"VAR_1 = Counter('synapse_http_httppusher_http_pushes_processed',\n 'Number of push notifications successfully sent')\n",
"VAR_2 = Counter('synapse_http_httppusher_http_pushes_failed',\n 'Number of push notifications which failed')\n",
"VAR_3 = Counter('synapse_http_httppusher_badge_updates_processed',\n 'Number of badge updates successfully sent')\n",
"VAR_4 = Counter('synapse_http_httppusher_badge_updates_failed',\n 'Number of badge updates which failed')\n",
"VAR_5 = 1\n",
"VAR_6 = 60 * 60\n",
"VAR_7 = 24 * 60 * 60 * 1000\n",
"def __init__(self, VAR_8, VAR_9):...\n",
"self.hs = VAR_8\n",
"self.store = self.hs.get_datastore()\n",
"self.storage = self.hs.get_storage()\n",
"self.clock = self.hs.get_clock()\n",
"self.state_handler = self.hs.get_state_handler()\n",
"self.user_id = VAR_9['user_name']\n",
"self.app_id = VAR_9['app_id']\n",
"self.app_display_name = VAR_9['app_display_name']\n",
"self.device_display_name = VAR_9['device_display_name']\n",
"self.pushkey = VAR_9['pushkey']\n",
"self.pushkey_ts = VAR_9['ts']\n",
"self.data = VAR_9['data']\n",
"self.last_stream_ordering = VAR_9['last_stream_ordering']\n",
"self.backoff_delay = CLASS_0.INITIAL_BACKOFF_SEC\n",
"self.failing_since = VAR_9['failing_since']\n",
"self.timed_call = None\n",
"self._is_processing = False\n",
"self._group_unread_count_by_room = VAR_8.config.push_group_unread_count_by_room\n",
"self.max_stream_ordering = None\n",
"if 'data' not in VAR_9:\n",
"self.data = VAR_9['data']\n",
"self.name = '%s/%s/%s' % (VAR_9['user_name'], VAR_9['app_id'], VAR_9['pushkey']\n )\n",
"if self.data is None:\n",
"if 'url' not in self.data:\n",
"self.url = self.data['url']\n",
"self.http_client = VAR_8.get_proxied_http_client()\n",
"self.data_minus_url = {}\n",
"self.data_minus_url.update(self.data)\n",
"def FUNC_0(self, VAR_10):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_10:\n",
"self._start_processing()\n",
"def FUNC_1(self, VAR_11: RoomStreamToken):...\n",
"VAR_18 = VAR_11.stream\n",
"self.max_stream_ordering = max(VAR_18, self.max_stream_ordering or 0)\n",
"self._start_processing()\n",
"def FUNC_2(self, VAR_12, VAR_13):...\n",
"run_as_background_process('http_pusher.on_new_receipts', self._update_badge)\n",
"async def FUNC_3(self):...\n",
"VAR_17 = await push_tools.get_badge_count(self.hs.get_datastore(), self.\n user_id, group_by_room=self._group_unread_count_by_room)\n",
"await self._send_badge(VAR_17)\n",
"def FUNC_4(self):...\n",
"self._start_processing()\n",
"def FUNC_5(self):...\n",
"if self.timed_call:\n",
"def FUNC_6(self):...\n",
"self.timed_call.cancel()\n",
"self.timed_call = None\n",
"if self._is_processing:\n",
"return\n",
"run_as_background_process('httppush.process', self._process)\n",
"async def FUNC_7(self):...\n",
"assert not self._is_processing\n",
"self._is_processing = True\n",
"self._is_processing = False\n",
"async def FUNC_8(self):...\n",
"while True:\n",
"\"\"\"docstring\"\"\"\n",
"VAR_27 = self.max_stream_ordering\n",
"VAR_19 = self.store.get_unread_push_actions_for_user_in_range_for_http\n",
"await self._unsafe_process()\n",
"VAR_0.exception('Exception processing notifs')\n",
"if self.max_stream_ordering == VAR_27:\n",
"VAR_20 = await VAR_19(self.user_id, self.last_stream_ordering, self.\n max_stream_ordering)\n",
"VAR_0.info(\n 'Processing %i unprocessed push actions for %s starting at stream_ordering %s'\n , len(VAR_20), self.name, self.last_stream_ordering)\n",
"for VAR_14 in VAR_20:\n",
"VAR_28 = await self._process_one(VAR_14)\n",
"async def FUNC_9(self, VAR_14):...\n",
"if VAR_28:\n",
"if 'notify' not in VAR_14['actions']:\n",
"VAR_1.inc()\n",
"VAR_2.inc()\n",
"return True\n",
"VAR_16 = push_rule_evaluator.tweaks_for_actions(VAR_14['actions'])\n",
"self.backoff_delay = CLASS_0.INITIAL_BACKOFF_SEC\n",
"if not self.failing_since:\n",
"VAR_17 = await push_tools.get_badge_count(self.hs.get_datastore(), self.\n user_id, group_by_room=self._group_unread_count_by_room)\n",
"self.last_stream_ordering = VAR_14['stream_ordering']\n",
"self.failing_since = self.clock.time_msec()\n",
"if self.failing_since and self.failing_since < self.clock.time_msec(\n",
"VAR_15 = await self.store.get_event(VAR_14['event_id'], allow_none=True)\n",
"VAR_29 = await self.store.update_pusher_last_stream_ordering_and_success(self\n .app_id, self.pushkey, self.user_id, self.last_stream_ordering, self.\n clock.time_msec())\n",
"await self.store.update_pusher_failing_since(self.app_id, self.pushkey,\n self.user_id, self.failing_since)\n",
"VAR_0.warning('Giving up on a notification to user %s, pushkey %s', self.\n user_id, self.pushkey)\n",
"VAR_0.info('Push failed: delaying for %ds', self.backoff_delay)\n",
"if VAR_15 is None:\n",
"if not VAR_29:\n",
"self.backoff_delay = CLASS_0.INITIAL_BACKOFF_SEC\n",
"self.timed_call = self.hs.get_reactor().callLater(self.backoff_delay, self.\n on_timer)\n",
"return True\n",
"VAR_21 = await self.dispatch_push(VAR_15, VAR_16, VAR_17)\n",
"self.on_stop()\n",
"if self.failing_since:\n",
"self.last_stream_ordering = VAR_14['stream_ordering']\n",
"self.backoff_delay = min(self.backoff_delay * 2, self.MAX_BACKOFF_SEC)\n",
"if VAR_21 is False:\n",
"return\n",
"self.failing_since = None\n",
"VAR_29 = await self.store.update_pusher_last_stream_ordering(self.app_id,\n self.pushkey, self.user_id, self.last_stream_ordering)\n",
"return False\n",
"if isinstance(VAR_21, list) or isinstance(VAR_21, tuple):\n",
"await self.store.update_pusher_failing_since(self.app_id, self.pushkey,\n self.user_id, self.failing_since)\n",
"if not VAR_29:\n",
"for pk in VAR_21:\n",
"return True\n",
"self.on_stop()\n",
"self.failing_since = None\n",
"if pk != self.pushkey:\n",
"return\n",
"await self.store.update_pusher_failing_since(self.app_id, self.pushkey,\n self.user_id, self.failing_since)\n",
"VAR_0.warning(\"Ignoring rejected pushkey %s because we didn't send it\", pk)\n",
"VAR_0.info('Pushkey %s was rejected: removing', pk)\n",
"await self.hs.remove_pusher(self.app_id, pk, self.user_id)\n"
] | [
"import logging\n",
"from prometheus_client import Counter\n",
"from twisted.internet.error import AlreadyCalled, AlreadyCancelled\n",
"from synapse.api.constants import EventTypes\n",
"from synapse.logging import opentracing\n",
"from synapse.metrics.background_process_metrics import run_as_background_process\n",
"from synapse.push import PusherConfigException\n",
"from synapse.types import RoomStreamToken\n",
"from . import push_rule_evaluator, push_tools\n",
"logger = logging.getLogger(__name__)\n",
"http_push_processed_counter = Counter(\n 'synapse_http_httppusher_http_pushes_processed',\n 'Number of push notifications successfully sent')\n",
"http_push_failed_counter = Counter('synapse_http_httppusher_http_pushes_failed'\n , 'Number of push notifications which failed')\n",
"http_badges_processed_counter = Counter(\n 'synapse_http_httppusher_badge_updates_processed',\n 'Number of badge updates successfully sent')\n",
"http_badges_failed_counter = Counter(\n 'synapse_http_httppusher_badge_updates_failed',\n 'Number of badge updates which failed')\n",
"INITIAL_BACKOFF_SEC = 1\n",
"MAX_BACKOFF_SEC = 60 * 60\n",
"GIVE_UP_AFTER_MS = 24 * 60 * 60 * 1000\n",
"def __init__(self, hs, pusherdict):...\n",
"self.hs = hs\n",
"self.store = self.hs.get_datastore()\n",
"self.storage = self.hs.get_storage()\n",
"self.clock = self.hs.get_clock()\n",
"self.state_handler = self.hs.get_state_handler()\n",
"self.user_id = pusherdict['user_name']\n",
"self.app_id = pusherdict['app_id']\n",
"self.app_display_name = pusherdict['app_display_name']\n",
"self.device_display_name = pusherdict['device_display_name']\n",
"self.pushkey = pusherdict['pushkey']\n",
"self.pushkey_ts = pusherdict['ts']\n",
"self.data = pusherdict['data']\n",
"self.last_stream_ordering = pusherdict['last_stream_ordering']\n",
"self.backoff_delay = HttpPusher.INITIAL_BACKOFF_SEC\n",
"self.failing_since = pusherdict['failing_since']\n",
"self.timed_call = None\n",
"self._is_processing = False\n",
"self._group_unread_count_by_room = hs.config.push_group_unread_count_by_room\n",
"self.max_stream_ordering = None\n",
"if 'data' not in pusherdict:\n",
"self.data = pusherdict['data']\n",
"self.name = '%s/%s/%s' % (pusherdict['user_name'], pusherdict['app_id'],\n pusherdict['pushkey'])\n",
"if self.data is None:\n",
"if 'url' not in self.data:\n",
"self.url = self.data['url']\n",
"self.http_client = hs.get_proxied_http_client()\n",
"self.data_minus_url = {}\n",
"self.data_minus_url.update(self.data)\n",
"def on_started(self, should_check_for_notifs):...\n",
"\"\"\"docstring\"\"\"\n",
"if should_check_for_notifs:\n",
"self._start_processing()\n",
"def on_new_notifications(self, max_token: RoomStreamToken):...\n",
"max_stream_ordering = max_token.stream\n",
"self.max_stream_ordering = max(max_stream_ordering, self.\n max_stream_ordering or 0)\n",
"self._start_processing()\n",
"def on_new_receipts(self, min_stream_id, max_stream_id):...\n",
"run_as_background_process('http_pusher.on_new_receipts', self._update_badge)\n",
"async def _update_badge(self):...\n",
"badge = await push_tools.get_badge_count(self.hs.get_datastore(), self.\n user_id, group_by_room=self._group_unread_count_by_room)\n",
"await self._send_badge(badge)\n",
"def on_timer(self):...\n",
"self._start_processing()\n",
"def on_stop(self):...\n",
"if self.timed_call:\n",
"def _start_processing(self):...\n",
"self.timed_call.cancel()\n",
"self.timed_call = None\n",
"if self._is_processing:\n",
"return\n",
"run_as_background_process('httppush.process', self._process)\n",
"async def _process(self):...\n",
"assert not self._is_processing\n",
"self._is_processing = True\n",
"self._is_processing = False\n",
"async def _unsafe_process(self):...\n",
"while True:\n",
"\"\"\"docstring\"\"\"\n",
"starting_max_ordering = self.max_stream_ordering\n",
"fn = self.store.get_unread_push_actions_for_user_in_range_for_http\n",
"await self._unsafe_process()\n",
"logger.exception('Exception processing notifs')\n",
"if self.max_stream_ordering == starting_max_ordering:\n",
"unprocessed = await fn(self.user_id, self.last_stream_ordering, self.\n max_stream_ordering)\n",
"logger.info(\n 'Processing %i unprocessed push actions for %s starting at stream_ordering %s'\n , len(unprocessed), self.name, self.last_stream_ordering)\n",
"for push_action in unprocessed:\n",
"processed = await self._process_one(push_action)\n",
"async def _process_one(self, push_action):...\n",
"if processed:\n",
"if 'notify' not in push_action['actions']:\n",
"http_push_processed_counter.inc()\n",
"http_push_failed_counter.inc()\n",
"return True\n",
"tweaks = push_rule_evaluator.tweaks_for_actions(push_action['actions'])\n",
"self.backoff_delay = HttpPusher.INITIAL_BACKOFF_SEC\n",
"if not self.failing_since:\n",
"badge = await push_tools.get_badge_count(self.hs.get_datastore(), self.\n user_id, group_by_room=self._group_unread_count_by_room)\n",
"self.last_stream_ordering = push_action['stream_ordering']\n",
"self.failing_since = self.clock.time_msec()\n",
"if self.failing_since and self.failing_since < self.clock.time_msec(\n",
"event = await self.store.get_event(push_action['event_id'], allow_none=True)\n",
"pusher_still_exists = (await self.store.\n update_pusher_last_stream_ordering_and_success(self.app_id, self.\n pushkey, self.user_id, self.last_stream_ordering, self.clock.time_msec()))\n",
"await self.store.update_pusher_failing_since(self.app_id, self.pushkey,\n self.user_id, self.failing_since)\n",
"logger.warning('Giving up on a notification to user %s, pushkey %s', self.\n user_id, self.pushkey)\n",
"logger.info('Push failed: delaying for %ds', self.backoff_delay)\n",
"if event is None:\n",
"if not pusher_still_exists:\n",
"self.backoff_delay = HttpPusher.INITIAL_BACKOFF_SEC\n",
"self.timed_call = self.hs.get_reactor().callLater(self.backoff_delay, self.\n on_timer)\n",
"return True\n",
"rejected = await self.dispatch_push(event, tweaks, badge)\n",
"self.on_stop()\n",
"if self.failing_since:\n",
"self.last_stream_ordering = push_action['stream_ordering']\n",
"self.backoff_delay = min(self.backoff_delay * 2, self.MAX_BACKOFF_SEC)\n",
"if rejected is False:\n",
"return\n",
"self.failing_since = None\n",
"pusher_still_exists = await self.store.update_pusher_last_stream_ordering(self\n .app_id, self.pushkey, self.user_id, self.last_stream_ordering)\n",
"return False\n",
"if isinstance(rejected, list) or isinstance(rejected, tuple):\n",
"await self.store.update_pusher_failing_since(self.app_id, self.pushkey,\n self.user_id, self.failing_since)\n",
"if not pusher_still_exists:\n",
"for pk in rejected:\n",
"return True\n",
"self.on_stop()\n",
"self.failing_since = None\n",
"if pk != self.pushkey:\n",
"return\n",
"await self.store.update_pusher_failing_since(self.app_id, self.pushkey,\n self.user_id, self.failing_since)\n",
"logger.warning(\"Ignoring rejected pushkey %s because we didn't send it\", pk)\n",
"logger.info('Pushkey %s was rejected: removing', pk)\n",
"await self.hs.remove_pusher(self.app_id, pk, self.user_id)\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,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"FunctionDef'",
"Expr'",
"AsyncFunctionDef'",
"Assign'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Condition",
"FunctionDef'",
"Expr'",
"Assign'",
"Condition",
"Return'",
"Expr'",
"AsyncFunctionDef'",
"Assert'",
"Assign'",
"Assign'",
"AsyncFunctionDef'",
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"For",
"Assign'",
"AsyncFunctionDef'",
"Condition",
"Condition",
"Expr'",
"Expr'",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Return'",
"Condition",
"Expr'",
"Condition",
"For",
"Return'",
"Expr'",
"Assign'",
"Condition",
"Return'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_67(VAR_10):...\n",
"VAR_213 = {}\n",
"for VAR_30, VAR_108 in (['x', VAR_10.getPosX()], ['y', VAR_10.getPosY()]):\n",
"if VAR_108 is not None:\n",
"return VAR_213\n",
"VAR_213[VAR_30] = {'value': VAR_108.getValue(), 'unit': str(VAR_108.getUnit())}\n"
] | [
"def marshal_pos(w):...\n",
"d = {}\n",
"for x, p in (['x', w.getPosX()], ['y', w.getPosY()]):\n",
"if p is not None:\n",
"return d\n",
"d[x] = {'value': p.getValue(), 'unit': str(p.getUnit())}\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Condition",
"Return'",
"Assign'"
] |
[
"def FUNC_11(self, VAR_4, VAR_39, VAR_40):...\n",
"if VAR_40 == u'*':\n",
"self.ip = u''\n"
] | [
"def _ip_changed(self, name, old, new):...\n",
"if new == u'*':\n",
"self.ip = u''\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'"
] |
[
"def FUNC_31(self):...\n",
"self.parser = saved_model_cli.create_parser()\n",
"VAR_9 = test.test_src_dir_path(VAR_0)\n",
"VAR_44 = np.array([[1], [2]])\n",
"VAR_45 = np.zeros((6, 3))\n",
"VAR_31 = os.path.join(test.get_temp_dir(),\n 'testRunCommandOutOverwrite_inputs.npz')\n",
"np.savez(VAR_31, VAR_26=x, VAR_27=x_notused)\n",
"VAR_46 = os.path.join(test.get_temp_dir(), 'y.npy')\n",
"open(VAR_46, 'a').close()\n",
"VAR_10 = self.parser.parse_args(['run', '--dir', VAR_9, '--tag_set',\n 'serve', '--signature_def', 'serving_default', '--inputs', 'x=' +\n VAR_31 + '[x0]', '--outdir', test.get_temp_dir()])\n",
"saved_model_cli.run(VAR_10)\n"
] | [
"def testRunCommandOutputFileExistError(self):...\n",
"self.parser = saved_model_cli.create_parser()\n",
"base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n",
"x = np.array([[1], [2]])\n",
"x_notused = np.zeros((6, 3))\n",
"input_path = os.path.join(test.get_temp_dir(),\n 'testRunCommandOutOverwrite_inputs.npz')\n",
"np.savez(input_path, x0=x, x1=x_notused)\n",
"output_file = os.path.join(test.get_temp_dir(), 'y.npy')\n",
"open(output_file, 'a').close()\n",
"args = self.parser.parse_args(['run', '--dir', base_path, '--tag_set',\n 'serve', '--signature_def', 'serving_default', '--inputs', 'x=' +\n input_path + '[x0]', '--outdir', test.get_temp_dir()])\n",
"saved_model_cli.run(args)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_27(VAR_9, VAR_14, VAR_15=False, VAR_10=None):...\n",
"VAR_10 = VAR_10 or []\n",
"if not config.config_read_column:\n",
"if VAR_14:\n",
"if VAR_14:\n",
"VAR_3.error('Custom Column No.%d is not existing in calibre database',\n config.config_read_column)\n",
"if VAR_15:\n",
"VAR_126 = and_(ub.ReadBook.user_id == int(VAR_87.id), ub.ReadBook.\n read_status == ub.ReadBook.STATUS_FINISHED)\n",
"VAR_126 = coalesce(ub.ReadBook.read_status, 0) != ub.ReadBook.STATUS_FINISHED\n",
"VAR_126 = db.cc_classes[config.config_read_column].value == True\n",
"VAR_126 = coalesce(db.cc_classes[config.config_read_column].value, False\n ) != True\n",
"if not VAR_15:\n",
"return VAR_63, VAR_65\n",
"if VAR_14:\n",
"VAR_63, VAR_68, VAR_65 = calibre_db.fill_indexpage(VAR_9, 0, db.Books,\n VAR_126, VAR_10, db.books_series_link, db.Books.id == db.\n books_series_link.c.book, db.Series, ub.ReadBook, db.Books.id == ub.\n ReadBook.book_id)\n",
"VAR_63, VAR_68, VAR_65 = calibre_db.fill_indexpage(VAR_9, 0, db.Books,\n VAR_126, VAR_10, db.books_series_link, db.Books.id == db.\n books_series_link.c.book, db.Series, db.cc_classes[config.\n config_read_column])\n",
"flash(_('Custom Column No.%(column)d is not existing in calibre database',\n column=config.config_read_column), category='error')\n",
"VAR_13 = _(u'Read Books') + ' (' + str(VAR_65.total_count) + ')'\n",
"VAR_13 = _(u'Unread Books') + ' (' + str(VAR_65.total_count) + ')'\n",
"return redirect(url_for('web.index'))\n",
"VAR_72 = 'read'\n",
"VAR_72 = 'unread'\n",
"return render_title_template('index.html', VAR_68=random, VAR_63=entries,\n VAR_65=pagination, VAR_149=name, VAR_9=pagename)\n"
] | [
"def render_read_books(page, are_read, as_xml=False, order=None):...\n",
"order = order or []\n",
"if not config.config_read_column:\n",
"if are_read:\n",
"if are_read:\n",
"log.error('Custom Column No.%d is not existing in calibre database', config\n .config_read_column)\n",
"if as_xml:\n",
"db_filter = and_(ub.ReadBook.user_id == int(current_user.id), ub.ReadBook.\n read_status == ub.ReadBook.STATUS_FINISHED)\n",
"db_filter = coalesce(ub.ReadBook.read_status, 0) != ub.ReadBook.STATUS_FINISHED\n",
"db_filter = db.cc_classes[config.config_read_column].value == True\n",
"db_filter = coalesce(db.cc_classes[config.config_read_column].value, False\n ) != True\n",
"if not as_xml:\n",
"return entries, pagination\n",
"if are_read:\n",
"entries, random, pagination = calibre_db.fill_indexpage(page, 0, db.Books,\n db_filter, order, db.books_series_link, db.Books.id == db.\n books_series_link.c.book, db.Series, ub.ReadBook, db.Books.id == ub.\n ReadBook.book_id)\n",
"entries, random, pagination = calibre_db.fill_indexpage(page, 0, db.Books,\n db_filter, order, db.books_series_link, db.Books.id == db.\n books_series_link.c.book, db.Series, db.cc_classes[config.\n config_read_column])\n",
"flash(_('Custom Column No.%(column)d is not existing in calibre database',\n column=config.config_read_column), category='error')\n",
"name = _(u'Read Books') + ' (' + str(pagination.total_count) + ')'\n",
"name = _(u'Unread Books') + ' (' + str(pagination.total_count) + ')'\n",
"return redirect(url_for('web.index'))\n",
"pagename = 'read'\n",
"pagename = 'unread'\n",
"return render_title_template('index.html', random=random, entries=entries,\n pagination=pagination, title=name, page=pagename)\n"
] | [
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",
"Condition",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_0(VAR_0):...\n",
"VAR_2 = FUNC_2(VAR_0)\n",
"VAR_0.write('string' % VAR_0.cfg.url_prefix_static)\n",
"VAR_3 = []\n",
"for macro in FUNC_1(VAR_0):\n",
"if macro == 'BR':\n",
"VAR_0.write('\\n'.join(VAR_3))\n",
"VAR_35 = ' selected=\"selected\"'\n",
"VAR_35 = ''\n",
"VAR_0.write(\"\"\"\n </select>\n </td>\n <td id=\"help\">\"\"\")\n",
"if macro in VAR_2:\n",
"VAR_4 = []\n",
"VAR_3.append('<option value=\"%s\"%s>%s</option>' % (VAR_2[macro].group(\n 'prototype'), VAR_35, macro))\n",
"VAR_3.append('<option value=\"%s\"%s>%s</option>' % (macro, VAR_35, macro))\n",
"for macro in FUNC_1(VAR_0):\n",
"if macro in VAR_2:\n",
"VAR_0.write(''.join(VAR_4))\n",
"VAR_29 = VAR_2[macro]\n",
"VAR_36 = macro\n",
"VAR_0.write(\n \"\"\"\n </td>\n </tr>\n </table>\n </td>\n </tr>\n</table>\n</body>\n</html>\n\"\"\"\n )\n",
"VAR_36 = VAR_29.group('prototype')\n",
"VAR_37 = ''\n",
"VAR_37 = VAR_29.group('help')\n",
"VAR_4.append('string' % (VAR_36, VAR_36, VAR_37))\n"
] | [
"def macro_dialog(request):...\n",
"help = get_macro_help(request)\n",
"request.write(\n \"\"\"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n<html>\n <head>\n <title>Insert Macro</title>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n <meta content=\"noindex,nofollow\" name=\"robots\">\n <script src=\"%s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js\" type=\"text/javascript\"></script>\n <script language=\"javascript\">\n\nvar oEditor = window.parent.InnerDialogLoaded() ;\nvar FCKLang = oEditor.FCKLang ;\nvar FCKMacros = oEditor.FCKMacros ;\n\nwindow.onload = function ()\n{\n // First of all, translate the dialog box texts\n oEditor.FCKLanguageManager.TranslatePage( document ) ;\n\n OnChange( \"BR\" );\n\n // Show the \"Ok\" button.\n window.parent.SetOkButton( true ) ;\n}\n\nfunction Ok()\n{\n if ( document.getElementById('txtName').value.length == 0 )\n {\n alert( FCKLang.MacroErrNoName ) ;\n return false ;\n }\n\n FCKMacros.Add( txtName.value ) ;\n return true ;\n}\n\nfunction OnChange( sMacro )\n{\n // sMacro = GetE(\"txtName\").value;\n oHelp = GetE(\"help\");\n for (var i=0; i<oHelp.childNodes.length; i++)\n {\n var oDiv = oHelp.childNodes[i];\n if (oDiv.nodeType==1)\n {\n // oDiv.style.display = (GetAttribute(oDiv, \"id\", \"\")==sMacro) ? '' : 'none';\n if (GetAttribute(oDiv, \"id\", \"\") == sMacro)\n {\n oDiv.style.display = '' ;\n // alert(\"enabled div id \" + sMacro) ;\n }\n else\n {\n oDiv.style.display = 'none' ;\n }\n }\n }\n}\n\n </script>\n </head>\n <body scroll=\"no\" style=\"OVERFLOW: hidden\">\n <table height=\"100%%\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%%\" border=\"0\">\n <tr>\n <td>\n <table cellSpacing=\"0\" cellPadding=\"0\" align=\"center\" border=\"0\">\n <tr>\n <td valign=\"top\">\n <span fckLang=\"MacroDlgName\">Macro Name</span><br>\n <select id=\"txtName\" size=\"10\" onchange=\"OnChange(this.value);\">\n\"\"\"\n % request.cfg.url_prefix_static)\n",
"macros = []\n",
"for macro in macro_list(request):\n",
"if macro == 'BR':\n",
"request.write('\\n'.join(macros))\n",
"selected = ' selected=\"selected\"'\n",
"selected = ''\n",
"request.write(\"\"\"\n </select>\n </td>\n <td id=\"help\">\"\"\")\n",
"if macro in help:\n",
"helptexts = []\n",
"macros.append('<option value=\"%s\"%s>%s</option>' % (help[macro].group(\n 'prototype'), selected, macro))\n",
"macros.append('<option value=\"%s\"%s>%s</option>' % (macro, selected, macro))\n",
"for macro in macro_list(request):\n",
"if macro in help:\n",
"request.write(''.join(helptexts))\n",
"match = help[macro]\n",
"prototype = macro\n",
"request.write(\n \"\"\"\n </td>\n </tr>\n </table>\n </td>\n </tr>\n</table>\n</body>\n</html>\n\"\"\"\n )\n",
"prototype = match.group('prototype')\n",
"helptext = ''\n",
"helptext = match.group('help')\n",
"helptexts.append(\n \"\"\"<div id=\"%s\" style=\"DISPLAY: none\">\n <b><<%s>></b>\n <br/>\n <textarea style=\"color:#000000\" cols=\"37\" rows=\"10\" disabled=\"disabled\">%s</textarea>\n </div>\"\"\"\n % (prototype, prototype, helptext))\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
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"For",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"For",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_162(VAR_10):...\n",
"if VAR_187:\n",
"self.amfrpc3_procedures[VAR_187 + '.' + VAR_10.__name__] = VAR_10\n",
"self.amfrpc3_procedures[VAR_10.__name__] = VAR_10\n",
"return VAR_10\n"
] | [
"def _amfrpc3(f):...\n",
"if domain:\n",
"self.amfrpc3_procedures[domain + '.' + f.__name__] = f\n",
"self.amfrpc3_procedures[f.__name__] = f\n",
"return f\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_15(self, VAR_4, VAR_39, VAR_40):...\n",
"self.log.warn(\"\"\"\n webapp_settings is deprecated, use tornado_settings.\n\"\"\")\n",
"self.tornado_settings = VAR_40\n"
] | [
"def _webapp_settings_changed(self, name, old, new):...\n",
"self.log.warn(\"\"\"\n webapp_settings is deprecated, use tornado_settings.\n\"\"\")\n",
"self.tornado_settings = new\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'"
] |
[
"def FUNC_20(VAR_9, VAR_12, VAR_10):...\n",
"VAR_63, VAR_64, VAR_65 = calibre_db.fill_indexpage(VAR_9, 0, db.Books, db.\n Books.authors.any(db.Authors.id == VAR_12), [VAR_10[0][0], db.Series.\n name, db.Books.series_index], db.books_series_link, db.Books.id == db.\n books_series_link.c.book, db.Series)\n",
"if VAR_63 is None or not len(VAR_63):\n",
"flash(_(\n u'Oops! Selected book title is unavailable. File does not exist or is not accessible'\n ), category='error')\n",
"if constants.sqlalchemy_version2:\n",
"return redirect(url_for('web.index'))\n",
"VAR_105 = calibre_db.session.get(db.Authors, VAR_12)\n",
"VAR_105 = calibre_db.session.query(db.Authors).get(VAR_12)\n",
"VAR_36 = VAR_105.name.replace('|', ',')\n",
"VAR_66 = None\n",
"VAR_67 = []\n",
"if services.goodreads_support and config.config_use_goodreads:\n",
"VAR_66 = services.goodreads_support.get_author_info(VAR_36)\n",
"return render_title_template('author.html', VAR_63=entries, VAR_65=\n pagination, id=author_id, VAR_150=_(u'Author: %(name)s', name=\n author_name), VAR_105=author_info, VAR_67=other_books, VAR_9='author',\n VAR_10=order[1])\n",
"VAR_67 = services.goodreads_support.get_other_books(VAR_66, VAR_63)\n"
] | [
"def render_author_books(page, author_id, order):...\n",
"entries, __, pagination = calibre_db.fill_indexpage(page, 0, db.Books, db.\n Books.authors.any(db.Authors.id == author_id), [order[0][0], db.Series.\n name, db.Books.series_index], db.books_series_link, db.Books.id == db.\n books_series_link.c.book, db.Series)\n",
"if entries is None or not len(entries):\n",
"flash(_(\n u'Oops! Selected book title is unavailable. File does not exist or is not accessible'\n ), category='error')\n",
"if constants.sqlalchemy_version2:\n",
"return redirect(url_for('web.index'))\n",
"author = calibre_db.session.get(db.Authors, author_id)\n",
"author = calibre_db.session.query(db.Authors).get(author_id)\n",
"author_name = author.name.replace('|', ',')\n",
"author_info = None\n",
"other_books = []\n",
"if services.goodreads_support and config.config_use_goodreads:\n",
"author_info = services.goodreads_support.get_author_info(author_name)\n",
"return render_title_template('author.html', entries=entries, pagination=\n pagination, id=author_id, title=_(u'Author: %(name)s', name=author_name\n ), author=author_info, other_books=other_books, page='author', order=\n order[1])\n",
"other_books = services.goodreads_support.get_other_books(author_info, entries)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'"
] |
[
"@staticmethod...\n",
"VAR_1.smooth()\n",
"return VAR_1.encode(formatter=UnsortedAttributes()).decode('utf-8')\n"
] | [
"@staticmethod...\n",
"soup.smooth()\n",
"return soup.encode(formatter=UnsortedAttributes()).decode('utf-8')\n"
] | [
0,
0,
0
] | [
"Condition",
"Expr'",
"Return'"
] |
[
"def FUNC_8(VAR_11: List[Text], VAR_12: Text) ->Type['Validator']:...\n",
"\"\"\"docstring\"\"\"\n",
"def FUNC_14(VAR_20: Text) ->bool:...\n",
"return VAR_20 is not None and any([VAR_20.endswith(file_type) for file_type in\n VAR_11])\n"
] | [
"def file_type_validator(valid_file_types: List[Text], error_message: Text...\n",
"\"\"\"docstring\"\"\"\n",
"def is_valid(path: Text) ->bool:...\n",
"return path is not None and any([path.endswith(file_type) for file_type in\n valid_file_types])\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_10(VAR_0, VAR_1, VAR_3):...\n",
"VAR_3.add(GET, 'http://example.org', body='Example\\n')\n",
"VAR_10 = 'bookmarks'\n",
"VAR_0.config['DEFAULT_BOOKMARKS_DIR'] = VAR_10\n",
"create_dir(VAR_10)\n",
"VAR_8 = VAR_1.post('/bookmarks/new', data={'url': 'http://example.org',\n 'submit': 'true'})\n",
"VAR_11 = get_items(structured=False)[0]\n",
"assert 'bookmarks' in VAR_11['path']\n"
] | [
"def test_creating_bookmark_without_passing_path_saves_to_default_dir(test_app,...\n",
"mocked_responses.add(GET, 'http://example.org', body='Example\\n')\n",
"bookmarks_dir = 'bookmarks'\n",
"test_app.config['DEFAULT_BOOKMARKS_DIR'] = bookmarks_dir\n",
"create_dir(bookmarks_dir)\n",
"resp = client.post('/bookmarks/new', data={'url': 'http://example.org',\n 'submit': 'true'})\n",
"bookmark = get_items(structured=False)[0]\n",
"assert 'bookmarks' in bookmark['path']\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assert'"
] |
[
"def FUNC_5(self, VAR_2: Text, VAR_3: Text) ->Tuple[Text, Text]:...\n",
"\"\"\"docstring\"\"\"\n",
"import tempfile\n",
"VAR_22 = tempfile.mkdtemp()\n",
"VAR_23 = self._tar_name(VAR_3, VAR_8=False)\n",
"VAR_21 = shutil.make_archive(os.path.join(VAR_22, VAR_23), 'gztar',\n root_dir=model_directory, base_dir='.')\n",
"VAR_13 = os.path.basename(VAR_21)\n",
"return VAR_13, VAR_21\n"
] | [
"def _compress(self, model_directory: Text, model_name: Text) ->Tuple[Text, Text...\n",
"\"\"\"docstring\"\"\"\n",
"import tempfile\n",
"dirpath = tempfile.mkdtemp()\n",
"base_name = self._tar_name(model_name, include_extension=False)\n",
"tar_name = shutil.make_archive(os.path.join(dirpath, base_name), 'gztar',\n root_dir=model_directory, base_dir='.')\n",
"file_key = os.path.basename(tar_name)\n",
"return file_key, tar_name\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Import'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_1(VAR_1: AbstractEventLoop, VAR_2: float=0.1) ->AbstractEventLoop:...\n",
"logging.info('Enabling coroutine debugging. Loop id {}.'.format(id(asyncio.\n get_event_loop())))\n",
"VAR_1.set_debug(True)\n",
"VAR_1.slow_callback_duration = VAR_2\n",
"warnings.simplefilter('always', ResourceWarning)\n",
"return VAR_1\n"
] | [
"def enable_async_loop_debugging(event_loop: AbstractEventLoop,...\n",
"logging.info('Enabling coroutine debugging. Loop id {}.'.format(id(asyncio.\n get_event_loop())))\n",
"event_loop.set_debug(True)\n",
"event_loop.slow_callback_duration = slow_callback_duration\n",
"warnings.simplefilter('always', ResourceWarning)\n",
"return event_loop\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_75(self, VAR_2, VAR_174=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_176 = None\n",
"VAR_177 = self.form_class(VAR_2.POST.copy())\n",
"if VAR_177.is_valid():\n",
"VAR_304 = VAR_177.cleaned_data['username']\n",
"return self.handle_not_logged_in(VAR_2, VAR_176, VAR_177)\n",
"VAR_305 = VAR_177.cleaned_data['password']\n",
"VAR_19 = VAR_177.cleaned_data['server']\n",
"VAR_306 = settings.SECURE\n",
"VAR_175 = Connector(VAR_19, VAR_306)\n",
"VAR_307 = True\n",
"if settings.CHECK_VERSION:\n",
"VAR_307 = VAR_175.check_version(self.useragent)\n",
"if VAR_19 is not None and VAR_304 is not None and VAR_305 is not None and VAR_307:\n",
"VAR_8 = VAR_175.create_connection(self.useragent, VAR_304, VAR_305, userip=\n get_client_ip(request))\n",
"if not VAR_175.is_server_up(self.useragent):\n",
"if VAR_8 is not None:\n",
"VAR_176 = 'Server is not responding, please contact administrator.'\n",
"if not settings.CHECK_VERSION:\n",
"VAR_2.session['connector'] = VAR_175\n",
"VAR_8.close(hard=False)\n",
"VAR_176 = (\n 'Connection not available, please check your credentials and version compatibility.'\n )\n",
"if not VAR_307:\n",
"VAR_335 = settings.UPGRADES_URL\n",
"VAR_335 = VAR_8.getUpgradesUrl()\n",
"upgradeCheck(url=upgrades_url)\n",
"VAR_176 = 'Client version does not match server, please contact administrator.'\n",
"VAR_176 = settings.LOGIN_INCORRECT_CREDENTIALS_TEXT\n",
"return self.handle_logged_in(VAR_2, VAR_8, VAR_175)\n"
] | [
"def post(self, request, api_version=None):...\n",
"\"\"\"docstring\"\"\"\n",
"error = None\n",
"form = self.form_class(request.POST.copy())\n",
"if form.is_valid():\n",
"username = form.cleaned_data['username']\n",
"return self.handle_not_logged_in(request, error, form)\n",
"password = form.cleaned_data['password']\n",
"server_id = form.cleaned_data['server']\n",
"is_secure = settings.SECURE\n",
"connector = Connector(server_id, is_secure)\n",
"compatible = True\n",
"if settings.CHECK_VERSION:\n",
"compatible = connector.check_version(self.useragent)\n",
"if server_id is not None and username is not None and password is not None and compatible:\n",
"conn = connector.create_connection(self.useragent, username, password,\n userip=get_client_ip(request))\n",
"if not connector.is_server_up(self.useragent):\n",
"if conn is not None:\n",
"error = 'Server is not responding, please contact administrator.'\n",
"if not settings.CHECK_VERSION:\n",
"request.session['connector'] = connector\n",
"conn.close(hard=False)\n",
"error = (\n 'Connection not available, please check your credentials and version compatibility.'\n )\n",
"if not compatible:\n",
"upgrades_url = settings.UPGRADES_URL\n",
"upgrades_url = conn.getUpgradesUrl()\n",
"upgradeCheck(url=upgrades_url)\n",
"error = 'Client version does not match server, please contact administrator.'\n",
"error = settings.LOGIN_INCORRECT_CREDENTIALS_TEXT\n",
"return self.handle_logged_in(request, conn, connector)\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
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_27(self, VAR_27):...\n",
"VAR_73 = self.playlistdb.deletePlaylist(VAR_27, self.getUserId(),\n override_owner=False)\n",
"if VAR_73 == 'success':\n",
"return VAR_73\n"
] | [
"def api_deleteplaylist(self, playlistid):...\n",
"res = self.playlistdb.deletePlaylist(playlistid, self.getUserId(),\n override_owner=False)\n",
"if res == 'success':\n",
"return res\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_61(VAR_2, VAR_39, **VAR_6):...\n",
"\"\"\"docstring\"\"\"\n",
"for VAR_310, VAR_375 in VAR_6.items():\n",
"VAR_2.session['callback'][VAR_39][VAR_310] = VAR_375\n"
] | [
"def update_callback(request, cbString, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"for key, value in kwargs.items():\n",
"request.session['callback'][cbString][key] = value\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"For",
"Assign'"
] |
[
"async def FUNC_5(self, VAR_15: str) ->None:...\n",
"\"\"\"docstring\"\"\"\n",
"await self.store.mark_remote_user_device_cache_as_stale(VAR_15)\n",
"VAR_0.exception('Failed to resync device for %s', VAR_15)\n",
"if self.config.worker_app:\n",
"await self._user_device_resync(VAR_27=sender)\n",
"await self._device_list_updater.user_device_resync(VAR_15)\n"
] | [
"async def _resync_device(self, sender: str) ->None:...\n",
"\"\"\"docstring\"\"\"\n",
"await self.store.mark_remote_user_device_cache_as_stale(sender)\n",
"logger.exception('Failed to resync device for %s', sender)\n",
"if self.config.worker_app:\n",
"await self._user_device_resync(user_id=sender)\n",
"await self._device_list_updater.user_device_resync(sender)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"AsyncFunctionDef'",
"Docstring",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_9(self):...\n",
"self.assertFormfield(models.Album, 'cover_art', widgets.AdminFileWidget)\n"
] | [
"def testFileField(self):...\n",
"self.assertFormfield(models.Album, 'cover_art', widgets.AdminFileWidget)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_65(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return '/app/Form/{doctype}/{name}'.format(VAR_2=self.doctype, VAR_3=self.name)\n"
] | [
"def get_url(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return '/app/Form/{doctype}/{name}'.format(doctype=self.doctype, name=self.name\n )\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_43(self, VAR_53, VAR_54):...\n",
"return VAR_53 * VAR_54\n"
] | [
"def multiply(self, a, b):...\n",
"return a * b\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@defer.inlineCallbacks...\n",
"VAR_11 = self.mock_handler.get_displayname\n",
"VAR_11.return_value = defer.succeed('Frank')\n",
"VAR_12, VAR_13 = yield self.mock_resource.trigger('GET', \n '/profile/%s/displayname' % VAR_0, None)\n",
"self.assertEquals(200, VAR_12)\n",
"self.assertEquals({'displayname': 'Frank'}, VAR_13)\n",
"self.assertEquals(VAR_11.call_args[0][0].localpart, '1234ABCD')\n"
] | [
"@defer.inlineCallbacks...\n",
"mocked_get = self.mock_handler.get_displayname\n",
"mocked_get.return_value = defer.succeed('Frank')\n",
"code, response = yield self.mock_resource.trigger('GET', \n '/profile/%s/displayname' % myid, None)\n",
"self.assertEquals(200, code)\n",
"self.assertEquals({'displayname': 'Frank'}, response)\n",
"self.assertEquals(mocked_get.call_args[0][0].localpart, '1234ABCD')\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@VAR_0.route('/create/runfile', methods=['GET', 'POST'])...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_50 = os.path.join(VAR_0.config['UPLOAD_FOLDER'], 'runfile.py')\n",
"if request.method == 'POST':\n",
"VAR_89 = request.form.get('runfile-data')\n",
"return render_template('runfile.html', title='Runfile')\n",
"VAR_14.write(VAR_89)\n",
"VAR_98 = FUNC_58('/internal/runfile', 'get', VAR_73={'path': runfile_path})\n",
"flash(str(err), 'danger')\n",
"flash(VAR_98['message'], 'success')\n",
"return redirect(request.url)\n"
] | [
"@gui.route('/create/runfile', methods=['GET', 'POST'])...\n",
"\"\"\"docstring\"\"\"\n",
"runfile_path = os.path.join(gui.config['UPLOAD_FOLDER'], 'runfile.py')\n",
"if request.method == 'POST':\n",
"runfile_data = request.form.get('runfile-data')\n",
"return render_template('runfile.html', title='Runfile')\n",
"f.write(runfile_data)\n",
"response_info = query_internal_api('/internal/runfile', 'get', params={\n 'path': runfile_path})\n",
"flash(str(err), 'danger')\n",
"flash(response_info['message'], 'success')\n",
"return redirect(request.url)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_39(self):...\n",
"VAR_14 = self._makeOne()\n",
"VAR_15 = VAR_14.createErrorInfo(AttributeError('nonesuch'), (12, 3))\n",
"self.assertTrue(VAR_15.type is AttributeError)\n",
"self.assertEqual(VAR_15.__allow_access_to_unprotected_subobjects__, 1)\n"
] | [
"def test_createErrorInfo_returns_unrestricted_object(self):...\n",
"context = self._makeOne()\n",
"info = context.createErrorInfo(AttributeError('nonesuch'), (12, 3))\n",
"self.assertTrue(info.type is AttributeError)\n",
"self.assertEqual(info.__allow_access_to_unprotected_subobjects__, 1)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def __call__(self, VAR_10, VAR_13, VAR_14, VAR_12):...\n",
"VAR_11 = VAR_13.get('request')\n",
"VAR_10 = self.traverse(VAR_10, VAR_11, VAR_12)\n",
"if VAR_14 is False:\n",
"return VAR_10\n",
"if getattr(VAR_10, '__call__', VAR_0) is not VAR_0 or isinstance(VAR_10, type):\n",
"return VAR_10()\n",
"return VAR_10\n"
] | [
"def __call__(self, base, econtext, call, path_items):...\n",
"request = econtext.get('request')\n",
"base = self.traverse(base, request, path_items)\n",
"if call is False:\n",
"return base\n",
"if getattr(base, '__call__', _marker) is not _marker or isinstance(base, type):\n",
"return base()\n",
"return base\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def __init__(self, VAR_14: FavaLedger) ->None:...\n",
"super().__init__(VAR_14)\n",
"self.lock = threading.Lock()\n"
] | [
"def __init__(self, ledger: FavaLedger) ->None:...\n",
"super().__init__(ledger)\n",
"self.lock = threading.Lock()\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'"
] |
[
"def FUNC_8(self, VAR_10):...\n",
"\"\"\"docstring\"\"\"\n",
"frappe.flags.error_message = _('Insufficient Permission for {0}').format(self\n .doctype)\n"
] | [
"def raise_no_permission_to(self, perm_type):...\n",
"\"\"\"docstring\"\"\"\n",
"frappe.flags.error_message = _('Insufficient Permission for {0}').format(self\n .doctype)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'"
] |
[
"def FUNC_56():...\n",
"VAR_3 = request.args(0)\n",
"from gluon.serializers import loads_json\n",
"if not session.plugins:\n",
"return dict(VAR_94=session.plugins['results'], VAR_3=request.args(0))\n",
"VAR_199 = urlopen('http://www.web2pyslices.com/' +\n 'public/api.json/action/list/content/Package?package' +\n '_type=plugin&search_index=false').read()\n",
"VAR_43.flash = T('Unable to download the list of plugins')\n",
"session.plugins = loads_json(VAR_199)\n",
"session.plugins = []\n"
] | [
"def plugins():...\n",
"app = request.args(0)\n",
"from gluon.serializers import loads_json\n",
"if not session.plugins:\n",
"return dict(plugins=session.plugins['results'], app=request.args(0))\n",
"rawlist = urlopen('http://www.web2pyslices.com/' +\n 'public/api.json/action/list/content/Package?package' +\n '_type=plugin&search_index=false').read()\n",
"response.flash = T('Unable to download the list of plugins')\n",
"session.plugins = loads_json(rawlist)\n",
"session.plugins = []\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"ImportFrom'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_14(self, VAR_18, VAR_19=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_48 = []\n",
"if not VAR_19:\n",
"VAR_19 = self.meta.get_field(VAR_18)\n",
"for VAR_21 in self.get(VAR_19.fieldname):\n",
"VAR_21.db_update()\n",
"if VAR_19.options in (self.flags.ignore_children_type or []):\n",
"VAR_48.append(VAR_21.name)\n",
"return\n",
"if VAR_48:\n",
"VAR_83 = frappe.db.sql('string'.format(VAR_19.options, ','.join(['%s'] *\n len(VAR_48))), [self.name, self.doctype, VAR_18] + VAR_48)\n",
"frappe.db.sql(\n \"\"\"delete from `tab{0}` where parent=%s\n\t\t\t\tand parenttype=%s and parentfield=%s\"\"\"\n .format(VAR_19.options), (self.name, self.doctype, VAR_18))\n",
"if len(VAR_83) > 0:\n",
"frappe.db.sql('delete from `tab{0}` where name in ({1})'.format(VAR_19.\n options, ','.join(['%s'] * len(VAR_83))), tuple(row[0] for row in VAR_83))\n"
] | [
"def update_child_table(self, fieldname, df=None):...\n",
"\"\"\"docstring\"\"\"\n",
"rows = []\n",
"if not df:\n",
"df = self.meta.get_field(fieldname)\n",
"for d in self.get(df.fieldname):\n",
"d.db_update()\n",
"if df.options in (self.flags.ignore_children_type or []):\n",
"rows.append(d.name)\n",
"return\n",
"if rows:\n",
"deleted_rows = frappe.db.sql(\n \"\"\"select name from `tab{0}` where parent=%s\n\t\t\t\tand parenttype=%s and parentfield=%s\n\t\t\t\tand name not in ({1})\"\"\"\n .format(df.options, ','.join(['%s'] * len(rows))), [self.name, self.\n doctype, fieldname] + rows)\n",
"frappe.db.sql(\n \"\"\"delete from `tab{0}` where parent=%s\n\t\t\t\tand parenttype=%s and parentfield=%s\"\"\"\n .format(df.options), (self.name, self.doctype, fieldname))\n",
"if len(deleted_rows) > 0:\n",
"frappe.db.sql('delete from `tab{0}` where name in ({1})'.format(df.options,\n ','.join(['%s'] * len(deleted_rows))), tuple(row[0] for row in\n deleted_rows))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"For",
"Expr'",
"Condition",
"Expr'",
"Return'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Expr'"
] |
[
"def __call__(self, VAR_9):...\n",
"if not re.compile('^\\\\w+$').match(VAR_9):\n",
"return VAR_9, T('Invalid application name')\n",
"if not request.vars.overwrite and os.path.exists(os.path.join(apath(VAR_122\n",
"return VAR_9, T('Application exists already')\n",
"return VAR_9, None\n"
] | [
"def __call__(self, value):...\n",
"if not re.compile('^\\\\w+$').match(value):\n",
"return value, T('Invalid application name')\n",
"if not request.vars.overwrite and os.path.exists(os.path.join(apath(r=\n",
"return value, T('Application exists already')\n",
"return value, None\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_1(self, VAR_3, VAR_4):...\n",
"return django.forms.CharField(widget=django.forms.Textarea, **options)\n"
] | [
"def create_multiline_field(self, field, options):...\n",
"return django.forms.CharField(widget=django.forms.Textarea, **options)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_5(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_1 = self.register_user('user', 'pass')\n",
"VAR_10 = self.login('user', 'pass')\n",
"VAR_11 = self.register_user('otheruser', 'pass')\n",
"VAR_12 = self.login('otheruser', 'pass')\n",
"VAR_18 = self.register_user('yetanotheruser', 'pass')\n",
"VAR_19 = self.login('yetanotheruser', 'pass')\n",
"VAR_15 = self.helper.create_room_as(VAR_11, tok=other_access_token)\n",
"self.helper.join(VAR_15=room, user=user_id, tok=access_token)\n",
"self.helper.join(VAR_15=room, user=yet_another_user_id, tok=\n yet_another_access_token)\n",
"VAR_13 = self.get_success(self.hs.get_datastore().get_user_by_access_token(\n VAR_10))\n",
"VAR_14 = VAR_13.token_id\n",
"self.get_success(self.hs.get_pusherpool().add_pusher(VAR_1=user_id, VAR_10=\n token_id, kind='http', app_id='m.http', app_display_name=\n 'HTTP Push Notifications', device_display_name='pushy push', pushkey=\n '[email protected]', lang=None, data={'url': 'example.com'}))\n",
"self.helper.send(VAR_15, VAR_7=\"@room eeek! There's a spider on the table!\",\n tok=other_access_token)\n",
"self.pump()\n",
"self.push_attempts[0][0].callback({})\n",
"self.pump()\n",
"self.assertEqual(len(self.push_attempts), 1)\n",
"self.assertEqual(self.push_attempts[0][1], 'example.com')\n",
"self.assertEqual(self.push_attempts[0][2]['notification']['prio'], 'high')\n",
"self.helper.send(VAR_15, VAR_7='@room the spider is gone', tok=\n yet_another_access_token)\n",
"self.pump()\n",
"self.assertEqual(len(self.push_attempts), 2)\n",
"self.assertEqual(self.push_attempts[1][1], 'example.com')\n",
"self.assertEqual(self.push_attempts[1][2]['notification']['prio'], 'low')\n"
] | [
"def test_sends_high_priority_for_atroom(self):...\n",
"\"\"\"docstring\"\"\"\n",
"user_id = self.register_user('user', 'pass')\n",
"access_token = self.login('user', 'pass')\n",
"other_user_id = self.register_user('otheruser', 'pass')\n",
"other_access_token = self.login('otheruser', 'pass')\n",
"yet_another_user_id = self.register_user('yetanotheruser', 'pass')\n",
"yet_another_access_token = self.login('yetanotheruser', 'pass')\n",
"room = self.helper.create_room_as(other_user_id, tok=other_access_token)\n",
"self.helper.join(room=room, user=user_id, tok=access_token)\n",
"self.helper.join(room=room, user=yet_another_user_id, tok=\n yet_another_access_token)\n",
"user_tuple = self.get_success(self.hs.get_datastore().\n get_user_by_access_token(access_token))\n",
"token_id = user_tuple.token_id\n",
"self.get_success(self.hs.get_pusherpool().add_pusher(user_id=user_id,\n access_token=token_id, kind='http', app_id='m.http', app_display_name=\n 'HTTP Push Notifications', device_display_name='pushy push', pushkey=\n '[email protected]', lang=None, data={'url': 'example.com'}))\n",
"self.helper.send(room, body=\"@room eeek! There's a spider on the table!\",\n tok=other_access_token)\n",
"self.pump()\n",
"self.push_attempts[0][0].callback({})\n",
"self.pump()\n",
"self.assertEqual(len(self.push_attempts), 1)\n",
"self.assertEqual(self.push_attempts[0][1], 'example.com')\n",
"self.assertEqual(self.push_attempts[0][2]['notification']['prio'], 'high')\n",
"self.helper.send(room, body='@room the spider is gone', tok=\n yet_another_access_token)\n",
"self.pump()\n",
"self.assertEqual(len(self.push_attempts), 2)\n",
"self.assertEqual(self.push_attempts[1][1], 'example.com')\n",
"self.assertEqual(self.push_attempts[1][2]['notification']['prio'], 'low')\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
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@VAR_25.whitelist()...\n",
"VAR_25.desk.form.run_method.runserverobj(VAR_3, VAR_4=docs, VAR_5=dt, VAR_6\n =dn, VAR_7=arg, VAR_8=args)\n"
] | [
"@frappe.whitelist()...\n",
"frappe.desk.form.run_method.runserverobj(method, docs=docs, dt=dt, dn=dn,\n arg=arg, args=args)\n"
] | [
2,
2
] | [
"Condition",
"Expr'"
] |
[
"def FUNC_69(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return hashlib.sha224(get_datetime_str(self.creation).encode()).hexdigest()\n"
] | [
"def get_signature(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return hashlib.sha224(get_datetime_str(self.creation).encode()).hexdigest()\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_29(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.flags.ignore_permissions or frappe.flags.in_install:\n",
"return\n",
"if frappe.session.user == 'Administrator':\n",
"return\n",
"VAR_57 = self.get_permlevel_access()\n",
"VAR_58 = self.meta.get_high_permlevel_fields()\n",
"if VAR_58:\n",
"self.reset_values_if_no_permlevel_access(VAR_57, VAR_58)\n",
"if self.is_new():\n",
"return\n",
"for VAR_19 in self.meta.get_table_fields():\n",
"VAR_58 = frappe.get_meta(VAR_19.options).get_high_permlevel_fields()\n",
"if VAR_58:\n",
"for VAR_21 in self.get(VAR_19.fieldname):\n",
"VAR_21.reset_values_if_no_permlevel_access(VAR_57, VAR_58)\n"
] | [
"def validate_higher_perm_levels(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.flags.ignore_permissions or frappe.flags.in_install:\n",
"return\n",
"if frappe.session.user == 'Administrator':\n",
"return\n",
"has_access_to = self.get_permlevel_access()\n",
"high_permlevel_fields = self.meta.get_high_permlevel_fields()\n",
"if high_permlevel_fields:\n",
"self.reset_values_if_no_permlevel_access(has_access_to, high_permlevel_fields)\n",
"if self.is_new():\n",
"return\n",
"for df in self.meta.get_table_fields():\n",
"high_permlevel_fields = frappe.get_meta(df.options).get_high_permlevel_fields()\n",
"if high_permlevel_fields:\n",
"for d in self.get(df.fieldname):\n",
"d.reset_values_if_no_permlevel_access(has_access_to, high_permlevel_fields)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Return'",
"For",
"Assign'",
"Condition",
"For",
"Expr'"
] |
[
"@VAR_1.route('/ajax/simulatemerge', methods=['POST'])...\n",
"VAR_79 = VAR_32.get_json().get('Merge_books')\n",
"if VAR_79:\n",
"VAR_100 = calibre_db.get_book(VAR_79[0]).title\n",
"return ''\n",
"VAR_79.pop(0)\n",
"if VAR_100:\n",
"for VAR_15 in VAR_79:\n",
"VAR_118 = []\n",
"return json.dumps({'to': VAR_100, 'from': VAR_118})\n",
"VAR_118.append(calibre_db.get_book(VAR_15).title)\n"
] | [
"@editbook.route('/ajax/simulatemerge', methods=['POST'])...\n",
"vals = request.get_json().get('Merge_books')\n",
"if vals:\n",
"to_book = calibre_db.get_book(vals[0]).title\n",
"return ''\n",
"vals.pop(0)\n",
"if to_book:\n",
"for book_id in vals:\n",
"from_book = []\n",
"return json.dumps({'to': to_book, 'from': from_book})\n",
"from_book.append(calibre_db.get_book(book_id).title)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Expr'",
"Condition",
"For",
"Assign'",
"Return'",
"Expr'"
] |
[
"def FUNC_3(VAR_2, VAR_3, VAR_4):...\n",
"\"\"\"docstring\"\"\"\n",
"return toBoolean(VAR_2.GET.get(VAR_3, VAR_4))\n"
] | [
"def get_bool_or_default(request, name, default):...\n",
"\"\"\"docstring\"\"\"\n",
"return toBoolean(request.GET.get(name, default))\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_62(VAR_95):...\n",
"VAR_32 = re.compile('^plugin_' + VAR_96 + '(/.*|\\\\..*)?$')\n",
"return [VAR_70 for VAR_70 in VAR_95 if VAR_70 and VAR_32.match(VAR_70)]\n"
] | [
"def filter_plugins(items):...\n",
"regex = re.compile('^plugin_' + plugin + '(/.*|\\\\..*)?$')\n",
"return [item for item in items if item and regex.match(item)]\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_3(VAR_3, VAR_5):...\n",
"if VAR_3['aggregate_function'] == 'count':\n",
"VAR_32 = 'Count'\n",
"VAR_33 = {'avg': 'Average', 'sum': 'Sum'}\n",
"return VAR_32\n",
"VAR_34 = VAR_5.get_label(VAR_3.aggregate_on)\n",
"VAR_32 = _('{function} of {fieldlabel}').format(function=sql_fn_map[args.\n aggregate_function], fieldlabel=aggregate_on_label)\n"
] | [
"def get_group_by_column_label(args, meta):...\n",
"if args['aggregate_function'] == 'count':\n",
"label = 'Count'\n",
"sql_fn_map = {'avg': 'Average', 'sum': 'Sum'}\n",
"return label\n",
"aggregate_on_label = meta.get_label(args.aggregate_on)\n",
"label = _('{function} of {fieldlabel}').format(function=sql_fn_map[args.\n aggregate_function], fieldlabel=aggregate_on_label)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Assign'"
] |
[
"@VAR_0.route('/shelf/massadd/<int:shelf_id>')...\n",
"VAR_0 = ub.session.query(ub.Shelf).filter(ub.Shelf.id == VAR_3).first()\n",
"if VAR_0 is None:\n",
"VAR_1.error('Invalid shelf specified: %s', VAR_3)\n",
"if not FUNC_0(VAR_0):\n",
"flash(_(u'Invalid shelf specified'), category='error')\n",
"VAR_1.warning('You are not allowed to add a book to the shelf'.format(VAR_0\n .name))\n",
"if current_user.id in ub.searched_ids and ub.searched_ids[current_user.id]:\n",
"return redirect(url_for('web.index'))\n",
"flash(_(u'You are not allowed to add a book to the shelf'), category='error')\n",
"VAR_17 = list()\n",
"VAR_1.error('Could not add books to shelf: {}'.format(VAR_0.name))\n",
"return redirect(url_for('web.index'))\n",
"VAR_18 = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == VAR_3\n ).all()\n",
"flash(_(u'Could not add books to shelf: %(sname)s', sname=shelf.name),\n category='error')\n",
"if VAR_18:\n",
"return redirect(url_for('web.index'))\n",
"VAR_29 = list()\n",
"VAR_17 = ub.searched_ids[current_user.id]\n",
"for VAR_4 in VAR_18:\n",
"if not VAR_17:\n",
"VAR_29.append(VAR_4.book_id)\n",
"for searchid in ub.searched_ids[current_user.id]:\n",
"VAR_1.error('Books are already part of {}'.format(VAR_0.name))\n",
"VAR_14 = ub.session.query(func.max(ub.BookShelf.order)).filter(ub.BookShelf\n .shelf == VAR_3).first()[0] or 0\n",
"if searchid not in VAR_29:\n",
"flash(_(u'Books are already part of the shelf: %(name)s', name=shelf.name),\n category='error')\n",
"for VAR_25 in VAR_17:\n",
"VAR_17.append(searchid)\n",
"return redirect(url_for('web.index'))\n",
"VAR_14 += 1\n",
"VAR_0.last_modified = datetime.utcnow()\n",
"VAR_0.books.append(ub.BookShelf(VAR_0=shelf.id, VAR_4=book, VAR_9=maxOrder))\n",
"ub.session.merge(VAR_0)\n",
"ub.session.rollback()\n",
"ub.session.commit()\n",
"VAR_1.error('Settings DB is not Writeable')\n",
"flash(_(u'Books have been added to shelf: %(sname)s', sname=shelf.name),\n category='success')\n",
"flash(_('Settings DB is not Writeable'), category='error')\n"
] | [
"@shelf.route('/shelf/massadd/<int:shelf_id>')...\n",
"shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()\n",
"if shelf is None:\n",
"log.error('Invalid shelf specified: %s', shelf_id)\n",
"if not check_shelf_edit_permissions(shelf):\n",
"flash(_(u'Invalid shelf specified'), category='error')\n",
"log.warning('You are not allowed to add a book to the shelf'.format(shelf.name)\n )\n",
"if current_user.id in ub.searched_ids and ub.searched_ids[current_user.id]:\n",
"return redirect(url_for('web.index'))\n",
"flash(_(u'You are not allowed to add a book to the shelf'), category='error')\n",
"books_for_shelf = list()\n",
"log.error('Could not add books to shelf: {}'.format(shelf.name))\n",
"return redirect(url_for('web.index'))\n",
"books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf ==\n shelf_id).all()\n",
"flash(_(u'Could not add books to shelf: %(sname)s', sname=shelf.name),\n category='error')\n",
"if books_in_shelf:\n",
"return redirect(url_for('web.index'))\n",
"book_ids = list()\n",
"books_for_shelf = ub.searched_ids[current_user.id]\n",
"for book_id in books_in_shelf:\n",
"if not books_for_shelf:\n",
"book_ids.append(book_id.book_id)\n",
"for searchid in ub.searched_ids[current_user.id]:\n",
"log.error('Books are already part of {}'.format(shelf.name))\n",
"maxOrder = ub.session.query(func.max(ub.BookShelf.order)).filter(ub.\n BookShelf.shelf == shelf_id).first()[0] or 0\n",
"if searchid not in book_ids:\n",
"flash(_(u'Books are already part of the shelf: %(name)s', name=shelf.name),\n category='error')\n",
"for book in books_for_shelf:\n",
"books_for_shelf.append(searchid)\n",
"return redirect(url_for('web.index'))\n",
"maxOrder += 1\n",
"shelf.last_modified = datetime.utcnow()\n",
"shelf.books.append(ub.BookShelf(shelf=shelf.id, book_id=book, order=maxOrder))\n",
"ub.session.merge(shelf)\n",
"ub.session.rollback()\n",
"ub.session.commit()\n",
"log.error('Settings DB is not Writeable')\n",
"flash(_(u'Books have been added to shelf: %(sname)s', sname=shelf.name),\n category='success')\n",
"flash(_('Settings DB is not Writeable'), category='error')\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
] | [
"Condition",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Return'",
"Expr'",
"Assign'",
"Expr'",
"Return'",
"Assign'",
"Expr'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"For",
"Condition",
"Expr'",
"For",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"For",
"Expr'",
"Return'",
"AugAssign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_63(VAR_121=True, VAR_24=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_24:\n",
"VAR_24 = VAR_1.sites_path\n",
"VAR_189 = FUNC_69(os.path.join(VAR_24, 'apps.txt'), VAR_126=True)\n",
"if VAR_121:\n",
"for VAR_219 in FUNC_69(os.path.join(VAR_1.site_path, 'apps.txt')):\n",
"if 'frappe' in VAR_189:\n",
"if VAR_219 not in VAR_189:\n",
"VAR_189.remove('frappe')\n",
"VAR_189.insert(0, 'frappe')\n",
"VAR_189.append(VAR_219)\n",
"return VAR_189\n"
] | [
"def get_all_apps(with_internal_apps=True, sites_path=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if not sites_path:\n",
"sites_path = local.sites_path\n",
"apps = get_file_items(os.path.join(sites_path, 'apps.txt'), raise_not_found\n =True)\n",
"if with_internal_apps:\n",
"for app in get_file_items(os.path.join(local.site_path, 'apps.txt')):\n",
"if 'frappe' in apps:\n",
"if app not in apps:\n",
"apps.remove('frappe')\n",
"apps.insert(0, 'frappe')\n",
"apps.append(app)\n",
"return apps\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Condition",
"For",
"Condition",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_19(VAR_33):...\n",
"import stat\n",
"from datetime import datetime\n",
"from octoprint.util.tz import UTC_TZ\n",
"VAR_88 = 0\n",
"for VAR_9 in VAR_33:\n",
"if VAR_88:\n",
"VAR_138 = os.stat(VAR_9)\n",
"VAR_88 = datetime.fromtimestamp(VAR_88).replace(microsecond=0).replace(tzinfo\n =UTC_TZ)\n",
"return VAR_88\n",
"if stat.S_ISREG(VAR_138.st_mode) and VAR_138.st_mtime > VAR_88:\n",
"VAR_88 = VAR_138.st_mtime\n"
] | [
"def _compute_date(files):...\n",
"import stat\n",
"from datetime import datetime\n",
"from octoprint.util.tz import UTC_TZ\n",
"max_timestamp = 0\n",
"for path in files:\n",
"if max_timestamp:\n",
"s = os.stat(path)\n",
"max_timestamp = datetime.fromtimestamp(max_timestamp).replace(microsecond=0\n ).replace(tzinfo=UTC_TZ)\n",
"return max_timestamp\n",
"if stat.S_ISREG(s.st_mode) and s.st_mtime > max_timestamp:\n",
"max_timestamp = s.st_mtime\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"For",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Condition",
"Assign'"
] |
[
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"FUNC_7(VAR_2)\n",
"VAR_7 = VAR_7 or VAR_350('webindex')\n",
"return HttpResponseRedirect(VAR_7)\n"
] | [
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"switch_active_group(request)\n",
"url = url or reverse('webindex')\n",
"return HttpResponseRedirect(url)\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Expr'",
"Assign'",
"Return'"
] |
[
"def __setattr__(self, VAR_46, VAR_105):...\n",
"self[VAR_46] = VAR_105\n"
] | [
"def __setattr__(self, key, value):...\n",
"self[key] = value\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"def FUNC_1(VAR_2, VAR_3, VAR_4, **VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_32 = frappe.get_doc(VAR_2, VAR_3)\n",
"VAR_32.unlock()\n",
"getattr(VAR_32, VAR_4)(**kwargs)\n",
"frappe.db.rollback()\n",
"if frappe.local.message_log:\n",
"VAR_87 = json.loads(frappe.local.message_log[-1]).get('message')\n",
"VAR_87 = '<pre><code>' + frappe.get_traceback() + '</pre></code>'\n",
"VAR_32.add_comment('Comment', _('Action Failed') + '<br><br>' + VAR_87)\n",
"VAR_32.notify_update()\n"
] | [
"def execute_action(doctype, name, action, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"doc = frappe.get_doc(doctype, name)\n",
"doc.unlock()\n",
"getattr(doc, action)(**kwargs)\n",
"frappe.db.rollback()\n",
"if frappe.local.message_log:\n",
"msg = json.loads(frappe.local.message_log[-1]).get('message')\n",
"msg = '<pre><code>' + frappe.get_traceback() + '</pre></code>'\n",
"doc.add_comment('Comment', _('Action Failed') + '<br><br>' + msg)\n",
"doc.notify_update()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_7(self):...\n",
"VAR_11 = FauxObject('rc')\n",
"VAR_12 = FauxRoot('root').__of__(VAR_11)\n",
"VAR_13 = FauxContainer('folder').__of__(VAR_12)\n",
"VAR_14 = FauxObject('object').__of__(VAR_13)\n",
"return VAR_11, VAR_12, VAR_13, VAR_14\n"
] | [
"def _makeTree(self):...\n",
"rc = FauxObject('rc')\n",
"root = FauxRoot('root').__of__(rc)\n",
"folder = FauxContainer('folder').__of__(root)\n",
"object = FauxObject('object').__of__(folder)\n",
"return rc, root, folder, object\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_10(self) ->None:...\n",
"VAR_16 = self.package_dir / 'models'\n",
"VAR_16.mkdir()\n",
"VAR_17 = VAR_16 / '__init__.py'\n",
"VAR_18 = []\n",
"VAR_19 = self.env.get_template('types.py')\n",
"VAR_20 = VAR_16 / 'types.py'\n",
"VAR_20.write_text(VAR_19.render())\n",
"VAR_21 = self.env.get_template('model.pyi')\n",
"for model in self.openapi.schemas.models.values():\n",
"VAR_36 = VAR_16 / f'{model.reference.module_name}.py'\n",
"VAR_22 = self.env.get_template('enum.pyi')\n",
"VAR_36.write_text(VAR_21.render(model=model))\n",
"for enum in self.openapi.enums.values():\n",
"VAR_18.append(import_string_from_reference(model.reference))\n",
"VAR_36 = VAR_16 / f'{enum.reference.module_name}.py'\n",
"VAR_23 = self.env.get_template('models_init.pyi')\n",
"VAR_36.write_text(VAR_22.render(enum=enum))\n",
"VAR_17.write_text(VAR_23.render(VAR_18=imports))\n",
"VAR_18.append(import_string_from_reference(enum.reference))\n"
] | [
"def _build_models(self) ->None:...\n",
"models_dir = self.package_dir / 'models'\n",
"models_dir.mkdir()\n",
"models_init = models_dir / '__init__.py'\n",
"imports = []\n",
"types_template = self.env.get_template('types.py')\n",
"types_path = models_dir / 'types.py'\n",
"types_path.write_text(types_template.render())\n",
"model_template = self.env.get_template('model.pyi')\n",
"for model in self.openapi.schemas.models.values():\n",
"module_path = models_dir / f'{model.reference.module_name}.py'\n",
"enum_template = self.env.get_template('enum.pyi')\n",
"module_path.write_text(model_template.render(model=model))\n",
"for enum in self.openapi.enums.values():\n",
"imports.append(import_string_from_reference(model.reference))\n",
"module_path = models_dir / f'{enum.reference.module_name}.py'\n",
"models_init_template = self.env.get_template('models_init.pyi')\n",
"module_path.write_text(enum_template.render(enum=enum))\n",
"models_init.write_text(models_init_template.render(imports=imports))\n",
"imports.append(import_string_from_reference(enum.reference))\n"
] | [
0,
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'",
"Expr'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Expr'",
"For",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_11(self):...\n",
"if not self.json:\n",
"self.json = '{}'\n"
] | [
"def update_report_json(self):...\n",
"if not self.json:\n",
"self.json = '{}'\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'"
] |
[
"def FUNC_16(VAR_19):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_41 = example_pb2.Example()\n",
"for feature_name, feature_list in VAR_19.items():\n",
"if not isinstance(feature_list, list):\n",
"return VAR_41.SerializeToString()\n",
"if isinstance(feature_list[0], float):\n",
"VAR_41.features.feature[feature_name].float_list.value.extend(feature_list)\n",
"if isinstance(feature_list[0], str):\n",
"VAR_41.features.feature[feature_name].bytes_list.value.extend([f.encode(\n 'utf8') for f in feature_list])\n",
"if isinstance(feature_list[0], bytes):\n",
"VAR_41.features.feature[feature_name].bytes_list.value.extend(feature_list)\n",
"if isinstance(feature_list[0], six.integer_types):\n",
"VAR_41.features.feature[feature_name].int64_list.value.extend(feature_list)\n"
] | [
"def _create_example_string(example_dict):...\n",
"\"\"\"docstring\"\"\"\n",
"example = example_pb2.Example()\n",
"for feature_name, feature_list in example_dict.items():\n",
"if not isinstance(feature_list, list):\n",
"return example.SerializeToString()\n",
"if isinstance(feature_list[0], float):\n",
"example.features.feature[feature_name].float_list.value.extend(feature_list)\n",
"if isinstance(feature_list[0], str):\n",
"example.features.feature[feature_name].bytes_list.value.extend([f.encode(\n 'utf8') for f in feature_list])\n",
"if isinstance(feature_list[0], bytes):\n",
"example.features.feature[feature_name].bytes_list.value.extend(feature_list)\n",
"if isinstance(feature_list[0], six.integer_types):\n",
"example.features.feature[feature_name].int64_list.value.extend(feature_list)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"For",
"Condition",
"Return'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_17(self):...\n",
"self.assert_expected(self.folder.t, 'CheckPathNothing.html')\n"
] | [
"def testPathNothing(self):...\n",
"self.assert_expected(self.folder.t, 'CheckPathNothing.html')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@app.route('/user/edit', methods=['GET', 'POST'])...\n",
"VAR_9 = forms.UserForm()\n",
"if VAR_9.validate_on_submit():\n",
"VAR_31 = get_db()\n",
"VAR_9.username.data = current_user.username\n",
"VAR_31.update({'username': VAR_9.username.data, 'hashed_password':\n generate_password_hash(VAR_9.password.data)}, doc_ids=[current_user.id])\n",
"return render_template('users/edit.html', VAR_9=form, title='Edit Profile')\n",
"flash('Information saved!', 'success')\n",
"return redirect('/')\n"
] | [
"@app.route('/user/edit', methods=['GET', 'POST'])...\n",
"form = forms.UserForm()\n",
"if form.validate_on_submit():\n",
"db = get_db()\n",
"form.username.data = current_user.username\n",
"db.update({'username': form.username.data, 'hashed_password':\n generate_password_hash(form.password.data)}, doc_ids=[current_user.id])\n",
"return render_template('users/edit.html', form=form, title='Edit Profile')\n",
"flash('Information saved!', 'success')\n",
"return redirect('/')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Return'",
"Expr'",
"Return'"
] |
[
"import os\n",
"from ConfigParser import ConfigParser, NoSectionError, NoOptionError\n",
"from swift.common.memcached import MemcacheRing\n",
"\"\"\"\n Caching middleware that manages caching in swift.\n \"\"\"\n",
"def __init__(self, VAR_2, VAR_3):...\n",
"self.app = VAR_2\n",
"self.memcache_servers = VAR_3.get('memcache_servers')\n",
"if not self.memcache_servers:\n",
"VAR_6 = os.path.join(VAR_3.get('swift_dir', '/etc/swift'), 'memcache.conf')\n",
"if not self.memcache_servers:\n",
"VAR_7 = ConfigParser()\n",
"self.memcache_servers = '127.0.0.1:11211'\n",
"self.memcache = MemcacheRing([s.strip() for s in self.memcache_servers.\n split(',') if s.strip()])\n",
"if VAR_7.read(VAR_6):\n",
"def __call__(self, VAR_4, VAR_5):...\n",
"self.memcache_servers = VAR_7.get('memcache', 'memcache_servers')\n",
"VAR_4['swift.cache'] = self.memcache\n",
"return self.app(VAR_4, VAR_5)\n"
] | [
"import os\n",
"from ConfigParser import ConfigParser, NoSectionError, NoOptionError\n",
"from swift.common.memcached import MemcacheRing\n",
"\"\"\"\n Caching middleware that manages caching in swift.\n \"\"\"\n",
"def __init__(self, app, conf):...\n",
"self.app = app\n",
"self.memcache_servers = conf.get('memcache_servers')\n",
"if not self.memcache_servers:\n",
"path = os.path.join(conf.get('swift_dir', '/etc/swift'), 'memcache.conf')\n",
"if not self.memcache_servers:\n",
"memcache_conf = ConfigParser()\n",
"self.memcache_servers = '127.0.0.1:11211'\n",
"self.memcache = MemcacheRing([s.strip() for s in self.memcache_servers.\n split(',') if s.strip()])\n",
"if memcache_conf.read(path):\n",
"def __call__(self, env, start_response):...\n",
"self.memcache_servers = memcache_conf.get('memcache', 'memcache_servers')\n",
"env['swift.cache'] = self.memcache\n",
"return self.app(env, start_response)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
5,
0,
0,
0,
0,
5,
0,
0,
5,
0,
0
] | [
"Import'",
"ImportFrom'",
"ImportFrom'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@FUNC_0...\n",
"return RegistrationHandler(self)\n"
] | [
"@cache_in_self...\n",
"return RegistrationHandler(self)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"import re\n",
"from django.template.base import Token, TokenType\n",
"import pytest\n",
"from django_unicorn.components import UnicornView\n",
"from django_unicorn.templatetags.unicorn import unicorn\n",
"from django_unicorn.utils import generate_checksum\n",
"from example.coffee.models import Flavor\n",
"VAR_1 = 'templates/test_component_parent.html'\n",
"VAR_1 = 'templates/test_component_kwargs.html'\n",
"VAR_2 = 'world'\n",
"def __init__(self, *VAR_3, **VAR_4):...\n",
"super().__init__(**kwargs)\n",
"self.hello = VAR_4.get('test_kwarg')\n",
"VAR_1 = 'templates/test_component_model.html'\n",
"VAR_5 = None\n",
"def __init__(self, *VAR_3, **VAR_4):...\n",
"super().__init__(**kwargs)\n",
"self.model_id = VAR_4.get('model_id')\n",
"VAR_1 = 'templates/test_component_parent.html'\n",
"def FUNC_16(self):...\n",
"self.call('testCall')\n",
"VAR_1 = 'templates/test_component_parent.html'\n",
"def FUNC_16(self):...\n",
"self.call('testCall2', 'hello')\n",
"def FUNC_0():...\n",
"VAR_6 = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' test_kwarg='tested!'\"\n )\n",
"VAR_7 = unicorn(None, VAR_6)\n",
"VAR_8 = {}\n",
"VAR_9 = VAR_7.render(VAR_8)\n",
"assert '->tested!<-' in VAR_9\n",
"def FUNC_1():...\n",
"VAR_6 = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' test_kwarg=test_var.nested\"\n )\n",
"VAR_7 = unicorn(None, VAR_6)\n",
"VAR_8 = {'test_var': {'nested': 'variable!'}}\n",
"VAR_9 = VAR_7.render(VAR_8)\n",
"assert '->variable!<-' in VAR_9\n",
"def FUNC_2(VAR_0):...\n",
"VAR_0.DEBUG = True\n",
"VAR_6 = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' parent=view\"\n )\n",
"VAR_7 = unicorn(None, VAR_6)\n",
"VAR_10 = CLASS_0(component_name='test', component_id='asdf')\n",
"VAR_8 = {'view': VAR_10}\n",
"VAR_7.render(VAR_8)\n",
"assert VAR_7.parent\n",
"assert VAR_7.component_id == 'asdf:tests.templatetags.test_unicorn_render.FakeComponentKwargs'\n",
"def FUNC_3(VAR_0):...\n",
"VAR_0.DEBUG = True\n",
"VAR_6 = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' parent=view key='blob'\"\n )\n",
"VAR_7 = unicorn(None, VAR_6)\n",
"VAR_10 = CLASS_0(component_name='test', component_id='asdf')\n",
"VAR_8 = {'view': VAR_10}\n",
"VAR_7.render(VAR_8)\n",
"assert VAR_7.component_id == 'asdf:tests.templatetags.test_unicorn_render.FakeComponentKwargs:blob'\n",
"def FUNC_4(VAR_0):...\n",
"VAR_0.DEBUG = True\n",
"VAR_6 = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' parent=view id='flob'\"\n )\n",
"VAR_7 = unicorn(None, VAR_6)\n",
"VAR_10 = CLASS_0(component_name='test', component_id='asdf')\n",
"VAR_8 = {'view': VAR_10}\n",
"VAR_7.render(VAR_8)\n",
"assert VAR_7.component_id == 'asdf:tests.templatetags.test_unicorn_render.FakeComponentKwargs:flob'\n",
"def FUNC_5(VAR_0):...\n",
"VAR_0.DEBUG = True\n",
"VAR_6 = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' parent=view pk=99\"\n )\n",
"VAR_7 = unicorn(None, VAR_6)\n",
"VAR_10 = CLASS_0(component_name='test', component_id='asdf')\n",
"VAR_8 = {'view': VAR_10}\n",
"VAR_7.render(VAR_8)\n",
"assert VAR_7.component_id == 'asdf:tests.templatetags.test_unicorn_render.FakeComponentKwargs:99'\n",
"def FUNC_6(VAR_0):...\n",
"VAR_0.DEBUG = True\n",
"VAR_6 = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' parent=view model=model\"\n )\n",
"VAR_7 = unicorn(None, VAR_6)\n",
"VAR_10 = CLASS_0(component_name='test', component_id='asdf')\n",
"def __init__(self):...\n",
"self.id = 178\n",
"def FUNC_17(self):...\n",
"return {'id': self.id}\n"
] | [
"import re\n",
"from django.template.base import Token, TokenType\n",
"import pytest\n",
"from django_unicorn.components import UnicornView\n",
"from django_unicorn.templatetags.unicorn import unicorn\n",
"from django_unicorn.utils import generate_checksum\n",
"from example.coffee.models import Flavor\n",
"template_name = 'templates/test_component_parent.html'\n",
"template_name = 'templates/test_component_kwargs.html'\n",
"hello = 'world'\n",
"def __init__(self, *args, **kwargs):...\n",
"super().__init__(**kwargs)\n",
"self.hello = kwargs.get('test_kwarg')\n",
"template_name = 'templates/test_component_model.html'\n",
"model_id = None\n",
"def __init__(self, *args, **kwargs):...\n",
"super().__init__(**kwargs)\n",
"self.model_id = kwargs.get('model_id')\n",
"template_name = 'templates/test_component_parent.html'\n",
"def mount(self):...\n",
"self.call('testCall')\n",
"template_name = 'templates/test_component_parent.html'\n",
"def mount(self):...\n",
"self.call('testCall2', 'hello')\n",
"def test_unicorn_render_kwarg():...\n",
"token = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' test_kwarg='tested!'\"\n )\n",
"unicorn_node = unicorn(None, token)\n",
"context = {}\n",
"actual = unicorn_node.render(context)\n",
"assert '->tested!<-' in actual\n",
"def test_unicorn_render_context_variable():...\n",
"token = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' test_kwarg=test_var.nested\"\n )\n",
"unicorn_node = unicorn(None, token)\n",
"context = {'test_var': {'nested': 'variable!'}}\n",
"actual = unicorn_node.render(context)\n",
"assert '->variable!<-' in actual\n",
"def test_unicorn_render_parent(settings):...\n",
"settings.DEBUG = True\n",
"token = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' parent=view\"\n )\n",
"unicorn_node = unicorn(None, token)\n",
"view = FakeComponentParent(component_name='test', component_id='asdf')\n",
"context = {'view': view}\n",
"unicorn_node.render(context)\n",
"assert unicorn_node.parent\n",
"assert unicorn_node.component_id == 'asdf:tests.templatetags.test_unicorn_render.FakeComponentKwargs'\n",
"def test_unicorn_render_parent_with_key(settings):...\n",
"settings.DEBUG = True\n",
"token = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' parent=view key='blob'\"\n )\n",
"unicorn_node = unicorn(None, token)\n",
"view = FakeComponentParent(component_name='test', component_id='asdf')\n",
"context = {'view': view}\n",
"unicorn_node.render(context)\n",
"assert unicorn_node.component_id == 'asdf:tests.templatetags.test_unicorn_render.FakeComponentKwargs:blob'\n",
"def test_unicorn_render_parent_with_id(settings):...\n",
"settings.DEBUG = True\n",
"token = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' parent=view id='flob'\"\n )\n",
"unicorn_node = unicorn(None, token)\n",
"view = FakeComponentParent(component_name='test', component_id='asdf')\n",
"context = {'view': view}\n",
"unicorn_node.render(context)\n",
"assert unicorn_node.component_id == 'asdf:tests.templatetags.test_unicorn_render.FakeComponentKwargs:flob'\n",
"def test_unicorn_render_parent_with_pk(settings):...\n",
"settings.DEBUG = True\n",
"token = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' parent=view pk=99\"\n )\n",
"unicorn_node = unicorn(None, token)\n",
"view = FakeComponentParent(component_name='test', component_id='asdf')\n",
"context = {'view': view}\n",
"unicorn_node.render(context)\n",
"assert unicorn_node.component_id == 'asdf:tests.templatetags.test_unicorn_render.FakeComponentKwargs:99'\n",
"def test_unicorn_render_parent_with_model_id(settings):...\n",
"settings.DEBUG = True\n",
"token = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' parent=view model=model\"\n )\n",
"unicorn_node = unicorn(None, token)\n",
"view = FakeComponentParent(component_name='test', component_id='asdf')\n",
"def __init__(self):...\n",
"self.id = 178\n",
"def to_json(self):...\n",
"return {'id': self.id}\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,
2,
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
] | [
"Import'",
"ImportFrom'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"FunctionDef'",
"Expr'",
"Assign'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assert'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assert'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assert'",
"Assert'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assert'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assert'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assert'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"@override_settings(LOGIN_URL='/login/')...\n",
"VAR_3 = self.client.get('/password_change/done/')\n",
"self.assertEqual(VAR_3.status_code, 302)\n",
"self.assertURLEqual(VAR_3.url, '/login/?next=/password_change/done/')\n"
] | [
"@override_settings(LOGIN_URL='/login/')...\n",
"response = self.client.get('/password_change/done/')\n",
"self.assertEqual(response.status_code, 302)\n",
"self.assertURLEqual(response.url, '/login/?next=/password_change/done/')\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def __init__(self, VAR_94, VAR_218, VAR_219={}):...\n",
"self.config = configparser.ConfigParser(VAR_219)\n",
"self.config.read(VAR_94)\n",
"if not self.config.has_section(VAR_218):\n",
"self.config.add_section(VAR_218)\n",
"self.section = VAR_218\n",
"self.filename = VAR_94\n"
] | [
"def __init__(self, filename, section, default_values={}):...\n",
"self.config = configparser.ConfigParser(default_values)\n",
"self.config.read(filename)\n",
"if not self.config.has_section(section):\n",
"self.config.add_section(section)\n",
"self.section = section\n",
"self.filename = filename\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Assign'"
] |
[
"def FUNC_26(VAR_57, VAR_58):...\n",
"if VAR_57 == 'tab':\n",
"return VAR_58 != 'timelapse' or VAR_51\n",
"return True\n"
] | [
"def default_template_filter(template_type, template_key):...\n",
"if template_type == 'tab':\n",
"return template_key != 'timelapse' or enable_timelapse\n",
"return True\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_21(VAR_9, VAR_5, VAR_10):...\n",
"VAR_38 = calibre_db.session.query(db.Publishers).filter(db.Publishers.id ==\n VAR_5).first()\n",
"if VAR_38:\n",
"VAR_63, VAR_68, VAR_65 = calibre_db.fill_indexpage(VAR_9, 0, db.Books, db.\n Books.publishers.any(db.Publishers.id == VAR_5), [db.Series.name,\n VAR_10[0], db.Books.series_index], db.books_series_link, db.Books.id ==\n db.books_series_link.c.book, db.Series)\n",
"abort(404)\n",
"return render_title_template('index.html', VAR_68=random, VAR_63=entries,\n VAR_65=pagination, id=book_id, VAR_149=_(u'Publisher: %(name)s', name=\n publisher.name), VAR_9='publisher')\n"
] | [
"def render_publisher_books(page, book_id, order):...\n",
"publisher = calibre_db.session.query(db.Publishers).filter(db.Publishers.id ==\n book_id).first()\n",
"if publisher:\n",
"entries, random, pagination = calibre_db.fill_indexpage(page, 0, db.Books,\n db.Books.publishers.any(db.Publishers.id == book_id), [db.Series.name,\n order[0], db.Books.series_index], db.books_series_link, db.Books.id ==\n db.books_series_link.c.book, db.Series)\n",
"abort(404)\n",
"return render_title_template('index.html', random=random, entries=entries,\n pagination=pagination, id=book_id, title=_(u'Publisher: %(name)s', name\n =publisher.name), page='publisher')\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_153(VAR_114):...\n",
"def FUNC_118(*VAR_9, **VAR_13):...\n",
"VAR_431, VAR_432, VAR_141 = self.basic()\n",
"VAR_141 = VAR_141 or self.user\n",
"VAR_433 = VAR_145\n",
"if callable(VAR_433):\n",
"VAR_433 = VAR_433()\n",
"if VAR_433:\n",
"if not VAR_141:\n",
"if callable(VAR_144):\n",
"if VAR_263.request.ajax:\n",
"VAR_453 = VAR_144()\n",
"VAR_453 = VAR_144\n",
"if VAR_90 is not None:\n",
"if not VAR_453:\n",
"if callable(VAR_90):\n",
"if self.settings.allow_basic_login_only or VAR_432 or VAR_263.request.is_restful:\n",
"VAR_263.session.flash = self.messages.access_denied\n",
"return VAR_114(*VAR_9, **b)\n",
"return VAR_90()\n",
"redirect(VAR_90)\n",
"VAR_112 = self.here()\n",
"return FUNC_3(self.settings.on_failed_authorization)\n",
"VAR_263.session.flash = VAR_263.response.flash\n",
"return FUNC_3(self.settings.on_failed_authentication, self.settings.\n login_url + '?_next=' + urllib_quote(VAR_112))\n"
] | [
"def decorator(action):...\n",
"def f(*a, **b):...\n",
"basic_allowed, basic_accepted, user = self.basic()\n",
"user = user or self.user\n",
"login_required = requires_login\n",
"if callable(login_required):\n",
"login_required = login_required()\n",
"if login_required:\n",
"if not user:\n",
"if callable(condition):\n",
"if current.request.ajax:\n",
"flag = condition()\n",
"flag = condition\n",
"if otherwise is not None:\n",
"if not flag:\n",
"if callable(otherwise):\n",
"if self.settings.allow_basic_login_only or basic_accepted or current.request.is_restful:\n",
"current.session.flash = self.messages.access_denied\n",
"return action(*a, **b)\n",
"return otherwise()\n",
"redirect(otherwise)\n",
"next = self.here()\n",
"return call_or_redirect(self.settings.on_failed_authorization)\n",
"current.session.flash = current.response.flash\n",
"return call_or_redirect(self.settings.on_failed_authentication, self.\n settings.login_url + '?_next=' + urllib_quote(next))\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
] | [
"FunctionDef'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Condition",
"Assign'",
"Return'",
"Return'",
"Expr'",
"Assign'",
"Return'",
"Assign'",
"Return'"
] |
[
"def FUNC_7(self, VAR_2):...\n",
"self.add_change()\n",
"return self.client.post(reverse('credits', VAR_3=self.get_kwargs()), {\n 'period': '', 'style': VAR_2, 'start_date': '2000-01-01', 'end_date':\n '2100-01-01'})\n"
] | [
"def get_credits(self, style):...\n",
"self.add_change()\n",
"return self.client.post(reverse('credits', kwargs=self.get_kwargs()), {\n 'period': '', 'style': style, 'start_date': '2000-01-01', 'end_date':\n '2100-01-01'})\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Return'"
] |
[
"def FUNC_5(self, VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"if isinstance(VAR_3.func, ast.Name):\n",
"VAR_11 = None\n",
"if VAR_3.func.id == 'ObjectId':\n",
"VAR_11 = \"('\" + VAR_3.args[0].s + \"')\"\n",
"if VAR_3.func.id == 'datetime':\n",
"if VAR_11:\n",
"VAR_12 = []\n",
"self.current_value = eval(VAR_3.func.id + VAR_11)\n",
"for arg in VAR_3.args:\n",
"VAR_12.append(str(arg.n))\n",
"VAR_11 = '(' + ', '.join(VAR_12) + ')'\n"
] | [
"def visit_Call(self, node):...\n",
"\"\"\"docstring\"\"\"\n",
"if isinstance(node.func, ast.Name):\n",
"expr = None\n",
"if node.func.id == 'ObjectId':\n",
"expr = \"('\" + node.args[0].s + \"')\"\n",
"if node.func.id == 'datetime':\n",
"if expr:\n",
"values = []\n",
"self.current_value = eval(node.func.id + expr)\n",
"for arg in node.args:\n",
"values.append(str(arg.n))\n",
"expr = '(' + ', '.join(values) + ')'\n"
] | [
0,
0,
0,
5,
0,
5,
0,
5,
0,
5,
0,
5,
5
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"For",
"Expr'",
"Assign'"
] |
[
"def FUNC_57(self, VAR_112=VAR_3, VAR_134=VAR_3, VAR_135=VAR_3, VAR_136=VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_254 = self.table_user()\n",
"VAR_56 = VAR_263.request\n",
"VAR_139 = VAR_263.session\n",
"if VAR_112 is VAR_3:\n",
"VAR_112 = self.get_vars_next() or self.settings.reset_password_next\n",
"if self.settings.prevent_password_reset_attacks:\n",
"VAR_199 = VAR_56.vars.key\n",
"VAR_199 = VAR_56.vars.key or FUNC_0(-1)\n",
"if not VAR_199 and len(VAR_56.args) > 1:\n",
"VAR_374 = int(VAR_199.split('-')[0])\n",
"VAR_139.flash = self.messages.invalid_reset_password\n",
"VAR_261 = self.settings.password_field\n",
"VAR_199 = VAR_56.args[-1]\n",
"if VAR_199:\n",
"if time.time() - VAR_374 > 60 * 60 * 24:\n",
"redirect(VAR_112, client_side=self.settings.client_side)\n",
"VAR_7 = SQLFORM.factory(VAR_1('first_name', VAR_60='First Name', VAR_91=\n True), VAR_1('last_name', VAR_60='Last Name', VAR_91=True), VAR_1(\n 'new_password', 'password', VAR_60=self.messages.new_password, VAR_279=\n self.table_user()[passfield].requires), VAR_1('new_password2',\n 'password', VAR_60=self.messages.verify_password, VAR_279=[IS_EXPR(\n 'value==%s' % repr(request.vars.new_password), self.messages.\n mismatched_password)]), submit_button='Confirm Registration', hidden=\n dict(_next=next), VAR_273=self.settings.formstyle, separator=self.\n settings.label_separator)\n",
"VAR_139._reset_password_key = VAR_199\n",
"VAR_199 = VAR_139._reset_password_key\n",
"VAR_141 = VAR_254(VAR_275=key)\n",
"if VAR_7.process().accepted:\n",
"if VAR_112:\n",
"if not VAR_141:\n",
"VAR_141.update_record(**{passfield: str(form.vars.new_password),\n 'first_name': str(form.vars.first_name), 'last_name': str(form.vars.\n last_name), 'registration_key': '', 'reset_password_key': ''})\n",
"return VAR_7\n",
"VAR_452 = {'_next': VAR_112}\n",
"VAR_452 = {}\n",
"VAR_139.flash = self.messages.password_changed\n",
"redirect(self.url(VAR_11='confirm_registration', VAR_96=redirect_vars))\n",
"if self.settings.login_after_password_change:\n",
"self.login_user(VAR_141)\n",
"redirect(VAR_112, client_side=self.settings.client_side)\n"
] | [
"def confirm_registration(self, next=DEFAULT, onvalidation=DEFAULT, onaccept...\n",
"\"\"\"docstring\"\"\"\n",
"table_user = self.table_user()\n",
"request = current.request\n",
"session = current.session\n",
"if next is DEFAULT:\n",
"next = self.get_vars_next() or self.settings.reset_password_next\n",
"if self.settings.prevent_password_reset_attacks:\n",
"key = request.vars.key\n",
"key = request.vars.key or getarg(-1)\n",
"if not key and len(request.args) > 1:\n",
"t0 = int(key.split('-')[0])\n",
"session.flash = self.messages.invalid_reset_password\n",
"passfield = self.settings.password_field\n",
"key = request.args[-1]\n",
"if key:\n",
"if time.time() - t0 > 60 * 60 * 24:\n",
"redirect(next, client_side=self.settings.client_side)\n",
"form = SQLFORM.factory(Field('first_name', label='First Name', required=\n True), Field('last_name', label='Last Name', required=True), Field(\n 'new_password', 'password', label=self.messages.new_password, requires=\n self.table_user()[passfield].requires), Field('new_password2',\n 'password', label=self.messages.verify_password, requires=[IS_EXPR(\n 'value==%s' % repr(request.vars.new_password), self.messages.\n mismatched_password)]), submit_button='Confirm Registration', hidden=\n dict(_next=next), formstyle=self.settings.formstyle, separator=self.\n settings.label_separator)\n",
"session._reset_password_key = key\n",
"key = session._reset_password_key\n",
"user = table_user(reset_password_key=key)\n",
"if form.process().accepted:\n",
"if next:\n",
"if not user:\n",
"user.update_record(**{passfield: str(form.vars.new_password), 'first_name':\n str(form.vars.first_name), 'last_name': str(form.vars.last_name),\n 'registration_key': '', 'reset_password_key': ''})\n",
"return form\n",
"redirect_vars = {'_next': next}\n",
"redirect_vars = {}\n",
"session.flash = self.messages.password_changed\n",
"redirect(self.url(args='confirm_registration', vars=redirect_vars))\n",
"if self.settings.login_after_password_change:\n",
"self.login_user(user)\n",
"redirect(next, client_side=self.settings.client_side)\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'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Expr'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_71(VAR_43, VAR_126=False):...\n",
"\"\"\"docstring\"\"\"\n",
"if isinstance(VAR_43, text_type):\n",
"VAR_43 = VAR_43.encode('utf-8')\n",
"if os.path.exists(VAR_43):\n",
"return FUNC_1(f.read())\n",
"if VAR_126:\n",
"return None\n"
] | [
"def read_file(path, raise_not_found=False):...\n",
"\"\"\"docstring\"\"\"\n",
"if isinstance(path, text_type):\n",
"path = path.encode('utf-8')\n",
"if os.path.exists(path):\n",
"return as_unicode(f.read())\n",
"if raise_not_found:\n",
"return None\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'"
] |
[
"def FUNC_17(self):...\n",
"def FUNC_28(VAR_5):...\n",
"VAR_26 = rest_framework.smart_urlquote\n",
"rest_framework.smart_urlquote = FUNC_28\n",
"assert rest_framework.smart_urlquote_wrapper('test') is None\n",
"rest_framework.smart_urlquote = VAR_26\n"
] | [
"def test_smart_urlquote_wrapper_handles_value_error(self):...\n",
"def mock_smart_urlquote(url):...\n",
"old = rest_framework.smart_urlquote\n",
"rest_framework.smart_urlquote = mock_smart_urlquote\n",
"assert rest_framework.smart_urlquote_wrapper('test') is None\n",
"rest_framework.smart_urlquote = old\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assert'",
"Assign'"
] |
[
"@staticmethod...\n",
"VAR_28 = urlparse(VAR_4.url)\n",
"return {'http_host': VAR_4.host, 'server_port': VAR_28.port, 'script_name':\n VAR_4.path, 'get_data': VAR_4.args.copy(), 'post_data': VAR_4.form.copy\n (), 'https': 'on' if current_app.config.get('ONELOGIN_HTTPS') else 'off'}\n"
] | [
"@staticmethod...\n",
"url_data = urlparse(req.url)\n",
"return {'http_host': req.host, 'server_port': url_data.port, 'script_name':\n req.path, 'get_data': req.args.copy(), 'post_data': req.form.copy(),\n 'https': 'on' if current_app.config.get('ONELOGIN_HTTPS') else 'off'}\n"
] | [
0,
0,
0
] | [
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_5(self, VAR_11, VAR_12, *VAR_6, **VAR_13):...\n",
"VAR_11.write(util.read_input(VAR_12))\n",
"assert not VAR_11._v_errors, 'Template errors: %s' % VAR_11._v_errors\n",
"VAR_15 = util.read_output(VAR_12)\n",
"if not isinstance(VAR_15, str):\n",
"VAR_15 = str(VAR_15, 'utf-8')\n",
"VAR_16 = VAR_11(*VAR_6, **kwargs)\n",
"util.check_html(VAR_15, VAR_16)\n"
] | [
"def assert_expected_unicode(self, t, fname, *args, **kwargs):...\n",
"t.write(util.read_input(fname))\n",
"assert not t._v_errors, 'Template errors: %s' % t._v_errors\n",
"expect = util.read_output(fname)\n",
"if not isinstance(expect, str):\n",
"expect = str(expect, 'utf-8')\n",
"out = t(*args, **kwargs)\n",
"util.check_html(expect, out)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assert'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_13(VAR_0):...\n",
"VAR_0.DEBUG = True\n",
"VAR_6 = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentCalls2'\")\n",
"VAR_7 = unicorn(None, VAR_6)\n",
"VAR_8 = {}\n",
"VAR_12 = VAR_7.render(VAR_8)\n",
"assert '<script type=\"module\"' in VAR_12\n",
"assert len(re.findall('<script type=\"module\"', VAR_12)) == 1\n",
"assert '\"calls\":[{\"fn\":\"testCall2\",\"args\":[\"hello\"]}]' in VAR_12\n"
] | [
"def test_unicorn_render_calls_with_arg(settings):...\n",
"settings.DEBUG = True\n",
"token = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentCalls2'\")\n",
"unicorn_node = unicorn(None, token)\n",
"context = {}\n",
"html = unicorn_node.render(context)\n",
"assert '<script type=\"module\"' in html\n",
"assert len(re.findall('<script type=\"module\"', html)) == 1\n",
"assert '\"calls\":[{\"fn\":\"testCall2\",\"args\":[\"hello\"]}]' in html\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assert'",
"Assert'",
"Assert'"
] |
[
"def FUNC_1(self) ->dict:...\n",
"VAR_32 = self.default_config()\n",
"VAR_32['worker_app'] = 'synapse.app.generic_worker'\n",
"VAR_32['worker_replication_host'] = 'testserv'\n",
"VAR_32['worker_replication_http_port'] = '8765'\n",
"return VAR_32\n"
] | [
"def _get_worker_hs_config(self) ->dict:...\n",
"config = self.default_config()\n",
"config['worker_app'] = 'synapse.app.generic_worker'\n",
"config['worker_replication_host'] = 'testserv'\n",
"config['worker_replication_http_port'] = '8765'\n",
"return config\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def __call__(self, VAR_10, VAR_13, VAR_14, VAR_12):...\n",
"VAR_11 = VAR_13.get('request')\n",
"if VAR_12:\n",
"VAR_10 = self.traverse(VAR_10, VAR_11, VAR_12)\n",
"if VAR_14 is False:\n",
"return VAR_10\n",
"if getattr(VAR_10, '__call__', VAR_0) is not VAR_0 or callable(VAR_10):\n",
"VAR_10 = render(VAR_10, VAR_13)\n",
"return VAR_10\n"
] | [
"def __call__(self, base, econtext, call, path_items):...\n",
"request = econtext.get('request')\n",
"if path_items:\n",
"base = self.traverse(base, request, path_items)\n",
"if call is False:\n",
"return base\n",
"if getattr(base, '__call__', _marker) is not _marker or callable(base):\n",
"base = render(base, econtext)\n",
"return base\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Condition",
"Assign'",
"Return'"
] |
[
"__version__ = '4.6.4'\n",
"def FUNC_0():...\n",
"\"\"\"docstring\"\"\"\n",
"import os\n",
"VAR_0 = __path__[0]\n",
"VAR_1 = os.path.join(VAR_0, 'includes')\n",
"VAR_2 = [VAR_1, VAR_0]\n",
"for name in os.listdir(VAR_1):\n",
"VAR_3 = os.path.join(VAR_1, name)\n",
"return VAR_2\n",
"if os.path.isdir(VAR_3):\n",
"VAR_2.append(VAR_3)\n"
] | [
"__version__ = '4.6.4'\n",
"def get_include():...\n",
"\"\"\"docstring\"\"\"\n",
"import os\n",
"lxml_path = __path__[0]\n",
"include_path = os.path.join(lxml_path, 'includes')\n",
"includes = [include_path, lxml_path]\n",
"for name in os.listdir(include_path):\n",
"path = os.path.join(include_path, name)\n",
"return includes\n",
"if os.path.isdir(path):\n",
"includes.append(path)\n"
] | [
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Assign'",
"FunctionDef'",
"Docstring",
"Import'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Return'",
"Condition",
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"VAR_4 = self.get_success(self.store.create_e2e_room_keys_version('user_id',\n {'algorithm': 'rot13', 'auth_data': {}}))\n",
"self.get_success(self.store.add_e2e_room_keys('user_id', VAR_4, [('room',\n 'session', VAR_0)]))\n",
"VAR_5 = self.get_success(self.store.create_e2e_room_keys_version('user_id',\n {'algorithm': 'rot13', 'auth_data': {}}))\n",
"self.get_success(self.store.add_e2e_room_keys('user_id', VAR_5, [('room',\n 'session', VAR_0)]))\n",
"VAR_6 = self.get_success(self.store.get_e2e_room_keys('user_id', VAR_4))\n",
"self.assertEqual(len(VAR_6['rooms']), 1)\n",
"VAR_6 = self.get_success(self.store.get_e2e_room_keys('user_id', VAR_5))\n",
"self.assertEqual(len(VAR_6['rooms']), 1)\n",
"self.get_success(self.store.delete_e2e_room_keys_version('user_id', VAR_4))\n",
"VAR_6 = self.get_success(self.store.get_e2e_room_keys('user_id', VAR_4))\n",
"self.assertEqual(len(VAR_6['rooms']), 0)\n",
"VAR_6 = self.get_success(self.store.get_e2e_room_keys('user_id', VAR_5))\n",
"self.assertEqual(len(VAR_6['rooms']), 1)\n"
] | [
"def test_room_keys_version_delete(self):...\n",
"version1 = self.get_success(self.store.create_e2e_room_keys_version(\n 'user_id', {'algorithm': 'rot13', 'auth_data': {}}))\n",
"self.get_success(self.store.add_e2e_room_keys('user_id', version1, [('room',\n 'session', room_key)]))\n",
"version2 = self.get_success(self.store.create_e2e_room_keys_version(\n 'user_id', {'algorithm': 'rot13', 'auth_data': {}}))\n",
"self.get_success(self.store.add_e2e_room_keys('user_id', version2, [('room',\n 'session', room_key)]))\n",
"keys = self.get_success(self.store.get_e2e_room_keys('user_id', version1))\n",
"self.assertEqual(len(keys['rooms']), 1)\n",
"keys = self.get_success(self.store.get_e2e_room_keys('user_id', version2))\n",
"self.assertEqual(len(keys['rooms']), 1)\n",
"self.get_success(self.store.delete_e2e_room_keys_version('user_id', version1))\n",
"keys = self.get_success(self.store.get_e2e_room_keys('user_id', version1))\n",
"self.assertEqual(len(keys['rooms']), 0)\n",
"keys = self.get_success(self.store.get_e2e_room_keys('user_id', version2))\n",
"self.assertEqual(len(keys['rooms']), 1)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_7(VAR_1):...\n",
"VAR_20.throw(_('Invalid Search Field {0}').format(VAR_1), VAR_20.DataError)\n"
] | [
"def _raise_exception(searchfield):...\n",
"frappe.throw(_('Invalid Search Field {0}').format(searchfield), frappe.\n DataError)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |