lines
listlengths 1
444
| raw_lines
listlengths 1
444
| label
listlengths 1
444
| type
listlengths 1
444
|
---|---|---|---|
[
"def FUNC_20(self, VAR_9=True):...\n",
"\"\"\"docstring\"\"\"\n",
"self._kill_process_type(VAR_13.PROCESS_TYPE_MONITOR, VAR_9=check_alive)\n"
] |
[
"def kill_monitor(self, check_alive=True):...\n",
"\"\"\"docstring\"\"\"\n",
"self._kill_process_type(ray_constants.PROCESS_TYPE_MONITOR, check_alive=\n check_alive)\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Expr'"
] |
[
"def __init__(self, *VAR_2, **VAR_3):...\n",
"super(CLASS_1, self).__init__(*VAR_2, **kwargs)\n",
"self.OIDC_OP_AUTH_ENDPOINT = import_from_settings(\n 'OIDC_OP_AUTHORIZATION_ENDPOINT')\n",
"self.OIDC_RP_CLIENT_ID = import_from_settings('OIDC_RP_CLIENT_ID')\n"
] |
[
"def __init__(self, *args, **kwargs):...\n",
"super(OIDCAuthenticationRequestView, self).__init__(*args, **kwargs)\n",
"self.OIDC_OP_AUTH_ENDPOINT = import_from_settings(\n 'OIDC_OP_AUTHORIZATION_ENDPOINT')\n",
"self.OIDC_RP_CLIENT_ID = import_from_settings('OIDC_RP_CLIENT_ID')\n"
] |
[
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'"
] |
[
"def FUNC_0(VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"if not FUNC_4('pdftotext'):\n",
"VAR_0.warning(\n 'GNU file was not found on the system. Switching to a weak file extension test.'\n )\n",
"VAR_9 = os.popen('file ' + re.escape(VAR_2)).read()\n",
"if VAR_2.lower().endswith('.pdf'):\n",
"VAR_19 = VAR_9.split(':')[1]\n",
"VAR_0.error('string')\n",
"VAR_10 = VAR_19.find('PDF') > -1\n",
"return True\n",
"return False\n",
"return VAR_10\n"
] |
[
"def is_pdf(document):...\n",
"\"\"\"docstring\"\"\"\n",
"if not executable_exists('pdftotext'):\n",
"log.warning(\n 'GNU file was not found on the system. Switching to a weak file extension test.'\n )\n",
"file_output = os.popen('file ' + re.escape(document)).read()\n",
"if document.lower().endswith('.pdf'):\n",
"filetype = file_output.split(':')[1]\n",
"log.error(\n \"Your version of the 'file' utility seems to be unsupported. Please report this to cds.support@cern.ch.\"\n )\n",
"pdf = filetype.find('PDF') > -1\n",
"return True\n",
"return False\n",
"return pdf\n"
] |
[
0,
0,
0,
0,
0,
0,
7,
7,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Return'",
"Return'",
"Return'"
] |
[
"def FUNC_8(self, VAR_8, VAR_9):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.fileExists(VAR_8):\n",
"VAR_7 = \"UPDATE {0} SET mod_time={1} WHERE path='{2}';\".format(VAR_2, VAR_9,\n VAR_8)\n",
"print(\"updateModTime: file doesn't exist!\")\n",
"self._run_command(VAR_7)\n"
] |
[
"def updateModTime(self, pth, mod_time):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.fileExists(pth):\n",
"command = \"UPDATE {0} SET mod_time={1} WHERE path='{2}';\".format(TABLE_NAME,\n mod_time, pth)\n",
"print(\"updateModTime: file doesn't exist!\")\n",
"self._run_command(command)\n"
] |
[
0,
0,
0,
4,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@wraps(VAR_5)...\n",
"VAR_26 = json.dumps(VAR_5(*VAR_18, **kwargs) or {'error':\n 'No data found for your request'}, default=serialize_to_json)\n",
"VAR_63 = [('Content-Type', 'application/json'), ('Content-Length', str(len(\n VAR_26)))]\n",
"return Response(VAR_26, status=200, VAR_63=headers)\n"
] |
[
"@wraps(func)...\n",
"result = json.dumps(func(*args, **kwargs) or {'error':\n 'No data found for your request'}, default=serialize_to_json)\n",
"headers = [('Content-Type', 'application/json'), ('Content-Length', str(len\n (result)))]\n",
"return Response(result, status=200, headers=headers)\n"
] |
[
0,
0,
0,
0
] |
[
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_11(self, VAR_9):...\n",
"if not self.logged_in():\n",
"print('shrub: unauthenticated; use \"login [username] to log in first')\n",
"VAR_20 = self.send_cmd('list_issues{} {}'.format(self.insecure_mode, VAR_9))\n",
"return\n",
"print(VAR_20)\n"
] |
[
"def do_list_issues(self, line):...\n",
"if not self.logged_in():\n",
"print('shrub: unauthenticated; use \"login [username] to log in first')\n",
"response = self.send_cmd('list_issues{} {}'.format(self.insecure_mode, line))\n",
"return\n",
"print(response)\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Expr'",
"Assign'",
"Return'",
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"return 'check submission %s' % self.submission_id\n"
] |
[
"def describe(self):...\n",
"return 'check submission %s' % self.submission_id\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_8():...\n",
"if FUNC_7():\n",
"VAR_29 = json.loads(FUNC_0(VAR_0['cache_file_32bit']))\n",
"VAR_9 = FUNC_2()\n",
"VAR_30 = json.loads(FUNC_0(VAR_0['cache_file_64bit']))\n",
"VAR_29 = FUNC_6(VAR_9, VAR_1)\n",
"return VAR_29, VAR_30\n",
"VAR_30 = FUNC_6(VAR_9, VAR_2)\n",
"FUNC_1(VAR_0['cache_file_32bit'], json.dumps(VAR_29))\n",
"FUNC_1(VAR_0['cache_file_64bit'], json.dumps(VAR_30))\n"
] |
[
"def check_cache():...\n",
"if cache_files_exist():\n",
"syscalls_32bit = json.loads(read_file_content(CONFIG['cache_file_32bit']))\n",
"syscall_names = parse_syscall_names()\n",
"syscalls_64bit = json.loads(read_file_content(CONFIG['cache_file_64bit']))\n",
"syscalls_32bit = generate_syscalls(syscall_names, BITNESS_32)\n",
"return syscalls_32bit, syscalls_64bit\n",
"syscalls_64bit = generate_syscalls(syscall_names, BITNESS_64)\n",
"write_file_content(CONFIG['cache_file_32bit'], json.dumps(syscalls_32bit))\n",
"write_file_content(CONFIG['cache_file_64bit'], json.dumps(syscalls_64bit))\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(self):...\n",
"return self.data['count']\n"
] |
[
"def count(self):...\n",
"return self.data['count']\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_46 = None\n",
"if self.xsrf_token_header:\n",
"VAR_46 = self.request.headers.get(self.xsrf_token_header)\n",
"if not VAR_46 and self.xsrf_token_request_param:\n",
"VAR_53 = self.request.get_all(self.xsrf_token_request_param)\n",
"return VAR_46\n",
"VAR_46 = VAR_53[0] if VAR_53 else None\n"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"token = None\n",
"if self.xsrf_token_header:\n",
"token = self.request.headers.get(self.xsrf_token_header)\n",
"if not token and self.xsrf_token_request_param:\n",
"param = self.request.get_all(self.xsrf_token_request_param)\n",
"return token\n",
"token = param[0] if param else None\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'"
] |
[
"@VAR_0.route('/email/resend', methods=['POST'])...\n",
"VAR_11 = dict()\n",
"VAR_6 = request.form.get('email')\n",
"VAR_10 = User.query.filter_by(VAR_6=request.form.get('email')).first()\n",
"if '@' not in VAR_6:\n",
"VAR_11['email'] = 'Please check your e-mail address is valid.'\n",
"if VAR_10:\n",
"return make_response(jsonify(errors=error, _csrf_token=session.get(\n '_csrf_token')), 400)\n",
"FUNC_4(VAR_10)\n",
"return make_response(jsonify(errors='User not found', _csrf_token=session.\n get('_csrf_token')), 404)\n",
"return jsonify(status='200', _csrf_token=session.get('_csrf_token'))\n"
] |
[
"@app.route('/email/resend', methods=['POST'])...\n",
"error = dict()\n",
"email = request.form.get('email')\n",
"u = User.query.filter_by(email=request.form.get('email')).first()\n",
"if '@' not in email:\n",
"error['email'] = 'Please check your e-mail address is valid.'\n",
"if u:\n",
"return make_response(jsonify(errors=error, _csrf_token=session.get(\n '_csrf_token')), 400)\n",
"send_email_to_user(u)\n",
"return make_response(jsonify(errors='User not found', _csrf_token=session.\n get('_csrf_token')), 404)\n",
"return jsonify(status='200', _csrf_token=session.get('_csrf_token'))\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Expr'",
"Return'",
"Return'"
] |
[
"@staticmethod...\n",
"VAR_5 = CLASS_0._get_report(VAR_1)\n",
"if not VAR_5:\n",
"VAR_9 = {'analysis': VAR_5}\n",
"VAR_13 = CLASS_0._get_dnsinfo(VAR_5)\n",
"VAR_9.update(VAR_13)\n",
"return VAR_9\n"
] |
[
"@staticmethod...\n",
"report = AnalysisController._get_report(task_id)\n",
"if not report:\n",
"data = {'analysis': report}\n",
"dnsinfo = AnalysisController._get_dnsinfo(report)\n",
"data.update(dnsinfo)\n",
"return data\n"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"@utils.synchronized('3par', external=True)...\n",
"self.common.client_login()\n",
"VAR_19 = self.common.create_cloned_volume(VAR_6, VAR_7)\n",
"self.common.client_logout()\n",
"return {'metadata': VAR_19}\n"
] |
[
"@utils.synchronized('3par', external=True)...\n",
"self.common.client_login()\n",
"new_vol = self.common.create_cloned_volume(volume, src_vref)\n",
"self.common.client_logout()\n",
"return {'metadata': new_vol}\n"
] |
[
0,
0,
0,
0,
0
] |
[
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_25(VAR_3, VAR_6):...\n",
"VAR_38 = FUNC_1(VAR_3)\n",
"VAR_45, VAR_41 = VAR_38.accept()\n",
"return Connection(VAR_45, VAR_38)\n"
] |
[
"def connect(addr, timeout):...\n",
"server = create_server(addr)\n",
"client, _ = server.accept()\n",
"return Connection(client, server)\n"
] |
[
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@defer.inlineCallbacks...\n",
"if os.path.isdir(VAR_0):\n",
"shutil.rmtree(VAR_0)\n",
"VAR_52 = u'verysecretpassphrase'\n",
"VAR_53 = os.path.join(VAR_0, 'secret.gpg')\n",
"VAR_54 = os.path.join(VAR_0, 'soledad.u1db')\n",
"VAR_55 = 'http://provider'\n",
"VAR_56 = ''\n",
"VAR_74 = Mock(return_value=None)\n",
"VAR_75 = Mock()\n",
"VAR_76 = Mock(return_value=('atoken', 300))\n",
"VAR_77 = Mock(return_value=True)\n",
"VAR_78 = Mock()\n",
"def __call__(self):...\n",
"return self\n"
] |
[
"@defer.inlineCallbacks...\n",
"if os.path.isdir(tempdir):\n",
"shutil.rmtree(tempdir)\n",
"passphrase = u'verysecretpassphrase'\n",
"secret_path = os.path.join(tempdir, 'secret.gpg')\n",
"local_db_path = os.path.join(tempdir, 'soledad.u1db')\n",
"server_url = 'http://provider'\n",
"cert_file = ''\n",
"get_doc = Mock(return_value=None)\n",
"put_doc = Mock()\n",
"lock = Mock(return_value=('atoken', 300))\n",
"unlock = Mock(return_value=True)\n",
"close = Mock()\n",
"def __call__(self):...\n",
"return self\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_18(self, VAR_7):...\n",
"self.__process_text(VAR_7)\n",
"self.__process_percent(VAR_7)\n"
] |
[
"def __process_status(self, job_id):...\n",
"self.__process_text(job_id)\n",
"self.__process_percent(job_id)\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(VAR_8):...\n",
"\"\"\"docstring\"\"\"\n",
"return expm(-1.0j * VAR_8 / 2 * VAR_4)\n"
] |
[
"def fry(theta):...\n",
"\"\"\"docstring\"\"\"\n",
"return expm(-1.0j * theta / 2 * Y)\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_35(VAR_29):...\n",
"VAR_40 = VAR_29.group('name')\n",
"VAR_16 = VAR_11[VAR_40]\n",
"if VAR_15:\n",
"if VAR_13 and VAR_16 == VAR_14:\n",
"return '{{{}}}'.format(VAR_40)\n",
"if VAR_12:\n",
"return str(VAR_16)\n",
"return VAR_14\n"
] |
[
"def format_match(match):...\n",
"name = match.group('name')\n",
"value = wildcards[name]\n",
"if keep_dynamic:\n",
"if fail_dynamic and value == dynamic_fill:\n",
"return '{{{}}}'.format(name)\n",
"if fill_missing:\n",
"return str(value)\n",
"return dynamic_fill\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_4(self):...\n",
"if self._user_notified_about_crash or self._IsServerAlive():\n",
"return\n",
"self._user_notified_about_crash = True\n",
"if self._server_stderr:\n",
"VAR_27 = ''.join(server_stderr_file.readlines()[:-VAR_1])\n",
"vimsupport.PostVimMessage(VAR_3)\n",
"vimsupport.PostMultiLineNotice(VAR_2 + VAR_27)\n"
] |
[
"def _NotifyUserIfServerCrashed(self):...\n",
"if self._user_notified_about_crash or self._IsServerAlive():\n",
"return\n",
"self._user_notified_about_crash = True\n",
"if self._server_stderr:\n",
"error_output = ''.join(server_stderr_file.readlines()[:-\n NUM_YCMD_STDERR_LINES_ON_CRASH])\n",
"vimsupport.PostVimMessage(SERVER_CRASH_MESSAGE_SAME_STDERR)\n",
"vimsupport.PostMultiLineNotice(SERVER_CRASH_MESSAGE_STDERR_FILE + error_output)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_8(self, VAR_8=False):...\n",
"if not self.NativeFiletypeCompletionAvailable(\n",
"self._latest_completion_request = OmniCompletionRequest(self._omnicomp)\n",
"VAR_5 = {}\n",
"return self._latest_completion_request\n",
"self._AddExtraConfDataIfNeeded(VAR_5)\n",
"if VAR_8:\n",
"VAR_5['force_semantic'] = True\n",
"self._latest_completion_request = CompletionRequest(VAR_5\n ) if self._IsServerAlive() else None\n"
] |
[
"def CreateCompletionRequest(self, force_semantic=False):...\n",
"if not self.NativeFiletypeCompletionAvailable(\n",
"self._latest_completion_request = OmniCompletionRequest(self._omnicomp)\n",
"extra_data = {}\n",
"return self._latest_completion_request\n",
"self._AddExtraConfDataIfNeeded(extra_data)\n",
"if force_semantic:\n",
"extra_data['force_semantic'] = True\n",
"self._latest_completion_request = CompletionRequest(extra_data\n ) if self._IsServerAlive() else None\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Expr'",
"Condition",
"Assign'",
"Assign'"
] |
[
"def FUNC_12(self, VAR_10=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_30 = vars(self.parse_known_args(VAR_15=True)[0])\n",
"VAR_13 = VAR_30.get('image_mode', None)\n",
"if VAR_13 is not None and VAR_13 != 'none':\n",
"self.add_image_args(VAR_13)\n",
"VAR_12 = VAR_30.get('task', None)\n",
"if VAR_12 is not None:\n",
"self.add_task_args(VAR_12)\n",
"VAR_31 = VAR_30.get('evaltask', None)\n",
"if VAR_31 is not None:\n",
"self.add_task_args(VAR_31)\n",
"VAR_11 = VAR_30.get('model', None)\n",
"if VAR_11 is not None:\n",
"self.add_model_subargs(VAR_11)\n",
"self.set_defaults(**self._defaults)\n"
] |
[
"def add_extra_args(self, args=None):...\n",
"\"\"\"docstring\"\"\"\n",
"parsed = vars(self.parse_known_args(nohelp=True)[0])\n",
"image_mode = parsed.get('image_mode', None)\n",
"if image_mode is not None and image_mode != 'none':\n",
"self.add_image_args(image_mode)\n",
"task = parsed.get('task', None)\n",
"if task is not None:\n",
"self.add_task_args(task)\n",
"evaltask = parsed.get('evaltask', None)\n",
"if evaltask is not None:\n",
"self.add_task_args(evaltask)\n",
"model = parsed.get('model', None)\n",
"if model is not None:\n",
"self.add_model_subargs(model)\n",
"self.set_defaults(**self._defaults)\n"
] |
[
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(self, VAR_2=False):...\n",
"VAR_12 = 'campaign-data/' + str(self.campaign_data['id'])\n",
"if VAR_2:\n",
"VAR_12 += '/aux-files/'\n",
"VAR_12 += '/dut-files/'\n",
"VAR_11 = []\n",
"for item in os.listdir(VAR_12):\n",
"VAR_11.append(VAR_12 + item)\n",
"if VAR_2:\n",
"self.debugger.aux.send_files(VAR_11)\n",
"self.debugger.dut.send_files(VAR_11)\n"
] |
[
"def send_dut_files(self, aux=False):...\n",
"location = 'campaign-data/' + str(self.campaign_data['id'])\n",
"if aux:\n",
"location += '/aux-files/'\n",
"location += '/dut-files/'\n",
"files = []\n",
"for item in os.listdir(location):\n",
"files.append(location + item)\n",
"if aux:\n",
"self.debugger.aux.send_files(files)\n",
"self.debugger.dut.send_files(files)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Condition",
"AugAssign'",
"AugAssign'",
"Assign'",
"For",
"Expr'",
"Condition",
"Expr'",
"Expr'"
] |
[
"@http.route(['/fit_subscribe_controller/subscribe'], type='http', auth=...\n",
"VAR_1 = int(VAR_1)\n",
"VAR_2 = VAR_2\n",
"VAR_4 = http.request.env['event.event'].sudo().browse(VAR_1)\n",
"VAR_6 = 0\n",
"VAR_5 = http.request.env.user.partner_id\n",
"VAR_7 = int(VAR_5.id)\n",
"if VAR_2:\n",
"for registration in VAR_4.registration_ids:\n",
"VAR_16 = http.request.env['event.registration'].sudo().search([(\n 'partner_id', '=', VAR_7), ('event_id', '=', VAR_4.id)])\n",
"for VAR_5 in registration.partner_id:\n",
"VAR_8 = str(http.request.httprequest.headers.environ['HTTP_REFERER'])\n",
"if VAR_16:\n",
"VAR_0.error('Unable to register: ' + str(e))\n",
"if VAR_5.id == VAR_7:\n",
"VAR_9 = str('/' + VAR_8.split('/')[-1])\n",
"if VAR_4.seats_available > 0 and VAR_4.seats_availability == u'limited':\n",
"if VAR_4.seats_available > 0 and VAR_4.seats_availability == u'limited':\n",
"VAR_0.info('Found existing registration, set state to cancelled.')\n",
"return http.request.redirect(VAR_9)\n",
"VAR_0.info('Found existing registration, set state to open (confirmed)')\n",
"VAR_0.info('Found existing registration, no seats available')\n",
"VAR_0.info('No registration found, create new one')\n",
"VAR_0.info('No seats available')\n",
"registration.state = 'cancel'\n",
"VAR_16.state = 'open'\n",
"http.request.env['event.registration'].sudo().create({'partner_id': VAR_7,\n 'event_id': VAR_1, 'name': VAR_5.name if VAR_5.name else '', 'phone': \n VAR_5.mobile if VAR_5.mobile else '', 'email': VAR_5.email if VAR_5.\n email else ''})\n",
"VAR_6 += 1\n",
"VAR_6 -= 1\n",
"VAR_6 -= 1\n",
"self._update_counter_subscription(VAR_4, VAR_5, VAR_6)\n",
"self._update_counter_subscription(VAR_4, VAR_5, VAR_6)\n",
"self._update_counter_subscription(VAR_4, VAR_5, VAR_6)\n"
] |
[
"@http.route(['/fit_subscribe_controller/subscribe'], type='http', auth=...\n",
"event_id = int(event_id)\n",
"event_is_participating = event_is_participating\n",
"event = http.request.env['event.event'].sudo().browse(event_id)\n",
"subscription_update_counter = 0\n",
"partner = http.request.env.user.partner_id\n",
"partner_id = int(partner.id)\n",
"if event_is_participating:\n",
"for registration in event.registration_ids:\n",
"existing_registration = http.request.env['event.registration'].sudo().search([\n ('partner_id', '=', partner_id), ('event_id', '=', event.id)])\n",
"for partner in registration.partner_id:\n",
"referer = str(http.request.httprequest.headers.environ['HTTP_REFERER'])\n",
"if existing_registration:\n",
"_logger.error('Unable to register: ' + str(e))\n",
"if partner.id == partner_id:\n",
"redirect = str('/' + referer.split('/')[-1])\n",
"if event.seats_available > 0 and event.seats_availability == u'limited':\n",
"if event.seats_available > 0 and event.seats_availability == u'limited':\n",
"_logger.info('Found existing registration, set state to cancelled.')\n",
"return http.request.redirect(redirect)\n",
"_logger.info('Found existing registration, set state to open (confirmed)')\n",
"_logger.info('Found existing registration, no seats available')\n",
"_logger.info('No registration found, create new one')\n",
"_logger.info('No seats available')\n",
"registration.state = 'cancel'\n",
"existing_registration.state = 'open'\n",
"http.request.env['event.registration'].sudo().create({'partner_id':\n partner_id, 'event_id': event_id, 'name': partner.name if partner.name else\n '', 'phone': partner.mobile if partner.mobile else '', 'email': partner\n .email if partner.email else ''})\n",
"subscription_update_counter += 1\n",
"subscription_update_counter -= 1\n",
"subscription_update_counter -= 1\n",
"self._update_counter_subscription(event, partner, subscription_update_counter)\n",
"self._update_counter_subscription(event, partner, subscription_update_counter)\n",
"self._update_counter_subscription(event, partner, subscription_update_counter)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
6,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"For",
"Assign'",
"For",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Return'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"AugAssign'",
"AugAssign'",
"AugAssign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_1(self, VAR_1, VAR_2=1):...\n",
"\"\"\"docstring\"\"\"\n",
"self.log_error(VAR_1)\n",
"self.close_all_connections()\n",
"sys.exit(VAR_2)\n"
] |
[
"def _exit(self, msg, error=1):...\n",
"\"\"\"docstring\"\"\"\n",
"self.log_error(msg)\n",
"self.close_all_connections()\n",
"sys.exit(error)\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_13(self):...\n",
"self.filteredImagesCache = []\n",
"if not self.randomImageFilter:\n",
"return\n",
"VAR_33 = self.randomImageFilter.lower()\n",
"for imagePath in VAR_4:\n",
"if VAR_33 in imagePath.lower():\n",
"print('\\tFiltered images with \"{}\"; {} images matching filter'.format(self.\n randomImageFilter, len(self.filteredImagesCache)))\n",
"self.filteredImagesCache.append(imagePath)\n"
] |
[
"def cacheFilteredImages(self):...\n",
"self.filteredImagesCache = []\n",
"if not self.randomImageFilter:\n",
"return\n",
"randomImageFilterLower = self.randomImageFilter.lower()\n",
"for imagePath in savedImagesCache:\n",
"if randomImageFilterLower in imagePath.lower():\n",
"print('\\tFiltered images with \"{}\"; {} images matching filter'.format(self.\n randomImageFilter, len(self.filteredImagesCache)))\n",
"self.filteredImagesCache.append(imagePath)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"For",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_16(self):...\n",
"if self.doctype not in VAR_54.local.valid_columns:\n",
"if self.doctype in ('DocField', 'DocPerm') and self.parent in ('DocType',\n",
"return VAR_54.local.valid_columns[self.doctype]\n",
"from frappe.model.meta import get_table_columns\n",
"VAR_65 = self.meta.get_valid_columns()\n",
"VAR_65 = get_table_columns(self.doctype)\n",
"VAR_54.local.valid_columns[self.doctype] = VAR_65\n"
] |
[
"def get_valid_columns(self):...\n",
"if self.doctype not in frappe.local.valid_columns:\n",
"if self.doctype in ('DocField', 'DocPerm') and self.parent in ('DocType',\n",
"return frappe.local.valid_columns[self.doctype]\n",
"from frappe.model.meta import get_table_columns\n",
"valid = self.meta.get_valid_columns()\n",
"valid = get_table_columns(self.doctype)\n",
"frappe.local.valid_columns[self.doctype] = valid\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Condition",
"Return'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_7(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = self\n",
"VAR_12 = []\n",
"VAR_5 = model.Identity(model.IDENTITY_USER, 'joe@example.com')\n",
"def FUNC_27(VAR_13):...\n",
"self.assertEqual('/request', VAR_13.path)\n",
"VAR_12.append('not_applicable')\n",
"return None\n"
] |
[
"def test_auth_method_order(self):...\n",
"\"\"\"docstring\"\"\"\n",
"test = self\n",
"calls = []\n",
"ident = model.Identity(model.IDENTITY_USER, 'joe@example.com')\n",
"def not_applicable(request):...\n",
"self.assertEqual('/request', request.path)\n",
"calls.append('not_applicable')\n",
"return None\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"if not VAR_101.user_is_admin:\n",
"abort(404, 'page not found')\n"
] |
[
"def run(self):...\n",
"if not c.user_is_admin:\n",
"abort(404, 'page not found')\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Expr'"
] |
[
"def FUNC_9(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_0.debug(_('Updating volume stats'))\n",
"VAR_34 = {}\n",
"VAR_35 = 'eqlx'\n",
"if self.configuration:\n",
"VAR_35 = self.configuration.safe_get('volume_backend_name')\n",
"VAR_34['volume_backend_name'] = VAR_35 or 'eqlx'\n",
"VAR_34['vendor_name'] = 'Dell'\n",
"VAR_34['driver_version'] = self.VERSION\n",
"VAR_34['storage_protocol'] = 'iSCSI'\n",
"VAR_34['reserved_percentage'] = 0\n",
"VAR_34['QoS_support'] = False\n",
"VAR_34['total_capacity_gb'] = 'infinite'\n",
"VAR_34['free_capacity_gb'] = 'infinite'\n",
"for line in self._eql_execute('pool', 'select', self.configuration.\n",
"if line.startswith('TotalCapacity:'):\n",
"self._stats = VAR_34\n",
"VAR_50 = line.rstrip().partition(' ')\n",
"if line.startswith('FreeSpace:'):\n",
"VAR_34['total_capacity_gb'] = self._get_space_in_gb(VAR_50[-1])\n",
"VAR_50 = line.rstrip().partition(' ')\n",
"VAR_34['free_capacity_gb'] = self._get_space_in_gb(VAR_50[-1])\n"
] |
[
"def _update_volume_stats(self):...\n",
"\"\"\"docstring\"\"\"\n",
"LOG.debug(_('Updating volume stats'))\n",
"data = {}\n",
"backend_name = 'eqlx'\n",
"if self.configuration:\n",
"backend_name = self.configuration.safe_get('volume_backend_name')\n",
"data['volume_backend_name'] = backend_name or 'eqlx'\n",
"data['vendor_name'] = 'Dell'\n",
"data['driver_version'] = self.VERSION\n",
"data['storage_protocol'] = 'iSCSI'\n",
"data['reserved_percentage'] = 0\n",
"data['QoS_support'] = False\n",
"data['total_capacity_gb'] = 'infinite'\n",
"data['free_capacity_gb'] = 'infinite'\n",
"for line in self._eql_execute('pool', 'select', self.configuration.\n",
"if line.startswith('TotalCapacity:'):\n",
"self._stats = data\n",
"out_tup = line.rstrip().partition(' ')\n",
"if line.startswith('FreeSpace:'):\n",
"data['total_capacity_gb'] = self._get_space_in_gb(out_tup[-1])\n",
"out_tup = line.rstrip().partition(' ')\n",
"data['free_capacity_gb'] = self._get_space_in_gb(out_tup[-1])\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'",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_10(VAR_12, VAR_5):...\n",
"return any(VAR_12[col_name] in values_list for col_name, values_list in\n VAR_5.items())\n"
] |
[
"def _match_any_filters(element_year, filters):...\n",
"return any(element_year[col_name] in values_list for col_name, values_list in\n filters.items())\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_3(VAR_1, VAR_2, VAR_3='', VAR_4=None):...\n",
"\"\"\"docstring\"\"\"\n",
"return FUNC_4(VAR_1, VAR_2['access_token'], VAR_6='', VAR_3=token_type,\n VAR_4=extra_data)\n"
] |
[
"def oauth2_token_setter(remote, resp, token_type='', extra_data=None):...\n",
"\"\"\"docstring\"\"\"\n",
"return token_setter(remote, resp['access_token'], secret='', token_type=\n token_type, extra_data=extra_data)\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"\"\"\"\nUnit tests for the SIEVE language parser.\n\"\"\"\n",
"from sievelib.parser import Parser\n",
"import sievelib.commands\n",
"import unittest\n",
"import cStringIO\n",
"VAR_0 = [{'name': 'testtag', 'type': ['tag'], 'write_tag': True, 'values':\n [':testtag'], 'extra_arg': {'type': 'number', 'required': False},\n 'required': False}, {'name': 'recipients', 'type': ['string',\n 'stringlist'], 'required': True}]\n",
"def FUNC_0(self):...\n",
"self.parser = Parser()\n",
"def FUNC_1(self, VAR_1, VAR_2):...\n",
"self.assertEqual(self.parser.parse(VAR_1), VAR_2)\n",
"def FUNC_2(self, VAR_1):...\n",
"self.__checkCompilation(VAR_1, True)\n",
"def FUNC_3(self, VAR_1):...\n",
"self.__checkCompilation(VAR_1, False)\n",
"def FUNC_4(self, VAR_3):...\n",
"VAR_4 = cStringIO.StringIO()\n",
"self.parser.dump(VAR_4)\n",
"VAR_5 = VAR_4.getvalue()\n",
"VAR_4.close()\n",
"self.assertEqual(VAR_5, VAR_3.lstrip())\n",
"def FUNC_5(self):...\n",
"sievelib.commands.add_commands(CLASS_0)\n",
"sievelib.commands.get_command_instance('mytest')\n",
"self.assertRaises(sievelib.commands.UnknownCommand, sievelib.commands.\n get_command_instance, 'unknowncommand')\n",
"self.compilation_ok(\n \"\"\"\n mytest :testtag 10 [\"testrecp1@example.com\"];\n \"\"\")\n",
"def FUNC_6(self):...\n",
"self.compilation_ok(\n \"\"\"\nif size :over 100k { # this is a comment\n discard;\n}\n\"\"\")\n",
"self.representation_is(\n \"\"\"\nif (type: control)\n size (type: test)\n :over\n 100k\n discard (type: action)\n\"\"\"\n )\n",
"def FUNC_7(self):...\n",
"self.compilation_ok('string')\n",
"self.representation_is(\n \"\"\"\nif (type: control)\n size (type: test)\n :over\n 100K\n discard (type: action)\n\"\"\"\n )\n",
"def FUNC_8(self):...\n",
"self.compilation_ok(\n \"\"\"\nif header :contains \"Cc\" \"/* comment */\" {\n discard;\n}\n\"\"\")\n",
"self.representation_is('string')\n",
"def FUNC_9(self):...\n",
"self.compilation_ok('string')\n",
"self.representation_is('string')\n",
"def FUNC_10(self):...\n",
"self.compilation_ok('string')\n",
"self.representation_is('string')\n",
"def FUNC_11(self):...\n",
"self.compilation_ok(\"\"\"\nif true {\n\n}\n\"\"\")\n",
"self.representation_is(\"\"\"\nif (type: control)\n true (type: test)\n\"\"\")\n",
"def FUNC_12(self):...\n",
"self.compilation_ok('string')\n",
"self.representation_is('string')\n",
"def FUNC_13(self):...\n",
"self.compilation_ok(\n \"\"\"\nif header :contains :comparator \"i;octet\" \"Subject\" \"MAKE MONEY FAST\" {\n discard;\n}\n\"\"\"\n )\n",
"self.representation_is('string')\n",
"def FUNC_14(self):...\n",
"self.compilation_ok(\n \"\"\"\nif address :all :is \"from\" \"tim@example.com\" {\n discard;\n}\n\"\"\")\n",
"self.representation_is('string')\n",
"def FUNC_15(self):...\n",
"self.compilation_ok(\"\"\"\nif not not not not true {\n stop;\n}\n\"\"\")\n",
"self.representation_is('string')\n",
"def FUNC_16(self):...\n",
"self.compilation_ok('keep;')\n",
"self.representation_is(\"\"\"\nkeep (type: action)\n\"\"\")\n",
"def FUNC_17(self):...\n",
"self.compilation_ok(\"\"\"\nif anyof (true) {\n discard;\n}\n\"\"\")\n",
"self.representation_is(\n \"\"\"\nif (type: control)\n anyof (type: test)\n true (type: test)\n discard (type: action)\n\"\"\"\n )\n",
"def FUNC_18(self):...\n",
"self.compilation_ok(\"\"\"\nif anyof(true, false) {\n discard;\n}\n\"\"\")\n",
"self.representation_is('string')\n",
"def FUNC_19(self):...\n",
"self.compilation_ok('string')\n",
"def FUNC_20(self):...\n",
"self.compilation_ok('string')\n",
"def FUNC_21(self):...\n",
"self.compilation_ok('string')\n",
"def FUNC_22(self):...\n",
"self.compilation_ok('string')\n",
"def FUNC_23(self):...\n",
"self.compilation_ok(\n \"\"\"\nrequire \"reject\";\n\nif header :contains \"subject\" \"viagra\" {\n reject;\n}\n\"\"\"\n )\n",
"def FUNC_24(self):...\n",
"self.compilation_ko(\n \"\"\"\n/* this is a comment /* with a nested comment inside */\nit is allowed by the RFC :p */\n\"\"\"\n )\n",
"def FUNC_25(self):...\n",
"self.compilation_ko(\n \"\"\"\nif header :is \"Sender\" \"me@example.com\" \n discard;\n}\n\"\"\")\n",
"def FUNC_26(self):...\n",
"self.compilation_ko(\n \"\"\"\nif header :is \"Sender\" \"me@example.com\" {\n discard;\n\n\"\"\")\n",
"def FUNC_27(self):...\n",
"self.compilation_ko(\n \"\"\"\nif header :is \"Sender\" \"Toto\" & header :contains \"Cc\" \"Tata\" {\n \n}\n\"\"\"\n )\n",
"def FUNC_28(self):...\n",
"self.compilation_ko('require [];')\n",
"def FUNC_29(self):...\n",
"self.compilation_ko('require [\"toto\", \"tata\";')\n",
"def FUNC_30(self):...\n",
"self.compilation_ko('require [\"toto\",];')\n",
"def FUNC_31(self):...\n",
"self.compilation_ko('string')\n",
"def FUNC_32(self):...\n",
"self.compilation_ko('string')\n",
"def FUNC_33(self):...\n",
"self.compilation_ko(\n \"\"\"\nif anyof (header :is \"Sender\" {\n fileinto \"trash\";\n}\n\"\"\")\n",
"def FUNC_34(self):...\n",
"self.compilation_ko(\n \"\"\"\nif anyof (header :is \"Sender\" \"me@example.com\",) {\n\n}\n\"\"\")\n",
"def FUNC_35(self):...\n",
"self.compilation_ko(\"\"\"\nrequire \"fileinto\", \"enveloppe\";\n\"\"\")\n",
"def FUNC_14(self):...\n",
"self.compilation_ko(\n \"\"\"\nif address \"From\" :is \"tim@example.com\" {\n discard;\n}\n\"\"\")\n",
"def FUNC_36(self):...\n",
"self.compilation_ko(\n \"\"\"\nif address :is \"From\" \"tim@example.com\" \"tutu\" {\n discard;\n}\n\"\"\")\n",
"def FUNC_37(self):...\n",
"self.compilation_ko(\"\"\"\nif not {\n discard;\n}\n\"\"\")\n",
"def FUNC_38(self):...\n",
"self.compilation_ko(\"\"\"\nrequire [\"fileinto\"]\n\"\"\")\n",
"def FUNC_39(self):...\n",
"self.compilation_ko(\"\"\"\nif true {\n stop\n}\n\"\"\")\n",
"def FUNC_40(self):...\n",
"self.compilation_ko(\"\"\"\nif (true) {\n\n}\n\"\"\")\n",
"def FUNC_41(self):...\n",
"self.compilation_ko(\"\"\"\nmacommande \"Toto\";\n\"\"\")\n",
"def FUNC_42(self):...\n",
"self.compilation_ko(\"\"\"\nelsif true {\n\n}\n\"\"\")\n",
"def FUNC_43(self):...\n",
"self.compilation_ko(\"\"\"\nelsif header :is \"From\" \"toto\" {\n\n}\n\"\"\")\n",
"def FUNC_44(self):...\n",
"self.compilation_ko(\"\"\"\nif true {\n elsif false {\n\n }\n}\n\"\"\")\n",
"def FUNC_45(self):...\n",
"self.compilation_ko('stop \"toto\";')\n",
"def FUNC_46(self):...\n",
"self.compilation_ko(\n \"\"\"\nif header :isnot \"Sent\" \"me@example.com\" {\n stop;\n}\n\"\"\")\n",
"def FUNC_47(self):...\n",
"self.compilation_ko(\"\"\"\nif header :isnot \"Sent\" 10000 {\n stop;\n}\n\"\"\")\n",
"def FUNC_48(self):...\n",
"self.compilation_ko(\n \"\"\"\nif header :contains :comparator \"i;prout\" \"Subject\" \"MAKE MONEY FAST\" {\n discard;\n}\n\"\"\"\n )\n",
"def FUNC_49(self):...\n",
"self.compilation_ko(\n \"\"\"\nif header :contains \"Subject\" \"MAKE MONEY FAST\" {\n fileinto \"spam\";\n}\n\"\"\"\n )\n",
"def FUNC_50(self):...\n",
"self.compilation_ko('true;')\n",
"if __name__ == '__main__':\n",
"unittest.main()\n"
] |
[
"\"\"\"\nUnit tests for the SIEVE language parser.\n\"\"\"\n",
"from sievelib.parser import Parser\n",
"import sievelib.commands\n",
"import unittest\n",
"import cStringIO\n",
"args_definition = [{'name': 'testtag', 'type': ['tag'], 'write_tag': True,\n 'values': [':testtag'], 'extra_arg': {'type': 'number', 'required': \n False}, 'required': False}, {'name': 'recipients', 'type': ['string',\n 'stringlist'], 'required': True}]\n",
"def setUp(self):...\n",
"self.parser = Parser()\n",
"def __checkCompilation(self, script, result):...\n",
"self.assertEqual(self.parser.parse(script), result)\n",
"def compilation_ok(self, script):...\n",
"self.__checkCompilation(script, True)\n",
"def compilation_ko(self, script):...\n",
"self.__checkCompilation(script, False)\n",
"def representation_is(self, content):...\n",
"target = cStringIO.StringIO()\n",
"self.parser.dump(target)\n",
"repr_ = target.getvalue()\n",
"target.close()\n",
"self.assertEqual(repr_, content.lstrip())\n",
"def test_add_command(self):...\n",
"sievelib.commands.add_commands(MytestCommand)\n",
"sievelib.commands.get_command_instance('mytest')\n",
"self.assertRaises(sievelib.commands.UnknownCommand, sievelib.commands.\n get_command_instance, 'unknowncommand')\n",
"self.compilation_ok(\n \"\"\"\n mytest :testtag 10 [\"testrecp1@example.com\"];\n \"\"\")\n",
"def test_hash_comment(self):...\n",
"self.compilation_ok(\n \"\"\"\nif size :over 100k { # this is a comment\n discard;\n}\n\"\"\")\n",
"self.representation_is(\n \"\"\"\nif (type: control)\n size (type: test)\n :over\n 100k\n discard (type: action)\n\"\"\"\n )\n",
"def test_bracket_comment(self):...\n",
"self.compilation_ok(\n \"\"\"\nif size :over 100K { /* this is a comment\n this is still a comment */ discard /* this is a comment\n */ ;\n}\n\"\"\"\n )\n",
"self.representation_is(\n \"\"\"\nif (type: control)\n size (type: test)\n :over\n 100K\n discard (type: action)\n\"\"\"\n )\n",
"def test_string_with_bracket_comment(self):...\n",
"self.compilation_ok(\n \"\"\"\nif header :contains \"Cc\" \"/* comment */\" {\n discard;\n}\n\"\"\")\n",
"self.representation_is(\n \"\"\"\nif (type: control)\n header (type: test)\n :contains\n \"Cc\"\n \"/* comment */\"\n discard (type: action)\n\"\"\"\n )\n",
"def test_multiline_string(self):...\n",
"self.compilation_ok(\n \"\"\"\nrequire \"reject\";\n\nif allof (false, address :is [\"From\", \"Sender\"] [\"blka@bla.com\"]) {\n reject text:\nnoreply\n============================\nYour email has been canceled\n============================\n.\n;\n stop;\n} else {\n reject text:\n================================\nYour email has been canceled too\n================================\n.\n;\n}\n\"\"\"\n )\n",
"self.representation_is(\n \"\"\"\nrequire (type: control)\n \"reject\"\nif (type: control)\n allof (type: test)\n false (type: test)\n address (type: test)\n :is\n [\"From\",\"Sender\"]\n [\"blka@bla.com\"]\n reject (type: action)\n text:\nnoreply\n============================\nYour email has been canceled\n============================\n.\n stop (type: control)\nelse (type: control)\n reject (type: action)\n text:\n================================\nYour email has been canceled too\n================================\n.\n\"\"\"\n )\n",
"def test_nested_blocks(self):...\n",
"self.compilation_ok(\n \"\"\"\nif header :contains \"Sender\" \"example.com\" {\n if header :contains \"Sender\" \"me@\" {\n discard;\n } elsif header :contains \"Sender\" \"you@\" {\n keep;\n }\n}\n\"\"\"\n )\n",
"self.representation_is(\n \"\"\"\nif (type: control)\n header (type: test)\n :contains\n \"Sender\"\n \"example.com\"\n if (type: control)\n header (type: test)\n :contains\n \"Sender\"\n \"me@\"\n discard (type: action)\n elsif (type: control)\n header (type: test)\n :contains\n \"Sender\"\n \"you@\"\n keep (type: action)\n\"\"\"\n )\n",
"def test_true_test(self):...\n",
"self.compilation_ok(\"\"\"\nif true {\n\n}\n\"\"\")\n",
"self.representation_is(\"\"\"\nif (type: control)\n true (type: test)\n\"\"\")\n",
"def test_rfc5228_extended(self):...\n",
"self.compilation_ok(\n \"\"\"\n#\n# Example Sieve Filter\n# Declare any optional features or extension used by the script\n#\nrequire [\"fileinto\"];\n\n#\n# Handle messages from known mailing lists\n# Move messages from IETF filter discussion list to filter mailbox\n#\nif header :is \"Sender\" \"owner-ietf-mta-filters@imc.org\"\n {\n fileinto \"filter\"; # move to \"filter\" mailbox\n }\n#\n# Keep all messages to or from people in my company\n#\nelsif address :DOMAIN :is [\"From\", \"To\"] \"example.com\"\n {\n keep; # keep in \"In\" mailbox\n }\n\n#\n# Try and catch unsolicited email. If a message is not to me,\n# or it contains a subject known to be spam, file it away.\n#\nelsif anyof (NOT address :all :contains\n [\"To\", \"Cc\", \"Bcc\"] \"me@example.com\",\n header :matches \"subject\"\n [\"*make*money*fast*\", \"*university*dipl*mas*\"])\n {\n fileinto \"spam\"; # move to \"spam\" mailbox\n }\nelse\n {\n # Move all other (non-company) mail to \"personal\"\n # mailbox.\n fileinto \"personal\";\n }\n\"\"\"\n )\n",
"self.representation_is(\n \"\"\"\nrequire (type: control)\n [\"fileinto\"]\nif (type: control)\n header (type: test)\n :is\n \"Sender\"\n \"owner-ietf-mta-filters@imc.org\"\n fileinto (type: action)\n \"filter\"\nelsif (type: control)\n address (type: test)\n :DOMAIN\n :is\n [\"From\",\"To\"]\n \"example.com\"\n keep (type: action)\nelsif (type: control)\n anyof (type: test)\n not (type: test)\n address (type: test)\n :all\n :contains\n [\"To\",\"Cc\",\"Bcc\"]\n \"me@example.com\"\n header (type: test)\n :matches\n \"subject\"\n [\"*make*money*fast*\",\"*university*dipl*mas*\"]\n fileinto (type: action)\n \"spam\"\nelse (type: control)\n fileinto (type: action)\n \"personal\\\"\n\"\"\"\n )\n",
"def test_explicit_comparator(self):...\n",
"self.compilation_ok(\n \"\"\"\nif header :contains :comparator \"i;octet\" \"Subject\" \"MAKE MONEY FAST\" {\n discard;\n}\n\"\"\"\n )\n",
"self.representation_is(\n \"\"\"\nif (type: control)\n header (type: test)\n \"i;octet\"\n :contains\n \"Subject\"\n \"MAKE MONEY FAST\"\n discard (type: action)\n\"\"\"\n )\n",
"def test_non_ordered_args(self):...\n",
"self.compilation_ok(\n \"\"\"\nif address :all :is \"from\" \"tim@example.com\" {\n discard;\n}\n\"\"\")\n",
"self.representation_is(\n \"\"\"\nif (type: control)\n address (type: test)\n :all\n :is\n \"from\"\n \"tim@example.com\"\n discard (type: action)\n\"\"\"\n )\n",
"def test_multiple_not(self):...\n",
"self.compilation_ok(\"\"\"\nif not not not not true {\n stop;\n}\n\"\"\")\n",
"self.representation_is(\n \"\"\"\nif (type: control)\n not (type: test)\n not (type: test)\n not (type: test)\n not (type: test)\n true (type: test)\n stop (type: control)\n\"\"\"\n )\n",
"def test_just_one_command(self):...\n",
"self.compilation_ok('keep;')\n",
"self.representation_is(\"\"\"\nkeep (type: action)\n\"\"\")\n",
"def test_singletest_testlist(self):...\n",
"self.compilation_ok(\"\"\"\nif anyof (true) {\n discard;\n}\n\"\"\")\n",
"self.representation_is(\n \"\"\"\nif (type: control)\n anyof (type: test)\n true (type: test)\n discard (type: action)\n\"\"\"\n )\n",
"def test_truefalse_testlist(self):...\n",
"self.compilation_ok(\"\"\"\nif anyof(true, false) {\n discard;\n}\n\"\"\")\n",
"self.representation_is(\n \"\"\"\nif (type: control)\n anyof (type: test)\n true (type: test)\n false (type: test)\n discard (type: action)\n\"\"\"\n )\n",
"def test_vacationext_basic(self):...\n",
"self.compilation_ok(\n \"\"\"\nrequire \"vacation\";\nif header :contains \"subject\" \"cyrus\" {\n vacation \"I'm out -- send mail to cyrus-bugs\";\n} else {\n vacation \"I'm out -- call me at +1 304 555 0123\";\n}\n\"\"\"\n )\n",
"def test_vacationext_medium(self):...\n",
"self.compilation_ok(\n \"\"\"\nrequire \"vacation\";\nif header :contains \"subject\" \"lunch\" {\n vacation :handle \"ran-away\" \"I'm out and can't meet for lunch\";\n} else {\n vacation :handle \"ran-away\" \"I'm out\";\n}\n\"\"\"\n )\n",
"def test_vacationext_with_limit(self):...\n",
"self.compilation_ok(\n \"\"\"\nrequire \"vacation\";\nvacation :days 23 :addresses [\"tjs@example.edu\",\n \"ts4z@landru.example.edu\"]\n \"I'm away until October 19.\n If it's an emergency, call 911, I guess.\" ;\n\"\"\"\n )\n",
"def test_vacationext_with_multiline(self):...\n",
"self.compilation_ok(\n \"\"\"\nrequire \"vacation\";\nvacation :mime text:\nContent-Type: multipart/alternative; boundary=foo\n\n--foo\n\nI'm at the beach relaxing. Mmmm, surf...\n\n--foo\nContent-Type: text/html; charset=us-ascii\n\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"\n \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n<HTML><HEAD><TITLE>How to relax</TITLE>\n<BASE HREF=\"http://home.example.com/pictures/\"></HEAD>\n<BODY><P>I'm at the <A HREF=\"beach.gif\">beach</A> relaxing.\nMmmm, <A HREF=\"ocean.gif\">surf</A>...\n</BODY></HTML>\n\n--foo--\n.\n;\n\"\"\"\n )\n",
"def test_reject_extension(self):...\n",
"self.compilation_ok(\n \"\"\"\nrequire \"reject\";\n\nif header :contains \"subject\" \"viagra\" {\n reject;\n}\n\"\"\"\n )\n",
"def test_nested_comments(self):...\n",
"self.compilation_ko(\n \"\"\"\n/* this is a comment /* with a nested comment inside */\nit is allowed by the RFC :p */\n\"\"\"\n )\n",
"def test_nonopened_block(self):...\n",
"self.compilation_ko(\n \"\"\"\nif header :is \"Sender\" \"me@example.com\" \n discard;\n}\n\"\"\")\n",
"def test_nonclosed_block(self):...\n",
"self.compilation_ko(\n \"\"\"\nif header :is \"Sender\" \"me@example.com\" {\n discard;\n\n\"\"\")\n",
"def test_unknown_token(self):...\n",
"self.compilation_ko(\n \"\"\"\nif header :is \"Sender\" \"Toto\" & header :contains \"Cc\" \"Tata\" {\n \n}\n\"\"\"\n )\n",
"def test_empty_string_list(self):...\n",
"self.compilation_ko('require [];')\n",
"def test_unclosed_string_list(self):...\n",
"self.compilation_ko('require [\"toto\", \"tata\";')\n",
"def test_misplaced_comma_in_string_list(self):...\n",
"self.compilation_ko('require [\"toto\",];')\n",
"def test_nonopened_tests_list(self):...\n",
"self.compilation_ko(\n \"\"\"\nif anyof header :is \"Sender\" \"me@example.com\",\n header :is \"Sender\" \"myself@example.com\") {\n fileinto \"trash\";\n}\n\"\"\"\n )\n",
"def test_nonclosed_tests_list(self):...\n",
"self.compilation_ko(\n \"\"\"\nif anyof (header :is \"Sender\" \"me@example.com\",\n header :is \"Sender\" \"myself@example.com\" {\n fileinto \"trash\";\n}\n\"\"\"\n )\n",
"def test_nonclosed_tests_list2(self):...\n",
"self.compilation_ko(\n \"\"\"\nif anyof (header :is \"Sender\" {\n fileinto \"trash\";\n}\n\"\"\")\n",
"def test_misplaced_comma_in_tests_list(self):...\n",
"self.compilation_ko(\n \"\"\"\nif anyof (header :is \"Sender\" \"me@example.com\",) {\n\n}\n\"\"\")\n",
"def test_comma_inside_arguments(self):...\n",
"self.compilation_ko(\"\"\"\nrequire \"fileinto\", \"enveloppe\";\n\"\"\")\n",
"def test_non_ordered_args(self):...\n",
"self.compilation_ko(\n \"\"\"\nif address \"From\" :is \"tim@example.com\" {\n discard;\n}\n\"\"\")\n",
"def test_extra_arg(self):...\n",
"self.compilation_ko(\n \"\"\"\nif address :is \"From\" \"tim@example.com\" \"tutu\" {\n discard;\n}\n\"\"\")\n",
"def test_empty_not(self):...\n",
"self.compilation_ko(\"\"\"\nif not {\n discard;\n}\n\"\"\")\n",
"def test_missing_semicolon(self):...\n",
"self.compilation_ko(\"\"\"\nrequire [\"fileinto\"]\n\"\"\")\n",
"def test_missing_semicolon_in_block(self):...\n",
"self.compilation_ko(\"\"\"\nif true {\n stop\n}\n\"\"\")\n",
"def test_misplaced_parenthesis(self):...\n",
"self.compilation_ko(\"\"\"\nif (true) {\n\n}\n\"\"\")\n",
"def test_unknown_control(self):...\n",
"self.compilation_ko(\"\"\"\nmacommande \"Toto\";\n\"\"\")\n",
"def test_misplaced_elsif(self):...\n",
"self.compilation_ko(\"\"\"\nelsif true {\n\n}\n\"\"\")\n",
"def test_misplaced_elsif2(self):...\n",
"self.compilation_ko(\"\"\"\nelsif header :is \"From\" \"toto\" {\n\n}\n\"\"\")\n",
"def test_misplaced_nested_elsif(self):...\n",
"self.compilation_ko(\"\"\"\nif true {\n elsif false {\n\n }\n}\n\"\"\")\n",
"def test_unexpected_argument(self):...\n",
"self.compilation_ko('stop \"toto\";')\n",
"def test_bad_arg_value(self):...\n",
"self.compilation_ko(\n \"\"\"\nif header :isnot \"Sent\" \"me@example.com\" {\n stop;\n}\n\"\"\")\n",
"def test_bad_arg_value2(self):...\n",
"self.compilation_ko(\"\"\"\nif header :isnot \"Sent\" 10000 {\n stop;\n}\n\"\"\")\n",
"def test_bad_comparator_value(self):...\n",
"self.compilation_ko(\n \"\"\"\nif header :contains :comparator \"i;prout\" \"Subject\" \"MAKE MONEY FAST\" {\n discard;\n}\n\"\"\"\n )\n",
"def test_not_included_extension(self):...\n",
"self.compilation_ko(\n \"\"\"\nif header :contains \"Subject\" \"MAKE MONEY FAST\" {\n fileinto \"spam\";\n}\n\"\"\"\n )\n",
"def test_test_outside_control(self):...\n",
"self.compilation_ko('true;')\n",
"if __name__ == '__main__':\n",
"unittest.main()\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Expr'",
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"Assign'",
"FunctionDef'",
"Assign'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Expr'",
"Condition",
"Expr'"
] |
[
"def __init__(self, VAR_18, VAR_35=100, **VAR_16):...\n",
"CLASS_17.__init__(self, VAR_18, VAR_35=length, VAR_37=errors.\n LOCATION_TOO_LONG, VAR_36=None, **kw)\n"
] |
[
"def __init__(self, item, length=100, **kw):...\n",
"VLength.__init__(self, item, length=length, length_error=errors.\n LOCATION_TOO_LONG, empty_error=None, **kw)\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_2(self, VAR_1):...\n",
"VAR_2 = self.connect()\n",
"VAR_3 = \"INSERT INTO crimes (description) VALUES ('{}');\".format(VAR_1)\n",
"VAR_2.close()\n",
"cursor.execute(VAR_3)\n",
"VAR_2.commit()\n"
] |
[
"def add_input(self, data):...\n",
"connection = self.connect()\n",
"query = \"INSERT INTO crimes (description) VALUES ('{}');\".format(data)\n",
"connection.close()\n",
"cursor.execute(query)\n",
"connection.commit()\n"
] |
[
0,
0,
4,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_14(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return self._get_users_api().get_current_user(self.request)\n"
] |
[
"def get_current_user(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return self._get_users_api().get_current_user(self.request)\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_6(self, VAR_33):...\n",
"if VAR_33 and self.valid_re.match(VAR_33):\n",
"return self.splitter.split(VAR_33)\n"
] |
[
"def run(self, val):...\n",
"if val and self.valid_re.match(val):\n",
"return self.splitter.split(val)\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Return'"
] |
[
"def FUNC_1(self, VAR_4):...\n",
"VAR_28 = decimal.Context(prec=self.max_digits)\n",
"return VAR_4.quantize(decimal.Decimal(1), VAR_28=context\n ) if VAR_4 == VAR_4.to_integral() else VAR_4.normalize(VAR_28)\n"
] |
[
"def _transform_decimal(self, value):...\n",
"context = decimal.Context(prec=self.max_digits)\n",
"return value.quantize(decimal.Decimal(1), context=context\n ) if value == value.to_integral() else value.normalize(context)\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_7(self):...\n",
"VAR_23 = []\n",
"VAR_24 = []\n",
"for VAR_21 in range(0, self.dim_x):\n",
"for VAR_22 in range(0, self.dim_y):\n",
"VAR_24.append(str(self.board[VAR_21][VAR_22]))\n",
"print(''.join(VAR_24))\n",
"VAR_24 = []\n"
] |
[
"def print_board(self):...\n",
"x_str = []\n",
"y_str = []\n",
"for x in range(0, self.dim_x):\n",
"for y in range(0, self.dim_y):\n",
"y_str.append(str(self.board[x][y]))\n",
"print(''.join(y_str))\n",
"y_str = []\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"For",
"For",
"Expr'",
"Expr'",
"Assign'"
] |
[
"@FUNC_0...\n",
"VAR_27 = VAR_10.get_transport()\n",
"VAR_7 = VAR_27.open_session()\n",
"VAR_7.invoke_shell()\n",
"VAR_0.debug(_('Reading CLI MOTD'))\n",
"self._get_output(VAR_7)\n",
"VAR_28 = 'stty columns 255'\n",
"VAR_0.debug(_(\"Setting CLI terminal width: '%s'\"), VAR_28)\n",
"VAR_7.send(VAR_28 + '\\r')\n",
"VAR_25 = self._get_output(VAR_7)\n",
"VAR_0.debug(_(\"Sending CLI command: '%s'\"), VAR_11)\n",
"VAR_7.send(VAR_11 + '\\r')\n",
"VAR_25 = self._get_output(VAR_7)\n",
"VAR_7.close()\n",
"if any(line.startswith(('% Error', 'Error:')) for line in VAR_25):\n",
"VAR_37 = _('Error executing EQL command')\n",
"return VAR_25\n",
"VAR_38 = '\\n'.join(VAR_25)\n",
"VAR_0.error(VAR_38)\n"
] |
[
"@with_timeout...\n",
"transport = ssh.get_transport()\n",
"chan = transport.open_session()\n",
"chan.invoke_shell()\n",
"LOG.debug(_('Reading CLI MOTD'))\n",
"self._get_output(chan)\n",
"cmd = 'stty columns 255'\n",
"LOG.debug(_(\"Setting CLI terminal width: '%s'\"), cmd)\n",
"chan.send(cmd + '\\r')\n",
"out = self._get_output(chan)\n",
"LOG.debug(_(\"Sending CLI command: '%s'\"), command)\n",
"chan.send(command + '\\r')\n",
"out = self._get_output(chan)\n",
"chan.close()\n",
"if any(line.startswith(('% Error', 'Error:')) for line in out):\n",
"desc = _('Error executing EQL command')\n",
"return out\n",
"cmdout = '\\n'.join(out)\n",
"LOG.error(cmdout)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"For",
"Assign'",
"Return'",
"Assign'",
"Expr'"
] |
[
"@Endpoint('GET', '/fsals')...\n",
"return Ganesha.fsals_available()\n"
] |
[
"@Endpoint('GET', '/fsals')...\n",
"return Ganesha.fsals_available()\n"
] |
[
0,
0
] |
[
"Condition",
"Return'"
] |
[
"def FUNC_19(self, VAR_6, VAR_14):...\n",
"self.common.extend_volume(VAR_6, VAR_14)\n"
] |
[
"def extend_volume(self, volume, new_size):...\n",
"self.common.extend_volume(volume, new_size)\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Expr'"
] |
[
"@odin.assign_field...\n",
"return 'Foo'\n"
] |
[
"@odin.assign_field...\n",
"return 'Foo'\n"
] |
[
0,
0
] |
[
"Condition",
"Return'"
] |
[
"def FUNC_33(self, VAR_11):...\n",
"\"\"\"docstring\"\"\"\n",
"logging.warn('Handling SAML errors')\n",
"VAR_26 = {'message': 'SAML request failed', 'errors': VAR_11.get_errors(),\n 'reason': VAR_11.get_last_error_reason(), 'request_id': VAR_11.\n get_last_request_id()}\n",
"logging.warn('Errors: {0}'.format(VAR_26))\n",
"VAR_2 = jsonify(**data)\n",
"VAR_2.status_code = 500\n",
"return VAR_2\n"
] |
[
"def _render_saml_errors_json(self, auth):...\n",
"\"\"\"docstring\"\"\"\n",
"logging.warn('Handling SAML errors')\n",
"data = {'message': 'SAML request failed', 'errors': auth.get_errors(),\n 'reason': auth.get_last_error_reason(), 'request_id': auth.\n get_last_request_id()}\n",
"logging.warn('Errors: {0}'.format(data))\n",
"resp = jsonify(**data)\n",
"resp.status_code = 500\n",
"return resp\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_4(self, VAR_0):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_9, VAR_10 = VAR_0.partition(' ')[::2]\n",
"VAR_11 = cmd.get_command(VAR_9)\n",
"VAR_12 = self.tokenizer.tokenize(VAR_10.strip())\n",
"return VAR_11(self), VAR_12\n"
] |
[
"def parse_line(self, line):...\n",
"\"\"\"docstring\"\"\"\n",
"cmd_name, cmd_args = line.partition(' ')[::2]\n",
"command_cls = cmd.get_command(cmd_name)\n",
"tokenized_cmd_args = self.tokenizer.tokenize(cmd_args.strip())\n",
"return command_cls(self), tokenized_cmd_args\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_12(VAR_5):...\n",
"for i in VAR_5:\n",
"if i not in string.ascii_letters and i not in string.digits:\n",
"return True\n",
"return False\n"
] |
[
"def is_valid_username(uname):...\n",
"for i in uname:\n",
"if i not in string.ascii_letters and i not in string.digits:\n",
"return True\n",
"return False\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"For",
"Condition",
"Return'",
"Return'"
] |
[
"def __init__(self):...\n",
"Tester.__init__(self, 'NavLoc')\n",
"self.jerky = False\n",
"self.walking_speed = 1\n",
"self.reached_goal = False\n",
"self.reached_corner = [False, False, False, False]\n",
"self.cc_square = [(0, 0), (1, 0), (1, 1), (0, 1)]\n",
"self.c_square = [(0, 0), (1, 0), (1, -1), (0, -1)]\n",
"self.corner_counter = 0\n",
"self.test_name = 'path'\n",
"VAR_0 = MD2.points\n",
"VAR_1 = MD2.locations\n",
"VAR_2 = MD2.neighbors\n",
"VAR_21 = MD2.landmarks\n",
"VAR_4 = MD2.landmark_pos\n",
"VAR_22 = MD2.landmark_orient\n",
"self.navloc = CLASS_0(VAR_0, VAR_1, VAR_2, VAR_21, VAR_4, VAR_22, VAR_6=\n self.jerky, VAR_7=self.walking_speed)\n",
"self.destination = [self.navloc.floorplan.graph['T'].location, self.navloc.\n floorplan.graph['R'].location]\n"
] |
[
"def __init__(self):...\n",
"Tester.__init__(self, 'NavLoc')\n",
"self.jerky = False\n",
"self.walking_speed = 1\n",
"self.reached_goal = False\n",
"self.reached_corner = [False, False, False, False]\n",
"self.cc_square = [(0, 0), (1, 0), (1, 1), (0, 1)]\n",
"self.c_square = [(0, 0), (1, 0), (1, -1), (0, -1)]\n",
"self.corner_counter = 0\n",
"self.test_name = 'path'\n",
"point_ids = MD2.points\n",
"locations = MD2.locations\n",
"neighbors = MD2.neighbors\n",
"landmarks = MD2.landmarks\n",
"landmark_positions = MD2.landmark_pos\n",
"landmark_orientations = MD2.landmark_orient\n",
"self.navloc = NavLoc(point_ids, locations, neighbors, landmarks,\n landmark_positions, landmark_orientations, jerky=self.jerky,\n walking_speed=self.walking_speed)\n",
"self.destination = [self.navloc.floorplan.graph['T'].location, self.navloc.\n floorplan.graph['R'].location]\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_16(self, VAR_16, VAR_19):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_46 = self.configuration.volume_name_template % VAR_19['id']\n",
"VAR_0.error(_('Failed to create clone of volume %s'), VAR_16['name'])\n",
"VAR_25 = self._eql_execute('volume', 'select', VAR_46, 'clone', VAR_16['name'])\n",
"return self._get_volume_data(VAR_25)\n"
] |
[
"def create_cloned_volume(self, volume, src_vref):...\n",
"\"\"\"docstring\"\"\"\n",
"src_volume_name = self.configuration.volume_name_template % src_vref['id']\n",
"LOG.error(_('Failed to create clone of volume %s'), volume['name'])\n",
"out = self._eql_execute('volume', 'select', src_volume_name, 'clone',\n volume['name'])\n",
"return self._get_volume_data(out)\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_0(VAR_0, VAR_1, **VAR_2):...\n",
"CLASS_0.invalidate(VAR_1.recipient.user)\n"
] |
[
"def invalidate_notifications(sender, instance, **kwargs):...\n",
"CachedNotifications.invalidate(instance.recipient.user)\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_24(self, VAR_37='/tmp/soledad-test/test'):...\n",
"return os.path.join(VAR_37, str(VAR_1.uuid4()))\n"
] |
[
"def _generate_soledad_test_folder_name(self, soledad_test_folder=...\n",
"return os.path.join(soledad_test_folder, str(uuid.uuid4()))\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_1(VAR_0):...\n",
"VAR_6 = sqlite3.connect('database.db')\n",
"VAR_7 = VAR_6.cursor()\n",
"VAR_8 = getBotUsername()\n",
"for VAR_1 in VAR_0:\n",
"if VAR_7.execute(\n",
"VAR_6.close()\n",
"VAR_14 = False\n",
"for reply in VAR_1.comments:\n",
"if not VAR_14 and FUNC_5(VAR_1) <= FUNC_6(VAR_1):\n",
"if reply.author.name == VAR_8:\n",
"print('Replying to submission: ' + str(VAR_1.id) + ' in series: ' + str(\n getTitle(VAR_1)))\n",
"VAR_14 = True\n",
"FUNC_2(VAR_1)\n"
] |
[
"def checkForSeriesSubmissions(submissionList):...\n",
"database = sqlite3.connect('database.db')\n",
"cursor = database.cursor()\n",
"botUsername = getBotUsername()\n",
"for submission in submissionList:\n",
"if cursor.execute(\n",
"database.close()\n",
"alreadyPosted = False\n",
"for reply in submission.comments:\n",
"if not alreadyPosted and getSeriesDateFromDatabase(submission\n",
"if reply.author.name == botUsername:\n",
"print('Replying to submission: ' + str(submission.id) + ' in series: ' +\n str(getTitle(submission)))\n",
"alreadyPosted = True\n",
"replyTrackedStats(submission)\n"
] |
[
0,
0,
0,
0,
0,
4,
0,
0,
0,
0,
0,
4,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Expr'",
"Assign'",
"For",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Expr'"
] |
[
"@property...\n",
"if self._services is None:\n",
"VAR_79 = mock(Services)\n",
"return self._services\n",
"VAR_79.keymanager = self.keymanager\n",
"VAR_79.mail_service = self.mail_service\n",
"VAR_79.draft_service = self.draft_service\n",
"VAR_79.search_engine = self.search_engine\n",
"VAR_79.feedback_service = self.feedback_service\n",
"VAR_79._leap_session = self.leap_session\n",
"self._services = VAR_79\n",
"self.leap_session.close = lambda : 'mocked'\n"
] |
[
"@property...\n",
"if self._services is None:\n",
"services = mock(Services)\n",
"return self._services\n",
"services.keymanager = self.keymanager\n",
"services.mail_service = self.mail_service\n",
"services.draft_service = self.draft_service\n",
"services.search_engine = self.search_engine\n",
"services.feedback_service = self.feedback_service\n",
"services._leap_session = self.leap_session\n",
"self._services = services\n",
"self.leap_session.close = lambda : 'mocked'\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_2(self, VAR_2, VAR_3, VAR_4, *VAR_5):...\n",
"self.write_data({'type': 'upgrader_finished'})\n"
] |
[
"def on_upgrader_finished(self, subject, changetype, objectID, *args):...\n",
"self.write_data({'type': 'upgrader_finished'})\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_13(self, *VAR_16, **VAR_10):...\n",
"if not self.is_group_user(VAR_8):\n",
"return VAR_7(self, *VAR_16, **kwargs)\n"
] |
[
"def wrapper(self, *args, **kwargs):...\n",
"if not self.is_group_user(group):\n",
"return method(self, *args, **kwargs)\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Return'"
] |
[
"def FUNC_29(VAR_39):...\n",
"if not VAR_39 or VAR_39 == 'None':\n",
"VAR_39 = datetime.today().strftime('%Y-%m-%d')\n",
"VAR_39 = VAR_39[:10]\n",
"return datetime.strptime(VAR_39, '%Y-%m-%d')\n"
] |
[
"def str_to_datetime(str):...\n",
"if not str or str == 'None':\n",
"str = datetime.today().strftime('%Y-%m-%d')\n",
"str = str[:10]\n",
"return datetime.strptime(str, '%Y-%m-%d')\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"def __init__(self, VAR_18, VAR_19):...\n",
"\"\"\"docstring\"\"\"\n",
"self.auth = VAR_18\n",
"self.data = None\n",
"self.station_data = None\n",
"self.station = VAR_19\n"
] |
[
"def __init__(self, auth, station):...\n",
"\"\"\"docstring\"\"\"\n",
"self.auth = auth\n",
"self.data = None\n",
"self.station_data = None\n",
"self.station = station\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"@integration_synonym_api...\n",
"FUNC_2(VAR_2)\n",
"FUNC_3(VAR_2, 'GNAT', VAR_7='1')\n",
"FUNC_5(VAR_4, VAR_5, VAR_11='NAT', VAR_10=[{'name': '----NAT'}, {'name':\n 'GNAT'}])\n"
] |
[
"@integration_synonym_api...\n",
"clean_database(solr)\n",
"seed_database_with(solr, 'GNAT', id='1')\n",
"verify_results(client, jwt, query='NAT', expected=[{'name': '----NAT'}, {\n 'name': 'GNAT'}])\n"
] |
[
0,
0,
0,
0
] |
[
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@VAR_0.route('/<page_name>/history')...\n",
"VAR_3 = VAR_1.query('string' % VAR_2)\n",
"VAR_11 = VAR_3.namedresult()\n",
"return render_template('page_history.html', VAR_2=page_name, VAR_11=\n page_histories)\n"
] |
[
"@app.route('/<page_name>/history')...\n",
"query = db.query(\n \"select page_content.timestamp, page_content.id from page, page_content where page.id = page_content.page_id and page.page_name = '%s'\"\n % page_name)\n",
"page_histories = query.namedresult()\n",
"return render_template('page_history.html', page_name=page_name,\n page_histories=page_histories)\n"
] |
[
0,
0,
0,
0
] |
[
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"@integration_synonym_api...\n",
"FUNC_2(VAR_2)\n",
"FUNC_3(VAR_2, 'FEEL', VAR_7='1')\n",
"FUNC_5(VAR_4, VAR_5, VAR_11='FILL', VAR_10=[{'name': '----FILL'}])\n"
] |
[
"@integration_synonym_api...\n",
"clean_database(solr)\n",
"seed_database_with(solr, 'FEEL', id='1')\n",
"verify_results(client, jwt, query='FILL', expected=[{'name': '----FILL'}])\n"
] |
[
0,
0,
0,
0
] |
[
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_12(self, VAR_7):...\n",
"if VAR_7.model_class._meta.primary_key:\n",
"VAR_28 = VAR_7.values['id']\n",
"VAR_19 = ','.join([VAR_45.encode('utf-8') for VAR_45 in VAR_7.values.keys()])\n",
"VAR_20 = ','.join([VAR_45.encode('utf-8') for VAR_45 in VAR_7.values.values()])\n",
"if VAR_7.model_class._meta.primary_key:\n",
"VAR_21 = 'UPDATE {0} SET ({1})=({2}) WHERE id = {3}'.format(VAR_7.\n model_class._meta.table_name, VAR_19, VAR_20, VAR_28)\n",
"print('ERROR: Not primary key cannot update row. Need to be implemented')\n",
"if VAR_7.return_id:\n",
"VAR_21 += ' RETURNING id'\n",
"VAR_21 += ';'\n",
"return VAR_21\n"
] |
[
"def generate_update(self, query):...\n",
"if query.model_class._meta.primary_key:\n",
"_id = query.values['id']\n",
"keys = ','.join([x.encode('utf-8') for x in query.values.keys()])\n",
"values = ','.join([x.encode('utf-8') for x in query.values.values()])\n",
"if query.model_class._meta.primary_key:\n",
"str_query = 'UPDATE {0} SET ({1})=({2}) WHERE id = {3}'.format(query.\n model_class._meta.table_name, keys, values, _id)\n",
"print('ERROR: Not primary key cannot update row. Need to be implemented')\n",
"if query.return_id:\n",
"str_query += ' RETURNING id'\n",
"str_query += ';'\n",
"return str_query\n"
] |
[
0,
0,
0,
0,
0,
0,
4,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"AugAssign'",
"AugAssign'",
"Return'"
] |
[
"def FUNC_0(self):...\n",
"return self.get_secure_cookie('user')\n"
] |
[
"def get_current_user(self):...\n",
"return self.get_secure_cookie('user')\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_6(VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_1.info('Setting up user environment...')\n",
"VAR_12 = '4.5.4'\n",
"VAR_13 = 'a946ea1d0c4a642ddf0c3a26a18bb16d'\n",
"if not conda.check_miniconda_version(USER_ENV_PREFIX, VAR_12):\n",
"VAR_1.info('Downloading & setting up user environment...')\n",
"apt.install_packages(['gcc'])\n",
"conda.install_miniconda(installer_path, USER_ENV_PREFIX)\n",
"conda.ensure_conda_packages(USER_ENV_PREFIX, ['conda==4.5.8'])\n",
"conda.ensure_pip_packages(USER_ENV_PREFIX, ['jupyterhub==0.9.4',\n 'notebook==5.7.0', 'jupyterlab==0.35.3', 'nteract-on-jupyter==1.9.12',\n 'nbgitpuller==0.6.1', 'nbresuse==0.3.0', 'ipywidgets==7.4.2',\n 'tornado<6.0'])\n",
"if VAR_3:\n",
"conda.ensure_pip_requirements(USER_ENV_PREFIX, VAR_3)\n"
] |
[
"def ensure_user_environment(user_requirements_txt_file):...\n",
"\"\"\"docstring\"\"\"\n",
"logger.info('Setting up user environment...')\n",
"miniconda_version = '4.5.4'\n",
"miniconda_installer_md5 = 'a946ea1d0c4a642ddf0c3a26a18bb16d'\n",
"if not conda.check_miniconda_version(USER_ENV_PREFIX, miniconda_version):\n",
"logger.info('Downloading & setting up user environment...')\n",
"apt.install_packages(['gcc'])\n",
"conda.install_miniconda(installer_path, USER_ENV_PREFIX)\n",
"conda.ensure_conda_packages(USER_ENV_PREFIX, ['conda==4.5.8'])\n",
"conda.ensure_pip_packages(USER_ENV_PREFIX, ['jupyterhub==0.9.4',\n 'notebook==5.7.0', 'jupyterlab==0.35.3', 'nteract-on-jupyter==1.9.12',\n 'nbgitpuller==0.6.1', 'nbresuse==0.3.0', 'ipywidgets==7.4.2',\n 'tornado<6.0'])\n",
"if user_requirements_txt_file:\n",
"conda.ensure_pip_requirements(USER_ENV_PREFIX, user_requirements_txt_file)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
6,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_6(self):...\n",
"VAR_5 = Mock()\n",
"VAR_5.sendmail.side_effect = lambda VAR_68: succeed(VAR_68)\n",
"return VAR_5\n"
] |
[
"def _create_mail_sender(self):...\n",
"mail_sender = Mock()\n",
"mail_sender.sendmail.side_effect = lambda mail: succeed(mail)\n",
"return mail_sender\n"
] |
[
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"CLASS_1.query.filter(CLASS_1.to_user_id == VAR_21, CLASS_1.id.in_(VAR_22)\n ).delete(synchronize_session=False)\n",
"db.session.commit()\n"
] |
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"Message.query.filter(Message.to_user_id == user_id, Message.id.in_(message_ids)\n ).delete(synchronize_session=False)\n",
"db.session.commit()\n"
] |
[
0,
0,
0,
0
] |
[
"Condition",
"Docstring",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"@wraps(VAR_5)...\n",
"VAR_26 = json.dumps(VAR_5(*VAR_18, **kwargs) or {'error':\n 'No data found for your request'}, default=serialize_to_json)\n",
"VAR_63 = [('Content-Type', 'application/json'), ('Content-Length', str(len(\n VAR_26)))]\n",
"return Response(VAR_26, status=200, VAR_63=headers)\n"
] |
[
"def json_response(func):...\n",
"\"\"\"docstring\"\"\"\n",
"@wraps(func)...\n",
"result = json.dumps(func(*args, **kwargs) or {'error':\n 'No data found for your request'}, default=serialize_to_json)\n",
"headers = [('Content-Type', 'application/json'), ('Content-Length', str(len\n (result)))]\n",
"return Response(result, status=200, headers=headers)\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_4(self, *VAR_2, **VAR_1):...\n",
"if VAR_1.pop('add_xsrf_token', True):\n",
"VAR_1 = self._set_xsrf_headers(VAR_1)\n",
"VAR_0 = super(CLASS_0, self).put(*VAR_2, **kwargs)\n",
"self._store_xsrf_token(VAR_0)\n",
"return VAR_0\n"
] |
[
"def put(self, *args, **kwargs):...\n",
"if kwargs.pop('add_xsrf_token', True):\n",
"kwargs = self._set_xsrf_headers(kwargs)\n",
"response = super(Session, self).put(*args, **kwargs)\n",
"self._store_xsrf_token(response)\n",
"return response\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_8(self):...\n",
"\"\"\"docstring\"\"\"\n",
"\"\"\"Test creating a Push via the API\"\"\"\n",
"self.client.login(VAR_8='autotest2', VAR_9='password')\n",
"VAR_4 = '/api/apps'\n",
"VAR_5 = self.client.post(VAR_4)\n",
"self.assertEqual(VAR_5.status_code, 201)\n",
"VAR_6 = VAR_5.data['id']\n",
"self.client.login(VAR_8='autotest', VAR_9='password')\n",
"VAR_18 = \"\"\"\n FROM busybox\n CMD /bin/true\n \"\"\"\n",
"VAR_7 = {'receive_user': 'autotest', 'receive_repo': VAR_6, 'image':\n '{app_id}:v2'.format(**locals()), 'sha':\n 'ecdff91c57a0b9ab82e89634df87e293d259a3aa', 'dockerfile': VAR_18}\n",
"VAR_4 = '/api/hooks/builds'\n",
"VAR_5 = self.client.post(VAR_4, json.dumps(VAR_7), content_type=\n 'application/json', HTTP_X_DEIS_BUILDER_AUTH=settings.BUILDER_KEY)\n",
"self.assertEqual(VAR_5.status_code, 200)\n",
"self.assertEqual(VAR_5.data['release']['version'], 2)\n"
] |
[
"def test_admin_can_hook(self):...\n",
"\"\"\"docstring\"\"\"\n",
"\"\"\"Test creating a Push via the API\"\"\"\n",
"self.client.login(username='autotest2', password='password')\n",
"url = '/api/apps'\n",
"response = self.client.post(url)\n",
"self.assertEqual(response.status_code, 201)\n",
"app_id = response.data['id']\n",
"self.client.login(username='autotest', password='password')\n",
"DOCKERFILE = \"\"\"\n FROM busybox\n CMD /bin/true\n \"\"\"\n",
"body = {'receive_user': 'autotest', 'receive_repo': app_id, 'image':\n '{app_id}:v2'.format(**locals()), 'sha':\n 'ecdff91c57a0b9ab82e89634df87e293d259a3aa', 'dockerfile': DOCKERFILE}\n",
"url = '/api/hooks/builds'\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json', HTTP_X_DEIS_BUILDER_AUTH=settings.BUILDER_KEY)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(response.data['release']['version'], 2)\n"
] |
[
0,
0,
0,
5,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@VAR_1.route('/signup', methods=['POST'])...\n",
"VAR_12 = request.form['email']\n",
"VAR_13 = query_user(VAR_12)\n",
"if VAR_13 == None:\n",
"VAR_14 = request.form['password']\n",
"flash('Email already in use')\n",
"VAR_19 = generate_password_hash(VAR_14)\n",
"return redirect('/signup')\n",
"insert_user(VAR_12, VAR_19)\n",
"VAR_18['email'] = VAR_12\n",
"VAR_20 = VAR_18.pop('return_url', None)\n",
"if VAR_20:\n",
"return redirect(VAR_20)\n",
"return redirect('/')\n"
] |
[
"@app.route('/signup', methods=['POST'])...\n",
"email = request.form['email']\n",
"user = query_user(email)\n",
"if user == None:\n",
"password = request.form['password']\n",
"flash('Email already in use')\n",
"password_hash = generate_password_hash(password)\n",
"return redirect('/signup')\n",
"insert_user(email, password_hash)\n",
"session['email'] = email\n",
"returnUrl = session.pop('return_url', None)\n",
"if returnUrl:\n",
"return redirect(returnUrl)\n",
"return redirect('/')\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Return'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"async def FUNC_2(self, VAR_5):...\n",
"if isinstance(VAR_5, RequestResponsePair):\n",
"self.stats['requests'] += 1\n",
"if not VAR_5.response:\n",
"self.stats['failed'] += 1\n",
"self.stats['finished'] += 1\n",
"self.stats['bytesRcv'] += VAR_5.response.bytesReceived\n"
] |
[
"async def push(self, item):...\n",
"if isinstance(item, RequestResponsePair):\n",
"self.stats['requests'] += 1\n",
"if not item.response:\n",
"self.stats['failed'] += 1\n",
"self.stats['finished'] += 1\n",
"self.stats['bytesRcv'] += item.response.bytesReceived\n"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
"AsyncFunctionDef'",
"Condition",
"AugAssign'",
"Condition",
"AugAssign'",
"AugAssign'",
"AugAssign'"
] |
[
"def FUNC_6(VAR_0, VAR_5, VAR_6, VAR_7):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_7:\n",
"print('FILL NULL FAILED WITH FOLLOWING MESSAGE:\\n' + str(e))\n",
"db.engine.execute(\n 'UPDATE \"{0}\" SET \"{1}\" = \\'{2}\\' WHERE (\"{1}\" = \\'\\') IS NOT FALSE'.\n format(VAR_0, VAR_5, VAR_6))\n",
"db.engine.execute('UPDATE \"{0}\" SET \"{1}\" = {2} WHERE \"{1}\" IS NULL'.format\n (VAR_0, VAR_5, VAR_6))\n"
] |
[
"def fill_null_with(table_name, attr, value, text_type):...\n",
"\"\"\"docstring\"\"\"\n",
"if text_type:\n",
"print('FILL NULL FAILED WITH FOLLOWING MESSAGE:\\n' + str(e))\n",
"db.engine.execute(\n 'UPDATE \"{0}\" SET \"{1}\" = \\'{2}\\' WHERE (\"{1}\" = \\'\\') IS NOT FALSE'.\n format(table_name, attr, value))\n",
"db.engine.execute('UPDATE \"{0}\" SET \"{1}\" = {2} WHERE \"{1}\" IS NULL'.format\n (table_name, attr, value))\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_8(VAR_7=None, VAR_8=None):...\n",
"VAR_49 = [VAR_8, VAR_7]\n",
"if not any(VAR_49) or all(VAR_49):\n",
"if VAR_8:\n",
"VAR_58 = 'child_leaf'\n",
"VAR_58 = 'child_branch'\n",
"VAR_59 = VAR_8\n",
"VAR_59 = VAR_7\n",
"return '{branch_part}_{id_part}'.format(**locals())\n"
] |
[
"def _build_child_key(child_branch=None, child_leaf=None):...\n",
"args = [child_leaf, child_branch]\n",
"if not any(args) or all(args):\n",
"if child_leaf:\n",
"branch_part = 'child_leaf'\n",
"branch_part = 'child_branch'\n",
"id_part = child_leaf\n",
"id_part = child_branch\n",
"return '{branch_part}_{id_part}'.format(**locals())\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def __repr__(self):...\n",
"return self.get_name()\n"
] |
[
"def __repr__(self):...\n",
"return self.get_name()\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_12(VAR_5, VAR_6):...\n",
"VAR_8 = {'Authorization': 'token ' + os.environ['GITHUB_TOKEN']}\n",
"VAR_9 = os.environ['BOT_USERNAME'], os.environ['BOT_PASSWORD']\n",
"VAR_11 = requests.get(VAR_5['diff_url'], VAR_8=headers, VAR_9=auth)\n",
"VAR_20 = unidiff.PatchSet(VAR_11.content.splitlines(), encoding=r.encoding)\n",
"VAR_21 = {}\n",
"for patchset in VAR_20:\n",
"if patchset.target_file[-3:] == '.py':\n",
"VAR_32 = ','.join(VAR_6['pycodestyle']['ignore'])\n",
"VAR_60 = patchset.target_file[1:]\n",
"VAR_33 = ''\n",
"VAR_21[VAR_60] = []\n",
"if len(VAR_32) > 0:\n",
"for hunk in patchset:\n",
"VAR_33 = '--ignore ' + VAR_32\n",
"for VAR_47 in VAR_21:\n",
"for VAR_66 in hunk.target_lines():\n",
"VAR_48 = VAR_47[1:]\n",
"if VAR_66.is_added:\n",
"VAR_10 = 'https://raw.githubusercontent.com/{}/{}/{}'\n",
"VAR_21[VAR_60].append(VAR_66.target_line_no)\n",
"VAR_10 = VAR_10.format(VAR_5['repository'], VAR_5['sha'], VAR_47)\n",
"VAR_11 = requests.get(VAR_10, VAR_8=headers, VAR_9=auth)\n",
"file_to_fix.write(VAR_11.text)\n",
"VAR_49 = 'autopep8 file_to_fix.py --diff {arg_to_ignore}'.format(VAR_33=\n arg_to_ignore)\n",
"VAR_50 = subprocess.Popen(VAR_49, shell=True, VAR_51=subprocess.PIPE)\n",
"VAR_51, VAR_52 = VAR_50.communicate()\n",
"VAR_5['diff'][VAR_48] = VAR_51.decode(VAR_11.encoding)\n",
"VAR_5['diff'][VAR_48] = VAR_5['diff'][VAR_48].replace('file_to_check.py',\n VAR_48)\n",
"VAR_5['diff'][VAR_48] = VAR_5['diff'][VAR_48].replace('\\\\', '\\\\\\\\')\n",
"VAR_10 = 'https://github.com/{}/blob/{}{}'\n",
"VAR_5[VAR_48 + '_link'] = VAR_10.format(VAR_5['repository'], VAR_5['sha'],\n VAR_47)\n",
"os.remove('file_to_fix.py')\n"
] |
[
"def autopep8(data, config):...\n",
"headers = {'Authorization': 'token ' + os.environ['GITHUB_TOKEN']}\n",
"auth = os.environ['BOT_USERNAME'], os.environ['BOT_PASSWORD']\n",
"r = requests.get(data['diff_url'], headers=headers, auth=auth)\n",
"patch = unidiff.PatchSet(r.content.splitlines(), encoding=r.encoding)\n",
"py_files = {}\n",
"for patchset in patch:\n",
"if patchset.target_file[-3:] == '.py':\n",
"to_ignore = ','.join(config['pycodestyle']['ignore'])\n",
"py_file = patchset.target_file[1:]\n",
"arg_to_ignore = ''\n",
"py_files[py_file] = []\n",
"if len(to_ignore) > 0:\n",
"for hunk in patchset:\n",
"arg_to_ignore = '--ignore ' + to_ignore\n",
"for file in py_files:\n",
"for line in hunk.target_lines():\n",
"filename = file[1:]\n",
"if line.is_added:\n",
"url = 'https://raw.githubusercontent.com/{}/{}/{}'\n",
"py_files[py_file].append(line.target_line_no)\n",
"url = url.format(data['repository'], data['sha'], file)\n",
"r = requests.get(url, headers=headers, auth=auth)\n",
"file_to_fix.write(r.text)\n",
"cmd = 'autopep8 file_to_fix.py --diff {arg_to_ignore}'.format(arg_to_ignore\n =arg_to_ignore)\n",
"proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)\n",
"stdout, _ = proc.communicate()\n",
"data['diff'][filename] = stdout.decode(r.encoding)\n",
"data['diff'][filename] = data['diff'][filename].replace('file_to_check.py',\n filename)\n",
"data['diff'][filename] = data['diff'][filename].replace('\\\\', '\\\\\\\\')\n",
"url = 'https://github.com/{}/blob/{}{}'\n",
"data[filename + '_link'] = url.format(data['repository'], data['sha'], file)\n",
"os.remove('file_to_fix.py')\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
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"For",
"Assign'",
"For",
"For",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"return sum(map(len, VAR_3.values()))\n"
] |
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"return sum(map(len, wildcards.values()))\n"
] |
[
0,
0,
0
] |
[
"Condition",
"Docstring",
"Return'"
] |
[
"from django import forms\n",
"from django.contrib.auth import get_user_model, authenticate\n",
"from django.contrib.auth.forms import UserCreationForm\n",
"from django.utils.translation import gettext as _\n",
"import magic, mimetypes\n",
"from .models import ScreenDoorUser, Position, Applicant\n",
"from .uservisibletext import ErrorMessages, CreatePositionFormText, CreateAccountFormText, StandardFormText, LoginFormText\n",
"VAR_17 = Applicant\n",
"VAR_18 = 'pdf',\n",
"VAR_0 = CreatePositionFormText.upload_new_position\n",
"VAR_1 = CreatePositionFormText.please_select_either_filetype\n",
"VAR_2 = CreatePositionFormText.pdf\n",
"VAR_3 = CreatePositionFormText.url\n",
"VAR_4 = CreatePositionFormText.browse_for_pdf\n",
"VAR_5 = CreatePositionFormText.link_to_job_description\n",
"VAR_6 = CreatePositionFormText.choose_a_file\n",
"VAR_7 = CreatePositionFormText.browse\n",
"VAR_8 = CreatePositionFormText.submit\n",
"VAR_17 = Position\n",
"VAR_18 = 'pdf', 'url_ref'\n",
"VAR_19 = {'url_ref': forms.TextInput(attrs={'disabled': 'disabled'})}\n",
"def FUNC_0(self):...\n",
"VAR_20 = self.cleaned_data.get('pdf')\n",
"VAR_21 = self.cleaned_data.get('url_ref')\n",
"if not VAR_20 and not VAR_21:\n",
"VAR_24 = forms.ValidationError(ErrorMessages.empty_create_position_form)\n",
"if VAR_20 and VAR_21:\n",
"self.add_error('pdf', VAR_24)\n",
"VAR_24 = forms.ValidationError(ErrorMessages.overfilled_create_position_form)\n",
"if VAR_20:\n",
"return\n",
"self.add_error('pdf', VAR_24)\n",
"VAR_25 = mimetypes.MimeTypes().types_map_inv[1][magic.from_buffer(self.\n cleaned_data['pdf'].read(), mime=True)][0]\n",
"if VAR_21:\n",
"return\n",
"if not VAR_25 == '.pdf':\n",
"VAR_24 = forms.ValidationError(ErrorMessages.url_upload_not_supported_yet)\n",
"return self.cleaned_data\n",
"VAR_24 = forms.ValidationError(ErrorMessages.incorrect_mime_type)\n",
"self.add_error('url_ref', VAR_24)\n",
"self.add_error('pdf', VAR_24)\n"
] |
[
"from django import forms\n",
"from django.contrib.auth import get_user_model, authenticate\n",
"from django.contrib.auth.forms import UserCreationForm\n",
"from django.utils.translation import gettext as _\n",
"import magic, mimetypes\n",
"from .models import ScreenDoorUser, Position, Applicant\n",
"from .uservisibletext import ErrorMessages, CreatePositionFormText, CreateAccountFormText, StandardFormText, LoginFormText\n",
"model = Applicant\n",
"fields = 'pdf',\n",
"text = CreatePositionFormText.upload_new_position\n",
"description = CreatePositionFormText.please_select_either_filetype\n",
"pdf_name = CreatePositionFormText.pdf\n",
"url_name = CreatePositionFormText.url\n",
"pdf_text = CreatePositionFormText.browse_for_pdf\n",
"url_text = CreatePositionFormText.link_to_job_description\n",
"upload_text = CreatePositionFormText.choose_a_file\n",
"browse_text = CreatePositionFormText.browse\n",
"submit_text = CreatePositionFormText.submit\n",
"model = Position\n",
"fields = 'pdf', 'url_ref'\n",
"widgets = {'url_ref': forms.TextInput(attrs={'disabled': 'disabled'})}\n",
"def clean(self):...\n",
"pdf = self.cleaned_data.get('pdf')\n",
"url = self.cleaned_data.get('url_ref')\n",
"if not pdf and not url:\n",
"msg = forms.ValidationError(ErrorMessages.empty_create_position_form)\n",
"if pdf and url:\n",
"self.add_error('pdf', msg)\n",
"msg = forms.ValidationError(ErrorMessages.overfilled_create_position_form)\n",
"if pdf:\n",
"return\n",
"self.add_error('pdf', msg)\n",
"file_type = mimetypes.MimeTypes().types_map_inv[1][magic.from_buffer(self.\n cleaned_data['pdf'].read(), mime=True)][0]\n",
"if url:\n",
"return\n",
"if not file_type == '.pdf':\n",
"msg = forms.ValidationError(ErrorMessages.url_upload_not_supported_yet)\n",
"return self.cleaned_data\n",
"msg = forms.ValidationError(ErrorMessages.incorrect_mime_type)\n",
"self.add_error('url_ref', msg)\n",
"self.add_error('pdf', msg)\n"
] |
[
0,
0,
0,
6,
6,
0,
6,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
6,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Return'",
"Expr'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(self, VAR_7, VAR_8, VAR_9):...\n",
"\"\"\"docstring\"\"\"\n"
] |
[
"def _responseFailed(self, failure, csessid, request):...\n",
"\"\"\"docstring\"\"\"\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Docstring"
] |
[
"\"\"\"Serve files directly from the ContentsManager.\"\"\"\n",
"import mimetypes\n",
"import json\n",
"from base64 import decodebytes\n",
"from tornado import web\n",
"from notebook.base.handlers import IPythonHandler\n",
"from notebook.utils import maybe_future\n",
"\"\"\"string\"\"\"\n",
"@property...\n",
"return super(CLASS_0, self).content_security_policy + '; sandbox allow-scripts'\n"
] |
[
"\"\"\"Serve files directly from the ContentsManager.\"\"\"\n",
"import mimetypes\n",
"import json\n",
"from base64 import decodebytes\n",
"from tornado import web\n",
"from notebook.base.handlers import IPythonHandler\n",
"from notebook.utils import maybe_future\n",
"\"\"\"serve files via ContentsManager\n\n Normally used when ContentsManager is not a FileContentsManager.\n\n FileContentsManager subclasses use AuthenticatedFilesHandler by default,\n a subclass of StaticFileHandler.\n \"\"\"\n",
"@property...\n",
"return super(FilesHandler, self\n ).content_security_policy + '; sandbox allow-scripts'\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Expr'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Expr'",
"Condition",
"Return'"
] |
[
"def FUNC_9(self, VAR_0):...\n",
"if not cint(self.published):\n",
"VAR_0.full_name = get_fullname(self.owner)\n",
"VAR_0.updated = global_date_format(self.published_on)\n",
"if self.blogger:\n",
"VAR_0.blogger_info = frappe.get_doc('Blogger', self.blogger).as_dict()\n",
"VAR_0.description = self.blog_intro or self.content[:140]\n",
"VAR_0.metatags = {'name': self.title, 'description': VAR_0.description}\n",
"if '<!-- markdown -->' in VAR_0.content:\n",
"VAR_0.content = markdown(VAR_0.content)\n",
"VAR_14 = find_first_image(self.content)\n",
"if VAR_14:\n",
"VAR_0.metatags['image'] = VAR_14\n",
"VAR_0.comment_list = get_comment_list(self.doctype, self.name)\n",
"if not VAR_0.comment_list:\n",
"VAR_0.comment_text = _('No comments yet')\n",
"if len(VAR_0.comment_list) == 1:\n",
"VAR_0.category = frappe.db.get_value('Blog Category', VAR_0.doc.\n blog_category, ['title', 'route'], as_dict=1)\n",
"VAR_0.comment_text = _('1 comment')\n",
"VAR_0.comment_text = _('{0} comments').format(len(VAR_0.comment_list))\n",
"VAR_0.parents = [{'name': _('Home'), 'route': '/'}, {'name': 'Blog',\n 'route': '/blog'}, {'label': VAR_0.category.title, 'route': VAR_0.\n category.route}]\n"
] |
[
"def get_context(self, context):...\n",
"if not cint(self.published):\n",
"context.full_name = get_fullname(self.owner)\n",
"context.updated = global_date_format(self.published_on)\n",
"if self.blogger:\n",
"context.blogger_info = frappe.get_doc('Blogger', self.blogger).as_dict()\n",
"context.description = self.blog_intro or self.content[:140]\n",
"context.metatags = {'name': self.title, 'description': context.description}\n",
"if '<!-- markdown -->' in context.content:\n",
"context.content = markdown(context.content)\n",
"image = find_first_image(self.content)\n",
"if image:\n",
"context.metatags['image'] = image\n",
"context.comment_list = get_comment_list(self.doctype, self.name)\n",
"if not context.comment_list:\n",
"context.comment_text = _('No comments yet')\n",
"if len(context.comment_list) == 1:\n",
"context.category = frappe.db.get_value('Blog Category', context.doc.\n blog_category, ['title', 'route'], as_dict=1)\n",
"context.comment_text = _('1 comment')\n",
"context.comment_text = _('{0} comments').format(len(context.comment_list))\n",
"context.parents = [{'name': _('Home'), 'route': '/'}, {'name': 'Blog',\n 'route': '/blog'}, {'label': context.category.title, 'route': context.\n category.route}]\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_2(self, VAR_2, VAR_3, VAR_4=None):...\n",
"VAR_8 = self.find_ord(VAR_2)\n",
"VAR_9 = self.find_ord(VAR_3)\n",
"if VAR_8 is None or VAR_9 is None:\n",
"self.edges.append((VAR_8, VAR_9, VAR_4))\n"
] |
[
"def add_edge(self, from_obj, to_obj, label=None):...\n",
"from_obj_ord = self.find_ord(from_obj)\n",
"to_obj_ord = self.find_ord(to_obj)\n",
"if from_obj_ord is None or to_obj_ord is None:\n",
"self.edges.append((from_obj_ord, to_obj_ord, label))\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Expr'"
] |
[
"def FUNC_11(self, VAR_9):...\n",
"\"\"\"docstring\"\"\"\n",
"def __init__(self, VAR_9, VAR_12):...\n",
"self._splitpath = fs.split_path(VAR_9)\n",
"self._lensplitpath = len(self._splitpath)\n",
"self._store = {}\n",
"self._ds = VAR_12\n",
"def FUNC_13(self, VAR_16):...\n",
"return True\n"
] |
[
"def get_path_context(self, targetpath):...\n",
"\"\"\"docstring\"\"\"\n",
"def __init__(self, targetpath, client):...\n",
"self._splitpath = fs.split_path(targetpath)\n",
"self._lensplitpath = len(self._splitpath)\n",
"self._store = {}\n",
"self._ds = client\n",
"def does_intersect_rule(self, rulectx):...\n",
"return True\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_23(self):...\n",
"return True\n"
] |
[
"def is_active(self):...\n",
"return True\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_0(VAR_27, VAR_28):...\n",
"VAR_15.pack_forget()\n",
"VAR_10.forget()\n",
"VAR_36 = Frame(self, bg='#f8f8f8')\n",
"VAR_36.rowconfigure(0, weight=1)\n",
"VAR_36.columnconfigure(0, weight=1)\n",
"VAR_36.rowconfigure(1, weight=3)\n",
"VAR_36.columnconfigure(1, weight=3)\n",
"VAR_36.pack()\n",
"VAR_37 = []\n",
"VAR_38 = []\n",
"VAR_39 = 'meal_planner.db'\n",
"VAR_48 = conn.cursor()\n",
"VAR_49 = VAR_48.execute('SELECT * FROM recipe')\n",
"for result in [VAR_49]:\n",
"for VAR_32 in result.fetchall():\n",
"for VAR_44 in range(len(VAR_37)):\n",
"VAR_51 = VAR_32[0]\n",
"Button(VAR_36, text=recipeNames[i], highlightbackground='#f8f8f8', command=\n lambda x=recipeNames[i], y=ingredientList[i]: add_recipe(x, y,\n add_meal_frame, rowLocation, columnLocation)).grid(VAR_32=i, VAR_33=0)\n",
"VAR_30 = VAR_32[4]\n",
"VAR_37.append(VAR_51)\n",
"VAR_38.append(VAR_30)\n"
] |
[
"def add_meal(rowLocation, columnLocation):...\n",
"menu.pack_forget()\n",
"viewRecipeFrame.forget()\n",
"add_meal_frame = Frame(self, bg='#f8f8f8')\n",
"add_meal_frame.rowconfigure(0, weight=1)\n",
"add_meal_frame.columnconfigure(0, weight=1)\n",
"add_meal_frame.rowconfigure(1, weight=3)\n",
"add_meal_frame.columnconfigure(1, weight=3)\n",
"add_meal_frame.pack()\n",
"recipeNames = []\n",
"ingredientList = []\n",
"database_file = 'meal_planner.db'\n",
"cursor = conn.cursor()\n",
"selection = cursor.execute('SELECT * FROM recipe')\n",
"for result in [selection]:\n",
"for row in result.fetchall():\n",
"for i in range(len(recipeNames)):\n",
"name = row[0]\n",
"Button(add_meal_frame, text=recipeNames[i], highlightbackground='#f8f8f8',\n command=lambda x=recipeNames[i], y=ingredientList[i]: add_recipe(x, y,\n add_meal_frame, rowLocation, columnLocation)).grid(row=i, column=0)\n",
"ingredients = row[4]\n",
"recipeNames.append(name)\n",
"ingredientList.append(ingredients)\n"
] |
[
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'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"For",
"For",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@VAR_0.route('/dashboard')...\n",
"VAR_28 = VAR_1.connection.cursor()\n",
"VAR_29 = VAR_28.execute(\n 'SELECT cid, crawl_date, pdf_crawled, pdf_processed, domain, url FROM Crawls'\n )\n",
"VAR_47 = VAR_28.fetchall()\n",
"if VAR_29 > 0:\n",
"return render_template('dashboard.html', VAR_47=crawls)\n",
"VAR_53 = 'No Crawls Found'\n",
"return render_template('dashboard.html', VAR_53=msg)\n"
] |
[
"@app.route('/dashboard')...\n",
"cur = mysql.connection.cursor()\n",
"result = cur.execute(\n 'SELECT cid, crawl_date, pdf_crawled, pdf_processed, domain, url FROM Crawls'\n )\n",
"crawls = cur.fetchall()\n",
"if result > 0:\n",
"return render_template('dashboard.html', crawls=crawls)\n",
"msg = 'No Crawls Found'\n",
"return render_template('dashboard.html', msg=msg)\n"
] |
[
0,
0,
4,
0,
0,
0,
0,
0
] |
[
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Return'"
] |
[
"def FUNC_8(self, VAR_11, VAR_3):...\n",
"return set(VAR_11['bookmarks'] if 'bookmarks' in VAR_11 else [])\n"
] |
[
"def get_bookmarks(self, levelfields, doc):...\n",
"return set(levelfields['bookmarks'] if 'bookmarks' in levelfields else [])\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_9(*VAR_13, **VAR_14):...\n",
"VAR_15 = 'memory alloced: %s kb' % str(gc.mem_alloc() / 1024)\n",
"VAR_16 = 'memory free: %s kb' % str(gc.mem_free() / 1024)\n",
"gc.collect()\n",
"VAR_17 = 'after collect: %s kb available' % str(gc.mem_free() / 1024)\n",
"print(FUNC_3(VAR_15, VAR_2='red'))\n",
"print(FUNC_3(VAR_16, VAR_2='green'))\n",
"print(FUNC_3(VAR_17, VAR_2='blue'))\n",
"VAR_9(*VAR_13, **kwargs)\n",
"VAR_18 = 'after %s excuted: %s kb available' % (VAR_9.__name__, str(gc.\n mem_free() / 1024))\n",
"print(FUNC_3(VAR_18, VAR_2='red'))\n"
] |
[
"def wrapper(*args, **kwargs):...\n",
"memory_alloc = 'memory alloced: %s kb' % str(gc.mem_alloc() / 1024)\n",
"memory_free = 'memory free: %s kb' % str(gc.mem_free() / 1024)\n",
"gc.collect()\n",
"memory_after_collect = 'after collect: %s kb available' % str(gc.mem_free() /\n 1024)\n",
"print(rainbow(memory_alloc, color='red'))\n",
"print(rainbow(memory_free, color='green'))\n",
"print(rainbow(memory_after_collect, color='blue'))\n",
"func(*args, **kwargs)\n",
"memory_after_func_excute = 'after %s excuted: %s kb available' % (func.\n __name__, str(gc.mem_free() / 1024))\n",
"print(rainbow(memory_after_func_excute, color='red'))\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def __init__(self, VAR_46=50, VAR_47=100):...\n",
"\"\"\"docstring\"\"\"\n",
"self.regex = re.compile(\n '((?P<value>.+)(?P=value){{{min_repeat},{max_repeat}}})$'.format(VAR_46\n =min_repeat - 1, VAR_47=max_repeat - 1))\n"
] |
[
"def __init__(self, min_repeat=50, max_repeat=100):...\n",
"\"\"\"docstring\"\"\"\n",
"self.regex = re.compile(\n '((?P<value>.+)(?P=value){{{min_repeat},{max_repeat}}})$'.format(\n min_repeat=min_repeat - 1, max_repeat=max_repeat - 1))\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'"
] |
[
"def FUNC_6(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = self.bindings['TEST_APP_COMPONENT_NAME']\n",
"VAR_1 = self.bindings\n",
"VAR_9 = self.agent.make_json_payload_from_kwargs(job=[{'type':\n 'deleteLoadBalancer', 'cloudProvider': 'gce', 'loadBalancerName':\n load_balancer_name, 'region': bindings['TEST_GCE_REGION'], 'regions': [\n bindings['TEST_GCE_REGION']], 'credentials': bindings['GCE_CREDENTIALS'\n ], 'user': '[anonymous]'}], description=\n 'Delete Load Balancer: {0} in {1}:{2}'.format(load_balancer_name,\n bindings['GCE_CREDENTIALS'], bindings['TEST_GCE_REGION']), application=\n self.TEST_APP)\n",
"VAR_10 = gcp.GceContractBuilder(self.gce_observer)\n",
"VAR_10.new_clause_builder('Health Check Removed', retryable_for_secs=30\n ).list_resources('http-health-checks').excludes_path_value('name', \n '%s-hc' % VAR_6)\n",
"VAR_10.new_clause_builder('TargetPool Removed').list_resources('target-pools'\n ).excludes_path_value('name', '%s-tp' % VAR_6)\n",
"VAR_10.new_clause_builder('Forwarding Rule Removed').list_resources(\n 'forwarding-rules').excludes_path_value('name', VAR_6)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'delete_load_balancer', data=payload, path='tasks'), VAR_5=builder.build())\n"
] |
[
"def delete_load_balancer(self):...\n",
"\"\"\"docstring\"\"\"\n",
"load_balancer_name = self.bindings['TEST_APP_COMPONENT_NAME']\n",
"bindings = self.bindings\n",
"payload = self.agent.make_json_payload_from_kwargs(job=[{'type':\n 'deleteLoadBalancer', 'cloudProvider': 'gce', 'loadBalancerName':\n load_balancer_name, 'region': bindings['TEST_GCE_REGION'], 'regions': [\n bindings['TEST_GCE_REGION']], 'credentials': bindings['GCE_CREDENTIALS'\n ], 'user': '[anonymous]'}], description=\n 'Delete Load Balancer: {0} in {1}:{2}'.format(load_balancer_name,\n bindings['GCE_CREDENTIALS'], bindings['TEST_GCE_REGION']), application=\n self.TEST_APP)\n",
"builder = gcp.GceContractBuilder(self.gce_observer)\n",
"builder.new_clause_builder('Health Check Removed', retryable_for_secs=30\n ).list_resources('http-health-checks').excludes_path_value('name', \n '%s-hc' % load_balancer_name)\n",
"builder.new_clause_builder('TargetPool Removed').list_resources('target-pools'\n ).excludes_path_value('name', '%s-tp' % load_balancer_name)\n",
"builder.new_clause_builder('Forwarding Rule Removed').list_resources(\n 'forwarding-rules').excludes_path_value('name', load_balancer_name)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'delete_load_balancer', data=payload, path='tasks'), contract=builder.\n build())\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._name\n"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._name\n"
] |
[
0,
0,
0
] |
[
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_25(self):...\n",
"self.cursor.execute('create table t1(s varchar(20))')\n",
"self.cursor.execute('insert into t1 values(?)', '1')\n",
"VAR_24 = self.cursor.execute('select * from t1').fetchone()\n",
"self.assertEqual(VAR_24[0], '1')\n",
"self.assertEqual(VAR_24[-1], '1')\n"
] |
[
"def test_negative_row_index(self):...\n",
"self.cursor.execute('create table t1(s varchar(20))')\n",
"self.cursor.execute('insert into t1 values(?)', '1')\n",
"row = self.cursor.execute('select * from t1').fetchone()\n",
"self.assertEqual(row[0], '1')\n",
"self.assertEqual(row[-1], '1')\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_15(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = {'SEVERITY': {'LOW': 4, 'MEDIUM': 5, 'HIGH': 0}, 'CONFIDENCE': {\n 'HIGH': 9}}\n",
"self.check_example('imports-aliases.py', VAR_2)\n"
] |
[
"def test_imports_aliases(self):...\n",
"\"\"\"docstring\"\"\"\n",
"expect = {'SEVERITY': {'LOW': 4, 'MEDIUM': 5, 'HIGH': 0}, 'CONFIDENCE': {\n 'HIGH': 9}}\n",
"self.check_example('imports-aliases.py', expect)\n"
] |
[
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_14(self):...\n",
"return self.CurrentFiletypeCompletionEnabled(\n ) and self.NativeFiletypeCompletionAvailable()\n"
] |
[
"def NativeFiletypeCompletionUsable(self):...\n",
"return self.CurrentFiletypeCompletionEnabled(\n ) and self.NativeFiletypeCompletionAvailable()\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_8(VAR_20, VAR_21, VAR_22=None):...\n",
"if VAR_20 not in VAR_5:\n",
"VAR_5[VAR_20] = []\n",
"VAR_45 = VAR_5[VAR_20]\n",
"VAR_21 = str(VAR_21)\n",
"VAR_22 = VAR_22 or ''\n",
"VAR_46 = VAR_22, VAR_21\n",
"VAR_0.info('Appending %s to targets[%s]', repr(VAR_46), VAR_20)\n",
"VAR_45.append(VAR_46)\n"
] |
[
"def add_target(domain, id_, tuser=None):...\n",
"if domain not in targets:\n",
"targets[domain] = []\n",
"tlist = targets[domain]\n",
"id_ = str(id_)\n",
"tuser = tuser or ''\n",
"t = tuser, id_\n",
"logger.info('Appending %s to targets[%s]', repr(t), domain)\n",
"tlist.append(t)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@VAR_0.route('/')...\n",
"return flask.render_template('addObsIndex.html', configuration=config,\n page_title=u'Interface de saisie des données')\n"
] |
[
"@addObs.route('/')...\n",
"return flask.render_template('addObsIndex.html', configuration=config,\n page_title=u'Interface de saisie des données')\n"
] |
[
0,
0
] |
[
"Condition",
"Return'"
] |
[
"def FUNC_5(self):...\n",
""
] |
[
"def run(self):...\n",
""
] |
[
0,
0
] |
[
"FunctionDef'",
"Condition"
] |
[
"def FUNC_8(self, VAR_13):...\n",
"\"\"\"docstring\"\"\"\n"
] |
[
"def p_expr(self, p):...\n",
"\"\"\"docstring\"\"\"\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Docstring"
] |
[
"@VAR_0.route('/api/issue/<int:id>', methods=['GET'])...\n",
"VAR_5 = FUNC_1().cursor()\n",
"VAR_7 = FUNC_3(VAR_5, VAR_6)\n",
"VAR_14 = []\n",
"VAR_15 = 200\n",
"if VAR_7 is None:\n",
"VAR_14.append(f'issue #{VAR_6} does not exist')\n",
"return jsonify({'data': list(issues.values()), 'errors': VAR_14}), VAR_15\n",
"VAR_15 = 404\n"
] |
[
"@app.route('/api/issue/<int:id>', methods=['GET'])...\n",
"cursor = get_database_connection().cursor()\n",
"issue = fetch_issue(cursor, id)\n",
"errors = []\n",
"status_code = 200\n",
"if issue is None:\n",
"errors.append(f'issue #{id} does not exist')\n",
"return jsonify({'data': list(issues.values()), 'errors': errors}), status_code\n",
"status_code = 404\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Return'",
"Assign'"
] |
[
"def FUNC_16(self):...\n",
"self.run_test_case(self.scenario.destroy_server_group('v000'))\n"
] |
[
"def test_g_destroy_server_group_v000(self):...\n",
"self.run_test_case(self.scenario.destroy_server_group('v000'))\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Expr'"
] |
[
"def __init__(self, VAR_7, VAR_14=errors.NO_THING_ID, *VAR_15, **VAR_16):...\n",
"CLASS_3.__init__(self, VAR_7, VAR_14, *VAR_15, **kw)\n"
] |
[
"def __init__(self, param, error=errors.NO_THING_ID, *a, **kw):...\n",
"VRequired.__init__(self, param, error, *a, **kw)\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_15(VAR_1, VAR_2, VAR_13, VAR_14, VAR_15):...\n",
"\"\"\"docstring\"\"\"\n",
"flash('Authorization with remote service failed.')\n",
"return redirect('/')\n"
] |
[
"def oauth2_handle_error(remote, resp, error_code, error_uri, error_description...\n",
"\"\"\"docstring\"\"\"\n",
"flash('Authorization with remote service failed.')\n",
"return redirect('/')\n"
] |
[
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Expr'",
"Return'"
] |
[
"def FUNC_7(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.testPath()\n",
"self.navloc.csvLogEKF(self.test_name)\n",
"self.navloc.csvLogMap(self.test_name)\n",
"self.navloc.csvLogTransform(self.test_name)\n",
"self.navloc.csvLogRawTags(self.test_name)\n",
"self.navloc.csvLogOdomTags(self.test_name)\n"
] |
[
"def main(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.testPath()\n",
"self.navloc.csvLogEKF(self.test_name)\n",
"self.navloc.csvLogMap(self.test_name)\n",
"self.navloc.csvLogTransform(self.test_name)\n",
"self.navloc.csvLogRawTags(self.test_name)\n",
"self.navloc.csvLogOdomTags(self.test_name)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_0(VAR_0):...\n",
"\"\"\"docstring\"\"\"\n",
"return '%s_%s' % (cfg['OAUTHCLIENT_SESSION_KEY_PREFIX'], VAR_0)\n"
] |
[
"def token_session_key(remote_app):...\n",
"\"\"\"docstring\"\"\"\n",
"return '%s_%s' % (cfg['OAUTHCLIENT_SESSION_KEY_PREFIX'], remote_app)\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Return'"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.