lines
sequencelengths 1
444
| raw_lines
sequencelengths 1
444
| label
sequencelengths 1
444
| type
sequencelengths 1
444
|
---|---|---|---|
[
"def FUNC_10(self, VAR_14):...\n",
"self.lasttok = None\n",
"self.lastid = None\n",
"self.parser.parse(VAR_14, lexer=self.lexer)\n"
] | [
"def parse(self, expr):...\n",
"self.lasttok = None\n",
"self.lastid = None\n",
"self.parser.parse(expr, lexer=self.lexer)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_15(VAR_16):...\n",
"\"\"\"docstring\"\"\"\n",
"if FUNC_12(VAR_16, 'temp'):\n",
"return VAR_19(VAR_16, 'protected')\n"
] | [
"def protected(value):...\n",
"\"\"\"docstring\"\"\"\n",
"if is_flagged(value, 'temp'):\n",
"return flag(value, 'protected')\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'"
] |
[
"def __eq__(self, VAR_35):...\n",
"return self.__class__ == VAR_35.__class__ and self.flattened == VAR_35.flattened and self.type == VAR_35.type\n"
] | [
"def __eq__(self, other):...\n",
"return self.__class__ == other.__class__ and self.flattened == other.flattened and self.type == other.type\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def __init__(self, VAR_2=None, *VAR_3, **VAR_4):...\n",
"super(CLASS_1, self).__init__(*VAR_3, **kwargs)\n",
"self.body = VAR_2\n"
] | [
"def __init__(self, body=None, *args, **kwargs):...\n",
"super(HttpStatus, self).__init__(*args, **kwargs)\n",
"self.body = body\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'"
] |
[
"@require_http_methods(['POST'])...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_16 = BadRequestRateLimiter()\n",
"if VAR_16.is_rate_limit_exceeded(VAR_3):\n",
"VAR_0.warning('Password reset rate limit exceeded')\n",
"VAR_10 = VAR_3.user\n",
"return HttpResponseForbidden()\n",
"VAR_17 = VAR_10.email if VAR_10.is_authenticated() else VAR_3.POST.get('email')\n",
"if VAR_17:\n",
"return HttpResponseBadRequest(_('No email address provided.'))\n",
"request_password_change(VAR_17, VAR_3.is_secure())\n",
"VAR_0.info('Invalid password reset attempt')\n",
"return HttpResponse(status=200)\n",
"VAR_10 = VAR_10 if VAR_10.is_authenticated() else VAR_2.objects.get(VAR_17=\n email)\n",
"VAR_16.tick_bad_request_counter(VAR_3)\n",
"destroy_oauth_tokens(VAR_10)\n"
] | [
"@require_http_methods(['POST'])...\n",
"\"\"\"docstring\"\"\"\n",
"limiter = BadRequestRateLimiter()\n",
"if limiter.is_rate_limit_exceeded(request):\n",
"AUDIT_LOG.warning('Password reset rate limit exceeded')\n",
"user = request.user\n",
"return HttpResponseForbidden()\n",
"email = user.email if user.is_authenticated() else request.POST.get('email')\n",
"if email:\n",
"return HttpResponseBadRequest(_('No email address provided.'))\n",
"request_password_change(email, request.is_secure())\n",
"AUDIT_LOG.info('Invalid password reset attempt')\n",
"return HttpResponse(status=200)\n",
"user = user if user.is_authenticated() else User.objects.get(email=email)\n",
"limiter.tick_bad_request_counter(request)\n",
"destroy_oauth_tokens(user)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Return'",
"Expr'",
"Expr'",
"Return'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_0(VAR_0, VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = {}\n",
"for count in range(0, 50):\n",
"if kb.dbms == 'Oracle' and VAR_0.endswith(' FROM DUAL'):\n",
"return None\n",
"VAR_0 = VAR_0[:-len(' FROM DUAL')]\n",
"if count:\n",
"VAR_0 += ', NULL'\n",
"if kb.dbms == 'Oracle':\n",
"VAR_0 += ' FROM DUAL'\n",
"VAR_5 = agent.postfixQuery(VAR_0, VAR_1)\n",
"VAR_6 = agent.payload(newValue=commentedQuery)\n",
"VAR_7 = Request.queryPage(VAR_6)\n",
"if not VAR_7 in VAR_2.keys():\n",
"VAR_2[VAR_7] = 1, VAR_5\n",
"VAR_2[VAR_7] = VAR_2[VAR_7][0] + 1, VAR_5\n",
"if count:\n",
"for element in VAR_2.values():\n",
"if element[0] == 1:\n",
"if kb.injPlace == 'GET':\n",
"VAR_4 = '%s?%s' % (conf.url, VAR_6)\n",
"if kb.injPlace == 'POST':\n",
"return VAR_4\n",
"VAR_4 = \"URL:\\t'%s'\" % conf.url\n",
"if kb.injPlace == 'Cookie':\n",
"VAR_4 += \"\\nPOST:\\t'%s'\\n\" % VAR_6\n",
"VAR_4 = \"URL:\\t'%s'\" % conf.url\n",
"if kb.injPlace == 'User-Agent':\n",
"VAR_4 += \"\\nCookie:\\t'%s'\\n\" % VAR_6\n",
"VAR_4 = \"URL:\\t\\t'%s'\" % conf.url\n",
"VAR_4 += \"\"\"\nUser-Agent:\t'%s'\n\"\"\" % VAR_6\n"
] | [
"def __effectiveUnionTest(query, comment):...\n",
"\"\"\"docstring\"\"\"\n",
"resultDict = {}\n",
"for count in range(0, 50):\n",
"if kb.dbms == 'Oracle' and query.endswith(' FROM DUAL'):\n",
"return None\n",
"query = query[:-len(' FROM DUAL')]\n",
"if count:\n",
"query += ', NULL'\n",
"if kb.dbms == 'Oracle':\n",
"query += ' FROM DUAL'\n",
"commentedQuery = agent.postfixQuery(query, comment)\n",
"payload = agent.payload(newValue=commentedQuery)\n",
"newResult = Request.queryPage(payload)\n",
"if not newResult in resultDict.keys():\n",
"resultDict[newResult] = 1, commentedQuery\n",
"resultDict[newResult] = resultDict[newResult][0] + 1, commentedQuery\n",
"if count:\n",
"for element in resultDict.values():\n",
"if element[0] == 1:\n",
"if kb.injPlace == 'GET':\n",
"value = '%s?%s' % (conf.url, payload)\n",
"if kb.injPlace == 'POST':\n",
"return value\n",
"value = \"URL:\\t'%s'\" % conf.url\n",
"if kb.injPlace == 'Cookie':\n",
"value += \"\\nPOST:\\t'%s'\\n\" % payload\n",
"value = \"URL:\\t'%s'\" % conf.url\n",
"if kb.injPlace == 'User-Agent':\n",
"value += \"\\nCookie:\\t'%s'\\n\" % payload\n",
"value = \"URL:\\t\\t'%s'\" % conf.url\n",
"value += \"\"\"\nUser-Agent:\t'%s'\n\"\"\" % payload\n"
] | [
0,
0,
0,
0,
0,
0,
0,
2,
0,
0,
0,
0,
0,
2,
0,
0,
0,
0,
2,
2,
0,
2,
0,
0,
0,
0,
2,
0,
0,
2,
0,
2
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"For",
"Condition",
"Return'",
"Assign'",
"Condition",
"AugAssign'",
"Condition",
"AugAssign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"For",
"Condition",
"Condition",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Condition",
"AugAssign'",
"Assign'",
"Condition",
"AugAssign'",
"Assign'",
"AugAssign'"
] |
[
"def FUNC_5():...\n",
"self.set_status(404, 'Not Found')\n",
"self._headers = tornado.httputil.HTTPHeaders()\n",
"self.add_header('Content-Length', '0')\n",
"self.flush()\n",
"return\n"
] | [
"def invoke_404():...\n",
"self.set_status(404, 'Not Found')\n",
"self._headers = tornado.httputil.HTTPHeaders()\n",
"self.add_header('Content-Length', '0')\n",
"self.flush()\n",
"return\n"
] | [
0,
0,
0,
0,
0,
4
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"import datetime\n",
"import MySQLdb\n",
"from backend.SQLConnector import SQLConnector\n",
"VAR_0 = 'transactions'\n",
"def __init__(self, VAR_1, VAR_2, VAR_3):...\n",
"self.project_id = VAR_1\n",
"self.user_id = VAR_2\n",
"self.money = VAR_3\n",
"self.time = datetime.datetime.now().isoformat(' ')\n",
"def FUNC_0(self):...\n",
"VAR_5 = {'id': self.id, 'project_id': self.project_id, 'user_id': self.\n user_id, 'money': self.money, 'time': self.time}\n",
"return VAR_5\n"
] | [
"import datetime\n",
"import MySQLdb\n",
"from backend.SQLConnector import SQLConnector\n",
"TABLE_NAME = 'transactions'\n",
"def __init__(self, project_id, user_id, money):...\n",
"self.project_id = project_id\n",
"self.user_id = user_id\n",
"self.money = money\n",
"self.time = datetime.datetime.now().isoformat(' ')\n",
"def to_json_obj(self):...\n",
"obj = {'id': self.id, 'project_id': self.project_id, 'user_id': self.\n user_id, 'money': self.money, 'time': self.time}\n",
"return obj\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"ImportFrom'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self, *VAR_4, **VAR_5):...\n",
"return self._run_ssh(VAR_4, VAR_14=self.configuration.eqlx_cli_max_retries)\n"
] | [
"def _eql_execute(self, *args, **kwargs):...\n",
"return self._run_ssh(args, attempts=self.configuration.eqlx_cli_max_retries)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_23(self, VAR_29):...\n",
""
] | [
"def is_localhost(self, hostname):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_9(self):...\n",
"return self.graded\n"
] | [
"def is_graded(self):...\n",
"return self.graded\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_5(VAR_6, VAR_9):...\n",
"VAR_10 = get_executing_test()\n",
"VAR_15 = selenium.webdriver.DesiredCapabilities.INTERNETEXPLORER\n",
"VAR_10.webdriver = selenium.webdriver.Remote(VAR_9, desired_capabilities=\n capabilities)\n",
"VAR_10.webdriver.get(VAR_6)\n",
"while VAR_10.webdriver:\n",
"time.sleep(0.1)\n",
"VAR_10.error = 'keyboard interrupt'\n",
"FUNC_6(VAR_10)\n"
] | [
"def start_remote_browser(url, command_executor):...\n",
"test = get_executing_test()\n",
"capabilities = selenium.webdriver.DesiredCapabilities.INTERNETEXPLORER\n",
"test.webdriver = selenium.webdriver.Remote(command_executor,\n desired_capabilities=capabilities)\n",
"test.webdriver.get(url)\n",
"while test.webdriver:\n",
"time.sleep(0.1)\n",
"test.error = 'keyboard interrupt'\n",
"check_is_test_failed(test)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_12(self):...\n",
"return False\n"
] | [
"def _do_search_default_automaton(self):...\n",
"return False\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_16(self, VAR_15):...\n",
"\"\"\"docstring\"\"\"\n",
"for o in self.products:\n",
"if o.match(VAR_15):\n",
"return False\n",
"return True\n"
] | [
"def is_producer(self, requested_output):...\n",
"\"\"\"docstring\"\"\"\n",
"for o in self.products:\n",
"if o.match(requested_output):\n",
"return False\n",
"return True\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"For",
"Condition",
"Return'",
"Return'"
] |
[
"def __init__(self, VAR_0):...\n",
"self.doctype = VAR_0\n",
"self.tables = []\n",
"self.conditions = []\n",
"self.or_conditions = []\n",
"self.fields = None\n",
"self.user = None\n",
"self.ignore_ifnull = False\n",
"self.flags = frappe._dict()\n"
] | [
"def __init__(self, doctype):...\n",
"self.doctype = doctype\n",
"self.tables = []\n",
"self.conditions = []\n",
"self.or_conditions = []\n",
"self.fields = None\n",
"self.user = None\n",
"self.ignore_ifnull = False\n",
"self.flags = frappe._dict()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_6(self, VAR_7):...\n",
"VAR_8 = self.content\n",
"while VAR_8:\n",
"yield VAR_8[:VAR_7]\n",
"VAR_8 = VAR_8[VAR_7:]\n"
] | [
"def iter_content(self, chunk_size):...\n",
"c = self.content\n",
"while c:\n",
"yield c[:chunk_size]\n",
"c = c[chunk_size:]\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Expr'",
"Assign'"
] |
[
"@VAR_11.event...\n",
"print(VAR_0 + 'Bot logged in!')\n"
] | [
"@bot.event...\n",
"print(DISCORD_PREFIX + 'Bot logged in!')\n"
] | [
0,
0
] | [
"Condition",
"Expr'"
] |
[
"def FUNC_2(self, VAR_7, VAR_8=None, VAR_9=False):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = Database().view_submit(VAR_7)\n",
"VAR_15, VAR_16 = [], []\n",
"for VAR_6 in VAR_2.data['data']:\n",
"if VAR_6['type'] == 'file':\n",
"return {'files': VAR_15, 'path': VAR_2.tmp_path}\n",
"VAR_22 = Storage.get_filename_from_path(VAR_6['data'])\n",
"if VAR_6['type'] == 'url':\n",
"VAR_18 = os.path.join(VAR_2.tmp_path, VAR_6['data'])\n",
"VAR_15.append({'filename': VAR_6['data'], 'filepath': '', 'relapath': '',\n 'selected': True, 'size': 0, 'type': 'url', 'package': 'ie', 'extrpath':\n [], 'duplicate': False, 'children': [], 'mime': 'text/html', 'finger':\n {'magic_human': 'url', 'magic': 'url'}})\n",
"VAR_21 = open(VAR_18, 'rb').read()\n",
"VAR_23 = sflock.unpack(VAR_18=filename, contents=filedata, VAR_8=password,\n VAR_16=duplicates)\n",
"if VAR_9:\n",
"VAR_23 = VAR_23.astree()\n",
"VAR_15.append(VAR_23)\n"
] | [
"def get_files(self, submit_id, password=None, astree=False):...\n",
"\"\"\"docstring\"\"\"\n",
"submit = Database().view_submit(submit_id)\n",
"files, duplicates = [], []\n",
"for data in submit.data['data']:\n",
"if data['type'] == 'file':\n",
"return {'files': files, 'path': submit.tmp_path}\n",
"filename = Storage.get_filename_from_path(data['data'])\n",
"if data['type'] == 'url':\n",
"filepath = os.path.join(submit.tmp_path, data['data'])\n",
"files.append({'filename': data['data'], 'filepath': '', 'relapath': '',\n 'selected': True, 'size': 0, 'type': 'url', 'package': 'ie', 'extrpath':\n [], 'duplicate': False, 'children': [], 'mime': 'text/html', 'finger':\n {'magic_human': 'url', 'magic': 'url'}})\n",
"filedata = open(filepath, 'rb').read()\n",
"unpacked = sflock.unpack(filepath=filename, contents=filedata, password=\n password, duplicates=duplicates)\n",
"if astree:\n",
"unpacked = unpacked.astree()\n",
"files.append(unpacked)\n"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
1,
1,
0,
1,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"For",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'"
] |
[
"def FUNC_39(VAR_101):...\n",
"VAR_101.output = VAR_69, VAR_70\n",
"return VAR_101\n"
] | [
"def decorate(ruleinfo):...\n",
"ruleinfo.output = paths, kwpaths\n",
"return ruleinfo\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_8(self, VAR_5):...\n",
"VAR_5.setResponseCode(OK)\n",
"return self._render_template(VAR_5)\n"
] | [
"def render_GET(self, request):...\n",
"request.setResponseCode(OK)\n",
"return self._render_template(request)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Return'"
] |
[
"def FUNC_12(VAR_35, VAR_27):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_52 = ''\n",
"for result in VAR_35:\n",
"VAR_80 = VAR_35[result]\n",
"VAR_52 += '\\n--\\n{0}'.format(FUNC_21())\n",
"if VAR_80:\n",
"return VAR_52\n",
"VAR_89 = sorted(VAR_80, key=lambda x: list_result[x], reverse=True)\n",
"VAR_52 += '\\n\\n{0}:\\n'.format(result)\n",
"for element in VAR_89:\n",
"VAR_52 += '\\n{0} {1}'.format(VAR_80[element], element)\n"
] | [
"def _output_text(complete_output, categories):...\n",
"\"\"\"docstring\"\"\"\n",
"output = ''\n",
"for result in complete_output:\n",
"list_result = complete_output[result]\n",
"output += '\\n--\\n{0}'.format(_signature())\n",
"if list_result:\n",
"return output\n",
"list_result_sorted = sorted(list_result, key=lambda x: list_result[x],\n reverse=True)\n",
"output += '\\n\\n{0}:\\n'.format(result)\n",
"for element in list_result_sorted:\n",
"output += '\\n{0} {1}'.format(list_result[element], element)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"For",
"Assign'",
"AugAssign'",
"Condition",
"Return'",
"Assign'",
"AugAssign'",
"For",
"AugAssign'"
] |
[
"@utils.synchronized('3par', external=True)...\n",
"\"\"\"docstring\"\"\"\n",
"self.common.client_login()\n",
"VAR_25 = self._create_host(VAR_7, VAR_10)\n",
"VAR_26 = self.common.create_vlun(VAR_7, VAR_25)\n",
"self.common.client_logout()\n",
"VAR_27 = self._get_iscsi_ip(VAR_25['name'])\n",
"VAR_28 = self.iscsi_ips[VAR_27]['ip_port']\n",
"VAR_29 = self.iscsi_ips[VAR_27]['iqn']\n",
"VAR_30 = {'driver_volume_type': 'iscsi', 'data': {'target_portal': '%s:%s' %\n (VAR_27, VAR_28), 'target_iqn': VAR_29, 'target_lun': VAR_26['lun'],\n 'target_discovered': True}}\n",
"return VAR_30\n"
] | [
"@utils.synchronized('3par', external=True)...\n",
"\"\"\"docstring\"\"\"\n",
"self.common.client_login()\n",
"host = self._create_host(volume, connector)\n",
"vlun = self.common.create_vlun(volume, host)\n",
"self.common.client_logout()\n",
"iscsi_ip = self._get_iscsi_ip(host['name'])\n",
"iscsi_ip_port = self.iscsi_ips[iscsi_ip]['ip_port']\n",
"iscsi_target_iqn = self.iscsi_ips[iscsi_ip]['iqn']\n",
"info = {'driver_volume_type': 'iscsi', 'data': {'target_portal': '%s:%s' %\n (iscsi_ip, iscsi_ip_port), 'target_iqn': iscsi_target_iqn, 'target_lun':\n vlun['lun'], 'target_discovered': True}}\n",
"return info\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_7(self, VAR_4):...\n",
"for VAR_6 in self.actors.keys():\n",
"if 'User Controlled' in self.actors[VAR_6].name:\n",
"self.actors[VAR_6].readKeys(VAR_4)\n"
] | [
"def readKeys(self, keys):...\n",
"for ID in self.actors.keys():\n",
"if 'User Controlled' in self.actors[ID].name:\n",
"self.actors[ID].readKeys(keys)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Condition",
"Expr'"
] |
[
"def FUNC_2(VAR_4, VAR_5):...\n",
"def __init__(self, VAR_13):...\n",
"self.filters = VAR_13\n",
"VAR_8 = CLASS_0(VAR_13=[directory_filter, file_filter])\n",
"VAR_9 = FUNC_1(VAR_1)\n",
"VAR_10 = FileWalker(VAR_8, VAR_1, VAR_9=walk_fn)\n",
"return [f for f in VAR_10.walk()]\n"
] | [
"def _walk(directory_filter, file_filter):...\n",
"def __init__(self, filters):...\n",
"self.filters = filters\n",
"loader = MockLoader(filters=[directory_filter, file_filter])\n",
"walk_fn = create_mock_os_walk(MOCK_START_PATH)\n",
"walker = FileWalker(loader, MOCK_START_PATH, walk_fn=walk_fn)\n",
"return [f for f in walker.walk()]\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_3(self):...\n",
"VAR_1 = list(self.uut.process_output([\n \"Random line that shouldn't be captured\\n\", '*************\\n'],\n 'a/file.py', ['original_file_lines_placeholder']))\n",
"self.assertEqual(len(VAR_1), 0)\n"
] | [
"def test_valid_output(self):...\n",
"out = list(self.uut.process_output([\n \"Random line that shouldn't be captured\\n\", '*************\\n'],\n 'a/file.py', ['original_file_lines_placeholder']))\n",
"self.assertEqual(len(out), 0)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_2(self, VAR_21, VAR_22):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_55 = VAR_21.rstrip('/').split('/')\n",
"if len(VAR_55[0]):\n",
"VAR_22 = [x for x in VAR_22.split('/') if len(x) and x is not None]\n",
"VAR_22, VAR_55 = [], VAR_55[1:]\n",
"VAR_21 = VAR_21[1:]\n",
"VAR_56 = []\n",
"def FUNC_33(VAR_57, VAR_22):...\n",
"if not len(VAR_57):\n",
"VAR_56.append('/%s' % ('/'.join(VAR_22),))\n",
"if VAR_57[0] == '.':\n",
"FUNC_33(VAR_55, VAR_22)\n",
"FUNC_33(VAR_57[1:], VAR_22)\n",
"if VAR_57[0] == '..':\n",
"return VAR_56\n",
"FUNC_33(VAR_57[1:], VAR_22[:-1])\n",
"VAR_65 = [x[VAR_1] for x in self.get_path('/'.join(VAR_22))]\n",
"VAR_74 = [x for x in VAR_65 if fnmatch.fnmatchcase(x, VAR_57[0])]\n",
"for match in VAR_74:\n",
"FUNC_33(VAR_57[1:], VAR_22 + [match])\n"
] | [
"def resolve_path_wc(self, path, cwd):...\n",
"\"\"\"docstring\"\"\"\n",
"pieces = path.rstrip('/').split('/')\n",
"if len(pieces[0]):\n",
"cwd = [x for x in cwd.split('/') if len(x) and x is not None]\n",
"cwd, pieces = [], pieces[1:]\n",
"path = path[1:]\n",
"found = []\n",
"def foo(p, cwd):...\n",
"if not len(p):\n",
"found.append('/%s' % ('/'.join(cwd),))\n",
"if p[0] == '.':\n",
"foo(pieces, cwd)\n",
"foo(p[1:], cwd)\n",
"if p[0] == '..':\n",
"return found\n",
"foo(p[1:], cwd[:-1])\n",
"names = [x[A_NAME] for x in self.get_path('/'.join(cwd))]\n",
"matches = [x for x in names if fnmatch.fnmatchcase(x, p[0])]\n",
"for match in matches:\n",
"foo(p[1:], cwd + [match])\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Return'",
"Expr'",
"Assign'",
"Assign'",
"For",
"Expr'"
] |
[
"def FUNC_26(self, VAR_22):...\n",
"\"\"\"docstring\"\"\"\n",
"return VAR_22 in self.sos_info['enabled']\n"
] | [
"def _check_enabled(self, plugin):...\n",
"\"\"\"docstring\"\"\"\n",
"return plugin in self.sos_info['enabled']\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_25(self):...\n",
"VAR_31 = json.loads(get_user_settings(self.doctype))\n",
"if hasattr(self, 'user_settings'):\n",
"VAR_31.update(self.user_settings)\n",
"if self.save_user_settings_fields:\n",
"VAR_31['fields'] = self.user_settings_fields\n",
"FUNC_25(self.doctype, VAR_31)\n"
] | [
"def update_user_settings(self):...\n",
"user_settings = json.loads(get_user_settings(self.doctype))\n",
"if hasattr(self, 'user_settings'):\n",
"user_settings.update(self.user_settings)\n",
"if self.save_user_settings_fields:\n",
"user_settings['fields'] = self.user_settings_fields\n",
"update_user_settings(self.doctype, user_settings)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Expr'"
] |
[
"def FUNC_15(self):...\n",
"self._omnicomp.OnFileReadyToParse(None)\n",
"if not self._IsServerAlive():\n",
"self._NotifyUserIfServerCrashed()\n",
"VAR_5 = {}\n",
"self._AddTagsFilesIfNeeded(VAR_5)\n",
"self._AddSyntaxDataIfNeeded(VAR_5)\n",
"self._AddExtraConfDataIfNeeded(VAR_5)\n",
"self._latest_file_parse_request = EventNotification('FileReadyToParse', VAR_5)\n",
"self._latest_file_parse_request.Start()\n"
] | [
"def OnFileReadyToParse(self):...\n",
"self._omnicomp.OnFileReadyToParse(None)\n",
"if not self._IsServerAlive():\n",
"self._NotifyUserIfServerCrashed()\n",
"extra_data = {}\n",
"self._AddTagsFilesIfNeeded(extra_data)\n",
"self._AddSyntaxDataIfNeeded(extra_data)\n",
"self._AddExtraConfDataIfNeeded(extra_data)\n",
"self._latest_file_parse_request = EventNotification('FileReadyToParse',\n extra_data)\n",
"self._latest_file_parse_request.Start()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"@wraps(VAR_7)...\n",
"if not app.config.get('USE_AUTH'):\n",
"return VAR_7(*VAR_9, **kwargs)\n",
"VAR_17 = FUNC_8()\n",
"logging.warning('Invalid token version used.')\n",
"if VAR_17:\n",
"return abort(403)\n",
"VAR_2 = 'user'\n",
"if VAR_17['user_type'] not in app.config['KMS_AUTH_USER_TYPES']:\n",
"logging.exception('Failed to decrypt authentication token.')\n",
"logging.error('Ran out of authentication methods')\n",
"if not FUNC_5(VAR_2, VAR_7.func_name):\n",
"VAR_18 = '{0} is not an allowed user type for KMS auth.'\n",
"VAR_19 = keymanager.decrypt_token(VAR_17['version'], VAR_17['user_type'],\n VAR_17['from'], VAR_17['token'])\n",
"VAR_18 = 'Access denied for {0}. Authentication Failed.'\n",
"return abort(403)\n",
"return abort(403)\n",
"if VAR_1.is_expired():\n",
"VAR_18 = VAR_18.format(VAR_17['user_type'])\n",
"logging.debug('Auth request had the following token_data: {0}'.format(VAR_19))\n",
"VAR_18 = VAR_18.format(VAR_17['from'])\n",
"return abort(401)\n",
"if VAR_1.is_authenticated():\n",
"logging.warning(VAR_18)\n",
"VAR_18 = 'Authenticated {0} with user_type {1} via kms auth'\n",
"logging.warning(VAR_18)\n",
"return abort(401)\n",
"VAR_1.check_authorization()\n",
"logging.warning('Not authorized -- ' + e.message)\n",
"VAR_1.set_expiration()\n",
"return abort(403)\n",
"VAR_18 = VAR_18.format(VAR_17['from'], VAR_17['user_type'])\n",
"return abort(403)\n",
"return abort(403)\n",
"g.user_type = VAR_2\n",
"logging.debug(VAR_18)\n",
"g.auth_type = VAR_1.auth_type\n",
"if FUNC_5(VAR_17['user_type'], VAR_7.func_name):\n",
"return VAR_7(*VAR_9, **kwargs)\n",
"g.user_type = VAR_17['user_type']\n",
"VAR_18 = '{0} is not authorized to access {1}.'\n",
"g.auth_type = 'kms'\n",
"VAR_18 = VAR_18.format(VAR_17['from'], VAR_7.func_name)\n",
"g.account = FUNC_4(VAR_19['key_alias'])\n",
"logging.warning(VAR_18)\n",
"g.username = VAR_17['from']\n",
"return abort(403)\n",
"return VAR_7(*VAR_9, **kwargs)\n"
] | [
"@wraps(f)...\n",
"if not app.config.get('USE_AUTH'):\n",
"return f(*args, **kwargs)\n",
"kms_auth_data = _get_kms_auth_data()\n",
"logging.warning('Invalid token version used.')\n",
"if kms_auth_data:\n",
"return abort(403)\n",
"user_type = 'user'\n",
"if kms_auth_data['user_type'] not in app.config['KMS_AUTH_USER_TYPES']:\n",
"logging.exception('Failed to decrypt authentication token.')\n",
"logging.error('Ran out of authentication methods')\n",
"if not user_type_has_privilege(user_type, f.func_name):\n",
"msg = '{0} is not an allowed user type for KMS auth.'\n",
"token_data = keymanager.decrypt_token(kms_auth_data['version'],\n kms_auth_data['user_type'], kms_auth_data['from'], kms_auth_data['token'])\n",
"msg = 'Access denied for {0}. Authentication Failed.'\n",
"return abort(403)\n",
"return abort(403)\n",
"if user_mod.is_expired():\n",
"msg = msg.format(kms_auth_data['user_type'])\n",
"logging.debug('Auth request had the following token_data: {0}'.format(\n token_data))\n",
"msg = msg.format(kms_auth_data['from'])\n",
"return abort(401)\n",
"if user_mod.is_authenticated():\n",
"logging.warning(msg)\n",
"msg = 'Authenticated {0} with user_type {1} via kms auth'\n",
"logging.warning(msg)\n",
"return abort(401)\n",
"user_mod.check_authorization()\n",
"logging.warning('Not authorized -- ' + e.message)\n",
"user_mod.set_expiration()\n",
"return abort(403)\n",
"msg = msg.format(kms_auth_data['from'], kms_auth_data['user_type'])\n",
"return abort(403)\n",
"return abort(403)\n",
"g.user_type = user_type\n",
"logging.debug(msg)\n",
"g.auth_type = user_mod.auth_type\n",
"if user_type_has_privilege(kms_auth_data['user_type'], f.func_name):\n",
"return f(*args, **kwargs)\n",
"g.user_type = kms_auth_data['user_type']\n",
"msg = '{0} is not authorized to access {1}.'\n",
"g.auth_type = 'kms'\n",
"msg = msg.format(kms_auth_data['from'], f.func_name)\n",
"g.account = account_for_key_alias(token_data['key_alias'])\n",
"logging.warning(msg)\n",
"g.username = kms_auth_data['from']\n",
"return abort(403)\n",
"return f(*args, **kwargs)\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
] | [
"Condition",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Return'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Return'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Return'",
"Expr'",
"Expr'",
"Expr'",
"Return'",
"Assign'",
"Return'",
"Return'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'",
"Return'"
] |
[
"def __str__(self):...\n",
"return '|%s|' % self.content\n"
] | [
"def __str__(self):...\n",
"return '|%s|' % self.content\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_9(self):...\n",
"return combine_vars(self.vars, self.get_magic_vars())\n"
] | [
"def get_vars(self):...\n",
"return combine_vars(self.vars, self.get_magic_vars())\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"from __future__ import absolute_import\n",
"from __future__ import print_function\n",
"from __future__ import unicode_literals\n",
"import codecs\n",
"import datetime\n",
"import io\n",
"import os\n",
"import sys\n",
"import time\n",
"import traceback\n",
"import urllib\n",
"import requests\n",
"VAR_0 = False\n",
"def __init__(self):...\n",
"self.xsrf_token = None\n",
"self.session = requests.Session()\n",
"def FUNC_0(self, VAR_1):...\n",
"VAR_15 = self.session.get(VAR_1)\n",
"for cookie in VAR_15.cookies:\n",
"if cookie.name == '_xsrf':\n",
"def FUNC_1(self, VAR_2):...\n",
"self.xsrf_token = cookie.value\n",
"self.read_xsrf_token(VAR_2.base_url)\n",
"VAR_2.execute()\n",
"def FUNC_2(self, VAR_1, VAR_3=None, VAR_4=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_4 is None:\n",
"if VAR_3 is None:\n",
"VAR_3 = VAR_3.copy()\n",
"for fobj in VAR_20.itervalues():\n",
"return VAR_15\n",
"VAR_15 = self.session.get(VAR_1)\n",
"VAR_3 = VAR_3.copy()\n",
"VAR_3['_xsrf'] = self.xsrf_token\n",
"fobj.close()\n",
"VAR_3['_xsrf'] = self.xsrf_token\n",
"VAR_20 = dict((k, io.open(v, 'rb')) for k, v in VAR_4)\n",
"VAR_15 = self.session.post(VAR_1, VAR_3)\n",
"VAR_15 = self.session.post(VAR_1, VAR_3, files=file_objs)\n"
] | [
"from __future__ import absolute_import\n",
"from __future__ import print_function\n",
"from __future__ import unicode_literals\n",
"import codecs\n",
"import datetime\n",
"import io\n",
"import os\n",
"import sys\n",
"import time\n",
"import traceback\n",
"import urllib\n",
"import requests\n",
"debug = False\n",
"def __init__(self):...\n",
"self.xsrf_token = None\n",
"self.session = requests.Session()\n",
"def read_xsrf_token(self, url):...\n",
"response = self.session.get(url)\n",
"for cookie in response.cookies:\n",
"if cookie.name == '_xsrf':\n",
"def login(self, login_request):...\n",
"self.xsrf_token = cookie.value\n",
"self.read_xsrf_token(login_request.base_url)\n",
"login_request.execute()\n",
"def do_request(self, url, data=None, file_names=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if file_names is None:\n",
"if data is None:\n",
"data = data.copy()\n",
"for fobj in file_objs.itervalues():\n",
"return response\n",
"response = self.session.get(url)\n",
"data = data.copy()\n",
"data['_xsrf'] = self.xsrf_token\n",
"fobj.close()\n",
"data['_xsrf'] = self.xsrf_token\n",
"file_objs = dict((k, io.open(v, 'rb')) for k, v in file_names)\n",
"response = self.session.post(url, data)\n",
"response = self.session.post(url, data, files=file_objs)\n"
] | [
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"For",
"Condition",
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"FunctionDef'",
"Docstring",
"Condition",
"Condition",
"Assign'",
"For",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_30(self):...\n",
"VAR_2 = FUNC_0(self.file\n ).st_mode & ~stat.S_IWUSR & ~stat.S_IWGRP & ~stat.S_IWOTH\n",
"if os.path.isdir(self.file):\n",
"for root, dirs, VAR_6 in os.walk(self.file):\n",
"FUNC_2(self.file, VAR_2)\n",
"for d in dirs:\n",
"FUNC_2(os.path.join(self.file, d), VAR_2)\n",
"for VAR_0 in VAR_6:\n",
"FUNC_2(os.path.join(self.file, VAR_0), VAR_2)\n"
] | [
"def protect(self):...\n",
"mode = lstat(self.file).st_mode & ~stat.S_IWUSR & ~stat.S_IWGRP & ~stat.S_IWOTH\n",
"if os.path.isdir(self.file):\n",
"for root, dirs, files in os.walk(self.file):\n",
"lchmod(self.file, mode)\n",
"for d in dirs:\n",
"lchmod(os.path.join(self.file, d), mode)\n",
"for f in files:\n",
"lchmod(os.path.join(self.file, f), mode)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"For",
"Expr'",
"For",
"Expr'",
"For",
"Expr'"
] |
[
"def FUNC_7(VAR_3):...\n",
"if os.path.exists(VAR_3):\n",
"if os.path.isdir(VAR_3):\n",
"os.remove(VAR_3)\n",
"os.removedirs(VAR_3)\n"
] | [
"def remove(file):...\n",
"if os.path.exists(file):\n",
"if os.path.isdir(file):\n",
"os.remove(file)\n",
"os.removedirs(file)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_17(VAR_13):...\n",
"\"\"\"docstring\"\"\"\n",
"return bytes(VAR_13, 'iso-8859-1').decode('utf-8')\n"
] | [
"def utf8_escape(input_string):...\n",
"\"\"\"docstring\"\"\"\n",
"return bytes(input_string, 'iso-8859-1').decode('utf-8')\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def __init__(self):...\n",
"self.content = VAR_2\n"
] | [
"def __init__(self):...\n",
"self.content = content\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"def FUNC_16(self, VAR_35=True):...\n",
"\"\"\"docstring\"\"\"\n",
"self.match_filters = []\n",
"self.match_conditions = []\n",
"VAR_54 = False\n",
"if not self.user:\n",
"self.user = frappe.session.user\n",
"if not self.tables:\n",
"self.extract_tables()\n",
"VAR_1 = frappe.get_meta(self.doctype)\n",
"VAR_55 = frappe.permissions.get_role_permissions(VAR_1, VAR_19=self.user)\n",
"self.shared = frappe.share.get_shared(self.doctype, self.user)\n",
"if not VAR_1.istable and not VAR_55.get('read'\n",
"VAR_54 = True\n",
"if VAR_55.get('apply_user_permissions', {}).get('read'):\n",
"if not self.shared:\n",
"VAR_36 = frappe.permissions.get_user_permissions(self.user)\n",
"if VAR_55.get('if_owner', {}).get('read'):\n",
"frappe.throw(_('No permission to read {0}').format(self.doctype), frappe.\n PermissionError)\n",
"self.conditions.append(self.get_share_condition())\n",
"self.add_user_permissions(VAR_36, VAR_37=role_permissions.get(\n 'user_permission_doctypes').get('read'))\n",
"self.match_conditions.append(\"`tab{0}`.owner = '{1}'\".format(self.doctype,\n frappe.db.escape(self.user, percent=False)))\n",
"if VAR_35:\n",
"VAR_33 = ''\n",
"return self.match_filters\n",
"if self.match_conditions:\n",
"VAR_33 = '((' + ') or ('.join(self.match_conditions) + '))'\n",
"VAR_63 = self.get_permission_query_conditions()\n",
"if VAR_63:\n",
"VAR_33 += ' and ' + VAR_63 if VAR_33 else VAR_63\n",
"if not VAR_54 and self.shared and VAR_33:\n",
"VAR_33 = '({conditions}) or ({shared_condition})'.format(VAR_33=conditions,\n shared_condition=self.get_share_condition())\n",
"return VAR_33\n"
] | [
"def build_match_conditions(self, as_condition=True):...\n",
"\"\"\"docstring\"\"\"\n",
"self.match_filters = []\n",
"self.match_conditions = []\n",
"only_if_shared = False\n",
"if not self.user:\n",
"self.user = frappe.session.user\n",
"if not self.tables:\n",
"self.extract_tables()\n",
"meta = frappe.get_meta(self.doctype)\n",
"role_permissions = frappe.permissions.get_role_permissions(meta, user=self.user\n )\n",
"self.shared = frappe.share.get_shared(self.doctype, self.user)\n",
"if not meta.istable and not role_permissions.get('read'\n",
"only_if_shared = True\n",
"if role_permissions.get('apply_user_permissions', {}).get('read'):\n",
"if not self.shared:\n",
"user_permissions = frappe.permissions.get_user_permissions(self.user)\n",
"if role_permissions.get('if_owner', {}).get('read'):\n",
"frappe.throw(_('No permission to read {0}').format(self.doctype), frappe.\n PermissionError)\n",
"self.conditions.append(self.get_share_condition())\n",
"self.add_user_permissions(user_permissions, user_permission_doctypes=\n role_permissions.get('user_permission_doctypes').get('read'))\n",
"self.match_conditions.append(\"`tab{0}`.owner = '{1}'\".format(self.doctype,\n frappe.db.escape(self.user, percent=False)))\n",
"if as_condition:\n",
"conditions = ''\n",
"return self.match_filters\n",
"if self.match_conditions:\n",
"conditions = '((' + ') or ('.join(self.match_conditions) + '))'\n",
"doctype_conditions = self.get_permission_query_conditions()\n",
"if doctype_conditions:\n",
"conditions += (' and ' + doctype_conditions if conditions else\n doctype_conditions)\n",
"if not only_if_shared and self.shared and conditions:\n",
"conditions = '({conditions}) or ({shared_condition})'.format(conditions=\n conditions, shared_condition=self.get_share_condition())\n",
"return conditions\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"AugAssign'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_5(VAR_4):...\n",
"if isinstance(VAR_4, six.binary_type):\n",
"VAR_4 = six.text_type(VAR_4, 'utf-8', 'ignore')\n",
"VAR_4 = VAR_4.strip()\n",
"VAR_22 = bool(VAR_3.match(VAR_4))\n",
"if VAR_22 and VAR_7.match(VAR_4[-1]):\n",
"return False\n",
"return VAR_22\n"
] | [
"def isSimpleTerm(term):...\n",
"if isinstance(term, six.binary_type):\n",
"term = six.text_type(term, 'utf-8', 'ignore')\n",
"term = term.strip()\n",
"simple = bool(simpleTerm.match(term))\n",
"if simple and is_digit.match(term[-1]):\n",
"return False\n",
"return simple\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_1(self, VAR_0):...\n",
"VAR_7 = 'Blog: ' + VAR_0\n",
"VAR_8 = ContentConverter.getRenderedBody(VAR_0)\n",
"if not VAR_8:\n",
"VAR_8 = \"<p>The post under '{}' does not exist.</p>\".format(VAR_0)\n",
"self.render('templates/BlogPost.html', title=contentTitle, postBody=\n renderedBody)\n"
] | [
"def get(self, request):...\n",
"contentTitle = 'Blog: ' + request\n",
"renderedBody = ContentConverter.getRenderedBody(request)\n",
"if not renderedBody:\n",
"renderedBody = \"<p>The post under '{}' does not exist.</p>\".format(request)\n",
"self.render('templates/BlogPost.html', title=contentTitle, postBody=\n renderedBody)\n"
] | [
0,
5,
5,
0,
5,
5
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'"
] |
[
"@auth.public...\n",
""
] | [
"@auth.public...\n",
""
] | [
0,
0
] | [
"Condition",
"Condition"
] |
[
"def FUNC_15(self):...\n",
"self.run_test_case(self.scenario.register_load_balancer_instances())\n"
] | [
"def test_c_register_load_balancer_instances(self):...\n",
"self.run_test_case(self.scenario.register_load_balancer_instances())\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"VAR_1 = 'cmd'\n",
"self.assertEqual(escape_path_argument('C:\\\\Windows\\\\has-a-weird-shell.txt',\n VAR_1), '\"C:\\\\Windows\\\\has-a-weird-shell.txt\"')\n",
"self.assertEqual(escape_path_argument('C:\\\\Windows\\\\lolrofl\\\\dirs\\\\', VAR_1\n ), '\"C:\\\\Windows\\\\lolrofl\\\\dirs\\\\\"')\n",
"self.assertEqual(escape_path_argument('X:\\\\Users\\\\Maito Gai\\\\fi le.exe',\n VAR_1), '\"X:\\\\Users\\\\Maito Gai\\\\fi le.exe\"')\n",
"self.assertEqual(escape_path_argument('X:\\\\Users\\\\Mai to Gai\\\\director y\\\\',\n VAR_1), '\"X:\\\\Users\\\\Mai to Gai\\\\director y\\\\\"')\n",
"self.assertEqual(escape_path_argument(\n 'X:\\\\Users\\\\Maito Gai\\\\\"seven-gates\".y', VAR_1),\n '\"X:\\\\Users\\\\Maito Gai\\\\^\"seven-gates^\".y\"')\n",
"self.assertEqual(escape_path_argument('System32\\\\my-custom relative tool\\\\',\n VAR_1), '\"System32\\\\my-custom relative tool\\\\\"')\n",
"self.assertEqual(escape_path_argument('System32\\\\illegal\" name \"\".curd',\n VAR_1), '\"System32\\\\illegal^\" name ^\"^\".curd\"')\n"
] | [
"def test_escape_path_argument_cmd(self):...\n",
"_type = 'cmd'\n",
"self.assertEqual(escape_path_argument('C:\\\\Windows\\\\has-a-weird-shell.txt',\n _type), '\"C:\\\\Windows\\\\has-a-weird-shell.txt\"')\n",
"self.assertEqual(escape_path_argument('C:\\\\Windows\\\\lolrofl\\\\dirs\\\\', _type\n ), '\"C:\\\\Windows\\\\lolrofl\\\\dirs\\\\\"')\n",
"self.assertEqual(escape_path_argument('X:\\\\Users\\\\Maito Gai\\\\fi le.exe',\n _type), '\"X:\\\\Users\\\\Maito Gai\\\\fi le.exe\"')\n",
"self.assertEqual(escape_path_argument('X:\\\\Users\\\\Mai to Gai\\\\director y\\\\',\n _type), '\"X:\\\\Users\\\\Mai to Gai\\\\director y\\\\\"')\n",
"self.assertEqual(escape_path_argument(\n 'X:\\\\Users\\\\Maito Gai\\\\\"seven-gates\".y', _type),\n '\"X:\\\\Users\\\\Maito Gai\\\\^\"seven-gates^\".y\"')\n",
"self.assertEqual(escape_path_argument('System32\\\\my-custom relative tool\\\\',\n _type), '\"System32\\\\my-custom relative tool\\\\\"')\n",
"self.assertEqual(escape_path_argument('System32\\\\illegal\" name \"\".curd',\n _type), '\"System32\\\\illegal^\" name ^\"^\".curd\"')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def __hash__(self):...\n",
"return self._file.__hash__()\n"
] | [
"def __hash__(self):...\n",
"return self._file.__hash__()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_3(self):...\n",
"return self.name\n"
] | [
"def get_name(self):...\n",
"return self.name\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_42():...\n",
"print('PAGE {}'.format(VAR_100))\n",
"VAR_117 = 'string'.format(VAR_100)\n",
"VAR_41 = get(VAR_117)\n",
"VAR_6 = VAR_41.text\n",
"VAR_46 = BeautifulSoup(VAR_6, 'html.parser')\n",
"VAR_118 = 'singles' if VAR_32 else 'doubles'\n",
"VAR_104 = VAR_46.find_all('a')\n",
"for link in VAR_104:\n",
"if link.has_attr('href') and 'tournament' in link['href']:\n",
"VAR_112 = link['href'].split('/')\n",
"VAR_120 = VAR_112[VAR_112.index('tournament') + 1]\n",
"if VAR_120 in VAR_43:\n",
"VAR_127 = VAR_101.tournament_show_events(VAR_120)\n",
"def FUNC_43(VAR_127, VAR_96):...\n",
"for VAR_121 in VAR_127['events']:\n",
"if all([(match in VAR_121) for match in VAR_96]):\n",
"return None\n",
"return VAR_121\n"
] | [
"def iterate():...\n",
"print('PAGE {}'.format(page))\n",
"results_url = (\n 'https://smash.gg/tournaments?per_page=30&filter=%7B%22upcoming%22%3Afalse%2C%22videogameIds%22%3A4%2C%22past%22%3Atrue%7D&page={}'\n .format(page))\n",
"r = get(results_url)\n",
"data = r.text\n",
"soup = BeautifulSoup(data, 'html.parser')\n",
"grep = 'singles' if singles else 'doubles'\n",
"links = soup.find_all('a')\n",
"for link in links:\n",
"if link.has_attr('href') and 'tournament' in link['href']:\n",
"url_parts = link['href'].split('/')\n",
"t = url_parts[url_parts.index('tournament') + 1]\n",
"if t in brackets:\n",
"events = smash.tournament_show_events(t)\n",
"def get_event(events, matches):...\n",
"for e in events['events']:\n",
"if all([(match in e) for match in matches]):\n",
"return None\n",
"return e\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"FunctionDef'",
"For",
"For",
"Return'",
"Return'"
] |
[
"from collections import defaultdict\n",
"from typing import Dict, Iterator, TypeVar\n",
"from .interface import ISpy\n",
"VAR_0 = TypeVar('T', bound=ISpy)\n",
"selected_fields: Dict[str, ISpy]\n",
"is_subquery: bool\n",
"def __init__(self):...\n",
"self.selected_fields = defaultdict(self.__class__)\n",
"self.is_subquery = False\n",
"def __getattr__(self, VAR_1: str) ->ISpy:...\n",
"return self.selected_fields[VAR_1]\n"
] | [
"from collections import defaultdict\n",
"from typing import Dict, Iterator, TypeVar\n",
"from .interface import ISpy\n",
"T = TypeVar('T', bound=ISpy)\n",
"selected_fields: Dict[str, ISpy]\n",
"is_subquery: bool\n",
"def __init__(self):...\n",
"self.selected_fields = defaultdict(self.__class__)\n",
"self.is_subquery = False\n",
"def __getattr__(self, name: str) ->ISpy:...\n",
"return self.selected_fields[name]\n"
] | [
0,
4,
4,
0,
0,
0,
0,
4,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"AnnAssign'",
"AnnAssign'",
"FunctionDef'",
"Assign'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_3(VAR_3):...\n",
"return ((65535 & VAR_3) << 16) + ((4294901760 & VAR_3) >> 16)\n"
] | [
"def hash(n):...\n",
"return ((65535 & n) << 16) + ((4294901760 & n) >> 16)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_22(VAR_2, VAR_18, VAR_19):...\n",
"if VAR_18.provider.id == '8.9.10.11':\n"
] | [
"def _validate(cluster_api, endpoint, conn):...\n",
"if endpoint.provider.id == '8.9.10.11':\n"
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def __init__(self, VAR_18, *VAR_15, **VAR_16):...\n",
"CLASS_3.__init__(self, VAR_18, errors.NO_USER, *VAR_15, **kw)\n"
] | [
"def __init__(self, item, *a, **kw):...\n",
"VRequired.__init__(self, item, errors.NO_USER, *a, **kw)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_21(self, VAR_2, VAR_3, VAR_4, *VAR_6):...\n",
"VAR_46 = self.pool.get('res.request')\n",
"VAR_47 = self.browse(VAR_2, VAR_3, VAR_4)\n",
"for VAR_23 in VAR_47:\n",
"VAR_51 = VAR_23.project_id\n",
"return True\n",
"if VAR_51:\n",
"if VAR_51.warn_manager and VAR_51.manager and VAR_51.manager.id != VAR_3:\n",
"self.write(VAR_2, VAR_3, [VAR_23.id], {'state': 'done', 'date_close': time.\n strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})\n",
"VAR_46.create(VAR_2, VAR_3, {'name': _(\"Task '%s' closed\") % VAR_23.name,\n 'state': 'waiting', 'act_from': VAR_3, 'act_to': VAR_51.manager.id,\n 'ref_partner_id': VAR_23.partner_id.id, 'ref_doc1': 'project.task,%d' %\n (VAR_23.id,), 'ref_doc2': 'project.project,%d' % (VAR_51.id,)})\n",
"if VAR_23.parent_id and VAR_23.parent_id.state in ('pending', 'draft'):\n",
"VAR_58 = True\n",
"for child in VAR_23.parent_id.child_ids:\n",
"if child.id != VAR_23.id and child.state not in ('done', 'cancelled'):\n",
"if VAR_58:\n",
"VAR_58 = False\n",
"self.do_reopen(VAR_2, VAR_3, [VAR_23.parent_id.id])\n"
] | [
"def do_close(self, cr, uid, ids, *args):...\n",
"request = self.pool.get('res.request')\n",
"tasks = self.browse(cr, uid, ids)\n",
"for task in tasks:\n",
"project = task.project_id\n",
"return True\n",
"if project:\n",
"if project.warn_manager and project.manager and project.manager.id != uid:\n",
"self.write(cr, uid, [task.id], {'state': 'done', 'date_close': time.\n strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})\n",
"request.create(cr, uid, {'name': _(\"Task '%s' closed\") % task.name, 'state':\n 'waiting', 'act_from': uid, 'act_to': project.manager.id,\n 'ref_partner_id': task.partner_id.id, 'ref_doc1': 'project.task,%d' % (\n task.id,), 'ref_doc2': 'project.project,%d' % (project.id,)})\n",
"if task.parent_id and task.parent_id.state in ('pending', 'draft'):\n",
"reopen = True\n",
"for child in task.parent_id.child_ids:\n",
"if child.id != task.id and child.state not in ('done', 'cancelled'):\n",
"if reopen:\n",
"reopen = False\n",
"self.do_reopen(cr, uid, [task.parent_id.id])\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Return'",
"Condition",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Assign'",
"For",
"Condition",
"Condition",
"Assign'",
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_0 = Client()\n",
"VAR_1 = VAR_2.environ['PHOBOS_DSS_connect_string']\n",
"VAR_2.environ['PHOBOS_DSS_connect_string'\n ] = \"dbname='tata', user='titi', password='toto'\"\n",
"self.assertRaises(EnvironmentError, VAR_0.connect)\n",
"VAR_2.environ['PHOBOS_DSS_connect_string'] = VAR_1\n"
] | [
"def test_client_connect_refused(self):...\n",
"\"\"\"docstring\"\"\"\n",
"cli = Client()\n",
"environ_save = os.environ['PHOBOS_DSS_connect_string']\n",
"os.environ['PHOBOS_DSS_connect_string'\n ] = \"dbname='tata', user='titi', password='toto'\"\n",
"self.assertRaises(EnvironmentError, cli.connect)\n",
"os.environ['PHOBOS_DSS_connect_string'] = environ_save\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'"
] |
[
"__author__ = 'Kyle Chesney'\n",
"from flask import *\n",
"from flask_login import LoginManager\n",
"import sqlite3\n",
"from datetime import datetime as dt\n",
"VAR_0 = Flask(__name__)\n",
"VAR_1 = LoginManager(VAR_0)\n",
"@VAR_0.route('/')...\n",
"return render_template('login.html')\n"
] | [
"__author__ = 'Kyle Chesney'\n",
"from flask import *\n",
"from flask_login import LoginManager\n",
"import sqlite3\n",
"from datetime import datetime as dt\n",
"app = Flask(__name__)\n",
"login = LoginManager(app)\n",
"@app.route('/')...\n",
"return render_template('login.html')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Assign'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"ImportFrom'",
"Assign'",
"Assign'",
"Condition",
"Return'"
] |
[
"@require_POST...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_51 = datetime.datetime.now()\n",
"VAR_52 = VAR_0.POST.copy()\n",
"VAR_1 = VAR_52.get('content_type')\n",
"VAR_53 = VAR_52.get('value_type', 'str')\n",
"VAR_54 = VAR_52.get('object_pk')\n",
"VAR_55 = VAR_52.get('field')\n",
"VAR_45 = VAR_52.get('value')\n",
"VAR_56 = [int(a) for a in VAR_54.split(',')]\n",
"if not VAR_55 or not VAR_45 or not VAR_56 or not VAR_1:\n",
"return FUNC_6(\n 'Following fields are required - content_type, object_pk, field and value.'\n )\n",
"VAR_55 = VAR_94(VAR_55)\n",
"VAR_45, VAR_46 = FUNC_5(VAR_45, VAR_53)\n",
"if VAR_46:\n",
"return FUNC_6(VAR_46)\n",
"VAR_57 = FUNC_0(VAR_0, VAR_1)\n",
"if not VAR_57:\n",
"return FUNC_6('Permission Dinied.')\n",
"VAR_58 = apps.get_model(*VAR_1.split('.', 1))\n",
"VAR_59 = VAR_58._default_manager.filter(pk__in=object_pk)\n",
"if not VAR_59:\n",
"return FUNC_6('No record found')\n",
"if not hasattr(VAR_59[0], VAR_55):\n",
"return FUNC_6('%s has no field %s' % (VAR_1, VAR_55))\n",
"if hasattr(VAR_59[0], 'log_action'):\n",
"for t in VAR_59:\n",
"FUNC_16(VAR_59, **{field: value})\n",
"t.log_action(who=request.user, VAR_68='Field %s changed from %s to %s.' % (\n field, getattr(t, field), value))\n",
"if hasattr(VAR_58, 'mail_scene'):\n",
"VAR_79 = VAR_58.mail_scene(VAR_13=targets, VAR_55=field, VAR_45=value,\n VAR_1=ctype, VAR_56=object_pk)\n",
"if VAR_1 == 'testruns.testcaserun' and VAR_55 == 'case_run_status':\n",
"if VAR_79:\n",
"for t in VAR_59:\n",
"return FUNC_7()\n",
"from tcms.core.utils.mailto import mailto\n",
"VAR_55 = 'close_date'\n",
"VAR_59.update(close_date=now, tested_by=request.user)\n",
"VAR_79['context']['user'] = VAR_0.user\n",
"t.log_action(who=request.user, VAR_68='Field %s changed from %s to %s.' % (\n field, getattr(t, field), now))\n",
"mailto(**mail_context)\n",
"if t.tested_by != VAR_0.user:\n",
"VAR_55 = 'tested_by'\n",
"VAR_55 = 'assignee'\n",
"t.log_action(who=request.user, VAR_68='Field %s changed from %s to %s.' % (\n field, getattr(t, field), request.user))\n",
"VAR_103 = t.assginee\n",
"if VAR_103 != VAR_0.user:\n",
"t.log_action(who=request.user, VAR_68='Field %s changed from %s to %s.' % (\n field, getattr(t, field), request.user))\n",
"t.save()\n"
] | [
"@require_POST...\n",
"\"\"\"docstring\"\"\"\n",
"now = datetime.datetime.now()\n",
"data = request.POST.copy()\n",
"ctype = data.get('content_type')\n",
"vtype = data.get('value_type', 'str')\n",
"object_pk_str = data.get('object_pk')\n",
"field = data.get('field')\n",
"value = data.get('value')\n",
"object_pk = [int(a) for a in object_pk_str.split(',')]\n",
"if not field or not value or not object_pk or not ctype:\n",
"return say_no(\n 'Following fields are required - content_type, object_pk, field and value.'\n )\n",
"field = str(field)\n",
"value, error = get_value_by_type(value, vtype)\n",
"if error:\n",
"return say_no(error)\n",
"has_perms = check_permission(request, ctype)\n",
"if not has_perms:\n",
"return say_no('Permission Dinied.')\n",
"model = apps.get_model(*ctype.split('.', 1))\n",
"targets = model._default_manager.filter(pk__in=object_pk)\n",
"if not targets:\n",
"return say_no('No record found')\n",
"if not hasattr(targets[0], field):\n",
"return say_no('%s has no field %s' % (ctype, field))\n",
"if hasattr(targets[0], 'log_action'):\n",
"for t in targets:\n",
"objects_update(targets, **{field: value})\n",
"t.log_action(who=request.user, action='Field %s changed from %s to %s.' % (\n field, getattr(t, field), value))\n",
"if hasattr(model, 'mail_scene'):\n",
"mail_context = model.mail_scene(objects=targets, field=field, value=value,\n ctype=ctype, object_pk=object_pk)\n",
"if ctype == 'testruns.testcaserun' and field == 'case_run_status':\n",
"if mail_context:\n",
"for t in targets:\n",
"return say_yes()\n",
"from tcms.core.utils.mailto import mailto\n",
"field = 'close_date'\n",
"targets.update(close_date=now, tested_by=request.user)\n",
"mail_context['context']['user'] = request.user\n",
"t.log_action(who=request.user, action='Field %s changed from %s to %s.' % (\n field, getattr(t, field), now))\n",
"mailto(**mail_context)\n",
"if t.tested_by != request.user:\n",
"field = 'tested_by'\n",
"field = 'assignee'\n",
"t.log_action(who=request.user, action='Field %s changed from %s to %s.' % (\n field, getattr(t, field), request.user))\n",
"assignee = t.assginee\n",
"if assignee != request.user:\n",
"t.log_action(who=request.user, action='Field %s changed from %s to %s.' % (\n field, getattr(t, field), request.user))\n",
"t.save()\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
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"For",
"Expr'",
"Expr'",
"Condition",
"Assign'",
"Condition",
"Condition",
"For",
"Return'",
"ImportFrom'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Expr'"
] |
[
"@memoized_property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._zinc_factory._compiler_bridge(self._products)\n"
] | [
"@memoized_property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._zinc_factory._compiler_bridge(self._products)\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_3(self):...\n",
"VAR_0.full_clean()\n",
"VAR_8 = CLASS_3(VAR_0)\n",
"VAR_9 = [('%s %s %s' % (VAR_11, VAR_11.name, VAR_8.depth)) for VAR_11 in VAR_8]\n",
"self.assertListEqual(['on_enter: ', 'on_enter: level2', 'on_exit: level2',\n 'on_enter: level2s[a]', 'on_exit: level2s[a]', 'on_enter: level2s[b]',\n 'on_enter: level2s[b].level3s[0]', 'on_exit: level2s[b].level3s[0]',\n 'on_enter: level2s[b].level3s[1]', 'on_exit: level2s[b].level3s[1]',\n 'on_exit: level2s[b]', 'on_enter: level2s[c]',\n 'on_enter: level2s[c].level3s[0]', 'on_exit: level2s[c].level3s[0]',\n 'on_exit: level2s[c]', 'on_exit: '], VAR_8.events)\n",
"self.assertListEqual(['odin.traversal.Level1 resource a 0',\n 'odin.traversal.Level2 resource b 1',\n 'odin.traversal.Level2 resource c 1',\n 'odin.traversal.Level2 resource d 1',\n 'odin.traversal.Level3 resource e 2',\n 'odin.traversal.Level3 resource f 2',\n 'odin.traversal.Level2 resource g 1',\n 'odin.traversal.Level3 resource h 2'], VAR_9)\n"
] | [
"def test_structure(self):...\n",
"TEST_STRUCTURE.full_clean()\n",
"resource_iter = TestResourceTraversalIterator(TEST_STRUCTURE)\n",
"resources = [('%s %s %s' % (r, r.name, resource_iter.depth)) for r in\n resource_iter]\n",
"self.assertListEqual(['on_enter: ', 'on_enter: level2', 'on_exit: level2',\n 'on_enter: level2s[a]', 'on_exit: level2s[a]', 'on_enter: level2s[b]',\n 'on_enter: level2s[b].level3s[0]', 'on_exit: level2s[b].level3s[0]',\n 'on_enter: level2s[b].level3s[1]', 'on_exit: level2s[b].level3s[1]',\n 'on_exit: level2s[b]', 'on_enter: level2s[c]',\n 'on_enter: level2s[c].level3s[0]', 'on_exit: level2s[c].level3s[0]',\n 'on_exit: level2s[c]', 'on_exit: '], resource_iter.events)\n",
"self.assertListEqual(['odin.traversal.Level1 resource a 0',\n 'odin.traversal.Level2 resource b 1',\n 'odin.traversal.Level2 resource c 1',\n 'odin.traversal.Level2 resource d 1',\n 'odin.traversal.Level3 resource e 2',\n 'odin.traversal.Level3 resource f 2',\n 'odin.traversal.Level2 resource g 1',\n 'odin.traversal.Level3 resource h 2'], resources)\n"
] | [
0,
0,
0,
0,
1,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@Json...\n",
"if VAR_2._chk_error(errors.NO_TITLE):\n",
"VAR_2._chk_error(errors.TITLE_TOO_LONG)\n",
"VAR_2._chk_errors((errors.NO_LOCATION, errors.NO_DESCRIPTION, errors.\n INVALID_DATE, errors.NO_DATE))\n",
"VAR_2._focus('title')\n",
"if VAR_2.error:\n",
"return\n",
"VAR_0 = Meetup(author_id=c.user._id, VAR_4=title, VAR_8=description, VAR_9=\n location, VAR_10=latitude, VAR_11=longitude, VAR_12=timestamp / 1000,\n VAR_13=tzoffset)\n",
"g.rendercache.invalidate_key_group(Meetup.group_cache_key())\n",
"VAR_0._commit()\n",
"VAR_17 = Link._submit(FUNC_1(VAR_0), FUNC_0(VAR_0), c.user, Subreddit.\n _by_name('discussion'), VAR_14, [])\n",
"VAR_17.meetup = VAR_0._id36\n",
"VAR_17._commit()\n",
"VAR_0.assoc_link = VAR_17._id\n",
"VAR_0._commit()\n",
"if g.write_query_queue:\n",
"queries.new_link(VAR_17)\n",
"VAR_2._redirect(url_for(action='show', id=meetup._id36))\n"
] | [
"@Json...\n",
"if res._chk_error(errors.NO_TITLE):\n",
"res._chk_error(errors.TITLE_TOO_LONG)\n",
"res._chk_errors((errors.NO_LOCATION, errors.NO_DESCRIPTION, errors.\n INVALID_DATE, errors.NO_DATE))\n",
"res._focus('title')\n",
"if res.error:\n",
"return\n",
"meetup = Meetup(author_id=c.user._id, title=title, description=description,\n location=location, latitude=latitude, longitude=longitude, timestamp=\n timestamp / 1000, tzoffset=tzoffset)\n",
"g.rendercache.invalidate_key_group(Meetup.group_cache_key())\n",
"meetup._commit()\n",
"l = Link._submit(meetup_article_title(meetup), meetup_article_text(meetup),\n c.user, Subreddit._by_name('discussion'), ip, [])\n",
"l.meetup = meetup._id36\n",
"l._commit()\n",
"meetup.assoc_link = l._id\n",
"meetup._commit()\n",
"if g.write_query_queue:\n",
"queries.new_link(l)\n",
"res._redirect(url_for(action='show', id=meetup._id36))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_10(self):...\n",
"from invenio.modules.oauthclient.models import RemoteAccount\n",
"RemoteAccount.create(1, 'testid', None)\n",
"self.assert401(self.client.get(url_for('oauthclient_settings.index'),\n follow_redirects=True))\n",
"self.login('admin', '')\n",
"VAR_10 = self.client.get(url_for('oauthclient_settings.index'))\n",
"self.assert200(VAR_10)\n",
"assert 'MyLinkedTestAccount' in VAR_10.data\n",
"assert url_for('oauthclient.disconnect', remote_app='test') in VAR_10.data\n",
"assert url_for('oauthclient.login', remote_app='full') in VAR_10.data\n",
"assert url_for('oauthclient.login', remote_app='test_invalid') in VAR_10.data\n"
] | [
"def test_settings_view(self):...\n",
"from invenio.modules.oauthclient.models import RemoteAccount\n",
"RemoteAccount.create(1, 'testid', None)\n",
"self.assert401(self.client.get(url_for('oauthclient_settings.index'),\n follow_redirects=True))\n",
"self.login('admin', '')\n",
"res = self.client.get(url_for('oauthclient_settings.index'))\n",
"self.assert200(res)\n",
"assert 'MyLinkedTestAccount' in res.data\n",
"assert url_for('oauthclient.disconnect', remote_app='test') in res.data\n",
"assert url_for('oauthclient.login', remote_app='full') in res.data\n",
"assert url_for('oauthclient.login', remote_app='test_invalid') in res.data\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"ImportFrom'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assert'",
"Assert'",
"Assert'",
"Assert'"
] |
[
"def FUNC_13(self):...\n",
"return any([FiletypeCompleterExistsForFiletype(x) for x in vimsupport.\n CurrentFiletypes()])\n"
] | [
"def NativeFiletypeCompletionAvailable(self):...\n",
"return any([FiletypeCompleterExistsForFiletype(x) for x in vimsupport.\n CurrentFiletypes()])\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._device_class\n"
] | [
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._device_class\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"VAR_91 = Subreddit._by_fullname(VAR_102.post.keys())\n",
"return VAR_91.values()\n"
] | [
"def run(self):...\n",
"subreddits = Subreddit._by_fullname(request.post.keys())\n",
"return subreddits.values()\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"VAR_5 = models.Session.create()\n",
"VAR_3 = models.Session.query().count()\n",
"self.assertTrue(VAR_3 == 1)\n",
"VAR_2 = EngineAuthRequest.blank('/auth/google')\n",
"VAR_2.cookies['_eauth'] = VAR_5.serialize()\n",
"VAR_9 = VAR_2.get_response(VAR_0)\n",
"VAR_9.request = VAR_2\n",
"VAR_9._save_session()\n",
"self.assertTrue(VAR_9.request.session.session_id == VAR_5.session_id)\n",
"VAR_6 = models.Session.query().count()\n",
"self.assertTrue(VAR_6 == 1)\n",
"VAR_9.request.session.user_id = '1'\n",
"VAR_9._save_session()\n",
"VAR_3 = models.Session.query().count()\n",
"self.assertTrue(VAR_3 == 1)\n",
"VAR_10 = models.Session.query().get()\n",
"self.assertEqual(VAR_10.key.id(), '1')\n"
] | [
"def test_save_session(self):...\n",
"s = models.Session.create()\n",
"s_count = models.Session.query().count()\n",
"self.assertTrue(s_count == 1)\n",
"req = EngineAuthRequest.blank('/auth/google')\n",
"req.cookies['_eauth'] = s.serialize()\n",
"resp = req.get_response(app)\n",
"resp.request = req\n",
"resp._save_session()\n",
"self.assertTrue(resp.request.session.session_id == s.session_id)\n",
"s_count2 = models.Session.query().count()\n",
"self.assertTrue(s_count2 == 1)\n",
"resp.request.session.user_id = '1'\n",
"resp._save_session()\n",
"s_count = models.Session.query().count()\n",
"self.assertTrue(s_count == 1)\n",
"s1 = models.Session.query().get()\n",
"self.assertEqual(s1.key.id(), '1')\n"
] | [
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'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_42(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.cursor.execute('create table t1(a int, b varchar(10))')\n",
"VAR_28 = [(1, 'good'), ('error', 'not an int'), (3, 'good')]\n",
"self.assertRaises(pyodbc.Error, self.cursor.executemany,\n 'insert into t1(a, b) value (?, ?)', VAR_28)\n"
] | [
"def test_executemany_failure(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.cursor.execute('create table t1(a int, b varchar(10))')\n",
"params = [(1, 'good'), ('error', 'not an int'), (3, 'good')]\n",
"self.assertRaises(pyodbc.Error, self.cursor.executemany,\n 'insert into t1(a, b) value (?, ?)', params)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_15(self, VAR_7, VAR_10):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_25 = None\n",
"VAR_11 = self.common._safe_hostname(VAR_10['host'])\n",
"VAR_33 = self.common.get_cpg(VAR_7, allowSnap=True)\n",
"VAR_13 = self.common.get_domain(VAR_33)\n",
"VAR_25 = self.common._get_3par_host(VAR_11)\n",
"VAR_14 = self.common.get_persona_type(VAR_7)\n",
"return VAR_25\n",
"if not VAR_25['iSCSIPaths']:\n",
"VAR_11 = self._create_3par_iscsi_host(VAR_11, VAR_10['initiator'], VAR_13,\n VAR_14)\n",
"self._modify_3par_iscsi_host(VAR_11, VAR_10['initiator'])\n",
"VAR_25 = self.common._get_3par_host(VAR_11)\n",
"VAR_25 = self.common._get_3par_host(VAR_11)\n"
] | [
"def _create_host(self, volume, connector):...\n",
"\"\"\"docstring\"\"\"\n",
"host = None\n",
"hostname = self.common._safe_hostname(connector['host'])\n",
"cpg = self.common.get_cpg(volume, allowSnap=True)\n",
"domain = self.common.get_domain(cpg)\n",
"host = self.common._get_3par_host(hostname)\n",
"persona_id = self.common.get_persona_type(volume)\n",
"return host\n",
"if not host['iSCSIPaths']:\n",
"hostname = self._create_3par_iscsi_host(hostname, connector['initiator'],\n domain, persona_id)\n",
"self._modify_3par_iscsi_host(hostname, connector['initiator'])\n",
"host = self.common._get_3par_host(hostname)\n",
"host = self.common._get_3par_host(hostname)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Assign'"
] |
[
"def FUNC_5():...\n",
"self.set_status(404, 'Not Found')\n",
"self._headers = tornado.httputil.HTTPHeaders()\n",
"self.add_header('Content-Length', '0')\n",
"self.flush()\n",
"return\n"
] | [
"def invoke_404():...\n",
"self.set_status(404, 'Not Found')\n",
"self._headers = tornado.httputil.HTTPHeaders()\n",
"self.add_header('Content-Length', '0')\n",
"self.flush()\n",
"return\n"
] | [
0,
0,
5,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"@FUNC_7...\n",
"\"\"\"docstring\"\"\"\n",
"FUNC_1(VAR_1, VAR_2)\n",
"return redirect('/')\n"
] | [
"@oauth_error_handler...\n",
"\"\"\"docstring\"\"\"\n",
"response_token_setter(remote, resp)\n",
"return redirect('/')\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Expr'",
"Return'"
] |
[
"import datetime\n",
"VAR_0 = [('This is the first post.', datetime.datetime.now())]\n",
"def FUNC_0():...\n",
"\"\"\"docstring\"\"\"\n",
"return reversed(VAR_0)\n"
] | [
"import datetime\n",
"POSTS = [('This is the first post.', datetime.datetime.now())]\n",
"def get_posts():...\n",
"\"\"\"docstring\"\"\"\n",
"return reversed(POSTS)\n"
] | [
0,
4,
0,
0,
4
] | [
"Import'",
"Assign'",
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_10(self):...\n",
"VAR_2 = 'response'\n",
"url_helper.urllib2.urlopen(mox.IgnoreArg(), mox.IgnoreArg(), timeout=mox.\n IgnoreArg()).AndRaise(urllib2.HTTPError('url', 500, 'error message',\n None, None))\n",
"time.sleep(mox.IgnoreArg())\n",
"url_helper.urllib2.urlopen(mox.IgnoreArg(), mox.IgnoreArg(), timeout=mox.\n IgnoreArg()).AndReturn(StringIO.StringIO(VAR_2))\n",
"self._mox.ReplayAll()\n",
"self.assertEqual(VAR_2, url_helper.UrlOpen('url', max_tries=10))\n",
"self._mox.VerifyAll()\n"
] | [
"def testUrlOpenHTTPErrorWithRetry(self):...\n",
"response = 'response'\n",
"url_helper.urllib2.urlopen(mox.IgnoreArg(), mox.IgnoreArg(), timeout=mox.\n IgnoreArg()).AndRaise(urllib2.HTTPError('url', 500, 'error message',\n None, None))\n",
"time.sleep(mox.IgnoreArg())\n",
"url_helper.urllib2.urlopen(mox.IgnoreArg(), mox.IgnoreArg(), timeout=mox.\n IgnoreArg()).AndReturn(StringIO.StringIO(response))\n",
"self._mox.ReplayAll()\n",
"self.assertEqual(response, url_helper.UrlOpen('url', max_tries=10))\n",
"self._mox.VerifyAll()\n"
] | [
0,
0,
0,
0,
5,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_5(self):...\n",
"\"\"\"docstring\"\"\"\n",
"import geopandas as gpd\n",
"import numpy as np\n",
"VAR_49 = gpd.read_file(self.subdomains_fn)\n",
"VAR_50 = VAR_49.groupby(self.id_field)\n",
"VAR_29 = self.rasterio_raster.height, self.rasterio_raster.width\n",
"VAR_30 = self.rasterio_raster.affine\n",
"VAR_51 = [self._rasterize_id(VAR_20, VAR_28, VAR_29, VAR_30, VAR_27=self.\n background_value) for VAR_28, VAR_20 in VAR_50]\n",
"self.sub_domains = VAR_51\n"
] | [
"def _rasterize_subdomains(self):...\n",
"\"\"\"docstring\"\"\"\n",
"import geopandas as gpd\n",
"import numpy as np\n",
"gdf = gpd.read_file(self.subdomains_fn)\n",
"id_groups = gdf.groupby(self.id_field)\n",
"out_shape = self.rasterio_raster.height, self.rasterio_raster.width\n",
"out_transform = self.rasterio_raster.affine\n",
"arr_list = [self._rasterize_id(df, value, out_shape, out_transform,\n background_value=self.background_value) for value, df in id_groups]\n",
"self.sub_domains = arr_list\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Import'",
"Import'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"@property...\n",
"return self._params\n"
] | [
"@property...\n",
"return self._params\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_2(self, VAR_1):...\n",
"VAR_1.seek(0, 2)\n",
"VAR_5 = VAR_1.tell()\n",
"VAR_1.seek(0)\n",
"return VAR_5\n"
] | [
"def get_filesize(self, file):...\n",
"file.seek(0, 2)\n",
"size = file.tell()\n",
"file.seek(0)\n",
"return size\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"super(CLASS_0, self).setUp()\n",
"self.shard = os.environ.get('SHARD')\n",
"self.env_var_override = EnvironmentVarGuard()\n"
] | [
"def setUp(self):...\n",
"super(TestPaverBokChoyCmd, self).setUp()\n",
"self.shard = os.environ.get('SHARD')\n",
"self.env_var_override = EnvironmentVarGuard()\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'"
] |
[
"def FUNC_1(VAR_3, VAR_2=None, VAR_4=True, VAR_5=True):...\n",
"\"\"\"docstring\"\"\"\n",
"assert isinstance(VAR_3, dict)\n",
"if VAR_5:\n",
"VAR_3 = VAR_3.copy()\n",
"if VAR_2:\n",
"VAR_39 = None\n",
"VAR_40 = VAR_3.pop(VAR_0, None)\n",
"if isinstance(VAR_2, (tuple, list)):\n",
"if not VAR_40:\n",
"VAR_44 = (FUNC_0(VAR_32) for VAR_32 in VAR_2)\n",
"VAR_44 = [FUNC_0(VAR_2)]\n",
"VAR_39 = registration.get_resource(VAR_40)\n",
"for FUNC_6, type_field in VAR_44:\n",
"if not VAR_39:\n",
"VAR_40 = VAR_3.get(type_field, None)\n",
"if not VAR_39:\n",
"VAR_11 = []\n",
"if VAR_40:\n",
"VAR_22 = {}\n",
"VAR_39 = registration.get_resource(VAR_40)\n",
"VAR_39 = registration.get_resource(FUNC_6)\n",
"for VAR_46 in VAR_39._meta.fields:\n",
"if not VAR_39:\n",
"VAR_12 = VAR_3.pop(VAR_46.name, NOT_PROVIDED)\n",
"if VAR_22:\n",
"if VAR_40:\n",
"if VAR_12 is NOT_PROVIDED:\n",
"VAR_23 = VAR_39(*VAR_11)\n",
"if FUNC_6 == VAR_40 or FUNC_6 in VAR_39._meta.parent_resource_names:\n",
"VAR_12 = VAR_46.get_default() if VAR_46.use_default_if_not_provided else None\n",
"VAR_12 = VAR_46.to_python(VAR_12)\n",
"VAR_22[VAR_46.name] = ve.error_messages\n",
"VAR_11.append(VAR_12)\n",
"if VAR_3:\n",
"VAR_23.extra_attrs(VAR_3)\n",
"if VAR_4:\n",
"VAR_23.full_clean()\n",
"return VAR_23\n"
] | [
"def create_resource_from_dict(d, resource=None, full_clean=True, copy_dict=True...\n",
"\"\"\"docstring\"\"\"\n",
"assert isinstance(d, dict)\n",
"if copy_dict:\n",
"d = d.copy()\n",
"if resource:\n",
"resource_type = None\n",
"document_resource_name = d.pop(DEFAULT_TYPE_FIELD, None)\n",
"if isinstance(resource, (tuple, list)):\n",
"if not document_resource_name:\n",
"resources = (resolve_resource_type(r) for r in resource)\n",
"resources = [resolve_resource_type(resource)]\n",
"resource_type = registration.get_resource(document_resource_name)\n",
"for resource_name, type_field in resources:\n",
"if not resource_type:\n",
"document_resource_name = d.get(type_field, None)\n",
"if not resource_type:\n",
"attrs = []\n",
"if document_resource_name:\n",
"errors = {}\n",
"resource_type = registration.get_resource(document_resource_name)\n",
"resource_type = registration.get_resource(resource_name)\n",
"for f in resource_type._meta.fields:\n",
"if not resource_type:\n",
"value = d.pop(f.name, NOT_PROVIDED)\n",
"if errors:\n",
"if document_resource_name:\n",
"if value is NOT_PROVIDED:\n",
"new_resource = resource_type(*attrs)\n",
"if resource_name == document_resource_name or resource_name in resource_type._meta.parent_resource_names:\n",
"value = f.get_default() if f.use_default_if_not_provided else None\n",
"value = f.to_python(value)\n",
"errors[f.name] = ve.error_messages\n",
"attrs.append(value)\n",
"if d:\n",
"new_resource.extra_attrs(d)\n",
"if full_clean:\n",
"new_resource.full_clean()\n",
"return new_resource\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
] | [
"FunctionDef'",
"Docstring",
"Assert'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Return'"
] |
[
"@rt.switch_runtime(fixtures.TEST_SITE_CONFIG, 'sys0')...\n",
"VAR_32 = CLASS_3.find_check\n",
"VAR_31 = CLASS_3.num_deps\n",
"VAR_0 = self.loader.load_all()\n",
"VAR_37 = VAR_32('Test0', VAR_0)\n",
"VAR_38 = VAR_32('Test1_default', VAR_0)\n",
"VAR_38.depends_on('Test0', rfm.DEPEND_EXACT, {'eX': ['e0']})\n",
"VAR_34 = dependency.build_deps(executors.generate_testcases(VAR_0))\n",
"assert VAR_31(VAR_34, 'Test1_default') == 4\n"
] | [
"@rt.switch_runtime(fixtures.TEST_SITE_CONFIG, 'sys0')...\n",
"find_check = TestDependencies.find_check\n",
"num_deps = TestDependencies.num_deps\n",
"checks = self.loader.load_all()\n",
"test0 = find_check('Test0', checks)\n",
"test1 = find_check('Test1_default', checks)\n",
"test1.depends_on('Test0', rfm.DEPEND_EXACT, {'eX': ['e0']})\n",
"deps = dependency.build_deps(executors.generate_testcases(checks))\n",
"assert num_deps(deps, 'Test1_default') == 4\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assert'"
] |
[
"@classmethod...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_1.name not in VAR_13:\n",
"if not callable(VAR_13[VAR_1.name]):\n",
"return VAR_13[VAR_1.name]\n",
"VAR_36 = [(VAR_15.val if isinstance(VAR_15, Variable) else VAR_15) for\n VAR_15 in VAR_1.params]\n",
"return VAR_13[VAR_1.name](*VAR_36)\n"
] | [
"@classmethod...\n",
"\"\"\"docstring\"\"\"\n",
"if A.name not in operator_map:\n",
"if not callable(operator_map[A.name]):\n",
"return operator_map[A.name]\n",
"p = [(x.val if isinstance(x, Variable) else x) for x in A.params]\n",
"return operator_map[A.name](*p)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Condition",
"Condition",
"Return'",
"Assign'",
"Return'"
] |
[
"def FUNC_8(self, VAR_10='main'):...\n",
"VAR_26 = 'string' % {'database': VAR_10}\n",
"self.db.executescript(VAR_26)\n",
"self.db.executescript('VACUUM;')\n",
"self.db.commit()\n"
] | [
"def optimize_database(self, database='main'):...\n",
"sqlstr = (\n \"\"\"\n CREATE TABLE tmp AS SELECT * FROM %(database)s.phrases;\n DELETE FROM %(database)s.phrases;\n INSERT INTO %(database)s.phrases SELECT * FROM tmp ORDER BY\n input_phrase, mlen ASC, user_freq DESC, freq DESC, id ASC;\n DROP TABLE tmp;\"\"\"\n % {'database': database})\n",
"self.db.executescript(sqlstr)\n",
"self.db.executescript('VACUUM;')\n",
"self.db.commit()\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_7(self, VAR_8):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.fileExists(VAR_8):\n",
"VAR_7 = \"SELECT mod_time FROM {0} WHERE path='{1}';\".format(VAR_2, VAR_8)\n",
"print(\"getModTime: File doesn't exist\")\n",
"VAR_16 = self._run_command(VAR_7)\n",
"VAR_16 = None\n",
"VAR_16 = VAR_16[0][0]\n",
"VAR_16 = None\n",
"return VAR_16\n"
] | [
"def getModTime(self, pth):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.fileExists(pth):\n",
"command = \"SELECT mod_time FROM {0} WHERE path='{1}';\".format(TABLE_NAME, pth)\n",
"print(\"getModTime: File doesn't exist\")\n",
"result = self._run_command(command)\n",
"result = None\n",
"result = result[0][0]\n",
"result = None\n",
"return result\n"
] | [
0,
0,
0,
4,
0,
4,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_15(self, VAR_15, VAR_8):...\n",
"VAR_27, VAR_28 = super().as_sql(VAR_15, VAR_8)\n",
"VAR_27 = '%s::%s' % (VAR_27, self.lhs.output_field.db_type(VAR_8))\n",
"return VAR_27, VAR_28\n"
] | [
"def as_sql(self, qn, connection):...\n",
"sql, params = super().as_sql(qn, connection)\n",
"sql = '%s::%s' % (sql, self.lhs.output_field.db_type(connection))\n",
"return sql, params\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_11(self):...\n",
"self.run_test_case(self.scenario.upsert_load_balancer(VAR_5=True))\n"
] | [
"def test_b_upsert_load_balancer_vpc(self):...\n",
"self.run_test_case(self.scenario.upsert_load_balancer(use_vpc=True))\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_0(VAR_0, VAR_1):...\n",
"VAR_4 = HttpResponse(VT().getPcap(VAR_1), content_type=\n 'application/vnd.tcpdump.pcap')\n",
"VAR_4['Content-Disposition'] = 'filename=%s.pcap' % VAR_1\n",
"return VAR_4\n"
] | [
"def getpcap(request, pk):...\n",
"response = HttpResponse(VT().getPcap(pk), content_type=\n 'application/vnd.tcpdump.pcap')\n",
"response['Content-Disposition'] = 'filename=%s.pcap' % pk\n",
"return response\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_0(VAR_0):...\n",
"VAR_7 = argparse.ArgumentParser()\n",
"VAR_7.add_argument('content_src_dir', help=\n 'Source directory containing content to be intalled.')\n",
"VAR_7.add_argument('content_dst_dir', help=\n 'Name of directory under <WWW-ROOT> for content to be located.')\n",
"VAR_7.add_argument('--www-root', help='WWW root path to install to.')\n",
"VAR_7.add_argument('--log-path', help='Directory to write logfiles to.')\n",
"VAR_8 = VAR_7.parse_args(VAR_0)\n",
"return VAR_8\n"
] | [
"def parse_args(argv):...\n",
"parser = argparse.ArgumentParser()\n",
"parser.add_argument('content_src_dir', help=\n 'Source directory containing content to be intalled.')\n",
"parser.add_argument('content_dst_dir', help=\n 'Name of directory under <WWW-ROOT> for content to be located.')\n",
"parser.add_argument('--www-root', help='WWW root path to install to.')\n",
"parser.add_argument('--log-path', help='Directory to write logfiles to.')\n",
"args = parser.parse_args(argv)\n",
"return args\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def __init__(self, VAR_17):...\n",
"self.json = VAR_17\n"
] | [
"def __init__(self, json):...\n",
"self.json = json\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"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'"
] |
[
"def FUNC_3(self, VAR_1, VAR_2, VAR_5, VAR_4=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_4 is None:\n",
"VAR_4 = {}\n",
"VAR_30 = VAR_4.get('states', [])\n",
"VAR_31 = VAR_4.get('what', ())\n",
"if not VAR_5:\n",
"VAR_5 = self.search(VAR_1, VAR_2, [])\n",
"VAR_29 = {}.fromkeys(VAR_5, 0.0)\n",
"if not VAR_5:\n",
"return VAR_29\n",
"if VAR_4.get('shop', False):\n",
"VAR_1.execute('select warehouse_id from sale_shop where id=%s', (int(VAR_4[\n 'shop']),))\n",
"if VAR_4.get('warehouse', False):\n",
"VAR_41 = VAR_1.fetchone()\n",
"VAR_1.execute('select lot_stock_id from stock_warehouse where id=%s', (int(\n VAR_4['warehouse']),))\n",
"if VAR_4.get('location', False):\n",
"if VAR_41:\n",
"VAR_41 = VAR_1.fetchone()\n",
"if type(VAR_4['location']) == type(1):\n",
"VAR_42 = []\n",
"VAR_4['warehouse'] = VAR_41[0]\n",
"if VAR_41:\n",
"VAR_42 = [VAR_4['location']]\n",
"if type(VAR_4['location']) in (type(''), type(u'')):\n",
"VAR_43 = self.pool.get('stock.warehouse').search(VAR_1, VAR_2, [], VAR_4=\n context)\n",
"VAR_4['location'] = VAR_41[0]\n",
"if VAR_4.get('compute_child', True):\n",
"VAR_42 = self.pool.get('stock.location').search(VAR_1, VAR_2, [('name',\n 'ilike', VAR_4['location'])], VAR_4=context)\n",
"VAR_42 = VAR_4['location']\n",
"for w in self.pool.get('stock.warehouse').browse(VAR_1, VAR_2, VAR_43,\n",
"VAR_44 = self.pool.get('stock.location').search(VAR_1, VAR_2, [(\n 'location_id', 'child_of', VAR_42)])\n",
"VAR_42 = VAR_42\n",
"VAR_42.append(w.lot_stock_id.id)\n",
"VAR_42 = VAR_44 or VAR_42\n",
"VAR_32 = {}\n",
"VAR_33 = {}\n",
"for VAR_45 in self.browse(VAR_1, VAR_2, VAR_5, VAR_4=context):\n",
"VAR_33[VAR_45.id] = VAR_45.uom_id.id\n",
"VAR_34 = []\n",
"VAR_32[VAR_45.uom_id.id] = VAR_45.uom_id\n",
"VAR_35 = []\n",
"VAR_36 = VAR_4.get('from_date', False)\n",
"VAR_37 = VAR_4.get('to_date', False)\n",
"VAR_38 = False\n",
"if VAR_36 and VAR_37:\n",
"VAR_38 = \"date_planned>='%s' and date_planned<='%s'\" % (VAR_36, VAR_37)\n",
"if VAR_36:\n",
"if 'in' in VAR_31:\n",
"VAR_38 = \"date_planned>='%s'\" % VAR_36\n",
"if VAR_37:\n",
"VAR_1.execute('string' + (VAR_38 and 'and ' + VAR_38 + ' ' or '') +\n 'group by product_id,product_uom', (tuple(VAR_42), tuple(VAR_42), tuple\n (VAR_5), tuple(VAR_30)))\n",
"if 'out' in VAR_31:\n",
"VAR_38 = \"date_planned<='%s'\" % VAR_37\n",
"VAR_34 = VAR_1.fetchall()\n",
"VAR_1.execute('string' + (VAR_38 and 'and ' + VAR_38 + ' ' or '') +\n 'group by product_id,product_uom', (tuple(VAR_42), tuple(VAR_42), tuple\n (VAR_5), tuple(VAR_30)))\n",
"VAR_39 = self.pool.get('product.uom')\n",
"VAR_35 = VAR_1.fetchall()\n",
"VAR_40 = map(lambda x: x[2], VAR_34) + map(lambda x: x[2], VAR_35)\n",
"if VAR_4.get('uom', False):\n",
"VAR_40 += [VAR_4['uom']]\n",
"VAR_40 = filter(lambda x: x not in VAR_32.keys(), VAR_40)\n",
"if VAR_40:\n",
"VAR_40 = VAR_39.browse(VAR_1, VAR_2, list(set(VAR_40)), VAR_4=context)\n",
"for VAR_46 in VAR_40:\n",
"VAR_32[VAR_46.id] = VAR_46\n",
"for VAR_47, prod_id, prod_uom in VAR_34:\n",
"VAR_47 = VAR_39._compute_qty_obj(VAR_1, VAR_2, VAR_32[prod_uom], VAR_47,\n VAR_32[VAR_4.get('uom', False) or VAR_33[prod_id]])\n",
"for VAR_47, prod_id, prod_uom in VAR_35:\n",
"VAR_29[prod_id] += VAR_47\n",
"VAR_47 = VAR_39._compute_qty_obj(VAR_1, VAR_2, VAR_32[prod_uom], VAR_47,\n VAR_32[VAR_4.get('uom', False) or VAR_33[prod_id]])\n",
"return VAR_29\n",
"VAR_29[prod_id] -= VAR_47\n"
] | [
"def get_product_available(self, cr, uid, ids, context=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if context is None:\n",
"context = {}\n",
"states = context.get('states', [])\n",
"what = context.get('what', ())\n",
"if not ids:\n",
"ids = self.search(cr, uid, [])\n",
"res = {}.fromkeys(ids, 0.0)\n",
"if not ids:\n",
"return res\n",
"if context.get('shop', False):\n",
"cr.execute('select warehouse_id from sale_shop where id=%s', (int(context[\n 'shop']),))\n",
"if context.get('warehouse', False):\n",
"res2 = cr.fetchone()\n",
"cr.execute('select lot_stock_id from stock_warehouse where id=%s', (int(\n context['warehouse']),))\n",
"if context.get('location', False):\n",
"if res2:\n",
"res2 = cr.fetchone()\n",
"if type(context['location']) == type(1):\n",
"location_ids = []\n",
"context['warehouse'] = res2[0]\n",
"if res2:\n",
"location_ids = [context['location']]\n",
"if type(context['location']) in (type(''), type(u'')):\n",
"wids = self.pool.get('stock.warehouse').search(cr, uid, [], context=context)\n",
"context['location'] = res2[0]\n",
"if context.get('compute_child', True):\n",
"location_ids = self.pool.get('stock.location').search(cr, uid, [('name',\n 'ilike', context['location'])], context=context)\n",
"location_ids = context['location']\n",
"for w in self.pool.get('stock.warehouse').browse(cr, uid, wids, context=context\n",
"child_location_ids = self.pool.get('stock.location').search(cr, uid, [(\n 'location_id', 'child_of', location_ids)])\n",
"location_ids = location_ids\n",
"location_ids.append(w.lot_stock_id.id)\n",
"location_ids = child_location_ids or location_ids\n",
"uoms_o = {}\n",
"product2uom = {}\n",
"for product in self.browse(cr, uid, ids, context=context):\n",
"product2uom[product.id] = product.uom_id.id\n",
"results = []\n",
"uoms_o[product.uom_id.id] = product.uom_id\n",
"results2 = []\n",
"from_date = context.get('from_date', False)\n",
"to_date = context.get('to_date', False)\n",
"date_str = False\n",
"if from_date and to_date:\n",
"date_str = \"date_planned>='%s' and date_planned<='%s'\" % (from_date, to_date)\n",
"if from_date:\n",
"if 'in' in what:\n",
"date_str = \"date_planned>='%s'\" % from_date\n",
"if to_date:\n",
"cr.execute(\n 'select sum(product_qty), product_id, product_uom from stock_move where location_id NOT IN %sand location_dest_id IN %sand product_id IN %sand state IN %s'\n + (date_str and 'and ' + date_str + ' ' or '') +\n 'group by product_id,product_uom', (tuple(location_ids), tuple(\n location_ids), tuple(ids), tuple(states)))\n",
"if 'out' in what:\n",
"date_str = \"date_planned<='%s'\" % to_date\n",
"results = cr.fetchall()\n",
"cr.execute(\n 'select sum(product_qty), product_id, product_uom from stock_move where location_id IN %sand location_dest_id NOT IN %s and product_id IN %sand state in %s'\n + (date_str and 'and ' + date_str + ' ' or '') +\n 'group by product_id,product_uom', (tuple(location_ids), tuple(\n location_ids), tuple(ids), tuple(states)))\n",
"uom_obj = self.pool.get('product.uom')\n",
"results2 = cr.fetchall()\n",
"uoms = map(lambda x: x[2], results) + map(lambda x: x[2], results2)\n",
"if context.get('uom', False):\n",
"uoms += [context['uom']]\n",
"uoms = filter(lambda x: x not in uoms_o.keys(), uoms)\n",
"if uoms:\n",
"uoms = uom_obj.browse(cr, uid, list(set(uoms)), context=context)\n",
"for o in uoms:\n",
"uoms_o[o.id] = o\n",
"for amount, prod_id, prod_uom in results:\n",
"amount = uom_obj._compute_qty_obj(cr, uid, uoms_o[prod_uom], amount, uoms_o\n [context.get('uom', False) or product2uom[prod_id]])\n",
"for amount, prod_id, prod_uom in results2:\n",
"res[prod_id] += amount\n",
"amount = uom_obj._compute_qty_obj(cr, uid, uoms_o[prod_uom], amount, uoms_o\n [context.get('uom', False) or product2uom[prod_id]])\n",
"return res\n",
"res[prod_id] -= amount\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,
4,
0,
0,
4,
0,
4,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"AugAssign'",
"Assign'",
"Condition",
"Assign'",
"For",
"Assign'",
"For",
"Assign'",
"For",
"AugAssign'",
"Assign'",
"Return'",
"AugAssign'"
] |
[
"@classmethod...\n",
"VAR_17 = str(VAR_12)\n",
"VAR_18 = \"UPPER(tag.name) LIKE UPPER('%%%s%%')\" % VAR_17\n",
"return self.select(VAR_18)\n"
] | [
"@classmethod...\n",
"text_query_str = str(text_query)\n",
"sql_query = \"UPPER(tag.name) LIKE UPPER('%%%s%%')\" % text_query_str\n",
"return self.select(sql_query)\n"
] | [
0,
4,
4,
4
] | [
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_17(VAR_4, VAR_1):...\n",
"VAR_38 = 5\n",
"if VAR_4 == 'country_ru' or VAR_4 == 'country_en':\n",
"VAR_52 = users.find_one(VAR_1).language + VAR_4\n",
"VAR_52 = VAR_4\n",
"VAR_39 = VAR_14 + timedelta(minutes=cache_time) < datetime.now(\n ) if VAR_14 else True\n",
"if not VAR_15.get(VAR_52, None) or not VAR_14 or VAR_39:\n",
"VAR_14 = datetime.now()\n",
"log.debug('Return cached result of %s...', VAR_3.__name__)\n",
"VAR_15[VAR_52] = VAR_3(VAR_4, VAR_1)\n",
"VAR_51 = VAR_14 + timedelta(minutes=cache_time) - datetime.now()\n",
"return VAR_15[VAR_52]\n",
"log.debug('Time to reevaluate result of %s is %s', VAR_3.__name__, str(\n VAR_51)[:-7])\n",
"return VAR_15[VAR_52]\n"
] | [
"def function_launcher(item_type, message):...\n",
"cache_time = 5\n",
"if item_type == 'country_ru' or item_type == 'country_en':\n",
"result_id = users.find_one(message).language + item_type\n",
"result_id = item_type\n",
"high_time = when_was_called + timedelta(minutes=cache_time) < datetime.now(\n ) if when_was_called else True\n",
"if not result.get(result_id, None) or not when_was_called or high_time:\n",
"when_was_called = datetime.now()\n",
"log.debug('Return cached result of %s...', func.__name__)\n",
"result[result_id] = func(item_type, message)\n",
"time_left = when_was_called + timedelta(minutes=cache_time) - datetime.now()\n",
"return result[result_id]\n",
"log.debug('Time to reevaluate result of %s is %s', func.__name__, str(\n time_left)[:-7])\n",
"return result[result_id]\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Return'",
"Expr'",
"Return'"
] |
[
"def FUNC_2(self, VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_7, VAR_8 = self.lineBuffer[0:self.lineBufferIndex], self.lineBuffer[self\n .lineBufferIndex:]\n",
"self.lineBuffer = VAR_7 + VAR_1 + VAR_8\n",
"self.lineBufferIndex += len(VAR_1)\n"
] | [
"def insert_buffer(self, buf):...\n",
"\"\"\"docstring\"\"\"\n",
"lead, rest = self.lineBuffer[0:self.lineBufferIndex], self.lineBuffer[self.\n lineBufferIndex:]\n",
"self.lineBuffer = lead + buf + rest\n",
"self.lineBufferIndex += len(buf)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"AugAssign'"
] |
[
"def FUNC_17(self, VAR_10='_cores _nodes'.split()):...\n",
"VAR_23 = {name: res for name, res in self.resources.items() if name not in\n VAR_10}\n",
"VAR_24 = {name: value for name, value in self.params.items()}\n",
"VAR_25 = {'rule': self.rule.name, 'local': self.dag.workflow.is_local(self.\n rule), 'input': self.input, 'output': self.output, 'params': VAR_24,\n 'threads': self.threads, 'resources': VAR_23}\n",
"return VAR_25\n"
] | [
"def properties(self, omit_resources='_cores _nodes'.split()):...\n",
"resources = {name: res for name, res in self.resources.items() if name not in\n omit_resources}\n",
"params = {name: value for name, value in self.params.items()}\n",
"properties = {'rule': self.rule.name, 'local': self.dag.workflow.is_local(\n self.rule), 'input': self.input, 'output': self.output, 'params':\n params, 'threads': self.threads, 'resources': resources}\n",
"return properties\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_5(self, VAR_1, VAR_2, VAR_8=None, VAR_9='form', VAR_4=None, VAR_14...\n",
"VAR_29 = super(CLASS_0, self).fields_view_get(VAR_1, VAR_2, VAR_8, VAR_9,\n VAR_4, VAR_14=toolbar, VAR_15=submenu)\n",
"if VAR_4 is None:\n",
"VAR_4 = {}\n",
"if 'location' in VAR_4 and VAR_4['location']:\n",
"VAR_51 = self.pool.get('stock.location').browse(VAR_1, VAR_2, VAR_4['location']\n )\n",
"return VAR_29\n",
"VAR_52 = VAR_29.get('fields', {})\n",
"if VAR_52:\n",
"if VAR_51.usage == 'supplier':\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'internal':\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Receptions')\n",
"if VAR_52.get('qty_available'):\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'customer':\n",
"VAR_29['fields']['qty_available']['string'] = _('Received Qty')\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Stock')\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'inventory':\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Deliveries')\n",
"if VAR_52.get('qty_available'):\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'procurement':\n",
"VAR_29['fields']['qty_available']['string'] = _('Delivered Qty')\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future P&L')\n",
"if VAR_52.get('qty_available'):\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'production':\n",
"VAR_29['fields']['qty_available']['string'] = _('P&L Qty')\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Qty')\n",
"if VAR_52.get('qty_available'):\n",
"if VAR_52.get('virtual_available'):\n",
"VAR_29['fields']['qty_available']['string'] = _('Unplanned Qty')\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Productions')\n",
"if VAR_52.get('qty_available'):\n",
"VAR_29['fields']['qty_available']['string'] = _('Produced Qty')\n"
] | [
"def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=...\n",
"res = super(product_product, self).fields_view_get(cr, uid, view_id,\n view_type, context, toolbar=toolbar, submenu=submenu)\n",
"if context is None:\n",
"context = {}\n",
"if 'location' in context and context['location']:\n",
"location_info = self.pool.get('stock.location').browse(cr, uid, context[\n 'location'])\n",
"return res\n",
"fields = res.get('fields', {})\n",
"if fields:\n",
"if location_info.usage == 'supplier':\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'internal':\n",
"res['fields']['virtual_available']['string'] = _('Future Receptions')\n",
"if fields.get('qty_available'):\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'customer':\n",
"res['fields']['qty_available']['string'] = _('Received Qty')\n",
"res['fields']['virtual_available']['string'] = _('Future Stock')\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'inventory':\n",
"res['fields']['virtual_available']['string'] = _('Future Deliveries')\n",
"if fields.get('qty_available'):\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'procurement':\n",
"res['fields']['qty_available']['string'] = _('Delivered Qty')\n",
"res['fields']['virtual_available']['string'] = _('Future P&L')\n",
"if fields.get('qty_available'):\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'production':\n",
"res['fields']['qty_available']['string'] = _('P&L Qty')\n",
"res['fields']['virtual_available']['string'] = _('Future Qty')\n",
"if fields.get('qty_available'):\n",
"if fields.get('virtual_available'):\n",
"res['fields']['qty_available']['string'] = _('Unplanned Qty')\n",
"res['fields']['virtual_available']['string'] = _('Future Productions')\n",
"if fields.get('qty_available'):\n",
"res['fields']['qty_available']['string'] = _('Produced Qty')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"For",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'"
] |
[
"@receiver(VAR_5, **decorator_kwargs)...\n",
"if settings.SUSPEND_SIGNALS:\n",
"return\n",
"return VAR_17(VAR_23, **kwargs)\n"
] | [
"@receiver(signal, **decorator_kwargs)...\n",
"if settings.SUSPEND_SIGNALS:\n",
"return\n",
"return func(sender, **kwargs)\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_24(self, *VAR_71, **VAR_72):...\n",
"def FUNC_39(VAR_101):...\n",
"VAR_101.params = VAR_71, VAR_72\n",
"return VAR_101\n"
] | [
"def params(self, *params, **kwparams):...\n",
"def decorate(ruleinfo):...\n",
"ruleinfo.params = params, kwparams\n",
"return ruleinfo\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_14(self, VAR_21, VAR_11, **VAR_6):...\n",
"if CLASS_28.has_unaccent is None:\n",
"VAR_45 = VAR_11.cursor()\n",
"if CLASS_28.has_unaccent:\n",
"VAR_45.execute(\n \"SELECT COUNT(proname) FROM pg_proc WHERE proname = 'f_unaccent';\")\n",
"CLASS_28.function = 'F_UNACCENT'\n",
"return super().as_sql(VAR_21, VAR_11, **kwargs)\n",
"VAR_46 = VAR_45.fetchone()\n",
"CLASS_28.has_unaccent = VAR_46 and VAR_46[0] > 0\n"
] | [
"def as_sql(self, compiler, connection, **kwargs):...\n",
"if CustomUnaccent.has_unaccent is None:\n",
"cursor = connection.cursor()\n",
"if CustomUnaccent.has_unaccent:\n",
"cursor.execute(\n \"SELECT COUNT(proname) FROM pg_proc WHERE proname = 'f_unaccent';\")\n",
"CustomUnaccent.function = 'F_UNACCENT'\n",
"return super().as_sql(compiler, connection, **kwargs)\n",
"response = cursor.fetchone()\n",
"CustomUnaccent.has_unaccent = response and response[0] > 0\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Return'",
"Assign'",
"Assign'"
] |
[
"@wraps(VAR_3)...\n",
"VAR_6 = VAR_5.headers.get(VAR_1)\n",
"VAR_11 = VAR_5.session.get_csrf_token()\n",
"if VAR_6 == VAR_11:\n",
"return VAR_3(VAR_9, VAR_5)\n"
] | [
"@wraps(fn)...\n",
"token = request.headers.get(HEADER_NAME)\n",
"session_token = request.session.get_csrf_token()\n",
"if token == session_token:\n",
"return fn(context, request)\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_57():...\n",
"self.cursor.execute('create table t1 (word varchar (100))')\n",
"VAR_38 = set(['a'])\n",
"self.cursor.execute('insert into t1 (word) VALUES (?)', [VAR_38])\n"
] | [
"def f():...\n",
"self.cursor.execute('create table t1 (word varchar (100))')\n",
"words = set(['a'])\n",
"self.cursor.execute('insert into t1 (word) VALUES (?)', [words])\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"@utils.synchronized('3par', external=True)...\n",
""
] | [
"@utils.synchronized('3par', external=True)...\n",
""
] | [
0,
0
] | [
"Condition",
"Condition"
] |
[
"def FUNC_11(self):...\n",
"return '{} {}'.format(FUNC_0(self.name), self.type.for_schema())\n"
] | [
"def for_schema(self):...\n",
"return '{} {}'.format(escape_col(self.name), self.type.for_schema())\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_3(self, VAR_6):...\n",
"if 'doctype' in VAR_6:\n",
"self.set('doctype', VAR_6.get('doctype'))\n",
"for VAR_7 in default_fields:\n",
"if VAR_7 in VAR_6:\n",
"for VAR_7, VAR_9 in iteritems(VAR_6):\n",
"self.set(VAR_7, VAR_6.get(VAR_7))\n",
"self.set(VAR_7, VAR_9)\n",
"return self\n"
] | [
"def update(self, d):...\n",
"if 'doctype' in d:\n",
"self.set('doctype', d.get('doctype'))\n",
"for key in default_fields:\n",
"if key in d:\n",
"for key, value in iteritems(d):\n",
"self.set(key, d.get(key))\n",
"self.set(key, value)\n",
"return self\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"For",
"Condition",
"For",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_2(self, VAR_8, VAR_9, VAR_10=None, VAR_11=None, VAR_12=(...\n",
"get_and_check_project(VAR_9, VAR_11, VAR_12)\n",
"VAR_28 = self.queryset.get(VAR_10=pk, VAR_1=project_pk)\n",
"VAR_28.pending_action = VAR_8\n",
"VAR_28.last_error = None\n",
"VAR_28.save()\n",
"scheduler.process_pending_tasks(background=True)\n",
"return Response({'success': True})\n"
] | [
"def set_pending_action(self, pending_action, request, pk=None, project_pk=...\n",
"get_and_check_project(request, project_pk, perms)\n",
"task = self.queryset.get(pk=pk, project=project_pk)\n",
"task.pending_action = pending_action\n",
"task.last_error = None\n",
"task.save()\n",
"scheduler.process_pending_tasks(background=True)\n",
"return Response({'success': True})\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_3(self, VAR_5):...\n",
"self.common = self._init_common()\n",
"self._check_flags()\n",
"self.common.do_setup(VAR_5)\n"
] | [
"def do_setup(self, context):...\n",
"self.common = self._init_common()\n",
"self._check_flags()\n",
"self.common.do_setup(context)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@utils.synchronized('3par', external=True)...\n",
"\"\"\"docstring\"\"\"\n",
"self.common.client_login()\n",
"self.common.terminate_connection(VAR_6, VAR_9['host'], VAR_9['wwpns'])\n",
"self.common.client_logout()\n"
] | [
"@utils.synchronized('3par', external=True)...\n",
"\"\"\"docstring\"\"\"\n",
"self.common.client_login()\n",
"self.common.terminate_connection(volume, connector['host'], connector['wwpns'])\n",
"self.common.client_logout()\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Expr'",
"Expr'",
"Expr'"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.