lines
sequencelengths 1
444
| raw_lines
sequencelengths 1
444
| label
sequencelengths 1
444
| type
sequencelengths 1
444
|
---|---|---|---|
[
"@staticmethod...\n",
"VAR_0 = Database()\n",
"VAR_11 = VAR_0.list_tasks(VAR_2=limit, VAR_3=offset, VAR_30='file',\n not_status=TASK_PENDING)\n",
"VAR_12 = VAR_0.list_tasks(VAR_2=limit, VAR_3=offset, VAR_30='url',\n not_status=TASK_PENDING)\n",
"VAR_9 = []\n",
"if VAR_11:\n",
"for VAR_10 in VAR_11:\n",
"if VAR_12:\n",
"VAR_27 = VAR_10.to_dict()\n",
"for VAR_10 in VAR_12:\n",
"return VAR_9\n",
"VAR_27['sample'] = VAR_0.view_sample(VAR_27['sample_id']).to_dict()\n",
"VAR_27 = VAR_10.to_dict()\n",
"VAR_28 = os.path.basename(VAR_27['target'])\n",
"if VAR_0.view_errors(VAR_10.id):\n",
"VAR_27.update({'filename': VAR_28})\n",
"VAR_27['errors'] = True\n",
"VAR_9.append(VAR_27)\n",
"if VAR_0.view_errors(VAR_10.id):\n",
"VAR_27['errors'] = True\n",
"VAR_9.append(VAR_27)\n"
] | [
"@staticmethod...\n",
"db = Database()\n",
"tasks_files = db.list_tasks(limit=limit, offset=offset, category='file',\n not_status=TASK_PENDING)\n",
"tasks_urls = db.list_tasks(limit=limit, offset=offset, category='url',\n not_status=TASK_PENDING)\n",
"data = []\n",
"if tasks_files:\n",
"for task in tasks_files:\n",
"if tasks_urls:\n",
"new = task.to_dict()\n",
"for task in tasks_urls:\n",
"return data\n",
"new['sample'] = db.view_sample(new['sample_id']).to_dict()\n",
"new = task.to_dict()\n",
"filename = os.path.basename(new['target'])\n",
"if db.view_errors(task.id):\n",
"new.update({'filename': filename})\n",
"new['errors'] = True\n",
"data.append(new)\n",
"if db.view_errors(task.id):\n",
"new['errors'] = True\n",
"data.append(new)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"For",
"Condition",
"Assign'",
"For",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Expr'"
] |
[
"def FUNC_6(self):...\n",
"if is_banned_IP(VAR_102.ip):\n",
"VAR_101.errors.add(errors.BANNED_IP)\n",
"return VAR_102.ip\n"
] | [
"def run(self):...\n",
"if is_banned_IP(request.ip):\n",
"c.errors.add(errors.BANNED_IP)\n",
"return request.ip\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Return'"
] |
[
"def FUNC_8(VAR_14, VAR_19, VAR_20, VAR_23=None, VAR_3=None, VAR_4=None,...\n",
"if VAR_14.method == 'GET':\n",
"VAR_27 = {'article__title': VAR_19}\n",
"return HttpResponseNotAllowed(['GET'])\n",
"if VAR_3 is not None:\n",
"VAR_8 = get_object_or_404(VAR_5, **{group_slug_field: group_slug})\n",
"VAR_53 = get_object_or_404(VAR_24, VAR_20=int(revision), **article_args)\n",
"VAR_27.update({'article__content_type': get_ct(VAR_8), 'article__object_id':\n VAR_8.id})\n",
"VAR_27 = {'title': VAR_19}\n",
"if VAR_3 is not None:\n",
"VAR_8 = get_object_or_404(VAR_5, **{group_slug_field: group_slug})\n",
"VAR_46 = VAR_47 = True\n",
"VAR_27.update({'content_type': get_ct(VAR_8), 'object_id': VAR_8.id})\n",
"if not VAR_46:\n",
"VAR_46 = FUNC_3(VAR_14.user, VAR_8, VAR_12, VAR_13)\n",
"return HttpResponseForbidden()\n",
"VAR_28 = VAR_2.get(**article_args)\n",
"VAR_47 = FUNC_4(VAR_14.user, VAR_8, VAR_12)\n",
"if VAR_23 is None:\n",
"VAR_23 = int(VAR_20) - 1\n",
"VAR_54 = None\n",
"if int(VAR_20) is not int(VAR_23) + 1:\n",
"VAR_54 = VAR_23\n",
"VAR_48 = {'article': VAR_28, 'article_title': VAR_28.title, 'changeset':\n VAR_53, 'differences': VAR_53.compare_to(VAR_23), 'from': VAR_54, 'to':\n VAR_20, 'allow_write': VAR_47}\n",
"if VAR_3 is not None:\n",
"VAR_48['group'] = VAR_8\n",
"if VAR_18 is not None:\n",
"VAR_48.update(VAR_18)\n",
"return render_to_response('/'.join([VAR_17, VAR_16]), VAR_48,\n context_instance=RequestContext(request))\n"
] | [
"def view_changeset(request, title, revision, revision_from=None, group_slug...\n",
"if request.method == 'GET':\n",
"article_args = {'article__title': title}\n",
"return HttpResponseNotAllowed(['GET'])\n",
"if group_slug is not None:\n",
"group = get_object_or_404(group_qs, **{group_slug_field: group_slug})\n",
"changeset = get_object_or_404(changes_qs, revision=int(revision), **\n article_args)\n",
"article_args.update({'article__content_type': get_ct(group),\n 'article__object_id': group.id})\n",
"article_args = {'title': title}\n",
"if group_slug is not None:\n",
"group = get_object_or_404(group_qs, **{group_slug_field: group_slug})\n",
"allow_read = allow_write = True\n",
"article_args.update({'content_type': get_ct(group), 'object_id': group.id})\n",
"if not allow_read:\n",
"allow_read = has_read_perm(request.user, group, is_member, is_private)\n",
"return HttpResponseForbidden()\n",
"article = article_qs.get(**article_args)\n",
"allow_write = has_write_perm(request.user, group, is_member)\n",
"if revision_from is None:\n",
"revision_from = int(revision) - 1\n",
"from_value = None\n",
"if int(revision) is not int(revision_from) + 1:\n",
"from_value = revision_from\n",
"template_params = {'article': article, 'article_title': article.title,\n 'changeset': changeset, 'differences': changeset.compare_to(\n revision_from), 'from': from_value, 'to': revision, 'allow_write':\n allow_write}\n",
"if group_slug is not None:\n",
"template_params['group'] = group\n",
"if extra_context is not None:\n",
"template_params.update(extra_context)\n",
"return render_to_response('/'.join([template_dir, template_name]),\n template_params, context_instance=RequestContext(request))\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
] | [
"Condition",
"Condition",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Return'"
] |
[
"def __init__(self, *VAR_6, **VAR_7):...\n",
"self.dg_type = VAR_7.pop('dg_type', 0)\n",
"self.user = VAR_7.pop('user', None)\n",
"super(CLASS_1, self).__init__(*VAR_6, **kwargs)\n",
"self.fields['weight_fraction_type'].widget.attrs.update({'style':\n 'height:2.75rem; !important'})\n",
"self.fields['script_selection'].widget.attrs.update({'style':\n 'height:2.75rem; !important'})\n",
"self.fields['extract_file'].widget.attrs.update({'accept': '.csv'})\n",
"if self.dg_type in ['FU', 'CP']:\n",
"self.collapsed = True\n"
] | [
"def __init__(self, *args, **kwargs):...\n",
"self.dg_type = kwargs.pop('dg_type', 0)\n",
"self.user = kwargs.pop('user', None)\n",
"super(ExtractionScriptForm, self).__init__(*args, **kwargs)\n",
"self.fields['weight_fraction_type'].widget.attrs.update({'style':\n 'height:2.75rem; !important'})\n",
"self.fields['script_selection'].widget.attrs.update({'style':\n 'height:2.75rem; !important'})\n",
"self.fields['extract_file'].widget.attrs.update({'accept': '.csv'})\n",
"if self.dg_type in ['FU', 'CP']:\n",
"self.collapsed = True\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Assign'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._server_version\n"
] | [
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._server_version\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_23(self, VAR_21, VAR_27, VAR_28):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_57 = self.getfile(VAR_21)\n",
"if VAR_57 == False:\n",
"if VAR_27 != -1:\n",
"VAR_57[VAR_3] = VAR_27\n",
"if VAR_28 != -1:\n",
"VAR_57[VAR_4] = VAR_28\n"
] | [
"def chown(self, path, uid, gid):...\n",
"\"\"\"docstring\"\"\"\n",
"p = self.getfile(path)\n",
"if p == False:\n",
"if uid != -1:\n",
"p[A_UID] = uid\n",
"if gid != -1:\n",
"p[A_GID] = gid\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'"
] |
[
"def FUNC_2(VAR_1, VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_1.enabled:\n",
"FUNC_0(VAR_2)\n",
"if VAR_1.use_tls:\n",
"VAR_3 = FTP_TLS(VAR_1.server)\n",
"VAR_3 = FTP(VAR_1.server)\n",
"VAR_3.login(VAR_1.username, VAR_1.password)\n",
"VAR_3.login(VAR_1.username, VAR_1.password)\n",
"VAR_3.prot_p()\n",
"if not VAR_1.files:\n",
"FUNC_3(VAR_3=ftp, VAR_2=local_directory, VAR_4=ftp_config.directory)\n",
"VAR_3.cwd(VAR_1.directory)\n",
"VAR_3.close()\n",
"VAR_19 = 1\n",
"VAR_20 = len(VAR_1.files)\n",
"for remote_filename in VAR_1.files:\n",
"VAR_46 = remote_filename\n",
"VAR_47 = os.path.join(VAR_2, VAR_46)\n",
"if not os.path.exists(VAR_47):\n",
"print('[Setup][FTP] ({}/{}) File already exists. Skipping: {}'.format(\n VAR_19, VAR_20, VAR_47))\n",
"VAR_3.retrbinary('RETR %s' % remote_filename, VAR_7.write)\n",
"print('[Setup][FTP] ({}/{}) Error downloading file. Skipping: {}'.format(\n VAR_19, VAR_20, VAR_47))\n",
"VAR_19 = VAR_19 + 1\n",
"print('[Setup][FTP] ({}/{}) File downloaded: {}'.format(VAR_19, VAR_20, VAR_47)\n )\n",
"VAR_7.close()\n",
"os.remove(VAR_47)\n"
] | [
"def fetch_data_via_ftp(ftp_config, local_directory):...\n",
"\"\"\"docstring\"\"\"\n",
"if ftp_config.enabled:\n",
"create_directory_tree(local_directory)\n",
"if ftp_config.use_tls:\n",
"ftp = FTP_TLS(ftp_config.server)\n",
"ftp = FTP(ftp_config.server)\n",
"ftp.login(ftp_config.username, ftp_config.password)\n",
"ftp.login(ftp_config.username, ftp_config.password)\n",
"ftp.prot_p()\n",
"if not ftp_config.files:\n",
"fetch_data_via_ftp_recursive(ftp=ftp, local_directory=local_directory,\n remote_directory=ftp_config.directory)\n",
"ftp.cwd(ftp_config.directory)\n",
"ftp.close()\n",
"file_counter = 1\n",
"file_list_total = len(ftp_config.files)\n",
"for remote_filename in ftp_config.files:\n",
"local_filename = remote_filename\n",
"filepath = os.path.join(local_directory, local_filename)\n",
"if not os.path.exists(filepath):\n",
"print('[Setup][FTP] ({}/{}) File already exists. Skipping: {}'.format(\n file_counter, file_list_total, filepath))\n",
"ftp.retrbinary('RETR %s' % remote_filename, local_file.write)\n",
"print('[Setup][FTP] ({}/{}) Error downloading file. Skipping: {}'.format(\n file_counter, file_list_total, filepath))\n",
"file_counter = file_counter + 1\n",
"print('[Setup][FTP] ({}/{}) File downloaded: {}'.format(file_counter,\n file_list_total, filepath))\n",
"local_file.close()\n",
"os.remove(filepath)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_0(VAR_0):...\n",
"return VAR_0.scheme in ['', 'file']\n"
] | [
"def is_file(parsed_uri):...\n",
"return parsed_uri.scheme in ['', 'file']\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_0(VAR_0, VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_1.last_login:\n",
"return reverse('core:user_index')\n",
"VAR_2 = VAR_0.POST.get('next', None)\n",
"if VAR_2 is None or VAR_2 == 'None':\n",
"if VAR_0.user.role == 'SimpleUsers':\n",
"return VAR_2\n",
"VAR_3 = VAR_0.localconfig.parameters.get_value('default_top_redirection')\n",
"VAR_2 = reverse('core:dashboard')\n",
"if VAR_3 != 'user':\n",
"VAR_4 = exts_pool.get_extension_infos(VAR_3)\n",
"VAR_2 = reverse('core:user_index')\n",
"VAR_2 = VAR_4['topredirection_url']\n"
] | [
"def find_nextlocation(request, user):...\n",
"\"\"\"docstring\"\"\"\n",
"if not user.last_login:\n",
"return reverse('core:user_index')\n",
"nextlocation = request.POST.get('next', None)\n",
"if nextlocation is None or nextlocation == 'None':\n",
"if request.user.role == 'SimpleUsers':\n",
"return nextlocation\n",
"topredir = request.localconfig.parameters.get_value('default_top_redirection')\n",
"nextlocation = reverse('core:dashboard')\n",
"if topredir != 'user':\n",
"infos = exts_pool.get_extension_infos(topredir)\n",
"nextlocation = reverse('core:user_index')\n",
"nextlocation = infos['topredirection_url']\n"
] | [
0,
0,
0,
0,
6,
6,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Condition",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_1(self):...\n",
"VAR_8 = Org.objects.order_by('id')\n",
"return VAR_8\n"
] | [
"def get_queryset(self):...\n",
"query = Org.objects.order_by('id')\n",
"return query\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"self._tab_after('t')\n",
"eq_(len(self.terminal.method_calls), 0)\n"
] | [
"def test_complete_not_found(self):...\n",
"self._tab_after('t')\n",
"eq_(len(self.terminal.method_calls), 0)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'"
] |
[
"import re\n",
"import tornado\n",
"from bzs import files\n",
"from bzs import const\n",
"VAR_0 = ['GET', 'HEAD']\n",
"@tornado.web.asynchronous...\n",
"VAR_2 = files.get_static_data('./static/404.html')\n",
"VAR_2 = '404 Not Found'\n",
"self.set_status(200, 'OK')\n",
"self._headers = tornado.httputil.HTTPHeaders()\n",
"self.add_header('Cache-Control', 'max-age=0')\n",
"self.add_header('Connection', 'close')\n",
"self.add_header('Content-Type', 'text/html')\n",
"self.add_header('Content-Length', str(len(VAR_2)))\n",
"self.write(VAR_2)\n",
"self.flush()\n",
"self.finish()\n",
"return self\n"
] | [
"import re\n",
"import tornado\n",
"from bzs import files\n",
"from bzs import const\n",
"SUPPORTED_METHODS = ['GET', 'HEAD']\n",
"@tornado.web.asynchronous...\n",
"file_data = files.get_static_data('./static/404.html')\n",
"file_data = '404 Not Found'\n",
"self.set_status(200, 'OK')\n",
"self._headers = tornado.httputil.HTTPHeaders()\n",
"self.add_header('Cache-Control', 'max-age=0')\n",
"self.add_header('Connection', 'close')\n",
"self.add_header('Content-Type', 'text/html')\n",
"self.add_header('Content-Length', str(len(file_data)))\n",
"self.write(file_data)\n",
"self.flush()\n",
"self.finish()\n",
"return self\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_7(VAR_13, VAR_2, VAR_5, VAR_12):...\n",
"VAR_26 = VAR_13.request.body\n",
"VAR_13.request.body = None\n",
"VAR_2 = FUNC_1(VAR_2)\n",
"db.Filesystem.mkfile(VAR_2, VAR_5, VAR_12.username, VAR_26)\n",
"VAR_6.set_result('bzs_upload_success')\n"
] | [
"def save_file_async(alter_ego, target_path, file_name, working_user):...\n",
"upload_data = alter_ego.request.body\n",
"alter_ego.request.body = None\n",
"target_path = decode_hexed_b64_to_str(target_path)\n",
"db.Filesystem.mkfile(target_path, file_name, working_user.username, upload_data\n )\n",
"future.set_result('bzs_upload_success')\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def __init__(self, VAR_0=None):...\n",
"self.depth = 0\n",
"self.name = VAR_0\n",
"self.hosts = []\n",
"self._hosts = None\n",
"self.vars = {}\n",
"self.child_groups = []\n",
"self.parent_groups = []\n",
"self._hosts_cache = None\n",
"self.priority = 1\n"
] | [
"def __init__(self, name=None):...\n",
"self.depth = 0\n",
"self.name = name\n",
"self.hosts = []\n",
"self._hosts = None\n",
"self.vars = {}\n",
"self.child_groups = []\n",
"self.parent_groups = []\n",
"self._hosts_cache = None\n",
"self.priority = 1\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._state\n"
] | [
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._state\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"return self.extracted_cpcat.extractedtext_ptr\n"
] | [
"def get_extractedtext(self):...\n",
"return self.extracted_cpcat.extractedtext_ptr\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_40(self):...\n",
"self.cursor.execute('create table t1(a int, b int, c int, d int)')\n",
"self.cursor.execute('insert into t1 values(1,2,3,4)')\n",
"VAR_24 = self.cursor.execute('select * from t1').fetchone()\n",
"VAR_20 = VAR_24[:]\n",
"self.assertTrue(VAR_20 is VAR_24)\n",
"VAR_20 = VAR_24[:-1]\n",
"self.assertEqual(VAR_20, (1, 2, 3))\n",
"VAR_20 = VAR_24[0:4]\n",
"self.assertTrue(VAR_20 is VAR_24)\n"
] | [
"def test_row_slicing(self):...\n",
"self.cursor.execute('create table t1(a int, b int, c int, d int)')\n",
"self.cursor.execute('insert into t1 values(1,2,3,4)')\n",
"row = self.cursor.execute('select * from t1').fetchone()\n",
"result = row[:]\n",
"self.assertTrue(result is row)\n",
"result = row[:-1]\n",
"self.assertEqual(result, (1, 2, 3))\n",
"result = row[0:4]\n",
"self.assertTrue(result is row)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_40(VAR_87):...\n",
"return filterfalse(self.is_rule, VAR_87)\n"
] | [
"def files(items):...\n",
"return filterfalse(self.is_rule, items)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_7(self):...\n",
"return self.content\n"
] | [
"def read(self):...\n",
"return self.content\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"return HttpResponseRedirect(self.failure_url)\n"
] | [
"def login_failure(self):...\n",
"return HttpResponseRedirect(self.failure_url)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_8(VAR_24):...\n",
"return binary_to_object_id(VAR_24).redis_shard_hash() % len(self.state.\n redis_clients)\n"
] | [
"def to_shard_index(id_bin):...\n",
"return binary_to_object_id(id_bin).redis_shard_hash() % len(self.state.\n redis_clients)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@utils.synchronized('3par', external=True)...\n",
"self.common.client_login()\n",
"self.common.create_snapshot(VAR_8)\n",
"self.common.client_logout()\n"
] | [
"@utils.synchronized('3par', external=True)...\n",
"self.common.client_login()\n",
"self.common.create_snapshot(snapshot)\n",
"self.common.client_logout()\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@atomic...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_5 = self.get_repo_root()\n",
"VAR_22 = self.get_branches(VAR_5)\n",
"if not self.quiet:\n",
"print('\\n'.join(VAR_22))\n",
"return VAR_22\n"
] | [
"@atomic...\n",
"\"\"\"docstring\"\"\"\n",
"fs_repo_root = self.get_repo_root()\n",
"branches = self.get_branches(fs_repo_root)\n",
"if not self.quiet:\n",
"print('\\n'.join(branches))\n",
"return branches\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Return'"
] |
[
"@VAR_0.route('/department/<department>', methods=['GET'])...\n",
"VAR_8 = FUNC_2()\n",
"VAR_0 = ProductsRepository.get_department_products(VAR_8, VAR_4)\n",
"VAR_10 = ProductsRepository.get_total_departments_products(VAR_8, VAR_4)\n",
"VAR_9 = ceil(VAR_10 / VAR_8['perPage'])\n",
"return jsonify(VAR_0=products, VAR_10=total_products, VAR_9=total_pages)\n"
] | [
"@products.route('/department/<department>', methods=['GET'])...\n",
"filters = get_filters()\n",
"products = ProductsRepository.get_department_products(filters, department)\n",
"total_products = ProductsRepository.get_total_departments_products(filters,\n department)\n",
"total_pages = ceil(total_products / filters['perPage'])\n",
"return jsonify(products=products, total_products=total_products,\n total_pages=total_pages)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_3():...\n",
"VAR_3 = FUNC_0()\n",
"VAR_4 = VAR_3.cursor()\n",
"VAR_4.execute('string')\n",
"VAR_4.execute('ALTER TABLE players OWNER TO postgres;')\n",
"VAR_4.execute('string')\n",
"VAR_4.execute('ALTER TABLE matches OWNER TO postgres;')\n",
"VAR_3.commit()\n",
"VAR_4.close()\n",
"VAR_3.close()\n",
"return 0\n"
] | [
"def create():...\n",
"co = connect()\n",
"cu = co.cursor()\n",
"cu.execute(\n 'CREATE TABLE players(id serial NOT NULL,name text NOT NULL, country text NOT NULL, code text, CONSTRAINT players_pkey PRIMARY KEY (id))WITH (OIDS=FALSE);'\n )\n",
"cu.execute('ALTER TABLE players OWNER TO postgres;')\n",
"cu.execute(\n 'CREATE TABLE matches (id serial NOT NULL, p1 text NOT NULL, p2 text NOT NULL, \"timestamp\" text NOT NULL,CONSTRAINT matches_pkey PRIMARY KEY (id))WITH (OIDS=FALSE);'\n )\n",
"cu.execute('ALTER TABLE matches OWNER TO postgres;')\n",
"co.commit()\n",
"cu.close()\n",
"co.close()\n",
"return 0\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_17 = [VAR_28.mtime for VAR_28 in self.expanded_output if VAR_28.exists]\n",
"if self.benchmark and self.benchmark.exists:\n",
"VAR_17.append(self.benchmark.mtime)\n",
"if VAR_17:\n",
"return min(VAR_17)\n",
"return None\n"
] | [
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"existing = [f.mtime for f in self.expanded_output if f.exists]\n",
"if self.benchmark and self.benchmark.exists:\n",
"existing.append(self.benchmark.mtime)\n",
"if existing:\n",
"return min(existing)\n",
"return None\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_3(self):...\n",
"VAR_5 = [{'application': self.TEST_APP, 'stack': self.TEST_STACK,\n 'credentials': self.bindings['GCE_CREDENTIALS'], 'zone': self.TEST_ZONE,\n 'network': 'default', 'targetSize': 1, 'capacity': {'min': 1, 'max': 1,\n 'desired': 1}, 'availabilityZones': {self.TEST_REGION: [self.TEST_ZONE]\n }, 'loadBalancers': [self.__lb_name], 'instanceMetadata': {\n 'load-balancer-names': self.__lb_name}, 'cloudProvider': 'gce', 'image':\n self.bindings['TEST_GCE_IMAGE_NAME'], 'instanceType': 'f1-micro',\n 'initialNumReplicas': 1, 'type': 'createServerGroup', 'account': self.\n bindings['GCE_CREDENTIALS'], 'user': 'integration-tests'}]\n",
"VAR_6 = gcp.GceContractBuilder(self.gce_observer)\n",
"VAR_6.new_clause_builder('Instance Created', retryable_for_secs=150\n ).list_resources('instance-groups').contains_path_value('name', self.\n __server_group_name)\n",
"VAR_7 = self.agent.make_json_payload_from_kwargs(VAR_5=job, description=\n 'Server Group Test - create initial server group', application=self.\n TEST_APP)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'create_instances', data=payload, path=self.__path), contract=builder.\n build())\n"
] | [
"def create_instances(self):...\n",
"job = [{'application': self.TEST_APP, 'stack': self.TEST_STACK,\n 'credentials': self.bindings['GCE_CREDENTIALS'], 'zone': self.TEST_ZONE,\n 'network': 'default', 'targetSize': 1, 'capacity': {'min': 1, 'max': 1,\n 'desired': 1}, 'availabilityZones': {self.TEST_REGION: [self.TEST_ZONE]\n }, 'loadBalancers': [self.__lb_name], 'instanceMetadata': {\n 'load-balancer-names': self.__lb_name}, 'cloudProvider': 'gce', 'image':\n self.bindings['TEST_GCE_IMAGE_NAME'], 'instanceType': 'f1-micro',\n 'initialNumReplicas': 1, 'type': 'createServerGroup', 'account': self.\n bindings['GCE_CREDENTIALS'], 'user': 'integration-tests'}]\n",
"builder = gcp.GceContractBuilder(self.gce_observer)\n",
"builder.new_clause_builder('Instance Created', retryable_for_secs=150\n ).list_resources('instance-groups').contains_path_value('name', self.\n __server_group_name)\n",
"payload = self.agent.make_json_payload_from_kwargs(job=job, description=\n 'Server Group Test - create initial server group', application=self.\n TEST_APP)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'create_instances', data=payload, path=self.__path), contract=builder.\n build())\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"@VAR_0.route('/rename_column', methods=['POST'])...\n",
"VAR_1 = get_dataset_with_id(request.args.get('dataset_id'))\n",
"VAR_2 = request.form['column']\n",
"VAR_3 = request.form['new_name']\n",
"rename_attribute(VAR_1.working_copy, VAR_2, VAR_3)\n",
"flash('An unexpected error occured while renaming the column', 'danger')\n",
"flash('Column renamed successfully.', 'success')\n",
"create_action('Renamed column {0} to {1}'.format(VAR_2, VAR_3), VAR_1.id,\n current_user.id)\n",
"return redirect(request.referrer)\n"
] | [
"@_transform.route('/rename_column', methods=['POST'])...\n",
"dataset = get_dataset_with_id(request.args.get('dataset_id'))\n",
"col = request.form['column']\n",
"new_name = request.form['new_name']\n",
"rename_attribute(dataset.working_copy, col, new_name)\n",
"flash('An unexpected error occured while renaming the column', 'danger')\n",
"flash('Column renamed successfully.', 'success')\n",
"create_action('Renamed column {0} to {1}'.format(col, new_name), dataset.id,\n current_user.id)\n",
"return redirect(request.referrer)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_4(VAR_0, VAR_3):...\n",
"VAR_4 = VAR_0.cursor()\n",
"VAR_5 = 'ALTER TABLE Presets DROP COLUMN id;'\n",
"VAR_4.execute(VAR_5)\n",
"VAR_5 = (\n 'ALTER TABLE Presets ADD COLUMN id INT AUTO_INCREMENT PRIMARY KEY NOT NULL FIRST;'\n )\n",
"VAR_4.execute(VAR_5)\n",
"VAR_6 = Table('Presets')\n",
"VAR_7 = MySQLQuery.from_(VAR_6).select(VAR_6.description).where(VAR_6.id ==\n VAR_3)\n",
"print(VAR_7)\n",
"VAR_5 = str(VAR_7)\n",
"VAR_4.execute(VAR_5)\n",
"VAR_8 = VAR_4.fetchone()\n",
"VAR_9 = str(VAR_8)\n",
"return VAR_9[2:-3]\n"
] | [
"def get_descriptin(conn, key):...\n",
"cursor = conn.cursor()\n",
"quer = 'ALTER TABLE Presets DROP COLUMN id;'\n",
"cursor.execute(quer)\n",
"quer = (\n 'ALTER TABLE Presets ADD COLUMN id INT AUTO_INCREMENT PRIMARY KEY NOT NULL FIRST;'\n )\n",
"cursor.execute(quer)\n",
"extable = Table('Presets')\n",
"q = MySQLQuery.from_(extable).select(extable.description).where(extable.id ==\n key)\n",
"print(q)\n",
"quer = str(q)\n",
"cursor.execute(quer)\n",
"row = cursor.fetchone()\n",
"strrow = str(row)\n",
"return strrow[2:-3]\n"
] | [
0,
0,
0,
0,
0,
0,
0,
4,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_0(VAR_0):...\n",
"\"\"\"docstring\"\"\"\n",
"return '%s_%s' % (cfg['OAUTHCLIENT_SESSION_KEY_PREFIX'], VAR_0)\n"
] | [
"def token_session_key(remote_app):...\n",
"\"\"\"docstring\"\"\"\n",
"return '%s_%s' % (cfg['OAUTHCLIENT_SESSION_KEY_PREFIX'], remote_app)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"return 'check submission %s' % self.submission_id\n"
] | [
"def describe(self):...\n",
"return 'check submission %s' % self.submission_id\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_29(VAR_39):...\n",
"if not VAR_39 or VAR_39 == 'None':\n",
"VAR_39 = datetime.today().strftime('%Y-%m-%d')\n",
"VAR_39 = VAR_39[:10]\n",
"return datetime.strptime(VAR_39, '%Y-%m-%d')\n"
] | [
"def str_to_datetime(str):...\n",
"if not str or str == 'None':\n",
"str = datetime.today().strftime('%Y-%m-%d')\n",
"str = str[:10]\n",
"return datetime.strptime(str, '%Y-%m-%d')\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"@property...\n",
"return self._output\n"
] | [
"@property...\n",
"return self._output\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"import os\n",
"import argparse\n",
"from jinja2 import Environment, FileSystemLoader\n",
"def FUNC_0(VAR_0, VAR_1):...\n",
"VAR_3 = os.path.dirname(os.path.abspath(__file__))\n",
"VAR_4 = Environment(loader=FileSystemLoader(UTILS_DIR))\n",
"return VAR_4.get_template('templates/eb/config.yml').render(APPLICATION_NAME\n =application_name, DEFAULT_REGION=default_region)\n"
] | [
"import os\n",
"import argparse\n",
"from jinja2 import Environment, FileSystemLoader\n",
"def make_eb_config(application_name, default_region):...\n",
"UTILS_DIR = os.path.dirname(os.path.abspath(__file__))\n",
"j2_env = Environment(loader=FileSystemLoader(UTILS_DIR))\n",
"return j2_env.get_template('templates/eb/config.yml').render(APPLICATION_NAME\n =application_name, DEFAULT_REGION=default_region)\n"
] | [
0,
0,
0,
0,
0,
3,
0
] | [
"Import'",
"Import'",
"ImportFrom'",
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@tornado.gen.coroutine...\n",
"VAR_30 = list(['SUM({})'.format(VAR_41) for VAR_41 in VAR_6])\n",
"VAR_17 = 'string'.format(','.join(VAR_30))\n",
"VAR_18 = VAR_3, VAR_2\n",
"VAR_19 = yield VAR_1.execute(query=sql, VAR_18=params)\n",
"VAR_26 = VAR_19.fetchall()\n",
"VAR_31, VAR_32 = calendar.monthrange(VAR_2, VAR_3)\n",
"VAR_25 = {}\n",
"for VAR_21 in VAR_26:\n",
"VAR_18 = {}\n",
"return VAR_25\n",
"VAR_11 = VAR_21[0]\n",
"VAR_36 = 1\n",
"for VAR_41 in VAR_6:\n",
"VAR_18[VAR_41] = VAR_21[VAR_36]\n",
"VAR_25[VAR_11] = VAR_18\n",
"VAR_36 += 1\n"
] | [
"@tornado.gen.coroutine...\n",
"avg_list = list(['SUM({})'.format(col) for col in cols])\n",
"sql = (\n 'SELECT DAY(date), {} FROM reports JOIN boiler_room_reports ON(reports.id = report_id) WHERE MONTH(date) = %s and YEAR(date) = %s GROUP BY date;'\n .format(','.join(avg_list)))\n",
"params = month, year\n",
"cursor = yield tx.execute(query=sql, params=params)\n",
"data = cursor.fetchall()\n",
"start_week, month_range = calendar.monthrange(year, month)\n",
"res = {}\n",
"for row in data:\n",
"params = {}\n",
"return res\n",
"day = row[0]\n",
"i = 1\n",
"for col in cols:\n",
"params[col] = row[i]\n",
"res[day] = params\n",
"i += 1\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"AugAssign'"
] |
[
"def FUNC_1(VAR_0):...\n",
"VAR_8 = FUNC_0(VAR_0)\n",
"VAR_9 = VAR_8.content_src_dir\n",
"VAR_10 = VAR_8.content_dst_dir\n",
"VAR_3 = VAR_8.www_root or DEFAULT_PYWEB_CONTENT_DIR\n",
"VAR_11 = VAR_8.log_path or DEFAULT_PYWEB_LOG_DIR\n",
"logging.basicConfig(filename=os.path.join(logpath, 'pyweb-installer.log'),\n level=logging.DEBUG)\n",
"VAR_4 = logging.getLogger('pyweb-installer')\n",
"print('Installing %s' % VAR_9)\n",
"print('Logging to %s' % os.path.join(VAR_11, 'pyweb-installer.log'))\n",
"VAR_18 = CLASS_1(VAR_9, VAR_10, VAR_3, VAR_4=logger)\n",
"print('Installation failed: %s' % str(e))\n",
"print('Installation complete.')\n",
"VAR_18.install()\n",
"VAR_4.critical('Installation failed.')\n",
"VAR_4.info('Installation complete.')\n",
"exit(1)\n"
] | [
"def main(argv):...\n",
"args = parse_args(argv)\n",
"src_dir = args.content_src_dir\n",
"dst_dir = args.content_dst_dir\n",
"www_root = args.www_root or DEFAULT_PYWEB_CONTENT_DIR\n",
"logpath = args.log_path or DEFAULT_PYWEB_LOG_DIR\n",
"logging.basicConfig(filename=os.path.join(logpath, 'pyweb-installer.log'),\n level=logging.DEBUG)\n",
"logger = logging.getLogger('pyweb-installer')\n",
"print('Installing %s' % src_dir)\n",
"print('Logging to %s' % os.path.join(logpath, 'pyweb-installer.log'))\n",
"installer = ContentInstaller(src_dir, dst_dir, www_root, logger=logger)\n",
"print('Installation failed: %s' % str(e))\n",
"print('Installation complete.')\n",
"installer.install()\n",
"logger.critical('Installation failed.')\n",
"logger.info('Installation complete.')\n",
"exit(1)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self.config.get(self.section, 'signup_link')\n"
] | [
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self.config.get(self.section, 'signup_link')\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_36(VAR_47):...\n",
"return fast_relpath(VAR_47, get_buildroot())\n"
] | [
"def relative_to_exec_root(path):...\n",
"return fast_relpath(path, get_buildroot())\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"\"\"\"docstring\"\"\"\n",
"for operation in self._queue:\n",
"if operation.name not in VAR_0:\n",
"VAR_16 = self.expectation(self._observe.name, self._observe.wires)\n",
"VAR_10 = [(x.val if isinstance(x, Variable) else x) for x in operation.params]\n",
"self._deallocate()\n",
"self.apply(operation.name, operation.wires, *VAR_10)\n",
"return VAR_16\n"
] | [
"def execute_queued(self):...\n",
"\"\"\"docstring\"\"\"\n",
"for operation in self._queue:\n",
"if operation.name not in operator_map:\n",
"result = self.expectation(self._observe.name, self._observe.wires)\n",
"par = [(x.val if isinstance(x, Variable) else x) for x in operation.params]\n",
"self._deallocate()\n",
"self.apply(operation.name, operation.wires, *par)\n",
"return result\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"For",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_1(VAR_0, VAR_1):...\n",
"return os.utime(VAR_0, VAR_1, follow_symlinks=os.utime not in os.\n supports_follow_symlinks)\n"
] | [
"def lutime(f, times):...\n",
"return os.utime(f, times, follow_symlinks=os.utime not in os.\n supports_follow_symlinks)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_14 = type(self)()\n",
"VAR_14.charset = self.charset\n",
"if self._parts:\n",
"VAR_14._parts = list(self._parts)\n",
"VAR_14._path = self._path\n",
"VAR_14._leading_slash = self._leading_slash\n",
"return VAR_14\n",
"VAR_14._trailing_slash = self._trailing_slash\n"
] | [
"def clone(self):...\n",
"\"\"\"docstring\"\"\"\n",
"new_obj = type(self)()\n",
"new_obj.charset = self.charset\n",
"if self._parts:\n",
"new_obj._parts = list(self._parts)\n",
"new_obj._path = self._path\n",
"new_obj._leading_slash = self._leading_slash\n",
"return new_obj\n",
"new_obj._trailing_slash = self._trailing_slash\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Assign'"
] |
[
"def FUNC_0(VAR_0):...\n",
"VAR_6 = ['preferred', 'other', 'exceptions']\n",
"VAR_7 = VAR_0.head.commit.tree['LICENSES']\n",
"VAR_8 = CLASS_2()\n",
"for d in VAR_6:\n",
"for VAR_5 in VAR_7[d].traverse():\n",
"return VAR_8\n",
"if not os.path.isfile(VAR_5.path):\n",
"VAR_23 = None\n",
"for l in open(VAR_5.path).readlines():\n",
"if l.startswith('Valid-License-Identifier:'):\n",
"VAR_26 = l.split(':')[1].strip().upper()\n",
"if l.startswith('SPDX-Exception-Identifier:'):\n",
"if VAR_26 in VAR_8.licenses:\n",
"VAR_23 = l.split(':')[1].strip().upper()\n",
"if l.startswith('SPDX-Licenses:'):\n",
"VAR_8.licenses.append(VAR_26)\n",
"VAR_8.exceptions[VAR_23] = []\n",
"for lic in l.split(':')[1].upper().strip().replace(' ', '').replace('\\t', ''\n",
"if l.startswith('License-Text:'):\n",
"if not lic in VAR_8.licenses:\n",
"if VAR_23:\n",
"VAR_8.exceptions[VAR_23].append(lic)\n",
"if not len(VAR_8.exceptions[VAR_23]):\n",
"VAR_8.license_files += 1\n",
"VAR_8.exception_files += 1\n"
] | [
"def read_spdxdata(repo):...\n",
"license_dirs = ['preferred', 'other', 'exceptions']\n",
"lictree = repo.head.commit.tree['LICENSES']\n",
"spdx = SPDXdata()\n",
"for d in license_dirs:\n",
"for el in lictree[d].traverse():\n",
"return spdx\n",
"if not os.path.isfile(el.path):\n",
"exception = None\n",
"for l in open(el.path).readlines():\n",
"if l.startswith('Valid-License-Identifier:'):\n",
"lid = l.split(':')[1].strip().upper()\n",
"if l.startswith('SPDX-Exception-Identifier:'):\n",
"if lid in spdx.licenses:\n",
"exception = l.split(':')[1].strip().upper()\n",
"if l.startswith('SPDX-Licenses:'):\n",
"spdx.licenses.append(lid)\n",
"spdx.exceptions[exception] = []\n",
"for lic in l.split(':')[1].upper().strip().replace(' ', '').replace('\\t', ''\n",
"if l.startswith('License-Text:'):\n",
"if not lic in spdx.licenses:\n",
"if exception:\n",
"spdx.exceptions[exception].append(lic)\n",
"if not len(spdx.exceptions[exception]):\n",
"spdx.license_files += 1\n",
"spdx.exception_files += 1\n"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"For",
"For",
"Return'",
"Condition",
"Assign'",
"For",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"For",
"Condition",
"Condition",
"Condition",
"Expr'",
"Condition",
"AugAssign'",
"AugAssign'"
] |
[
"@bot.message_handler(content_types=['photo'])...\n",
"VAR_7 = users.find_one(VAR_1)\n",
"bot.send_message(VAR_7.chat_id, messages[VAR_7.language]['as_file'])\n",
"log.info('%s sent photo as a photo.', VAR_7)\n"
] | [
"@bot.message_handler(content_types=['photo'])...\n",
"user = users.find_one(message)\n",
"bot.send_message(user.chat_id, messages[user.language]['as_file'])\n",
"log.info('%s sent photo as a photo.', user)\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_12(self, VAR_10, VAR_12, **VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_5 = {}\n",
"VAR_5['volumeName'] = VAR_10['name']\n",
"VAR_5['serverName'] = VAR_12['host']\n",
"self._cliq_run_xml('unassignVolumeToServer', VAR_5)\n"
] | [
"def terminate_connection(self, volume, connector, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"cliq_args = {}\n",
"cliq_args['volumeName'] = volume['name']\n",
"cliq_args['serverName'] = connector['host']\n",
"self._cliq_run_xml('unassignVolumeToServer', cliq_args)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_3():...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_7 = {}\n",
"for arg in request.args:\n",
"VAR_8 = re.findall('_oc_(.*)', arg)\n",
"return VAR_7\n",
"if VAR_8:\n",
"VAR_7[VAR_8[0]] = request.args.get(arg), request.args.get('_od_' + VAR_8[0])\n"
] | [
"def get_order_args():...\n",
"\"\"\"docstring\"\"\"\n",
"orders = {}\n",
"for arg in request.args:\n",
"re_match = re.findall('_oc_(.*)', arg)\n",
"return orders\n",
"if re_match:\n",
"orders[re_match[0]] = request.args.get(arg), request.args.get('_od_' +\n re_match[0])\n"
] | [
0,
0,
0,
0,
0,
0,
0,
4
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"For",
"Assign'",
"Return'",
"Condition",
"Assign'"
] |
[
"def FUNC_2(self):...\n",
"VAR_1 = VAR_0.copy()\n",
"VAR_2 = self._get(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 302)\n",
"self.assertEqual(User.objects.count(), 2)\n",
"VAR_3 = User.objects.get(username='[email protected]')\n",
"self.assertEqual(VAR_3.email, '[email protected]')\n",
"self.assertEqual(VAR_3.first_name, 'Teemu')\n",
"self.assertEqual(VAR_3.last_name, 'Teekkari')\n",
"self.assertEqual(VAR_3.userprofile.student_id, '123453')\n"
] | [
"def test_valid_new(self):...\n",
"meta = DEF_SHIBD_META.copy()\n",
"response = self._get(meta)\n",
"self.assertEqual(response.status_code, 302)\n",
"self.assertEqual(User.objects.count(), 2)\n",
"user = User.objects.get(username='[email protected]')\n",
"self.assertEqual(user.email, '[email protected]')\n",
"self.assertEqual(user.first_name, 'Teemu')\n",
"self.assertEqual(user.last_name, 'Teekkari')\n",
"self.assertEqual(user.userprofile.student_id, '123453')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_3(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_15 = time.time()\n",
"VAR_16 = []\n",
"VAR_17 = ((VAR_8, remove) for VAR_8, (t, remove) in self.last_alive.\n iteritems() if VAR_15 - t > VAR_3)\n",
"for VAR_8, remove in VAR_17:\n",
"if remove:\n",
"for VAR_8 in VAR_16:\n",
"VAR_16.append(VAR_8)\n",
"self.last_alive[VAR_8] = VAR_15, True\n",
"VAR_35 = self.sessionhandler.sessions_from_csessid(VAR_8)\n",
"self.lineSend(VAR_8, ['ajax_keepalive', [], {}])\n",
"for VAR_20 in VAR_35:\n",
"VAR_20.disconnect()\n",
"self.last_alive.pop(VAR_8, None)\n",
"if not self.last_alive:\n",
"self.keep_alive.stop()\n",
"self.keep_alive = None\n"
] | [
"def _keepalive(self):...\n",
"\"\"\"docstring\"\"\"\n",
"now = time.time()\n",
"to_remove = []\n",
"keep_alives = ((csessid, remove) for csessid, (t, remove) in self.\n last_alive.iteritems() if now - t > _KEEPALIVE)\n",
"for csessid, remove in keep_alives:\n",
"if remove:\n",
"for csessid in to_remove:\n",
"to_remove.append(csessid)\n",
"self.last_alive[csessid] = now, True\n",
"sessions = self.sessionhandler.sessions_from_csessid(csessid)\n",
"self.lineSend(csessid, ['ajax_keepalive', [], {}])\n",
"for sess in sessions:\n",
"sess.disconnect()\n",
"self.last_alive.pop(csessid, None)\n",
"if not self.last_alive:\n",
"self.keep_alive.stop()\n",
"self.keep_alive = None\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"For",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"For",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Assign'"
] |
[
"@VAR_0.route('/cities/<city_id>', methods=['GET'])...\n",
"return get_by_id('cities', VAR_3)\n"
] | [
"@locations.route('/cities/<city_id>', methods=['GET'])...\n",
"return get_by_id('cities', city_id)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_5(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = '/api/apps'\n",
"VAR_5 = {'id': 'autotest'}\n",
"VAR_3 = self.client.post(VAR_2, json.dumps(VAR_5), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_3.status_code, 201)\n",
"VAR_4 = VAR_3.data['id']\n",
"VAR_6 = os.path.join(settings.DEIS_LOG_DIR, VAR_4 + '.log')\n",
"VAR_2 = '/api/apps/{app_id}/logs'.format(**locals())\n",
"VAR_3 = self.client.get(VAR_2)\n",
"self.assertIn('autotest created initial release', VAR_3.data)\n",
"self.assertEqual(VAR_3.status_code, 200)\n",
"os.remove(VAR_6)\n"
] | [
"def test_app_release_notes_in_logs(self):...\n",
"\"\"\"docstring\"\"\"\n",
"url = '/api/apps'\n",
"body = {'id': 'autotest'}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 201)\n",
"app_id = response.data['id']\n",
"path = os.path.join(settings.DEIS_LOG_DIR, app_id + '.log')\n",
"url = '/api/apps/{app_id}/logs'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertIn('autotest created initial release', response.data)\n",
"self.assertEqual(response.status_code, 200)\n",
"os.remove(path)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_14(VAR_17, VAR_14=None):...\n",
"VAR_55 = FUNC_15(VAR_17)\n",
"for VAR_28 in VAR_55:\n",
"if re.search(VAR_28, VAR_14, re.IGNORECASE):\n",
"return False\n",
"return True\n"
] | [
"def player_in_bracket(player, bracket=None):...\n",
"tags = get_coalesce_tags(player)\n",
"for tag in tags:\n",
"if re.search(tag, bracket, re.IGNORECASE):\n",
"return False\n",
"return True\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_5(self, *VAR_2, **VAR_1):...\n",
"VAR_1 = self._set_xsrf_headers(VAR_1)\n",
"VAR_0 = super(CLASS_0, self).delete(*VAR_2, **kwargs)\n",
"self._store_xsrf_token(VAR_0)\n",
"return VAR_0\n"
] | [
"def delete(self, *args, **kwargs):...\n",
"kwargs = self._set_xsrf_headers(kwargs)\n",
"response = super(Session, self).delete(*args, **kwargs)\n",
"self._store_xsrf_token(response)\n",
"return response\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_0(self, VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_9 = os.path.join(VAR_1, 'saml2_settings.py')\n",
"VAR_2.update({'TOKEN_SERVICE_URL': 'http://login', 'SAML2_SETTINGS_MODULE':\n VAR_9, 'NO_AUTHN_URLS': ['^/test$']})\n",
"return VAR_2\n"
] | [
"def update_config(self, config):...\n",
"\"\"\"docstring\"\"\"\n",
"saml_config = os.path.join(HERE, 'saml2_settings.py')\n",
"config.update({'TOKEN_SERVICE_URL': 'http://login', 'SAML2_SETTINGS_MODULE':\n saml_config, 'NO_AUTHN_URLS': ['^/test$']})\n",
"return config\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_27(self, VAR_15):...\n",
""
] | [
"def add(self, item):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_12(self, **VAR_2):...\n",
"VAR_27 = super().get_context_data(**kwargs)\n",
"VAR_27['header'] = self.header\n",
"VAR_27['filter'] = self.filter\n",
"VAR_27['is_filtered'] = self.is_filtered\n",
"return VAR_27\n"
] | [
"def get_context_data(self, **kwargs):...\n",
"context = super().get_context_data(**kwargs)\n",
"context['header'] = self.header\n",
"context['filter'] = self.filter\n",
"context['is_filtered'] = self.is_filtered\n",
"return context\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_17(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.master = SosNode(self.config['master'], self.config)\n",
"self.log_debug('Failed to connect to master: %s' % e)\n",
"self._exit(\"\"\"Could not connect to master node.\nAborting...\"\"\", 1)\n"
] | [
"def connect_to_master(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.master = SosNode(self.config['master'], self.config)\n",
"self.log_debug('Failed to connect to master: %s' % e)\n",
"self._exit(\"\"\"Could not connect to master node.\nAborting...\"\"\", 1)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_12(self, VAR_21):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_24 = self.getfile(VAR_21)\n",
"return False\n",
"return VAR_24[VAR_2] == VAR_11\n"
] | [
"def islink(self, path):...\n",
"\"\"\"docstring\"\"\"\n",
"f = self.getfile(path)\n",
"return False\n",
"return f[A_TYPE] == T_LINK\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Return'",
"Return'"
] |
[
"def FUNC_8(self):...\n",
"VAR_7 = BokChoyTestSuite('', serversonly=True)\n",
"self.assertEqual(VAR_7.cmd, '')\n"
] | [
"def test_serversonly(self):...\n",
"suite = BokChoyTestSuite('', serversonly=True)\n",
"self.assertEqual(suite.cmd, '')\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_15(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.opt:\n",
"self.parse_args(VAR_16=False)\n",
"VAR_35 = {}\n",
"for VAR_39, VAR_0 in self.opt.items():\n",
"VAR_35[VAR_38(VAR_39)] = VAR_38(VAR_0)\n",
"for group in self._action_groups:\n",
"VAR_40 = {a.dest: getattr(self.args, a.dest, None) for a in group.\n _group_actions}\n",
"VAR_14 = argparse.Namespace(**group_dict)\n",
"VAR_41 = 0\n",
"for VAR_39 in VAR_14.__dict__:\n",
"if VAR_39 in VAR_35:\n",
"if VAR_41 == 0:\n",
"print('[ ' + group.title + ': ] ')\n",
"VAR_41 += 1\n",
"print('[ ' + VAR_39 + ': ' + VAR_35[VAR_39] + ' ]')\n"
] | [
"def print_args(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.opt:\n",
"self.parse_args(print_args=False)\n",
"values = {}\n",
"for key, value in self.opt.items():\n",
"values[str(key)] = str(value)\n",
"for group in self._action_groups:\n",
"group_dict = {a.dest: getattr(self.args, a.dest, None) for a in group.\n _group_actions}\n",
"namespace = argparse.Namespace(**group_dict)\n",
"count = 0\n",
"for key in namespace.__dict__:\n",
"if key in values:\n",
"if count == 0:\n",
"print('[ ' + group.title + ': ] ')\n",
"count += 1\n",
"print('[ ' + key + ': ' + values[key] + ' ]')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Assign'",
"For",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Condition",
"Expr'",
"AugAssign'",
"Expr'"
] |
[
"def FUNC_7(VAR_12):...\n",
"VAR_3.execute('SELECT * FROM games WHERE ID = %i' % VAR_12)\n",
"VAR_12 = VAR_3.fetchone()\n",
"return VAR_12\n"
] | [
"def getGameID(ID):...\n",
"db.execute('SELECT * FROM games WHERE ID = %i' % ID)\n",
"ID = db.fetchone()\n",
"return ID\n"
] | [
0,
4,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Return'"
] |
[
"import json\n",
"import time\n",
"import pytest\n",
"from pytest_bdd import scenario, then, parsers\n",
"from tests import kube_utils\n",
"from tests import utils\n",
"@scenario('../features/pods_alive.feature', 'List Pods')...\n",
"@scenario('../features/pods_alive.feature', 'Exec in Pods')...\n",
"@scenario('../features/pods_alive.feature', 'Expected Pods')...\n",
"@then(parsers.parse(...\n",
"VAR_8 = 'string'\n",
"VAR_9 = VAR_0.check_output(VAR_8.format(VAR_1, VAR_2))\n",
"assert len(VAR_9.strip()) > 0, 'No {0} found in namespace {1}'.format(VAR_1,\n VAR_2)\n",
"@then(parsers.parse(...\n",
"VAR_6 = kube_utils.get_pods(VAR_0, VAR_4, VAR_2)\n",
"assert len(VAR_6\n ) == 1, 'Expected one (and only one) pod with label {l}, found {f}'.format(\n l=label, f=len(candidates))\n",
"VAR_7 = VAR_6[0]\n",
"VAR_8 = ' '.join(['kubectl', '--kubeconfig=/etc/kubernetes/admin.conf',\n 'exec', '--namespace {0}'.format(VAR_2), VAR_7['metadata']['name'], VAR_3])\n",
"VAR_0.check_output(VAR_8)\n",
"@then(parsers.parse(...\n",
"def FUNC_6():...\n",
"VAR_10 = kube_utils.get_pods(VAR_0, VAR_4, VAR_2='kube-system',\n status_phase='Running')\n",
"assert len(VAR_10) >= VAR_5\n",
"utils.retry(FUNC_6, times=10, wait=3)\n"
] | [
"import json\n",
"import time\n",
"import pytest\n",
"from pytest_bdd import scenario, then, parsers\n",
"from tests import kube_utils\n",
"from tests import utils\n",
"@scenario('../features/pods_alive.feature', 'List Pods')...\n",
"@scenario('../features/pods_alive.feature', 'Exec in Pods')...\n",
"@scenario('../features/pods_alive.feature', 'Expected Pods')...\n",
"@then(parsers.parse(...\n",
"cmd = (\n 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get {0} --namespace {1} -o custom-columns=:metadata.name'\n )\n",
"cmd_res = host.check_output(cmd.format(resource, namespace))\n",
"assert len(cmd_res.strip()) > 0, 'No {0} found in namespace {1}'.format(\n resource, namespace)\n",
"@then(parsers.parse(...\n",
"candidates = kube_utils.get_pods(host, label, namespace)\n",
"assert len(candidates\n ) == 1, 'Expected one (and only one) pod with label {l}, found {f}'.format(\n l=label, f=len(candidates))\n",
"pod = candidates[0]\n",
"cmd = ' '.join(['kubectl', '--kubeconfig=/etc/kubernetes/admin.conf',\n 'exec', '--namespace {0}'.format(namespace), pod['metadata']['name'],\n command])\n",
"host.check_output(cmd)\n",
"@then(parsers.parse(...\n",
"def _check_pods_count():...\n",
"pods = kube_utils.get_pods(host, label, namespace='kube-system',\n status_phase='Running')\n",
"assert len(pods) >= min_pods_count\n",
"utils.retry(_check_pods_count, times=10, wait=3)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
2,
2,
0,
0,
0,
0,
2,
2,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Condition",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assert'",
"Condition",
"Assign'",
"Assert'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"FunctionDef'",
"Assign'",
"Assert'",
"Expr'"
] |
[
"def __str__(self):...\n",
"return str(self.raw_chem_name) if self.raw_chem_name else ''\n"
] | [
"def __str__(self):...\n",
"return str(self.raw_chem_name) if self.raw_chem_name else ''\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_4(self, VAR_3):...\n",
"VAR_11 = VAR_3.split(',')\n",
"VAR_8 = 'ORDER BY '\n",
"for part in VAR_11:\n",
"VAR_8 += part[1:]\n",
"return VAR_8.rstrip(', ')\n",
"if part[0] == '-':\n",
"VAR_8 += ' DESC, '\n",
"VAR_8 += ' ASC, '\n"
] | [
"def create_sort_by(self, sort_by):...\n",
"parts = sort_by.split(',')\n",
"sql = 'ORDER BY '\n",
"for part in parts:\n",
"sql += part[1:]\n",
"return sql.rstrip(', ')\n",
"if part[0] == '-':\n",
"sql += ' DESC, '\n",
"sql += ' ASC, '\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"For",
"AugAssign'",
"Return'",
"Condition",
"AugAssign'",
"AugAssign'"
] |
[
"def FUNC_2(VAR_1, VAR_2, *VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_2:\n",
"if not VAR_2.startswith('test_'):\n",
"VAR_15 = [method for method in dir(VAR_1) if method.startswith('test_')]\n",
"VAR_2 = 'test_%s' % VAR_2\n",
"VAR_15 = [VAR_2]\n",
"return unittest.TestSuite([VAR_1(VAR_2, *VAR_3) for VAR_2 in VAR_15])\n"
] | [
"def load_tests(testclass, name, *args):...\n",
"\"\"\"docstring\"\"\"\n",
"if name:\n",
"if not name.startswith('test_'):\n",
"names = [method for method in dir(testclass) if method.startswith('test_')]\n",
"name = 'test_%s' % name\n",
"names = [name]\n",
"return unittest.TestSuite([testclass(name, *args) for name in names])\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_0(self):...\n",
"def FUNC_33(self):...\n",
"@api.public...\n",
"@api.require(lambda : True)...\n"
] | [
"def test_good(self):...\n",
"def some_other_method(self):...\n",
"@api.public...\n",
"@api.require(lambda : True)...\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"FunctionDef'",
"Condition",
"Condition"
] |
[
"def FUNC_9():...\n",
"if VAR_4 == VAR_5:\n",
"VAR_14 = 'string' % (VAR_4, VAR_5, VAR_5, VAR_4)\n",
"VAR_7.execute(VAR_14)\n",
"if VAR_7.fetchone()[0] > 0:\n"
] | [
"def _checkPairing():...\n",
"if winner == loser:\n",
"q = (\n \"\"\"\n SELECT COUNT(*) FROM matches\n WHERE (matches.winner_id = %s AND matches.loser_id = %s)\n OR (matches.winner_id = %s AND matches.loser_id = %s);\n \"\"\"\n % (winner, loser, loser, winner))\n",
"cur.execute(q)\n",
"if cur.fetchone()[0] > 0:\n"
] | [
0,
0,
4,
4,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Expr'",
"Condition"
] |
[
"def __lt__(self, VAR_16):...\n",
"VAR_39 = self.workflow._ruleorder.compare(self, VAR_16)\n",
"return VAR_39 < 0\n"
] | [
"def __lt__(self, rule):...\n",
"comp = self.workflow._ruleorder.compare(self, rule)\n",
"return comp < 0\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_29(VAR_13):...\n",
""
] | [
"def failing(request):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_42(self):...\n",
"VAR_32 = list()\n",
"for VAR_14 in self.get_columns_list():\n",
"if not self.is_relation(VAR_14):\n",
"return VAR_32\n",
"VAR_38 = self.get_property_first_col(VAR_14).name\n",
"VAR_32.append(VAR_14)\n",
"if not self.is_pk(VAR_38) and not self.is_fk(VAR_38) and not self.is_image(\n",
"VAR_32.append(VAR_14)\n"
] | [
"def get_search_columns_list(self):...\n",
"ret_lst = list()\n",
"for col_name in self.get_columns_list():\n",
"if not self.is_relation(col_name):\n",
"return ret_lst\n",
"tmp_prop = self.get_property_first_col(col_name).name\n",
"ret_lst.append(col_name)\n",
"if not self.is_pk(tmp_prop) and not self.is_fk(tmp_prop) and not self.is_image(\n",
"ret_lst.append(col_name)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_2(self, VAR_6):...\n",
"\"\"\"docstring\"\"\"\n",
"g.oidc_id_token = VAR_6\n",
"g.oidc_id_token_dirty = True\n"
] | [
"def set_cookie_id_token(self, id_token):...\n",
"\"\"\"docstring\"\"\"\n",
"g.oidc_id_token = id_token\n",
"g.oidc_id_token_dirty = True\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'"
] |
[
"def FUNC_3(self):...\n",
"VAR_7.environ['SWARMING_LOAD_TEST'] = '1'\n",
"self.assertEqual(['id', 'load_test'], sorted(bot_main.get_dimensions(None)))\n"
] | [
"def test_get_dimensions_load_test(self):...\n",
"os.environ['SWARMING_LOAD_TEST'] = '1'\n",
"self.assertEqual(['id', 'load_test'], sorted(bot_main.get_dimensions(None)))\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_30(self, VAR_47):...\n",
"VAR_69, VAR_73 = self.put('/mails', VAR_47)\n",
"return VAR_69, VAR_73\n"
] | [
"def put_mail(self, data):...\n",
"res, req = self.put('/mails', data)\n",
"return res, req\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_1():...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_5 = {}\n",
"for arg in request.args:\n",
"VAR_8 = re.findall('page_(.*)', arg)\n",
"return VAR_5\n",
"if VAR_8:\n",
"VAR_5[VAR_8[0]] = int(request.args.get(arg))\n"
] | [
"def get_page_args():...\n",
"\"\"\"docstring\"\"\"\n",
"pages = {}\n",
"for arg in request.args:\n",
"re_match = re.findall('page_(.*)', arg)\n",
"return pages\n",
"if re_match:\n",
"pages[re_match[0]] = int(request.args.get(arg))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"For",
"Assign'",
"Return'",
"Condition",
"Assign'"
] |
[
"def FUNC_13(VAR_9, VAR_7, VAR_11, VAR_10):...\n",
"if VAR_11 == 'POST':\n",
"return CLASS_0.session.post(FUNC_2(VAR_7), VAR_9=ToUtf8Json(data), headers=\n _HEADERS, VAR_10=timeout)\n",
"if VAR_11 == 'GET':\n",
"return CLASS_0.session.get(FUNC_2(VAR_7), headers=_HEADERS, VAR_10=timeout)\n"
] | [
"def SendRequest(data, handler, method, timeout):...\n",
"if method == 'POST':\n",
"return BaseRequest.session.post(_BuildUri(handler), data=ToUtf8Json(data),\n headers=_HEADERS, timeout=timeout)\n",
"if method == 'GET':\n",
"return BaseRequest.session.get(_BuildUri(handler), headers=_HEADERS,\n timeout=timeout)\n"
] | [
0,
0,
7,
0,
7
] | [
"FunctionDef'",
"Condition",
"Return'",
"Condition",
"Return'"
] |
[
"def __eq__(self, VAR_1):...\n",
"if not isinstance(VAR_1, CLASS_0):\n",
"return False\n",
"return self._uuid == VAR_1._uuid\n"
] | [
"def __eq__(self, other):...\n",
"if not isinstance(other, Host):\n",
"return False\n",
"return self._uuid == other._uuid\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_39(VAR_7, VAR_30=None):...\n",
"if 'challonge' in VAR_7:\n",
"VAR_12, VAR_113 = FUNC_5(VAR_7)\n",
"VAR_97 = constants.DISPLAY_MAP\n",
"VAR_46 = BeautifulSoup(VAR_12, 'html.parser')\n",
"for k in VAR_97:\n",
"VAR_114 = VAR_46.find('div', {'id': 'title'})\n",
"if k.lower() in VAR_7.lower():\n",
"if 'smash.gg' in VAR_7:\n",
"if VAR_114 and hasattr(VAR_114, 'title'):\n",
"VAR_125 = VAR_97[k]\n",
"VAR_115 = VAR_7.split('event')[0].split('/')[-2].split('-')\n",
"return VAR_7\n",
"VAR_123 = VAR_114.text.rstrip().lstrip()\n",
"VAR_2.info('url {} has no title'.format(VAR_7))\n",
"if VAR_30:\n",
"VAR_116 = [VAR_93.title() for VAR_93 in VAR_115]\n",
"VAR_124 = re.sub('[^a-z A-Z 0-9 # / \\\\ .]', '', VAR_123)\n",
"VAR_114 = VAR_46.find('h1', {'class': 'title'})\n",
"VAR_124 = '{} {}'.format(VAR_125, VAR_30)\n",
"return VAR_125\n",
"return ' '.join(VAR_116)\n",
"return VAR_124\n",
"if VAR_114:\n",
"return VAR_124\n",
"VAR_124 = VAR_114.find(text=True).lstrip().rstrip()\n",
"VAR_2.info('just found new title for url: {} - {}'.format(VAR_7, VAR_124))\n",
"return VAR_124\n"
] | [
"def get_display_base(url, counter=None):...\n",
"if 'challonge' in url:\n",
"html, _ = hit_url(url)\n",
"d_map = constants.DISPLAY_MAP\n",
"soup = BeautifulSoup(html, 'html.parser')\n",
"for k in d_map:\n",
"display_name = soup.find('div', {'id': 'title'})\n",
"if k.lower() in url.lower():\n",
"if 'smash.gg' in url:\n",
"if display_name and hasattr(display_name, 'title'):\n",
"base = d_map[k]\n",
"parts = url.split('event')[0].split('/')[-2].split('-')\n",
"return url\n",
"title = display_name.text.rstrip().lstrip()\n",
"LOG.info('url {} has no title'.format(url))\n",
"if counter:\n",
"display_list = [s.title() for s in parts]\n",
"name = re.sub('[^a-z A-Z 0-9 # / \\\\ .]', '', title)\n",
"display_name = soup.find('h1', {'class': 'title'})\n",
"name = '{} {}'.format(base, counter)\n",
"return base\n",
"return ' '.join(display_list)\n",
"return name\n",
"if display_name:\n",
"return name\n",
"name = display_name.find(text=True).lstrip().rstrip()\n",
"LOG.info('just found new title for url: {} - {}'.format(url, name))\n",
"return name\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Return'",
"Return'",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_4(VAR_15, VAR_16):...\n",
"VAR_33 = {}\n",
"for in_file, VAR_45 in VAR_15:\n",
"VAR_33[VAR_45] = FUNC_5(in_file, VAR_16)\n",
"return VAR_33\n"
] | [
"def build_tree(templates, config):...\n",
"res = {}\n",
"for in_file, out_file in templates:\n",
"res[out_file] = render_template(in_file, config)\n",
"return res\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Assign'",
"Return'"
] |
[
"def __init__(self):...\n",
"self.content = None\n",
"self.filled = False\n",
"def FUNC_0(self, VAR_0):...\n",
"if VAR_0 == 'L':\n",
"self.content = 'L'\n",
"if VAR_0 == 'R':\n",
"self.filled = True\n",
"self.content = 'R'\n",
"self.content = VAR_0\n",
"def FUNC_1(self):...\n",
"self.filled = True\n",
"return self.content\n"
] | [
"def __init__(self):...\n",
"self.content = None\n",
"self.filled = False\n",
"def set(self, content):...\n",
"if content == 'L':\n",
"self.content = 'L'\n",
"if content == 'R':\n",
"self.filled = True\n",
"self.content = 'R'\n",
"self.content = content\n",
"def get(self):...\n",
"self.filled = True\n",
"return self.content\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_15(VAR_8):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_13 = None\n",
"VAR_11 = None\n",
"VAR_33 = (\n \"host='localhost' dbname='data1000' user='postgres' password='postgres'\")\n",
"print(error)\n",
"if VAR_13 is not None:\n",
"print('Connecting to the PostgreSQL database...')\n",
"VAR_13.close()\n",
"return VAR_11\n",
"VAR_13 = psycopg2.connect(VAR_33)\n",
"print('Database connection closed.')\n",
"VAR_34 = VAR_13.cursor()\n",
"VAR_34.execute(VAR_8)\n",
"VAR_11 = VAR_34.fetchall()\n",
"print(VAR_11)\n",
"VAR_34.close()\n"
] | [
"def queryAll(query):...\n",
"\"\"\"docstring\"\"\"\n",
"conn = None\n",
"result = None\n",
"conn_string = (\n \"host='localhost' dbname='data1000' user='postgres' password='postgres'\")\n",
"print(error)\n",
"if conn is not None:\n",
"print('Connecting to the PostgreSQL database...')\n",
"conn.close()\n",
"return result\n",
"conn = psycopg2.connect(conn_string)\n",
"print('Database connection closed.')\n",
"cur = conn.cursor()\n",
"cur.execute(query)\n",
"result = cur.fetchall()\n",
"print(result)\n",
"cur.close()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Return'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(self):...\n",
"self._check_key(VAR_0)\n"
] | [
"def test_rsa_key(self):...\n",
"self._check_key(RSA_PUBKEY)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_0(self, VAR_5):...\n",
"VAR_14 = 'string'.format(VAR_5)\n",
"self.cur.execute(VAR_14)\n",
"return self.cur.fetchall()\n"
] | [
"def get_roster(self, server_id):...\n",
"sql = (\n \"\"\"SELECT username, role\n FROM roles\n WHERE roles.server_id = {0};\n \"\"\"\n .format(server_id))\n",
"self.cur.execute(sql)\n",
"return self.cur.fetchall()\n"
] | [
0,
4,
4,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_8(self):...\n",
"VAR_21 = self.agent.type_to_payload('deleteGoogleLoadBalancerDescription',\n {'region': self.bindings['TEST_GCE_REGION'], 'credentials': self.\n bindings['GCE_CREDENTIALS'], 'loadBalancerName': self.__use_lb_name})\n",
"VAR_20 = gcp.GceContractBuilder(self.gce_observer)\n",
"VAR_20.new_clause_builder('Health Check Removed').list_resources(\n 'http-health-checks').excludes_path_value('name', self.__use_lb_hc_name)\n",
"VAR_20.new_clause_builder('Target Pool Removed').list_resources('target-pools'\n ).excludes_path_value('name', self.__use_lb_tp_name)\n",
"VAR_20.new_clause_builder('Forwarding Rule Removed').list_resources(\n 'forwarding-rules').excludes_path_value('name', self.__use_lb_name)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'delete_load_balancer', data=payload, VAR_29='ops'), contract=builder.\n build())\n"
] | [
"def delete_load_balancer(self):...\n",
"payload = self.agent.type_to_payload('deleteGoogleLoadBalancerDescription',\n {'region': self.bindings['TEST_GCE_REGION'], 'credentials': self.\n bindings['GCE_CREDENTIALS'], 'loadBalancerName': self.__use_lb_name})\n",
"builder = gcp.GceContractBuilder(self.gce_observer)\n",
"builder.new_clause_builder('Health Check Removed').list_resources(\n 'http-health-checks').excludes_path_value('name', self.__use_lb_hc_name)\n",
"builder.new_clause_builder('Target Pool Removed').list_resources('target-pools'\n ).excludes_path_value('name', self.__use_lb_tp_name)\n",
"builder.new_clause_builder('Forwarding Rule Removed').list_resources(\n 'forwarding-rules').excludes_path_value('name', self.__use_lb_name)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'delete_load_balancer', data=payload, path='ops'), contract=builder.build()\n )\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"@VAR_1.route('/get_common_ingredients_with/<ingredient>')...\n",
"VAR_28 = VAR_3.query_common_ingredients_with(VAR_10)\n",
"if VAR_28 == -1:\n",
"return None\n",
"return VAR_28\n"
] | [
"@app.route('/get_common_ingredients_with/<ingredient>')...\n",
"result = database.query_common_ingredients_with(ingredient)\n",
"if result == -1:\n",
"return None\n",
"return result\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"self.uut.gives_corrected = True\n",
"VAR_1 = tuple(self.uut.process_output(['a', 'b'], 'filename', ['a', 'b']))\n",
"self.assertEqual((), VAR_1)\n",
"VAR_1 = tuple(self.uut.process_output(['a', 'b'], 'filename', ['a']))\n",
"self.assertEqual(len(VAR_1), 1)\n"
] | [
"def test_gives_corrected(self):...\n",
"self.uut.gives_corrected = True\n",
"out = tuple(self.uut.process_output(['a', 'b'], 'filename', ['a', 'b']))\n",
"self.assertEqual((), out)\n",
"out = tuple(self.uut.process_output(['a', 'b'], 'filename', ['a']))\n",
"self.assertEqual(len(out), 1)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"@staticmethod...\n",
"return VAR_82\n"
] | [
"@staticmethod...\n",
"return f\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_4(self):...\n",
"VAR_3 = reverse('users:update')\n",
"VAR_4 = {'purchase_step_form': {'purchase_step': PS_DAP},\n 'marital_status_form': {'status': SC_SI}, 'first_home_form': {\n 'firsthome': True}, 'house_type_form': {'house_type': HT_SF,\n 'house_age': HA_15, 'house_cond': HC_SL}, 'city_form': {\n 'preferred_city': ''}, 'max_budget_form': {'budget': 1200.59},\n 'current_rent_form': {'current_rent': 321.49}, 'how_soon_form': {\n 'how_soon': HS_3}, 'personal_profile_form': {'first_name':\n 'TestFirstName', 'last_name': 'TestLastName', 'zipcode': '10118',\n 'phone_number': '+263771819478', 'email': '[email protected]'}}\n",
"self.client.login(username='testuser', password='password')\n",
"self.assertTemplateUsed('users/update.html')\n",
"for VAR_6 in VAR_4:\n",
"VAR_5 = VAR_4[VAR_6]\n",
"VAR_4 = {'purchase_step': 8}\n",
"VAR_4[VAR_6][VAR_6] = 'Update'\n",
"self.client.post(VAR_3, VAR_4)\n",
"VAR_7 = self.client.post(VAR_3, VAR_5)\n",
"self.assertEqual(self.view.get_object().purchase_step, PS_DAP)\n",
"self.assertEqual(VAR_7.status_code, 302)\n",
"VAR_4 = {'status': 8}\n",
"self.assertTemplateUsed('users/update.html')\n",
"self.client.post(VAR_3, VAR_4)\n",
"self.assertEqual(self.view.get_object().status, None)\n",
"VAR_4 = {'house_type': 8, 'house_age': 8, 'house_cond': 8}\n",
"self.client.post(VAR_3, VAR_4)\n",
"self.assertEqual(self.view.get_object().house_type, None)\n",
"self.assertEqual(self.view.get_object().house_age, None)\n",
"self.assertEqual(self.view.get_object().house_cond, None)\n",
"VAR_4 = {'budget': 'TEXT'}\n",
"self.client.post(VAR_3, VAR_4)\n",
"self.assertEqual(self.view.get_object().budget, None)\n",
"VAR_4 = {'current_rent': 'TEXT'}\n",
"self.client.post(VAR_3, VAR_4)\n",
"self.assertEqual(self.view.get_object().current_rent, None)\n",
"VAR_4 = {'how_soon': 8}\n",
"self.client.post(VAR_3, VAR_4)\n",
"self.assertEqual(self.view.get_object().how_soon, None)\n",
"VAR_4 = {'first_name': 'TestFirstName', 'last_name': 'TestLastName',\n 'zipcode': '10118', 'phone_number': '+26334465657456774567', 'email':\n '[email protected]'}\n",
"self.client.post(VAR_3, VAR_4)\n",
"self.assertEqual(self.view.get_object().first_name, '')\n",
"self.assertEqual(self.view.get_object().zipcode, None)\n",
"self.assertEqual(self.view.get_object().email, 'testuser')\n"
] | [
"def test_updating_user_info(self):...\n",
"update_url = reverse('users:update')\n",
"data = {'purchase_step_form': {'purchase_step': PS_DAP},\n 'marital_status_form': {'status': SC_SI}, 'first_home_form': {\n 'firsthome': True}, 'house_type_form': {'house_type': HT_SF,\n 'house_age': HA_15, 'house_cond': HC_SL}, 'city_form': {\n 'preferred_city': ''}, 'max_budget_form': {'budget': 1200.59},\n 'current_rent_form': {'current_rent': 321.49}, 'how_soon_form': {\n 'how_soon': HS_3}, 'personal_profile_form': {'first_name':\n 'TestFirstName', 'last_name': 'TestLastName', 'zipcode': '10118',\n 'phone_number': '+263771819478', 'email': '[email protected]'}}\n",
"self.client.login(username='testuser', password='password')\n",
"self.assertTemplateUsed('users/update.html')\n",
"for form in data:\n",
"data_to_pass = data[form]\n",
"data = {'purchase_step': 8}\n",
"data[form][form] = 'Update'\n",
"self.client.post(update_url, data)\n",
"response = self.client.post(update_url, data_to_pass)\n",
"self.assertEqual(self.view.get_object().purchase_step, PS_DAP)\n",
"self.assertEqual(response.status_code, 302)\n",
"data = {'status': 8}\n",
"self.assertTemplateUsed('users/update.html')\n",
"self.client.post(update_url, data)\n",
"self.assertEqual(self.view.get_object().status, None)\n",
"data = {'house_type': 8, 'house_age': 8, 'house_cond': 8}\n",
"self.client.post(update_url, data)\n",
"self.assertEqual(self.view.get_object().house_type, None)\n",
"self.assertEqual(self.view.get_object().house_age, None)\n",
"self.assertEqual(self.view.get_object().house_cond, None)\n",
"data = {'budget': 'TEXT'}\n",
"self.client.post(update_url, data)\n",
"self.assertEqual(self.view.get_object().budget, None)\n",
"data = {'current_rent': 'TEXT'}\n",
"self.client.post(update_url, data)\n",
"self.assertEqual(self.view.get_object().current_rent, None)\n",
"data = {'how_soon': 8}\n",
"self.client.post(update_url, data)\n",
"self.assertEqual(self.view.get_object().how_soon, None)\n",
"data = {'first_name': 'TestFirstName', 'last_name': 'TestLastName',\n 'zipcode': '10118', 'phone_number': '+26334465657456774567', 'email':\n '[email protected]'}\n",
"self.client.post(update_url, data)\n",
"self.assertEqual(self.view.get_object().first_name, '')\n",
"self.assertEqual(self.view.get_object().zipcode, None)\n",
"self.assertEqual(self.view.get_object().email, 'testuser')\n"
] | [
0,
0,
0,
6,
0,
0,
0,
0,
0,
6,
6,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def __init__(self, VAR_7, VAR_14, *VAR_15, **VAR_16):...\n",
"CLASS_0.__init__(self, VAR_7, *VAR_15, **kw)\n",
"self._error = VAR_14\n"
] | [
"def __init__(self, param, error, *a, **kw):...\n",
"Validator.__init__(self, param, *a, **kw)\n",
"self._error = error\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'"
] |
[
"def FUNC_14(VAR_24=sys.argv):...\n",
"VAR_39 = FUNC_12(VAR_24)\n",
"if VAR_39.print_templates:\n",
"print(VAR_39.templates)\n",
"if not VAR_39.metadata:\n",
"return 0\n",
"if 'OS_CONFIG_FILES' in os.environ:\n",
"if VAR_39.templates is None:\n",
"VAR_28.error(e)\n",
"return 0\n",
"VAR_39.metadata = os.environ['OS_CONFIG_FILES'].split(':')\n",
"VAR_39.metadata = FUNC_13(VAR_39.os_config_files)\n",
"if VAR_39.key:\n",
"return 1\n",
"if not VAR_39.metadata and VAR_39.os_config_files == VAR_2:\n",
"FUNC_2(VAR_39.metadata, VAR_39.key, VAR_39.type, VAR_39.key_default, VAR_39\n .fallback_metadata)\n",
"FUNC_1(VAR_39.metadata, VAR_39.templates, VAR_39.output, VAR_39.validate,\n VAR_39.subhash, VAR_39.fallback_metadata)\n",
"VAR_28.warning('DEPRECATED: falling back to %s' % VAR_3)\n",
"VAR_28.info('success')\n",
"VAR_39.metadata = FUNC_13(VAR_3)\n"
] | [
"def main(argv=sys.argv):...\n",
"opts = parse_opts(argv)\n",
"if opts.print_templates:\n",
"print(opts.templates)\n",
"if not opts.metadata:\n",
"return 0\n",
"if 'OS_CONFIG_FILES' in os.environ:\n",
"if opts.templates is None:\n",
"logger.error(e)\n",
"return 0\n",
"opts.metadata = os.environ['OS_CONFIG_FILES'].split(':')\n",
"opts.metadata = load_list_from_json(opts.os_config_files)\n",
"if opts.key:\n",
"return 1\n",
"if not opts.metadata and opts.os_config_files == OS_CONFIG_FILES_PATH:\n",
"print_key(opts.metadata, opts.key, opts.type, opts.key_default, opts.\n fallback_metadata)\n",
"install_config(opts.metadata, opts.templates, opts.output, opts.validate,\n opts.subhash, opts.fallback_metadata)\n",
"logger.warning('DEPRECATED: falling back to %s' % OS_CONFIG_FILES_PATH_OLD)\n",
"logger.info('success')\n",
"opts.metadata = load_list_from_json(OS_CONFIG_FILES_PATH_OLD)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Return'",
"Condition",
"Condition",
"Expr'",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'"
] |
[
"@api.model...\n",
"VAR_58 = self.env['phone.common'].get_record_from_phone_number(VAR_42)\n",
"if VAR_58:\n",
"VAR_54 = self.browse(VAR_58[1])\n",
"return VAR_58 and VAR_54.lang\n"
] | [
"@api.model...\n",
"record = self.env['phone.common'].get_record_from_phone_number(phone)\n",
"if record:\n",
"partner = self.browse(record[1])\n",
"return record and partner.lang\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"@memoized_property...\n",
"return NativeToolchain.scoped_instance(self)\n"
] | [
"@memoized_property...\n",
"return NativeToolchain.scoped_instance(self)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"@staticmethod...\n",
"return FUNC_1(CLASS_0.PostDataToHandlerAsync(VAR_9, VAR_7, VAR_10))\n"
] | [
"@staticmethod...\n",
"return JsonFromFuture(BaseRequest.PostDataToHandlerAsync(data, handler,\n timeout))\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_6(VAR_9, VAR_8):...\n",
"VAR_10 = {}\n",
"for VAR_7 in VAR_9:\n",
"VAR_10[VAR_7] = FUNC_5(VAR_7, VAR_8)\n",
"return OrderedDict(sorted(VAR_10.items(), key=itemgetter(1)))\n"
] | [
"def generate_syscalls(syscall_names, bitness):...\n",
"syscalls = {}\n",
"for syscall_name in syscall_names:\n",
"syscalls[syscall_name] = get_syscall_number(syscall_name, bitness)\n",
"return OrderedDict(sorted(syscalls.items(), key=itemgetter(1)))\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Assign'",
"Return'"
] |
[
"def FUNC_14(self, VAR_17):...\n",
"VAR_21 = fs.split_path(VAR_17.path)\n",
"VAR_22 = len(VAR_21)\n",
"VAR_23 = min(self._lensplitpath, VAR_22)\n",
"VAR_24 = self._splitpath[:VAR_23] == VAR_21 and VAR_22 <= self._lensplitpath\n",
"if VAR_24 and VAR_22 not in self._store:\n",
"self._store[VAR_22] = []\n",
"return VAR_24\n"
] | [
"def does_intersect_path(self, pathctx):...\n",
"testpath = fs.split_path(pathctx.path)\n",
"lentestpath = len(testpath)\n",
"lenpath = min(self._lensplitpath, lentestpath)\n",
"does_pass = self._splitpath[:lenpath\n ] == testpath and lentestpath <= self._lensplitpath\n",
"if does_pass and lentestpath not in self._store:\n",
"self._store[lentestpath] = []\n",
"return does_pass\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"\"\"\"string\"\"\"\n",
"import sys\n",
"import citest.aws_testing as aws\n",
"import citest.json_contract as jc\n",
"import citest.service_testing as st\n",
"import spinnaker_testing as sk\n",
"import spinnaker_testing.gate as gate\n",
"\"\"\"string\"\"\"\n",
"@classmethod...\n",
"\"\"\"docstring\"\"\"\n",
"return gate.new_agent(VAR_1)\n"
] | [
"\"\"\"\nSmoke test to see if Spinnaker can interoperate with Amazon Web Services.\n\nSee testable_service/integration_test.py and spinnaker_testing/spinnaker.py\nfor more details.\n\nThe smoke test will use ssh to peek at the spinnaker configuration\nto determine the managed project it should verify, and to determine\nthe spinnaker account name to use when sending it commands.\n\nSample Usage:\n Assuming you have created $PASSPHRASE_FILE (which you should chmod 400)\n and $CITEST_ROOT points to the root directory of this repository\n (which is . if you execute this from the root)\n\n PYTHONPATH=$CITEST_ROOT:$CITEST_ROOT/spinnaker python $CITEST_ROOT/spinnaker/spinnaker_system/smoke_test.py --gce_ssh_passphrase_file=$PASSPHRASE_FILE --gce_project=$PROJECT --gce_zone=$ZONE --gce_instance=$INSTANCE\n --test_aws_zone=$AWS_ZONE --aws_profile=$AWS_PROFILE\nor\n PYTHONPATH=$CITEST_ROOT:$CITEST_ROOT/spinnaker python $CITEST_ROOT/spinnaker/spinnaker_system/smoke_test.py --native_hostname=host-running-smoke-test\n --test_aws_zone=$AWS_ZONE --aws_profile=$AWS_PROFILE\n\n Note that the $AWS_ZONE is not directly used, rather it is a standard\n parameter being used to infer the region. The test is going to pick\n some different availability zones within the region in order to test kato.\n These are currently hardcoded in.\n\"\"\"\n",
"import sys\n",
"import citest.aws_testing as aws\n",
"import citest.json_contract as jc\n",
"import citest.service_testing as st\n",
"import spinnaker_testing as sk\n",
"import spinnaker_testing.gate as gate\n",
"\"\"\"Defines the scenario for the smoke test.\n\n This scenario defines the different test operations.\n We're going to:\n Create a Spinnaker Application\n Create a Load Balancer\n Create a Server Group\n Delete each of the above (in reverse order)\n \"\"\"\n",
"@classmethod...\n",
"\"\"\"docstring\"\"\"\n",
"return gate.new_agent(bindings)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Expr'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Expr'",
"Condition",
"Docstring",
"Return'"
] |
[
"@staticmethod...\n",
"if VAR_6.last_run_at:\n",
"return VAR_6.schedule.remaining_estimate(last_run_at=obj.last_run_at)\n",
"VAR_23, VAR_24 = VAR_6.schedule.is_due(last_run_at=datetime.now(pytz.utc))\n",
"VAR_25 = datetime.now(pytz.utc) + timedelta(seconds=y)\n",
"return naturaltime(VAR_25)\n"
] | [
"@staticmethod...\n",
"if obj.last_run_at:\n",
"return obj.schedule.remaining_estimate(last_run_at=obj.last_run_at)\n",
"z, y = obj.schedule.is_due(last_run_at=datetime.now(pytz.utc))\n",
"date = datetime.now(pytz.utc) + timedelta(seconds=y)\n",
"return naturaltime(date)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_17(self, VAR_9, VAR_7):...\n",
"VAR_19 = self._stop_events[VAR_7]\n",
"VAR_20 = subprocess.Popen(VAR_9, stdin=subprocess.PIPE, stdout=subprocess.\n PIPE, stderr=subprocess.PIPE, shell=True)\n",
"VAR_21 = '\\x1b[2K\\x1b[0'\n",
"VAR_22 = (\n '\\x1b[2K\\x1b[A\\x1b[2K\\x1b[A\\x1b[2K\\x1b[A\\x1b[2K\\x1b[A\\x1b[2K\\x1b[A\\x1b[2K\\x1b[A\\x1b[2K\\x1b[0'\n )\n",
"while not VAR_19.is_set():\n",
"VAR_32 = VAR_20.stdout.readline().decode('utf-8')\n",
"self._job_percent[VAR_7] = 100\n",
"if len(VAR_32) == 0:\n",
"self.__process_status(VAR_7)\n",
"if VAR_20.poll() is not None:\n",
"VAR_32 = VAR_32.strip()\n",
"VAR_23 = VAR_20.poll()\n",
"VAR_19.set()\n",
"time.sleep(0.5)\n",
"VAR_33 = VAR_32.find(VAR_21)\n",
"self._job_exitstatus[VAR_7] = VAR_23\n",
"if VAR_33 != -1:\n",
"for _ in range(1000):\n",
"VAR_32 = VAR_32[VAR_33 + len(VAR_21):]\n",
"VAR_34 = VAR_32.find(VAR_22)\n",
"VAR_32 = VAR_20.stderr.readline().decode('utf-8')\n",
"logging.info('Copy process exited with exit status {}'.format(VAR_23))\n",
"if VAR_34 != -1:\n",
"if len(VAR_32) == 0:\n",
"VAR_19.set()\n",
"VAR_32 = VAR_32[VAR_34 + len(VAR_21):]\n",
"VAR_32 = VAR_32.replace(VAR_21, '')\n",
"VAR_32 = VAR_32.strip()\n",
"VAR_32 = VAR_32.replace(VAR_22, '')\n",
"self._job_error_text[VAR_7] += VAR_32\n",
"VAR_27 = re.search('(ERROR.*)', VAR_32)\n",
"self._job_error_text[VAR_7] += '\\n'\n",
"if VAR_27 is not None:\n",
"VAR_37 = VAR_27.groups()[0]\n",
"VAR_27 = re.search('([A-Za-z ]+):\\\\s*(.*)', VAR_32)\n",
"logging.error(VAR_37)\n",
"if VAR_27 is None:\n",
"self._job_error_text[VAR_7] += VAR_37\n",
"logging.info('No match in {}'.format(VAR_32))\n",
"VAR_35, VAR_31 = VAR_27.groups()\n",
"self._job_error_text[VAR_7] += '\\n'\n",
"time.sleep(0.5)\n",
"self._job_status[VAR_7][VAR_35] = VAR_31\n",
"self.__process_status(VAR_7)\n"
] | [
"def __execute_interactive(self, command, job_id):...\n",
"stop_event = self._stop_events[job_id]\n",
"process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=\n subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\n",
"reset_sequence1 = '\\x1b[2K\\x1b[0'\n",
"reset_sequence2 = (\n '\\x1b[2K\\x1b[A\\x1b[2K\\x1b[A\\x1b[2K\\x1b[A\\x1b[2K\\x1b[A\\x1b[2K\\x1b[A\\x1b[2K\\x1b[A\\x1b[2K\\x1b[0'\n )\n",
"while not stop_event.is_set():\n",
"line = process.stdout.readline().decode('utf-8')\n",
"self._job_percent[job_id] = 100\n",
"if len(line) == 0:\n",
"self.__process_status(job_id)\n",
"if process.poll() is not None:\n",
"line = line.strip()\n",
"exitstatus = process.poll()\n",
"stop_event.set()\n",
"time.sleep(0.5)\n",
"q1 = line.find(reset_sequence1)\n",
"self._job_exitstatus[job_id] = exitstatus\n",
"if q1 != -1:\n",
"for _ in range(1000):\n",
"line = line[q1 + len(reset_sequence1):]\n",
"q2 = line.find(reset_sequence2)\n",
"line = process.stderr.readline().decode('utf-8')\n",
"logging.info('Copy process exited with exit status {}'.format(exitstatus))\n",
"if q2 != -1:\n",
"if len(line) == 0:\n",
"stop_event.set()\n",
"line = line[q2 + len(reset_sequence1):]\n",
"line = line.replace(reset_sequence1, '')\n",
"line = line.strip()\n",
"line = line.replace(reset_sequence2, '')\n",
"self._job_error_text[job_id] += line\n",
"match = re.search('(ERROR.*)', line)\n",
"self._job_error_text[job_id] += '\\n'\n",
"if match is not None:\n",
"error = match.groups()[0]\n",
"match = re.search('([A-Za-z ]+):\\\\s*(.*)', line)\n",
"logging.error(error)\n",
"if match is None:\n",
"self._job_error_text[job_id] += error\n",
"logging.info('No match in {}'.format(line))\n",
"key, value = match.groups()\n",
"self._job_error_text[job_id] += '\\n'\n",
"time.sleep(0.5)\n",
"self._job_status[job_id][key] = value\n",
"self.__process_status(job_id)\n"
] | [
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"For",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"AugAssign'",
"Assign'",
"AugAssign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"AugAssign'",
"Expr'",
"Assign'",
"AugAssign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_8(self, VAR_9):...\n",
"if self.count:\n",
"self.scope['results'][start_url] += VAR_9['results'][start_url]\n",
"self.scope = VAR_9\n",
"self.count += 1\n"
] | [
"def updateScope(self, scope):...\n",
"if self.count:\n",
"self.scope['results'][start_url] += scope['results'][start_url]\n",
"self.scope = scope\n",
"self.count += 1\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"AugAssign'",
"Assign'",
"AugAssign'"
] |
[
"def FUNC_2(self):...\n",
"self.set_titlebar(self.headerbar)\n"
] | [
"def set_headerbar(self):...\n",
"self.set_titlebar(self.headerbar)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_9(VAR_11):...\n",
"return ray.ObjectID(VAR_11)\n"
] | [
"def binary_to_object_id(binary_object_id):...\n",
"return ray.ObjectID(binary_object_id)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_0(VAR_1, VAR_2, VAR_3, VAR_4=True):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_5 = VAR_2.course_instance\n",
"if VAR_5.technical_error_emails:\n",
"VAR_9 = VAR_5.technical_error_emails.split(',')\n",
"VAR_9 = (p.user.email for p in VAR_5.course.teachers.all() if p.user.email)\n",
"VAR_6 = '-'\n",
"if VAR_4:\n",
"VAR_6 = traceback.format_exc()\n",
"VAR_7 = settings.EXERCISE_ERROR_SUBJECT.format(course=instance.course.code,\n VAR_2=str(exercise))\n",
"VAR_8 = settings.EXERCISE_ERROR_DESCRIPTION.format(VAR_3=message,\n exercise_url=request.build_absolute_uri(exercise.get_absolute_url()),\n course_edit_url=request.build_absolute_uri(instance.get_url(\n 'course-details')), VAR_6=error_trace, request_fields=repr(request))\n",
"if VAR_9:\n",
"send_mail(VAR_7, VAR_8, settings.SERVER_EMAIL, VAR_9, True)\n",
"VAR_0.exception('Failed to send error emails.')\n"
] | [
"def email_course_error(request, exercise, message, exception=True):...\n",
"\"\"\"docstring\"\"\"\n",
"instance = exercise.course_instance\n",
"if instance.technical_error_emails:\n",
"recipients = instance.technical_error_emails.split(',')\n",
"recipients = (p.user.email for p in instance.course.teachers.all() if p.\n user.email)\n",
"error_trace = '-'\n",
"if exception:\n",
"error_trace = traceback.format_exc()\n",
"subject = settings.EXERCISE_ERROR_SUBJECT.format(course=instance.course.\n code, exercise=str(exercise))\n",
"body = settings.EXERCISE_ERROR_DESCRIPTION.format(message=message,\n exercise_url=request.build_absolute_uri(exercise.get_absolute_url()),\n course_edit_url=request.build_absolute_uri(instance.get_url(\n 'course-details')), error_trace=error_trace, request_fields=repr(request))\n",
"if recipients:\n",
"send_mail(subject, body, settings.SERVER_EMAIL, recipients, True)\n",
"logger.exception('Failed to send error emails.')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(VAR_7=None, VAR_8=0, VAR_9=0):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_7 is None:\n",
"return True\n",
"return False\n",
"VAR_21 = re.match('^([^;]+)(; length=([0-9]+))?$', VAR_7, re.IGNORECASE)\n",
"VAR_22 = parse_http_date(VAR_21.group(1))\n",
"VAR_23 = VAR_21.group(3)\n",
"if VAR_23 and int(VAR_23) != VAR_9:\n",
"if int(VAR_8) > VAR_22:\n"
] | [
"def was_modified_since(header=None, mtime=0, size=0):...\n",
"\"\"\"docstring\"\"\"\n",
"if header is None:\n",
"return True\n",
"return False\n",
"matches = re.match('^([^;]+)(; length=([0-9]+))?$', header, re.IGNORECASE)\n",
"header_mtime = parse_http_date(matches.group(1))\n",
"header_len = matches.group(3)\n",
"if header_len and int(header_len) != size:\n",
"if int(mtime) > header_mtime:\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.