lines
listlengths
1
444
raw_lines
listlengths
1
444
label
listlengths
1
444
type
listlengths
1
444
[ "def FUNC_1(VAR_1=None):...\n", "\"\"\"docstring\"\"\"\n", "VAR_4 = 'df -i'\n", "if VAR_1 is not None:\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 line.startswith('Filesystem'):\n", "return VAR_2\n", "VAR_5 = line.split()\n", "if not VAR_5:\n", "if __grains__['kernel'] == 'OpenBSD':\n", "VAR_0.warn('Problem parsing inode usage information')\n", "VAR_2[VAR_5[8]] = {'inodes': int(VAR_5[5]) + int(VAR_5[6]), 'used': VAR_5[5\n ], 'free': VAR_5[6], 'use': VAR_5[7], 'filesystem': VAR_5[0]}\n", "VAR_2[VAR_5[5]] = {'inodes': VAR_5[1], 'used': VAR_5[2], 'free': VAR_5[3],\n 'use': VAR_5[4], 'filesystem': VAR_5[0]}\n", "VAR_2 = {}\n" ]
[ "def inodeusage(args=None):...\n", "\"\"\"docstring\"\"\"\n", "cmd = 'df -i'\n", "if args is not None:\n", "cmd = cmd + ' -' + args\n", "ret = {}\n", "out = __salt__['cmd.run'](cmd).splitlines()\n", "for line in out:\n", "if line.startswith('Filesystem'):\n", "return ret\n", "comps = line.split()\n", "if not comps:\n", "if __grains__['kernel'] == 'OpenBSD':\n", "log.warn('Problem parsing inode usage information')\n", "ret[comps[8]] = {'inodes': int(comps[5]) + int(comps[6]), 'used': comps[5],\n 'free': comps[6], 'use': comps[7], 'filesystem': comps[0]}\n", "ret[comps[5]] = {'inodes': comps[1], 'used': comps[2], 'free': comps[3],\n 'use': comps[4], 'filesystem': comps[0]}\n", "ret = {}\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "For", "Condition", "Return'", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_12(self, VAR_4, VAR_14):...\n", "super().validate(VAR_4, VAR_14)\n", "json_encode(VAR_4, cls=self.encoder)\n" ]
[ "def validate(self, value, model_instance):...\n", "super().validate(value, model_instance)\n", "json_encode(value, cls=self.encoder)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'" ]
[ "def FUNC_0():...\n", "VAR_13 = VAR_0.path.dirname(VAR_0.path.abspath(__file__))\n", "return VAR_0.path.join(VAR_13, 'server/ycmd.py')\n" ]
[ "def _PathToServerScript():...\n", "dir_of_current_script = os.path.dirname(os.path.abspath(__file__))\n", "return os.path.join(dir_of_current_script, 'server/ycmd.py')\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_0(*VAR_0, **VAR_1):...\n", "def FUNC_5(VAR_12):...\n", "def FUNC_9(self, *VAR_15, **VAR_75):...\n", "for validator in VAR_0:\n", "if VAR_102.method == 'POST' and hasattr(self, 'ajax_login_redirect'):\n", "return FUNC_9\n", "validator(VAR_75)\n", "VAR_16 = self.build_arg_list(VAR_12, VAR_75)\n", "return self.ajax_login_redirect('/')\n", "return self.intermediate_redirect('/login')\n", "for VAR_110, validator in VAR_1.iteritems():\n", "VAR_16[VAR_110] = validator(VAR_75)\n", "return VAR_12(self, *VAR_15, **kw)\n" ]
[ "def validate(*simple_vals, **param_vals):...\n", "def val(fn):...\n", "def newfn(self, *a, **env):...\n", "for validator in simple_vals:\n", "if request.method == 'POST' and hasattr(self, 'ajax_login_redirect'):\n", "return newfn\n", "validator(env)\n", "kw = self.build_arg_list(fn, env)\n", "return self.ajax_login_redirect('/')\n", "return self.intermediate_redirect('/login')\n", "for var, validator in param_vals.iteritems():\n", "kw[var] = validator(env)\n", "return fn(self, *a, **kw)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "FunctionDef'", "For", "Condition", "Return'", "Expr'", "Assign'", "Return'", "Return'", "For", "Assign'", "Return'" ]
[ "def FUNC_12(self):...\n", "VAR_14 = DataGroup.objects.filter(group_type__code='CO').first()\n", "VAR_15 = self.client.get(f'/datagroup/%s/' % VAR_14.id)\n", "self.assertIn(b'Download Raw', VAR_15.content)\n", "VAR_16 = DataDocument.objects.filter(id__in=ExtractedChemical.objects.all()\n .values('extracted_text_id')).order_by().values_list('data_group_id',\n flat=True).distinct()\n", "for dg_id in VAR_16:\n", "VAR_15 = self.client.get(f'/datagroup/raw_extracted_records/%s/' % dg_id)\n", "VAR_15 = self.client.get(f'/datagroup/raw_extracted_records/%s/' % VAR_16[0])\n", "self.assertEqual(VAR_15.status_code, 200)\n", "VAR_17 = (\n 'ExtractedChemical_id,raw_cas,raw_chem_name,raw_min_comp,raw_central_comp,raw_max_comp,unit_type'\n )\n", "VAR_18 = list(i.decode('utf-8') for i in VAR_15.streaming_content)\n", "self.assertIn(VAR_17, VAR_18[1])\n" ]
[ "def test_download_raw_comp_data(self):...\n", "dg_co = DataGroup.objects.filter(group_type__code='CO').first()\n", "resp = self.client.get(f'/datagroup/%s/' % dg_co.id)\n", "self.assertIn(b'Download Raw', resp.content)\n", "dg_ids = DataDocument.objects.filter(id__in=ExtractedChemical.objects.all()\n .values('extracted_text_id')).order_by().values_list('data_group_id',\n flat=True).distinct()\n", "for dg_id in dg_ids:\n", "resp = self.client.get(f'/datagroup/raw_extracted_records/%s/' % dg_id)\n", "resp = self.client.get(f'/datagroup/raw_extracted_records/%s/' % dg_ids[0])\n", "self.assertEqual(resp.status_code, 200)\n", "field_list = (\n 'ExtractedChemical_id,raw_cas,raw_chem_name,raw_min_comp,raw_central_comp,raw_max_comp,unit_type'\n )\n", "content = list(i.decode('utf-8') for i in resp.streaming_content)\n", "self.assertIn(field_list, content[1])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "For", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_21(self, VAR_17, VAR_16):...\n", "\"\"\"docstring\"\"\"\n", "self._check_volume(VAR_16)\n", "VAR_0.warn(_('Volume %s is not found!, it may have been deleted'), VAR_16[\n 'name'])\n", "VAR_0.error(_('Failed to ensure export of volume %s'), VAR_16['name'])\n" ]
[ "def ensure_export(self, context, volume):...\n", "\"\"\"docstring\"\"\"\n", "self._check_volume(volume)\n", "LOG.warn(_('Volume %s is not found!, it may have been deleted'), volume['name']\n )\n", "LOG.error(_('Failed to ensure export of volume %s'), volume['name'])\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_46(self):...\n", "self.compilation_ko(\n \"\"\"\nif header :isnot \"Sent\" \"me@example.com\" {\n stop;\n}\n\"\"\")\n" ]
[ "def test_bad_arg_value(self):...\n", "self.compilation_ko(\n \"\"\"\nif header :isnot \"Sent\" \"me@example.com\" {\n stop;\n}\n\"\"\")\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def __getitem__(self, *VAR_30):...\n", "return dict.__getitem__(self, VAR_30)\n" ]
[ "def __getitem__(self, *key):...\n", "return dict.__getitem__(self, key)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_15(VAR_22, VAR_23):...\n", "VAR_22 = [{c[0]: VAR_82[i] for i, c in enumerate(VAR_23)} for VAR_82 in VAR_22]\n", "VAR_23 = [{'name': m[0], 'type': m[1]} for m in VAR_23]\n", "for VAR_7 in VAR_23:\n", "if VAR_4.match(VAR_7['type']):\n", "return VAR_22, VAR_23\n", "for VAR_82 in VAR_22:\n", "if VAR_3.match(VAR_7['type']):\n", "VAR_82[VAR_7['name']] = VAR_82[VAR_7['name']].replace(tzinfo=tz.tzutc()\n ).isoformat()\n", "for VAR_82 in VAR_22:\n", "VAR_35 = datetime(*VAR_82[VAR_7['name']].timetuple()[:6]).replace(tzinfo=tz\n .tzutc())\n", "VAR_82[VAR_7['name']] = VAR_35.isoformat()\n" ]
[ "def scrub_ch_data(data, meta):...\n", "data = [{c[0]: d[i] for i, c in enumerate(meta)} for d in data]\n", "meta = [{'name': m[0], 'type': m[1]} for m in meta]\n", "for col in meta:\n", "if DATETIME_TYPE_RE.match(col['type']):\n", "return data, meta\n", "for d in data:\n", "if DATE_TYPE_RE.match(col['type']):\n", "d[col['name']] = d[col['name']].replace(tzinfo=tz.tzutc()).isoformat()\n", "for d in data:\n", "dt = datetime(*d[col['name']].timetuple()[:6]).replace(tzinfo=tz.tzutc())\n", "d[col['name']] = dt.isoformat()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "For", "Condition", "Return'", "For", "Condition", "Assign'", "For", "Assign'", "Assign'" ]
[ "def FUNC_13(self, VAR_64):...\n", "self._onsuccess = VAR_64\n" ]
[ "def onsuccess(self, func):...\n", "self._onsuccess = func\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "VAR_30 = db.session.query(CLASS_0.username, CLASS_0.projects_mapped.any(\n VAR_23).label('participant')).filter(CLASS_0.username.ilike(VAR_22.\n lower() + '%')).order_by(desc('participant').nullslast(), CLASS_0.username\n ).paginate(VAR_24, 20, True)\n", "if VAR_30.total == 0:\n", "VAR_31 = UserFilterDTO()\n", "for VAR_33 in VAR_30.items:\n", "VAR_31.usernames.append(VAR_33.username)\n", "VAR_31.pagination = Pagination(VAR_30)\n", "if VAR_23 is not None:\n", "return VAR_31\n", "VAR_41 = ProjectParticipantUser()\n", "VAR_41.username = VAR_33.username\n", "VAR_41.project_id = VAR_23\n", "VAR_41.is_participant = bool(VAR_33.participant)\n", "VAR_31.users.append(VAR_41)\n" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "results = db.session.query(User.username, User.projects_mapped.any(\n project_id).label('participant')).filter(User.username.ilike(\n user_filter.lower() + '%')).order_by(desc('participant').nullslast(),\n User.username).paginate(page, 20, True)\n", "if results.total == 0:\n", "dto = UserFilterDTO()\n", "for result in results.items:\n", "dto.usernames.append(result.username)\n", "dto.pagination = Pagination(results)\n", "if project_id is not None:\n", "return dto\n", "participant = ProjectParticipantUser()\n", "participant.username = result.username\n", "participant.project_id = project_id\n", "participant.is_participant = bool(result.participant)\n", "dto.users.append(participant)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Condition", "Assign'", "For", "Expr'", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def __call__(self, VAR_11):...\n", "VAR_15 = []\n", "if self.param:\n", "for p in utils.tup(self.param):\n", "return self.run(*VAR_15)\n", "if self.post and VAR_102.post.get(p):\n", "VAR_33 = VAR_102.post[p]\n", "if self.get and VAR_102.get.get(p):\n", "VAR_15.append(VAR_33)\n", "VAR_33 = VAR_102.get[p]\n", "if self.url and VAR_11.get(p):\n", "VAR_33 = VAR_11[p]\n", "VAR_33 = self.default\n" ]
[ "def __call__(self, url):...\n", "a = []\n", "if self.param:\n", "for p in utils.tup(self.param):\n", "return self.run(*a)\n", "if self.post and request.post.get(p):\n", "val = request.post[p]\n", "if self.get and request.get.get(p):\n", "a.append(val)\n", "val = request.get[p]\n", "if self.url and url.get(p):\n", "val = url[p]\n", "val = self.default\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "For", "Return'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_8(VAR_7):...\n", "return render(VAR_7, 'index.html')\n" ]
[ "def index(request):...\n", "return render(request, 'index.html')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_0(self):...\n", "return hpcommon.HP3PARCommon(self.configuration)\n" ]
[ "def _init_common(self):...\n", "return hpcommon.HP3PARCommon(self.configuration)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_12(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_7, VAR_12 = self.make_xsrf_handling_app()\n", "VAR_17 = VAR_7.get('/request').body\n", "VAR_7.post('/request?xsrf_token=%s' % VAR_17)\n", "self.assertEqual([('POST', True)], VAR_12)\n" ]
[ "def test_xsrf_token_get_param(self):...\n", "\"\"\"docstring\"\"\"\n", "app, calls = self.make_xsrf_handling_app()\n", "token = app.get('/request').body\n", "app.post('/request?xsrf_token=%s' % token)\n", "self.assertEqual([('POST', True)], calls)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_1(self, VAR_1):...\n", "return self.properties\n" ]
[ "def _fake_get_iscsi_properties(self, volume):...\n", "return self.properties\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_7(self, VAR_11: bool):...\n", "\"\"\"docstring\"\"\"\n", "self.is_expert = VAR_11\n", "db.session.commit()\n" ]
[ "def set_is_expert(self, is_expert: bool):...\n", "\"\"\"docstring\"\"\"\n", "self.is_expert = is_expert\n", "db.session.commit()\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'" ]
[ "def FUNC_10(self):...\n", "frappe.set_user('test1@example.com')\n", "self.assertRaises(frappe.PermissionError, get_filters_cond, 'DocType', dict\n (istable=1), [])\n", "self.assertTrue(get_filters_cond('DocType', dict(istable=1), [],\n ignore_permissions=True))\n", "frappe.set_user('Administrator')\n" ]
[ "def test_ignore_permissions_for_get_filters_cond(self):...\n", "frappe.set_user('test1@example.com')\n", "self.assertRaises(frappe.PermissionError, get_filters_cond, 'DocType', dict\n (istable=1), [])\n", "self.assertTrue(get_filters_cond('DocType', dict(istable=1), [],\n ignore_permissions=True))\n", "frappe.set_user('Administrator')\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_4(self):...\n", "VAR_5 = models.Session.create()\n", "VAR_3 = models.Session.query().count()\n", "self.assertTrue(VAR_3 == 1)\n", "VAR_2 = EngineAuthRequest.blank('/auth/google')\n", "VAR_2.cookies['_eauth'] = VAR_5.serialize()\n", "VAR_2._load_session()\n", "self.assertTrue(VAR_2.session.session_id == VAR_5.session_id)\n", "VAR_6 = models.Session.query().count()\n", "self.assertTrue(VAR_6 == 1)\n" ]
[ "def test_laod_session_session_id_and_user_id(self):...\n", "s = models.Session.create()\n", "s_count = models.Session.query().count()\n", "self.assertTrue(s_count == 1)\n", "req = EngineAuthRequest.blank('/auth/google')\n", "req.cookies['_eauth'] = s.serialize()\n", "req._load_session()\n", "self.assertTrue(req.session.session_id == s.session_id)\n", "s_count2 = models.Session.query().count()\n", "self.assertTrue(s_count2 == 1)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "@staticmethod...\n", "return FUNC_1(CLASS_0._TalkToHandlerAsync('', VAR_7, 'GET', VAR_10))\n" ]
[ "@staticmethod...\n", "return JsonFromFuture(BaseRequest._TalkToHandlerAsync('', handler, 'GET',\n timeout))\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_18(VAR_1):...\n", "import sql\n", "VAR_13 = ['haproxy -q -c -f %s' % sql.get_setting('haproxy_config_path')]\n", "VAR_37 = FUNC_8(VAR_1)\n", "for command in VAR_13:\n", "VAR_76, VAR_12, VAR_42 = VAR_37.exec_command(command, get_pty=True)\n", "VAR_37.close()\n", "if not VAR_42.read():\n", "return True\n", "return False\n" ]
[ "def check_haproxy_config(serv):...\n", "import sql\n", "commands = ['haproxy -q -c -f %s' % sql.get_setting('haproxy_config_path')]\n", "ssh = ssh_connect(serv)\n", "for command in commands:\n", "stdin, stdout, stderr = ssh.exec_command(command, get_pty=True)\n", "ssh.close()\n", "if not stderr.read():\n", "return True\n", "return False\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Import'", "Assign'", "Assign'", "For", "Assign'", "Expr'", "Condition", "Return'", "Return'" ]
[ "def FUNC_25(self):...\n", "VAR_76 = getattr(self, self.object)\n", "return VAR_76()\n" ]
[ "def get(self):...\n", "func = getattr(self, self.object)\n", "return func()\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "@defer.inlineCallbacks...\n", "VAR_72, VAR_73 = self.post('/attachment', VAR_27=data, VAR_28=headers)\n", "VAR_69 = yield VAR_72\n", "defer.returnValue((VAR_69, VAR_73))\n" ]
[ "@defer.inlineCallbacks...\n", "deferred_result, req = self.post('/attachment', body=data, headers=headers)\n", "res = yield deferred_result\n", "defer.returnValue((res, req))\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Expr'" ]
[ "@VAR_0.route('/explore')...\n", "return render_template('explore.html')\n" ]
[ "@app.route('/explore')...\n", "return render_template('explore.html')\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_3(self, VAR_2):...\n", "VAR_8 = 'WHERE '\n", "VAR_9 = LuceneParser()\n", "VAR_10 = VAR_9.parse(VAR_2)\n", "for tuple in VAR_10:\n", "VAR_8 += '{} {} {}'.format(tuple[0], tuple[1], tuple[2])\n", "return VAR_8\n" ]
[ "def create_where(self, where):...\n", "sql = 'WHERE '\n", "lucene_parser = LuceneParser()\n", "where_tuples = lucene_parser.parse(where)\n", "for tuple in where_tuples:\n", "sql += '{} {} {}'.format(tuple[0], tuple[1], tuple[2])\n", "return sql\n" ]
[ 0, 4, 0, 4, 4, 4, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "For", "AugAssign'", "Return'" ]
[ "def FUNC_34(self, VAR_48):...\n", "VAR_69, VAR_73 = self.delete('/mail/%s' % VAR_48)\n", "return VAR_69\n" ]
[ "def delete_mail(self, mail_ident):...\n", "res, req = self.delete('/mail/%s' % mail_ident)\n", "return res\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "@trial_timeout(5)...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_6(VAR_10):...\n", "self.assertEqual(VAR_10, VAR_11)\n", "VAR_11 = 'magnet:?xt=urn:btih:DC4B96CF85A85CEEDB8ADC4B96CF85A85CEEDB8A'\n", "VAR_2 = get_random_port()\n", "self.setUpHttpRedirectServer(VAR_2, VAR_11)\n", "VAR_6 = 'http://localhost:%d' % VAR_2\n", "VAR_12 = http_get(VAR_6).addCallback(FUNC_6)\n", "return VAR_12\n" ]
[ "@trial_timeout(5)...\n", "\"\"\"docstring\"\"\"\n", "def on_callback(response):...\n", "self.assertEqual(response, magnet_link)\n", "magnet_link = 'magnet:?xt=urn:btih:DC4B96CF85A85CEEDB8ADC4B96CF85A85CEEDB8A'\n", "port = get_random_port()\n", "self.setUpHttpRedirectServer(port, magnet_link)\n", "test_url = 'http://localhost:%d' % port\n", "http_deferred = http_get(test_url).addCallback(on_callback)\n", "return http_deferred\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "FunctionDef'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Return'" ]
[ "@staticmethod...\n", "VAR_3 = AnalysisController.get_report(VAR_0)\n", "VAR_3 = VAR_3['analysis']\n", "VAR_5 = VAR_3['info']['analysis_path']\n", "VAR_6 = 0\n", "for directory in VAR_1:\n", "VAR_14 = '%s/%s' % (VAR_5, directory)\n", "for filename in VAR_2:\n", "if os.path.isdir(VAR_14):\n", "VAR_14 = '%s/%s' % (VAR_5, filename)\n", "VAR_7 = VAR_6 / 6.5\n", "VAR_6 += get_directory_size(VAR_14)\n", "if os.path.isfile(VAR_14):\n", "return {'size': int(VAR_7), 'size_human': filesizeformat(VAR_7)}\n", "VAR_6 += os.path.getsize(VAR_14)\n" ]
[ "@staticmethod...\n", "report = AnalysisController.get_report(task_id)\n", "report = report['analysis']\n", "path = report['info']['analysis_path']\n", "size_total = 0\n", "for directory in taken_dirs:\n", "destination = '%s/%s' % (path, directory)\n", "for filename in taken_files:\n", "if os.path.isdir(destination):\n", "destination = '%s/%s' % (path, filename)\n", "size_estimated = size_total / 6.5\n", "size_total += get_directory_size(destination)\n", "if os.path.isfile(destination):\n", "return {'size': int(size_estimated), 'size_human': filesizeformat(\n size_estimated)}\n", "size_total += os.path.getsize(destination)\n" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "For", "Condition", "Assign'", "Assign'", "AugAssign'", "Condition", "Return'", "AugAssign'" ]
[ "@VAR_13.whitelist()...\n", "if isinstance(VAR_4, string_types):\n", "VAR_4 = json.loads(VAR_4)\n", "VAR_9 = VAR_13.get_meta(VAR_1)\n", "if VAR_0:\n", "FUNC_0(VAR_0)\n", "if not VAR_0:\n", "VAR_0 = 'name'\n", "VAR_14 = VAR_13.get_hooks().standard_queries or {}\n", "if VAR_3 and VAR_3.split()[0].lower() != 'select':\n", "VAR_13.response['values'] = VAR_13.call(VAR_3, VAR_1, VAR_2, VAR_0, VAR_6,\n VAR_5, VAR_4, VAR_8=as_dict)\n", "if not VAR_3 and VAR_1 in VAR_14:\n", "FUNC_2(VAR_1, VAR_2, VAR_14[VAR_1][0], VAR_0, VAR_6, VAR_5, VAR_4)\n", "if VAR_3:\n", "VAR_13.throw(_('This query style is discontinued'))\n", "if isinstance(VAR_4, dict):\n", "VAR_25 = VAR_4.items()\n", "if VAR_4 == None:\n", "VAR_4 = []\n", "VAR_4 = []\n", "VAR_19 = []\n", "for f in VAR_25:\n", "if VAR_2:\n", "if isinstance(f[1], (list, tuple)):\n", "VAR_26 = ['name']\n", "if VAR_9.get('fields', {'fieldname': 'enabled', 'fieldtype': 'Check'}):\n", "VAR_4.append([VAR_1, f[0], f[1][0], f[1][1]])\n", "VAR_4.append([VAR_1, f[0], '=', f[1]])\n", "if VAR_9.title_field:\n", "VAR_4.append([VAR_1, 'enabled', '=', 1])\n", "if VAR_9.get('fields', {'fieldname': 'disabled', 'fieldtype': 'Check'}):\n", "VAR_26.append(VAR_9.title_field)\n", "if VAR_9.search_fields:\n", "VAR_4.append([VAR_1, 'disabled', '!=', 1])\n", "VAR_20 = FUNC_3(VAR_9, VAR_0 or 'name')\n", "VAR_26.extend(VAR_9.get_search_fields())\n", "for f in VAR_26:\n", "if VAR_7:\n", "VAR_27 = VAR_9.get_field(f.strip())\n", "VAR_20 = list(set(VAR_20 + json.loads(VAR_7)))\n", "VAR_21 = [('`tab%s`.`%s`' % (VAR_9.name, f.strip())) for f in VAR_20]\n", "if f == 'name' or VAR_27 and VAR_27.fieldtype in ['Data', 'Text',\n", "VAR_21.append('locate(\"{_txt}\", `tab{doctype}`.`name`) as `_relevance`'.\n format(_txt=frappe.db.escape((txt or '').replace('%', '')), VAR_1=\n frappe.db.escape(doctype)))\n", "VAR_19.append([VAR_1, f.strip(), 'like', '%{0}%'.format(VAR_2)])\n", "from frappe.model.db_query import get_order_by\n", "VAR_22 = get_order_by(VAR_1, VAR_9)\n", "VAR_23 = 'if(_relevance, _relevance, 99999), `tab{0}`.idx desc, {1}'.format(\n VAR_1, VAR_22)\n", "VAR_24 = VAR_13.get_list(VAR_1, VAR_4=filters, VAR_20=formatted_fields,\n VAR_19=or_filters, limit_start=start, limit_page_length=page_length,\n VAR_23=order_by, ignore_permissions=True if doctype == 'DocType' else \n False, as_list=not as_dict)\n", "if VAR_8:\n", "for r in VAR_24:\n", "VAR_13.response['values'] = [r[:-1] for r in VAR_24]\n", "r.pop('_relevance')\n", "VAR_13.response['values'] = VAR_24\n" ]
[ "@frappe.whitelist()...\n", "if isinstance(filters, string_types):\n", "filters = json.loads(filters)\n", "meta = frappe.get_meta(doctype)\n", "if searchfield:\n", "sanitize_searchfield(searchfield)\n", "if not searchfield:\n", "searchfield = 'name'\n", "standard_queries = frappe.get_hooks().standard_queries or {}\n", "if query and query.split()[0].lower() != 'select':\n", "frappe.response['values'] = frappe.call(query, doctype, txt, searchfield,\n start, page_length, filters, as_dict=as_dict)\n", "if not query and doctype in standard_queries:\n", "search_widget(doctype, txt, standard_queries[doctype][0], searchfield,\n start, page_length, filters)\n", "if query:\n", "frappe.throw(_('This query style is discontinued'))\n", "if isinstance(filters, dict):\n", "filters_items = filters.items()\n", "if filters == None:\n", "filters = []\n", "filters = []\n", "or_filters = []\n", "for f in filters_items:\n", "if txt:\n", "if isinstance(f[1], (list, tuple)):\n", "search_fields = ['name']\n", "if meta.get('fields', {'fieldname': 'enabled', 'fieldtype': 'Check'}):\n", "filters.append([doctype, f[0], f[1][0], f[1][1]])\n", "filters.append([doctype, f[0], '=', f[1]])\n", "if meta.title_field:\n", "filters.append([doctype, 'enabled', '=', 1])\n", "if meta.get('fields', {'fieldname': 'disabled', 'fieldtype': 'Check'}):\n", "search_fields.append(meta.title_field)\n", "if meta.search_fields:\n", "filters.append([doctype, 'disabled', '!=', 1])\n", "fields = get_std_fields_list(meta, searchfield or 'name')\n", "search_fields.extend(meta.get_search_fields())\n", "for f in search_fields:\n", "if filter_fields:\n", "fmeta = meta.get_field(f.strip())\n", "fields = list(set(fields + json.loads(filter_fields)))\n", "formatted_fields = [('`tab%s`.`%s`' % (meta.name, f.strip())) for f in fields]\n", "if f == 'name' or fmeta and fmeta.fieldtype in ['Data', 'Text',\n", "formatted_fields.append(\n 'locate(\"{_txt}\", `tab{doctype}`.`name`) as `_relevance`'.format(_txt=\n frappe.db.escape((txt or '').replace('%', '')), doctype=frappe.db.\n escape(doctype)))\n", "or_filters.append([doctype, f.strip(), 'like', '%{0}%'.format(txt)])\n", "from frappe.model.db_query import get_order_by\n", "order_by_based_on_meta = get_order_by(doctype, meta)\n", "order_by = 'if(_relevance, _relevance, 99999), `tab{0}`.idx desc, {1}'.format(\n doctype, order_by_based_on_meta)\n", "values = frappe.get_list(doctype, filters=filters, fields=formatted_fields,\n or_filters=or_filters, limit_start=start, limit_page_length=page_length,\n order_by=order_by, ignore_permissions=True if doctype == 'DocType' else\n False, as_list=not as_dict)\n", "if as_dict:\n", "for r in values:\n", "frappe.response['values'] = [r[:-1] for r in values]\n", "r.pop('_relevance')\n", "frappe.response['values'] = values\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "For", "Condition", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Assign'", "Expr'", "For", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Condition", "For", "Assign'", "Expr'", "Assign'" ]
[ "@db_session...\n", "\"\"\"docstring\"\"\"\n", "VAR_37 = {'id': self.rowid, 'name': self.title, 'infohash': hexlify(self.\n infohash), 'size': self.size, 'category': self.tags, 'num_seeders':\n self.health.seeders, 'num_leechers': self.health.leechers,\n 'last_tracker_check': self.health.last_check, 'status': self.status}\n", "if VAR_29:\n", "VAR_37['trackers'] = [VAR_39.url for VAR_39 in self.health.trackers]\n", "return VAR_37\n" ]
[ "@db_session...\n", "\"\"\"docstring\"\"\"\n", "simple_dict = {'id': self.rowid, 'name': self.title, 'infohash': hexlify(\n self.infohash), 'size': self.size, 'category': self.tags, 'num_seeders':\n self.health.seeders, 'num_leechers': self.health.leechers,\n 'last_tracker_check': self.health.last_check, 'status': self.status}\n", "if include_trackers:\n", "simple_dict['trackers'] = [tracker.url for tracker in self.health.trackers]\n", "return simple_dict\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Condition", "Assign'", "Return'" ]
[ "def __init__(self, VAR_1, **VAR_2):...\n", "self._type = VAR_1\n", "self._db_params = VAR_2\n" ]
[ "def __init__(self, type, **kwargs):...\n", "self._type = type\n", "self._db_params = kwargs\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'" ]
[ "def FUNC_44(self):...\n", "return [i.name for i in self.obj.__mapper__.columns if isinstance(i.type,\n FileColumn)]\n" ]
[ "def get_file_column_list(self):...\n", "return [i.name for i in self.obj.__mapper__.columns if isinstance(i.type,\n FileColumn)]\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_11(self):...\n", "\"\"\"docstring\"\"\"\n", "if len(self.tables) > 1:\n", "for VAR_73, VAR_34 in enumerate(self.fields):\n", "if '.' not in VAR_34:\n", "self.fields[VAR_73] = '{0}.{1}'.format(self.tables[0], VAR_34)\n" ]
[ "def set_field_tables(self):...\n", "\"\"\"docstring\"\"\"\n", "if len(self.tables) > 1:\n", "for i, f in enumerate(self.fields):\n", "if '.' not in f:\n", "self.fields[i] = '{0}.{1}'.format(self.tables[0], f)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "For", "Condition", "Assign'" ]
[ "def FUNC_6(self, VAR_21):...\n", "if VAR_21:\n", "VAR_106 = int(VAR_21, 36)\n", "if self.redirect:\n", "return Link._byID(VAR_106, True)\n", "abort(404, 'page not found')\n", "return None\n" ]
[ "def run(self, link_id):...\n", "if link_id:\n", "aid = int(link_id, 36)\n", "if self.redirect:\n", "return Link._byID(aid, True)\n", "abort(404, 'page not found')\n", "return None\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Condition", "Return'", "Expr'", "Return'" ]
[ "def FUNC_1(self, VAR_4):...\n", "VAR_7 = self._get_engine(VAR_4)\n", "return VAR_7.table_names()\n" ]
[ "def get_table_names(self, connection_url):...\n", "engine = self._get_engine(connection_url)\n", "return engine.table_names()\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def __init__(self):...\n", "self.conn = MySQLdb.connect(*self.dsn)\n", "self.cur = self.conn.cursor()\n" ]
[ "def __init__(self):...\n", "self.conn = MySQLdb.connect(*self.dsn)\n", "self.cur = self.conn.cursor()\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'" ]
[ "def __str__(self):...\n", "VAR_26 = self.before\n", "for c in self.children:\n", "VAR_26 += str(c) + self.inter\n", "VAR_26 += self.after\n", "return VAR_26\n" ]
[ "def __str__(self):...\n", "s = self.before\n", "for c in self.children:\n", "s += str(c) + self.inter\n", "s += self.after\n", "return s\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "AugAssign'", "AugAssign'", "Return'" ]
[ "def FUNC_0(VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.model.document import Document\n", "if not VAR_1 in VAR_0:\n", "VAR_31, VAR_32 = VAR_54.db.get_value('DocType', VAR_1, ('module', 'custom'),\n cache=True) or ['Core', False]\n", "return VAR_0[VAR_1]\n", "if VAR_32:\n", "VAR_51 = Document\n", "VAR_52 = load_doctype_module(VAR_1, VAR_31)\n", "VAR_0[VAR_1] = VAR_51\n", "VAR_53 = VAR_1.replace(' ', '').replace('-', '')\n", "if hasattr(VAR_52, VAR_53):\n", "VAR_51 = getattr(VAR_52, VAR_53)\n", "if issubclass(VAR_51, CLASS_0):\n", "VAR_51 = getattr(VAR_52, VAR_53)\n" ]
[ "def get_controller(doctype):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.model.document import Document\n", "if not doctype in _classes:\n", "module_name, custom = frappe.db.get_value('DocType', doctype, ('module',\n 'custom'), cache=True) or ['Core', False]\n", "return _classes[doctype]\n", "if custom:\n", "_class = Document\n", "module = load_doctype_module(doctype, module_name)\n", "_classes[doctype] = _class\n", "classname = doctype.replace(' ', '').replace('-', '')\n", "if hasattr(module, classname):\n", "_class = getattr(module, classname)\n", "if issubclass(_class, BaseDocument):\n", "_class = getattr(module, classname)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "ImportFrom'", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'" ]
[ "def __call__(self, VAR_2, VAR_3, VAR_4=None):...\n", "self.reply(VAR_2, \"I don't know that. Did you mean: {} {}\".format(self.\n _new_name, VAR_3))\n" ]
[ "def __call__(self, msg, arguments, errorSink=None):...\n", "self.reply(msg, \"I don't know that. Did you mean: {} {}\".format(self.\n _new_name, arguments))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_13(self, VAR_15):...\n", "self.database_manager = DatabaseManager(self.filechooser_creation_dialog.\n get_filename(), 'liufhre86ewoiwejmrcu8owe')\n", "VAR_28 = Gtk.Builder()\n", "VAR_28.add_from_resource('/run/terminal/KeepassGtk/create_database.ui')\n", "VAR_6 = VAR_28.get_object('headerbar')\n", "CreateDatabase(self, self.create_tab(VAR_15, VAR_6), self.database_manager)\n" ]
[ "def start_database_creation_routine(self, tab_title):...\n", "self.database_manager = DatabaseManager(self.filechooser_creation_dialog.\n get_filename(), 'liufhre86ewoiwejmrcu8owe')\n", "builder = Gtk.Builder()\n", "builder.add_from_resource('/run/terminal/KeepassGtk/create_database.ui')\n", "headerbar = builder.get_object('headerbar')\n", "CreateDatabase(self, self.create_tab(tab_title, headerbar), self.\n database_manager)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "@VAR_0.route('/uploadfile', methods=['GET', 'POST'])...\n", "if request.method == 'POST':\n", "if 'file' not in request.files:\n", "flash('No selected items')\n", "VAR_17 = request.files['file']\n", "return 'Err'\n", "if VAR_17.filename == '':\n", "flash('No file selected')\n", "if VAR_17 and FUNC_11(VAR_17.filename):\n", "return 'Err'\n", "VAR_5 = secure_filename(VAR_17.filename)\n", "VAR_17.save(os.path.join(VAR_0.config['UPLOAD_FOLDER'], VAR_5))\n", "return redirect(url_for('uploaded_file', VAR_5=filename))\n" ]
[ "@app.route('/uploadfile', methods=['GET', 'POST'])...\n", "if request.method == 'POST':\n", "if 'file' not in request.files:\n", "flash('No selected items')\n", "file = request.files['file']\n", "return 'Err'\n", "if file.filename == '':\n", "flash('No file selected')\n", "if file and allowed_file(file.filename):\n", "return 'Err'\n", "filename = secure_filename(file.filename)\n", "file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))\n", "return redirect(url_for('uploaded_file', filename=filename))\n" ]
[ 0, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 4, 4 ]
[ "Condition", "Condition", "Condition", "Expr'", "Assign'", "Return'", "Condition", "Expr'", "Condition", "Return'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_4(self, VAR_7=None, VAR_8=None, VAR_4=None, VAR_9=None, VAR_10=...\n", "if not VAR_18 and not frappe.has_permission(self.doctype, 'read', VAR_19=user):\n", "frappe.flags.error_message = _('Insufficient Permission for {0}').format(frappe\n .bold(self.doctype))\n", "if isinstance(VAR_8, dict) or isinstance(VAR_8, list) and VAR_8 and isinstance(\n", "VAR_4, VAR_8 = VAR_8, VAR_4\n", "if VAR_8 and isinstance(VAR_4, list) and len(VAR_4) > 1 and isinstance(VAR_4\n", "if VAR_8:\n", "VAR_4, VAR_8 = VAR_8, VAR_4\n", "self.fields = VAR_8\n", "self.fields = ['`tab{0}`.`name`'.format(self.doctype)]\n", "if VAR_23:\n", "VAR_13 = VAR_23\n", "if VAR_24:\n", "VAR_14 = VAR_24\n", "if VAR_25:\n", "VAR_14 = VAR_25\n", "self.filters = VAR_4 or []\n", "self.or_filters = VAR_9 or []\n", "self.docstatus = VAR_10 or []\n", "self.group_by = VAR_11\n", "self.order_by = VAR_12\n", "self.limit_start = 0 if VAR_13 is False else cint(VAR_13)\n", "self.limit_page_length = cint(VAR_14) if VAR_14 else None\n", "self.with_childnames = VAR_16\n", "self.debug = VAR_17\n", "self.join = VAR_21\n", "self.distinct = VAR_22\n", "self.as_list = VAR_15\n", "self.ignore_ifnull = VAR_26\n", "self.flags.ignore_permissions = VAR_18\n", "self.user = VAR_19 or frappe.session.user\n", "self.update = VAR_29\n", "self.user_settings_fields = copy.deepcopy(self.fields)\n", "if VAR_31:\n", "self.user_settings = json.loads(VAR_31)\n", "if VAR_7:\n", "VAR_39 = self.run_custom_query(VAR_7)\n", "VAR_39 = self.build_and_run()\n", "if VAR_20 and not VAR_15 and self.doctype:\n", "self.add_comment_count(VAR_39)\n", "if VAR_27:\n", "self.save_user_settings_fields = VAR_28\n", "return VAR_39\n", "self.update_user_settings()\n" ]
[ "def execute(self, query=None, fields=None, filters=None, or_filters=None,...\n", "if not ignore_permissions and not frappe.has_permission(self.doctype,\n", "frappe.flags.error_message = _('Insufficient Permission for {0}').format(frappe\n .bold(self.doctype))\n", "if isinstance(fields, dict) or isinstance(fields, list\n", "filters, fields = fields, filters\n", "if fields and isinstance(filters, list) and len(filters) > 1 and isinstance(\n", "if fields:\n", "filters, fields = fields, filters\n", "self.fields = fields\n", "self.fields = ['`tab{0}`.`name`'.format(self.doctype)]\n", "if start:\n", "limit_start = start\n", "if page_length:\n", "limit_page_length = page_length\n", "if limit:\n", "limit_page_length = limit\n", "self.filters = filters or []\n", "self.or_filters = or_filters or []\n", "self.docstatus = docstatus or []\n", "self.group_by = group_by\n", "self.order_by = order_by\n", "self.limit_start = 0 if limit_start is False else cint(limit_start)\n", "self.limit_page_length = cint(limit_page_length) if limit_page_length else None\n", "self.with_childnames = with_childnames\n", "self.debug = debug\n", "self.join = join\n", "self.distinct = distinct\n", "self.as_list = as_list\n", "self.ignore_ifnull = ignore_ifnull\n", "self.flags.ignore_permissions = ignore_permissions\n", "self.user = user or frappe.session.user\n", "self.update = update\n", "self.user_settings_fields = copy.deepcopy(self.fields)\n", "if user_settings:\n", "self.user_settings = json.loads(user_settings)\n", "if query:\n", "result = self.run_custom_query(query)\n", "result = self.build_and_run()\n", "if with_comment_count and not as_list and self.doctype:\n", "self.add_comment_count(result)\n", "if save_user_settings:\n", "self.save_user_settings_fields = save_user_settings_fields\n", "return result\n", "self.update_user_settings()\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 ]
[ "Condition", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Return'", "Expr'" ]
[ "def FUNC_2(self, VAR_4):...\n", "def FUNC_8(VAR_13, VAR_14):...\n", "VAR_5 = self.paths[VAR_13]\n", "return VAR_5._handlers.get(VAR_14, None)\n" ]
[ "def find_handler(self, req):...\n", "def get_handlers(path, method):...\n", "component = self.paths[path]\n", "return component._handlers.get(method, None)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_8(self, VAR_8=False):...\n", "if not self.NativeFiletypeCompletionAvailable(\n", "self._latest_completion_request = OmniCompletionRequest(self._omnicomp)\n", "VAR_5 = {}\n", "return self._latest_completion_request\n", "self._AddExtraConfDataIfNeeded(VAR_5)\n", "if VAR_8:\n", "VAR_5['force_semantic'] = True\n", "self._latest_completion_request = CompletionRequest(VAR_5\n ) if self._IsServerAlive() else None\n" ]
[ "def CreateCompletionRequest(self, force_semantic=False):...\n", "if not self.NativeFiletypeCompletionAvailable(\n", "self._latest_completion_request = OmniCompletionRequest(self._omnicomp)\n", "extra_data = {}\n", "return self._latest_completion_request\n", "self._AddExtraConfDataIfNeeded(extra_data)\n", "if force_semantic:\n", "extra_data['force_semantic'] = True\n", "self._latest_completion_request = CompletionRequest(extra_data\n ) if self._IsServerAlive() else None\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Return'", "Expr'", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_3():...\n", "\"\"\"docstring\"\"\"\n", "VAR_1 = 'string'\n", "return FUNC_0(VAR_1)\n" ]
[ "def get_show_stoper_days():...\n", "\"\"\"docstring\"\"\"\n", "cmd = \"\"\"SELECT to_char(date, 'FMMonth DD, YYYY') as date,\n ROUND(error_percent, 2) as error_rate\n FROM(\n SELECT time::date AS date,\n 100 * (COUNT(*) FILTER (WHERE status = '404 NOT FOUND') /\n COUNT(*)::numeric) AS error_percent\n FROM log GROUP BY time::date) a\n WHERE error_percent > 1\"\"\"\n", "return execute_query(cmd)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_16(self):...\n", "\"\"\"docstring\"\"\"\n", "logging.info('Initiating SAML logout request')\n", "VAR_42 = self._current_user_nameid()\n", "logging.warning('No SAML data in session. Cannot SLO log out')\n", "VAR_11 = self._saml_auth()\n", "VAR_43 = self._current_saml_session_id()\n", "self.clear_session()\n", "if not VAR_11.get_slo_url():\n", "return self.redirect_to_goodbye()\n", "logging.warning('No SingleLogOut endpoint defined for IdP')\n", "self.clear_session()\n", "self.clear_session()\n", "return flask.redirect(VAR_11.logout(name_id=current_nameid, session_index=\n current_session_id))\n", "return self.redirect_to_goodbye()\n" ]
[ "def log_out(self):...\n", "\"\"\"docstring\"\"\"\n", "logging.info('Initiating SAML logout request')\n", "current_nameid = self._current_user_nameid()\n", "logging.warning('No SAML data in session. Cannot SLO log out')\n", "auth = self._saml_auth()\n", "current_session_id = self._current_saml_session_id()\n", "self.clear_session()\n", "if not auth.get_slo_url():\n", "return self.redirect_to_goodbye()\n", "logging.warning('No SingleLogOut endpoint defined for IdP')\n", "self.clear_session()\n", "self.clear_session()\n", "return flask.redirect(auth.logout(name_id=current_nameid, session_index=\n current_session_id))\n", "return self.redirect_to_goodbye()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Condition", "Return'", "Expr'", "Expr'", "Expr'", "Return'", "Return'" ]
[ "def FUNC_6(self, VAR_11='', VAR_6=None):...\n", "VAR_5 = self.session.query(self.obj)\n", "VAR_5 = self._get_base_query(VAR_5=query, VAR_6=filters)\n", "VAR_25 = VAR_5.all()\n", "VAR_27 = GroupByDateYear(VAR_11, 'Group by Year')\n", "return VAR_27.apply(VAR_25)\n" ]
[ "def query_year_group(self, group_by='', filters=None):...\n", "query = self.session.query(self.obj)\n", "query = self._get_base_query(query=query, filters=filters)\n", "query_result = query.all()\n", "group_year = GroupByDateYear(group_by, 'Group by Year')\n", "return group_year.apply(query_result)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_26(self):...\n", "for VAR_25 in self.meta.get('fields'):\n", "if VAR_25.fieldtype == 'Check':\n", "if self.docstatus is not None:\n", "self.set(VAR_25.fieldname, cint(self.get(VAR_25.fieldname)))\n", "if self.get(VAR_25.fieldname) is not None:\n", "self.docstatus = cint(self.docstatus)\n", "if VAR_25.fieldtype == 'Int':\n", "self.set(VAR_25.fieldname, cint(self.get(VAR_25.fieldname)))\n", "if VAR_25.fieldtype in ('Float', 'Currency', 'Percent'):\n", "self.set(VAR_25.fieldname, flt(self.get(VAR_25.fieldname)))\n" ]
[ "def _fix_numeric_types(self):...\n", "for df in self.meta.get('fields'):\n", "if df.fieldtype == 'Check':\n", "if self.docstatus is not None:\n", "self.set(df.fieldname, cint(self.get(df.fieldname)))\n", "if self.get(df.fieldname) is not None:\n", "self.docstatus = cint(self.docstatus)\n", "if df.fieldtype == 'Int':\n", "self.set(df.fieldname, cint(self.get(df.fieldname)))\n", "if df.fieldtype in ('Float', 'Currency', 'Percent'):\n", "self.set(df.fieldname, flt(self.get(df.fieldname)))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Condition", "Condition", "Expr'", "Condition", "Assign'", "Condition", "Expr'", "Condition", "Expr'" ]
[ "def FUNC_5(VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12):...\n", "\"\"\"docstring\"\"\"\n", "VAR_18 = sql.connect('./resources/messages.db')\n", "VAR_14 = 0\n", "VAR_17 = ''\n", "if VAR_8 == None:\n", "VAR_8 = 'NULL'\n", "VAR_20 = 'string'\n", "VAR_21 = VAR_18.cursor()\n", "print(''.join(traceback.format_exception(etype=type(e), value=e, tb=e.\n __traceback__)))\n", "VAR_18.close()\n", "VAR_22 = VAR_6, VAR_9, VAR_10, VAR_11, VAR_12, VAR_14, VAR_17, VAR_7, VAR_8\n", "VAR_18.rollback()\n", "return VAR_41\n", "VAR_21.execute(VAR_20, VAR_22)\n", "VAR_41 = False\n", "VAR_18.commit()\n", "VAR_41 = True\n" ]
[ "def add_message(message, timeposted, eventtime, poster_id, poster_username,...\n", "\"\"\"docstring\"\"\"\n", "con = sql.connect('./resources/messages.db')\n", "likes = 0\n", "comments = ''\n", "if eventtime == None:\n", "eventtime = 'NULL'\n", "cmd = \"\"\"INSERT INTO messages (message, poster_id, poster_username,\n poster_firstname, poster_lastname, likes, comments,\n timeposted, eventtime)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);\"\"\"\n", "cur = con.cursor()\n", "print(''.join(traceback.format_exception(etype=type(e), value=e, tb=e.\n __traceback__)))\n", "con.close()\n", "info = (message, poster_id, poster_username, poster_firstname,\n poster_lastname, likes, comments, timeposted, eventtime)\n", "con.rollback()\n", "return success\n", "cur.execute(cmd, info)\n", "success = False\n", "con.commit()\n", "success = True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Return'", "Expr'", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_9(VAR_3, VAR_6):...\n", "VAR_0, VAR_10 = FUNC_0()\n", "VAR_18 = 'SELECT poll_name from {} where adm_token = \"{}\"'.format(CFG(\n 'admintoken_table_name'), VAR_6)\n", "VAR_20 = FUNC_3(VAR_10, VAR_18)\n", "FUNC_1(VAR_0)\n", "return VAR_20 == VAR_3\n" ]
[ "def checkAdmTokenValid(poll_name, adm_token):...\n", "conn, c = connectDB()\n", "req = 'SELECT poll_name from {} where adm_token = \"{}\"'.format(CFG(\n 'admintoken_table_name'), adm_token)\n", "answer = queryOne(c, req)\n", "closeDB(conn)\n", "return answer == poll_name\n" ]
[ 0, 0, 4, 4, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_4(self):...\n", "self.run_test_case(self.scenario.upsert_load_balancer())\n" ]
[ "def test_a_upsert_load_balancer(self):...\n", "self.run_test_case(self.scenario.upsert_load_balancer())\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_16(self):...\n", "self.run_test_case(self.scenario.create_http_load_balancer())\n" ]
[ "def test_d_create_http_load_balancer(self):...\n", "self.run_test_case(self.scenario.create_http_load_balancer())\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def __init__(self, VAR_15=4, VAR_16=0.5, VAR_8='ping', **VAR_1):...\n", "super().__init__(VAR_8, **kwargs)\n", "self.argparse.add_argument('-6', '--ipv6', action='store_true', dest='ipv6',\n default=False, help='Use ping6 instead of ping')\n", "self.argparse.add_argument('--alot', action='store_true', dest='alot', help\n ='Send more pings')\n", "self.argparse.add_argument('host', help='Host which is to be pinged')\n", "self.pingargs = ['-q', '-i{0:f}'.format(VAR_16)]\n" ]
[ "def __init__(self, count=4, interval=0.5, command_name='ping', **kwargs):...\n", "super().__init__(command_name, **kwargs)\n", "self.argparse.add_argument('-6', '--ipv6', action='store_true', dest='ipv6',\n default=False, help='Use ping6 instead of ping')\n", "self.argparse.add_argument('--alot', action='store_true', dest='alot', help\n ='Send more pings')\n", "self.argparse.add_argument('host', help='Host which is to be pinged')\n", "self.pingargs = ['-q', '-i{0:f}'.format(interval)]\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'" ]
[ "def FUNC_7(self, *VAR_16, **VAR_17):...\n", "" ]
[ "def recv(self, *args, **kwargs):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_38(self, VAR_47, VAR_48=None, **VAR_46):...\n", "from core.models import Template\n", "VAR_60 = Template.get(Template.blog == self._tags.get('blog', None), \n Template.title == VAR_48)\n", "VAR_18 = CLASS_1(VAR_60.body, VAR_26=self._tags)\n", "self.includes.append(VAR_48)\n", "return VAR_18.execute(VAR_47['_stdout'], VAR_47)\n" ]
[ "def _include(self, env, _name=None, **kwargs):...\n", "from core.models import Template\n", "template_to_import = Template.get(Template.blog == self._tags.get('blog',\n None), Template.title == _name)\n", "tpl = MetalTemplate(template_to_import.body, tags=self._tags)\n", "self.includes.append(_name)\n", "return tpl.execute(env['_stdout'], env)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "@user_passes_test(user_is_superuser)...\n", "VAR_11 = []\n", "VAR_10 = get_object_or_404(TestRailConfiguration, pk=testrail_id)\n", "VAR_12 = APIClient(VAR_10.instance.host)\n", "VAR_12.user = VAR_10.instance.username\n", "VAR_12.password = VAR_10.instance.password\n", "VAR_13 = VAR_12.send_get('get_suites/' + str(VAR_10.project_id))\n", "for suite in VAR_13:\n", "VAR_11.append(suite['name'])\n", "if VAR_10.test_suite != VAR_11:\n", "VAR_10.test_suite = VAR_11\n", "VAR_4 = context_project_dashboard(VAR_0)\n", "VAR_10.save()\n", "VAR_4['last_tab'] = 'test_rails'\n", "return render(VAR_0, 'projects/project_dashboard.html', VAR_4)\n" ]
[ "@user_passes_test(user_is_superuser)...\n", "suites = []\n", "testrail = get_object_or_404(TestRailConfiguration, pk=testrail_id)\n", "client = APIClient(testrail.instance.host)\n", "client.user = testrail.instance.username\n", "client.password = testrail.instance.password\n", "testrail_find_suites = client.send_get('get_suites/' + str(testrail.project_id)\n )\n", "for suite in testrail_find_suites:\n", "suites.append(suite['name'])\n", "if testrail.test_suite != suites:\n", "testrail.test_suite = suites\n", "context = context_project_dashboard(request)\n", "testrail.save()\n", "context['last_tab'] = 'test_rails'\n", "return render(request, 'projects/project_dashboard.html', context)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Expr'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_5(self):...\n", "\"\"\"docstring\"\"\"\n", "client.devices.insert([])\n", "client.devices.insert(None)\n", "client.devices.delete([])\n", "client.devices.delete(None)\n", "client.media.insert([])\n", "client.media.insert(None)\n", "client.media.delete([])\n", "client.media.delete(None)\n" ]
[ "def test_manipulate_empty(self):...\n", "\"\"\"docstring\"\"\"\n", "client.devices.insert([])\n", "client.devices.insert(None)\n", "client.devices.delete([])\n", "client.devices.delete(None)\n", "client.media.insert([])\n", "client.media.insert(None)\n", "client.media.delete([])\n", "client.media.delete(None)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_11(VAR_13):...\n", "return binascii.unhexlify(VAR_13)\n" ]
[ "def hex_to_binary(hex_identifier):...\n", "return binascii.unhexlify(hex_identifier)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@mock.patch('requests.post', FUNC_0)...\n", "VAR_4 = '/api/apps'\n", "VAR_5 = self.client.post(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 201)\n", "VAR_6 = VAR_5.data['id']\n", "VAR_4 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "self.assertEqual(len(VAR_5.data['results']), 0)\n", "VAR_4 = '/api/apps/{app_id}/builds'.format(**locals())\n", "VAR_8 = {'image': 'autotest/example', 'dockerfile':\n \"\"\"FROM busybox\nCMD /bin/true\"\"\"}\n", "VAR_5 = self.client.post(VAR_4, json.dumps(VAR_8), content_type=\n 'application/json')\n", "self.assertEqual(VAR_5.status_code, 201)\n", "VAR_4 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_8 = {'cmd': 6}\n", "VAR_5 = self.client.post(VAR_4, json.dumps(VAR_8), content_type=\n 'application/json')\n", "self.assertEqual(VAR_5.status_code, 204)\n", "VAR_4 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "self.assertEqual(len(VAR_5.data['results']), 6)\n", "VAR_4 = '/api/apps/{app_id}'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "VAR_4 = '/api/apps/{app_id}/containers/cmd'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "self.assertEqual(len(VAR_5.data['results']), 6)\n", "VAR_4 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_8 = {'cmd': 3}\n", "VAR_5 = self.client.post(VAR_4, json.dumps(VAR_8), content_type=\n 'application/json')\n", "self.assertEqual(VAR_5.status_code, 204)\n", "VAR_4 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "self.assertEqual(len(VAR_5.data['results']), 3)\n", "self.assertEqual(max(VAR_7['num'] for VAR_7 in VAR_5.data['results']), 3)\n", "VAR_4 = '/api/apps/{app_id}'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "VAR_4 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_8 = {'cmd': 0}\n", "VAR_5 = self.client.post(VAR_4, json.dumps(VAR_8), content_type=\n 'application/json')\n", "self.assertEqual(VAR_5.status_code, 204)\n", "VAR_4 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "self.assertEqual(len(VAR_5.data['results']), 0)\n", "VAR_4 = '/api/apps/{app_id}'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n" ]
[ "@mock.patch('requests.post', mock_import_repository_task)...\n", "url = '/api/apps'\n", "response = self.client.post(url)\n", "self.assertEqual(response.status_code, 201)\n", "app_id = response.data['id']\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 0)\n", "url = '/api/apps/{app_id}/builds'.format(**locals())\n", "body = {'image': 'autotest/example', 'dockerfile':\n \"\"\"FROM busybox\nCMD /bin/true\"\"\"}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'cmd': 6}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 6)\n", "url = '/api/apps/{app_id}'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "url = '/api/apps/{app_id}/containers/cmd'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 6)\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'cmd': 3}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 3)\n", "self.assertEqual(max(c['num'] for c in response.data['results']), 3)\n", "url = '/api/apps/{app_id}'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'cmd': 0}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 0)\n", "url = '/api/apps/{app_id}'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\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 ]
[ "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_0(self, VAR_1, VAR_2=None, VAR_3=False):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = 'string'.format(default_store=store, repo_dir=REPO_DIR, shard_str=\n '/shard_' + self.shard if self.shard else '', exp_text=name,\n a11y_custom_file=\n 'node_modules/edx-custom-a11y-rules/lib/custom_a11y_rules.js', VAR_3=\n verify_xss)\n", "return VAR_6\n" ]
[ "def _expected_command(self, name, store=None, verify_xss=False):...\n", "\"\"\"docstring\"\"\"\n", "expected_statement = (\n \"DEFAULT_STORE={default_store} SCREENSHOT_DIR='{repo_dir}/test_root/log{shard_str}' BOK_CHOY_HAR_DIR='{repo_dir}/test_root/log{shard_str}/hars' BOKCHOY_A11Y_CUSTOM_RULES_FILE='{repo_dir}/{a11y_custom_file}' SELENIUM_DRIVER_LOG_DIR='{repo_dir}/test_root/log{shard_str}' VERIFY_XSS='{verify_xss}' nosetests {repo_dir}/common/test/acceptance/{exp_text} --with-xunit --xunit-file={repo_dir}/reports/bok_choy{shard_str}/xunit.xml --verbosity=2 \"\n .format(default_store=store, repo_dir=REPO_DIR, shard_str='/shard_' +\n self.shard if self.shard else '', exp_text=name, a11y_custom_file=\n 'node_modules/edx-custom-a11y-rules/lib/custom_a11y_rules.js',\n verify_xss=verify_xss))\n", "return expected_statement\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "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'" ]
[ "def FUNC_8(self):...\n", "\"\"\"docstring\"\"\"\n", "\"\"\"Test creating a Push via the API\"\"\"\n", "self.client.login(VAR_8='autotest2', VAR_9='password')\n", "VAR_4 = '/api/apps'\n", "VAR_5 = self.client.post(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 201)\n", "VAR_6 = VAR_5.data['id']\n", "self.client.login(VAR_8='autotest', VAR_9='password')\n", "VAR_18 = \"\"\"\n FROM busybox\n CMD /bin/true\n \"\"\"\n", "VAR_7 = {'receive_user': 'autotest', 'receive_repo': VAR_6, 'image':\n '{app_id}:v2'.format(**locals()), 'sha':\n 'ecdff91c57a0b9ab82e89634df87e293d259a3aa', 'dockerfile': VAR_18}\n", "VAR_4 = '/api/hooks/builds'\n", "VAR_5 = self.client.post(VAR_4, json.dumps(VAR_7), content_type=\n 'application/json', HTTP_X_DEIS_BUILDER_AUTH=settings.BUILDER_KEY)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "self.assertEqual(VAR_5.data['release']['version'], 2)\n" ]
[ "def test_admin_can_hook(self):...\n", "\"\"\"docstring\"\"\"\n", "\"\"\"Test creating a Push via the API\"\"\"\n", "self.client.login(username='autotest2', password='password')\n", "url = '/api/apps'\n", "response = self.client.post(url)\n", "self.assertEqual(response.status_code, 201)\n", "app_id = response.data['id']\n", "self.client.login(username='autotest', password='password')\n", "DOCKERFILE = \"\"\"\n FROM busybox\n CMD /bin/true\n \"\"\"\n", "body = {'receive_user': 'autotest', 'receive_repo': app_id, 'image':\n '{app_id}:v2'.format(**locals()), 'sha':\n 'ecdff91c57a0b9ab82e89634df87e293d259a3aa', 'dockerfile': DOCKERFILE}\n", "url = '/api/hooks/builds'\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json', HTTP_X_DEIS_BUILDER_AUTH=settings.BUILDER_KEY)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(response.data['release']['version'], 2)\n" ]
[ 0, 0, 0, 5, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def __hash__(self):...\n", "return self.name.__hash__()\n" ]
[ "def __hash__(self):...\n", "return self.name.__hash__()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_9(self):...\n", "\"\"\"docstring\"\"\"\n", "frappe.db.sql('delete from tabEvent')\n", "VAR_4 = FUNC_0()\n", "VAR_5 = FUNC_0(VAR_1='2016-07-05 23:59:59')\n", "VAR_6 = FUNC_0(VAR_1='2016-07-06 00:00:00')\n", "VAR_7 = FUNC_0(VAR_1='2016-07-07 23:59:59')\n", "VAR_8 = FUNC_0(VAR_1='2016-07-08 00:00:01')\n", "VAR_3 = DatabaseQuery('Event').execute(filters={'starts_on': ['between',\n None]}, fields=['name'])\n", "self.assertTrue({'name': VAR_5.name} not in VAR_3)\n", "VAR_3 = DatabaseQuery('Event').execute(filters={'starts_on': ['between', [\n '2016-07-06', '2016-07-07']]}, fields=['name'])\n", "self.assertTrue({'name': VAR_6.name} in VAR_3)\n", "self.assertTrue({'name': VAR_7.name} in VAR_3)\n", "self.assertTrue({'name': VAR_5.name} not in VAR_3)\n", "self.assertTrue({'name': VAR_8.name} not in VAR_3)\n", "VAR_3 = DatabaseQuery('Event').execute(filters={'starts_on': ['between', [\n '2016-07-07']]}, fields=['name'])\n", "self.assertTrue({'name': VAR_7.name} in VAR_3)\n", "self.assertTrue({'name': VAR_8.name} in VAR_3)\n", "self.assertTrue({'name': VAR_4.name} in VAR_3)\n", "self.assertTrue({'name': VAR_5.name} not in VAR_3)\n", "self.assertTrue({'name': VAR_6.name} not in VAR_3)\n" ]
[ "def test_between_filters(self):...\n", "\"\"\"docstring\"\"\"\n", "frappe.db.sql('delete from tabEvent')\n", "todays_event = create_event()\n", "event1 = create_event(starts_on='2016-07-05 23:59:59')\n", "event2 = create_event(starts_on='2016-07-06 00:00:00')\n", "event3 = create_event(starts_on='2016-07-07 23:59:59')\n", "event4 = create_event(starts_on='2016-07-08 00:00:01')\n", "data = DatabaseQuery('Event').execute(filters={'starts_on': ['between',\n None]}, fields=['name'])\n", "self.assertTrue({'name': event1.name} not in data)\n", "data = DatabaseQuery('Event').execute(filters={'starts_on': ['between', [\n '2016-07-06', '2016-07-07']]}, fields=['name'])\n", "self.assertTrue({'name': event2.name} in data)\n", "self.assertTrue({'name': event3.name} in data)\n", "self.assertTrue({'name': event1.name} not in data)\n", "self.assertTrue({'name': event4.name} not in data)\n", "data = DatabaseQuery('Event').execute(filters={'starts_on': ['between', [\n '2016-07-07']]}, fields=['name'])\n", "self.assertTrue({'name': event3.name} in data)\n", "self.assertTrue({'name': event4.name} in data)\n", "self.assertTrue({'name': todays_event.name} in data)\n", "self.assertTrue({'name': event1.name} not in data)\n", "self.assertTrue({'name': event2.name} not in data)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "@functools.lru_cache(None)...\n", "\"\"\"docstring\"\"\"\n", "return self._get_model_field(CustomerResponse, VAR_7)\n" ]
[ "@functools.lru_cache(None)...\n", "\"\"\"docstring\"\"\"\n", "return self._get_model_field(CustomerResponse, name)\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def FUNC_10(self, VAR_10, VAR_12):...\n", "\"\"\"docstring\"\"\"\n", "self._create_server(VAR_12)\n", "VAR_5 = {}\n", "VAR_5['volumeName'] = VAR_10['name']\n", "VAR_5['serverName'] = VAR_12['host']\n", "self._cliq_run_xml('assignVolumeToServer', VAR_5)\n", "VAR_32 = self._get_iscsi_properties(VAR_10)\n", "return {'driver_volume_type': 'iscsi', 'data': VAR_32}\n" ]
[ "def initialize_connection(self, volume, connector):...\n", "\"\"\"docstring\"\"\"\n", "self._create_server(connector)\n", "cliq_args = {}\n", "cliq_args['volumeName'] = volume['name']\n", "cliq_args['serverName'] = connector['host']\n", "self._cliq_run_xml('assignVolumeToServer', cliq_args)\n", "iscsi_properties = self._get_iscsi_properties(volume)\n", "return {'driver_volume_type': 'iscsi', 'data': iscsi_properties}\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Return'" ]
[ "@FUNC_7...\n", "\"\"\"docstring\"\"\"\n", "if not current_user.is_authenticated():\n", "return current_app.login_manager.unauthorized()\n", "VAR_20 = RemoteAccount.get(user_id=current_user.get_id(), client_id=remote.\n consumer_key)\n", "if VAR_20:\n", "VAR_20.delete()\n", "return redirect(url_for('oauthclient_settings.index'))\n" ]
[ "@oauth_error_handler...\n", "\"\"\"docstring\"\"\"\n", "if not current_user.is_authenticated():\n", "return current_app.login_manager.unauthorized()\n", "account = RemoteAccount.get(user_id=current_user.get_id(), client_id=remote\n .consumer_key)\n", "if account:\n", "account.delete()\n", "return redirect(url_for('oauthclient_settings.index'))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Return'", "Assign'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_5(VAR_0):...\n", "VAR_11 = VAR_0.GET.get('first_name', '')\n", "VAR_12 = Student.objects.raw(\n \"select * from sio_student where first_name = '\" + VAR_11 + \"'\")\n", "VAR_13 = serializers.serialize('json', VAR_12)\n", "return HttpResponse(VAR_13, content_type='application/json')\n" ]
[ "def get_student_by_name(request):...\n", "first_name = request.GET.get('first_name', '')\n", "students = Student.objects.raw(\n \"select * from sio_student where first_name = '\" + first_name + \"'\")\n", "response_text = serializers.serialize('json', students)\n", "return HttpResponse(response_text, content_type='application/json')\n" ]
[ 0, 0, 4, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "\"\"\"\n1-filter_states.py\n\"\"\"\n", "import MySQLdb\n", "import sys\n", "def FUNC_0():...\n", "\"\"\"docstring\"\"\"\n", "VAR_0 = MySQLdb.connect(host='localhost', port=3306, user=sys.argv[1],\n passwd=sys.argv[2], VAR_0=sys.argv[3])\n", "return VAR_0\n" ]
[ "\"\"\"\n1-filter_states.py\n\"\"\"\n", "import MySQLdb\n", "import sys\n", "def init_db():...\n", "\"\"\"docstring\"\"\"\n", "db = MySQLdb.connect(host='localhost', port=3306, user=sys.argv[1], passwd=\n sys.argv[2], db=sys.argv[3])\n", "return db\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "Import'", "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_10(self):...\n", "self.assertFalse(self.course_module.is_open(self.yesterday))\n", "self.assertTrue(self.course_module.is_open(self.today))\n", "self.assertTrue(self.course_module.is_open())\n", "self.assertTrue(self.course_module.is_open(self.tomorrow))\n", "self.assertFalse(self.course_module.is_open(self.two_days_from_now))\n" ]
[ "def test_course_module_open(self):...\n", "self.assertFalse(self.course_module.is_open(self.yesterday))\n", "self.assertTrue(self.course_module.is_open(self.today))\n", "self.assertTrue(self.course_module.is_open())\n", "self.assertTrue(self.course_module.is_open(self.tomorrow))\n", "self.assertFalse(self.course_module.is_open(self.two_days_from_now))\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def __init__(self):...\n", "self._time = 0.0\n" ]
[ "def __init__(self):...\n", "self._time = 0.0\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "def FUNC_18(*VAR_20, **VAR_11):...\n", "\"\"\"docstring\"\"\"\n", "VAR_32 = VAR_20[0]\n", "if len(VAR_20) == 1:\n", "VAR_53 = product\n", "if len(VAR_20) == 2:\n", "if isinstance(VAR_32, str):\n", "VAR_53 = VAR_20[1]\n", "VAR_32 = [VAR_32]\n", "def FUNC_36(VAR_11):...\n", "for VAR_51, VAR_58 in VAR_11.items():\n", "if isinstance(VAR_58, str) or not isinstance(VAR_58, Iterable):\n", "return [VAR_10.format(**comb) for comb in map(dict, VAR_53(*FUNC_36(VAR_11)\n )) for VAR_10 in VAR_32]\n", "VAR_58 = [VAR_58]\n", "yield [(VAR_51, VAR_16) for VAR_16 in VAR_58]\n" ]
[ "def expand(*args, **wildcards):...\n", "\"\"\"docstring\"\"\"\n", "filepatterns = args[0]\n", "if len(args) == 1:\n", "combinator = product\n", "if len(args) == 2:\n", "if isinstance(filepatterns, str):\n", "combinator = args[1]\n", "filepatterns = [filepatterns]\n", "def flatten(wildcards):...\n", "for wildcard, values in wildcards.items():\n", "if isinstance(values, str) or not isinstance(values, Iterable):\n", "return [filepattern.format(**comb) for comb in map(dict, combinator(*\n flatten(wildcards))) for filepattern in filepatterns]\n", "values = [values]\n", "yield [(wildcard, value) for value in values]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "FunctionDef'", "For", "Condition", "Return'", "Assign'", "Expr'" ]
[ "def FUNC_1(VAR_1, VAR_6):...\n", "" ]
[ "def directory_index(path, fullpath):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_0(self):...\n", "if not GenericRequest.test_success(self):\n", "return False\n", "return self.get_user_test_id() is not None\n" ]
[ "def test_success(self):...\n", "if not GenericRequest.test_success(self):\n", "return False\n", "return self.get_user_test_id() is not None\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_7(self, VAR_12):...\n", "self.cursor.execute('SELECT * FROM brand WHERE id = %s;', (VAR_12,))\n", "return self.cursor.fetchall()\n" ]
[ "def find_brand_by_id(self, brand_id):...\n", "self.cursor.execute('SELECT * FROM brand WHERE id = %s;', (brand_id,))\n", "return self.cursor.fetchall()\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Return'" ]
[ "\"\"\"This module contains the device class and context manager\"\"\"\n", "import numpy as np\n", "from scipy.linalg import expm, eigh\n", "import openqml as qm\n", "from openqml import Device, DeviceError, qfunc, QNode, Variable, __version__\n", "VAR_0 = 1e-10\n", "def FUNC_0(VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "VAR_19, VAR_20 = eigh(VAR_1)\n", "VAR_21 = []\n", "for k in range(2):\n", "VAR_35 = VAR_20[:, (k)]\n", "return VAR_19, VAR_21\n", "VAR_21.append(np.outer(VAR_35.conj(), VAR_35))\n" ]
[ "\"\"\"This module contains the device class and context manager\"\"\"\n", "import numpy as np\n", "from scipy.linalg import expm, eigh\n", "import openqml as qm\n", "from openqml import Device, DeviceError, qfunc, QNode, Variable, __version__\n", "tolerance = 1e-10\n", "def spectral_decomposition_qubit(A):...\n", "\"\"\"docstring\"\"\"\n", "d, v = eigh(A)\n", "P = []\n", "for k in range(2):\n", "temp = v[:, (k)]\n", "return d, P\n", "P.append(np.outer(temp.conj(), temp))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "ImportFrom'", "Import'", "ImportFrom'", "Assign'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "For", "Assign'", "Return'", "Expr'" ]
[ "def FUNC_6():...\n", "\"\"\"docstring\"\"\"\n", "return FUNC_2('select count(*) from Player')\n" ]
[ "def countPlayers():...\n", "\"\"\"docstring\"\"\"\n", "return fetchone('select count(*) from Player')\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "@staticmethod...\n", "if not VAR_1 or not VAR_7 or not VAR_6:\n", "if not VAR_5:\n", "VAR_5 = CLASS_0.get_report(VAR_1)['analysis']\n", "VAR_16 = VAR_5['behavior']['generic']\n", "VAR_17 = [z for z in VAR_16 if z['pid'] == VAR_6]\n", "if not VAR_17:\n", "VAR_17 = VAR_17[0]\n", "VAR_18 = VAR_17['summary']\n", "if VAR_7 not in VAR_18:\n", "if VAR_3:\n", "VAR_18[VAR_7] = VAR_18[VAR_7][VAR_3:]\n", "if VAR_2:\n", "VAR_18[VAR_7] = VAR_18[VAR_7][:VAR_2]\n", "return VAR_18[VAR_7]\n" ]
[ "@staticmethod...\n", "if not task_id or not watcher or not pid:\n", "if not report:\n", "report = AnalysisController.get_report(task_id)['analysis']\n", "behavior_generic = report['behavior']['generic']\n", "process = [z for z in behavior_generic if z['pid'] == pid]\n", "if not process:\n", "process = process[0]\n", "summary = process['summary']\n", "if watcher not in summary:\n", "if offset:\n", "summary[watcher] = summary[watcher][offset:]\n", "if limit:\n", "summary[watcher] = summary[watcher][:limit]\n", "return summary[watcher]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Return'" ]
[ "def FUNC_7(VAR_3, VAR_9):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_9 == 'login':\n", "return external_auth_login(VAR_3)\n", "if VAR_9 == 'register':\n", "return external_auth_register(VAR_3)\n" ]
[ "def _external_auth_intercept(request, mode):...\n", "\"\"\"docstring\"\"\"\n", "if mode == 'login':\n", "return external_auth_login(request)\n", "if mode == 'register':\n", "return external_auth_register(request)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "Return'" ]
[ "@classmethod...\n", "return change_log.is_changle_log_indexed()\n" ]
[ "@classmethod...\n", "return change_log.is_changle_log_indexed()\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_8(VAR_9, VAR_10=False):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_9 is None and VAR_10:\n", "return ''\n", "if not isinstance(VAR_9, bytes):\n", "if sys.version_info >= (3, 0):\n", "return VAR_9.decode('ascii')\n", "return VAR_9\n" ]
[ "def decode(byte_str, allow_none=False):...\n", "\"\"\"docstring\"\"\"\n", "if byte_str is None and allow_none:\n", "return ''\n", "if not isinstance(byte_str, bytes):\n", "if sys.version_info >= (3, 0):\n", "return byte_str.decode('ascii')\n", "return byte_str\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "Condition", "Return'", "Return'" ]
[ "@VAR_1.route('/openFile')...\n", "if not 'email' in VAR_18 and not 'social' in VAR_18:\n", "if 'diagram' in request.args:\n", "VAR_9 = []\n", "return redirect('/login?return_url=openFile&diagram=true')\n", "return redirect('/login?return_url=openFile')\n", "if 'email' in VAR_18:\n", "VAR_12 = VAR_18['email']\n", "if 'social' in VAR_18:\n", "VAR_10 = os.path.join(VAR_1.config['UPLOAD_FOLDER'], VAR_12)\n", "VAR_12 = VAR_18['social']\n", "VAR_9 = os.listdir(VAR_10)\n", "os.makedirs(VAR_10, exist_ok=True)\n", "return render_template('openFile.html', VAR_9=files)\n" ]
[ "@app.route('/openFile')...\n", "if not 'email' in session and not 'social' in session:\n", "if 'diagram' in request.args:\n", "files = []\n", "return redirect('/login?return_url=openFile&diagram=true')\n", "return redirect('/login?return_url=openFile')\n", "if 'email' in session:\n", "email = session['email']\n", "if 'social' in session:\n", "userpath = os.path.join(app.config['UPLOAD_FOLDER'], email)\n", "email = session['social']\n", "files = os.listdir(userpath)\n", "os.makedirs(userpath, exist_ok=True)\n", "return render_template('openFile.html', files=files)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Condition", "Assign'", "Return'", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def __init__(self, VAR_16):...\n", "self.flags = dict()\n" ]
[ "def __init__(self, value):...\n", "self.flags = dict()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "def FUNC_7(VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "VAR_20 = kijiji_api.KijijiApi()\n", "VAR_20.delete_ad_using_title(VAR_2)\n" ]
[ "def delete_ad_using_title(name):...\n", "\"\"\"docstring\"\"\"\n", "api = kijiji_api.KijijiApi()\n", "api.delete_ad_using_title(name)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "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", "from django.conf import settings\n", "from django.test import TransactionTestCase\n", "from scheduler import chaos\n", "\"\"\"Tests creation of containers on nodes\"\"\"\n", "VAR_0 = ['tests.json']\n", "def FUNC_0(self):...\n", "self.assertTrue(self.client.login(username='autotest', password='password'))\n", "chaos.CREATE_ERROR_RATE = 0\n", "chaos.DESTROY_ERROR_RATE = 0\n", "chaos.START_ERROR_RATE = 0\n", "chaos.STOP_ERROR_RATE = 0\n", "settings.SCHEDULER_MODULE = 'chaos'\n", "settings.SSH_PRIVATE_KEY = '<some-ssh-private-key>'\n", "def FUNC_1(self):...\n", "settings.SCHEDULER_MODULE = 'mock'\n", "settings.SSH_PRIVATE_KEY = ''\n", "def FUNC_2(self):...\n", "VAR_1 = '/api/apps'\n", "VAR_2 = self.client.post(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 201)\n", "VAR_3 = VAR_2.data['id']\n", "VAR_1 = '/api/apps/{app_id}/builds'.format(**locals())\n", "VAR_4 = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 201)\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 1)\n", "VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_4 = {'web': 0}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 204)\n", "chaos.CREATE_ERROR_RATE = 0.5\n", "VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_4 = {'web': 20}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 503)\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 20)\n", "VAR_5 = set([c['state'] for c in VAR_2.data['results']])\n", "self.assertEqual(VAR_5, set(['error', 'created']))\n", "def FUNC_3(self):...\n", "VAR_1 = '/api/apps'\n", "VAR_2 = self.client.post(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 201)\n", "VAR_3 = VAR_2.data['id']\n", "VAR_1 = '/api/apps/{app_id}/builds'.format(**locals())\n", "VAR_4 = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 201)\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 1)\n", "VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_4 = {'web': 0}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 204)\n", "chaos.START_ERROR_RATE = 0.5\n", "VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_4 = {'web': 20}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 204)\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 20)\n", "VAR_5 = set([c['state'] for c in VAR_2.data['results']])\n", "self.assertEqual(VAR_5, set(['crashed', 'up']))\n", "def FUNC_4(self):...\n", "VAR_1 = '/api/apps'\n", "VAR_2 = self.client.post(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 201)\n", "VAR_3 = VAR_2.data['id']\n", "VAR_1 = '/api/apps/{app_id}/builds'.format(**locals())\n", "VAR_4 = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 201)\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 1)\n", "VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_4 = {'web': 20}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 204)\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 20)\n", "chaos.DESTROY_ERROR_RATE = 0.5\n", "VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_4 = {'web': 0}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 503)\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "VAR_5 = set([c['state'] for c in VAR_2.data['results']])\n", "self.assertEqual(VAR_5, set(['error']))\n", "VAR_6 = 20\n", "for _ in range(100):\n", "VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n", "def FUNC_5(self):...\n", "VAR_4 = {'web': 0}\n", "VAR_1 = '/api/apps'\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "VAR_2 = self.client.post(VAR_1)\n", "if VAR_2.status_code == 204:\n", "self.assertEqual(VAR_2.status_code, 201)\n", "self.assertEquals(VAR_2.status_code, 503)\n", "VAR_3 = VAR_2.data['id']\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_1 = '/api/apps/{app_id}/builds'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "VAR_4 = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "self.assertEqual(VAR_2.status_code, 200)\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "VAR_6 = len(VAR_2.data['results'])\n", "self.assertEqual(VAR_2.status_code, 201)\n", "VAR_1 = '/api/apps/{app_id}/builds'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 2)\n", "VAR_1 = '/api/apps/{app_id}/releases'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 2)\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 1)\n", "VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_4 = {'web': 20}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 204)\n", "chaos.CREATE_ERROR_RATE = 0.5\n", "chaos.START_ERROR_RATE = 0.5\n", "VAR_1 = '/api/apps/{app_id}/builds'.format(**locals())\n", "VAR_4 = {'image': 'autotest/example', 'sha': 'b' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 503)\n", "VAR_1 = '/api/apps/{app_id}/releases'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 2)\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 20)\n", "VAR_5 = set([c['state'] for c in VAR_2.data['results']])\n", "self.assertEqual(VAR_5, set(['up']))\n", "def FUNC_6(self):...\n", "VAR_1 = '/api/apps'\n", "VAR_2 = self.client.post(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 201)\n", "VAR_3 = VAR_2.data['id']\n", "VAR_1 = '/api/apps/{app_id}/builds'.format(**locals())\n", "VAR_4 = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 201)\n", "VAR_1 = '/api/apps/{app_id}/releases'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 2)\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 1)\n", "VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_4 = {'web': 20}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 204)\n", "chaos.CREATE_ERROR_RATE = 0.5\n", "chaos.START_ERROR_RATE = 0.5\n", "VAR_1 = '/api/apps/{app_id}/config'.format(**locals())\n", "VAR_4 = {'values': json.dumps({'NEW_URL1': 'http://localhost:8080/'})}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 503)\n", "VAR_1 = '/api/apps/{app_id}/releases'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 2)\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 20)\n", "VAR_5 = set([c['state'] for c in VAR_2.data['results']])\n", "self.assertEqual(VAR_5, set(['up']))\n", "def FUNC_7(self):...\n", "VAR_1 = '/api/apps'\n", "VAR_2 = self.client.post(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 201)\n", "VAR_3 = VAR_2.data['id']\n", "VAR_1 = '/api/apps/{app_id}/builds'.format(**locals())\n", "VAR_4 = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 201)\n", "VAR_1 = '/api/apps/{app_id}/builds'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 2)\n", "VAR_1 = '/api/apps/{app_id}/releases'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 2)\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 1)\n", "chaos.CREATE_ERROR_RATE = 1\n", "VAR_1 = '/api/apps/{app_id}/run'.format(**locals())\n", "VAR_4 = {'command': 'ls -al'}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 503)\n" ]
[ "\"\"\"\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.conf import settings\n", "from django.test import TransactionTestCase\n", "from scheduler import chaos\n", "\"\"\"Tests creation of containers on nodes\"\"\"\n", "fixtures = ['tests.json']\n", "def setUp(self):...\n", "self.assertTrue(self.client.login(username='autotest', password='password'))\n", "chaos.CREATE_ERROR_RATE = 0\n", "chaos.DESTROY_ERROR_RATE = 0\n", "chaos.START_ERROR_RATE = 0\n", "chaos.STOP_ERROR_RATE = 0\n", "settings.SCHEDULER_MODULE = 'chaos'\n", "settings.SSH_PRIVATE_KEY = '<some-ssh-private-key>'\n", "def tearDown(self):...\n", "settings.SCHEDULER_MODULE = 'mock'\n", "settings.SSH_PRIVATE_KEY = ''\n", "def test_create_chaos(self):...\n", "url = '/api/apps'\n", "response = self.client.post(url)\n", "self.assertEqual(response.status_code, 201)\n", "app_id = response.data['id']\n", "url = '/api/apps/{app_id}/builds'.format(**locals())\n", "body = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 1)\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'web': 0}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\n", "chaos.CREATE_ERROR_RATE = 0.5\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'web': 20}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 503)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 20)\n", "states = set([c['state'] for c in response.data['results']])\n", "self.assertEqual(states, set(['error', 'created']))\n", "def test_start_chaos(self):...\n", "url = '/api/apps'\n", "response = self.client.post(url)\n", "self.assertEqual(response.status_code, 201)\n", "app_id = response.data['id']\n", "url = '/api/apps/{app_id}/builds'.format(**locals())\n", "body = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 1)\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'web': 0}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\n", "chaos.START_ERROR_RATE = 0.5\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'web': 20}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 20)\n", "states = set([c['state'] for c in response.data['results']])\n", "self.assertEqual(states, set(['crashed', 'up']))\n", "def test_destroy_chaos(self):...\n", "url = '/api/apps'\n", "response = self.client.post(url)\n", "self.assertEqual(response.status_code, 201)\n", "app_id = response.data['id']\n", "url = '/api/apps/{app_id}/builds'.format(**locals())\n", "body = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 1)\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'web': 20}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 20)\n", "chaos.DESTROY_ERROR_RATE = 0.5\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'web': 0}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 503)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "states = set([c['state'] for c in response.data['results']])\n", "self.assertEqual(states, set(['error']))\n", "containers = 20\n", "for _ in range(100):\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "def test_build_chaos(self):...\n", "body = {'web': 0}\n", "url = '/api/apps'\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "response = self.client.post(url)\n", "if response.status_code == 204:\n", "self.assertEqual(response.status_code, 201)\n", "self.assertEquals(response.status_code, 503)\n", "app_id = response.data['id']\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "url = '/api/apps/{app_id}/builds'.format(**locals())\n", "response = self.client.get(url)\n", "body = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "self.assertEqual(response.status_code, 200)\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "containers = len(response.data['results'])\n", "self.assertEqual(response.status_code, 201)\n", "url = '/api/apps/{app_id}/builds'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 2)\n", "url = '/api/apps/{app_id}/releases'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 2)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 1)\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'web': 20}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\n", "chaos.CREATE_ERROR_RATE = 0.5\n", "chaos.START_ERROR_RATE = 0.5\n", "url = '/api/apps/{app_id}/builds'.format(**locals())\n", "body = {'image': 'autotest/example', 'sha': 'b' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 503)\n", "url = '/api/apps/{app_id}/releases'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 2)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 20)\n", "states = set([c['state'] for c in response.data['results']])\n", "self.assertEqual(states, set(['up']))\n", "def test_config_chaos(self):...\n", "url = '/api/apps'\n", "response = self.client.post(url)\n", "self.assertEqual(response.status_code, 201)\n", "app_id = response.data['id']\n", "url = '/api/apps/{app_id}/builds'.format(**locals())\n", "body = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "url = '/api/apps/{app_id}/releases'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 2)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 1)\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'web': 20}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\n", "chaos.CREATE_ERROR_RATE = 0.5\n", "chaos.START_ERROR_RATE = 0.5\n", "url = '/api/apps/{app_id}/config'.format(**locals())\n", "body = {'values': json.dumps({'NEW_URL1': 'http://localhost:8080/'})}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 503)\n", "url = '/api/apps/{app_id}/releases'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 2)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 20)\n", "states = set([c['state'] for c in response.data['results']])\n", "self.assertEqual(states, set(['up']))\n", "def test_run_chaos(self):...\n", "url = '/api/apps'\n", "response = self.client.post(url)\n", "self.assertEqual(response.status_code, 201)\n", "app_id = response.data['id']\n", "url = '/api/apps/{app_id}/builds'.format(**locals())\n", "body = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "url = '/api/apps/{app_id}/builds'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 2)\n", "url = '/api/apps/{app_id}/releases'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 2)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 1)\n", "chaos.CREATE_ERROR_RATE = 1\n", "url = '/api/apps/{app_id}/run'.format(**locals())\n", "body = {'command': 'ls -al'}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 503)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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'", "Expr'", "Assign'", "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "For", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "from flask import Flask, render_template, redirect, request\n", "import pg, markdown, time\n", "from time import strftime, localtime\n", "import pg, markdown, time\n", "from wiki_linkify import wiki_linkify\n", "VAR_0 = Flask('WikiApp')\n", "VAR_1 = pg.DB(dbname='wiki_db_redo')\n", "@VAR_0.route('/')...\n", "return render_template('homepage.html')\n" ]
[ "from flask import Flask, render_template, redirect, request\n", "import pg, markdown, time\n", "from time import strftime, localtime\n", "import pg, markdown, time\n", "from wiki_linkify import wiki_linkify\n", "app = Flask('WikiApp')\n", "db = pg.DB(dbname='wiki_db_redo')\n", "@app.route('/')...\n", "return render_template('homepage.html')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Import'", "ImportFrom'", "Import'", "ImportFrom'", "Assign'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_8(VAR_6, VAR_9):...\n", "VAR_7 = VAR_6.headers.get('Cache-Control', '')\n", "VAR_20 = [directive.lower().strip() for directive in VAR_7.split(',')]\n", "return VAR_9 in VAR_20\n" ]
[ "def validate_cache_control_header(page, expected_directive):...\n", "header = page.headers.get('Cache-Control', '')\n", "directives = [directive.lower().strip() for directive in header.split(',')]\n", "return expected_directive in directives\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self._scm\n" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self._scm\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def FUNC_0(self, VAR_20):...\n", "\"\"\"docstring\"\"\"\n", "for VAR_21, directories, filenames in os.walk(VAR_20):\n", "for VAR_32 in filenames:\n", "VAR_72 = os.path.join(VAR_21, VAR_32)\n", "VAR_73 = '/' + os.path.relpath(VAR_72, VAR_20)\n", "VAR_24 = self.getfile(VAR_73, VAR_23=False)\n", "if VAR_24 and VAR_24[VAR_2] == VAR_13:\n", "self.update_realfile(VAR_24, VAR_72)\n" ]
[ "def init_honeyfs(self, honeyfs_path):...\n", "\"\"\"docstring\"\"\"\n", "for path, directories, filenames in os.walk(honeyfs_path):\n", "for filename in filenames:\n", "realfile_path = os.path.join(path, filename)\n", "virtual_path = '/' + os.path.relpath(realfile_path, honeyfs_path)\n", "f = self.getfile(virtual_path, follow_symlinks=False)\n", "if f and f[A_TYPE] == T_FILE:\n", "self.update_realfile(f, realfile_path)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "For", "For", "Assign'", "Assign'", "Assign'", "Condition", "Expr'" ]
[ "def __init__(self, VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6):...\n", "self.vid = VAR_2\n", "self.path = VAR_4\n", "self.code = VAR_3\n", "self.path = VAR_4\n", "self.offset = VAR_5\n", "self.go_env = VAR_6\n", "super(CLASS_0, self).__init__(VAR_0, VAR_1)\n" ]
[ "def __init__(self, callback, uid, vid, code, path, offset, go_env):...\n", "self.vid = vid\n", "self.path = path\n", "self.code = code\n", "self.path = path\n", "self.offset = offset\n", "self.go_env = go_env\n", "super(Gocode, self).__init__(callback, uid)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_0(VAR_0, VAR_1=[], VAR_2=CreateStudentForm(), VAR_3=...\n", "VAR_5 = {'courses': Course.objects.all(), 'messages': VAR_1,\n 'create_student_form': VAR_2, 'create_course_form': VAR_3,\n 'register_student_form': VAR_4}\n", "return render(VAR_0, 'sio.html', VAR_5)\n" ]
[ "def make_view(request, messages=[], create_student_form=CreateStudentForm(),...\n", "context = {'courses': Course.objects.all(), 'messages': messages,\n 'create_student_form': create_student_form, 'create_course_form':\n create_course_form, 'register_student_form': register_student_form}\n", "return render(request, 'sio.html', context)\n" ]
[ 0, 0, 0 ]
[ "Condition", "Assign'", "Return'" ]
[ "def FUNC_39(self, VAR_20):...\n", "for VAR_14 in self.list_properties.keys():\n", "if self.is_relation(VAR_14):\n", "if VAR_20 == self.get_related_model(VAR_14):\n", "return VAR_14\n" ]
[ "def get_related_fk(self, model):...\n", "for col_name in self.list_properties.keys():\n", "if self.is_relation(col_name):\n", "if model == self.get_related_model(col_name):\n", "return col_name\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Condition", "Condition", "Return'" ]
[ "def FUNC_8(VAR_7):...\n", "return render(VAR_7, 'index.html')\n" ]
[ "def index(request):...\n", "return render(request, 'index.html')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_0(VAR_0):...\n", "return open(VAR_0).read().splitlines()\n" ]
[ "def _requires_from_file(filename):...\n", "return open(filename).read().splitlines()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "\"\"\"string\"\"\"\n", "import json\n", "import re\n", "import time\n", "from twisted.web import server, resource\n", "from twisted.internet.task import LoopingCall\n", "from django.utils.functional import Promise\n", "from django.utils.encoding import force_unicode\n", "from django.conf import settings\n", "from evennia.utils.ansi import parse_ansi\n", "from evennia.utils import utils\n", "from evennia.utils.text2html import parse_html\n", "from evennia.server import session\n", "VAR_0 = utils.mod_import(settings.SESSION_ENGINE).SessionStore\n", "VAR_1 = re.compile('%s' % settings.SCREENREADER_REGEX_STRIP, re.DOTALL + re\n .MULTILINE)\n", "VAR_2 = settings.SERVERNAME\n", "VAR_3 = 30\n", "def FUNC_1(self, VAR_4):...\n", "if isinstance(VAR_4, Promise):\n", "return force_unicode(VAR_4)\n", "return super(CLASS_0, self).default(VAR_4)\n" ]
[ "\"\"\"\nAJAX/COMET fallback webclient\n\nThe AJAX/COMET web client consists of two components running on\ntwisted and django. They are both a part of the Evennia website url\ntree (so the testing website might be located on\nhttp://localhost:4001/, whereas the webclient can be found on\nhttp://localhost:4001/webclient.)\n\n/webclient - this url is handled through django's template\n system and serves the html page for the client\n itself along with its javascript chat program.\n/webclientdata - this url is called by the ajax chat using\n POST requests (long-polling when necessary)\n The WebClient resource in this module will\n handle these requests and act as a gateway\n to sessions connected over the webclient.\n\"\"\"\n", "import json\n", "import re\n", "import time\n", "from twisted.web import server, resource\n", "from twisted.internet.task import LoopingCall\n", "from django.utils.functional import Promise\n", "from django.utils.encoding import force_unicode\n", "from django.conf import settings\n", "from evennia.utils.ansi import parse_ansi\n", "from evennia.utils import utils\n", "from evennia.utils.text2html import parse_html\n", "from evennia.server import session\n", "_CLIENT_SESSIONS = utils.mod_import(settings.SESSION_ENGINE).SessionStore\n", "_RE_SCREENREADER_REGEX = re.compile('%s' % settings.\n SCREENREADER_REGEX_STRIP, re.DOTALL + re.MULTILINE)\n", "_SERVERNAME = settings.SERVERNAME\n", "_KEEPALIVE = 30\n", "def default(self, obj):...\n", "if isinstance(obj, Promise):\n", "return force_unicode(obj)\n", "return super(LazyEncoder, self).default(obj)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "from email.mime.multipart import MIMEMultipart\n", "from email.mime.text import MIMEText\n", "import json\n", "import logging\n", "from datetime import datetime\n", "import peewee\n", "import smtplib\n", "import tornado.web\n", "import db\n", "import handlers\n", "import settings\n", "def FUNC_0(VAR_0, VAR_1=None, VAR_2=None):...\n", "if VAR_2 is None:\n", "VAR_2 = VAR_0.dataset\n", "VAR_3 = db.build_dict_from_row(VAR_2)\n", "VAR_3['version'] = db.build_dict_from_row(VAR_0)\n", "VAR_3['version']['available_from'] = VAR_3['version']['available_from'\n ].strftime('%Y-%m-%d')\n", "VAR_3['has_image'] = VAR_2.has_image()\n", "if VAR_1:\n", "VAR_3['is_admin'] = VAR_1.is_admin(VAR_2)\n", "return VAR_3\n", "if VAR_1.has_access(VAR_2):\n", "VAR_3['authorization_level'] = 'has_access'\n", "if VAR_1.has_requested_access(VAR_2):\n", "VAR_3['authorization_level'] = 'has_requested_access'\n", "VAR_3['authorization_level'] = 'no_access'\n" ]
[ "from email.mime.multipart import MIMEMultipart\n", "from email.mime.text import MIMEText\n", "import json\n", "import logging\n", "from datetime import datetime\n", "import peewee\n", "import smtplib\n", "import tornado.web\n", "import db\n", "import handlers\n", "import settings\n", "def build_dataset_structure(dataset_version, user=None, dataset=None):...\n", "if dataset is None:\n", "dataset = dataset_version.dataset\n", "r = db.build_dict_from_row(dataset)\n", "r['version'] = db.build_dict_from_row(dataset_version)\n", "r['version']['available_from'] = r['version']['available_from'].strftime(\n '%Y-%m-%d')\n", "r['has_image'] = dataset.has_image()\n", "if user:\n", "r['is_admin'] = user.is_admin(dataset)\n", "return r\n", "if user.has_access(dataset):\n", "r['authorization_level'] = 'has_access'\n", "if user.has_requested_access(dataset):\n", "r['authorization_level'] = 'has_requested_access'\n", "r['authorization_level'] = 'no_access'\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 ]
[ "ImportFrom'", "ImportFrom'", "Import'", "Import'", "ImportFrom'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "FunctionDef'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_6(self, VAR_59, VAR_60):...\n", "if self.remember:\n", "VAR_96 = '%s_%s' % (VAR_60, self.nav.get_param)\n", "if VAR_59 not in self.nav.options:\n", "VAR_97 = copy(VAR_101.user.sort_options) if VAR_101.user else {}\n", "VAR_59 = self.nav.default\n", "if self.remember and VAR_101.user_is_loggedin and VAR_59 != VAR_98:\n", "VAR_98 = VAR_97.get(VAR_96)\n", "VAR_97[VAR_96] = VAR_59\n", "return VAR_59\n", "if not VAR_59:\n", "VAR_101.user.sort_options = VAR_97\n", "VAR_59 = VAR_98\n", "VAR_82 = VAR_101.user\n", "utils.worker.do(lambda : VAR_82._commit())\n" ]
[ "def run(self, sort, where):...\n", "if self.remember:\n", "pref = '%s_%s' % (where, self.nav.get_param)\n", "if sort not in self.nav.options:\n", "user_prefs = copy(c.user.sort_options) if c.user else {}\n", "sort = self.nav.default\n", "if self.remember and c.user_is_loggedin and sort != user_pref:\n", "user_pref = user_prefs.get(pref)\n", "user_prefs[pref] = sort\n", "return sort\n", "if not sort:\n", "c.user.sort_options = user_prefs\n", "sort = user_pref\n", "user = c.user\n", "utils.worker.do(lambda : user._commit())\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_5(self):...\n", "return shellutil.run('/sbin/chkconfig --add waagent', VAR_8=False)\n" ]
[ "def register_agent_service(self):...\n", "return shellutil.run('/sbin/chkconfig --add waagent', chk_err=False)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@view_config(route_name='note', permission='edit', request_method='POST',...\n", "FUNC_5(VAR_1.note, VAR_0)\n", "return HTTPFound(location=request.route_url('notes'))\n" ]
[ "@view_config(route_name='note', permission='edit', request_method='POST',...\n", "_save_or_create_note(context.note, request)\n", "return HTTPFound(location=request.route_url('notes'))\n" ]
[ 0, 0, 0 ]
[ "Condition", "Expr'", "Return'" ]
[ "def FUNC_9(self):...\n", "self.client.login(username=self.tester.username, password='password')\n", "remove_perm_from_user(self.tester, self.permission)\n", "VAR_4 = {'content_type': 'testplans.testplan', 'object_pk': self.plan.pk,\n 'field': 'is_active', 'value': 'False', 'value_type': 'bool'}\n", "VAR_1 = self.client.post(self.update_url, VAR_4)\n", "self.assertJSONEqual(str(VAR_1.content, encoding=settings.DEFAULT_CHARSET),\n {'rc': 1, 'response': 'Permission Dinied.'})\n" ]
[ "def test_refuse_if_missing_permission(self):...\n", "self.client.login(username=self.tester.username, password='password')\n", "remove_perm_from_user(self.tester, self.permission)\n", "post_data = {'content_type': 'testplans.testplan', 'object_pk': self.plan.\n pk, 'field': 'is_active', 'value': 'False', 'value_type': 'bool'}\n", "response = self.client.post(self.update_url, post_data)\n", "self.assertJSONEqual(str(response.content, encoding=settings.\n DEFAULT_CHARSET), {'rc': 1, 'response': 'Permission Dinied.'})\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'" ]