lines
sequencelengths 1
383
| raw_lines
sequencelengths 1
383
| label
sequencelengths 1
383
| type
sequencelengths 1
383
|
---|---|---|---|
[
"@require_POST...\n",
"return FUNC_72(VAR_2, VAR_27='chgrp', VAR_5=conn, **kwargs)\n"
] | [
"@require_POST...\n",
"return dryRun(request, action='chgrp', conn=conn, **kwargs)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_1(VAR_4: pathlib.Path):...\n",
"VAR_13 = pathlib.Path(str(VAR_4) + '.data')\n",
"VAR_5 = pathlib.Path(str(VAR_4) + '.meta')\n",
"return VAR_13, VAR_5\n"
] | [
"def get_paths(base_path: pathlib.Path):...\n",
"data_file = pathlib.Path(str(base_path) + '.data')\n",
"metadata_file = pathlib.Path(str(base_path) + '.meta')\n",
"return data_file, metadata_file\n"
] | [
0,
1,
1,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_24(self, VAR_22):...\n",
"if not VAR_22.strip():\n",
"VAR_102 = '[]'\n",
"VAR_114 = self.model.search(VAR_22.strip())\n",
"return VAR_102\n",
"VAR_102 = [entry.to_dict() for entry in VAR_114]\n"
] | [
"def api_search(self, searchstring):...\n",
"if not searchstring.strip():\n",
"jsonresults = '[]'\n",
"searchresults = self.model.search(searchstring.strip())\n",
"return jsonresults\n",
"jsonresults = [entry.to_dict() for entry in searchresults]\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Assign'"
] |
[
"def FUNC_6(self) ->None:...\n",
"subprocess.run('isort .', cwd=self.project_dir, shell=True, stdout=\n subprocess.PIPE, stderr=subprocess.PIPE)\n",
"subprocess.run('black .', cwd=self.project_dir, shell=True, stdout=\n subprocess.PIPE, stderr=subprocess.PIPE)\n"
] | [
"def _reformat(self) ->None:...\n",
"subprocess.run('isort .', cwd=self.project_dir, shell=True, stdout=\n subprocess.PIPE, stderr=subprocess.PIPE)\n",
"subprocess.run('black .', cwd=self.project_dir, shell=True, stdout=\n subprocess.PIPE, stderr=subprocess.PIPE)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'"
] |
[
"def FUNC_5(VAR_22, *VAR_23, **VAR_24):...\n",
"VAR_65 = type(VAR_22)\n",
"VAR_55 = fromstring(VAR_22)\n",
"FUNC_4(VAR_55, *VAR_23, **kw)\n",
"return _transform_result(VAR_65, VAR_55)\n"
] | [
"def word_break_html(html, *args, **kw):...\n",
"result_type = type(html)\n",
"doc = fromstring(html)\n",
"word_break(doc, *args, **kw)\n",
"return _transform_result(result_type, doc)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"@VAR_0.route('/api/templates/<int:template_id>', methods=['DELETE'])...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_98 = FUNC_58(f'/internal/templates/{VAR_19}', 'delete')\n",
"return jsonify({'success': False, 'message': str(err)}), 400\n",
"return jsonify(VAR_98)\n"
] | [
"@gui.route('/api/templates/<int:template_id>', methods=['DELETE'])...\n",
"\"\"\"docstring\"\"\"\n",
"response_info = query_internal_api(f'/internal/templates/{template_id}',\n 'delete')\n",
"return jsonify({'success': False, 'message': str(err)}), 400\n",
"return jsonify(response_info)\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'",
"Return'"
] |
[
"def FUNC_51(self):...\n",
"self.logout(VAR_112=None, VAR_140=None, VAR_136=None)\n"
] | [
"def logout_bare(self):...\n",
"self.logout(next=None, onlogout=None, log=None)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_23(self):...\n",
"self._validate_mandatory()\n",
"self._validate_data_fields()\n",
"self._validate_selects()\n",
"self._validate_non_negative()\n",
"self._validate_length()\n",
"self._extract_images_from_text_editor()\n",
"self._sanitize_content()\n",
"self._save_passwords()\n",
"self.validate_workflow()\n",
"VAR_50 = self.get_all_children()\n",
"for VAR_21 in VAR_50:\n",
"VAR_21._validate_data_fields()\n",
"if self.is_new():\n",
"VAR_21._validate_selects()\n",
"for VAR_18 in optional_fields:\n",
"self.validate_set_only_once()\n",
"VAR_21._validate_non_negative()\n",
"self.set(VAR_18, None)\n",
"VAR_21._validate_length()\n",
"VAR_21._extract_images_from_text_editor()\n",
"VAR_21._sanitize_content()\n",
"VAR_21._save_passwords()\n"
] | [
"def _validate(self):...\n",
"self._validate_mandatory()\n",
"self._validate_data_fields()\n",
"self._validate_selects()\n",
"self._validate_non_negative()\n",
"self._validate_length()\n",
"self._extract_images_from_text_editor()\n",
"self._sanitize_content()\n",
"self._save_passwords()\n",
"self.validate_workflow()\n",
"children = self.get_all_children()\n",
"for d in children:\n",
"d._validate_data_fields()\n",
"if self.is_new():\n",
"d._validate_selects()\n",
"for fieldname in optional_fields:\n",
"self.validate_set_only_once()\n",
"d._validate_non_negative()\n",
"self.set(fieldname, None)\n",
"d._validate_length()\n",
"d._extract_images_from_text_editor()\n",
"d._sanitize_content()\n",
"d._save_passwords()\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'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"For",
"Expr'",
"Condition",
"Expr'",
"For",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@csrf_exempt...\n",
"VAR_6 = {'config': {'enable_collect_everything': True}, 'editorParams': {},\n 'isAuthenticated': False, 'supportedCompression': ['gzip', 'gzip-js',\n 'lz64']}\n",
"if VAR_1.COOKIES.get(settings.TOOLBAR_COOKIE_NAME\n",
"VAR_6['isAuthenticated'] = True\n",
"if VAR_1.user.is_authenticated:\n",
"if settings.JS_URL and VAR_1.user.toolbar_mode == User.TOOLBAR:\n",
"VAR_9, VAR_10 = FUNC_1(VAR_1)\n",
"VAR_6['featureFlags'] = []\n",
"VAR_6['editorParams'] = {'jsURL': settings.JS_URL, 'toolbarVersion': 'toolbar'}\n",
"VAR_6.update(VAR_9)\n",
"VAR_6['sessionRecording'] = False\n",
"if VAR_10:\n",
"if VAR_1.method == 'POST':\n",
"VAR_1.user.temporary_token = secrets.token_urlsafe(32)\n",
"statsd.incr(f'posthog_cloud_raw_endpoint_success', tags={'endpoint': 'decide'})\n",
"VAR_13 = load_data_from_request(VAR_1)\n",
"statsd.incr(f'posthog_cloud_decide_defaulted_api_version_on_value_error',\n tags={'endpoint': 'decide', 'api_version_string': api_version_string})\n",
"VAR_11 = get_token(VAR_13, VAR_1)\n",
"VAR_1.user.save()\n",
"return cors_response(VAR_1, JsonResponse(VAR_6))\n",
"VAR_14 = VAR_1.GET.get('v')\n",
"VAR_15 = 2\n",
"VAR_0 = Team.objects.get_team_from_token(VAR_11)\n",
"VAR_15 = int(VAR_14) if VAR_14 else 1\n",
"capture_exception(error)\n",
"if VAR_0 is None and VAR_11:\n",
"return cors_response(VAR_1, generate_exception_response('decide',\n f'Malformed request data: {error}', code='malformed_data'))\n",
"VAR_16 = get_project_id(VAR_13, VAR_1)\n",
"if VAR_0:\n",
"if not VAR_16:\n",
"VAR_18 = get_overridden_feature_flags(VAR_0.pk, VAR_13['distinct_id'],\n VAR_13.get('groups', {}))\n",
"return cors_response(VAR_1, generate_exception_response('decide',\n 'Project API key invalid. You can find your project API key in PostHog project settings.'\n , code='invalid_api_key', type='authentication_error', status_code=\n status.HTTP_401_UNAUTHORIZED))\n",
"VAR_17 = User.objects.get_from_personal_api_key(VAR_11)\n",
"VAR_6['featureFlags'] = VAR_18 if VAR_15 >= 2 else list(VAR_18.keys())\n",
"if VAR_17 is None:\n",
"if VAR_0.session_recording_opt_in and (FUNC_0(VAR_0, VAR_1) or len(VAR_0.\n",
"return cors_response(VAR_1, generate_exception_response('decide',\n 'Invalid Personal API key.', code='invalid_personal_key', type=\n 'authentication_error', status_code=status.HTTP_401_UNAUTHORIZED))\n",
"VAR_0 = VAR_17.teams.get(id=project_id)\n",
"VAR_6['sessionRecording'] = {'endpoint': '/s/'}\n"
] | [
"@csrf_exempt...\n",
"response = {'config': {'enable_collect_everything': True}, 'editorParams':\n {}, 'isAuthenticated': False, 'supportedCompression': ['gzip',\n 'gzip-js', 'lz64']}\n",
"if request.COOKIES.get(settings.TOOLBAR_COOKIE_NAME\n",
"response['isAuthenticated'] = True\n",
"if request.user.is_authenticated:\n",
"if settings.JS_URL and request.user.toolbar_mode == User.TOOLBAR:\n",
"r, update_user_token = decide_editor_params(request)\n",
"response['featureFlags'] = []\n",
"response['editorParams'] = {'jsURL': settings.JS_URL, 'toolbarVersion':\n 'toolbar'}\n",
"response.update(r)\n",
"response['sessionRecording'] = False\n",
"if update_user_token:\n",
"if request.method == 'POST':\n",
"request.user.temporary_token = secrets.token_urlsafe(32)\n",
"statsd.incr(f'posthog_cloud_raw_endpoint_success', tags={'endpoint': 'decide'})\n",
"data = load_data_from_request(request)\n",
"statsd.incr(f'posthog_cloud_decide_defaulted_api_version_on_value_error',\n tags={'endpoint': 'decide', 'api_version_string': api_version_string})\n",
"token = get_token(data, request)\n",
"request.user.save()\n",
"return cors_response(request, JsonResponse(response))\n",
"api_version_string = request.GET.get('v')\n",
"api_version = 2\n",
"team = Team.objects.get_team_from_token(token)\n",
"api_version = int(api_version_string) if api_version_string else 1\n",
"capture_exception(error)\n",
"if team is None and token:\n",
"return cors_response(request, generate_exception_response('decide',\n f'Malformed request data: {error}', code='malformed_data'))\n",
"project_id = get_project_id(data, request)\n",
"if team:\n",
"if not project_id:\n",
"feature_flags = get_overridden_feature_flags(team.pk, data['distinct_id'],\n data.get('groups', {}))\n",
"return cors_response(request, generate_exception_response('decide',\n 'Project API key invalid. You can find your project API key in PostHog project settings.'\n , code='invalid_api_key', type='authentication_error', status_code=\n status.HTTP_401_UNAUTHORIZED))\n",
"user = User.objects.get_from_personal_api_key(token)\n",
"response['featureFlags'] = feature_flags if api_version >= 2 else list(\n feature_flags.keys())\n",
"if user is None:\n",
"if team.session_recording_opt_in and (on_permitted_domain(team, request) or\n",
"return cors_response(request, generate_exception_response('decide',\n 'Invalid Personal API key.', code='invalid_personal_key', type=\n 'authentication_error', status_code=status.HTTP_401_UNAUTHORIZED))\n",
"team = user.teams.get(id=project_id)\n",
"response['sessionRecording'] = {'endpoint': '/s/'}\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",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Return'",
"Assign'",
"Assign'"
] |
[
"def FUNC_25(VAR_23):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_53 = 'string'\n",
"VAR_54 = VAR_23.add_parser('run', description=run_msg, formatter_class=\n argparse.RawTextHelpFormatter)\n",
"VAR_54.add_argument('--dir', type=str, required=True, help=\n 'directory containing the SavedModel to execute')\n",
"VAR_54.add_argument('--tag_set', type=str, required=True, help=\n \"tag-set of graph in SavedModel to load, separated by ','\")\n",
"VAR_54.add_argument('--signature_def', type=str, required=True, metavar=\n 'SIGNATURE_DEF_KEY', help='key of SignatureDef to run')\n",
"VAR_55 = 'string'\n",
"VAR_54.add_argument('--inputs', type=str, default='', help=msg)\n",
"VAR_55 = 'string'\n",
"VAR_54.add_argument('--input_exprs', type=str, default='', help=msg)\n",
"VAR_55 = 'string'\n",
"VAR_54.add_argument('--input_examples', type=str, default='', help=msg)\n",
"VAR_54.add_argument('--outdir', type=str, default=None, help=\n 'if specified, output tensor(s) will be saved to given directory')\n",
"VAR_54.add_argument('--overwrite', action='store_true', help=\n 'if set, output file will be overwritten if it already exists.')\n",
"VAR_54.add_argument('--tf_debug', action='store_true', help=\n 'if set, will use TensorFlow Debugger (tfdbg) to watch the intermediate Tensors and runtime GraphDefs while running the SavedModel.'\n )\n",
"VAR_54.add_argument('--worker', type=str, default=None, help=\n 'if specified, a Session will be run on the worker. Valid worker specification is a bns or gRPC path.'\n )\n",
"VAR_54.add_argument('--init_tpu', action='store_true', default=None, help=\n 'if specified, tpu.initialize_system will be called on the Session. This option should be only used if the worker is a TPU job.'\n )\n",
"VAR_54.add_argument('--use_tfrt', action='store_true', default=None, help=\n 'if specified, TFRT session will be used, instead of TF1 session.')\n",
"VAR_54.set_defaults(func=run)\n"
] | [
"def add_run_subparser(subparsers):...\n",
"\"\"\"docstring\"\"\"\n",
"run_msg = \"\"\"Usage example:\nTo run input tensors from files through a MetaGraphDef and save the output tensors to files:\n$saved_model_cli show --dir /tmp/saved_model --tag_set serve \\\\\n --signature_def serving_default \\\\\n --inputs input1_key=/tmp/124.npz[x],input2_key=/tmp/123.npy \\\\\n --input_exprs 'input3_key=np.ones(2)' \\\\\n --input_examples 'input4_key=[{\"id\":[26],\"weights\":[0.5, 0.5]}]' \\\\\n --outdir=/out\n\nFor more information about input file format, please see:\nhttps://www.tensorflow.org/guide/saved_model_cli\n\"\"\"\n",
"parser_run = subparsers.add_parser('run', description=run_msg,\n formatter_class=argparse.RawTextHelpFormatter)\n",
"parser_run.add_argument('--dir', type=str, required=True, help=\n 'directory containing the SavedModel to execute')\n",
"parser_run.add_argument('--tag_set', type=str, required=True, help=\n \"tag-set of graph in SavedModel to load, separated by ','\")\n",
"parser_run.add_argument('--signature_def', type=str, required=True, metavar\n ='SIGNATURE_DEF_KEY', help='key of SignatureDef to run')\n",
"msg = (\n \"Loading inputs from files, in the format of '<input_key>=<filename>, or '<input_key>=<filename>[<variable_name>]', separated by ';'. The file format can only be from .npy, .npz or pickle.\"\n )\n",
"parser_run.add_argument('--inputs', type=str, default='', help=msg)\n",
"msg = (\n 'Specifying inputs by python expressions, in the format of \"<input_key>=\\'<python expression>\\'\", separated by \\';\\'. numpy module is available as \\'np\\'. Please note that the expression will be evaluated as-is, and is susceptible to code injection. When this is set, the value will override duplicate input keys from --inputs option.'\n )\n",
"parser_run.add_argument('--input_exprs', type=str, default='', help=msg)\n",
"msg = (\n 'Specifying tf.Example inputs as list of dictionaries. For example: <input_key>=[{feature0:value_list,feature1:value_list}]. Use \";\" to separate input keys. Will override duplicate input keys from --inputs and --input_exprs option.'\n )\n",
"parser_run.add_argument('--input_examples', type=str, default='', help=msg)\n",
"parser_run.add_argument('--outdir', type=str, default=None, help=\n 'if specified, output tensor(s) will be saved to given directory')\n",
"parser_run.add_argument('--overwrite', action='store_true', help=\n 'if set, output file will be overwritten if it already exists.')\n",
"parser_run.add_argument('--tf_debug', action='store_true', help=\n 'if set, will use TensorFlow Debugger (tfdbg) to watch the intermediate Tensors and runtime GraphDefs while running the SavedModel.'\n )\n",
"parser_run.add_argument('--worker', type=str, default=None, help=\n 'if specified, a Session will be run on the worker. Valid worker specification is a bns or gRPC path.'\n )\n",
"parser_run.add_argument('--init_tpu', action='store_true', default=None,\n help=\n 'if specified, tpu.initialize_system will be called on the Session. This option should be only used if the worker is a TPU job.'\n )\n",
"parser_run.add_argument('--use_tfrt', action='store_true', default=None,\n help='if specified, TFRT session will be used, instead of TF1 session.')\n",
"parser_run.set_defaults(func=run)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_11(VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_53 = VAR_2.GET\n",
"VAR_54 = VAR_53.get('m', '_') + VAR_53.get('p', '_') + VAR_53.get('c', '_'\n ) + VAR_53.get('q', '_')\n",
"return VAR_54\n"
] | [
"def _get_signature_from_request(request):...\n",
"\"\"\"docstring\"\"\"\n",
"r = request.GET\n",
"rv = r.get('m', '_') + r.get('p', '_') + r.get('c', '_') + r.get('q', '_')\n",
"return rv\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Return'"
] |
[
"def __init__(self, VAR_1, VAR_2):...\n",
"if VAR_1 is None:\n",
"return\n",
"super().__init__()\n",
"self.enabled = VAR_1.get('enabled', False)\n",
"self.renew_by_email_enabled = 'renew_at' in VAR_1\n",
"if self.enabled:\n",
"if 'period' in VAR_1:\n",
"VAR_7 = VAR_1.get('template_dir')\n",
"self.period = self.parse_duration(VAR_1['period'])\n",
"if 'renew_at' in VAR_1:\n",
"if not VAR_7:\n",
"self.renew_at = self.parse_duration(VAR_1['renew_at'])\n",
"if 'renew_email_subject' in VAR_1:\n",
"VAR_7 = pkg_resources.resource_filename('synapse', 'res/templates')\n",
"if 'account_renewed_html_path' in VAR_1:\n",
"self.renew_email_subject = VAR_1['renew_email_subject']\n",
"self.renew_email_subject = 'Renew your %(app)s account'\n",
"VAR_12 = os.path.join(VAR_7, VAR_1['account_renewed_html_path'])\n",
"self.account_renewed_html_content = (\n '<html><body>Your account has been successfully renewed.</body><html>')\n",
"self.startup_job_max_delta = self.period * 10.0 / 100.0\n",
"self.account_renewed_html_content = self.read_file(VAR_12,\n 'account_validity.account_renewed_html_path')\n",
"if 'invalid_token_html_path' in VAR_1:\n",
"VAR_12 = os.path.join(VAR_7, VAR_1['invalid_token_html_path'])\n",
"self.invalid_token_html_content = (\n '<html><body>Invalid renewal token.</body><html>')\n",
"self.invalid_token_html_content = self.read_file(VAR_12,\n 'account_validity.invalid_token_html_path')\n"
] | [
"def __init__(self, config, synapse_config):...\n",
"if config is None:\n",
"return\n",
"super().__init__()\n",
"self.enabled = config.get('enabled', False)\n",
"self.renew_by_email_enabled = 'renew_at' in config\n",
"if self.enabled:\n",
"if 'period' in config:\n",
"template_dir = config.get('template_dir')\n",
"self.period = self.parse_duration(config['period'])\n",
"if 'renew_at' in config:\n",
"if not template_dir:\n",
"self.renew_at = self.parse_duration(config['renew_at'])\n",
"if 'renew_email_subject' in config:\n",
"template_dir = pkg_resources.resource_filename('synapse', 'res/templates')\n",
"if 'account_renewed_html_path' in config:\n",
"self.renew_email_subject = config['renew_email_subject']\n",
"self.renew_email_subject = 'Renew your %(app)s account'\n",
"file_path = os.path.join(template_dir, config['account_renewed_html_path'])\n",
"self.account_renewed_html_content = (\n '<html><body>Your account has been successfully renewed.</body><html>')\n",
"self.startup_job_max_delta = self.period * 10.0 / 100.0\n",
"self.account_renewed_html_content = self.read_file(file_path,\n 'account_validity.account_renewed_html_path')\n",
"if 'invalid_token_html_path' in config:\n",
"file_path = os.path.join(template_dir, config['invalid_token_html_path'])\n",
"self.invalid_token_html_content = (\n '<html><body>Invalid renewal token.</body><html>')\n",
"self.invalid_token_html_content = self.read_file(file_path,\n 'account_validity.invalid_token_html_path')\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'",
"Condition",
"Return'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_13(self):...\n",
"VAR_21 = (\n 'inputx=C:\\\\Program Files\\\\data.npz[v:0];input:0=c:\\\\PROGRA~1\\\\data.npy')\n",
"VAR_23 = saved_model_cli.preprocess_inputs_arg_string(VAR_21)\n",
"self.assertTrue(VAR_23['inputx'] == ('C:\\\\Program Files\\\\data.npz', 'v:0'))\n",
"self.assertTrue(VAR_23['input:0'] == ('c:\\\\PROGRA~1\\\\data.npy', None))\n"
] | [
"def testInputPreProcessFileNames(self):...\n",
"input_str = (\n 'inputx=C:\\\\Program Files\\\\data.npz[v:0];input:0=c:\\\\PROGRA~1\\\\data.npy')\n",
"input_dict = saved_model_cli.preprocess_inputs_arg_string(input_str)\n",
"self.assertTrue(input_dict['inputx'] == ('C:\\\\Program Files\\\\data.npz', 'v:0'))\n",
"self.assertTrue(input_dict['input:0'] == ('c:\\\\PROGRA~1\\\\data.npy', None))\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_27(VAR_87=False, VAR_88=False, VAR_89=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_89:\n",
"VAR_89 = ['GET', 'POST', 'PUT', 'DELETE']\n",
"def FUNC_115(VAR_129):...\n",
"VAR_83.append(VAR_129)\n",
"VAR_86[VAR_129] = VAR_89\n",
"if VAR_87:\n",
"VAR_84.append(VAR_129)\n",
"return VAR_129\n",
"if VAR_88:\n",
"VAR_85.append(VAR_129)\n"
] | [
"def whitelist(allow_guest=False, xss_safe=False, methods=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if not methods:\n",
"methods = ['GET', 'POST', 'PUT', 'DELETE']\n",
"def innerfn(fn):...\n",
"whitelisted.append(fn)\n",
"allowed_http_methods_for_whitelisted_func[fn] = methods\n",
"if allow_guest:\n",
"guest_methods.append(fn)\n",
"return fn\n",
"if xss_safe:\n",
"xss_safe_methods.append(fn)\n"
] | [
0,
0,
0,
0,
0,
2,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"FunctionDef'",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Return'",
"Condition",
"Expr'"
] |
[
"def FUNC_16(self):...\n",
"VAR_15 = self._makeOne()\n",
"VAR_16 = CLASS_1()\n",
"VAR_17 = CLASS_0(RESPONSE=response)\n",
"VAR_25 = b'cookie:from_other_plugin'\n",
"VAR_26 = encodebytes(VAR_25)\n",
"VAR_26 = VAR_26.rstrip()\n",
"if six.PY3:\n",
"VAR_26 = VAR_26.decode('utf8')\n",
"VAR_17.set(VAR_15.cookie_name, VAR_26)\n",
"self.assertEqual(VAR_15.extractCredentials(VAR_17), {})\n"
] | [
"def test_extractCredentials_from_cookie_with_colon_that_is_not_ours(self):...\n",
"helper = self._makeOne()\n",
"response = FauxCookieResponse()\n",
"request = FauxSettableRequest(RESPONSE=response)\n",
"cookie_str = b'cookie:from_other_plugin'\n",
"cookie_val = encodebytes(cookie_str)\n",
"cookie_val = cookie_val.rstrip()\n",
"if six.PY3:\n",
"cookie_val = cookie_val.decode('utf8')\n",
"request.set(helper.cookie_name, cookie_val)\n",
"self.assertEqual(helper.extractCredentials(request), {})\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@VAR_1.post('/json_body')...\n",
"\"\"\"docstring\"\"\"\n",
"return\n"
] | [
"@test_router.post('/json_body')...\n",
"\"\"\"docstring\"\"\"\n",
"return\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_16(self):...\n",
"VAR_5 = self._makeContext()\n",
"self.assertEqual(VAR_5.evaluate('x | string:x'), 'x')\n"
] | [
"def test_hybrid_with_string_expression(self):...\n",
"ec = self._makeContext()\n",
"self.assertEqual(ec.evaluate('x | string:x'), 'x')\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def __init__(self):...\n",
"self._context = SSL.Context(SSL.SSLv23_METHOD)\n",
"self._context.set_verify(VERIFY_NONE, lambda *_: None)\n"
] | [
"def __init__(self):...\n",
"self._context = SSL.Context(SSL.SSLv23_METHOD)\n",
"self._context.set_verify(VERIFY_NONE, lambda *_: None)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"@app.route('/folders/rename', methods=['POST'])...\n",
"VAR_9 = forms.RenameDirectoryForm()\n",
"if VAR_9.validate_on_submit():\n",
"return redirect('/')\n",
"VAR_35 = data.rename_folder(VAR_9.current_path.data, VAR_9.new_name.data)\n",
"flash('Directory not found.', 'error')\n",
"if not VAR_35:\n",
"flash('Target directory exists.', 'error')\n",
"flash('Invalid input.', 'error')\n",
"flash('Renamed successfully.', 'success')\n",
"return redirect(f'/?path={VAR_35}')\n"
] | [
"@app.route('/folders/rename', methods=['POST'])...\n",
"form = forms.RenameDirectoryForm()\n",
"if form.validate_on_submit():\n",
"return redirect('/')\n",
"new_path = data.rename_folder(form.current_path.data, form.new_name.data)\n",
"flash('Directory not found.', 'error')\n",
"if not new_path:\n",
"flash('Target directory exists.', 'error')\n",
"flash('Invalid input.', 'error')\n",
"flash('Renamed successfully.', 'success')\n",
"return redirect(f'/?path={new_path}')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def __getattr__(self, VAR_14: str) ->Any:...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_14 in self._configs.keys():\n",
"return self._configs[VAR_14]\n",
"return self._get_unclassed_config(None, VAR_14)\n"
] | [
"def __getattr__(self, item: str) ->Any:...\n",
"\"\"\"docstring\"\"\"\n",
"if item in self._configs.keys():\n",
"return self._configs[item]\n",
"return self._get_unclassed_config(None, item)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_0(VAR_4: EscapableEntity) ->str:...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_7 = type(VAR_4)\n",
"if VAR_4 is None:\n",
"return u''\n",
"if VAR_7 == int:\n",
"return str(VAR_4)\n",
"if isinstance(VAR_4, HTML):\n",
"return VAR_4.__html__()\n",
"if isinstance(VAR_7, str):\n",
"return html_escape(VAR_4, quote=True)\n",
"if isinstance(VAR_7, bytes):\n",
"return html_escape(ensure_str(VAR_4), quote=True)\n",
"return html_escape(u'%s' % VAR_4, quote=True)\n"
] | [
"def escape_attribute(value: EscapableEntity) ->str:...\n",
"\"\"\"docstring\"\"\"\n",
"attr_type = type(value)\n",
"if value is None:\n",
"return u''\n",
"if attr_type == int:\n",
"return str(value)\n",
"if isinstance(value, HTML):\n",
"return value.__html__()\n",
"if isinstance(attr_type, str):\n",
"return html_escape(value, quote=True)\n",
"if isinstance(attr_type, bytes):\n",
"return html_escape(ensure_str(value), quote=True)\n",
"return html_escape(u'%s' % value, quote=True)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_59():...\n",
"\"\"\"docstring\"\"\"\n",
"if 'templates_per_page' not in VAR_84:\n",
"VAR_84['templates_per_page'] = 10\n",
"if 'templates_filter' not in VAR_84:\n",
"VAR_84['templates_filter'] = {key: 'any' for key in ['application', 'backend']}\n",
"if 'jobs_per_page' not in VAR_84:\n",
"VAR_84['jobs_per_page'] = 10\n",
"if 'jobs_filter' not in VAR_84:\n",
"VAR_84['jobs_filter'] = {key: 'any' for key in ['status', 'application',\n 'backend']}\n",
"if 'subjobs_per_page' not in VAR_84:\n",
"VAR_84['subjobs_per_page'] = 10\n",
"if 'subjobs_filter' not in VAR_84:\n",
"VAR_84['subjobs_filter'] = {key: 'any' for key in ['status', 'application',\n 'backend']}\n"
] | [
"def create_session_defaults():...\n",
"\"\"\"docstring\"\"\"\n",
"if 'templates_per_page' not in session:\n",
"session['templates_per_page'] = 10\n",
"if 'templates_filter' not in session:\n",
"session['templates_filter'] = {key: 'any' for key in ['application', 'backend']\n }\n",
"if 'jobs_per_page' not in session:\n",
"session['jobs_per_page'] = 10\n",
"if 'jobs_filter' not in session:\n",
"session['jobs_filter'] = {key: 'any' for key in ['status', 'application',\n 'backend']}\n",
"if 'subjobs_per_page' not in session:\n",
"session['subjobs_per_page'] = 10\n",
"if 'subjobs_filter' not in session:\n",
"session['subjobs_filter'] = {key: 'any' for key in ['status', 'application',\n 'backend']}\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'"
] |
[
"def FUNC_27(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(['run', '--dir', VAR_9, '--tag_set',\n 'serve', '--signature_def', 'INVALID_SIGNATURE', '--input_exprs',\n 'x2=np.ones((3,1))'])\n",
"saved_model_cli.run(VAR_10)\n"
] | [
"def testRunCommandInvalidSignature(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(['run', '--dir', base_path, '--tag_set',\n 'serve', '--signature_def', 'INVALID_SIGNATURE', '--input_exprs',\n 'x2=np.ones((3,1))'])\n",
"saved_model_cli.run(args)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_17(VAR_30, VAR_1):...\n",
"VAR_2 = VAR_1.server_name\n",
"VAR_54 = VAR_45[VAR_2]\n",
"VAR_54.remove(id(VAR_1))\n",
"if not VAR_54:\n",
"VAR_0.debug('Releasing key lookup lock on %s', VAR_2)\n",
"return VAR_30\n",
"FUNC_16(VAR_2)\n"
] | [
"def lookup_done(res, verify_request):...\n",
"server_name = verify_request.server_name\n",
"server_requests = server_to_request_ids[server_name]\n",
"server_requests.remove(id(verify_request))\n",
"if not server_requests:\n",
"logger.debug('Releasing key lookup lock on %s', server_name)\n",
"return res\n",
"drop_server_lock(server_name)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Return'",
"Expr'"
] |
[
"def FUNC_4(self, VAR_7=None, VAR_8=[], VAR_9=None):...\n",
"for member in VAR_8:\n",
"VAR_32 = '/rooms/%s/state/m.room.member/%s' % (VAR_7, member)\n",
"VAR_22, VAR_23 = self.make_request('GET', VAR_32)\n",
"self.assertEquals(VAR_9, VAR_23.code)\n"
] | [
"def _test_get_membership(self, room=None, members=[], expect_code=None):...\n",
"for member in members:\n",
"path = '/rooms/%s/state/m.room.member/%s' % (room, member)\n",
"request, channel = self.make_request('GET', path)\n",
"self.assertEquals(expect_code, channel.code)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_2(self, VAR_1, VAR_2):...\n",
"self.fetches = []\n",
"def FUNC_10(VAR_23, VAR_24, VAR_25, VAR_26=None, VAR_27=None):...\n",
"\"\"\"docstring\"\"\"\n",
"def FUNC_11(VAR_37):...\n",
"VAR_4, VAR_39 = VAR_37\n",
"VAR_25.write(VAR_4)\n",
"return VAR_39\n"
] | [
"def make_homeserver(self, reactor, clock):...\n",
"self.fetches = []\n",
"def get_file(destination, path, output_stream, args=None, max_size=None):...\n",
"\"\"\"docstring\"\"\"\n",
"def write_to(r):...\n",
"data, response = r\n",
"output_stream.write(data)\n",
"return response\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"FunctionDef'",
"Docstring",
"FunctionDef'",
"Assign'",
"Expr'",
"Return'"
] |
[
"async def FUNC_18(VAR_3, **VAR_4):...\n",
""
] | [
"async def callback(request, **kwargs):...\n",
""
] | [
0,
0
] | [
"AsyncFunctionDef'",
"Condition"
] |
[
"def FUNC_8(self, VAR_23=None, **VAR_22):...\n",
"\"\"\"docstring\"\"\"\n",
"self.attrs = self.widget.build_attrs(VAR_23=None, **kwargs)\n",
"return self.attrs\n"
] | [
"def build_attrs(self, extra_attrs=None, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"self.attrs = self.widget.build_attrs(extra_attrs=None, **kwargs)\n",
"return self.attrs\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Return'"
] |
[
"async def FUNC_5(self):...\n",
"if hasattr(self, 'resolved_ref'):\n",
"return self.resolved_ref\n",
"VAR_28 = f'https://api.github.com/gists/{self.gist_id}'\n",
"self.log.debug('Fetching %s', VAR_28)\n",
"VAR_41 = await self.github_api_request(VAR_28)\n",
"if VAR_41 is None:\n",
"return None\n",
"VAR_45 = json.loads(VAR_41.body.decode('utf-8'))\n",
"if not self.allow_secret_gist and not VAR_45['public']:\n",
"VAR_51 = [e['version'] for e in VAR_45['history']]\n",
"if self.unresolved_ref in {'', 'HEAD', 'master'}:\n",
"self.resolved_ref = VAR_51[0]\n",
"if self.unresolved_ref not in VAR_51:\n",
"return self.resolved_ref\n",
"return None\n",
"self.resolved_ref = self.unresolved_ref\n"
] | [
"async def get_resolved_ref(self):...\n",
"if hasattr(self, 'resolved_ref'):\n",
"return self.resolved_ref\n",
"api_url = f'https://api.github.com/gists/{self.gist_id}'\n",
"self.log.debug('Fetching %s', api_url)\n",
"resp = await self.github_api_request(api_url)\n",
"if resp is None:\n",
"return None\n",
"ref_info = json.loads(resp.body.decode('utf-8'))\n",
"if not self.allow_secret_gist and not ref_info['public']:\n",
"all_versions = [e['version'] for e in ref_info['history']]\n",
"if self.unresolved_ref in {'', 'HEAD', 'master'}:\n",
"self.resolved_ref = all_versions[0]\n",
"if self.unresolved_ref not in all_versions:\n",
"return self.resolved_ref\n",
"return None\n",
"self.resolved_ref = self.unresolved_ref\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"AsyncFunctionDef'",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Return'",
"Assign'"
] |
[
"@pytest.mark.options(EXTERNAL_SERVER_NAME='works.com')...\n",
"VAR_3.setattr('flask.request.host_url', 'http://example.com')\n",
"assert _validate_redirect_url('http://works.com') is True\n",
"VAR_3.undo()\n"
] | [
"@pytest.mark.options(EXTERNAL_SERVER_NAME='works.com')...\n",
"monkeypatch.setattr('flask.request.host_url', 'http://example.com')\n",
"assert _validate_redirect_url('http://works.com') is True\n",
"monkeypatch.undo()\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Expr'",
"Assert'",
"Expr'"
] |
[
"def FUNC_58(VAR_44):...\n",
"return [VAR_221 for VAR_221 in VAR_44 if not (VAR_221[:1] in '#' or VAR_221\n .endswith('~') or VAR_221.endswith('.bak'))]\n"
] | [
"def ignore(fs):...\n",
"return [f for f in fs if not (f[:1] in '#' or f.endswith('~') or f.endswith\n ('.bak'))]\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_38(self, VAR_33='created', VAR_34=''):...\n",
"VAR_77 = self.playlistdb.showPlaylists(self.getUserId(), VAR_34)\n",
"VAR_78 = int(time.time())\n",
"VAR_79 = False\n",
"for VAR_110 in VAR_77:\n",
"VAR_110['username'] = self.userdb.getNameById(VAR_110['userid'])\n",
"if VAR_33[0] == '-':\n",
"VAR_110['type'] = 'playlist'\n",
"VAR_79 = True\n",
"if not VAR_33 in ('username', 'age', 'title', 'default'):\n",
"VAR_110['age'] = VAR_78 - VAR_110['created']\n",
"VAR_33 = VAR_33[1:]\n",
"VAR_33 = 'created'\n",
"if VAR_33 == 'default':\n",
"VAR_33 = 'age'\n",
"VAR_77 = sorted(VAR_77, key=lambda x: x[sortby], reverse=is_reverse)\n",
"VAR_79 = False\n",
"return VAR_77\n"
] | [
"def api_showplaylists(self, sortby='created', filterby=''):...\n",
"playlists = self.playlistdb.showPlaylists(self.getUserId(), filterby)\n",
"curr_time = int(time.time())\n",
"is_reverse = False\n",
"for pl in playlists:\n",
"pl['username'] = self.userdb.getNameById(pl['userid'])\n",
"if sortby[0] == '-':\n",
"pl['type'] = 'playlist'\n",
"is_reverse = True\n",
"if not sortby in ('username', 'age', 'title', 'default'):\n",
"pl['age'] = curr_time - pl['created']\n",
"sortby = sortby[1:]\n",
"sortby = 'created'\n",
"if sortby == 'default':\n",
"sortby = 'age'\n",
"playlists = sorted(playlists, key=lambda x: x[sortby], reverse=is_reverse)\n",
"is_reverse = False\n",
"return playlists\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@default('git_credentials')...\n",
"if self.access_token:\n",
"if self.client_id:\n",
"return ''\n",
"return 'username={client_id}\\\\npassword={token}'.format(VAR_26=self.\n client_id, token=self.access_token)\n",
"return 'username={token}\\\\npassword=x-oauth-basic'.format(token=self.\n access_token)\n"
] | [
"@default('git_credentials')...\n",
"if self.access_token:\n",
"if self.client_id:\n",
"return ''\n",
"return 'username={client_id}\\\\npassword={token}'.format(client_id=self.\n client_id, token=self.access_token)\n",
"return 'username={token}\\\\npassword=x-oauth-basic'.format(token=self.\n access_token)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Condition",
"Return'",
"Return'",
"Return'"
] |
[
"def FUNC_26(self, VAR_14, VAR_43=None):...\n",
"VAR_14 = VAR_14.rstrip('\\n')\n",
"if not VAR_43:\n",
"VAR_43 = FUNC_48(self.default_rules)\n",
"if self._in_footnote and 'footnote' in VAR_43:\n",
"VAR_43.remove('footnote')\n",
"VAR_83 = self.renderer.placeholder()\n",
"def FUNC_84(VAR_14):...\n",
"for VAR_13 in VAR_43:\n",
"VAR_21 = getattr(self.rules, VAR_13)\n",
"return False\n",
"VAR_44 = VAR_21.match(VAR_14)\n",
"if not VAR_44:\n",
"self.line_match = VAR_44\n",
"VAR_87 = getattr(self, 'output_%s' % VAR_13)(VAR_44)\n",
"if VAR_87 is not None:\n",
"return VAR_44, VAR_87\n"
] | [
"def output(self, text, rules=None):...\n",
"text = text.rstrip('\\n')\n",
"if not rules:\n",
"rules = list(self.default_rules)\n",
"if self._in_footnote and 'footnote' in rules:\n",
"rules.remove('footnote')\n",
"output = self.renderer.placeholder()\n",
"def manipulate(text):...\n",
"for key in rules:\n",
"pattern = getattr(self.rules, key)\n",
"return False\n",
"m = pattern.match(text)\n",
"if not m:\n",
"self.line_match = m\n",
"out = getattr(self, 'output_%s' % key)(m)\n",
"if out is not None:\n",
"return m, out\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"FunctionDef'",
"For",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'"
] |
[
"@VAR_22.setter...\n",
"self._callback = VAR_26\n"
] | [
"@callback.setter...\n",
"self._callback = value\n"
] | [
0,
0
] | [
"Condition",
"Assign'"
] |
[
"def FUNC_2(VAR_5: Decimal, VAR_6: (str | None)=None, VAR_7: bool=False,...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_5 and not VAR_7:\n",
"return ''\n",
"if VAR_5 == ZERO:\n",
"return g.ledger.format_decimal(ZERO, VAR_6)\n",
"if VAR_8:\n",
"VAR_5 = -VAR_5\n",
"return g.ledger.format_decimal(VAR_5, VAR_6)\n"
] | [
"def format_currency(value: Decimal, currency: (str | None)=None,...\n",
"\"\"\"docstring\"\"\"\n",
"if not value and not show_if_zero:\n",
"return ''\n",
"if value == ZERO:\n",
"return g.ledger.format_decimal(ZERO, currency)\n",
"if invert:\n",
"value = -value\n",
"return g.ledger.format_decimal(value, currency)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_33(self):...\n",
"if frappe.flags.in_import:\n",
"return\n",
"VAR_60 = frappe.new_doc(self.doctype, as_dict=True)\n",
"self.update_if_missing(VAR_60)\n",
"for VAR_19 in self.meta.get_table_fields():\n",
"VAR_60 = frappe.new_doc(VAR_19.options, as_dict=True)\n",
"VAR_26 = self.get(VAR_19.fieldname)\n",
"if isinstance(VAR_26, list):\n",
"for VAR_21 in VAR_26:\n",
"VAR_21.update_if_missing(VAR_60)\n"
] | [
"def _set_defaults(self):...\n",
"if frappe.flags.in_import:\n",
"return\n",
"new_doc = frappe.new_doc(self.doctype, as_dict=True)\n",
"self.update_if_missing(new_doc)\n",
"for df in self.meta.get_table_fields():\n",
"new_doc = frappe.new_doc(df.options, as_dict=True)\n",
"value = self.get(df.fieldname)\n",
"if isinstance(value, list):\n",
"for d in value:\n",
"d.update_if_missing(new_doc)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Expr'",
"For",
"Assign'",
"Assign'",
"Condition",
"For",
"Expr'"
] |
[
"@unittest.override_config({'rc_joins': {'local': {'per_second': 0.5,...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_34 = [self.helper.create_room_as(self.user_id), self.helper.\n create_room_as(self.user_id), self.helper.create_room_as(self.user_id)]\n",
"self.reactor.advance(2)\n",
"VAR_34.append(self.helper.create_room_as(self.user_id))\n",
"VAR_35 = self.hs.get_datastore()\n",
"self.get_success(VAR_35.create_profile(UserID.from_string(self.user_id).\n localpart))\n",
"VAR_32 = '/_matrix/client/r0/profile/%s/displayname' % self.user_id\n",
"VAR_22, VAR_23 = self.make_request('PUT', VAR_32, {'displayname': 'John Doe'})\n",
"self.assertEquals(VAR_23.code, 200, VAR_23.json_body)\n",
"for VAR_29 in VAR_34:\n",
"VAR_32 = '/_matrix/client/r0/rooms/%s/state/m.room.member/%s' % (VAR_29,\n self.user_id)\n",
"VAR_22, VAR_23 = self.make_request('GET', VAR_32)\n",
"self.assertEquals(VAR_23.code, 200)\n",
"self.assertIn('displayname', VAR_23.json_body)\n",
"self.assertEquals(VAR_23.json_body['displayname'], 'John Doe')\n"
] | [
"@unittest.override_config({'rc_joins': {'local': {'per_second': 0.5,...\n",
"\"\"\"docstring\"\"\"\n",
"room_ids = [self.helper.create_room_as(self.user_id), self.helper.\n create_room_as(self.user_id), self.helper.create_room_as(self.user_id)]\n",
"self.reactor.advance(2)\n",
"room_ids.append(self.helper.create_room_as(self.user_id))\n",
"store = self.hs.get_datastore()\n",
"self.get_success(store.create_profile(UserID.from_string(self.user_id).\n localpart))\n",
"path = '/_matrix/client/r0/profile/%s/displayname' % self.user_id\n",
"request, channel = self.make_request('PUT', path, {'displayname': 'John Doe'})\n",
"self.assertEquals(channel.code, 200, channel.json_body)\n",
"for room_id in room_ids:\n",
"path = '/_matrix/client/r0/rooms/%s/state/m.room.member/%s' % (room_id,\n self.user_id)\n",
"request, channel = self.make_request('GET', path)\n",
"self.assertEquals(channel.code, 200)\n",
"self.assertIn('displayname', channel.json_body)\n",
"self.assertEquals(channel.json_body['displayname'], 'John Doe')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"For",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_45(self, VAR_64):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.options.get('skip_style') and VAR_64.lower().startswith('<style'):\n",
"return ''\n",
"if self.options.get('escape'):\n",
"return VAR_19(VAR_64)\n",
"return VAR_64\n"
] | [
"def block_html(self, html):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.options.get('skip_style') and html.lower().startswith('<style'):\n",
"return ''\n",
"if self.options.get('escape'):\n",
"return escape(html)\n",
"return html\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_32():...\n",
"logging.set_verbosity(logging.INFO)\n",
"VAR_63 = FUNC_31()\n",
"VAR_22 = VAR_63.parse_args()\n",
"if not hasattr(VAR_22, 'func'):\n",
"VAR_63.error('too few arguments')\n",
"VAR_22.func(VAR_22)\n"
] | [
"def main():...\n",
"logging.set_verbosity(logging.INFO)\n",
"parser = create_parser()\n",
"args = parser.parse_args()\n",
"if not hasattr(args, 'func'):\n",
"parser.error('too few arguments')\n",
"args.func(args)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'"
] |
[
"async def FUNC_1(VAR_1, VAR_4):...\n",
"async def FUNC_6(VAR_6):...\n",
"VAR_7 = await VAR_4(VAR_6)\n",
"VAR_10 = 'public; max-age={}'.format(VAR_2)\n",
"if VAR_6.path in VAR_3 or VAR_2 <= 0:\n",
"VAR_10 = 'no-cache'\n",
"VAR_7.headers.setdefault('Cache-Control', VAR_10)\n",
"return VAR_7\n"
] | [
"async def cache_control_middleware(app, handler):...\n",
"async def middleware_handler(request):...\n",
"response = await handler(request)\n",
"cache_control_value = 'public; max-age={}'.format(CACHE_MAX_AGE)\n",
"if request.path in NO_CACHE_ENDPOINTS or CACHE_MAX_AGE <= 0:\n",
"cache_control_value = 'no-cache'\n",
"response.headers.setdefault('Cache-Control', cache_control_value)\n",
"return response\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"AsyncFunctionDef'",
"AsyncFunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_49():...\n",
"VAR_83 = False\n",
"VAR_16 = request.form.to_dict()\n",
"VAR_83 |= FUNC_38(VAR_16, 'config_port')\n",
"ub.session.rollback()\n",
"config.save()\n",
"VAR_83 |= FUNC_41(VAR_16, 'config_trustedhosts')\n",
"VAR_0.error('Settings DB is not Writeable')\n",
"if VAR_83:\n",
"VAR_83 |= FUNC_41(VAR_16, 'config_keyfile')\n",
"FUNC_50(_('Settings DB is not Writeable'))\n",
"web_server.stop(True)\n",
"return FUNC_50(None, VAR_83)\n",
"if config.config_keyfile and not os.path.isfile(config.config_keyfile):\n",
"return FUNC_50(_('Keyfile Location is not Valid, Please Enter Correct Path'))\n",
"VAR_83 |= FUNC_41(VAR_16, 'config_certfile')\n",
"if config.config_certfile and not os.path.isfile(config.config_certfile):\n",
"return FUNC_50(_('Certfile Location is not Valid, Please Enter Correct Path'))\n",
"FUNC_40(VAR_16, 'config_uploading')\n",
"FUNC_40(VAR_16, 'config_unicode_filename')\n",
"VAR_83 |= FUNC_40(VAR_16, 'config_anonbrowse'\n ) and config.config_login_type == constants.LOGIN_LDAP\n",
"FUNC_40(VAR_16, 'config_public_reg')\n",
"FUNC_40(VAR_16, 'config_register_email')\n",
"VAR_83 |= FUNC_40(VAR_16, 'config_kobo_sync')\n",
"FUNC_38(VAR_16, 'config_external_port')\n",
"FUNC_40(VAR_16, 'config_kobo_proxy')\n",
"if 'config_upload_formats' in VAR_16:\n",
"VAR_16['config_upload_formats'] = ','.join(helper.uniq([VAR_17.lstrip().\n rstrip().lower() for VAR_17 in VAR_16['config_upload_formats'].split(',')])\n )\n",
"FUNC_41(VAR_16, 'config_calibre')\n",
"FUNC_41(VAR_16, 'config_upload_formats')\n",
"FUNC_41(VAR_16, 'config_converterpath')\n",
"constants.EXTENSIONS_UPLOAD = config.config_upload_formats.split(',')\n",
"FUNC_41(VAR_16, 'config_kepubifypath')\n",
"VAR_83 |= FUNC_38(VAR_16, 'config_login_type')\n",
"if config.config_login_type == constants.LOGIN_LDAP:\n",
"VAR_20, VAR_71 = FUNC_45(VAR_16)\n",
"FUNC_39(VAR_16, 'config_remote_login')\n",
"if VAR_71:\n",
"if not config.config_remote_login:\n",
"return VAR_71\n",
"VAR_83 |= VAR_20\n",
"ub.session.query(ub.RemoteAuthToken).filter(ub.RemoteAuthToken.token_type == 0\n ).delete()\n",
"FUNC_39(VAR_16, 'config_use_goodreads')\n",
"FUNC_41(VAR_16, 'config_goodreads_api_key')\n",
"FUNC_41(VAR_16, 'config_goodreads_api_secret')\n",
"if services.goodreads_support:\n",
"services.goodreads_support.connect(config.config_goodreads_api_key, config.\n config_goodreads_api_secret, config.config_use_goodreads)\n",
"FUNC_38(VAR_16, 'config_updatechannel')\n",
"FUNC_39(VAR_16, 'config_allow_reverse_proxy_header_login')\n",
"FUNC_41(VAR_16, 'config_reverse_proxy_login_header_name')\n",
"if config.config_login_type == constants.LOGIN_OAUTH:\n",
"VAR_83 |= FUNC_43(VAR_16)\n",
"VAR_20, VAR_71 = FUNC_44(VAR_16)\n",
"if VAR_71:\n",
"return VAR_71\n",
"VAR_83 |= VAR_20\n",
"FUNC_41(VAR_16, 'config_rarfile_location')\n",
"if 'config_rarfile_location' in VAR_16:\n",
"VAR_124 = helper.check_unrar(config.config_rarfile_location)\n",
"if VAR_124:\n",
"return FUNC_50(VAR_124)\n"
] | [
"def _configuration_update_helper():...\n",
"reboot_required = False\n",
"to_save = request.form.to_dict()\n",
"reboot_required |= _config_int(to_save, 'config_port')\n",
"ub.session.rollback()\n",
"config.save()\n",
"reboot_required |= _config_string(to_save, 'config_trustedhosts')\n",
"log.error('Settings DB is not Writeable')\n",
"if reboot_required:\n",
"reboot_required |= _config_string(to_save, 'config_keyfile')\n",
"_configuration_result(_('Settings DB is not Writeable'))\n",
"web_server.stop(True)\n",
"return _configuration_result(None, reboot_required)\n",
"if config.config_keyfile and not os.path.isfile(config.config_keyfile):\n",
"return _configuration_result(_(\n 'Keyfile Location is not Valid, Please Enter Correct Path'))\n",
"reboot_required |= _config_string(to_save, 'config_certfile')\n",
"if config.config_certfile and not os.path.isfile(config.config_certfile):\n",
"return _configuration_result(_(\n 'Certfile Location is not Valid, Please Enter Correct Path'))\n",
"_config_checkbox_int(to_save, 'config_uploading')\n",
"_config_checkbox_int(to_save, 'config_unicode_filename')\n",
"reboot_required |= _config_checkbox_int(to_save, 'config_anonbrowse'\n ) and config.config_login_type == constants.LOGIN_LDAP\n",
"_config_checkbox_int(to_save, 'config_public_reg')\n",
"_config_checkbox_int(to_save, 'config_register_email')\n",
"reboot_required |= _config_checkbox_int(to_save, 'config_kobo_sync')\n",
"_config_int(to_save, 'config_external_port')\n",
"_config_checkbox_int(to_save, 'config_kobo_proxy')\n",
"if 'config_upload_formats' in to_save:\n",
"to_save['config_upload_formats'] = ','.join(helper.uniq([x.lstrip().rstrip(\n ).lower() for x in to_save['config_upload_formats'].split(',')]))\n",
"_config_string(to_save, 'config_calibre')\n",
"_config_string(to_save, 'config_upload_formats')\n",
"_config_string(to_save, 'config_converterpath')\n",
"constants.EXTENSIONS_UPLOAD = config.config_upload_formats.split(',')\n",
"_config_string(to_save, 'config_kepubifypath')\n",
"reboot_required |= _config_int(to_save, 'config_login_type')\n",
"if config.config_login_type == constants.LOGIN_LDAP:\n",
"reboot, message = _configuration_ldap_helper(to_save)\n",
"_config_checkbox(to_save, 'config_remote_login')\n",
"if message:\n",
"if not config.config_remote_login:\n",
"return message\n",
"reboot_required |= reboot\n",
"ub.session.query(ub.RemoteAuthToken).filter(ub.RemoteAuthToken.token_type == 0\n ).delete()\n",
"_config_checkbox(to_save, 'config_use_goodreads')\n",
"_config_string(to_save, 'config_goodreads_api_key')\n",
"_config_string(to_save, 'config_goodreads_api_secret')\n",
"if services.goodreads_support:\n",
"services.goodreads_support.connect(config.config_goodreads_api_key, config.\n config_goodreads_api_secret, config.config_use_goodreads)\n",
"_config_int(to_save, 'config_updatechannel')\n",
"_config_checkbox(to_save, 'config_allow_reverse_proxy_header_login')\n",
"_config_string(to_save, 'config_reverse_proxy_login_header_name')\n",
"if config.config_login_type == constants.LOGIN_OAUTH:\n",
"reboot_required |= _configuration_oauth_helper(to_save)\n",
"reboot, message = _configuration_logfile_helper(to_save)\n",
"if message:\n",
"return message\n",
"reboot_required |= reboot\n",
"_config_string(to_save, 'config_rarfile_location')\n",
"if 'config_rarfile_location' in to_save:\n",
"unrar_status = helper.check_unrar(config.config_rarfile_location)\n",
"if unrar_status:\n",
"return _configuration_result(unrar_status)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"AugAssign'",
"Expr'",
"Expr'",
"AugAssign'",
"Expr'",
"Condition",
"AugAssign'",
"Expr'",
"Expr'",
"Return'",
"Condition",
"Return'",
"AugAssign'",
"Condition",
"Return'",
"Expr'",
"Expr'",
"AugAssign'",
"Expr'",
"Expr'",
"AugAssign'",
"Expr'",
"Expr'",
"For",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"AugAssign'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Condition",
"Return'",
"AugAssign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"AugAssign'",
"Assign'",
"Condition",
"Return'",
"AugAssign'",
"Expr'",
"Condition",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_83(VAR_9, *VAR_2, **VAR_3):...\n",
"if GlobalStaff().has_user(VAR_9.user):\n",
"return VAR_1(VAR_9, *VAR_2, **kwargs)\n",
"return HttpResponseForbidden(\n u'Must be {platform_name} staff to perform this action.'.format(\n platform_name=settings.PLATFORM_NAME))\n"
] | [
"def wrapped(request, *args, **kwargs):...\n",
"if GlobalStaff().has_user(request.user):\n",
"return func(request, *args, **kwargs)\n",
"return HttpResponseForbidden(\n u'Must be {platform_name} staff to perform this action.'.format(\n platform_name=settings.PLATFORM_NAME))\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_9(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self._create_alias(self.admin_user)\n",
"self.get_failure(self.handler.delete_association(create_requester(self.\n test_user), self.room_alias), synapse.api.errors.AuthError)\n"
] | [
"def test_delete_alias_not_allowed(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self._create_alias(self.admin_user)\n",
"self.get_failure(self.handler.delete_association(create_requester(self.\n test_user), self.room_alias), synapse.api.errors.AuthError)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Expr'"
] |
[
"def __enter__(self):...\n",
"FUNC_4(self.site)\n",
"return VAR_1\n"
] | [
"def __enter__(self):...\n",
"init(self.site)\n",
"return local\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Return'"
] |
[
"def FUNC_60(*VAR_119):...\n",
"\"\"\"docstring\"\"\"\n",
"return os.path.join(VAR_1.site_path, *VAR_119)\n"
] | [
"def get_site_path(*joins):...\n",
"\"\"\"docstring\"\"\"\n",
"return os.path.join(local.site_path, *joins)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_18(self, VAR_1):...\n",
"VAR_5 = VAR_1.MagicMock()\n",
"VAR_26 = VAR_1.MagicMock()\n",
"VAR_23 = oai.Schema.construct(type=mocker.MagicMock())\n",
"from openapi_python_client.parser.errors import PropertyError\n",
"from openapi_python_client.parser.properties import property_from_data\n",
"assert property_from_data(VAR_5=name, VAR_26=required, VAR_23=data\n ) == PropertyError(VAR_23=data, detail=f'unknown type {data.type}')\n"
] | [
"def test_property_from_data_unsupported_type(self, mocker):...\n",
"name = mocker.MagicMock()\n",
"required = mocker.MagicMock()\n",
"data = oai.Schema.construct(type=mocker.MagicMock())\n",
"from openapi_python_client.parser.errors import PropertyError\n",
"from openapi_python_client.parser.properties import property_from_data\n",
"assert property_from_data(name=name, required=required, data=data\n ) == PropertyError(data=data, detail=f'unknown type {data.type}')\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"ImportFrom'",
"ImportFrom'",
"Assert'"
] |
[
"def FUNC_61(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\n",
"if VAR_199:\n",
"VAR_374 = int(VAR_199.split('-')[0])\n",
"VAR_139.flash = self.messages.invalid_reset_password\n",
"VAR_199 = VAR_141.registration_key\n",
"VAR_139._reset_password_key = VAR_199\n",
"VAR_199 = VAR_139._reset_password_key\n",
"if time.time() - VAR_374 > 60 * 60 * 24:\n",
"redirect(VAR_112, client_side=self.settings.client_side)\n",
"if VAR_199 in ('pending', 'disabled', 'blocked') or (VAR_199 or '').startswith(\n",
"redirect(self.url(VAR_11='reset_password'))\n",
"VAR_141 = VAR_254(VAR_275=key)\n",
"VAR_139.flash = self.messages.registration_pending\n",
"if VAR_134 is VAR_3:\n",
"if not VAR_141:\n",
"redirect(VAR_112, client_side=self.settings.client_side)\n",
"VAR_134 = self.settings.reset_password_onvalidation\n",
"if VAR_135 is VAR_3:\n",
"VAR_135 = self.settings.reset_password_onaccept\n",
"VAR_261 = self.settings.password_field\n",
"VAR_7 = SQLFORM.factory(VAR_1('new_password', 'password', VAR_60=self.\n messages.new_password, VAR_279=self.table_user()[passfield].requires),\n VAR_1('new_password2', 'password', VAR_60=self.messages.verify_password,\n VAR_279=[IS_EXPR('value==%s' % repr(request.vars.new_password), self.\n messages.mismatched_password)]), submit_button=self.messages.\n password_reset_button, hidden=dict(_next=next), VAR_273=self.settings.\n formstyle, separator=self.settings.label_separator)\n",
"if VAR_7.accepts(VAR_56, VAR_139, VAR_134=onvalidation, hideerror=self.\n",
"VAR_141.update_record(**{passfield: str(form.vars.new_password),\n 'registration_key': '', 'reset_password_key': ''})\n",
"return VAR_7\n",
"VAR_139.flash = self.messages.password_changed\n",
"if self.settings.login_after_password_change:\n",
"self.login_user(VAR_141)\n",
"VAR_26(VAR_135, VAR_7)\n",
"redirect(VAR_112, client_side=self.settings.client_side)\n"
] | [
"def reset_password(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\n",
"if key:\n",
"t0 = int(key.split('-')[0])\n",
"session.flash = self.messages.invalid_reset_password\n",
"key = user.registration_key\n",
"session._reset_password_key = key\n",
"key = session._reset_password_key\n",
"if time.time() - t0 > 60 * 60 * 24:\n",
"redirect(next, client_side=self.settings.client_side)\n",
"if key in ('pending', 'disabled', 'blocked') or (key or '').startswith(\n",
"redirect(self.url(args='reset_password'))\n",
"user = table_user(reset_password_key=key)\n",
"session.flash = self.messages.registration_pending\n",
"if onvalidation is DEFAULT:\n",
"if not user:\n",
"redirect(next, client_side=self.settings.client_side)\n",
"onvalidation = self.settings.reset_password_onvalidation\n",
"if onaccept is DEFAULT:\n",
"onaccept = self.settings.reset_password_onaccept\n",
"passfield = self.settings.password_field\n",
"form = SQLFORM.factory(Field('new_password', 'password', label=self.\n messages.new_password, requires=self.table_user()[passfield].requires),\n Field('new_password2', 'password', label=self.messages.verify_password,\n requires=[IS_EXPR('value==%s' % repr(request.vars.new_password), self.\n messages.mismatched_password)]), submit_button=self.messages.\n password_reset_button, hidden=dict(_next=next), formstyle=self.settings\n .formstyle, separator=self.settings.label_separator)\n",
"if form.accepts(request, session, onvalidation=onvalidation, hideerror=self\n",
"user.update_record(**{passfield: str(form.vars.new_password),\n 'registration_key': '', 'reset_password_key': ''})\n",
"return form\n",
"session.flash = self.messages.password_changed\n",
"if self.settings.login_after_password_change:\n",
"self.login_user(user)\n",
"callback(onaccept, form)\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,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Return'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def __getattr__(self, VAR_199):...\n",
"if VAR_199 not in self.__dict__:\n",
"self.__dict__[VAR_199] = Storage()\n",
"return self.__dict__[VAR_199]\n"
] | [
"def __getattr__(self, key):...\n",
"if key not in self.__dict__:\n",
"self.__dict__[key] = Storage()\n",
"return self.__dict__[key]\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Return'"
] |
[
"def __init__(self, *VAR_4, **VAR_5):...\n",
"self.queryset = VAR_5.pop('queryset')\n",
"return super(CLASS_0, self).__init__(*VAR_4, **kwargs)\n"
] | [
"def __init__(self, *args, **kwargs):...\n",
"self.queryset = kwargs.pop('queryset')\n",
"return super(TagFormWidget, self).__init__(*args, **kwargs)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_24(self):...\n",
"self.client.logout()\n"
] | [
"def tearDown(self):...\n",
"self.client.logout()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_0(VAR_18: Text=DEFAULT_MODELS_PATH) ->Text:...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_18:\n",
"if not os.path.exists(VAR_18):\n",
"if os.path.isdir(VAR_18):\n",
"VAR_18 = FUNC_2(VAR_18)\n",
"if not VAR_18.endswith('.tar.gz'):\n",
"if not VAR_18:\n",
"return VAR_18\n"
] | [
"def get_local_model(model_path: Text=DEFAULT_MODELS_PATH) ->Text:...\n",
"\"\"\"docstring\"\"\"\n",
"if not model_path:\n",
"if not os.path.exists(model_path):\n",
"if os.path.isdir(model_path):\n",
"model_path = get_latest_model(model_path)\n",
"if not model_path.endswith('.tar.gz'):\n",
"if not model_path:\n",
"return model_path\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Return'"
] |
[
"def FUNC_45(self, VAR_54, VAR_55):...\n",
"return VAR_54 * VAR_55\n"
] | [
"def multiply(self, a, b):...\n",
"return a * b\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@csrf.exempt...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_27 = request.form.get('html')\n",
"if not VAR_27:\n",
"return 'No HTML provided', 400\n",
"VAR_28 = DataObj(url=request.form.get('url'), type='bookmark')\n",
"VAR_28.process_bookmark_url(VAR_27)\n",
"if VAR_28.insert():\n",
"return redirect(f'/dataobj/{VAR_28.id}')\n",
"return 'Could not save bookmark', 500\n"
] | [
"@csrf.exempt...\n",
"\"\"\"docstring\"\"\"\n",
"html = request.form.get('html')\n",
"if not html:\n",
"return 'No HTML provided', 400\n",
"bookmark = DataObj(url=request.form.get('url'), type='bookmark')\n",
"bookmark.process_bookmark_url(html)\n",
"if bookmark.insert():\n",
"return redirect(f'/dataobj/{bookmark.id}')\n",
"return 'Could not save bookmark', 500\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_13(self):...\n",
"self.assert_expected(self.folder.t, 'StringExpression.html')\n"
] | [
"def testStringExpressions(self):...\n",
"self.assert_expected(self.folder.t, 'StringExpression.html')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@FUNC_0...\n",
"return CasHandler(self)\n"
] | [
"@cache_in_self...\n",
"return CasHandler(self)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_14():...\n",
"VAR_23.component_instance.json_args = VAR_34\n",
"VAR_23.component_instance.special_args.extend(VAR_21)\n"
] | [
"def marshall_element_args():...\n",
"element.component_instance.json_args = serialized_json_args\n",
"element.component_instance.special_args.extend(special_args)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_45(*VAR_79, **VAR_42):...\n",
"\"\"\"docstring\"\"\"\n",
"import frappe.model.document\n",
"VAR_94 = frappe.model.document.get_doc(*VAR_79, **kwargs)\n",
"if VAR_79 and len(VAR_79) > 1:\n",
"VAR_46 = FUNC_42(VAR_79[0], VAR_79[1])\n",
"return VAR_94\n",
"VAR_1.document_cache[VAR_46] = VAR_94\n",
"FUNC_10().hset('document_cache', VAR_46, VAR_94.as_dict())\n"
] | [
"def get_doc(*args, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"import frappe.model.document\n",
"doc = frappe.model.document.get_doc(*args, **kwargs)\n",
"if args and len(args) > 1:\n",
"key = get_document_cache_key(args[0], args[1])\n",
"return doc\n",
"local.document_cache[key] = doc\n",
"cache().hset('document_cache', key, doc.as_dict())\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Import'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Expr'"
] |
[
"def FUNC_120():...\n",
"VAR_214 = VAR_1.db.get_value('DocType', VAR_62, 'module')\n",
"return VAR_1.module_app[FUNC_56(VAR_214)]\n"
] | [
"def _get_doctype_app():...\n",
"doctype_module = local.db.get_value('DocType', doctype, 'module')\n",
"return local.module_app[scrub(doctype_module)]\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_55(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if frappe.flags.in_patch:\n",
"return\n",
"frappe.publish_realtime('doc_update', {'modified': self.modified, 'doctype':\n self.doctype, 'name': self.name}, VAR_2=self.doctype, docname=self.name,\n after_commit=True)\n",
"if not self.meta.get('read_only') and not self.meta.get('issingle'\n",
"VAR_90 = {'doctype': self.doctype, 'name': self.name, 'user': frappe.\n session.user}\n",
"frappe.publish_realtime('list_update', VAR_90, after_commit=True)\n"
] | [
"def notify_update(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if frappe.flags.in_patch:\n",
"return\n",
"frappe.publish_realtime('doc_update', {'modified': self.modified, 'doctype':\n self.doctype, 'name': self.name}, doctype=self.doctype, docname=self.\n name, after_commit=True)\n",
"if not self.meta.get('read_only') and not self.meta.get('issingle'\n",
"data = {'doctype': self.doctype, 'name': self.name, 'user': frappe.session.user\n }\n",
"frappe.publish_realtime('list_update', data, after_commit=True)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Expr'",
"Condition",
"Assign'",
"Expr'"
] |
[
"def FUNC_7(self):...\n",
"VAR_10 = test.test_src_dir_path(VAR_0)\n",
"self.parser = saved_model_cli.create_parser()\n",
"VAR_11 = self.parser.parse_args(['show', '--dir', VAR_10, '--tag_set',\n 'badtagset'])\n",
"saved_model_cli.show(VAR_11)\n"
] | [
"def testShowCommandErrorNoTagSet(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 'badtagset'])\n",
"saved_model_cli.show(args)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_4(self, VAR_3, VAR_9, VAR_4, VAR_10):...\n",
"VAR_13 = self.event_builder_factory.for_room_version(RoomVersions.V1, {\n 'type': EventTypes.Redaction, 'sender': VAR_4.to_string(), 'state_key':\n VAR_4.to_string(), 'room_id': VAR_3.to_string(), 'content': {'reason':\n VAR_10}, 'redacts': VAR_9})\n",
"VAR_14, VAR_15 = self.get_success(self.event_creation_handler.\n create_new_client_event(VAR_13))\n",
"self.get_success(self.storage.persistence.persist_event(VAR_14, VAR_15))\n",
"return VAR_14\n"
] | [
"def inject_redaction(self, room, event_id, user, reason):...\n",
"builder = self.event_builder_factory.for_room_version(RoomVersions.V1, {\n 'type': EventTypes.Redaction, 'sender': user.to_string(), 'state_key':\n user.to_string(), 'room_id': room.to_string(), 'content': {'reason':\n reason}, 'redacts': event_id})\n",
"event, context = self.get_success(self.event_creation_handler.\n create_new_client_event(builder))\n",
"self.get_success(self.storage.persistence.persist_event(event, context))\n",
"return event\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_25(self):...\n",
"VAR_71 = 'nbserver-%s.json' % os.getpid()\n",
"return os.path.join(self.runtime_dir, VAR_71)\n"
] | [
"def _info_file_default(self):...\n",
"info_file = 'nbserver-%s.json' % os.getpid()\n",
"return os.path.join(self.runtime_dir, info_file)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_0(VAR_0):...\n",
"@wraps(VAR_0)...\n",
"VAR_4 = VAR_1.user\n",
"if not VAR_4.is_authenticated:\n",
"return redirect_to_login(next=request.get_full_path(), login_url=settings.\n LOGIN_URL)\n",
"if not VAR_4.st.is_moderator:\n",
"return VAR_0(VAR_1, *VAR_2, **kwargs)\n"
] | [
"def moderator_required(view_func):...\n",
"@wraps(view_func)...\n",
"user = request.user\n",
"if not user.is_authenticated:\n",
"return redirect_to_login(next=request.get_full_path(), login_url=settings.\n LOGIN_URL)\n",
"if not user.st.is_moderator:\n",
"return view_func(request, *args, **kwargs)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'"
] |
[
"def FUNC_3(self, VAR_6):...\n",
"if VAR_6.enable_registration is not None:\n",
"self.enable_registration = bool(strtobool(str(VAR_6.enable_registration)))\n"
] | [
"def read_arguments(self, args):...\n",
"if args.enable_registration is not None:\n",
"self.enable_registration = bool(strtobool(str(args.enable_registration)))\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'"
] |
[
"def FUNC_15(VAR_10, VAR_3, VAR_11, VAR_8):...\n",
"VAR_0 = ub.session.query(ub.Shelf).filter(ub.Shelf.id == VAR_3).first()\n",
"if VAR_0 and FUNC_1(VAR_0):\n",
"if VAR_10 == 1:\n",
"flash(_(u'Error opening shelf. Shelf does not exist or is not accessible'),\n category='error')\n",
"if VAR_8 == 'pubnew':\n",
"VAR_30 = sys.maxsize\n",
"return redirect(url_for('web.index'))\n",
"FUNC_14(VAR_3, [db.Books.pubdate.desc()])\n",
"if VAR_8 == 'pubold':\n",
"VAR_6 = 'shelfdown.html'\n",
"FUNC_14(VAR_3, [db.Books.pubdate])\n",
"if VAR_8 == 'abc':\n",
"VAR_16, VAR_26, VAR_27 = calibre_db.fill_indexpage(VAR_11, VAR_30, db.Books,\n ub.BookShelf.shelf == VAR_3, [ub.BookShelf.order.asc()], ub.BookShelf, \n ub.BookShelf.book_id == db.Books.id)\n",
"FUNC_14(VAR_3, [db.Books.sort])\n",
"if VAR_8 == 'zyx':\n",
"VAR_28 = calibre_db.session.query(ub.BookShelf).join(db.Books, ub.BookShelf\n .book_id == db.Books.id, isouter=True).filter(db.Books.id == None).all()\n",
"FUNC_14(VAR_3, [db.Books.sort.desc()])\n",
"if VAR_8 == 'new':\n",
"for entry in VAR_28:\n",
"FUNC_14(VAR_3, [db.Books.timestamp.desc()])\n",
"if VAR_8 == 'old':\n",
"VAR_1.info('Not existing book {} in {} deleted'.format(entry.book_id, VAR_0))\n",
"return render_title_template(VAR_6, entries=result, VAR_27=pagination,\n VAR_7=_(u\"Shelf: '%(name)s'\", name=shelf.name), VAR_0=shelf, VAR_6='shelf')\n",
"FUNC_14(VAR_3, [db.Books.timestamp])\n",
"if VAR_8 == 'authaz':\n",
"ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == entry.book_id\n ).delete()\n",
"ub.session.rollback()\n",
"FUNC_14(VAR_3, [db.Books.author_sort.asc(), db.Series.name, db.Books.\n series_index])\n",
"if VAR_8 == 'authza':\n",
"ub.session.commit()\n",
"VAR_1.error('Settings DB is not Writeable')\n",
"FUNC_14(VAR_3, [db.Books.author_sort.desc(), db.Series.name.desc(), db.\n Books.series_index.desc()])\n",
"VAR_6 = 'shelf.html'\n",
"flash(_('Settings DB is not Writeable'), category='error')\n",
"VAR_30 = 0\n"
] | [
"def render_show_shelf(shelf_type, shelf_id, page_no, sort_param):...\n",
"shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()\n",
"if shelf and check_shelf_view_permissions(shelf):\n",
"if shelf_type == 1:\n",
"flash(_(u'Error opening shelf. Shelf does not exist or is not accessible'),\n category='error')\n",
"if sort_param == 'pubnew':\n",
"pagesize = sys.maxsize\n",
"return redirect(url_for('web.index'))\n",
"change_shelf_order(shelf_id, [db.Books.pubdate.desc()])\n",
"if sort_param == 'pubold':\n",
"page = 'shelfdown.html'\n",
"change_shelf_order(shelf_id, [db.Books.pubdate])\n",
"if sort_param == 'abc':\n",
"result, __, pagination = calibre_db.fill_indexpage(page_no, pagesize, db.\n Books, ub.BookShelf.shelf == shelf_id, [ub.BookShelf.order.asc()], ub.\n BookShelf, ub.BookShelf.book_id == db.Books.id)\n",
"change_shelf_order(shelf_id, [db.Books.sort])\n",
"if sort_param == 'zyx':\n",
"wrong_entries = calibre_db.session.query(ub.BookShelf).join(db.Books, ub.\n BookShelf.book_id == db.Books.id, isouter=True).filter(db.Books.id == None\n ).all()\n",
"change_shelf_order(shelf_id, [db.Books.sort.desc()])\n",
"if sort_param == 'new':\n",
"for entry in wrong_entries:\n",
"change_shelf_order(shelf_id, [db.Books.timestamp.desc()])\n",
"if sort_param == 'old':\n",
"log.info('Not existing book {} in {} deleted'.format(entry.book_id, shelf))\n",
"return render_title_template(page, entries=result, pagination=pagination,\n title=_(u\"Shelf: '%(name)s'\", name=shelf.name), shelf=shelf, page='shelf')\n",
"change_shelf_order(shelf_id, [db.Books.timestamp])\n",
"if sort_param == 'authaz':\n",
"ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == entry.book_id\n ).delete()\n",
"ub.session.rollback()\n",
"change_shelf_order(shelf_id, [db.Books.author_sort.asc(), db.Series.name,\n db.Books.series_index])\n",
"if sort_param == 'authza':\n",
"ub.session.commit()\n",
"log.error('Settings DB is not Writeable')\n",
"change_shelf_order(shelf_id, [db.Books.author_sort.desc(), db.Series.name.\n desc(), db.Books.series_index.desc()])\n",
"page = 'shelf.html'\n",
"flash(_('Settings DB is not Writeable'), category='error')\n",
"pagesize = 0\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
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Return'",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"For",
"Expr'",
"Condition",
"Expr'",
"Return'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'"
] |
[
"def FUNC_7(self):...\n",
"\"\"\"docstring\"\"\"\n",
"event_from_pdu_json({'type': EventTypes.Message, 'content': {'foo': [{'bar':\n 2 ** 56}]}, 'room_id': '!room:test', 'sender': '@user:test', 'depth': 1,\n 'prev_events': [], 'auth_events': [], 'origin_server_ts': 1234},\n RoomVersions.V6)\n"
] | [
"def test_invalid_nested(self):...\n",
"\"\"\"docstring\"\"\"\n",
"event_from_pdu_json({'type': EventTypes.Message, 'content': {'foo': [{'bar':\n 2 ** 56}]}, 'room_id': '!room:test', 'sender': '@user:test', 'depth': 1,\n 'prev_events': [], 'auth_events': [], 'origin_server_ts': 1234},\n RoomVersions.V6)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'"
] |
[
"def FUNC_45(self):...\n",
"return json.dumps(audiotranscode.getDecoders())\n"
] | [
"def api_getdecoders(self):...\n",
"return json.dumps(audiotranscode.getDecoders())\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_23():...\n",
"from frappe.utils.user import UserPermissions\n",
"if not VAR_1.user_perms:\n",
"VAR_1.user_perms = UserPermissions(VAR_1.session.user)\n",
"return VAR_1.user_perms\n"
] | [
"def get_user():...\n",
"from frappe.utils.user import UserPermissions\n",
"if not local.user_perms:\n",
"local.user_perms = UserPermissions(local.session.user)\n",
"return local.user_perms\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"ImportFrom'",
"Condition",
"Assign'",
"Return'"
] |
[
"@FUNC_0...\n",
"return InitialSyncHandler(self)\n"
] | [
"@cache_in_self...\n",
"return InitialSyncHandler(self)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = FUNC_1('/groups/%s/users/%s/remove', VAR_30, VAR_16)\n",
"return self.client.post_json(VAR_5=destination, VAR_2=path, VAR_3={\n 'requester_user_id': requester_user_id}, VAR_39=content, VAR_15=True)\n"
] | [
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"path = _create_v1_path('/groups/%s/users/%s/remove', group_id, user_id)\n",
"return self.client.post_json(destination=destination, path=path, args={\n 'requester_user_id': requester_user_id}, data=content, ignore_backoff=True)\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'"
] |
[
"@VAR_2.route('/robots.txt')...\n",
"return send_from_directory(constants.STATIC_DIR, 'robots.txt')\n"
] | [
"@web.route('/robots.txt')...\n",
"return send_from_directory(constants.STATIC_DIR, 'robots.txt')\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_4(VAR_10: Dependant, VAR_22: Optional[Any]=None) ->Callable[[...\n",
"async def FUNC_5(VAR_25: WebSocket) ->None:...\n",
"VAR_53 = await solve_dependencies(VAR_24=websocket, VAR_10=dependant,\n VAR_22=dependency_overrides_provider)\n",
"VAR_11, VAR_51, VAR_56, VAR_57, VAR_58 = VAR_53\n",
"if VAR_51:\n",
"await VAR_25.close(code=WS_1008_POLICY_VIOLATION)\n",
"assert VAR_10.call is not None, 'dependant.call must be a function'\n",
"await VAR_10.call(**values)\n",
"return FUNC_5\n"
] | [
"def get_websocket_app(dependant: Dependant, dependency_overrides_provider:...\n",
"async def app(websocket: WebSocket) ->None:...\n",
"solved_result = await solve_dependencies(request=websocket, dependant=\n dependant, dependency_overrides_provider=dependency_overrides_provider)\n",
"values, errors, _, _2, _3 = solved_result\n",
"if errors:\n",
"await websocket.close(code=WS_1008_POLICY_VIOLATION)\n",
"assert dependant.call is not None, 'dependant.call must be a function'\n",
"await dependant.call(**values)\n",
"return app\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"AsyncFunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assert'",
"Expr'",
"Return'"
] |
[
"def FUNC_15(VAR_35, VAR_36=''):...\n",
"return VAR_35\n"
] | [
"def deserialize_component(ui_value, widget_id=''):...\n",
"return ui_value\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@CLASS_4('spawn-output')...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_20 = jinja.render('pre.html', title='spawn output', content=spawn_output)\n",
"return 'text/html', VAR_20\n"
] | [
"@add_handler('spawn-output')...\n",
"\"\"\"docstring\"\"\"\n",
"src = jinja.render('pre.html', title='spawn output', content=spawn_output)\n",
"return 'text/html', src\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'"
] |
[
"def FUNC_25(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(), '--overwrite'])\n",
"saved_model_cli.run(VAR_10)\n",
"VAR_42 = np.load(VAR_46)\n",
"VAR_43 = np.array([[2.5], [3.0]])\n",
"self.assertAllClose(VAR_43, VAR_42)\n"
] | [
"def testRunCommandOutOverwrite(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(), '--overwrite'])\n",
"saved_model_cli.run(args)\n",
"y_actual = np.load(output_file)\n",
"y_expected = np.array([[2.5], [3.0]])\n",
"self.assertAllClose(y_expected, y_actual)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"import io\n",
"import os\n",
"from ..InputSource import InputSource\n",
"from ..messages import *\n",
"from .main import scriptPath\n",
"from .status import splitStatus\n",
"def __init__(self, VAR_6=None, VAR_7=None):...\n",
"self.type = VAR_6\n",
"if self.type not in ('readonly', 'latest'):\n",
"self.fallback = VAR_7\n",
"def FUNC_1(self, *VAR_8, **VAR_9):...\n",
"VAR_12 = VAR_9.get('str', False)\n",
"VAR_13 = VAR_9.get('okayToFail', False)\n",
"VAR_10 = VAR_9.get('type', self.type)\n",
"VAR_11 = self._buildPath(VAR_8=segs, VAR_10=fileType)\n",
"if VAR_12:\n",
"if self.fallback:\n",
"def FUNC_2(self, *VAR_8, **VAR_9):...\n",
"return fh.read()\n",
"return open(VAR_11, encoding='utf-8')\n",
"return self._fail(VAR_11, VAR_12, VAR_13)\n",
"return self.fallback.fetch(*VAR_8, VAR_12=str, VAR_13=okayToFail)\n",
"return self._fail(VAR_11, VAR_12, VAR_13)\n",
"VAR_10 = VAR_9.get('type', self.type)\n",
"for _, _, files in os.walk(self._buildPath(VAR_8, VAR_10=fileType)):\n",
"yield from files\n",
"def FUNC_3(self, VAR_8, VAR_10=None):...\n",
"if VAR_10 is None:\n",
"VAR_10 = self.type\n",
"if VAR_10 == 'readonly':\n",
"return scriptPath('spec-data', 'readonly', *VAR_8)\n",
"return scriptPath('spec-data', *VAR_8)\n"
] | [
"import io\n",
"import os\n",
"from ..InputSource import InputSource\n",
"from ..messages import *\n",
"from .main import scriptPath\n",
"from .status import splitStatus\n",
"def __init__(self, type=None, fallback=None):...\n",
"self.type = type\n",
"if self.type not in ('readonly', 'latest'):\n",
"self.fallback = fallback\n",
"def fetch(self, *segs, **kwargs):...\n",
"str = kwargs.get('str', False)\n",
"okayToFail = kwargs.get('okayToFail', False)\n",
"fileType = kwargs.get('type', self.type)\n",
"location = self._buildPath(segs=segs, fileType=fileType)\n",
"if str:\n",
"if self.fallback:\n",
"def walkFiles(self, *segs, **kwargs):...\n",
"return fh.read()\n",
"return open(location, encoding='utf-8')\n",
"return self._fail(location, str, okayToFail)\n",
"return self.fallback.fetch(*segs, str=str, okayToFail=okayToFail)\n",
"return self._fail(location, str, okayToFail)\n",
"fileType = kwargs.get('type', self.type)\n",
"for _, _, files in os.walk(self._buildPath(segs, fileType=fileType)):\n",
"yield from files\n",
"def _buildPath(self, segs, fileType=None):...\n",
"if fileType is None:\n",
"fileType = self.type\n",
"if fileType == 'readonly':\n",
"return scriptPath('spec-data', 'readonly', *segs)\n",
"return scriptPath('spec-data', *segs)\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
] | [
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"FunctionDef'",
"Return'",
"Return'",
"Return'",
"Return'",
"Return'",
"Assign'",
"For",
"Expr'",
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def __post_init__(self) ->None:...\n",
"super().__post_init__()\n",
"if self.default is not None:\n",
"self.default = f'\"{self.default}\"'\n"
] | [
"def __post_init__(self) ->None:...\n",
"super().__post_init__()\n",
"if self.default is not None:\n",
"self.default = f'\"{self.default}\"'\n"
] | [
0,
5,
5,
5
] | [
"FunctionDef'",
"Expr'",
"Condition",
"Assign'"
] |
[
"@CLASS_4('help')...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_23 = VAR_3.path()\n",
"if not VAR_23 or VAR_23 == '/':\n",
"VAR_23 = 'index.html'\n",
"VAR_23 = VAR_23.lstrip('/')\n",
"if not docutils.docs_up_to_date(VAR_23):\n",
"message.error(\n 'Your documentation is outdated! Please re-run scripts/asciidoc2html.py.')\n",
"VAR_15 = 'html/doc/{}'.format(VAR_23)\n",
"if not VAR_23.endswith('.html'):\n",
"VAR_42 = utils.read_file(VAR_15, binary=True)\n",
"VAR_31, VAR_39 = mimetypes.guess_type(VAR_23)\n",
"VAR_32 = utils.read_file(VAR_15)\n",
"VAR_43 = VAR_15.replace('.html', '.asciidoc')\n",
"return 'text/html', VAR_32\n",
"assert VAR_31 is not None, VAR_3\n",
"if VAR_43.startswith('html/doc/'):\n",
"return VAR_31, VAR_42\n",
"VAR_43 = VAR_43.replace('html/doc/', '../doc/help/')\n",
"VAR_46 = utils.read_file(VAR_43)\n",
"VAR_46 = None\n",
"if VAR_46 is None:\n",
"VAR_44 = textwrap.dedent('string')\n",
"return 'text/plain', (VAR_44 + VAR_46).encode('utf-8')\n"
] | [
"@add_handler('help')...\n",
"\"\"\"docstring\"\"\"\n",
"urlpath = url.path()\n",
"if not urlpath or urlpath == '/':\n",
"urlpath = 'index.html'\n",
"urlpath = urlpath.lstrip('/')\n",
"if not docutils.docs_up_to_date(urlpath):\n",
"message.error(\n 'Your documentation is outdated! Please re-run scripts/asciidoc2html.py.')\n",
"path = 'html/doc/{}'.format(urlpath)\n",
"if not urlpath.endswith('.html'):\n",
"bdata = utils.read_file(path, binary=True)\n",
"mimetype, _encoding = mimetypes.guess_type(urlpath)\n",
"data = utils.read_file(path)\n",
"asciidoc_path = path.replace('.html', '.asciidoc')\n",
"return 'text/html', data\n",
"assert mimetype is not None, url\n",
"if asciidoc_path.startswith('html/doc/'):\n",
"return mimetype, bdata\n",
"asciidoc_path = asciidoc_path.replace('html/doc/', '../doc/help/')\n",
"asciidoc = utils.read_file(asciidoc_path)\n",
"asciidoc = None\n",
"if asciidoc is None:\n",
"preamble = textwrap.dedent(\n \"\"\"\n There was an error loading the documentation!\n\n This most likely means the documentation was not generated\n properly. If you are running qutebrowser from the git repository,\n please (re)run scripts/asciidoc2html.py and reload this page.\n\n If you're running a released version this is a bug, please use\n :report to report it.\n\n Falling back to the plaintext version.\n\n ---------------------------------------------------------------\n\n\n \"\"\"\n )\n",
"return 'text/plain', (preamble + asciidoc).encode('utf-8')\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
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Assert'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"@VAR_0.route('/upload', methods=['GET', 'POST'])...\n",
"if not config.config_uploading:\n",
"abort(404)\n",
"if VAR_33.method == 'POST' and 'btn-upload' in VAR_33.files:\n",
"for VAR_41 in VAR_33.files.getlist('btn-upload'):\n",
"return Response(json.dumps({'location': url_for('web.index')}), mimetype=\n 'application/json')\n",
"VAR_40 = False\n",
"calibre_db.session.rollback()\n",
"calibre_db.update_title_sort(config)\n",
"VAR_1.error('Database error: %s', e)\n",
"calibre_db.session.connection().connection.connection.create_function('uuid4',\n 0, lambda : str(uuid4()))\n",
"flash(_(u'Database error: %(error)s.', VAR_51=e), category='error')\n",
"VAR_37, VAR_51 = FUNC_36(VAR_41)\n",
"if VAR_51:\n",
"return VAR_51\n",
"VAR_42, VAR_63, VAR_71 = FUNC_35(VAR_40, VAR_37)\n",
"VAR_40 |= FUNC_19(Markup(VAR_37.description).unescape(), VAR_42)\n",
"VAR_14 = VAR_42.id\n",
"VAR_38 = VAR_42.title\n",
"VAR_51 = helper.update_dir_structure_file(VAR_14, config.config_calibre_dir,\n VAR_63[0], VAR_37.file_path, VAR_71 + VAR_37.extension.lower())\n",
"FUNC_37(VAR_37, VAR_42)\n",
"calibre_db.session.commit()\n",
"if config.config_use_google_drive:\n",
"gdriveutils.updateGdriveCalibreFromLocal()\n",
"if VAR_51:\n",
"flash(VAR_51, category='error')\n",
"VAR_109 = '<a href=\"{}\">{}</a>'.format(url_for('web.show_book', VAR_14=\n book_id), escape(VAR_38))\n",
"VAR_110 = _(u'File %(file)s uploaded', file=link)\n",
"WorkerThread.add(current_user.name, TaskUpload(VAR_110))\n",
"if len(VAR_33.files.getlist('btn-upload')) < 2:\n",
"if current_user.role_edit() or current_user.role_admin():\n",
"VAR_120 = {'location': url_for('editbook.edit_book', VAR_14=book_id)}\n",
"VAR_120 = {'location': url_for('web.show_book', VAR_14=book_id)}\n",
"return Response(json.dumps(VAR_120), mimetype='application/json')\n",
"return Response(json.dumps(VAR_120), mimetype='application/json')\n"
] | [
"@editbook.route('/upload', methods=['GET', 'POST'])...\n",
"if not config.config_uploading:\n",
"abort(404)\n",
"if request.method == 'POST' and 'btn-upload' in request.files:\n",
"for requested_file in request.files.getlist('btn-upload'):\n",
"return Response(json.dumps({'location': url_for('web.index')}), mimetype=\n 'application/json')\n",
"modif_date = False\n",
"calibre_db.session.rollback()\n",
"calibre_db.update_title_sort(config)\n",
"log.error('Database error: %s', e)\n",
"calibre_db.session.connection().connection.connection.create_function('uuid4',\n 0, lambda : str(uuid4()))\n",
"flash(_(u'Database error: %(error)s.', error=e), category='error')\n",
"meta, error = file_handling_on_upload(requested_file)\n",
"if error:\n",
"return error\n",
"db_book, input_authors, title_dir = create_book_on_upload(modif_date, meta)\n",
"modif_date |= edit_book_comments(Markup(meta.description).unescape(), db_book)\n",
"book_id = db_book.id\n",
"title = db_book.title\n",
"error = helper.update_dir_structure_file(book_id, config.config_calibre_dir,\n input_authors[0], meta.file_path, title_dir + meta.extension.lower())\n",
"move_coverfile(meta, db_book)\n",
"calibre_db.session.commit()\n",
"if config.config_use_google_drive:\n",
"gdriveutils.updateGdriveCalibreFromLocal()\n",
"if error:\n",
"flash(error, category='error')\n",
"link = '<a href=\"{}\">{}</a>'.format(url_for('web.show_book', book_id=\n book_id), escape(title))\n",
"uploadText = _(u'File %(file)s uploaded', file=link)\n",
"WorkerThread.add(current_user.name, TaskUpload(uploadText))\n",
"if len(request.files.getlist('btn-upload')) < 2:\n",
"if current_user.role_edit() or current_user.role_admin():\n",
"resp = {'location': url_for('editbook.edit_book', book_id=book_id)}\n",
"resp = {'location': url_for('web.show_book', book_id=book_id)}\n",
"return Response(json.dumps(resp), mimetype='application/json')\n",
"return Response(json.dumps(resp), mimetype='application/json')\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
] | [
"Condition",
"Condition",
"Expr'",
"Condition",
"For",
"Return'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"AugAssign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Return'"
] |
[
"@VAR_0.route('/api/jobs/<int:job_id>/subjobs/<int:subjob_id>/<attribute>',...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_114 = FUNC_58(f'/internal/jobs/{VAR_9}/subjobs/{VAR_11}/{VAR_16}', 'get')\n",
"return jsonify({'success': False, 'message': str(err)}), 400\n",
"return jsonify(VAR_114)\n"
] | [
"@gui.route('/api/jobs/<int:job_id>/subjobs/<int:subjob_id>/<attribute>',...\n",
"\"\"\"docstring\"\"\"\n",
"subjob_attribute_info = query_internal_api(\n f'/internal/jobs/{job_id}/subjobs/{subjob_id}/{attribute}', 'get')\n",
"return jsonify({'success': False, 'message': str(err)}), 400\n",
"return jsonify(subjob_attribute_info)\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'",
"Return'"
] |
[
"async def FUNC_13(self, VAR_33: str, VAR_34: BinaryIO, VAR_15: Optional[int...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_46 = {b'User-Agent': [self.user_agent]}\n",
"if VAR_24:\n",
"VAR_46.update(VAR_24)\n",
"VAR_13 = await self.request('GET', VAR_33, VAR_24=Headers(actual_headers))\n",
"VAR_49 = dict(VAR_13.headers.getAllRawHeaders())\n",
"if b'Content-Length' in VAR_49 and VAR_15 and int(VAR_49[b'Content-Length'][0]\n",
"VAR_0.warning('Requested URL is too large > %r bytes' % (VAR_15,))\n",
"if VAR_13.code > 299:\n",
"VAR_0.warning('Got %d when downloading %s' % (VAR_13.code, VAR_33))\n",
"VAR_56 = await make_deferred_yieldable(FUNC_3(VAR_13, VAR_34, VAR_15))\n",
"return VAR_56, VAR_49, VAR_13.request.absoluteURI.decode('ascii'), VAR_13.code\n"
] | [
"async def get_file(self, url: str, output_stream: BinaryIO, max_size:...\n",
"\"\"\"docstring\"\"\"\n",
"actual_headers = {b'User-Agent': [self.user_agent]}\n",
"if headers:\n",
"actual_headers.update(headers)\n",
"response = await self.request('GET', url, headers=Headers(actual_headers))\n",
"resp_headers = dict(response.headers.getAllRawHeaders())\n",
"if b'Content-Length' in resp_headers and max_size and int(resp_headers[\n",
"logger.warning('Requested URL is too large > %r bytes' % (max_size,))\n",
"if response.code > 299:\n",
"logger.warning('Got %d when downloading %s' % (response.code, url))\n",
"length = await make_deferred_yieldable(readBodyToFile(response,\n output_stream, max_size))\n",
"return length, resp_headers, response.request.absoluteURI.decode('ascii'\n ), response.code\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Return'"
] |
[
"async def FUNC_8(self):...\n",
"if not hasattr(self, 'resolved_ref'):\n",
"self.resolved_ref = await self.get_resolved_ref()\n",
"return f'https://{self.hostname}/{self.user}/{self.repo}/tree/{self.resolved_ref}'\n"
] | [
"async def get_resolved_ref_url(self):...\n",
"if not hasattr(self, 'resolved_ref'):\n",
"self.resolved_ref = await self.get_resolved_ref()\n",
"return f'https://{self.hostname}/{self.user}/{self.repo}/tree/{self.resolved_ref}'\n"
] | [
0,
0,
0,
0
] | [
"AsyncFunctionDef'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_85(self, *VAR_0, **VAR_1):...\n",
"VAR_73 = []\n",
"VAR_25 = VAR_6.__name__\n",
"VAR_91 = frappe.get_doc_hooks()\n",
"for handler in (VAR_91.get(self.doctype, {}).get(VAR_25, []) + VAR_91.get(\n",
"VAR_73.append(frappe.get_attr(handler))\n",
"VAR_92 = FUNC_84(VAR_6, *VAR_73)\n",
"return VAR_92(self, VAR_25, *VAR_0, **kwargs)\n"
] | [
"def composer(self, *args, **kwargs):...\n",
"hooks = []\n",
"method = f.__name__\n",
"doc_events = frappe.get_doc_hooks()\n",
"for handler in (doc_events.get(self.doctype, {}).get(method, []) +\n",
"hooks.append(frappe.get_attr(handler))\n",
"composed = compose(f, *hooks)\n",
"return composed(self, method, *args, **kwargs)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_40(self):...\n",
"VAR_85 = self.denied_column_value or ''\n",
"return [t.strip() for t in VAR_85.split(',')]\n"
] | [
"def list_denied_column_values(self):...\n",
"mct = self.denied_column_value or ''\n",
"return [t.strip() for t in mct.split(',')]\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_5(VAR_5, VAR_0):...\n",
"if VAR_0 == VAR_12:\n",
"self.resync_attempts += 1\n"
] | [
"def query_user_devices(destination, user_id):...\n",
"if user_id == remote_user_id:\n",
"self.resync_attempts += 1\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"AugAssign'"
] |
[
"@VAR_0.route('/ajax/sort_value/<field>/<int:bookid>')...\n",
"if VAR_45 in ['title', 'authors', 'sort', 'author_sort']:\n",
"VAR_16 = calibre_db.get_filtered_book(VAR_46)\n",
"return ''\n",
"if VAR_16:\n",
"if VAR_45 == 'title':\n",
"return json.dumps({'sort': VAR_16.sort})\n",
"if VAR_45 == 'authors':\n",
"return json.dumps({'author_sort': VAR_16.author_sort})\n",
"if VAR_45 == 'sort':\n",
"return json.dumps({'sort': VAR_16.title})\n",
"if VAR_45 == 'author_sort':\n",
"return json.dumps({'author_sort': VAR_16.author})\n"
] | [
"@editbook.route('/ajax/sort_value/<field>/<int:bookid>')...\n",
"if field in ['title', 'authors', 'sort', 'author_sort']:\n",
"book = calibre_db.get_filtered_book(bookid)\n",
"return ''\n",
"if book:\n",
"if field == 'title':\n",
"return json.dumps({'sort': book.sort})\n",
"if field == 'authors':\n",
"return json.dumps({'author_sort': book.author_sort})\n",
"if field == 'sort':\n",
"return json.dumps({'sort': book.title})\n",
"if field == 'author_sort':\n",
"return json.dumps({'author_sort': book.author})\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Assign'",
"Return'",
"Condition",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'"
] |
[
"def FUNC_1(self, VAR_3, VAR_4, VAR_6):...\n",
"self.helper.auth_user_id = self.rmcreator_id\n",
"self.uncreated_rmid = '!aa:test'\n",
"self.created_rmid = self.helper.create_room_as(self.rmcreator_id, is_public\n =False)\n",
"self.created_public_rmid = self.helper.create_room_as(self.rmcreator_id,\n is_public=True)\n",
"self.created_rmid_msg_path = ('rooms/%s/send/m.room.message/a1' % self.\n created_rmid).encode('ascii')\n",
"VAR_22, VAR_23 = self.make_request('PUT', self.created_rmid_msg_path,\n b'{\"msgtype\":\"m.text\",\"body\":\"test msg\"}')\n",
"self.assertEquals(200, VAR_23.code, VAR_23.result)\n",
"VAR_22, VAR_23 = self.make_request('PUT', ('rooms/%s/state/m.room.topic' %\n self.created_public_rmid).encode('ascii'), b'{\"topic\":\"Public Room Topic\"}'\n )\n",
"self.assertEquals(200, VAR_23.code, VAR_23.result)\n",
"self.helper.auth_user_id = self.user_id\n"
] | [
"def prepare(self, reactor, clock, hs):...\n",
"self.helper.auth_user_id = self.rmcreator_id\n",
"self.uncreated_rmid = '!aa:test'\n",
"self.created_rmid = self.helper.create_room_as(self.rmcreator_id, is_public\n =False)\n",
"self.created_public_rmid = self.helper.create_room_as(self.rmcreator_id,\n is_public=True)\n",
"self.created_rmid_msg_path = ('rooms/%s/send/m.room.message/a1' % self.\n created_rmid).encode('ascii')\n",
"request, channel = self.make_request('PUT', self.created_rmid_msg_path,\n b'{\"msgtype\":\"m.text\",\"body\":\"test msg\"}')\n",
"self.assertEquals(200, channel.code, channel.result)\n",
"request, channel = self.make_request('PUT', ('rooms/%s/state/m.room.topic' %\n self.created_public_rmid).encode('ascii'), b'{\"topic\":\"Public Room Topic\"}'\n )\n",
"self.assertEquals(200, channel.code, channel.result)\n",
"self.helper.auth_user_id = self.user_id\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'"
] |
[
"def FUNC_21():...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_3 = FUNC_5()\n",
"VAR_5 = '/'.join(request.args)\n",
"VAR_49 = request.vars.sender\n",
"if isinstance(VAR_49, list):\n",
"VAR_49 = VAR_49[0]\n",
"VAR_46 = FORM.confirm(T('Delete'), {T('Cancel'): URL(VAR_49, VAR_157=\n request.vars.id)})\n",
"if VAR_46.accepted:\n",
"return dict(VAR_46=dialog, VAR_5=filename)\n",
"VAR_177 = apath(VAR_5, VAR_122=request)\n",
"session.flash = T('unable to delete file \"%(filename)s\"', dict(VAR_5=filename))\n",
"redirect(URL(VAR_49, VAR_157=request.vars.id2))\n",
"VAR_160 = FUNC_0(open(VAR_177, 'r').read())\n",
"os.unlink(VAR_177)\n",
"FUNC_1(VAR_3, 'DELETE', VAR_5, VAR_6=-lineno)\n",
"session.flash = T('file \"%(filename)s\" deleted', dict(VAR_5=filename))\n"
] | [
"def delete():...\n",
"\"\"\"docstring\"\"\"\n",
"app = get_app()\n",
"filename = '/'.join(request.args)\n",
"sender = request.vars.sender\n",
"if isinstance(sender, list):\n",
"sender = sender[0]\n",
"dialog = FORM.confirm(T('Delete'), {T('Cancel'): URL(sender, anchor=request\n .vars.id)})\n",
"if dialog.accepted:\n",
"return dict(dialog=dialog, filename=filename)\n",
"full_path = apath(filename, r=request)\n",
"session.flash = T('unable to delete file \"%(filename)s\"', dict(filename=\n filename))\n",
"redirect(URL(sender, anchor=request.vars.id2))\n",
"lineno = count_lines(open(full_path, 'r').read())\n",
"os.unlink(full_path)\n",
"log_progress(app, 'DELETE', filename, progress=-lineno)\n",
"session.flash = T('file \"%(filename)s\" deleted', dict(filename=filename))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'"
] |
[
"def FUNC_22(VAR_15, VAR_17, VAR_29, VAR_20, VAR_30, VAR_31):...\n",
"VAR_48 = False\n",
"if VAR_20[VAR_31] == 'None':\n",
"VAR_20[VAR_31] = None\n",
"if VAR_29.datatype == 'bool':\n",
"if VAR_20[VAR_31] != VAR_30:\n",
"VAR_20[VAR_31] = 1 if VAR_20[VAR_31] == 'True' else 0\n",
"if VAR_29.datatype == 'comments':\n",
"if VAR_30 is not None:\n",
"return VAR_48, VAR_20\n",
"VAR_20[VAR_31] = Markup(VAR_20[VAR_31]).unescape()\n",
"if VAR_29.datatype == 'datetime':\n",
"if VAR_20[VAR_31] is not None:\n",
"VAR_87 = db.cc_classes[VAR_29.id]\n",
"VAR_20[VAR_31] = datetime.strptime(VAR_20[VAR_31], '%Y-%m-%d')\n",
"VAR_20[VAR_31] = db.Books.DEFAULT_PUBDATE\n",
"setattr(getattr(VAR_17, VAR_31)[0], 'value', VAR_20[VAR_31])\n",
"VAR_105 = getattr(VAR_17, VAR_31)[0]\n",
"VAR_88 = VAR_87(value=to_save[cc_string], VAR_17=book_id)\n",
"VAR_48 = True\n",
"getattr(VAR_17, VAR_31).remove(VAR_105)\n",
"calibre_db.session.add(VAR_88)\n",
"calibre_db.session.delete(VAR_105)\n",
"VAR_48 = True\n",
"VAR_48 = True\n"
] | [
"def edit_cc_data_value(book_id, book, c, to_save, cc_db_value, cc_string):...\n",
"changed = False\n",
"if to_save[cc_string] == 'None':\n",
"to_save[cc_string] = None\n",
"if c.datatype == 'bool':\n",
"if to_save[cc_string] != cc_db_value:\n",
"to_save[cc_string] = 1 if to_save[cc_string] == 'True' else 0\n",
"if c.datatype == 'comments':\n",
"if cc_db_value is not None:\n",
"return changed, to_save\n",
"to_save[cc_string] = Markup(to_save[cc_string]).unescape()\n",
"if c.datatype == 'datetime':\n",
"if to_save[cc_string] is not None:\n",
"cc_class = db.cc_classes[c.id]\n",
"to_save[cc_string] = datetime.strptime(to_save[cc_string], '%Y-%m-%d')\n",
"to_save[cc_string] = db.Books.DEFAULT_PUBDATE\n",
"setattr(getattr(book, cc_string)[0], 'value', to_save[cc_string])\n",
"del_cc = getattr(book, cc_string)[0]\n",
"new_cc = cc_class(value=to_save[cc_string], book=book_id)\n",
"changed = True\n",
"getattr(book, cc_string).remove(del_cc)\n",
"calibre_db.session.add(new_cc)\n",
"calibre_db.session.delete(del_cc)\n",
"changed = True\n",
"changed = True\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'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Return'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'"
] |
[
"def FUNC_21(self, VAR_9, VAR_20):...\n",
"f.write(VAR_20)\n"
] | [
"def albumartcache_save(self, path, data):...\n",
"f.write(data)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_2(VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"return os.path.normpath(os.path.join(VAR_3, os.pardir))\n"
] | [
"def parent_dir(directory):...\n",
"\"\"\"docstring\"\"\"\n",
"return os.path.normpath(os.path.join(directory, os.pardir))\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"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'"
] |
[
"def FUNC_12(self, VAR_13):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_68 = self.fields['method'].choices\n",
"self.fields['method'].choices = [choice for choice in VAR_68 if choice[0] !=\n VAR_13]\n"
] | [
"def remove_translation_choice(self, value):...\n",
"\"\"\"docstring\"\"\"\n",
"choices = self.fields['method'].choices\n",
"self.fields['method'].choices = [choice for choice in choices if choice[0] !=\n value]\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'"
] |
[
"def FUNC_4(VAR_3, VAR_6, VAR_7):...\n",
"VAR_50 = False\n",
"if len(VAR_7) > 0:\n",
"for del_element in VAR_7:\n",
"return VAR_50\n",
"VAR_3.remove(del_element)\n",
"VAR_50 = True\n",
"if len(del_element.books) == 0:\n",
"VAR_6.delete(del_element)\n"
] | [
"def remove_objects(db_book_object, db_session, del_elements):...\n",
"changed = False\n",
"if len(del_elements) > 0:\n",
"for del_element in del_elements:\n",
"return changed\n",
"db_book_object.remove(del_element)\n",
"changed = True\n",
"if len(del_element.books) == 0:\n",
"db_session.delete(del_element)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"For",
"Return'",
"Expr'",
"Assign'",
"Condition",
"Expr'"
] |
[
"from django.shortcuts import render, redirect\n",
"from django.contrib import messages\n",
"from django.utils.translation import gettext as _\n",
"from django.contrib.auth import get_user_model\n",
"import spirit\n",
"import django\n",
"from spirit.category.models import Category\n",
"from spirit.comment.flag.models import CommentFlag\n",
"from spirit.comment.like.models import CommentLike\n",
"from spirit.comment.models import Comment\n",
"from spirit.topic.models import Topic\n",
"from spirit.core.utils.views import is_post, post_data\n",
"from spirit.core.utils.decorators import administrator_required\n",
"from .forms import BasicConfigForm\n",
"VAR_0 = get_user_model()\n",
"@administrator_required...\n",
"VAR_2 = BasicConfigForm(data=post_data(request))\n",
"if is_post(VAR_1) and VAR_2.is_valid():\n",
"VAR_2.save()\n",
"return render(VAR_1=request, template_name='spirit/admin/config_basic.html',\n VAR_3={'form': form})\n",
"messages.info(VAR_1, _('Settings updated!'))\n",
"return redirect(VAR_1.GET.get('next', VAR_1.get_full_path()))\n"
] | [
"from django.shortcuts import render, redirect\n",
"from django.contrib import messages\n",
"from django.utils.translation import gettext as _\n",
"from django.contrib.auth import get_user_model\n",
"import spirit\n",
"import django\n",
"from spirit.category.models import Category\n",
"from spirit.comment.flag.models import CommentFlag\n",
"from spirit.comment.like.models import CommentLike\n",
"from spirit.comment.models import Comment\n",
"from spirit.topic.models import Topic\n",
"from spirit.core.utils.views import is_post, post_data\n",
"from spirit.core.utils.decorators import administrator_required\n",
"from .forms import BasicConfigForm\n",
"User = get_user_model()\n",
"@administrator_required...\n",
"form = BasicConfigForm(data=post_data(request))\n",
"if is_post(request) and form.is_valid():\n",
"form.save()\n",
"return render(request=request, template_name=\n 'spirit/admin/config_basic.html', context={'form': form})\n",
"messages.info(request, _('Settings updated!'))\n",
"return redirect(request.GET.get('next', request.get_full_path()))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Return'",
"Expr'",
"Return'"
] |
[
"def FUNC_19(self):...\n",
"from OFS.Folder import Folder\n",
"VAR_14 = self.folder\n",
"self.folder = CLASS_1()\n",
"self.folder.t, self.folder.laf = VAR_14.t, VAR_14.laf\n",
"self.folder.laf.write('ok')\n",
"self.assert_expected(self.folder.t, 'CheckPathTraverse.html')\n"
] | [
"def testPathTraverse(self):...\n",
"from OFS.Folder import Folder\n",
"f = self.folder\n",
"self.folder = Folder()\n",
"self.folder.t, self.folder.laf = f.t, f.laf\n",
"self.folder.laf.write('ok')\n",
"self.assert_expected(self.folder.t, 'CheckPathTraverse.html')\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_6(VAR_10, VAR_11, VAR_4):...\n",
"if VAR_4 == 'custom':\n",
"if VAR_10.value != VAR_11:\n",
"if VAR_4 == 'languages':\n",
"VAR_10.value = VAR_11\n",
"return VAR_10\n",
"if VAR_10.lang_code != VAR_11:\n",
"if VAR_4 == 'series':\n",
"VAR_10.lang_code = VAR_11\n",
"if VAR_10.name != VAR_11:\n",
"if VAR_4 == 'author':\n",
"VAR_10.name = VAR_11\n",
"if VAR_10.name != VAR_11:\n",
"if VAR_4 == 'publisher':\n",
"VAR_10.sort = VAR_11\n",
"VAR_10.name = VAR_11\n",
"if VAR_10.name != VAR_11:\n",
"if VAR_10.name != VAR_11:\n",
"VAR_10.sort = VAR_11.replace('|', ',')\n",
"VAR_10.name = VAR_11\n",
"VAR_10.name = VAR_11\n",
"VAR_10.sort = None\n"
] | [
"def create_objects_for_addition(db_element, add_element, db_type):...\n",
"if db_type == 'custom':\n",
"if db_element.value != add_element:\n",
"if db_type == 'languages':\n",
"db_element.value = add_element\n",
"return db_element\n",
"if db_element.lang_code != add_element:\n",
"if db_type == 'series':\n",
"db_element.lang_code = add_element\n",
"if db_element.name != add_element:\n",
"if db_type == 'author':\n",
"db_element.name = add_element\n",
"if db_element.name != add_element:\n",
"if db_type == 'publisher':\n",
"db_element.sort = add_element\n",
"db_element.name = add_element\n",
"if db_element.name != add_element:\n",
"if db_element.name != add_element:\n",
"db_element.sort = add_element.replace('|', ',')\n",
"db_element.name = add_element\n",
"db_element.name = add_element\n",
"db_element.sort = None\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Return'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"@expose('/login/', methods=['GET', 'POST'])...\n",
"@self.appbuilder.sm.oid.loginhandler...\n",
"if g.user is not None and g.user.is_authenticated:\n",
"return redirect(self.appbuilder.get_url_for_index)\n",
"VAR_10 = LoginForm_oid()\n",
"if VAR_10.validate_on_submit():\n",
"VAR_53['remember_me'] = VAR_10.remember_me.data\n",
"return self.render_template(self.login_template, VAR_37=self.title, VAR_10=\n form, providers=self.appbuilder.sm.openid_providers, appbuilder=self.\n appbuilder)\n",
"return self.appbuilder.sm.oid.try_login(VAR_10.openid.data, ask_for=self.\n oid_ask_for, ask_for_optional=self.oid_ask_for_optional)\n"
] | [
"@expose('/login/', methods=['GET', 'POST'])...\n",
"@self.appbuilder.sm.oid.loginhandler...\n",
"if g.user is not None and g.user.is_authenticated:\n",
"return redirect(self.appbuilder.get_url_for_index)\n",
"form = LoginForm_oid()\n",
"if form.validate_on_submit():\n",
"session['remember_me'] = form.remember_me.data\n",
"return self.render_template(self.login_template, title=self.title, form=\n form, providers=self.appbuilder.sm.openid_providers, appbuilder=self.\n appbuilder)\n",
"return self.appbuilder.sm.oid.try_login(form.openid.data, ask_for=self.\n oid_ask_for, ask_for_optional=self.oid_ask_for_optional)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Return'"
] |
[
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_201 = VAR_5.getExperimenterPhoto(VAR_40)\n",
"return HttpResponse(VAR_201, content_type='image/jpeg')\n"
] | [
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"photo = conn.getExperimenterPhoto(oid)\n",
"return HttpResponse(photo, content_type='image/jpeg')\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.