lines
sequencelengths 1
444
| raw_lines
sequencelengths 1
444
| label
sequencelengths 1
444
| type
sequencelengths 1
444
|
---|---|---|---|
[
"@FUNC_7...\n",
"\"\"\"docstring\"\"\"\n",
"if not current_user.is_authenticated():\n",
"return current_app.login_manager.unauthorized()\n",
"VAR_20 = RemoteAccount.get(user_id=current_user.get_id(), client_id=remote.\n consumer_key)\n",
"if VAR_20:\n",
"VAR_20.delete()\n",
"return redirect(url_for('oauthclient_settings.index'))\n"
] | [
"@oauth_error_handler...\n",
"\"\"\"docstring\"\"\"\n",
"if not current_user.is_authenticated():\n",
"return current_app.login_manager.unauthorized()\n",
"account = RemoteAccount.get(user_id=current_user.get_id(), client_id=remote\n .consumer_key)\n",
"if account:\n",
"account.delete()\n",
"return redirect(url_for('oauthclient_settings.index'))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Condition",
"Expr'",
"Return'"
] |
[
"def FUNC_3(self):...\n",
"self.handled_resp = 1\n",
"self.handled_remote = 1\n",
"self.handled_args = 1\n",
"self.handled_kwargs = 1\n"
] | [
"def handler_invalid(self):...\n",
"self.handled_resp = 1\n",
"self.handled_remote = 1\n",
"self.handled_args = 1\n",
"self.handled_kwargs = 1\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_7(self):...\n",
"self.object.run()\n",
"return '/threat_hunter'\n"
] | [
"def get_success_url(self):...\n",
"self.object.run()\n",
"return '/threat_hunter'\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Return'"
] |
[
"def FUNC_16(self):...\n",
"self.run_test_case(self.scenario.destroy_server_group('v000'))\n"
] | [
"def test_g_destroy_server_group_v000(self):...\n",
"self.run_test_case(self.scenario.destroy_server_group('v000'))\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return import_from_settings('LOGOUT_REDIRECT_URL', '/')\n"
] | [
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return import_from_settings('LOGOUT_REDIRECT_URL', '/')\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_9(self):...\n",
"self.run_test_case(self.scenario.create_app())\n"
] | [
"def test_a_create_app(self):...\n",
"self.run_test_case(self.scenario.create_app())\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"import os\n",
"import sys\n",
"import threading\n",
"import traceback\n",
"import types\n",
"from importlib.abc import InspectLoader\n",
"from cauldron import environ\n",
"from cauldron import templating\n",
"from cauldron.cli import threads\n",
"from cauldron.runner import redirection\n",
"from cauldron.session import projects\n",
"def FUNC_0(VAR_0: bool):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = threading.current_thread()\n",
"if isinstance(VAR_6, threads.CauldronThread):\n",
"VAR_6.is_executing = VAR_0\n",
"def FUNC_1(VAR_1: 'projects.Project', VAR_2: 'projects.ProjectStep') ->dict:...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_7 = VAR_2.definition.name.rsplit('.', 1)[0]\n",
"VAR_8 = types.ModuleType(VAR_7)\n",
"VAR_17 = f.read()\n",
"VAR_3 = InspectLoader.source_to_code(VAR_17, VAR_2.source_path)\n",
"return FUNC_2(VAR_1, VAR_17, VAR_4)\n",
"setattr(VAR_8, '__file__', VAR_2.source_path)\n",
"setattr(VAR_8, '__package__', '.'.join([VAR_1.id.replace('.', '-')] + VAR_2\n .filename.rsplit('.', 1)[0].split(os.sep)))\n",
"def FUNC_6():...\n",
"VAR_2.test_locals = dict()\n",
"VAR_2.test_locals.update(VAR_8.__dict__)\n",
"exec(VAR_3, VAR_2.test_locals)\n",
"FUNC_0(True)\n",
"VAR_18 = {'success': False}\n",
"FUNC_0(False)\n",
"threads.abort_thread()\n",
"VAR_18 = None\n",
"return {'success': True} if VAR_18 is None else VAR_18\n",
"if environ.modes.has(environ.modes.TESTING):\n",
"VAR_18 = FUNC_5(VAR_1, VAR_4)\n",
"FUNC_6()\n",
"exec(VAR_3, VAR_8.__dict__)\n",
"VAR_18 = None\n"
] | [
"import os\n",
"import sys\n",
"import threading\n",
"import traceback\n",
"import types\n",
"from importlib.abc import InspectLoader\n",
"from cauldron import environ\n",
"from cauldron import templating\n",
"from cauldron.cli import threads\n",
"from cauldron.runner import redirection\n",
"from cauldron.session import projects\n",
"def set_executing(on: bool):...\n",
"\"\"\"docstring\"\"\"\n",
"my_thread = threading.current_thread()\n",
"if isinstance(my_thread, threads.CauldronThread):\n",
"my_thread.is_executing = on\n",
"def run(project: 'projects.Project', step: 'projects.ProjectStep') ->dict:...\n",
"\"\"\"docstring\"\"\"\n",
"module_name = step.definition.name.rsplit('.', 1)[0]\n",
"module = types.ModuleType(module_name)\n",
"source_code = f.read()\n",
"code = InspectLoader.source_to_code(source_code, step.source_path)\n",
"return render_syntax_error(project, source_code, error)\n",
"setattr(module, '__file__', step.source_path)\n",
"setattr(module, '__package__', '.'.join([project.id.replace('.', '-')] +\n step.filename.rsplit('.', 1)[0].split(os.sep)))\n",
"def exec_test():...\n",
"step.test_locals = dict()\n",
"step.test_locals.update(module.__dict__)\n",
"exec(code, step.test_locals)\n",
"set_executing(True)\n",
"out = {'success': False}\n",
"set_executing(False)\n",
"threads.abort_thread()\n",
"out = None\n",
"return {'success': True} if out is None else out\n",
"if environ.modes.has(environ.modes.TESTING):\n",
"out = render_error(project, error)\n",
"exec_test()\n",
"exec(code, module.__dict__)\n",
"out = None\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
6,
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'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Expr'",
"Expr'",
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Assign'"
] |
[
"def FUNC_3(self, VAR_7):...\n",
"VAR_11 = VAR_7[0]\n",
"VAR_12 = VAR_7[1]\n",
"VAR_13 = self.G.nodes(1)[VAR_11][1]['keys']\n",
"VAR_14 = self.G.nodes(1)[VAR_12][1]['keys']\n",
"VAR_15 = VAR_13.intersection(VAR_14)\n",
"VAR_16 = set()\n",
"VAR_17 = 0\n",
"while not VAR_15.issubset(VAR_16):\n",
"VAR_25 = random.randint(0, self.size)\n",
"self.G[VAR_11][VAR_12]['lkvm'] = VAR_17\n",
"VAR_16.union(self.G.nodes(1)[VAR_25][1]['keys'])\n",
"VAR_17 = VAR_17 + 1\n"
] | [
"def calcLKVM(self, edge):...\n",
"i = edge[0]\n",
"j = edge[1]\n",
"iKeys = self.G.nodes(1)[i][1]['keys']\n",
"jKeys = self.G.nodes(1)[j][1]['keys']\n",
"sharedKeys = iKeys.intersection(jKeys)\n",
"c = set()\n",
"lkvm = 0\n",
"while not sharedKeys.issubset(c):\n",
"randNodeIndex = random.randint(0, self.size)\n",
"self.G[i][j]['lkvm'] = lkvm\n",
"c.union(self.G.nodes(1)[randNodeIndex][1]['keys'])\n",
"lkvm = lkvm + 1\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'"
] |
[
"def FUNC_3(VAR_3, VAR_6):...\n",
"VAR_2 = FUNC_2(VAR_3, 'rank', VAR_0)\n",
"VAR_11 = VAR_2[0][0]\n",
"VAR_12 = FUNC_0(\"SELECT {} FROM {} WHERE FUNCTION = '{}';\".format(VAR_11,\n VAR_1, VAR_6))\n",
"if VAR_12[0][0] == True:\n",
"return True\n",
"return False\n"
] | [
"def rank_check(id, function):...\n",
"query = check(id, 'rank', user_table)\n",
"rank = query[0][0]\n",
"query2 = fetch(\"SELECT {} FROM {} WHERE FUNCTION = '{}';\".format(rank,\n rank_permit_table, function))\n",
"if query2[0][0] == True:\n",
"return True\n",
"return False\n"
] | [
0,
4,
4,
4,
4,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_6(VAR_7, VAR_15):...\n",
"VAR_9 = VAR_7.find_where({'window_name': VAR_15})\n",
"return VAR_9\n"
] | [
"def find_window(session, window_name):...\n",
"window = session.find_where({'window_name': window_name})\n",
"return window\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"import hashlib\n",
"import os\n",
"import pandas as pd\n",
"def FUNC_0(VAR_0, VAR_1, **VAR_2):...\n",
"VAR_6 = '{}/{}?'.format(VAR_0, VAR_1)\n",
"VAR_7 = sorted(VAR_2.keys())\n",
"for key in VAR_7:\n",
"VAR_6 += '{}={}&'.format(key, VAR_2[key])\n",
"return hashlib.sha224(VAR_6.encode('utf8')).hexdigest()\n"
] | [
"import hashlib\n",
"import os\n",
"import pandas as pd\n",
"def query_hash(project_id, query_name, **query_params):...\n",
"id_string = '{}/{}?'.format(project_id, query_name)\n",
"keylist = sorted(query_params.keys())\n",
"for key in keylist:\n",
"id_string += '{}={}&'.format(key, query_params[key])\n",
"return hashlib.sha224(id_string.encode('utf8')).hexdigest()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"FunctionDef'",
"Assign'",
"Assign'",
"For",
"AugAssign'",
"Return'"
] |
[
"def FUNC_4(self):...\n",
"VAR_1 = 'http://my.url.com'\n",
"VAR_2 = 'True'\n",
"url_helper.urllib2.urlopen(mox.StrContains(VAR_1), timeout=mox.IgnoreArg()\n ).AndReturn(StringIO.StringIO(VAR_2))\n",
"self._mox.ReplayAll()\n",
"self.assertEqual(url_helper.UrlOpen(VAR_1, method='GET'), VAR_2)\n",
"self._mox.VerifyAll()\n"
] | [
"def testUrlOpenGETSuccess(self):...\n",
"url = 'http://my.url.com'\n",
"response = 'True'\n",
"url_helper.urllib2.urlopen(mox.StrContains(url), timeout=mox.IgnoreArg()\n ).AndReturn(StringIO.StringIO(response))\n",
"self._mox.ReplayAll()\n",
"self.assertEqual(url_helper.UrlOpen(url, method='GET'), response)\n",
"self._mox.VerifyAll()\n"
] | [
0,
0,
0,
5,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@commands.command(aliases=['stock115', 'stock'])...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_7 = discord.Embed(VAR_2='Running stock (unmodified) 11.4+ firmware?',\n VAR_3=discord.Color.dark_orange())\n",
"VAR_7.description = 'string'\n",
"await self.bot.say('', VAR_7=embed)\n"
] | [
"@commands.command(aliases=['stock115', 'stock'])...\n",
"\"\"\"docstring\"\"\"\n",
"embed = discord.Embed(title='Running stock (unmodified) 11.4+ firmware?',\n color=discord.Color.dark_orange())\n",
"embed.description = \"\"\"You have 3 possible options for installing CFW:\n- [NTRBoot](https://3ds.guide/ntrboot) which needs a compatible DS flashcart and maybe an additional hacked 3DS or DS(i) console depending on the flashcart\n- [DSiWare](https://3ds.guide/installing-boot9strap-\\\\(dsiware\\\\)) which requires a hacked 3DS\n- [Hardmod](https://3ds.guide/installing-boot9strap-\\\\(hardmod\\\\)) which requires soldering **Not for beginners!**\n **Downgrading is impossible on 11.4+!**\"\"\"\n",
"await self.bot.say('', embed=embed)\n"
] | [
0,
0,
0,
2,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_0():...\n",
"VAR_13 = VAR_0.path.dirname(VAR_0.path.abspath(__file__))\n",
"return VAR_0.path.join(VAR_13, 'server/ycmd.py')\n"
] | [
"def _PathToServerScript():...\n",
"dir_of_current_script = os.path.dirname(os.path.abspath(__file__))\n",
"return os.path.join(dir_of_current_script, 'server/ycmd.py')\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_16(self, VAR_18, VAR_11, VAR_19, VAR_20, VAR_21, VAR_22, VAR_23,...\n",
"VAR_28 = (VAR_18.classes_dir,) + tuple(ce.path for ce in VAR_19)\n",
"if self.get_options().capture_classpath:\n",
"self._record_compile_classpath(VAR_28, VAR_18.target, VAR_18.classes_dir)\n",
"VAR_36 = JvmPlatform.preferred_jvm_distribution([VAR_21], strict=True)\n",
"VAR_36 = JvmPlatform.preferred_jvm_distribution([VAR_21], strict=False)\n",
"VAR_29 = ['{}/bin/javac'.format(VAR_36.real_home)]\n",
"VAR_29.extend(['-classpath', ':'.join(VAR_28)])\n",
"if VAR_21.args:\n",
"VAR_37 = VAR_21.args\n",
"if self.execution_strategy == self.HERMETIC:\n",
"if any('$JAVA_HOME' in a for a in VAR_21.args):\n",
"VAR_29.extend(['-d', '.'])\n",
"VAR_29.extend(['-d', VAR_18.classes_dir])\n",
"VAR_2.debug('Substituting \"$JAVA_HOME\" with \"{}\" in jvm-platform args.'.\n format(VAR_36.home))\n",
"VAR_29.extend(VAR_37)\n",
"VAR_29.extend(self._javac_plugin_args(VAR_24))\n",
"VAR_37 = (a.replace('$JAVA_HOME', VAR_36.home) for a in VAR_21.args)\n",
"VAR_29.extend(['-source', str(VAR_21.source_level), '-target', str(VAR_21.\n target_level)])\n",
"VAR_29.extend(VAR_11)\n",
"if VAR_22:\n",
"VAR_29.extend(self.get_options().fatal_warnings_enabled_args)\n",
"VAR_29.extend(self.get_options().fatal_warnings_disabled_args)\n",
"VAR_29.extend(batched_sources)\n",
"if self.execution_strategy == self.HERMETIC:\n",
"self._execute_hermetic_compile(VAR_29, VAR_18)\n",
"self.context.log.debug('Executing {}'.format(' '.join(VAR_29)))\n",
"VAR_38 = subprocess.Popen(VAR_29, stdout=workunit.output('stdout'), stderr=\n workunit.output('stderr'))\n",
"VAR_39 = VAR_38.wait()\n",
"workunit.set_outcome(WorkUnit.FAILURE if VAR_39 else WorkUnit.SUCCESS)\n",
"if VAR_39:\n"
] | [
"def compile(self, ctx, args, dependency_classpath, upstream_analysis,...\n",
"classpath = (ctx.classes_dir,) + tuple(ce.path for ce in dependency_classpath)\n",
"if self.get_options().capture_classpath:\n",
"self._record_compile_classpath(classpath, ctx.target, ctx.classes_dir)\n",
"distribution = JvmPlatform.preferred_jvm_distribution([settings], strict=True)\n",
"distribution = JvmPlatform.preferred_jvm_distribution([settings], strict=False)\n",
"javac_cmd = ['{}/bin/javac'.format(distribution.real_home)]\n",
"javac_cmd.extend(['-classpath', ':'.join(classpath)])\n",
"if settings.args:\n",
"settings_args = settings.args\n",
"if self.execution_strategy == self.HERMETIC:\n",
"if any('$JAVA_HOME' in a for a in settings.args):\n",
"javac_cmd.extend(['-d', '.'])\n",
"javac_cmd.extend(['-d', ctx.classes_dir])\n",
"logger.debug('Substituting \"$JAVA_HOME\" with \"{}\" in jvm-platform args.'.\n format(distribution.home))\n",
"javac_cmd.extend(settings_args)\n",
"javac_cmd.extend(self._javac_plugin_args(javac_plugin_map))\n",
"settings_args = (a.replace('$JAVA_HOME', distribution.home) for a in\n settings.args)\n",
"javac_cmd.extend(['-source', str(settings.source_level), '-target', str(\n settings.target_level)])\n",
"javac_cmd.extend(args)\n",
"if fatal_warnings:\n",
"javac_cmd.extend(self.get_options().fatal_warnings_enabled_args)\n",
"javac_cmd.extend(self.get_options().fatal_warnings_disabled_args)\n",
"javac_cmd.extend(batched_sources)\n",
"if self.execution_strategy == self.HERMETIC:\n",
"self._execute_hermetic_compile(javac_cmd, ctx)\n",
"self.context.log.debug('Executing {}'.format(' '.join(javac_cmd)))\n",
"p = subprocess.Popen(javac_cmd, stdout=workunit.output('stdout'), stderr=\n workunit.output('stderr'))\n",
"return_code = p.wait()\n",
"workunit.set_outcome(WorkUnit.FAILURE if return_code else WorkUnit.SUCCESS)\n",
"if return_code:\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Condition",
"For",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Condition"
] |
[
"def FUNC_5(self, VAR_0, VAR_1):...\n",
""
] | [
"def del_sig_handler(self, interface, method):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"@property...\n",
"if self._snakefile is None:\n",
"return os.path.abspath(os.path.join(self.workdir, 'Snakefile'))\n",
"if not os.path.isabs(self._snakefile):\n",
"return os.path.abspath(os.path.join(self.workflow.basedir, self._snakefile))\n",
"return self._snakefile\n"
] | [
"@property...\n",
"if self._snakefile is None:\n",
"return os.path.abspath(os.path.join(self.workdir, 'Snakefile'))\n",
"if not os.path.isabs(self._snakefile):\n",
"return os.path.abspath(os.path.join(self.workflow.basedir, self._snakefile))\n",
"return self._snakefile\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_16(self):...\n",
"VAR_7 = Pa11yCrawler('')\n",
"VAR_7.get_test_course()\n",
"self._mock_sh.assert_has_calls([call(\n 'wget {targz} -O {dir}demo_course.tar.gz'.format(targz=suite.\n tar_gz_file, dir=suite.imports_dir)), call(\n 'tar zxf {dir}demo_course.tar.gz -C {dir}'.format(dir=suite.imports_dir))])\n"
] | [
"def test_get_test_course(self):...\n",
"suite = Pa11yCrawler('')\n",
"suite.get_test_course()\n",
"self._mock_sh.assert_has_calls([call(\n 'wget {targz} -O {dir}demo_course.tar.gz'.format(targz=suite.\n tar_gz_file, dir=suite.imports_dir)), call(\n 'tar zxf {dir}demo_course.tar.gz -C {dir}'.format(dir=suite.imports_dir))])\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"super(CLASS_0, self).setUp()\n",
"self.shard = os.environ.get('SHARD')\n",
"self.env_var_override = EnvironmentVarGuard()\n"
] | [
"def setUp(self):...\n",
"super(TestPaverBokChoyCmd, self).setUp()\n",
"self.shard = os.environ.get('SHARD')\n",
"self.env_var_override = EnvironmentVarGuard()\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'"
] |
[
"def FUNC_3(self, VAR_3, VAR_4):...\n",
""
] | [
"def retrieveLastInsertId(self, conn, cur):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_39 = {re.compile(p): v for p, v in VAR_9.items()}\n",
"def FUNC_35(VAR_40):...\n",
"VAR_68 = VAR_10[VAR_40]\n",
"for pattern, has_argument in VAR_39.items():\n",
"if pattern.match(VAR_68):\n",
"VAR_8.warn(\n \"Zinc argument '{}' is not supported, and is subject to change/removal!\"\n .format(VAR_68))\n",
"return 2 if has_argument else 1\n",
"return 1\n"
] | [
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"valid_patterns = {re.compile(p): v for p, v in whitelisted_args.items()}\n",
"def validate(idx):...\n",
"arg = args[idx]\n",
"for pattern, has_argument in valid_patterns.items():\n",
"if pattern.match(arg):\n",
"log.warn(\n \"Zinc argument '{}' is not supported, and is subject to change/removal!\"\n .format(arg))\n",
"return 2 if has_argument else 1\n",
"return 1\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"FunctionDef'",
"Assign'",
"For",
"Condition",
"Expr'",
"Return'",
"Return'"
] |
[
"def FUNC_12():...\n",
"VAR_18 = requests.get(FUNC_2('healthy'))\n",
"VAR_18.raise_for_status()\n",
"return VAR_18.json()\n"
] | [
"def _ServerIsHealthy():...\n",
"response = requests.get(_BuildUri('healthy'))\n",
"response.raise_for_status()\n",
"return response.json()\n"
] | [
0,
7,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"if not self.campaign['id']:\n",
"self.cursor.execute('SELECT * FROM log_campaign ORDER BY id DESC LIMIT 1')\n",
"if self.campaign['id'] == '*':\n",
"return self.cursor.fetchone()\n",
"self.cursor.execute('SELECT * FROM log_campaign ORDER BY id')\n",
"self.cursor.execute('SELECT * FROM log_campaign WHERE id=?', [self.campaign\n ['id']])\n",
"return self.cursor.fetchall()\n",
"return self.cursor.fetchone()\n"
] | [
"def get_campaign(self):...\n",
"if not self.campaign['id']:\n",
"self.cursor.execute('SELECT * FROM log_campaign ORDER BY id DESC LIMIT 1')\n",
"if self.campaign['id'] == '*':\n",
"return self.cursor.fetchone()\n",
"self.cursor.execute('SELECT * FROM log_campaign ORDER BY id')\n",
"self.cursor.execute('SELECT * FROM log_campaign WHERE id=?', [self.campaign\n ['id']])\n",
"return self.cursor.fetchall()\n",
"return self.cursor.fetchone()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Condition",
"Return'",
"Expr'",
"Expr'",
"Return'",
"Return'"
] |
[
"@VAR_1.route(VAR_0 + '/create', methods=['GET'])...\n",
"return ujson.dumps({'success': True})\n"
] | [
"@thread.route(BASE_URL + '/create', methods=['GET'])...\n",
"return ujson.dumps({'success': True})\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"VAR_1 = '/api/apps'\n",
"VAR_2 = self.client.post(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 201)\n",
"VAR_3 = VAR_2.data['id']\n",
"VAR_1 = '/api/apps/{app_id}/builds'.format(**locals())\n",
"VAR_4 = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n",
"VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_2.status_code, 201)\n",
"VAR_1 = '/api/apps/{app_id}/releases'.format(**locals())\n",
"VAR_2 = self.client.get(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 200)\n",
"self.assertEqual(len(VAR_2.data['results']), 2)\n",
"VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n",
"VAR_2 = self.client.get(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 200)\n",
"self.assertEqual(len(VAR_2.data['results']), 1)\n",
"VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n",
"VAR_4 = {'web': 20}\n",
"VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_2.status_code, 204)\n",
"chaos.CREATE_ERROR_RATE = 0.5\n",
"chaos.START_ERROR_RATE = 0.5\n",
"VAR_1 = '/api/apps/{app_id}/config'.format(**locals())\n",
"VAR_4 = {'values': json.dumps({'NEW_URL1': 'http://localhost:8080/'})}\n",
"VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_2.status_code, 503)\n",
"VAR_1 = '/api/apps/{app_id}/releases'.format(**locals())\n",
"VAR_2 = self.client.get(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 200)\n",
"self.assertEqual(len(VAR_2.data['results']), 2)\n",
"VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n",
"VAR_2 = self.client.get(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 200)\n",
"self.assertEqual(len(VAR_2.data['results']), 20)\n",
"VAR_5 = set([c['state'] for c in VAR_2.data['results']])\n",
"self.assertEqual(VAR_5, set(['up']))\n"
] | [
"def test_config_chaos(self):...\n",
"url = '/api/apps'\n",
"response = self.client.post(url)\n",
"self.assertEqual(response.status_code, 201)\n",
"app_id = response.data['id']\n",
"url = '/api/apps/{app_id}/builds'.format(**locals())\n",
"body = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 201)\n",
"url = '/api/apps/{app_id}/releases'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(len(response.data['results']), 2)\n",
"url = '/api/apps/{app_id}/containers'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(len(response.data['results']), 1)\n",
"url = '/api/apps/{app_id}/scale'.format(**locals())\n",
"body = {'web': 20}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 204)\n",
"chaos.CREATE_ERROR_RATE = 0.5\n",
"chaos.START_ERROR_RATE = 0.5\n",
"url = '/api/apps/{app_id}/config'.format(**locals())\n",
"body = {'values': json.dumps({'NEW_URL1': 'http://localhost:8080/'})}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 503)\n",
"url = '/api/apps/{app_id}/releases'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(len(response.data['results']), 2)\n",
"url = '/api/apps/{app_id}/containers'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(len(response.data['results']), 20)\n",
"states = set([c['state'] for c in response.data['results']])\n",
"self.assertEqual(states, set(['up']))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_6(self, VAR_8=None):...\n",
"if self.closed:\n",
"if self._session is None:\n",
"if VAR_8 is None:\n",
"VAR_8 = self._adapter\n",
"assert VAR_8 is not None\n",
"if not self._session.is_client:\n",
"self._detach()\n"
] | [
"def detach(self, adapter=None):...\n",
"if self.closed:\n",
"if self._session is None:\n",
"if adapter is None:\n",
"adapter = self._adapter\n",
"assert adapter is not None\n",
"if not self._session.is_client:\n",
"self._detach()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assert'",
"Condition",
"Expr'"
] |
[
"def FUNC_1(self, VAR_6):...\n",
"if VAR_6:\n",
"VAR_15 = Announce.by_id(VAR_6, self.sql_session).scalar()\n",
"VAR_18 = FUNC_0(self.get_argument('start', '0'), -1, 0, 10000000000000000000)\n",
"if not VAR_15:\n",
"VAR_19 = FUNC_0(self.get_argument('step', '12'), 0, 1, 20)\n",
"if VAR_15.is_private and not self.is_group_user('Announcement Manager'):\n",
"VAR_20 = self.get_argument('search', '')\n",
"VAR_16 = AttachmentList.by_ann_id(VAR_6, self.sql_session).all()\n",
"VAR_21 = self.get_argument('group', '')\n",
"self.ann_d = VAR_15.to_dict()\n",
"VAR_22 = self.get_argument('author', '')\n",
"self.ann_d['tags'] = AnnTag.get_ann_tags(VAR_6, self.sql_session)\n",
"VAR_23 = FUNC_0(self.get_argument('hours', ''), 0, 1, 23999999976)\n",
"self.ann_d['atts'] = [att.to_dict() for att in VAR_16]\n",
"if VAR_18 == -1 or VAR_19 == 0:\n",
"VAR_17 = {'title': self.ann_d['title'], 'uri': '/announce/%s' % self.ann_d[\n 'id'], 'content': BeautifulSoup(markdown(self.ann_d['content']),\n 'html.parser').text}\n",
"VAR_8 = self.sql_session.query(Announce)\n",
"self.set_header('Cache-Control', 'max-age=300')\n",
"if VAR_20:\n",
"self.page_render(self.ann_d, 'announce.html', VAR_17=meta)\n",
"VAR_8 = VAR_8.filter(Announce.full_text_search(VAR_20))\n",
"VAR_8 = VAR_8.order_by(Announce.created.desc())\n",
"if VAR_22:\n",
"VAR_8 = VAR_8.filter(Announce.author_name == VAR_22)\n",
"if VAR_21:\n",
"VAR_8 = VAR_8.filter(Announce.author_group_name == VAR_21)\n",
"if VAR_23:\n",
"VAR_31 = datetime.utcnow() - timedelta(VAR_23=hours)\n",
"if not self.is_group_user('Announcement Manager'):\n",
"VAR_8 = VAR_8.filter(Announce.created >= VAR_31)\n",
"VAR_8 = VAR_8.filter(Announce.is_private == False)\n",
"VAR_24 = VAR_8.count()\n",
"VAR_8 = VAR_8.offset(VAR_18).limit(VAR_19)\n",
"VAR_25 = VAR_8.all()\n",
"VAR_26 = self.sql_session.query(Announce.author_group_name).group_by(Announce\n .author_group_name).all()\n",
"VAR_27 = self.sql_session.query(Announce.author_name).group_by(Announce.\n author_name).all()\n",
"def FUNC_8(VAR_15):...\n",
"VAR_32 = VAR_15.to_dict()\n",
"VAR_32['tags'] = AnnTag.get_ann_tags(VAR_15.id, self.sql_session)\n",
"return VAR_32\n"
] | [
"def get(self, ann_id):...\n",
"if ann_id:\n",
"ann = Announce.by_id(ann_id, self.sql_session).scalar()\n",
"start = _to_int(self.get_argument('start', '0'), -1, 0, 10000000000000000000)\n",
"if not ann:\n",
"step = _to_int(self.get_argument('step', '12'), 0, 1, 20)\n",
"if ann.is_private and not self.is_group_user('Announcement Manager'):\n",
"search = self.get_argument('search', '')\n",
"atts = AttachmentList.by_ann_id(ann_id, self.sql_session).all()\n",
"group = self.get_argument('group', '')\n",
"self.ann_d = ann.to_dict()\n",
"author = self.get_argument('author', '')\n",
"self.ann_d['tags'] = AnnTag.get_ann_tags(ann_id, self.sql_session)\n",
"hours = _to_int(self.get_argument('hours', ''), 0, 1, 23999999976)\n",
"self.ann_d['atts'] = [att.to_dict() for att in atts]\n",
"if start == -1 or step == 0:\n",
"meta = {'title': self.ann_d['title'], 'uri': '/announce/%s' % self.ann_d[\n 'id'], 'content': BeautifulSoup(markdown(self.ann_d['content']),\n 'html.parser').text}\n",
"q = self.sql_session.query(Announce)\n",
"self.set_header('Cache-Control', 'max-age=300')\n",
"if search:\n",
"self.page_render(self.ann_d, 'announce.html', meta=meta)\n",
"q = q.filter(Announce.full_text_search(search))\n",
"q = q.order_by(Announce.created.desc())\n",
"if author:\n",
"q = q.filter(Announce.author_name == author)\n",
"if group:\n",
"q = q.filter(Announce.author_group_name == group)\n",
"if hours:\n",
"start_time = datetime.utcnow() - timedelta(hours=hours)\n",
"if not self.is_group_user('Announcement Manager'):\n",
"q = q.filter(Announce.created >= start_time)\n",
"q = q.filter(Announce.is_private == False)\n",
"total = q.count()\n",
"q = q.offset(start).limit(step)\n",
"anns = q.all()\n",
"groups = self.sql_session.query(Announce.author_group_name).group_by(Announce\n .author_group_name).all()\n",
"authors = self.sql_session.query(Announce.author_name).group_by(Announce.\n author_name).all()\n",
"def _make_ann(ann):...\n",
"_d = ann.to_dict()\n",
"_d['tags'] = AnnTag.get_ann_tags(ann.id, self.sql_session)\n",
"return _d\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"self.mock(bot_main, 'get_remote', lambda : self.server)\n",
"VAR_9 = []\n",
"def FUNC_21(VAR_10):...\n",
"VAR_9.append(1)\n",
"return False\n"
] | [
"def test_setup_bot(self):...\n",
"self.mock(bot_main, 'get_remote', lambda : self.server)\n",
"setup_bots = []\n",
"def setup_bot(_bot):...\n",
"setup_bots.append(1)\n",
"return False\n"
] | [
0,
5,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"FunctionDef'",
"Expr'",
"Return'"
] |
[
"import os\n",
"import unittest\n",
"from coalib.bearlib.abstractions.Lint import Lint\n",
"from coalib.misc.ContextManagers import prepare_file\n",
"from coalib.misc.Shell import escape_path_argument\n",
"from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY\n",
"from coalib.results.SourceRange import SourceRange\n",
"from coalib.settings.Section import Section\n",
"def FUNC_0(self):...\n",
"VAR_0 = Section('some_name')\n",
"self.uut = Lint(VAR_0, None)\n",
"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",
"self.assertEqual(VAR_1[0].affected_code[0], SourceRange.from_values(\n 'a/file.py', 1, 0))\n",
"self.assertEqual(VAR_1[0].severity, RESULT_SEVERITY.INFO)\n",
"self.assertEqual(VAR_1[0].message, 'Info message')\n",
"self.assertEqual(VAR_1[1].affected_code[0], SourceRange.from_values(\n 'a/file.py', 2, 2))\n",
"self.assertEqual(VAR_1[1].severity, RESULT_SEVERITY.NORMAL)\n",
"self.assertEqual(VAR_1[1].message, 'Normal message')\n",
"self.assertEqual(VAR_1[2].affected_code[0], SourceRange.from_values(\n 'a/file.py', 3, 4))\n",
"self.assertEqual(VAR_1[2].severity, RESULT_SEVERITY.MAJOR)\n",
"self.assertEqual(VAR_1[2].message, 'Major message')\n",
"def FUNC_2(self):...\n",
"self.uut.output_regex = 'string'\n",
"self.uut.severity_map = {'I': RESULT_SEVERITY.INFO}\n",
"VAR_1 = list(self.uut.process_output(['info_msg|1.0|2.3|I: Info message\\n'],\n 'a/file.py', ['original_file_lines_placeholder']))\n",
"self.assertEqual(len(VAR_1), 1)\n",
"self.assertEqual(VAR_1[0].affected_code[0].start.line, 1)\n",
"self.assertEqual(VAR_1[0].affected_code[0].start.column, 0)\n",
"self.assertEqual(VAR_1[0].affected_code[0].end.line, 2)\n",
"self.assertEqual(VAR_1[0].affected_code[0].end.column, 3)\n",
"self.assertEqual(VAR_1[0].severity, RESULT_SEVERITY.INFO)\n",
"self.assertEqual(VAR_1[0].origin, 'Lint (info_msg)')\n",
"def FUNC_3(self):...\n",
"VAR_1 = list(self.uut.process_output([\n \"Random line that shouldn't be captured\\n\", '*************\\n'],\n 'a/file.py', ['original_file_lines_placeholder']))\n",
"self.assertEqual(len(VAR_1), 0)\n",
"def FUNC_4(self):...\n",
"self.uut.executable = 'more'\n",
"self.uut.use_stdin = True\n",
"self.uut.use_stderr = False\n",
"self.uut.process_output = lambda output, filename, file: output\n",
"VAR_1 = self.uut.lint(file=lines)\n",
"self.assertTrue(('abcd\\n', 'efgh\\n') == VAR_1 or ('abcd\\n', 'efgh\\n', '\\n') ==\n VAR_1)\n",
"def FUNC_5(self):...\n",
"self.uut.executable = 'echo'\n",
"self.uut.arguments = 'hello'\n",
"self.uut.use_stdin = False\n",
"self.uut.use_stderr = True\n",
"self.uut.process_output = lambda output, filename, file: output\n",
"VAR_1 = self.uut.lint('unused_filename')\n",
"self.assertEqual((), VAR_1)\n",
"self.uut.use_stderr = False\n",
"VAR_1 = self.uut.lint('unused_filename')\n",
"self.assertEqual(('hello\\n',), VAR_1)\n",
"def FUNC_9(VAR_2):...\n",
"assert VAR_2 == 'hello'\n",
"VAR_3 = self.uut.warn\n",
"self.uut.warn = FUNC_9\n",
"self.uut._print_errors(['hello', '\\n'])\n",
"self.uut.warn = VAR_3\n",
"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 FUNC_7(self):...\n",
"VAR_4 = Lint.executable\n",
"VAR_5 = 'invalid_binary_which_doesnt_exist'\n",
"Lint.executable = VAR_5\n",
"self.assertEqual(Lint.check_prerequisites(), \"'{}' is not installed.\".\n format(VAR_5))\n",
"Lint.executable = 'echo'\n",
"self.assertTrue(Lint.check_prerequisites())\n",
"self.assertTrue(Lint.check_prerequisites())\n",
"Lint.executable = VAR_4\n",
"def FUNC_8(self):...\n",
"self.uut.executable = 'echo'\n",
"self.uut.arguments = '-c {config_file}'\n",
"self.assertEqual(self.uut._create_command(config_file='configfile').strip(),\n 'echo -c ' + escape_path_argument('configfile'))\n",
"def FUNC_8(self):...\n",
"self.uut.executable = 'echo'\n",
"self.uut.config_file = lambda : ['config line1']\n",
"VAR_6 = self.uut.generate_config_file()\n",
"self.assertTrue(os.path.isfile(VAR_6))\n",
"os.remove(VAR_6)\n",
"self.uut.lint('filename')\n"
] | [
"import os\n",
"import unittest\n",
"from coalib.bearlib.abstractions.Lint import Lint\n",
"from coalib.misc.ContextManagers import prepare_file\n",
"from coalib.misc.Shell import escape_path_argument\n",
"from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY\n",
"from coalib.results.SourceRange import SourceRange\n",
"from coalib.settings.Section import Section\n",
"def setUp(self):...\n",
"section = Section('some_name')\n",
"self.uut = Lint(section, None)\n",
"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",
"self.assertEqual(out[0].affected_code[0], SourceRange.from_values(\n 'a/file.py', 1, 0))\n",
"self.assertEqual(out[0].severity, RESULT_SEVERITY.INFO)\n",
"self.assertEqual(out[0].message, 'Info message')\n",
"self.assertEqual(out[1].affected_code[0], SourceRange.from_values(\n 'a/file.py', 2, 2))\n",
"self.assertEqual(out[1].severity, RESULT_SEVERITY.NORMAL)\n",
"self.assertEqual(out[1].message, 'Normal message')\n",
"self.assertEqual(out[2].affected_code[0], SourceRange.from_values(\n 'a/file.py', 3, 4))\n",
"self.assertEqual(out[2].severity, RESULT_SEVERITY.MAJOR)\n",
"self.assertEqual(out[2].message, 'Major message')\n",
"def test_custom_regex(self):...\n",
"self.uut.output_regex = (\n '(?P<origin>\\\\w+)\\\\|(?P<line>\\\\d+)\\\\.(?P<column>\\\\d+)\\\\|(?P<end_line>\\\\d+)\\\\.(?P<end_column>\\\\d+)\\\\|(?P<severity>\\\\w+): (?P<message>.*)'\n )\n",
"self.uut.severity_map = {'I': RESULT_SEVERITY.INFO}\n",
"out = list(self.uut.process_output(['info_msg|1.0|2.3|I: Info message\\n'],\n 'a/file.py', ['original_file_lines_placeholder']))\n",
"self.assertEqual(len(out), 1)\n",
"self.assertEqual(out[0].affected_code[0].start.line, 1)\n",
"self.assertEqual(out[0].affected_code[0].start.column, 0)\n",
"self.assertEqual(out[0].affected_code[0].end.line, 2)\n",
"self.assertEqual(out[0].affected_code[0].end.column, 3)\n",
"self.assertEqual(out[0].severity, RESULT_SEVERITY.INFO)\n",
"self.assertEqual(out[0].origin, 'Lint (info_msg)')\n",
"def test_valid_output(self):...\n",
"out = list(self.uut.process_output([\n \"Random line that shouldn't be captured\\n\", '*************\\n'],\n 'a/file.py', ['original_file_lines_placeholder']))\n",
"self.assertEqual(len(out), 0)\n",
"def test_stdin_input(self):...\n",
"self.uut.executable = 'more'\n",
"self.uut.use_stdin = True\n",
"self.uut.use_stderr = False\n",
"self.uut.process_output = lambda output, filename, file: output\n",
"out = self.uut.lint(file=lines)\n",
"self.assertTrue(('abcd\\n', 'efgh\\n') == out or ('abcd\\n', 'efgh\\n', '\\n') ==\n out)\n",
"def test_stderr_output(self):...\n",
"self.uut.executable = 'echo'\n",
"self.uut.arguments = 'hello'\n",
"self.uut.use_stdin = False\n",
"self.uut.use_stderr = True\n",
"self.uut.process_output = lambda output, filename, file: output\n",
"out = self.uut.lint('unused_filename')\n",
"self.assertEqual((), out)\n",
"self.uut.use_stderr = False\n",
"out = self.uut.lint('unused_filename')\n",
"self.assertEqual(('hello\\n',), out)\n",
"def assert_warn(line):...\n",
"assert line == 'hello'\n",
"old_warn = self.uut.warn\n",
"self.uut.warn = assert_warn\n",
"self.uut._print_errors(['hello', '\\n'])\n",
"self.uut.warn = old_warn\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",
"def test_missing_binary(self):...\n",
"old_binary = Lint.executable\n",
"invalid_binary = 'invalid_binary_which_doesnt_exist'\n",
"Lint.executable = invalid_binary\n",
"self.assertEqual(Lint.check_prerequisites(), \"'{}' is not installed.\".\n format(invalid_binary))\n",
"Lint.executable = 'echo'\n",
"self.assertTrue(Lint.check_prerequisites())\n",
"self.assertTrue(Lint.check_prerequisites())\n",
"Lint.executable = old_binary\n",
"def test_config_file_generator(self):...\n",
"self.uut.executable = 'echo'\n",
"self.uut.arguments = '-c {config_file}'\n",
"self.assertEqual(self.uut._create_command(config_file='configfile').strip(),\n 'echo -c ' + escape_path_argument('configfile'))\n",
"def test_config_file_generator(self):...\n",
"self.uut.executable = 'echo'\n",
"self.uut.config_file = lambda : ['config line1']\n",
"config_filename = self.uut.generate_config_file()\n",
"self.assertTrue(os.path.isfile(config_filename))\n",
"os.remove(config_filename)\n",
"self.uut.lint('filename')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"FunctionDef'",
"Assign'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"FunctionDef'",
"Assert'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@property...\n",
"return self._input\n"
] | [
"@property...\n",
"return self._input\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"from datetime import datetime\n",
"from django.conf import settings\n",
"from django.core.cache import cache\n",
"from django.template import RequestContext\n",
"from django.core.urlresolvers import reverse\n",
"from django.http import Http404, HttpResponseRedirect, HttpResponseNotAllowed, HttpResponse, HttpResponseForbidden\n",
"from django.shortcuts import get_object_or_404, render_to_response, redirect\n",
"from django.contrib.contenttypes.models import ContentType\n",
"from django.contrib import messages\n",
"from django.core.exceptions import ObjectDoesNotExist\n",
"from wiki.forms import ArticleForm\n",
"from wiki.models import Article, ChangeSet, dmp\n",
"from wiki.utils import get_ct\n",
"from django.contrib.auth.decorators import login_required\n",
"from wl_utils import get_real_ip\n",
"import re\n",
"VAR_25 = settings.WIKI_LOCK_DURATION\n",
"VAR_25 = 15\n",
"from notification import models as notification\n",
"VAR_41 = None\n",
"VAR_0 = Article.objects.all()\n",
"VAR_1 = ChangeSet.objects.all()\n",
"def FUNC_0(VAR_2, VAR_3=None, VAR_4=None, VAR_5=None):...\n",
"VAR_8 = None\n",
"if VAR_3 is not None:\n",
"VAR_8 = get_object_or_404(VAR_5, **{group_slug_field: group_slug})\n",
"return VAR_2, VAR_8\n",
"VAR_2 = VAR_2.filter(content_type=get_ct(group), object_id=group.id)\n"
] | [
"from datetime import datetime\n",
"from django.conf import settings\n",
"from django.core.cache import cache\n",
"from django.template import RequestContext\n",
"from django.core.urlresolvers import reverse\n",
"from django.http import Http404, HttpResponseRedirect, HttpResponseNotAllowed, HttpResponse, HttpResponseForbidden\n",
"from django.shortcuts import get_object_or_404, render_to_response, redirect\n",
"from django.contrib.contenttypes.models import ContentType\n",
"from django.contrib import messages\n",
"from django.core.exceptions import ObjectDoesNotExist\n",
"from wiki.forms import ArticleForm\n",
"from wiki.models import Article, ChangeSet, dmp\n",
"from wiki.utils import get_ct\n",
"from django.contrib.auth.decorators import login_required\n",
"from wl_utils import get_real_ip\n",
"import re\n",
"WIKI_LOCK_DURATION = settings.WIKI_LOCK_DURATION\n",
"WIKI_LOCK_DURATION = 15\n",
"from notification import models as notification\n",
"notification = None\n",
"ALL_ARTICLES = Article.objects.all()\n",
"ALL_CHANGES = ChangeSet.objects.all()\n",
"def get_articles_by_group(article_qs, group_slug=None, group_slug_field=...\n",
"group = None\n",
"if group_slug is not None:\n",
"group = get_object_or_404(group_qs, **{group_slug_field: group_slug})\n",
"return article_qs, group\n",
"article_qs = article_qs.filter(content_type=get_ct(group), object_id=group.id)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
6,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Assign'",
"Assign'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'"
] |
[
"def FUNC_1(self):...\n",
"self.handled_resp = None\n",
"self.handled_remote = None\n",
"self.handled_args = None\n",
"self.handled_kwargs = None\n",
"from invenio.modules.oauthclient.models import RemoteToken, RemoteAccount\n",
"RemoteToken.query.delete()\n",
"RemoteAccount.query.delete()\n",
"db.session.commit()\n"
] | [
"def tearDown(self):...\n",
"self.handled_resp = None\n",
"self.handled_remote = None\n",
"self.handled_args = None\n",
"self.handled_kwargs = None\n",
"from invenio.modules.oauthclient.models import RemoteToken, RemoteAccount\n",
"RemoteToken.query.delete()\n",
"RemoteAccount.query.delete()\n",
"db.session.commit()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"ImportFrom'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"for VAR_13 in DataDocument.objects.all():\n",
"VAR_11 = VAR_13.id\n",
"VAR_12 = self.client.get('/datadocument/%s/' % VAR_11)\n",
"self.assertEqual(VAR_12.status_code, 200,\n 'The page must return a 200 status code')\n",
"VAR_20 = ExtractedText.objects.get(data_document=dd)\n",
"self.assertContains(VAR_12, 'No Extracted Text exists for this Data Document')\n",
"self.assertContains(VAR_12, '<h4>Extracted Text')\n"
] | [
"def test_absent_extracted_text(self):...\n",
"for dd in DataDocument.objects.all():\n",
"ddid = dd.id\n",
"resp = self.client.get('/datadocument/%s/' % ddid)\n",
"self.assertEqual(resp.status_code, 200,\n 'The page must return a 200 status code')\n",
"extracted_text = ExtractedText.objects.get(data_document=dd)\n",
"self.assertContains(resp, 'No Extracted Text exists for this Data Document')\n",
"self.assertContains(resp, '<h4>Extracted Text')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def __init__(self, VAR_7=None, VAR_8=None, VAR_12=True):...\n",
"if VAR_7:\n",
"self.entry_id = VAR_7\n",
"self.create_entry()\n",
"self.populate_entry_data()\n",
"self.set_entry_id()\n",
"self.writeable = VAR_12\n",
"if VAR_8:\n",
"self.title = VAR_8\n",
"self.update_title()\n"
] | [
"def __init__(self, entry_id=None, title=None, writeable=True):...\n",
"if entry_id:\n",
"self.entry_id = entry_id\n",
"self.create_entry()\n",
"self.populate_entry_data()\n",
"self.set_entry_id()\n",
"self.writeable = writeable\n",
"if title:\n",
"self.title = title\n",
"self.update_title()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Expr'"
] |
[
"@staticmethod...\n",
"for i in xrange(VAR_1):\n",
"yield unichr(random.randint(0, 65535))\n"
] | [
"@staticmethod...\n",
"for i in xrange(cnt):\n",
"yield unichr(random.randint(0, 65535))\n"
] | [
0,
0,
0
] | [
"Condition",
"For",
"Expr'"
] |
[
"@pyqtSlot(str)...\n",
"self.log_area.moveCursor(QTextCursor.End)\n",
"self.log_area.insertPlainText(VAR_3)\n"
] | [
"@pyqtSlot(str)...\n",
"self.log_area.moveCursor(QTextCursor.End)\n",
"self.log_area.insertPlainText(message)\n"
] | [
0,
0,
0
] | [
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_26(self, VAR_26, VAR_7, VAR_27, VAR_28):...\n",
"if VAR_28 is None:\n",
"VAR_49 = 'ADD'\n",
"if VAR_27 is None:\n",
"VAR_3 = '%s,None' % VAR_27\n",
"VAR_49 = 'REMOVE'\n",
"VAR_49 = 'UPDATE'\n",
"if not VAR_7 is None:\n",
"VAR_3 = 'None,%s' % VAR_28\n",
"VAR_3 = '%s,%s' % (VAR_27, VAR_28)\n",
"VAR_50 = '(%s)' % VAR_26.parent\n",
"self.__logger.debug('%s ROOT (%s)' % (VAR_49, VAR_3))\n",
"self.__logger.debug('%s%s %s.%s (%s)' % (' ' * len(VAR_26), VAR_49, VAR_50,\n VAR_7.resource_attr, VAR_3))\n"
] | [
"def __log_traverse_one(self, path, attribute, source, target):...\n",
"if target is None:\n",
"mode = 'ADD'\n",
"if source is None:\n",
"data = '%s,None' % source\n",
"mode = 'REMOVE'\n",
"mode = 'UPDATE'\n",
"if not attribute is None:\n",
"data = 'None,%s' % target\n",
"data = '%s,%s' % (source, target)\n",
"parent = '(%s)' % path.parent\n",
"self.__logger.debug('%s ROOT (%s)' % (mode, data))\n",
"self.__logger.debug('%s%s %s.%s (%s)' % (' ' * len(path), mode, parent,\n attribute.resource_attr, data))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_5(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_16 = self.describe()\n",
"self.start_time = time.time()\n",
"self.response = self.browser.do_request(self.url, self.data, self.files)\n",
"self.exception_data = traceback.format_exc()\n",
"self.outcome = None\n",
"self.stop_time = time.time()\n",
"self.response.raise_for_status()\n",
"self.outcome = CLASS_1.OUTCOME_ERROR\n",
"VAR_17 = None\n",
"self.duration = self.stop_time - self.start_time\n",
"self.status_code = self.response.status_code\n",
"VAR_17 = self.test_success()\n",
"self.exception_data = traceback.format_exc()\n",
"if self.outcome is None:\n",
"self.res_data = self.response.text\n",
"self.outcome = CLASS_1.OUTCOME_ERROR\n",
"if VAR_17 is None:\n",
"print(\"\"\"Request '%s' terminated with an exception: %s\n%s\"\"\" % (VAR_16,\n repr(exc), self.exception_data), file=sys.stderr)\n",
"if len(self.response.history) > 0:\n",
"if VAR_0:\n",
"if VAR_17:\n",
"self.redirected_to = self.response.url\n",
"print(\"Could not determine status for request '%s'\" % VAR_16, file=sys.stderr)\n",
"self.outcome = CLASS_1.OUTCOME_UNDECIDED\n",
"if VAR_0:\n",
"if not VAR_17:\n",
"print(\"Request '%s' successfully completed in %.3fs\" % (VAR_16, self.\n duration), file=sys.stderr)\n",
"self.outcome = CLASS_1.OUTCOME_SUCCESS\n",
"if VAR_0:\n",
"print(\"Request '%s' failed\" % VAR_16, file=sys.stderr)\n",
"self.outcome = CLASS_1.OUTCOME_FAILURE\n",
"if self.exception_data is not None:\n",
"print(self.exception_data, file=sys.stderr)\n"
] | [
"def _execute(self):...\n",
"\"\"\"docstring\"\"\"\n",
"description = self.describe()\n",
"self.start_time = time.time()\n",
"self.response = self.browser.do_request(self.url, self.data, self.files)\n",
"self.exception_data = traceback.format_exc()\n",
"self.outcome = None\n",
"self.stop_time = time.time()\n",
"self.response.raise_for_status()\n",
"self.outcome = GenericRequest.OUTCOME_ERROR\n",
"success = None\n",
"self.duration = self.stop_time - self.start_time\n",
"self.status_code = self.response.status_code\n",
"success = self.test_success()\n",
"self.exception_data = traceback.format_exc()\n",
"if self.outcome is None:\n",
"self.res_data = self.response.text\n",
"self.outcome = GenericRequest.OUTCOME_ERROR\n",
"if success is None:\n",
"print(\"\"\"Request '%s' terminated with an exception: %s\n%s\"\"\" % (description,\n repr(exc), self.exception_data), file=sys.stderr)\n",
"if len(self.response.history) > 0:\n",
"if debug:\n",
"if success:\n",
"self.redirected_to = self.response.url\n",
"print(\"Could not determine status for request '%s'\" % description, file=sys\n .stderr)\n",
"self.outcome = GenericRequest.OUTCOME_UNDECIDED\n",
"if debug:\n",
"if not success:\n",
"print(\"Request '%s' successfully completed in %.3fs\" % (description, self.\n duration), file=sys.stderr)\n",
"self.outcome = GenericRequest.OUTCOME_SUCCESS\n",
"if debug:\n",
"print(\"Request '%s' failed\" % description, file=sys.stderr)\n",
"self.outcome = GenericRequest.OUTCOME_FAILURE\n",
"if self.exception_data is not None:\n",
"print(self.exception_data, file=sys.stderr)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Expr'"
] |
[
"def FUNC_13(self, VAR_10=None, VAR_14=None, VAR_15=False):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_15:\n",
"VAR_10 = sys.argv[1:] if VAR_10 is None else VAR_10\n",
"return super().parse_known_args(VAR_10, VAR_14)\n",
"VAR_10 = [a for a in VAR_10 if a != '-h' and a != '--help']\n"
] | [
"def parse_known_args(self, args=None, namespace=None, nohelp=False):...\n",
"\"\"\"docstring\"\"\"\n",
"if nohelp:\n",
"args = sys.argv[1:] if args is None else args\n",
"return super().parse_known_args(args, namespace)\n",
"args = [a for a in args if a != '-h' and a != '--help']\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Return'",
"Assign'"
] |
[
"def FUNC_0(self):...\n",
"VAR_0 = self.client.get('/api/v1/questions/answers', headers={\n 'Authorization': 'JWT ' + self.token})\n",
"self.assertEqual(VAR_0.status_code, 200)\n",
"self.assertEqual(VAR_0.get_json()['status'], 'success')\n"
] | [
"def test_list_answers(self):...\n",
"response = self.client.get('/api/v1/questions/answers', headers={\n 'Authorization': 'JWT ' + self.token})\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(response.get_json()['status'], 'success')\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_0(VAR_0):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_0 = str(VAR_0)\n",
"pathlib.Path(VAR_0).mkdir(parents=True, exist_ok=True)\n"
] | [
"def create_directory_tree(path):...\n",
"\"\"\"docstring\"\"\"\n",
"path = str(path)\n",
"pathlib.Path(path).mkdir(parents=True, exist_ok=True)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_5(VAR_3, VAR_7, VAR_8=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_5 = {'currentProvider': None, 'providers': [], 'secondaryProviders': [],\n 'finishAuthUrl': None, 'errorMessage': None}\n",
"if third_party_auth.is_enabled():\n",
"if not enterprise_customer_for_request(VAR_3):\n",
"return VAR_5\n",
"for enabled in third_party_auth.provider.Registry.displayed_for_login(VAR_8\n",
"VAR_41 = pipeline.get(VAR_3)\n",
"VAR_49 = {'id': enabled.provider_id, 'name': enabled.name, 'iconClass': \n enabled.icon_class or None, 'iconImage': enabled.icon_image.url if\n enabled.icon_image else None, 'loginUrl': pipeline.get_login_url(\n enabled.provider_id, pipeline.AUTH_ENTRY_LOGIN, redirect_url=\n redirect_to), 'registerUrl': pipeline.get_login_url(enabled.provider_id,\n pipeline.AUTH_ENTRY_REGISTER, redirect_url=redirect_to)}\n",
"if VAR_41 is not None:\n",
"VAR_5['providers' if not enabled.secondary else 'secondaryProviders'].append(\n VAR_49)\n",
"VAR_46 = third_party_auth.provider.Registry.get_from_pipeline(VAR_41)\n",
"for msg in messages.get_messages(VAR_3):\n",
"if VAR_46 is not None:\n",
"if msg.extra_tags.split()[0] == 'social-auth':\n",
"VAR_5['currentProvider'] = VAR_46.name\n",
"VAR_5['errorMessage'] = _(unicode(msg))\n",
"VAR_5['finishAuthUrl'] = pipeline.get_complete_url(VAR_46.backend_name)\n",
"if VAR_46.skip_registration_form:\n",
"VAR_5['autoSubmitRegForm'] = True\n"
] | [
"def _third_party_auth_context(request, redirect_to, tpa_hint=None):...\n",
"\"\"\"docstring\"\"\"\n",
"context = {'currentProvider': None, 'providers': [], 'secondaryProviders':\n [], 'finishAuthUrl': None, 'errorMessage': None}\n",
"if third_party_auth.is_enabled():\n",
"if not enterprise_customer_for_request(request):\n",
"return context\n",
"for enabled in third_party_auth.provider.Registry.displayed_for_login(tpa_hint\n",
"running_pipeline = pipeline.get(request)\n",
"info = {'id': enabled.provider_id, 'name': enabled.name, 'iconClass': \n enabled.icon_class or None, 'iconImage': enabled.icon_image.url if\n enabled.icon_image else None, 'loginUrl': pipeline.get_login_url(\n enabled.provider_id, pipeline.AUTH_ENTRY_LOGIN, redirect_url=\n redirect_to), 'registerUrl': pipeline.get_login_url(enabled.provider_id,\n pipeline.AUTH_ENTRY_REGISTER, redirect_url=redirect_to)}\n",
"if running_pipeline is not None:\n",
"context['providers' if not enabled.secondary else 'secondaryProviders'].append(\n info)\n",
"current_provider = third_party_auth.provider.Registry.get_from_pipeline(\n running_pipeline)\n",
"for msg in messages.get_messages(request):\n",
"if current_provider is not None:\n",
"if msg.extra_tags.split()[0] == 'social-auth':\n",
"context['currentProvider'] = current_provider.name\n",
"context['errorMessage'] = _(unicode(msg))\n",
"context['finishAuthUrl'] = pipeline.get_complete_url(current_provider.\n backend_name)\n",
"if current_provider.skip_registration_form:\n",
"context['autoSubmitRegForm'] = True\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"For",
"Return'",
"For",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"For",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'"
] |
[
"def FUNC_4(VAR_0, VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_16 = VAR_0.tournamentplayer_set.all()\n",
"VAR_17 = VAR_5.roundplayer_set.all()\n",
"VAR_18 = []\n",
"VAR_13 = set()\n",
"VAR_19 = set()\n",
"for VAR_36 in VAR_17:\n",
"assert VAR_36.gameplayers().count(\n ) == 0, '%d games already exist for %s in this round' % (VAR_36.\n gameplayers().count(), str(VAR_36))\n",
"assert not VAR_13 or not VAR_19\n",
"VAR_18.append(VAR_36)\n",
"if VAR_13:\n",
"if VAR_36.game_count == 1:\n",
"assert (len(VAR_18) - len(VAR_13)) % 7 == 0\n",
"if VAR_19:\n",
"if VAR_36.game_count == 0:\n",
"assert (len(VAR_18) + len(VAR_19)) % 7 == 0\n",
"for tp in VAR_16:\n",
"VAR_13.add(VAR_36.tournamentplayer())\n",
"if VAR_36.game_count == 2:\n",
"if not VAR_17.filter(player=tp.player).exists():\n",
"return VAR_13, VAR_19\n",
"VAR_19.add(VAR_36.tournamentplayer())\n",
"assert 0, 'Unexpected game_count value %d for %s' % (VAR_36.game_count, str\n (VAR_36))\n",
"VAR_13.add(tp)\n"
] | [
"def _sitters_and_two_gamers(tournament, the_round):...\n",
"\"\"\"docstring\"\"\"\n",
"tourney_players = tournament.tournamentplayer_set.all()\n",
"round_players = the_round.roundplayer_set.all()\n",
"rps = []\n",
"sitters = set()\n",
"two_gamers = set()\n",
"for rp in round_players:\n",
"assert rp.gameplayers().count(\n ) == 0, '%d games already exist for %s in this round' % (rp.gameplayers\n ().count(), str(rp))\n",
"assert not sitters or not two_gamers\n",
"rps.append(rp)\n",
"if sitters:\n",
"if rp.game_count == 1:\n",
"assert (len(rps) - len(sitters)) % 7 == 0\n",
"if two_gamers:\n",
"if rp.game_count == 0:\n",
"assert (len(rps) + len(two_gamers)) % 7 == 0\n",
"for tp in tourney_players:\n",
"sitters.add(rp.tournamentplayer())\n",
"if rp.game_count == 2:\n",
"if not round_players.filter(player=tp.player).exists():\n",
"return sitters, two_gamers\n",
"two_gamers.add(rp.tournamentplayer())\n",
"assert 0, 'Unexpected game_count value %d for %s' % (rp.game_count, str(rp))\n",
"sitters.add(tp)\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
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assert'",
"Assert'",
"Expr'",
"Condition",
"Condition",
"Assert'",
"Condition",
"Condition",
"Assert'",
"For",
"Expr'",
"Condition",
"Condition",
"Return'",
"Expr'",
"Assert'",
"Expr'"
] |
[
"def FUNC_33(VAR_39):...\n",
"return True\n"
] | [
"def acquire(self2):...\n",
"return True\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"from __future__ import absolute_import, division, print_function\n",
"__metaclass__ = type\n",
"from ansible.errors import AnsibleError\n",
"\"\"\" a group of ansible hosts \"\"\"\n",
"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 __repr__(self):...\n",
"return self.get_name()\n"
] | [
"from __future__ import absolute_import, division, print_function\n",
"__metaclass__ = type\n",
"from ansible.errors import AnsibleError\n",
"\"\"\" a group of ansible hosts \"\"\"\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",
"def __repr__(self):...\n",
"return self.get_name()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"Assign'",
"ImportFrom'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def __init__(self, VAR_1, VAR_4=None):...\n",
"\"\"\"docstring\"\"\"\n",
"super(CLASS_0, self).__init__(VAR_1, VAR_4)\n",
"VAR_1 = self.bindings\n",
"VAR_1['TEST_APP_COMPONENT_NAME'] = '{app}-{stack}-{detail}'.format(app=\n bindings['TEST_APP'], stack=bindings['TEST_STACK'], detail=bindings[\n 'TEST_COMPONENT_DETAIL'])\n",
"self.TEST_APP = VAR_1['TEST_APP']\n"
] | [
"def __init__(self, bindings, agent=None):...\n",
"\"\"\"docstring\"\"\"\n",
"super(AwsSmokeTestScenario, self).__init__(bindings, agent)\n",
"bindings = self.bindings\n",
"bindings['TEST_APP_COMPONENT_NAME'] = '{app}-{stack}-{detail}'.format(app=\n bindings['TEST_APP'], stack=bindings['TEST_STACK'], detail=bindings[\n 'TEST_COMPONENT_DETAIL'])\n",
"self.TEST_APP = bindings['TEST_APP']\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"@memoized_property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._zinc_factory._zinc(self._products)\n"
] | [
"@memoized_property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._zinc_factory._zinc(self._products)\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_7(self):...\n",
"VAR_2 = self.client.get(f'/datagroup/{DataGroup.objects.first().id}/'\n ).content.decode('utf8')\n",
"self.assertIn('0 extracted', VAR_2,\n 'Data Group should contain a count of 0 total extracted documents')\n",
"self.objects.doc.extracted = True\n",
"self.objects.doc.save()\n",
"VAR_2 = self.client.get(f'/datagroup/{DataGroup.objects.first().id}/'\n ).content.decode('utf8')\n",
"self.assertIn('1 extracted', VAR_2,\n 'Data Group should contain a count of 1 total extracted documents')\n"
] | [
"def test_extracted_count(self):...\n",
"response = self.client.get(f'/datagroup/{DataGroup.objects.first().id}/'\n ).content.decode('utf8')\n",
"self.assertIn('0 extracted', response,\n 'Data Group should contain a count of 0 total extracted documents')\n",
"self.objects.doc.extracted = True\n",
"self.objects.doc.save()\n",
"response = self.client.get(f'/datagroup/{DataGroup.objects.first().id}/'\n ).content.decode('utf8')\n",
"self.assertIn('1 extracted', response,\n 'Data Group should contain a count of 1 total extracted documents')\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_25(self):...\n",
"if not os.path.isfile(self.newproxyfile):\n",
"return\n",
"VAR_48 = set()\n",
"for VAR_57 in f:\n",
"return VAR_48.difference(self.proxylist)\n",
"VAR_57 = VAR_57.rstrip('\\n')\n",
"self.log.exception('Line %s raised exception %s', VAR_57, e)\n",
"VAR_58 = tuple(VAR_57.split(' '))\n",
"if len(VAR_58) < 2:\n",
"self.log.warning('Line %s has too few spaces', VAR_57)\n",
"if len(VAR_58) > 2:\n",
"self.log.debug('Line %s has too much spaces', VAR_57)\n",
"VAR_48.add(VAR_58)\n",
"VAR_58 = VAR_58[0], VAR_58[1]\n"
] | [
"def read_newproxies(self):...\n",
"if not os.path.isfile(self.newproxyfile):\n",
"return\n",
"newproxies = set()\n",
"for line in f:\n",
"return newproxies.difference(self.proxylist)\n",
"line = line.rstrip('\\n')\n",
"self.log.exception('Line %s raised exception %s', line, e)\n",
"proxypair = tuple(line.split(' '))\n",
"if len(proxypair) < 2:\n",
"self.log.warning('Line %s has too few spaces', line)\n",
"if len(proxypair) > 2:\n",
"self.log.debug('Line %s has too much spaces', line)\n",
"newproxies.add(proxypair)\n",
"proxypair = proxypair[0], proxypair[1]\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"For",
"Return'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Assign'"
] |
[
"def __init__(self, VAR_7, VAR_14=errors.NO_THING_ID, *VAR_15, **VAR_16):...\n",
"CLASS_3.__init__(self, VAR_7, VAR_14, *VAR_15, **kw)\n"
] | [
"def __init__(self, param, error=errors.NO_THING_ID, *a, **kw):...\n",
"VRequired.__init__(self, param, error, *a, **kw)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_10():...\n",
"return {'divider': True}\n"
] | [
"def divider_entry():...\n",
"return {'divider': True}\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_3(VAR_7):...\n",
"\"\"\"docstring\"\"\"\n",
"@functools.wraps(VAR_7)...\n",
"assert isinstance(self, webapp2.RequestHandler)\n",
"assert self.request.method == 'GET'\n",
"if model.is_replica():\n",
"VAR_40 = model.get_replication_state().primary_url\n",
"return VAR_7(self, *VAR_9, **kwargs)\n",
"VAR_41 = 'http://' if utils.is_local_dev_server() else 'https://'\n",
"assert VAR_40 and VAR_40.startswith(VAR_41), VAR_40\n",
"assert self.request.path_qs.startswith('/'), self.request.path_qs\n",
"self.redirect(VAR_40.rstrip('/') + self.request.path_qs, abort=True)\n"
] | [
"def redirect_ui_on_replica(method):...\n",
"\"\"\"docstring\"\"\"\n",
"@functools.wraps(method)...\n",
"assert isinstance(self, webapp2.RequestHandler)\n",
"assert self.request.method == 'GET'\n",
"if model.is_replica():\n",
"primary_url = model.get_replication_state().primary_url\n",
"return method(self, *args, **kwargs)\n",
"protocol = 'http://' if utils.is_local_dev_server() else 'https://'\n",
"assert primary_url and primary_url.startswith(protocol), primary_url\n",
"assert self.request.path_qs.startswith('/'), self.request.path_qs\n",
"self.redirect(primary_url.rstrip('/') + self.request.path_qs, abort=True)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assert'",
"Assert'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Assert'",
"Assert'",
"Expr'"
] |
[
"def FUNC_4():...\n",
"return FUNC_5(LoginForm())\n"
] | [
"def render_login():...\n",
"return render_loginForm(LoginForm())\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@hook.command(autohelp=False)...\n",
"return FUNC_1(VAR_8, 'ban', VAR_4, VAR_5, VAR_1, VAR_6, VAR_7)\n"
] | [
"@hook.command(autohelp=False)...\n",
"return process_vote(inp, 'ban', chan, mask, db, notice, conn)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"from datetime import datetime\n",
"from django.contrib.auth.decorators import login_required\n",
"from django.shortcuts import render, redirect, get_object_or_404\n",
"from dashboard.forms import DataSourceForm, PriorityForm\n",
"from dashboard.models import DataSource, DataGroup, DataDocument\n",
"from .data_group import DataGroupForm\n",
"from django.db.models import Count, Q\n",
"@login_required()...\n",
"VAR_3 = DataSource.objects.all()\n",
"VAR_4, VAR_5 = [], []\n",
"for ds in VAR_3:\n",
"VAR_5.append(PriorityForm(VAR_0.POST or None, instance=ds))\n",
"VAR_6 = Count('datagroup__datadocument')\n",
"VAR_7 = Count('datagroup__datadocument', filter=Q(\n datagroup__datadocument__matched=True))\n",
"VAR_8 = Count('datagroup__datadocument__extractedtext')\n",
"VAR_4 = DataSource.objects.annotate(VAR_6=registered).annotate(VAR_7=\n uploaded, VAR_8=extracted)\n",
"VAR_9 = zip(VAR_4, VAR_5)\n",
"if VAR_0.method == 'POST':\n",
"VAR_10 = DataSource.objects.get(VAR_2=request.POST['ds_pk'])\n",
"return render(VAR_0, VAR_1, {'object_list': VAR_9})\n",
"VAR_12 = PriorityForm(VAR_0.POST or None, instance=datasource)\n",
"if VAR_12.is_valid():\n",
"VAR_15 = VAR_12.cleaned_data['priority']\n",
"VAR_10.priority = VAR_15\n",
"VAR_10.save()\n",
"return redirect('data_source_list')\n"
] | [
"from datetime import datetime\n",
"from django.contrib.auth.decorators import login_required\n",
"from django.shortcuts import render, redirect, get_object_or_404\n",
"from dashboard.forms import DataSourceForm, PriorityForm\n",
"from dashboard.models import DataSource, DataGroup, DataDocument\n",
"from .data_group import DataGroupForm\n",
"from django.db.models import Count, Q\n",
"@login_required()...\n",
"datasources = DataSource.objects.all()\n",
"ds_list, frm_list = [], []\n",
"for ds in datasources:\n",
"frm_list.append(PriorityForm(request.POST or None, instance=ds))\n",
"registered = Count('datagroup__datadocument')\n",
"uploaded = Count('datagroup__datadocument', filter=Q(\n datagroup__datadocument__matched=True))\n",
"extracted = Count('datagroup__datadocument__extractedtext')\n",
"ds_list = DataSource.objects.annotate(registered=registered).annotate(uploaded\n =uploaded, extracted=extracted)\n",
"out = zip(ds_list, frm_list)\n",
"if request.method == 'POST':\n",
"datasource = DataSource.objects.get(pk=request.POST['ds_pk'])\n",
"return render(request, template_name, {'object_list': out})\n",
"form = PriorityForm(request.POST or None, instance=datasource)\n",
"if form.is_valid():\n",
"priority = form.cleaned_data['priority']\n",
"datasource.priority = priority\n",
"datasource.save()\n",
"return redirect('data_source_list')\n"
] | [
6,
0,
0,
0,
0,
6,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Condition",
"Assign'",
"Assign'",
"For",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"@classmethod...\n",
"VAR_30 = []\n",
"for plugin, VAR_11 in VAR_24.items():\n",
"for arg in VAR_11:\n",
"return VAR_30\n",
"if ' ' in arg:\n",
"VAR_30.append('-Xplugin:{} {}'.format(plugin, ' '.join(VAR_11)))\n"
] | [
"@classmethod...\n",
"ret = []\n",
"for plugin, args in javac_plugin_map.items():\n",
"for arg in args:\n",
"return ret\n",
"if ' ' in arg:\n",
"ret.append('-Xplugin:{} {}'.format(plugin, ' '.join(args)))\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"For",
"For",
"Return'",
"Condition",
"Expr'"
] |
[
"def __init__(self, VAR_11=VAR_2):...\n",
"return self.load_sqlfs(VAR_11)\n"
] | [
"def __init__(self, db=Database):...\n",
"return self.load_sqlfs(db)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_57():...\n",
"self.cursor.execute('create table t1 (word varchar (100))')\n",
"VAR_38 = set(['a'])\n",
"self.cursor.executemany('insert into t1 (word) values (?)', [VAR_38])\n"
] | [
"def f():...\n",
"self.cursor.execute('create table t1 (word varchar (100))')\n",
"words = set(['a'])\n",
"self.cursor.executemany('insert into t1 (word) values (?)', [words])\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_8(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_4 = '/api/apps'\n",
"VAR_5 = self.client.post(VAR_4)\n",
"self.assertEqual(VAR_5.status_code, 201)\n",
"VAR_6 = VAR_5.data['id']\n",
"VAR_4 = '/api/apps/{app_id}/builds'.format(**locals())\n",
"VAR_8 = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n",
"VAR_5 = self.client.post(VAR_4, json.dumps(VAR_8), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_5.status_code, 201)\n",
"VAR_4 = '/api/apps/{app_id}/scale'.format(**locals())\n",
"VAR_8 = {'web': 4, 'worker': 2}\n",
"VAR_5 = self.client.post(VAR_4, json.dumps(VAR_8), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_5.status_code, 204)\n",
"VAR_4 = '/api/apps/{app_id}/containers'.format(**locals())\n",
"VAR_5 = self.client.get(VAR_4)\n",
"self.assertEqual(VAR_5.status_code, 200)\n",
"self.assertEqual(len(VAR_5.data['results']), 6)\n",
"VAR_10 = VAR_5.data['results'][0]['uuid']\n",
"VAR_11 = Container.objects.get(VAR_10=uuid)\n",
"self.assertEqual(VAR_11.short_name(), '{}.{}.{}'.format(VAR_11.app, VAR_11.\n type, VAR_11.num))\n",
"self.assertEqual(str(VAR_11), '{}.{}.{}'.format(VAR_11.app, VAR_11.type,\n VAR_11.num))\n"
] | [
"def test_container_str(self):...\n",
"\"\"\"docstring\"\"\"\n",
"url = '/api/apps'\n",
"response = self.client.post(url)\n",
"self.assertEqual(response.status_code, 201)\n",
"app_id = response.data['id']\n",
"url = '/api/apps/{app_id}/builds'.format(**locals())\n",
"body = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 201)\n",
"url = '/api/apps/{app_id}/scale'.format(**locals())\n",
"body = {'web': 4, 'worker': 2}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 204)\n",
"url = '/api/apps/{app_id}/containers'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(len(response.data['results']), 6)\n",
"uuid = response.data['results'][0]['uuid']\n",
"container = Container.objects.get(uuid=uuid)\n",
"self.assertEqual(container.short_name(), '{}.{}.{}'.format(container.app,\n container.type, container.num))\n",
"self.assertEqual(str(container), '{}.{}.{}'.format(container.app, container\n .type, container.num))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"from flask import jsonify, request, make_response, g\n",
"from sqlalchemy.exc import IntegrityError\n",
"from . import api\n",
"from .. import db, auth\n",
"from ..models import Song\n",
"from .errors import bad_request, route_not_found\n",
"@api.route('/songs/<name>')...\n",
"return jsonify(VAR_0=name)\n"
] | [
"from flask import jsonify, request, make_response, g\n",
"from sqlalchemy.exc import IntegrityError\n",
"from . import api\n",
"from .. import db, auth\n",
"from ..models import Song\n",
"from .errors import bad_request, route_not_found\n",
"@api.route('/songs/<name>')...\n",
"return jsonify(name=name)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Condition",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"LogoutHandler.post(self)\n",
"self.get('You logged out')\n"
] | [
"def post(self):...\n",
"LogoutHandler.post(self)\n",
"self.get('You logged out')\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'"
] |
[
"def __call__(self, *VAR_19, **VAR_5):...\n",
"return CLASS_9(self.start, self.end, *VAR_19, **kwargs)\n"
] | [
"def __call__(self, *args, **kwargs):...\n",
"return SliceTransform(self.start, self.end, *args, **kwargs)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_3(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.assertTrue(VAR_6.data['is_superuser'])\n",
"VAR_4 = {'username': 'second', '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.assertFalse(VAR_6.data['is_superuser'])\n",
"self.assertTrue(self.client.login(VAR_1='first', VAR_2='password'))\n",
"VAR_5 = '/api/admin/perms'\n",
"VAR_7 = {'username': 'second'}\n",
"VAR_6 = self.client.post(VAR_5, json.dumps(VAR_7), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_6.status_code, 201)\n",
"VAR_6 = self.client.delete(VAR_5 + '/second')\n",
"self.assertEqual(VAR_6.status_code, 204)\n",
"VAR_6 = self.client.get(VAR_5)\n",
"self.assertEqual(VAR_6.status_code, 200)\n",
"self.assertEqual(len(VAR_6.data['results']), 1)\n",
"self.assertNotIn('two', str(VAR_6.data['results']))\n"
] | [
"def test_delete(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",
"self.assertTrue(response.data['is_superuser'])\n",
"submit = {'username': 'second', '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",
"self.assertFalse(response.data['is_superuser'])\n",
"self.assertTrue(self.client.login(username='first', password='password'))\n",
"url = '/api/admin/perms'\n",
"body = {'username': 'second'}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 201)\n",
"response = self.client.delete(url + '/second')\n",
"self.assertEqual(response.status_code, 204)\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(len(response.data['results']), 1)\n",
"self.assertNotIn('two', str(response.data['results']))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def __init__(self, VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5=None, VAR_6=...\n",
"self.logger = logging.getLogger('fuxploider')\n",
"self.postData = VAR_4\n",
"self.formUrl = VAR_6\n",
"VAR_18 = urlparse(self.formUrl)\n",
"self.schema = VAR_18.scheme\n",
"self.host = VAR_18.netloc\n",
"self.uploadUrl = urljoin(VAR_6, VAR_7)\n",
"self.session = VAR_2\n",
"self.trueRegex = VAR_1\n",
"self.notRegex = VAR_0\n",
"self.inputName = VAR_8\n",
"self.uploadsFolder = VAR_5\n",
"self.size = VAR_3\n",
"self.validExtensions = []\n",
"self.httpRequests = 0\n",
"self.codeExecUrlPattern = None\n",
"self.logLock = Lock()\n",
"self.stopThreads = False\n",
"self.shouldLog = True\n"
] | [
"def __init__(self, notRegex, trueRegex, session, size, postData,...\n",
"self.logger = logging.getLogger('fuxploider')\n",
"self.postData = postData\n",
"self.formUrl = formUrl\n",
"url = urlparse(self.formUrl)\n",
"self.schema = url.scheme\n",
"self.host = url.netloc\n",
"self.uploadUrl = urljoin(formUrl, formAction)\n",
"self.session = session\n",
"self.trueRegex = trueRegex\n",
"self.notRegex = notRegex\n",
"self.inputName = inputName\n",
"self.uploadsFolder = uploadsFolder\n",
"self.size = size\n",
"self.validExtensions = []\n",
"self.httpRequests = 0\n",
"self.codeExecUrlPattern = None\n",
"self.logLock = Lock()\n",
"self.stopThreads = False\n",
"self.shouldLog = True\n"
] | [
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'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"import time\n",
"import mox\n",
"import paramiko\n",
"from cinder import context\n",
"from cinder import exception\n",
"from cinder.openstack.common import log as logging\n",
"from cinder.openstack.common import processutils\n",
"from cinder import test\n",
"from cinder.volume import configuration as conf\n",
"from cinder.volume.drivers import eqlx\n",
"VAR_0 = logging.getLogger(__name__)\n",
"def FUNC_0(self):...\n",
"super(CLASS_0, self).setUp()\n",
"self.configuration = mox.MockObject(conf.Configuration)\n",
"self.configuration.append_config_values(mox.IgnoreArg())\n",
"self.configuration.san_is_local = False\n",
"self.configuration.san_ip = '10.0.0.1'\n",
"self.configuration.san_login = 'foo'\n",
"self.configuration.san_password = 'bar'\n",
"self.configuration.san_ssh_port = 16022\n",
"self.configuration.san_thin_provision = True\n",
"self.configuration.eqlx_pool = 'non-default'\n",
"self.configuration.eqlx_use_chap = True\n",
"self.configuration.eqlx_group_name = 'group-0'\n",
"self.configuration.eqlx_cli_timeout = 30\n",
"self.configuration.eqlx_cli_max_retries = 5\n",
"self.configuration.eqlx_chap_login = 'admin'\n",
"self.configuration.eqlx_chap_password = 'password'\n",
"self.configuration.volume_name_template = 'volume_%s'\n",
"self._context = context.get_admin_context()\n",
"self.driver = eqlx.DellEQLSanISCSIDriver(configuration=self.configuration)\n",
"self.volume_name = 'fakevolume'\n",
"self.volid = 'fakeid'\n",
"self.connector = {'ip': '10.0.0.2', 'initiator':\n 'iqn.1993-08.org.debian:01:222', 'host': 'fakehost'}\n",
"self.fake_iqn = 'iqn.2003-10.com.equallogic:group01:25366:fakev'\n",
"self.driver._group_ip = '10.0.1.6'\n",
"self.properties = {'target_discoverd': True, 'target_portal': '%s:3260' %\n self.driver._group_ip, 'target_iqn': self.fake_iqn, 'volume_id': 1}\n",
"self._model_update = {'provider_location': '%s:3260,1 %s 0' % (self.driver.\n _group_ip, self.fake_iqn), 'provider_auth': 'CHAP %s %s' % (self.\n configuration.eqlx_chap_login, self.configuration.eqlx_chap_password)}\n",
"def FUNC_1(self, VAR_1):...\n",
"return self.properties\n"
] | [
"import time\n",
"import mox\n",
"import paramiko\n",
"from cinder import context\n",
"from cinder import exception\n",
"from cinder.openstack.common import log as logging\n",
"from cinder.openstack.common import processutils\n",
"from cinder import test\n",
"from cinder.volume import configuration as conf\n",
"from cinder.volume.drivers import eqlx\n",
"LOG = logging.getLogger(__name__)\n",
"def setUp(self):...\n",
"super(DellEQLSanISCSIDriverTestCase, self).setUp()\n",
"self.configuration = mox.MockObject(conf.Configuration)\n",
"self.configuration.append_config_values(mox.IgnoreArg())\n",
"self.configuration.san_is_local = False\n",
"self.configuration.san_ip = '10.0.0.1'\n",
"self.configuration.san_login = 'foo'\n",
"self.configuration.san_password = 'bar'\n",
"self.configuration.san_ssh_port = 16022\n",
"self.configuration.san_thin_provision = True\n",
"self.configuration.eqlx_pool = 'non-default'\n",
"self.configuration.eqlx_use_chap = True\n",
"self.configuration.eqlx_group_name = 'group-0'\n",
"self.configuration.eqlx_cli_timeout = 30\n",
"self.configuration.eqlx_cli_max_retries = 5\n",
"self.configuration.eqlx_chap_login = 'admin'\n",
"self.configuration.eqlx_chap_password = 'password'\n",
"self.configuration.volume_name_template = 'volume_%s'\n",
"self._context = context.get_admin_context()\n",
"self.driver = eqlx.DellEQLSanISCSIDriver(configuration=self.configuration)\n",
"self.volume_name = 'fakevolume'\n",
"self.volid = 'fakeid'\n",
"self.connector = {'ip': '10.0.0.2', 'initiator':\n 'iqn.1993-08.org.debian:01:222', 'host': 'fakehost'}\n",
"self.fake_iqn = 'iqn.2003-10.com.equallogic:group01:25366:fakev'\n",
"self.driver._group_ip = '10.0.1.6'\n",
"self.properties = {'target_discoverd': True, 'target_portal': '%s:3260' %\n self.driver._group_ip, 'target_iqn': self.fake_iqn, 'volume_id': 1}\n",
"self._model_update = {'provider_location': '%s:3260,1 %s 0' % (self.driver.\n _group_ip, self.fake_iqn), 'provider_auth': 'CHAP %s %s' % (self.\n configuration.eqlx_chap_login, self.configuration.eqlx_chap_password)}\n",
"def _fake_get_iscsi_properties(self, volume):...\n",
"return self.properties\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_4(self, VAR_6, **VAR_7):...\n",
"if self.closed:\n",
"if self._adapter is None:\n",
"if self._session is not None:\n"
] | [
"def attach_pid(self, pid, **kwargs):...\n",
"if self.closed:\n",
"if self._adapter is None:\n",
"if self._session is not None:\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"Condition"
] |
[
"def FUNC_6(self, VAR_9):...\n",
"VAR_19 = urllib2.Request(self.url + VAR_9)\n",
"VAR_20 = self._opener.open(VAR_19)\n",
"VAR_10 = VAR_20.read()\n",
"return VAR_10\n"
] | [
"def get(self, suburl):...\n",
"request = urllib2.Request(self.url + suburl)\n",
"f = self._opener.open(request)\n",
"data = f.read()\n",
"return data\n"
] | [
0,
5,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_9(self, VAR_4, VAR_13, VAR_14):...\n",
"VAR_35 = None\n",
"if VAR_4.properties.commands:\n",
"VAR_35 = VAR_4.properties.commands[0]\n",
"if VAR_4.properties.command:\n",
"VAR_36 = {'cmd': 'run', 'manifest': {'bot_id': VAR_14, 'command': VAR_35,\n 'dimensions': VAR_4.properties.dimensions, 'env': VAR_4.properties.env,\n 'extra_args': VAR_4.properties.extra_args, 'grace_period': VAR_4.\n properties.grace_period_secs, 'hard_timeout': VAR_4.properties.\n execution_timeout_secs, 'host': utils.get_versioned_hosturl(),\n 'io_timeout': VAR_4.properties.io_timeout_secs, 'inputs_ref': VAR_4.\n properties.inputs_ref, 'task_id': task_pack.pack_run_result_key(VAR_13)}}\n",
"VAR_35 = VAR_4.properties.command\n",
"self.send_response(utils.to_json_encodable(VAR_36))\n"
] | [
"def _cmd_run(self, request, run_result_key, bot_id):...\n",
"cmd = None\n",
"if request.properties.commands:\n",
"cmd = request.properties.commands[0]\n",
"if request.properties.command:\n",
"out = {'cmd': 'run', 'manifest': {'bot_id': bot_id, 'command': cmd,\n 'dimensions': request.properties.dimensions, 'env': request.properties.\n env, 'extra_args': request.properties.extra_args, 'grace_period':\n request.properties.grace_period_secs, 'hard_timeout': request.\n properties.execution_timeout_secs, 'host': utils.get_versioned_hosturl(\n ), 'io_timeout': request.properties.io_timeout_secs, 'inputs_ref':\n request.properties.inputs_ref, 'task_id': task_pack.pack_run_result_key\n (run_result_key)}}\n",
"cmd = request.properties.command\n",
"self.send_response(utils.to_json_encodable(out))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_2():...\n",
"VAR_2 = json.load(f)\n"
] | [
"def read_cms_config():...\n",
"cms_config = json.load(f)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"def FUNC_9(self, VAR_18, VAR_11, VAR_12):...\n",
"self.logger.info('Arrived at ' + str((VAR_11, VAR_12)) +\n ' (map position is ' + str((self.navloc.map_pos.x, self.navloc.map_pos.\n y)) + ')')\n",
"self.navloc.csvLogArrival(self.test_name, VAR_11, VAR_12)\n"
] | [
"def logArrival(self, name, x, y):...\n",
"self.logger.info('Arrived at ' + str((x, y)) + ' (map position is ' + str((\n self.navloc.map_pos.x, self.navloc.map_pos.y)) + ')')\n",
"self.navloc.csvLogArrival(self.test_name, x, y)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'"
] |
[
"from django.utils import timezone\n",
"from django.contrib.auth.models import User\n",
"from dashboard.models import *\n",
"VAR_0 = ['00_superuser', '01_lookups', '02_datasource', '03_datagroup',\n '04_PUC', '05_product', '06_datadocument', '07_rawchem_etc',\n '08_script', '09_productdocument', '10_habits_and_practices',\n '11_habits_and_practices_to_puc', '12_product_to_puc', '13_puc_tag']\n",
"\"\"\"dot.notation access to dictionary attributes\"\"\"\n",
"__getattr__ = dict.get\n",
"__setattr__ = dict.__setitem__\n",
"__delattr__ = dict.__delitem__\n",
"def FUNC_0():...\n",
"VAR_1 = User.objects.create_user(username='Karyn', password='specialP@55word')\n",
"VAR_2 = User.objects.create_superuser(username='SuperKaryn', password=\n 'specialP@55word', email='me@epa.gov')\n",
"VAR_3 = DataSource.objects.create(title='Data Source for Test',\n estimated_records=2, state='AT', priority='HI')\n",
"VAR_4 = Script.objects.create(title='Test Download Script', url=\n 'http://www.epa.gov/', qa_begun=False, script_type='DL')\n",
"VAR_5 = Script.objects.create(title='Test Extraction Script', url=\n 'http://www.epa.gov/', qa_begun=False, script_type='EX')\n",
"VAR_6 = GroupType.objects.create(title='Composition', code='CO')\n",
"VAR_7 = DataGroup.objects.create(name='Data Group for Test', description=\n 'Testing...', data_source=ds, download_script=script, downloaded_by=\n user, downloaded_at=timezone.now(), group_type=gt, csv=\n 'register_records_matching.csv', url='https://www.epa.gov')\n",
"VAR_8 = DocumentType.objects.create(title='MSDS', code='MS', group_type=gt)\n",
"VAR_9 = DataDocument.objects.create(title='test document', data_group=dg,\n document_type=dt, filename='example.pdf')\n",
"VAR_10 = Product.objects.create(data_source=ds, upc='Test UPC for ProductToPUC'\n )\n",
"VAR_11 = PUC.objects.create(gen_cat='Test General Category', prod_fam=\n 'Test Product Family', prod_type='Test Product Type', description=\n 'Test Product Description', last_edited_by=user, kind='FO')\n",
"VAR_12 = ExtractedText.objects.create(prod_name=\n 'Test Extracted Text Record', data_document=doc, extraction_script=exscript\n )\n",
"VAR_13 = UnitType.objects.create(title='percent composition')\n",
"VAR_14 = WeightFractionType.objects.create(title='reported', description=\n 'reported')\n",
"VAR_15 = ExtractedChemical.objects.create(extracted_text=extext, unit_type=\n ut, weight_fraction_type=wft, raw_chem_name='Test Chem Name', raw_cas=\n 'test_cas')\n",
"VAR_16 = VAR_15.rawchem_ptr\n",
"VAR_17 = Ingredient.objects.create(lower_wf_analysis=0.123456789012345,\n central_wf_analysis=0.2, upper_wf_analysis=1, VAR_4=script, rawchem_ptr=rc)\n",
"VAR_18 = PUCTag.objects.create(name='Test PUC Attribute')\n",
"VAR_19 = ProductDocument.objects.create(product=p, document=doc)\n",
"VAR_20 = ExtractedHabitsAndPractices.objects.create(extracted_text=extext,\n product_surveyed='Test Product Surveyed', prevalence='Continuous')\n",
"return CLASS_0({'user': VAR_1, 'superuser': VAR_2, 'ds': VAR_3, 'script':\n VAR_4, 'exscript': VAR_5, 'dg': VAR_7, 'doc': VAR_9, 'p': VAR_10, 'puc':\n VAR_11, 'extext': VAR_12, 'ut': VAR_13, 'wft': VAR_14, 'rc': VAR_16,\n 'ec': VAR_15, 'pt': VAR_18, 'pd': VAR_19, 'ing': VAR_17, 'dt': VAR_8,\n 'gt': VAR_6, 'ehp': VAR_20})\n"
] | [
"from django.utils import timezone\n",
"from django.contrib.auth.models import User\n",
"from dashboard.models import *\n",
"fixtures_standard = ['00_superuser', '01_lookups', '02_datasource',\n '03_datagroup', '04_PUC', '05_product', '06_datadocument',\n '07_rawchem_etc', '08_script', '09_productdocument',\n '10_habits_and_practices', '11_habits_and_practices_to_puc',\n '12_product_to_puc', '13_puc_tag']\n",
"\"\"\"dot.notation access to dictionary attributes\"\"\"\n",
"__getattr__ = dict.get\n",
"__setattr__ = dict.__setitem__\n",
"__delattr__ = dict.__delitem__\n",
"def load_model_objects():...\n",
"user = User.objects.create_user(username='Karyn', password='specialP@55word')\n",
"superuser = User.objects.create_superuser(username='SuperKaryn', password=\n 'specialP@55word', email='me@epa.gov')\n",
"ds = DataSource.objects.create(title='Data Source for Test',\n estimated_records=2, state='AT', priority='HI')\n",
"script = Script.objects.create(title='Test Download Script', url=\n 'http://www.epa.gov/', qa_begun=False, script_type='DL')\n",
"exscript = Script.objects.create(title='Test Extraction Script', url=\n 'http://www.epa.gov/', qa_begun=False, script_type='EX')\n",
"gt = GroupType.objects.create(title='Composition', code='CO')\n",
"dg = DataGroup.objects.create(name='Data Group for Test', description=\n 'Testing...', data_source=ds, download_script=script, downloaded_by=\n user, downloaded_at=timezone.now(), group_type=gt, csv=\n 'register_records_matching.csv', url='https://www.epa.gov')\n",
"dt = DocumentType.objects.create(title='MSDS', code='MS', group_type=gt)\n",
"doc = DataDocument.objects.create(title='test document', data_group=dg,\n document_type=dt, filename='example.pdf')\n",
"p = Product.objects.create(data_source=ds, upc='Test UPC for ProductToPUC')\n",
"puc = PUC.objects.create(gen_cat='Test General Category', prod_fam=\n 'Test Product Family', prod_type='Test Product Type', description=\n 'Test Product Description', last_edited_by=user, kind='FO')\n",
"extext = ExtractedText.objects.create(prod_name=\n 'Test Extracted Text Record', data_document=doc, extraction_script=exscript\n )\n",
"ut = UnitType.objects.create(title='percent composition')\n",
"wft = WeightFractionType.objects.create(title='reported', description=\n 'reported')\n",
"ec = ExtractedChemical.objects.create(extracted_text=extext, unit_type=ut,\n weight_fraction_type=wft, raw_chem_name='Test Chem Name', raw_cas=\n 'test_cas')\n",
"rc = ec.rawchem_ptr\n",
"ing = Ingredient.objects.create(lower_wf_analysis=0.123456789012345,\n central_wf_analysis=0.2, upper_wf_analysis=1, script=script, rawchem_ptr=rc\n )\n",
"pt = PUCTag.objects.create(name='Test PUC Attribute')\n",
"pd = ProductDocument.objects.create(product=p, document=doc)\n",
"ehp = ExtractedHabitsAndPractices.objects.create(extracted_text=extext,\n product_surveyed='Test Product Surveyed', prevalence='Continuous')\n",
"return dotdict({'user': user, 'superuser': superuser, 'ds': ds, 'script':\n script, 'exscript': exscript, 'dg': dg, 'doc': doc, 'p': p, 'puc': puc,\n 'extext': extext, 'ut': ut, 'wft': wft, 'rc': rc, 'ec': ec, 'pt': pt,\n 'pd': pd, 'ing': ing, 'dt': dt, 'gt': gt, 'ehp': ehp})\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@rest_utils.ajax()...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_35 = quotas.get_disabled_quotas(VAR_1)\n",
"VAR_36 = [quota for quota in quotas.QUOTA_FIELDS if quota not in VAR_35]\n",
"return {'items': VAR_36}\n"
] | [
"@rest_utils.ajax()...\n",
"\"\"\"docstring\"\"\"\n",
"disabled_quotas = quotas.get_disabled_quotas(request)\n",
"editable_quotas = [quota for quota in quotas.QUOTA_FIELDS if quota not in\n disabled_quotas]\n",
"return {'items': editable_quotas}\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_1(VAR_6, VAR_7):...\n",
"if not which(VAR_6):\n"
] | [
"def check_executable(cmdname, pkg):...\n",
"if not which(cmdname):\n"
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_15(self, VAR_16, VAR_18):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_25 = self._eql_execute('volume', 'select', VAR_18['volume_name'],\n 'snapshot', 'select', VAR_18['name'], 'clone', VAR_16['name'])\n",
"VAR_0.error(_('Failed to create volume from snapshot %s'), VAR_18['name'])\n",
"return self._get_volume_data(VAR_25)\n"
] | [
"def create_volume_from_snapshot(self, volume, snapshot):...\n",
"\"\"\"docstring\"\"\"\n",
"out = self._eql_execute('volume', 'select', snapshot['volume_name'],\n 'snapshot', 'select', snapshot['name'], 'clone', volume['name'])\n",
"LOG.error(_('Failed to create volume from snapshot %s'), snapshot['name'])\n",
"return self._get_volume_data(out)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Return'"
] |
[
"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_1(VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"from app.questions.api.v1.view import question_blueprint\n",
"from .home.views import home_blueprint\n",
"from .auth.api.v1.view import auth_blueprint\n",
"from .answers.api.v1.view import answers_blueprint\n",
"from .votes.api.v1.view import votes_blueprint\n",
"from .comments.api.v1.view import comments_blueprint\n",
"VAR_2 = [answers_blueprint, question_blueprint, auth_blueprint,\n votes_blueprint, comments_blueprint, home_blueprint]\n",
"for bp in VAR_2:\n",
"VAR_1.register_blueprint(bp)\n"
] | [
"def configure_blueprints(app):...\n",
"\"\"\"docstring\"\"\"\n",
"from app.questions.api.v1.view import question_blueprint\n",
"from .home.views import home_blueprint\n",
"from .auth.api.v1.view import auth_blueprint\n",
"from .answers.api.v1.view import answers_blueprint\n",
"from .votes.api.v1.view import votes_blueprint\n",
"from .comments.api.v1.view import comments_blueprint\n",
"app_blueprints = [answers_blueprint, question_blueprint, auth_blueprint,\n votes_blueprint, comments_blueprint, home_blueprint]\n",
"for bp in app_blueprints:\n",
"app.register_blueprint(bp)\n"
] | [
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"For",
"Expr'"
] |
[
"def FUNC_3(self, VAR_7):...\n",
"self.index = VAR_7\n"
] | [
"def set_index(self, new_index):...\n",
"self.index = new_index\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"def __eq__(self, VAR_35):...\n",
"return self.__class__ == VAR_35.__class__ and self.size == VAR_35.size\n"
] | [
"def __eq__(self, other):...\n",
"return self.__class__ == other.__class__ and self.size == other.size\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_27(self, VAR_14, VAR_30, VAR_29):...\n",
"VAR_53 = \"%s '%s' '%s'\" % (VAR_5, VAR_30, VAR_14)\n",
"VAR_12 = \"ssh %s 'bash -s' < %s\" % (VAR_29, VAR_53)\n",
"FUNC_7(self.session, VAR_12)\n"
] | [
"def start_remote_clone_session(self, comp_name, session_name, hostname):...\n",
"remote_cmd = \"%s '%s' '%s'\" % (SCRIPT_CLONE_PATH, session_name, comp_name)\n",
"cmd = \"ssh %s 'bash -s' < %s\" % (hostname, remote_cmd)\n",
"send_main_session_command(self.session, cmd)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_6(self, VAR_23):...\n",
"VAR_23 = FUNC_1(VAR_23)\n",
"if not VAR_23:\n",
"return self.error()\n",
"VAR_15 = Subreddit._by_name(VAR_23)\n",
"return VAR_23\n",
"return self.error(errors.SUBREDDIT_EXISTS)\n"
] | [
"def run(self, name):...\n",
"name = chksrname(name)\n",
"if not name:\n",
"return self.error()\n",
"a = Subreddit._by_name(name)\n",
"return name\n",
"return self.error(errors.SUBREDDIT_EXISTS)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Return'",
"Return'"
] |
[
"def FUNC_20(self):...\n",
"\"\"\"docstring\"\"\"\n",
"tournament.registerPlayer(VAR_1='a')\n"
] | [
"def test_name_less_two_characters(self):...\n",
"\"\"\"docstring\"\"\"\n",
"tournament.registerPlayer(player_name='a')\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'"
] |
[
"@staticmethod...\n",
"def FUNC_14(VAR_7):...\n",
"def FUNC_13(self, *VAR_16, **VAR_10):...\n",
"if not self.is_group_user(VAR_8):\n",
"return VAR_7(self, *VAR_16, **kwargs)\n"
] | [
"@staticmethod...\n",
"def decorator(method):...\n",
"def wrapper(self, *args, **kwargs):...\n",
"if not self.is_group_user(group):\n",
"return method(self, *args, **kwargs)\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"FunctionDef'",
"FunctionDef'",
"Condition",
"Return'"
] |
[
"{'name': 'FIT BCNL Events', 'category': 'Website', 'version': '10.0.0.0.1',\n 'author': 'Fundament IT', 'website': 'https://fundament.it/', 'licence':\n 'AGPL-3', 'depends': ['website_event'], 'summary': '', 'description':\n \"\"\"\nExtension for the default Events module; used for BCNL, .\n \"\"\",\n 'data': ['data/fit_actions.xml', 'data/fit_event_views.xml',\n 'data/fit_product_views.xml', 'data/fit_res_partner_view.xml',\n 'report/fit_report_subscription_view.xml', 'security/user_groups.xml',\n 'views/fit_event_views.xml', 'views/fit_subscription_templates.xml',\n 'views/fit_website_event_sale_templates.xml',\n 'views/fit_website_event_templates.xml',\n 'views/fit_website_templates.xml'], 'installable': True}\n"
] | [
"{'name': 'FIT BCNL Events', 'category': 'Website', 'version': '10.0.0.0.1',\n 'author': 'Fundament IT', 'website': 'https://fundament.it/', 'licence':\n 'AGPL-3', 'depends': ['website_event'], 'summary': '', 'description':\n \"\"\"\nExtension for the default Events module; used for BCNL, .\n \"\"\",\n 'data': ['data/fit_actions.xml', 'data/fit_event_views.xml',\n 'data/fit_product_views.xml', 'data/fit_res_partner_view.xml',\n 'report/fit_report_subscription_view.xml', 'security/user_groups.xml',\n 'views/fit_event_views.xml', 'views/fit_subscription_templates.xml',\n 'views/fit_website_event_sale_templates.xml',\n 'views/fit_website_event_templates.xml',\n 'views/fit_website_templates.xml'], 'installable': True}\n"
] | [
6
] | [
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"VAR_28 = Gtk.Builder()\n",
"VAR_28.add_from_resource('/run/terminal/KeepassGtk/main_window.ui')\n",
"self.headerbar = VAR_28.get_object('headerbar')\n",
"VAR_29 = VAR_28.get_object('open_button')\n",
"VAR_29.connect('clicked', self.open_filechooser, None)\n",
"VAR_30 = VAR_28.get_object('new_button')\n",
"VAR_30.connect('clicked', self.create_filechooser, None)\n",
"self.set_titlebar(self.headerbar)\n"
] | [
"def create_headerbar(self):...\n",
"builder = Gtk.Builder()\n",
"builder.add_from_resource('/run/terminal/KeepassGtk/main_window.ui')\n",
"self.headerbar = builder.get_object('headerbar')\n",
"file_open_button = builder.get_object('open_button')\n",
"file_open_button.connect('clicked', self.open_filechooser, None)\n",
"file_new_button = builder.get_object('new_button')\n",
"file_new_button.connect('clicked', self.create_filechooser, None)\n",
"self.set_titlebar(self.headerbar)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_0(self, VAR_0):...\n",
""
] | [
"def get(self, user_id):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_7(self):...\n",
"super(CLASS_0, self).validate()\n",
"if not self.blog_intro:\n",
"self.blog_intro = self.content[:140]\n",
"if self.blog_intro:\n",
"self.blog_intro = strip_html_tags(self.blog_intro)\n",
"self.blog_intro = self.blog_intro[:140]\n",
"if self.published and not self.published_on:\n",
"self.published_on = today()\n",
"frappe.db.sql('string', (self.blogger,))\n"
] | [
"def validate(self):...\n",
"super(BlogPost, self).validate()\n",
"if not self.blog_intro:\n",
"self.blog_intro = self.content[:140]\n",
"if self.blog_intro:\n",
"self.blog_intro = strip_html_tags(self.blog_intro)\n",
"self.blog_intro = self.blog_intro[:140]\n",
"if self.published and not self.published_on:\n",
"self.published_on = today()\n",
"frappe.db.sql(\n \"\"\"update tabBlogger set posts=(select count(*) from `tabBlog Post`\n\t\t\twhere ifnull(blogger,'')=tabBlogger.name)\n\t\t\twhere name=%s\"\"\"\n , (self.blogger,))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'"
] |
[
"import re\n",
"from flask import request\n",
"\"\"\"\n Stack data structure will not insert\n equal sequential data\n \"\"\"\n",
"def __init__(self, VAR_1=None, VAR_2=5):...\n",
"self.size = VAR_2\n",
"self.data = VAR_1 or []\n",
"def FUNC_5(self, VAR_3):...\n",
"if self.data:\n",
"if VAR_3 != self.data[len(self.data) - 1]:\n",
"self.data.append(VAR_3)\n",
"self.data.append(VAR_3)\n",
"if len(self.data) > self.size:\n",
"self.data.pop(0)\n",
"def FUNC_6(self):...\n",
"if len(self.data) == 0:\n",
"return None\n",
"return self.data.pop(len(self.data) - 1)\n"
] | [
"import re\n",
"from flask import request\n",
"\"\"\"\n Stack data structure will not insert\n equal sequential data\n \"\"\"\n",
"def __init__(self, list=None, size=5):...\n",
"self.size = size\n",
"self.data = list or []\n",
"def push(self, item):...\n",
"if self.data:\n",
"if item != self.data[len(self.data) - 1]:\n",
"self.data.append(item)\n",
"self.data.append(item)\n",
"if len(self.data) > self.size:\n",
"self.data.pop(0)\n",
"def pop(self):...\n",
"if len(self.data) == 0:\n",
"return None\n",
"return self.data.pop(len(self.data) - 1)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"ImportFrom'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"FunctionDef'",
"Condition",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_11(self, VAR_2, VAR_3, VAR_19, VAR_20={}, VAR_7={}):...\n",
"VAR_39 = self.browse(VAR_2, VAR_3, VAR_19, VAR_7=context)\n",
"VAR_20 = VAR_20 or {}\n",
"VAR_7['active_test'] = False\n",
"VAR_20['state'] = 'open'\n",
"if not VAR_20.get('name', False):\n",
"VAR_20['name'] = VAR_39.name + _(' (copy)')\n",
"VAR_34 = super(VAR_51, self).copy(VAR_2, VAR_3, VAR_19, VAR_20, VAR_7)\n",
"VAR_4 = self.search(VAR_2, VAR_3, [('parent_id', 'child_of', [VAR_34])])\n",
"VAR_2.execute('update project_task set active=True where project_id in %s',\n tuple(VAR_4))\n",
"return VAR_34\n"
] | [
"def copy(self, cr, uid, id, default={}, context={}):...\n",
"proj = self.browse(cr, uid, id, context=context)\n",
"default = default or {}\n",
"context['active_test'] = False\n",
"default['state'] = 'open'\n",
"if not default.get('name', False):\n",
"default['name'] = proj.name + _(' (copy)')\n",
"res = super(project, self).copy(cr, uid, id, default, context)\n",
"ids = self.search(cr, uid, [('parent_id', 'child_of', [res])])\n",
"cr.execute('update project_task set active=True where project_id in %s',\n tuple(ids))\n",
"return res\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def __iter__(self):...\n",
"return iter(self.current)\n"
] | [
"def __iter__(self):...\n",
"return iter(self.current)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_1(self, VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.local:\n",
"self.sftp.stat(VAR_5)\n",
"return False\n",
"os.stat(VAR_5)\n",
"return False\n",
"return True\n",
"return True\n"
] | [
"def file_exists(self, fname):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.local:\n",
"self.sftp.stat(fname)\n",
"return False\n",
"os.stat(fname)\n",
"return False\n",
"return True\n",
"return True\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Return'",
"Expr'",
"Return'",
"Return'",
"Return'"
] |
[
"def FUNC_6(self, VAR_64):...\n",
"if not VAR_64:\n",
"return None\n",
"VAR_88 = [int(i, 36) for i in VAR_64.split(',')]\n",
"VAR_89 = Comment._byID(VAR_88, data=True, return_dict=False)\n",
"return VAR_89\n"
] | [
"def run(self, id_str):...\n",
"if not id_str:\n",
"return None\n",
"cids = [int(i, 36) for i in id_str.split(',')]\n",
"comments = Comment._byID(cids, data=True, return_dict=False)\n",
"return comments\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_14(VAR_16):...\n",
"\"\"\"docstring\"\"\"\n",
"return FUNC_13(VAR_16)\n"
] | [
"def temporary(value):...\n",
"\"\"\"docstring\"\"\"\n",
"return temp(value)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"@property...\n",
"return (file for VAR_13 in self.rules for file in chain(VAR_13.input,\n VAR_13.output) if not callable(file) and not file.contains_wildcard())\n"
] | [
"@property...\n",
"return (file for rule in self.rules for file in chain(rule.input, rule.\n output) if not callable(file) and not file.contains_wildcard())\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def __init__(self, VAR_1):...\n",
"self.conn = VAR_1\n",
"self.s = VAR_1.s\n",
"self.addr = VAR_1.addr\n",
"self.args = VAR_1.args\n",
"self.auth = VAR_1.auth\n",
"self.sr = VAR_1.sr\n",
"self.bufsz = 1024 * 32\n",
"self.ok = True\n",
"self.log_func = VAR_1.log_func\n",
"self.log_src = VAR_1.log_src\n"
] | [
"def __init__(self, conn):...\n",
"self.conn = conn\n",
"self.s = conn.s\n",
"self.addr = conn.addr\n",
"self.args = conn.args\n",
"self.auth = conn.auth\n",
"self.sr = conn.sr\n",
"self.bufsz = 1024 * 32\n",
"self.ok = True\n",
"self.log_func = conn.log_func\n",
"self.log_src = conn.log_src\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def __setstate__(self, VAR_0):...\n",
"return self.deserialize(VAR_0)\n"
] | [
"def __setstate__(self, data):...\n",
"return self.deserialize(data)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_10(self, VAR_7):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_12 = {}\n",
"for tag_list in self.get_tags_dict(VAR_7).values():\n",
"for VAR_6 in tag_list:\n",
"return VAR_12\n",
"if VAR_6 not in VAR_12:\n",
"VAR_12[VAR_6] = 1\n",
"VAR_12[VAR_6] += 1\n"
] | [
"def tag_count(self, tids):...\n",
"\"\"\"docstring\"\"\"\n",
"count_dict = {}\n",
"for tag_list in self.get_tags_dict(tids).values():\n",
"for tag in tag_list:\n",
"return count_dict\n",
"if tag not in count_dict:\n",
"count_dict[tag] = 1\n",
"count_dict[tag] += 1\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"For",
"For",
"Return'",
"Condition",
"Assign'",
"AugAssign'"
] |
[
"def FUNC_1(self, VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"return VAR_2 in self.__id_map\n"
] | [
"def has_id(self, entity_id):...\n",
"\"\"\"docstring\"\"\"\n",
"return entity_id in self.__id_map\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_0(VAR_4):...\n",
"return render(VAR_4, 'index.html')\n"
] | [
"def index(request):...\n",
"return render(request, 'index.html')\n"
] | [
0,
5
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_13(VAR_1, **VAR_6):...\n",
"import sql\n",
"VAR_43 = 'waf.sh'\n",
"VAR_44 = sql.get_setting('tmp_config_path')\n",
"VAR_24 = sql.get_setting('proxy')\n",
"VAR_53 = sql.get_setting('haproxy_dir')\n",
"VAR_54 = FUNC_14(VAR_1)\n",
"os.system('cp scripts/%s .' % VAR_43)\n",
"VAR_13 = ['sudo chmod +x ' + VAR_44 + VAR_43 + ' && ' + VAR_44 + VAR_43 +\n ' PROXY=' + VAR_24 + ' HAPROXY_PATH=' + VAR_53 + ' VERSION=' + VAR_54]\n",
"VAR_51 = str(FUNC_15(VAR_1, VAR_44, VAR_43))\n",
"if VAR_51:\n",
"print('error: ' + VAR_51)\n",
"os.system('rm -f %s' % VAR_43)\n",
"VAR_42 = FUNC_22(VAR_1, VAR_13, print_out='1')\n",
"if VAR_42 is None:\n",
"sql.insert_waf_metrics_enable(VAR_1, '0')\n"
] | [
"def waf_install(serv, **kwargs):...\n",
"import sql\n",
"script = 'waf.sh'\n",
"tmp_config_path = sql.get_setting('tmp_config_path')\n",
"proxy = sql.get_setting('proxy')\n",
"haproxy_dir = sql.get_setting('haproxy_dir')\n",
"ver = check_haproxy_version(serv)\n",
"os.system('cp scripts/%s .' % script)\n",
"commands = ['sudo chmod +x ' + tmp_config_path + script + ' && ' +\n tmp_config_path + script + ' PROXY=' + proxy + ' HAPROXY_PATH=' +\n haproxy_dir + ' VERSION=' + ver]\n",
"error = str(upload(serv, tmp_config_path, script))\n",
"if error:\n",
"print('error: ' + error)\n",
"os.system('rm -f %s' % script)\n",
"stderr = ssh_command(serv, commands, print_out='1')\n",
"if stderr is None:\n",
"sql.insert_waf_metrics_enable(serv, '0')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Import'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Expr'"
] |
[
"from __future__ import absolute_import, division, print_function, with_statement\n",
"import os\n",
"import sys\n",
"import argparse\n",
"if __name__ == '__main__':\n",
"VAR_0 = argparse.ArgumentParser(description='See README')\n",
"VAR_0.add_argument('-c', '--count', default=3, type=int, help=\n 'with how many failure times it should be considered as an attack')\n",
"VAR_1 = VAR_0.parse_args()\n",
"VAR_2 = {}\n",
"VAR_3 = set()\n",
"for line in sys.stdin:\n",
"if 'can not parse header when' in line:\n",
"VAR_4 = line.split()[-1].split(':')[-2]\n",
"if VAR_4 not in VAR_2:\n",
"VAR_2[VAR_4] = 1\n",
"VAR_2[VAR_4] += 1\n",
"print(VAR_4)\n",
"if VAR_4 not in VAR_3 and VAR_2[VAR_4] >= VAR_1.count:\n",
"sys.stdout.flush()\n",
"VAR_3.add(VAR_4)\n",
"VAR_5 = 'iptables -A INPUT -s %s -j DROP' % VAR_4\n",
"print(VAR_5, file=sys.stderr)\n",
"sys.stderr.flush()\n",
"os.system(VAR_5)\n"
] | [
"from __future__ import absolute_import, division, print_function, with_statement\n",
"import os\n",
"import sys\n",
"import argparse\n",
"if __name__ == '__main__':\n",
"parser = argparse.ArgumentParser(description='See README')\n",
"parser.add_argument('-c', '--count', default=3, type=int, help=\n 'with how many failure times it should be considered as an attack')\n",
"config = parser.parse_args()\n",
"ips = {}\n",
"banned = set()\n",
"for line in sys.stdin:\n",
"if 'can not parse header when' in line:\n",
"ip = line.split()[-1].split(':')[-2]\n",
"if ip not in ips:\n",
"ips[ip] = 1\n",
"ips[ip] += 1\n",
"print(ip)\n",
"if ip not in banned and ips[ip] >= config.count:\n",
"sys.stdout.flush()\n",
"banned.add(ip)\n",
"cmd = 'iptables -A INPUT -s %s -j DROP' % ip\n",
"print(cmd, file=sys.stderr)\n",
"sys.stderr.flush()\n",
"os.system(cmd)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
2,
0,
0,
0,
2,
0,
0,
0,
2,
2,
0,
2
] | [
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Assign'",
"Condition",
"Assign'",
"AugAssign'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |