lines
sequencelengths
1
444
raw_lines
sequencelengths
1
444
label
sequencelengths
1
444
type
sequencelengths
1
444
[ "def FUNC_1(VAR_1, VAR_6):...\n", "" ]
[ "def directory_index(path, fullpath):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "@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_13(self, VAR_13):...\n", "if VAR_13:\n", "self._update_backend_status()\n", "return self.device_stats\n" ]
[ "def get_volume_stats(self, refresh):...\n", "if refresh:\n", "self._update_backend_status()\n", "return self.device_stats\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_1(VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "VAR_1.value = beamr.interpreters.Heading(VAR_1.value)\n", "return VAR_1\n" ]
[ "def t_HEADING(t):...\n", "\"\"\"docstring\"\"\"\n", "t.value = beamr.interpreters.Heading(t.value)\n", "return t\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_0(VAR_1, VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_2 or VAR_2 == '/':\n", "return [VAR_1], []\n", "VAR_2 = re.sub('\\\\/+', '/', VAR_2)\n", "if VAR_2.endswith('/'):\n", "VAR_2 = VAR_2[:-1]\n", "if VAR_2.startswith('/'):\n", "VAR_2 = VAR_2[1:]\n", "VAR_2 = VAR_2.split('/')\n", "VAR_5 = [VAR_1]\n", "while VAR_2:\n", "VAR_4 = VAR_2[0]\n", "return VAR_5[1:], VAR_2\n", "VAR_10 = CLASS_0(VAR_5[-1])\n", "VAR_9 = follow_symlinks(VAR_10.traverse(VAR_4))\n", "if not VAR_9:\n", "VAR_5.append(VAR_9)\n", "VAR_2 = VAR_2[1:]\n" ]
[ "def traverse_path(obj, path):...\n", "\"\"\"docstring\"\"\"\n", "if not path or path == '/':\n", "return [obj], []\n", "path = re.sub('\\\\/+', '/', path)\n", "if path.endswith('/'):\n", "path = path[:-1]\n", "if path.startswith('/'):\n", "path = path[1:]\n", "path = path.split('/')\n", "ret = [obj]\n", "while path:\n", "name = path[0]\n", "return ret[1:], path\n", "traverser = ITraverser(ret[-1])\n", "next_obj = follow_symlinks(traverser.traverse(name))\n", "if not next_obj:\n", "ret.append(next_obj)\n", "path = path[1:]\n" ]
[ 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'" ]
[ "from django.utils.translation import string_concat\n", "from django.utils.translation import ugettext_lazy as _\n", "from django.utils.translation import ungettext_lazy\n", "from horizon import tables\n", "from openstack_dashboard import api\n", "from openstack_dashboard.usage import quotas\n", "VAR_0 = ('compute', 'os_compute_api:os-keypairs:delete'),\n", "VAR_1 = _('string')\n", "@staticmethod...\n", "return ungettext_lazy(u'Delete Key Pair', u'Delete Key Pairs', VAR_2)\n" ]
[ "from django.utils.translation import string_concat\n", "from django.utils.translation import ugettext_lazy as _\n", "from django.utils.translation import ungettext_lazy\n", "from horizon import tables\n", "from openstack_dashboard import api\n", "from openstack_dashboard.usage import quotas\n", "policy_rules = ('compute', 'os_compute_api:os-keypairs:delete'),\n", "help_text = _(\n 'Removing a key pair can leave OpenStack resources orphaned. You should not remove a key pair unless you are certain it is not being used anywhere.'\n )\n", "@staticmethod...\n", "return ungettext_lazy(u'Delete Key Pair', u'Delete Key Pairs', count)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_1(self, VAR_1, VAR_2, VAR_5, VAR_6, VAR_4={}):...\n", "\"\"\"docstring\"\"\"\n", "VAR_22 = self.pool.get('stock.location')\n", "VAR_23 = self.pool.get('account.move')\n", "VAR_24 = self.pool.get('account.move.line')\n", "VAR_25 = VAR_6.get('new_price', 0.0)\n", "VAR_19 = VAR_6.get('stock_output_account', False)\n", "VAR_18 = VAR_6.get('stock_input_account', False)\n", "VAR_20 = VAR_6.get('stock_journal', False)\n", "VAR_17 = self.browse(VAR_1, VAR_2, VAR_5)[0]\n", "VAR_21 = VAR_17.categ_id.property_stock_variation\n", "VAR_26 = VAR_21 and VAR_21.id or False\n", "if not VAR_26:\n", "VAR_27 = []\n", "VAR_28 = VAR_22.search(VAR_1, VAR_2, [('usage', '=', 'internal')])\n", "for rec_id in VAR_5:\n", "for location in VAR_22.browse(VAR_1, VAR_2, VAR_28):\n", "return VAR_27\n", "VAR_49 = VAR_4.copy()\n", "self.write(VAR_1, VAR_2, rec_id, {'standard_price': VAR_25})\n", "VAR_49.update({'location': location.id, 'compute_child': False})\n", "VAR_45 = self.browse(VAR_1, VAR_2, rec_id, VAR_4=c)\n", "VAR_53 = VAR_45.qty_available\n", "VAR_54 = VAR_45.standard_price - VAR_25\n", "if not VAR_54:\n", "if VAR_53:\n", "VAR_56 = location.company_id and location.company_id.id or False\n", "if not VAR_56:\n", "if not VAR_20:\n", "VAR_20 = (VAR_45.categ_id.property_stock_journal and VAR_45.categ_id.\n property_stock_journal.id or False)\n", "if not VAR_20:\n", "VAR_57 = VAR_23.create(VAR_1, VAR_2, {'journal_id': VAR_20, 'company_id':\n VAR_56})\n", "VAR_27.append(VAR_57)\n", "if VAR_54 > 0:\n", "if not VAR_18:\n", "if VAR_54 < 0:\n", "VAR_18 = VAR_45.product_tmpl_id.property_stock_account_input.id\n", "if not VAR_18:\n", "if not VAR_19:\n", "VAR_18 = VAR_45.categ_id.property_stock_account_input_categ.id\n", "if not VAR_18:\n", "VAR_19 = VAR_45.product_tmpl_id.property_stock_account_output.id\n", "if not VAR_19:\n", "VAR_58 = VAR_53 * VAR_54\n", "VAR_19 = VAR_45.categ_id.property_stock_account_output_categ.id\n", "if not VAR_19:\n", "VAR_24.create(VAR_1, VAR_2, {'name': VAR_45.name, 'account_id': VAR_18,\n 'debit': VAR_58, 'move_id': VAR_57})\n", "VAR_58 = VAR_53 * -VAR_54\n", "VAR_24.create(VAR_1, VAR_2, {'name': VAR_45.categ_id.name, 'account_id':\n VAR_26, 'credit': VAR_58, 'move_id': VAR_57})\n", "VAR_24.create(VAR_1, VAR_2, {'name': VAR_45.name, 'account_id': VAR_19,\n 'credit': VAR_58, 'move_id': VAR_57})\n", "VAR_24.create(VAR_1, VAR_2, {'name': VAR_45.categ_id.name, 'account_id':\n VAR_26, 'debit': VAR_58, 'move_id': VAR_57})\n" ]
[ "def do_change_standard_price(self, cr, uid, ids, datas, context={}):...\n", "\"\"\"docstring\"\"\"\n", "location_obj = self.pool.get('stock.location')\n", "move_obj = self.pool.get('account.move')\n", "move_line_obj = self.pool.get('account.move.line')\n", "new_price = datas.get('new_price', 0.0)\n", "stock_output_acc = datas.get('stock_output_account', False)\n", "stock_input_acc = datas.get('stock_input_account', False)\n", "journal_id = datas.get('stock_journal', False)\n", "product_obj = self.browse(cr, uid, ids)[0]\n", "account_variation = product_obj.categ_id.property_stock_variation\n", "account_variation_id = account_variation and account_variation.id or False\n", "if not account_variation_id:\n", "move_ids = []\n", "loc_ids = location_obj.search(cr, uid, [('usage', '=', 'internal')])\n", "for rec_id in ids:\n", "for location in location_obj.browse(cr, uid, loc_ids):\n", "return move_ids\n", "c = context.copy()\n", "self.write(cr, uid, rec_id, {'standard_price': new_price})\n", "c.update({'location': location.id, 'compute_child': False})\n", "product = self.browse(cr, uid, rec_id, context=c)\n", "qty = product.qty_available\n", "diff = product.standard_price - new_price\n", "if not diff:\n", "if qty:\n", "company_id = location.company_id and location.company_id.id or False\n", "if not company_id:\n", "if not journal_id:\n", "journal_id = (product.categ_id.property_stock_journal and product.categ_id.\n property_stock_journal.id or False)\n", "if not journal_id:\n", "move_id = move_obj.create(cr, uid, {'journal_id': journal_id, 'company_id':\n company_id})\n", "move_ids.append(move_id)\n", "if diff > 0:\n", "if not stock_input_acc:\n", "if diff < 0:\n", "stock_input_acc = product.product_tmpl_id.property_stock_account_input.id\n", "if not stock_input_acc:\n", "if not stock_output_acc:\n", "stock_input_acc = product.categ_id.property_stock_account_input_categ.id\n", "if not stock_input_acc:\n", "stock_output_acc = product.product_tmpl_id.property_stock_account_output.id\n", "if not stock_output_acc:\n", "amount_diff = qty * diff\n", "stock_output_acc = product.categ_id.property_stock_account_output_categ.id\n", "if not stock_output_acc:\n", "move_line_obj.create(cr, uid, {'name': product.name, 'account_id':\n stock_input_acc, 'debit': amount_diff, 'move_id': move_id})\n", "amount_diff = qty * -diff\n", "move_line_obj.create(cr, uid, {'name': product.categ_id.name, 'account_id':\n account_variation_id, 'credit': amount_diff, 'move_id': move_id})\n", "move_line_obj.create(cr, uid, {'name': product.name, 'account_id':\n stock_output_acc, 'credit': amount_diff, 'move_id': move_id})\n", "move_line_obj.create(cr, uid, {'name': product.categ_id.name, 'account_id':\n account_variation_id, 'debit': amount_diff, 'move_id': move_id})\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 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "For", "For", "Return'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Expr'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_19(self, *VAR_67):...\n", "self._localrules.update(VAR_67)\n" ]
[ "def localrules(self, *rulenames):...\n", "self._localrules.update(rulenames)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_2(VAR_3, VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "VAR_5 = VAR_5.copy()\n", "VAR_18 = FUNC_4(VAR_3)\n", "if VAR_18:\n", "VAR_5['data']['registration_form_desc']['fields'] = FUNC_3(VAR_5['data'][\n 'registration_form_desc'])\n", "VAR_5['enable_enterprise_sidebar'] = False\n", "VAR_5.update(VAR_18)\n", "return VAR_5\n", "VAR_5['enable_enterprise_sidebar'] = True\n", "VAR_5['data']['hide_auth_warnings'] = True\n" ]
[ "def update_context_for_enterprise(request, context):...\n", "\"\"\"docstring\"\"\"\n", "context = context.copy()\n", "sidebar_context = enterprise_sidebar_context(request)\n", "if sidebar_context:\n", "context['data']['registration_form_desc']['fields'] = enterprise_fields_only(\n context['data']['registration_form_desc'])\n", "context['enable_enterprise_sidebar'] = False\n", "context.update(sidebar_context)\n", "return context\n", "context['enable_enterprise_sidebar'] = True\n", "context['data']['hide_auth_warnings'] = True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Return'", "Assign'", "Assign'" ]
[ "def FUNC_1(self):...\n", "return self.get_secure_cookie('username')\n" ]
[ "def get_current_user(self):...\n", "return self.get_secure_cookie('username')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_39(VAR_62):...\n", "return json.loads(VAR_62) if VAR_21 else VAR_62\n" ]
[ "def get_str(_str):...\n", "return json.loads(_str) if as_json else _str\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_0(self):...\n", "VAR_1 = 'sh'\n", "self.assertEqual(escape_path_argument('/home/usr/a-file', VAR_1),\n '/home/usr/a-file')\n", "self.assertEqual(escape_path_argument('/home/usr/a-dir/', VAR_1),\n '/home/usr/a-dir/')\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(\n 'relative something/with cherries and/pickles.delicious', VAR_1),\n 'relative\\\\ something/with\\\\ cherries\\\\ and/pickles.delicious')\n" ]
[ "def test_escape_path_argument_sh(self):...\n", "_type = 'sh'\n", "self.assertEqual(escape_path_argument('/home/usr/a-file', _type),\n '/home/usr/a-file')\n", "self.assertEqual(escape_path_argument('/home/usr/a-dir/', _type),\n '/home/usr/a-dir/')\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(\n 'relative something/with cherries and/pickles.delicious', _type),\n 'relative\\\\ something/with\\\\ cherries\\\\ and/pickles.delicious')\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "@VAR_8.event...\n", "print('{0.user} connected to server'.format(VAR_8))\n", "print('Whitelisted channel IDs are: ' + str(VAR_2))\n", "print('Whitelisted role IDs are: ' + str(VAR_4))\n" ]
[ "@bot.event...\n", "print('{0.user} connected to server'.format(bot))\n", "print('Whitelisted channel IDs are: ' + str(chan_whitelist))\n", "print('Whitelisted role IDs are: ' + str(role_whitelist))\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def __init__(self, VAR_10, VAR_13, VAR_14, VAR_11=None):...\n", "CLASS_1.__init__(self, VAR_10, VAR_11)\n", "self.username = VAR_13\n", "self.password = VAR_14\n", "self.url = '%slogin' % self.base_url\n", "self.data = {'username': self.username, 'password': self.password, 'next': '/'}\n" ]
[ "def __init__(self, browser, username, password, base_url=None):...\n", "GenericRequest.__init__(self, browser, base_url)\n", "self.username = username\n", "self.password = password\n", "self.url = '%slogin' % self.base_url\n", "self.data = {'username': self.username, 'password': self.password, 'next': '/'}\n" ]
[ 0, 0, 0, 0, 5, 5 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "@ndb.transactional...\n", "VAR_14 = WfAnalysis.Get(VAR_5, VAR_6, VAR_7)\n", "if not VAR_14 or not VAR_14.suspected_cls:\n", "return False\n", "VAR_15 = 0\n", "VAR_16 = 0\n", "for VAR_23 in VAR_14.suspected_cls:\n", "if VAR_23['repo_name'] == VAR_0 and VAR_23['revision'] == VAR_1:\n", "if VAR_15 + VAR_16 == len(VAR_14.suspected_cls):\n", "VAR_23['status'] = VAR_3\n", "if VAR_23.get('status') == suspected_cl_status.CORRECT:\n", "if VAR_15 == 0:\n", "VAR_14.put()\n", "VAR_15 += 1\n", "if VAR_23.get('status') == suspected_cl_status.INCORRECT:\n", "VAR_14.result_status = result_status.FOUND_INCORRECT\n", "if VAR_16 == 0:\n", "return True\n", "VAR_16 += 1\n", "VAR_14.result_status = result_status.FOUND_CORRECT\n", "VAR_14.result_status = result_status.PARTIALLY_CORRECT_FOUND\n" ]
[ "@ndb.transactional...\n", "analysis = WfAnalysis.Get(master_name, builder_name, build_number)\n", "if not analysis or not analysis.suspected_cls:\n", "return False\n", "num_correct = 0\n", "num_incorrect = 0\n", "for cl in analysis.suspected_cls:\n", "if cl['repo_name'] == repo_name and cl['revision'] == revision:\n", "if num_correct + num_incorrect == len(analysis.suspected_cls):\n", "cl['status'] = cl_status\n", "if cl.get('status') == suspected_cl_status.CORRECT:\n", "if num_correct == 0:\n", "analysis.put()\n", "num_correct += 1\n", "if cl.get('status') == suspected_cl_status.INCORRECT:\n", "analysis.result_status = result_status.FOUND_INCORRECT\n", "if num_incorrect == 0:\n", "return True\n", "num_incorrect += 1\n", "analysis.result_status = result_status.FOUND_CORRECT\n", "analysis.result_status = result_status.PARTIALLY_CORRECT_FOUND\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "For", "Condition", "Condition", "Assign'", "Condition", "Condition", "Expr'", "AugAssign'", "Condition", "Assign'", "Condition", "Return'", "AugAssign'", "Assign'", "Assign'" ]
[ "def FUNC_0(VAR_1=None):...\n", "\"\"\"docstring\"\"\"\n", "if __grains__['kernel'] == 'Linux':\n", "VAR_4 = 'df -P'\n", "if __grains__['kernel'] == 'OpenBSD':\n", "if VAR_1:\n", "VAR_4 = 'df -kP'\n", "VAR_4 = 'df'\n", "VAR_4 = VAR_4 + ' -' + VAR_1\n", "VAR_2 = {}\n", "VAR_3 = __salt__['cmd.run'](VAR_4).splitlines()\n", "for line in VAR_3:\n", "if not line:\n", "return VAR_2\n", "if line.startswith('Filesystem'):\n", "VAR_5 = line.split()\n", "while not VAR_5[1].isdigit():\n", "VAR_5[0] = '{0} {1}'.format(VAR_5[0], VAR_5[1])\n", "if __grains__['kernel'] == 'Darwin':\n", "VAR_0.warn('Problem parsing disk usage information')\n", "VAR_5.pop(1)\n", "VAR_2[VAR_5[8]] = {'filesystem': VAR_5[0], '512-blocks': VAR_5[1], 'used':\n VAR_5[2], 'available': VAR_5[3], 'capacity': VAR_5[4], 'iused': VAR_5[5\n ], 'ifree': VAR_5[6], '%iused': VAR_5[7]}\n", "VAR_2[VAR_5[5]] = {'filesystem': VAR_5[0], '1K-blocks': VAR_5[1], 'used':\n VAR_5[2], 'available': VAR_5[3], 'capacity': VAR_5[4]}\n", "VAR_2 = {}\n" ]
[ "def usage(args=None):...\n", "\"\"\"docstring\"\"\"\n", "if __grains__['kernel'] == 'Linux':\n", "cmd = 'df -P'\n", "if __grains__['kernel'] == 'OpenBSD':\n", "if args:\n", "cmd = 'df -kP'\n", "cmd = 'df'\n", "cmd = cmd + ' -' + args\n", "ret = {}\n", "out = __salt__['cmd.run'](cmd).splitlines()\n", "for line in out:\n", "if not line:\n", "return ret\n", "if line.startswith('Filesystem'):\n", "comps = line.split()\n", "while not comps[1].isdigit():\n", "comps[0] = '{0} {1}'.format(comps[0], comps[1])\n", "if __grains__['kernel'] == 'Darwin':\n", "log.warn('Problem parsing disk usage information')\n", "comps.pop(1)\n", "ret[comps[8]] = {'filesystem': comps[0], '512-blocks': comps[1], 'used':\n comps[2], 'available': comps[3], 'capacity': comps[4], 'iused': comps[5\n ], 'ifree': comps[6], '%iused': comps[7]}\n", "ret[comps[5]] = {'filesystem': comps[0], '1K-blocks': comps[1], 'used':\n comps[2], 'available': comps[3], 'capacity': comps[4]}\n", "ret = {}\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Condition", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_6(self, VAR_10, VAR_11, VAR_12=None, VAR_20=None):...\n", "VAR_30 = self.uploadFile(VAR_10, VAR_11, VAR_12)\n", "VAR_31 = self.isASuccessfulUpload(VAR_30[0].text)\n", "VAR_23 = {'uploaded': False, 'codeExec': False}\n", "if VAR_31:\n", "VAR_23['uploaded'] = True\n", "return VAR_23\n", "if self.shouldLog:\n", "self.logger.info(\"\\x1b[1;32mUpload of '%s' with mime type %s successful\\x1b[m\",\n VAR_30[1], VAR_11)\n", "if VAR_31 != True:\n", "if self.shouldLog:\n", "if VAR_20 and valid_regex(VAR_20) and (self.uploadsFolder or self.trueRegex):\n", "self.logger.info(\n '\\x1b[1;32m\\tTrue regex matched the following information : %s\\x1b[m',\n VAR_31)\n", "VAR_18 = None\n", "VAR_41 = None\n", "if self.uploadsFolder:\n", "VAR_18 = (self.schema + '://' + self.host + '/' + self.uploadsFolder + '/' +\n VAR_30[1])\n", "if self.codeExecUrlPattern:\n", "VAR_35 = VAR_30[1]\n", "VAR_18 = self.codeExecUrlPattern.replace('$captGroup$', VAR_31)\n", "if VAR_18:\n", "VAR_41 = None\n", "VAR_48 = self.detectCodeExec(VAR_18, VAR_20)\n", "if VAR_41:\n", "for b in getPoisoningBytes():\n", "if VAR_48:\n", "VAR_48 = self.detectCodeExec(VAR_41, VAR_20)\n", "if b in VAR_35:\n", "VAR_23['codeExec'] = True\n", "if VAR_48:\n", "VAR_41 = b.join(VAR_18.split(b)[:-1])\n", "VAR_23['codeExec'] = True\n" ]
[ "def submitTestCase(self, suffix, mime, payload=None, codeExecRegex=None):...\n", "fu = self.uploadFile(suffix, mime, payload)\n", "uploadRes = self.isASuccessfulUpload(fu[0].text)\n", "result = {'uploaded': False, 'codeExec': False}\n", "if uploadRes:\n", "result['uploaded'] = True\n", "return result\n", "if self.shouldLog:\n", "self.logger.info(\"\\x1b[1;32mUpload of '%s' with mime type %s successful\\x1b[m\",\n fu[1], mime)\n", "if uploadRes != True:\n", "if self.shouldLog:\n", "if codeExecRegex and valid_regex(codeExecRegex) and (self.uploadsFolder or\n", "self.logger.info(\n '\\x1b[1;32m\\tTrue regex matched the following information : %s\\x1b[m',\n uploadRes)\n", "url = None\n", "secondUrl = None\n", "if self.uploadsFolder:\n", "url = self.schema + '://' + self.host + '/' + self.uploadsFolder + '/' + fu[1]\n", "if self.codeExecUrlPattern:\n", "filename = fu[1]\n", "url = self.codeExecUrlPattern.replace('$captGroup$', uploadRes)\n", "if url:\n", "secondUrl = None\n", "executedCode = self.detectCodeExec(url, codeExecRegex)\n", "if secondUrl:\n", "for b in getPoisoningBytes():\n", "if executedCode:\n", "executedCode = self.detectCodeExec(secondUrl, codeExecRegex)\n", "if b in filename:\n", "result['codeExec'] = True\n", "if executedCode:\n", "secondUrl = b.join(url.split(b)[:-1])\n", "result['codeExec'] = True\n" ]
[ 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Condition", "Expr'", "Condition", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "For", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_32(VAR_39, VAR_49=None):...\n", "VAR_39.returncode = VAR_1\n", "json.dump(VAR_22, VAR_32)\n", "return 0\n" ]
[ "def wait(self2, timeout=None):...\n", "self2.returncode = returncode\n", "json.dump(result, f)\n", "return 0\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Return'" ]
[ "def __repr__(self):...\n", "return self.rule.name\n" ]
[ "def __repr__(self):...\n", "return self.rule.name\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_9(self, VAR_10):...\n", "VAR_22 = _('local_path not supported')\n" ]
[ "def local_path(self, volume):...\n", "msg = _('local_path not supported')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "def FUNC_34(self):...\n", "\"\"\"docstring\"\"\"\n", "if self.flags.ignore_save_passwords is True:\n", "return\n", "for VAR_25 in self.meta.get('fields', {'fieldtype': ('=', 'Password')}):\n", "if self.flags.ignore_save_passwords and VAR_25.fieldname in self.flags.ignore_save_passwords:\n", "VAR_62 = self.get(VAR_25.fieldname)\n", "if VAR_62 and not self.is_dummy_password(VAR_62):\n", "set_encrypted_password(self.doctype, self.name, VAR_62, VAR_25.fieldname)\n", "self.set(VAR_25.fieldname, '*' * len(VAR_62))\n" ]
[ "def _save_passwords(self):...\n", "\"\"\"docstring\"\"\"\n", "if self.flags.ignore_save_passwords is True:\n", "return\n", "for df in self.meta.get('fields', {'fieldtype': ('=', 'Password')}):\n", "if self.flags.ignore_save_passwords and df.fieldname in self.flags.ignore_save_passwords:\n", "new_password = self.get(df.fieldname)\n", "if new_password and not self.is_dummy_password(new_password):\n", "set_encrypted_password(self.doctype, self.name, new_password, df.fieldname)\n", "self.set(df.fieldname, '*' * len(new_password))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "For", "Condition", "Assign'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_11(VAR_11, VAR_12=0, **VAR_13):...\n", "if VAR_12:\n", "VAR_11[0:0] = [None] * VAR_12\n", "VAR_30 = int(VAR_11.numFound)\n", "VAR_31 = VAR_30 - len(VAR_11)\n", "VAR_11.extend([None] * VAR_31)\n" ]
[ "def padResults(results, start=0, **kw):...\n", "if start:\n", "results[0:0] = [None] * start\n", "found = int(results.numFound)\n", "tail = found - len(results)\n", "results.extend([None] * tail)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "\"\"\"\nUnit tests for the Deis api app.\n\nRun the tests with \"./manage.py test api\\\"\n\"\"\"\n", "from __future__ import unicode_literals\n", "import json\n", "import mock\n", "import requests\n", "from django.test import TransactionTestCase\n", "from api.models import Release\n", "def FUNC_0(*VAR_0, **VAR_1):...\n", "VAR_2 = requests.Response()\n", "VAR_2.status_code = 200\n", "VAR_2._content_consumed = True\n", "return VAR_2\n" ]
[ "\"\"\"\nUnit tests for the Deis api app.\n\nRun the tests with \"./manage.py test api\\\"\n\"\"\"\n", "from __future__ import unicode_literals\n", "import json\n", "import mock\n", "import requests\n", "from django.test import TransactionTestCase\n", "from api.models import Release\n", "def mock_import_repository_task(*args, **kwargs):...\n", "resp = requests.Response()\n", "resp.status_code = 200\n", "resp._content_consumed = True\n", "return resp\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "ImportFrom'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_12(self):...\n", "return self.current_user()['last_name']\n" ]
[ "def current_last_name(self):...\n", "return self.current_user()['last_name']\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "from utils.admin import load_credentials\n", "import MySQLdb\n", "import json\n", "VAR_0 = load_credentials()\n", "VAR_1 = VAR_0['dbhost'], VAR_0['dbuser'], VAR_0['dbpass'], VAR_0['dbname']\n", "def __init__(self):...\n", "self.conn = MySQLdb.connect(*self.dsn)\n", "self.cur = self.conn.cursor()\n", "def __enter__(self):...\n", "return CLASS_0()\n" ]
[ "from utils.admin import load_credentials\n", "import MySQLdb\n", "import json\n", "credentials = load_credentials()\n", "dsn = credentials['dbhost'], credentials['dbuser'], credentials['dbpass'\n ], credentials['dbname']\n", "def __init__(self):...\n", "self.conn = MySQLdb.connect(*self.dsn)\n", "self.cur = self.conn.cursor()\n", "def __enter__(self):...\n", "return DBase()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Import'", "Import'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "FunctionDef'", "Return'" ]
[ "\"\"\"\n Root factory <=> Acl handling\n\"\"\"\n", "from pyramid.security import Allow, Deny, Everyone, Authenticated, ALL_PERMISSIONS\n", "from sqlalchemy.orm import undefer_group\n", "from autonomie.models.config import ConfigFiles\n", "from autonomie.models.activity import Activity\n", "from autonomie.models.company import Company\n", "from autonomie.models.competence import CompetenceGrid, CompetenceGridItem, CompetenceGridSubItem\n", "from autonomie.models.customer import Customer\n", "from autonomie.models.files import File, Template, TemplatingHistory\n", "from autonomie.models.project import Project, Phase\n", "from autonomie.models.task.task import TaskLine, TaskLineGroup, DiscountLine\n", "from autonomie.models.task.estimation import PaymentLine\n", "from autonomie.models.task.estimation import Estimation\n", "from autonomie.models.task.invoice import Invoice, CancelInvoice, Payment\n", "from autonomie.models.workshop import Workshop, Timeslot\n", "from autonomie.models.expense import ExpenseSheet, ExpensePayment, ExpenseType, ExpenseKmType, ExpenseTelType\n", "from autonomie.models.user import User, UserDatas\n", "from autonomie_celery.models import Job\n", "from autonomie.models.statistics import StatisticSheet, StatisticEntry, BaseStatisticCriterion\n", "from autonomie.models.sale_product import SaleProduct, SaleProductGroup, SaleProductCategory\n", "from autonomie.models.tva import Tva\n", "VAR_0 = [(Allow, 'group:admin', ALL_PERMISSIONS), (Deny, 'group:manager', (\n 'admin',)), (Allow, 'group:manager', ALL_PERMISSIONS), (Allow,\n 'group:contractor', ('visit',))]\n", "VAR_1 = [(Allow, 'group:admin', ('admin', 'manage', 'admin_treasury')), (\n Allow, 'group:manager', ('manage', 'admin_treasury'))]\n", "\"\"\"string\"\"\"\n", "__name__ = 'root'\n", "@property...\n", "\"\"\"docstring\"\"\"\n", "VAR_11 = VAR_0[:]\n", "VAR_11.append((Allow, Authenticated, 'view'))\n", "return VAR_11\n" ]
[ "\"\"\"\n Root factory <=> Acl handling\n\"\"\"\n", "from pyramid.security import Allow, Deny, Everyone, Authenticated, ALL_PERMISSIONS\n", "from sqlalchemy.orm import undefer_group\n", "from autonomie.models.config import ConfigFiles\n", "from autonomie.models.activity import Activity\n", "from autonomie.models.company import Company\n", "from autonomie.models.competence import CompetenceGrid, CompetenceGridItem, CompetenceGridSubItem\n", "from autonomie.models.customer import Customer\n", "from autonomie.models.files import File, Template, TemplatingHistory\n", "from autonomie.models.project import Project, Phase\n", "from autonomie.models.task.task import TaskLine, TaskLineGroup, DiscountLine\n", "from autonomie.models.task.estimation import PaymentLine\n", "from autonomie.models.task.estimation import Estimation\n", "from autonomie.models.task.invoice import Invoice, CancelInvoice, Payment\n", "from autonomie.models.workshop import Workshop, Timeslot\n", "from autonomie.models.expense import ExpenseSheet, ExpensePayment, ExpenseType, ExpenseKmType, ExpenseTelType\n", "from autonomie.models.user import User, UserDatas\n", "from autonomie_celery.models import Job\n", "from autonomie.models.statistics import StatisticSheet, StatisticEntry, BaseStatisticCriterion\n", "from autonomie.models.sale_product import SaleProduct, SaleProductGroup, SaleProductCategory\n", "from autonomie.models.tva import Tva\n", "DEFAULT_PERM = [(Allow, 'group:admin', ALL_PERMISSIONS), (Deny,\n 'group:manager', ('admin',)), (Allow, 'group:manager', ALL_PERMISSIONS),\n (Allow, 'group:contractor', ('visit',))]\n", "DEFAULT_PERM_NEW = [(Allow, 'group:admin', ('admin', 'manage',\n 'admin_treasury')), (Allow, 'group:manager', ('manage', 'admin_treasury'))]\n", "\"\"\"\n Ressource factory, returns the appropriate resource regarding\n the request object\n \"\"\"\n", "__name__ = 'root'\n", "@property...\n", "\"\"\"docstring\"\"\"\n", "acl = DEFAULT_PERM[:]\n", "acl.append((Allow, Authenticated, 'view'))\n", "return acl\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 ]
[ "Expr'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Docstring", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_8(VAR_6):...\n", "if 'player1' not in VAR_6.lower() and 'player2' not in VAR_6.lower():\n", "if VAR_1:\n", "if '\"player1\":null' in VAR_6.lower() or '\"player2\":null' in VAR_6.lower():\n", "print('didnt find any players, must be invalid')\n", "return False\n", "if VAR_1:\n", "return True\n", "print('found a null player, must be invalid')\n", "return False\n" ]
[ "def bracket_complete(data):...\n", "if 'player1' not in data.lower() and 'player2' not in data.lower():\n", "if debug:\n", "if '\"player1\":null' in data.lower() or '\"player2\":null' in data.lower():\n", "print('didnt find any players, must be invalid')\n", "return False\n", "if debug:\n", "return True\n", "print('found a null player, must be invalid')\n", "return False\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Condition", "Expr'", "Return'", "Condition", "Return'", "Expr'", "Return'" ]
[ "@api.public...\n", "self.response.write(ipaddr.ip_to_string(api.get_peer_ip()))\n" ]
[ "@api.public...\n", "self.response.write(ipaddr.ip_to_string(api.get_peer_ip()))\n" ]
[ 0, 0 ]
[ "Condition", "Expr'" ]
[ "def FUNC_2(self):...\n", "VAR_17 = \"\"\"\n GROUP BY\n qcp.id,\n chd.date\n \"\"\"\n", "return VAR_17\n" ]
[ "def _group_by(self):...\n", "group_by_str = \"\"\"\n GROUP BY\n qcp.id,\n chd.date\n \"\"\"\n", "return group_by_str\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "\"\"\"string\"\"\"\n", "from tornado.escape import json_encode\n", "import tornado.web\n", "import tornado.ioloop\n", "import api.aggregation\n", "import api.survey\n", "import api.submission\n", "import api.user\n", "from pages.api.aggregations import AggregationHandler\n", "from pages.auth import LogoutHandler, LoginHandler\n", "from pages.api.submissions import SubmissionsAPIHandler, SingleSubmissionAPIHandler, SubmitAPIHandler\n", "from pages.api.surveys import SurveysAPIHandler, SingleSurveyAPIHandler\n", "from pages.util.base import BaseHandler, get_json_request_body, validation_message, catch_bare_integrity_error\n", "import pages.util.ui\n", "from pages.debug import DebugLoginHandler, DebugLogoutHandler\n", "from pages.view.surveys import ViewHandler\n", "from pages.view.submissions import ViewSubmissionsHandler, ViewSubmissionHandler\n", "import settings\n", "from utils.logger import setup_custom_logger\n", "from db.survey import SurveyPrefixDoesNotIdentifyASurveyError, SurveyPrefixTooShortError, get_survey_id_from_prefix, get_surveys_by_email, IncorrectQuestionIdError\n", "VAR_0 = setup_custom_logger('dokomo')\n", "def FUNC_0(self, VAR_5=''):...\n", "VAR_8 = get_surveys_by_email(self.current_user, 10)\n", "self.render('index.html', message=msg, VAR_8=surveys)\n", "def FUNC_1(self):...\n", "LogoutHandler.post(self)\n", "self.get('You logged out')\n", "def FUNC_0(self, VAR_6: str):...\n", "VAR_10 = get_survey_id_from_prefix(VAR_6)\n", "def FUNC_1(self, VAR_7):...\n", "if len(VAR_6) < 36:\n", "SubmitAPIHandler.post(self, VAR_7)\n", "self.redirect('/survey/{}'.format(VAR_10), permanent=False)\n", "VAR_11 = api.survey.display_survey(VAR_10)['result']\n", "@tornado.web.authenticated...\n", "self.render('survey.html', VAR_11=json_encode(survey), survey_title=survey[\n 'survey_title'])\n", "self.write(api.user.generate_token({'email': self.current_user}))\n", "@tornado.web.authenticated...\n", "VAR_9 = get_json_request_body(self)\n", "self.write(api.user.generate_token(VAR_9))\n", "VAR_1 = {'template_path': 'templates', 'static_path': 'static',\n 'xsrf_cookies': True, 'login_url': '/', 'cookie_secret': settings.\n COOKIE_SECRET, 'ui_methods': VAR_3.util.ui, 'debug': True}\n", "VAR_2 = (\n '[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}')\n", "VAR_3 = [('/', CLASS_0), ('/view/?', ViewHandler), ('/view/({})/?'.format(\n VAR_2), ViewSubmissionsHandler), ('/view/submission/({})/?'.format(\n VAR_2), ViewSubmissionHandler), ('/survey/(.+)/?', CLASS_1), (\n '/user/login/persona/?', LoginHandler), ('/user/generate-api-token/?',\n CLASS_2), ('/api/aggregate/({})/?'.format(VAR_2), AggregationHandler),\n ('/api/surveys/?', SurveysAPIHandler), ('/api/surveys/({})/?'.format(\n VAR_2), SingleSurveyAPIHandler), ('/api/surveys/({})/submit/?'.format(\n VAR_2), SubmitAPIHandler), ('/api/surveys/({})/submissions/?'.format(\n VAR_2), SubmissionsAPIHandler), ('/api/submissions/({})/?'.format(VAR_2\n ), SingleSubmissionAPIHandler)]\n", "if VAR_1.get('debug', False):\n", "VAR_3 += [('/debug/login/(.+)/?', DebugLoginHandler), ('/debug/logout/?',\n DebugLogoutHandler)]\n", "VAR_4 = tornado.web.Application(VAR_3, **config)\n", "if __name__ == '__main__':\n", "VAR_4.listen(settings.WEBAPP_PORT, '0.0.0.0')\n", "VAR_0.info('starting server on port ' + str(settings.WEBAPP_PORT))\n", "tornado.ioloop.IOLoop.current().start()\n" ]
[ "\"\"\"\nThis tornado server creates the client app by serving html/css/js and\nit also functions as the wsgi container for accepting survey form post\nrequests back from the client app.\n\"\"\"\n", "from tornado.escape import json_encode\n", "import tornado.web\n", "import tornado.ioloop\n", "import api.aggregation\n", "import api.survey\n", "import api.submission\n", "import api.user\n", "from pages.api.aggregations import AggregationHandler\n", "from pages.auth import LogoutHandler, LoginHandler\n", "from pages.api.submissions import SubmissionsAPIHandler, SingleSubmissionAPIHandler, SubmitAPIHandler\n", "from pages.api.surveys import SurveysAPIHandler, SingleSurveyAPIHandler\n", "from pages.util.base import BaseHandler, get_json_request_body, validation_message, catch_bare_integrity_error\n", "import pages.util.ui\n", "from pages.debug import DebugLoginHandler, DebugLogoutHandler\n", "from pages.view.surveys import ViewHandler\n", "from pages.view.submissions import ViewSubmissionsHandler, ViewSubmissionHandler\n", "import settings\n", "from utils.logger import setup_custom_logger\n", "from db.survey import SurveyPrefixDoesNotIdentifyASurveyError, SurveyPrefixTooShortError, get_survey_id_from_prefix, get_surveys_by_email, IncorrectQuestionIdError\n", "logger = setup_custom_logger('dokomo')\n", "def get(self, msg=''):...\n", "surveys = get_surveys_by_email(self.current_user, 10)\n", "self.render('index.html', message=msg, surveys=surveys)\n", "def post(self):...\n", "LogoutHandler.post(self)\n", "self.get('You logged out')\n", "def get(self, survey_prefix: str):...\n", "survey_id = get_survey_id_from_prefix(survey_prefix)\n", "def post(self, uuid):...\n", "if len(survey_prefix) < 36:\n", "SubmitAPIHandler.post(self, uuid)\n", "self.redirect('/survey/{}'.format(survey_id), permanent=False)\n", "survey = api.survey.display_survey(survey_id)['result']\n", "@tornado.web.authenticated...\n", "self.render('survey.html', survey=json_encode(survey), survey_title=survey[\n 'survey_title'])\n", "self.write(api.user.generate_token({'email': self.current_user}))\n", "@tornado.web.authenticated...\n", "data = get_json_request_body(self)\n", "self.write(api.user.generate_token(data))\n", "config = {'template_path': 'templates', 'static_path': 'static',\n 'xsrf_cookies': True, 'login_url': '/', 'cookie_secret': settings.\n COOKIE_SECRET, 'ui_methods': pages.util.ui, 'debug': True}\n", "UUID_REGEX = (\n '[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}')\n", "pages = [('/', Index), ('/view/?', ViewHandler), ('/view/({})/?'.format(\n UUID_REGEX), ViewSubmissionsHandler), ('/view/submission/({})/?'.format\n (UUID_REGEX), ViewSubmissionHandler), ('/survey/(.+)/?', Survey), (\n '/user/login/persona/?', LoginHandler), ('/user/generate-api-token/?',\n APITokenGenerator), ('/api/aggregate/({})/?'.format(UUID_REGEX),\n AggregationHandler), ('/api/surveys/?', SurveysAPIHandler), (\n '/api/surveys/({})/?'.format(UUID_REGEX), SingleSurveyAPIHandler), (\n '/api/surveys/({})/submit/?'.format(UUID_REGEX), SubmitAPIHandler), (\n '/api/surveys/({})/submissions/?'.format(UUID_REGEX),\n SubmissionsAPIHandler), ('/api/submissions/({})/?'.format(UUID_REGEX),\n SingleSubmissionAPIHandler)]\n", "if config.get('debug', False):\n", "pages += [('/debug/login/(.+)/?', DebugLoginHandler), ('/debug/logout/?',\n DebugLogoutHandler)]\n", "app = tornado.web.Application(pages, **config)\n", "if __name__ == '__main__':\n", "app.listen(settings.WEBAPP_PORT, '0.0.0.0')\n", "logger.info('starting server on port ' + str(settings.WEBAPP_PORT))\n", "tornado.ioloop.IOLoop.current().start()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0 ]
[ "Expr'", "ImportFrom'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "Assign'", "FunctionDef'", "Assign'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "FunctionDef'", "Condition", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Condition", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Condition", "AugAssign'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def __init__(self, VAR_4, VAR_5=False, VAR_6='smash'):...\n", "self.start_time = time.time()\n", "self.testing = VAR_5\n", "self.scenes = VAR_4\n", "VAR_6 = 'smash_test' if VAR_5 else VAR_6\n", "self.db = get_db(db=db_name)\n", "VAR_11 = 'SELECT count(*) FROM matches'\n", "VAR_12 = self.db.exec(VAR_11)\n", "if VAR_12[0][0] == 0:\n", "VAR_2 = True\n", "self.data_processor = processData(self.db)\n", "VAR_3.info('validURL being created')\n" ]
[ "def __init__(self, scenes, testing=False, db_name='smash'):...\n", "self.start_time = time.time()\n", "self.testing = testing\n", "self.scenes = scenes\n", "db_name = 'smash_test' if testing else db_name\n", "self.db = get_db(db=db_name)\n", "sql = 'SELECT count(*) FROM matches'\n", "res = self.db.exec(sql)\n", "if res[0][0] == 0:\n", "should_tweet = True\n", "self.data_processor = processData(self.db)\n", "LOG.info('validURL being created')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_7(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_12 = User(VAR_17=NEW_COMPLETED_SIGNUP_USER_EXAMPLE)\n", "self.app.central_userdb.save(VAR_12, check_sync=False)\n" ]
[ "def init_data(self):...\n", "\"\"\"docstring\"\"\"\n", "test_user = User(data=NEW_COMPLETED_SIGNUP_USER_EXAMPLE)\n", "self.app.central_userdb.save(test_user, check_sync=False)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'" ]
[ "@property...\n", "return self.exists and not os.access(self.file, os.W_OK)\n" ]
[ "@property...\n", "return self.exists and not os.access(self.file, os.W_OK)\n" ]
[ 0, 7 ]
[ "Condition", "Return'" ]
[ "def FUNC_1(self, VAR_7):...\n", "VAR_7.is_valid(self)\n", "VAR_11 = VAR_7.save(sent_by=self.request.user, room=self.room)\n", "if not settings.IS_TESTING:\n", "VAR_9 = {'id': VAR_11.id.__str__(), 'timestamp': VAR_11.time_ago,\n 'timestamp_string': VAR_11.timestamp_string, 'user_handle': self.\n request.user.full_name, 'user_type': self.request.user.user_type,\n 'message': VAR_11.text, 'file_name': os.path.basename(urlparse(VAR_11.\n attachment.path).path) if VAR_11.attachment else None, 'file_link': \n VAR_11.file_download_link if VAR_11.attachment else None}\n", "VAR_8 = get_room_group_channel(VAR_11.room.id)\n", "self.push_socket_update(VAR_8, VAR_9)\n" ]
[ "def perform_create(self, serializer):...\n", "serializer.is_valid(self)\n", "instance = serializer.save(sent_by=self.request.user, room=self.room)\n", "if not settings.IS_TESTING:\n", "data = {'id': instance.id.__str__(), 'timestamp': instance.time_ago,\n 'timestamp_string': instance.timestamp_string, 'user_handle': self.\n request.user.full_name, 'user_type': self.request.user.user_type,\n 'message': instance.text, 'file_name': os.path.basename(urlparse(\n instance.attachment.path).path) if instance.attachment else None,\n 'file_link': instance.file_download_link if instance.attachment else None}\n", "group_channel = get_room_group_channel(instance.room.id)\n", "self.push_socket_update(group_channel, data)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_2(self):...\n", "VAR_6 = BeautifulSoup(self.res_data, 'html.parser')\n", "VAR_7 = {}\n", "VAR_8 = VAR_6.find_all(id='submission_status')[0]\n", "VAR_7['status'] = VAR_8.text.strip()\n", "VAR_9 = VAR_6.find_all(id='compilation')\n", "if VAR_9:\n", "VAR_12 = VAR_9[0]\n", "VAR_7['compile_output'] = None\n", "VAR_7['compile_output'] = '\\n'.join([pre.text.strip() for pre in VAR_12.\n findAll('pre')])\n", "VAR_10 = []\n", "VAR_9 = VAR_6.find_all(id=re.compile('^eval_outcome_'))\n", "VAR_11 = VAR_6.find_all(id=re.compile('^eval_text_'))\n", "for outcome_tag, text_tag in zip(VAR_9, VAR_11):\n", "VAR_10.append({'outcome': outcome_tag.text.strip(), 'text': text_tag.text.\n strip()})\n", "VAR_7['evaluations'] = VAR_10\n", "return VAR_7\n" ]
[ "def get_submission_info(self):...\n", "soup = BeautifulSoup(self.res_data, 'html.parser')\n", "info = {}\n", "tag = soup.find_all(id='submission_status')[0]\n", "info['status'] = tag.text.strip()\n", "tags = soup.find_all(id='compilation')\n", "if tags:\n", "content = tags[0]\n", "info['compile_output'] = None\n", "info['compile_output'] = '\\n'.join([pre.text.strip() for pre in content.\n findAll('pre')])\n", "evaluations = []\n", "tags = soup.find_all(id=re.compile('^eval_outcome_'))\n", "text_tags = soup.find_all(id=re.compile('^eval_text_'))\n", "for outcome_tag, text_tag in zip(tags, text_tags):\n", "evaluations.append({'outcome': outcome_tag.text.strip(), 'text': text_tag.\n text.strip()})\n", "info['evaluations'] = evaluations\n", "return info\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Expr'", "Assign'", "Return'" ]
[ "@defer.inlineCallbacks...\n", "self.creds = self._get_creds_from(VAR_5)\n", "VAR_18, VAR_13, VAR_19 = yield self._portal.login(self.creds, None, IResource)\n", "defer.returnValue(VAR_13)\n" ]
[ "@defer.inlineCallbacks...\n", "self.creds = self._get_creds_from(request)\n", "iface, leap_session, logout = yield self._portal.login(self.creds, None,\n IResource)\n", "defer.returnValue(leap_session)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_3(self):...\n", "VAR_2 = self.connect()\n", "VAR_3 = 'DELETE FROM crimes;'\n", "VAR_2.close()\n", "cursor.execute(VAR_3)\n", "VAR_2.commit()\n" ]
[ "def clear_all(self):...\n", "connection = self.connect()\n", "query = 'DELETE FROM crimes;'\n", "connection.close()\n", "cursor.execute(query)\n", "connection.commit()\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_2(self, VAR_10):...\n", "\"\"\"docstring\"\"\"\n", "VAR_18 = None\n", "if VAR_10 in vars(self):\n", "VAR_18 = getattr(self, VAR_10)\n", "return VAR_18\n" ]
[ "def get_val(self, attr_name):...\n", "\"\"\"docstring\"\"\"\n", "value = None\n", "if attr_name in vars(self):\n", "value = getattr(self, attr_name)\n", "return value\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Return'" ]
[ "import pygame\n", "from draw_utils import Rectangle\n", "from draw_utils import Circle\n", "from draw_utils import Line\n", "from vector2 import Vector2\n", "from a_star import AStar\n", "from graph import Graph\n", "from node import Node\n", "from visual_node import GraphVisual\n", "def FUNC_0():...\n", "pygame.init()\n", "VAR_0 = 1360\n", "VAR_1 = 760\n", "VAR_2 = pygame.display.set_mode((VAR_0, VAR_1))\n", "VAR_2.fill((0, 0, 0))\n", "VAR_3 = Graph(34, 19)\n", "VAR_4 = GraphVisual(VAR_3, 40, VAR_2)\n", "VAR_5 = pygame.rect.Rect(3, 363, 36, 36)\n", "VAR_6 = pygame.rect.Rect(1323, 363, 36, 36)\n", "VAR_7 = Node(Vector2(0, 9))\n", "VAR_8 = Node(Vector2(33, 9))\n", "VAR_9 = AStar(VAR_3, VAR_7, VAR_8)\n", "VAR_10 = []\n", "VAR_11 = []\n", "VAR_12 = False\n", "VAR_13 = False\n", "VAR_14 = False\n", "VAR_15 = False\n", "while True:\n", "VAR_2.fill((0, 0, 0))\n", "VAR_4 = GraphVisual(VAR_3, 40, VAR_2)\n", "for event in pygame.event.get():\n", "if event.type == pygame.QUIT:\n", "pygame.event.pump()\n", "return\n", "if event.type == pygame.MOUSEBUTTONDOWN:\n", "VAR_15 = False\n", "if event.type == pygame.MOUSEBUTTONUP:\n", "if event.button == 1:\n", "VAR_14 = False\n", "if event.type == pygame.MOUSEMOTION:\n", "if VAR_5.collidepoint(event.pos):\n", "if pygame.key.get_pressed()[pygame.K_RETURN]:\n", "if event.button == 1:\n", "if VAR_12:\n", "VAR_12 = True\n", "if VAR_6.collidepoint(event.pos):\n", "VAR_15 = True\n", "if VAR_15:\n", "VAR_16 = 0\n", "VAR_20, VAR_21 = event.pos\n", "if VAR_13:\n", "VAR_20, VAR_21 = event.pos\n", "VAR_13 = True\n", "VAR_16 = 0\n", "if not VAR_11:\n", "VAR_16 = 0\n", "pygame.draw.rect(VAR_2, (0, 255, 0), VAR_5)\n", "if VAR_12 is True or VAR_13 is True:\n", "VAR_5.x = VAR_20 + VAR_22\n", "VAR_20, VAR_21 = event.pos\n", "if VAR_14:\n", "VAR_22 = VAR_5.x - VAR_20\n", "VAR_20, VAR_21 = event.pos\n", "for node in VAR_4.node_visual_colliders:\n", "VAR_11 = VAR_9.find_path()\n", "VAR_9 = AStar(VAR_3, VAR_7, VAR_8)\n", "VAR_17 = 1\n", "pygame.draw.rect(VAR_2, (255, 0, 0), VAR_6)\n", "for collider in VAR_4.node_visual_colliders:\n", "VAR_5.y = VAR_21 + VAR_23\n", "VAR_6.x = VAR_20 + VAR_22\n", "VAR_16 = 0\n", "VAR_23 = VAR_5.y - VAR_21\n", "VAR_22 = VAR_6.x - VAR_20\n", "if node.collidepoint(event.pos) and VAR_14 is False:\n", "VAR_11 = VAR_9.find_path()\n", "while VAR_17 <= len(VAR_11) - 1:\n", "VAR_16 = 0\n", "if VAR_5.colliderect(collider):\n", "VAR_9 = AStar(VAR_3, VAR_7, VAR_8)\n", "VAR_6.y = VAR_21 + VAR_23\n", "for node in VAR_4.node_visual_colliders:\n", "VAR_23 = VAR_6.y - VAR_21\n", "VAR_24 = VAR_3.nodes[VAR_16].is_traversable\n", "VAR_16 += 1\n", "VAR_18 = Vector2(VAR_11[VAR_16].get_x() * 40, VAR_11[VAR_16].get_y() * 40)\n", "for node in VAR_3.nodes:\n", "VAR_5.left = VAR_4.node_visual_colliders[VAR_16].left\n", "if VAR_6.colliderect(collider):\n", "if node.collidepoint(event.pos) and VAR_3.nodes[VAR_16\n", "VAR_14 = True\n", "VAR_19 = Vector2(VAR_11[VAR_17].get_x() * 40, VAR_11[VAR_17].get_y() * 40)\n", "if node.is_traversable is False:\n", "pygame.display.flip()\n", "VAR_5.top = VAR_4.node_visual_colliders[VAR_16].top\n", "VAR_6.left = VAR_4.node_visual_colliders[VAR_16].left\n", "VAR_16 += 1\n", "VAR_3.nodes[VAR_16].toggle_state('wall')\n", "VAR_16 += 1\n", "VAR_10.append(Line(VAR_2, (0, 0, 255), Vector2(VAR_18.x_pos + 20, VAR_18.\n y_pos + 20), Vector2(VAR_19.x_pos + 20, VAR_19.y_pos + 20), 5))\n", "pygame.draw.rect(VAR_2, (0, 0, 0), VAR_4.node_visual_colliders[VAR_16])\n", "VAR_16 += 1\n", "VAR_12 = False\n", "VAR_6.top = VAR_4.node_visual_colliders[VAR_16].top\n", "VAR_16 += 1\n", "VAR_7 = Node(Vector2(VAR_4.node_visuals[VAR_16].node.get_x(), VAR_4.\n node_visuals[VAR_16].node.get_y()))\n", "VAR_13 = False\n", "VAR_17 += 1\n", "VAR_8 = Node(Vector2(VAR_4.node_visuals[VAR_16].node.get_x(), VAR_4.\n node_visuals[VAR_16].node.get_y()))\n" ]
[ "import pygame\n", "from draw_utils import Rectangle\n", "from draw_utils import Circle\n", "from draw_utils import Line\n", "from vector2 import Vector2\n", "from a_star import AStar\n", "from graph import Graph\n", "from node import Node\n", "from visual_node import GraphVisual\n", "def main():...\n", "pygame.init()\n", "screen_width = 1360\n", "screen_height = 760\n", "screen = pygame.display.set_mode((screen_width, screen_height))\n", "screen.fill((0, 0, 0))\n", "grid = Graph(34, 19)\n", "visual_graph = GraphVisual(grid, 40, screen)\n", "start_square = pygame.rect.Rect(3, 363, 36, 36)\n", "goal_square = pygame.rect.Rect(1323, 363, 36, 36)\n", "start_node = Node(Vector2(0, 9))\n", "goal_node = Node(Vector2(33, 9))\n", "astar = AStar(grid, start_node, goal_node)\n", "drawn_path = []\n", "path = []\n", "dragging_start = False\n", "dragging_goal = False\n", "mouse_is_down = False\n", "pressed_enter = False\n", "while True:\n", "screen.fill((0, 0, 0))\n", "visual_graph = GraphVisual(grid, 40, screen)\n", "for event in pygame.event.get():\n", "if event.type == pygame.QUIT:\n", "pygame.event.pump()\n", "return\n", "if event.type == pygame.MOUSEBUTTONDOWN:\n", "pressed_enter = False\n", "if event.type == pygame.MOUSEBUTTONUP:\n", "if event.button == 1:\n", "mouse_is_down = False\n", "if event.type == pygame.MOUSEMOTION:\n", "if start_square.collidepoint(event.pos):\n", "if pygame.key.get_pressed()[pygame.K_RETURN]:\n", "if event.button == 1:\n", "if dragging_start:\n", "dragging_start = True\n", "if goal_square.collidepoint(event.pos):\n", "pressed_enter = True\n", "if pressed_enter:\n", "count = 0\n", "mouse_x, mouse_y = event.pos\n", "if dragging_goal:\n", "mouse_x, mouse_y = event.pos\n", "dragging_goal = True\n", "count = 0\n", "if not path:\n", "count = 0\n", "pygame.draw.rect(screen, (0, 255, 0), start_square)\n", "if dragging_start is True or dragging_goal is True:\n", "start_square.x = mouse_x + offset_x\n", "mouse_x, mouse_y = event.pos\n", "if mouse_is_down:\n", "offset_x = start_square.x - mouse_x\n", "mouse_x, mouse_y = event.pos\n", "for node in visual_graph.node_visual_colliders:\n", "path = astar.find_path()\n", "astar = AStar(grid, start_node, goal_node)\n", "count_two = 1\n", "pygame.draw.rect(screen, (255, 0, 0), goal_square)\n", "for collider in visual_graph.node_visual_colliders:\n", "start_square.y = mouse_y + offset_y\n", "goal_square.x = mouse_x + offset_x\n", "count = 0\n", "offset_y = start_square.y - mouse_y\n", "offset_x = goal_square.x - mouse_x\n", "if node.collidepoint(event.pos) and mouse_is_down is False:\n", "path = astar.find_path()\n", "while count_two <= len(path) - 1:\n", "count = 0\n", "if start_square.colliderect(collider):\n", "astar = AStar(grid, start_node, goal_node)\n", "goal_square.y = mouse_y + offset_y\n", "for node in visual_graph.node_visual_colliders:\n", "offset_y = goal_square.y - mouse_y\n", "current_state = grid.nodes[count].is_traversable\n", "count += 1\n", "line_start = Vector2(path[count].get_x() * 40, path[count].get_y() * 40)\n", "for node in grid.nodes:\n", "start_square.left = visual_graph.node_visual_colliders[count].left\n", "if goal_square.colliderect(collider):\n", "if node.collidepoint(event.pos) and grid.nodes[count\n", "mouse_is_down = True\n", "line_end = Vector2(path[count_two].get_x() * 40, path[count_two].get_y() * 40)\n", "if node.is_traversable is False:\n", "pygame.display.flip()\n", "start_square.top = visual_graph.node_visual_colliders[count].top\n", "goal_square.left = visual_graph.node_visual_colliders[count].left\n", "count += 1\n", "grid.nodes[count].toggle_state('wall')\n", "count += 1\n", "drawn_path.append(Line(screen, (0, 0, 255), Vector2(line_start.x_pos + 20, \n line_start.y_pos + 20), Vector2(line_end.x_pos + 20, line_end.y_pos + \n 20), 5))\n", "pygame.draw.rect(screen, (0, 0, 0), visual_graph.node_visual_colliders[count])\n", "count += 1\n", "dragging_start = False\n", "goal_square.top = visual_graph.node_visual_colliders[count].top\n", "count += 1\n", "start_node = Node(Vector2(visual_graph.node_visuals[count].node.get_x(),\n visual_graph.node_visuals[count].node.get_y()))\n", "dragging_goal = False\n", "count_two += 1\n", "goal_node = Node(Vector2(visual_graph.node_visuals[count].node.get_x(),\n visual_graph.node_visuals[count].node.get_y()))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "For", "Condition", "Expr'", "Return'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Condition", "Condition", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Assign'", "Expr'", "For", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "For", "Assign'", "Assign'", "AugAssign'", "Assign'", "For", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "AugAssign'", "Expr'", "AugAssign'", "Expr'", "Expr'", "AugAssign'", "Assign'", "Assign'", "AugAssign'", "Assign'", "Assign'", "AugAssign'", "Assign'" ]
[ "def FUNC_6(self):...\n", "super().continue_dut('resume')\n" ]
[ "def continue_dut(self):...\n", "super().continue_dut('resume')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_14(self, VAR_8):...\n", "\"\"\"docstring\"\"\"\n", "VAR_7 = \"DELETE FROM {0} WHERE path='{1}';\".format(VAR_2, VAR_8)\n", "self._run_command(VAR_7)\n" ]
[ "def deleteFile(self, pth):...\n", "\"\"\"docstring\"\"\"\n", "command = \"DELETE FROM {0} WHERE path='{1}';\".format(TABLE_NAME, pth)\n", "self._run_command(command)\n" ]
[ 0, 0, 4, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'" ]
[ "def FUNC_6(self, VAR_47):...\n", "if VAR_101.user_is_admin:\n", "return True\n", "if VAR_101.user_is_loggedin:\n", "VAR_18 = Thing._by_fullname(VAR_47, data=True)\n", "abort(403, 'forbidden')\n", "VAR_109 = VAR_18.subreddit_slow\n", "if VAR_109.can_ban(VAR_101.user):\n", "return True\n" ]
[ "def run(self, thing_name):...\n", "if c.user_is_admin:\n", "return True\n", "if c.user_is_loggedin:\n", "item = Thing._by_fullname(thing_name, data=True)\n", "abort(403, 'forbidden')\n", "subreddit = item.subreddit_slow\n", "if subreddit.can_ban(c.user):\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Condition", "Assign'", "Expr'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_1(self, VAR_2, VAR_4=None):...\n", "VAR_1 = self.current_user\n", "VAR_13 = False\n", "VAR_14 = False\n", "VAR_2 = db.get_dataset(VAR_2)\n", "if VAR_4:\n", "VAR_4 = db.DatasetVersion.select().where(db.DatasetVersion.version == VAR_4,\n db.DatasetVersion.dataset == VAR_2).get()\n", "VAR_4 = VAR_2.current_version.get()\n", "if VAR_4.available_from > datetime.now():\n", "VAR_13 = True\n", "if not (VAR_1 and VAR_1.is_admin(VAR_2)):\n", "if not VAR_13:\n", "self.send_error(status_code=403)\n", "VAR_14 = True\n", "VAR_37 = VAR_2.current_version.get()\n", "VAR_12 = FUNC_0(VAR_4, VAR_1, VAR_2)\n", "return\n", "VAR_13 = VAR_37.version == VAR_4.version\n", "VAR_12['current'] = VAR_13\n", "VAR_12['future'] = VAR_14\n", "self.finish(VAR_12)\n" ]
[ "def get(self, dataset, version=None):...\n", "user = self.current_user\n", "current_version = False\n", "future_version = False\n", "dataset = db.get_dataset(dataset)\n", "if version:\n", "version = db.DatasetVersion.select().where(db.DatasetVersion.version ==\n version, db.DatasetVersion.dataset == dataset).get()\n", "version = dataset.current_version.get()\n", "if version.available_from > datetime.now():\n", "current_version = True\n", "if not (user and user.is_admin(dataset)):\n", "if not current_version:\n", "self.send_error(status_code=403)\n", "future_version = True\n", "cv = dataset.current_version.get()\n", "ret = build_dataset_structure(version, user, dataset)\n", "return\n", "current_version = cv.version == version.version\n", "ret['current'] = current_version\n", "ret['future'] = future_version\n", "self.finish(ret)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_16(VAR_24):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_21(VAR_55):...\n", "@wraps(VAR_55)...\n", "def FUNC_27(VAR_6):...\n", "if callable(VAR_6):\n", "return VAR_6()\n", "if request.method == 'POST':\n", "return VAR_55(*VAR_69, **kwargs)\n", "VAR_10 = json.loads(request.data)\n", "VAR_54 = {'error': {'type': 'schema', 'message': str(e)}, 'schema': VAR_24}\n", "schemas.validate(VAR_10, VAR_24)\n", "return json.dumps(VAR_54, sort_keys=True, indent=4, default=default_encode\n ), 400, {'Content-Type': 'application/json'}\n", "VAR_70['validated_body'] = VAR_10\n", "if VAR_70.get('timer'):\n", "VAR_70['timer'].mark('validate_schema')\n" ]
[ "def validate_request(schema):...\n", "\"\"\"docstring\"\"\"\n", "def decorator(func):...\n", "@wraps(func)...\n", "def default_encode(value):...\n", "if callable(value):\n", "return value()\n", "if request.method == 'POST':\n", "return func(*args, **kwargs)\n", "body = json.loads(request.data)\n", "result = {'error': {'type': 'schema', 'message': str(e)}, 'schema': schema}\n", "schemas.validate(body, schema)\n", "return json.dumps(result, sort_keys=True, indent=4, default=default_encode\n ), 400, {'Content-Type': 'application/json'}\n", "kwargs['validated_body'] = body\n", "if kwargs.get('timer'):\n", "kwargs['timer'].mark('validate_schema')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Condition", "FunctionDef'", "Condition", "Return'", "Condition", "Return'", "Assign'", "Assign'", "Expr'", "Return'", "Assign'", "Condition", "Expr'" ]
[ "def FUNC_10(self, VAR_12):...\n", "\"\"\"docstring\"\"\"\n", "for t in ids_to_tasks(VAR_12).split(','):\n", "VAR_29 = get_task_module(t)\n", "if hasattr(VAR_29, 'add_cmdline_args'):\n", "VAR_29.add_cmdline_args(self)\n" ]
[ "def add_task_args(self, task):...\n", "\"\"\"docstring\"\"\"\n", "for t in ids_to_tasks(task).split(','):\n", "agent = get_task_module(t)\n", "if hasattr(agent, 'add_cmdline_args'):\n", "agent.add_cmdline_args(self)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "For", "Assign'", "Condition", "Expr'" ]
[ "def FUNC_24(self, VAR_28):...\n", "\"\"\"docstring\"\"\"\n", "VAR_58 = VAR_28,\n", "if self.execute('SELECT * FROM history WHERE nzo_id=?', VAR_58):\n", "return VAR_83, VAR_34, VAR_39, VAR_40, VAR_84\n", "VAR_64 = self.c.fetchall()[0]\n", "return '', '', '', '', ''\n", "VAR_83 = VAR_64.get('report')\n", "VAR_34 = VAR_64.get('url')\n", "VAR_39 = VAR_64.get('pp')\n", "VAR_40 = VAR_64.get('script')\n", "VAR_84 = VAR_64.get('category')\n" ]
[ "def get_other(self, nzo_id):...\n", "\"\"\"docstring\"\"\"\n", "t = nzo_id,\n", "if self.execute('SELECT * FROM history WHERE nzo_id=?', t):\n", "return dtype, url, pp, script, cat\n", "items = self.c.fetchall()[0]\n", "return '', '', '', '', ''\n", "dtype = items.get('report')\n", "url = items.get('url')\n", "pp = items.get('pp')\n", "script = items.get('script')\n", "cat = items.get('category')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Return'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_18(VAR_32, VAR_33, VAR_5=False):...\n", "\"\"\"docstring\"\"\"\n", "VAR_60 = {}\n", "VAR_52 = {}\n", "for VAR_93, _ in VAR_32:\n", "for VAR_83 in VAR_93.fieldcodes:\n", "for VAR_94, _ in VAR_33:\n", "VAR_60.setdefault(VAR_83, set()).add(VAR_93.output(VAR_5))\n", "if len(VAR_94.fieldcodes):\n", "for VAR_83, VAR_36 in VAR_60.items():\n", "for VAR_83 in VAR_94.fieldcodes:\n", "for VAR_62 in VAR_94.getComponents():\n", "VAR_52[VAR_83] = ', '.join(VAR_36)\n", "return VAR_52\n", "VAR_60.setdefault(VAR_83, set()).add(VAR_94.output(VAR_5))\n", "for VAR_83 in VAR_62.fieldcodes:\n", "VAR_60.setdefault(VAR_83, set()).add('%s*' % VAR_94.output(VAR_5))\n", "VAR_60.setdefault('*', set()).add(VAR_62.output(VAR_5))\n" ]
[ "def _get_fieldcodes(skw_matches, ckw_matches, spires=False):...\n", "\"\"\"docstring\"\"\"\n", "fieldcodes = {}\n", "output = {}\n", "for skw, _ in skw_matches:\n", "for fieldcode in skw.fieldcodes:\n", "for ckw, _ in ckw_matches:\n", "fieldcodes.setdefault(fieldcode, set()).add(skw.output(spires))\n", "if len(ckw.fieldcodes):\n", "for fieldcode, keywords in fieldcodes.items():\n", "for fieldcode in ckw.fieldcodes:\n", "for kw in ckw.getComponents():\n", "output[fieldcode] = ', '.join(keywords)\n", "return output\n", "fieldcodes.setdefault(fieldcode, set()).add(ckw.output(spires))\n", "for fieldcode in kw.fieldcodes:\n", "fieldcodes.setdefault(fieldcode, set()).add('%s*' % ckw.output(spires))\n", "fieldcodes.setdefault('*', set()).add(kw.output(spires))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "For", "For", "For", "Expr'", "Condition", "For", "For", "For", "Assign'", "Return'", "Expr'", "For", "Expr'", "Expr'" ]
[ "def FUNC_0(self, VAR_8, VAR_2):...\n", "VAR_14 = self.__cache_map[VAR_8]\n", "return VAR_14.get_by_id(VAR_2)\n" ]
[ "def get_by_id(self, entity_class, entity_id):...\n", "cache = self.__cache_map[entity_class]\n", "return cache.get_by_id(entity_id)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_5():...\n", "self.set_status(404, 'Not Found')\n", "self._headers = tornado.httputil.HTTPHeaders()\n", "self.add_header('Content-Length', '0')\n", "self.flush()\n", "return\n" ]
[ "def invoke_404():...\n", "self.set_status(404, 'Not Found')\n", "self._headers = tornado.httputil.HTTPHeaders()\n", "self.add_header('Content-Length', '0')\n", "self.flush()\n", "return\n" ]
[ 0, 0, 0, 0, 0, 4 ]
[ "FunctionDef'", "Expr'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_3(VAR_9, VAR_10):...\n", "VAR_15 = VAR_9.search_fields and VAR_9.search_fields.split(',') or []\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_15 = ['name'] + VAR_15 + VAR_16\n", "if not VAR_10 in VAR_15:\n", "VAR_15 = VAR_15 + [VAR_10]\n", "return VAR_15\n" ]
[ "def get_std_fields_list(meta, key):...\n", "sflist = meta.search_fields and meta.search_fields.split(',') or []\n", "title_field = [meta.title_field\n ] if meta.title_field and meta.title_field not in sflist else []\n", "sflist = ['name'] + sflist + title_field\n", "if not key in sflist:\n", "sflist = sflist + [key]\n", "return sflist\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'" ]
[ "def __init__(self, VAR_17):...\n", "self.json = VAR_17\n" ]
[ "def __init__(self, json):...\n", "self.json = json\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "@tornado.web.authenticated...\n", "self.doSettings(False)\n" ]
[ "@tornado.web.authenticated...\n", "self.doSettings(False)\n" ]
[ 0, 0 ]
[ "Condition", "Expr'" ]
[ "def FUNC_16(self, VAR_21, VAR_22, VAR_20=None):...\n", "\"\"\"docstring\"\"\"\n", "if type(VAR_21) == str:\n", "VAR_21 = self.locate(VAR_21)\n", "if type(VAR_22) == str:\n", "VAR_22 = self.locate(VAR_22)\n", "if not VAR_21 or not VAR_22:\n", "return False\n", "VAR_50 = FUNC_16.deepcopy(VAR_21)\n", "VAR_50.parent = VAR_22\n", "VAR_22.sub_items.add(VAR_50)\n", "VAR_22.sub_names_idx[VAR_50.file_name] = VAR_50\n", "self._copy_recursive(VAR_50, VAR_22, VAR_20)\n", "self._update_in_db(VAR_22)\n", "return True\n" ]
[ "def copy(self, source, target_parent, new_owner=None):...\n", "\"\"\"docstring\"\"\"\n", "if type(source) == str:\n", "source = self.locate(source)\n", "if type(target_parent) == str:\n", "target_parent = self.locate(target_parent)\n", "if not source or not target_parent:\n", "return False\n", "target = copy.deepcopy(source)\n", "target.parent = target_parent\n", "target_parent.sub_items.add(target)\n", "target_parent.sub_names_idx[target.file_name] = target\n", "self._copy_recursive(target, target_parent, new_owner)\n", "self._update_in_db(target_parent)\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def __exit__(self, VAR_27, VAR_28, VAR_29):...\n", "os.dup2(self.backup, self.fd)\n" ]
[ "def __exit__(self, type, value, traceback):...\n", "os.dup2(self.backup, self.fd)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_20(self, VAR_14):...\n", "" ]
[ "def is_relation_one_to_one(self, col_name):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "from osv import osv\n", "from tools.translate import _\n", "VAR_0 = 'pos.close.statement'\n", "VAR_1 = 'Close Statements'\n", "def FUNC_0(self, VAR_2, VAR_3, VAR_4, VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = self.pool.get('res.users').browse(VAR_2, VAR_3, VAR_3).company_id.id\n", "VAR_7 = []\n", "VAR_8 = self.pool.get('ir.model.data')\n", "VAR_9 = self.pool.get('account.bank.statement')\n", "VAR_10 = self.pool.get('account.journal')\n", "VAR_2.execute(\n 'select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id'\n % VAR_3)\n", "VAR_11 = map(lambda x1: x1[0], VAR_2.fetchall())\n", "VAR_2.execute('string' % ','.join(map(lambda x: \"'\" + str(x) + \"'\", VAR_11)))\n", "VAR_12 = map(lambda x1: x1[0], VAR_2.fetchall())\n", "for journal in VAR_10.browse(VAR_2, VAR_3, VAR_12):\n", "VAR_4 = VAR_9.search(VAR_2, VAR_3, [('state', '!=', 'confirm'), ('user_id',\n '=', VAR_3), ('journal_id', '=', journal.id)])\n", "VAR_13 = self.pool.get('ir.model.data')\n", "if not VAR_4:\n", "VAR_14 = VAR_13._get_id(VAR_2, VAR_3, 'account', 'view_bank_statement_tree')\n", "VAR_7.append(VAR_4[0])\n", "VAR_15 = VAR_13._get_id(VAR_2, VAR_3, 'account', 'view_bank_statement_form2')\n", "if not journal.check_dtls:\n", "if VAR_14:\n", "VAR_9.button_confirm_cash(VAR_2, VAR_3, VAR_4, VAR_5)\n", "VAR_14 = VAR_13.browse(VAR_2, VAR_3, VAR_14, VAR_5=context).res_id\n", "if VAR_15:\n", "VAR_15 = VAR_13.browse(VAR_2, VAR_3, VAR_15, VAR_5=context).res_id\n", "return {'domain': \"[('id','in',\" + str(VAR_7) + ')]', 'name':\n 'Close Statements', 'view_type': 'form', 'view_mode': 'tree,form',\n 'res_model': 'account.bank.statement', 'views': [(VAR_14, 'tree'), (\n VAR_15, 'form')], 'type': 'ir.actions.act_window'}\n" ]
[ "from osv import osv\n", "from tools.translate import _\n", "_name = 'pos.close.statement'\n", "_description = 'Close Statements'\n", "def close_statement(self, cr, uid, ids, context):...\n", "\"\"\"docstring\"\"\"\n", "company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id\n", "list_statement = []\n", "mod_obj = self.pool.get('ir.model.data')\n", "statement_obj = self.pool.get('account.bank.statement')\n", "journal_obj = self.pool.get('account.journal')\n", "cr.execute(\n 'select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id'\n % uid)\n", "j_ids = map(lambda x1: x1[0], cr.fetchall())\n", "cr.execute(\n \"\"\" select id from account_journal\n where auto_cash='True' and type='cash'\n and id in (%s)\"\"\"\n % ','.join(map(lambda x: \"'\" + str(x) + \"'\", j_ids)))\n", "journal_ids = map(lambda x1: x1[0], cr.fetchall())\n", "for journal in journal_obj.browse(cr, uid, journal_ids):\n", "ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id',\n '=', uid), ('journal_id', '=', journal.id)])\n", "data_obj = self.pool.get('ir.model.data')\n", "if not ids:\n", "id2 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')\n", "list_statement.append(ids[0])\n", "id3 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')\n", "if not journal.check_dtls:\n", "if id2:\n", "statement_obj.button_confirm_cash(cr, uid, ids, context)\n", "id2 = data_obj.browse(cr, uid, id2, context=context).res_id\n", "if id3:\n", "id3 = data_obj.browse(cr, uid, id3, context=context).res_id\n", "return {'domain': \"[('id','in',\" + str(list_statement) + ')]', 'name':\n 'Close Statements', 'view_type': 'form', 'view_mode': 'tree,form',\n 'res_model': 'account.bank.statement', 'views': [(id2, 'tree'), (id3,\n 'form')], 'type': 'ir.actions.act_window'}\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "For", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Condition", "Assign'", "Return'" ]
[ "@cached_property...\n", "\"\"\"docstring\"\"\"\n", "return [VAR_46 for VAR_46 in self.composite_fields if getattr(VAR_46,\n 'use_container', False)]\n" ]
[ "@cached_property...\n", "\"\"\"docstring\"\"\"\n", "return [f for f in self.composite_fields if getattr(f, 'use_container', False)]\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def FUNC_4(VAR_6, VAR_7=3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = list(VAR_6)\n", "VAR_26 = lambda : [VAR_0 for VAR_0 in VAR_6 if not os.path.exists(VAR_0)]\n", "VAR_27 = VAR_26()\n", "if VAR_27:\n", "logger.info('Waiting at most {} seconds for missing files.'.format(VAR_7))\n", "for _ in range(VAR_7):\n", "if not VAR_26():\n", "return\n", "VAR_23.sleep(1)\n" ]
[ "def wait_for_files(files, latency_wait=3):...\n", "\"\"\"docstring\"\"\"\n", "files = list(files)\n", "get_missing = lambda : [f for f in files if not os.path.exists(f)]\n", "missing = get_missing()\n", "if missing:\n", "logger.info('Waiting at most {} seconds for missing files.'.format(\n latency_wait))\n", "for _ in range(latency_wait):\n", "if not get_missing():\n", "return\n", "time.sleep(1)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "For", "Condition", "Return'", "Expr'" ]
[ "def FUNC_1(VAR_0, VAR_1):...\n", "VAR_10 = StringIO()\n", "VAR_11 = csv.writer(VAR_10)\n", "VAR_12 = ['#datetime', 'user', 'screen_name', 'text']\n", "VAR_11.writerow(VAR_12)\n", "for tw in tweet.objects.filter(hunt_id=Hunt(id=pk)).order_by('datetime'):\n", "VAR_21 = tw.datetime.astimezone(timezone('Asia/Tokyo'))\n", "VAR_13 = BytesIO(BOM_UTF8 + VAR_10.getvalue().encode('utf8'))\n", "VAR_22 = [VAR_21, tw.user, tw.screen_name, tw.text]\n", "VAR_14 = HttpResponse(VAR_13.getvalue(), content_type='text/csv')\n", "VAR_11.writerow(VAR_22)\n", "VAR_14['Content-Disposition'] = 'filename=hunter%s.csv' % VAR_1\n", "return VAR_14\n" ]
[ "def hunt_export(request, pk):...\n", "stream = StringIO()\n", "writer = csv.writer(stream)\n", "header = ['#datetime', 'user', 'screen_name', 'text']\n", "writer.writerow(header)\n", "for tw in tweet.objects.filter(hunt_id=Hunt(id=pk)).order_by('datetime'):\n", "dt = tw.datetime.astimezone(timezone('Asia/Tokyo'))\n", "b_stream = BytesIO(BOM_UTF8 + stream.getvalue().encode('utf8'))\n", "row = [dt, tw.user, tw.screen_name, tw.text]\n", "response = HttpResponse(b_stream.getvalue(), content_type='text/csv')\n", "writer.writerow(row)\n", "response['Content-Disposition'] = 'filename=hunter%s.csv' % pk\n", "return response\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "For", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_24(self, VAR_21):...\n", "\"\"\"docstring\"\"\"\n", "VAR_57 = self.getfile(VAR_21, VAR_23=False)\n", "if VAR_57 == False:\n", "self.get_path(os.path.dirname(VAR_21)).remove(VAR_57)\n", "return\n" ]
[ "def remove(self, path):...\n", "\"\"\"docstring\"\"\"\n", "p = self.getfile(path, follow_symlinks=False)\n", "if p == False:\n", "self.get_path(os.path.dirname(path)).remove(p)\n", "return\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_1(self, VAR_6, VAR_7=True, VAR_8=1):...\n", "if not self.sshpool:\n", "VAR_13 = self.configuration.san_password\n", "VAR_12 = None\n", "VAR_14 = self.configuration.san_private_key\n", "VAR_17 = VAR_8\n", "VAR_0.error(_('Error running SSH command: %s') % VAR_6)\n", "VAR_15 = self.configuration.ssh_min_pool_conn\n", "while VAR_8 > 0:\n", "VAR_16 = self.configuration.ssh_max_pool_conn\n", "VAR_8 -= 1\n", "self.sshpool = utils.SSHPool(self.configuration.san_ip, self.configuration.\n san_ssh_port, self.configuration.ssh_conn_timeout, self.configuration.\n san_login, VAR_13=password, VAR_14=privatekey, VAR_15=min_size, VAR_16=\n max_size)\n", "return utils.ssh_execute(ssh, VAR_6, VAR_7=check_exit_code)\n", "VAR_0.error(e)\n", "VAR_12 = e\n", "greenthread.sleep(random.randint(20, 500) / 100.0)\n" ]
[ "def _run_ssh(self, command, check_exit_code=True, attempts=1):...\n", "if not self.sshpool:\n", "password = self.configuration.san_password\n", "last_exception = None\n", "privatekey = self.configuration.san_private_key\n", "total_attempts = attempts\n", "LOG.error(_('Error running SSH command: %s') % command)\n", "min_size = self.configuration.ssh_min_pool_conn\n", "while attempts > 0:\n", "max_size = self.configuration.ssh_max_pool_conn\n", "attempts -= 1\n", "self.sshpool = utils.SSHPool(self.configuration.san_ip, self.configuration.\n san_ssh_port, self.configuration.ssh_conn_timeout, self.configuration.\n san_login, password=password, privatekey=privatekey, min_size=min_size,\n max_size=max_size)\n", "return utils.ssh_execute(ssh, command, check_exit_code=check_exit_code)\n", "LOG.error(e)\n", "last_exception = e\n", "greenthread.sleep(random.randint(20, 500) / 100.0)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "AugAssign'", "Assign'", "Return'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_17(VAR_29):...\n", "" ]
[ "def get_option(key):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_11(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_15 = self.clone()\n", "if VAR_15.charset is None:\n", "VAR_17 = b'/'\n", "VAR_17 = '/'\n", "VAR_16 = VAR_17 + VAR_17.join(VAR_15.parts)\n", "if VAR_15._trailing_slash:\n", "VAR_16 += VAR_17\n", "return VAR_16\n" ]
[ "def to_route(self):...\n", "\"\"\"docstring\"\"\"\n", "clone = self.clone()\n", "if clone.charset is None:\n", "slash = b'/'\n", "slash = '/'\n", "route = slash + slash.join(clone.parts)\n", "if clone._trailing_slash:\n", "route += slash\n", "return route\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "AugAssign'", "Return'" ]
[ "def FUNC_1(self, VAR_9):...\n", "VAR_17 = self.get_val('mydict')\n", "VAR_17['package_list'] = VAR_9\n" ]
[ "def set_packages(self, package_list):...\n", "mydict = self.get_val('mydict')\n", "mydict['package_list'] = package_list\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'" ]
[ "def __init__(self, VAR_1, VAR_2=None):...\n", "super(CLASS_0, self).__init__(VAR_1, VAR_2)\n", "self.TEST_APP = VAR_1['TEST_APP']\n", "self.__path = 'applications/%s/tasks' % self.TEST_APP\n", "self.TEST_STACK = VAR_1['TEST_STACK']\n", "self.TEST_REGION = VAR_1['TEST_GCE_REGION']\n", "self.TEST_ZONE = VAR_1['TEST_GCE_ZONE']\n", "self.__cluster_name = '%s-%s' % (self.TEST_APP, self.TEST_STACK)\n", "self.__server_group_name = '%s-v000' % self.__cluster_name\n", "self.__cloned_server_group_name = '%s-v001' % self.__cluster_name\n", "self.__lb_name = '%s-%s-fe' % (self.TEST_APP, self.TEST_STACK)\n" ]
[ "def __init__(self, bindings, agent=None):...\n", "super(GoogleServerGroupTestScenario, self).__init__(bindings, agent)\n", "self.TEST_APP = bindings['TEST_APP']\n", "self.__path = 'applications/%s/tasks' % self.TEST_APP\n", "self.TEST_STACK = bindings['TEST_STACK']\n", "self.TEST_REGION = bindings['TEST_GCE_REGION']\n", "self.TEST_ZONE = bindings['TEST_GCE_ZONE']\n", "self.__cluster_name = '%s-%s' % (self.TEST_APP, self.TEST_STACK)\n", "self.__server_group_name = '%s-v000' % self.__cluster_name\n", "self.__cloned_server_group_name = '%s-v001' % self.__cluster_name\n", "self.__lb_name = '%s-%s-fe' % (self.TEST_APP, self.TEST_STACK)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_1():...\n", "VAR_3 = FUNC_0()\n", "VAR_4 = VAR_3.cursor()\n", "VAR_4.execute('DROP TABLE IF EXISTS players CASCADE;')\n", "VAR_4.execute('DROP TABLE IF EXISTS matches CASCADE;')\n", "VAR_3.commit()\n", "VAR_4.close()\n", "VAR_3.close()\n", "return 0\n" ]
[ "def drop():...\n", "co = connect()\n", "cu = co.cursor()\n", "cu.execute('DROP TABLE IF EXISTS players CASCADE;')\n", "cu.execute('DROP TABLE IF EXISTS matches CASCADE;')\n", "co.commit()\n", "cu.close()\n", "co.close()\n", "return 0\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "@app.route('/<issue>/articles/', methods=['GET'])...\n", "" ]
[ "@app.route('/<issue>/articles/', methods=['GET'])...\n", "" ]
[ 0, 0 ]
[ "Condition", "Condition" ]
[ "def FUNC_32(VAR_19):...\n", "return dict((expr, vimsupport.VimExpressionToPythonType(expr)) for expr in\n VAR_19)\n" ]
[ "def BuildExtraConfData(extra_conf_vim_data):...\n", "return dict((expr, vimsupport.VimExpressionToPythonType(expr)) for expr in\n extra_conf_vim_data)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_1(self):...\n", "super(CLASS_0, self).clean()\n", "VAR_13 = {}\n", "if self.cleaned_data['action'] == 'create':\n", "return self.cleaned_data\n", "VAR_13['title'] = self.cleaned_data['title']\n", "VAR_13['content_type'] = self.cleaned_data['content_type']\n", "VAR_13['object_id'] = self.cleaned_data['object_id']\n" ]
[ "def clean(self):...\n", "super(ArticleForm, self).clean()\n", "kw = {}\n", "if self.cleaned_data['action'] == 'create':\n", "return self.cleaned_data\n", "kw['title'] = self.cleaned_data['title']\n", "kw['content_type'] = self.cleaned_data['content_type']\n", "kw['object_id'] = self.cleaned_data['object_id']\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_5(VAR_9):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_9.status in ['new', 'active']:\n", "return 'inactive'\n", "if VAR_9.status == 'inactive':\n", "VAR_22 = {'scope': VAR_9, 'status': ['active', 'inactive']}\n", "return VAR_9.status\n", "if org_admin_logic.getForFields(VAR_22, unique=True):\n", "return 'active'\n", "return 'new'\n" ]
[ "def _orgStatusRetriever(entity):...\n", "\"\"\"docstring\"\"\"\n", "if entity.status in ['new', 'active']:\n", "return 'inactive'\n", "if entity.status == 'inactive':\n", "fields = {'scope': entity, 'status': ['active', 'inactive']}\n", "return entity.status\n", "if org_admin_logic.getForFields(fields, unique=True):\n", "return 'active'\n", "return 'new'\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "Assign'", "Return'", "Condition", "Return'", "Return'" ]
[ "@VAR_0.route('/statistics/<int:cid>')...\n", "VAR_28 = VAR_1.connection.cursor()\n", "VAR_29 = VAR_28.execute('SELECT * FROM Crawls WHERE cid = %s' % VAR_7)\n", "VAR_30 = VAR_28.fetchall()[0]\n", "VAR_28.close()\n", "print(VAR_10.get('stats', None))\n", "print(VAR_30['stats'])\n", "VAR_31 = json.loads(VAR_30['stats'])\n", "VAR_32 = json.loads(VAR_30['hierarchy'])\n", "VAR_33 = VAR_31.items()\n", "VAR_34 = sum([subdict['n_tables_pages'] for filename, subdict in VAR_33])\n", "VAR_35 = sum([subdict['n_table_rows'] for filename, subdict in VAR_33])\n", "VAR_36 = sum([subdict['table_sizes']['medium'] for filename, subdict in VAR_33]\n )\n", "VAR_37 = sum([subdict['table_sizes']['small'] for filename, subdict in VAR_33])\n", "VAR_38 = sum([subdict['table_sizes']['large'] for filename, subdict in VAR_33])\n", "VAR_39 = [subdict['creation_date'] for filename, subdict in VAR_33]\n", "VAR_40 = list(map(lambda str: pdf_date_format_to_datetime(str), VAR_39))\n", "if len(VAR_40) > 0:\n", "VAR_50 = min(VAR_40)\n", "VAR_50 = 'None'\n", "VAR_51 = max(VAR_40)\n", "VAR_51 = 'None'\n", "return render_template('statistics.html', VAR_21=crawl['pdf_crawled'],\n VAR_24=crawl['pdf_processed'], VAR_34=n_tables, VAR_35=n_rows, n_errors\n =crawl['process_errors'], VAR_17=crawl['domain'], VAR_37=small_tables,\n VAR_36=medium_tables, VAR_38=large_tables, VAR_22=json_stats, hierarchy\n =json_hierarchy, end_time=crawl['crawl_date'], crawl_total_time=round(\n crawl['crawl_total_time'] / 60.0, 1), VAR_27=round(crawl[\n 'proc_total_time'] / 60.0, 1), VAR_50=oldest_pdf, VAR_51=most_recent_pdf)\n" ]
[ "@app.route('/statistics/<int:cid>')...\n", "cur = mysql.connection.cursor()\n", "result = cur.execute('SELECT * FROM Crawls WHERE cid = %s' % cid)\n", "crawl = cur.fetchall()[0]\n", "cur.close()\n", "print(session.get('stats', None))\n", "print(crawl['stats'])\n", "json_stats = json.loads(crawl['stats'])\n", "json_hierarchy = json.loads(crawl['hierarchy'])\n", "stats_items = json_stats.items()\n", "n_tables = sum([subdict['n_tables_pages'] for filename, subdict in stats_items]\n )\n", "n_rows = sum([subdict['n_table_rows'] for filename, subdict in stats_items])\n", "medium_tables = sum([subdict['table_sizes']['medium'] for filename, subdict in\n stats_items])\n", "small_tables = sum([subdict['table_sizes']['small'] for filename, subdict in\n stats_items])\n", "large_tables = sum([subdict['table_sizes']['large'] for filename, subdict in\n stats_items])\n", "creation_dates_pdf = [subdict['creation_date'] for filename, subdict in\n stats_items]\n", "creation_dates = list(map(lambda str: pdf_date_format_to_datetime(str),\n creation_dates_pdf))\n", "if len(creation_dates) > 0:\n", "oldest_pdf = min(creation_dates)\n", "oldest_pdf = 'None'\n", "most_recent_pdf = max(creation_dates)\n", "most_recent_pdf = 'None'\n", "return render_template('statistics.html', n_files=crawl['pdf_crawled'],\n n_success=crawl['pdf_processed'], n_tables=n_tables, n_rows=n_rows,\n n_errors=crawl['process_errors'], domain=crawl['domain'], small_tables=\n small_tables, medium_tables=medium_tables, large_tables=large_tables,\n stats=json_stats, hierarchy=json_hierarchy, end_time=crawl['crawl_date'\n ], crawl_total_time=round(crawl['crawl_total_time'] / 60.0, 1),\n proc_total_time=round(crawl['proc_total_time'] / 60.0, 1), oldest_pdf=\n oldest_pdf, most_recent_pdf=most_recent_pdf)\n" ]
[ 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_19(VAR_18, VAR_20, VAR_10, VAR_26, VAR_27, VAR_28):...\n", "VAR_48 = VAR_20, VAR_4[VAR_20]['name']\n", "VAR_34 = FUNC_1(VAR_10)\n", "VAR_49 = SubmitRequest(VAR_34, VAR_48, base_url=CWS_BASE_URL, VAR_26=\n submission_format, VAR_27=filenames, VAR_28=language)\n", "VAR_49.execute()\n", "VAR_29 = VAR_49.get_submission_id()\n", "if VAR_29 is None:\n", "return VAR_29\n" ]
[ "def cws_submit(contest_id, task_id, user_id, submission_format, filenames,...\n", "task = task_id, created_tasks[task_id]['name']\n", "browser = get_cws_browser(user_id)\n", "sr = SubmitRequest(browser, task, base_url=CWS_BASE_URL, submission_format=\n submission_format, filenames=filenames, language=language)\n", "sr.execute()\n", "submission_id = sr.get_submission_id()\n", "if submission_id is None:\n", "return submission_id\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Return'" ]
[ "@classmethod...\n", "return ['runtime_classpath', 'zinc_analysis', 'zinc_args']\n" ]
[ "@classmethod...\n", "return ['runtime_classpath', 'zinc_analysis', 'zinc_args']\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "from openerp import api, models, fields\n", "import logging\n", "from datetime import datetime, timedelta\n", "VAR_0 = logging.getLogger(__name__)\n", "VAR_1 = 'product.template'\n", "VAR_2 = fields.Char(help='Code from bulonfer, not shown', select=1)\n", "VAR_3 = fields.Integer(help='Group Wholesaler')\n", "VAR_4 = fields.Integer(help='Bulk Wholesaler quantity of units')\n", "VAR_5 = fields.Integer(help='Bulk retail quantity of units')\n", "VAR_6 = fields.Boolean(help='True if the asociated category needs rebuild',\n default=False)\n", "VAR_7 = fields.Float(help='Cost price based on the purchase invoice')\n", "VAR_8 = fields.Float(help='Margin % from today cost to list price')\n", "VAR_9 = fields.Float(help=\n \"\"\"Today cost in product currency, it is automatically updated when the prices coming from Bulonfer are processed.\nOr when a price sheet is loaded for no Bulonfer vendors\"\"\"\n )\n", "VAR_10 = fields.One2many(comodel_name='stock.quant', inverse_name=\n 'product_tmpl_id', domain=[('location_id.usage', '=', 'internal')])\n", "VAR_11 = fields.Char(help='default_code of the product to get prices from')\n", "def FUNC_0(self, VAR_12):...\n", "\"\"\"docstring\"\"\"\n", "VAR_21 = self.env['stock.quant']\n", "return VAR_21.search([('product_tmpl_id', '=', VAR_12.id), (\n 'location_id.usage', '=', 'internal')], order='in_date', limit=1)\n" ]
[ "from openerp import api, models, fields\n", "import logging\n", "from datetime import datetime, timedelta\n", "_logger = logging.getLogger(__name__)\n", "_inherit = 'product.template'\n", "item_code = fields.Char(help='Code from bulonfer, not shown', select=1)\n", "upv = fields.Integer(help='Group Wholesaler')\n", "wholesaler_bulk = fields.Integer(help='Bulk Wholesaler quantity of units')\n", "retail_bulk = fields.Integer(help='Bulk retail quantity of units')\n", "invalidate_category = fields.Boolean(help=\n 'True if the asociated category needs rebuild', default=False)\n", "system_cost = fields.Float(help='Cost price based on the purchase invoice')\n", "margin = fields.Float(help='Margin % from today cost to list price')\n", "bulonfer_cost = fields.Float(help=\n \"\"\"Today cost in product currency, it is automatically updated when the prices coming from Bulonfer are processed.\nOr when a price sheet is loaded for no Bulonfer vendors\"\"\"\n )\n", "cost_history_ids = fields.One2many(comodel_name='stock.quant', inverse_name\n ='product_tmpl_id', domain=[('location_id.usage', '=', 'internal')])\n", "parent_price_product = fields.Char(help=\n 'default_code of the product to get prices from')\n", "def oldest_quant(self, prod):...\n", "\"\"\"docstring\"\"\"\n", "quant_obj = self.env['stock.quant']\n", "return quant_obj.search([('product_tmpl_id', '=', prod.id), (\n 'location_id.usage', '=', 'internal')], order='in_date', limit=1)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Import'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_2(self):...\n", "self.browser.quit()\n" ]
[ "def tearDown(self):...\n", "self.browser.quit()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_2(VAR_0):...\n", "VAR_1 = VAR_0.index('>')\n", "sys.stdout = open(VAR_0[VAR_1 + 1], 'w')\n", "print('this is a test')\n" ]
[ "def SetUpOutputRedirect(cmd):...\n", "i = cmd.index('>')\n", "sys.stdout = open(cmd[i + 1], 'w')\n", "print('this is a test')\n" ]
[ 0, 6, 6, 6 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_3(self, VAR_3):...\n", "return self._doc['collections'][VAR_3] if VAR_3 in self._doc['collections'\n ] else None\n" ]
[ "def get_collection(self, collectionname):...\n", "return self._doc['collections'][collectionname] if collectionname in self._doc[\n 'collections'] else None\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@session_manager...\n", "\"\"\"docstring\"\"\"\n", "from invenio.modules.accounts.models import User, UserEXT\n", "from invenio.ext.sqlalchemy import db\n", "from ..handlers import token_session_key\n", "from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound\n", "import json\n", "import requests\n", "VAR_6 = session.get(token_session_key(VAR_2.name) + '_account_info').get(\n 'external_id')\n", "VAR_7 = {'orcid': VAR_6}\n", "VAR_4.remote_account.extra_data = VAR_7\n", "VAR_8 = User.query.join(UserEXT).filter_by(id=orcid, method='orcid').one()\n", "current_app.logger.exception('No user entry in userEXT.')\n", "if VAR_8 and not any([VAR_8.given_names, VAR_8.family_name]):\n", "VAR_9 = 'http://orcid.org/{0}/orcid-bio'.format(VAR_6)\n", "VAR_10 = {'Accept': 'application/orcid+json'}\n", "VAR_11 = requests.get(VAR_9, VAR_10=headers)\n", "VAR_12 = VAR_11.status_code\n", "if VAR_12 == requests.codes.ok:\n", "VAR_13 = json.loads(VAR_11.content)\n", "current_app.logger.exception('Not valid JSON response from ' +\n 'ORCID:\\n {0}'.format(repr(VAR_13)))\n", "VAR_14 = VAR_13['orcid-profile']['orcid-bio']['personal-details']\n", "current_app.logger.exception('Unexpected return format ' +\n 'from ORCID:\\n {0}'.format(repr(VAR_13)))\n", "db.session.add(VAR_8)\n", "return\n", "VAR_8.given_names = VAR_14['given-names']['value']\n", "return\n", "current_user.reload()\n", "VAR_8.family_name = VAR_14['family-name']['value']\n" ]
[ "@session_manager...\n", "\"\"\"docstring\"\"\"\n", "from invenio.modules.accounts.models import User, UserEXT\n", "from invenio.ext.sqlalchemy import db\n", "from ..handlers import token_session_key\n", "from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound\n", "import json\n", "import requests\n", "orcid = session.get(token_session_key(remote.name) + '_account_info').get(\n 'external_id')\n", "extra_data = {'orcid': orcid}\n", "token.remote_account.extra_data = extra_data\n", "user = User.query.join(UserEXT).filter_by(id=orcid, method='orcid').one()\n", "current_app.logger.exception('No user entry in userEXT.')\n", "if user and not any([user.given_names, user.family_name]):\n", "request_url = 'http://orcid.org/{0}/orcid-bio'.format(orcid)\n", "headers = {'Accept': 'application/orcid+json'}\n", "response = requests.get(request_url, headers=headers)\n", "code = response.status_code\n", "if code == requests.codes.ok:\n", "orcid_bio = json.loads(response.content)\n", "current_app.logger.exception('Not valid JSON response from ' +\n 'ORCID:\\n {0}'.format(repr(orcid_bio)))\n", "name = orcid_bio['orcid-profile']['orcid-bio']['personal-details']\n", "current_app.logger.exception('Unexpected return format ' +\n 'from ORCID:\\n {0}'.format(repr(orcid_bio)))\n", "db.session.add(user)\n", "return\n", "user.given_names = name['given-names']['value']\n", "return\n", "current_user.reload()\n", "user.family_name = name['family-name']['value']\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Import'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Return'", "Assign'", "Return'", "Expr'", "Assign'" ]
[ "def __init__(self, VAR_19=False, **VAR_4):...\n", "CLASS_1.__init__(self, **kwargs)\n", "self.subscribed = VAR_19\n" ]
[ "def __init__(self, subscribed=False, **kwargs):...\n", "TriblerContentModel.__init__(self, **kwargs)\n", "self.subscribed = subscribed\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'" ]
[ "def __init__(self, VAR_15, VAR_16, VAR_17):...\n", "\"\"\"docstring\"\"\"\n", "self._name = 'Netatmo {} {}'.format(VAR_16, VAR_5[VAR_17][0])\n", "self.netatmo_data = VAR_15\n", "self.module_name = VAR_16\n", "self.type = VAR_17\n", "self._state = None\n", "self._device_class = VAR_5[self.type][3]\n", "self._icon = VAR_5[self.type][2]\n", "self._unit_of_measurement = VAR_5[self.type][1]\n", "VAR_20 = self.netatmo_data.station_data.moduleByName(module=module_name)['_id']\n", "self.module_id = VAR_20[1]\n" ]
[ "def __init__(self, netatmo_data, module_name, sensor_type):...\n", "\"\"\"docstring\"\"\"\n", "self._name = 'Netatmo {} {}'.format(module_name, SENSOR_TYPES[sensor_type][0])\n", "self.netatmo_data = netatmo_data\n", "self.module_name = module_name\n", "self.type = sensor_type\n", "self._state = None\n", "self._device_class = SENSOR_TYPES[self.type][3]\n", "self._icon = SENSOR_TYPES[self.type][2]\n", "self._unit_of_measurement = SENSOR_TYPES[self.type][1]\n", "module_id = self.netatmo_data.station_data.moduleByName(module=module_name)[\n '_id']\n", "self.module_id = module_id[1]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "\"\"\"\nUnit tests for the Deis api app.\n\nRun the tests with \"./manage.py test api\\\"\n\"\"\"\n", "from __future__ import unicode_literals\n", "import json\n", "from django.test import TestCase\n", "from api.models import Key\n", "from api.utils import fingerprint\n", "VAR_0 = 'string'\n", "VAR_1 = 'string'\n", "\"\"\"Tests cloud provider credentials\"\"\"\n", "VAR_2 = ['tests.json']\n", "def FUNC_0(self):...\n", "self.assertTrue(self.client.login(username='autotest', password='password'))\n", "def FUNC_1(self, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_4 = '/api/keys'\n", "VAR_5 = {'id': '[email protected]', 'public': VAR_3}\n", "VAR_6 = self.client.post(VAR_4, json.dumps(VAR_5), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "VAR_7 = VAR_6.data['id']\n", "VAR_6 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_6.status_code, 200)\n", "self.assertEqual(len(VAR_6.data['results']), 1)\n", "VAR_4 = '/api/keys/{key_id}'.format(**locals())\n", "VAR_6 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_6.status_code, 200)\n", "self.assertEqual(VAR_5['id'], VAR_6.data['id'])\n", "self.assertEqual(VAR_5['public'], VAR_6.data['public'])\n", "VAR_6 = self.client.delete(VAR_4)\n", "self.assertEqual(VAR_6.status_code, 204)\n", "def FUNC_2(self):...\n", "self._check_key(VAR_0)\n", "def FUNC_3(self):...\n", "self._check_key(VAR_1)\n", "def FUNC_4(self, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_4 = '/api/keys'\n", "VAR_5 = {'id': '[email protected]', 'public': VAR_3}\n", "VAR_6 = self.client.post(VAR_4, json.dumps(VAR_5), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "VAR_6 = self.client.post(VAR_4, json.dumps(VAR_5), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 400)\n", "def FUNC_5(self):...\n", "self._check_duplicate_key(VAR_0)\n", "def FUNC_6(self):...\n", "self._check_duplicate_key(VAR_1)\n", "def FUNC_7(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_4 = '/api/keys'\n", "VAR_5 = {'id': 'autotest', 'public': 'string'}\n", "VAR_6 = self.client.post(VAR_4, json.dumps(VAR_5), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "VAR_8 = Key.objects.get(uuid=response.data['uuid'])\n", "self.assertEqual(str(VAR_8),\n 'ssh-rsa AAAAB3NzaC.../HJDw9QckTS0vN [email protected]')\n", "def FUNC_8(self):...\n", "VAR_9 = fingerprint(VAR_0)\n", "self.assertEquals(VAR_9, '54:6d:da:1f:91:b5:2b:6f:a2:83:90:c4:f9:73:76:f5')\n" ]
[ "\"\"\"\nUnit tests for the Deis api app.\n\nRun the tests with \"./manage.py test api\\\"\n\"\"\"\n", "from __future__ import unicode_literals\n", "import json\n", "from django.test import TestCase\n", "from api.models import Key\n", "from api.utils import fingerprint\n", "RSA_PUBKEY = (\n 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCfQkkUUoxpvcNMkvv7jqnfodgs37M2eBOAPgLK+KNBMaZaaKB4GF1QhTCMfFhoiTW3rqa0J75bHJcdkoobtTHlK8XUrFqsquWyg3XhsTYr/3RQQXvO86e2sF7SVDJqVtpnbQGc5SgNrHCeHJmf5HTbXSIjCO/AJSvIjnituT/SIAMGeBw0Nq/iSltwYAek1hiKO7wSmLcIQ8U4A00KEUtalaumf2aHOcfjgPfzlbZGP0S0cuBwSqLr8b5XGPmkASNdUiuJY4MJOce7bFU14B7oMAy2xacODUs1momUeYtGI9T7X2WMowJaO7tP3GlsgBMP81VfYTfYChAyJpKp2yoP autotest@autotesting comment'\n )\n", "ECDSA_PUBKEY = (\n 'ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCGB0x9lmubbLJTF5NekCI0Cgjyip6jJh/t/qQQi1LAZisbREBJ8Wy+hwSn3tnbf/Imh9X+MQnrrza0jaQ3QUAQ= autotest@autotesting comment'\n )\n", "\"\"\"Tests cloud provider credentials\"\"\"\n", "fixtures = ['tests.json']\n", "def setUp(self):...\n", "self.assertTrue(self.client.login(username='autotest', password='password'))\n", "def _check_key(self, pubkey):...\n", "\"\"\"docstring\"\"\"\n", "url = '/api/keys'\n", "body = {'id': '[email protected]', 'public': pubkey}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "key_id = response.data['id']\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 1)\n", "url = '/api/keys/{key_id}'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(body['id'], response.data['id'])\n", "self.assertEqual(body['public'], response.data['public'])\n", "response = self.client.delete(url)\n", "self.assertEqual(response.status_code, 204)\n", "def test_rsa_key(self):...\n", "self._check_key(RSA_PUBKEY)\n", "def test_ecdsa_key(self):...\n", "self._check_key(ECDSA_PUBKEY)\n", "def _check_duplicate_key(self, pubkey):...\n", "\"\"\"docstring\"\"\"\n", "url = '/api/keys'\n", "body = {'id': '[email protected]', 'public': pubkey}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 400)\n", "def test_rsa_duplicate_key(self):...\n", "self._check_duplicate_key(RSA_PUBKEY)\n", "def test_ecdsa_duplicate_key(self):...\n", "self._check_duplicate_key(ECDSA_PUBKEY)\n", "def test_rsa_key_str(self):...\n", "\"\"\"docstring\"\"\"\n", "url = '/api/keys'\n", "body = {'id': 'autotest', 'public':\n 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDzqPAwHN70xsB0LXG//KzOgcPikyhdN/KRc4x3j/RA0pmFj63Ywv0PJ2b1LcMSqfR8F11WBlrW8c9xFua0ZAKzI+gEk5uqvOR78bs/SITOtKPomW4e/1d2xEkJqOmYH30u94+NZZYwEBqYaRb34fhtrnJS70XeGF0RhXE5Qea5eh7DBbeLxPfSYd8rfHgzMSb/wmx3h2vmHdQGho20pfJktNu7DxeVkTHn9REMUphf85su7slTgTlWKq++3fASE8PdmFGzb6PkOR4c+LS5WWXd2oM6HyBQBxxiwXbA2lSgQxOdgDiM2FzT0GVSFMUklkUHMdsaG6/HJDw9QckTS0vN [email protected]'\n }\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "key = Key.objects.get(uuid=response.data['uuid'])\n", "self.assertEqual(str(key),\n 'ssh-rsa AAAAB3NzaC.../HJDw9QckTS0vN [email protected]')\n", "def test_rsa_key_fingerprint(self):...\n", "fp = fingerprint(RSA_PUBKEY)\n", "self.assertEquals(fp, '54:6d:da:1f:91:b5:2b:6f:a2:83:90:c4:f9:73:76:f5')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 5, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Expr'", "Assign'", "FunctionDef'", "Expr'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_14(VAR_6, VAR_7):...\n", "FUNC_0.timeout = VAR_6['ini'].getint('sessions', 'session_idle_timeout')\n", "FUNC_3.timeout = VAR_6['ini'].getint('sessions', 'cached_page_timeout')\n", "VAR_6.router.add_get('/', FUNC_4)\n", "VAR_6.router.add_get('/index', FUNC_4)\n", "VAR_6.router.add_get('/login', FUNC_5)\n", "VAR_6.router.add_post('/login', FUNC_6)\n", "VAR_6.router.add_get('/settings', FUNC_9)\n", "VAR_6.router.add_post('/settings', FUNC_10)\n", "VAR_6.router.add_get('/mapmaker', FUNC_7)\n", "VAR_6.router.add_get('/map', FUNC_8)\n", "VAR_6.router.add_get('/mazetest', FUNC_11)\n", "VAR_6.router.add_static('/static/', path='static', name='static')\n", "session_setup(VAR_6, EncryptedCookieStorage(VAR_7))\n" ]
[ "def add_routes(app, secret_key):...\n", "handle_html.timeout = app['ini'].getint('sessions', 'session_idle_timeout')\n", "cache_page.timeout = app['ini'].getint('sessions', 'cached_page_timeout')\n", "app.router.add_get('/', GET_index)\n", "app.router.add_get('/index', GET_index)\n", "app.router.add_get('/login', GET_login)\n", "app.router.add_post('/login', POST_login)\n", "app.router.add_get('/settings', GET_settings)\n", "app.router.add_post('/settings', POST_settings)\n", "app.router.add_get('/mapmaker', GET_mapmaker)\n", "app.router.add_get('/map', GET_map)\n", "app.router.add_get('/mazetest', GET_test)\n", "app.router.add_static('/static/', path='static', name='static')\n", "session_setup(app, EncryptedCookieStorage(secret_key))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_2(self, VAR_1):...\n", "VAR_12 = self._formatCredentials(VAR_1, VAR_8='current')\n", "VAR_9 = '{} rclone lsjson current:'.format(VAR_12)\n", "VAR_28 = self._execute(VAR_9)\n", "VAR_36 = e.returncode\n", "return {'result': True, 'message': 'Success'}\n", "return {'result': False, 'message': 'Exit status {}'.format(VAR_36)}\n" ]
[ "def verify(self, data):...\n", "credentials = self._formatCredentials(data, name='current')\n", "command = '{} rclone lsjson current:'.format(credentials)\n", "result = self._execute(command)\n", "returncode = e.returncode\n", "return {'result': True, 'message': 'Success'}\n", "return {'result': False, 'message': 'Exit status {}'.format(returncode)}\n" ]
[ 0, 0, 2, 2, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Return'" ]
[ "def FUNC_0(self, VAR_5, VAR_6, VAR_7):...\n", "VAR_9 = ''\n", "VAR_10 = ''\n", "for key in VAR_7:\n", "VAR_9 = VAR_9 + ', %s'\n", "VAR_11 = []\n", "VAR_10 = VAR_10 + ', %s'\n", "VAR_12 = []\n", "VAR_11.append(VAR_5)\n", "for key in VAR_7:\n", "VAR_11.append(key)\n", "VAR_11 = VAR_11 + VAR_12\n", "VAR_12.append(VAR_7[key])\n", "VAR_13 = self.connection.cursor()\n", "VAR_13.execute('INSERT INTO %s (TIMESTAMP' + VAR_9 + ') VALUES (%s,' +\n VAR_10 + ')', VAR_11)\n", "VAR_13.close()\n", "print('posted successfully!')\n", "print('Insert Error: %s'.format(e))\n", "self.connection.commit()\n", "if e == missing_column:\n", "print('Attempting to alter table!')\n", "if e == missing_table:\n", "VAR_15 = ''\n", "self.createTable(VAR_5, VAR_7)\n", "print('Failed to create table??: %s'.format(e))\n", "self.insertData(VAR_5, VAR_6, VAR_7)\n", "print('Unexpected error when reinserted!')\n", "VAR_16 = []\n", "print('Created table successfully - reinserting')\n", "print('posted successfully!')\n", "VAR_14 = self.__getType(VAR_7[VAR_15])\n", "print('Got a type error %s'.format(e))\n", "VAR_13 = self.connection.cursor()\n", "print('Failed to alter table with error e'.format(e))\n", "print('Table alteration succeeded - attempting to insert again')\n", "VAR_16.append(VAR_5)\n", "print('Error with field %s'.format(VAR_15))\n", "VAR_13.execute('ALTER TABLE %s ADD COLUMN %s %s', VAR_16)\n", "self.insertData(VAR_5, VAR_6, VAR_7)\n", "print('Unexpected error when reinserted!')\n", "VAR_16.append(columnkName)\n", "print('Table alteration failed')\n", "self.connection.commit()\n", "print('posted successfully!')\n", "VAR_16.append(VAR_14)\n" ]
[ "def insertData(self, tableName, timeStamp, tableObj):...\n", "cols = ''\n", "vals = ''\n", "for key in tableObj:\n", "cols = cols + ', %s'\n", "nameList = []\n", "vals = vals + ', %s'\n", "valList = []\n", "nameList.append(tableName)\n", "for key in tableObj:\n", "nameList.append(key)\n", "nameList = nameList + valList\n", "valList.append(tableObj[key])\n", "cursor = self.connection.cursor()\n", "cursor.execute('INSERT INTO %s (TIMESTAMP' + cols + ') VALUES (%s,' + vals +\n ')', nameList)\n", "cursor.close()\n", "print('posted successfully!')\n", "print('Insert Error: %s'.format(e))\n", "self.connection.commit()\n", "if e == missing_column:\n", "print('Attempting to alter table!')\n", "if e == missing_table:\n", "columnName = ''\n", "self.createTable(tableName, tableObj)\n", "print('Failed to create table??: %s'.format(e))\n", "self.insertData(tableName, timeStamp, tableObj)\n", "print('Unexpected error when reinserted!')\n", "params = []\n", "print('Created table successfully - reinserting')\n", "print('posted successfully!')\n", "t = self.__getType(tableObj[columnName])\n", "print('Got a type error %s'.format(e))\n", "cursor = self.connection.cursor()\n", "print('Failed to alter table with error e'.format(e))\n", "print('Table alteration succeeded - attempting to insert again')\n", "params.append(tableName)\n", "print('Error with field %s'.format(columnName))\n", "cursor.execute('ALTER TABLE %s ADD COLUMN %s %s', params)\n", "self.insertData(tableName, timeStamp, tableObj)\n", "print('Unexpected error when reinserted!')\n", "params.append(columnkName)\n", "print('Table alteration failed')\n", "self.connection.commit()\n", "print('posted successfully!')\n", "params.append(t)\n" ]
[ 0, 0, 0, 0, 4, 4, 0, 0, 4, 0, 4, 4, 0, 0, 4, 0, 4, 4, 0, 4, 4, 4, 4, 0, 4, 0, 0, 4, 0, 0, 4, 4, 0, 4, 0, 4, 4, 4, 0, 0, 4, 0, 0, 0, 4 ]
[ "FunctionDef'", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "For", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Condition", "Expr'", "Condition", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "__author__ = 'Johannes Köster'\n", "__copyright__ = 'Copyright 2015, Johannes Köster'\n", "__email__ = '[email protected]'\n", "__license__ = 'MIT'\n", "import os\n", "import re\n", "import sys\n", "import inspect\n", "import sre_constants\n", "from collections import defaultdict\n", "from snakemake.io import IOFile, _IOFile, protected, temp, dynamic, Namedlist\n", "from snakemake.io import expand, InputFiles, OutputFiles, Wildcards, Params, Log\n", "from snakemake.io import apply_wildcards, is_flagged, not_iterable\n", "from snakemake.exceptions import RuleException, IOFileException, WildcardError, InputFunctionException\n", "def __init__(self, *VAR_0, VAR_1=None, VAR_2=None):...\n", "\"\"\"docstring\"\"\"\n", "if len(VAR_0) == 2:\n", "VAR_10, VAR_41 = VAR_0\n", "if len(VAR_0) == 1:\n", "self.name = VAR_10\n", "VAR_17 = VAR_0[0]\n", "def FUNC_0(self, VAR_3, VAR_4=True):...\n", "self.workflow = VAR_41\n", "self.name = VAR_17.name\n", "def FUNC_21(VAR_16):...\n", "self.docstring = None\n", "self.workflow = VAR_17.workflow\n", "return (VAR_16.input, VAR_16.dynamic_input) if VAR_4 else (VAR_16.output,\n VAR_16.dynamic_output)\n", "self.message = None\n", "self.docstring = VAR_17.docstring\n", "self._input = InputFiles()\n", "self.message = VAR_17.message\n", "self._output = OutputFiles()\n", "self._input = InputFiles(VAR_17._input)\n", "self._params = Params()\n", "self._output = OutputFiles(VAR_17._output)\n", "self.dependencies = dict()\n", "self._params = Params(VAR_17._params)\n", "self.dynamic_output = set()\n", "self.dependencies = dict(VAR_17.dependencies)\n", "self.dynamic_input = set()\n", "self.dynamic_output = set(VAR_17.dynamic_output)\n", "self.temp_output = set()\n", "self.dynamic_input = set(VAR_17.dynamic_input)\n", "self.protected_output = set()\n", "self.temp_output = set(VAR_17.temp_output)\n", "self.touch_output = set()\n", "self.protected_output = set(VAR_17.protected_output)\n", "self.subworkflow_input = dict()\n", "self.touch_output = set(VAR_17.touch_output)\n", "self.resources = dict(_cores=1, _nodes=1)\n", "self.subworkflow_input = dict(VAR_17.subworkflow_input)\n", "self.priority = 0\n", "self.resources = VAR_17.resources\n", "self.version = None\n", "self.priority = VAR_17.priority\n", "self._log = Log()\n", "self.version = VAR_17.version\n", "self._benchmark = None\n", "self._log = VAR_17._log\n", "self.wildcard_names = set()\n", "self._benchmark = VAR_17._benchmark\n", "self.lineno = VAR_1\n", "self.wildcard_names = set(VAR_17.wildcard_names)\n", "self.snakefile = VAR_2\n", "self.lineno = VAR_17.lineno\n", "self.run_func = None\n", "self.snakefile = VAR_17.snakefile\n", "self.shellcmd = None\n", "self.run_func = VAR_17.run_func\n", "self.norun = False\n", "self.shellcmd = VAR_17.shellcmd\n", "self.norun = VAR_17.norun\n" ]
[ "__author__ = 'Johannes Köster'\n", "__copyright__ = 'Copyright 2015, Johannes Köster'\n", "__email__ = '[email protected]'\n", "__license__ = 'MIT'\n", "import os\n", "import re\n", "import sys\n", "import inspect\n", "import sre_constants\n", "from collections import defaultdict\n", "from snakemake.io import IOFile, _IOFile, protected, temp, dynamic, Namedlist\n", "from snakemake.io import expand, InputFiles, OutputFiles, Wildcards, Params, Log\n", "from snakemake.io import apply_wildcards, is_flagged, not_iterable\n", "from snakemake.exceptions import RuleException, IOFileException, WildcardError, InputFunctionException\n", "def __init__(self, *args, lineno=None, snakefile=None):...\n", "\"\"\"docstring\"\"\"\n", "if len(args) == 2:\n", "name, workflow = args\n", "if len(args) == 1:\n", "self.name = name\n", "other = args[0]\n", "def dynamic_branch(self, wildcards, input=True):...\n", "self.workflow = workflow\n", "self.name = other.name\n", "def get_io(rule):...\n", "self.docstring = None\n", "self.workflow = other.workflow\n", "return (rule.input, rule.dynamic_input) if input else (rule.output, rule.\n dynamic_output)\n", "self.message = None\n", "self.docstring = other.docstring\n", "self._input = InputFiles()\n", "self.message = other.message\n", "self._output = OutputFiles()\n", "self._input = InputFiles(other._input)\n", "self._params = Params()\n", "self._output = OutputFiles(other._output)\n", "self.dependencies = dict()\n", "self._params = Params(other._params)\n", "self.dynamic_output = set()\n", "self.dependencies = dict(other.dependencies)\n", "self.dynamic_input = set()\n", "self.dynamic_output = set(other.dynamic_output)\n", "self.temp_output = set()\n", "self.dynamic_input = set(other.dynamic_input)\n", "self.protected_output = set()\n", "self.temp_output = set(other.temp_output)\n", "self.touch_output = set()\n", "self.protected_output = set(other.protected_output)\n", "self.subworkflow_input = dict()\n", "self.touch_output = set(other.touch_output)\n", "self.resources = dict(_cores=1, _nodes=1)\n", "self.subworkflow_input = dict(other.subworkflow_input)\n", "self.priority = 0\n", "self.resources = other.resources\n", "self.version = None\n", "self.priority = other.priority\n", "self._log = Log()\n", "self.version = other.version\n", "self._benchmark = None\n", "self._log = other._log\n", "self.wildcard_names = set()\n", "self._benchmark = other._benchmark\n", "self.lineno = lineno\n", "self.wildcard_names = set(other.wildcard_names)\n", "self.snakefile = snakefile\n", "self.lineno = other.lineno\n", "self.run_func = None\n", "self.snakefile = other.snakefile\n", "self.shellcmd = None\n", "self.run_func = other.run_func\n", "self.norun = False\n", "self.shellcmd = other.shellcmd\n", "self.norun = other.norun\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Assign'", "Assign'", "Assign'", "Assign'", "Import'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "FunctionDef'", "Docstring", "Assign'", "Return'", "Assign'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_7(self, VAR_21, VAR_23=True):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_21 == '/':\n", "return self.fs\n", "VAR_55 = VAR_21.strip('/').split('/')\n", "VAR_22 = ''\n", "VAR_57 = self.fs\n", "for VAR_66 in VAR_55:\n", "if VAR_66 not in [x[VAR_1] for x in VAR_57[VAR_8]]:\n", "return VAR_57\n", "return False\n", "for x in VAR_57[VAR_8]:\n", "if x[VAR_1] == VAR_66:\n", "VAR_22 = '/'.join((VAR_22, VAR_66))\n", "if VAR_66 == VAR_55[-1] and VAR_23 == False:\n", "VAR_57 = x\n", "if x[VAR_2] == VAR_11:\n", "if x[VAR_9][0] == '/':\n", "VAR_57 = x\n", "VAR_57 = self.getfile(x[VAR_9], VAR_23=follow_symlinks)\n", "VAR_57 = self.getfile('/'.join((VAR_22, x[VAR_9])), VAR_23=follow_symlinks)\n", "if VAR_57 == False:\n", "return False\n" ]
[ "def getfile(self, path, follow_symlinks=True):...\n", "\"\"\"docstring\"\"\"\n", "if path == '/':\n", "return self.fs\n", "pieces = path.strip('/').split('/')\n", "cwd = ''\n", "p = self.fs\n", "for piece in pieces:\n", "if piece not in [x[A_NAME] for x in p[A_CONTENTS]]:\n", "return p\n", "return False\n", "for x in p[A_CONTENTS]:\n", "if x[A_NAME] == piece:\n", "cwd = '/'.join((cwd, piece))\n", "if piece == pieces[-1] and follow_symlinks == False:\n", "p = x\n", "if x[A_TYPE] == T_LINK:\n", "if x[A_TARGET][0] == '/':\n", "p = x\n", "p = self.getfile(x[A_TARGET], follow_symlinks=follow_symlinks)\n", "p = self.getfile('/'.join((cwd, x[A_TARGET])), follow_symlinks=follow_symlinks)\n", "if p == False:\n", "return False\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Assign'", "Assign'", "Assign'", "For", "For", "Return'", "Return'", "For", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_7(self, VAR_14):...\n", "" ]
[ "def is_image(self, col_name):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_3(self, VAR_2, VAR_4, VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "return True\n" ]
[ "def has_object_permission(self, request, view, obj):...\n", "\"\"\"docstring\"\"\"\n", "return True\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_23(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_17 = []\n", "for VAR_7, VAR_12 in self.all_processes.items():\n", "for VAR_16 in VAR_12:\n", "return VAR_17\n", "if VAR_16.process.poll() is None:\n", "VAR_17.append((VAR_7, VAR_16.process))\n" ]
[ "def live_processes(self):...\n", "\"\"\"docstring\"\"\"\n", "result = []\n", "for process_type, process_infos in self.all_processes.items():\n", "for process_info in process_infos:\n", "return result\n", "if process_info.process.poll() is None:\n", "result.append((process_type, process_info.process))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "For", "For", "Return'", "Condition", "Expr'" ]
[ "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'" ]
[ "def FUNC_1(self, VAR_3):...\n", "VAR_7 = None\n", "VAR_8 = VAR_3.contents\n", "VAR_9 = []\n", "for VAR_5 in VAR_8:\n", "if isinstance(VAR_5, NavigableString):\n", "return VAR_7\n", "if '(' in VAR_5:\n", "if isinstance(VAR_5, Tag) and not VAR_9:\n", "VAR_9.append('(')\n", "if ')' in VAR_5:\n", "VAR_21 = VAR_5\n", "VAR_9.pop()\n", "if not getattr(VAR_5, 'name', None) == 'a':\n", "VAR_21 = VAR_5.find('a')\n", "if self.is_valid(VAR_21):\n", "return VAR_21.attrs['href']\n" ]
[ "def parse_tag(self, tag):...\n", "next_wiki = None\n", "contents = tag.contents\n", "stack = []\n", "for element in contents:\n", "if isinstance(element, NavigableString):\n", "return next_wiki\n", "if '(' in element:\n", "if isinstance(element, Tag) and not stack:\n", "stack.append('(')\n", "if ')' in element:\n", "a_tag = element\n", "stack.pop()\n", "if not getattr(element, 'name', None) == 'a':\n", "a_tag = element.find('a')\n", "if self.is_valid(a_tag):\n", "return a_tag.attrs['href']\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "For", "Condition", "Return'", "Condition", "Condition", "Expr'", "Condition", "Assign'", "Expr'", "Condition", "Assign'", "Condition", "Return'" ]
[ "from sqlalchemy import create_engine\n", "from sqlalchemy.pool import StaticPool\n", "from .serializer import make_row_serializable\n", "from .cache import Cache\n", "from .connection_url import is_sqlite\n", "def __init__(self, VAR_0, VAR_1):...\n", "self.has_rows = VAR_1 is not None\n", "self.keys = VAR_0\n", "self.rows = VAR_1\n", "@classmethod...\n", "if VAR_3.returns_rows:\n", "VAR_0 = VAR_3.keys()\n", "return VAR_2(None, None)\n", "VAR_1 = [make_row_serializable(row) for row in VAR_3]\n", "return VAR_2(VAR_0, VAR_1)\n" ]
[ "from sqlalchemy import create_engine\n", "from sqlalchemy.pool import StaticPool\n", "from .serializer import make_row_serializable\n", "from .cache import Cache\n", "from .connection_url import is_sqlite\n", "def __init__(self, keys, rows):...\n", "self.has_rows = rows is not None\n", "self.keys = keys\n", "self.rows = rows\n", "@classmethod...\n", "if result.returns_rows:\n", "keys = result.keys()\n", "return cls(None, None)\n", "rows = [make_row_serializable(row) for row in result]\n", "return cls(keys, rows)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Return'", "Assign'", "Return'" ]
[ "@classmethod...\n", "VAR_37 = []\n", "VAR_38 = 1.0\n", "VAR_39 = 0.0\n", "VAR_40 = 0\n", "for elem in (VAR_22 + [None]):\n", "if isinstance(elem, CLASS_4):\n", "VAR_37.append(elem)\n", "if len(VAR_37) > 0:\n", "VAR_38 -= elem.percentage\n", "VAR_37[0].before = VAR_21.begin\n", "if isinstance(elem, CLASS_0):\n", "VAR_39 += elem.units\n", "VAR_37[-1].after += VAR_21.end\n", "VAR_21.resolve(elem.children)\n", "VAR_40 += elem.unspecified\n", "if VAR_38 < 0.0:\n", "warn('Fixed column widths exceed 100%.', VAR_38, 'remaining, setting to 0.')\n", "for col in VAR_37:\n", "VAR_38 = 0.0\n", "if col.unspecified:\n", "VAR_37 = []\n", "col.percentage = VAR_38 / VAR_40\n", "col.before += VAR_21.marker % (col.percentage if col.percentage > 0.0 else \n col.units / VAR_39 * VAR_38)\n", "VAR_38 = 1.0\n", "VAR_39 = 0.0\n", "VAR_40 = 0\n" ]
[ "@classmethod...\n", "currentColumnSet = []\n", "totalSpace = 1.0\n", "totalUnits = 0.0\n", "unspecifiedCount = 0\n", "for elem in (docList + [None]):\n", "if isinstance(elem, Column):\n", "currentColumnSet.append(elem)\n", "if len(currentColumnSet) > 0:\n", "totalSpace -= elem.percentage\n", "currentColumnSet[0].before = cls.begin\n", "if isinstance(elem, Hierarchy):\n", "totalUnits += elem.units\n", "currentColumnSet[-1].after += cls.end\n", "cls.resolve(elem.children)\n", "unspecifiedCount += elem.unspecified\n", "if totalSpace < 0.0:\n", "warn('Fixed column widths exceed 100%.', totalSpace, 'remaining, setting to 0.'\n )\n", "for col in currentColumnSet:\n", "totalSpace = 0.0\n", "if col.unspecified:\n", "currentColumnSet = []\n", "col.percentage = totalSpace / unspecifiedCount\n", "col.before += cls.marker % (col.percentage if col.percentage > 0.0 else col\n .units / totalUnits * totalSpace)\n", "totalSpace = 1.0\n", "totalUnits = 0.0\n", "unspecifiedCount = 0\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Condition", "Expr'", "Condition", "AugAssign'", "Assign'", "Condition", "AugAssign'", "AugAssign'", "Expr'", "AugAssign'", "Condition", "Expr'", "For", "Assign'", "Condition", "Assign'", "Assign'", "AugAssign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_6(VAR_8):...\n", "\"\"\"docstring\"\"\"\n", "return hasattr(VAR_8, '__self__') and VAR_8.__self__ is not None\n" ]
[ "def is_class_method(f):...\n", "\"\"\"docstring\"\"\"\n", "return hasattr(f, '__self__') and f.__self__ is not None\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "from grokcore.component import baseclass, context\n", "from zope.component import provideSubscriptionAdapter\n", "import argparse\n", "from opennode.oms.endpoint.ssh import cmd\n", "from opennode.oms.endpoint.ssh.completion import Completer\n", "from opennode.oms.endpoint.ssh.cmdline import GroupDictAction\n", "from opennode.oms.model.model.base import IContainer\n", "from opennode.oms.model.model import creatable_models\n", "from opennode.oms.zodb import db\n", "\"\"\"Completes a command.\"\"\"\n", "context(cmd.NoCommand)\n", "def FUNC_0(self, VAR_0, VAR_1, VAR_2):...\n", "return [name for name in cmd.commands().keys() if name.startswith(VAR_0)]\n" ]
[ "from grokcore.component import baseclass, context\n", "from zope.component import provideSubscriptionAdapter\n", "import argparse\n", "from opennode.oms.endpoint.ssh import cmd\n", "from opennode.oms.endpoint.ssh.completion import Completer\n", "from opennode.oms.endpoint.ssh.cmdline import GroupDictAction\n", "from opennode.oms.model.model.base import IContainer\n", "from opennode.oms.model.model import creatable_models\n", "from opennode.oms.zodb import db\n", "\"\"\"Completes a command.\"\"\"\n", "context(cmd.NoCommand)\n", "def complete(self, token, parsed, parser):...\n", "return [name for name in cmd.commands().keys() if name.startswith(token)]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Expr'", "Expr'", "FunctionDef'", "Return'" ]
[ "def FUNC_30(self, VAR_16):...\n", "" ]
[ "def delete_all(self, items):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_55(self):...\n", "\"\"\"docstring\"\"\"\n", "self.run_example('multiline_statement.py')\n", "self.assertEqual(0, len(self.b_mgr.skipped))\n", "self.assertEqual(1, len(self.b_mgr.files_list))\n", "self.assertTrue(self.b_mgr.files_list[0].endswith('multiline_statement.py'))\n", "VAR_10 = self.b_mgr.get_issue_list()\n", "self.assertEqual(2, len(VAR_10))\n", "self.assertTrue(VAR_10[0].fname.endswith('examples/multiline_statement.py'))\n", "self.assertEqual(1, VAR_10[0].lineno)\n", "self.assertEqual(list(range(1, 3)), VAR_10[0].linerange)\n", "self.assertIn('subprocess', VAR_10[0].get_code())\n", "self.assertEqual(5, VAR_10[1].lineno)\n", "self.assertEqual(list(range(3, 6 + 1)), VAR_10[1].linerange)\n", "self.assertIn('shell=True', VAR_10[1].get_code())\n" ]
[ "def test_multiline_code(self):...\n", "\"\"\"docstring\"\"\"\n", "self.run_example('multiline_statement.py')\n", "self.assertEqual(0, len(self.b_mgr.skipped))\n", "self.assertEqual(1, len(self.b_mgr.files_list))\n", "self.assertTrue(self.b_mgr.files_list[0].endswith('multiline_statement.py'))\n", "issues = self.b_mgr.get_issue_list()\n", "self.assertEqual(2, len(issues))\n", "self.assertTrue(issues[0].fname.endswith('examples/multiline_statement.py'))\n", "self.assertEqual(1, issues[0].lineno)\n", "self.assertEqual(list(range(1, 3)), issues[0].linerange)\n", "self.assertIn('subprocess', issues[0].get_code())\n", "self.assertEqual(5, issues[1].lineno)\n", "self.assertEqual(list(range(3, 6 + 1)), issues[1].linerange)\n", "self.assertIn('shell=True', issues[1].get_code())\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def __init__(self, VAR_2=None, VAR_3=None, VAR_4=True):...\n", "self.vars = {}\n", "self.groups = []\n", "self._uuid = None\n", "self.name = VAR_2\n", "self.address = VAR_2\n", "if VAR_3:\n", "self.set_variable('ansible_port', int(VAR_3))\n", "if VAR_4:\n", "self._uuid = get_unique_id()\n", "self.implicit = False\n" ]
[ "def __init__(self, name=None, port=None, gen_uuid=True):...\n", "self.vars = {}\n", "self.groups = []\n", "self._uuid = None\n", "self.name = name\n", "self.address = name\n", "if port:\n", "self.set_variable('ansible_port', int(port))\n", "if gen_uuid:\n", "self._uuid = get_unique_id()\n", "self.implicit = False\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_0(self, VAR_4):...\n", "return 'hstore'\n" ]
[ "def db_type(self, connection):...\n", "return 'hstore'\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def __init__(self, VAR_8):...\n", "\"\"\"docstring\"\"\"\n", "self.default_tag = VAR_8\n" ]
[ "def __init__(self, default_tag):...\n", "\"\"\"docstring\"\"\"\n", "self.default_tag = default_tag\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'" ]