lines
sequencelengths
1
444
raw_lines
sequencelengths
1
444
label
sequencelengths
1
444
type
sequencelengths
1
444
[ "@app.route('/manage/articles', methods=['GET', 'POST'])...\n", "if current_user.is_authenticated:\n", "VAR_8 = ArticleCreateForm()\n", "return redirect('/index')\n", "if VAR_8.validate_on_submit():\n", "VAR_10 = Article(VAR_9=createform.body.data, url=createform.url.data,\n imageurl=createform.imageurl.data, author=current_user)\n", "VAR_4 = FUNC_0('Article')\n", "db.session.add(VAR_10)\n", "return render_template('managearticles.html', VAR_11='Manage Articles',\n VAR_8=createform, items=results)\n", "db.session.commit()\n", "flash('Posted!')\n", "return redirect('/manage/articles')\n" ]
[ "@app.route('/manage/articles', methods=['GET', 'POST'])...\n", "if current_user.is_authenticated:\n", "createform = ArticleCreateForm()\n", "return redirect('/index')\n", "if createform.validate_on_submit():\n", "article = Article(body=createform.body.data, url=createform.url.data,\n imageurl=createform.imageurl.data, author=current_user)\n", "results = get_table_dict('Article')\n", "db.session.add(article)\n", "return render_template('managearticles.html', title='Manage Articles',\n createform=createform, items=results)\n", "db.session.commit()\n", "flash('Posted!')\n", "return redirect('/manage/articles')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Assign'", "Expr'", "Return'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_0(VAR_0, VAR_1):...\n", "VAR_1.execute('string'.format(VAR_0=playlist_id))\n", "VAR_8 = VAR_1.fetchall()\n", "return VAR_8\n" ]
[ "def retrieve_videos_from_playlist(playlist_id, db):...\n", "db.execute(\n 'SELECT id, title, thumbnail, position from video WHERE playlist_id={playlist_id} ORDER BY position ASC;'\n .format(playlist_id=playlist_id))\n", "rows = db.fetchall()\n", "return rows\n" ]
[ 0, 4, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Return'" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self.config.get(self.section, 'raven_dsn')\n" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self.config.get(self.section, 'raven_dsn')\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def FUNC_7(VAR_3):...\n", "if os.path.exists(VAR_3):\n", "if os.path.isdir(VAR_3):\n", "os.remove(VAR_3)\n", "os.removedirs(VAR_3)\n" ]
[ "def remove(file):...\n", "if os.path.exists(file):\n", "if os.path.isdir(file):\n", "os.remove(file)\n", "os.removedirs(file)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_2(self):...\n", "return \"\"\"Task: %s (ID %d)\nFile: %s\n\"\"\" % (self.task[1], self.task[0], repr\n (self.filenames)) + GenericRequest.specific_info(self)\n" ]
[ "def specific_info(self):...\n", "return \"\"\"Task: %s (ID %d)\nFile: %s\n\"\"\" % (self.task[1], self.task[0], repr\n (self.filenames)) + GenericRequest.specific_info(self)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_22(self, *VAR_69, **VAR_70):...\n", "def FUNC_39(VAR_101):...\n", "VAR_101.input = VAR_69, VAR_70\n", "return VAR_101\n" ]
[ "def input(self, *paths, **kwpaths):...\n", "def decorate(ruleinfo):...\n", "ruleinfo.input = paths, kwpaths\n", "return ruleinfo\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_32(self):...\n", "VAR_50 = {}\n", "for VAR_11, VAR_18 in self.userqueues.items():\n", "VAR_54 = VAR_18.qsize()\n", "f.write(pickle.dumps(VAR_50, pickle.HIGHEST_PROTOCOL))\n", "VAR_55 = []\n", "self.log.info('Saved users')\n", "for i in range(VAR_54):\n", "VAR_55.append(VAR_18.get(False))\n", "VAR_50[VAR_11] = VAR_55\n" ]
[ "def save_users(self):...\n", "users = {}\n", "for d, uq in self.userqueues.items():\n", "uqsize = uq.qsize()\n", "f.write(pickle.dumps(users, pickle.HIGHEST_PROTOCOL))\n", "uds = []\n", "self.log.info('Saved users')\n", "for i in range(uqsize):\n", "uds.append(uq.get(False))\n", "users[d] = uds\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Assign'", "Expr'", "Assign'", "Expr'", "For", "Expr'", "Assign'" ]
[ "def FUNC_5(VAR_4, VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "VAR_45 = VAR_46 = None\n", "def FUNC_32(VAR_47):...\n", "VAR_78 = datetime.datetime\n", "if VAR_47 == 'NOW':\n", "return VAR_78.now()\n", "return VAR_78.strptime(VAR_47, '%Y%m%d %H%M%S')\n" ]
[ "def get_value_by_type(val, v_type):...\n", "\"\"\"docstring\"\"\"\n", "value = error = None\n", "def get_time(time):...\n", "date_time = datetime.datetime\n", "if time == 'NOW':\n", "return date_time.now()\n", "return date_time.strptime(time, '%Y%m%d %H%M%S')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "FunctionDef'", "Assign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_4(self, VAR_5):...\n", "VAR_10 = self.guilds[0].roles\n", "return [x for x in VAR_10 if x.name == VAR_5][0]\n" ]
[ "def get_matching_role(self, role_name):...\n", "all_roles = self.guilds[0].roles\n", "return [x for x in all_roles if x.name == role_name][0]\n" ]
[ 0, 0, 2 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "@VAR_0.route('/<page_name>/save', methods=['POST'])...\n", "VAR_7 = request.form.get('content')\n", "VAR_3 = VAR_1.query('string' % VAR_2)\n", "VAR_8 = VAR_3.namedresult()\n", "if len(VAR_8) < 1:\n", "VAR_1.insert('page', {'page_name': VAR_2})\n", "VAR_3 = VAR_1.query(\"select id from page where page_name = '%s'\" % VAR_2)\n", "VAR_9 = VAR_3.namedresult()[0].id\n", "VAR_1.insert('page_content', {'page_id': VAR_9, 'content': VAR_7,\n 'timestamp': time.strftime('%Y-%m-%d %H:%M:%S', localtime())})\n", "return redirect('/%s' % VAR_2)\n" ]
[ "@app.route('/<page_name>/save', methods=['POST'])...\n", "content = request.form.get('content')\n", "query = db.query(\n \"select page_content.content, page.id as page_id, page_content.id as content_id from page, page_content where page.id = page_content.page_id and page.page_name = '%s' order by page_content.id desc limit 1\"\n % page_name)\n", "result = query.namedresult()\n", "if len(result) < 1:\n", "db.insert('page', {'page_name': page_name})\n", "query = db.query(\"select id from page where page_name = '%s'\" % page_name)\n", "page_id = query.namedresult()[0].id\n", "db.insert('page_content', {'page_id': page_id, 'content': content,\n 'timestamp': time.strftime('%Y-%m-%d %H:%M:%S', localtime())})\n", "return redirect('/%s' % page_name)\n" ]
[ 0, 0, 0, 0, 0, 0, 4, 0, 0, 4 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_4(self, VAR_11, VAR_7):...\n", "pq.ops.R(0) | self.reg[0]\n", "pq.ops.All(pq.ops.Measure) | self.reg\n", "self.eng.flush()\n", "if VAR_11 == 'PauliZ':\n", "VAR_21 = self.eng.backend.get_probabilities([self.reg[VAR_7]])\n", "if VAR_11 == 'AllPauliZ':\n", "if '1' in VAR_21:\n", "VAR_21 = self.eng.backend.get_probabilities(self.reg)\n", "return VAR_19\n", "VAR_19 = 2 * VAR_21['1'] - 1\n", "VAR_19 = -(2 * VAR_21['0'] - 1)\n", "VAR_19 = [(2 * sum(p for state, p in VAR_21.items() if state[i] == '1') - 1 -\n (2 * sum(p for state, p in VAR_21.items() if state[i] == '0') - 1)) for\n i in range(len(self.reg))]\n", "VAR_20 = 1 - VAR_19 ** 2\n", "VAR_20 = [(1 - e ** 2) for e in VAR_19]\n" ]
[ "def expectation(self, observable, wires):...\n", "pq.ops.R(0) | self.reg[0]\n", "pq.ops.All(pq.ops.Measure) | self.reg\n", "self.eng.flush()\n", "if observable == 'PauliZ':\n", "probabilities = self.eng.backend.get_probabilities([self.reg[wires]])\n", "if observable == 'AllPauliZ':\n", "if '1' in probabilities:\n", "probabilities = self.eng.backend.get_probabilities(self.reg)\n", "return expectation_value\n", "expectation_value = 2 * probabilities['1'] - 1\n", "expectation_value = -(2 * probabilities['0'] - 1)\n", "expectation_value = [(2 * sum(p for state, p in probabilities.items() if \n state[i] == '1') - 1 - (2 * sum(p for state, p in probabilities.items() if\n state[i] == '0') - 1)) for i in range(len(self.reg))]\n", "variance = 1 - expectation_value ** 2\n", "variance = [(1 - e ** 2) for e in expectation_value]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_24(self):...\n", "VAR_4 = 'hubba-bubba'\n", "VAR_3 = '/afterlogin/'\n", "VAR_10 = self.login(VAR_4, VAR_3)\n", "VAR_22 = 'csrf token'\n", "VAR_32['_csrft_'] = VAR_22\n", "VAR_33 = self.app.dispatch_request()\n", "self.assertEqual(VAR_33.status, '200 OK')\n", "self.assertIn(\n 'https://idp.example.com/simplesaml/saml2/idp/SingleLogoutService.php',\n json.loads(VAR_33.data)['payload']['location'])\n" ]
[ "def test_logout_loggedin(self):...\n", "eppn = 'hubba-bubba'\n", "came_from = '/afterlogin/'\n", "cookie = self.login(eppn, came_from)\n", "csrft = 'csrf token'\n", "session['_csrft_'] = csrft\n", "response2 = self.app.dispatch_request()\n", "self.assertEqual(response2.status, '200 OK')\n", "self.assertIn(\n 'https://idp.example.com/simplesaml/saml2/idp/SingleLogoutService.php',\n json.loads(response2.data)['payload']['location'])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_6(self, VAR_33):...\n", "if not VAR_33:\n", "return\n", "VAR_33 = int(VAR_33)\n", "VAR_101.errors.add(errors.BAD_NUMBER)\n", "if self.min is not None and VAR_33 < self.min:\n", "VAR_33 = self.min\n", "if self.max is not None and VAR_33 > self.max:\n", "return VAR_33\n", "VAR_33 = self.max\n" ]
[ "def run(self, val):...\n", "if not val:\n", "return\n", "val = int(val)\n", "c.errors.add(errors.BAD_NUMBER)\n", "if self.min is not None and val < self.min:\n", "val = self.min\n", "if self.max is not None and val > self.max:\n", "return val\n", "val = self.max\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "Expr'", "Condition", "Assign'", "Condition", "Return'", "Assign'" ]
[ "def FUNC_3(self):...\n", "VAR_3 = ('SELECT jdk_entries.title, jdk_entries.body ' +\n 'FROM jdk_entries ' + 'WHERE jdk_entries.id = ' + self.entry_id + ';')\n", "self.title, self.body = FUNC_0(VAR_3, True)[0]\n", "return None\n" ]
[ "def populate_entry_data(self):...\n", "sql = ('SELECT jdk_entries.title, jdk_entries.body ' + 'FROM jdk_entries ' +\n 'WHERE jdk_entries.id = ' + self.entry_id + ';')\n", "self.title, self.body = db_execute(sql, True)[0]\n", "return None\n" ]
[ 0, 4, 4, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_13(self, VAR_11, VAR_10, VAR_12=False):...\n", "VAR_33 = []\n", "for result in re.findall(VAR_11, VAR_10, re.S):\n", "for line in result.splitlines():\n", "return VAR_33\n", "if not VAR_12:\n", "VAR_70 = line.split(',')\n", "VAR_33.append(line.split()[0])\n", "VAR_33.extend(p.strip() for p in VAR_70 if p.strip())\n" ]
[ "def _regex_sos_help(self, regex, sosinfo, is_list=False):...\n", "res = []\n", "for result in re.findall(regex, sosinfo, re.S):\n", "for line in result.splitlines():\n", "return res\n", "if not is_list:\n", "r = line.split(',')\n", "res.append(line.split()[0])\n", "res.extend(p.strip() for p in r if p.strip())\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "For", "Return'", "Condition", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_4(VAR_0):...\n", "VAR_8 = {'disabled': 0, 'is_stock_item': 1}\n", "if VAR_0.get('item_group'):\n", "VAR_8.update({'item_group': VAR_0['item_group']})\n", "if VAR_0.get('item'):\n", "VAR_8.update({'name': VAR_0['item']})\n", "VAR_3 = frappe.get_all('Item', fields=['name', 'item_group', 'item_name'],\n VAR_0=filters_dict, order_by='name')\n", "return VAR_3\n" ]
[ "def get_items(filters):...\n", "filters_dict = {'disabled': 0, 'is_stock_item': 1}\n", "if filters.get('item_group'):\n", "filters_dict.update({'item_group': filters['item_group']})\n", "if filters.get('item'):\n", "filters_dict.update({'name': filters['item']})\n", "items = frappe.get_all('Item', fields=['name', 'item_group', 'item_name'],\n filters=filters_dict, order_by='name')\n", "return items\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_13():...\n", "VAR_6.info('stats', VAR_52='24d92d16-770e-4088-b769-4020e127a7ff', **self.stats\n )\n" ]
[ "def logStats():...\n", "logger.info('stats', uuid='24d92d16-770e-4088-b769-4020e127a7ff', **self.stats)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_2(self):...\n", "" ]
[ "def tearDown(self):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_28(self, VAR_23):...\n", "return self.mtime > VAR_23\n" ]
[ "def is_newer(self, time):...\n", "return self.mtime > time\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@app.route('/api/server/connect', methods=['PUT'])...\n", "controller.indi_server.connect()\n", "VAR_17 = not timeout(5)(controller.indi_server.is_connected)()\n", "return notify('indi_server', 'indi_server_connect', controller.indi_server.\n to_map(), VAR_17)\n" ]
[ "@app.route('/api/server/connect', methods=['PUT'])...\n", "controller.indi_server.connect()\n", "is_error = not timeout(5)(controller.indi_server.is_connected)()\n", "return notify('indi_server', 'indi_server_connect', controller.indi_server.\n to_map(), is_error)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Assign'", "Return'" ]
[ "from __future__ import unicode_literals\n", "import frappe, unittest\n", "from frappe.model.db_query import DatabaseQuery\n", "from frappe.desk.reportview import get_filters_cond\n", "def FUNC_1(self):...\n", "self.assertTrue({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n limit_page_length=None))\n", "def FUNC_2(self):...\n", "self.assertTrue({'name': 'DocType', 'issingle': 0} in DatabaseQuery(\n 'DocType').execute(fields=['name', 'issingle'], limit_page_length=None))\n", "def FUNC_3(self):...\n", "self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters=[['DocType', 'name', 'like', 'J%']]))\n", "def FUNC_4(self):...\n", "self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters=[{'name': ['like', 'J%']}]))\n", "def FUNC_5(self):...\n", "self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters={'name': ['like', 'J%']}))\n", "def FUNC_6(self):...\n", "self.assertTrue({'name': 'DocField'} in DatabaseQuery('DocType').execute(\n filters={'name': 'DocField'}))\n", "def FUNC_7(self):...\n", "self.assertFalse(DatabaseQuery('DocType').execute(filters={'name': ['in',\n None]}))\n", "self.assertTrue({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters={'name': ['not in', None]}))\n", "for result in [{'name': 'DocType'}, {'name': 'DocField'}]:\n", "self.assertTrue(result in DatabaseQuery('DocType').execute(filters={'name':\n ['in', 'DocType,DocField']}))\n", "for result in [{'name': 'DocType'}, {'name': 'DocField'}]:\n", "self.assertFalse(result in DatabaseQuery('DocType').execute(filters={'name':\n ['not in', 'DocType,DocField']}))\n", "def FUNC_8(self):...\n", "VAR_3 = DatabaseQuery('DocField').execute(filters={'parent': 'DocType'},\n fields=['fieldname', 'fieldtype'], or_filters=[{'fieldtype': 'Table'},\n {'fieldtype': 'Select'}])\n", "self.assertTrue({'fieldtype': 'Table', 'fieldname': 'fields'} in VAR_3)\n", "self.assertTrue({'fieldtype': 'Select', 'fieldname': 'document_type'} in VAR_3)\n", "self.assertFalse({'fieldtype': 'Check', 'fieldname': 'issingle'} in VAR_3)\n", "def FUNC_9(self):...\n", "\"\"\"docstring\"\"\"\n", "frappe.db.sql('delete from tabEvent')\n", "VAR_4 = FUNC_0()\n", "VAR_5 = FUNC_0(VAR_1='2016-07-05 23:59:59')\n", "VAR_6 = FUNC_0(VAR_1='2016-07-06 00:00:00')\n", "VAR_7 = FUNC_0(VAR_1='2016-07-07 23:59:59')\n", "VAR_8 = FUNC_0(VAR_1='2016-07-08 00:00:01')\n", "VAR_3 = DatabaseQuery('Event').execute(filters={'starts_on': ['between',\n None]}, fields=['name'])\n", "self.assertTrue({'name': VAR_5.name} not in VAR_3)\n", "VAR_3 = DatabaseQuery('Event').execute(filters={'starts_on': ['between', [\n '2016-07-06', '2016-07-07']]}, fields=['name'])\n", "self.assertTrue({'name': VAR_6.name} in VAR_3)\n", "self.assertTrue({'name': VAR_7.name} in VAR_3)\n", "self.assertTrue({'name': VAR_5.name} not in VAR_3)\n", "self.assertTrue({'name': VAR_8.name} not in VAR_3)\n", "VAR_3 = DatabaseQuery('Event').execute(filters={'starts_on': ['between', [\n '2016-07-07']]}, fields=['name'])\n", "self.assertTrue({'name': VAR_7.name} in VAR_3)\n", "self.assertTrue({'name': VAR_8.name} in VAR_3)\n", "self.assertTrue({'name': VAR_4.name} in VAR_3)\n", "self.assertTrue({'name': VAR_5.name} not in VAR_3)\n", "self.assertTrue({'name': VAR_6.name} not in VAR_3)\n", "def FUNC_10(self):...\n", "frappe.set_user('[email protected]')\n", "self.assertRaises(frappe.PermissionError, get_filters_cond, 'DocType', dict\n (istable=1), [])\n", "self.assertTrue(get_filters_cond('DocType', dict(istable=1), [],\n ignore_permissions=True))\n", "frappe.set_user('Administrator')\n", "def FUNC_11(self):...\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name', 'issingle, version()'], limit_start=0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name',\n 'issingle, IF(issingle=1, (select name from tabUser), count(name))'],\n limit_start=0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name', 'issingle, (select count(*) from tabSessions)'],\n limit_start=0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name',\n \"issingle, SELECT LOCATE('', `tabUser`.`user`) AS user;\"], limit_start=\n 0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name',\n 'issingle, IF(issingle=1, (SELECT name from tabUser), count(*))'],\n limit_start=0, limit_page_length=1)\n", "VAR_3 = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n 'count(name)'], limit_start=0, limit_page_length=1)\n", "self.assertTrue('count(name)' in VAR_3[0])\n", "VAR_3 = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n \"locate('', name) as _relevance\"], limit_start=0, limit_page_length=1)\n", "self.assertTrue('_relevance' in VAR_3[0])\n", "VAR_3 = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n 'date(creation) as creation'], limit_start=0, limit_page_length=1)\n", "self.assertTrue('creation' in VAR_3[0])\n", "VAR_3 = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n 'datediff(modified, creation) as date_diff'], limit_start=0,\n limit_page_length=1)\n", "self.assertTrue('date_diff' in VAR_3[0])\n", "def FUNC_0(VAR_0='_Test Event', VAR_1=None):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.utils import get_datetime\n", "VAR_2 = frappe.get_doc({'doctype': 'Event', 'subject': VAR_0, 'event_type':\n 'Public', 'starts_on': get_datetime(VAR_1)}).insert(ignore_permissions=True\n )\n", "return VAR_2\n" ]
[ "from __future__ import unicode_literals\n", "import frappe, unittest\n", "from frappe.model.db_query import DatabaseQuery\n", "from frappe.desk.reportview import get_filters_cond\n", "def test_basic(self):...\n", "self.assertTrue({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n limit_page_length=None))\n", "def test_fields(self):...\n", "self.assertTrue({'name': 'DocType', 'issingle': 0} in DatabaseQuery(\n 'DocType').execute(fields=['name', 'issingle'], limit_page_length=None))\n", "def test_filters_1(self):...\n", "self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters=[['DocType', 'name', 'like', 'J%']]))\n", "def test_filters_2(self):...\n", "self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters=[{'name': ['like', 'J%']}]))\n", "def test_filters_3(self):...\n", "self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters={'name': ['like', 'J%']}))\n", "def test_filters_4(self):...\n", "self.assertTrue({'name': 'DocField'} in DatabaseQuery('DocType').execute(\n filters={'name': 'DocField'}))\n", "def test_in_not_in_filters(self):...\n", "self.assertFalse(DatabaseQuery('DocType').execute(filters={'name': ['in',\n None]}))\n", "self.assertTrue({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters={'name': ['not in', None]}))\n", "for result in [{'name': 'DocType'}, {'name': 'DocField'}]:\n", "self.assertTrue(result in DatabaseQuery('DocType').execute(filters={'name':\n ['in', 'DocType,DocField']}))\n", "for result in [{'name': 'DocType'}, {'name': 'DocField'}]:\n", "self.assertFalse(result in DatabaseQuery('DocType').execute(filters={'name':\n ['not in', 'DocType,DocField']}))\n", "def test_or_filters(self):...\n", "data = DatabaseQuery('DocField').execute(filters={'parent': 'DocType'},\n fields=['fieldname', 'fieldtype'], or_filters=[{'fieldtype': 'Table'},\n {'fieldtype': 'Select'}])\n", "self.assertTrue({'fieldtype': 'Table', 'fieldname': 'fields'} in data)\n", "self.assertTrue({'fieldtype': 'Select', 'fieldname': 'document_type'} in data)\n", "self.assertFalse({'fieldtype': 'Check', 'fieldname': 'issingle'} in data)\n", "def test_between_filters(self):...\n", "\"\"\"docstring\"\"\"\n", "frappe.db.sql('delete from tabEvent')\n", "todays_event = create_event()\n", "event1 = create_event(starts_on='2016-07-05 23:59:59')\n", "event2 = create_event(starts_on='2016-07-06 00:00:00')\n", "event3 = create_event(starts_on='2016-07-07 23:59:59')\n", "event4 = create_event(starts_on='2016-07-08 00:00:01')\n", "data = DatabaseQuery('Event').execute(filters={'starts_on': ['between',\n None]}, fields=['name'])\n", "self.assertTrue({'name': event1.name} not in data)\n", "data = DatabaseQuery('Event').execute(filters={'starts_on': ['between', [\n '2016-07-06', '2016-07-07']]}, fields=['name'])\n", "self.assertTrue({'name': event2.name} in data)\n", "self.assertTrue({'name': event3.name} in data)\n", "self.assertTrue({'name': event1.name} not in data)\n", "self.assertTrue({'name': event4.name} not in data)\n", "data = DatabaseQuery('Event').execute(filters={'starts_on': ['between', [\n '2016-07-07']]}, fields=['name'])\n", "self.assertTrue({'name': event3.name} in data)\n", "self.assertTrue({'name': event4.name} in data)\n", "self.assertTrue({'name': todays_event.name} in data)\n", "self.assertTrue({'name': event1.name} not in data)\n", "self.assertTrue({'name': event2.name} not in data)\n", "def test_ignore_permissions_for_get_filters_cond(self):...\n", "frappe.set_user('[email protected]')\n", "self.assertRaises(frappe.PermissionError, get_filters_cond, 'DocType', dict\n (istable=1), [])\n", "self.assertTrue(get_filters_cond('DocType', dict(istable=1), [],\n ignore_permissions=True))\n", "frappe.set_user('Administrator')\n", "def test_query_fields_sanitizer(self):...\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name', 'issingle, version()'], limit_start=0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name',\n 'issingle, IF(issingle=1, (select name from tabUser), count(name))'],\n limit_start=0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name', 'issingle, (select count(*) from tabSessions)'],\n limit_start=0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name',\n \"issingle, SELECT LOCATE('', `tabUser`.`user`) AS user;\"], limit_start=\n 0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name',\n 'issingle, IF(issingle=1, (SELECT name from tabUser), count(*))'],\n limit_start=0, limit_page_length=1)\n", "data = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n 'count(name)'], limit_start=0, limit_page_length=1)\n", "self.assertTrue('count(name)' in data[0])\n", "data = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n \"locate('', name) as _relevance\"], limit_start=0, limit_page_length=1)\n", "self.assertTrue('_relevance' in data[0])\n", "data = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n 'date(creation) as creation'], limit_start=0, limit_page_length=1)\n", "self.assertTrue('creation' in data[0])\n", "data = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n 'datediff(modified, creation) as date_diff'], limit_start=0,\n limit_page_length=1)\n", "self.assertTrue('date_diff' in data[0])\n", "def create_event(subject='_Test Event', starts_on=None):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.utils import get_datetime\n", "event = frappe.get_doc({'doctype': 'Event', 'subject': subject,\n 'event_type': 'Public', 'starts_on': get_datetime(starts_on)}).insert(\n ignore_permissions=True)\n", "return event\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, 4 ]
[ "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "For", "Expr'", "For", "Expr'", "FunctionDef'", "Assign'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "FunctionDef'", "Docstring", "ImportFrom'", "Assign'", "Return'" ]
[ "def FUNC_21(VAR_55):...\n", "@wraps(VAR_55)...\n", "VAR_70['timer'] = CLASS_2(VAR_25)\n", "return VAR_55(*VAR_69, **kwargs)\n" ]
[ "def decorator(func):...\n", "@wraps(func)...\n", "kwargs['timer'] = Timer(name)\n", "return func(*args, **kwargs)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Return'" ]
[ "def FUNC_7(self, VAR_2, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_16 = []\n", "if os.path.exists(VAR_2):\n", "for pyfile in sorted(os.listdir(VAR_2)):\n", "return VAR_16\n", "if not pyfile.endswith('.py'):\n", "if '__' in pyfile:\n", "VAR_27, VAR_28 = os.path.splitext(pyfile)\n", "VAR_1 = 'soscollector.%s.%s' % (VAR_3, VAR_27)\n", "VAR_16.extend(self._import_modules(VAR_1))\n" ]
[ "def _find_modules_in_path(self, path, modulename):...\n", "\"\"\"docstring\"\"\"\n", "modules = []\n", "if os.path.exists(path):\n", "for pyfile in sorted(os.listdir(path)):\n", "return modules\n", "if not pyfile.endswith('.py'):\n", "if '__' in pyfile:\n", "fname, ext = os.path.splitext(pyfile)\n", "modname = 'soscollector.%s.%s' % (modulename, fname)\n", "modules.extend(self._import_modules(modname))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "For", "Return'", "Condition", "Condition", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_5(self, VAR_10=None, VAR_11=None, VAR_1=None):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_10 is None:\n", "VAR_10 = str(len(self._rules) + 1)\n", "if self.is_rule(VAR_10):\n", "VAR_13 = Rule(VAR_10, self, VAR_11=lineno, VAR_1=snakefile)\n", "self._rules[VAR_13.name] = VAR_13\n", "self.rule_count += 1\n", "if not self.first_rule:\n", "self.first_rule = VAR_13.name\n", "return VAR_10\n" ]
[ "def add_rule(self, name=None, lineno=None, snakefile=None):...\n", "\"\"\"docstring\"\"\"\n", "if name is None:\n", "name = str(len(self._rules) + 1)\n", "if self.is_rule(name):\n", "rule = Rule(name, self, lineno=lineno, snakefile=snakefile)\n", "self._rules[rule.name] = rule\n", "self.rule_count += 1\n", "if not self.first_rule:\n", "self.first_rule = rule.name\n", "return name\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "AugAssign'", "Condition", "Assign'", "Return'" ]
[ "def FUNC_0(self):...\n", "if self.check_xsrf_cookie() == False:\n", "return self.redirect('ftypeerror')\n" ]
[ "def check_xsrf(self):...\n", "if self.check_xsrf_cookie() == False:\n", "return self.redirect('ftypeerror')\n" ]
[ 0, 0, 5 ]
[ "FunctionDef'", "Condition", "Return'" ]
[ "from __future__ import unicode_literals\n", "import frappe, json\n", "from frappe.utils import cstr, unique\n", "from frappe import _\n", "from six import string_types\n", "def FUNC_0(VAR_0):...\n", "VAR_12 = ['select', 'delete', 'drop', 'update', 'case', 'and', 'or', 'like']\n", "def FUNC_6():...\n", "VAR_13.throw(_('Invalid Search Field'), VAR_13.DataError)\n", "if len(VAR_0) >= 3:\n", "if '=' in VAR_0:\n", "@VAR_13.whitelist()...\n", "FUNC_6()\n", "if ' --' in VAR_0:\n", "FUNC_2(VAR_1, VAR_2, VAR_3, VAR_0=searchfield, VAR_5=page_length, VAR_4=filters\n )\n", "FUNC_6()\n", "if any(' {0} '.format(keyword) in VAR_0.split() for keyword in VAR_12):\n", "VAR_13.response['results'] = FUNC_4(VAR_13.response['values'])\n", "FUNC_6()\n", "if any(keyword in VAR_0.split() for keyword in VAR_12):\n", "@VAR_13.whitelist()...\n", "FUNC_6()\n", "if isinstance(VAR_4, string_types):\n", "VAR_4 = json.loads(VAR_4)\n", "VAR_9 = VAR_13.get_meta(VAR_1)\n", "if VAR_0:\n", "FUNC_0(VAR_0)\n", "if not VAR_0:\n", "VAR_0 = 'name'\n", "VAR_14 = VAR_13.get_hooks().standard_queries or {}\n", "if VAR_3 and VAR_3.split()[0].lower() != 'select':\n", "VAR_13.response['values'] = VAR_13.call(VAR_3, VAR_1, VAR_2, VAR_0, VAR_6,\n VAR_5, VAR_4, VAR_8=as_dict)\n", "if not VAR_3 and VAR_1 in VAR_14:\n", "def FUNC_3(VAR_9, VAR_10):...\n", "FUNC_2(VAR_1, VAR_2, VAR_14[VAR_1][0], VAR_0, VAR_6, VAR_5, VAR_4)\n", "if VAR_3:\n", "VAR_15 = VAR_9.search_fields and VAR_9.search_fields.split(',') or []\n", "VAR_13.throw(_('This query style is discontinued'))\n", "if isinstance(VAR_4, dict):\n", "VAR_16 = [VAR_9.title_field\n ] if VAR_9.title_field and VAR_9.title_field not in VAR_15 else []\n", "VAR_25 = VAR_4.items()\n", "if VAR_4 == None:\n", "VAR_15 = ['name'] + VAR_15 + VAR_16\n", "VAR_4 = []\n", "VAR_4 = []\n", "VAR_19 = []\n", "if not VAR_10 in VAR_15:\n", "for f in VAR_25:\n", "if VAR_2:\n", "VAR_15 = VAR_15 + [VAR_10]\n", "return VAR_15\n", "if isinstance(f[1], (list, tuple)):\n", "VAR_26 = ['name']\n", "if VAR_9.get('fields', {'fieldname': 'enabled', 'fieldtype': 'Check'}):\n", "VAR_4.append([VAR_1, f[0], f[1][0], f[1][1]])\n", "VAR_4.append([VAR_1, f[0], '=', f[1]])\n", "if VAR_9.title_field:\n", "VAR_4.append([VAR_1, 'enabled', '=', 1])\n", "if VAR_9.get('fields', {'fieldname': 'disabled', 'fieldtype': 'Check'}):\n", "VAR_26.append(VAR_9.title_field)\n", "if VAR_9.search_fields:\n", "VAR_4.append([VAR_1, 'disabled', '!=', 1])\n", "VAR_20 = FUNC_3(VAR_9, VAR_0 or 'name')\n", "VAR_26.extend(VAR_9.get_search_fields())\n", "for f in VAR_26:\n", "if VAR_7:\n", "VAR_27 = VAR_9.get_field(f.strip())\n", "VAR_20 = list(set(VAR_20 + json.loads(VAR_7)))\n", "VAR_21 = [('`tab%s`.`%s`' % (VAR_9.name, f.strip())) for f in VAR_20]\n", "if f == 'name' or VAR_27 and VAR_27.fieldtype in ['Data', 'Text',\n", "VAR_21.append('locate(\"{_txt}\", `tab{doctype}`.`name`) as `_relevance`'.\n format(_txt=frappe.db.escape((txt or '').replace('%', '')), VAR_1=\n frappe.db.escape(doctype)))\n", "VAR_19.append([VAR_1, f.strip(), 'like', '%{0}%'.format(VAR_2)])\n", "from frappe.model.db_query import get_order_by\n", "VAR_22 = get_order_by(VAR_1, VAR_9)\n", "VAR_23 = 'if(_relevance, _relevance, 99999), `tab{0}`.idx desc, {1}'.format(\n VAR_1, VAR_22)\n", "VAR_24 = VAR_13.get_list(VAR_1, VAR_4=filters, VAR_20=formatted_fields,\n VAR_19=or_filters, limit_start=start, limit_page_length=page_length,\n VAR_23=order_by, ignore_permissions=True if doctype == 'DocType' else \n False, as_list=not as_dict)\n", "if VAR_8:\n", "for r in VAR_24:\n", "VAR_13.response['values'] = [r[:-1] for r in VAR_24]\n", "r.pop('_relevance')\n", "VAR_13.response['values'] = VAR_24\n" ]
[ "from __future__ import unicode_literals\n", "import frappe, json\n", "from frappe.utils import cstr, unique\n", "from frappe import _\n", "from six import string_types\n", "def sanitize_searchfield(searchfield):...\n", "blacklisted_keywords = ['select', 'delete', 'drop', 'update', 'case', 'and',\n 'or', 'like']\n", "def _raise_exception():...\n", "frappe.throw(_('Invalid Search Field'), frappe.DataError)\n", "if len(searchfield) >= 3:\n", "if '=' in searchfield:\n", "@frappe.whitelist()...\n", "_raise_exception()\n", "if ' --' in searchfield:\n", "search_widget(doctype, txt, query, searchfield=searchfield, page_length=\n page_length, filters=filters)\n", "_raise_exception()\n", "if any(' {0} '.format(keyword) in searchfield.split() for keyword in\n", "frappe.response['results'] = build_for_autosuggest(frappe.response['values'])\n", "_raise_exception()\n", "if any(keyword in searchfield.split() for keyword in blacklisted_keywords):\n", "@frappe.whitelist()...\n", "_raise_exception()\n", "if isinstance(filters, string_types):\n", "filters = json.loads(filters)\n", "meta = frappe.get_meta(doctype)\n", "if searchfield:\n", "sanitize_searchfield(searchfield)\n", "if not searchfield:\n", "searchfield = 'name'\n", "standard_queries = frappe.get_hooks().standard_queries or {}\n", "if query and query.split()[0].lower() != 'select':\n", "frappe.response['values'] = frappe.call(query, doctype, txt, searchfield,\n start, page_length, filters, as_dict=as_dict)\n", "if not query and doctype in standard_queries:\n", "def get_std_fields_list(meta, key):...\n", "search_widget(doctype, txt, standard_queries[doctype][0], searchfield,\n start, page_length, filters)\n", "if query:\n", "sflist = meta.search_fields and meta.search_fields.split(',') or []\n", "frappe.throw(_('This query style is discontinued'))\n", "if isinstance(filters, dict):\n", "title_field = [meta.title_field\n ] if meta.title_field and meta.title_field not in sflist else []\n", "filters_items = filters.items()\n", "if filters == None:\n", "sflist = ['name'] + sflist + title_field\n", "filters = []\n", "filters = []\n", "or_filters = []\n", "if not key in sflist:\n", "for f in filters_items:\n", "if txt:\n", "sflist = sflist + [key]\n", "return sflist\n", "if isinstance(f[1], (list, tuple)):\n", "search_fields = ['name']\n", "if meta.get('fields', {'fieldname': 'enabled', 'fieldtype': 'Check'}):\n", "filters.append([doctype, f[0], f[1][0], f[1][1]])\n", "filters.append([doctype, f[0], '=', f[1]])\n", "if meta.title_field:\n", "filters.append([doctype, 'enabled', '=', 1])\n", "if meta.get('fields', {'fieldname': 'disabled', 'fieldtype': 'Check'}):\n", "search_fields.append(meta.title_field)\n", "if meta.search_fields:\n", "filters.append([doctype, 'disabled', '!=', 1])\n", "fields = get_std_fields_list(meta, searchfield or 'name')\n", "search_fields.extend(meta.get_search_fields())\n", "for f in search_fields:\n", "if filter_fields:\n", "fmeta = meta.get_field(f.strip())\n", "fields = list(set(fields + json.loads(filter_fields)))\n", "formatted_fields = [('`tab%s`.`%s`' % (meta.name, f.strip())) for f in fields]\n", "if f == 'name' or fmeta and fmeta.fieldtype in ['Data', 'Text',\n", "formatted_fields.append(\n 'locate(\"{_txt}\", `tab{doctype}`.`name`) as `_relevance`'.format(_txt=\n frappe.db.escape((txt or '').replace('%', '')), doctype=frappe.db.\n escape(doctype)))\n", "or_filters.append([doctype, f.strip(), 'like', '%{0}%'.format(txt)])\n", "from frappe.model.db_query import get_order_by\n", "order_by_based_on_meta = get_order_by(doctype, meta)\n", "order_by = 'if(_relevance, _relevance, 99999), `tab{0}`.idx desc, {1}'.format(\n doctype, order_by_based_on_meta)\n", "values = frappe.get_list(doctype, filters=filters, fields=formatted_fields,\n or_filters=or_filters, limit_start=start, limit_page_length=page_length,\n order_by=order_by, ignore_permissions=True if doctype == 'DocType' else\n False, as_list=not as_dict)\n", "if as_dict:\n", "for r in values:\n", "frappe.response['values'] = [r[:-1] for r in values]\n", "r.pop('_relevance')\n", "frappe.response['values'] = values\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "FunctionDef'", "Expr'", "Condition", "Condition", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "For", "Assign'", "Expr'", "For", "Condition", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "FunctionDef'", "Expr'", "Condition", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "For", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Assign'", "Expr'", "For", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Condition", "For", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_22(self):...\n", "VAR_14 = self.new_mocked_client(client.NSX3Client)\n", "VAR_14.update('ports/1', {'name': 'a-new-name'})\n", "FUNC_2('put', VAR_14, 'https://1.2.3.4/api/v1/ports/1', VAR_8=jsonutils.\n dumps({'name': 'a-new-name'}))\n" ]
[ "def test_update_resource(self):...\n", "api = self.new_mocked_client(client.NSX3Client)\n", "api.update('ports/1', {'name': 'a-new-name'})\n", "assert_json_call('put', api, 'https://1.2.3.4/api/v1/ports/1', data=\n jsonutils.dumps({'name': 'a-new-name'}))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_26(VAR_51, VAR_52):...\n", "for sub_ in VAR_51.sub_items:\n", "FUNC_26(sub_, VAR_52)\n", "VAR_51.owner = VAR_52\n", "if VAR_51.is_dir:\n", "self._update_in_db(VAR_51)\n", "return\n" ]
[ "def _chown_recursive(item_, owner_):...\n", "for sub_ in item_.sub_items:\n", "_chown_recursive(sub_, owner_)\n", "item_.owner = owner_\n", "if item_.is_dir:\n", "self._update_in_db(item_)\n", "return\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Expr'", "Assign'", "Condition", "Expr'", "Return'" ]
[ "@VAR_0.route('/clear')...\n", "" ]
[ "@app.route('/clear')...\n", "" ]
[ 0, 0 ]
[ "Condition", "Condition" ]
[ "def FUNC_6(VAR_6):...\n", "assert VAR_6 == VAR_3\n", "return VAR_0\n" ]
[ "def _os_walk(path):...\n", "assert path == mock_path\n", "return MOCK_PATHS\n" ]
[ 0, 0, 1 ]
[ "FunctionDef'", "Assert'", "Return'" ]
[ "def FUNC_1(VAR_2: Profile, VAR_3: str, VAR_4: str, VAR_5: str, VAR_6):...\n", "m: Media = Media()\n", "upload_base_path: str = 'uploads/' + str(date.today().year)\n", "VAR_7 = upload_base_path + '/HIGHRES_' + ntpath.basename(VAR_6.name.replace\n (' ', '_'))\n", "VAR_8 = upload_base_path + '/LOWRES_' + ntpath.basename(VAR_6.name.replace(\n ' ', '_'))\n", "if not os.path.exists(PATH_TO_UPLOAD_FOLDER_ON_DISK + upload_base_path):\n", "os.makedirs(PATH_TO_UPLOAD_FOLDER_ON_DISK + upload_base_path)\n", "for chunk in VAR_6.chunks():\n", "destination.write(chunk)\n", "VAR_9 = Image.open(VAR_7)\n", "VAR_10, VAR_11 = VAR_9.size\n", "VAR_12 = math.sqrt(math.pow(VAR_10, 2) + math.pow(VAR_11, 2))\n", "VAR_10 /= VAR_12\n", "VAR_11 /= VAR_12\n", "VAR_10 *= VAR_0\n", "VAR_11 *= VAR_0\n", "VAR_13 = VAR_9.resize((int(VAR_10), int(VAR_11)), PIL.Image.LANCZOS)\n", "VAR_13.save(VAR_8)\n", "m.text = VAR_5\n", "m.cachedText = compile_markdown(VAR_5)\n", "m.category = VAR_4\n", "m.highResFile = '/' + VAR_7\n", "m.lowResFile = '/' + VAR_8\n", "m.headline = VAR_3\n", "m.save()\n", "mu: MediaUpload = MediaUpload()\n", "mu.UID = VAR_2\n", "mu.MID = m\n", "mu.save()\n", "logging.info(\"Uploaded file '\" + str(VAR_6.name) +\n \"' and cropped it. The resulting PK is \" + str(m.pk))\n" ]
[ "def handle_file(u: Profile, headline: str, category: str, text: str, file):...\n", "m: Media = Media()\n", "upload_base_path: str = 'uploads/' + str(date.today().year)\n", "high_res_file_name = upload_base_path + '/HIGHRES_' + ntpath.basename(file.\n name.replace(' ', '_'))\n", "low_res_file_name = upload_base_path + '/LOWRES_' + ntpath.basename(file.\n name.replace(' ', '_'))\n", "if not os.path.exists(PATH_TO_UPLOAD_FOLDER_ON_DISK + upload_base_path):\n", "os.makedirs(PATH_TO_UPLOAD_FOLDER_ON_DISK + upload_base_path)\n", "for chunk in file.chunks():\n", "destination.write(chunk)\n", "original = Image.open(high_res_file_name)\n", "width, height = original.size\n", "diameter = math.sqrt(math.pow(width, 2) + math.pow(height, 2))\n", "width /= diameter\n", "height /= diameter\n", "width *= IMAGE_SCALE\n", "height *= IMAGE_SCALE\n", "cropped = original.resize((int(width), int(height)), PIL.Image.LANCZOS)\n", "cropped.save(low_res_file_name)\n", "m.text = text\n", "m.cachedText = compile_markdown(text)\n", "m.category = category\n", "m.highResFile = '/' + high_res_file_name\n", "m.lowResFile = '/' + low_res_file_name\n", "m.headline = headline\n", "m.save()\n", "mu: MediaUpload = MediaUpload()\n", "mu.UID = u\n", "mu.MID = m\n", "mu.save()\n", "logging.info(\"Uploaded file '\" + str(file.name) +\n \"' and cropped it. The resulting PK is \" + str(m.pk))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 3, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "AnnAssign'", "AnnAssign'", "Assign'", "Assign'", "Condition", "Expr'", "For", "Expr'", "Assign'", "Assign'", "Assign'", "AugAssign'", "AugAssign'", "AugAssign'", "AugAssign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "AnnAssign'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_3(VAR_4):...\n", "VAR_14 = VAR_1.confs\n", "VAR_15 = {'email': VAR_9, 'hash': hashlib.sha1(VAR_9 + VAR_3).hexdigest()}\n", "VAR_14.insert(VAR_15)\n", "send_mail('[FreeMail] Email Confirmation', \n 'Confirm your account by clicking on the following link: ' +\n '<a href=\"localhost:5000/confirm/' + VAR_9 + '/' + VAR_15['hash'] +\n '\">Here</a>', '[email protected]', [VAR_9], fail_silently=False)\n", "return HttpResponse('Confirmation page created')\n" ]
[ "def sendConf(request):...\n", "confs = db.confs\n", "new_conf = {'email': email, 'hash': hashlib.sha1(email + SALT).hexdigest()}\n", "confs.insert(new_conf)\n", "send_mail('[FreeMail] Email Confirmation', \n 'Confirm your account by clicking on the following link: ' +\n '<a href=\"localhost:5000/confirm/' + email + '/' + new_conf['hash'] +\n '\">Here</a>', '[email protected]', [email], fail_silently=False)\n", "return HttpResponse('Confirmation page created')\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "@staticmethod...\n", "if VAR_5 is None or VAR_8 is None:\n", "return dict()\n", "VAR_11 = CLASS_1.get_fields(VAR_5)\n", "return dict(zip(VAR_11, list(VAR_8)))\n" ]
[ "@staticmethod...\n", "if cursor is None or query_set is None:\n", "return dict()\n", "fields = DBManager.get_fields(cursor)\n", "return dict(zip(fields, list(query_set)))\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Return'", "Assign'", "Return'" ]
[ "def FUNC_3(VAR_3):...\n", "VAR_25 = {'COMPILATION_ERROR': 0, 'OK': 0, 'TIME_LIMIT_EXCEEDED': 0,\n 'WRONG_ANSWER': 0, 'RUNTIME_ERROR': 0, 'MEMORY_LIMIT_EXCEEDED': 0}\n", "VAR_26 = ['red', 'green', 'tan', 'blue', 'purple', 'orange']\n", "VAR_8 = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) +\n '\\\\users\\\\' + VAR_3 + '.db')\n", "VAR_9 = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + '\\\\cf.db')\n", "VAR_10 = VAR_8.cursor()\n", "VAR_11 = VAR_9.cursor()\n", "VAR_27 = 0\n", "VAR_18 = list()\n", "VAR_19 = list()\n", "for i in VAR_0:\n", "VAR_11.execute('SELECT * FROM ' + str(i))\n", "for i in VAR_25.keys():\n", "VAR_14 = VAR_11.fetchone()\n", "VAR_18.append(i)\n", "VAR_22, VAR_23 = plt.subplots()\n", "while VAR_14 != None:\n", "VAR_19.append(VAR_25[i])\n", "VAR_23.pie(VAR_19, labels=b, VAR_26=colors, shadow=True, startangle=90)\n", "VAR_10.execute(\"SELECT * FROM result WHERE problem = '\" + str(VAR_14[0]) +\n \"' AND diff = '\" + str(VAR_14[1]) + \"'\")\n", "VAR_23.axis('equal')\n", "VAR_31 = VAR_10.fetchone()\n", "VAR_23.legend(VAR_18)\n", "if VAR_31 != None:\n", "VAR_23.set_title(\n 'How many different verdict in last status of problem you have: ')\n", "for j in VAR_25.keys():\n", "VAR_14 = VAR_11.fetchone()\n", "VAR_24 = os.path.join(os.path.abspath(os.path.dirname(__file__)) +\n '\\\\users\\\\', VAR_3 + '.png')\n", "if VAR_31[2] == j:\n", "if os.path.exists(VAR_24):\n", "VAR_25[j] += 1\n", "os.remove(VAR_24)\n", "plt.savefig(os.path.abspath(os.path.dirname(__file__)) + '\\\\users\\\\' +\n VAR_3 + '.png')\n", "VAR_27 += 1\n", "VAR_8.close()\n", "VAR_9.close()\n", "plt.close()\n", "VAR_15 = VAR_3 + ' has at least one submissions in ' + str(VAR_27\n ) + ' problems'\n", "return VAR_15\n" ]
[ "def create_text_stats(username):...\n", "verdict = {'COMPILATION_ERROR': 0, 'OK': 0, 'TIME_LIMIT_EXCEEDED': 0,\n 'WRONG_ANSWER': 0, 'RUNTIME_ERROR': 0, 'MEMORY_LIMIT_EXCEEDED': 0}\n", "colors = ['red', 'green', 'tan', 'blue', 'purple', 'orange']\n", "conn = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) +\n '\\\\users\\\\' + username + '.db')\n", "conn2 = sqlite3.connect(os.path.abspath(os.path.dirname(__file__)) + '\\\\cf.db')\n", "cursor = conn.cursor()\n", "cursor2 = conn2.cursor()\n", "count = 0\n", "a = list()\n", "b = list()\n", "for i in available_tags:\n", "cursor2.execute('SELECT * FROM ' + str(i))\n", "for i in verdict.keys():\n", "x = cursor2.fetchone()\n", "a.append(i)\n", "fig1, ax1 = plt.subplots()\n", "while x != None:\n", "b.append(verdict[i])\n", "ax1.pie(b, labels=b, colors=colors, shadow=True, startangle=90)\n", "cursor.execute(\"SELECT * FROM result WHERE problem = '\" + str(x[0]) +\n \"' AND diff = '\" + str(x[1]) + \"'\")\n", "ax1.axis('equal')\n", "y = cursor.fetchone()\n", "ax1.legend(a)\n", "if y != None:\n", "ax1.set_title('How many different verdict in last status of problem you have: '\n )\n", "for j in verdict.keys():\n", "x = cursor2.fetchone()\n", "path = os.path.join(os.path.abspath(os.path.dirname(__file__)) +\n '\\\\users\\\\', username + '.png')\n", "if y[2] == j:\n", "if os.path.exists(path):\n", "verdict[j] += 1\n", "os.remove(path)\n", "plt.savefig(os.path.abspath(os.path.dirname(__file__)) + '\\\\users\\\\' +\n username + '.png')\n", "count += 1\n", "conn.close()\n", "conn2.close()\n", "plt.close()\n", "s = username + ' has at least one submissions in ' + str(count) + ' problems'\n", "return s\n" ]
[ 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 4, 4, 4, 4, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Expr'", "For", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Condition", "Expr'", "For", "Assign'", "Assign'", "Condition", "Condition", "AugAssign'", "Expr'", "Expr'", "AugAssign'", "Expr'", "Expr'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_1(*, VAR_1=(1, 1), VAR_2=(5000, 5000), VAR_3=0):...\n", "VAR_7 = deque([VAR_1])\n", "VAR_8 = {VAR_1: 0}\n", "while VAR_7:\n", "VAR_0 = VAR_7.popleft()\n", "return len(list(filter(lambda c: c <= VAR_3, VAR_8.values())))\n", "for delta in ((-1, 0), (1, 0), (0, -1), (0, 1)):\n", "VAR_9 = tuple(map(operator.add, VAR_0, delta))\n", "VAR_10 = VAR_8[VAR_0] + 1\n", "if FUNC_0(VAR_9):\n", "if VAR_9 == VAR_2:\n", "return VAR_10\n", "if VAR_9 not in VAR_8 or VAR_8[VAR_9] > VAR_10:\n", "VAR_8[VAR_9] = VAR_10\n", "VAR_7.append(VAR_9)\n" ]
[ "def search(*, start=(1, 1), target=(5000, 5000), count=0):...\n", "q = deque([start])\n", "costs = {start: 0}\n", "while q:\n", "location = q.popleft()\n", "return len(list(filter(lambda c: c <= count, costs.values())))\n", "for delta in ((-1, 0), (1, 0), (0, -1), (0, 1)):\n", "neighbor = tuple(map(operator.add, location, delta))\n", "cost = costs[location] + 1\n", "if isopen(neighbor):\n", "if neighbor == target:\n", "return cost\n", "if neighbor not in costs or costs[neighbor] > cost:\n", "costs[neighbor] = cost\n", "q.append(neighbor)\n" ]
[ 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "For", "Assign'", "Assign'", "Condition", "Condition", "Return'", "Condition", "Assign'", "Expr'" ]
[ "@tornado.gen.coroutine...\n", "VAR_17 = 'string'\n", "VAR_18 = FUNC_12(VAR_10, 'date'), '%d.%m.%Y', FUNC_12(VAR_10,\n 'temp_average_air'), FUNC_12(VAR_10, 'temp_average_water'), FUNC_12(VAR_10,\n 'expected_temp_air_day'), FUNC_12(VAR_10, 'expected_temp_air_night'\n ), FUNC_12(VAR_10, 'expected_temp_air_all_day'), FUNC_12(VAR_10,\n 'forecast_date'), '%d.%m.%Y', FUNC_12(VAR_10, 'forecast_weather'), FUNC_12(\n VAR_10, 'forecast_direction'), FUNC_12(VAR_10, 'forecast_speed'), FUNC_12(\n VAR_10, 'forecast_temp_day_from'), FUNC_12(VAR_10, 'forecast_temp_day_to'\n ), FUNC_12(VAR_10, 'forecast_temp_night_from'), FUNC_12(VAR_10,\n 'forecast_temp_night_to')\n", "yield VAR_1.execute(query=sql, VAR_18=params)\n" ]
[ "@tornado.gen.coroutine...\n", "sql = (\n 'INSERT INTO reports VALUES (NULL, STR_TO_DATE(%s, %s), %s, %s, %s, %s, %s, STR_TO_DATE(%s, %s), %s, %s, %s, %s, %s, %s, %s)'\n )\n", "params = get_safe_val(src, 'date'), '%d.%m.%Y', get_safe_val(src,\n 'temp_average_air'), get_safe_val(src, 'temp_average_water'), get_safe_val(\n src, 'expected_temp_air_day'), get_safe_val(src, 'expected_temp_air_night'\n ), get_safe_val(src, 'expected_temp_air_all_day'), get_safe_val(src,\n 'forecast_date'), '%d.%m.%Y', get_safe_val(src, 'forecast_weather'\n ), get_safe_val(src, 'forecast_direction'), get_safe_val(src,\n 'forecast_speed'), get_safe_val(src, 'forecast_temp_day_from'\n ), get_safe_val(src, 'forecast_temp_day_to'), get_safe_val(src,\n 'forecast_temp_night_from'), get_safe_val(src, 'forecast_temp_night_to')\n", "yield tx.execute(query=sql, params=params)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_2(self, VAR_10):...\n", "\"\"\"docstring\"\"\"\n", "return Navigation.goToOrientation(self, self.transformAngle(VAR_10, 'map',\n 'odom'))\n" ]
[ "def goToOrientation(self, angle):...\n", "\"\"\"docstring\"\"\"\n", "return Navigation.goToOrientation(self, self.transformAngle(angle, 'map',\n 'odom'))\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def __init__(self, *VAR_6, **VAR_7):...\n", "super().__init__(*VAR_6, **kwargs)\n" ]
[ "def __init__(self, *args, **kwargs):...\n", "super().__init__(*args, **kwargs)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_3(self):...\n", "self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters=[['DocType', 'name', 'like', 'J%']]))\n" ]
[ "def test_filters_1(self):...\n", "self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters=[['DocType', 'name', 'like', 'J%']]))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_8(self):...\n", "self.driver._eql_execute = self.mox.CreateMock(self.driver._eql_execute)\n", "VAR_5 = {'id': 'fake_uuid'}\n", "VAR_1 = {'name': self.volume_name}\n", "VAR_6 = self.configuration.volume_name_template % VAR_5['id']\n", "self.driver._eql_execute('volume', 'select', VAR_6, 'clone', VAR_1['name']\n ).AndReturn(['iSCSI target name is %s.' % self.fake_iqn])\n", "self.mox.ReplayAll()\n", "VAR_2 = self.driver.create_cloned_volume(VAR_1, VAR_5)\n", "self.assertEqual(VAR_2, self._model_update)\n" ]
[ "def test_create_cloned_volume(self):...\n", "self.driver._eql_execute = self.mox.CreateMock(self.driver._eql_execute)\n", "src_vref = {'id': 'fake_uuid'}\n", "volume = {'name': self.volume_name}\n", "src_volume_name = self.configuration.volume_name_template % src_vref['id']\n", "self.driver._eql_execute('volume', 'select', src_volume_name, 'clone',\n volume['name']).AndReturn(['iSCSI target name is %s.' % self.fake_iqn])\n", "self.mox.ReplayAll()\n", "model_update = self.driver.create_cloned_volume(volume, src_vref)\n", "self.assertEqual(model_update, self._model_update)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_13(self, *VAR_16, **VAR_10):...\n", "if not self.is_group_user(VAR_8):\n", "return VAR_7(self, *VAR_16, **kwargs)\n" ]
[ "def wrapper(self, *args, **kwargs):...\n", "if not self.is_group_user(group):\n", "return method(self, *args, **kwargs)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'" ]
[ "def FUNC_15(self, VAR_27: int):...\n", "\"\"\"docstring\"\"\"\n", "VAR_35 = License.get_by_id(VAR_27)\n", "self.accepted_licenses.append(VAR_35)\n", "db.session.commit()\n" ]
[ "def accept_license_terms(self, license_id: int):...\n", "\"\"\"docstring\"\"\"\n", "image_license = License.get_by_id(license_id)\n", "self.accepted_licenses.append(image_license)\n", "db.session.commit()\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Expr'" ]
[ "from paramiko import AutoAddPolicy, SSHClient\n", "from scp import SCPClient\n", "from serial import Serial\n", "import sys\n", "from termcolor import colored\n", "from time import sleep\n", "from error import DrSEUsError\n", "from sql import sql\n", "VAR_0 = [('drseus_sighandler: SIGSEGV', 'Signal SIGSEGV'), (\n 'drseus_sighandler: SIGILL', 'Signal SIGILL'), (\n 'drseus_sighandler: SIGBUS', 'Signal SIGBUS'), (\n 'drseus_sighandler: SIGFPE', 'Signal SIGFPE'), (\n 'drseus_sighandler: SIGABRT', 'Signal SIGABRT'), (\n 'drseus_sighandler: SIGIOT', 'Signal SIGIOT'), (\n 'drseus_sighandler: SIGTRAP', 'Signal SIGTRAP'), (\n 'drseus_sighandler: SIGSYS', 'Signal SIGSYS'), (\n 'drseus_sighandler: SIGEMT', 'Signal SIGEMT'), ('command not found',\n 'Invalid command'), ('No such file or directory', 'Missing file'), (\n 'panic', 'Kernel error'), ('Oops', 'Kernel error'), (\n 'Segmentation fault', 'Segmentation fault'), ('Illegal instruction',\n 'Illegal instruction'), ('Call Trace:', 'Kernel error'), (\n 'detected stalls on CPU', 'Stall detected'), (\n 'malloc(), memory corruption', 'Kernel error'), ('Bad swap file entry',\n 'Kernel error'), ('Unable to handle kernel paging request',\n 'Kernel error'), ('Alignment trap', 'Kernel error'), ('Unhandled fault',\n 'Kernel error'), ('free(), invalid next size', 'Kernel error'), (\n 'double free or corruption', 'Kernel error'), ('????????', '????????'),\n ('Hit any key to stop autoboot:', 'Reboot'), (\"can't get kernel image\",\n 'Error booting')]\n", "def __init__(self, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5=False):...\n", "self.campaign_data = VAR_1\n", "self.result_data = VAR_2\n", "self.options = VAR_3\n", "self.aux = VAR_5\n", "self.uboot_command = (self.options.dut_uboot if not self.aux else self.\n options.aux_uboot)\n", "VAR_17 = VAR_3.dut_serial_port if not VAR_5 else VAR_3.aux_serial_port\n", "VAR_18 = VAR_3.dut_baud_rate if not VAR_5 else VAR_3.aux_baud_rate\n", "self.serial = Serial(port=None, baudrate=baud_rate, timeout=options.timeout,\n rtscts=True)\n", "if self.campaign_data['use_simics']:\n", "self.serial._dsrdtr = True\n", "self.serial.port = VAR_17\n", "self.serial.open()\n", "self.serial.reset_input_buffer()\n", "self.prompt = VAR_3.dut_prompt if not VAR_5 else VAR_3.aux_prompt\n", "self.prompt += ' '\n", "self.rsakey = VAR_4\n", "def __str__(self):...\n", "VAR_10 = 'Serial Port: ' + self.serial.port + '\\n\\tTimeout: ' + str(self.\n serial.timeout) + \"\"\" seconds\n\tPrompt: \\\"\"\"\" + self.prompt + '\"'\n", "VAR_10 += '\\n\\tIP Address: ' + self.ip_address\n", "VAR_10 += '\\n\\tSCP Port: ' + str(self.options.dut_scp_port if not self.aux else\n self.options.aux_scp_port)\n", "return VAR_10\n" ]
[ "from paramiko import AutoAddPolicy, SSHClient\n", "from scp import SCPClient\n", "from serial import Serial\n", "import sys\n", "from termcolor import colored\n", "from time import sleep\n", "from error import DrSEUsError\n", "from sql import sql\n", "error_messages = [('drseus_sighandler: SIGSEGV', 'Signal SIGSEGV'), (\n 'drseus_sighandler: SIGILL', 'Signal SIGILL'), (\n 'drseus_sighandler: SIGBUS', 'Signal SIGBUS'), (\n 'drseus_sighandler: SIGFPE', 'Signal SIGFPE'), (\n 'drseus_sighandler: SIGABRT', 'Signal SIGABRT'), (\n 'drseus_sighandler: SIGIOT', 'Signal SIGIOT'), (\n 'drseus_sighandler: SIGTRAP', 'Signal SIGTRAP'), (\n 'drseus_sighandler: SIGSYS', 'Signal SIGSYS'), (\n 'drseus_sighandler: SIGEMT', 'Signal SIGEMT'), ('command not found',\n 'Invalid command'), ('No such file or directory', 'Missing file'), (\n 'panic', 'Kernel error'), ('Oops', 'Kernel error'), (\n 'Segmentation fault', 'Segmentation fault'), ('Illegal instruction',\n 'Illegal instruction'), ('Call Trace:', 'Kernel error'), (\n 'detected stalls on CPU', 'Stall detected'), (\n 'malloc(), memory corruption', 'Kernel error'), ('Bad swap file entry',\n 'Kernel error'), ('Unable to handle kernel paging request',\n 'Kernel error'), ('Alignment trap', 'Kernel error'), ('Unhandled fault',\n 'Kernel error'), ('free(), invalid next size', 'Kernel error'), (\n 'double free or corruption', 'Kernel error'), ('????????', '????????'),\n ('Hit any key to stop autoboot:', 'Reboot'), (\"can't get kernel image\",\n 'Error booting')]\n", "def __init__(self, campaign_data, result_data, options, rsakey, aux=False):...\n", "self.campaign_data = campaign_data\n", "self.result_data = result_data\n", "self.options = options\n", "self.aux = aux\n", "self.uboot_command = (self.options.dut_uboot if not self.aux else self.\n options.aux_uboot)\n", "serial_port = options.dut_serial_port if not aux else options.aux_serial_port\n", "baud_rate = options.dut_baud_rate if not aux else options.aux_baud_rate\n", "self.serial = Serial(port=None, baudrate=baud_rate, timeout=options.timeout,\n rtscts=True)\n", "if self.campaign_data['use_simics']:\n", "self.serial._dsrdtr = True\n", "self.serial.port = serial_port\n", "self.serial.open()\n", "self.serial.reset_input_buffer()\n", "self.prompt = options.dut_prompt if not aux else options.aux_prompt\n", "self.prompt += ' '\n", "self.rsakey = rsakey\n", "def __str__(self):...\n", "string = 'Serial Port: ' + self.serial.port + '\\n\\tTimeout: ' + str(self.\n serial.timeout) + \"\"\" seconds\n\tPrompt: \\\"\"\"\" + self.prompt + '\"'\n", "string += '\\n\\tIP Address: ' + self.ip_address\n", "string += '\\n\\tSCP Port: ' + str(self.options.dut_scp_port if not self.aux else\n self.options.aux_scp_port)\n", "return 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 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "AugAssign'", "Assign'", "FunctionDef'", "Assign'", "AugAssign'", "AugAssign'", "Return'" ]
[ "def FUNC_23(self, VAR_2, VAR_3, VAR_8, *VAR_5):...\n", "if isinstance(VAR_8, Circuit):\n", "VAR_12 = {'circuit_id': VAR_8.circuit_id, 'bytes_up': VAR_8.bytes_up,\n 'bytes_down': VAR_8.bytes_down, 'uptime': time.time() - VAR_8.creation_time\n }\n", "self.write_data({'type': 'circuit_removed', 'event': VAR_12})\n" ]
[ "def on_circuit_removed(self, subject, changetype, circuit, *args):...\n", "if isinstance(circuit, Circuit):\n", "event = {'circuit_id': circuit.circuit_id, 'bytes_up': circuit.bytes_up,\n 'bytes_down': circuit.bytes_down, 'uptime': time.time() - circuit.\n creation_time}\n", "self.write_data({'type': 'circuit_removed', 'event': event})\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Expr'" ]
[ "def FUNC_2(self):...\n", "VAR_1 = 'INVALID'\n", "self.assertEqual(escape_path_argument('/home/usr/a-file', VAR_1),\n '/home/usr/a-file')\n", "self.assertEqual(escape_path_argument('/home/us r/a-file with spaces.bla',\n VAR_1), '/home/us r/a-file with spaces.bla')\n", "self.assertEqual(escape_path_argument('|home|us r|a*dir with spaces|x|',\n VAR_1), '|home|us r|a*dir with spaces|x|')\n", "self.assertEqual(escape_path_argument('system|a|b|c?d', VAR_1),\n 'system|a|b|c?d')\n" ]
[ "def test_escape_path_argument_unsupported(self):...\n", "_type = 'INVALID'\n", "self.assertEqual(escape_path_argument('/home/usr/a-file', _type),\n '/home/usr/a-file')\n", "self.assertEqual(escape_path_argument('/home/us r/a-file with spaces.bla',\n _type), '/home/us r/a-file with spaces.bla')\n", "self.assertEqual(escape_path_argument('|home|us r|a*dir with spaces|x|',\n _type), '|home|us r|a*dir with spaces|x|')\n", "self.assertEqual(escape_path_argument('system|a|b|c?d', _type),\n 'system|a|b|c?d')\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def __getattr__(self, VAR_21):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_12(*VAR_20):...\n", "return self._rpc(VAR_21, *VAR_20)\n" ]
[ "def __getattr__(self, name):...\n", "\"\"\"docstring\"\"\"\n", "def rpc_call(*args):...\n", "return self._rpc(name, *args)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Return'" ]
[ "def FUNC_25(self, VAR_26, VAR_27):...\n", "VAR_47 = []\n", "for VAR_24 in self.opened_databases:\n", "if VAR_24.database_manager.changes is True:\n", "if VAR_47.__len__() > 0:\n", "VAR_47.append(VAR_24)\n", "VAR_28 = Gtk.Builder()\n", "VAR_28.add_from_resource('/run/terminal/KeepassGtk/quit_dialog.ui')\n", "self.quit_dialog = VAR_28.get_object('quit_dialog')\n", "self.quit_dialog.set_destroy_with_parent(True)\n", "self.quit_dialog.set_modal(True)\n", "self.quit_dialog.set_transient_for(self)\n", "VAR_50 = VAR_28.get_object('back_button')\n", "VAR_51 = VAR_28.get_object('quit_button')\n", "VAR_50.connect('clicked', self.on_back_button_clicked)\n", "VAR_51.connect('clicked', self.on_quit_button_clicked)\n", "VAR_52 = VAR_28.get_object('unsaved_databases_list_box')\n", "for VAR_24 in VAR_47:\n", "VAR_53 = Gtk.ListBoxRow()\n", "self.quit_dialog.present()\n", "VAR_23 = Gtk.CheckButton()\n", "return True\n", "VAR_23.set_label(VAR_24.database_manager.database_path)\n", "VAR_23.connect('toggled', self.on_save_check_button_toggled, VAR_24)\n", "VAR_53.add(VAR_23)\n", "VAR_53.show_all()\n", "VAR_52.add(VAR_53)\n" ]
[ "def on_application_quit(self, window, event):...\n", "unsaved_databases_list = []\n", "for db in self.opened_databases:\n", "if db.database_manager.changes is True:\n", "if unsaved_databases_list.__len__() > 0:\n", "unsaved_databases_list.append(db)\n", "builder = Gtk.Builder()\n", "builder.add_from_resource('/run/terminal/KeepassGtk/quit_dialog.ui')\n", "self.quit_dialog = builder.get_object('quit_dialog')\n", "self.quit_dialog.set_destroy_with_parent(True)\n", "self.quit_dialog.set_modal(True)\n", "self.quit_dialog.set_transient_for(self)\n", "back_button = builder.get_object('back_button')\n", "quit_button = builder.get_object('quit_button')\n", "back_button.connect('clicked', self.on_back_button_clicked)\n", "quit_button.connect('clicked', self.on_quit_button_clicked)\n", "unsaved_databases_list_box = builder.get_object('unsaved_databases_list_box')\n", "for db in unsaved_databases_list:\n", "unsaved_database_row = Gtk.ListBoxRow()\n", "self.quit_dialog.present()\n", "check_button = Gtk.CheckButton()\n", "return True\n", "check_button.set_label(db.database_manager.database_path)\n", "check_button.connect('toggled', self.on_save_check_button_toggled, db)\n", "unsaved_database_row.add(check_button)\n", "unsaved_database_row.show_all()\n", "unsaved_databases_list_box.add(unsaved_database_row)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Condition", "Condition", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "For", "Assign'", "Expr'", "Assign'", "Return'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_6(self):...\n", "self.runall(self.checks, skip_system_check=True)\n", "VAR_15 = self.runner.stats\n", "self.assertEqual(8, VAR_15.num_cases())\n", "self.assertEqual(4, len(VAR_15.failures()))\n", "self.assertEqual(2, self._num_failures_stage('setup'))\n", "self.assertEqual(1, self._num_failures_stage('sanity'))\n", "self.assertEqual(1, self._num_failures_stage('performance'))\n" ]
[ "def test_runall_skip_system_check(self):...\n", "self.runall(self.checks, skip_system_check=True)\n", "stats = self.runner.stats\n", "self.assertEqual(8, stats.num_cases())\n", "self.assertEqual(4, len(stats.failures()))\n", "self.assertEqual(2, self._num_failures_stage('setup'))\n", "self.assertEqual(1, self._num_failures_stage('sanity'))\n", "self.assertEqual(1, self._num_failures_stage('performance'))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "@integration_synonym_api...\n", "FUNC_2(VAR_2)\n", "FUNC_3(VAR_2, 'JM Van Damme inc', VAR_7='1')\n", "FUNC_3(VAR_2, 'SOME RANDOM NAME', VAR_7='2')\n", "FUNC_5(VAR_4, VAR_5, VAR_11=query, VAR_10=[{'name': '----*'}])\n" ]
[ "@integration_synonym_api...\n", "clean_database(solr)\n", "seed_database_with(solr, 'JM Van Damme inc', id='1')\n", "seed_database_with(solr, 'SOME RANDOM NAME', id='2')\n", "verify_results(client, jwt, query=query, expected=[{'name': '----*'}])\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_10(self, VAR_30):...\n", "VAR_38 = self.to_dict()\n", "for comp in ['title', 'size', 'tags', 'torrent_date', 'tracker_info']:\n", "if comp not in VAR_30 or str(VAR_38[comp]) == str(VAR_30[comp]):\n", "return False\n", "return True\n" ]
[ "def metadata_conflicting(self, b):...\n", "a = self.to_dict()\n", "for comp in ['title', 'size', 'tags', 'torrent_date', 'tracker_info']:\n", "if comp not in b or str(a[comp]) == str(b[comp]):\n", "return False\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Condition", "Return'", "Return'" ]
[ "def FUNC_0(self, VAR_1=True):...\n", "self.is_api = VAR_1\n", "self.assets = Environment(os.path.join(os.path.dirname(__file__),\n '../static'), '/static')\n", "VAR_11 = Bundle('css/bootstrap.min.css', 'css/material.min.css', Bundle(\n 'css/schoolcms.css', 'css/dropdown.css', filters='cssmin'),\n 'outdatedbrowser/outdatedbrowser.min.css', output='dict/plugin.min.css')\n", "VAR_12 = Bundle(Bundle('outdatedbrowser/outdatedbrowser.min.js',\n 'react-0.13.2/react-with-addons.min.js', 'js/jquery-2.1.3.min.js',\n 'js/bootstrap.min.js', 'js/react-bootstrap.min.js',\n 'js/react-mini-router.min.js', 'js/marked.min.js', 'js/material.min.js',\n 'js/isMobile.min.js', 'js/moment-with-locales.min.js', 'js/dropdown.js',\n filters='jsmin'), Bundle('schoolcms/init.jsx', 'schoolcms/mixin/*.jsx',\n 'schoolcms/component/*.jsx', 'schoolcms/page/*.jsx', filters=('react',\n 'jsmin')), output='dict/plugin.min.js')\n", "self.assets.register('css_all', VAR_11)\n", "self.assets.register('js_all', VAR_12)\n" ]
[ "def initialize(self, is_api=True):...\n", "self.is_api = is_api\n", "self.assets = Environment(os.path.join(os.path.dirname(__file__),\n '../static'), '/static')\n", "css_all = Bundle('css/bootstrap.min.css', 'css/material.min.css', Bundle(\n 'css/schoolcms.css', 'css/dropdown.css', filters='cssmin'),\n 'outdatedbrowser/outdatedbrowser.min.css', output='dict/plugin.min.css')\n", "js_all = Bundle(Bundle('outdatedbrowser/outdatedbrowser.min.js',\n 'react-0.13.2/react-with-addons.min.js', 'js/jquery-2.1.3.min.js',\n 'js/bootstrap.min.js', 'js/react-bootstrap.min.js',\n 'js/react-mini-router.min.js', 'js/marked.min.js', 'js/material.min.js',\n 'js/isMobile.min.js', 'js/moment-with-locales.min.js', 'js/dropdown.js',\n filters='jsmin'), Bundle('schoolcms/init.jsx', 'schoolcms/mixin/*.jsx',\n 'schoolcms/component/*.jsx', 'schoolcms/page/*.jsx', filters=('react',\n 'jsmin')), output='dict/plugin.min.js')\n", "self.assets.register('css_all', css_all)\n", "self.assets.register('js_all', js_all)\n" ]
[ 0, 0, 5, 5, 5, 5, 5 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "@staticmethod...\n", "return ungettext_lazy(u'Delete Key Pair', u'Delete Key Pairs', VAR_2)\n" ]
[ "@staticmethod...\n", "return ungettext_lazy(u'Delete Key Pair', u'Delete Key Pairs', count)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_0():...\n", "return st.ScenarioTestRunner.main(CLASS_0, test_case_list=[\n GoogleKatoIntegrationTest])\n" ]
[ "def main():...\n", "return st.ScenarioTestRunner.main(GoogleKatoTestScenario, test_case_list=[\n GoogleKatoIntegrationTest])\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@classmethod...\n", "\"\"\"docstring\"\"\"\n", "return gate.new_agent(VAR_1)\n" ]
[ "@classmethod...\n", "\"\"\"docstring\"\"\"\n", "return gate.new_agent(bindings)\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def FUNC_0():...\n", "\"\"\"docstring\"\"\"\n", "logging.debug('Getting cli arguments')\n", "VAR_0 = argparse.ArgumentParser(description=\n 'A benchmark for genomics routines in Python.')\n", "VAR_1 = VAR_0.add_subparsers(title='commands', dest='command')\n", "VAR_1.required = True\n", "VAR_2 = VAR_1.add_parser('config', help=\n 'Setting up the default configuration of the benchmark. It creates the default configuration file.'\n )\n", "VAR_2.add_argument('--output_config', type=str, required=True, help=\n 'Specify the output path to a configuration file.', metavar='FILEPATH')\n", "VAR_2.add_argument('-f', action='store_true', help=\n 'Overwrite the destination file if it already exists.')\n", "VAR_3 = VAR_1.add_parser('setup', help=\n 'Preparation and setting up of the data for the benchmark. It requires a configuration file.'\n )\n", "VAR_3.add_argument('--config_file', required=True, help=\n 'Location of the configuration file', metavar='FILEPATH')\n", "VAR_4 = VAR_1.add_parser('exec', help=\n 'Execution of the benchmark modes. It requires a configuration file.')\n", "VAR_4.add_argument('--label', type=str, default='run', metavar='RUN_LABEL',\n help='Label for the benchmark run.')\n", "VAR_4.add_argument('--config_file', type=str, required=True, help=\n 'Specify the path to a configuration file.', metavar='FILEPATH')\n", "VAR_5 = vars(VAR_0.parse_args())\n", "return VAR_5\n" ]
[ "def get_cli_arguments():...\n", "\"\"\"docstring\"\"\"\n", "logging.debug('Getting cli arguments')\n", "parser = argparse.ArgumentParser(description=\n 'A benchmark for genomics routines in Python.')\n", "subparser = parser.add_subparsers(title='commands', dest='command')\n", "subparser.required = True\n", "config_parser = subparser.add_parser('config', help=\n 'Setting up the default configuration of the benchmark. It creates the default configuration file.'\n )\n", "config_parser.add_argument('--output_config', type=str, required=True, help\n ='Specify the output path to a configuration file.', metavar='FILEPATH')\n", "config_parser.add_argument('-f', action='store_true', help=\n 'Overwrite the destination file if it already exists.')\n", "data_setup_parser = subparser.add_parser('setup', help=\n 'Preparation and setting up of the data for the benchmark. It requires a configuration file.'\n )\n", "data_setup_parser.add_argument('--config_file', required=True, help=\n 'Location of the configuration file', metavar='FILEPATH')\n", "benchmark_exec_parser = subparser.add_parser('exec', help=\n 'Execution of the benchmark modes. It requires a configuration file.')\n", "benchmark_exec_parser.add_argument('--label', type=str, default='run',\n metavar='RUN_LABEL', help='Label for the benchmark run.')\n", "benchmark_exec_parser.add_argument('--config_file', type=str, required=True,\n help='Specify the path to a configuration file.', metavar='FILEPATH')\n", "runtime_configuration = vars(parser.parse_args())\n", "return runtime_configuration\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_21(VAR_12, VAR_14, VAR_15):...\n", "VAR_31 = getattr(VAR_1, VAR_15, None)\n", "if VAR_31 is not None:\n", "VAR_12 += \"{}='{}' \".format(VAR_14, VAR_31)\n", "return VAR_12\n" ]
[ "def _addCredential(credentials, env_key, data_key):...\n", "value = getattr(data, data_key, None)\n", "if value is not None:\n", "credentials += \"{}='{}' \".format(env_key, value)\n", "return credentials\n" ]
[ 0, 0, 0, 2, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "AugAssign'", "Return'" ]
[ "from flask import render_template, request, redirect, url_for\n", "from flask_login import login_user, login_required, logout_user, current_user\n", "from application import app, db\n", "from application.help import getArticlesWithCondition\n", "from application.articles.models import Article\n", "from application.articles.forms import ArticleForm\n", "from application.help import getEditorOptions, getIssueOptions, getPeopleOptions\n", "from application.issues.models import Issue\n", "from application.issues.forms import IssueForm\n", "from sqlalchemy.sql import text\n", "@app.route('/issues/', methods=['GET'])...\n", "VAR_2 = text('SELECT issue.id, issue.name FROM issue ORDER BY issue.name')\n", "VAR_3 = db.engine.execute(VAR_2)\n", "return render_template('/issues/list.html', current_user=current_user,\n VAR_3=issues)\n" ]
[ "from flask import render_template, request, redirect, url_for\n", "from flask_login import login_user, login_required, logout_user, current_user\n", "from application import app, db\n", "from application.help import getArticlesWithCondition\n", "from application.articles.models import Article\n", "from application.articles.forms import ArticleForm\n", "from application.help import getEditorOptions, getIssueOptions, getPeopleOptions\n", "from application.issues.models import Issue\n", "from application.issues.forms import IssueForm\n", "from sqlalchemy.sql import text\n", "@app.route('/issues/', methods=['GET'])...\n", "query = text('SELECT issue.id, issue.name FROM issue ORDER BY issue.name')\n", "issues = db.engine.execute(query)\n", "return render_template('/issues/list.html', current_user=current_user,\n issues=issues)\n" ]
[ 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Condition", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_12(self, VAR_9):...\n", "\"\"\"docstring\"\"\"\n", "VAR_19 = self.session.query(self.resource_type).get(VAR_9)\n", "if VAR_19 is None:\n", "return self._specific_fields(VAR_19)\n" ]
[ "def detail(self, model_id):...\n", "\"\"\"docstring\"\"\"\n", "model = self.session.query(self.resource_type).get(model_id)\n", "if model is None:\n", "return self._specific_fields(model)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Return'" ]
[ "def FUNC_9(VAR_0, VAR_5, VAR_8, VAR_9):...\n", "" ]
[ "def find_replace(table_name, attr, find, replace):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_0(VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "VAR_3 = psycopg2.connect(database=DBNAME)\n", "VAR_4 = VAR_3.cursor()\n", "VAR_4.execute(VAR_1)\n", "VAR_5 = VAR_4.fetchall()\n", "VAR_3.close()\n", "return VAR_5\n" ]
[ "def execute_query(cmd):...\n", "\"\"\"docstring\"\"\"\n", "conn = psycopg2.connect(database=DBNAME)\n", "cursor = conn.cursor()\n", "cursor.execute(cmd)\n", "result = cursor.fetchall()\n", "conn.close()\n", "return result\n" ]
[ 0, 0, 0, 0, 4, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_2(VAR_2, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "for VAR_61, value in VAR_3.items():\n", "if isinstance(VAR_2, collections.Mapping):\n", "return VAR_2\n", "if isinstance(value, collections.Mapping):\n", "VAR_2 = {VAR_61: VAR_3[VAR_61]}\n", "VAR_2[VAR_61] = FUNC_2(VAR_2.get(VAR_61, {}), value)\n", "VAR_2[VAR_61] = VAR_3[VAR_61]\n" ]
[ "def update_dict(base, head):...\n", "\"\"\"docstring\"\"\"\n", "for key, value in head.items():\n", "if isinstance(base, collections.Mapping):\n", "return base\n", "if isinstance(value, collections.Mapping):\n", "base = {key: head[key]}\n", "base[key] = update_dict(base.get(key, {}), value)\n", "base[key] = head[key]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "For", "Condition", "Return'", "Condition", "Assign'", "Assign'", "Assign'" ]
[ "@auth.require(auth.is_admin)...\n", "VAR_4 = {'machines': [], 'next_page_token': None}\n", "if VAR_1:\n", "VAR_5 = models.CatalogMachineEntry.get_by_id(VAR_1)\n", "VAR_6 = models.CatalogMachineEntry.query().order(models.CatalogMachineEntry\n .dimensions.hostname)\n", "if not VAR_5:\n", "VAR_7 = self.request.get('page_token') or ''\n", "self.abort(404)\n", "VAR_4['machines'] = [VAR_5]\n", "VAR_4['machines'], VAR_4['next_page_token'] = datastore_utils.fetch_page(VAR_6,\n 50, VAR_7)\n", "self.response.write(template.render('templates/catalog.html', VAR_4=params))\n" ]
[ "@auth.require(auth.is_admin)...\n", "params = {'machines': [], 'next_page_token': None}\n", "if machine_id:\n", "machine = models.CatalogMachineEntry.get_by_id(machine_id)\n", "query = models.CatalogMachineEntry.query().order(models.CatalogMachineEntry\n .dimensions.hostname)\n", "if not machine:\n", "page_token = self.request.get('page_token') or ''\n", "self.abort(404)\n", "params['machines'] = [machine]\n", "params['machines'], params['next_page_token'] = datastore_utils.fetch_page(\n query, 50, page_token)\n", "self.response.write(template.render('templates/catalog.html', params=params))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "VAR_6['url'] = VAR_7.url\n", "VAR_6['credentials'] = json.dumps(VAR_7.credentials)\n", "VAR_6['scopes'] = '\\n'.join(VAR_7.scopes)\n", "VAR_6['headers'] = json.dumps(VAR_7.headers)\n" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "params['url'] = data.url\n", "params['credentials'] = json.dumps(data.credentials)\n", "params['scopes'] = '\\n'.join(data.scopes)\n", "params['headers'] = json.dumps(data.headers)\n" ]
[ 0, 0, 5, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_6(self):...\n", "VAR_14 = self.new_mocked_client(client.RESTClient, url_prefix='api/v1/ports')\n", "VAR_14.list()\n", "FUNC_1('get', VAR_14, 'https://1.2.3.4/api/v1/ports')\n" ]
[ "def test_client_list(self):...\n", "api = self.new_mocked_client(client.RESTClient, url_prefix='api/v1/ports')\n", "api.list()\n", "assert_call('get', api, 'https://1.2.3.4/api/v1/ports')\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_7(VAR_4):...\n", "VAR_4['from'] = US\n", "sendgrid[send - VAR_9](VAR_4)\n", "return HttpResponse('All Good')\n" ]
[ "def recieveEmailINTHEASS(request):...\n", "request['from'] = US\n", "sendgrid[send - email](request)\n", "return HttpResponse('All Good')\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Return'" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "VAR_23 = {}\n", "for VAR_48 in VAR_10.keys():\n", "if VAR_48 not in VAR_9:\n", "if GLSetting.loglevel == 'DEBUG':\n", "log.err('key %s not in %s' % (VAR_48, VAR_9))\n", "VAR_23[VAR_48] = VAR_9[VAR_48]\n", "for double_k in VAR_9.keys():\n", "VAR_9 = VAR_23\n", "if double_k not in VAR_10.keys():\n", "for VAR_48, VAR_6 in VAR_10.iteritems():\n", "log.err('[!?] key %s not expected' % double_k)\n", "if not CLASS_1.validate_type(VAR_9[VAR_48], VAR_6):\n", "for VAR_48, VAR_6 in VAR_9.iteritems():\n", "if not CLASS_1.validate_type(VAR_6, VAR_10[VAR_48]):\n", "return True\n" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "valid_jmessage = {}\n", "for key in message_template.keys():\n", "if key not in jmessage:\n", "if GLSetting.loglevel == 'DEBUG':\n", "log.err('key %s not in %s' % (key, jmessage))\n", "valid_jmessage[key] = jmessage[key]\n", "for double_k in jmessage.keys():\n", "jmessage = valid_jmessage\n", "if double_k not in message_template.keys():\n", "for key, value in message_template.iteritems():\n", "log.err('[!?] key %s not expected' % double_k)\n", "if not BaseHandler.validate_type(jmessage[key], value):\n", "for key, value in jmessage.iteritems():\n", "if not BaseHandler.validate_type(value, message_template[key]):\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "For", "Condition", "Condition", "Expr'", "Assign'", "For", "Assign'", "Condition", "For", "Expr'", "Condition", "For", "Condition", "Return'" ]
[ "import sqlobject\n", "import vdm.sqlobject.base as vdmbase\n", "import vdm.base as vdmbase\n", "VAR_16 = 'name'\n", "from vdm.sqlobject.base import State\n", "from vdm.base import State\n", "VAR_0 = sqlobject.UnicodeCol(alternateID=True)\n", "VAR_1 = sqlobject.MultipleJoin('Package')\n", "VAR_2 = sqlobject.ForeignKey('Package', cascade=True)\n", "VAR_3 = sqlobject.UnicodeCol(default=None)\n", "VAR_4 = sqlobject.UnicodeCol(default=None)\n", "VAR_5 = sqlobject.UnicodeCol(default=None)\n", "VAR_6 = sqlobject.ForeignKey('License', default=None)\n", "VAR_7 = sqlobject.UnicodeCol(default=None)\n", "VAR_2 = sqlobject.ForeignKey('Tag', cascade=True)\n", "VAR_2 = sqlobject.ForeignKey('PackageTag', cascade=True)\n", "VAR_8 = CLASS_1\n", "VAR_9 = vdmbase.get_attribute_names(VAR_8)\n", "VAR_0 = sqlobject.UnicodeCol(alternateID=True)\n", "VAR_10 = [('tags', 'ckan.models.package', 'Tag', 'PackageTag')]\n", "def FUNC_0(self, VAR_11):...\n", "VAR_14 = self.revision.model.tags.get(VAR_11)\n", "VAR_14 = self.transaction.model.tags.create(VAR_0=tagname)\n", "self.tags.create(VAR_14=tag)\n", "VAR_8 = CLASS_2\n", "VAR_0 = sqlobject.UnicodeCol(alternateID=True)\n", "VAR_9 = vdmbase.get_attribute_names(VAR_8)\n", "VAR_10 = [('packages', 'ckan.models.package', 'Package', 'PackageTag')]\n", "@classmethod...\n", "VAR_17 = str(VAR_12)\n", "VAR_18 = \"UPPER(tag.name) LIKE UPPER('%%%s%%')\" % VAR_17\n", "return self.select(VAR_18)\n" ]
[ "import sqlobject\n", "import vdm.sqlobject.base as vdmbase\n", "import vdm.base as vdmbase\n", "_defaultOrder = 'name'\n", "from vdm.sqlobject.base import State\n", "from vdm.base import State\n", "name = sqlobject.UnicodeCol(alternateID=True)\n", "packages = sqlobject.MultipleJoin('Package')\n", "base = sqlobject.ForeignKey('Package', cascade=True)\n", "title = sqlobject.UnicodeCol(default=None)\n", "url = sqlobject.UnicodeCol(default=None)\n", "download_url = sqlobject.UnicodeCol(default=None)\n", "license = sqlobject.ForeignKey('License', default=None)\n", "notes = sqlobject.UnicodeCol(default=None)\n", "base = sqlobject.ForeignKey('Tag', cascade=True)\n", "base = sqlobject.ForeignKey('PackageTag', cascade=True)\n", "sqlobj_version_class = PackageRevision\n", "versioned_attributes = vdmbase.get_attribute_names(sqlobj_version_class)\n", "name = sqlobject.UnicodeCol(alternateID=True)\n", "m2m = [('tags', 'ckan.models.package', 'Tag', 'PackageTag')]\n", "def add_tag_by_name(self, tagname):...\n", "tag = self.revision.model.tags.get(tagname)\n", "tag = self.transaction.model.tags.create(name=tagname)\n", "self.tags.create(tag=tag)\n", "sqlobj_version_class = TagRevision\n", "name = sqlobject.UnicodeCol(alternateID=True)\n", "versioned_attributes = vdmbase.get_attribute_names(sqlobj_version_class)\n", "m2m = [('packages', 'ckan.models.package', 'Package', 'PackageTag')]\n", "@classmethod...\n", "text_query_str = str(text_query)\n", "sql_query = \"UPPER(tag.name) LIKE UPPER('%%%s%%')\" % text_query_str\n", "return self.select(sql_query)\n" ]
[ 0, 0, 0, 0, 0, 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, 4, 4 ]
[ "Import'", "Import'", "Import'", "Assign'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_1(VAR_4, VAR_5, VAR_6, VAR_7, VAR_8=None, VAR_9=None):...\n", "VAR_16 = FUNC_11(collect_config.collect_config(VAR_4, VAR_9), VAR_8)\n", "VAR_31 = FUNC_4(FUNC_9(VAR_5), VAR_16)\n", "if not VAR_7:\n", "for VAR_13, VAR_14 in VAR_31.items():\n", "FUNC_3(os.path.join(VAR_6, FUNC_10('/', VAR_13)), VAR_14)\n" ]
[ "def install_config(config_path, template_root, output_path, validate,...\n", "config = strip_hash(collect_config.collect_config(config_path,\n fallback_metadata), subhash)\n", "tree = build_tree(template_paths(template_root), config)\n", "if not validate:\n", "for path, contents in tree.items():\n", "write_file(os.path.join(output_path, strip_prefix('/', path)), contents)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "For", "Expr'" ]
[ "def __init__(self, VAR_23, VAR_24, VAR_25, VAR_26, VAR_27=0, *VAR_8, **VAR_9):...\n", "\"\"\"docstring\"\"\"\n", "import numpy as np\n", "self.subdomains_fn = VAR_23\n", "self.rasterio_raster = VAR_24\n", "self.id_field = VAR_25\n", "self.name_field = VAR_26\n", "self.background_value = VAR_27\n", "self._rasterize_subdomains()\n", "self._get_subdomains_dict()\n" ]
[ "def __init__(self, subdomains_fn, rasterio_raster, id_field, name_field,...\n", "\"\"\"docstring\"\"\"\n", "import numpy as np\n", "self.subdomains_fn = subdomains_fn\n", "self.rasterio_raster = rasterio_raster\n", "self.id_field = id_field\n", "self.name_field = name_field\n", "self.background_value = background_value\n", "self._rasterize_subdomains()\n", "self._get_subdomains_dict()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Import'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_3(self, VAR_6, VAR_7):...\n", "self.model.reset()\n", "self.load_torrents(1, 50)\n" ]
[ "def _on_view_sort(self, column, ascending):...\n", "self.model.reset()\n", "self.load_torrents(1, 50)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'" ]
[ "def FUNC_24(self, VAR_39):...\n", "for r in VAR_39:\n", "if not r.name:\n", "r._comment_count = 0\n", "if '_comments' in r:\n", "r._comment_count = len(json.loads(r._comments or '[]'))\n" ]
[ "def add_comment_count(self, result):...\n", "for r in result:\n", "if not r.name:\n", "r._comment_count = 0\n", "if '_comments' in r:\n", "r._comment_count = len(json.loads(r._comments or '[]'))\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Condition", "Assign'", "Condition", "Assign'" ]
[ "def __init__(self, VAR_18, *VAR_15, **VAR_16):...\n", "CLASS_3.__init__(self, VAR_18, errors.BAD_PASSWORD, *VAR_15, **kw)\n" ]
[ "def __init__(self, item, *a, **kw):...\n", "VRequired.__init__(self, item, errors.BAD_PASSWORD, *a, **kw)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_1(VAR_0, VAR_1):...\n", "VAR_5 = VAR_1.keys()\n", "VAR_6 = VAR_1.values()\n", "VAR_7 = [(VAR_5[i] + '=' + VAR_6[i]) for i in range(len(VAR_5))]\n", "VAR_8 = '&'.join(VAR_7)\n", "VAR_4 = 'curl -d ' + '\"' + VAR_8 + '\" ' + '-X POST ' + start_url + VAR_0\n", "return VAR_4\n" ]
[ "def createPostScript(endpoint, params):...\n", "keys = params.keys()\n", "values = params.values()\n", "pair = [(keys[i] + '=' + values[i]) for i in range(len(keys))]\n", "evil_param = '&'.join(pair)\n", "script = ('curl -d ' + '\"' + evil_param + '\" ' + '-X POST ' + start_url +\n endpoint)\n", "return script\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_29():...\n", "self.assertIn('reauthn-for-chpass', VAR_32)\n", "VAR_29 = VAR_32['reauthn-for-chpass']\n", "VAR_30 = int(time.time())\n", "self.assertTrue(VAR_30 - VAR_29 < 5)\n" ]
[ "def _check():...\n", "self.assertIn('reauthn-for-chpass', session)\n", "then = session['reauthn-for-chpass']\n", "now = int(time.time())\n", "self.assertTrue(now - then < 5)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_1:\n", "if not VAR_8:\n", "VAR_8 = CLASS_0.get_report(VAR_1)['signatures']\n", "VAR_9 = collections.OrderedDict()\n", "for signature in VAR_8:\n", "VAR_25 = signature['severity']\n", "return VAR_9\n", "if VAR_25 > 3:\n", "VAR_25 = 3\n", "if not VAR_9.has_key(VAR_25):\n", "VAR_9[VAR_25] = []\n", "VAR_9[VAR_25].append(signature)\n" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "if not task_id:\n", "if not signatures:\n", "signatures = AnalysisController.get_report(task_id)['signatures']\n", "data = collections.OrderedDict()\n", "for signature in signatures:\n", "severity = signature['severity']\n", "return data\n", "if severity > 3:\n", "severity = 3\n", "if not data.has_key(severity):\n", "data[severity] = []\n", "data[severity].append(signature)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Condition", "Assign'", "Assign'", "For", "Assign'", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Expr'" ]
[ "\"\"\"string\"\"\"\n", "__revision__ = '$Rev$'\n", "__date__ = '$Date$'\n", "__author__ = '$Author$'\n", "from django.db import connection, models, transaction\n", "def FUNC_0(self, **VAR_0):...\n", "\"\"\"docstring\"\"\"\n", "VAR_1 = ['UPDATE', connection.ops.quote_name(self._meta.db_table), 'SET']\n", "for field_name in VAR_0:\n", "setattr(self, field_name, VAR_0[field_name])\n", "VAR_1.pop(-1)\n", "VAR_2 = self._meta.get_field(field_name)\n", "VAR_1.extend(['WHERE', 'id', '=', str(self.id)])\n", "VAR_3 = VAR_2.get_db_prep_save(VAR_0[field_name])\n", "VAR_1 = ' '.join(VAR_1)\n", "if isinstance(VAR_3, basestring):\n", "connection.cursor().execute(VAR_1)\n", "VAR_3 = \"'%s'\" % VAR_3.encode('utf-8').replace('\\\\', '\\\\\\\\')\n", "if isinstance(VAR_3, models.Model):\n", "transaction.commit_unless_managed()\n", "VAR_1.extend((connection.ops.quote_name(VAR_2.column), '=', VAR_3, ','))\n", "VAR_3 = str(VAR_3.id)\n", "if VAR_3 is None:\n", "FUNC_0.alters_data = True\n", "VAR_3 = 'NULL'\n", "VAR_3 = str(VAR_3)\n" ]
[ "\"\"\"\nUpdate only selected fields of a model.\n\nThe problem with model.save() is that it also overwrites all other\nfields with possibly stale data.\n\"\"\"\n", "__revision__ = '$Rev$'\n", "__date__ = '$Date$'\n", "__author__ = '$Author$'\n", "from django.db import connection, models, transaction\n", "def update_fields(self, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "sql = ['UPDATE', connection.ops.quote_name(self._meta.db_table), 'SET']\n", "for field_name in kwargs:\n", "setattr(self, field_name, kwargs[field_name])\n", "sql.pop(-1)\n", "field = self._meta.get_field(field_name)\n", "sql.extend(['WHERE', 'id', '=', str(self.id)])\n", "value = field.get_db_prep_save(kwargs[field_name])\n", "sql = ' '.join(sql)\n", "if isinstance(value, basestring):\n", "connection.cursor().execute(sql)\n", "value = \"'%s'\" % value.encode('utf-8').replace('\\\\', '\\\\\\\\')\n", "if isinstance(value, models.Model):\n", "transaction.commit_unless_managed()\n", "sql.extend((connection.ops.quote_name(field.column), '=', value, ','))\n", "value = str(value.id)\n", "if value is None:\n", "update_fields.alters_data = True\n", "value = 'NULL'\n", "value = str(value)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 4, 4, 4, 4, 0, 4, 4, 4, 0, 4, 4 ]
[ "Expr'", "Assign'", "Assign'", "Assign'", "ImportFrom'", "FunctionDef'", "Docstring", "Assign'", "For", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_14(self, VAR_13):...\n", "\"\"\"docstring\"\"\"\n", "if self.host.containerized:\n", "VAR_13 = VAR_13 % {'image': self.config['image'] or self.host.container_image}\n", "self.host.prefix = VAR_13\n" ]
[ "def _set_sos_prefix(self, prefix):...\n", "\"\"\"docstring\"\"\"\n", "if self.host.containerized:\n", "prefix = prefix % {'image': self.config['image'] or self.host.container_image}\n", "self.host.prefix = prefix\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_7(self, VAR_9):...\n", "\"\"\"docstring\"\"\"\n", "self.insecure_mode = ' --insecure'\n", "print('*** Using insecure code paths.')\n" ]
[ "def do_insecure_on(self, line):...\n", "\"\"\"docstring\"\"\"\n", "self.insecure_mode = ' --insecure'\n", "print('*** Using insecure code paths.')\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'" ]
[ "def FUNC_11(self):...\n", "VAR_3 = 5\n", "for i in range(VAR_3):\n", "VAR_11 = urllib.urlencode({url_helper.swarm_constants.COUNT_KEY: i})\n", "self._mox.ReplayAll()\n", "url_helper.urllib2.urlopen(mox.IgnoreArg(), VAR_11, timeout=mox.IgnoreArg()\n ).AndRaise(urllib2.URLError('url'))\n", "self.assertEqual(url_helper.UrlOpen('url', max_tries=attempts), None)\n", "if i != VAR_3 - 1:\n", "self._mox.VerifyAll()\n", "time.sleep(mox.IgnoreArg())\n" ]
[ "def testEnsureCountKeyIncludedInOpen(self):...\n", "attempts = 5\n", "for i in range(attempts):\n", "encoded_data = urllib.urlencode({url_helper.swarm_constants.COUNT_KEY: i})\n", "self._mox.ReplayAll()\n", "url_helper.urllib2.urlopen(mox.IgnoreArg(), encoded_data, timeout=mox.\n IgnoreArg()).AndRaise(urllib2.URLError('url'))\n", "self.assertEqual(url_helper.UrlOpen('url', max_tries=attempts), None)\n", "if i != attempts - 1:\n", "self._mox.VerifyAll()\n", "time.sleep(mox.IgnoreArg())\n" ]
[ 0, 0, 0, 0, 0, 5, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Assign'", "Expr'", "Expr'", "Expr'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_15(VAR_7, VAR_8, VAR_12):...\n", "if hasattr(VAR_12, 'contribute_to_class'):\n", "VAR_12.contribute_to_class(VAR_7, VAR_8)\n", "setattr(VAR_7, VAR_8, VAR_12)\n" ]
[ "def add_to_class(cls, name, value):...\n", "if hasattr(value, 'contribute_to_class'):\n", "value.contribute_to_class(cls, name)\n", "setattr(cls, name, value)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Expr'" ]
[ "async def FUNC_17(self, VAR_30, VAR_31, VAR_32=None, VAR_33=False, VAR_34=...\n", "\"\"\"docstring\"\"\"\n", "VAR_35 = VAR_35 or self.page_size\n", "def FUNC_19():...\n", "VAR_28 = getattr(VAR_1, VAR_30, None)\n", "if not VAR_28:\n", "VAR_64 = self.inspect()[VAR_30]\n", "VAR_55 = self.sql_time_limit_ms\n", "if VAR_64['file'] == ':memory:':\n", "if VAR_34 and VAR_34 < VAR_55:\n", "VAR_28 = sqlite3.connect(':memory:')\n", "VAR_28 = sqlite3.connect('file:{}?immutable=1'.format(VAR_64['file']), uri=\n True, check_same_thread=False)\n", "VAR_55 = VAR_34\n", "VAR_70 = VAR_28.cursor()\n", "if e.args == ('interrupted',):\n", "if VAR_33:\n", "self.prepare_connection(VAR_28)\n", "VAR_70.execute(VAR_31, VAR_32 or {})\n", "print('ERROR: conn={}, sql = {}, params = {}: {}'.format(VAR_28, repr(\n VAR_31), VAR_32, e))\n", "return Results(VAR_72, VAR_73, VAR_70.description)\n", "return Results(VAR_72, False, VAR_70.description)\n", "setattr(VAR_1, VAR_30, VAR_28)\n", "VAR_71 = self.max_returned_rows\n", "if VAR_71 == VAR_35:\n", "VAR_71 += 1\n", "if VAR_71 and VAR_33:\n", "VAR_72 = VAR_70.fetchmany(VAR_71 + 1)\n", "VAR_72 = VAR_70.fetchall()\n", "VAR_73 = len(VAR_72) > VAR_71\n", "VAR_73 = False\n", "VAR_72 = VAR_72[:VAR_71]\n" ]
[ "async def execute(self, db_name, sql, params=None, truncate=False,...\n", "\"\"\"docstring\"\"\"\n", "page_size = page_size or self.page_size\n", "def sql_operation_in_thread():...\n", "conn = getattr(connections, db_name, None)\n", "if not conn:\n", "info = self.inspect()[db_name]\n", "time_limit_ms = self.sql_time_limit_ms\n", "if info['file'] == ':memory:':\n", "if custom_time_limit and custom_time_limit < time_limit_ms:\n", "conn = sqlite3.connect(':memory:')\n", "conn = sqlite3.connect('file:{}?immutable=1'.format(info['file']), uri=True,\n check_same_thread=False)\n", "time_limit_ms = custom_time_limit\n", "cursor = conn.cursor()\n", "if e.args == ('interrupted',):\n", "if truncate:\n", "self.prepare_connection(conn)\n", "cursor.execute(sql, params or {})\n", "print('ERROR: conn={}, sql = {}, params = {}: {}'.format(conn, repr(sql),\n params, e))\n", "return Results(rows, truncated, cursor.description)\n", "return Results(rows, False, cursor.description)\n", "setattr(connections, db_name, conn)\n", "max_returned_rows = self.max_returned_rows\n", "if max_returned_rows == page_size:\n", "max_returned_rows += 1\n", "if max_returned_rows and truncate:\n", "rows = cursor.fetchmany(max_returned_rows + 1)\n", "rows = cursor.fetchall()\n", "truncated = len(rows) > max_returned_rows\n", "truncated = False\n", "rows = rows[:max_returned_rows]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "FunctionDef'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Expr'", "Expr'", "Expr'", "Return'", "Return'", "Expr'", "Assign'", "Condition", "AugAssign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_11(VAR_1, *VAR_8, **VAR_9):...\n", "\"\"\"docstring\"\"\"\n", "if current_user.is_authenticated():\n", "return redirect('/')\n", "VAR_21 = FUNC_5(VAR_1)\n", "if not VAR_21:\n", "return redirect('/')\n", "if not VAR_16.get(VAR_17(VAR_1.name) + '_autoregister', False):\n", "return redirect(url_for('.login', VAR_0=remote.name))\n", "VAR_22 = EmailSignUpForm(request.form)\n", "if VAR_22.validate_on_submit():\n", "VAR_27 = VAR_16.get(VAR_17(VAR_1.name) + '_account_info')\n", "return render_template('oauthclient/signup.html', VAR_22=form, VAR_1=remote,\n app_title=cfg['OAUTHCLIENT_REMOTE_APPS'][remote.name].get('title', ''),\n app_description=cfg['OAUTHCLIENT_REMOTE_APPS'][remote.name].get(\n 'description', ''), app_icon=cfg['OAUTHCLIENT_REMOTE_APPS'][remote.name\n ].get('icon', None))\n", "VAR_11 = oauth_register(VAR_27, VAR_22.data)\n", "if VAR_11 is None:\n", "VAR_16.pop(VAR_17(VAR_1.name) + '_autoregister', None)\n", "if not oauth_authenticate(VAR_1.consumer_key, VAR_11, require_existing_link\n", "return current_app.login_manager.unauthorized()\n", "VAR_5 = FUNC_4(VAR_1, VAR_21[0], VAR_6=oauth_token[1])\n", "VAR_19 = signup_handlers[VAR_1.name]\n", "if VAR_5 is None:\n", "if not VAR_5.remote_account.extra_data:\n", "VAR_19['setup'](VAR_5)\n", "VAR_16.pop(VAR_17(VAR_1.name) + '_account_info', None)\n", "if request.args.get('next', None):\n", "return redirect(request.args.get('next'))\n", "return redirect('/')\n" ]
[ "def signup_handler(remote, *args, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "if current_user.is_authenticated():\n", "return redirect('/')\n", "oauth_token = token_getter(remote)\n", "if not oauth_token:\n", "return redirect('/')\n", "if not session.get(token_session_key(remote.name) + '_autoregister', False):\n", "return redirect(url_for('.login', remote_app=remote.name))\n", "form = EmailSignUpForm(request.form)\n", "if form.validate_on_submit():\n", "account_info = session.get(token_session_key(remote.name) + '_account_info')\n", "return render_template('oauthclient/signup.html', form=form, remote=remote,\n app_title=cfg['OAUTHCLIENT_REMOTE_APPS'][remote.name].get('title', ''),\n app_description=cfg['OAUTHCLIENT_REMOTE_APPS'][remote.name].get(\n 'description', ''), app_icon=cfg['OAUTHCLIENT_REMOTE_APPS'][remote.name\n ].get('icon', None))\n", "user = oauth_register(account_info, form.data)\n", "if user is None:\n", "session.pop(token_session_key(remote.name) + '_autoregister', None)\n", "if not oauth_authenticate(remote.consumer_key, user, require_existing_link=\n", "return current_app.login_manager.unauthorized()\n", "token = token_setter(remote, oauth_token[0], secret=oauth_token[1])\n", "handlers = signup_handlers[remote.name]\n", "if token is None:\n", "if not token.remote_account.extra_data:\n", "handlers['setup'](token)\n", "session.pop(token_session_key(remote.name) + '_account_info', None)\n", "if request.args.get('next', None):\n", "return redirect(request.args.get('next'))\n", "return redirect('/')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Assign'", "Condition", "Return'", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Return'", "Assign'", "Condition", "Expr'", "Condition", "Return'", "Assign'", "Assign'", "Condition", "Condition", "Expr'", "Expr'", "Condition", "Return'", "Return'" ]
[ "@VAR_0.simple_tag...\n", "return [FUNC_19(VAR_11) for VAR_11 in VAR_12.split()]\n" ]
[ "@register.simple_tag...\n", "return [get_format_info(format) for format in formats.split()]\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_21(VAR_16):...\n", "return (VAR_16.input, VAR_16.dynamic_input) if VAR_4 else (VAR_16.output,\n VAR_16.dynamic_output)\n" ]
[ "def get_io(rule):...\n", "return (rule.input, rule.dynamic_input) if input else (rule.output, rule.\n dynamic_output)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_0(self, **VAR_1):...\n", "VAR_3 = super().get_context_data(**kwargs)\n", "VAR_3['search_form'] = SearchForm()\n", "return VAR_3\n" ]
[ "def get_context_data(self, **kwargs):...\n", "context = super().get_context_data(**kwargs)\n", "context['search_form'] = SearchForm()\n", "return context\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "@api.route('/items/<int:item_id>', methods=['GET'])...\n", "VAR_1 = (\n 'SELECT id, name_enus FROM tblDBCItem WHERE id = {} AND auctionable = true;'\n .format(VAR_0))\n", "VAR_2 = mysql.connection.cursor()\n", "VAR_2.execute(VAR_1)\n", "VAR_3 = VAR_2.fetchone()\n", "if VAR_3:\n", "VAR_6 = {}\n", "return jsonify({'error': 'item not found'}), 404\n", "for VAR_7 in zip([column[0] for column in VAR_2.description], VAR_3):\n", "VAR_6[VAR_7[0]] = VAR_7[1]\n", "return jsonify(VAR_6)\n" ]
[ "@api.route('/items/<int:item_id>', methods=['GET'])...\n", "sql = (\n 'SELECT id, name_enus FROM tblDBCItem WHERE id = {} AND auctionable = true;'\n .format(item_id))\n", "cursor = mysql.connection.cursor()\n", "cursor.execute(sql)\n", "data = cursor.fetchone()\n", "if data:\n", "item = {}\n", "return jsonify({'error': 'item not found'}), 404\n", "for tup in zip([column[0] for column in cursor.description], data):\n", "item[tup[0]] = tup[1]\n", "return jsonify(item)\n" ]
[ 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Return'", "For", "Assign'", "Return'" ]
[ "def FUNC_6(self, VAR_27):...\n", "if VAR_27:\n", "VAR_27 = int(VAR_27, 36)\n", "return Comment._byID(VAR_27, True)\n" ]
[ "def run(self, cid):...\n", "if cid:\n", "cid = int(cid, 36)\n", "return Comment._byID(cid, True)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Return'" ]
[ "@app.route('/achievements')...\n", "\"\"\"docstring\"\"\"\n", "VAR_5 = request.args.get('language', 'en')\n", "VAR_6 = request.args.get('region', 'US')\n", "VAR_11 = db.connection.cursor(db.pymysql.cursors.DictCursor)\n", "VAR_11.execute(VAR_0 + ' ORDER BY `order` ASC', {'language': VAR_5,\n 'region': VAR_6})\n", "return flask.jsonify(items=cursor.fetchall())\n" ]
[ "@app.route('/achievements')...\n", "\"\"\"docstring\"\"\"\n", "language = request.args.get('language', 'en')\n", "region = request.args.get('region', 'US')\n", "cursor = db.connection.cursor(db.pymysql.cursors.DictCursor)\n", "cursor.execute(SELECT_ACHIEVEMENTS_QUERY + ' ORDER BY `order` ASC', {\n 'language': language, 'region': region})\n", "return flask.jsonify(items=cursor.fetchall())\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_6(self, VAR_33):...\n", "if self.options and VAR_33 not in self.options:\n", "VAR_101.errors.add(errors.INVALID_OPTION)\n", "return VAR_33\n", "return self.default\n" ]
[ "def run(self, val):...\n", "if self.options and val not in self.options:\n", "c.errors.add(errors.INVALID_OPTION)\n", "return val\n", "return self.default\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Return'", "Return'" ]
[ "async def FUNC_1(self, VAR_2: str) ->None:...\n", "VAR_7 = await as_future(session.query(database.Paste).filter(database.Paste\n .paste_id == VAR_2).first)\n", "if not VAR_7:\n", "self.set_status(404)\n", "self.write({'paste_id': VAR_7.paste_id, 'raw': VAR_7.raw, 'fmt': VAR_7.fmt,\n 'lexer': VAR_7.lexer, 'expiry': VAR_7.exp_date.isoformat()})\n", "return\n" ]
[ "async def get(self, paste_id: str) ->None:...\n", "paste = await as_future(session.query(database.Paste).filter(database.Paste\n .paste_id == paste_id).first)\n", "if not paste:\n", "self.set_status(404)\n", "self.write({'paste_id': paste.paste_id, 'raw': paste.raw, 'fmt': paste.fmt,\n 'lexer': paste.lexer, 'expiry': paste.exp_date.isoformat()})\n", "return\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Assign'", "Condition", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_11(self, VAR_18, VAR_19=False):...\n", "VAR_15 = {'page_title': 'OAuth2 web client ID', 'web_client_id': VAR_18 or\n '', 'saved': VAR_19}\n", "self.reply('auth/admin/bootstrap_oauth.html', VAR_15)\n" ]
[ "def show_page(self, web_client_id, saved=False):...\n", "env = {'page_title': 'OAuth2 web client ID', 'web_client_id': web_client_id or\n '', 'saved': saved}\n", "self.reply('auth/admin/bootstrap_oauth.html', env)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "@staticmethod...\n", "if not isinstance(VAR_1, int):\n", "VAR_9 = {}\n", "VAR_10 = VAR_0.view_task(VAR_1, details=True)\n", "if VAR_10:\n", "VAR_19 = VAR_10.to_dict()\n", "return Exception('Task not found')\n", "VAR_19['guest'] = {}\n", "if VAR_10.guest:\n", "VAR_19['guest'] = VAR_10.guest.to_dict()\n", "VAR_19['errors'] = []\n", "for error in VAR_10.errors:\n", "VAR_19['errors'].append(error.message)\n", "VAR_19['sample'] = {}\n", "if VAR_10.sample_id:\n", "VAR_26 = VAR_0.view_sample(VAR_10.sample_id)\n", "VAR_9['task'] = VAR_19\n", "VAR_19['sample'] = VAR_26.to_dict()\n", "return VAR_9\n" ]
[ "@staticmethod...\n", "if not isinstance(task_id, int):\n", "data = {}\n", "task = db.view_task(task_id, details=True)\n", "if task:\n", "entry = task.to_dict()\n", "return Exception('Task not found')\n", "entry['guest'] = {}\n", "if task.guest:\n", "entry['guest'] = task.guest.to_dict()\n", "entry['errors'] = []\n", "for error in task.errors:\n", "entry['errors'].append(error.message)\n", "entry['sample'] = {}\n", "if task.sample_id:\n", "sample = db.view_sample(task.sample_id)\n", "data['task'] = entry\n", "entry['sample'] = sample.to_dict()\n", "return data\n" ]
[ 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1 ]
[ "Condition", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Assign'", "Condition", "Assign'", "Assign'", "For", "Expr'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_20(self, VAR_21):...\n", "\"\"\"docstring\"\"\"\n", "VAR_21 = VAR_21.rstrip('/')\n", "VAR_60 = os.path.basename(VAR_21)\n", "VAR_61 = os.path.dirname(VAR_21)\n", "VAR_58 = self.getfile(VAR_21, VAR_23=False)\n", "if VAR_58 == False:\n", "if VAR_58[VAR_2] != VAR_12:\n", "if len(self.get_path(VAR_21)) > 0:\n", "VAR_62 = self.get_path(VAR_61, VAR_23=True)\n", "for i in VAR_62[:]:\n", "if i[VAR_1] == VAR_60:\n", "return False\n", "VAR_62.remove(i)\n", "return True\n" ]
[ "def rmdir(self, path):...\n", "\"\"\"docstring\"\"\"\n", "path = path.rstrip('/')\n", "name = os.path.basename(path)\n", "parent = os.path.dirname(path)\n", "dir = self.getfile(path, follow_symlinks=False)\n", "if dir == False:\n", "if dir[A_TYPE] != T_DIR:\n", "if len(self.get_path(path)) > 0:\n", "pdir = self.get_path(parent, follow_symlinks=True)\n", "for i in pdir[:]:\n", "if i[A_NAME] == name:\n", "return False\n", "pdir.remove(i)\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "For", "Condition", "Return'", "Expr'", "Return'" ]
[ "def FUNC_17(self, VAR_19, VAR_18, VAR_20):...\n", "VAR_13 = set()\n", "for VAR_17 in VAR_20:\n", "VAR_21 = fs.split_path(VAR_17.path)\n", "return VAR_13\n", "VAR_23 = len(VAR_21)\n", "if self._lensplitpath > VAR_23:\n", "VAR_13.add(self._splitpath[VAR_23])\n" ]
[ "def get_parameters(self, key, levelctx, pathctxlist):...\n", "ret = set()\n", "for pathctx in pathctxlist:\n", "testpath = fs.split_path(pathctx.path)\n", "return ret\n", "lenpath = len(testpath)\n", "if self._lensplitpath > lenpath:\n", "ret.add(self._splitpath[lenpath])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Assign'", "Return'", "Assign'", "Condition", "Expr'" ]
[ "def FUNC_30(self):...\n", "self.compilation_ko('require [\"toto\",];')\n" ]
[ "def test_misplaced_comma_in_string_list(self):...\n", "self.compilation_ko('require [\"toto\",];')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_16(VAR_12):...\n", "VAR_16 = JarDependency('missing spec', ' //:{}'.format(VAR_12))\n", "VAR_4.register_jvm_tool(VAR_8, VAR_4._key_for_tool_version(VAR_12, 'custom'\n ), VAR_15=[dummy_jardep])\n" ]
[ "def register_custom_tool(key):...\n", "dummy_jardep = JarDependency('missing spec', ' //:{}'.format(key))\n", "cls.register_jvm_tool(register, cls._key_for_tool_version(key, 'custom'),\n classpath=[dummy_jardep])\n" ]
[ 0, 0, 7 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_10(self, VAR_2, *VAR_3, **VAR_4):...\n", "VAR_0.debug(f'{self.__class__.__name__} access check')\n", "if (self.access_granted or self.access_form_valid\n", "return self._redirect_from_passphrase(VAR_2)\n", "if self.access_granted or self.access_form_valid:\n", "return super().dispatch(VAR_2, *VAR_3, **kwargs)\n", "return self._render_access_form()\n" ]
[ "def dispatch(self, request, *args, **kwargs):...\n", "logger.debug(f'{self.__class__.__name__} access check')\n", "if (self.access_granted or self.access_form_valid\n", "return self._redirect_from_passphrase(request)\n", "if self.access_granted or self.access_form_valid:\n", "return super().dispatch(request, *args, **kwargs)\n", "return self._render_access_form()\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "For", "Return'", "For", "Return'", "Return'" ]
[ "def FUNC_9(VAR_19):...\n", "VAR_33 = []\n", "for cur_root, _subdirs, files in os.walk(VAR_19):\n", "for f in files:\n", "return VAR_33\n", "VAR_46 = os.path.join(cur_root, f), os.path.join(FUNC_10(VAR_19, cur_root), f)\n", "VAR_33.append(VAR_46)\n" ]
[ "def template_paths(root):...\n", "res = []\n", "for cur_root, _subdirs, files in os.walk(root):\n", "for f in files:\n", "return res\n", "inout = os.path.join(cur_root, f), os.path.join(strip_prefix(root, cur_root), f\n )\n", "res.append(inout)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "For", "Return'", "Assign'", "Expr'" ]
[ "@VAR_0.inclusion_tag('diploma/_diploma_button.html', takes_context=True)...\n", "VAR_3 = _prepare_context(VAR_1, VAR_2)\n", "VAR_4 = CourseDiplomaDesign.objects.filter(course=points.instance).first()\n", "VAR_5 = None\n", "if VAR_4 and VAR_3.user.is_authenticated():\n", "VAR_5 = reverse('diploma-create', kwargs={'coursediploma_id': design.id,\n 'userprofile_id': points.user.userprofile.id})\n", "return {'grade': assign_grade(VAR_3, VAR_4), 'url': VAR_5,\n 'is_course_staff': VAR_1.get('is_course_staff')}\n" ]
[ "@register.inclusion_tag('diploma/_diploma_button.html', takes_context=True)...\n", "points = _prepare_context(context, student)\n", "design = CourseDiplomaDesign.objects.filter(course=points.instance).first()\n", "url = None\n", "if design and points.user.is_authenticated():\n", "url = reverse('diploma-create', kwargs={'coursediploma_id': design.id,\n 'userprofile_id': points.user.userprofile.id})\n", "return {'grade': assign_grade(points, design), 'url': url,\n 'is_course_staff': context.get('is_course_staff')}\n" ]
[ 0, 0, 0, 0, 4, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'" ]
[ "def FUNC_8(self):...\n", "FUNC_1(self.name.upper() + ' SCRIPT')\n", "self.check_verifications_done_before_modifying_system()\n", "self.check_set_usage()\n", "self.check_helper_usage_dependencies()\n", "self.check_deprecated_practices()\n" ]
[ "def analyze(self):...\n", "print_header(self.name.upper() + ' SCRIPT')\n", "self.check_verifications_done_before_modifying_system()\n", "self.check_set_usage()\n", "self.check_helper_usage_dependencies()\n", "self.check_deprecated_practices()\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]