lines
sequencelengths 1
444
| raw_lines
sequencelengths 1
444
| label
sequencelengths 1
444
| type
sequencelengths 1
444
|
---|---|---|---|
[
"@property...\n",
"return import_from_settings('LOGIN_REDIRECT_URL_FAILURE', '/')\n"
] | [
"@property...\n",
"return import_from_settings('LOGIN_REDIRECT_URL_FAILURE', '/')\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_2(VAR_1):...\n",
"FUNC_0()\n",
"FUNC_1()\n",
"VAR_1.add_cog(CLASS_0(VAR_1))\n"
] | [
"def setup(bot):...\n",
"check_folders()\n",
"check_files()\n",
"bot.add_cog(Database(bot))\n"
] | [
0,
0,
0,
2
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"import socket\n",
"import sys\n",
"import re\n",
"import os\n",
"from _thread import *\n",
"from subprocess import Popen, PIPE\n",
"VAR_0 = ''\n",
"VAR_1 = 4949\n",
"VAR_2 = '0.1.0'\n",
"VAR_3 = 'utf-8'\n",
"VAR_4 = '\\n'\n",
"VAR_5 = os.getcwd() + '\\\\plugins'\n",
"VAR_6 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n",
"VAR_6.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n",
"VAR_6.bind((VAR_0, VAR_1))\n",
"print('failed!' + str(msg.errno))\n",
"VAR_6.listen(10)\n",
"sys.exit()\n",
"def FUNC_0(VAR_7):...\n",
"return VAR_7.encode(VAR_3)\n"
] | [
"import socket\n",
"import sys\n",
"import re\n",
"import os\n",
"from _thread import *\n",
"from subprocess import Popen, PIPE\n",
"HOST = ''\n",
"PORT = 4949\n",
"VERSION = '0.1.0'\n",
"ENCODING = 'utf-8'\n",
"LINEBREAK = '\\n'\n",
"PLUGINPATH = os.getcwd() + '\\\\plugins'\n",
"s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n",
"s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\n",
"s.bind((HOST, PORT))\n",
"print('failed!' + str(msg.errno))\n",
"s.listen(10)\n",
"sys.exit()\n",
"def output(what):...\n",
"return what.encode(ENCODING)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_7(self):...\n",
"VAR_2 = CLASS_1.construct_testscript_command('test_input_program.py')\n",
"VAR_3, VAR_4 = run_shell_command(VAR_2, '1 4 10 22')\n",
"self.assertEqual(VAR_3, '37\\n')\n",
"self.assertEqual(VAR_4, '')\n",
"VAR_3, VAR_4 = run_shell_command(VAR_2, '1 p 5')\n",
"self.assertEqual(VAR_3, '')\n",
"self.assertEqual(VAR_4, 'INVALID INPUT\\n')\n"
] | [
"def test_run_shell_command_with_stdin(self):...\n",
"command = RunShellCommandTest.construct_testscript_command(\n 'test_input_program.py')\n",
"stdout, stderr = run_shell_command(command, '1 4 10 22')\n",
"self.assertEqual(stdout, '37\\n')\n",
"self.assertEqual(stderr, '')\n",
"stdout, stderr = run_shell_command(command, '1 p 5')\n",
"self.assertEqual(stdout, '')\n",
"self.assertEqual(stderr, 'INVALID INPUT\\n')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_6(self):...\n",
"self.uut.gives_corrected = True\n",
"VAR_1 = tuple(self.uut.process_output(['a', 'b'], 'filename', ['a', 'b']))\n",
"self.assertEqual((), VAR_1)\n",
"VAR_1 = tuple(self.uut.process_output(['a', 'b'], 'filename', ['a']))\n",
"self.assertEqual(len(VAR_1), 1)\n"
] | [
"def test_gives_corrected(self):...\n",
"self.uut.gives_corrected = True\n",
"out = tuple(self.uut.process_output(['a', 'b'], 'filename', ['a', 'b']))\n",
"self.assertEqual((), out)\n",
"out = tuple(self.uut.process_output(['a', 'b'], 'filename', ['a']))\n",
"self.assertEqual(len(out), 1)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_2(self):...\n",
"return shellutil.run('/usr/bin/bigstart restart sshd', VAR_8=False)\n"
] | [
"def restart_ssh_service(self):...\n",
"return shellutil.run('/usr/bin/bigstart restart sshd', chk_err=False)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_3(VAR_10=None, VAR_4=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_10 = VAR_10 or []\n",
"VAR_4 = VAR_4 or []\n",
"VAR_13 = hashlib.md5(str(time.time())).hexdigest()\n",
"VAR_14 = []\n",
"for VAR_18, VAR_9 in VAR_10:\n",
"VAR_18 = FUNC_2(VAR_18)\n",
"for VAR_18, VAR_19, VAR_9 in VAR_4:\n",
"VAR_9 = FUNC_2(VAR_9)\n",
"VAR_18 = FUNC_2(VAR_18)\n",
"if len(VAR_14) > 1:\n",
"VAR_14.append('--' + VAR_13)\n",
"VAR_19 = FUNC_2(VAR_19)\n",
"VAR_14[-2] += '--'\n",
"VAR_15 = '\\r\\n'.join(VAR_14)\n",
"VAR_14.append('Content-Disposition: form-data; name=\"%s\"' % VAR_18)\n",
"VAR_9 = FUNC_2(VAR_9)\n",
"VAR_16 = 'multipart/form-data; boundary=%s' % VAR_13\n",
"VAR_14.append('')\n",
"VAR_14.append('--' + VAR_13)\n",
"return VAR_16, VAR_15\n",
"VAR_14.append(VAR_9)\n",
"VAR_14.append('Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"' %\n (VAR_18, VAR_19))\n",
"VAR_14.append('--' + VAR_13)\n",
"VAR_14.append('Content-Type: application/octet-stream')\n",
"VAR_14.append('')\n",
"VAR_14.append('')\n",
"VAR_14.append(VAR_9)\n",
"VAR_14.append('--' + VAR_13)\n",
"VAR_14.append('')\n"
] | [
"def EncodeMultipartFormData(fields=None, files=None):...\n",
"\"\"\"docstring\"\"\"\n",
"fields = fields or []\n",
"files = files or []\n",
"boundary = hashlib.md5(str(time.time())).hexdigest()\n",
"body_list = []\n",
"for key, value in fields:\n",
"key = _ConvertToAscii(key)\n",
"for key, filename, value in files:\n",
"value = _ConvertToAscii(value)\n",
"key = _ConvertToAscii(key)\n",
"if len(body_list) > 1:\n",
"body_list.append('--' + boundary)\n",
"filename = _ConvertToAscii(filename)\n",
"body_list[-2] += '--'\n",
"body = '\\r\\n'.join(body_list)\n",
"body_list.append('Content-Disposition: form-data; name=\"%s\"' % key)\n",
"value = _ConvertToAscii(value)\n",
"content_type = 'multipart/form-data; boundary=%s' % boundary\n",
"body_list.append('')\n",
"body_list.append('--' + boundary)\n",
"return content_type, body\n",
"body_list.append(value)\n",
"body_list.append('Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"' %\n (key, filename))\n",
"body_list.append('--' + boundary)\n",
"body_list.append('Content-Type: application/octet-stream')\n",
"body_list.append('')\n",
"body_list.append('')\n",
"body_list.append(value)\n",
"body_list.append('--' + boundary)\n",
"body_list.append('')\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
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"For",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"AugAssign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Return'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_3(VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13=None, VAR_14=32...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_30, VAR_31 = VAR_11\n",
"VAR_32 = glob.glob(os.path.join(VAR_7, VAR_9, VAR_10, VAR_8, '*.tif'))\n",
"VAR_32 = FUNC_0(FUNC_1(VAR_32, VAR_4=decade_begin, VAR_5=decade_end, VAR_1=\n '_', VAR_3=-1))\n",
"VAR_33 = pd.Series(VAR_32).groupby([os.path.basename(i).split('_')[-2] for\n i in VAR_32])\n",
"VAR_33 = {i: j.tolist() for i, j in VAR_33}\n",
"VAR_34 = {}\n",
"for VAR_58 in VAR_33:\n",
"VAR_54 = mp.Pool(VAR_14)\n",
"return {'_'.join([VAR_9, VAR_10, VAR_8, VAR_13, VAR_57(VAR_30), VAR_57(\n VAR_31)]): VAR_34}\n",
"VAR_53 = np.array(VAR_54.map(FUNC_2, VAR_33[VAR_58]))\n",
"VAR_54.close()\n",
"VAR_54.join()\n",
"VAR_54.terminate()\n",
"VAR_54 = None\n",
"VAR_55 = np.mean(VAR_53, axis=0)\n",
"VAR_53 = None\n",
"VAR_56 = np.ma.masked_array(VAR_55, VAR_12 == 0)\n",
"VAR_34[VAR_57(VAR_58)] = {'stdev': VAR_57(np.std(VAR_56)), 'mean': VAR_57(\n np.mean(VAR_56)), 'min': VAR_57(np.min(VAR_56)), 'max': VAR_57(np.max(\n VAR_56))}\n",
"if VAR_13 == None:\n",
"VAR_13, = VAR_57(np.unique(VAR_12 > 0))\n"
] | [
"def get_metrics(base_path, variable, model, scenario, decade, mask,...\n",
"\"\"\"docstring\"\"\"\n",
"decade_begin, decade_end = decade\n",
"modeled_files = glob.glob(os.path.join(base_path, model, scenario, variable,\n '*.tif'))\n",
"modeled_files = sort_files(only_years(modeled_files, begin=decade_begin,\n end=decade_end, split_on='_', elem_year=-1))\n",
"month_grouped = pd.Series(modeled_files).groupby([os.path.basename(i).split\n ('_')[-2] for i in modeled_files])\n",
"month_grouped = {i: j.tolist() for i, j in month_grouped}\n",
"month_dict = {}\n",
"for month in month_grouped:\n",
"pool = mp.Pool(ncpus)\n",
"return {'_'.join([model, scenario, variable, domain_name, str(decade_begin),\n str(decade_end)]): month_dict}\n",
"arr = np.array(pool.map(f, month_grouped[month]))\n",
"pool.close()\n",
"pool.join()\n",
"pool.terminate()\n",
"pool = None\n",
"mean_arr = np.mean(arr, axis=0)\n",
"arr = None\n",
"masked = np.ma.masked_array(mean_arr, mask == 0)\n",
"month_dict[str(month)] = {'stdev': str(np.std(masked)), 'mean': str(np.mean\n (masked)), 'min': str(np.min(masked)), 'max': str(np.max(masked))}\n",
"if domain_name == None:\n",
"domain_name, = str(np.unique(mask > 0))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Return'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'"
] |
[
"def __hash__(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_36 = self.get_id()\n",
"return VAR_36 is None and id(self._data) or hash((self._get_entity_type(),\n VAR_36))\n"
] | [
"def __hash__(self):...\n",
"\"\"\"docstring\"\"\"\n",
"data_id = self.get_id()\n",
"return data_id is None and id(self._data) or hash((self._get_entity_type(),\n data_id))\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Return'"
] |
[
"def FUNC_3(self):...\n",
"VAR_4 = {'username': 'first', 'password': 'password', 'email':\n '[email protected]'}\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 '[email protected]'}\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 '[email protected]'}\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 '[email protected]'}\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'"
] |
[
"import datetime\n",
"import psycopg2\n",
"def FUNC_0():...\n",
"VAR_1 = psycopg2.connect('dbname=forum')\n",
"VAR_2 = VAR_1.cursor()\n",
"\"\"\"Return all posts from the 'database', most recent first.\"\"\"\n",
"VAR_2.execute('SELECT time, content FROM posts order by time DESC')\n",
"VAR_3 = ({'content': str(row[1]), 'time': str(row[0])} for row in VAR_2.\n fetchall())\n",
"VAR_1.close()\n",
"return VAR_3\n"
] | [
"import datetime\n",
"import psycopg2\n",
"def get_posts():...\n",
"db = psycopg2.connect('dbname=forum')\n",
"c = db.cursor()\n",
"\"\"\"Return all posts from the 'database', most recent first.\"\"\"\n",
"c.execute('SELECT time, content FROM posts order by time DESC')\n",
"posts = ({'content': str(row[1]), 'time': str(row[0])} for row in c.fetchall())\n",
"db.close()\n",
"return posts\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def __init__(self, *VAR_6, **VAR_7):...\n",
"super(CLASS_23, self).__init__(*VAR_6, **kwargs)\n",
"if hasattr(self.instance, 'dsstox') and self.instance.dsstox is not None:\n",
"self.fields['true_cas'] = forms.CharField(max_length=200)\n",
"self.fields['true_cas'].initial = self.instance.dsstox.true_cas\n",
"self.fields['true_cas'].disabled = True\n",
"self.fields['true_chemname'] = forms.CharField(max_length=400)\n",
"self.fields['true_chemname'].initial = self.instance.dsstox.true_chemname\n",
"self.fields['true_chemname'].disabled = True\n",
"self.fields['SID'] = forms.CharField(max_length=50)\n",
"self.fields['SID'].initial = self.instance.dsstox.sid\n",
"self.fields['SID'].disabled = True\n"
] | [
"def __init__(self, *args, **kwargs):...\n",
"super(ExtractedChemicalForm, self).__init__(*args, **kwargs)\n",
"if hasattr(self.instance, 'dsstox') and self.instance.dsstox is not None:\n",
"self.fields['true_cas'] = forms.CharField(max_length=200)\n",
"self.fields['true_cas'].initial = self.instance.dsstox.true_cas\n",
"self.fields['true_cas'].disabled = True\n",
"self.fields['true_chemname'] = forms.CharField(max_length=400)\n",
"self.fields['true_chemname'].initial = self.instance.dsstox.true_chemname\n",
"self.fields['true_chemname'].disabled = True\n",
"self.fields['SID'] = forms.CharField(max_length=50)\n",
"self.fields['SID'].initial = self.instance.dsstox.sid\n",
"self.fields['SID'].disabled = True\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_38(self, VAR_40, VAR_41, VAR_42=None):...\n",
"\"\"\"docstring\"\"\"\n",
"self._names[VAR_40] = VAR_41, VAR_42\n",
"if VAR_42 is None:\n",
"setattr(self, VAR_40, self[VAR_41])\n",
"setattr(self, VAR_40, CLASS_2(VAR_37=self[index:end]))\n"
] | [
"def set_name(self, name, index, end=None):...\n",
"\"\"\"docstring\"\"\"\n",
"self._names[name] = index, end\n",
"if end is None:\n",
"setattr(self, name, self[index])\n",
"setattr(self, name, Namedlist(toclone=self[index:end]))\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Expr'",
"Expr'"
] |
[
"from dataclasses import dataclass\n",
"from typing import Optional, List, Union, Any, Tuple\n",
"from . import db\n",
"VAR_6: Optional[int]\n",
"VAR_1: int\n",
"content: str\n",
"created_at: Optional[str] = None\n",
"updated_at: Optional[str] = None\n",
"def __json__(self, *VAR_8):...\n",
"return vars(self)\n"
] | [
"from dataclasses import dataclass\n",
"from typing import Optional, List, Union, Any, Tuple\n",
"from . import db\n",
"note_id: Optional[int]\n",
"user_id: int\n",
"content: str\n",
"created_at: Optional[str] = None\n",
"updated_at: Optional[str] = None\n",
"def __json__(self, *args):...\n",
"return vars(self)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"AnnAssign'",
"AnnAssign'",
"AnnAssign'",
"AnnAssign'",
"AnnAssign'",
"FunctionDef'",
"Return'"
] |
[
"@auth.route('/reset', methods=['GET', 'POST'])...\n",
"if not current_user.is_anonymous:\n",
"return redirect(url_for('main.index'))\n",
"VAR_1 = PasswordResetRequestForm()\n",
"if VAR_1.validate_on_submit():\n",
"VAR_2 = User.query.filter_by(email=form.email.data).first()\n",
"return render_template('auth/reset_password.html', VAR_1=form)\n",
"if VAR_2:\n",
"VAR_0 = VAR_2.generate_reset_token()\n",
"flash('An email with instructions for resetting your password has been sent.')\n",
"send_email(VAR_2.email, 'Reset Your Password', 'auth/email/reset_password',\n VAR_2=user, VAR_0=token, next=request.args.get('next'))\n",
"return redirect(url_for('auth.login'))\n"
] | [
"@auth.route('/reset', methods=['GET', 'POST'])...\n",
"if not current_user.is_anonymous:\n",
"return redirect(url_for('main.index'))\n",
"form = PasswordResetRequestForm()\n",
"if form.validate_on_submit():\n",
"user = User.query.filter_by(email=form.email.data).first()\n",
"return render_template('auth/reset_password.html', form=form)\n",
"if user:\n",
"token = user.generate_reset_token()\n",
"flash('An email with instructions for resetting your password has been sent.')\n",
"send_email(user.email, 'Reset Your Password', 'auth/email/reset_password',\n user=user, token=token, next=request.args.get('next'))\n",
"return redirect(url_for('auth.login'))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_23(VAR_6):...\n",
"return FUNC_7(VAR_6, 'Expires', '-1')\n"
] | [
"def validate_expires(page):...\n",
"return validate_security_header(page, 'Expires', '-1')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_2(VAR_6):...\n",
"\"\"\"docstring\"\"\"\n",
"FUNC_5(VAR_6)\n",
"VAR_8 = FUNC_6(VAR_6)\n",
"VAR_15 = FUNC_7(request.data, VAR_8)\n",
"FUNC_8(VAR_15)\n",
"if os.path.isfile('keys/%s/%s.key' % (VAR_6, VAR_15['name'])):\n",
"f.write(VAR_15['key'])\n",
"return 'Key successfully updated', VAR_2\n"
] | [
"def updateKey(client):...\n",
"\"\"\"docstring\"\"\"\n",
"validateClient(client)\n",
"client_pub_key = loadClientRSAKey(client)\n",
"token_data = decodeRequestToken(request.data, client_pub_key)\n",
"validateNewKeyData(token_data)\n",
"if os.path.isfile('keys/%s/%s.key' % (client, token_data['name'])):\n",
"f.write(token_data['key'])\n",
"return 'Key successfully updated', CREATED\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Return'"
] |
[
"def FUNC_11(self, VAR_7, VAR_9):...\n",
"if isinstance(VAR_9, list):\n",
"for v in VAR_9:\n",
"self.append(VAR_7, v)\n"
] | [
"def extend(self, key, value):...\n",
"if isinstance(value, list):\n",
"for v in value:\n",
"self.append(key, v)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"For",
"Expr'"
] |
[
"def FUNC_6(self):...\n",
"self.login()\n",
"while True:\n",
"VAR_29 = random.random()\n",
"VAR_30 = random.choice(self.tasks)\n",
"if VAR_29 < 0.1 and self.submissions_path is not None:\n",
"self.do_step(SubmitRandomRequest(self.browser, VAR_30, VAR_10=self.base_url,\n VAR_11=self.submissions_path))\n",
"if VAR_29 < 0.6 and VAR_30[2] != []:\n",
"self.do_step(TaskStatementRequest(self.browser, VAR_30[1], random.choice(\n VAR_30[2]), VAR_10=self.base_url))\n",
"self.do_step(TaskRequest(self.browser, VAR_30[1], VAR_10=self.base_url))\n"
] | [
"def act(self):...\n",
"self.login()\n",
"while True:\n",
"choice = random.random()\n",
"task = random.choice(self.tasks)\n",
"if choice < 0.1 and self.submissions_path is not None:\n",
"self.do_step(SubmitRandomRequest(self.browser, task, base_url=self.base_url,\n submissions_path=self.submissions_path))\n",
"if choice < 0.6 and task[2] != []:\n",
"self.do_step(TaskStatementRequest(self.browser, task[1], random.choice(task\n [2]), base_url=self.base_url))\n",
"self.do_step(TaskRequest(self.browser, task[1], base_url=self.base_url))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def __init__(self, VAR_0, VAR_1, VAR_2, VAR_3, VAR_4):...\n",
"self.connection = psycopg2.connect(dbname=database, VAR_0=host, VAR_1=port,\n user=username, VAR_4=password)\n"
] | [
"def __init__(self, host, port, database, username, password):...\n",
"self.connection = psycopg2.connect(dbname=database, host=host, port=port,\n user=username, password=password)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"from sqlalchemy.sql import text\n",
"from .dbhelper import engine\n",
"def __init__(self, VAR_0, VAR_1, VAR_2, VAR_3=1, *VAR_4, **VAR_5):...\n",
"self.user_id = VAR_0\n",
"self.username = VAR_1\n",
"self.hashed_password = VAR_2\n",
"self.roll_id = VAR_3\n",
"def FUNC_0(self):...\n",
"return {'user_id': self.user_id, 'username': self.username}\n"
] | [
"from sqlalchemy.sql import text\n",
"from .dbhelper import engine\n",
"def __init__(self, user_id, username, hashed_password, roll_id=1, *args, **...\n",
"self.user_id = user_id\n",
"self.username = username\n",
"self.hashed_password = hashed_password\n",
"self.roll_id = roll_id\n",
"def to_dict(self):...\n",
"return {'user_id': self.user_id, 'username': self.username}\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_3(VAR_0, VAR_3):...\n",
"VAR_4 = VAR_0.cursor()\n",
"VAR_5 = 'ALTER TABLE Presets DROP COLUMN id;'\n",
"VAR_4.execute(VAR_5)\n",
"VAR_5 = (\n 'ALTER TABLE Presets ADD COLUMN id INT AUTO_INCREMENT PRIMARY KEY NOT NULL FIRST;'\n )\n",
"VAR_4.execute(VAR_5)\n",
"VAR_6 = Table('Presets')\n",
"VAR_7 = MySQLQuery.from_(VAR_6).select(VAR_6.querval).where(VAR_6.id == VAR_3)\n",
"print(VAR_7)\n",
"VAR_5 = str(VAR_7)\n",
"VAR_4.execute(VAR_5)\n",
"VAR_8 = VAR_4.fetchone()\n",
"VAR_9 = str(VAR_8)\n",
"return VAR_9[2:-3]\n"
] | [
"def get_preset(conn, key):...\n",
"cursor = conn.cursor()\n",
"quer = 'ALTER TABLE Presets DROP COLUMN id;'\n",
"cursor.execute(quer)\n",
"quer = (\n 'ALTER TABLE Presets ADD COLUMN id INT AUTO_INCREMENT PRIMARY KEY NOT NULL FIRST;'\n )\n",
"cursor.execute(quer)\n",
"extable = Table('Presets')\n",
"q = MySQLQuery.from_(extable).select(extable.querval).where(extable.id == key)\n",
"print(q)\n",
"quer = str(q)\n",
"cursor.execute(quer)\n",
"row = cursor.fetchone()\n",
"strrow = str(row)\n",
"return strrow[2:-3]\n"
] | [
0,
0,
0,
0,
0,
0,
0,
4,
0,
0,
0,
4,
4,
4
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"VAR_5 = [{'cloudProvider': 'gce', 'loadBalancerName': self.__lb_name,\n 'ipProtocol': 'TCP', 'portRange': '8080', 'provider': 'gce', 'stack':\n self.TEST_STACK, 'detail': 'frontend', 'credentials': self.bindings[\n 'GCE_CREDENTIALS'], 'region': self.TEST_REGION, 'listeners': [{\n 'protocol': 'TCP', 'portRange': '8080', 'healthCheck': False}], 'name':\n self.__lb_name, 'type': 'upsertLoadBalancer', 'availabilityZones': {\n self.TEST_REGION: []}, 'user': 'integration-tests'}]\n",
"VAR_6 = gcp.GceContractBuilder(self.gce_observer)\n",
"VAR_6.new_clause_builder('Load Balancer Created', retryable_for_secs=30\n ).list_resources('forwarding-rules').contains_path_value('name', self.\n __lb_name)\n",
"VAR_7 = self.agent.make_json_payload_from_kwargs(VAR_5=job, description=\n 'Server Group Test - create load balancer', application=self.TEST_APP)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'create_load_balancer', data=payload, path=self.__path), contract=\n builder.build())\n"
] | [
"def create_load_balancer(self):...\n",
"job = [{'cloudProvider': 'gce', 'loadBalancerName': self.__lb_name,\n 'ipProtocol': 'TCP', 'portRange': '8080', 'provider': 'gce', 'stack':\n self.TEST_STACK, 'detail': 'frontend', 'credentials': self.bindings[\n 'GCE_CREDENTIALS'], 'region': self.TEST_REGION, 'listeners': [{\n 'protocol': 'TCP', 'portRange': '8080', 'healthCheck': False}], 'name':\n self.__lb_name, 'type': 'upsertLoadBalancer', 'availabilityZones': {\n self.TEST_REGION: []}, 'user': 'integration-tests'}]\n",
"builder = gcp.GceContractBuilder(self.gce_observer)\n",
"builder.new_clause_builder('Load Balancer Created', retryable_for_secs=30\n ).list_resources('forwarding-rules').contains_path_value('name', self.\n __lb_name)\n",
"payload = self.agent.make_json_payload_from_kwargs(job=job, description=\n 'Server Group Test - create load balancer', application=self.TEST_APP)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'create_load_balancer', data=payload, path=self.__path), contract=\n builder.build())\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_11(self, VAR_12=None, VAR_13=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_12 and not VAR_13:\n",
"VAR_12, VAR_13 = self.model.rowCount() + 1, self.model.rowCount(\n ) + self.model.item_load_batch\n",
"if self.filter_input and self.filter_input.text().lower():\n",
"VAR_24 = self.filter_input.text().lower()\n",
"VAR_24 = ''\n",
"VAR_19, VAR_20 = self._get_sort_parameters()\n",
"self.request_mgr = TriblerRequestManager()\n",
"self.request_mgr.perform_request('metadata/channels/%s/torrents' % self.\n model.channel_pk, self.on_torrents, VAR_23={'first': start, 'last': end,\n 'sort_by': sort_by, 'sort_asc': sort_asc, 'hide_xxx': self.model.\n hide_xxx, 'filter': to_fts_query(filter_text)})\n"
] | [
"def load_torrents(self, start=None, end=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if not start and not end:\n",
"start, end = self.model.rowCount() + 1, self.model.rowCount(\n ) + self.model.item_load_batch\n",
"if self.filter_input and self.filter_input.text().lower():\n",
"filter_text = self.filter_input.text().lower()\n",
"filter_text = ''\n",
"sort_by, sort_asc = self._get_sort_parameters()\n",
"self.request_mgr = TriblerRequestManager()\n",
"self.request_mgr.perform_request('metadata/channels/%s/torrents' % self.\n model.channel_pk, self.on_torrents, url_params={'first': start, 'last':\n end, 'sort_by': sort_by, 'sort_asc': sort_asc, 'hide_xxx': self.model.\n hide_xxx, 'filter': to_fts_query(filter_text)})\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_0():...\n",
"VAR_3 = 'data', 'data/database/'\n",
"for folder in VAR_3:\n",
"if not os.path.exists(folder):\n",
"print('Creating ' + folder + ' folder...')\n",
"os.makedirs(folder)\n"
] | [
"def check_folders():...\n",
"folders = 'data', 'data/database/'\n",
"for folder in folders:\n",
"if not os.path.exists(folder):\n",
"print('Creating ' + folder + ' folder...')\n",
"os.makedirs(folder)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Condition",
"Expr'",
"Expr'"
] |
[
"@route('POST', '/-test/fail', VAR_1=website)...\n",
"VAR_16 = get_http_argument('message')\n",
"VAR_0.error(VAR_16)\n",
"get_executing_test().error = VAR_16\n"
] | [
"@route('POST', '/-test/fail', website=website)...\n",
"message = get_http_argument('message')\n",
"LOGGER.error(message)\n",
"get_executing_test().error = message\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Expr'",
"Assign'"
] |
[
"def FUNC_1(self):...\n",
"VAR_11 = []\n",
"VAR_11.append(self.options.directory + '/' + self.options.application)\n",
"if self.options.files:\n",
"for file_ in self.options.files:\n",
"os.makedirs('campaign-data/' + str(self.campaign_data['id']) + '/dut-files')\n",
"VAR_11.append(self.options.directory + '/' + file_)\n",
"for item in VAR_11:\n",
"copy(item, 'campaign-data/' + str(self.campaign_data['id']) + '/dut-files/')\n",
"if self.campaign_data['use_aux']:\n",
"VAR_15 = []\n",
"self.debugger.dut.send_files(VAR_11)\n",
"VAR_15.append(self.options.directory + '/' + self.options.aux_application)\n",
"if self.campaign_data['use_aux']:\n",
"if self.options.aux_files:\n",
"VAR_16.join()\n",
"self.debugger.dut.command()\n",
"for file_ in self.options.aux_files:\n",
"os.makedirs('campaign-data/' + str(self.campaign_data['id']) + '/aux-files')\n",
"VAR_16 = Thread(target=self.debugger.aux.command)\n",
"if self.campaign_data['use_aux']:\n",
"VAR_15.append(self.options.directory + '/' + file_)\n",
"for item in VAR_15:\n",
"VAR_16.start()\n",
"VAR_16.join()\n",
"self.debugger.time_application()\n",
"copy(item, 'campaign-data/' + str(self.campaign_data['id']) + '/aux-files/')\n",
"VAR_16 = Thread(target=self.debugger.aux.send_files, args=(aux_files,))\n",
"if self.campaign_data['output_file']:\n",
"VAR_16.start()\n",
"if self.campaign_data['use_aux_output']:\n",
"if self.campaign_data['use_simics']:\n",
"self.debugger.aux.get_file(self.campaign_data['output_file'], \n 'campaign-data/' + str(self.campaign_data['id']) + '/gold_' + self.\n campaign_data['output_file'])\n",
"self.debugger.dut.get_file(self.campaign_data['output_file'], \n 'campaign-data/' + str(self.campaign_data['id']) + '/gold_' + self.\n campaign_data['output_file'])\n",
"self.debugger.close()\n",
"db.update_dict('campaign', self.campaign_data)\n",
"self.close()\n"
] | [
"def setup_campaign(self):...\n",
"files = []\n",
"files.append(self.options.directory + '/' + self.options.application)\n",
"if self.options.files:\n",
"for file_ in self.options.files:\n",
"os.makedirs('campaign-data/' + str(self.campaign_data['id']) + '/dut-files')\n",
"files.append(self.options.directory + '/' + file_)\n",
"for item in files:\n",
"copy(item, 'campaign-data/' + str(self.campaign_data['id']) + '/dut-files/')\n",
"if self.campaign_data['use_aux']:\n",
"aux_files = []\n",
"self.debugger.dut.send_files(files)\n",
"aux_files.append(self.options.directory + '/' + self.options.aux_application)\n",
"if self.campaign_data['use_aux']:\n",
"if self.options.aux_files:\n",
"aux_process.join()\n",
"self.debugger.dut.command()\n",
"for file_ in self.options.aux_files:\n",
"os.makedirs('campaign-data/' + str(self.campaign_data['id']) + '/aux-files')\n",
"aux_process = Thread(target=self.debugger.aux.command)\n",
"if self.campaign_data['use_aux']:\n",
"aux_files.append(self.options.directory + '/' + file_)\n",
"for item in aux_files:\n",
"aux_process.start()\n",
"aux_process.join()\n",
"self.debugger.time_application()\n",
"copy(item, 'campaign-data/' + str(self.campaign_data['id']) + '/aux-files/')\n",
"aux_process = Thread(target=self.debugger.aux.send_files, args=(aux_files,))\n",
"if self.campaign_data['output_file']:\n",
"aux_process.start()\n",
"if self.campaign_data['use_aux_output']:\n",
"if self.campaign_data['use_simics']:\n",
"self.debugger.aux.get_file(self.campaign_data['output_file'], \n 'campaign-data/' + str(self.campaign_data['id']) + '/gold_' + self.\n campaign_data['output_file'])\n",
"self.debugger.dut.get_file(self.campaign_data['output_file'], \n 'campaign-data/' + str(self.campaign_data['id']) + '/gold_' + self.\n campaign_data['output_file'])\n",
"self.debugger.close()\n",
"db.update_dict('campaign', self.campaign_data)\n",
"self.close()\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'",
"Expr'",
"Condition",
"For",
"Expr'",
"Expr'",
"For",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Condition",
"Expr'",
"Expr'",
"For",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"For",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"import PathPlannerModule as PPM\n",
"import math\n",
"VAR_0 = PPM.PathPlanner()\n",
"VAR_1 = 0, 0\n",
"VAR_2 = 10000\n",
"for angle in range(0, 360):\n",
"VAR_3 = angle * math.pi / 180\n",
"VAR_4 = int(round(math.sin(VAR_3) * VAR_2)), int(round(math.cos(VAR_3) * VAR_2)\n )\n",
"print('end = ' + str(VAR_4))\n",
"VAR_0.Raycast(VAR_1, VAR_4)\n",
"print('')\n"
] | [
"import PathPlannerModule as PPM\n",
"import math\n",
"pathPlanner = PPM.PathPlanner()\n",
"origin = 0, 0\n",
"r = 10000\n",
"for angle in range(0, 360):\n",
"ang = angle * math.pi / 180\n",
"end = int(round(math.sin(ang) * r)), int(round(math.cos(ang) * r))\n",
"print('end = ' + str(end))\n",
"pathPlanner.Raycast(origin, end)\n",
"print('')\n"
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
"Import'",
"Import'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_1(self, VAR_2, VAR_6, VAR_7, VAR_4, VAR_3):...\n",
"if VAR_7:\n",
"VAR_7 = float(VAR_7)\n",
"VAR_7 = None\n",
"setattr(VAR_2, VAR_6, VAR_7)\n"
] | [
"def parse_input(self, report, name, value, request, attribute):...\n",
"if value:\n",
"value = float(value)\n",
"value = None\n",
"setattr(report, name, value)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_6(self):...\n",
"return self.connection_pool.closeCachedConnections()\n"
] | [
"def close_connections(self):...\n",
"return self.connection_pool.closeCachedConnections()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_0(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_18 = pq.backends.ClassicalSimulator(**self.filter_kwargs_for_backend(\n self.kwargs))\n",
"self.eng = pq.MainEngine(VAR_18)\n",
"super().reset()\n"
] | [
"def reset(self):...\n",
"\"\"\"docstring\"\"\"\n",
"backend = pq.backends.ClassicalSimulator(**self.filter_kwargs_for_backend(\n self.kwargs))\n",
"self.eng = pq.MainEngine(backend)\n",
"super().reset()\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_24(VAR_25, VAR_23, *VAR_24):...\n",
"if VAR_23 == 'on_after_task':\n",
"VAR_50, VAR_51, VAR_5, VAR_52 = VAR_24\n",
"self.assertEqual(False, VAR_50)\n",
"self.assertEqual(True, VAR_51)\n",
"self.assertEqual({'pool': 'default'}, VAR_5)\n",
"self.assertEqual(VAR_22, VAR_52)\n"
] | [
"def call_hook(_botobj, name, *args):...\n",
"if name == 'on_after_task':\n",
"failure, internal_failure, dimensions, summary = args\n",
"self.assertEqual(False, failure)\n",
"self.assertEqual(True, internal_failure)\n",
"self.assertEqual({'pool': 'default'}, dimensions)\n",
"self.assertEqual(result, summary)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_33(self):...\n",
"def FUNC_39(VAR_101):...\n",
"VAR_101.norun = True\n",
"return VAR_101\n"
] | [
"def norun(self):...\n",
"def decorate(ruleinfo):...\n",
"ruleinfo.norun = True\n",
"return ruleinfo\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"@VAR_0.route('/<id>/reviews', methods=['GET'])...\n",
"VAR_8 = FUNC_2()\n",
"VAR_16 = ProductsRepository.get_product_reviews(VAR_5, VAR_8)\n",
"VAR_17 = ProductsRepository.get_total_product_reviews(VAR_5)\n",
"VAR_9 = ceil(VAR_17 / VAR_8['perPage'])\n",
"return jsonify(VAR_16=product_reviews, VAR_17=total_product_reviews, VAR_9=\n total_pages)\n"
] | [
"@products.route('/<id>/reviews', methods=['GET'])...\n",
"filters = get_filters()\n",
"product_reviews = ProductsRepository.get_product_reviews(id, filters)\n",
"total_product_reviews = ProductsRepository.get_total_product_reviews(id)\n",
"total_pages = ceil(total_product_reviews / filters['perPage'])\n",
"return jsonify(product_reviews=product_reviews, total_product_reviews=\n total_product_reviews, total_pages=total_pages)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def __eq__(self, VAR_1):...\n",
"if not isinstance(VAR_1, CLASS_0):\n",
"return False\n",
"return self._uuid == VAR_1._uuid\n"
] | [
"def __eq__(self, other):...\n",
"if not isinstance(other, Host):\n",
"return False\n",
"return self._uuid == other._uuid\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_4(self):...\n",
"self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters=[{'name': ['like', 'J%']}]))\n"
] | [
"def test_filters_2(self):...\n",
"self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters=[{'name': ['like', 'J%']}]))\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_4(self, VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_7 = get_random_string(import_from_settings('OIDC_STATE_SIZE', 32))\n",
"VAR_8 = import_from_settings('OIDC_REDIRECT_FIELD_NAME', 'next')\n",
"VAR_9 = {'response_type': 'code', 'scope': 'openid', 'client_id': self.\n OIDC_RP_CLIENT_ID, 'redirect_uri': absolutify(VAR_1, reverse(\n 'oidc_authentication_callback')), 'state': VAR_7}\n",
"if import_from_settings('OIDC_USE_NONCE', True):\n",
"VAR_6 = get_random_string(import_from_settings('OIDC_NONCE_SIZE', 32))\n",
"VAR_1.session['oidc_state'] = VAR_7\n",
"VAR_9.update({'nonce': VAR_6})\n",
"VAR_1.session['oidc_login_next'] = VAR_1.GET.get(VAR_8)\n",
"VAR_1.session['oidc_nonce'] = VAR_6\n",
"VAR_10 = urlencode(VAR_9)\n",
"VAR_11 = '{url}?{query}'.format(url=self.OIDC_OP_AUTH_ENDPOINT, VAR_10=query)\n",
"return HttpResponseRedirect(VAR_11)\n"
] | [
"def get(self, request):...\n",
"\"\"\"docstring\"\"\"\n",
"state = get_random_string(import_from_settings('OIDC_STATE_SIZE', 32))\n",
"redirect_field_name = import_from_settings('OIDC_REDIRECT_FIELD_NAME', 'next')\n",
"params = {'response_type': 'code', 'scope': 'openid', 'client_id': self.\n OIDC_RP_CLIENT_ID, 'redirect_uri': absolutify(request, reverse(\n 'oidc_authentication_callback')), 'state': state}\n",
"if import_from_settings('OIDC_USE_NONCE', True):\n",
"nonce = get_random_string(import_from_settings('OIDC_NONCE_SIZE', 32))\n",
"request.session['oidc_state'] = state\n",
"params.update({'nonce': nonce})\n",
"request.session['oidc_login_next'] = request.GET.get(redirect_field_name)\n",
"request.session['oidc_nonce'] = nonce\n",
"query = urlencode(params)\n",
"redirect_url = '{url}?{query}'.format(url=self.OIDC_OP_AUTH_ENDPOINT, query\n =query)\n",
"return HttpResponseRedirect(redirect_url)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
6,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"from collections import namedtuple\n",
"from logging import getLogger\n",
"from sqlalchemy import exc\n",
"from .models import db, REQUIRED_MISC_SIGNATURES\n",
"from .packet import get_number_required, get_misc_signatures\n",
"VAR_0 = getLogger(__name__)\n",
"def FUNC_0(VAR_1, VAR_2=False, VAR_3=False):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_4 = namedtuple('spacket', ['rit_username', 'name', 'did_sign',\n 'total_signatures', 'required_signatures'])\n",
"VAR_5 = []\n",
"VAR_6 = get_number_required()\n",
"if VAR_2 and VAR_3:\n",
"VAR_6 -= 1\n",
"VAR_7 = FUNC_1(VAR_1, VAR_2, VAR_3)\n",
"VAR_8 = get_misc_signatures()\n",
"for pkt in FUNC_2():\n",
"VAR_0.error(e)\n",
"return VAR_5\n",
"VAR_9 = VAR_7.get(pkt.username)\n",
"VAR_10 = VAR_8.get(pkt.username)\n",
"if VAR_9 is None:\n",
"VAR_9 = False\n",
"if VAR_10 is None:\n",
"VAR_10 = 0\n",
"if VAR_10 > REQUIRED_MISC_SIGNATURES:\n",
"VAR_10 = REQUIRED_MISC_SIGNATURES\n",
"VAR_5.append(VAR_4(pkt.username, pkt.name, VAR_9, pkt.received + VAR_10, VAR_6)\n )\n"
] | [
"from collections import namedtuple\n",
"from logging import getLogger\n",
"from sqlalchemy import exc\n",
"from .models import db, REQUIRED_MISC_SIGNATURES\n",
"from .packet import get_number_required, get_misc_signatures\n",
"LOGGER = getLogger(__name__)\n",
"def current_packets(member, intro=False, onfloor=False):...\n",
"\"\"\"docstring\"\"\"\n",
"SPacket = namedtuple('spacket', ['rit_username', 'name', 'did_sign',\n 'total_signatures', 'required_signatures'])\n",
"packets = []\n",
"required = get_number_required()\n",
"if intro and onfloor:\n",
"required -= 1\n",
"signed_packets = get_signed_packets(member, intro, onfloor)\n",
"misc_signatures = get_misc_signatures()\n",
"for pkt in query_packets_with_signed():\n",
"LOGGER.error(e)\n",
"return packets\n",
"signed = signed_packets.get(pkt.username)\n",
"misc = misc_signatures.get(pkt.username)\n",
"if signed is None:\n",
"signed = False\n",
"if misc is None:\n",
"misc = 0\n",
"if misc > REQUIRED_MISC_SIGNATURES:\n",
"misc = REQUIRED_MISC_SIGNATURES\n",
"packets.append(SPacket(pkt.username, pkt.name, signed, pkt.received + misc,\n required))\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
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"AugAssign'",
"Assign'",
"Assign'",
"For",
"Expr'",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Expr'"
] |
[
"def FUNC_3(VAR_3):...\n",
""
] | [
"def chkuser(x):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_7(self, VAR_4):...\n",
"self.wait_next()\n",
"self.log.total += 1\n",
"VAR_4.execute()\n",
"print('Unhandled exception while executing the request: %s' % exc, file=sys\n .stderr)\n",
"self.log.__dict__[VAR_4.outcome] += 1\n",
"return\n",
"self.log.total_time += VAR_4.duration\n",
"self.log.max_time = max(self.log.max_time, VAR_4.duration)\n",
"self.log.store_to_file(VAR_4)\n"
] | [
"def do_step(self, request):...\n",
"self.wait_next()\n",
"self.log.total += 1\n",
"request.execute()\n",
"print('Unhandled exception while executing the request: %s' % exc, file=sys\n .stderr)\n",
"self.log.__dict__[request.outcome] += 1\n",
"return\n",
"self.log.total_time += request.duration\n",
"self.log.max_time = max(self.log.max_time, request.duration)\n",
"self.log.store_to_file(request)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"AugAssign'",
"Expr'",
"Expr'",
"AugAssign'",
"Return'",
"AugAssign'",
"Assign'",
"Expr'"
] |
[
"def __enter__(self):...\n",
"return CLASS_0()\n"
] | [
"def __enter__(self):...\n",
"return DBase()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_4(self, VAR_6=0, VAR_7=False):...\n",
"def FUNC_8():...\n",
"VAR_17 = False\n",
"VAR_18 = 'campaign-data/' + str(self.campaign_data['id']) + '/results/' + str(\n self.result_data['id'])\n",
"os.makedirs(VAR_18)\n",
"VAR_19 = VAR_18 + '/' + self.campaign_data['output_file']\n",
"VAR_20 = 'campaign-data/' + str(self.campaign_data['id']\n ) + '/gold_' + self.campaign_data['output_file']\n",
"if self.campaign_data['use_aux_output']:\n",
"self.debugger.aux.get_file(self.campaign_data['output_file'], VAR_19)\n",
"self.debugger.dut.get_file(self.campaign_data['output_file'], VAR_19)\n",
"if not os.listdir(VAR_18):\n",
"os.rmdir(VAR_18)\n",
"VAR_28 = solution.read()\n",
"VAR_17 = True\n",
"VAR_29 = result.read()\n",
"if self.campaign_data['use_aux_output']:\n",
"self.result_data['data_diff'] = SequenceMatcher(None, VAR_28, VAR_29\n ).quick_ratio()\n",
"self.debugger.aux.command('rm ' + self.campaign_data['output_file'])\n",
"self.debugger.dut.command('rm ' + self.campaign_data['output_file'])\n",
"if self.result_data['data_diff'] == 1.0:\n",
"if VAR_17:\n",
"os.remove(VAR_19)\n",
"VAR_5 = ''\n",
"if not os.listdir(VAR_18):\n",
"VAR_4 = ''\n",
"os.rmdir(VAR_18)\n",
"if self.campaign_data['use_aux']:\n",
"VAR_22 = self.debugger.aux.read_until()\n",
"VAR_22 = ''\n",
"if self.campaign_data['kill_dut']:\n",
"VAR_21 = self.debugger.dut.read_until()\n",
"VAR_21 = ''\n",
"for line in VAR_21.split('\\n'):\n",
"self.debugger.dut.serial.write('\\x03')\n",
"self.debugger.dut.serial.write('\\x03')\n",
"VAR_5 = error.type\n",
"if 'drseus_detected_errors:' in line:\n",
"if self.campaign_data['use_aux']:\n",
"VAR_5 = error.type\n",
"VAR_4 = 'Execution error'\n",
"self.result_data['detected_errors'] = int(line.replace(\n 'drseus_detected_errors:', ''))\n",
"for line in VAR_22.split('\\n'):\n",
"if self.campaign_data['output_file'] and not VAR_5:\n",
"VAR_4 = 'AUX execution error'\n",
"if 'drseus_detected_errors:' in line:\n",
"if not VAR_5:\n",
"FUNC_8()\n",
"if error.type == DrSEUsError.scp_error:\n",
"if self.result_data['detected_errors'] is None:\n",
"if self.result_data['detected_errors']:\n",
"return VAR_5, VAR_4\n",
"VAR_5 = 'Error getting output file'\n",
"if error.type == DrSEUsError.missing_output:\n",
"self.result_data['detected_errors'] = 0\n",
"self.result_data['detected_errors'] += int(line.replace(\n 'drseus_detected_errors:', ''))\n",
"if self.result_data['data_diff'] is None or self.result_data['data_diff'\n",
"if self.result_data['data_diff'] is not None and self.result_data['data_diff'\n",
"VAR_4 = 'SCP error'\n",
"VAR_5 = 'Missing output file'\n",
"VAR_5 = error.type\n",
"VAR_5 = 'Detected data error'\n",
"if self.result_data['data_diff'] is not None and self.result_data['data_diff'\n",
"VAR_5 = 'Silent data error'\n",
"if VAR_7:\n",
"VAR_4 = 'SCP error'\n",
"VAR_4 = 'Post execution error'\n",
"VAR_4 = 'Data error'\n",
"VAR_5 = 'Corrected data error'\n",
"VAR_4 = 'Data error'\n",
"VAR_5 = 'Persistent faults'\n",
"if VAR_6:\n",
"VAR_4 = 'Data error'\n",
"VAR_4 = 'No error'\n",
"VAR_5 = 'Latent faults'\n",
"VAR_5 = 'Masked faults'\n",
"VAR_4 = 'No error'\n",
"VAR_4 = 'No error'\n"
] | [
"def __monitor_execution(self, latent_faults=0, persistent_faults=False):...\n",
"def check_output():...\n",
"missing_output = False\n",
"result_folder = 'campaign-data/' + str(self.campaign_data['id']\n ) + '/results/' + str(self.result_data['id'])\n",
"os.makedirs(result_folder)\n",
"output_location = result_folder + '/' + self.campaign_data['output_file']\n",
"gold_location = 'campaign-data/' + str(self.campaign_data['id']\n ) + '/gold_' + self.campaign_data['output_file']\n",
"if self.campaign_data['use_aux_output']:\n",
"self.debugger.aux.get_file(self.campaign_data['output_file'], output_location)\n",
"self.debugger.dut.get_file(self.campaign_data['output_file'], output_location)\n",
"if not os.listdir(result_folder):\n",
"os.rmdir(result_folder)\n",
"solutionContents = solution.read()\n",
"missing_output = True\n",
"resultContents = result.read()\n",
"if self.campaign_data['use_aux_output']:\n",
"self.result_data['data_diff'] = SequenceMatcher(None, solutionContents,\n resultContents).quick_ratio()\n",
"self.debugger.aux.command('rm ' + self.campaign_data['output_file'])\n",
"self.debugger.dut.command('rm ' + self.campaign_data['output_file'])\n",
"if self.result_data['data_diff'] == 1.0:\n",
"if missing_output:\n",
"os.remove(output_location)\n",
"outcome = ''\n",
"if not os.listdir(result_folder):\n",
"outcome_category = ''\n",
"os.rmdir(result_folder)\n",
"if self.campaign_data['use_aux']:\n",
"aux_buff = self.debugger.aux.read_until()\n",
"aux_buff = ''\n",
"if self.campaign_data['kill_dut']:\n",
"buff = self.debugger.dut.read_until()\n",
"buff = ''\n",
"for line in buff.split('\\n'):\n",
"self.debugger.dut.serial.write('\\x03')\n",
"self.debugger.dut.serial.write('\\x03')\n",
"outcome = error.type\n",
"if 'drseus_detected_errors:' in line:\n",
"if self.campaign_data['use_aux']:\n",
"outcome = error.type\n",
"outcome_category = 'Execution error'\n",
"self.result_data['detected_errors'] = int(line.replace(\n 'drseus_detected_errors:', ''))\n",
"for line in aux_buff.split('\\n'):\n",
"if self.campaign_data['output_file'] and not outcome:\n",
"outcome_category = 'AUX execution error'\n",
"if 'drseus_detected_errors:' in line:\n",
"if not outcome:\n",
"check_output()\n",
"if error.type == DrSEUsError.scp_error:\n",
"if self.result_data['detected_errors'] is None:\n",
"if self.result_data['detected_errors']:\n",
"return outcome, outcome_category\n",
"outcome = 'Error getting output file'\n",
"if error.type == DrSEUsError.missing_output:\n",
"self.result_data['detected_errors'] = 0\n",
"self.result_data['detected_errors'] += int(line.replace(\n 'drseus_detected_errors:', ''))\n",
"if self.result_data['data_diff'] is None or self.result_data['data_diff'\n",
"if self.result_data['data_diff'] is not None and self.result_data['data_diff'\n",
"outcome_category = 'SCP error'\n",
"outcome = 'Missing output file'\n",
"outcome = error.type\n",
"outcome = 'Detected data error'\n",
"if self.result_data['data_diff'] is not None and self.result_data['data_diff'\n",
"outcome = 'Silent data error'\n",
"if persistent_faults:\n",
"outcome_category = 'SCP error'\n",
"outcome_category = 'Post execution error'\n",
"outcome_category = 'Data error'\n",
"outcome = 'Corrected data error'\n",
"outcome_category = 'Data error'\n",
"outcome = 'Persistent faults'\n",
"if latent_faults:\n",
"outcome_category = 'Data error'\n",
"outcome_category = 'No error'\n",
"outcome = 'Latent faults'\n",
"outcome = 'Masked faults'\n",
"outcome_category = 'No error'\n",
"outcome_category = 'No error'\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
] | [
"FunctionDef'",
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"For",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Condition",
"Condition",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"AugAssign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_15 = set()\n",
"for VAR_28, VAR_27 in zip(self.output, self.rule.output):\n",
"if VAR_28 in self.dynamic_output:\n",
"VAR_16 = defaultdict(list)\n",
"for VAR_28, w in self.expand_dynamic(VAR_27, VAR_13=self.wildcards, VAR_14=\n",
"for combination in VAR_15:\n",
"VAR_15.add(tuple(w.items()))\n",
"for name, value in combination:\n",
"return VAR_16\n",
"VAR_16[name].append(value)\n"
] | [
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"combinations = set()\n",
"for f, f_ in zip(self.output, self.rule.output):\n",
"if f in self.dynamic_output:\n",
"wildcards = defaultdict(list)\n",
"for f, w in self.expand_dynamic(f_, restriction=self.wildcards, omit_value=\n",
"for combination in combinations:\n",
"combinations.add(tuple(w.items()))\n",
"for name, value in combination:\n",
"return wildcards\n",
"wildcards[name].append(value)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"For",
"Condition",
"Assign'",
"For",
"For",
"Expr'",
"For",
"Return'",
"Expr'"
] |
[
"from argparse import ArgumentParser\n",
"from ply import lex, yacc\n",
"import locale\n",
"import traceback\n",
"import sys\n",
"import git\n",
"import re\n",
"import os\n",
"def __init__(self, VAR_3, VAR_4):...\n",
"self.tok = VAR_3\n",
"self.txt = VAR_4\n",
"def __init__(self, VAR_5, VAR_4):...\n",
"self.el = VAR_5\n",
"self.txt = VAR_4\n",
"def __init__(self):...\n",
"self.license_files = 0\n",
"self.exception_files = 0\n",
"self.licenses = []\n",
"self.exceptions = {}\n",
"def FUNC_0(VAR_0):...\n",
"VAR_6 = ['preferred', 'other', 'exceptions']\n",
"VAR_7 = VAR_0.head.commit.tree['LICENSES']\n",
"VAR_8 = CLASS_2()\n",
"for d in VAR_6:\n",
"for VAR_5 in VAR_7[d].traverse():\n",
"return VAR_8\n",
"if not os.path.isfile(VAR_5.path):\n",
"VAR_23 = None\n",
"for l in open(VAR_5.path).readlines():\n",
"if l.startswith('Valid-License-Identifier:'):\n",
"VAR_26 = l.split(':')[1].strip().upper()\n",
"if l.startswith('SPDX-Exception-Identifier:'):\n",
"if VAR_26 in VAR_8.licenses:\n",
"VAR_23 = l.split(':')[1].strip().upper()\n",
"if l.startswith('SPDX-Licenses:'):\n",
"VAR_8.licenses.append(VAR_26)\n",
"VAR_8.exceptions[VAR_23] = []\n",
"for lic in l.split(':')[1].upper().strip().replace(' ', '').replace('\\t', ''\n",
"if l.startswith('License-Text:'):\n",
"if not lic in VAR_8.licenses:\n",
"if VAR_23:\n",
"VAR_8.exceptions[VAR_23].append(lic)\n",
"if not len(VAR_8.exceptions[VAR_23]):\n",
"VAR_8.license_files += 1\n",
"VAR_8.exception_files += 1\n"
] | [
"from argparse import ArgumentParser\n",
"from ply import lex, yacc\n",
"import locale\n",
"import traceback\n",
"import sys\n",
"import git\n",
"import re\n",
"import os\n",
"def __init__(self, tok, txt):...\n",
"self.tok = tok\n",
"self.txt = txt\n",
"def __init__(self, el, txt):...\n",
"self.el = el\n",
"self.txt = txt\n",
"def __init__(self):...\n",
"self.license_files = 0\n",
"self.exception_files = 0\n",
"self.licenses = []\n",
"self.exceptions = {}\n",
"def read_spdxdata(repo):...\n",
"license_dirs = ['preferred', 'other', 'exceptions']\n",
"lictree = repo.head.commit.tree['LICENSES']\n",
"spdx = SPDXdata()\n",
"for d in license_dirs:\n",
"for el in lictree[d].traverse():\n",
"return spdx\n",
"if not os.path.isfile(el.path):\n",
"exception = None\n",
"for l in open(el.path).readlines():\n",
"if l.startswith('Valid-License-Identifier:'):\n",
"lid = l.split(':')[1].strip().upper()\n",
"if l.startswith('SPDX-Exception-Identifier:'):\n",
"if lid in spdx.licenses:\n",
"exception = l.split(':')[1].strip().upper()\n",
"if l.startswith('SPDX-Licenses:'):\n",
"spdx.licenses.append(lid)\n",
"spdx.exceptions[exception] = []\n",
"for lic in l.split(':')[1].upper().strip().replace(' ', '').replace('\\t', ''\n",
"if l.startswith('License-Text:'):\n",
"if not lic in spdx.licenses:\n",
"if exception:\n",
"spdx.exceptions[exception].append(lic)\n",
"if not len(spdx.exceptions[exception]):\n",
"spdx.license_files += 1\n",
"spdx.exception_files += 1\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"FunctionDef'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"For",
"For",
"Return'",
"Condition",
"Assign'",
"For",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"For",
"Condition",
"Condition",
"Condition",
"Expr'",
"Condition",
"AugAssign'",
"AugAssign'"
] |
[
"def FUNC_27(VAR_8):...\n",
"return '{}#{}'.format(VAR_7, VAR_8)\n"
] | [
"def u(string):...\n",
"return '{}#{}'.format(uuid_str, string)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_31(VAR_62):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_84 = 0\n",
"while VAR_62[VAR_84].isdigit():\n",
"VAR_84 += 1\n",
"if VAR_84 > 0:\n",
"return int(VAR_62[:VAR_84])\n",
"return 0\n"
] | [
"def _get_value_kw(kw):...\n",
"\"\"\"docstring\"\"\"\n",
"i = 0\n",
"while kw[i].isdigit():\n",
"i += 1\n",
"if i > 0:\n",
"return int(kw[:i])\n",
"return 0\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"AugAssign'",
"Condition",
"Return'",
"Return'"
] |
[
"@rest_utils.ajax(data_required=True)...\n",
"\"\"\"docstring\"\"\"\n",
"if api.base.is_service_enabled(VAR_1, 'compute'):\n",
"VAR_35 = quotas.get_disabled_quotas(VAR_1)\n",
"VAR_46 = [quota for quota in quotas.NOVA_QUOTA_FIELDS if quota not in VAR_35]\n",
"VAR_47 = {key: VAR_1.DATA.get(key, None) for key in VAR_46}\n",
"VAR_48 = {key: value for key, value in VAR_47.items() if value is not None}\n",
"api.nova.default_quota_update(VAR_1, **nova_data)\n"
] | [
"@rest_utils.ajax(data_required=True)...\n",
"\"\"\"docstring\"\"\"\n",
"if api.base.is_service_enabled(request, 'compute'):\n",
"disabled_quotas = quotas.get_disabled_quotas(request)\n",
"filtered_quotas = [quota for quota in quotas.NOVA_QUOTA_FIELDS if quota not in\n disabled_quotas]\n",
"request_data = {key: request.DATA.get(key, None) for key in filtered_quotas}\n",
"nova_data = {key: value for key, value in request_data.items() if value is not\n None}\n",
"api.nova.default_quota_update(request, **nova_data)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"@functools.wraps(VAR_0)...\n",
"if not self.request.headers.get('X-XSRF-Token-Request'):\n",
"return VAR_0(self, *VAR_5, **kwargs)\n"
] | [
"@functools.wraps(f)...\n",
"if not self.request.headers.get('X-XSRF-Token-Request'):\n",
"return f(self, *args, **kwargs)\n"
] | [
0,
0,
0
] | [
"Condition",
"Condition",
"Return'"
] |
[
"def FUNC_0(self, VAR_2, VAR_3, VAR_4, VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = []\n",
"VAR_7 = self.pool.get('ir.model.data')\n",
"VAR_8 = self.pool.get('res.users').browse(VAR_2, VAR_3, VAR_3).company_id.id\n",
"VAR_9 = self.pool.get('account.bank.statement')\n",
"VAR_10 = self.pool.get('ir.sequence')\n",
"VAR_11 = self.pool.get('account.journal')\n",
"VAR_2.execute(\n 'select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id'\n % VAR_3)\n",
"VAR_12 = map(lambda x1: x1[0], VAR_2.fetchall())\n",
"VAR_2.execute('string' % ','.join(map(lambda x: \"'\" + str(x) + \"'\", VAR_12)))\n",
"VAR_13 = map(lambda x1: x1[0], VAR_2.fetchall())\n",
"for journal in VAR_11.browse(VAR_2, VAR_3, VAR_13):\n",
"VAR_4 = VAR_9.search(VAR_2, VAR_3, [('state', '!=', 'confirm'), ('user_id',\n '=', VAR_3), ('journal_id', '=', journal.id)])\n",
"VAR_14 = self.pool.get('ir.model.data')\n",
"if len(VAR_4):\n",
"VAR_15 = VAR_14._get_id(VAR_2, VAR_3, 'account', 'view_bank_statement_tree')\n",
"VAR_17 = ''\n",
"VAR_16 = VAR_14._get_id(VAR_2, VAR_3, 'account', 'view_bank_statement_form2')\n",
"if journal.sequence_id:\n",
"if VAR_15:\n",
"VAR_17 = VAR_10.get_id(VAR_2, VAR_3, journal.sequence_id.id)\n",
"VAR_17 = VAR_10.get(VAR_2, VAR_3, 'account.bank.statement')\n",
"VAR_15 = VAR_14.browse(VAR_2, VAR_3, VAR_15, VAR_5=context).res_id\n",
"if VAR_16:\n",
"VAR_18 = VAR_9.create(VAR_2, VAR_3, {'journal_id': journal.id, 'company_id':\n VAR_8, 'user_id': VAR_3, 'state': 'open', 'name': VAR_17,\n 'starting_details_ids': VAR_9._get_cash_close_box_lines(VAR_2, VAR_3, [])})\n",
"VAR_16 = VAR_14.browse(VAR_2, VAR_3, VAR_16, VAR_5=context).res_id\n",
"return {'domain': \"[('state','=','open')]\", 'name': 'Open Statement',\n 'view_type': 'form', 'view_mode': 'tree,form', 'res_model':\n 'account.bank.statement', 'views': [(VAR_15, 'tree'), (VAR_16, 'form')],\n 'type': 'ir.actions.act_window'}\n",
"VAR_9.button_open(VAR_2, VAR_3, [VAR_18], VAR_5)\n"
] | [
"def open_statement(self, cr, uid, ids, context):...\n",
"\"\"\"docstring\"\"\"\n",
"list_statement = []\n",
"mod_obj = self.pool.get('ir.model.data')\n",
"company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id\n",
"statement_obj = self.pool.get('account.bank.statement')\n",
"sequence_obj = self.pool.get('ir.sequence')\n",
"journal_obj = self.pool.get('account.journal')\n",
"cr.execute(\n 'select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id'\n % uid)\n",
"j_ids = map(lambda x1: x1[0], cr.fetchall())\n",
"cr.execute(\n \"\"\" select id from account_journal\n where auto_cash='True' and type='cash'\n and id in (%s)\"\"\"\n % ','.join(map(lambda x: \"'\" + str(x) + \"'\", j_ids)))\n",
"journal_ids = map(lambda x1: x1[0], cr.fetchall())\n",
"for journal in journal_obj.browse(cr, uid, journal_ids):\n",
"ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id',\n '=', uid), ('journal_id', '=', journal.id)])\n",
"data_obj = self.pool.get('ir.model.data')\n",
"if len(ids):\n",
"id2 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')\n",
"number = ''\n",
"id3 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')\n",
"if journal.sequence_id:\n",
"if id2:\n",
"number = sequence_obj.get_id(cr, uid, journal.sequence_id.id)\n",
"number = sequence_obj.get(cr, uid, 'account.bank.statement')\n",
"id2 = data_obj.browse(cr, uid, id2, context=context).res_id\n",
"if id3:\n",
"statement_id = statement_obj.create(cr, uid, {'journal_id': journal.id,\n 'company_id': company_id, 'user_id': uid, 'state': 'open', 'name':\n number, 'starting_details_ids': statement_obj._get_cash_close_box_lines\n (cr, uid, [])})\n",
"id3 = data_obj.browse(cr, uid, id3, context=context).res_id\n",
"return {'domain': \"[('state','=','open')]\", 'name': 'Open Statement',\n 'view_type': 'form', 'view_mode': 'tree,form', 'res_model':\n 'account.bank.statement', 'views': [(id2, 'tree'), (id3, 'form')],\n 'type': 'ir.actions.act_window'}\n",
"statement_obj.button_open(cr, uid, [statement_id], context)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
4,
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'",
"Expr'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Expr'"
] |
[
"def __init__(self, VAR_1):...\n",
"self.dim_x, self.dim_y = self.calc_dim(VAR_1)\n",
"self.g_count, self.v_count, self.z_count = self.calc_monster_count(VAR_1)\n",
"self.board = []\n",
"self._init_board()\n",
"self.generate_board(VAR_1)\n",
"self.north_count, self.east_count, self.south_count, self.west_count = (self\n .calc_board_count(VAR_1))\n"
] | [
"def __init__(self, board_str):...\n",
"self.dim_x, self.dim_y = self.calc_dim(board_str)\n",
"self.g_count, self.v_count, self.z_count = self.calc_monster_count(board_str)\n",
"self.board = []\n",
"self._init_board()\n",
"self.generate_board(board_str)\n",
"self.north_count, self.east_count, self.south_count, self.west_count = (self\n .calc_board_count(board_str))\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'"
] |
[
"def FUNC_4(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_21 = self.request.get('url').strip()\n",
"VAR_22 = buildbot.ParseBuildUrl(VAR_21)\n",
"if not VAR_22:\n",
"return {'data': {'success': False}}\n",
"VAR_5, VAR_6, VAR_7 = VAR_22\n",
"VAR_3 = int(self.request.get('status'))\n",
"VAR_8 = self.request.get('cl_info')\n",
"VAR_9 = users.get_current_user().email().split('@')[0]\n",
"VAR_18 = FUNC_3(VAR_5, VAR_6, VAR_7, VAR_8, VAR_3, VAR_9)\n",
"return {'data': {'success': VAR_18}}\n"
] | [
"def HandleGet(self):...\n",
"\"\"\"docstring\"\"\"\n",
"url = self.request.get('url').strip()\n",
"build_info = buildbot.ParseBuildUrl(url)\n",
"if not build_info:\n",
"return {'data': {'success': False}}\n",
"master_name, builder_name, build_number = build_info\n",
"cl_status = int(self.request.get('status'))\n",
"cl_info = self.request.get('cl_info')\n",
"user_name = users.get_current_user().email().split('@')[0]\n",
"success = _UpdateSuspectedCLAndAnalysis(master_name, builder_name,\n build_number, cl_info, cl_status, user_name)\n",
"return {'data': {'success': success}}\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_0(VAR_8, VAR_9, VAR_10, VAR_11=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_12 = VAR_8.components.netatmo\n",
"VAR_13 = CLASS_1(VAR_12.NETATMO_AUTH, VAR_9.get(VAR_2, None))\n",
"VAR_14 = []\n",
"import pyatmo\n",
"if VAR_1 in VAR_9:\n",
"return None\n",
"VAR_10(VAR_14, True)\n",
"for VAR_16, monitored_conditions in VAR_9[VAR_1].items():\n",
"for VAR_16 in VAR_13.get_module_names():\n",
"if VAR_16 not in VAR_13.get_module_names():\n",
"for variable in VAR_13.station_data.monitoredConditions(VAR_16):\n",
"VAR_0.error('Module name: \"%s\" not found', VAR_16)\n",
"for variable in monitored_conditions:\n",
"if variable in VAR_5.keys():\n",
"VAR_14.append(CLASS_0(VAR_13, VAR_16, variable))\n",
"VAR_14.append(CLASS_0(VAR_13, VAR_16, variable))\n",
"VAR_0.warning('Ignoring unknown var %s for mod %s', variable, VAR_16)\n"
] | [
"def setup_platform(hass, config, add_devices, discovery_info=None):...\n",
"\"\"\"docstring\"\"\"\n",
"netatmo = hass.components.netatmo\n",
"data = NetAtmoData(netatmo.NETATMO_AUTH, config.get(CONF_STATION, None))\n",
"dev = []\n",
"import pyatmo\n",
"if CONF_MODULES in config:\n",
"return None\n",
"add_devices(dev, True)\n",
"for module_name, monitored_conditions in config[CONF_MODULES].items():\n",
"for module_name in data.get_module_names():\n",
"if module_name not in data.get_module_names():\n",
"for variable in data.station_data.monitoredConditions(module_name):\n",
"_LOGGER.error('Module name: \"%s\" not found', module_name)\n",
"for variable in monitored_conditions:\n",
"if variable in SENSOR_TYPES.keys():\n",
"dev.append(NetAtmoSensor(data, module_name, variable))\n",
"dev.append(NetAtmoSensor(data, module_name, variable))\n",
"_LOGGER.warning('Ignoring unknown var %s for mod %s', variable, module_name)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Import'",
"Condition",
"Return'",
"Expr'",
"For",
"For",
"Condition",
"For",
"Expr'",
"For",
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@classmethod...\n",
"return [lambda _request: VAR_22]\n"
] | [
"@classmethod...\n",
"return [lambda _request: peer_ident]\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_2(VAR_0):...\n",
"VAR_3 = FUNC_0()\n",
"VAR_4 = VAR_3.cursor()\n",
"VAR_4.execute('TRUNCATE ' + VAR_0 + ';')\n",
"VAR_3.commit()\n",
"VAR_4.close()\n",
"VAR_3.close()\n"
] | [
"def truncate(table):...\n",
"co = connect()\n",
"cu = co.cursor()\n",
"cu.execute('TRUNCATE ' + table + ';')\n",
"co.commit()\n",
"cu.close()\n",
"co.close()\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_4(VAR_9):...\n",
"if VAR_9['exception']['TYPE'] == UnknownExtraConf.__name__:\n"
] | [
"def _RaiseExceptionForData(data):...\n",
"if data['exception']['TYPE'] == UnknownExtraConf.__name__:\n"
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_9(self):...\n",
"VAR_25 = self.conn.tpl_mounts.render(this=self)\n",
"self.reply(VAR_25.encode('utf-8'))\n"
] | [
"def tx_mounts(self):...\n",
"html = self.conn.tpl_mounts.render(this=self)\n",
"self.reply(html.encode('utf-8'))\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"@api.multi...\n",
"\"\"\"docstring\"\"\"\n",
"self.ensure_one()\n",
"for VAR_12 in self:\n",
"if not VAR_16 and VAR_14 == 'BULONFER':\n",
"VAR_12.state = 'obsolete'\n",
"VAR_12.state = 'sellable'\n",
"return\n",
"if not VAR_18:\n",
"VAR_18 = datetime.today().strftime('%Y-%m-%d')\n",
"self.insert_historic_cost(VAR_14, VAR_15, VAR_16, VAR_17, VAR_18)\n",
"VAR_20 = self.oldest_quant(VAR_12)\n",
"self.fix_quant_data(VAR_20, VAR_12, VAR_16)\n",
"VAR_12.bulonfer_cost = VAR_16\n",
"if VAR_14 == 'BULONFER':\n",
"VAR_36 = self.env['product_autoload.item']\n",
"VAR_12.list_price = VAR_19\n",
"VAR_37 = VAR_36.search([('code', '=', VAR_12.item_code)])\n",
"VAR_12.margin = 100 * (VAR_19 / VAR_16 - 1) if VAR_16 != 0 else 10000000000.0\n",
"VAR_12.margin = 100 * VAR_37.margin\n",
"VAR_12.list_price = VAR_16 * (VAR_37.margin + 1)\n"
] | [
"@api.multi...\n",
"\"\"\"docstring\"\"\"\n",
"self.ensure_one()\n",
"for prod in self:\n",
"if not cost and vendor_ref == 'BULONFER':\n",
"prod.state = 'obsolete'\n",
"prod.state = 'sellable'\n",
"return\n",
"if not date:\n",
"date = datetime.today().strftime('%Y-%m-%d')\n",
"self.insert_historic_cost(vendor_ref, min_qty, cost, vendors_code, date)\n",
"quant = self.oldest_quant(prod)\n",
"self.fix_quant_data(quant, prod, cost)\n",
"prod.bulonfer_cost = cost\n",
"if vendor_ref == 'BULONFER':\n",
"item_obj = self.env['product_autoload.item']\n",
"prod.list_price = price\n",
"item = item_obj.search([('code', '=', prod.item_code)])\n",
"prod.margin = 100 * (price / cost - 1) if cost != 0 else 10000000000.0\n",
"prod.margin = 100 * item.margin\n",
"prod.list_price = cost * (item.margin + 1)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Expr'",
"For",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_19(self):...\n",
"self._diag_interface.OnCursorMoved()\n"
] | [
"def OnCursorMoved(self):...\n",
"self._diag_interface.OnCursorMoved()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_1():...\n",
"VAR_13 = argparse.ArgumentParser(description='Stress tester for CMS')\n",
"VAR_13.add_argument('-c', '--contest-id', action='store', type=int,\n required=True, help='ID of the contest to test against')\n",
"VAR_13.add_argument('-n', '--actor-num', action='store', type=int, help=\n 'the number of actors to spawn')\n",
"VAR_13.add_argument('-s', '--sort-actors', action='store_true', help=\n 'sort usernames alphabetically before slicing them')\n",
"VAR_13.add_argument('-u', '--base-url', action='store', type=utf8_decoder,\n help='base URL for placing HTTP requests')\n",
"VAR_13.add_argument('-S', '--submissions-path', action='store', type=\n utf8_decoder, help='base path for submission to send')\n",
"VAR_13.add_argument('-p', '--prepare-path', action='store', type=\n utf8_decoder, help='file to put contest info to')\n",
"VAR_13.add_argument('-r', '--read-from', action='store', type=utf8_decoder,\n help='file to read contest info from')\n",
"VAR_13.add_argument('-t', '--time-coeff', action='store', type=float,\n default=10.0, help='average wait between actions')\n",
"VAR_13.add_argument('-o', '--only-submit', action='store_true', help=\n 'whether the actor only submits solutions')\n",
"VAR_14 = VAR_13.parse_args()\n",
"if VAR_14.prepare_path is not None:\n",
"VAR_12, VAR_8 = FUNC_0(VAR_14.contest_id)\n",
"assert VAR_14.time_coeff > 0.0\n",
"VAR_27 = dict()\n",
"assert not (VAR_14.only_submit and VAR_14.submissions_path == '')\n",
"VAR_27['users'] = VAR_12\n",
"VAR_12 = []\n",
"VAR_27['tasks'] = VAR_8\n",
"VAR_8 = []\n",
"file_.write('%s' % VAR_27)\n",
"if VAR_14.read_from is None:\n",
"return\n",
"VAR_12, VAR_8 = FUNC_0(VAR_14.contest_id)\n",
"VAR_27 = ast.literal_eval(file_.read())\n",
"if VAR_14.actor_num is not None:\n",
"VAR_12 = VAR_27['users']\n",
"VAR_28 = VAR_12.items()\n",
"if VAR_14.base_url is not None:\n",
"VAR_8 = VAR_27['tasks']\n",
"if VAR_14.sort_actors:\n",
"VAR_10 = VAR_14.base_url\n",
"VAR_10 = 'http://%s:%d/' % (get_service_address(ServiceCoord(\n 'ContestWebServer', 0))[0], config.contest_listen_port[0])\n",
"VAR_28.sort()\n",
"random.shuffle(VAR_28)\n",
"VAR_7 = VAR_1\n",
"VAR_12 = dict(VAR_28[:VAR_14.actor_num])\n",
"VAR_7['time_coeff'] = VAR_14.time_coeff\n",
"VAR_15 = CLASS_3\n",
"if VAR_14.only_submit:\n",
"VAR_15 = CLASS_4\n",
"VAR_16 = [VAR_15(VAR_5, data['password'], VAR_7, VAR_8, VAR_9=RequestLog(\n log_dir=os.path.join('./test_logs', username)), VAR_10=base_url, VAR_11\n =args.submissions_path) for VAR_5, data in VAR_12.iteritems()]\n",
"for actor in VAR_16:\n",
"actor.start()\n",
"while True:\n",
"print('Taking down actors', file=sys.stderr)\n",
"VAR_17 = False\n",
"time.sleep(1)\n",
"for actor in VAR_16:\n",
"while not VAR_17:\n",
"actor.die = True\n",
"for actor in VAR_16:\n",
"print('Test finished', file=sys.stderr)\n",
"actor.join()\n",
"VAR_18 = CLASS_0()\n",
"for actor in VAR_16:\n",
"VAR_18.merge(actor.log)\n",
"VAR_18.print_stats()\n"
] | [
"def main():...\n",
"parser = argparse.ArgumentParser(description='Stress tester for CMS')\n",
"parser.add_argument('-c', '--contest-id', action='store', type=int,\n required=True, help='ID of the contest to test against')\n",
"parser.add_argument('-n', '--actor-num', action='store', type=int, help=\n 'the number of actors to spawn')\n",
"parser.add_argument('-s', '--sort-actors', action='store_true', help=\n 'sort usernames alphabetically before slicing them')\n",
"parser.add_argument('-u', '--base-url', action='store', type=utf8_decoder,\n help='base URL for placing HTTP requests')\n",
"parser.add_argument('-S', '--submissions-path', action='store', type=\n utf8_decoder, help='base path for submission to send')\n",
"parser.add_argument('-p', '--prepare-path', action='store', type=\n utf8_decoder, help='file to put contest info to')\n",
"parser.add_argument('-r', '--read-from', action='store', type=utf8_decoder,\n help='file to read contest info from')\n",
"parser.add_argument('-t', '--time-coeff', action='store', type=float,\n default=10.0, help='average wait between actions')\n",
"parser.add_argument('-o', '--only-submit', action='store_true', help=\n 'whether the actor only submits solutions')\n",
"args = parser.parse_args()\n",
"if args.prepare_path is not None:\n",
"users, tasks = harvest_contest_data(args.contest_id)\n",
"assert args.time_coeff > 0.0\n",
"contest_data = dict()\n",
"assert not (args.only_submit and args.submissions_path == '')\n",
"contest_data['users'] = users\n",
"users = []\n",
"contest_data['tasks'] = tasks\n",
"tasks = []\n",
"file_.write('%s' % contest_data)\n",
"if args.read_from is None:\n",
"return\n",
"users, tasks = harvest_contest_data(args.contest_id)\n",
"contest_data = ast.literal_eval(file_.read())\n",
"if args.actor_num is not None:\n",
"users = contest_data['users']\n",
"user_items = users.items()\n",
"if args.base_url is not None:\n",
"tasks = contest_data['tasks']\n",
"if args.sort_actors:\n",
"base_url = args.base_url\n",
"base_url = 'http://%s:%d/' % (get_service_address(ServiceCoord(\n 'ContestWebServer', 0))[0], config.contest_listen_port[0])\n",
"user_items.sort()\n",
"random.shuffle(user_items)\n",
"metrics = DEFAULT_METRICS\n",
"users = dict(user_items[:args.actor_num])\n",
"metrics['time_coeff'] = args.time_coeff\n",
"actor_class = RandomActor\n",
"if args.only_submit:\n",
"actor_class = SubmitActor\n",
"actors = [actor_class(username, data['password'], metrics, tasks, log=\n RequestLog(log_dir=os.path.join('./test_logs', username)), base_url=\n base_url, submissions_path=args.submissions_path) for username, data in\n users.iteritems()]\n",
"for actor in actors:\n",
"actor.start()\n",
"while True:\n",
"print('Taking down actors', file=sys.stderr)\n",
"finished = False\n",
"time.sleep(1)\n",
"for actor in actors:\n",
"while not finished:\n",
"actor.die = True\n",
"for actor in actors:\n",
"print('Test finished', file=sys.stderr)\n",
"actor.join()\n",
"great_log = RequestLog()\n",
"for actor in actors:\n",
"great_log.merge(actor.log)\n",
"great_log.print_stats()\n"
] | [
0,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
5,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Assert'",
"Assign'",
"Assert'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"For",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"For",
"Condition",
"Assign'",
"For",
"Expr'",
"Expr'",
"Assign'",
"For",
"Expr'",
"Expr'"
] |
[
"def FUNC_13(self, VAR_15):...\n",
"self.is_authenticated = True\n",
"self.is_active = True\n",
"self.is_anonymous = False\n",
"self.username = VAR_15\n"
] | [
"def authenticate(self, username):...\n",
"self.is_authenticated = True\n",
"self.is_active = True\n",
"self.is_anonymous = False\n",
"self.username = username\n"
] | [
0,
4,
4,
4,
4
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"from osv import osv\n",
"from tools.translate import _\n",
"import time\n",
"VAR_0 = 'pos.open.statement'\n",
"VAR_1 = 'Open Statements'\n",
"def FUNC_0(self, VAR_2, VAR_3, VAR_4, VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = []\n",
"VAR_7 = self.pool.get('ir.model.data')\n",
"VAR_8 = self.pool.get('res.users').browse(VAR_2, VAR_3, VAR_3).company_id.id\n",
"VAR_9 = self.pool.get('account.bank.statement')\n",
"VAR_10 = self.pool.get('ir.sequence')\n",
"VAR_11 = self.pool.get('account.journal')\n",
"VAR_2.execute(\n 'select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id'\n % VAR_3)\n",
"VAR_12 = map(lambda x1: x1[0], VAR_2.fetchall())\n",
"VAR_2.execute('string' % ','.join(map(lambda x: \"'\" + str(x) + \"'\", VAR_12)))\n",
"VAR_13 = map(lambda x1: x1[0], VAR_2.fetchall())\n",
"for journal in VAR_11.browse(VAR_2, VAR_3, VAR_13):\n",
"VAR_4 = VAR_9.search(VAR_2, VAR_3, [('state', '!=', 'confirm'), ('user_id',\n '=', VAR_3), ('journal_id', '=', journal.id)])\n",
"VAR_14 = self.pool.get('ir.model.data')\n",
"if len(VAR_4):\n",
"VAR_15 = VAR_14._get_id(VAR_2, VAR_3, 'account', 'view_bank_statement_tree')\n",
"VAR_17 = ''\n",
"VAR_16 = VAR_14._get_id(VAR_2, VAR_3, 'account', 'view_bank_statement_form2')\n",
"if journal.sequence_id:\n",
"if VAR_15:\n",
"VAR_17 = VAR_10.get_id(VAR_2, VAR_3, journal.sequence_id.id)\n",
"VAR_17 = VAR_10.get(VAR_2, VAR_3, 'account.bank.statement')\n",
"VAR_15 = VAR_14.browse(VAR_2, VAR_3, VAR_15, VAR_5=context).res_id\n",
"if VAR_16:\n",
"VAR_18 = VAR_9.create(VAR_2, VAR_3, {'journal_id': journal.id, 'company_id':\n VAR_8, 'user_id': VAR_3, 'state': 'open', 'name': VAR_17,\n 'starting_details_ids': VAR_9._get_cash_close_box_lines(VAR_2, VAR_3, [])})\n",
"VAR_16 = VAR_14.browse(VAR_2, VAR_3, VAR_16, VAR_5=context).res_id\n",
"return {'domain': \"[('state','=','open')]\", 'name': 'Open Statement',\n 'view_type': 'form', 'view_mode': 'tree,form', 'res_model':\n 'account.bank.statement', 'views': [(VAR_15, 'tree'), (VAR_16, 'form')],\n 'type': 'ir.actions.act_window'}\n",
"VAR_9.button_open(VAR_2, VAR_3, [VAR_18], VAR_5)\n"
] | [
"from osv import osv\n",
"from tools.translate import _\n",
"import time\n",
"_name = 'pos.open.statement'\n",
"_description = 'Open Statements'\n",
"def open_statement(self, cr, uid, ids, context):...\n",
"\"\"\"docstring\"\"\"\n",
"list_statement = []\n",
"mod_obj = self.pool.get('ir.model.data')\n",
"company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id\n",
"statement_obj = self.pool.get('account.bank.statement')\n",
"sequence_obj = self.pool.get('ir.sequence')\n",
"journal_obj = self.pool.get('account.journal')\n",
"cr.execute(\n 'select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id'\n % uid)\n",
"j_ids = map(lambda x1: x1[0], cr.fetchall())\n",
"cr.execute(\n \"\"\" select id from account_journal\n where auto_cash='True' and type='cash'\n and id in (%s)\"\"\"\n % ','.join(map(lambda x: \"'\" + str(x) + \"'\", j_ids)))\n",
"journal_ids = map(lambda x1: x1[0], cr.fetchall())\n",
"for journal in journal_obj.browse(cr, uid, journal_ids):\n",
"ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id',\n '=', uid), ('journal_id', '=', journal.id)])\n",
"data_obj = self.pool.get('ir.model.data')\n",
"if len(ids):\n",
"id2 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')\n",
"number = ''\n",
"id3 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')\n",
"if journal.sequence_id:\n",
"if id2:\n",
"number = sequence_obj.get_id(cr, uid, journal.sequence_id.id)\n",
"number = sequence_obj.get(cr, uid, 'account.bank.statement')\n",
"id2 = data_obj.browse(cr, uid, id2, context=context).res_id\n",
"if id3:\n",
"statement_id = statement_obj.create(cr, uid, {'journal_id': journal.id,\n 'company_id': company_id, 'user_id': uid, 'state': 'open', 'name':\n number, 'starting_details_ids': statement_obj._get_cash_close_box_lines\n (cr, uid, [])})\n",
"id3 = data_obj.browse(cr, uid, id3, context=context).res_id\n",
"return {'domain': \"[('state','=','open')]\", 'name': 'Open Statement',\n 'view_type': 'form', 'view_mode': 'tree,form', 'res_model':\n 'account.bank.statement', 'views': [(id2, 'tree'), (id3, 'form')],\n 'type': 'ir.actions.act_window'}\n",
"statement_obj.button_open(cr, uid, [statement_id], context)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"Import'",
"Assign'",
"Assign'",
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Expr'"
] |
[
"from base import Field\n",
"from primaryKeyField import PrimaryKeyField\n",
"from referenceField import ReferenceField\n",
"def __init__(self, VAR_0, VAR_1=None, VAR_2=None, VAR_3=False, VAR_4=False,...\n",
"super(CLASS_0, self).__init__(*VAR_5, **kwargs)\n",
"self.rel_model = VAR_0\n",
"self.reference = VAR_1 or VAR_0._meta.fields['id']\n",
"self.related_name = VAR_2\n",
"self.on_delete = VAR_3\n",
"self.on_update = VAR_4\n",
"def FUNC_0(self, VAR_7, VAR_8):...\n",
"self.name = VAR_8\n",
"self.model_class = VAR_7\n",
"self.related_name = self.related_name or '%ss' % VAR_7._meta.name\n",
"VAR_7._meta.add_field(self)\n",
"if self.related_name in self.rel_model._meta.fields:\n",
"print('ERROR: Foreign key conflict')\n",
"if self.related_name in self.rel_model._meta.reverse_rel:\n",
"print('ERROR: Foreign key %s already exists on model %s' % (self.\n related_name, VAR_7._meta.name))\n",
"self.model_class._meta.rel[self.name] = self\n",
"self.model_class._meta.rel_class[self.rel_model] = self\n",
"VAR_1 = ReferenceField(self.model_class)\n",
"VAR_1.add_to_model(self.rel_model, self.related_name, self.name)\n",
"def FUNC_1(self, VAR_8):...\n",
"VAR_10 = self.reference.get_db_field()\n",
"VAR_11 = '%s %s REFERENCES %s(%s)' % (self.name, VAR_10, self.rel_model.\n _meta.table_name, self.reference.name)\n",
"if self.on_delete:\n",
"VAR_11 += ' ON DELETE CASCADE'\n",
"if self.on_update:\n",
"VAR_11 += ' ON UPDATE CASCADE'\n",
"if self.unique:\n",
"VAR_11 += ' UNIQUE'\n",
"return VAR_11\n"
] | [
"from base import Field\n",
"from primaryKeyField import PrimaryKeyField\n",
"from referenceField import ReferenceField\n",
"def __init__(self, rel_model, reference=None, related_name=None, on_delete=...\n",
"super(ForeignKeyField, self).__init__(*args, **kwargs)\n",
"self.rel_model = rel_model\n",
"self.reference = reference or rel_model._meta.fields['id']\n",
"self.related_name = related_name\n",
"self.on_delete = on_delete\n",
"self.on_update = on_update\n",
"def add_to_model(self, model_class, name):...\n",
"self.name = name\n",
"self.model_class = model_class\n",
"self.related_name = self.related_name or '%ss' % model_class._meta.name\n",
"model_class._meta.add_field(self)\n",
"if self.related_name in self.rel_model._meta.fields:\n",
"print('ERROR: Foreign key conflict')\n",
"if self.related_name in self.rel_model._meta.reverse_rel:\n",
"print('ERROR: Foreign key %s already exists on model %s' % (self.\n related_name, model_class._meta.name))\n",
"self.model_class._meta.rel[self.name] = self\n",
"self.model_class._meta.rel_class[self.rel_model] = self\n",
"reference = ReferenceField(self.model_class)\n",
"reference.add_to_model(self.rel_model, self.related_name, self.name)\n",
"def create_field(self, name):...\n",
"_type = self.reference.get_db_field()\n",
"field_string = '%s %s REFERENCES %s(%s)' % (self.name, _type, self.\n rel_model._meta.table_name, self.reference.name)\n",
"if self.on_delete:\n",
"field_string += ' ON DELETE CASCADE'\n",
"if self.on_update:\n",
"field_string += ' ON UPDATE CASCADE'\n",
"if self.unique:\n",
"field_string += ' UNIQUE'\n",
"return field_string\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
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"AugAssign'",
"Condition",
"AugAssign'",
"Condition",
"AugAssign'",
"Return'"
] |
[
"def FUNC_9(self):...\n",
"VAR_5 = [{'loadBalancerName': self.__lb_name, 'networkLoadBalancerName':\n self.__lb_name, 'region': 'us-central1', 'type': 'deleteLoadBalancer',\n 'regions': ['us-central1'], 'credentials': self.bindings[\n 'GCE_CREDENTIALS'], 'cloudProvider': 'gce', 'user': 'integration-tests'}]\n",
"VAR_6 = gcp.GceContractBuilder(self.gce_observer)\n",
"VAR_6.new_clause_builder('Load Balancer Created', retryable_for_secs=30\n ).list_resources('forwarding-rules').excludes_path_value('name', self.\n __lb_name)\n",
"VAR_7 = self.agent.make_json_payload_from_kwargs(VAR_5=job, description=\n 'Server Group Test - delete load balancer', application=self.TEST_APP)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'delete_load_balancer', data=payload, path=self.__path), contract=\n builder.build())\n"
] | [
"def delete_load_balancer(self):...\n",
"job = [{'loadBalancerName': self.__lb_name, 'networkLoadBalancerName': self\n .__lb_name, 'region': 'us-central1', 'type': 'deleteLoadBalancer',\n 'regions': ['us-central1'], 'credentials': self.bindings[\n 'GCE_CREDENTIALS'], 'cloudProvider': 'gce', 'user': 'integration-tests'}]\n",
"builder = gcp.GceContractBuilder(self.gce_observer)\n",
"builder.new_clause_builder('Load Balancer Created', retryable_for_secs=30\n ).list_resources('forwarding-rules').excludes_path_value('name', self.\n __lb_name)\n",
"payload = self.agent.make_json_payload_from_kwargs(job=job, description=\n 'Server Group Test - delete load balancer', application=self.TEST_APP)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'delete_load_balancer', data=payload, path=self.__path), contract=\n builder.build())\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"import cgi\n",
"import os\n",
"import http.cookies\n",
"import funct\n",
"import sql\n",
"from jinja2 import Environment, FileSystemLoader\n",
"VAR_0 = Environment(loader=FileSystemLoader('templates/'))\n",
"VAR_1 = VAR_0.get_template('config.html')\n",
"print('Content-type: text/html\\n')\n",
"funct.check_login()\n",
"VAR_2 = cgi.FieldStorage()\n",
"VAR_3 = VAR_2.getvalue('serv')\n",
"VAR_4 = ''\n",
"VAR_5 = ''\n",
"VAR_6 = ''\n",
"VAR_7 = ''\n",
"VAR_8 = ''\n",
"VAR_10 = http.cookies.SimpleCookie(os.environ.get('HTTP_COOKIE'))\n",
"VAR_9 = funct.get_config_var('configs', 'haproxy_save_configs_dir')\n",
"VAR_11 = VAR_10.get('uuid')\n",
"if VAR_3 is not None:\n",
"VAR_12 = sql.get_user_name_by_uuid(VAR_11.value)\n",
"VAR_5 = VAR_9 + VAR_3 + '-' + funct.get_data('config') + '.cfg'\n",
"if VAR_3 is not None and VAR_2.getvalue('open') is not None:\n",
"VAR_13 = sql.get_dick_permit()\n",
"if VAR_3 is not None and VAR_2.getvalue('config') is not None:\n",
"funct.logging(VAR_3, 'config.py open config')\n",
"VAR_7 = funct.get_config(VAR_3, VAR_5)\n",
"VAR_14 = sql.get_token(VAR_11.value)\n",
"VAR_1 = VAR_1.render(h2=1, title='Working with HAProxy configs', VAR_15=\n role, action='config.py', VAR_12=user, select_id='serv', VAR_3=serv,\n VAR_8=aftersave, VAR_16=config_read, VAR_5=cfg, selects=servers, VAR_6=\n stderr, VAR_7=error, note=1, VAR_14=token)\n",
"funct.logging(VAR_3, 'config.py edited config')\n",
"VAR_16 = VAR_2.getvalue('config')\n",
"VAR_20 = open(VAR_5, 'r')\n",
"VAR_7 += \"<br />Can't read import config file\"\n",
"os.system('/bin/mv %s %s.old' % (VAR_5, VAR_5))\n",
"VAR_15 = sql.get_user_role_by_uuid(VAR_11.value)\n",
"print(VAR_1)\n",
"VAR_17 = VAR_2.getvalue('oldconfig')\n",
"VAR_4 = VAR_20.read()\n",
"VAR_18 = VAR_2.getvalue('save')\n",
"VAR_20.close\n",
"VAR_8 = 1\n",
"VAR_20.write(VAR_16)\n",
"VAR_7 = \"Can't read import config file\"\n",
"VAR_19 = sql.is_master(VAR_3)\n",
"for master in VAR_19:\n",
"if master[0] != None:\n",
"VAR_6 = funct.upload_and_restart(VAR_3, VAR_5, just_save=save)\n",
"funct.upload_and_restart(master[0], VAR_5, just_save=save)\n",
"funct.diff_config(VAR_17, VAR_5)\n",
"os.system('/bin/rm -f ' + VAR_9 + '*.old')\n"
] | [
"import cgi\n",
"import os\n",
"import http.cookies\n",
"import funct\n",
"import sql\n",
"from jinja2 import Environment, FileSystemLoader\n",
"env = Environment(loader=FileSystemLoader('templates/'))\n",
"template = env.get_template('config.html')\n",
"print('Content-type: text/html\\n')\n",
"funct.check_login()\n",
"form = cgi.FieldStorage()\n",
"serv = form.getvalue('serv')\n",
"config_read = ''\n",
"cfg = ''\n",
"stderr = ''\n",
"error = ''\n",
"aftersave = ''\n",
"cookie = http.cookies.SimpleCookie(os.environ.get('HTTP_COOKIE'))\n",
"hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')\n",
"user_id = cookie.get('uuid')\n",
"if serv is not None:\n",
"user = sql.get_user_name_by_uuid(user_id.value)\n",
"cfg = hap_configs_dir + serv + '-' + funct.get_data('config') + '.cfg'\n",
"if serv is not None and form.getvalue('open') is not None:\n",
"servers = sql.get_dick_permit()\n",
"if serv is not None and form.getvalue('config') is not None:\n",
"funct.logging(serv, 'config.py open config')\n",
"error = funct.get_config(serv, cfg)\n",
"token = sql.get_token(user_id.value)\n",
"template = template.render(h2=1, title='Working with HAProxy configs', role\n =role, action='config.py', user=user, select_id='serv', serv=serv,\n aftersave=aftersave, config=config_read, cfg=cfg, selects=servers,\n stderr=stderr, error=error, note=1, token=token)\n",
"funct.logging(serv, 'config.py edited config')\n",
"config = form.getvalue('config')\n",
"conf = open(cfg, 'r')\n",
"error += \"<br />Can't read import config file\"\n",
"os.system('/bin/mv %s %s.old' % (cfg, cfg))\n",
"role = sql.get_user_role_by_uuid(user_id.value)\n",
"print(template)\n",
"oldcfg = form.getvalue('oldconfig')\n",
"config_read = conf.read()\n",
"save = form.getvalue('save')\n",
"conf.close\n",
"aftersave = 1\n",
"conf.write(config)\n",
"error = \"Can't read import config file\"\n",
"MASTERS = sql.is_master(serv)\n",
"for master in MASTERS:\n",
"if master[0] != None:\n",
"stderr = funct.upload_and_restart(serv, cfg, just_save=save)\n",
"funct.upload_and_restart(master[0], cfg, just_save=save)\n",
"funct.diff_config(oldcfg, cfg)\n",
"os.system('/bin/rm -f ' + hap_configs_dir + '*.old')\n"
] | [
0,
0,
0,
0,
0,
0,
3,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"AugAssign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"For",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_6(self):...\n",
"for att in self._['tmpatts']:\n",
"os.makedirs('file/%s' % att.key)\n",
"os.rename('file/tmp/%s' % att.key, 'file/%s/%s' % (att.key, att.filename))\n",
"VAR_29 = AttachmentList(key=att.key, VAR_6=self.ann_id, content_type=att.\n content_type, filename=att.filename)\n",
"self.sql_session.add(VAR_29)\n",
"TempFileList.by_key(att.key, self.sql_session).delete()\n"
] | [
"def parse_att(self):...\n",
"for att in self._['tmpatts']:\n",
"os.makedirs('file/%s' % att.key)\n",
"os.rename('file/tmp/%s' % att.key, 'file/%s/%s' % (att.key, att.filename))\n",
"new_att = AttachmentList(key=att.key, ann_id=self.ann_id, content_type=att.\n content_type, filename=att.filename)\n",
"self.sql_session.add(new_att)\n",
"TempFileList.by_key(att.key, self.sql_session).delete()\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_14(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not FUNC_0(self.request.host):\n"
] | [
"def prepare(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not validate_host(self.request.host):\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition"
] |
[
"def FUNC_3(VAR_6):...\n",
"if VAR_6:\n",
"return {'startDate': min(VAR_6).strftime('%Y-%m-%d %H:%M'), 'endDate': max(\n VAR_6).strftime('%Y-%m-%d %H:%M')}\n"
] | [
"def get_date_range(dates):...\n",
"if dates:\n",
"return {'startDate': min(dates).strftime('%Y-%m-%d %H:%M'), 'endDate': max(\n dates).strftime('%Y-%m-%d %H:%M')}\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'"
] |
[
"def FUNC_13(VAR_25, VAR_27):...\n",
""
] | [
"def get_renderer(view, method):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_8(self, VAR_10):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_5 = {}\n",
"VAR_5['volumeName'] = VAR_10['name']\n",
"VAR_5['prompt'] = 'false'\n",
"VAR_27 = self._cliq_get_volume_info(VAR_10['name'])\n",
"VAR_0.error('Volume did not exist. It will not be deleted')\n",
"self._cliq_run_xml('deleteVolume', VAR_5)\n",
"return\n"
] | [
"def delete_volume(self, volume):...\n",
"\"\"\"docstring\"\"\"\n",
"cliq_args = {}\n",
"cliq_args['volumeName'] = volume['name']\n",
"cliq_args['prompt'] = 'false'\n",
"volume_info = self._cliq_get_volume_info(volume['name'])\n",
"LOG.error('Volume did not exist. It will not be deleted')\n",
"self._cliq_run_xml('deleteVolume', cliq_args)\n",
"return\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_2(VAR_7=None, VAR_8=0, VAR_9=0):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_7 is None:\n",
"return True\n",
"return False\n",
"VAR_21 = re.match('^([^;]+)(; length=([0-9]+))?$', VAR_7, re.IGNORECASE)\n",
"VAR_22 = parse_http_date(VAR_21.group(1))\n",
"VAR_23 = VAR_21.group(3)\n",
"if VAR_23 and int(VAR_23) != VAR_9:\n",
"if int(VAR_8) > VAR_22:\n"
] | [
"def was_modified_since(header=None, mtime=0, size=0):...\n",
"\"\"\"docstring\"\"\"\n",
"if header is None:\n",
"return True\n",
"return False\n",
"matches = re.match('^([^;]+)(; length=([0-9]+))?$', header, re.IGNORECASE)\n",
"header_mtime = parse_http_date(matches.group(1))\n",
"header_len = matches.group(3)\n",
"if header_len and int(header_len) != size:\n",
"if int(mtime) > header_mtime:\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition"
] |
[
"def FUNC_2(self, VAR_2, VAR_4):...\n",
"VAR_5 = getattr(VAR_4, self.obj_var, None)\n",
"return VAR_5 is None or self.has_object_permission(VAR_2, VAR_4, VAR_5)\n"
] | [
"def has_permission(self, request, view):...\n",
"obj = getattr(view, self.obj_var, None)\n",
"return obj is None or self.has_object_permission(request, view, obj)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_12(self):...\n",
""
] | [
"def allow_dhcp_broadcast(self):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"@api.require(lambda : True)...\n",
""
] | [
"@api.require(lambda : True)...\n",
""
] | [
0,
0
] | [
"Condition",
"Condition"
] |
[
"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='[email protected]')\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"
] | [
"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='[email protected]')\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
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_3(self, VAR_1, VAR_2, VAR_5, VAR_4=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_4 is None:\n",
"VAR_4 = {}\n",
"VAR_30 = VAR_4.get('states', [])\n",
"VAR_31 = VAR_4.get('what', ())\n",
"if not VAR_5:\n",
"VAR_5 = self.search(VAR_1, VAR_2, [])\n",
"VAR_29 = {}.fromkeys(VAR_5, 0.0)\n",
"if not VAR_5:\n",
"return VAR_29\n",
"if VAR_4.get('shop', False):\n",
"VAR_1.execute('select warehouse_id from sale_shop where id=%s', (int(VAR_4[\n 'shop']),))\n",
"if VAR_4.get('warehouse', False):\n",
"VAR_41 = VAR_1.fetchone()\n",
"VAR_1.execute('select lot_stock_id from stock_warehouse where id=%s', (int(\n VAR_4['warehouse']),))\n",
"if VAR_4.get('location', False):\n",
"if VAR_41:\n",
"VAR_41 = VAR_1.fetchone()\n",
"if type(VAR_4['location']) == type(1):\n",
"VAR_42 = []\n",
"VAR_4['warehouse'] = VAR_41[0]\n",
"if VAR_41:\n",
"VAR_42 = [VAR_4['location']]\n",
"if type(VAR_4['location']) in (type(''), type(u'')):\n",
"VAR_43 = self.pool.get('stock.warehouse').search(VAR_1, VAR_2, [], VAR_4=\n context)\n",
"VAR_4['location'] = VAR_41[0]\n",
"if VAR_4.get('compute_child', True):\n",
"VAR_42 = self.pool.get('stock.location').search(VAR_1, VAR_2, [('name',\n 'ilike', VAR_4['location'])], VAR_4=context)\n",
"VAR_42 = VAR_4['location']\n",
"for w in self.pool.get('stock.warehouse').browse(VAR_1, VAR_2, VAR_43,\n",
"VAR_44 = self.pool.get('stock.location').search(VAR_1, VAR_2, [(\n 'location_id', 'child_of', VAR_42)])\n",
"VAR_42 = VAR_42\n",
"VAR_42.append(w.lot_stock_id.id)\n",
"VAR_42 = VAR_44 or VAR_42\n",
"VAR_32 = {}\n",
"VAR_33 = {}\n",
"for VAR_45 in self.browse(VAR_1, VAR_2, VAR_5, VAR_4=context):\n",
"VAR_33[VAR_45.id] = VAR_45.uom_id.id\n",
"VAR_34 = []\n",
"VAR_32[VAR_45.uom_id.id] = VAR_45.uom_id\n",
"VAR_35 = []\n",
"VAR_36 = VAR_4.get('from_date', False)\n",
"VAR_37 = VAR_4.get('to_date', False)\n",
"VAR_38 = False\n",
"if VAR_36 and VAR_37:\n",
"VAR_38 = \"date_planned>='%s' and date_planned<='%s'\" % (VAR_36, VAR_37)\n",
"if VAR_36:\n",
"if 'in' in VAR_31:\n",
"VAR_38 = \"date_planned>='%s'\" % VAR_36\n",
"if VAR_37:\n",
"VAR_1.execute('string' + (VAR_38 and 'and ' + VAR_38 + ' ' or '') +\n 'group by product_id,product_uom', (tuple(VAR_42), tuple(VAR_42), tuple\n (VAR_5), tuple(VAR_30)))\n",
"if 'out' in VAR_31:\n",
"VAR_38 = \"date_planned<='%s'\" % VAR_37\n",
"VAR_34 = VAR_1.fetchall()\n",
"VAR_1.execute('string' + (VAR_38 and 'and ' + VAR_38 + ' ' or '') +\n 'group by product_id,product_uom', (tuple(VAR_42), tuple(VAR_42), tuple\n (VAR_5), tuple(VAR_30)))\n",
"VAR_39 = self.pool.get('product.uom')\n",
"VAR_35 = VAR_1.fetchall()\n",
"VAR_40 = map(lambda x: x[2], VAR_34) + map(lambda x: x[2], VAR_35)\n",
"if VAR_4.get('uom', False):\n",
"VAR_40 += [VAR_4['uom']]\n",
"VAR_40 = filter(lambda x: x not in VAR_32.keys(), VAR_40)\n",
"if VAR_40:\n",
"VAR_40 = VAR_39.browse(VAR_1, VAR_2, list(set(VAR_40)), VAR_4=context)\n",
"for VAR_46 in VAR_40:\n",
"VAR_32[VAR_46.id] = VAR_46\n",
"for VAR_47, prod_id, prod_uom in VAR_34:\n",
"VAR_47 = VAR_39._compute_qty_obj(VAR_1, VAR_2, VAR_32[prod_uom], VAR_47,\n VAR_32[VAR_4.get('uom', False) or VAR_33[prod_id]])\n",
"for VAR_47, prod_id, prod_uom in VAR_35:\n",
"VAR_29[prod_id] += VAR_47\n",
"VAR_47 = VAR_39._compute_qty_obj(VAR_1, VAR_2, VAR_32[prod_uom], VAR_47,\n VAR_32[VAR_4.get('uom', False) or VAR_33[prod_id]])\n",
"return VAR_29\n",
"VAR_29[prod_id] -= VAR_47\n"
] | [
"def get_product_available(self, cr, uid, ids, context=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if context is None:\n",
"context = {}\n",
"states = context.get('states', [])\n",
"what = context.get('what', ())\n",
"if not ids:\n",
"ids = self.search(cr, uid, [])\n",
"res = {}.fromkeys(ids, 0.0)\n",
"if not ids:\n",
"return res\n",
"if context.get('shop', False):\n",
"cr.execute('select warehouse_id from sale_shop where id=%s', (int(context[\n 'shop']),))\n",
"if context.get('warehouse', False):\n",
"res2 = cr.fetchone()\n",
"cr.execute('select lot_stock_id from stock_warehouse where id=%s', (int(\n context['warehouse']),))\n",
"if context.get('location', False):\n",
"if res2:\n",
"res2 = cr.fetchone()\n",
"if type(context['location']) == type(1):\n",
"location_ids = []\n",
"context['warehouse'] = res2[0]\n",
"if res2:\n",
"location_ids = [context['location']]\n",
"if type(context['location']) in (type(''), type(u'')):\n",
"wids = self.pool.get('stock.warehouse').search(cr, uid, [], context=context)\n",
"context['location'] = res2[0]\n",
"if context.get('compute_child', True):\n",
"location_ids = self.pool.get('stock.location').search(cr, uid, [('name',\n 'ilike', context['location'])], context=context)\n",
"location_ids = context['location']\n",
"for w in self.pool.get('stock.warehouse').browse(cr, uid, wids, context=context\n",
"child_location_ids = self.pool.get('stock.location').search(cr, uid, [(\n 'location_id', 'child_of', location_ids)])\n",
"location_ids = location_ids\n",
"location_ids.append(w.lot_stock_id.id)\n",
"location_ids = child_location_ids or location_ids\n",
"uoms_o = {}\n",
"product2uom = {}\n",
"for product in self.browse(cr, uid, ids, context=context):\n",
"product2uom[product.id] = product.uom_id.id\n",
"results = []\n",
"uoms_o[product.uom_id.id] = product.uom_id\n",
"results2 = []\n",
"from_date = context.get('from_date', False)\n",
"to_date = context.get('to_date', False)\n",
"date_str = False\n",
"if from_date and to_date:\n",
"date_str = \"date_planned>='%s' and date_planned<='%s'\" % (from_date, to_date)\n",
"if from_date:\n",
"if 'in' in what:\n",
"date_str = \"date_planned>='%s'\" % from_date\n",
"if to_date:\n",
"cr.execute(\n 'select sum(product_qty), product_id, product_uom from stock_move where location_id NOT IN %sand location_dest_id IN %sand product_id IN %sand state IN %s'\n + (date_str and 'and ' + date_str + ' ' or '') +\n 'group by product_id,product_uom', (tuple(location_ids), tuple(\n location_ids), tuple(ids), tuple(states)))\n",
"if 'out' in what:\n",
"date_str = \"date_planned<='%s'\" % to_date\n",
"results = cr.fetchall()\n",
"cr.execute(\n 'select sum(product_qty), product_id, product_uom from stock_move where location_id IN %sand location_dest_id NOT IN %s and product_id IN %sand state in %s'\n + (date_str and 'and ' + date_str + ' ' or '') +\n 'group by product_id,product_uom', (tuple(location_ids), tuple(\n location_ids), tuple(ids), tuple(states)))\n",
"uom_obj = self.pool.get('product.uom')\n",
"results2 = cr.fetchall()\n",
"uoms = map(lambda x: x[2], results) + map(lambda x: x[2], results2)\n",
"if context.get('uom', False):\n",
"uoms += [context['uom']]\n",
"uoms = filter(lambda x: x not in uoms_o.keys(), uoms)\n",
"if uoms:\n",
"uoms = uom_obj.browse(cr, uid, list(set(uoms)), context=context)\n",
"for o in uoms:\n",
"uoms_o[o.id] = o\n",
"for amount, prod_id, prod_uom in results:\n",
"amount = uom_obj._compute_qty_obj(cr, uid, uoms_o[prod_uom], amount, uoms_o\n [context.get('uom', False) or product2uom[prod_id]])\n",
"for amount, prod_id, prod_uom in results2:\n",
"res[prod_id] += amount\n",
"amount = uom_obj._compute_qty_obj(cr, uid, uoms_o[prod_uom], amount, uoms_o\n [context.get('uom', False) or product2uom[prod_id]])\n",
"return res\n",
"res[prod_id] -= amount\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
0,
0,
4,
0,
4,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"AugAssign'",
"Assign'",
"Condition",
"Assign'",
"For",
"Assign'",
"For",
"Assign'",
"For",
"AugAssign'",
"Assign'",
"Return'",
"AugAssign'"
] |
[
"def FUNC_8(self):...\n",
"run_shell_command('super-cool-command', weird_parameter2='abc')\n",
"run_shell_command('super-cool-command', universal_newlines=False)\n"
] | [
"def test_run_shell_command_kwargs_delegation(self):...\n",
"run_shell_command('super-cool-command', weird_parameter2='abc')\n",
"run_shell_command('super-cool-command', universal_newlines=False)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'"
] |
[
"def FUNC_6(self, VAR_29):...\n",
"if VAR_29 is None:\n",
"return VAR_101.user.pref_numsites\n",
"return VAR_54(VAR_55(int(VAR_29), 1), 250)\n"
] | [
"def run(self, limit):...\n",
"if limit is None:\n",
"return c.user.pref_numsites\n",
"return min(max(int(limit), 1), 250)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_6():...\n",
"VAR_13.throw(_('Invalid Search Field'), VAR_13.DataError)\n"
] | [
"def _raise_exception():...\n",
"frappe.throw(_('Invalid Search Field'), frappe.DataError)\n"
] | [
0,
4
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_12(VAR_24):...\n",
"VAR_38 = argparse.ArgumentParser(description=\n 'Reads and merges JSON configuration files specified by colon separated environment variable OS_CONFIG_FILES, unless overridden by command line option --metadata. If no files are specified this way, falls back to legacy behavior of searching the fallback metadata path for a single config file.'\n )\n",
"VAR_38.add_argument('-t', '--templates', metavar='TEMPLATE_ROOT', help=\n \"\"\"path to template root directory (default:\n %(default)s)\"\"\"\n , VAR_12=TEMPLATES_DIR)\n",
"VAR_38.add_argument('-o', '--output', metavar='OUT_DIR', help=\n 'root directory for output (default:%(default)s)', VAR_12='/')\n",
"VAR_38.add_argument('-m', '--metadata', metavar='METADATA_FILE', nargs='*',\n help=\n 'Overrides environment variable OS_CONFIG_FILES. Specify multiple times, rather than separate files with \":\".'\n , VAR_12=[])\n",
"VAR_38.add_argument('--fallback-metadata', metavar='FALLBACK_METADATA',\n nargs='*', help=\n 'Files to search when OS_CONFIG_FILES is empty. (default: %(default)s)',\n VAR_12=['/var/cache/heat-cfntools/last_metadata',\n '/var/lib/heat-cfntools/cfn-init-data',\n '/var/lib/cloud/data/cfn-init-data'])\n",
"VAR_38.add_argument('-v', '--validate', help=\n 'validate only. do not write files', VAR_12=False, action='store_true')\n",
"VAR_38.add_argument('--print-templates', VAR_12=False, action='store_true',\n help='Print templates root and exit.')\n",
"VAR_38.add_argument('-s', '--subhash', help=\n 'use the sub-hash named by this key, instead of the full metadata hash')\n",
"VAR_38.add_argument('--key', metavar='KEY', VAR_12=None, help=\n 'print the specified key and exit. (may be used with --type and --key-default)'\n )\n",
"VAR_38.add_argument('--type', VAR_12='default', help=\n 'exit with error if the specified --key does not match type. Valid types are <int|default|netaddress|netdevice|dsn|swiftdevices|raw>'\n )\n",
"VAR_38.add_argument('--key-default', help=\n 'This option only affects running with --key. Print this if key is not found. This value is not subject to type restrictions. If --key is specified and no default is specified, program exits with an error on missing key.'\n )\n",
"VAR_38.add_argument('--version', action='version', version=version.\n version_info.version_string())\n",
"VAR_38.add_argument('--os-config-files', VAR_12=OS_CONFIG_FILES_PATH, help=\n 'Set path to os_config_files.json')\n",
"VAR_39 = VAR_38.parse_args(VAR_24[1:])\n",
"return VAR_39\n"
] | [
"def parse_opts(argv):...\n",
"parser = argparse.ArgumentParser(description=\n 'Reads and merges JSON configuration files specified by colon separated environment variable OS_CONFIG_FILES, unless overridden by command line option --metadata. If no files are specified this way, falls back to legacy behavior of searching the fallback metadata path for a single config file.'\n )\n",
"parser.add_argument('-t', '--templates', metavar='TEMPLATE_ROOT', help=\n \"\"\"path to template root directory (default:\n %(default)s)\"\"\"\n , default=TEMPLATES_DIR)\n",
"parser.add_argument('-o', '--output', metavar='OUT_DIR', help=\n 'root directory for output (default:%(default)s)', default='/')\n",
"parser.add_argument('-m', '--metadata', metavar='METADATA_FILE', nargs='*',\n help=\n 'Overrides environment variable OS_CONFIG_FILES. Specify multiple times, rather than separate files with \":\".'\n , default=[])\n",
"parser.add_argument('--fallback-metadata', metavar='FALLBACK_METADATA',\n nargs='*', help=\n 'Files to search when OS_CONFIG_FILES is empty. (default: %(default)s)',\n default=['/var/cache/heat-cfntools/last_metadata',\n '/var/lib/heat-cfntools/cfn-init-data',\n '/var/lib/cloud/data/cfn-init-data'])\n",
"parser.add_argument('-v', '--validate', help=\n 'validate only. do not write files', default=False, action='store_true')\n",
"parser.add_argument('--print-templates', default=False, action='store_true',\n help='Print templates root and exit.')\n",
"parser.add_argument('-s', '--subhash', help=\n 'use the sub-hash named by this key, instead of the full metadata hash')\n",
"parser.add_argument('--key', metavar='KEY', default=None, help=\n 'print the specified key and exit. (may be used with --type and --key-default)'\n )\n",
"parser.add_argument('--type', default='default', help=\n 'exit with error if the specified --key does not match type. Valid types are <int|default|netaddress|netdevice|dsn|swiftdevices|raw>'\n )\n",
"parser.add_argument('--key-default', help=\n 'This option only affects running with --key. Print this if key is not found. This value is not subject to type restrictions. If --key is specified and no default is specified, program exits with an error on missing key.'\n )\n",
"parser.add_argument('--version', action='version', version=version.\n version_info.version_string())\n",
"parser.add_argument('--os-config-files', default=OS_CONFIG_FILES_PATH, help\n ='Set path to os_config_files.json')\n",
"opts = parser.parse_args(argv[1:])\n",
"return opts\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_8(self, VAR_14):...\n",
""
] | [
"def is_file(self, col_name):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_7(self):...\n",
"VAR_1 = self.client.get('/qa/extractionscript/5', follow=True)\n",
"VAR_1 = self.client.get('/qa/extractedtext/7', follow=True)\n"
] | [
"def test_approval(self):...\n",
"response = self.client.get('/qa/extractionscript/5', follow=True)\n",
"response = self.client.get('/qa/extractedtext/7', follow=True)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'"
] |
[
"def FUNC_6(self):...\n",
"self.driver._eql_execute = self.mox.CreateMock(self.driver._eql_execute)\n",
"VAR_3 = {'name': 'fakesnap', 'volume_name': 'fakevolume_name'}\n",
"VAR_4 = 'fake_snap_name'\n",
"self.driver._eql_execute('volume', 'select', VAR_3['volume_name'],\n 'snapshot', 'create-now').AndReturn(['Snapshot name is %s' % VAR_4])\n",
"self.driver._eql_execute('volume', 'select', VAR_3['volume_name'],\n 'snapshot', 'rename', VAR_4, VAR_3['name'])\n",
"self.mox.ReplayAll()\n",
"self.driver.create_snapshot(VAR_3)\n"
] | [
"def test_create_snapshot(self):...\n",
"self.driver._eql_execute = self.mox.CreateMock(self.driver._eql_execute)\n",
"snapshot = {'name': 'fakesnap', 'volume_name': 'fakevolume_name'}\n",
"snap_name = 'fake_snap_name'\n",
"self.driver._eql_execute('volume', 'select', snapshot['volume_name'],\n 'snapshot', 'create-now').AndReturn(['Snapshot name is %s' % snap_name])\n",
"self.driver._eql_execute('volume', 'select', snapshot['volume_name'],\n 'snapshot', 'rename', snap_name, snapshot['name'])\n",
"self.mox.ReplayAll()\n",
"self.driver.create_snapshot(snapshot)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_37(self, VAR_14, VAR_18):...\n",
"VAR_31 = self.get_related_model(VAR_14)\n",
"return self.session.query(VAR_31).get(VAR_18)\n"
] | [
"def get_related_obj(self, col_name, value):...\n",
"rel_model = self.get_related_model(col_name)\n",
"return self.session.query(rel_model).get(value)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return FUNC_0(self.request, self.request.user)\n"
] | [
"def get_redirect_url(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return find_nextlocation(self.request, self.request.user)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_11(self, VAR_14=None, VAR_15=False, VAR_16=False, VAR_17=1, VAR_18...\n",
"self.global_resources = dict() if VAR_52 is None else VAR_52\n",
"self.global_resources['_cores'] = VAR_17\n",
"self.global_resources['_nodes'] = VAR_18\n",
"def FUNC_2(VAR_87):...\n",
"return map(self._rules.__getitem__, filter(self.is_rule, VAR_87))\n"
] | [
"def execute(self, targets=None, dryrun=False, touch=False, cores=1, nodes=1,...\n",
"self.global_resources = dict() if resources is None else resources\n",
"self.global_resources['_cores'] = cores\n",
"self.global_resources['_nodes'] = nodes\n",
"def rules(items):...\n",
"return map(self._rules.__getitem__, filter(self.is_rule, items))\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_10(VAR_32, VAR_34):...\n",
"logging.info('Got signal %s', VAR_32)\n"
] | [
"def handler(sig, _):...\n",
"logging.info('Got signal %s', sig)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_33(VAR_57, VAR_22):...\n",
"if not len(VAR_57):\n",
"VAR_56.append('/%s' % ('/'.join(VAR_22),))\n",
"if VAR_57[0] == '.':\n",
"FUNC_33(VAR_57[1:], VAR_22)\n",
"if VAR_57[0] == '..':\n",
"FUNC_33(VAR_57[1:], VAR_22[:-1])\n",
"VAR_65 = [x[VAR_1] for x in self.get_path('/'.join(VAR_22))]\n",
"VAR_74 = [x for x in VAR_65 if fnmatch.fnmatchcase(x, VAR_57[0])]\n",
"for match in VAR_74:\n",
"FUNC_33(VAR_57[1:], VAR_22 + [match])\n"
] | [
"def foo(p, cwd):...\n",
"if not len(p):\n",
"found.append('/%s' % ('/'.join(cwd),))\n",
"if p[0] == '.':\n",
"foo(p[1:], cwd)\n",
"if p[0] == '..':\n",
"foo(p[1:], cwd[:-1])\n",
"names = [x[A_NAME] for x in self.get_path('/'.join(cwd))]\n",
"matches = [x for x in names if fnmatch.fnmatchcase(x, p[0])]\n",
"for match in matches:\n",
"foo(p[1:], cwd + [match])\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"For",
"Expr'"
] |
[
"\"\"\"string\"\"\"\n",
"import os\n",
"import unittest\n",
"from mock import patch, call\n",
"from test.test_support import EnvironmentVarGuard\n",
"from paver.easy import BuildFailure\n",
"from pavelib.utils.test.suites import BokChoyTestSuite, Pa11yCrawler\n",
"VAR_0 = os.getcwd()\n",
"\"\"\"\n Paver Bok Choy Command test cases\n \"\"\"\n",
"def FUNC_0(self, VAR_1, VAR_2=None, VAR_3=False):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = 'string'.format(default_store=store, repo_dir=REPO_DIR, shard_str=\n '/shard_' + self.shard if self.shard else '', exp_text=name,\n a11y_custom_file=\n 'node_modules/edx-custom-a11y-rules/lib/custom_a11y_rules.js', VAR_3=\n verify_xss)\n",
"return VAR_6\n"
] | [
"\"\"\"\nTests for the bok-choy paver commands themselves.\nRun just this test with: paver test_lib -t pavelib/paver_tests/test_paver_bok_choy_cmds.py\n\"\"\"\n",
"import os\n",
"import unittest\n",
"from mock import patch, call\n",
"from test.test_support import EnvironmentVarGuard\n",
"from paver.easy import BuildFailure\n",
"from pavelib.utils.test.suites import BokChoyTestSuite, Pa11yCrawler\n",
"REPO_DIR = os.getcwd()\n",
"\"\"\"\n Paver Bok Choy Command test cases\n \"\"\"\n",
"def _expected_command(self, name, store=None, verify_xss=False):...\n",
"\"\"\"docstring\"\"\"\n",
"expected_statement = (\n \"DEFAULT_STORE={default_store} SCREENSHOT_DIR='{repo_dir}/test_root/log{shard_str}' BOK_CHOY_HAR_DIR='{repo_dir}/test_root/log{shard_str}/hars' BOKCHOY_A11Y_CUSTOM_RULES_FILE='{repo_dir}/{a11y_custom_file}' SELENIUM_DRIVER_LOG_DIR='{repo_dir}/test_root/log{shard_str}' VERIFY_XSS='{verify_xss}' nosetests {repo_dir}/common/test/acceptance/{exp_text} --with-xunit --xunit-file={repo_dir}/reports/bok_choy{shard_str}/xunit.xml --verbosity=2 \"\n .format(default_store=store, repo_dir=REPO_DIR, shard_str='/shard_' +\n self.shard if self.shard else '', exp_text=name, a11y_custom_file=\n 'node_modules/edx-custom-a11y-rules/lib/custom_a11y_rules.js',\n verify_xss=verify_xss))\n",
"return expected_statement\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Expr'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Expr'",
"FunctionDef'",
"Docstring",
"Assign'",
"Return'"
] |
[
"def FUNC_0(self):...\n",
"return self.get_serializer_class().setup_eager_loading(Action.objects.\n filter(published=True))\n"
] | [
"def get_queryset(self):...\n",
"return self.get_serializer_class().setup_eager_loading(Action.objects.\n filter(published=True))\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_9(self):...\n",
"self.object.restart()\n",
"return '/twitter_hunter'\n"
] | [
"def get_success_url(self):...\n",
"self.object.restart()\n",
"return '/twitter_hunter'\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Return'"
] |
[
"def FUNC_18(self, VAR_16):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = self.host.pkg_query(VAR_16)\n",
"VAR_33 = self.run_command(VAR_6)\n",
"if VAR_33['status'] == 0:\n",
"return True\n",
"return False\n"
] | [
"def is_installed(self, pkg):...\n",
"\"\"\"docstring\"\"\"\n",
"cmd = self.host.pkg_query(pkg)\n",
"res = self.run_command(cmd)\n",
"if res['status'] == 0:\n",
"return True\n",
"return False\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"@utils.synchronized('3par', external=True)...\n",
"self.common.client_login()\n",
"self.common.delete_volume(VAR_7)\n",
"self.common.client_logout()\n"
] | [
"@utils.synchronized('3par', external=True)...\n",
"self.common.client_login()\n",
"self.common.delete_volume(volume)\n",
"self.common.client_logout()\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_25(self, VAR_11, VAR_28):...\n",
"VAR_12 = \"ssh -t %s 'tmux kill-session -t %s'\" % (VAR_28, VAR_11)\n",
"FUNC_7(self.session, VAR_12)\n"
] | [
"def kill_remote_session_by_name(self, name, host):...\n",
"cmd = \"ssh -t %s 'tmux kill-session -t %s'\" % (host, name)\n",
"send_main_session_command(self.session, cmd)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"@permission_required('tournament.add_game')...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_7 = get_modifiable_tournament_or_404(VAR_3, VAR_2.user)\n",
"VAR_8 = FUNC_0(VAR_7, VAR_1)\n",
"VAR_12 = VAR_8.roundplayer_set.count()\n",
"VAR_13 = VAR_12 % 7\n",
"if VAR_13 == 0:\n",
"return HttpResponseRedirect(reverse('seed_games', args=(tournament_id,\n round_num)))\n",
"VAR_14 = 7 - VAR_13\n",
"VAR_9 = {'tournament': VAR_7, 'round': VAR_8, 'count': VAR_12, 'sitters':\n VAR_13, 'doubles': VAR_14}\n",
"VAR_15 = GetSevenPlayersForm(VAR_2.POST or None, VAR_5=r)\n",
"if VAR_15.is_valid():\n",
"for VAR_36 in VAR_8.roundplayer_set.exclude(game_count=1):\n",
"VAR_9['form'] = VAR_15\n",
"VAR_36.game_count = 1\n",
"for VAR_34 in range(VAR_13):\n",
"return render(VAR_2, 'rounds/get_seven.html', VAR_9)\n",
"VAR_36.save()\n",
"VAR_36 = VAR_15.cleaned_data['sitter_%d' % VAR_34]\n",
"for VAR_34 in range(VAR_14):\n",
"if VAR_36:\n",
"VAR_36 = VAR_15.cleaned_data['double_%d' % VAR_34]\n",
"return HttpResponseRedirect(reverse('seed_games', args=(tournament_id,\n round_num)))\n",
"VAR_36.game_count = 0\n",
"if VAR_36:\n",
"VAR_36.save()\n",
"VAR_36.game_count = 2\n",
"VAR_36.save()\n"
] | [
"@permission_required('tournament.add_game')...\n",
"\"\"\"docstring\"\"\"\n",
"t = get_modifiable_tournament_or_404(tournament_id, request.user)\n",
"r = get_round_or_404(t, round_num)\n",
"count = r.roundplayer_set.count()\n",
"sitters = count % 7\n",
"if sitters == 0:\n",
"return HttpResponseRedirect(reverse('seed_games', args=(tournament_id,\n round_num)))\n",
"doubles = 7 - sitters\n",
"context = {'tournament': t, 'round': r, 'count': count, 'sitters': sitters,\n 'doubles': doubles}\n",
"form = GetSevenPlayersForm(request.POST or None, the_round=r)\n",
"if form.is_valid():\n",
"for rp in r.roundplayer_set.exclude(game_count=1):\n",
"context['form'] = form\n",
"rp.game_count = 1\n",
"for i in range(sitters):\n",
"return render(request, 'rounds/get_seven.html', context)\n",
"rp.save()\n",
"rp = form.cleaned_data['sitter_%d' % i]\n",
"for i in range(doubles):\n",
"if rp:\n",
"rp = form.cleaned_data['double_%d' % i]\n",
"return HttpResponseRedirect(reverse('seed_games', args=(tournament_id,\n round_num)))\n",
"rp.game_count = 0\n",
"if rp:\n",
"rp.save()\n",
"rp.game_count = 2\n",
"rp.save()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"For",
"Assign'",
"Assign'",
"For",
"Return'",
"Expr'",
"Assign'",
"For",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_15(self):...\n",
"self.mock(bot_main, 'post_error_task', lambda *VAR_24: self.fail(VAR_24))\n",
"def FUNC_24(VAR_14, VAR_23, *VAR_24):...\n",
"if VAR_23 == 'on_after_task':\n",
"VAR_50, VAR_51, VAR_5, VAR_52 = VAR_24\n",
"self.mock(bot_main, 'call_hook', FUNC_24)\n",
"self.assertEqual(self.attributes['dimensions'], VAR_14.dimensions)\n",
"VAR_22 = self._mock_popen(VAR_3='https://localhost:3')\n",
"self.assertEqual(False, VAR_50)\n",
"VAR_19 = {'command': ['echo', 'hi'], 'dimensions': {'os': 'Amiga', 'pool':\n 'default'}, 'grace_period': 30, 'hard_timeout': 60, 'host':\n 'https://localhost:3', 'task_id': '24'}\n",
"self.assertEqual(False, VAR_51)\n",
"self.assertEqual(self.root_dir, self.bot.base_dir)\n",
"self.assertEqual({'os': 'Amiga', 'pool': 'default'}, VAR_5)\n",
"bot_main.run_manifest(self.bot, VAR_19, time.time())\n",
"self.assertEqual(VAR_22, VAR_52)\n"
] | [
"def test_run_manifest(self):...\n",
"self.mock(bot_main, 'post_error_task', lambda *args: self.fail(args))\n",
"def call_hook(botobj, name, *args):...\n",
"if name == 'on_after_task':\n",
"failure, internal_failure, dimensions, summary = args\n",
"self.mock(bot_main, 'call_hook', call_hook)\n",
"self.assertEqual(self.attributes['dimensions'], botobj.dimensions)\n",
"result = self._mock_popen(url='https://localhost:3')\n",
"self.assertEqual(False, failure)\n",
"manifest = {'command': ['echo', 'hi'], 'dimensions': {'os': 'Amiga', 'pool':\n 'default'}, 'grace_period': 30, 'hard_timeout': 60, 'host':\n 'https://localhost:3', 'task_id': '24'}\n",
"self.assertEqual(False, internal_failure)\n",
"self.assertEqual(self.root_dir, self.bot.base_dir)\n",
"self.assertEqual({'os': 'Amiga', 'pool': 'default'}, dimensions)\n",
"bot_main.run_manifest(self.bot, manifest, time.time())\n",
"self.assertEqual(result, summary)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_26(VAR_8):...\n",
"api.reset_local_state()\n",
"return VAR_7.get('/request', extra_environ={'REMOTE_ADDR': ip}).body\n"
] | [
"def call(ip):...\n",
"api.reset_local_state()\n",
"return app.get('/request', extra_environ={'REMOTE_ADDR': ip}).body\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Return'"
] |
[
"def FUNC_3(self):...\n",
"VAR_1 = '/api/apps'\n",
"VAR_2 = self.client.post(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 201)\n",
"VAR_3 = VAR_2.data['id']\n",
"VAR_1 = '/api/apps/{app_id}/builds'.format(**locals())\n",
"VAR_4 = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n",
"VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_2.status_code, 201)\n",
"VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n",
"VAR_2 = self.client.get(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 200)\n",
"self.assertEqual(len(VAR_2.data['results']), 1)\n",
"VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n",
"VAR_4 = {'web': 0}\n",
"VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_2.status_code, 204)\n",
"chaos.START_ERROR_RATE = 0.5\n",
"VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n",
"VAR_4 = {'web': 20}\n",
"VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_2.status_code, 204)\n",
"VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n",
"VAR_2 = self.client.get(VAR_1)\n",
"self.assertEqual(VAR_2.status_code, 200)\n",
"self.assertEqual(len(VAR_2.data['results']), 20)\n",
"VAR_5 = set([c['state'] for c in VAR_2.data['results']])\n",
"self.assertEqual(VAR_5, set(['crashed', 'up']))\n"
] | [
"def test_start_chaos(self):...\n",
"url = '/api/apps'\n",
"response = self.client.post(url)\n",
"self.assertEqual(response.status_code, 201)\n",
"app_id = response.data['id']\n",
"url = '/api/apps/{app_id}/builds'.format(**locals())\n",
"body = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 201)\n",
"url = '/api/apps/{app_id}/containers'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(len(response.data['results']), 1)\n",
"url = '/api/apps/{app_id}/scale'.format(**locals())\n",
"body = {'web': 0}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 204)\n",
"chaos.START_ERROR_RATE = 0.5\n",
"url = '/api/apps/{app_id}/scale'.format(**locals())\n",
"body = {'web': 20}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 204)\n",
"url = '/api/apps/{app_id}/containers'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(len(response.data['results']), 20)\n",
"states = set([c['state'] for c in response.data['results']])\n",
"self.assertEqual(states, set(['crashed', 'up']))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_36(VAR_11):...\n",
"for VAR_51, VAR_58 in VAR_11.items():\n",
"if isinstance(VAR_58, str) or not isinstance(VAR_58, Iterable):\n",
"VAR_58 = [VAR_58]\n",
"yield [(VAR_51, VAR_16) for VAR_16 in VAR_58]\n"
] | [
"def flatten(wildcards):...\n",
"for wildcard, values in wildcards.items():\n",
"if isinstance(values, str) or not isinstance(values, Iterable):\n",
"values = [values]\n",
"yield [(wildcard, value) for value in values]\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Condition",
"Assign'",
"Expr'"
] |
[
"def FUNC_19(self, VAR_20, VAR_24):...\n",
"if self._connection is None:\n",
"self._connection = self._engine.connect()\n",
"return self._connection.execute(VAR_20, VAR_24)\n"
] | [
"def __execute(self, sql, bindings):...\n",
"if self._connection is None:\n",
"self._connection = self._engine.connect()\n",
"return self._connection.execute(sql, bindings)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_1():...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_9 = 'string'\n",
"VAR_11 = get_cursor()\n",
"VAR_13 = VAR_11.execute(VAR_9).fetchone()[0]\n",
"return VAR_13\n"
] | [
"def get_all_books_count():...\n",
"\"\"\"docstring\"\"\"\n",
"stmt = \"\"\"\n select count(*) from books as b\n left outer join collaborations as c on c.book_id=b.id\n left outer join authors as a on a.id=c.author_id\n left join series as s on s.id=b.series_id\n \"\"\"\n",
"csr = get_cursor()\n",
"count = csr.execute(stmt).fetchone()[0]\n",
"return count\n"
] | [
0,
0,
4,
0,
4,
4
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |