lines
listlengths 1
444
| raw_lines
listlengths 1
444
| label
listlengths 1
444
| type
listlengths 1
444
|
|---|---|---|---|
[
"def FUNC_8(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_1 = self.bindings\n",
"VAR_15 = '{app}-{stack}-v000'.format(app=self.TEST_APP, stack=bindings[\n 'TEST_STACK'])\n",
"VAR_12 = self.agent.make_json_payload_from_kwargs(job=[{'cloudProvider':\n 'aws', 'type': 'destroyServerGroup', 'serverGroupName': group_name,\n 'asgName': group_name, 'region': bindings['TEST_AWS_REGION'], 'regions':\n [bindings['TEST_AWS_REGION']], 'credentials': bindings[\n 'AWS_CREDENTIALS'], 'user': '[anonymous]'}], application=self.TEST_APP,\n description='DestroyServerGroup: ' + group_name)\n",
"VAR_13 = aws.AwsContractBuilder(self.aws_observer)\n",
"VAR_13.new_clause_builder('Auto Scaling Group Removed').collect_resources(\n 'autoscaling', 'describe-auto-scaling-groups', args=[\n '--auto-scaling-group-names', group_name], no_resources_ok=True\n ).contains_path_value('AutoScalingGroups', {'MaxSize': 0})\n",
"VAR_13.new_clause_builder('Instances Are Removed', retryable_for_secs=30\n ).collect_resources('ec2', 'describe-instances', no_resources_ok=True\n ).excludes_path_value('name', VAR_15)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'delete_server_group', data=payload, path='tasks'), VAR_6=builder.build())\n"
] |
[
"def delete_server_group(self):...\n",
"\"\"\"docstring\"\"\"\n",
"bindings = self.bindings\n",
"group_name = '{app}-{stack}-v000'.format(app=self.TEST_APP, stack=bindings[\n 'TEST_STACK'])\n",
"payload = self.agent.make_json_payload_from_kwargs(job=[{'cloudProvider':\n 'aws', 'type': 'destroyServerGroup', 'serverGroupName': group_name,\n 'asgName': group_name, 'region': bindings['TEST_AWS_REGION'], 'regions':\n [bindings['TEST_AWS_REGION']], 'credentials': bindings[\n 'AWS_CREDENTIALS'], 'user': '[anonymous]'}], application=self.TEST_APP,\n description='DestroyServerGroup: ' + group_name)\n",
"builder = aws.AwsContractBuilder(self.aws_observer)\n",
"builder.new_clause_builder('Auto Scaling Group Removed').collect_resources(\n 'autoscaling', 'describe-auto-scaling-groups', args=[\n '--auto-scaling-group-names', group_name], no_resources_ok=True\n ).contains_path_value('AutoScalingGroups', {'MaxSize': 0})\n",
"builder.new_clause_builder('Instances Are Removed', retryable_for_secs=30\n ).collect_resources('ec2', 'describe-instances', no_resources_ok=True\n ).excludes_path_value('name', group_name)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'delete_server_group', data=payload, path='tasks'), contract=builder.\n build())\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_13(self, VAR_14):...\n",
"return [CLASS_2(VAR_14, column.name, CLASS_5(column.type)) for column in\n self.nested_columns]\n"
] |
[
"def flatten(self, name):...\n",
"return [FlattenedColumn(name, column.name, Array(column.type)) for column in\n self.nested_columns]\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_15(self):...\n",
"return self.datadocument_set.filter(extracted=True).count()\n"
] |
[
"def extracted_docs(self):...\n",
"return self.datadocument_set.filter(extracted=True).count()\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"@VAR_0.route('/logout')...\n",
"logout_user()\n",
"return Response('<p>Logged out</p>')\n"
] |
[
"@app.route('/logout')...\n",
"logout_user()\n",
"return Response('<p>Logged out</p>')\n"
] |
[
0,
0,
0
] |
[
"Condition",
"Expr'",
"Return'"
] |
[
"@VAR_1.route('/saveAs', methods=['POST'])...\n",
"if not 'email' in VAR_18 and not 'social' in VAR_18:\n",
"return '', 401\n",
"VAR_2 = VAR_6 if VAR_6 else request.form['filename']\n",
"if VAR_2:\n",
"if VAR_2[-4:] != '.pml':\n",
"flash('Invalid File')\n",
"VAR_2 += '.pml'\n",
"if FUNC_1(VAR_2):\n",
"return redirect('/saveAs')\n",
"VAR_18['currentFile'] = VAR_2\n",
"if 'email' in VAR_18:\n",
"VAR_12 = VAR_18['email']\n",
"if 'social' in VAR_18:\n",
"VAR_23 = os.path.join(VAR_1.config['UPLOAD_FOLDER'], VAR_12)\n",
"VAR_12 = VAR_18['social']\n",
"os.makedirs(VAR_23, exist_ok=True)\n",
"VAR_24 = os.path.join(VAR_23, VAR_2)\n",
"VAR_25 = VAR_18.pop('tempFile', None)\n",
"if VAR_25:\n",
"shutil.copy(VAR_25, VAR_24)\n",
"if 'diagram' in request.referrer or 'diagram' in request.args or 'diagram' in request.form:\n",
"return redirect('/diagram?filename=%s' % VAR_2)\n",
"return redirect('/?filename=%s' % VAR_2)\n"
] |
[
"@app.route('/saveAs', methods=['POST'])...\n",
"if not 'email' in session and not 'social' in session:\n",
"return '', 401\n",
"name = fname if fname else request.form['filename']\n",
"if name:\n",
"if name[-4:] != '.pml':\n",
"flash('Invalid File')\n",
"name += '.pml'\n",
"if allowed_file(name):\n",
"return redirect('/saveAs')\n",
"session['currentFile'] = name\n",
"if 'email' in session:\n",
"email = session['email']\n",
"if 'social' in session:\n",
"savepath = os.path.join(app.config['UPLOAD_FOLDER'], email)\n",
"email = session['social']\n",
"os.makedirs(savepath, exist_ok=True)\n",
"saveFilePath = os.path.join(savepath, name)\n",
"tempFilePath = session.pop('tempFile', None)\n",
"if tempFilePath:\n",
"shutil.copy(tempFilePath, saveFilePath)\n",
"if 'diagram' in request.referrer or 'diagram' in request.args or 'diagram' in request.form:\n",
"return redirect('/diagram?filename=%s' % name)\n",
"return redirect('/?filename=%s' % name)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Condition",
"Return'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"AugAssign'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"For",
"Return'",
"Return'"
] |
[
"def FUNC_25(self, VAR_38, VAR_39=1, VAR_40=100):...\n",
"VAR_33 = 'tag:%s' % VAR_38\n",
"return self.search(VAR_33, VAR_39, VAR_40)\n"
] |
[
"def get_mails_by_tag(self, tag, page=1, window=100):...\n",
"tags = 'tag:%s' % tag\n",
"return self.search(tags, page, window)\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_17(self, VAR_34):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_34:\n",
"return True\n",
"if self.tempfiles[VAR_34] is not None:\n",
"VAR_70 = hashlib.sha256(FUNC_14(self.tempfiles[VAR_34], 'rb').read()\n ).hexdigest()\n",
"return os.close(VAR_34)\n",
"VAR_71 = self.cfg.get('honeypot', 'download_path') + '/' + VAR_70\n",
"if os.path.exists(VAR_71):\n",
"os.remove(self.tempfiles[VAR_34])\n",
"os.rename(self.tempfiles[VAR_34], VAR_71)\n",
"self.update_realfile(self.getfile(self.filenames[VAR_34]), VAR_71)\n",
"log.msg(format='SFTP Uploaded file \"%(filename)s\" to %(outfile)s', eventid=\n 'cowrie.session.file_upload', VAR_32=os.path.basename(self.filenames[fd\n ]), VAR_59=shasumfile, VAR_70=shasum)\n"
] |
[
"def close(self, fd):...\n",
"\"\"\"docstring\"\"\"\n",
"if not fd:\n",
"return True\n",
"if self.tempfiles[fd] is not None:\n",
"shasum = hashlib.sha256(open(self.tempfiles[fd], 'rb').read()).hexdigest()\n",
"return os.close(fd)\n",
"shasumfile = self.cfg.get('honeypot', 'download_path') + '/' + shasum\n",
"if os.path.exists(shasumfile):\n",
"os.remove(self.tempfiles[fd])\n",
"os.rename(self.tempfiles[fd], shasumfile)\n",
"self.update_realfile(self.getfile(self.filenames[fd]), shasumfile)\n",
"log.msg(format='SFTP Uploaded file \"%(filename)s\" to %(outfile)s', eventid=\n 'cowrie.session.file_upload', filename=os.path.basename(self.filenames[\n fd]), outfile=shasumfile, shasum=shasum)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_8(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_28 = self.add_argument_group('ParlAI Model Arguments')\n",
"VAR_28.add_argument('-m', '--model', default=None, help=\n 'the model class name. can match parlai/agents/<model> for agents in that directory, or can provide a fully specified module for `from X import Y` via `-m X:Y` (e.g. `-m parlai.agents.seq2seq.seq2seq:Seq2SeqAgent`)'\n )\n",
"VAR_28.add_argument('-mf', '--model-file', default=None, help=\n 'model file name for loading and saving models')\n",
"VAR_28.add_argument('--dict-class', help=\n 'the class of the dictionary agent uses')\n"
] |
[
"def add_model_args(self):...\n",
"\"\"\"docstring\"\"\"\n",
"model_args = self.add_argument_group('ParlAI Model Arguments')\n",
"model_args.add_argument('-m', '--model', default=None, help=\n 'the model class name. can match parlai/agents/<model> for agents in that directory, or can provide a fully specified module for `from X import Y` via `-m X:Y` (e.g. `-m parlai.agents.seq2seq.seq2seq:Seq2SeqAgent`)'\n )\n",
"model_args.add_argument('-mf', '--model-file', default=None, help=\n 'model file name for loading and saving models')\n",
"model_args.add_argument('--dict-class', help=\n 'the class of the dictionary agent uses')\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_6(self, VAR_23):...\n",
"if VAR_23 and self.r_css_name.match(VAR_23):\n",
"return VAR_23\n"
] |
[
"def run(self, name):...\n",
"if name and self.r_css_name.match(name):\n",
"return name\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Return'"
] |
[
"def FUNC_5(self):...\n",
"self.driver._eql_execute = self.mox.CreateMock(self.driver._eql_execute)\n",
"VAR_1 = {'name': self.volume_name, 'size': 1}\n",
"self.driver._eql_execute('volume', 'select', VAR_1['name'], 'show')\n",
"self.mox.ReplayAll()\n",
"self.driver.ensure_export({}, VAR_1)\n"
] |
[
"def test_ensure_export(self):...\n",
"self.driver._eql_execute = self.mox.CreateMock(self.driver._eql_execute)\n",
"volume = {'name': self.volume_name, 'size': 1}\n",
"self.driver._eql_execute('volume', 'select', volume['name'], 'show')\n",
"self.mox.ReplayAll()\n",
"self.driver.ensure_export({}, volume)\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_7(self):...\n",
"VAR_7 = BokChoyTestSuite('', default_store='invalid')\n",
"VAR_1 = 'tests'\n",
"self.assertEqual(VAR_7.cmd, self._expected_command(VAR_1=name, VAR_2='invalid')\n )\n"
] |
[
"def test_invalid_default_store(self):...\n",
"suite = BokChoyTestSuite('', default_store='invalid')\n",
"name = 'tests'\n",
"self.assertEqual(suite.cmd, self._expected_command(name=name, store='invalid'))\n"
] |
[
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_17(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = {'SEVERITY': {'LOW': 2}, 'CONFIDENCE': {'HIGH': 2}}\n",
"self.check_example('imports-function.py', VAR_2)\n"
] |
[
"def test_imports_function(self):...\n",
"\"\"\"docstring\"\"\"\n",
"expect = {'SEVERITY': {'LOW': 2}, 'CONFIDENCE': {'HIGH': 2}}\n",
"self.check_example('imports-function.py', expect)\n"
] |
[
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def __init__(self, VAR_18, *VAR_15, **VAR_16):...\n",
"self.item = VAR_18\n",
"CLASS_0.__init__(self, VAR_18, *VAR_15, **kw)\n"
] |
[
"def __init__(self, item, *a, **kw):...\n",
"self.item = item\n",
"Validator.__init__(self, item, *a, **kw)\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_0():...\n",
"\"\"\"docstring\"\"\"\n",
"return os.getlogin() in VAR_13.getgrnam('admin').gr_mem\n"
] |
[
"def is_admin():...\n",
"\"\"\"docstring\"\"\"\n",
"return os.getlogin() in grp.getgrnam('admin').gr_mem\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_0(self):...\n",
"self.assertTrue(self.client.login(username='autotest', password='password'))\n",
"chaos.CREATE_ERROR_RATE = 0\n",
"chaos.DESTROY_ERROR_RATE = 0\n",
"chaos.START_ERROR_RATE = 0\n",
"chaos.STOP_ERROR_RATE = 0\n",
"settings.SCHEDULER_MODULE = 'chaos'\n",
"settings.SSH_PRIVATE_KEY = '<some-ssh-private-key>'\n"
] |
[
"def setUp(self):...\n",
"self.assertTrue(self.client.login(username='autotest', password='password'))\n",
"chaos.CREATE_ERROR_RATE = 0\n",
"chaos.DESTROY_ERROR_RATE = 0\n",
"chaos.START_ERROR_RATE = 0\n",
"chaos.STOP_ERROR_RATE = 0\n",
"settings.SCHEDULER_MODULE = 'chaos'\n",
"settings.SSH_PRIVATE_KEY = '<some-ssh-private-key>'\n"
] |
[
0,
5,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_8(self, VAR_14):...\n",
""
] |
[
"def is_file(self, col_name):...\n",
""
] |
[
0,
0
] |
[
"FunctionDef'",
"Condition"
] |
[
"def FUNC_7(self, VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_13 = inspect.stack()[1][3]\n",
"VAR_1 = '[sos_collector:%s] %s' % (VAR_13, VAR_1)\n",
"self.logger.debug(VAR_1)\n",
"if self.config['verbose']:\n",
"self.console.debug(VAR_1)\n"
] |
[
"def log_debug(self, msg):...\n",
"\"\"\"docstring\"\"\"\n",
"caller = inspect.stack()[1][3]\n",
"msg = '[sos_collector:%s] %s' % (caller, msg)\n",
"self.logger.debug(msg)\n",
"if self.config['verbose']:\n",
"self.console.debug(msg)\n"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_30(self, VAR_16):...\n",
""
] |
[
"def delete_all(self, items):...\n",
""
] |
[
0,
0
] |
[
"FunctionDef'",
"Condition"
] |
[
"def FUNC_2(VAR_1, VAR_3, VAR_4, VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = FUNC_3(VAR_1)\n",
"VAR_7 = VAR_6.cursor(MySQLdb.cursors.DictCursor)\n",
"VAR_8 = 'SELECT * FROM questions WHERE id=' + VAR_3\n",
"VAR_7.execute(VAR_8)\n",
"VAR_10 = VAR_7.fetchone()\n",
"VAR_11 = VAR_10['ts']\n",
"if VAR_5 == 'publish':\n",
"VAR_8 = \"update questions set status='completed', answer=%s, ts=%s where id=%s\"\n",
"if VAR_5 == 'save':\n",
"VAR_8 = (\n \"update questions set status='in-progress', answer=%s, ts=%s where id=%s\")\n",
"VAR_7.execute(VAR_8, (VAR_4, VAR_11, VAR_3))\n"
] |
[
"def updateAnswer(database, q_id, answer, update_type):...\n",
"\"\"\"docstring\"\"\"\n",
"conn = dbConnect(database)\n",
"curs = conn.cursor(MySQLdb.cursors.DictCursor)\n",
"statement = 'SELECT * FROM questions WHERE id=' + q_id\n",
"curs.execute(statement)\n",
"row = curs.fetchone()\n",
"timestamp = row['ts']\n",
"if update_type == 'publish':\n",
"statement = (\n \"update questions set status='completed', answer=%s, ts=%s where id=%s\")\n",
"if update_type == 'save':\n",
"statement = (\n \"update questions set status='in-progress', answer=%s, ts=%s where id=%s\")\n",
"curs.execute(statement, (answer, timestamp, q_id))\n"
] |
[
0,
0,
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Expr'"
] |
[
"def FUNC_0(VAR_0: HttpRequest, VAR_1: str):...\n",
"VAR_7 = None\n",
"VAR_11: Profile = None\n",
"if VAR_0.GET.get('user_id'):\n",
"VAR_7 = int(VAR_0.GET['user_id'])\n",
"if VAR_7 is not None:\n",
"VAR_11 = Profile.objects.get(pk=user_id)\n",
"VAR_8 = Form()\n",
"VAR_8.action_url = VAR_1\n",
"if VAR_11:\n",
"VAR_8.add_content(PlainText('<h3>Edit user \"' + VAR_11.authuser.username +\n '\"</h3>'))\n",
"VAR_8.add_content(PlainText('<h3>Add new user</h3>'))\n",
"VAR_8.add_content(PlainText(\n '<a href=\"/admin/media/select?action_url=/admin/actions/change-user-avatar&payload='\n + str(VAR_7) + 'string'))\n",
"if not VAR_11:\n",
"VAR_8.add_content(PlainText(\"username (can't be edited later on): \"))\n",
"if VAR_0.GET.get('fault') and VAR_11:\n",
"VAR_8.add_content(TextField(name='username'))\n",
"VAR_8.add_content(PlainText('Unable to edit user due to: ' + str(VAR_0.GET[\n 'fault'])))\n",
"if VAR_0.GET.get('fault'):\n",
"current_user: Profile = get_current_user(VAR_0)\n",
"VAR_8.add_content(PlainText('Unable to add user due to: ' + str(VAR_0.GET[\n 'fault'])))\n",
"if current_user.rights > 3:\n",
"if not VAR_11:\n",
"if VAR_11:\n",
"VAR_8.add_content(CheckBox(name='active', text='User Active', checked=\n CheckEnum.CHECKED))\n",
"VAR_19: CheckEnum = CheckEnum.CHECKED\n",
"VAR_8.add_content(PlainText('Email address: '))\n",
"VAR_8.add_content(PlainText('Email address: '))\n",
"if not VAR_11.active:\n",
"VAR_8.add_content(TextField(name='email', button_text=str(profile.authuser.\n email)))\n",
"VAR_8.add_content(TextField(name='email'))\n",
"VAR_19 = CheckEnum.NOT_CHECKED\n",
"VAR_8.add_content(CheckBox(name='active', text='User Active', checked=m))\n",
"VAR_8.add_content(PlainText('Display name: '))\n",
"VAR_8.add_content(PlainText('Display name: '))\n",
"VAR_8.add_content(TextField(name='display_name', button_text=profile.\n displayName))\n",
"VAR_8.add_content(TextField(name='display_name'))\n",
"VAR_8.add_content(PlainText('DECT: '))\n",
"VAR_8.add_content(PlainText('DECT: '))\n",
"VAR_8.add_content(NumberField(name='dect', button_text=str(profile.dect),\n minimum=0))\n",
"VAR_8.add_content(NumberField(name='dect', minimum=0))\n",
"VAR_8.add_content(PlainText('Number of allowed reservations: '))\n",
"VAR_8.add_content(PlainText('Number of allowed reservations: '))\n",
"VAR_8.add_content(NumberField(name='allowed_reservations', button_text=str(\n profile.number_of_allowed_reservations), minimum=0))\n",
"VAR_8.add_content(NumberField(name='allowed_reservations', button_text=str(\n 1), minimum=0))\n",
"VAR_8.add_content(PlainText('Rights: '))\n",
"VAR_8.add_content(PlainText('Rights: '))\n",
"VAR_8.add_content(NumberField(name='rights', button_text=str(profile.rights\n ), minimum=0, maximum=4))\n",
"VAR_8.add_content(NumberField(name='rights', button_text=str(0), minimum=0,\n maximum=4))\n",
"VAR_8.add_content(PlainText('Notes:<br/>'))\n",
"VAR_8.add_content(PlainText('Notes:<br/>'))\n",
"VAR_8.add_content(TextArea(name='notes', text=str(profile.notes)))\n",
"VAR_8.add_content(TextArea(name='notes', placeholder=\n 'Hier könnte ihre Werbung stehen'))\n",
"if VAR_11:\n",
"VAR_8.add_content(PlainText(\n '<br /><br />Change password (leave blank in order to not change it):'))\n",
"VAR_8.add_content(PlainText('<br />Choose a password: '))\n",
"VAR_8.add_content(PasswordField(name='password', required=False))\n",
"VAR_8.add_content(PlainText('Confirm your password: '))\n",
"VAR_8.add_content(PasswordField(name='confirm_password', required=False))\n",
"VAR_8.add_content(PlainText(get_csrf_form_element(VAR_0)))\n",
"VAR_8.add_content(SubmitButton())\n",
"VAR_9 = (\n '<div class=\"w3-row w3-padding-64 w3-twothird w3-container admin-popup\">')\n",
"VAR_9 += VAR_8.render_html(VAR_0)\n",
"VAR_9 += '</div>'\n",
"return VAR_9\n"
] |
[
"def render_edit_page(http_request: HttpRequest, action_url: str):...\n",
"user_id = None\n",
"profile: Profile = None\n",
"if http_request.GET.get('user_id'):\n",
"user_id = int(http_request.GET['user_id'])\n",
"if user_id is not None:\n",
"profile = Profile.objects.get(pk=user_id)\n",
"f = Form()\n",
"f.action_url = action_url\n",
"if profile:\n",
"f.add_content(PlainText('<h3>Edit user \"' + profile.authuser.username +\n '\"</h3>'))\n",
"f.add_content(PlainText('<h3>Add new user</h3>'))\n",
"f.add_content(PlainText(\n '<a href=\"/admin/media/select?action_url=/admin/actions/change-user-avatar&payload='\n + str(user_id) +\n '\"><img class=\"button-img\" alt=\"Change avatar\" src=\"/staticfiles/frontpage/change-avatar.png\"/></a><br />'\n ))\n",
"if not profile:\n",
"f.add_content(PlainText(\"username (can't be edited later on): \"))\n",
"if http_request.GET.get('fault') and profile:\n",
"f.add_content(TextField(name='username'))\n",
"f.add_content(PlainText('Unable to edit user due to: ' + str(http_request.\n GET['fault'])))\n",
"if http_request.GET.get('fault'):\n",
"current_user: Profile = get_current_user(http_request)\n",
"f.add_content(PlainText('Unable to add user due to: ' + str(http_request.\n GET['fault'])))\n",
"if current_user.rights > 3:\n",
"if not profile:\n",
"if profile:\n",
"f.add_content(CheckBox(name='active', text='User Active', checked=CheckEnum\n .CHECKED))\n",
"m: CheckEnum = CheckEnum.CHECKED\n",
"f.add_content(PlainText('Email address: '))\n",
"f.add_content(PlainText('Email address: '))\n",
"if not profile.active:\n",
"f.add_content(TextField(name='email', button_text=str(profile.authuser.email)))\n",
"f.add_content(TextField(name='email'))\n",
"m = CheckEnum.NOT_CHECKED\n",
"f.add_content(CheckBox(name='active', text='User Active', checked=m))\n",
"f.add_content(PlainText('Display name: '))\n",
"f.add_content(PlainText('Display name: '))\n",
"f.add_content(TextField(name='display_name', button_text=profile.displayName))\n",
"f.add_content(TextField(name='display_name'))\n",
"f.add_content(PlainText('DECT: '))\n",
"f.add_content(PlainText('DECT: '))\n",
"f.add_content(NumberField(name='dect', button_text=str(profile.dect),\n minimum=0))\n",
"f.add_content(NumberField(name='dect', minimum=0))\n",
"f.add_content(PlainText('Number of allowed reservations: '))\n",
"f.add_content(PlainText('Number of allowed reservations: '))\n",
"f.add_content(NumberField(name='allowed_reservations', button_text=str(\n profile.number_of_allowed_reservations), minimum=0))\n",
"f.add_content(NumberField(name='allowed_reservations', button_text=str(1),\n minimum=0))\n",
"f.add_content(PlainText('Rights: '))\n",
"f.add_content(PlainText('Rights: '))\n",
"f.add_content(NumberField(name='rights', button_text=str(profile.rights),\n minimum=0, maximum=4))\n",
"f.add_content(NumberField(name='rights', button_text=str(0), minimum=0,\n maximum=4))\n",
"f.add_content(PlainText('Notes:<br/>'))\n",
"f.add_content(PlainText('Notes:<br/>'))\n",
"f.add_content(TextArea(name='notes', text=str(profile.notes)))\n",
"f.add_content(TextArea(name='notes', placeholder=\n 'Hier könnte ihre Werbung stehen'))\n",
"if profile:\n",
"f.add_content(PlainText(\n '<br /><br />Change password (leave blank in order to not change it):'))\n",
"f.add_content(PlainText('<br />Choose a password: '))\n",
"f.add_content(PasswordField(name='password', required=False))\n",
"f.add_content(PlainText('Confirm your password: '))\n",
"f.add_content(PasswordField(name='confirm_password', required=False))\n",
"f.add_content(PlainText(get_csrf_form_element(http_request)))\n",
"f.add_content(SubmitButton())\n",
"a = '<div class=\"w3-row w3-padding-64 w3-twothird w3-container admin-popup\">'\n",
"a += f.render_html(http_request)\n",
"a += '</div>'\n",
"return a\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"AnnAssign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Condition",
"AnnAssign'",
"Expr'",
"Condition",
"Condition",
"Condition",
"Expr'",
"AnnAssign'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"AugAssign'",
"AugAssign'",
"Return'"
] |
[
"def FUNC_1(self, **VAR_3):...\n",
"VAR_5 = super().get_context_data(**kwargs)\n",
"VAR_5['search_form'] = SearchForm()\n",
"return VAR_5\n"
] |
[
"def get_context_data(self, **kwargs):...\n",
"context = super().get_context_data(**kwargs)\n",
"context['search_form'] = SearchForm()\n",
"return context\n"
] |
[
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_24(VAR_14, VAR_23, *VAR_24):...\n",
"if VAR_23 == 'on_after_task':\n",
"VAR_50, VAR_51, VAR_5, VAR_52 = VAR_24\n",
"self.assertEqual(self.attributes['dimensions'], VAR_14.dimensions)\n",
"self.assertEqual(False, VAR_50)\n",
"self.assertEqual(False, VAR_51)\n",
"self.assertEqual({'os': 'Amiga', 'pool': 'default'}, VAR_5)\n",
"self.assertEqual(VAR_22, VAR_52)\n"
] |
[
"def call_hook(botobj, name, *args):...\n",
"if name == 'on_after_task':\n",
"failure, internal_failure, dimensions, summary = args\n",
"self.assertEqual(self.attributes['dimensions'], botobj.dimensions)\n",
"self.assertEqual(False, failure)\n",
"self.assertEqual(False, internal_failure)\n",
"self.assertEqual({'os': 'Amiga', 'pool': 'default'}, dimensions)\n",
"self.assertEqual(result, summary)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_1(VAR_0, VAR_1):...\n",
"VAR_9 = StringIO()\n",
"VAR_10 = csv.writer(VAR_9)\n",
"VAR_11 = ['#published', 'date', 'info', 'level', 'attribute_count', 'org']\n",
"VAR_10.writerow(VAR_11)\n",
"for event in Event.objects.filter(id__in=Hunt(id=pk).events.all()).order_by(\n",
"VAR_16 = event.publish_timestamp.astimezone(timezone('Asia/Tokyo'))\n",
"VAR_12 = BytesIO(BOM_UTF8 + VAR_9.getvalue().encode('utf8'))\n",
"VAR_17 = [VAR_16, event.date, event.info, event.get_threat_level_id_display\n (), event.attribute_count, event.org.name]\n",
"VAR_13 = HttpResponse(VAR_12.getvalue(), content_type='text/csv')\n",
"VAR_10.writerow(VAR_17)\n",
"VAR_13['Content-Disposition'] = 'filename=hunter%s.csv' % VAR_1\n",
"return VAR_13\n"
] |
[
"def hunt_export(request, pk):...\n",
"stream = StringIO()\n",
"writer = csv.writer(stream)\n",
"header = ['#published', 'date', 'info', 'level', 'attribute_count', 'org']\n",
"writer.writerow(header)\n",
"for event in Event.objects.filter(id__in=Hunt(id=pk).events.all()).order_by(\n",
"dt = event.publish_timestamp.astimezone(timezone('Asia/Tokyo'))\n",
"b_stream = BytesIO(BOM_UTF8 + stream.getvalue().encode('utf8'))\n",
"row = [dt, event.date, event.info, event.get_threat_level_id_display(),\n event.attribute_count, event.org.name]\n",
"response = HttpResponse(b_stream.getvalue(), content_type='text/csv')\n",
"writer.writerow(row)\n",
"response['Content-Disposition'] = 'filename=hunter%s.csv' % pk\n",
"return response\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def __init__(self, VAR_7):...\n",
"self._user_options = VAR_7\n",
"self._user_notified_about_crash = False\n",
"self._diag_interface = DiagnosticInterface(VAR_7)\n",
"self._omnicomp = OmniCompleter(VAR_7)\n",
"self._latest_completion_request = None\n",
"self._latest_file_parse_request = None\n",
"self._server_stdout = None\n",
"self._server_stderr = None\n",
"self._server_popen = None\n",
"self._filetypes_with_keywords_loaded = set()\n",
"self._temp_options_filename = None\n",
"self._ycmd_keepalive = YcmdKeepalive()\n",
"self._SetupServer()\n",
"self._ycmd_keepalive.Start()\n"
] |
[
"def __init__(self, user_options):...\n",
"self._user_options = user_options\n",
"self._user_notified_about_crash = False\n",
"self._diag_interface = DiagnosticInterface(user_options)\n",
"self._omnicomp = OmniCompleter(user_options)\n",
"self._latest_completion_request = None\n",
"self._latest_file_parse_request = None\n",
"self._server_stdout = None\n",
"self._server_stderr = None\n",
"self._server_popen = None\n",
"self._filetypes_with_keywords_loaded = set()\n",
"self._temp_options_filename = None\n",
"self._ycmd_keepalive = YcmdKeepalive()\n",
"self._SetupServer()\n",
"self._ycmd_keepalive.Start()\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
7,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"\"\"\"docstring\"\"\"\n"
] |
[
"def _start_event_client(self):...\n",
"\"\"\"docstring\"\"\"\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Docstring"
] |
[
"@detail_route(methods=['post'])...\n",
"return self.set_pending_action(pending_actions.REMOVE, *VAR_13, VAR_12=(\n 'delete_project',), **kwargs)\n"
] |
[
"@detail_route(methods=['post'])...\n",
"return self.set_pending_action(pending_actions.REMOVE, *args, perms=(\n 'delete_project',), **kwargs)\n"
] |
[
0,
0
] |
[
"Condition",
"Return'"
] |
[
"@command...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = VAR_1[0]\n",
"if VAR_6 == 'create':\n",
"wrapper.todoist.create_project(VAR_1[1])\n",
"if VAR_6 == 'complete':\n",
"wrapper.todoist.complete_project(VAR_1[1])\n",
"if VAR_6 == 'clear':\n",
"wrapper.todoist.clear_project(VAR_1[1])\n",
"if VAR_6 == 'delete':\n",
"wrapper.todoist.delete_project(VAR_1[1])\n"
] |
[
"@command...\n",
"\"\"\"docstring\"\"\"\n",
"sub_cmd = args[0]\n",
"if sub_cmd == 'create':\n",
"wrapper.todoist.create_project(args[1])\n",
"if sub_cmd == 'complete':\n",
"wrapper.todoist.complete_project(args[1])\n",
"if sub_cmd == 'clear':\n",
"wrapper.todoist.clear_project(args[1])\n",
"if sub_cmd == 'delete':\n",
"wrapper.todoist.delete_project(args[1])\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Docstring",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'"
] |
[
"@VAR_1.route('/run/form/remove/<field>', methods=['POST'])...\n",
"VAR_37 = FUNC_15()\n",
"VAR_37[VAR_11].pop_entry()\n",
"VAR_10 = FUNC_14(VAR_37)\n",
"FUNC_16(VAR_37, VAR_10)\n",
"return json.dumps({'commands': VAR_10, 'html': render_template(\n 'run_form.html', VAR_9=run_form)})\n"
] |
[
"@app.route('/run/form/remove/<field>', methods=['POST'])...\n",
"run_form = get_run_form()\n",
"run_form[field].pop_entry()\n",
"commands = get_commands(run_form)\n",
"set_form_defaults(run_form, commands)\n",
"return json.dumps({'commands': commands, 'html': render_template(\n 'run_form.html', form=run_form)})\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"For",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_0(VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_1:\n",
"VAR_1 = ''\n",
"VAR_1 = VAR_1.replace('*', '%').replace(' ', '%')\n",
"if VAR_1 and VAR_1.startswith('^'):\n",
"VAR_1 = VAR_1.replace('^', '')\n",
"if VAR_1 and VAR_1.endswith('$'):\n",
"VAR_1 += '%'\n",
"VAR_1 = VAR_1.replace('$', '')\n",
"VAR_1 = '%' + VAR_1 + '%'\n",
"return VAR_1\n",
"VAR_1 = '%' + VAR_1\n"
] |
[
"def convert_search(search):...\n",
"\"\"\"docstring\"\"\"\n",
"if not search:\n",
"search = ''\n",
"search = search.replace('*', '%').replace(' ', '%')\n",
"if search and search.startswith('^'):\n",
"search = search.replace('^', '')\n",
"if search and search.endswith('$'):\n",
"search += '%'\n",
"search = search.replace('$', '')\n",
"search = '%' + search + '%'\n",
"return search\n",
"search = '%' + search\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"AugAssign'",
"Assign'",
"Assign'",
"Return'",
"Assign'"
] |
[
"def __getstate__(self):...\n",
"return self.serialize()\n"
] |
[
"def __getstate__(self):...\n",
"return self.serialize()\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"\"\"\"View-related code common to the whole app.\"\"\"\n",
"import functools\n",
"import re\n",
"import django.http\n",
"import django.utils.decorators\n",
"import django.views\n",
"import config\n",
"import const\n",
"import resources\n",
"import site_settings\n",
"import utils\n",
"\"\"\"Base view class shared across the app.\"\"\"\n",
"VAR_0 = None\n",
"VAR_1 = {'lang': utils.strip}\n",
"def FUNC_0(self, VAR_2, *VAR_3, **VAR_4):...\n",
"\"\"\"docstring\"\"\"\n",
"self.params = utils.Struct()\n",
"self.read_params(VAR_5=BaseView._GET_PARAMETERS)\n",
"self.env = utils.Struct()\n",
"self.env.repo = VAR_4.get('repo', None)\n",
"self.env.action = self.ACTION_ID\n",
"self.env.config = config.Configuration(self.env.repo or '*')\n",
"VAR_13 = self.params.get('lang') or self.request.LANGUAGE_CODE\n",
"VAR_13 = re.sub('[^A-Za-z0-9-]', '', VAR_13)\n",
"VAR_13 = const.LANGUAGE_SYNONYMS.get(VAR_13, VAR_13)\n",
"if VAR_13 in const.LANGUAGE_ENDONYMS.keys():\n",
"self.env.lang = VAR_13\n",
"self.env.lang = self.env.config.language_menu_options[0\n ] if self.env.config.language_menu_options else const.DEFAULT_LANGUAGE_CODE\n",
"self.env.rtl = self.env.lang in const.LANGUAGES_BIDI\n",
"self.env.charset = const.CHARSET_UTF8\n",
"self.env.global_url = self.build_absolute_uri('/global')\n",
"def FUNC_1(self, VAR_5=None, VAR_6=None, VAR_7=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.request.method == 'GET':\n",
"if VAR_5:\n",
"if VAR_6:\n",
"for key, validator in VAR_5.items():\n",
"def FUNC_2(self):...\n",
"for key, validator in VAR_6.items():\n",
"if VAR_7:\n",
"if key in self.request.GET:\n",
"\"\"\"docstring\"\"\"\n",
"if key in self.request.POST:\n",
"for key, validator in VAR_7.items():\n",
"setattr(self.params, key, validator(self.request.GET[key]))\n",
"if not site_settings.OPTIONAL_PATH_PREFIX:\n",
"setattr(self.params, key, validator(self.request.POST[key]))\n",
"if key in self.request.FILES:\n",
"return False\n",
"VAR_14 = self.request.path[1:]\n",
"setattr(self.params, key, validator(self.request.FILES[key]))\n",
"if VAR_14 == site_settings.OPTIONAL_PATH_PREFIX:\n",
"return True\n",
"return VAR_14.startswith('%s/' % site_settings.OPTIONAL_PATH_PREFIX)\n"
] |
[
"\"\"\"View-related code common to the whole app.\"\"\"\n",
"import functools\n",
"import re\n",
"import django.http\n",
"import django.utils.decorators\n",
"import django.views\n",
"import config\n",
"import const\n",
"import resources\n",
"import site_settings\n",
"import utils\n",
"\"\"\"Base view class shared across the app.\"\"\"\n",
"ACTION_ID = None\n",
"_GET_PARAMETERS = {'lang': utils.strip}\n",
"def setup(self, request, *args, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"self.params = utils.Struct()\n",
"self.read_params(get_params=BaseView._GET_PARAMETERS)\n",
"self.env = utils.Struct()\n",
"self.env.repo = kwargs.get('repo', None)\n",
"self.env.action = self.ACTION_ID\n",
"self.env.config = config.Configuration(self.env.repo or '*')\n",
"lang = self.params.get('lang') or self.request.LANGUAGE_CODE\n",
"lang = re.sub('[^A-Za-z0-9-]', '', lang)\n",
"lang = const.LANGUAGE_SYNONYMS.get(lang, lang)\n",
"if lang in const.LANGUAGE_ENDONYMS.keys():\n",
"self.env.lang = lang\n",
"self.env.lang = self.env.config.language_menu_options[0\n ] if self.env.config.language_menu_options else const.DEFAULT_LANGUAGE_CODE\n",
"self.env.rtl = self.env.lang in const.LANGUAGES_BIDI\n",
"self.env.charset = const.CHARSET_UTF8\n",
"self.env.global_url = self.build_absolute_uri('/global')\n",
"def read_params(self, get_params=None, post_params=None, file_params=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.request.method == 'GET':\n",
"if get_params:\n",
"if post_params:\n",
"for key, validator in get_params.items():\n",
"def _request_is_for_prefixed_path(self):...\n",
"for key, validator in post_params.items():\n",
"if file_params:\n",
"if key in self.request.GET:\n",
"\"\"\"docstring\"\"\"\n",
"if key in self.request.POST:\n",
"for key, validator in file_params.items():\n",
"setattr(self.params, key, validator(self.request.GET[key]))\n",
"if not site_settings.OPTIONAL_PATH_PREFIX:\n",
"setattr(self.params, key, validator(self.request.POST[key]))\n",
"if key in self.request.FILES:\n",
"return False\n",
"req_path = self.request.path[1:]\n",
"setattr(self.params, key, validator(self.request.FILES[key]))\n",
"if req_path == site_settings.OPTIONAL_PATH_PREFIX:\n",
"return True\n",
"return req_path.startswith('%s/' % site_settings.OPTIONAL_PATH_PREFIX)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Expr'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Expr'",
"Assign'",
"Assign'",
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Docstring",
"Condition",
"Condition",
"Condition",
"For",
"FunctionDef'",
"For",
"Condition",
"Condition",
"Docstring",
"Condition",
"For",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_16(self, VAR_20):...\n",
"VAR_0.debug(f'{self.__class__.__name__} form valid')\n",
"VAR_25 = super().form_valid(VAR_20)\n",
"self.view_action()\n",
"return VAR_25\n"
] |
[
"def form_valid(self, form):...\n",
"logger.debug(f'{self.__class__.__name__} form valid')\n",
"output = super().form_valid(form)\n",
"self.view_action()\n",
"return output\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_3(self):...\n",
"VAR_8 = 'test_foo.py'\n",
"VAR_7 = BokChoyTestSuite('', test_spec=spec)\n",
"VAR_1 = 'tests/{}'.format(VAR_8)\n",
"self.assertEqual(VAR_7.cmd, self._expected_command(VAR_1=name))\n"
] |
[
"def test_suite_spec(self):...\n",
"spec = 'test_foo.py'\n",
"suite = BokChoyTestSuite('', test_spec=spec)\n",
"name = 'tests/{}'.format(spec)\n",
"self.assertEqual(suite.cmd, self._expected_command(name=name))\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_13(VAR_4, VAR_5):...\n",
"VAR_9 = FUNC_0()\n",
"VAR_10 = VAR_9.cursor()\n",
"VAR_10.execute(\n \"\"\"\n INSERT INTO isalso(name,also) VALUES('{}','{}')\n \"\"\"\n .format(VAR_4, VAR_5))\n",
"VAR_2.error('Execution failed with error: {}'.format(e))\n",
"VAR_9.commit()\n",
"VAR_2.debug('added to isalso name {} with value {}'.format(VAR_4, VAR_5))\n",
"VAR_9.close()\n"
] |
[
"def also_add(name, also):...\n",
"db = db_connect()\n",
"cursor = db.cursor()\n",
"cursor.execute(\n \"\"\"\n INSERT INTO isalso(name,also) VALUES('{}','{}')\n \"\"\"\n .format(name, also))\n",
"logger.error('Execution failed with error: {}'.format(e))\n",
"db.commit()\n",
"logger.debug('added to isalso name {} with value {}'.format(name, also))\n",
"db.close()\n"
] |
[
0,
0,
0,
4,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_27(VAR_6):...\n",
"if callable(VAR_6):\n",
"return VAR_6()\n"
] |
[
"def default_encode(value):...\n",
"if callable(value):\n",
"return value()\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Return'"
] |
[
"def FUNC_4(VAR_11):...\n",
"VAR_17 = []\n",
"for r in VAR_11:\n",
"VAR_18 = {'value': r[0], 'description': ', '.join(unique(cstr(d) for d in r if\n d)[1:])}\n",
"return VAR_17\n",
"VAR_17.append(VAR_18)\n"
] |
[
"def build_for_autosuggest(res):...\n",
"results = []\n",
"for r in res:\n",
"out = {'value': r[0], 'description': ', '.join(unique(cstr(d) for d in r if\n d)[1:])}\n",
"return results\n",
"results.append(out)\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"For",
"Assign'",
"Return'",
"Expr'"
] |
[
"def __init__(self, VAR_18, *VAR_15, **VAR_16):...\n",
"CLASS_3.__init__(self, VAR_18, errors.BAD_PASSWORD, *VAR_15, **kw)\n"
] |
[
"def __init__(self, item, *a, **kw):...\n",
"VRequired.__init__(self, item, errors.BAD_PASSWORD, *a, **kw)\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_3(self):...\n",
"return self.headerbar\n"
] |
[
"def get_headerbar(self):...\n",
"return self.headerbar\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_12(self, VAR_16):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_28 = ['volume', 'create', VAR_16['name'], '%sG' % VAR_16['size']]\n",
"VAR_0.error(_('Failed to create volume %s'), VAR_16['name'])\n",
"if self.configuration.eqlx_pool != 'default':\n",
"VAR_28.append('pool')\n",
"if self.configuration.san_thin_provision:\n",
"VAR_28.append(self.configuration.eqlx_pool)\n",
"VAR_28.append('thin-provision')\n",
"VAR_25 = self._eql_execute(*VAR_28)\n",
"return self._get_volume_data(VAR_25)\n"
] |
[
"def create_volume(self, volume):...\n",
"\"\"\"docstring\"\"\"\n",
"cmd = ['volume', 'create', volume['name'], '%sG' % volume['size']]\n",
"LOG.error(_('Failed to create volume %s'), volume['name'])\n",
"if self.configuration.eqlx_pool != 'default':\n",
"cmd.append('pool')\n",
"if self.configuration.san_thin_provision:\n",
"cmd.append(self.configuration.eqlx_pool)\n",
"cmd.append('thin-provision')\n",
"out = self._eql_execute(*cmd)\n",
"return self._get_volume_data(out)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_4(VAR_0):...\n",
"return {'linters': get_settings(VAR_0, 'anaconda_go_linters', []),\n 'lint_test': get_settings(VAR_0, 'anaconda_go_lint_test', False),\n 'exclude_regexps': get_settings(VAR_0, 'anaconda_go_exclude_regexps', [\n ]), 'max_line_length': get_settings(VAR_0,\n 'anaconda_go_max_line_length', 120), 'gocyclo_threshold': get_settings(\n VAR_0, 'anaconda_go_gocyclo_threshold', 10), 'golint_min_confidence':\n get_settings(VAR_0, 'anaconda_go_golint_min_confidence', 0.8),\n 'goconst_min_occurrences': get_settings(VAR_0,\n 'anaconda_go_goconst_min_occurrences', 3), 'min_const_length':\n get_settings(VAR_0, 'anaconda_go_min_const_length', 3),\n 'dupl_threshold': get_settings(VAR_0, 'anaconda_go_dupl_threshold', 50),\n 'path': get_working_directory(VAR_0)}\n"
] |
[
"def _get_settings(view):...\n",
"return {'linters': get_settings(view, 'anaconda_go_linters', []),\n 'lint_test': get_settings(view, 'anaconda_go_lint_test', False),\n 'exclude_regexps': get_settings(view, 'anaconda_go_exclude_regexps', []\n ), 'max_line_length': get_settings(view, 'anaconda_go_max_line_length',\n 120), 'gocyclo_threshold': get_settings(view,\n 'anaconda_go_gocyclo_threshold', 10), 'golint_min_confidence':\n get_settings(view, 'anaconda_go_golint_min_confidence', 0.8),\n 'goconst_min_occurrences': get_settings(view,\n 'anaconda_go_goconst_min_occurrences', 3), 'min_const_length':\n get_settings(view, 'anaconda_go_min_const_length', 3), 'dupl_threshold':\n get_settings(view, 'anaconda_go_dupl_threshold', 50), 'path':\n get_working_directory(view)}\n"
] |
[
0,
1
] |
[
"FunctionDef'",
"Return'"
] |
[
"@tornado.web.authenticated...\n",
"self.render('webInterface/index.html')\n"
] |
[
"@tornado.web.authenticated...\n",
"self.render('webInterface/index.html')\n"
] |
[
0,
0
] |
[
"Condition",
"Expr'"
] |
[
"def FUNC_0(VAR_1):...\n",
"if isinstance(VAR_1, rdflib.Graph):\n",
"return VAR_1\n",
"VAR_11 = False\n",
"VAR_12 = False\n",
"VAR_13 = None\n",
"if isinstance(VAR_1, str):\n",
"if VAR_1.startswith('file://'):\n",
"VAR_14 = rdflib.Graph()\n",
"VAR_11 = True\n",
"if len(VAR_1) < 240:\n",
"if VAR_11:\n",
"VAR_1 = VAR_1[7:]\n",
"if VAR_1.endswith('.ttl'):\n",
"if not VAR_11:\n",
"import os\n",
"if VAR_12:\n",
"VAR_11 = True\n",
"if VAR_1.endswith('.xml'):\n",
"VAR_12 = True\n",
"VAR_18 = os.path.abspath(VAR_1)\n",
"VAR_14.parse(source=target)\n",
"return VAR_14\n",
"VAR_13 = 'turtle'\n",
"VAR_11 = True\n",
"if VAR_1.endswith('.json'):\n",
"VAR_14.parse(source=None, publicID=None, format=rdf_format, location=None,\n file=file)\n",
"VAR_13 = 'xml'\n",
"VAR_11 = True\n",
"VAR_13 = 'json-ld'\n"
] |
[
"def _load_into_graph(target):...\n",
"if isinstance(target, rdflib.Graph):\n",
"return target\n",
"target_is_file = False\n",
"target_is_text = False\n",
"rdf_format = None\n",
"if isinstance(target, str):\n",
"if target.startswith('file://'):\n",
"g = rdflib.Graph()\n",
"target_is_file = True\n",
"if len(target) < 240:\n",
"if target_is_file:\n",
"target = target[7:]\n",
"if target.endswith('.ttl'):\n",
"if not target_is_file:\n",
"import os\n",
"if target_is_text:\n",
"target_is_file = True\n",
"if target.endswith('.xml'):\n",
"target_is_text = True\n",
"file_name = os.path.abspath(target)\n",
"g.parse(source=target)\n",
"return g\n",
"rdf_format = 'turtle'\n",
"target_is_file = True\n",
"if target.endswith('.json'):\n",
"g.parse(source=None, publicID=None, format=rdf_format, location=None, file=file\n )\n",
"rdf_format = 'xml'\n",
"target_is_file = True\n",
"rdf_format = 'json-ld'\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Import'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_1(self):...\n",
"VAR_1 = self.objects.dg.pk\n",
"VAR_2 = self.client.get(f'/datagroup/{VAR_1}/')\n",
"self.assertFalse(self.objects.doc.matched,\n 'Document should start w/ matched False')\n",
"self.assertFalse(self.objects.doc.extracted,\n 'Document should start w/ extracted False')\n",
"self.assertFalse(VAR_2.context['datagroup'].all_matched(),\n 'UploadForm should be included in the page!')\n",
"self.assertFalse(VAR_2.context['extract_form'],\n 'ExtractForm should not be included in the page!')\n",
"self.objects.doc.matched = True\n",
"self.objects.doc.save()\n",
"VAR_2 = self.client.get(f'/datagroup/{VAR_1}/')\n",
"self.assertTrue(VAR_2.context['datagroup'].all_matched(),\n 'UploadForm should not be included in the page!')\n",
"self.assertIsInstance(VAR_2.context['extract_form'], ExtractionScriptForm,\n 'ExtractForm should be included in the page!')\n",
"self.objects.doc.extracted = True\n",
"self.objects.doc.save()\n",
"VAR_2 = self.client.get(f'/datagroup/{VAR_1}/')\n",
"self.assertTrue(VAR_2.context['datagroup'].all_matched(),\n 'UploadForm should not be included in the page!')\n",
"self.assertFalse(VAR_2.context['extract_form'],\n 'ExtractForm should not be included in the page!')\n"
] |
[
"def test_detail_form_load(self):...\n",
"pk = self.objects.dg.pk\n",
"response = self.client.get(f'/datagroup/{pk}/')\n",
"self.assertFalse(self.objects.doc.matched,\n 'Document should start w/ matched False')\n",
"self.assertFalse(self.objects.doc.extracted,\n 'Document should start w/ extracted False')\n",
"self.assertFalse(response.context['datagroup'].all_matched(),\n 'UploadForm should be included in the page!')\n",
"self.assertFalse(response.context['extract_form'],\n 'ExtractForm should not be included in the page!')\n",
"self.objects.doc.matched = True\n",
"self.objects.doc.save()\n",
"response = self.client.get(f'/datagroup/{pk}/')\n",
"self.assertTrue(response.context['datagroup'].all_matched(),\n 'UploadForm should not be included in the page!')\n",
"self.assertIsInstance(response.context['extract_form'],\n ExtractionScriptForm, 'ExtractForm should be included in the page!')\n",
"self.objects.doc.extracted = True\n",
"self.objects.doc.save()\n",
"response = self.client.get(f'/datagroup/{pk}/')\n",
"self.assertTrue(response.context['datagroup'].all_matched(),\n 'UploadForm should not be included in the page!')\n",
"self.assertFalse(response.context['extract_form'],\n 'ExtractForm should not be included in the page!')\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_14(self, VAR_21, VAR_11):...\n",
"if VAR_0(VAR_11):\n",
"VAR_37, VAR_41 = self.process_lhs(VAR_21, VAR_11)\n",
"VAR_42, VAR_43 = self.process_rhs(VAR_21, VAR_11)\n",
"assert len(VAR_43) == 1, _('A string must be provided as argument')\n",
"VAR_38 = VAR_41 + VAR_43\n",
"return '%s ? %s' % (VAR_37, VAR_42), VAR_38\n"
] |
[
"def as_sql(self, compiler, connection):...\n",
"if is_postgresql(connection):\n",
"lhs, lhs_params = self.process_lhs(compiler, connection)\n",
"rhs, rhs_params = self.process_rhs(compiler, connection)\n",
"assert len(rhs_params) == 1, _('A string must be provided as argument')\n",
"params = lhs_params + rhs_params\n",
"return '%s ? %s' % (lhs, rhs), params\n"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assert'",
"Assign'",
"Return'"
] |
[
"def FUNC_0(self, VAR_1):...\n",
"VAR_15 = self.session.get(VAR_1)\n",
"for cookie in VAR_15.cookies:\n",
"if cookie.name == '_xsrf':\n",
"self.xsrf_token = cookie.value\n"
] |
[
"def read_xsrf_token(self, url):...\n",
"response = self.session.get(url)\n",
"for cookie in response.cookies:\n",
"if cookie.name == '_xsrf':\n",
"self.xsrf_token = cookie.value\n"
] |
[
0,
5,
5,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"For",
"Condition",
"Assign'"
] |
[
"def FUNC_6(self, VAR_44, VAR_50):...\n",
"if not FUNC_2(VAR_44):\n",
"return self.error()\n",
"if VAR_50 != VAR_44:\n",
"return self.error(errors.BAD_PASSWORD_MATCH)\n",
"return VAR_44\n"
] |
[
"def run(self, password, verify):...\n",
"if not chkpass(password):\n",
"return self.error()\n",
"if verify != password:\n",
"return self.error(errors.BAD_PASSWORD_MATCH)\n",
"return password\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_31(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.cursor.execute('create table t1(i int)')\n",
"self.cursor.execute('delete from t1')\n",
"self.assertEqual(self.cursor.rowcount, 0)\n"
] |
[
"def test_rowcount_nodata(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.cursor.execute('create table t1(i int)')\n",
"self.cursor.execute('delete from t1')\n",
"self.assertEqual(self.cursor.rowcount, 0)\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(self, VAR_3):...\n",
"VAR_0.info('About to check if ranks need updating for {}'.format(VAR_3))\n",
"VAR_8 = 'select count(*) from ranks where scene=\"{}\";'.format(VAR_3)\n",
"VAR_11 = self.db.exec(VAR_8)\n",
"VAR_12 = VAR_11[0][0]\n",
"VAR_13 = (5 if VAR_3 == 'pro' or VAR_3 == 'pro_wiiu' else constants.\n TOURNAMENTS_PER_RANK)\n",
"if VAR_12 == 0:\n",
"VAR_0.info('Detected that we need to bulk update ranks for {}'.format(VAR_3))\n",
"VAR_8 = (\"select date from ranks where scene='{}' order by date desc limit 1;\"\n .format(VAR_3))\n",
"VAR_27 = bracket_utils.get_first_month(self.db, VAR_3)\n",
"VAR_11 = self.db.exec(VAR_8)\n",
"VAR_28 = bracket_utils.get_last_month(self.db, VAR_3)\n",
"VAR_30 = VAR_11[0][0]\n",
"VAR_29 = bracket_utils.iter_months(VAR_27, VAR_28, include_first=False,\n include_last=True)\n",
"VAR_31 = bracket_utils.has_month_passed(VAR_30)\n",
"for month in VAR_29:\n",
"if VAR_31:\n",
"VAR_6, VAR_38 = bracket_utils.get_n_tournaments_before_date(self.db, VAR_3,\n month, VAR_13)\n",
"VAR_39 = datetime.datetime.today().strftime('%Y-%m-%d')\n",
"VAR_0.info(\n 'It has not yet been 1 month since we calculated ranks for {}. Skipping'\n .format(VAR_3))\n",
"self.process_ranks(VAR_3, VAR_6, month)\n",
"VAR_40 = 'Detected that we need up update monthly ranks for {}, on {}'.format(\n VAR_3, VAR_39)\n",
"VAR_0.info(VAR_40)\n",
"if not VAR_39.split('-')[-1] == '1':\n",
"VAR_0.exc('We are calculating ranks today, {}, but it isnt the first'.\n format(VAR_39))\n",
"VAR_29 = bracket_utils.iter_months(VAR_30, VAR_39, include_first=False,\n include_last=True)\n",
"for month in VAR_29:\n",
"VAR_42 = bracket_utils.get_previous_month(month)\n",
"VAR_43 = bracket_utils.get_tournaments_during_month(self.db, VAR_3, VAR_42)\n",
"if len(VAR_43) > 0:\n",
"tweet('Calculating {} ranks for {}'.format(month, VAR_3))\n",
"VAR_6, VAR_38 = bracket_utils.get_n_tournaments_before_date(self.db, VAR_3,\n month, VAR_13)\n",
"self.process_ranks(VAR_3, VAR_6, month)\n"
] |
[
"def check_and_update_ranks(self, scene):...\n",
"LOG.info('About to check if ranks need updating for {}'.format(scene))\n",
"sql = 'select count(*) from ranks where scene=\"{}\";'.format(scene)\n",
"res = self.db.exec(sql)\n",
"count = res[0][0]\n",
"n = (5 if scene == 'pro' or scene == 'pro_wiiu' else constants.\n TOURNAMENTS_PER_RANK)\n",
"if count == 0:\n",
"LOG.info('Detected that we need to bulk update ranks for {}'.format(scene))\n",
"sql = (\"select date from ranks where scene='{}' order by date desc limit 1;\"\n .format(scene))\n",
"first_month = bracket_utils.get_first_month(self.db, scene)\n",
"res = self.db.exec(sql)\n",
"last_month = bracket_utils.get_last_month(self.db, scene)\n",
"last_rankings_date = res[0][0]\n",
"months = bracket_utils.iter_months(first_month, last_month, include_first=\n False, include_last=True)\n",
"more_than_one_month = bracket_utils.has_month_passed(last_rankings_date)\n",
"for month in months:\n",
"if more_than_one_month:\n",
"urls, _ = bracket_utils.get_n_tournaments_before_date(self.db, scene, month, n)\n",
"today = datetime.datetime.today().strftime('%Y-%m-%d')\n",
"LOG.info(\n 'It has not yet been 1 month since we calculated ranks for {}. Skipping'\n .format(scene))\n",
"self.process_ranks(scene, urls, month)\n",
"msg = 'Detected that we need up update monthly ranks for {}, on {}'.format(\n scene, today)\n",
"LOG.info(msg)\n",
"if not today.split('-')[-1] == '1':\n",
"LOG.exc('We are calculating ranks today, {}, but it isnt the first'.format(\n today))\n",
"months = bracket_utils.iter_months(last_rankings_date, today, include_first\n =False, include_last=True)\n",
"for month in months:\n",
"prev_date = bracket_utils.get_previous_month(month)\n",
"brackets_during_month = bracket_utils.get_tournaments_during_month(self.db,\n scene, prev_date)\n",
"if len(brackets_during_month) > 0:\n",
"tweet('Calculating {} ranks for {}'.format(month, scene))\n",
"urls, _ = bracket_utils.get_n_tournaments_before_date(self.db, scene, month, n)\n",
"self.process_ranks(scene, urls, month)\n"
] |
[
0,
0,
4,
4,
0,
0,
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Expr'"
] |
[
"import psycopg2\n",
"import re\n",
"def FUNC_0():...\n",
"\"\"\"docstring\"\"\"\n",
"return psycopg2.connect('dbname=tournament')\n"
] |
[
"import psycopg2\n",
"import re\n",
"def connect():...\n",
"\"\"\"docstring\"\"\"\n",
"return psycopg2.connect('dbname=tournament')\n"
] |
[
0,
0,
0,
0,
0
] |
[
"Import'",
"Import'",
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_1(self, VAR_5, VAR_6, VAR_14, VAR_8, VAR_10, VAR_11, VAR_12,...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_13 is None:\n",
"VAR_13 = {}\n",
"VAR_39 = 0.0\n",
"VAR_40 = self.pool.get('res.currency')\n",
"VAR_42 = self.pool.get('account.move.line')\n",
"VAR_43 = self.get_accounts(VAR_5, VAR_6, [VAR_14.id], VAR_10, VAR_13)\n",
"VAR_44 = VAR_42.search(VAR_5, VAR_6, [('period_id', 'in', [p.id for p in\n VAR_8]), ('account_id', 'in', VAR_43)], VAR_13=context)\n",
"VAR_45 = VAR_42.browse(VAR_5, VAR_6, VAR_44, VAR_13=context)\n",
"for line in VAR_45:\n",
"VAR_60 = line.company_id.currency_id.id\n",
"return VAR_39\n",
"if line.debit != 0:\n",
"VAR_66 = line.debit\n",
"VAR_66 = line.credit\n",
"VAR_67 = -1\n",
"VAR_67 = 1\n",
"VAR_41 = VAR_13.copy()\n",
"VAR_41['date'] = VAR_12.strptime(DEFAULT_SERVER_DATE_FORMAT)\n",
"VAR_39 += VAR_67 * VAR_40.compute(VAR_5, VAR_6, VAR_60, VAR_11, VAR_66,\n VAR_13=ctx)\n"
] |
[
"def get_real_values(self, cr, uid, item, periods, company_id, currency_id,...\n",
"\"\"\"docstring\"\"\"\n",
"if context is None:\n",
"context = {}\n",
"result = 0.0\n",
"currency_obj = self.pool.get('res.currency')\n",
"move_line_obj = self.pool.get('account.move.line')\n",
"accounts = self.get_accounts(cr, uid, [item.id], company_id, context)\n",
"move_line_ids = move_line_obj.search(cr, uid, [('period_id', 'in', [p.id for\n p in periods]), ('account_id', 'in', accounts)], context=context)\n",
"move_lines = move_line_obj.browse(cr, uid, move_line_ids, context=context)\n",
"for line in move_lines:\n",
"line_currency_id = line.company_id.currency_id.id\n",
"return result\n",
"if line.debit != 0:\n",
"amount = line.debit\n",
"amount = line.credit\n",
"sign = -1\n",
"sign = 1\n",
"ctx = context.copy()\n",
"ctx['date'] = change_date.strptime(DEFAULT_SERVER_DATE_FORMAT)\n",
"result += sign * currency_obj.compute(cr, uid, line_currency_id,\n currency_id, amount, context=ctx)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"AugAssign'"
] |
[
"def FUNC_0(VAR_0='_Test Event', VAR_1=None):...\n",
"\"\"\"docstring\"\"\"\n",
"from frappe.utils import get_datetime\n",
"VAR_2 = frappe.get_doc({'doctype': 'Event', 'subject': VAR_0, 'event_type':\n 'Public', 'starts_on': get_datetime(VAR_1)}).insert(ignore_permissions=True\n )\n",
"return VAR_2\n"
] |
[
"def create_event(subject='_Test Event', starts_on=None):...\n",
"\"\"\"docstring\"\"\"\n",
"from frappe.utils import get_datetime\n",
"event = frappe.get_doc({'doctype': 'Event', 'subject': subject,\n 'event_type': 'Public', 'starts_on': get_datetime(starts_on)}).insert(\n ignore_permissions=True)\n",
"return event\n"
] |
[
0,
0,
0,
0,
4
] |
[
"FunctionDef'",
"Docstring",
"ImportFrom'",
"Assign'",
"Return'"
] |
[
"def FUNC_16(self, VAR_11):...\n",
"if not self._IsServerAlive():\n",
"return\n",
"SendEventNotificationAsync('BufferUnload', {'unloaded_buffer': VAR_11})\n"
] |
[
"def OnBufferUnload(self, deleted_buffer_file):...\n",
"if not self._IsServerAlive():\n",
"return\n",
"SendEventNotificationAsync('BufferUnload', {'unloaded_buffer':\n deleted_buffer_file})\n"
] |
[
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Return'",
"Expr'"
] |
[
"def FUNC_39(VAR_101):...\n",
"VAR_101.version = VAR_78\n",
"return VAR_101\n"
] |
[
"def decorate(ruleinfo):...\n",
"ruleinfo.version = version\n",
"return ruleinfo\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_7(VAR_7):...\n",
"\"\"\"docstring\"\"\"\n",
"@wraps(VAR_7)...\n",
"return VAR_7(*VAR_8, **kwargs)\n",
"current_app.logger.warning(e.message, exc_info=True)\n",
"return FUNC_16\n",
"return FUNC_15(e.remote, e.response, e.code, e.uri, e.description)\n"
] |
[
"def oauth_error_handler(f):...\n",
"\"\"\"docstring\"\"\"\n",
"@wraps(f)...\n",
"return f(*args, **kwargs)\n",
"current_app.logger.warning(e.message, exc_info=True)\n",
"return inner\n",
"return oauth2_handle_error(e.remote, e.response, e.code, e.uri, e.description)\n"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Expr'",
"Return'",
"Return'"
] |
[
"def FUNC_2(self, VAR_8, VAR_9='', VAR_7=10):...\n",
"if self.options.debug:\n",
"print(colored('getting file...', 'blue'), end='')\n",
"VAR_19 = SSHClient()\n",
"sys.stdout.flush()\n",
"VAR_19.set_missing_host_key_policy(AutoAddPolicy())\n",
"for attempt in range(VAR_7):\n",
"VAR_19.connect(self.ip_address, port=self.options.dut_scp_port if not self.\n aux else self.options.aux_scp_port, username='root', pkey=self.rsakey,\n allow_agent=False, look_for_keys=False)\n",
"if self.options.command != 'new':\n",
"VAR_25 = SCPClient(VAR_19.get_transport())\n",
"db.log_event_exception(self.result_data['id'], 'DUT' if not self.aux else\n 'AUX', 'SSH error')\n",
"print(colored(self.serial.port + ' ' + str(self.result_data['id']) +\n ': error receiving file (attempt ' + str(attempt + 1) + '/' + str(VAR_7\n ) + '): ' + str(error), 'red'))\n",
"VAR_25.get(VAR_8, VAR_9=local_path)\n",
"if self.options.command != 'new':\n",
"VAR_25.close()\n",
"if attempt < VAR_7 - 1:\n",
"db.log_event_exception(self.result_data['id'], 'DUT' if not self.aux else\n 'AUX', 'SCP error')\n",
"print(colored(self.serial.port + ' ' + str(self.result_data['id']) +\n ': error receiving file (attempt ' + str(attempt + 1) + '/' + str(VAR_7\n ) + '): ' + str(error), 'red'))\n",
"VAR_19.close()\n",
"sleep(30)\n",
"VAR_25.close()\n",
"if self.options.debug:\n",
"VAR_19.close()\n",
"print(colored('done', 'blue'))\n",
"if attempt < VAR_7 - 1:\n",
"sleep(30)\n"
] |
[
"def get_file(self, file_, local_path='', attempts=10):...\n",
"if self.options.debug:\n",
"print(colored('getting file...', 'blue'), end='')\n",
"ssh = SSHClient()\n",
"sys.stdout.flush()\n",
"ssh.set_missing_host_key_policy(AutoAddPolicy())\n",
"for attempt in range(attempts):\n",
"ssh.connect(self.ip_address, port=self.options.dut_scp_port if not self.aux\n else self.options.aux_scp_port, username='root', pkey=self.rsakey,\n allow_agent=False, look_for_keys=False)\n",
"if self.options.command != 'new':\n",
"dut_scp = SCPClient(ssh.get_transport())\n",
"db.log_event_exception(self.result_data['id'], 'DUT' if not self.aux else\n 'AUX', 'SSH error')\n",
"print(colored(self.serial.port + ' ' + str(self.result_data['id']) +\n ': error receiving file (attempt ' + str(attempt + 1) + '/' + str(\n attempts) + '): ' + str(error), 'red'))\n",
"dut_scp.get(file_, local_path=local_path)\n",
"if self.options.command != 'new':\n",
"dut_scp.close()\n",
"if attempt < attempts - 1:\n",
"db.log_event_exception(self.result_data['id'], 'DUT' if not self.aux else\n 'AUX', 'SCP error')\n",
"print(colored(self.serial.port + ' ' + str(self.result_data['id']) +\n ': error receiving file (attempt ' + str(attempt + 1) + '/' + str(\n attempts) + '): ' + str(error), 'red'))\n",
"ssh.close()\n",
"sleep(30)\n",
"dut_scp.close()\n",
"if self.options.debug:\n",
"ssh.close()\n",
"print(colored('done', 'blue'))\n",
"if attempt < attempts - 1:\n",
"sleep(30)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"For",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_3(VAR_13, VAR_14):...\n",
"VAR_28.info('writing %s', VAR_13)\n",
"if os.path.exists(VAR_13):\n",
"VAR_41 = os.stat(VAR_13)\n",
"VAR_42, VAR_43, VAR_44 = 420, -1, -1\n",
"VAR_42, VAR_43, VAR_44 = VAR_41.st_mode, VAR_41.st_uid, VAR_41.st_gid\n",
"VAR_32 = os.path.dirname(VAR_13)\n",
"os.path.exists(VAR_32) or os.makedirs(VAR_32)\n",
"newfile.write(VAR_14)\n",
"os.chmod(newfile.name, VAR_42)\n",
"os.chown(newfile.name, VAR_43, VAR_44)\n",
"os.rename(newfile.name, VAR_13)\n"
] |
[
"def write_file(path, contents):...\n",
"logger.info('writing %s', path)\n",
"if os.path.exists(path):\n",
"stat = os.stat(path)\n",
"mode, uid, gid = 420, -1, -1\n",
"mode, uid, gid = stat.st_mode, stat.st_uid, stat.st_gid\n",
"d = os.path.dirname(path)\n",
"os.path.exists(d) or os.makedirs(d)\n",
"newfile.write(contents)\n",
"os.chmod(newfile.name, mode)\n",
"os.chown(newfile.name, uid, gid)\n",
"os.rename(newfile.name, path)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_8(self):...\n",
"return FUNC_3(self)\n"
] |
[
"def get_current_user(self):...\n",
"return login_get_current_user(self)\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"import os\n",
"import sqlite3\n",
"import utils\n",
"from os import path\n",
"from utils import SQLiteUtils\n",
"VAR_0 = SQLiteUtils.getSQLiteType\n",
"from threading import Lock\n",
"from textual_data import DATABASES_FOLDER_NAME, METADATA_FILENAME\n",
"VAR_1 = path.dirname(path.realpath(__file__))\n",
"VAR_2 = 'files'\n",
"def __init__(self, VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"super(CLASS_0, self).__init__()\n",
"os.makedirs(path.join(VAR_1, DATABASES_FOLDER_NAME), exist_ok=True)\n",
"self.filename = path.join(VAR_1, DATABASES_FOLDER_NAME, VAR_3 + '.db')\n",
"self.lock = Lock()\n",
"VAR_13 = {'type': 0, 'meta': 'str', 'path': 'str', 'mod_time': 0, 'file_id':\n 'str'}\n",
"if VAR_13:\n",
"if path.isfile(self.filename):\n",
"def FUNC_0(self):...\n",
"for i in VAR_13.keys():\n",
"self.createTable(VAR_13)\n",
"\"\"\"docstring\"\"\"\n",
"self._addColumn(i, VAR_13[i])\n",
"return self.filename\n"
] |
[
"import os\n",
"import sqlite3\n",
"import utils\n",
"from os import path\n",
"from utils import SQLiteUtils\n",
"getSQLiteType = SQLiteUtils.getSQLiteType\n",
"from threading import Lock\n",
"from textual_data import DATABASES_FOLDER_NAME, METADATA_FILENAME\n",
"SCRIPT_FOLDER = path.dirname(path.realpath(__file__))\n",
"TABLE_NAME = 'files'\n",
"def __init__(self, filename):...\n",
"\"\"\"docstring\"\"\"\n",
"super(FileDB, self).__init__()\n",
"os.makedirs(path.join(SCRIPT_FOLDER, DATABASES_FOLDER_NAME), exist_ok=True)\n",
"self.filename = path.join(SCRIPT_FOLDER, DATABASES_FOLDER_NAME, filename +\n '.db')\n",
"self.lock = Lock()\n",
"initial = {'type': 0, 'meta': 'str', 'path': 'str', 'mod_time': 0,\n 'file_id': 'str'}\n",
"if initial:\n",
"if path.isfile(self.filename):\n",
"def getDBFilename(self):...\n",
"for i in initial.keys():\n",
"self.createTable(initial)\n",
"\"\"\"docstring\"\"\"\n",
"self._addColumn(i, initial[i])\n",
"return self.filename\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
] |
[
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"FunctionDef'",
"Docstring",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"FunctionDef'",
"For",
"Expr'",
"Docstring",
"Expr'",
"Return'"
] |
[
"@VAR_0.route('/flag-check/<level>', methods=['POST'])...\n",
"VAR_21 = psycopg2.connect('dbname=unlock user=ubuntu')\n",
"VAR_22 = VAR_21.cursor()\n",
"VAR_22.execute('SELECT * FROM unlock_flags WHERE level=' + VAR_6 + ';')\n",
"VAR_23 = VAR_22.fetchone()\n",
"VAR_22.close()\n",
"VAR_21.close()\n",
"if str(request.form['flag']) == str(VAR_23[1]):\n",
"if int(current_user.level1_progress) <= 2:\n",
"return 'false'\n",
"current_user.level1_progress = 3\n",
"if int(current_user.progress) <= 1:\n",
"current_user.progress = 2\n",
"VAR_2.session.commit()\n",
"return 'true'\n"
] |
[
"@app.route('/flag-check/<level>', methods=['POST'])...\n",
"conn = psycopg2.connect('dbname=unlock user=ubuntu')\n",
"cur = conn.cursor()\n",
"cur.execute('SELECT * FROM unlock_flags WHERE level=' + level + ';')\n",
"res = cur.fetchone()\n",
"cur.close()\n",
"conn.close()\n",
"if str(request.form['flag']) == str(res[1]):\n",
"if int(current_user.level1_progress) <= 2:\n",
"return 'false'\n",
"current_user.level1_progress = 3\n",
"if int(current_user.progress) <= 1:\n",
"current_user.progress = 2\n",
"db.session.commit()\n",
"return 'true'\n"
] |
[
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"For",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Return'"
] |
[
"def __str__(self):...\n",
"return str(self.raw_chem_name) if self.raw_chem_name else ''\n"
] |
[
"def __str__(self):...\n",
"return str(self.raw_chem_name) if self.raw_chem_name else ''\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"self.client = VAR_0.test_client()\n",
"self.data = {'username': 'Paul', 'email': 'pkinuthia10@gmail.com',\n 'password': 'password'}\n",
"\"\"\" Login to get a JWT token \"\"\"\n",
"self.client.post('/api/v1/auth/signup', json=self.data)\n",
"VAR_1 = self.client.post('/api/v1/auth/login', json=self.data)\n",
"self.token = VAR_1.get_json().get('auth_token')\n",
"self.user_id = str(VAR_1.get_json()['id'])\n"
] |
[
"def setUp(self):...\n",
"self.client = app.test_client()\n",
"self.data = {'username': 'Paul', 'email': 'pkinuthia10@gmail.com',\n 'password': 'password'}\n",
"\"\"\" Login to get a JWT token \"\"\"\n",
"self.client.post('/api/v1/auth/signup', json=self.data)\n",
"response = self.client.post('/api/v1/auth/login', json=self.data)\n",
"self.token = response.get_json().get('auth_token')\n",
"self.user_id = str(response.get_json()['id'])\n"
] |
[
0,
4,
4,
4,
4,
4,
4,
4
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_1(self, *VAR_4, **VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_11 = self.REQUEST\n",
"VAR_12 = VAR_11.RESPONSE\n",
"VAR_12.setHeader('Content-Type', 'text/css')\n",
"VAR_13 = []\n",
"for stylesheet in self.getStylesheets():\n",
"return '\\n'.join(VAR_13)\n",
"VAR_24 = stylesheet(self)\n",
"VAR_24 = str(stylesheet)\n",
"VAR_13.append(\n '/* ######################################################################'\n )\n",
"VAR_13.append(' ### %s' % stylesheet.absolute_url())\n",
"VAR_13.append(\n ' ###################################################################### */'\n )\n",
"VAR_13.append(VAR_24)\n"
] |
[
"def zmi_manage_css(self, *args, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"request = self.REQUEST\n",
"response = request.RESPONSE\n",
"response.setHeader('Content-Type', 'text/css')\n",
"css = []\n",
"for stylesheet in self.getStylesheets():\n",
"return '\\n'.join(css)\n",
"s = stylesheet(self)\n",
"s = str(stylesheet)\n",
"css.append(\n '/* ######################################################################'\n )\n",
"css.append(' ### %s' % stylesheet.absolute_url())\n",
"css.append(\n ' ###################################################################### */'\n )\n",
"css.append(s)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"For",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_5(self, VAR_1, VAR_2, VAR_8=None, VAR_9='form', VAR_4=None, VAR_14...\n",
"VAR_29 = super(CLASS_0, self).fields_view_get(VAR_1, VAR_2, VAR_8, VAR_9,\n VAR_4, VAR_14=toolbar, VAR_15=submenu)\n",
"if VAR_4 is None:\n",
"VAR_4 = {}\n",
"if 'location' in VAR_4 and VAR_4['location']:\n",
"VAR_51 = self.pool.get('stock.location').browse(VAR_1, VAR_2, VAR_4['location']\n )\n",
"return VAR_29\n",
"VAR_52 = VAR_29.get('fields', {})\n",
"if VAR_52:\n",
"if VAR_51.usage == 'supplier':\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'internal':\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Receptions')\n",
"if VAR_52.get('qty_available'):\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'customer':\n",
"VAR_29['fields']['qty_available']['string'] = _('Received Qty')\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Stock')\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'inventory':\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Deliveries')\n",
"if VAR_52.get('qty_available'):\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'procurement':\n",
"VAR_29['fields']['qty_available']['string'] = _('Delivered Qty')\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future P&L')\n",
"if VAR_52.get('qty_available'):\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'production':\n",
"VAR_29['fields']['qty_available']['string'] = _('P&L Qty')\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Qty')\n",
"if VAR_52.get('qty_available'):\n",
"if VAR_52.get('virtual_available'):\n",
"VAR_29['fields']['qty_available']['string'] = _('Unplanned Qty')\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Productions')\n",
"if VAR_52.get('qty_available'):\n",
"VAR_29['fields']['qty_available']['string'] = _('Produced Qty')\n"
] |
[
"def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=...\n",
"res = super(product_product, self).fields_view_get(cr, uid, view_id,\n view_type, context, toolbar=toolbar, submenu=submenu)\n",
"if context is None:\n",
"context = {}\n",
"if 'location' in context and context['location']:\n",
"location_info = self.pool.get('stock.location').browse(cr, uid, context[\n 'location'])\n",
"return res\n",
"fields = res.get('fields', {})\n",
"if fields:\n",
"if location_info.usage == 'supplier':\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'internal':\n",
"res['fields']['virtual_available']['string'] = _('Future Receptions')\n",
"if fields.get('qty_available'):\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'customer':\n",
"res['fields']['qty_available']['string'] = _('Received Qty')\n",
"res['fields']['virtual_available']['string'] = _('Future Stock')\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'inventory':\n",
"res['fields']['virtual_available']['string'] = _('Future Deliveries')\n",
"if fields.get('qty_available'):\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'procurement':\n",
"res['fields']['qty_available']['string'] = _('Delivered Qty')\n",
"res['fields']['virtual_available']['string'] = _('Future P&L')\n",
"if fields.get('qty_available'):\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'production':\n",
"res['fields']['qty_available']['string'] = _('P&L Qty')\n",
"res['fields']['virtual_available']['string'] = _('Future Qty')\n",
"if fields.get('qty_available'):\n",
"if fields.get('virtual_available'):\n",
"res['fields']['qty_available']['string'] = _('Unplanned Qty')\n",
"res['fields']['virtual_available']['string'] = _('Future Productions')\n",
"if fields.get('qty_available'):\n",
"res['fields']['qty_available']['string'] = _('Produced Qty')\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"For",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'"
] |
[
"def __init__(self, VAR_3, VAR_4):...\n",
"self.model = VAR_3\n",
"self.model.on_sort.connect(self._on_view_sort)\n",
"self.table_view = VAR_4\n",
"self.table_view.setModel(self.model)\n",
"self.table_view.verticalScrollBar().valueChanged.connect(self._on_list_scroll)\n",
"self.request_mgr = None\n"
] |
[
"def __init__(self, model, table_view):...\n",
"self.model = model\n",
"self.model.on_sort.connect(self._on_view_sort)\n",
"self.table_view = table_view\n",
"self.table_view.setModel(self.model)\n",
"self.table_view.verticalScrollBar().valueChanged.connect(self._on_list_scroll)\n",
"self.request_mgr = None\n"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'"
] |
[
"def FUNC_0():...\n",
"VAR_4 = configparser.ConfigParser()\n",
"VAR_4.read('config.ini')\n",
"return queries.Query(host=config['database']['host'], dbname=config[\n 'database']['dbname'], VAR_19=config['database']['user'], password=\n config['database']['pass'])\n"
] |
[
"def init():...\n",
"config = configparser.ConfigParser()\n",
"config.read('config.ini')\n",
"return queries.Query(host=config['database']['host'], dbname=config[\n 'database']['dbname'], user=config['database']['user'], password=config\n ['database']['pass'])\n"
] |
[
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Expr'",
"Return'"
] |
[
"@functools.wraps(VAR_3)...\n",
"VAR_23 = VAR_5.pop('timeout', None)\n",
"VAR_24 = eventlet.spawn(VAR_3, self, *VAR_4, **kwargs)\n",
"if VAR_23 is None:\n",
"return VAR_24.wait()\n",
"VAR_36 = eventlet.spawn_after(VAR_23, VAR_24.kill)\n",
"VAR_48 = VAR_24.wait()\n",
"VAR_36.cancel()\n",
"return VAR_48\n"
] |
[
"@functools.wraps(f)...\n",
"timeout = kwargs.pop('timeout', None)\n",
"gt = eventlet.spawn(f, self, *args, **kwargs)\n",
"if timeout is None:\n",
"return gt.wait()\n",
"kill_thread = eventlet.spawn_after(timeout, gt.kill)\n",
"res = gt.wait()\n",
"kill_thread.cancel()\n",
"return res\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"@route('GET', '/-test/jquery.js', VAR_1=website)...\n",
"get_current_http_response().set_header('Content-Type',\n 'text/javascript; charset=utf-8')\n",
"return (as_path(__file__).dirname() / 'jquery.js').text()\n"
] |
[
"@route('GET', '/-test/jquery.js', website=website)...\n",
"get_current_http_response().set_header('Content-Type',\n 'text/javascript; charset=utf-8')\n",
"return (as_path(__file__).dirname() / 'jquery.js').text()\n"
] |
[
0,
0,
0
] |
[
"Condition",
"Expr'",
"Return'"
] |
[
"def FUNC_4(self):...\n",
"if self.closed:\n",
"def FUNC_26():...\n",
"return self.closed\n"
] |
[
"def iter_messages(self):...\n",
"if self.closed:\n",
"def stop():...\n",
"return self.closed\n"
] |
[
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_7(VAR_13):...\n",
"VAR_32 = BeautifulSoup(VAR_13, 'html.parser')\n",
"VAR_21 = VAR_32.find_all('form')\n",
"VAR_33 = []\n",
"if len(VAR_21) > 0:\n",
"for VAR_46 in VAR_21:\n",
"return VAR_33\n",
"VAR_42 = VAR_46.findChildren('input', {'type': 'file'})\n",
"if len(VAR_42) > 0:\n",
"VAR_33.append((VAR_46, VAR_42))\n"
] |
[
"def detectForms(html):...\n",
"soup = BeautifulSoup(html, 'html.parser')\n",
"detectedForms = soup.find_all('form')\n",
"returnForms = []\n",
"if len(detectedForms) > 0:\n",
"for f in detectedForms:\n",
"return returnForms\n",
"fileInputs = f.findChildren('input', {'type': 'file'})\n",
"if len(fileInputs) > 0:\n",
"returnForms.append((f, fileInputs))\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"For",
"Return'",
"Assign'",
"Condition",
"Expr'"
] |
[
"def FUNC_11(self, VAR_12):...\n",
"VAR_5 = {}\n",
"VAR_5['serverName'] = VAR_12['host']\n",
"VAR_16 = self._cliq_run_xml('getServerInfo', VAR_5, False)\n",
"VAR_33 = VAR_16.find('response')\n",
"VAR_34 = VAR_33.attrib.get('result')\n",
"if VAR_34 != '0':\n",
"VAR_5 = {}\n",
"VAR_5['serverName'] = VAR_12['host']\n",
"VAR_5['initiator'] = VAR_12['initiator']\n",
"self._cliq_run_xml('createServer', VAR_5)\n"
] |
[
"def _create_server(self, connector):...\n",
"cliq_args = {}\n",
"cliq_args['serverName'] = connector['host']\n",
"out = self._cliq_run_xml('getServerInfo', cliq_args, False)\n",
"response = out.find('response')\n",
"result = response.attrib.get('result')\n",
"if result != '0':\n",
"cliq_args = {}\n",
"cliq_args['serverName'] = connector['host']\n",
"cliq_args['initiator'] = connector['initiator']\n",
"self._cliq_run_xml('createServer', cliq_args)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_8(VAR_12, VAR_8, VAR_7, VAR_13, VAR_27, VAR_10):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_21 = VAR_14 = VAR_20 = FUNC_0()\n",
"VAR_16 = {'cost_usd': VAR_13 * (VAR_20 - VAR_27) / 60.0 / 60.0, 'id': VAR_8\n .bot_id, 'task_id': VAR_8.task_id}\n",
"FUNC_4(VAR_12, VAR_16, None, '', 0)\n",
"if VAR_8.command:\n",
"VAR_30 = VAR_8.command\n",
"VAR_9 = os.path.join(VAR_7, 'isolated_result.json')\n",
"VAR_9 = None\n",
"VAR_30 = FUNC_2(VAR_7, VAR_8, VAR_9, VAR_10)\n",
"VAR_41 = None\n",
"if VAR_9:\n",
"VAR_8.hard_timeout = 0\n",
"if VAR_8.env:\n",
"os.remove(VAR_9)\n",
"if VAR_8.grace_period:\n",
"VAR_41 = os.environ.copy()\n",
"logging.info('cmd=%s', VAR_30)\n",
"VAR_8.grace_period *= 2\n",
"for VAR_48, value in VAR_8.env.iteritems():\n",
"logging.info('env=%s', VAR_41)\n",
"if not value:\n",
"VAR_24 = subprocess42.Popen(VAR_30, VAR_41=env, cwd=work_dir, detached=True,\n VAR_18=subprocess42.PIPE, stderr=subprocess42.STDOUT, stdin=\n subprocess42.PIPE)\n",
"VAR_18 = \"\"\"Command \"%s\" failed to start.\nError: %s\"\"\" % (' '.join(VAR_30), e)\n",
"VAR_19 = 0\n",
"VAR_41.pop(VAR_48, None)\n",
"VAR_41[VAR_48] = value\n",
"VAR_20 = FUNC_0()\n",
"VAR_18 = ''\n",
"VAR_16['cost_usd'] = VAR_13 * (VAR_20 - VAR_27) / 60.0 / 60.0\n",
"VAR_17 = None\n",
"VAR_16['duration'] = VAR_20 - VAR_14\n",
"VAR_42 = False\n",
"VAR_16['io_timeout'] = False\n",
"VAR_43 = False\n",
"VAR_16['hard_timeout'] = False\n",
"VAR_44 = None\n",
"FUNC_4(VAR_12, VAR_16, 1, VAR_18, 0)\n",
"VAR_45 = False\n",
"return {u'exit_code': -1, u'hard_timeout': False, u'io_timeout': False,\n u'must_signal_internal_failure': None, u'version': VAR_4}\n",
"VAR_23 = None\n",
"VAR_46 = lambda : FUNC_6(VAR_8, VAR_14, VAR_22, VAR_23, VAR_18)\n",
"VAR_44 = u'task_runner received signal %s' % e.signal\n",
"VAR_20 = FUNC_0()\n",
"VAR_47 = lambda : VAR_1 - len(VAR_18)\n",
"VAR_17 = FUNC_7(VAR_24, VAR_8.grace_period, 'signal %d' % e.signal)\n",
"VAR_16['cost_usd'] = VAR_13 * (VAR_20 - VAR_27) / 60.0 / 60.0\n",
"VAR_22 = FUNC_0()\n",
"VAR_42 = True\n",
"VAR_16['duration'] = VAR_20 - VAR_14\n",
"for VAR_34, new_data in VAR_24.yield_any(VAR_47=maxsize, timeout=calc):\n",
"VAR_17 = FUNC_7(VAR_24, VAR_8.grace_period, 'exception %s' % e)\n",
"VAR_16['io_timeout'] = VAR_43\n",
"VAR_20 = FUNC_0()\n",
"logging.info('Waiting for proces exit')\n",
"VAR_16['hard_timeout'] = VAR_42\n",
"if new_data:\n",
"VAR_17 = VAR_24.wait()\n",
"if VAR_9:\n",
"VAR_18 += new_data\n",
"if FUNC_5(VAR_18, VAR_20, VAR_21):\n",
"if VAR_17 is None:\n",
"if (VAR_43 or VAR_42) and not os.path.isfile(VAR_9):\n",
"logging.error('Swallowing error: %s', e)\n",
"VAR_22 = VAR_20\n",
"VAR_21 = FUNC_0()\n",
"if not VAR_23:\n",
"VAR_17 = -1\n",
"FUNC_4(VAR_12, VAR_16, VAR_17, VAR_18, VAR_19)\n",
"logging.warning(\"TIMED_OUT and there's no result file\")\n",
"VAR_50 = json.load(f)\n",
"if not VAR_44:\n",
"VAR_16['cost_usd'] = VAR_13 * (VAR_21 - VAR_27) / 60.0 / 60.0\n",
"if VAR_8.io_timeout and VAR_20 - VAR_22 > VAR_8.io_timeout:\n",
"if not VAR_45 and VAR_20 >= VAR_23 + VAR_8.grace_period:\n",
"return {u'exit_code': VAR_17, u'hard_timeout': VAR_42, u'io_timeout':\n VAR_43, u'must_signal_internal_failure': VAR_44, u'version': VAR_4}\n",
"VAR_17 = -1\n",
"logging.debug('run_isolated:\\n%s', VAR_50)\n",
"VAR_44 = str(e)\n",
"FUNC_4(VAR_12, VAR_16, None, VAR_18, VAR_19)\n",
"VAR_43 = True\n",
"if VAR_8.hard_timeout and VAR_20 - VAR_14 > VAR_8.hard_timeout:\n",
"logging.warning('Grace exhausted; sending SIGKILL')\n",
"if VAR_50['outputs_ref']:\n",
"VAR_19 += len(VAR_18)\n",
"logging.warning('I/O timeout; sending SIGTERM')\n",
"VAR_42 = True\n",
"VAR_24.kill()\n",
"VAR_16['outputs_ref'] = VAR_50['outputs_ref']\n",
"VAR_42 = VAR_42 or VAR_50['had_hard_timeout']\n",
"VAR_18 = ''\n",
"VAR_24.terminate()\n",
"logging.warning('Hard timeout; sending SIGTERM')\n",
"VAR_45 = True\n",
"VAR_16['hard_timeout'] = VAR_42\n",
"VAR_23 = FUNC_0()\n",
"VAR_24.terminate()\n",
"if not VAR_43 and not VAR_42:\n",
"VAR_23 = FUNC_0()\n",
"if VAR_50['internal_failure']:\n",
"VAR_17 = VAR_50['exit_code']\n",
"VAR_44 = VAR_50['internal_failure']\n",
"if VAR_17:\n",
"if VAR_50.get('duration') is not None:\n",
"logging.error('%s', VAR_44)\n",
"VAR_44 = 'run_isolated internal failure %d' % VAR_17\n",
"VAR_16['bot_overhead'] = VAR_16['duration']\n",
"VAR_49 = VAR_50.get('stats')\n",
"logging.error('%s', VAR_44)\n",
"VAR_16['duration'] = VAR_50['duration']\n",
"if VAR_49:\n",
"VAR_16['bot_overhead'] -= VAR_16['duration']\n",
"VAR_16['isolated_stats'] = VAR_49\n",
"VAR_16['bot_overhead'] -= VAR_50.get('download', {}).get('duration', 0)\n",
"VAR_16['bot_overhead'] -= VAR_50.get('upload', {}).get('duration', 0)\n",
"if VAR_16['bot_overhead'] < 0:\n",
"VAR_16['bot_overhead'] = 0\n"
] |
[
"def run_command(swarming_server, task_details, work_dir, cost_usd_hour,...\n",
"\"\"\"docstring\"\"\"\n",
"last_packet = start = now = monotonic_time()\n",
"params = {'cost_usd': cost_usd_hour * (now - task_start) / 60.0 / 60.0,\n 'id': task_details.bot_id, 'task_id': task_details.task_id}\n",
"post_update(swarming_server, params, None, '', 0)\n",
"if task_details.command:\n",
"cmd = task_details.command\n",
"isolated_result = os.path.join(work_dir, 'isolated_result.json')\n",
"isolated_result = None\n",
"cmd = get_isolated_cmd(work_dir, task_details, isolated_result, min_free_space)\n",
"env = None\n",
"if isolated_result:\n",
"task_details.hard_timeout = 0\n",
"if task_details.env:\n",
"os.remove(isolated_result)\n",
"if task_details.grace_period:\n",
"env = os.environ.copy()\n",
"logging.info('cmd=%s', cmd)\n",
"task_details.grace_period *= 2\n",
"for key, value in task_details.env.iteritems():\n",
"logging.info('env=%s', env)\n",
"if not value:\n",
"proc = subprocess42.Popen(cmd, env=env, cwd=work_dir, detached=True, stdout\n =subprocess42.PIPE, stderr=subprocess42.STDOUT, stdin=subprocess42.PIPE)\n",
"stdout = \"\"\"Command \"%s\" failed to start.\nError: %s\"\"\" % (' '.join(cmd), e)\n",
"output_chunk_start = 0\n",
"env.pop(key, None)\n",
"env[key] = value\n",
"now = monotonic_time()\n",
"stdout = ''\n",
"params['cost_usd'] = cost_usd_hour * (now - task_start) / 60.0 / 60.0\n",
"exit_code = None\n",
"params['duration'] = now - start\n",
"had_hard_timeout = False\n",
"params['io_timeout'] = False\n",
"had_io_timeout = False\n",
"params['hard_timeout'] = False\n",
"must_signal_internal_failure = None\n",
"post_update(swarming_server, params, 1, stdout, 0)\n",
"kill_sent = False\n",
"return {u'exit_code': -1, u'hard_timeout': False, u'io_timeout': False,\n u'must_signal_internal_failure': None, u'version': OUT_VERSION}\n",
"timed_out = None\n",
"calc = lambda : calc_yield_wait(task_details, start, last_io, timed_out, stdout\n )\n",
"must_signal_internal_failure = u'task_runner received signal %s' % e.signal\n",
"now = monotonic_time()\n",
"maxsize = lambda : MAX_CHUNK_SIZE - len(stdout)\n",
"exit_code = kill_and_wait(proc, task_details.grace_period, 'signal %d' % e.\n signal)\n",
"params['cost_usd'] = cost_usd_hour * (now - task_start) / 60.0 / 60.0\n",
"last_io = monotonic_time()\n",
"had_hard_timeout = True\n",
"params['duration'] = now - start\n",
"for _, new_data in proc.yield_any(maxsize=maxsize, timeout=calc):\n",
"exit_code = kill_and_wait(proc, task_details.grace_period, 'exception %s' % e)\n",
"params['io_timeout'] = had_io_timeout\n",
"now = monotonic_time()\n",
"logging.info('Waiting for proces exit')\n",
"params['hard_timeout'] = had_hard_timeout\n",
"if new_data:\n",
"exit_code = proc.wait()\n",
"if isolated_result:\n",
"stdout += new_data\n",
"if should_post_update(stdout, now, last_packet):\n",
"if exit_code is None:\n",
"if (had_io_timeout or had_hard_timeout) and not os.path.isfile(isolated_result\n",
"logging.error('Swallowing error: %s', e)\n",
"last_io = now\n",
"last_packet = monotonic_time()\n",
"if not timed_out:\n",
"exit_code = -1\n",
"post_update(swarming_server, params, exit_code, stdout, output_chunk_start)\n",
"logging.warning(\"TIMED_OUT and there's no result file\")\n",
"run_isolated_result = json.load(f)\n",
"if not must_signal_internal_failure:\n",
"params['cost_usd'] = cost_usd_hour * (last_packet - task_start) / 60.0 / 60.0\n",
"if task_details.io_timeout and now - last_io > task_details.io_timeout:\n",
"if not kill_sent and now >= timed_out + task_details.grace_period:\n",
"return {u'exit_code': exit_code, u'hard_timeout': had_hard_timeout,\n u'io_timeout': had_io_timeout, u'must_signal_internal_failure':\n must_signal_internal_failure, u'version': OUT_VERSION}\n",
"exit_code = -1\n",
"logging.debug('run_isolated:\\n%s', run_isolated_result)\n",
"must_signal_internal_failure = str(e)\n",
"post_update(swarming_server, params, None, stdout, output_chunk_start)\n",
"had_io_timeout = True\n",
"if task_details.hard_timeout and now - start > task_details.hard_timeout:\n",
"logging.warning('Grace exhausted; sending SIGKILL')\n",
"if run_isolated_result['outputs_ref']:\n",
"output_chunk_start += len(stdout)\n",
"logging.warning('I/O timeout; sending SIGTERM')\n",
"had_hard_timeout = True\n",
"proc.kill()\n",
"params['outputs_ref'] = run_isolated_result['outputs_ref']\n",
"had_hard_timeout = had_hard_timeout or run_isolated_result['had_hard_timeout']\n",
"stdout = ''\n",
"proc.terminate()\n",
"logging.warning('Hard timeout; sending SIGTERM')\n",
"kill_sent = True\n",
"params['hard_timeout'] = had_hard_timeout\n",
"timed_out = monotonic_time()\n",
"proc.terminate()\n",
"if not had_io_timeout and not had_hard_timeout:\n",
"timed_out = monotonic_time()\n",
"if run_isolated_result['internal_failure']:\n",
"exit_code = run_isolated_result['exit_code']\n",
"must_signal_internal_failure = run_isolated_result['internal_failure']\n",
"if exit_code:\n",
"if run_isolated_result.get('duration') is not None:\n",
"logging.error('%s', must_signal_internal_failure)\n",
"must_signal_internal_failure = 'run_isolated internal failure %d' % exit_code\n",
"params['bot_overhead'] = params['duration']\n",
"stats = run_isolated_result.get('stats')\n",
"logging.error('%s', must_signal_internal_failure)\n",
"params['duration'] = run_isolated_result['duration']\n",
"if stats:\n",
"params['bot_overhead'] -= params['duration']\n",
"params['isolated_stats'] = stats\n",
"params['bot_overhead'] -= run_isolated_result.get('download', {}).get(\n 'duration', 0)\n",
"params['bot_overhead'] -= run_isolated_result.get('upload', {}).get('duration',\n 0)\n",
"if params['bot_overhead'] < 0:\n",
"params['bot_overhead'] = 0\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"AugAssign'",
"For",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"AugAssign'",
"Condition",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"AugAssign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"AugAssign'",
"Assign'",
"AugAssign'",
"AugAssign'",
"Condition",
"Assign'"
] |
[
"def FUNC_20(self):...\n",
"VAR_16 = self.mox.CreateMock(paramiko.SSHClient)\n",
"VAR_12 = self.mox.CreateMock(paramiko.Channel)\n",
"VAR_17 = self.mox.CreateMock(paramiko.Transport)\n",
"self.mox.StubOutWithMock(self.driver, '_get_output')\n",
"self.mox.StubOutWithMock(VAR_16, 'get_transport')\n",
"self.mox.StubOutWithMock(VAR_12, 'invoke_shell')\n",
"VAR_15 = ['Error: test run', '% Error']\n",
"VAR_16.get_transport().AndReturn(VAR_17)\n",
"VAR_17.open_session().AndReturn(VAR_12)\n",
"VAR_12.invoke_shell()\n",
"self.driver._get_output(VAR_12).AndReturn(VAR_15)\n",
"VAR_18 = 'this is dummy command'\n",
"VAR_12.send('stty columns 255' + '\\r')\n",
"self.driver._get_output(VAR_12).AndReturn(VAR_15)\n",
"VAR_12.send(VAR_18 + '\\r')\n",
"self.driver._get_output(VAR_12).AndReturn(VAR_15)\n",
"VAR_12.close()\n",
"self.mox.ReplayAll()\n",
"self.assertRaises(processutils.ProcessExecutionError, self.driver.\n _ssh_execute, VAR_16, VAR_18)\n"
] |
[
"def test_ssh_execute_error(self):...\n",
"ssh = self.mox.CreateMock(paramiko.SSHClient)\n",
"chan = self.mox.CreateMock(paramiko.Channel)\n",
"transport = self.mox.CreateMock(paramiko.Transport)\n",
"self.mox.StubOutWithMock(self.driver, '_get_output')\n",
"self.mox.StubOutWithMock(ssh, 'get_transport')\n",
"self.mox.StubOutWithMock(chan, 'invoke_shell')\n",
"expected_output = ['Error: test run', '% Error']\n",
"ssh.get_transport().AndReturn(transport)\n",
"transport.open_session().AndReturn(chan)\n",
"chan.invoke_shell()\n",
"self.driver._get_output(chan).AndReturn(expected_output)\n",
"cmd = 'this is dummy command'\n",
"chan.send('stty columns 255' + '\\r')\n",
"self.driver._get_output(chan).AndReturn(expected_output)\n",
"chan.send(cmd + '\\r')\n",
"self.driver._get_output(chan).AndReturn(expected_output)\n",
"chan.close()\n",
"self.mox.ReplayAll()\n",
"self.assertRaises(processutils.ProcessExecutionError, self.driver.\n _ssh_execute, ssh, cmd)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@VAR_0.route('/', methods=['GET'])...\n",
"VAR_8 = FUNC_2()\n",
"if VAR_8['search'] is None:\n",
"VAR_0 = ProductsRepository.get_products(VAR_8)\n",
"VAR_0 = ProductsRepository.search_products(VAR_8, VAR_8['search'])\n",
"VAR_10 = ProductsRepository.get_total_products(VAR_8)\n",
"VAR_10 = ProductsRepository.get_total_searched_products(VAR_8, VAR_8['search'])\n",
"VAR_9 = ceil(VAR_10 / VAR_8['perPage'])\n",
"return jsonify(VAR_0=products, VAR_10=total_products, VAR_9=total_pages)\n"
] |
[
"@products.route('/', methods=['GET'])...\n",
"filters = get_filters()\n",
"if filters['search'] is None:\n",
"products = ProductsRepository.get_products(filters)\n",
"products = ProductsRepository.search_products(filters, filters['search'])\n",
"total_products = ProductsRepository.get_total_products(filters)\n",
"total_products = ProductsRepository.get_total_searched_products(filters,\n filters['search'])\n",
"total_pages = ceil(total_products / filters['perPage'])\n",
"return jsonify(products=products, total_products=total_products,\n total_pages=total_pages)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_10(self, VAR_16):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_11 = ['volume', 'select', VAR_16['name'], 'show']\n",
"self._eql_execute(*VAR_11)\n",
"if err.stdout.find('does not exist.\\n') > -1:\n",
"VAR_0.debug(_('Volume %s does not exist, it may have already been deleted'),\n VAR_16['name'])\n"
] |
[
"def _check_volume(self, volume):...\n",
"\"\"\"docstring\"\"\"\n",
"command = ['volume', 'select', volume['name'], 'show']\n",
"self._eql_execute(*command)\n",
"if err.stdout.find('does not exist.\\n') > -1:\n",
"LOG.debug(_('Volume %s does not exist, it may have already been deleted'),\n volume['name'])\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_15(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.opt:\n",
"self.parse_args(VAR_16=False)\n",
"VAR_35 = {}\n",
"for VAR_39, VAR_0 in self.opt.items():\n",
"VAR_35[VAR_38(VAR_39)] = VAR_38(VAR_0)\n",
"for group in self._action_groups:\n",
"VAR_40 = {a.dest: getattr(self.args, a.dest, None) for a in group.\n _group_actions}\n",
"VAR_14 = argparse.Namespace(**group_dict)\n",
"VAR_41 = 0\n",
"for VAR_39 in VAR_14.__dict__:\n",
"if VAR_39 in VAR_35:\n",
"if VAR_41 == 0:\n",
"print('[ ' + group.title + ': ] ')\n",
"VAR_41 += 1\n",
"print('[ ' + VAR_39 + ': ' + VAR_35[VAR_39] + ' ]')\n"
] |
[
"def print_args(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.opt:\n",
"self.parse_args(print_args=False)\n",
"values = {}\n",
"for key, value in self.opt.items():\n",
"values[str(key)] = str(value)\n",
"for group in self._action_groups:\n",
"group_dict = {a.dest: getattr(self.args, a.dest, None) for a in group.\n _group_actions}\n",
"namespace = argparse.Namespace(**group_dict)\n",
"count = 0\n",
"for key in namespace.__dict__:\n",
"if key in values:\n",
"if count == 0:\n",
"print('[ ' + group.title + ': ] ')\n",
"count += 1\n",
"print('[ ' + key + ': ' + values[key] + ' ]')\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Assign'",
"For",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Condition",
"Expr'",
"AugAssign'",
"Expr'"
] |
[
"def FUNC_7(VAR_7):...\n",
"\"\"\"docstring\"\"\"\n",
"@wraps(VAR_7)...\n",
"return VAR_7(*VAR_8, **kwargs)\n",
"current_app.logger.warning(e.message, exc_info=True)\n",
"return FUNC_16\n",
"return FUNC_15(e.remote, e.response, e.code, e.uri, e.description)\n"
] |
[
"def oauth_error_handler(f):...\n",
"\"\"\"docstring\"\"\"\n",
"@wraps(f)...\n",
"return f(*args, **kwargs)\n",
"current_app.logger.warning(e.message, exc_info=True)\n",
"return inner\n",
"return oauth2_handle_error(e.remote, e.response, e.code, e.uri, e.description)\n"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Expr'",
"Return'",
"Return'"
] |
[
"def FUNC_4(VAR_4, VAR_5):...\n",
"print(VAR_1)\n",
"VAR_12 = VAR_1[0]\n",
"print(VAR_12)\n",
"print(VAR_4)\n",
"for dev in VAR_1:\n",
"for ap in dev.AccessPoints:\n",
"print(VAR_26)\n",
"if ap.Ssid == VAR_4:\n",
"VAR_13 = {'802-11-wireless': {'security': '802-11-wireless-security'},\n '802-11-wireless-security': {'key-mgmt': 'wpa-psk', 'psk': VAR_5}}\n",
"VAR_26 = ap\n",
"VAR_14 = VAR_0.AddAndActivateConnection(VAR_13, VAR_12, VAR_26)\n"
] |
[
"def add_newWifiConn(wifiname, wifipass):...\n",
"print(wlans)\n",
"wlan0 = wlans[0]\n",
"print(wlan0)\n",
"print(wifiname)\n",
"for dev in wlans:\n",
"for ap in dev.AccessPoints:\n",
"print(currentwifi)\n",
"if ap.Ssid == wifiname:\n",
"params = {'802-11-wireless': {'security': '802-11-wireless-security'},\n '802-11-wireless-security': {'key-mgmt': 'wpa-psk', 'psk': wifipass}}\n",
"currentwifi = ap\n",
"conn = nm.AddAndActivateConnection(params, wlan0, currentwifi)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"For",
"For",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self.config.get(self.section, 'default_scoped_affiliation')\n"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self.config.get(self.section, 'default_scoped_affiliation')\n"
] |
[
0,
0,
0
] |
[
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_3(VAR_0, VAR_1, VAR_2):...\n",
"VAR_1['VMWARE_USER'] = VAR_0.get_input('username', default='')\n",
"VAR_1['VMWARE_PASSWORD'] = VAR_0.get_input('password', default='')\n",
"VAR_1['VMWARE_HOST'] = VAR_0.get_input('host', default='')\n",
"VAR_1['VMWARE_VALIDATE_CERTS'] = str(settings.VMWARE_VALIDATE_CERTS)\n"
] |
[
"def vmware(cred, env, private_data_dir):...\n",
"env['VMWARE_USER'] = cred.get_input('username', default='')\n",
"env['VMWARE_PASSWORD'] = cred.get_input('password', default='')\n",
"env['VMWARE_HOST'] = cred.get_input('host', default='')\n",
"env['VMWARE_VALIDATE_CERTS'] = str(settings.VMWARE_VALIDATE_CERTS)\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_1 and not VAR_2:\n",
"VAR_8 = []\n",
"for taken_dir in VAR_1:\n",
"if isinstance(taken_dir, tuple):\n",
"VAR_1 = VAR_8\n",
"VAR_8.append(taken_dir[0])\n",
"VAR_8.append(taken_dir)\n",
"if not VAR_3:\n",
"VAR_3 = AnalysisController.get_report(VAR_0)\n",
"VAR_3 = VAR_3['analysis']\n",
"VAR_5 = VAR_3['info']['analysis_path']\n",
"VAR_9 = io.BytesIO()\n",
"VAR_10 = zipfile.ZipFile(VAR_9, 'w', zipfile.ZIP_DEFLATED, allowZip64=True)\n",
"for dirpath, dirnames, filenames in os.walk(VAR_5):\n",
"if os.path.basename(dirpath) == VAR_0:\n",
"VAR_11 = {'action': VAR_3.get('debug', {}).get('action', []), 'errors':\n VAR_3.get('debug', {}).get('errors', [])}\n",
"for filename in filenames:\n",
"if os.path.basename(dirpath) in VAR_1:\n",
"VAR_10.writestr('analysis.json', json.dumps(VAR_11, indent=4, default=\n json_default))\n",
"if filename in VAR_2:\n",
"for filename in filenames:\n",
"VAR_10.close()\n",
"VAR_10.write(os.path.join(dirpath, filename), filename)\n",
"VAR_10.write(os.path.join(dirpath, filename), os.path.join(os.path.basename\n (dirpath), filename))\n",
"return VAR_9\n"
] |
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"if not taken_dirs and not taken_files:\n",
"taken_dirs_tmp = []\n",
"for taken_dir in taken_dirs:\n",
"if isinstance(taken_dir, tuple):\n",
"taken_dirs = taken_dirs_tmp\n",
"taken_dirs_tmp.append(taken_dir[0])\n",
"taken_dirs_tmp.append(taken_dir)\n",
"if not report:\n",
"report = AnalysisController.get_report(task_id)\n",
"report = report['analysis']\n",
"path = report['info']['analysis_path']\n",
"f = io.BytesIO()\n",
"z = zipfile.ZipFile(f, 'w', zipfile.ZIP_DEFLATED, allowZip64=True)\n",
"for dirpath, dirnames, filenames in os.walk(path):\n",
"if os.path.basename(dirpath) == task_id:\n",
"obj = {'action': report.get('debug', {}).get('action', []), 'errors':\n report.get('debug', {}).get('errors', [])}\n",
"for filename in filenames:\n",
"if os.path.basename(dirpath) in taken_dirs:\n",
"z.writestr('analysis.json', json.dumps(obj, indent=4, default=json_default))\n",
"if filename in taken_files:\n",
"for filename in filenames:\n",
"z.close()\n",
"z.write(os.path.join(dirpath, filename), filename)\n",
"z.write(os.path.join(dirpath, filename), os.path.join(os.path.basename(\n dirpath), filename))\n",
"return f\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
] |
[
"Condition",
"Docstring",
"Condition",
"Assign'",
"For",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Assign'",
"For",
"Condition",
"Expr'",
"Condition",
"For",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"print('TOTAL: %5d' % self.total, file=sys.stderr)\n",
"print('SUCCESS: %5d' % self.success, file=sys.stderr)\n",
"print('FAIL: %5d' % self.failure, file=sys.stderr)\n",
"print('ERROR: %5d' % self.error, file=sys.stderr)\n",
"print('UNDECIDED: %5d' % self.undecided, file=sys.stderr)\n",
"print('Total time: %7.3f' % self.total_time, file=sys.stderr)\n",
"print('Average time: %7.3f' % (self.total_time / self.total), file=sys.stderr)\n",
"print('Max time: %7.3f' % self.max_time, file=sys.stderr)\n"
] |
[
"def print_stats(self):...\n",
"print('TOTAL: %5d' % self.total, file=sys.stderr)\n",
"print('SUCCESS: %5d' % self.success, file=sys.stderr)\n",
"print('FAIL: %5d' % self.failure, file=sys.stderr)\n",
"print('ERROR: %5d' % self.error, file=sys.stderr)\n",
"print('UNDECIDED: %5d' % self.undecided, file=sys.stderr)\n",
"print('Total time: %7.3f' % self.total_time, file=sys.stderr)\n",
"print('Average time: %7.3f' % (self.total_time / self.total), file=sys.stderr)\n",
"print('Max time: %7.3f' % self.max_time, file=sys.stderr)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_4():...\n",
"def FUNC_7(VAR_6):...\n",
"return 'dir2' not in VAR_6\n"
] |
[
"def test_it_filters_on_directories():...\n",
"def directory_filter(path):...\n",
"return 'dir2' not in path\n"
] |
[
0,
0,
1
] |
[
"FunctionDef'",
"FunctionDef'",
"Return'"
] |
[
"async def FUNC_0(VAR_6):...\n",
"return response.text('')\n"
] |
[
"async def favicon(request):...\n",
"return response.text('')\n"
] |
[
0,
0
] |
[
"AsyncFunctionDef'",
"Return'"
] |
[
"def FUNC_4(self, VAR_10):...\n",
"VAR_16 = VAR_10.get_base_urls()\n",
"VAR_17 = VAR_10.get_users()\n",
"VAR_8 = VAR_10.get_name()\n",
"VAR_3.info('found the following users for scene {}: {}'.format(VAR_8, VAR_17))\n",
"for user in VAR_17:\n",
"VAR_11 = \"SELECT * FROM user_analyzed WHERE user='{}';\".format(user)\n",
"for base_url in VAR_16:\n",
"VAR_23 = self.db.exec(VAR_11)\n",
"VAR_3.info('About to start this analysis thread for scene {}'.format(VAR_10\n .get_name()))\n",
"if not VAR_0 and VAR_2:\n",
"if len(VAR_23) > 0:\n",
"VAR_11 = \"SELECT first,last FROM valids WHERE base_url = '\" + str(base_url\n ) + \"';\"\n",
"tweet('About to start ranking for scene {}'.format(VAR_8))\n",
"self.data_processor.check_and_update_ranks(VAR_8)\n",
"VAR_27 = bracket_utils.get_brackets_from_user(user, pages=1)\n",
"VAR_28 = bracket_utils.get_brackets_from_user(user)\n",
"VAR_24 = self.db.exec(VAR_11)\n",
"for VAR_32 in VAR_27:\n",
"for url in VAR_28:\n",
"VAR_25 = len(VAR_24) > 0\n",
"VAR_3.info('here are the brackets from the most recent page of user {}: {}'\n .format(user, VAR_27))\n",
"VAR_3.info('found this url from a user: {} {}'.format(url, user))\n",
"VAR_3.info('done with user {}'.format(user))\n",
"if VAR_25:\n",
"VAR_11 = \"SELECT * FROM user_analyzed WHERE url='{}' AND user='{}';\".format(\n VAR_32, user)\n",
"VAR_26 = bracket_utils.get_display_base(url)\n",
"VAR_3.info('validURLs found values in the database' + str(VAR_24))\n",
"VAR_29 = bracket_utils._get_first_valid_url(base_url)\n",
"VAR_23 = self.db.exec(VAR_11)\n",
"if 'doubles' in VAR_26.lower() or 'dubs' in VAR_26.lower():\n",
"VAR_29 = VAR_24[0][0]\n",
"VAR_30 = bracket_utils._get_last_valid_url(base_url, VAR_29)\n",
"if len(VAR_23) == 0:\n",
"VAR_3.info(\n 'We are skipping the tournament {} because it is a doubles tournament'.\n format(VAR_26))\n",
"self.data_processor.process(url, VAR_8, VAR_26)\n",
"VAR_30 = VAR_24[0][1]\n",
"VAR_11 = 'INSERT INTO valids (base_url, first, last, scene) VALUES ('\n",
"VAR_3.info('found this url from a user: {} {}'.format(VAR_32, user))\n",
"VAR_3.info('url {} is not new for user {}'.format(VAR_32, user))\n",
"VAR_11 = (\n \"INSERT INTO user_analyzed (url, user, scene) VALUES ('{}', '{}', '{}');\"\n .format(url, user, VAR_8))\n",
"VAR_31 = bracket_utils._get_last_valid_url(base_url, VAR_30 - 1)\n",
"VAR_11 += \"'\" + str(base_url) + \"', \" + str(VAR_29) + ', ' + str(VAR_30\n ) + \", '\" + str(VAR_8) + \"');\"\n",
"VAR_26 = bracket_utils.get_display_base(VAR_32)\n",
"self.db.exec(VAR_11)\n",
"if not VAR_31 == VAR_30:\n",
"self.db.exec(VAR_11)\n",
"if 'doubles' in VAR_26.lower() or 'dubs' in VAR_26.lower():\n",
"if VAR_31 - VAR_30 > 5:\n",
"for i in range(VAR_29, VAR_30 + 1):\n",
"VAR_3.info(\n 'We are skipping the tournament {} because it is a doubles tournament'.\n format(VAR_26))\n",
"self.data_processor.process(VAR_32, VAR_8, VAR_26)\n",
"f.write(\n '[validURLs.py:55]: found a SHIT TON of new tournaments for bracket: {}'\n .format(base_url))\n",
"VAR_32 = base_url.replace('###', str(VAR_31))\n",
"VAR_32 = base_url.replace('###', str(i))\n",
"VAR_11 = (\n \"INSERT INTO user_analyzed (url, user, scene) VALUES ('{}', '{}', '{}');\"\n .format(VAR_32, user, VAR_8))\n",
"VAR_11 = 'UPDATE valids SET last=' + str(VAR_31) + \" where base_url = '\" + str(\n base_url) + \"';\"\n",
"VAR_3.info('Found new bracket: {}'.format(VAR_32))\n",
"VAR_26 = bracket_utils.get_display_base(VAR_32, counter=i)\n",
"self.db.exec(VAR_11)\n",
"self.db.exec(VAR_11)\n",
"VAR_33 = 'Found new bracket: {}'.format(VAR_32)\n",
"if 'doubles' in VAR_26.lower() or 'dubs' in VAR_26.lower():\n",
"VAR_33 = 'Found new {} bracket: {}'.format(VAR_8, VAR_32)\n",
"for i in range(VAR_30 + 1, VAR_31 + 1):\n",
"tweet(VAR_33)\n",
"VAR_3.info(\n 'We are skipping the tournament {} because it is a doubles tournament'.\n format(VAR_26))\n",
"self.data_processor.process(VAR_32, VAR_8, VAR_26)\n",
"tweet(VAR_33)\n",
"VAR_32 = base_url.replace('###', str(i))\n",
"VAR_26 = bracket_utils.get_display_base(VAR_32, counter=i)\n",
"if 'doubles' in VAR_26.lower() or 'dubs' in VAR_26.lower():\n",
"VAR_3.info(\n 'We are skipping the tournament {} because it is a doubles tournament'.\n format(VAR_26))\n",
"self.data_processor.process(VAR_32, VAR_8, VAR_26, new_bracket=True)\n"
] |
[
"def analyze_scene(self, scene):...\n",
"base_urls = scene.get_base_urls()\n",
"users = scene.get_users()\n",
"name = scene.get_name()\n",
"LOG.info('found the following users for scene {}: {}'.format(name, users))\n",
"for user in users:\n",
"sql = \"SELECT * FROM user_analyzed WHERE user='{}';\".format(user)\n",
"for base_url in base_urls:\n",
"results = self.db.exec(sql)\n",
"LOG.info('About to start this analysis thread for scene {}'.format(scene.\n get_name()))\n",
"if not analyzed_scenes and should_tweet:\n",
"if len(results) > 0:\n",
"sql = \"SELECT first,last FROM valids WHERE base_url = '\" + str(base_url) + \"';\"\n",
"tweet('About to start ranking for scene {}'.format(name))\n",
"self.data_processor.check_and_update_ranks(name)\n",
"most_recent_page = bracket_utils.get_brackets_from_user(user, pages=1)\n",
"user_urls = bracket_utils.get_brackets_from_user(user)\n",
"result = self.db.exec(sql)\n",
"for bracket in most_recent_page:\n",
"for url in user_urls:\n",
"has_results = len(result) > 0\n",
"LOG.info('here are the brackets from the most recent page of user {}: {}'.\n format(user, most_recent_page))\n",
"LOG.info('found this url from a user: {} {}'.format(url, user))\n",
"LOG.info('done with user {}'.format(user))\n",
"if has_results:\n",
"sql = \"SELECT * FROM user_analyzed WHERE url='{}' AND user='{}';\".format(\n bracket, user)\n",
"display_name = bracket_utils.get_display_base(url)\n",
"LOG.info('validURLs found values in the database' + str(result))\n",
"first = bracket_utils._get_first_valid_url(base_url)\n",
"results = self.db.exec(sql)\n",
"if 'doubles' in display_name.lower() or 'dubs' in display_name.lower():\n",
"first = result[0][0]\n",
"last = bracket_utils._get_last_valid_url(base_url, first)\n",
"if len(results) == 0:\n",
"LOG.info('We are skipping the tournament {} because it is a doubles tournament'\n .format(display_name))\n",
"self.data_processor.process(url, name, display_name)\n",
"last = result[0][1]\n",
"sql = 'INSERT INTO valids (base_url, first, last, scene) VALUES ('\n",
"LOG.info('found this url from a user: {} {}'.format(bracket, user))\n",
"LOG.info('url {} is not new for user {}'.format(bracket, user))\n",
"sql = (\n \"INSERT INTO user_analyzed (url, user, scene) VALUES ('{}', '{}', '{}');\"\n .format(url, user, name))\n",
"new_last = bracket_utils._get_last_valid_url(base_url, last - 1)\n",
"sql += \"'\" + str(base_url) + \"', \" + str(first) + ', ' + str(last\n ) + \", '\" + str(name) + \"');\"\n",
"display_name = bracket_utils.get_display_base(bracket)\n",
"self.db.exec(sql)\n",
"if not new_last == last:\n",
"self.db.exec(sql)\n",
"if 'doubles' in display_name.lower() or 'dubs' in display_name.lower():\n",
"if new_last - last > 5:\n",
"for i in range(first, last + 1):\n",
"LOG.info('We are skipping the tournament {} because it is a doubles tournament'\n .format(display_name))\n",
"self.data_processor.process(bracket, name, display_name)\n",
"f.write(\n '[validURLs.py:55]: found a SHIT TON of new tournaments for bracket: {}'\n .format(base_url))\n",
"bracket = base_url.replace('###', str(new_last))\n",
"bracket = base_url.replace('###', str(i))\n",
"sql = (\n \"INSERT INTO user_analyzed (url, user, scene) VALUES ('{}', '{}', '{}');\"\n .format(bracket, user, name))\n",
"sql = 'UPDATE valids SET last=' + str(new_last) + \" where base_url = '\" + str(\n base_url) + \"';\"\n",
"LOG.info('Found new bracket: {}'.format(bracket))\n",
"display_name = bracket_utils.get_display_base(bracket, counter=i)\n",
"self.db.exec(sql)\n",
"self.db.exec(sql)\n",
"msg = 'Found new bracket: {}'.format(bracket)\n",
"if 'doubles' in display_name.lower() or 'dubs' in display_name.lower():\n",
"msg = 'Found new {} bracket: {}'.format(name, bracket)\n",
"for i in range(last + 1, new_last + 1):\n",
"tweet(msg)\n",
"LOG.info('We are skipping the tournament {} because it is a doubles tournament'\n .format(display_name))\n",
"self.data_processor.process(bracket, name, display_name)\n",
"tweet(msg)\n",
"bracket = base_url.replace('###', str(i))\n",
"display_name = bracket_utils.get_display_base(bracket, counter=i)\n",
"if 'doubles' in display_name.lower() or 'dubs' in display_name.lower():\n",
"LOG.info('We are skipping the tournament {} because it is a doubles tournament'\n .format(display_name))\n",
"self.data_processor.process(bracket, name, display_name, new_bracket=True)\n"
] |
[
0,
0,
0,
0,
0,
0,
4,
0,
4,
0,
0,
0,
4,
0,
0,
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
0,
0,
4,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
4,
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"For",
"Assign'",
"For",
"Assign'",
"Expr'",
"Condition",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"For",
"For",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"AugAssign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Condition",
"For",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"For",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_10(self):...\n",
"VAR_2 = EngineAuthRequest.blank('/auth/google')\n",
"VAR_2._load_session()\n",
"VAR_2.set_redirect_uri()\n",
"VAR_2._config = {'success_uri': '/callback'}\n",
"VAR_19 = VAR_2.get_redirect_uri()\n",
"self.assertEqual(VAR_19, '/callback')\n",
"VAR_2 = EngineAuthRequest.blank('/auth/google?next=/newcallback')\n",
"VAR_2._load_session()\n",
"VAR_2.set_redirect_uri()\n",
"VAR_2._config = {'success_uri': '/callback'}\n",
"VAR_19 = VAR_2.get_redirect_uri()\n",
"self.assertEqual(VAR_19, '/newcallback')\n",
"VAR_2 = EngineAuthRequest.blank('/auth/google?next=/newcallback&a=121&123=a')\n",
"VAR_2._load_session()\n",
"VAR_2.set_redirect_uri()\n",
"VAR_2._config = {'success_uri': '/callback'}\n",
"VAR_19 = VAR_2.get_redirect_uri()\n",
"self.assertEqual(VAR_19, '/newcallback')\n"
] |
[
"def test_set_redirect_uri(self):...\n",
"req = EngineAuthRequest.blank('/auth/google')\n",
"req._load_session()\n",
"req.set_redirect_uri()\n",
"req._config = {'success_uri': '/callback'}\n",
"redirect_uri = req.get_redirect_uri()\n",
"self.assertEqual(redirect_uri, '/callback')\n",
"req = EngineAuthRequest.blank('/auth/google?next=/newcallback')\n",
"req._load_session()\n",
"req.set_redirect_uri()\n",
"req._config = {'success_uri': '/callback'}\n",
"redirect_uri = req.get_redirect_uri()\n",
"self.assertEqual(redirect_uri, '/newcallback')\n",
"req = EngineAuthRequest.blank('/auth/google?next=/newcallback&a=121&123=a')\n",
"req._load_session()\n",
"req.set_redirect_uri()\n",
"req._config = {'success_uri': '/callback'}\n",
"redirect_uri = req.get_redirect_uri()\n",
"self.assertEqual(redirect_uri, '/newcallback')\n"
] |
[
0,
0,
0,
6,
6,
6,
6,
6,
0,
0,
0,
0,
6,
6,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_4(VAR_0):...\n",
"VAR_0.clear_filters()\n",
"for arg in request.args:\n",
"VAR_8 = re.findall('_flt_(\\\\d)_(.*)', arg)\n",
"if VAR_8:\n",
"VAR_0.add_filter_index(VAR_8[0][1], int(VAR_8[0][0]), request.args.get(arg))\n"
] |
[
"def get_filter_args(filters):...\n",
"filters.clear_filters()\n",
"for arg in request.args:\n",
"re_match = re.findall('_flt_(\\\\d)_(.*)', arg)\n",
"if re_match:\n",
"filters.add_filter_index(re_match[0][1], int(re_match[0][0]), request.args.\n get(arg))\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"For",
"Assign'",
"Condition",
"Expr'"
] |
[
"def FUNC_15(self):...\n",
"self._test_strtype('text', None, 100)\n"
] |
[
"def test_text_null(self):...\n",
"self._test_strtype('text', None, 100)\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Expr'"
] |
[
"@tornado.web.asynchronous...\n",
"VAR_6 = tornado.concurrent.Future()\n",
"def FUNC_6(VAR_12, VAR_2, VAR_5):...\n",
"VAR_26 = VAR_12.request.body\n",
"VAR_2 = FUNC_1(VAR_2)\n",
"def FUNC_8(VAR_4):...\n",
"if not os.path.exists('D:' + VAR_4):\n",
"return VAR_4\n",
"VAR_28 = 1\n",
"while VAR_28 < 101:\n",
"VAR_32 = re.sub('\\\\.(.*?)$', ' (%d).\\\\1' % VAR_28, VAR_4)\n",
"return ''\n",
"if not os.path.exists('D:' + VAR_32):\n",
"return VAR_32\n",
"VAR_28 = VAR_28 + 1\n"
] |
[
"@tornado.web.asynchronous...\n",
"future = tornado.concurrent.Future()\n",
"def save_file_async(alter_ego, target_path, file_name):...\n",
"upload_data = alter_ego.request.body\n",
"target_path = decode_hexed_b64_to_str(target_path)\n",
"def get_non_duplicate_path(file_path):...\n",
"if not os.path.exists('D:' + file_path):\n",
"return file_path\n",
"duplicate = 1\n",
"while duplicate < 101:\n",
"new_path = re.sub('\\\\.(.*?)$', ' (%d).\\\\1' % duplicate, file_path)\n",
"return ''\n",
"if not os.path.exists('D:' + new_path):\n",
"return new_path\n",
"duplicate = duplicate + 1\n"
] |
[
0,
0,
0,
0,
0,
0,
4,
4,
4,
4,
4,
4,
4,
4,
4
] |
[
"Condition",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Condition",
"Return'",
"Assign'"
] |
[
"@VAR_0.filter...\n",
"return VAR_4['publish'] <= VAR_5\n"
] |
[
"@register.filter...\n",
"return entry['publish'] <= now\n"
] |
[
0,
0
] |
[
"Condition",
"Return'"
] |
[
"def FUNC_8(self, VAR_6):...\n",
"\"\"\"docstring\"\"\"\n",
"def __init__(self, VAR_15):...\n",
"self._store = []\n",
"self._ds = VAR_15\n",
"def FUNC_13(self, VAR_16):...\n",
"return VAR_6 in VAR_16.bookmarks\n"
] |
[
"def get_bookmark_parameters(self, bookmark):...\n",
"\"\"\"docstring\"\"\"\n",
"def __init__(self, dirstructure):...\n",
"self._store = []\n",
"self._ds = dirstructure\n",
"def does_intersect_rule(self, rulectx):...\n",
"return bookmark in rulectx.bookmarks\n"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"FunctionDef'",
"Assign'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_6(VAR_20):...\n",
"VAR_29 = bisect(VAR_7, int(time.time()) - VAR_12)\n",
"for expired_reporter in range(VAR_29):\n",
"VAR_5.pop(expired_reporter)\n",
"VAR_7 = VAR_7[VAR_29:]\n",
"VAR_6 = VAR_6[VAR_29:]\n",
"VAR_30 = VAR_20 in VAR_5\n",
"logging.info('is_recent_reporter: %d returns %r', VAR_20, VAR_30)\n",
"return VAR_30\n"
] |
[
"def is_recent_reporter(sender_id):...\n",
"least_recent_index = bisect(last_submitted_times, int(time.time()) -\n report_cooldown)\n",
"for expired_reporter in range(least_recent_index):\n",
"reporters_dict.pop(expired_reporter)\n",
"last_submitted_times = last_submitted_times[least_recent_index:]\n",
"reporters_list = reporters_list[least_recent_index:]\n",
"is_recent = sender_id in reporters_dict\n",
"logging.info('is_recent_reporter: %d returns %r', sender_id, is_recent)\n",
"return is_recent\n"
] |
[
0,
0,
4,
4,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"For",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_14(self):...\n",
"VAR_16 = 3\n",
"VAR_17 = scrape(limit=test_limit, test=True, since='week_ago')\n",
"self.assertEqual(len(VAR_17), VAR_16)\n",
"VAR_18 = 'SELECT * FROM df_dilfo WHERE closed=0 LIMIT 1'\n",
"VAR_34 = pd.read_sql(VAR_18, conn).iloc[0]\n",
"communicate(VAR_17, VAR_34, test=True)\n"
] |
[
"def test_scarpe_to_communicate(self):...\n",
"test_limit = 3\n",
"web_df = scrape(limit=test_limit, test=True, since='week_ago')\n",
"self.assertEqual(len(web_df), test_limit)\n",
"match_first_query = 'SELECT * FROM df_dilfo WHERE closed=0 LIMIT 1'\n",
"dilfo_row = pd.read_sql(match_first_query, conn).iloc[0]\n",
"communicate(web_df, dilfo_row, test=True)\n"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = self.stdout_interceptor\n",
"VAR_3 = self.stderr_interceptor\n",
"return max([self._last_update_time, VAR_2.last_write_time if VAR_2 else 0, \n VAR_3.last_write_time if VAR_3 else 0])\n"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"stdout = self.stdout_interceptor\n",
"stderr = self.stderr_interceptor\n",
"return max([self._last_update_time, stdout.last_write_time if stdout else 0,\n stderr.last_write_time if stderr else 0])\n"
] |
[
0,
0,
0,
0,
0
] |
[
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Return'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self.config.get(self.section, 'default_eppn_scope')\n"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self.config.get(self.section, 'default_eppn_scope')\n"
] |
[
0,
0,
0
] |
[
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_5(self, VAR_2, VAR_3):...\n",
"self.assertEqual(len(VAR_2.providers), len(VAR_3))\n",
"def FUNC_21(VAR_12, VAR_13):...\n",
"for VAR_7 in VAR_2.providers:\n",
"if VAR_7.id == VAR_12 and VAR_7.url == VAR_13:\n",
"self.fail('Provider: %s not found' % VAR_12)\n",
"return\n",
"for provider_tuple in VAR_3:\n",
"FUNC_21(provider_tuple[0], provider_tuple[1])\n"
] |
[
"def _assert_providers(self, cluster_api, provider_tuples):...\n",
"self.assertEqual(len(cluster_api.providers), len(provider_tuples))\n",
"def _assert_provider(pid, purl):...\n",
"for provider in cluster_api.providers:\n",
"if provider.id == pid and provider.url == purl:\n",
"self.fail('Provider: %s not found' % pid)\n",
"return\n",
"for provider_tuple in provider_tuples:\n",
"_assert_provider(provider_tuple[0], provider_tuple[1])\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"FunctionDef'",
"For",
"Condition",
"Expr'",
"Return'",
"For",
"Expr'"
] |
[
"def FUNC_5(VAR_11):...\n",
""
] |
[
"def delete_expense(txn_id):...\n",
""
] |
[
0,
0
] |
[
"FunctionDef'",
"Condition"
] |
[
"def __str__(self):...\n",
"VAR_23 = 'BDI3000 at ' + self.options.debugger_ip_address + ' port ' + str(self\n .port)\n",
"return VAR_23\n"
] |
[
"def __str__(self):...\n",
"string = 'BDI3000 at ' + self.options.debugger_ip_address + ' port ' + str(self\n .port)\n",
"return string\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def __hash__(self):...\n",
"return hash(self.name)\n"
] |
[
"def __hash__(self):...\n",
"return hash(self.name)\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_38(self, VAR_84):...\n",
"return [VAR_82 for job in VAR_84.jobs for VAR_82 in job.subworkflow_input if\n job.subworkflow_input[VAR_82] is self]\n"
] |
[
"def targets(self, dag):...\n",
"return [f for job in dag.jobs for f in job.subworkflow_input if job.\n subworkflow_input[f] is self]\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"\"\"\"string\"\"\"\n",
"import json\n",
"import mysql.connector as mysql\n",
"import src.settings as conf\n",
"\"\"\"\n MySQL class:\n \tTodas as funções para manipulação do DB\n \"\"\"\n",
"def __init__(self):...\n",
"self.__connection = mysql.connect(**conf.DATABASE)\n",
"self.cursor = self.__connection.cursor()\n",
"def FUNC_0(self, VAR_0):...\n",
"\"\"\"docstring\"\"\"\n",
"self.cursor.execute(VAR_0)\n",
"print('Error: {}'.format(error))\n",
"return self.cursor\n"
] |
[
"\"\"\" mysql File\n\n Arquivo onde se encontra todas as funções para trabalhar com o db\nTodo:\n\n None\n\n\"\"\"\n",
"import json\n",
"import mysql.connector as mysql\n",
"import src.settings as conf\n",
"\"\"\"\n MySQL class:\n \tTodas as funções para manipulação do DB\n \"\"\"\n",
"def __init__(self):...\n",
"self.__connection = mysql.connect(**conf.DATABASE)\n",
"self.cursor = self.__connection.cursor()\n",
"def execute(self, query):...\n",
"\"\"\"docstring\"\"\"\n",
"self.cursor.execute(query)\n",
"print('Error: {}'.format(error))\n",
"return self.cursor\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Expr'",
"Import'",
"Import'",
"Import'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"FunctionDef'",
"Docstring",
"Expr'",
"Expr'",
"Return'"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.