lines
sequencelengths
1
444
raw_lines
sequencelengths
1
444
label
sequencelengths
1
444
type
sequencelengths
1
444
[ "@data(*VAR_3)...\n", "VAR_12 = get_street_number(VAR_1)\n", "self.assertEqual(VAR_4, VAR_12)\n" ]
[ "@data(*address_test_data)...\n", "output_string = get_street_number(input_string)\n", "self.assertEqual(desired_string1, output_string)\n" ]
[ 0, 0, 0 ]
[ "Condition", "Assign'", "Expr'" ]
[ "def FUNC_1(self):...\n", "\"\"\"docstring\"\"\"\n", "if self.eng is not None:\n", "self.eng = None\n", "self.state = None\n" ]
[ "def reset(self):...\n", "\"\"\"docstring\"\"\"\n", "if self.eng is not None:\n", "self.eng = None\n", "self.state = None\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_1(self, VAR_2):...\n", "VAR_1 = self.current_user\n", "VAR_2 = db.get_dataset(VAR_2)\n", "VAR_15 = db.DatasetVersion.select(db.DatasetVersion.version, db.\n DatasetVersion.available_from).where(db.DatasetVersion.dataset == VAR_2)\n", "logging.info('ListDatasetVersions')\n", "VAR_16 = []\n", "VAR_17 = False\n", "for v in reversed(VAR_15):\n", "VAR_30 = False\n", "self.finish({'data': VAR_16})\n", "VAR_31 = False\n", "if v.available_from > datetime.now():\n", "if not (VAR_1 and VAR_1.is_admin(VAR_2)):\n", "if not VAR_17 and v.available_from < datetime.now():\n", "VAR_31 = True\n", "VAR_17 = True\n", "VAR_16.insert(0, {'name': v.version, 'available_from': v.available_from.\n strftime('%Y-%m-%d'), 'current': VAR_30, 'future': VAR_31})\n", "VAR_30 = True\n" ]
[ "def get(self, dataset):...\n", "user = self.current_user\n", "dataset = db.get_dataset(dataset)\n", "versions = db.DatasetVersion.select(db.DatasetVersion.version, db.\n DatasetVersion.available_from).where(db.DatasetVersion.dataset == dataset)\n", "logging.info('ListDatasetVersions')\n", "data = []\n", "found_current = False\n", "for v in reversed(versions):\n", "current = False\n", "self.finish({'data': data})\n", "future = False\n", "if v.available_from > datetime.now():\n", "if not (user and user.is_admin(dataset)):\n", "if not found_current and v.available_from < datetime.now():\n", "future = True\n", "found_current = True\n", "data.insert(0, {'name': v.version, 'available_from': v.available_from.\n strftime('%Y-%m-%d'), 'current': current, 'future': future})\n", "current = True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "For", "Assign'", "Expr'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Expr'", "Assign'" ]
[ "async def FUNC_2(self) ->None:...\n", "VAR_1 = self.get_body_argument('lexer')\n", "VAR_5 = self.get_body_argument('code')\n", "VAR_6 = self.get_body_argument('expiry')\n", "if not VAR_5:\n", "VAR_0.info('APINew.post: a paste was submitted without content')\n", "if VAR_1 not in utility.list_languages():\n", "VAR_0.info('APINew.post: a paste was submitted with an invalid lexer')\n", "if VAR_6 not in utility.expiries:\n", "VAR_0.info('APINew.post: a paste was submitted with an invalid expiry')\n", "VAR_7 = database.Paste(VAR_5, VAR_1, utility.expiries[VAR_6])\n", "session.add(VAR_7)\n", "session.commit()\n", "self.write({'paste_id': VAR_7.paste_id, 'removal_id': VAR_7.removal_id})\n" ]
[ "async def post(self) ->None:...\n", "lexer = self.get_body_argument('lexer')\n", "raw = self.get_body_argument('code')\n", "expiry = self.get_body_argument('expiry')\n", "if not raw:\n", "log.info('APINew.post: a paste was submitted without content')\n", "if lexer not in utility.list_languages():\n", "log.info('APINew.post: a paste was submitted with an invalid lexer')\n", "if expiry not in utility.expiries:\n", "log.info('APINew.post: a paste was submitted with an invalid expiry')\n", "paste = database.Paste(raw, lexer, utility.expiries[expiry])\n", "session.add(paste)\n", "session.commit()\n", "self.write({'paste_id': paste.paste_id, 'removal_id': paste.removal_id})\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_45(VAR_25, VAR_39):...\n", "if self.parentfield:\n", "return '{} #{}: {}: {}'.format(_('Row'), self.idx, _(VAR_25.label), VAR_39)\n", "return '{}: {}'.format(_(VAR_25.label), VAR_39)\n" ]
[ "def get_msg(df, docname):...\n", "if self.parentfield:\n", "return '{} #{}: {}: {}'.format(_('Row'), self.idx, _(df.label), docname)\n", "return '{}: {}'.format(_(df.label), docname)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "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_6():...\n", "if not request.method in VAR_0:\n", "return True\n", "if not request.environ.get('AUTH_TYPE') == 'cookie':\n", "return True\n", "if config.get('skip_authentication'):\n", "return True\n", "if request.environ.get('HTTP_REFERER'):\n", "VAR_7 = urlparse(request.environ.get('HTTP_REFERER'))\n", "if request.method == 'GET' and FUNC_4():\n", "VAR_8 = VAR_7.hostname\n", "return True\n", "return False\n", "if VAR_7.port:\n", "VAR_8 += ':' + str(VAR_7.port)\n", "if VAR_8.endswith(request.environ['adhocracy.domain']):\n", "if request.method != 'GET':\n", "return True\n" ]
[ "def check():...\n", "if not request.method in methods:\n", "return True\n", "if not request.environ.get('AUTH_TYPE') == 'cookie':\n", "return True\n", "if config.get('skip_authentication'):\n", "return True\n", "if request.environ.get('HTTP_REFERER'):\n", "ref_url = urlparse(request.environ.get('HTTP_REFERER'))\n", "if request.method == 'GET' and has_token():\n", "ref_host = ref_url.hostname\n", "return True\n", "return False\n", "if ref_url.port:\n", "ref_host += ':' + str(ref_url.port)\n", "if ref_host.endswith(request.environ['adhocracy.domain']):\n", "if request.method != 'GET':\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 5, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Return'", "Return'", "Condition", "AugAssign'", "Condition", "Condition", "Return'" ]
[ "@VAR_0.route('/search', methods=['POST'])...\n", "VAR_10 = request.form.get('search')\n", "return redirect('/%s' % VAR_10)\n" ]
[ "@app.route('/search', methods=['POST'])...\n", "search = request.form.get('search')\n", "return redirect('/%s' % search)\n" ]
[ 0, 0, 4 ]
[ "Condition", "Assign'", "Return'" ]
[ "def FUNC_11(VAR_34):...\n", "if VAR_34.startswith('!'):\n", "return VAR_34[1:]\n", "return VAR_34.format(VAR_11=url, VAR_36=dest.name)\n" ]
[ "def formatCommand(e):...\n", "if e.startswith('!'):\n", "return e[1:]\n", "return e.format(url=url, dest=dest.name)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def __init__(self, VAR_1, VAR_5, VAR_4=None):...\n", "GenericRequest.__init__(self, VAR_1, VAR_4)\n", "self.url = '%stasks/%s/description' % (self.base_url, VAR_5)\n", "self.task_id = VAR_5\n" ]
[ "def __init__(self, browser, task_id, base_url=None):...\n", "GenericRequest.__init__(self, browser, base_url)\n", "self.url = '%stasks/%s/description' % (self.base_url, task_id)\n", "self.task_id = task_id\n" ]
[ 0, 0, 5, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'" ]
[ "def FUNC_2(VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "if not FUNC_1(VAR_1):\n", "VAR_1.run_command('move_to', {'to': 'eof'})\n", "VAR_1.run_command('insert_snippet', {'contents': '\\n\\n' + VAR_4()})\n", "VAR_1.run_command('move_to', {'to': 'bof'})\n" ]
[ "def add_separator(view):...\n", "\"\"\"docstring\"\"\"\n", "if not has_meta(view):\n", "view.run_command('move_to', {'to': 'eof'})\n", "view.run_command('insert_snippet', {'contents': '\\n\\n' + meta_separator()})\n", "view.run_command('move_to', {'to': 'bof'})\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_2(self, *VAR_4, **VAR_5):...\n", "return self.manage_menu(VAR_4, VAR_5)\n" ]
[ "def zmi_manage_menu(self, *args, **kwargs):...\n", "return self.manage_menu(args, kwargs)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "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 FUNC_9(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_21 = self.agent.type_to_payload(\n 'registerInstancesWithGoogleLoadBalancerDescription', {\n 'loadBalancerNames': [self.__use_lb_name], 'instanceIds': self.\n use_instance_names[:2], 'region': self.bindings['TEST_GCE_REGION'],\n 'credentials': self.bindings['GCE_CREDENTIALS']})\n", "VAR_20 = gcp.GceContractBuilder(self.gce_observer)\n", "VAR_20.new_clause_builder('Instances in Target Pool', retryable_for_secs=15\n ).list_resources('target-pools').contains_pred_list([jc.\n PathContainsPredicate('name', self.__use_lb_tp_name), jc.\n PathEqPredicate('region', self.bindings['TEST_GCE_REGION']), jc.\n PathElementsContainPredicate('instances', self.use_instance_names[0]),\n jc.PathElementsContainPredicate('instances', self.use_instance_names[1])]\n ).excludes_pred_list([jc.PathContainsPredicate('name', self.\n __use_lb_tp_name), jc.PathElementsContainPredicate('instances', self.\n use_instance_names[2])])\n", "return st.OperationContract(self.new_post_operation(title=\n 'register_load_balancer_instances', data=payload, VAR_29='ops'),\n contract=builder.build())\n" ]
[ "def register_load_balancer_instances(self):...\n", "\"\"\"docstring\"\"\"\n", "payload = self.agent.type_to_payload(\n 'registerInstancesWithGoogleLoadBalancerDescription', {\n 'loadBalancerNames': [self.__use_lb_name], 'instanceIds': self.\n use_instance_names[:2], 'region': self.bindings['TEST_GCE_REGION'],\n 'credentials': self.bindings['GCE_CREDENTIALS']})\n", "builder = gcp.GceContractBuilder(self.gce_observer)\n", "builder.new_clause_builder('Instances in Target Pool', retryable_for_secs=15\n ).list_resources('target-pools').contains_pred_list([jc.\n PathContainsPredicate('name', self.__use_lb_tp_name), jc.\n PathEqPredicate('region', self.bindings['TEST_GCE_REGION']), jc.\n PathElementsContainPredicate('instances', self.use_instance_names[0]),\n jc.PathElementsContainPredicate('instances', self.use_instance_names[1])]\n ).excludes_pred_list([jc.PathContainsPredicate('name', self.\n __use_lb_tp_name), jc.PathElementsContainPredicate('instances', self.\n use_instance_names[2])])\n", "return st.OperationContract(self.new_post_operation(title=\n 'register_load_balancer_instances', data=payload, path='ops'), contract\n =builder.build())\n" ]
[ 0, 0, 0, 0, 1, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def __repr__(self):...\n", "return self.get_name()\n" ]
[ "def __repr__(self):...\n", "return self.get_name()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_1(self):...\n", "VAR_2 = self.get_user()\n", "if VAR_2:\n", "VAR_5 = VAR_2.user_id\n", "VAR_5 = None\n", "return VAR_5\n" ]
[ "def get_user_id(self):...\n", "user = self.get_user()\n", "if user:\n", "user_id = user.user_id\n", "user_id = None\n", "return user_id\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Assign'", "Return'" ]
[ "@utils.synchronized('3par', external=True)...\n", "\"\"\"docstring\"\"\"\n", "self.common.client_login()\n", "VAR_20 = self._create_host(VAR_6, VAR_9)\n", "VAR_21 = self.common.create_vlun(VAR_6, VAR_20)\n", "VAR_22 = self.common.get_ports()\n", "self.common.client_logout()\n", "VAR_23 = {'driver_volume_type': 'fibre_channel', 'data': {'target_lun':\n VAR_21['lun'], 'target_discovered': True, 'target_wwn': VAR_22['FC']}}\n", "return VAR_23\n" ]
[ "@utils.synchronized('3par', external=True)...\n", "\"\"\"docstring\"\"\"\n", "self.common.client_login()\n", "host = self._create_host(volume, connector)\n", "vlun = self.common.create_vlun(volume, host)\n", "ports = self.common.get_ports()\n", "self.common.client_logout()\n", "info = {'driver_volume_type': 'fibre_channel', 'data': {'target_lun': vlun[\n 'lun'], 'target_discovered': True, 'target_wwn': ports['FC']}}\n", "return info\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_7(self):...\n", "return self.content\n" ]
[ "def read(self):...\n", "return self.content\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@api_post...\n", "VAR_7 = VAR_3.pop('submit_id', None)\n", "VAR_0.submit(VAR_7=submit_id, config=body)\n", "return JsonResponse({'status': True, 'submit_id': VAR_7}, encoder=JsonSerialize\n )\n" ]
[ "@api_post...\n", "submit_id = body.pop('submit_id', None)\n", "submit_manager.submit(submit_id=submit_id, config=body)\n", "return JsonResponse({'status': True, 'submit_id': submit_id}, encoder=\n JsonSerialize)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_15(self):...\n", "self.run_test_case(self.scenario.enable_server_group())\n" ]
[ "def test_f_enable_server_group(self):...\n", "self.run_test_case(self.scenario.enable_server_group())\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "@defer.inlineCallbacks...\n", "if self._mode.is_single_user:\n", "VAR_61 = CLASS_0(VAR_19, self._tmp_dir.name)\n", "yield VAR_61.start()\n", "self.accounts[VAR_19] = VAR_61\n" ]
[ "@defer.inlineCallbacks...\n", "if self._mode.is_single_user:\n", "account = AppTestAccount(account_name, self._tmp_dir.name)\n", "yield account.start()\n", "self.accounts[account_name] = account\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_3(self, VAR_9):...\n", "for VAR_10 in VAR_9:\n", "self.analyze_scene(VAR_10)\n" ]
[ "def analyze_scenes(self, chunk):...\n", "for scene in chunk:\n", "self.analyze_scene(scene)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "For", "Expr'" ]
[ "def FUNC_4(self, VAR_7):...\n", "\"\"\"docstring\"\"\"\n", "VAR_12 = VAR_7.get('lang', 'en')\n", "if VAR_12 == 'cn':\n", "VAR_18 = 'https://www.zhihu.com/api/v3/oauth/captcha?lang=cn'\n", "VAR_18 = 'https://www.zhihu.com/api/v3/oauth/captcha?lang=en'\n", "VAR_10 = self.session.get(VAR_18, VAR_7=headers)\n", "VAR_13 = re.search('true', VAR_10.text)\n", "if VAR_13:\n", "VAR_19 = self.session.put(VAR_18, VAR_7=headers)\n", "return ''\n", "VAR_20 = re.findall('\"img_base64\":\"(.+)\"', VAR_19.text, re.S)[0].replace('\\\\n',\n '')\n", "f.write(base64.b64decode(VAR_20))\n", "VAR_21 = Image.open('./captcha.jpg')\n", "if VAR_12 == 'cn':\n", "plt.imshow(VAR_21)\n", "VAR_21.show()\n", "print('点击所有倒立的汉字,按回车提交')\n", "VAR_23 = input('请输入图片里的验证码:')\n", "VAR_22 = plt.ginput(7)\n", "self.session.post(VAR_18, data={'input_text': capt}, VAR_7=headers)\n", "VAR_23 = json.dumps({'img_size': [200, 44], 'input_points': [[i[0] / 2, i[1\n ] / 2] for i in VAR_22]})\n", "return VAR_23\n" ]
[ "def _get_captcha(self, headers):...\n", "\"\"\"docstring\"\"\"\n", "lang = headers.get('lang', 'en')\n", "if lang == 'cn':\n", "api = 'https://www.zhihu.com/api/v3/oauth/captcha?lang=cn'\n", "api = 'https://www.zhihu.com/api/v3/oauth/captcha?lang=en'\n", "resp = self.session.get(api, headers=headers)\n", "show_captcha = re.search('true', resp.text)\n", "if show_captcha:\n", "put_resp = self.session.put(api, headers=headers)\n", "return ''\n", "img_base64 = re.findall('\"img_base64\":\"(.+)\"', put_resp.text, re.S)[0].replace(\n '\\\\n', '')\n", "f.write(base64.b64decode(img_base64))\n", "img = Image.open('./captcha.jpg')\n", "if lang == 'cn':\n", "plt.imshow(img)\n", "img.show()\n", "print('点击所有倒立的汉字,按回车提交')\n", "capt = input('请输入图片里的验证码:')\n", "points = plt.ginput(7)\n", "self.session.post(api, data={'input_text': capt}, headers=headers)\n", "capt = json.dumps({'img_size': [200, 44], 'input_points': [[i[0] / 2, i[1] /\n 2] for i in points]})\n", "return capt\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Return'" ]
[ "def __init__(self, VAR_1, VAR_2, VAR_3, VAR_4=None):...\n", "self.logger = VAR_4 or logging.getLogger('ContentInstaller')\n", "VAR_12, VAR_13, VAR_14 = self._sanity_check_path(VAR_1, VAR_2, VAR_3)\n", "self.src_path = VAR_12\n", "self.dst_path = VAR_13\n", "self.www_root = VAR_14\n" ]
[ "def __init__(self, src_path, dst_path, www_root, logger=None):...\n", "self.logger = logger or logging.getLogger('ContentInstaller')\n", "_src, _dst, _www = self._sanity_check_path(src_path, dst_path, www_root)\n", "self.src_path = _src\n", "self.dst_path = _dst\n", "self.www_root = _www\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_14(self, VAR_11, VAR_12):...\n", "self.common._cli_run('createhost -iscsi -add %s %s' % (VAR_11, VAR_12), None)\n" ]
[ "def _modify_3par_iscsi_host(self, hostname, iscsi_iqn):...\n", "self.common._cli_run('createhost -iscsi -add %s %s' % (hostname, iscsi_iqn),\n None)\n" ]
[ 0, 2 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_1(self):...\n", "self.assertTrue({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n limit_page_length=None))\n" ]
[ "def test_basic(self):...\n", "self.assertTrue({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n limit_page_length=None))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_0(self):...\n", "self.assertTrue(self.client.login(username='autotest', password='password'))\n" ]
[ "def setUp(self):...\n", "self.assertTrue(self.client.login(username='autotest', password='password'))\n" ]
[ 0, 5 ]
[ "FunctionDef'", "Expr'" ]
[ "def __iter__(self):...\n", "return iter(self._flattened)\n" ]
[ "def __iter__(self):...\n", "return iter(self._flattened)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_8(self, VAR_2, VAR_3, VAR_4, VAR_7={}):...\n", "self.write(VAR_2, VAR_3, VAR_4, {'state': 'pending'}, VAR_7=context)\n", "return True\n" ]
[ "def set_pending(self, cr, uid, ids, context={}):...\n", "self.write(cr, uid, ids, {'state': 'pending'}, context=context)\n", "return True\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Return'" ]
[ "from django.utils import timezone\n", "from django.db.models import Avg, Count, Min, Max, Sum\n", "def FUNC_0(VAR_0):...\n", "from pages.models import Post\n", "VAR_1 = Post.objects.filter(published_date__lte=timezone.now())\n", "VAR_2 = Post.objects.values('subject').annotate(newest_published_date=Max(\n 'published_date'))\n", "VAR_3 = Post.objects.filter(subject__in=[b.get('subject') for b in pb],\n published_date__in=[b.get('newest_published_date') for b in pb])\n", "return {'navbarMain': VAR_3}\n" ]
[ "from django.utils import timezone\n", "from django.db.models import Avg, Count, Min, Max, Sum\n", "def navbarmain(request):...\n", "from pages.models import Post\n", "navbarMain = Post.objects.filter(published_date__lte=timezone.now())\n", "pb = Post.objects.values('subject').annotate(newest_published_date=Max(\n 'published_date'))\n", "pb_list = Post.objects.filter(subject__in=[b.get('subject') for b in pb],\n published_date__in=[b.get('newest_published_date') for b in pb])\n", "return {'navbarMain': pb_list}\n" ]
[ 0, 0, 0, 0, 4, 4, 4, 4 ]
[ "ImportFrom'", "ImportFrom'", "FunctionDef'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_2(VAR_0, VAR_6=None):...\n", "VAR_0 = VAR_0.groupby('matched_id').matched_id.count().as_matrix()\n", "VAR_0 = VAR_0.astype(int)\n", "VAR_26 = list(VAR_0).count(1)\n", "VAR_27 = np.delete(VAR_0, np.argwhere(VAR_0 == 1))\n", "if VAR_26 == len(VAR_0):\n", "VAR_30 = pd.DataFrame({'contacts': [VAR_26]}, VAR_29=['1 contact'])\n", "if VAR_6 is not None:\n", "logger.info('all ones!')\n", "VAR_51, VAR_7 = np.histogram(VAR_27, VAR_6)\n", "VAR_51, VAR_7 = np.histogram(VAR_27, 'auto')\n", "return VAR_30, 1\n", "VAR_28 = [VAR_26] + list(VAR_51)\n", "if len(VAR_7) > 4:\n", "VAR_29 = [pd.Interval(1, 2, 'left')] + [pd.Interval(int(b[0]), int(b[1]) + \n 1, 'left') for b in list(FUNC_1(list(VAR_7), 2))]\n", "VAR_6 = 4\n", "VAR_30 = pd.DataFrame({'contacts': VAR_28}, VAR_29=\n contacts_interval_to_text(index))\n", "VAR_51, VAR_7 = np.histogram(VAR_27, VAR_6)\n", "logger.info(VAR_51)\n", "logger.info(VAR_7)\n", "logger.info(VAR_29)\n", "logger.info(VAR_30)\n", "return VAR_30, VAR_7\n" ]
[ "def get_contact_dist(data, bins=None):...\n", "data = data.groupby('matched_id').matched_id.count().as_matrix()\n", "data = data.astype(int)\n", "one_contact = list(data).count(1)\n", "rest = np.delete(data, np.argwhere(data == 1))\n", "if one_contact == len(data):\n", "df_hist = pd.DataFrame({'contacts': [one_contact]}, index=['1 contact'])\n", "if bins is not None:\n", "logger.info('all ones!')\n", "num, groups = np.histogram(rest, bins)\n", "num, groups = np.histogram(rest, 'auto')\n", "return df_hist, 1\n", "hist = [one_contact] + list(num)\n", "if len(groups) > 4:\n", "index = [pd.Interval(1, 2, 'left')] + [pd.Interval(int(b[0]), int(b[1]) + 1,\n 'left') for b in list(window(list(groups), 2))]\n", "bins = 4\n", "df_hist = pd.DataFrame({'contacts': hist}, index=contacts_interval_to_text(\n index))\n", "num, groups = np.histogram(rest, bins)\n", "logger.info(num)\n", "logger.info(groups)\n", "logger.info(index)\n", "logger.info(df_hist)\n", "return df_hist, groups\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Return'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "def __init__(self, VAR_5, VAR_3):...\n", "self.smart_list = VAR_5\n", "self.object = VAR_3\n" ]
[ "def __init__(self, smart_list, object):...\n", "self.smart_list = smart_list\n", "self.object = object\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'" ]
[ "def FUNC_3(VAR_10=None, VAR_4=None):...\n", "\"\"\"docstring\"\"\"\n", "VAR_10 = VAR_10 or []\n", "VAR_4 = VAR_4 or []\n", "VAR_13 = hashlib.md5(str(time.time())).hexdigest()\n", "VAR_14 = []\n", "for VAR_18, VAR_9 in VAR_10:\n", "VAR_18 = FUNC_2(VAR_18)\n", "for VAR_18, VAR_19, VAR_9 in VAR_4:\n", "VAR_9 = FUNC_2(VAR_9)\n", "VAR_18 = FUNC_2(VAR_18)\n", "if len(VAR_14) > 1:\n", "VAR_14.append('--' + VAR_13)\n", "VAR_19 = FUNC_2(VAR_19)\n", "VAR_14[-2] += '--'\n", "VAR_15 = '\\r\\n'.join(VAR_14)\n", "VAR_14.append('Content-Disposition: form-data; name=\"%s\"' % VAR_18)\n", "VAR_9 = FUNC_2(VAR_9)\n", "VAR_16 = 'multipart/form-data; boundary=%s' % VAR_13\n", "VAR_14.append('')\n", "VAR_14.append('--' + VAR_13)\n", "return VAR_16, VAR_15\n", "VAR_14.append(VAR_9)\n", "VAR_14.append('Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"' %\n (VAR_18, VAR_19))\n", "VAR_14.append('--' + VAR_13)\n", "VAR_14.append('Content-Type: application/octet-stream')\n", "VAR_14.append('')\n", "VAR_14.append('')\n", "VAR_14.append(VAR_9)\n", "VAR_14.append('--' + VAR_13)\n", "VAR_14.append('')\n" ]
[ "def EncodeMultipartFormData(fields=None, files=None):...\n", "\"\"\"docstring\"\"\"\n", "fields = fields or []\n", "files = files or []\n", "boundary = hashlib.md5(str(time.time())).hexdigest()\n", "body_list = []\n", "for key, value in fields:\n", "key = _ConvertToAscii(key)\n", "for key, filename, value in files:\n", "value = _ConvertToAscii(value)\n", "key = _ConvertToAscii(key)\n", "if len(body_list) > 1:\n", "body_list.append('--' + boundary)\n", "filename = _ConvertToAscii(filename)\n", "body_list[-2] += '--'\n", "body = '\\r\\n'.join(body_list)\n", "body_list.append('Content-Disposition: form-data; name=\"%s\"' % key)\n", "value = _ConvertToAscii(value)\n", "content_type = 'multipart/form-data; boundary=%s' % boundary\n", "body_list.append('')\n", "body_list.append('--' + boundary)\n", "return content_type, body\n", "body_list.append(value)\n", "body_list.append('Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"' %\n (key, filename))\n", "body_list.append('--' + boundary)\n", "body_list.append('Content-Type: application/octet-stream')\n", "body_list.append('')\n", "body_list.append('')\n", "body_list.append(value)\n", "body_list.append('--' + boundary)\n", "body_list.append('')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "For", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "AugAssign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Return'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_0(self):...\n", "" ]
[ "def get(self):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "from django.http import HttpRequest, HttpResponseRedirect\n", "from ..models import GroupReservation, ArticleRequested, Article, ArticleGroup, SubReservation\n", "from .magic import get_current_user\n", "import json\n", "import datetime\n", "RESERVATION_CONSTRUCTION_COOKIE_KEY: str = (\n 'org.technikradio.c3shop.frontpage' + '.reservation.cookiekey')\n", "EMPTY_COOKY_VALUE: str = \"\"\"\n{\n\"notes\": \"\",\n\"articles\": [],\n\"pickup_date\": \"\"\n}\n\"\"\"\n", "def FUNC_0(VAR_0, VAR_1):...\n", "res: GroupReservation = GroupReservation.objects.get(id=rid)\n", "def FUNC_1(VAR_2: HttpRequest, VAR_3: str):...\n", "VAR_5: str = VAR_3\n", "if VAR_2.GET.get('redirect'):\n", "VAR_5 = VAR_2.GET['redirect']\n", "VAR_5 = '/admin'\n", "if 'rid' not in VAR_2.GET:\n", "return HttpResponseRedirect(\n '/admin?error=Missing%20reservation%20id%20in%20request')\n", "u: Profile = get_current_user(VAR_2)\n", "VAR_4 = GroupReservation.objects.get(id=str(request.GET['rid']))\n", "if VAR_4.createdByUser != u and u.rights < 2:\n", "return HttpResponseRedirect('/admin?error=noyb')\n", "if VAR_4.submitted == True:\n", "return HttpResponseRedirect('/admin?error=Already%20submitted')\n", "if 'article_id' in VAR_2.POST:\n", "aid: int = int(VAR_2.GET.get('article_id'))\n", "if 'group_id' not in VAR_2.GET:\n", "quantity: int = int(VAR_2.POST['quantity'])\n", "return HttpResponseRedirect('/admin?error=missing%20group%20id')\n", "g: ArticleGroup = ArticleGroup.objects.get(id=int(request.GET['group_id']))\n", "notes: str = VAR_2.POST['notes']\n", "for art in Article.objects.all().filter(group=g):\n", "VAR_6 = ArticleRequested()\n", "if str('quantity_' + str(art.id)) not in VAR_2.POST or str('notes_' + str(\n", "if 'srid' in VAR_2.GET:\n", "VAR_6.AID = Article.objects.get(id=aid)\n", "return HttpResponseRedirect(\n '/admin?error=Missing%20article%20data%20in%20request')\n", "VAR_9 = int(VAR_2.POST['quantity_' + str(art.id)])\n", "VAR_7 = HttpResponseRedirect(VAR_5 + '?rid=' + str(VAR_4.id) + '&srid=' +\n VAR_2.GET['srid'])\n", "VAR_7 = HttpResponseRedirect(VAR_5 + '?rid=' + str(VAR_4.id))\n", "VAR_6.RID = VAR_4\n", "if VAR_9 > 0:\n", "return VAR_7\n", "if 'srid' in VAR_2.GET:\n", "VAR_6 = ArticleRequested()\n", "VAR_6.SRID = SubReservation.objects.get(id=int(request.GET['srid']))\n", "VAR_6.amount = quantity\n", "VAR_6.AID = art\n", "VAR_6.notes = notes\n", "VAR_6.RID = VAR_4\n", "VAR_6.save()\n", "VAR_6.amount = VAR_9\n", "if 'srid' in VAR_2.GET:\n", "VAR_6.SRID = SubReservation.objects.get(id=int(request.GET['srid']))\n", "VAR_6.notes = str(VAR_2.POST[str('notes_' + str(art.id))])\n", "VAR_6.save()\n" ]
[ "from django.http import HttpRequest, HttpResponseRedirect\n", "from ..models import GroupReservation, ArticleRequested, Article, ArticleGroup, SubReservation\n", "from .magic import get_current_user\n", "import json\n", "import datetime\n", "RESERVATION_CONSTRUCTION_COOKIE_KEY: str = (\n 'org.technikradio.c3shop.frontpage' + '.reservation.cookiekey')\n", "EMPTY_COOKY_VALUE: str = \"\"\"\n{\n\"notes\": \"\",\n\"articles\": [],\n\"pickup_date\": \"\"\n}\n\"\"\"\n", "def update_reservation_articles(postdict, rid):...\n", "res: GroupReservation = GroupReservation.objects.get(id=rid)\n", "def add_article_action(request: HttpRequest, default_foreward_url: str):...\n", "forward_url: str = default_foreward_url\n", "if request.GET.get('redirect'):\n", "forward_url = request.GET['redirect']\n", "forward_url = '/admin'\n", "if 'rid' not in request.GET:\n", "return HttpResponseRedirect(\n '/admin?error=Missing%20reservation%20id%20in%20request')\n", "u: Profile = get_current_user(request)\n", "current_reservation = GroupReservation.objects.get(id=str(request.GET['rid']))\n", "if current_reservation.createdByUser != u and u.rights < 2:\n", "return HttpResponseRedirect('/admin?error=noyb')\n", "if current_reservation.submitted == True:\n", "return HttpResponseRedirect('/admin?error=Already%20submitted')\n", "if 'article_id' in request.POST:\n", "aid: int = int(request.GET.get('article_id'))\n", "if 'group_id' not in request.GET:\n", "quantity: int = int(request.POST['quantity'])\n", "return HttpResponseRedirect('/admin?error=missing%20group%20id')\n", "g: ArticleGroup = ArticleGroup.objects.get(id=int(request.GET['group_id']))\n", "notes: str = request.POST['notes']\n", "for art in Article.objects.all().filter(group=g):\n", "ar = ArticleRequested()\n", "if str('quantity_' + str(art.id)) not in request.POST or str('notes_' + str\n", "if 'srid' in request.GET:\n", "ar.AID = Article.objects.get(id=aid)\n", "return HttpResponseRedirect(\n '/admin?error=Missing%20article%20data%20in%20request')\n", "amount = int(request.POST['quantity_' + str(art.id)])\n", "response = HttpResponseRedirect(forward_url + '?rid=' + str(\n current_reservation.id) + '&srid=' + request.GET['srid'])\n", "response = HttpResponseRedirect(forward_url + '?rid=' + str(\n current_reservation.id))\n", "ar.RID = current_reservation\n", "if amount > 0:\n", "return response\n", "if 'srid' in request.GET:\n", "ar = ArticleRequested()\n", "ar.SRID = SubReservation.objects.get(id=int(request.GET['srid']))\n", "ar.amount = quantity\n", "ar.AID = art\n", "ar.notes = notes\n", "ar.RID = current_reservation\n", "ar.save()\n", "ar.amount = amount\n", "if 'srid' in request.GET:\n", "ar.SRID = SubReservation.objects.get(id=int(request.GET['srid']))\n", "ar.notes = str(request.POST[str('notes_' + str(art.id))])\n", "ar.save()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Import'", "AnnAssign'", "AnnAssign'", "FunctionDef'", "AnnAssign'", "FunctionDef'", "AnnAssign'", "Condition", "Assign'", "Assign'", "Condition", "Return'", "AnnAssign'", "Assign'", "Condition", "Return'", "Condition", "Return'", "Condition", "AnnAssign'", "Condition", "AnnAssign'", "Return'", "AnnAssign'", "AnnAssign'", "For", "Assign'", "Condition", "Condition", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'" ]
[ "def __init__(self, VAR_7, VAR_71=20, **VAR_16):...\n", "self.num = VAR_71\n", "CLASS_0.__init__(self, VAR_7=param, **kw)\n" ]
[ "def __init__(self, param, num=20, **kw):...\n", "self.num = num\n", "Validator.__init__(self, param=param, **kw)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_0(self, VAR_2, VAR_3, VAR_4):...\n", "if not VAR_4:\n", "return\n", "if validate_hash(VAR_4):\n", "if validate_url(VAR_4):\n", "VAR_21 = VirusTotalAPI().hash_fetch(VAR_4)\n", "VAR_2['errors'].append('Error retrieving file hash: %s' % e)\n", "VAR_18 = Files.create(VAR_3, VAR_4, VAR_21)\n", "VAR_2['data'].append({'type': 'url', 'data': VAR_4})\n", "VAR_2['errors'].append(\"'%s' was neither a valid hash or url\" % VAR_4)\n", "return\n", "VAR_2['data'].append({'type': 'file', 'data': VAR_18})\n", "return\n", "return\n" ]
[ "def _handle_string(self, submit, tmppath, line):...\n", "if not line:\n", "return\n", "if validate_hash(line):\n", "if validate_url(line):\n", "filedata = VirusTotalAPI().hash_fetch(line)\n", "submit['errors'].append('Error retrieving file hash: %s' % e)\n", "filepath = Files.create(tmppath, line, filedata)\n", "submit['data'].append({'type': 'url', 'data': line})\n", "submit['errors'].append(\"'%s' was neither a valid hash or url\" % line)\n", "return\n", "submit['data'].append({'type': 'file', 'data': filepath})\n", "return\n", "return\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Condition", "Condition", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Return'", "Expr'", "Return'", "Return'" ]
[ "@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'" ]
[ "def FUNC_8(self):...\n", "" ]
[ "def describe(self):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_1():...\n", "return [webapp2.Route('/internal/cron/ereporter2/cleanup', CLASS_6),\n webapp2.Route('/internal/cron/ereporter2/mail', CLASS_5)]\n" ]
[ "def get_backend_routes():...\n", "return [webapp2.Route('/internal/cron/ereporter2/cleanup',\n CronEreporter2Cleanup), webapp2.Route('/internal/cron/ereporter2/mail',\n CronEreporter2Mail)]\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "from dataclasses import dataclass\n", "from typing import Dict\n", "import exifread\n", "from exifread.classes import IfdTag\n", "from geopy.geocoders import Nominatim\n", "from photogpsbot import bot, log, db, User\n", "\"\"\"\n Coordinates have invalid format\n \"\"\"\n", "\"\"\"\n There is no location info\n \"\"\"\n", "\"\"\"\n Means that there is no EXIF within the photo at all\n\n \"\"\"\n", "\"\"\"\n Means that there is actually no any data of our interest within the picture\n\n \"\"\"\n", "\"\"\"\n A class to store info about a photo from user.\n \"\"\"\n", "VAR_0: User\n", "VAR_10: str = None\n", "VAR_25: str = None\n", "VAR_26: str = None\n", "VAR_21: str = None\n", "VAR_22: Dict[str, str] = None\n", "VAR_7: float = None\n", "VAR_8: float = None\n", "\"\"\"\n Raw data from photo that is still have to be converted in order to be used.\n \"\"\"\n", "VAR_0: User\n", "VAR_10: str = None\n", "VAR_11: str = None\n", "VAR_12: str = None\n", "VAR_13: str = None\n", "VAR_14: str = None\n", "VAR_29: str = None\n", "VAR_30: IfdTag = None\n", "VAR_31: str = None\n", "VAR_32: IfdTag = None\n", "def __init__(self, VAR_0, VAR_1):...\n", "self.user = VAR_0\n", "self.file = VAR_1\n", "self.raw_data = None\n", "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "VAR_9 = exifread.process_file(VAR_1, details=False)\n", "if not len(VAR_9.keys()):\n", "VAR_28 = \"This picture doesn't contain EXIF.\"\n", "VAR_10 = VAR_9.get('EXIF DateTimeOriginal', None)\n", "log.info(VAR_28)\n", "VAR_10 = str(VAR_10) if VAR_10 else None\n", "VAR_11 = str(VAR_9.get('Image Make', ''))\n", "VAR_12 = str(VAR_9.get('Image Model', ''))\n", "VAR_13 = str(VAR_9.get('EXIF LensMake', ''))\n", "VAR_14 = str(VAR_9.get('EXIF LensModel', ''))\n", "if not any([VAR_10, VAR_11, VAR_12, VAR_13, VAR_14]):\n", "VAR_28 = 'There is no data of interest in this photo'\n", "VAR_29 = str(VAR_9['GPS GPSLatitudeRef'])\n", "log.info(\"This picture doesn't contain coordinates.\")\n", "return VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_29, VAR_30, VAR_31, VAR_32\n", "log.info(VAR_28)\n", "VAR_30 = VAR_9['GPS GPSLatitude']\n", "return VAR_10, VAR_11, VAR_12, VAR_13, VAR_14\n", "VAR_31 = str(VAR_9['GPS GPSLongitudeRef'])\n", "VAR_32 = VAR_9['GPS GPSLongitude']\n", "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "VAR_15 = ''\n", "for x in VAR_2.split(' '):\n", "if x not in VAR_15:\n", "return VAR_15.rstrip()\n", "VAR_15 += x + ' '\n" ]
[ "from dataclasses import dataclass\n", "from typing import Dict\n", "import exifread\n", "from exifread.classes import IfdTag\n", "from geopy.geocoders import Nominatim\n", "from photogpsbot import bot, log, db, User\n", "\"\"\"\n Coordinates have invalid format\n \"\"\"\n", "\"\"\"\n There is no location info\n \"\"\"\n", "\"\"\"\n Means that there is no EXIF within the photo at all\n\n \"\"\"\n", "\"\"\"\n Means that there is actually no any data of our interest within the picture\n\n \"\"\"\n", "\"\"\"\n A class to store info about a photo from user.\n \"\"\"\n", "user: User\n", "date_time: str = None\n", "camera: str = None\n", "lens: str = None\n", "address: str = None\n", "country: Dict[str, str] = None\n", "latitude: float = None\n", "longitude: float = None\n", "\"\"\"\n Raw data from photo that is still have to be converted in order to be used.\n \"\"\"\n", "user: User\n", "date_time: str = None\n", "camera_brand: str = None\n", "camera_model: str = None\n", "lens_brand: str = None\n", "lens_model: str = None\n", "latitude_reference: str = None\n", "raw_latitude: IfdTag = None\n", "longitude_reference: str = None\n", "raw_longitude: IfdTag = None\n", "def __init__(self, user, file):...\n", "self.user = user\n", "self.file = file\n", "self.raw_data = None\n", "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "exif = exifread.process_file(file, details=False)\n", "if not len(exif.keys()):\n", "reason = \"This picture doesn't contain EXIF.\"\n", "date_time = exif.get('EXIF DateTimeOriginal', None)\n", "log.info(reason)\n", "date_time = str(date_time) if date_time else None\n", "camera_brand = str(exif.get('Image Make', ''))\n", "camera_model = str(exif.get('Image Model', ''))\n", "lens_brand = str(exif.get('EXIF LensMake', ''))\n", "lens_model = str(exif.get('EXIF LensModel', ''))\n", "if not any([date_time, camera_brand, camera_model, lens_brand, lens_model]):\n", "reason = 'There is no data of interest in this photo'\n", "latitude_reference = str(exif['GPS GPSLatitudeRef'])\n", "log.info(\"This picture doesn't contain coordinates.\")\n", "return date_time, camera_brand, camera_model, lens_brand, lens_model, latitude_reference, raw_latitude, longitude_reference, raw_longitude\n", "log.info(reason)\n", "raw_latitude = exif['GPS GPSLatitude']\n", "return date_time, camera_brand, camera_model, lens_brand, lens_model\n", "longitude_reference = str(exif['GPS GPSLongitudeRef'])\n", "raw_longitude = exif['GPS GPSLongitude']\n", "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "deduped_string = ''\n", "for x in string.split(' '):\n", "if x not in deduped_string:\n", "return deduped_string.rstrip()\n", "deduped_string += x + ' '\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "Expr'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "Docstring", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Return'", "Expr'", "Assign'", "Return'", "Assign'", "Assign'", "Condition", "Docstring", "Assign'", "For", "Condition", "Return'", "AugAssign'" ]
[ "def FUNC_16(self, VAR_17):...\n", "if not path.exists(VAR_17):\n", "return None\n", "VAR_50 = sqlite3.connect(VAR_17)\n", "return None\n", "VAR_51 = {}\n", "for VAR_59 in VAR_50.execute('SELECT * FROM desc;').fetchall():\n", "VAR_51[VAR_59[0]] = VAR_59[1]\n", "return VAR_51\n" ]
[ "def get_database_desc(self, db_file):...\n", "if not path.exists(db_file):\n", "return None\n", "db = sqlite3.connect(db_file)\n", "return None\n", "desc = {}\n", "for row in db.execute('SELECT * FROM desc;').fetchall():\n", "desc[row[0]] = row[1]\n", "return desc\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "Return'", "Assign'", "For", "Assign'", "Return'" ]
[ "def FUNC_3(self, VAR_4):...\n", "if isinstance(VAR_4, datetime.datetime) or isinstance(VAR_4, datetime.date):\n", "return localize(VAR_4)\n", "return VAR_4\n" ]
[ "def format(self, value):...\n", "if isinstance(value, datetime.datetime) or isinstance(value, datetime.date):\n", "return localize(value)\n", "return value\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_10(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_24 = self.scripts['install']\n", "if VAR_24.exists:\n", "if VAR_24.contains('ynh_install_app_dependencies'):\n", "for VAR_18 in ['upgrade', 'restore']:\n", "if VAR_24.contains('yunohost service add'):\n", "if self.scripts[VAR_18].exists and not self.scripts[VAR_18].contains(\n", "if self.scripts['remove'].exists and not self.scripts['remove'].contains(\n", "FUNC_3('ynh_install_app_dependencies should also be in %s script' % VAR_18)\n", "FUNC_4('string')\n" ]
[ "def check_helper_consistency(self):...\n", "\"\"\"docstring\"\"\"\n", "install_script = self.scripts['install']\n", "if install_script.exists:\n", "if install_script.contains('ynh_install_app_dependencies'):\n", "for name in ['upgrade', 'restore']:\n", "if install_script.contains('yunohost service add'):\n", "if self.scripts[name].exists and not self.scripts[name].contains(\n", "if self.scripts['remove'].exists and not self.scripts['remove'].contains(\n", "print_warning('ynh_install_app_dependencies should also be in %s script' % name\n )\n", "print_error(\n \"You used 'yunohost service add' in the install script, but not 'yunohost service remove' in the remove script.\"\n )\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Condition", "For", "Condition", "Condition", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_23(self, VAR_12=False):...\n", "if self.DiagnosticsForCurrentFileReady():\n", "VAR_22 = self._latest_file_parse_request.Response()\n", "return []\n", "self._latest_file_parse_request = None\n", "if VAR_12:\n", "return vimsupport.ConvertDiagnosticsToQfList(VAR_22)\n", "return VAR_22\n" ]
[ "def GetDiagnosticsFromStoredRequest(self, qflist_format=False):...\n", "if self.DiagnosticsForCurrentFileReady():\n", "diagnostics = self._latest_file_parse_request.Response()\n", "return []\n", "self._latest_file_parse_request = None\n", "if qflist_format:\n", "return vimsupport.ConvertDiagnosticsToQfList(diagnostics)\n", "return diagnostics\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Return'", "Assign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_16(self):...\n", "self.assertEqual(self.driver._get_space_in_gb('123.0GB'), 123.0)\n", "self.assertEqual(self.driver._get_space_in_gb('123.0TB'), 123.0 * 1024)\n", "self.assertEqual(self.driver._get_space_in_gb('1024.0MB'), 1.0)\n" ]
[ "def test_get_space_in_gb(self):...\n", "self.assertEqual(self.driver._get_space_in_gb('123.0GB'), 123.0)\n", "self.assertEqual(self.driver._get_space_in_gb('123.0TB'), 123.0 * 1024)\n", "self.assertEqual(self.driver._get_space_in_gb('1024.0MB'), 1.0)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_16(self):...\n", "return self.username\n" ]
[ "def returnUsername(self):...\n", "return self.username\n" ]
[ 0, 4 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_4(self, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_4 = '/api/keys'\n", "VAR_5 = {'id': '[email protected]', 'public': VAR_3}\n", "VAR_6 = self.client.post(VAR_4, json.dumps(VAR_5), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "VAR_6 = self.client.post(VAR_4, json.dumps(VAR_5), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 400)\n" ]
[ "def _check_duplicate_key(self, pubkey):...\n", "\"\"\"docstring\"\"\"\n", "url = '/api/keys'\n", "body = {'id': '[email protected]', 'public': pubkey}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 400)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "from odoo import tools\n", "from odoo import api, fields, models\n", "VAR_0 = 'qc.problem.report'\n", "VAR_1 = 'Problem Tracking Report'\n", "VAR_2 = False\n", "VAR_3 = 'date'\n", "VAR_4 = 'date desc'\n", "VAR_5 = fields.Char('Name', readonly=True)\n", "VAR_6 = fields.Datetime('Helpdesk Create Date', readonly=True)\n", "VAR_7 = fields.Text('Notes', readonly=True)\n", "VAR_8 = fields.Many2one('qc.problem.group', 'Problem Group', readonly=True)\n", "VAR_9 = fields.Integer('Color Index', readonly=True)\n", "VAR_10 = fields.Selection([('0', 'Normal'), ('1', 'Low'), ('2', 'High'), (\n '3', 'Very High')], 'Rating', readonly=True)\n", "VAR_11 = fields.Many2one('qc.stage', 'Stage', readonly=True)\n", "VAR_12 = fields.Many2one('qc.team', 'QC Team', readonly=True)\n", "VAR_13 = fields.Many2one('res.company', 'Company', readonly=True)\n", "VAR_14 = fields.Integer('Helpdesk Tickets Count', readonly=True)\n", "def FUNC_0(self):...\n", "VAR_15 = 'string'\n", "return VAR_15\n" ]
[ "from odoo import tools\n", "from odoo import api, fields, models\n", "_name = 'qc.problem.report'\n", "_description = 'Problem Tracking Report'\n", "_auto = False\n", "_rec_name = 'date'\n", "_order = 'date desc'\n", "name = fields.Char('Name', readonly=True)\n", "date = fields.Datetime('Helpdesk Create Date', readonly=True)\n", "notes = fields.Text('Notes', readonly=True)\n", "problem_group_id = fields.Many2one('qc.problem.group', 'Problem Group',\n readonly=True)\n", "color = fields.Integer('Color Index', readonly=True)\n", "priority = fields.Selection([('0', 'Normal'), ('1', 'Low'), ('2', 'High'),\n ('3', 'Very High')], 'Rating', readonly=True)\n", "stage_id = fields.Many2one('qc.stage', 'Stage', readonly=True)\n", "qc_team_id = fields.Many2one('qc.team', 'QC Team', readonly=True)\n", "company_id = fields.Many2one('res.company', 'Company', readonly=True)\n", "crm_helpdesk_count = fields.Integer('Helpdesk Tickets Count', readonly=True)\n", "def _select(self):...\n", "select_str = \"\"\"\n SELECT qcp.id as id,\n qcp.name as name,\n qcp.notes as notes,\n qcp.problem_group_id as problem_group_id,\n qcp.color as color,\n qcp.priority as priority,\n qcp.stage_id as stage_id,\n qcp.qc_team_id as qc_team_id,\n qcp.company_id as company_id,\n count(hpr) as crm_helpdesk_count,\n chd.date as date\n \"\"\"\n", "return select_str\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Return'" ]
[ "@VAR_19.route('/test')...\n", "return 'OK'\n" ]
[ "@test_views.route('/test')...\n", "return 'OK'\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_1(self):...\n", "super(CLASS_1, self).setUp()\n", "VAR_12 = patch('pavelib.utils.test.suites.bokchoy_suite.sh')\n", "self._mock_sh = VAR_12.start()\n", "self.addCleanup(VAR_12.stop)\n" ]
[ "def setUp(self):...\n", "super(TestPaverPa11yCrawlerCmd, self).setUp()\n", "mock_sh = patch('pavelib.utils.test.suites.bokchoy_suite.sh')\n", "self._mock_sh = mock_sh.start()\n", "self.addCleanup(mock_sh.stop)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_21(VAR_21):...\n", "\"\"\"docstring\"\"\"\n", "return json.load(VAR_0)\n", "VAR_0.seek(0)\n", "import yaml\n", "return yaml.load(VAR_0)\n" ]
[ "def _load_configfile(configpath):...\n", "\"\"\"docstring\"\"\"\n", "return json.load(f)\n", "f.seek(0)\n", "import yaml\n", "return yaml.load(f)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'", "Expr'", "Import'", "Return'" ]
[ "def FUNC_4():...\n", "VAR_33 = FUNC_3(VAR_21=parent, VAR_22=child, VAR_23=\n ExtractedChemicalFormSet, VAR_24=ExtractedChemicalForm)\n", "return CLASS_16, VAR_33\n" ]
[ "def one():...\n", "ChemicalFormSet = make_formset(parent_model=parent, model=child, formset=\n ExtractedChemicalFormSet, form=ExtractedChemicalForm)\n", "return ExtractedTextForm, ChemicalFormSet\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "@utils.synchronized('3par', external=True)...\n", "\"\"\"docstring\"\"\"\n", "self.common.client_login()\n", "VAR_23 = self.common.create_volume_from_snapshot(VAR_7, VAR_9)\n", "self.common.client_logout()\n", "return {'metadata': VAR_23}\n" ]
[ "@utils.synchronized('3par', external=True)...\n", "\"\"\"docstring\"\"\"\n", "self.common.client_login()\n", "metadata = self.common.create_volume_from_snapshot(volume, snapshot)\n", "self.common.client_logout()\n", "return {'metadata': metadata}\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Expr'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_42(self):...\n", "VAR_32 = list()\n", "for VAR_14 in self.get_columns_list():\n", "if not self.is_relation(VAR_14):\n", "return VAR_32\n", "VAR_38 = self.get_property_first_col(VAR_14).name\n", "VAR_32.append(VAR_14)\n", "if not self.is_pk(VAR_38) and not self.is_fk(VAR_38) and not self.is_image(\n", "VAR_32.append(VAR_14)\n" ]
[ "def get_search_columns_list(self):...\n", "ret_lst = list()\n", "for col_name in self.get_columns_list():\n", "if not self.is_relation(col_name):\n", "return ret_lst\n", "tmp_prop = self.get_property_first_col(col_name).name\n", "ret_lst.append(col_name)\n", "if not self.is_pk(tmp_prop) and not self.is_fk(tmp_prop) and not self.is_image(\n", "ret_lst.append(col_name)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Condition", "Return'", "Assign'", "Expr'", "Condition", "Expr'" ]
[ "def __setattr__(self, VAR_10, VAR_11):...\n", "if self.__dict__.get(VAR_10):\n", "self.__dict__[VAR_10] = VAR_11\n" ]
[ "def __setattr__(self, name, value):...\n", "if self.__dict__.get(name):\n", "self.__dict__[name] = value\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'" ]
[ "def FUNC_11(self, VAR_14=None, VAR_15=False, VAR_16=False, VAR_17=1, VAR_18...\n", "self.global_resources = dict() if VAR_52 is None else VAR_52\n", "self.global_resources['_cores'] = VAR_17\n", "self.global_resources['_nodes'] = VAR_18\n", "def FUNC_2(VAR_87):...\n", "return map(self._rules.__getitem__, filter(self.is_rule, VAR_87))\n" ]
[ "def execute(self, targets=None, dryrun=False, touch=False, cores=1, nodes=1,...\n", "self.global_resources = dict() if resources is None else resources\n", "self.global_resources['_cores'] = cores\n", "self.global_resources['_nodes'] = nodes\n", "def rules(items):...\n", "return map(self._rules.__getitem__, filter(self.is_rule, items))\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Return'" ]
[ "def FUNC_18(self, VAR_25, VAR_27):...\n", "VAR_20 = request_mock(VAR_25=path, method='PUT', VAR_27=body, VAR_28={\n 'Content-Type': ['application/json']})\n", "return self._render(VAR_20)\n" ]
[ "def put(self, path, body):...\n", "request = request_mock(path=path, method='PUT', body=body, headers={\n 'Content-Type': ['application/json']})\n", "return self._render(request)\n" ]
[ 0, 5, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def __eq__(self, VAR_25):...\n", "VAR_0 = VAR_25._file if isinstance(VAR_25, CLASS_0) else VAR_25\n", "return self._file == VAR_0\n" ]
[ "def __eq__(self, other):...\n", "f = other._file if isinstance(other, _IOFile) else other\n", "return self._file == f\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_0(self, VAR_2, VAR_3, VAR_4, VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = []\n", "VAR_7 = self.pool.get('ir.model.data')\n", "VAR_8 = self.pool.get('res.users').browse(VAR_2, VAR_3, VAR_3).company_id.id\n", "VAR_9 = self.pool.get('account.bank.statement')\n", "VAR_10 = self.pool.get('ir.sequence')\n", "VAR_11 = self.pool.get('account.journal')\n", "VAR_2.execute(\n 'select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id'\n % VAR_3)\n", "VAR_12 = map(lambda x1: x1[0], VAR_2.fetchall())\n", "VAR_2.execute('string' % ','.join(map(lambda x: \"'\" + str(x) + \"'\", VAR_12)))\n", "VAR_13 = map(lambda x1: x1[0], VAR_2.fetchall())\n", "for journal in VAR_11.browse(VAR_2, VAR_3, VAR_13):\n", "VAR_4 = VAR_9.search(VAR_2, VAR_3, [('state', '!=', 'confirm'), ('user_id',\n '=', VAR_3), ('journal_id', '=', journal.id)])\n", "VAR_14 = self.pool.get('ir.model.data')\n", "if len(VAR_4):\n", "VAR_15 = VAR_14._get_id(VAR_2, VAR_3, 'account', 'view_bank_statement_tree')\n", "VAR_17 = ''\n", "VAR_16 = VAR_14._get_id(VAR_2, VAR_3, 'account', 'view_bank_statement_form2')\n", "if journal.sequence_id:\n", "if VAR_15:\n", "VAR_17 = VAR_10.get_id(VAR_2, VAR_3, journal.sequence_id.id)\n", "VAR_17 = VAR_10.get(VAR_2, VAR_3, 'account.bank.statement')\n", "VAR_15 = VAR_14.browse(VAR_2, VAR_3, VAR_15, VAR_5=context).res_id\n", "if VAR_16:\n", "VAR_18 = VAR_9.create(VAR_2, VAR_3, {'journal_id': journal.id, 'company_id':\n VAR_8, 'user_id': VAR_3, 'state': 'open', 'name': VAR_17,\n 'starting_details_ids': VAR_9._get_cash_close_box_lines(VAR_2, VAR_3, [])})\n", "VAR_16 = VAR_14.browse(VAR_2, VAR_3, VAR_16, VAR_5=context).res_id\n", "return {'domain': \"[('state','=','open')]\", 'name': 'Open Statement',\n 'view_type': 'form', 'view_mode': 'tree,form', 'res_model':\n 'account.bank.statement', 'views': [(VAR_15, 'tree'), (VAR_16, 'form')],\n 'type': 'ir.actions.act_window'}\n", "VAR_9.button_open(VAR_2, VAR_3, [VAR_18], VAR_5)\n" ]
[ "def open_statement(self, cr, uid, ids, context):...\n", "\"\"\"docstring\"\"\"\n", "list_statement = []\n", "mod_obj = self.pool.get('ir.model.data')\n", "company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id\n", "statement_obj = self.pool.get('account.bank.statement')\n", "sequence_obj = self.pool.get('ir.sequence')\n", "journal_obj = self.pool.get('account.journal')\n", "cr.execute(\n 'select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id'\n % uid)\n", "j_ids = map(lambda x1: x1[0], cr.fetchall())\n", "cr.execute(\n \"\"\" select id from account_journal\n where auto_cash='True' and type='cash'\n and id in (%s)\"\"\"\n % ','.join(map(lambda x: \"'\" + str(x) + \"'\", j_ids)))\n", "journal_ids = map(lambda x1: x1[0], cr.fetchall())\n", "for journal in journal_obj.browse(cr, uid, journal_ids):\n", "ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id',\n '=', uid), ('journal_id', '=', journal.id)])\n", "data_obj = self.pool.get('ir.model.data')\n", "if len(ids):\n", "id2 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')\n", "number = ''\n", "id3 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')\n", "if journal.sequence_id:\n", "if id2:\n", "number = sequence_obj.get_id(cr, uid, journal.sequence_id.id)\n", "number = sequence_obj.get(cr, uid, 'account.bank.statement')\n", "id2 = data_obj.browse(cr, uid, id2, context=context).res_id\n", "if id3:\n", "statement_id = statement_obj.create(cr, uid, {'journal_id': journal.id,\n 'company_id': company_id, 'user_id': uid, 'state': 'open', 'name':\n number, 'starting_details_ids': statement_obj._get_cash_close_box_lines\n (cr, uid, [])})\n", "id3 = data_obj.browse(cr, uid, id3, context=context).res_id\n", "return {'domain': \"[('state','=','open')]\", 'name': 'Open Statement',\n 'view_type': 'form', 'view_mode': 'tree,form', 'res_model':\n 'account.bank.statement', 'views': [(id2, 'tree'), (id3, 'form')],\n 'type': 'ir.actions.act_window'}\n", "statement_obj.button_open(cr, uid, [statement_id], context)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "For", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Return'", "Expr'" ]
[ "def FUNC_33(VAR_32):...\n", "" ]
[ "def _iter(item):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_9(VAR_12):...\n", "if os.path.isfile(VAR_12):\n", "VAR_41 = f.read()\n", "return None\n", "return VAR_41\n" ]
[ "def read_file_contents(local_filepath):...\n", "if os.path.isfile(local_filepath):\n", "data = f.read()\n", "return None\n", "return data\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Return'", "Return'" ]
[ "def FUNC_28(self, VAR_15):...\n", "" ]
[ "def edit(self, item):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_0(VAR_0, VAR_1):...\n", "VAR_3 = os.path.dirname(os.path.abspath(__file__))\n", "VAR_4 = Environment(loader=FileSystemLoader(UTILS_DIR))\n", "return VAR_4.get_template('templates/eb/config.yml').render(APPLICATION_NAME\n =application_name, DEFAULT_REGION=default_region)\n" ]
[ "def make_eb_config(application_name, default_region):...\n", "UTILS_DIR = os.path.dirname(os.path.abspath(__file__))\n", "j2_env = Environment(loader=FileSystemLoader(UTILS_DIR))\n", "return j2_env.get_template('templates/eb/config.yml').render(APPLICATION_NAME\n =application_name, DEFAULT_REGION=default_region)\n" ]
[ 0, 0, 3, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_6(self, VAR_40):...\n", "if VAR_40 and len(VAR_40) > 500:\n", "VAR_101.errors.add(errors.DESC_TOO_LONG)\n", "return unkeep_space(VAR_40 or '')\n" ]
[ "def run(self, description):...\n", "if description and len(description) > 500:\n", "c.errors.add(errors.DESC_TOO_LONG)\n", "return unkeep_space(description or '')\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_4(self):...\n", "VAR_2 = CLASS_1.construct_testscript_command('test_interactive_program.py')\n", "self.assertEqual(p.stdout.readline(), 'test_program X\\n')\n", "self.assertEqual(p.stdout.readline(), 'Type in a number:\\n')\n", "p.stdin.write('33\\n')\n", "p.stdin.flush()\n", "self.assertEqual(p.stdout.readline(), '33\\n')\n", "self.assertEqual(p.stdout.readline(), 'Exiting program.\\n')\n" ]
[ "def test_run_interactive_shell_command(self):...\n", "command = RunShellCommandTest.construct_testscript_command(\n 'test_interactive_program.py')\n", "self.assertEqual(p.stdout.readline(), 'test_program X\\n')\n", "self.assertEqual(p.stdout.readline(), 'Type in a number:\\n')\n", "p.stdin.write('33\\n')\n", "p.stdin.flush()\n", "self.assertEqual(p.stdout.readline(), '33\\n')\n", "self.assertEqual(p.stdout.readline(), 'Exiting program.\\n')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_9(self, VAR_19):...\n", "for VAR_14 in VAR_19:\n", "f.write(VAR_14 + '\\n')\n", "VAR_3.debug('Created %s' % self.output_file)\n" ]
[ "def write_lines(self, lines):...\n", "for line in lines:\n", "f.write(line + '\\n')\n", "LOG.debug('Created %s' % self.output_file)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Expr'", "Expr'" ]
[ "def FUNC_8(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_1 = self.bindings\n", "VAR_15 = '{app}-{stack}-v000'.format(app=self.TEST_APP, stack=bindings[\n 'TEST_STACK'])\n", "VAR_12 = self.agent.make_json_payload_from_kwargs(job=[{'cloudProvider':\n 'aws', 'type': 'destroyServerGroup', 'serverGroupName': group_name,\n 'asgName': group_name, 'region': bindings['TEST_AWS_REGION'], 'regions':\n [bindings['TEST_AWS_REGION']], 'credentials': bindings[\n 'AWS_CREDENTIALS'], 'user': '[anonymous]'}], application=self.TEST_APP,\n description='DestroyServerGroup: ' + group_name)\n", "VAR_13 = aws.AwsContractBuilder(self.aws_observer)\n", "VAR_13.new_clause_builder('Auto Scaling Group Removed').collect_resources(\n 'autoscaling', 'describe-auto-scaling-groups', args=[\n '--auto-scaling-group-names', group_name], no_resources_ok=True\n ).contains_path_value('AutoScalingGroups', {'MaxSize': 0})\n", "VAR_13.new_clause_builder('Instances Are Removed', retryable_for_secs=30\n ).collect_resources('ec2', 'describe-instances', no_resources_ok=True\n ).excludes_path_value('name', VAR_15)\n", "return st.OperationContract(self.new_post_operation(title=\n 'delete_server_group', data=payload, path='tasks'), VAR_6=builder.build())\n" ]
[ "def delete_server_group(self):...\n", "\"\"\"docstring\"\"\"\n", "bindings = self.bindings\n", "group_name = '{app}-{stack}-v000'.format(app=self.TEST_APP, stack=bindings[\n 'TEST_STACK'])\n", "payload = self.agent.make_json_payload_from_kwargs(job=[{'cloudProvider':\n 'aws', 'type': 'destroyServerGroup', 'serverGroupName': group_name,\n 'asgName': group_name, 'region': bindings['TEST_AWS_REGION'], 'regions':\n [bindings['TEST_AWS_REGION']], 'credentials': bindings[\n 'AWS_CREDENTIALS'], 'user': '[anonymous]'}], application=self.TEST_APP,\n description='DestroyServerGroup: ' + group_name)\n", "builder = aws.AwsContractBuilder(self.aws_observer)\n", "builder.new_clause_builder('Auto Scaling Group Removed').collect_resources(\n 'autoscaling', 'describe-auto-scaling-groups', args=[\n '--auto-scaling-group-names', group_name], no_resources_ok=True\n ).contains_path_value('AutoScalingGroups', {'MaxSize': 0})\n", "builder.new_clause_builder('Instances Are Removed', retryable_for_secs=30\n ).collect_resources('ec2', 'describe-instances', no_resources_ok=True\n ).excludes_path_value('name', group_name)\n", "return st.OperationContract(self.new_post_operation(title=\n 'delete_server_group', data=payload, path='tasks'), contract=builder.\n build())\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def __init__(self, VAR_15, VAR_16, VAR_17):...\n", "\"\"\"docstring\"\"\"\n", "self._name = 'Netatmo {} {}'.format(VAR_16, VAR_5[VAR_17][0])\n", "self.netatmo_data = VAR_15\n", "self.module_name = VAR_16\n", "self.type = VAR_17\n", "self._state = None\n", "self._device_class = VAR_5[self.type][3]\n", "self._icon = VAR_5[self.type][2]\n", "self._unit_of_measurement = VAR_5[self.type][1]\n", "VAR_20 = self.netatmo_data.station_data.moduleByName(module=module_name)['_id']\n", "self.module_id = VAR_20[1]\n" ]
[ "def __init__(self, netatmo_data, module_name, sensor_type):...\n", "\"\"\"docstring\"\"\"\n", "self._name = 'Netatmo {} {}'.format(module_name, SENSOR_TYPES[sensor_type][0])\n", "self.netatmo_data = netatmo_data\n", "self.module_name = module_name\n", "self.type = sensor_type\n", "self._state = None\n", "self._device_class = SENSOR_TYPES[self.type][3]\n", "self._icon = SENSOR_TYPES[self.type][2]\n", "self._unit_of_measurement = SENSOR_TYPES[self.type][1]\n", "module_id = self.netatmo_data.station_data.moduleByName(module=module_name)[\n '_id']\n", "self.module_id = module_id[1]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "@VAR_0.route('/<productId>/reviews/<userId>', methods=['PUT'])...\n", "VAR_18 = FUNC_6()\n", "ProductsRepository.add_product_review(VAR_6, VAR_7, VAR_18)\n", "return 'Duplicate'\n", "return 'Ok'\n" ]
[ "@products.route('/<productId>/reviews/<userId>', methods=['PUT'])...\n", "review = get_review()\n", "ProductsRepository.add_product_review(productId, userId, review)\n", "return 'Duplicate'\n", "return 'Ok'\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Expr'", "Return'", "Return'" ]
[ "def FUNC_22(VAR_30, VAR_3):...\n", "if not isinstance(VAR_30, _IOFile):\n", "return IOFile(VAR_30, VAR_16=self)\n", "return VAR_30.apply_wildcards(VAR_3, fill_missing=f in self.dynamic_input,\n fail_dynamic=self.dynamic_output)\n" ]
[ "def concretize_iofile(f, wildcards):...\n", "if not isinstance(f, _IOFile):\n", "return IOFile(f, rule=self)\n", "return f.apply_wildcards(wildcards, fill_missing=f in self.dynamic_input,\n fail_dynamic=self.dynamic_output)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_20(VAR_18, VAR_20, VAR_10, VAR_26, VAR_27, VAR_28):...\n", "VAR_48 = VAR_20, VAR_4[VAR_20]['name']\n", "VAR_34 = FUNC_1(VAR_10)\n", "VAR_49 = SubmitUserTestRequest(VAR_34, VAR_48, base_url=CWS_BASE_URL,\n VAR_26=submission_format, VAR_27=filenames)\n", "VAR_49.execute()\n", "VAR_31 = VAR_49.get_user_test_id()\n", "if VAR_31 is None:\n", "return VAR_31\n" ]
[ "def cws_submit_user_test(contest_id, task_id, user_id, submission_format,...\n", "task = task_id, created_tasks[task_id]['name']\n", "browser = get_cws_browser(user_id)\n", "sr = SubmitUserTestRequest(browser, task, base_url=CWS_BASE_URL,\n submission_format=submission_format, filenames=filenames)\n", "sr.execute()\n", "user_test_id = sr.get_user_test_id()\n", "if user_test_id is None:\n", "return user_test_id\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_8(VAR_0):...\n", "VAR_24, VAR_25 = os.path.split(VAR_0)\n", "return VAR_25 or os.path.basename(VAR_24)\n" ]
[ "def path_leaf(path):...\n", "head, tail = os.path.split(path)\n", "return tail or os.path.basename(head)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_41(self):...\n", "for VAR_40 in self._names:\n", "yield VAR_40, getattr(self, VAR_40)\n" ]
[ "def items(self):...\n", "for name in self._names:\n", "yield name, getattr(self, name)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "For", "Expr'" ]
[ "def FUNC_0():...\n", "if VAR_8 is None:\n", "VAR_8 = Browser()\n", "return VAR_8\n", "VAR_53 = AWSLoginRequest(VAR_8, VAR_5['username'], VAR_5['password'],\n base_url=AWS_BASE_URL)\n", "VAR_8.login(VAR_53)\n" ]
[ "def get_aws_browser():...\n", "if aws_browser is None:\n", "aws_browser = Browser()\n", "return aws_browser\n", "lr = AWSLoginRequest(aws_browser, admin_info['username'], admin_info[\n 'password'], base_url=AWS_BASE_URL)\n", "aws_browser.login(lr)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Return'", "Assign'", "Expr'" ]
[ "def FUNC_36(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_11 = 'TRUNCATE TABLE players;'\n", "tools.query(VAR_11)\n", "self.assertEqual(FUNC_5(VAR_1='Double Quarder', VAR_2='Playland'), 0)\n", "VAR_11 = 'SELECT * FROM matches ORDER BY id LIMIT 1'\n", "VAR_13 = tools.query(VAR_11)\n", "VAR_14 = VAR_13[0][0]\n", "self.assertEqual(FUNC_5(VAR_1='Big Mac Sauce', VAR_2='Playland'), 0)\n", "VAR_11 = 'SELECT * FROM matches ORDER BY id LIMIT 1'\n", "VAR_13 = tools.query(VAR_11)\n", "VAR_15 = str(VAR_13[0][0])\n", "VAR_14 = str(VAR_14 + 2)\n", "tournament.reportMatch(p1=i1, p2=i2)\n" ]
[ "def test_p1_not_valid(self):...\n", "\"\"\"docstring\"\"\"\n", "q = 'TRUNCATE TABLE players;'\n", "tools.query(q)\n", "self.assertEqual(dummy_player(player_name='Double Quarder', country=\n 'Playland'), 0)\n", "q = 'SELECT * FROM matches ORDER BY id LIMIT 1'\n", "p = tools.query(q)\n", "i1 = p[0][0]\n", "self.assertEqual(dummy_player(player_name='Big Mac Sauce', country=\n 'Playland'), 0)\n", "q = 'SELECT * FROM matches ORDER BY id LIMIT 1'\n", "p = tools.query(q)\n", "i2 = str(p[0][0])\n", "i1 = str(i1 + 2)\n", "tournament.reportMatch(p1=i1, p2=i2)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_5(VAR_4, *VAR_5, **VAR_6):...\n", "" ]
[ "def dummy_handler(remote, *args, **kargs):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "@FUNC_0...\n", "VAR_12 = await get_session(VAR_3)\n", "if 'uname' not in VAR_12:\n", "return VAR_4\n", "return 'string' % VAR_12['uname']\n" ]
[ "@handle_html...\n", "session = await get_session(request)\n", "if 'uname' not in session:\n", "return base\n", "return \"\"\"<b>You're already logged in as <i>%s</i>!</b>\n<form action='/login' method='post'><input type='submit' name='action' value='logout'/></form>\"\"\" % session[\n 'uname']\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Return'", "Return'" ]
[ "def __init__(self, VAR_24):...\n", "self.redirections = VAR_24\n", "self.stack = None\n" ]
[ "def __init__(self, redirections):...\n", "self.redirections = redirections\n", "self.stack = None\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'" ]
[ "def FUNC_6(self):...\n", "VAR_21 = self.agent.type_to_payload('deleteGoogleHttpLoadBalancerDescription',\n {'loadBalancerName': self.__use_http_lb_name, 'credentials': self.\n bindings['GCE_CREDENTIALS']})\n", "VAR_20 = gcp.GceContractBuilder(self.gce_observer)\n", "VAR_20.new_clause_builder('Health Check Removed').list_resources(\n 'http-health-checks').excludes_path_value('name', self.\n __use_http_lb_hc_name)\n", "VAR_20.new_clause_builder('Forwarding Rules Removed').list_resources(\n 'forwarding-rules').excludes_path_value('name', self.__use_http_lb_fr_name)\n", "VAR_20.new_clause_builder('Backend Service Removed').list_resources(\n 'backend-services').excludes_path_value('name', self.__use_http_lb_bs_name)\n", "VAR_20.new_clause_builder('Url Map Removed').list_resources('url-maps'\n ).excludes_path_value('name', self.__use_http_lb_map_name)\n", "VAR_20.new_clause_builder('Target Http Proxy Removed').list_resources(\n 'target-http-proxies').excludes_path_value('name', self.\n __use_http_lb_proxy_name)\n", "return st.OperationContract(self.new_post_operation(title=\n 'delete_http_load_balancer', data=payload, VAR_29='ops'), contract=\n builder.build())\n" ]
[ "def delete_http_load_balancer(self):...\n", "payload = self.agent.type_to_payload('deleteGoogleHttpLoadBalancerDescription',\n {'loadBalancerName': self.__use_http_lb_name, 'credentials': self.\n bindings['GCE_CREDENTIALS']})\n", "builder = gcp.GceContractBuilder(self.gce_observer)\n", "builder.new_clause_builder('Health Check Removed').list_resources(\n 'http-health-checks').excludes_path_value('name', self.\n __use_http_lb_hc_name)\n", "builder.new_clause_builder('Forwarding Rules Removed').list_resources(\n 'forwarding-rules').excludes_path_value('name', self.__use_http_lb_fr_name)\n", "builder.new_clause_builder('Backend Service Removed').list_resources(\n 'backend-services').excludes_path_value('name', self.__use_http_lb_bs_name)\n", "builder.new_clause_builder('Url Map Removed').list_resources('url-maps'\n ).excludes_path_value('name', self.__use_http_lb_map_name)\n", "builder.new_clause_builder('Target Http Proxy Removed').list_resources(\n 'target-http-proxies').excludes_path_value('name', self.\n __use_http_lb_proxy_name)\n", "return st.OperationContract(self.new_post_operation(title=\n 'delete_http_load_balancer', data=payload, path='ops'), contract=\n builder.build())\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "def __init__(self, VAR_10, VAR_11={}):...\n", "self._leap_provider = VAR_10\n", "self._credentials = VAR_11.copy()\n" ]
[ "def __init__(self, leap_provider, credentials={}):...\n", "self._leap_provider = leap_provider\n", "self._credentials = credentials.copy()\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'" ]
[ "def FUNC_8(self, VAR_18, VAR_11):...\n", "VAR_24 = [self.key_name]\n", "VAR_25 = self.lhs\n", "while isinstance(VAR_25, CLASS_2):\n", "VAR_24.insert(0, VAR_25.key_name)\n", "VAR_26, VAR_27 = VAR_18.compile(VAR_25)\n", "VAR_25 = VAR_25.lhs\n", "if len(VAR_24) > 1:\n", "return '(%s %s %%s)' % (VAR_26, self.nested_operator), [VAR_24] + VAR_27\n", "int(self.key_name)\n", "VAR_29 = \"'%s'\" % self.key_name\n", "VAR_29 = '%s' % self.key_name\n", "return '(%s %s %s)' % (VAR_26, self.operator, VAR_29), VAR_27\n" ]
[ "def as_sql(self, compiler, connection):...\n", "key_transforms = [self.key_name]\n", "previous = self.lhs\n", "while isinstance(previous, KeyTransform):\n", "key_transforms.insert(0, previous.key_name)\n", "lhs, params = compiler.compile(previous)\n", "previous = previous.lhs\n", "if len(key_transforms) > 1:\n", "return '(%s %s %%s)' % (lhs, self.nested_operator), [key_transforms] + params\n", "int(self.key_name)\n", "lookup = \"'%s'\" % self.key_name\n", "lookup = '%s' % self.key_name\n", "return '(%s %s %s)' % (lhs, self.operator, lookup), params\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Return'", "Expr'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_9(VAR_10):...\n", "\"\"\"docstring\"\"\"\n", "VAR_42 = []\n", "for field in ['arrayjoin', 'groupby', 'orderby', 'selected_columns']:\n", "if field in VAR_10:\n", "if 'conditions' in VAR_10:\n", "VAR_42.extend(FUNC_0(VAR_10[field]))\n", "VAR_67 = list(chain(*[([c] if FUNC_8(c) else c) for c in VAR_10['conditions']])\n )\n", "if 'aggregations' in VAR_10:\n", "VAR_42.extend([c[0] for c in VAR_67])\n", "VAR_42.extend([a[1] for a in VAR_10['aggregations']])\n", "return set(chain(*[FUNC_10(ex) for ex in VAR_42]))\n" ]
[ "def all_referenced_columns(body):...\n", "\"\"\"docstring\"\"\"\n", "col_exprs = []\n", "for field in ['arrayjoin', 'groupby', 'orderby', 'selected_columns']:\n", "if field in body:\n", "if 'conditions' in body:\n", "col_exprs.extend(to_list(body[field]))\n", "flat_conditions = list(chain(*[([c] if is_condition(c) else c) for c in\n body['conditions']]))\n", "if 'aggregations' in body:\n", "col_exprs.extend([c[0] for c in flat_conditions])\n", "col_exprs.extend([a[1] for a in body['aggregations']])\n", "return set(chain(*[columns_in_expr(ex) for ex in col_exprs]))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "For", "Condition", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_39(VAR_101):...\n", "VAR_101.shellcmd = VAR_81\n", "return VAR_101\n" ]
[ "def decorate(ruleinfo):...\n", "ruleinfo.shellcmd = cmd\n", "return ruleinfo\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_8(self):...\n", "self.create_temp_file()\n", "if self.body is not None:\n", "self.write_body_to_temp_file()\n", "self.open_temp_file()\n", "VAR_19 = self.get_temp_file_data()\n", "if VAR_19 != self.body:\n", "self.body = VAR_19\n", "self.remove_temp_file()\n", "VAR_3 = ('UPDATE jdk_entries ' + \"SET body = '\" + self.body + \"' \" +\n \"WHERE jdk_entries.id = '\" + self.entry_id + \"';\")\n", "return None\n", "FUNC_0(VAR_3)\n", "self.update_date_modified()\n" ]
[ "def edit_entry(self):...\n", "self.create_temp_file()\n", "if self.body is not None:\n", "self.write_body_to_temp_file()\n", "self.open_temp_file()\n", "body_new = self.get_temp_file_data()\n", "if body_new != self.body:\n", "self.body = body_new\n", "self.remove_temp_file()\n", "sql = ('UPDATE jdk_entries ' + \"SET body = '\" + self.body + \"' \" +\n \"WHERE jdk_entries.id = '\" + self.entry_id + \"';\")\n", "return None\n", "db_execute(sql)\n", "self.update_date_modified()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Condition", "Expr'", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Return'", "Expr'", "Expr'" ]
[ "def FUNC_10(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_35 = len(self._target_roots)\n", "self.run_tracker.pantsd_stats.set_target_root_size(VAR_35)\n", "return VAR_35\n" ]
[ "def _set_target_root_count_in_runtracker(self):...\n", "\"\"\"docstring\"\"\"\n", "target_count = len(self._target_roots)\n", "self.run_tracker.pantsd_stats.set_target_root_size(target_count)\n", "return target_count\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_3(self, VAR_2, VAR_9):...\n", "VAR_2 = db.get_dataset(VAR_2)\n", "VAR_1 = db.User.select().where(db.User.email == VAR_9).get()\n", "db.UserAccessLog.create(VAR_1=user, VAR_2=dataset, action='access_revoked')\n" ]
[ "def post(self, dataset, email):...\n", "dataset = db.get_dataset(dataset)\n", "user = db.User.select().where(db.User.email == email).get()\n", "db.UserAccessLog.create(user=user, dataset=dataset, action='access_revoked')\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_8(self, VAR_9, VAR_10=None, VAR_11=None):...\n", "get_and_check_project(VAR_9, VAR_11)\n", "VAR_28 = self.queryset.get(VAR_10=pk, VAR_1=project_pk)\n", "VAR_26 = CLASS_1(VAR_28)\n", "return Response(VAR_26.data)\n" ]
[ "def retrieve(self, request, pk=None, project_pk=None):...\n", "get_and_check_project(request, project_pk)\n", "task = self.queryset.get(pk=pk, project=project_pk)\n", "serializer = TaskSerializer(task)\n", "return Response(serializer.data)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_39(VAR_101):...\n", "VAR_101.params = VAR_71, VAR_72\n", "return VAR_101\n" ]
[ "def decorate(ruleinfo):...\n", "ruleinfo.params = params, kwparams\n", "return ruleinfo\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_9(self):...\n", "url_helper.urllib2.urlopen(mox.IgnoreArg(), mox.IgnoreArg(), timeout=mox.\n IgnoreArg()).AndRaise(urllib2.HTTPError('url', 400, 'error message',\n None, None))\n", "self._mox.ReplayAll()\n", "self.assertIsNone(url_helper.UrlOpen('url', max_tries=10))\n", "self._mox.VerifyAll()\n" ]
[ "def testUrlOpenHTTPErrorNoRetry(self):...\n", "url_helper.urllib2.urlopen(mox.IgnoreArg(), mox.IgnoreArg(), timeout=mox.\n IgnoreArg()).AndRaise(urllib2.HTTPError('url', 400, 'error message',\n None, None))\n", "self._mox.ReplayAll()\n", "self.assertIsNone(url_helper.UrlOpen('url', max_tries=10))\n", "self._mox.VerifyAll()\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "import unittest\n", "from ... import create_app\n", "VAR_0 = FUNC_0('config.TestConfig')\n", "\"\"\"A base test case.\"\"\"\n", "def FUNC_0(self):...\n", "VAR_0.config.from_object('config.TestConfig')\n", "return VAR_0\n" ]
[ "import unittest\n", "from ... import create_app\n", "app = create_app('config.TestConfig')\n", "\"\"\"A base test case.\"\"\"\n", "def create_app(self):...\n", "app.config.from_object('config.TestConfig')\n", "return app\n" ]
[ 4, 4, 4, 4, 0, 4, 4 ]
[ "Import'", "ImportFrom'", "Assign'", "Expr'", "FunctionDef'", "Expr'", "Return'" ]
[ "def FUNC_18(self, VAR_3):...\n", "print('ERROR: database connection is down (error: {0})'.format(VAR_3.value))\n", "return DeadConnectionDetector.startReconnecting(self, VAR_3)\n" ]
[ "def startReconnecting(self, f):...\n", "print('ERROR: database connection is down (error: {0})'.format(f.value))\n", "return DeadConnectionDetector.startReconnecting(self, f)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Return'" ]
[ "def FUNC_0(VAR_6):...\n", "@wraps(VAR_6)...\n", "if 'logged_in' in VAR_10:\n", "return VAR_6(*VAR_8, **kwargs)\n", "flash('Unauthorized, Please login', 'danger')\n", "return redirect(url_for('login'))\n" ]
[ "def is_logged_in(f):...\n", "@wraps(f)...\n", "if 'logged_in' in session:\n", "return f(*args, **kwargs)\n", "flash('Unauthorized, Please login', 'danger')\n", "return redirect(url_for('login'))\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Return'", "Expr'", "Return'" ]
[ "def FUNC_2(VAR_3):...\n", "return VAR_3 if VAR_3 and VAR_4.match(VAR_3) else None\n" ]
[ "def chkpass(x):...\n", "return x if x and pass_rx.match(x) else None\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_0(self, VAR_4=None, VAR_5=None, VAR_6=True):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_6 and self.load_cookies():\n", "if self.check_login():\n", "VAR_7 = self.session.headers.copy()\n", "return True\n", "VAR_7.update({'authorization': 'oauth c3cef7c66a1843f8b3a9e6a1e3160e20',\n 'X-Xsrftoken': self._get_token()})\n", "VAR_4, VAR_5 = self._check_user_pass(VAR_4, VAR_5)\n", "self.login_data.update({'username': VAR_4, 'password': VAR_5})\n", "VAR_8 = str(int(time.time() * 1000))\n", "self.login_data.update({'captcha': self._get_captcha(VAR_7), 'timestamp':\n VAR_8, 'signature': self._get_signature(VAR_8)})\n", "VAR_10 = self.session.post(self.login_api, data=self.login_data, VAR_7=headers)\n", "if 'error' in VAR_10.text:\n", "print(re.findall('\"message\":\"(.+?)\"', VAR_10.text)[0])\n", "if self.check_login():\n", "print('登录失败')\n", "return True\n", "return False\n" ]
[ "def login(self, username=None, password=None, load_cookies=True):...\n", "\"\"\"docstring\"\"\"\n", "if load_cookies and self.load_cookies():\n", "if self.check_login():\n", "headers = self.session.headers.copy()\n", "return True\n", "headers.update({'authorization': 'oauth c3cef7c66a1843f8b3a9e6a1e3160e20',\n 'X-Xsrftoken': self._get_token()})\n", "username, password = self._check_user_pass(username, password)\n", "self.login_data.update({'username': username, 'password': password})\n", "timestamp = str(int(time.time() * 1000))\n", "self.login_data.update({'captcha': self._get_captcha(headers), 'timestamp':\n timestamp, 'signature': self._get_signature(timestamp)})\n", "resp = self.session.post(self.login_api, data=self.login_data, headers=headers)\n", "if 'error' in resp.text:\n", "print(re.findall('\"message\":\"(.+?)\"', resp.text)[0])\n", "if self.check_login():\n", "print('登录失败')\n", "return True\n", "return False\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Condition", "Assign'", "Return'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Return'", "Return'" ]
[ "def FUNC_12(self):...\n", "\"\"\"docstring\"\"\"\n", "return self.to_bytes().decode('ascii')\n" ]
[ "def to_str(self):...\n", "\"\"\"docstring\"\"\"\n", "return self.to_bytes().decode('ascii')\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "from flask import render_template, redirect, url_for, request, flash, abort, Markup, send_from_directory\n", "from app import app, fbdb\n", "from .forms import ProcessingForm, FILE_MAP\n", "from . import utils\n", "from shutil import copyfile, rmtree\n", "import os\n", "import tempfile\n", "import requests\n", "import subprocess as sub\n", "@app.route('/')...\n", "return render_template('index.html', title='GenSET')\n" ]
[ "from flask import render_template, redirect, url_for, request, flash, abort, Markup, send_from_directory\n", "from app import app, fbdb\n", "from .forms import ProcessingForm, FILE_MAP\n", "from . import utils\n", "from shutil import copyfile, rmtree\n", "import os\n", "import tempfile\n", "import requests\n", "import subprocess as sub\n", "@app.route('/')...\n", "return render_template('index.html', title='GenSET')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Import'", "Import'", "Import'", "Condition", "Return'" ]
[ "def FUNC_39(VAR_101):...\n", "VAR_101.version = VAR_78\n", "return VAR_101\n" ]
[ "def decorate(ruleinfo):...\n", "ruleinfo.version = version\n", "return ruleinfo\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_6(self, VAR_64):...\n", "VAR_90 = VAR_64.split(',')\n", "return Thing._by_fullname(VAR_90, data=True, return_dict=False)\n" ]
[ "def run(self, id_str):...\n", "tids = id_str.split(',')\n", "return Thing._by_fullname(tids, data=True, return_dict=False)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_5(self):...\n", "" ]
[ "def _check_children_depth(self):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]