lines listlengths 1 444 | raw_lines listlengths 1 444 | label listlengths 1 444 | type listlengths 1 444 |
|---|---|---|---|
[
"def FUNC_13(self):...\n",
"self._latest_job_id += 1\n",
"while self._job_id_exists(self._latest_job_id):\n",
"self._latest_job_id += 1\n",
"return self._latest_job_id\n"
] | [
"def _get_next_job_id(self):...\n",
"self._latest_job_id += 1\n",
"while self._job_id_exists(self._latest_job_id):\n",
"self._latest_job_id += 1\n",
"return self._latest_job_id\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"AugAssign'",
"Condition",
"AugAssign'",
"Return'"
] |
[
"def FUNC_3(self):...\n",
"\"\"\"docstring\"\"\"\n",
"for mda in client.media.get():\n",
"self.assertTrue(isinstance(mda, MediaInfo))\n"
] | [
"def test_list_media(self):...\n",
"\"\"\"docstring\"\"\"\n",
"for mda in client.media.get():\n",
"self.assertTrue(isinstance(mda, MediaInfo))\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"For",
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"VAR_1 = list(self.uut.process_output(['1.0|0: Info message\\n',\n '2.2|1: Normal message\\n', \"\"\"3.4|2: Major message\n\"\"\"], 'a/file.py', [\n 'original_file_lines_placeholder']))\n",
"self.assertEqual(len(VAR_1), 3)\n",
"self.assertEqual(VAR_1[0].origin, 'Lint')\n",
"s... | [
"def test_invalid_output(self):...\n",
"out = list(self.uut.process_output(['1.0|0: Info message\\n',\n '2.2|1: Normal message\\n', \"\"\"3.4|2: Major message\n\"\"\"], 'a/file.py', [\n 'original_file_lines_placeholder']))\n",
"self.assertEqual(len(out), 3)\n",
"self.assertEqual(out[0].origin, 'Lint')\n... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(self, VAR_0):...\n",
"return VAR_0.method != 'GET'\n"
] | [
"def rw_transaction(self, request):...\n",
"return request.method != 'GET'\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@property...\n",
"return self._log\n"
] | [
"@property...\n",
"return self._log\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_17(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = {'SEVERITY': {'LOW': 2}, 'CONFIDENCE': {'HIGH': 2}}\n",
"self.check_example('imports-function.py', VAR_2)\n"
] | [
"def test_imports_function(self):...\n",
"\"\"\"docstring\"\"\"\n",
"expect = {'SEVERITY': {'LOW': 2}, 'CONFIDENCE': {'HIGH': 2}}\n",
"self.check_example('imports-function.py', expect)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_6(self, VAR_51, VAR_44):...\n",
"VAR_51 = FUNC_3(VAR_51)\n",
"VAR_82 = None\n",
"if VAR_51:\n",
"VAR_82 = valid_login(VAR_51, VAR_44)\n",
"if not VAR_82:\n",
"return self.error()\n",
"return VAR_82\n"
] | [
"def run(self, user_name, password):...\n",
"user_name = chkuser(user_name)\n",
"user = None\n",
"if user_name:\n",
"user = valid_login(user_name, password)\n",
"if not user:\n",
"return self.error()\n",
"return user\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"self._mox.ReplayAll()\n",
"self.assertEqual(url_helper.UrlOpen('url', max_tries=-1), None)\n",
"self._mox.VerifyAll()\n"
] | [
"def testUrlOpenInvalidTryCount(self):...\n",
"self._mox.ReplayAll()\n",
"self.assertEqual(url_helper.UrlOpen('url', max_tries=-1), None)\n",
"self._mox.VerifyAll()\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"import argparse\n",
"import json\n",
"import logging\n",
"import os\n",
"import subprocess\n",
"import sys\n",
"import tempfile\n",
"from pystache import context\n",
"from os_apply_config import collect_config\n",
"from os_apply_config import config_exception as exc\n",
"from os_apply_config im... | [
"import argparse\n",
"import json\n",
"import logging\n",
"import os\n",
"import subprocess\n",
"import sys\n",
"import tempfile\n",
"from pystache import context\n",
"from os_apply_config import collect_config\n",
"from os_apply_config import config_exception as exc\n",
"from os_apply_config im... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Condition",
"Assign'... |
[
"def FUNC_10(self):...\n",
""
] | [
"def close(self):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_0(self):...\n",
"\"\"\"docstring\"\"\"\n",
"send_email(context_data={'milestone': 'first', 'students_number': 2,\n 'course_title': 'Test Course', 'lesson_title': 'Test Lesson',\n 'current_site': Site.objects.get_current(), 'course_id': 1,\n 'unit_lesson_id': 1, 'courselet_pk': 1}, from_email=... | [
"def test_send_email(self):...\n",
"\"\"\"docstring\"\"\"\n",
"send_email(context_data={'milestone': 'first', 'students_number': 2,\n 'course_title': 'Test Course', 'lesson_title': 'Test Lesson',\n 'current_site': Site.objects.get_current(), 'course_id': 1,\n 'unit_lesson_id': 1, 'courselet_pk': 1}, fr... | [
0,
0,
6,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Expr'"
] |
[
"def FUNC_39():...\n",
"from lib.evaluators.PyQt4Evaluator import Evaluator\n",
"return Evaluator()\n"
] | [
"def ev_init():...\n",
"from lib.evaluators.PyQt4Evaluator import Evaluator\n",
"return Evaluator()\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"ImportFrom'",
"Return'"
] |
[
"def FUNC_1(VAR_2):...\n",
"if not VAR_2 in VAR_0:\n",
"return 'Incorrect tag.'\n",
"VAR_13 = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) +\n '\\\\theory.db')\n",
"VAR_8 = VAR_13.cursor()\n",
"VAR_8.execute('select * from ' + VAR_2)\n",
"VAR_14 = VAR_8.fetchone()\n",
"VAR_15 = ''\n",... | [
"def get_theory_from_tag(tag):...\n",
"if not tag in available_tags:\n",
"return 'Incorrect tag.'\n",
"base = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) +\n '\\\\theory.db')\n",
"conn = base.cursor()\n",
"conn.execute('select * from ' + tag)\n",
"x = conn.fetchone()\n",
"s = ''\n",
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4
] | [
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"AugAssign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_13(self, VAR_9, VAR_10=None, VAR_11=None, VAR_17='', VAR_18='',...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_28 = self.get_and_check_task(VAR_9, VAR_10, VAR_11)\n",
"VAR_29 = VAR_28.get_tile_path(VAR_17, VAR_18, VAR_19)\n",
"if os.path.isfile(VAR_29):\n",
"VAR_32 = open(VAR_29, 'rb')\n",
"return Htt... | [
"def get(self, request, pk=None, project_pk=None, z='', x='', y=''):...\n",
"\"\"\"docstring\"\"\"\n",
"task = self.get_and_check_task(request, pk, project_pk)\n",
"tile_path = task.get_tile_path(z, x, y)\n",
"if os.path.isfile(tile_path):\n",
"tile = open(tile_path, 'rb')\n",
"return HttpResponse(FileW... | [
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_3():...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_11 = ['@jupyterlab/hub-extension', '@jupyter-widgets/jupyterlab-manager']\n",
"subprocess.check_output([os.path.join(USER_ENV_PREFIX, 'bin/jupyter'),\n 'labextension', 'install'] + VAR_11)\n"
] | [
"def ensure_jupyterlab_extensions():...\n",
"\"\"\"docstring\"\"\"\n",
"extensions = ['@jupyterlab/hub-extension',\n '@jupyter-widgets/jupyterlab-manager']\n",
"subprocess.check_output([os.path.join(USER_ENV_PREFIX, 'bin/jupyter'),\n 'labextension', 'install'] + extensions)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def __hash__(self):...\n",
"return hash(self._path)\n"
] | [
"def __hash__(self):...\n",
"return hash(self._path)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_2(VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"os.makedirs(STATE_DIR, mode=448, exist_ok=True)\n",
"FUNC_1()\n",
"systemd.reload_daemon()\n",
"VAR_25 = f.read()\n",
"VAR_26 = f.read()\n",
"VAR_9 = os.path.join(STATE_DIR, 'traefik-api.secret')\n",
"if not os.path.exists(VAR_9):\n",
"f.write... | [
"def ensure_jupyterhub_service(prefix):...\n",
"\"\"\"docstring\"\"\"\n",
"os.makedirs(STATE_DIR, mode=448, exist_ok=True)\n",
"remove_chp()\n",
"systemd.reload_daemon()\n",
"hub_unit_template = f.read()\n",
"traefik_unit_template = f.read()\n",
"proxy_secret_path = os.path.join(STATE_DIR, 'traefik-ap... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def __init__(self, VAR_4, VAR_5):...\n",
"self.prompts = ['A9#0>', 'A9#1>']\n",
"self.targets = devices['a9_bdi']\n",
"super().__init__(VAR_4, VAR_5)\n"
] | [
"def __init__(self, database, options):...\n",
"self.prompts = ['A9#0>', 'A9#1>']\n",
"self.targets = devices['a9_bdi']\n",
"super().__init__(database, options)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def __init__(self, VAR_1=None, VAR_2=5):...\n",
"self.size = VAR_2\n",
"self.data = VAR_1 or []\n"
] | [
"def __init__(self, list=None, size=5):...\n",
"self.size = size\n",
"self.data = list or []\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'"
] |
[
"def FUNC_6(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = self.client.get('/api/apps')\n",
"self.assertEqual(VAR_6.status_code, 200)\n",
"self.assertEqual(len(VAR_6.data['results']), 2)\n"
] | [
"def test_admin_can_list(self):...\n",
"\"\"\"docstring\"\"\"\n",
"response = self.client.get('/api/apps')\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(len(response.data['results']), 2)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def __init__(self, VAR_6):...\n",
"super(CLASS_3, self).__init__(VAR_6)\n",
"self.events = []\n"
] | [
"def __init__(self, resource):...\n",
"super(TestResourceTraversalIterator, self).__init__(resource)\n",
"self.events = []\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'"
] |
[
"def FUNC_1(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_18 = ['hp3par_api_url', 'hp3par_username', 'hp3par_password', 'san_ip',\n 'san_login', 'san_password']\n",
"self.common.check_flags(self.configuration, VAR_18)\n"
] | [
"def _check_flags(self):...\n",
"\"\"\"docstring\"\"\"\n",
"required_flags = ['hp3par_api_url', 'hp3par_username', 'hp3par_password',\n 'san_ip', 'san_login', 'san_password']\n",
"self.common.check_flags(self.configuration, required_flags)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_50(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = {'SEVERITY': {'LOW': 11}, 'CONFIDENCE': {'HIGH': 11}}\n",
"self.check_example('partial_path_process.py', VAR_2)\n"
] | [
"def test_partial_path(self):...\n",
"\"\"\"docstring\"\"\"\n",
"expect = {'SEVERITY': {'LOW': 11}, 'CONFIDENCE': {'HIGH': 11}}\n",
"self.check_example('partial_path_process.py', expect)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_4(self, VAR_8, VAR_9=False, VAR_10=False):...\n",
"VAR_22 = []\n",
"VAR_27 = VAR_9 and VAR_8 in self.uread\n",
"VAR_28 = VAR_10 and VAR_8 in self.uwrite\n",
"if VAR_27 or VAR_28:\n",
"VAR_22.append(self.vpath)\n",
"for _, VAR_21 in sorted(self.nodes.items()):\n",
"VAR_22.extend(VAR_21.user_t... | [
"def user_tree(self, uname, readable=False, writable=False):...\n",
"ret = []\n",
"opt1 = readable and uname in self.uread\n",
"opt2 = writable and uname in self.uwrite\n",
"if opt1 or opt2:\n",
"ret.append(self.vpath)\n",
"for _, vn in sorted(self.nodes.items()):\n",
"ret.extend(vn.user_tree(uname, r... | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"For",
"Expr'",
"Return'"
] |
[
"def FUNC_1():...\n",
"VAR_3 = VAR_5.cursor().execute(\n \"SELECT name FROM sqlite_master WHERE type='table';\").fetchall()\n",
"VAR_3 = [x[0] for x in VAR_3]\n",
"VAR_4 = 'SELECT * FROM {}'\n",
"for table in VAR_3:\n",
"pd.read_sql(VAR_4.format(table), VAR_5).to_csv('{}.csv'.format(table),\n index=... | [
"def dbtables_to_csv():...\n",
"table_names = conn.cursor().execute(\n \"SELECT name FROM sqlite_master WHERE type='table';\").fetchall()\n",
"table_names = [x[0] for x in table_names]\n",
"open_query = 'SELECT * FROM {}'\n",
"for table in table_names:\n",
"pd.read_sql(open_query.format(table), conn).t... | [
0,
0,
0,
4,
0,
4
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Expr'"
] |
[
"def FUNC_12(self, VAR_19, VAR_17, VAR_16):...\n",
"if self.immutable_file_test(VAR_17, VAR_16):\n",
"VAR_19['Cache-Control'] = 'max-age={0}, public, immutable'.format(self.FOREVER)\n",
"if self.max_age is not None:\n",
"VAR_19['Cache-Control'] = 'max-age={0}, public'.format(self.max_age)\n"
] | [
"def add_cache_headers(self, headers, path, url):...\n",
"if self.immutable_file_test(path, url):\n",
"headers['Cache-Control'] = 'max-age={0}, public, immutable'.format(self.FOREVER\n )\n",
"if self.max_age is not None:\n",
"headers['Cache-Control'] = 'max-age={0}, public'.format(self.max_age)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Assign'"
] |
[
"def FUNC_5(self):...\n",
"for VAR_30 in VAR_7(len(self.attkeys)):\n",
"if self.attkeys[VAR_30]:\n",
"if self._['alert']:\n",
"VAR_8 = self.sql_session.query(TempFileList)\n",
"return False\n",
"if not self._['title']:\n",
"VAR_8 = VAR_8.filter(TempFileList.key == self.attkeys[VAR_30])\n",
"self._['... | [
"def check_ann(self):...\n",
"for i in xrange(len(self.attkeys)):\n",
"if self.attkeys[i]:\n",
"if self._['alert']:\n",
"q = self.sql_session.query(TempFileList)\n",
"return False\n",
"if not self._['title']:\n",
"q = q.filter(TempFileList.key == self.attkeys[i])\n",
"self._['alert'] = '標題不能空白'\n",
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Condition",
"Condition",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Return'",
"Expr'"
] |
[
"def FUNC_8(VAR_17):...\n",
"if VAR_17 != -1:\n",
"VAR_24 = CLASS_0(self.sorted_menu[VAR_17][2])\n",
"VAR_25 = self.window.open_file(self.sorted_menu[VAR_17][2])\n"
] | [
"def open_the_file(index):...\n",
"if index != -1:\n",
"urtext_file = UrtextFile(self.sorted_menu[index][2])\n",
"new_view = self.window.open_file(self.sorted_menu[index][2])\n"
] | [
0,
0,
1,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'"
] |
[
"def FUNC_6(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_4 = '/some/path_%d' % randint(0, 1000000)\n",
"client.media.add(PHO_DEV_DIR, 'POSIX', None, VAR_4, locked=False)\n",
"VAR_5 = client.media.get(id=label)[0]\n",
"self.assertFalse(VAR_5.is_locked())\n",
"client.media.lock([VAR_5])\n",
"client.med... | [
"def test_media_lock_unlock(self):...\n",
"\"\"\"docstring\"\"\"\n",
"label = '/some/path_%d' % randint(0, 1000000)\n",
"client.media.add(PHO_DEV_DIR, 'POSIX', None, label, locked=False)\n",
"media = client.media.get(id=label)[0]\n",
"self.assertFalse(media.is_locked())\n",
"client.media.lock([media])\n... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"@staticmethod...\n",
"return users.is_current_user_admin()\n"
] | [
"@staticmethod...\n",
"return users.is_current_user_admin()\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"@utils.synchronized('3par', external=True)...\n",
"\"\"\"docstring\"\"\"\n",
"self.common.client_login()\n",
"VAR_20 = self._create_host(VAR_6, VAR_9)\n",
"VAR_21 = self.common.create_vlun(VAR_6, VAR_20)\n",
"VAR_22 = self.common.get_ports()\n",
"self.common.client_logout()\n",
"VAR_23 = {'driver_vol... | [
"@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",
"ports = self.common.get_ports()\n",
"self.common.client_logout()\n",
"info = {'driver_volume... | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"\"\"\"string\"\"\"\n",
"from __future__ import absolute_import, division, print_function, unicode_literals\n",
"from functools import wraps\n",
"from pyramid.events import NewResponse\n",
"from pyramid.httpexceptions import HTTPForbidden\n",
"from . import _\n",
"VAR_0 = 'XSRF-TOKEN'\n",
"VAR_1 = 'X-... | [
"\"\"\"Make Pyramid play ball with AngularJS to achieve CSRF protection.\n\n To start using this module, include it in your application configuration::\n\n # Integrate with Angular for CSRF protection:\n config.include('bag.web.pyramid.angular_csrf')\n\n For any GET requests, this causes the res... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0
] | [
"Expr'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"FunctionDef'",
"Condition",
"ImportFrom'",
"Expr'",
"FunctionDef'",
"Assign'",
"Condition",
"Condition",
"Return'",
... |
[
"def FUNC_6(self, VAR_23):...\n",
"if VAR_23 and self.r_css_name.match(VAR_23):\n",
"return VAR_23\n"
] | [
"def run(self, name):...\n",
"if name and self.r_css_name.match(name):\n",
"return name\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'"
] |
[
"def FUNC_19(self):...\n",
"VAR_16 = self.mox.CreateMock(paramiko.SSHClient)\n",
"VAR_12 = self.mox.CreateMock(paramiko.Channel)\n",
"VAR_17 = self.mox.CreateMock(paramiko.Transport)\n",
"self.mox.StubOutWithMock(self.driver, '_get_output')\n",
"self.mox.StubOutWithMock(VAR_12, 'invoke_shell')\n",
"VAR_... | [
"def test_ssh_execute(self):...\n",
"ssh = self.mox.CreateMock(paramiko.SSHClient)\n",
"chan = self.mox.CreateMock(paramiko.Channel)\n",
"transport = self.mox.CreateMock(paramiko.Transport)\n",
"self.mox.StubOutWithMock(self.driver, '_get_output')\n",
"self.mox.StubOutWithMock(chan, 'invoke_shell')\n",
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_30(self):...\n",
"if VAR_54.flags.in_import or self.is_new(\n",
"return\n",
"VAR_42 = [VAR_6.fieldname for VAR_6 in self.meta.get('fields', {\n 'set_only_once': ('=', 1)})]\n",
"if VAR_42:\n",
"VAR_57 = VAR_54.db.get_value(self.doctype, self.name, VAR_42, as_dict=True)\n",
"for VAR_16 in VA... | [
"def _validate_constants(self):...\n",
"if frappe.flags.in_import or self.is_new(\n",
"return\n",
"constants = [d.fieldname for d in self.meta.get('fields', {'set_only_once':\n ('=', 1)})]\n",
"if constants:\n",
"values = frappe.db.get_value(self.doctype, self.name, constants, as_dict=True)\n",
"for ... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"For",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'"
] |
[
"def FUNC_0(self, **VAR_4):...\n",
"VAR_5 = super().get_context_data(**kwargs)\n",
"VAR_22 = self.object_list.count()\n",
"VAR_5['count'] = VAR_22\n",
"return VAR_5\n"
] | [
"def get_context_data(self, **kwargs):...\n",
"context = super().get_context_data(**kwargs)\n",
"count = self.object_list.count()\n",
"context['count'] = count\n",
"return context\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_1():...\n",
"VAR_3 = files.get_static_data('./static/home.html')\n",
"VAR_4 = users.get_user_by_cookie(self.get_cookie('user_active_login',\n default=''))\n",
"VAR_3 = preproc.preprocess_webpage(VAR_3, VAR_4)\n",
"VAR_2.set_result(VAR_3)\n"
] | [
"def get_index_html_async():...\n",
"file_data = files.get_static_data('./static/home.html')\n",
"working_user = users.get_user_by_cookie(self.get_cookie('user_active_login',\n default=''))\n",
"file_data = preproc.preprocess_webpage(file_data, working_user)\n",
"future.set_result(file_data)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def __init__(self, VAR_39=1024, **VAR_1):...\n",
"super().__init__(**kwargs)\n",
"self.degree_limit = VAR_39\n"
] | [
"def __init__(self, degree_limit=1024, **kwargs):...\n",
"super().__init__(**kwargs)\n",
"self.degree_limit = degree_limit\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'"
] |
[
"def FUNC_30(self):...\n",
"VAR_46 = FlaskForm.validate(self)\n",
"if not VAR_46:\n",
"return False\n",
"VAR_6 = FUNC_3(self.email.data)\n",
"if not VAR_6 or not FUNC_5(VAR_6, self.password.data):\n",
"self.password.errors.append('Invalid email or password')\n",
"self.user = VAR_6\n",
"return False\... | [
"def validate(self):...\n",
"rv = FlaskForm.validate(self)\n",
"if not rv:\n",
"return False\n",
"user = auth_get_user_by_email(self.email.data)\n",
"if not user or not auth_check_password(user, self.password.data):\n",
"self.password.errors.append('Invalid email or password')\n",
"self.user = user\n"... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Return'",
"Return'"
] |
[
"VAR_0 = 10\n",
"VAR_1 = True\n"
] | [
"culture_events_shown_on_home_page = 10\n",
"auto_cross_reference = True\n"
] | [
0,
0
] | [
"Assign'",
"Assign'"
] |
[
"def __hash__(self):...\n",
"return hash(self.name)\n"
] | [
"def __hash__(self):...\n",
"return hash(self.name)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@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_10(self):...\n",
"VAR_20 = open(VAR_2, 'w')\n",
"VAR_20.write(self.body)\n",
"VAR_20.close()\n",
"return None\n"
] | [
"def write_body_to_temp_file(self):...\n",
"temp_file = open(TEMP_FILE, 'w')\n",
"temp_file.write(self.body)\n",
"temp_file.close()\n",
"return None\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_7(self, *VAR_32, **VAR_33):...\n",
""
] | [
"def execute(self, *args, **kwargs):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_3(VAR_1):...\n",
""
] | [
"def parse_int(s):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_10():...\n",
"VAR_0.run(debug=True, host='0.0.0.0')\n"
] | [
"def main():...\n",
"app.run(debug=True, host='0.0.0.0')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def __init__(self, VAR_0):...\n",
"\"\"\"docstring\"\"\"\n",
"self.connection = False\n",
"self.db_path = VAR_0\n",
"if os.path.exists(self.db_path) and os.path.isfile(self.db_path):\n",
"self.connection = sqlite3.connect(self.db_path)\n",
"print('db does not exist')\n",
"self.cursor = self.connectio... | [
"def __init__(self, db_path):...\n",
"\"\"\"docstring\"\"\"\n",
"self.connection = False\n",
"self.db_path = db_path\n",
"if os.path.exists(self.db_path) and os.path.isfile(self.db_path):\n",
"self.connection = sqlite3.connect(self.db_path)\n",
"print('db does not exist')\n",
"self.cursor = self.conne... | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Assign'"
] |
[
"def __init__(self, VAR_1, VAR_2, VAR_3, VAR_4=None):...\n",
"GenericRequest.__init__(self, VAR_1, VAR_4)\n",
"self.url = self.base_url\n",
"self.username = VAR_2\n",
"self.loggedin = VAR_3\n"
] | [
"def __init__(self, browser, username, loggedin, base_url=None):...\n",
"GenericRequest.__init__(self, browser, base_url)\n",
"self.url = self.base_url\n",
"self.username = username\n",
"self.loggedin = loggedin\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_20(self, VAR_16):...\n",
"return self.meta.get_field(VAR_16).options\n"
] | [
"def get_table_field_doctype(self, fieldname):...\n",
"return self.meta.get_field(fieldname).options\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"import datetime\n",
"import json\n",
"import os\n",
"import sys\n",
"import unittest\n",
"from test_support import test_env\n",
"test_env.setup_test_env()\n",
"from google.appengine.api import oauth\n",
"from google.appengine.api import users\n",
"import webapp2\n",
"import webtest\n",
"from ... | [
"import datetime\n",
"import json\n",
"import os\n",
"import sys\n",
"import unittest\n",
"from test_support import test_env\n",
"test_env.setup_test_env()\n",
"from google.appengine.api import oauth\n",
"from google.appengine.api import users\n",
"import webapp2\n",
"import webtest\n",
"from ... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"Expr'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Expr'",
... |
[
"def FUNC_2(VAR_0, VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"assert 'db' in VAR_0, '`db` not set in config'\n",
"VAR_14 = VAR_0['db']\n",
"VAR_15, VAR_16 = os.path.splitext(VAR_14)\n",
"VAR_15 += '.db'\n",
"VAR_17 = os.path.join(DATA_DIRE, VAR_15)\n",
"if not os.path.isfile(VAR_17):\n",
"VAR_18 = s... | [
"def get_sqlite(settings, columns):...\n",
"\"\"\"docstring\"\"\"\n",
"assert 'db' in settings, '`db` not set in config'\n",
"name = settings['db']\n",
"fname, _ = os.path.splitext(name)\n",
"fname += '.db'\n",
"fil = os.path.join(DATA_DIRE, fname)\n",
"if not os.path.isfile(fil):\n",
"db = sqlite3.... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assert'",
"Assign'",
"Assign'",
"AugAssign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Return'"
] |
[
"def __hash__(self):...\n",
"return hash(self.cname) ^ hash(self.pname) ^ hash(self.ename)\n"
] | [
"def __hash__(self):...\n",
"return hash(self.cname) ^ hash(self.pname) ^ hash(self.ename)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_1(self, VAR_6, VAR_7=True, VAR_8=1):...\n",
"if not self.sshpool:\n",
"VAR_13 = self.configuration.san_password\n",
"VAR_12 = None\n",
"VAR_14 = self.configuration.san_private_key\n",
"VAR_17 = VAR_8\n",
"VAR_0.error(_('Error running SSH command: %s') % VAR_6)\n",
"VAR_15 = self.configuratio... | [
"def _run_ssh(self, command, check_exit_code=True, attempts=1):...\n",
"if not self.sshpool:\n",
"password = self.configuration.san_password\n",
"last_exception = None\n",
"privatekey = self.configuration.san_private_key\n",
"total_attempts = attempts\n",
"LOG.error(_('Error running SSH command: %s') % ... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"AugAssign'",
"Assign'",
"Return'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"@VAR_0.route('/saml2-metadata')...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_25 = entity_descriptor(current_app.saml2_config)\n",
"VAR_26 = make_response(VAR_25.to_string(), 200)\n",
"VAR_26.headers['Content-Type'] = 'text/xml; charset=utf8'\n",
"return VAR_26\n"
] | [
"@authn_views.route('/saml2-metadata')...\n",
"\"\"\"docstring\"\"\"\n",
"metadata = entity_descriptor(current_app.saml2_config)\n",
"response = make_response(metadata.to_string(), 200)\n",
"response.headers['Content-Type'] = 'text/xml; charset=utf8'\n",
"return response\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_24(self):...\n",
"VAR_13 = webapp2.Request({})\n",
"self.assertIsNone(handler.service_to_service_authentication(VAR_13))\n"
] | [
"def test_non_applicable(self):...\n",
"request = webapp2.Request({})\n",
"self.assertIsNone(handler.service_to_service_authentication(request))\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_0():...\n",
"return MySQLdb.connect(host='localhost', user='root', passwd='root', VAR_28\n ='ouija')\n"
] | [
"def create_db_connnection():...\n",
"return MySQLdb.connect(host='localhost', user='root', passwd='root', db='ouija'\n )\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_0(VAR_0):...\n",
"VAR_13 = getattr(VAR_0, 'rules', None)\n",
"if VAR_13:\n",
"VAR_13 = json.dumps(VAR_13, indent=4)\n",
"return safestring.mark_safe(VAR_13)\n"
] | [
"def get_rules_as_json(mapping):...\n",
"rules = getattr(mapping, 'rules', None)\n",
"if rules:\n",
"rules = json.dumps(rules, indent=4)\n",
"return safestring.mark_safe(rules)\n"
] | [
0,
0,
0,
0,
3
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_0(self, VAR_4, VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = 'string'.format(VAR_5=' '.join(start_urls), VAR_4=report_dir)\n",
"return VAR_6\n"
] | [
"def _expected_command(self, report_dir, start_urls):...\n",
"\"\"\"docstring\"\"\"\n",
"expected_statement = (\n 'pa11ycrawler run {start_urls} --pa11ycrawler-allowed-domains=localhost --pa11ycrawler-reports-dir={report_dir} --pa11ycrawler-deny-url-matcher=logout --pa11y-reporter=\"1.0-json\" --depth-limit=... | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Return'"
] |
[
"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\... | [
"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:... | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_14(self, VAR_12=True, VAR_13=False):...\n",
"VAR_6 = VAR_54._dict()\n",
"for VAR_16 in self.meta.get_valid_columns():\n",
"VAR_6[VAR_16] = self.get(VAR_16)\n",
"return VAR_6\n",
"if not VAR_12 and VAR_6[VAR_16] is None:\n",
"VAR_25 = self.meta.get_field(VAR_16)\n",
"if VAR_25:\n",
"if VAR_... | [
"def get_valid_dict(self, sanitize=True, convert_dates_to_str=False):...\n",
"d = frappe._dict()\n",
"for fieldname in self.meta.get_valid_columns():\n",
"d[fieldname] = self.get(fieldname)\n",
"return d\n",
"if not sanitize and d[fieldname] is None:\n",
"df = self.meta.get_field(fieldname)\n",
"if df... | [
0,
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'",
"For",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Condition"... |
[
"def FUNC_0(self):...\n",
"return hpcommon.HP3PARCommon(self.configuration)\n"
] | [
"def _init_common(self):...\n",
"return hpcommon.HP3PARCommon(self.configuration)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_4(self):...\n",
"self.driver._eql_execute = self.mox.CreateMock(self.driver._eql_execute)\n",
"VAR_1 = {'name': self.volume_name, 'size': 1, 'id': self.volid}\n",
"self.driver._eql_execute('volume', 'select', VAR_1['name'], 'show').AndRaise(\n processutils.ProcessExecutionError(stdout=\n \"\"\... | [
"def test_delete_absent_volume(self):...\n",
"self.driver._eql_execute = self.mox.CreateMock(self.driver._eql_execute)\n",
"volume = {'name': self.volume_name, 'size': 1, 'id': self.volid}\n",
"self.driver._eql_execute('volume', 'select', volume['name'], 'show').AndRaise(\n processutils.ProcessExecutionErr... | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_12(self, VAR_1, VAR_62=False, VAR_63=False, VAR_4=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if not urllib.parse.urlparse(VAR_1).scheme:\n",
"if not os.path.isabs(VAR_1) and self.included_stack:\n",
"if VAR_1 in self.included:\n",
"VAR_108 = os.path.dirname(self.included_stack[-1])\n",
"VAR_1 =... | [
"def include(self, snakefile, overwrite_first_rule=False, print_compilation=...\n",
"\"\"\"docstring\"\"\"\n",
"if not urllib.parse.urlparse(snakefile).scheme:\n",
"if not os.path.isabs(snakefile) and self.included_stack:\n",
"if snakefile in self.included:\n",
"current_path = os.path.dirname(self.include... | [
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",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Return'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Expr'"
] |
[
"def FUNC_34(VAR_39):...\n",
"self.fail()\n"
] | [
"def release(self2):...\n",
"self.fail()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@rest_utils.ajax()...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_20 = api.nova.server_list(VAR_1)[0]\n",
"return {'items': [s.to_dict() for s in VAR_20]}\n"
] | [
"@rest_utils.ajax()...\n",
"\"\"\"docstring\"\"\"\n",
"servers = api.nova.server_list(request)[0]\n",
"return {'items': [s.to_dict() for s in servers]}\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self, VAR_14, VAR_15=None, VAR_16=200):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_15 = (VAR_15 or {}).copy()\n",
"VAR_15.setdefault('css_file', None)\n",
"VAR_15.setdefault('js_file', None)\n",
"VAR_15.setdefault('navbar_tab_id', None)\n",
"VAR_15.setdefault('page_title', 'Untitled')\n",
"VAR... | [
"def reply(self, path, env=None, status=200):...\n",
"\"\"\"docstring\"\"\"\n",
"env = (env or {}).copy()\n",
"env.setdefault('css_file', None)\n",
"env.setdefault('js_file', None)\n",
"env.setdefault('navbar_tab_id', None)\n",
"env.setdefault('page_title', 'Untitled')\n",
"user = self.get_current_use... | [
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'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Assert'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_39(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = {'SEVERITY': {'MEDIUM': 14}, 'CONFIDENCE': {'HIGH': 14}}\n",
"self.check_example('urlopen.py', VAR_2)\n"
] | [
"def test_urlopen(self):...\n",
"\"\"\"docstring\"\"\"\n",
"expect = {'SEVERITY': {'MEDIUM': 14}, 'CONFIDENCE': {'HIGH': 14}}\n",
"self.check_example('urlopen.py', expect)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"@jwt.requires_auth...\n",
""
] | [
"@jwt.requires_auth...\n",
""
] | [
0,
0
] | [
"Condition",
"Condition"
] |
[
"def FUNC_6(self, VAR_11):...\n",
"return utils.sanitize_url(VAR_11)\n"
] | [
"def run(self, url):...\n",
"return utils.sanitize_url(url)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_0(VAR_0, VAR_1, VAR_2=('view_project',)):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = models.Project.objects.get(pk=project_pk, deleting=False)\n",
"return VAR_6\n",
"for perm in VAR_2:\n",
"if not VAR_0.user.has_perm(perm, VAR_6):\n"
] | [
"def get_and_check_project(request, project_pk, perms=('view_project',)):...\n",
"\"\"\"docstring\"\"\"\n",
"project = models.Project.objects.get(pk=project_pk, deleting=False)\n",
"return project\n",
"for perm in perms:\n",
"if not request.user.has_perm(perm, project):\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Return'",
"For",
"Condition"
] |
[
"def __init__(self, VAR_1=None, VAR_2=5):...\n",
"self.size = VAR_2\n",
"self.data = VAR_1 or []\n"
] | [
"def __init__(self, list=None, size=5):...\n",
"self.size = size\n",
"self.data = list or []\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'"
] |
[
"def __init__(self, VAR_18, *VAR_15, **VAR_16):...\n",
"CLASS_3.__init__(self, VAR_18, errors.NO_URL, *VAR_15, **kw)\n"
] | [
"def __init__(self, item, *a, **kw):...\n",
"VRequired.__init__(self, item, errors.NO_URL, *a, **kw)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_2(self):...\n",
"VAR_14 = utils.GetUnusedLocalhostPort()\n",
"self._temp_options_filename = options_file.name\n",
"json.dump(dict(self._user_options), options_file)\n",
"options_file.flush()\n",
"VAR_21 = [utils.PathToPythonInterpreter(), FUNC_0(), '--port={0}'.format(\n VAR_14), '--options_f... | [
"def _SetupServer(self):...\n",
"server_port = utils.GetUnusedLocalhostPort()\n",
"self._temp_options_filename = options_file.name\n",
"json.dump(dict(self._user_options), options_file)\n",
"options_file.flush()\n",
"args = [utils.PathToPythonInterpreter(), _PathToServerScript(),\n '--port={0}'.format(... | [
0,
0,
7,
7,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_27(self, VAR_75):...\n",
"def FUNC_39(VAR_101):...\n",
"VAR_101.threads = VAR_75\n",
"return VAR_101\n"
] | [
"def threads(self, threads):...\n",
"def decorate(ruleinfo):...\n",
"ruleinfo.threads = threads\n",
"return ruleinfo\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_38(self, VAR_19):...\n",
"return [view.datamodel.get_related_fk(self.obj) for view in VAR_19]\n"
] | [
"def get_related_fks(self, related_views):...\n",
"return [view.datamodel.get_related_fk(self.obj) for view in related_views]\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@patch('invenio.ext.session.interface.SessionInterface.save_session')...\n",
"from invenio.modules.oauthclient.client import oauth\n",
"VAR_9 = MagicMock()\n",
"VAR_9.get_id = MagicMock(return_value=1)\n",
"VAR_9.is_authenticated = MagicMock(return_value=True)\n",
"VAR_10 = c.get(url_for('oauthclient.log... | [
"@patch('invenio.ext.session.interface.SessionInterface.save_session')...\n",
"from invenio.modules.oauthclient.client import oauth\n",
"user = MagicMock()\n",
"user.get_id = MagicMock(return_value=1)\n",
"user.is_authenticated = MagicMock(return_value=True)\n",
"res = c.get(url_for('oauthclient.login', r... | [
5,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assert'",
"Assert'",
"Expr'",
"Assign'",
"Assert'"
] |
[
"def FUNC_7(self):...\n",
"VAR_11 = models.User.create_user('test:12345')\n",
"VAR_2 = EngineAuthRequest.blank('/auth/google')\n",
"VAR_2._load_session()\n",
"VAR_2.session.user_id = VAR_11.get_id()\n",
"VAR_2._load_user()\n",
"self.assertEqual(VAR_11, VAR_2.user)\n"
] | [
"def test__load_user(self):...\n",
"user = models.User.create_user('test:12345')\n",
"req = EngineAuthRequest.blank('/auth/google')\n",
"req._load_session()\n",
"req.session.user_id = user.get_id()\n",
"req._load_user()\n",
"self.assertEqual(user, req.user)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_7(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.update()\n",
"return self.data.keys()\n"
] | [
"def get_module_names(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.update()\n",
"return self.data.keys()\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Return'"
] |
[
"def FUNC_0():...\n",
"CLASS_0(BOT_TOKEN)\n"
] | [
"def main():...\n",
"MainPicSender(BOT_TOKEN)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_12(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = {'SEVERITY': {'LOW': 7}, 'CONFIDENCE': {'MEDIUM': 7}}\n",
"self.check_example('hardcoded-passwords.py', VAR_2)\n"
] | [
"def test_hardcoded_passwords(self):...\n",
"\"\"\"docstring\"\"\"\n",
"expect = {'SEVERITY': {'LOW': 7}, 'CONFIDENCE': {'MEDIUM': 7}}\n",
"self.check_example('hardcoded-passwords.py', expect)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_0(VAR_0='_Test Event', VAR_1=None):...\n",
"\"\"\"docstring\"\"\"\n",
"from frappe.utils import get_datetime\n",
"VAR_2 = frappe.get_doc({'doctype': 'Event', 'subject': VAR_0, 'event_type':\n 'Public', 'starts_on': get_datetime(VAR_1)}).insert(ignore_permissions=True\n )\n",
"return VAR_2\n"... | [
"def create_event(subject='_Test Event', starts_on=None):...\n",
"\"\"\"docstring\"\"\"\n",
"from frappe.utils import get_datetime\n",
"event = frappe.get_doc({'doctype': 'Event', 'subject': subject,\n 'event_type': 'Public', 'starts_on': get_datetime(starts_on)}).insert(\n ignore_permissions=True)\n",
... | [
0,
0,
0,
0,
4
] | [
"FunctionDef'",
"Docstring",
"ImportFrom'",
"Assign'",
"Return'"
] |
[
"def __str__(self):...\n",
"VAR_26 = list()\n",
"if self.forced:\n",
"VAR_26.append('Forced execution')\n",
"if self.noio:\n",
"VAR_26 = '; '.join(VAR_26)\n",
"VAR_26.append('Rules with neither input nor output files are always executed.')\n",
"if self.nooutput:\n",
"return VAR_26\n",
"VAR_26.appe... | [
"def __str__(self):...\n",
"s = list()\n",
"if self.forced:\n",
"s.append('Forced execution')\n",
"if self.noio:\n",
"s = '; '.join(s)\n",
"s.append('Rules with neither input nor output files are always executed.')\n",
"if self.nooutput:\n",
"return s\n",
"s.append(\n 'Rules with a run or shell... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Return'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_18(self):...\n",
"self.run_test_case(self.scenario.deregister_load_balancer_instances())\n"
] | [
"def test_w_deregister_load_balancer_instances(self):...\n",
"self.run_test_case(self.scenario.deregister_load_balancer_instances())\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_2(self):...\n",
"VAR_4 = {'username': 'first', 'password': 'password', 'email':\n 'autotest@deis.io'}\n",
"VAR_5 = '/api/auth/register'\n",
"VAR_6 = self.client.post(VAR_5, json.dumps(VAR_4), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_6.status_code, 201)\n",
"self.assert... | [
"def test_create(self):...\n",
"submit = {'username': 'first', 'password': 'password', 'email':\n 'autotest@deis.io'}\n",
"url = '/api/auth/register'\n",
"response = self.client.post(url, json.dumps(submit), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 201)\n",
"se... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
5,
0,
0,
5,
0,
5,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_11(self):...\n",
"VAR_9 = 'foo'\n",
"VAR_7 = BokChoyTestSuite('', VAR_9=test_dir)\n",
"self.assertEqual(VAR_7.cmd, self._expected_command(VAR_1=test_dir))\n"
] | [
"def test_test_dir(self):...\n",
"test_dir = 'foo'\n",
"suite = BokChoyTestSuite('', test_dir=test_dir)\n",
"self.assertEqual(suite.cmd, self._expected_command(name=test_dir))\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_10(self, VAR_13):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_10 = {'code': 'from google.appengine.ext import db\\n' + VAR_13,\n 'xsrf_token': self.xsrf_token}\n",
"VAR_21 = self.post('_ah/admin/interactive/execute', VAR_10)\n",
"VAR_22 = re.search(re.escape('<pre id=\"output\">') + '(.*?)' + re.esc... | [
"def query(self, cmd):...\n",
"\"\"\"docstring\"\"\"\n",
"data = {'code': 'from google.appengine.ext import db\\n' + cmd, 'xsrf_token':\n self.xsrf_token}\n",
"result = self.post('_ah/admin/interactive/execute', data)\n",
"match = re.search(re.escape('<pre id=\"output\">') + '(.*?)' + re.escape(\n \"\... | [
0,
0,
0,
5,
5,
5
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_9(self, VAR_0):...\n",
"if not cint(self.published):\n",
"VAR_0.full_name = get_fullname(self.owner)\n",
"VAR_0.updated = global_date_format(self.published_on)\n",
"if self.blogger:\n",
"VAR_0.blogger_info = frappe.get_doc('Blogger', self.blogger).as_dict()\n",
"VAR_0.description = self.blog_i... | [
"def get_context(self, context):...\n",
"if not cint(self.published):\n",
"context.full_name = get_fullname(self.owner)\n",
"context.updated = global_date_format(self.published_on)\n",
"if self.blogger:\n",
"context.blogger_info = frappe.get_doc('Blogger', self.blogger).as_dict()\n",
"context.descriptio... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"from .model import random_id\n",
"import subprocess\n",
"import json\n",
"import os\n",
"from .settings import settings\n",
"from .exceptions import NotFoundError, BadRequestError\n",
"def __init__(self, VAR_1, VAR_2=False):...\n",
"self.id = random_id(VAR_1.get('id'))\n",
"self.name = VAR_1['name'... | [
"from .model import random_id\n",
"import subprocess\n",
"import json\n",
"import os\n",
"from .settings import settings\n",
"from .exceptions import NotFoundError, BadRequestError\n",
"def __init__(self, obj, readonly=False):...\n",
"self.id = random_id(obj.get('id'))\n",
"self.name = obj['name']\n... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_19(self, *VAR_67):...\n",
"self._localrules.update(VAR_67)\n"
] | [
"def localrules(self, *rulenames):...\n",
"self._localrules.update(rulenames)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@auth.require(acl.is_bot)...\n",
"self.response.headers['Content-Type'] = 'text/x-python'\n",
"self.response.headers['Content-Disposition'\n ] = 'attachment; filename=\"swarming_bot_bootstrap.py\"'\n",
"self.response.out.write(bot_code.get_bootstrap(self.request.host_url).content)\n"
] | [
"@auth.require(acl.is_bot)...\n",
"self.response.headers['Content-Type'] = 'text/x-python'\n",
"self.response.headers['Content-Disposition'\n ] = 'attachment; filename=\"swarming_bot_bootstrap.py\"'\n",
"self.response.out.write(bot_code.get_bootstrap(self.request.host_url).content)\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_1(VAR_3, VAR_4):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_7 = \"\"\"\n SELECT boot_val\n FROM pg_settings\n WHERE name = '%s'\n \"\"\"\n",
"VAR_3.execute(VAR_7 % VAR_4)\n",
"return VAR_3.fetchone()[0]\n"
] | [
"def option_get_default_value(cursor, option):...\n",
"\"\"\"docstring\"\"\"\n",
"query = \"\"\"\n SELECT boot_val\n FROM pg_settings\n WHERE name = '%s'\n \"\"\"\n",
"cursor.execute(query % option)\n",
"return cursor.fetchone()[0]\n"
] | [
0,
0,
4,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_7():...\n",
"if os.path.isfile(CFG('dbname')):\n",
"return\n",
"VAR_0, VAR_10 = FUNC_0()\n",
"VAR_10.execute('CREATE TABLE ' + CFG('poll_table_name') + 'string')\n",
"VAR_10.execute('CREATE TABLE {}(name_option text, count integer)'.format(\n CFG('options_table_name')))\n",
"VAR_10.execute(... | [
"def init():...\n",
"if os.path.isfile(CFG('dbname')):\n",
"return\n",
"conn, c = connectDB()\n",
"c.execute('CREATE TABLE ' + CFG('poll_table_name') +\n '( name text, options text, has_tokens integer, show_results integer, ... | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_6(VAR_0):...\n",
"return render_form(VAR_0, True, url_for('auth_login'), 'Login',\n 'Invalid username or password.')\n"
] | [
"def render_loginInvalid(form):...\n",
"return render_form(form, True, url_for('auth_login'), 'Login',\n 'Invalid username or password.')\n"
] | [
0,
4
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_9(self, *VAR_15, **VAR_75):...\n",
""
] | [
"def newfn(self, *a, **env):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_11(self, VAR_14=None, VAR_15=False, VAR_16=False, VAR_17=1, VAR_18...\n",
"self.global_resources = dict() if VAR_52 is None else VAR_52\n",
"self.global_resources['_cores'] = VAR_17\n",
"self.global_resources['_nodes'] = VAR_18\n",
"def FUNC_2(VAR_87):...\n",
"return map(self._rules.__getitem__,... | [
"def execute(self, targets=None, dryrun=False, touch=False, cores=1, nodes=1,...\n",
"self.global_resources = dict() if resources is None else resources\n",
"self.global_resources['_cores'] = cores\n",
"self.global_resources['_nodes'] = nodes\n",
"def rules(items):...\n",
"return map(self._rules.__getitem... | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"VAR_1 = 'INVALID'\n",
"self.assertEqual(escape_path_argument('/home/usr/a-file', VAR_1),\n '/home/usr/a-file')\n",
"self.assertEqual(escape_path_argument('/home/us r/a-file with spaces.bla',\n VAR_1), '/home/us r/a-file with spaces.bla')\n",
"self.assertEqual(escape_path_arg... | [
"def test_escape_path_argument_unsupported(self):...\n",
"_type = 'INVALID'\n",
"self.assertEqual(escape_path_argument('/home/usr/a-file', _type),\n '/home/usr/a-file')\n",
"self.assertEqual(escape_path_argument('/home/us r/a-file with spaces.bla',\n _type), '/home/us r/a-file with spaces.bla')\n",
"s... | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_29(self, VAR_5):...\n",
"def FUNC_31():...\n",
"VAR_24 = vim.eval('tagfiles()')\n",
"VAR_25 = VAR_0.getcwd()\n",
"return [VAR_0.path.join(VAR_25, x) for x in VAR_24]\n"
] | [
"def _AddTagsFilesIfNeeded(self, extra_data):...\n",
"def GetTagFiles():...\n",
"tag_files = vim.eval('tagfiles()')\n",
"current_working_directory = os.getcwd()\n",
"return [os.path.join(current_working_directory, x) for x in tag_files]\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@VAR_0.route('/loadMailles', methods=['GET'])...\n",
"VAR_8 = getConnexion()\n",
"VAR_9 = 'string'\n",
"VAR_8.cur.execute(VAR_9)\n",
"VAR_11 = VAR_8.cur.fetchone()\n",
"VAR_8.closeAll()\n",
"return Response(flask.json.dumps(VAR_11), mimetype='application/json')\n"
] | [
"@addObs.route('/loadMailles', methods=['GET'])...\n",
"db = getConnexion()\n",
"sql = \"\"\" SELECT row_to_json(fc)\n FROM ( SELECT \n 'FeatureCollection' AS type, \n array_to_json(array_agg(f)) AS features\n FROM(\n SELECT 'Feature' ... | [
0,
0,
0,
4,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_5(VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"return decode(VAR_3['_saml2_session_name_id'])\n",
"return None\n"
] | [
"def _get_name_id(session):...\n",
"\"\"\"docstring\"\"\"\n",
"return decode(session['_saml2_session_name_id'])\n",
"return None\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'",
"Return'"
] |
[
"\"\"\"Tools to help run tests against the Django app.\"\"\"\n",
"import const\n",
"import utils\n",
"import scrape\n",
"import testutils.base\n",
"\"\"\"A base class for tests for the Django app.\"\"\"\n",
"VAR_0 = 'k'\n",
"def FUNC_0(self):...\n",
"super(CLASS_0, self).setUp()\n",
"self._xsrf_to... | [
"\"\"\"Tools to help run tests against the Django app.\"\"\"\n",
"import const\n",
"import utils\n",
"import scrape\n",
"import testutils.base\n",
"\"\"\"A base class for tests for the Django app.\"\"\"\n",
"_USER_ID = 'k'\n",
"def setUp(self):...\n",
"super(ViewTestsBase, self).setUp()\n",
"self.... | [
0,
0,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
5,
0,
5
] | [
"Expr'",
"Import'",
"Import'",
"Import'",
"Import'",
"Expr'",
"Assign'",
"FunctionDef'",
"Expr'",
"Assign'",
"FunctionDef'",
"Docstring",
"Expr'",
"FunctionDef'",
"Return'"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.