lines listlengths 1 383 | raw_lines listlengths 1 383 | label listlengths 1 383 | type listlengths 1 383 |
|---|---|---|---|
[
"def FUNC_4(VAR_1: Any) ->str:...\n",
"assert isinstance(VAR_1, type), repr(VAR_1)\n",
"if VAR_1.__module__.startswith('pytorch_lightning.'):\n",
"return f'pl.{VAR_1.__name__}'\n",
"return f'{VAR_1.__module__}.{VAR_1.__qualname__}'\n"
] | [
"def _get_abbrev_qualified_cls_name(cls: Any) ->str:...\n",
"assert isinstance(cls, type), repr(cls)\n",
"if cls.__module__.startswith('pytorch_lightning.'):\n",
"return f'pl.{cls.__name__}'\n",
"return f'{cls.__module__}.{cls.__qualname__}'\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assert'",
"Condition",
"Return'",
"Return'"
] |
[
"@VAR_2.route('/ajax/simulatedbchange', methods=['POST'])...\n",
"VAR_84, VAR_85 = FUNC_47()\n",
"return Response(json.dumps({'change': VAR_84, 'valid': VAR_85}), mimetype=\n 'application/json')\n"
] | [
"@admi.route('/ajax/simulatedbchange', methods=['POST'])...\n",
"db_change, db_valid = _db_simulate_change()\n",
"return Response(json.dumps({'change': db_change, 'valid': db_valid}),\n mimetype='application/json')\n"
] | [
0,
0,
0
] | [
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_47(self, VAR_12):...\n",
"VAR_22, VAR_23 = self.make_request('GET',\n '/_matrix/client/r0/rooms/{}/state/m.room.member/{}'.format(self.\n room_id, self.second_user_id), VAR_16=self.creator_tok)\n",
"self.assertEqual(VAR_23.code, 200, VAR_23.result)\n",
"VAR_57 = VAR_23.json_body\n",
"self.as... | [
"def _check_for_reason(self, reason):...\n",
"request, channel = self.make_request('GET',\n '/_matrix/client/r0/rooms/{}/state/m.room.member/{}'.format(self.\n room_id, self.second_user_id), access_token=self.creator_tok)\n",
"self.assertEqual(channel.code, 200, channel.result)\n",
"event_content = chan... | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_1(VAR_6: list[FavaLedger]) ->None:...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_38: dict[str, FavaLedger] = {}\n",
"for VAR_5 in VAR_6:\n",
"VAR_36 = FUNC_0(VAR_5)\n",
"VAR_1.config['LEDGERS'] = VAR_38\n",
"VAR_37 = next_key(VAR_36, VAR_38)\n",
"VAR_38[VAR_37] = VAR_5\n"
] | [
"def update_ledger_slugs(ledgers: list[FavaLedger]) ->None:...\n",
"\"\"\"docstring\"\"\"\n",
"ledgers_by_slug: dict[str, FavaLedger] = {}\n",
"for ledger in ledgers:\n",
"slug = ledger_slug(ledger)\n",
"app.config['LEDGERS'] = ledgers_by_slug\n",
"unique_key = next_key(slug, ledgers_by_slug)\n",
"led... | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"AnnAssign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_118(VAR_120=None):...\n",
"VAR_184 = {}\n",
"for VAR_219 in ([VAR_120] if VAR_120 else FUNC_64(VAR_122=True)):\n",
"VAR_219 = 'frappe' if VAR_219 == 'webnotes' else VAR_219\n",
"return VAR_184\n",
"VAR_226 = FUNC_55(VAR_219 + '.hooks')\n",
"if VAR_1.flags.in_install_app:\n",
"for VAR_46 in d... | [
"def load_app_hooks(app_name=None):...\n",
"hooks = {}\n",
"for app in ([app_name] if app_name else get_installed_apps(sort=True)):\n",
"app = 'frappe' if app == 'webnotes' else app\n",
"return hooks\n",
"app_hooks = get_module(app + '.hooks')\n",
"if local.flags.in_install_app:\n",
"for key in dir(ap... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Assign'",
"Return'",
"Assign'",
"Condition",
"For",
"Expr'",
"Condition",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_51(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self._doc_before_save = None\n",
"if not self.is_new():\n",
"self._doc_before_save = frappe.get_doc(self.doctype, self.name)\n",
"self._doc_before_save = None\n",
"frappe.clear_last_message()\n"
] | [
"def load_doc_before_save(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self._doc_before_save = None\n",
"if not self.is_new():\n",
"self._doc_before_save = frappe.get_doc(self.doctype, self.name)\n",
"self._doc_before_save = None\n",
"frappe.clear_last_message()\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_1(VAR_0, VAR_1: FlaskClient):...\n",
"VAR_0.config['THEME_CONF']['use_custom_css'] = True\n",
"VAR_6 = 'custom.css'\n",
"VAR_7 = \"\"\"\n body {\n color: red\n }\n \"\"\"\n",
"os.mkdir(f\"{VAR_0.config['USER_DIR']}/css/\")\n",
"f.write(VAR_7)\n",
"VAR_0.config['THEM... | [
"def test_get_custom_css(test_app, client: FlaskClient):...\n",
"test_app.config['THEME_CONF']['use_custom_css'] = True\n",
"css_file = 'custom.css'\n",
"css_contents = \"\"\"\n body {\n color: red\n }\n \"\"\"\n",
"os.mkdir(f\"{test_app.config['USER_DIR']}/css/\")\n",
"f.write... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assert'",
"Assign'"
] |
[
"def FUNC_33(VAR_30, VAR_35='\\n'):...\n",
"print(VAR_29 + VAR_30, VAR_35=end)\n"
] | [
"def in_print(s, end='\\n'):...\n",
"print(indent_str + s, end=end)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def __init__(self, VAR_26: str, VAR_27: Callable[..., Any], *, VAR_29:...\n",
"if isinstance(VAR_13, enum.IntEnum):\n",
"VAR_13 = int(VAR_13)\n",
"self.path = VAR_26\n",
"self.endpoint = VAR_27\n",
"self.name = get_name(VAR_27) if VAR_28 is None else VAR_28\n",
"self.path_regex, self.path_format, self.... | [
"def __init__(self, path: str, endpoint: Callable[..., Any], *,...\n",
"if isinstance(status_code, enum.IntEnum):\n",
"status_code = int(status_code)\n",
"self.path = path\n",
"self.endpoint = endpoint\n",
"self.name = get_name(endpoint) if name is None else name\n",
"self.path_regex, self.path_format, ... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"AnnAssign'",
"Assign'",
"Assign'",
"Condition",
"Assert'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"AnnAssign'",
"Assign'",
"Condition",
"Assign'",
"... |
[
"@defer.inlineCallbacks...\n",
"VAR_18 = yield FUNC_7(VAR_11)\n",
"for member in VAR_18:\n",
"if VAR_14 is not None and member == VAR_14:\n",
"if VAR_6.is_mine(member):\n",
"if VAR_12 is not None:\n",
"if VAR_13 is not None:\n",
"VAR_12.add(member)\n",
"VAR_13.add(member.domain)\n"
] | [
"@defer.inlineCallbacks...\n",
"members = yield get_room_members(room_id)\n",
"for member in members:\n",
"if ignore_user is not None and member == ignore_user:\n",
"if hs.is_mine(member):\n",
"if localusers is not None:\n",
"if remotedomains is not None:\n",
"localusers.add(member)\n",
"remotedomai... | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"For",
"Condition",
"Condition",
"Condition",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_3(self):...\n",
"VAR_10 = self.get_success(self.handler.check_device_registered(VAR_5=\n '@boris:foo', VAR_6='fco', initial_device_display_name='display name'))\n",
"self.assertEqual(VAR_10, 'fco')\n",
"VAR_11 = self.get_success(self.handler.store.get_device('@boris:foo', 'fco'))\n",
"self.asse... | [
"def test_device_is_created_if_doesnt_exist(self):...\n",
"res = self.get_success(self.handler.check_device_registered(user_id=\n '@boris:foo', device_id='fco', initial_device_display_name='display name'))\n",
"self.assertEqual(res, 'fco')\n",
"dev = self.get_success(self.handler.store.get_device('@boris:f... | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"@VAR_2.route('/ajax/listbooks')...\n",
"VAR_79 = int(request.args.get('offset') or 0)\n",
"VAR_19 = int(request.args.get('limit') or config.config_books_per_page)\n",
"VAR_80 = request.args.get('search')\n",
"VAR_7 = request.args.get('sort', 'id')\n",
"VAR_10 = request.args.get('order', '').lower()\n",
... | [
"@web.route('/ajax/listbooks')...\n",
"off = int(request.args.get('offset') or 0)\n",
"limit = int(request.args.get('limit') or config.config_books_per_page)\n",
"search = request.args.get('search')\n",
"sort = request.args.get('sort', 'id')\n",
"order = request.args.get('order', '').lower()\n",
"state ... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
... |
[
"def __init__(self, VAR_3=None):...\n",
"VAR_28 = {'class': 'vCommaSeparatedIntegerField'}\n",
"if VAR_3 is not None:\n",
"VAR_28.update(VAR_3)\n",
"super(CLASS_16, self).__init__(VAR_3=final_attrs)\n"
] | [
"def __init__(self, attrs=None):...\n",
"final_attrs = {'class': 'vCommaSeparatedIntegerField'}\n",
"if attrs is not None:\n",
"final_attrs.update(attrs)\n",
"super(AdminCommaSeparatedIntegerFieldWidget, self).__init__(attrs=final_attrs)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_32(VAR_87):...\n",
"VAR_86.update(to_bytes(VAR_87, encoding='utf-8', errors='replace'))\n"
] | [
"def hash_update(value):...\n",
"hash.update(to_bytes(value, encoding='utf-8', errors='replace'))\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_9(self):...\n",
"if not self.get('roles') and self.is_standard == 'No':\n",
"VAR_5 = frappe.get_meta(self.ref_doctype)\n",
"if not VAR_5.istable:\n",
"VAR_35 = [{'role': d.role} for d in VAR_5.permissions if d.permlevel == 0]\n",
"self.set('roles', VAR_35)\n"
] | [
"def set_doctype_roles(self):...\n",
"if not self.get('roles') and self.is_standard == 'No':\n",
"meta = frappe.get_meta(self.ref_doctype)\n",
"if not meta.istable:\n",
"roles = [{'role': d.role} for d in meta.permissions if d.permlevel == 0]\n",
"self.set('roles', roles)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Expr'"
] |
[
"def FUNC_10(VAR_0, VAR_1):...\n",
"self.query_handlers[VAR_0] = VAR_1\n"
] | [
"def register_query_handler(query_type, handler):...\n",
"self.query_handlers[query_type] = handler\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"def FUNC_26(VAR_9, VAR_13, VAR_10):...\n",
""
] | [
"def render_language_books(page, name, order):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def __unicode__(self):...\n",
"return f\"<Text '{self.offendingText}' shows up in both lt and local-lt>\"\n"
] | [
"def __unicode__(self):...\n",
"return f\"<Text '{self.offendingText}' shows up in both lt and local-lt>\"\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_0(self, VAR_2, VAR_3):...\n",
"VAR_4 = self.setup_test_homeserver('server', http_client=None)\n",
"self.handler = VAR_4.get_device_handler()\n",
"self.registration = VAR_4.get_registration_handler()\n",
"self.auth = VAR_4.get_auth()\n",
"self.store = VAR_4.get_datastore()\n",
"return VAR_4\n"
... | [
"def make_homeserver(self, reactor, clock):...\n",
"hs = self.setup_test_homeserver('server', http_client=None)\n",
"self.handler = hs.get_device_handler()\n",
"self.registration = hs.get_registration_handler()\n",
"self.auth = hs.get_auth()\n",
"self.store = hs.get_datastore()\n",
"return hs\n"
] | [
0,
4,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@VAR_1.route('/ajax/delete/<int:book_id>')...\n",
"return Response(FUNC_13(VAR_15, '', True), mimetype='application/json')\n"
] | [
"@editbook.route('/ajax/delete/<int:book_id>')...\n",
"return Response(delete_book(book_id, '', True), mimetype='application/json')\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_0(self):...\n",
"VAR_5 = super().default_config()\n",
"VAR_5['send_federation'] = False\n",
"return VAR_5\n"
] | [
"def default_config(self):...\n",
"conf = super().default_config()\n",
"conf['send_federation'] = False\n",
"return conf\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"async def FUNC_17(VAR_46: 'TrainingDataImporter', VAR_21: Union[Path, Text]...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_18 = Path(VAR_21) / DEFAULT_CORE_SUBDIRECTORY_NAME\n",
"VAR_52 = await VAR_46.get_domain()\n",
"VAR_52.persist(VAR_18 / DEFAULT_DOMAIN_PATH)\n"
] | [
"async def update_model_with_new_domain(importer: 'TrainingDataImporter',...\n",
"\"\"\"docstring\"\"\"\n",
"model_path = Path(unpacked_model_path) / DEFAULT_CORE_SUBDIRECTORY_NAME\n",
"domain = await importer.get_domain()\n",
"domain.persist(model_path / DEFAULT_DOMAIN_PATH)\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_11(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = self._make_request(b'GET', b'/res/')\n",
"self.assertEqual(VAR_6.result['code'], b'200')\n",
"self.assertEqual(VAR_6.result['body'], b'/res/')\n"
] | [
"def test_known_request(self):...\n",
"\"\"\"docstring\"\"\"\n",
"channel = self._make_request(b'GET', b'/res/')\n",
"self.assertEqual(channel.result['code'], b'200')\n",
"self.assertEqual(channel.result['body'], b'/res/')\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def __str__(self):...\n",
"return '%s' % self.title\n"
] | [
"def __str__(self):...\n",
"return '%s' % self.title\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@wraps(VAR_10)...\n",
"VAR_1 = self.__class__\n",
"if VAR_2:\n",
"VAR_42 = [arg[0] for arg in FUNC_3(VAR_1)]\n",
"VAR_39 = vars(FUNC_2(VAR_1))\n",
"VAR_3.update(dict(zip(VAR_42, VAR_2)))\n",
"VAR_3 = dict(list(VAR_39.items()) + list(VAR_3.items()))\n",
"return VAR_10(self, **kwargs)\n"
] | [
"@wraps(fn)...\n",
"cls = self.__class__\n",
"if args:\n",
"cls_arg_names = [arg[0] for arg in get_init_arguments_and_types(cls)]\n",
"env_variables = vars(parse_env_variables(cls))\n",
"kwargs.update(dict(zip(cls_arg_names, args)))\n",
"kwargs = dict(list(env_variables.items()) + list(kwargs.items()))\... | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_7(self):...\n",
"return self.spec\n"
] | [
"def get_repo_url(self):...\n",
"return self.spec\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"from __future__ import unicode_literals\n",
"from django import template\n",
"from djblets.gravatars import get_gravatar_url, get_gravatar_url_for_email\n",
"from djblets.util.decorators import basictag\n",
"VAR_0 = template.Library()\n",
"@VAR_0.tag...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_5 = get_gra... | [
"from __future__ import unicode_literals\n",
"from django import template\n",
"from djblets.gravatars import get_gravatar_url, get_gravatar_url_for_email\n",
"from djblets.util.decorators import basictag\n",
"register = template.Library()\n",
"@register.tag...\n",
"\"\"\"docstring\"\"\"\n",
"url = get... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Condition",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_140(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.wiki_menu_items and self.settings.controller and self.settings.function:\n",
"self.wiki_menu_items = self.menu(self.settings.controller, self.settings.\n function)\n",
"VAR_263.response.menu += self.wiki_menu_items\n"
] | [
"def automenu(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.wiki_menu_items and self.settings.controller and self.settings.function:\n",
"self.wiki_menu_items = self.menu(self.settings.controller, self.settings.\n function)\n",
"current.response.menu += self.wiki_menu_items\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"AugAssign'"
] |
[
"@app.route('/plugin_assets/<string:name>/<path:filename>')...\n",
"return redirect(url_for('plugin.' + VAR_23 + '.static', VAR_32=filename))\n"
] | [
"@app.route('/plugin_assets/<string:name>/<path:filename>')...\n",
"return redirect(url_for('plugin.' + name + '.static', filename=filename))\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_1(self, VAR_3, VAR_4, VAR_11):...\n",
"self.user_id = self.register_user('user', 'password')\n",
"self.tok = self.login('user', 'password')\n",
"self.room_id = self.helper.create_room_as(self.user_id, VAR_52=self.tok,\n is_public=False)\n",
"self.other_user_id = self.register_user('user2', 'pas... | [
"def prepare(self, reactor, clock, homeserver):...\n",
"self.user_id = self.register_user('user', 'password')\n",
"self.tok = self.login('user', 'password')\n",
"self.room_id = self.helper.create_room_as(self.user_id, tok=self.tok,\n is_public=False)\n",
"self.other_user_id = self.register_user('user2', ... | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@app.after_request...\n",
"VAR_1.headers['Content-Security-Policy'\n ] = \"default-src 'self' 'unsafe-inline' 'unsafe-eval';\"\n",
"if request.endpoint == 'editbook.edit_book':\n",
"VAR_1.headers['Content-Security-Policy'] += 'img-src * data:'\n",
"VAR_1.headers['X-Content-Type-Options'] = 'nosniff'\n",... | [
"@app.after_request...\n",
"resp.headers['Content-Security-Policy'\n ] = \"default-src 'self' 'unsafe-inline' 'unsafe-eval';\"\n",
"if request.endpoint == 'editbook.edit_book':\n",
"resp.headers['Content-Security-Policy'] += 'img-src * data:'\n",
"resp.headers['X-Content-Type-Options'] = 'nosniff'\n",
... | [
0,
3,
0,
3,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"AugAssign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_23(self):...\n",
"VAR_5 = self._makeContext()\n",
"self.assertEqual(VAR_5.evaluate('path: '), None)\n"
] | [
"def test_empty_path_expression_explicit_with_trailing_whitespace(self):...\n",
"ec = self._makeContext()\n",
"self.assertEqual(ec.evaluate('path: '), None)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_1(VAR_1, VAR_2=False):...\n",
"\"\"\"docstring\"\"\"\n",
"for hook in VAR_25.get_hooks('override_whitelisted_methods', {}).get(VAR_1, []\n",
"VAR_1 = hook\n",
"if run_server_script_api(VAR_1):\n",
"return None\n",
"VAR_3 = FUNC_11(VAR_1)\n",
"if VAR_25.local.conf.developer_mode:\n",
"if VA... | [
"def execute_cmd(cmd, from_async=False):...\n",
"\"\"\"docstring\"\"\"\n",
"for hook in frappe.get_hooks('override_whitelisted_methods', {}).get(cmd, []):\n",
"cmd = hook\n",
"if run_server_script_api(cmd):\n",
"return None\n",
"method = get_attr(cmd)\n",
"if frappe.local.conf.developer_mode:\n",
"i... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
2,
0
] | [
"FunctionDef'",
"Docstring",
"For",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Return'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_19(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.assigned_to:\n",
"return _('Unassigned')\n",
"if self.assigned_to.get_full_name():\n",
"return self.assigned_to.get_full_name()\n",
"return self.assigned_to.get_username()\n"
] | [
"def _get_assigned_to(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.assigned_to:\n",
"return _('Unassigned')\n",
"if self.assigned_to.get_full_name():\n",
"return self.assigned_to.get_full_name()\n",
"return self.assigned_to.get_username()\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_9(VAR_18, VAR_19, VAR_20, VAR_21):...\n",
"VAR_69 = settings().getBoolean(['server', 'firstRun'])\n",
"VAR_70 = {}\n",
"for VAR_131 in LOCALES:\n",
"VAR_41 = [permission.as_dict() for permission in Permissions.all()]\n",
"VAR_70[VAR_131.language] = {'language': VAR_131.language, 'display':\n ... | [
"def _get_render_kwargs(templates, plugin_names, plugin_vars, now):...\n",
"first_run = settings().getBoolean(['server', 'firstRun'])\n",
"locales = {}\n",
"for loc in LOCALES:\n",
"permissions = [permission.as_dict() for permission in Permissions.all()]\n",
"locales[loc.language] = {'language': loc.langu... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_49():...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_3 = FUNC_5()\n",
"update_all_languages(apath(VAR_3, VAR_122=request))\n",
"session.flash = T('Language files (static strings) updated')\n",
"redirect(URL('design', VAR_98=app, VAR_157='languages'))\n"
] | [
"def update_languages():...\n",
"\"\"\"docstring\"\"\"\n",
"app = get_app()\n",
"update_all_languages(apath(app, r=request))\n",
"session.flash = T('Language files (static strings) updated')\n",
"redirect(URL('design', args=app, anchor='languages'))\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_22(self):...\n",
"assert join('/', '/') == '/'\n",
"assert join(None, '/') == '/'\n",
"assert join('/', None) == '/'\n"
] | [
"def test_it_doesnt_eat_single_slash(self):...\n",
"assert join('/', '/') == '/'\n",
"assert join(None, '/') == '/'\n",
"assert join('/', None) == '/'\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assert'",
"Assert'",
"Assert'"
] |
[
"def FUNC_0(VAR_0):...\n",
"VAR_1 = os.path.dirname(os.path.abspath(__file__))\n",
"return open(os.path.join(VAR_1, VAR_0)).read()\n"
] | [
"def _read(fname):...\n",
"here = os.path.dirname(os.path.abspath(__file__))\n",
"return open(os.path.join(here, fname)).read()\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_15(self):...\n",
"VAR_26 = np.array([[1], [2]])\n",
"VAR_31 = os.path.join(test.get_temp_dir(), 'input.npz')\n",
"np.savez(VAR_31, VAR_53=x0)\n",
"VAR_20 = 'x=' + VAR_31 + '[a];y=' + VAR_31\n",
"VAR_30 = saved_model_cli.load_inputs_from_input_arg_string(VAR_20, '', '')\n",
"self.assertTrue(np.... | [
"def testInputParserNPZ(self):...\n",
"x0 = np.array([[1], [2]])\n",
"input_path = os.path.join(test.get_temp_dir(), 'input.npz')\n",
"np.savez(input_path, a=x0)\n",
"input_str = 'x=' + input_path + '[a];y=' + input_path\n",
"feed_dict = saved_model_cli.load_inputs_from_input_arg_string(input_str, '', ''\... | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_26(VAR_37, VAR_38):...\n",
"VAR_76 = FUNC_25(VAR_38 + '/v1/tunnel-request' if VAR_38 is not None else VAR_3\n )\n",
"if VAR_76 and VAR_76.code == 200:\n",
"VAR_97 = json.loads(VAR_76.read().decode('utf-8'))[0]\n",
"return create_tunnel(VAR_97, VAR_2, VAR_37)\n"
] | [
"def setup_tunnel(local_server_port, endpoint):...\n",
"response = url_request(endpoint + '/v1/tunnel-request' if endpoint is not\n None else GRADIO_API_SERVER)\n",
"if response and response.code == 200:\n",
"payload = json.loads(response.read().decode('utf-8'))[0]\n",
"return create_tunnel(payload, LOCA... | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_5(self, VAR_24):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_79 = []\n",
"VAR_79.append(('/deprecatedwidgets/(.*)', CLASS_0))\n",
"VAR_79.extend(FUNC_1('tree.handlers'))\n",
"VAR_79.extend([('/login', VAR_24['login_handler_class'])])\n",
"VAR_79.extend([('/logout', VAR_24['logout_handler_class'])])... | [
"def init_handlers(self, settings):...\n",
"\"\"\"docstring\"\"\"\n",
"handlers = []\n",
"handlers.append(('/deprecatedwidgets/(.*)', DeprecationHandler))\n",
"handlers.extend(load_handlers('tree.handlers'))\n",
"handlers.extend([('/login', settings['login_handler_class'])])\n",
"handlers.extend([('/log... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Import'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Ass... |
[
"@app.after_request...\n",
"VAR_1.headers['Content-Security-Policy'] = (\"default-src 'self'\" + ''.join(\n [(' ' + host) for host in config.config_trustedhosts.strip().split(',')\n ]) +\n \" 'unsafe-inline' 'unsafe-eval'; font-src 'self' data:; img-src 'self' data:\"\n )\n",
"if request.endpoint ==... | [
"@app.after_request...\n",
"resp.headers['Content-Security-Policy'] = (\"default-src 'self'\" + ''.join([\n (' ' + host) for host in config.config_trustedhosts.strip().split(',')]\n ) +\n \" 'unsafe-inline' 'unsafe-eval'; font-src 'self' data:; img-src 'self' data:\"\n )\n",
"if request.endpoint == ... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"AugAssign'",
"Condition",
"Assign'",
"AugAssign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@VAR_0.route('/plugins')...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_110 = VAR_8\n",
"flash(str(err), 'danger')\n",
"return render_template('plugins.html', VAR_110=plugins_info)\n",
"return redirect(url_for('dashboard'))\n"
] | [
"@gui.route('/plugins')...\n",
"\"\"\"docstring\"\"\"\n",
"plugins_info = plugins\n",
"flash(str(err), 'danger')\n",
"return render_template('plugins.html', plugins_info=plugins_info)\n",
"return redirect(url_for('dashboard'))\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Expr'",
"Return'",
"Return'"
] |
[
"def FUNC_121(*VAR_79, **VAR_42):...\n",
"if VAR_13.read_from_replica:\n",
"FUNC_6()\n",
"VAR_225 = VAR_129(*VAR_79, **get_newargs(fn, kwargs))\n",
"if VAR_1 and hasattr(VAR_1, 'primary_db'):\n",
"return VAR_225\n",
"VAR_1.db.close()\n",
"VAR_1.db = VAR_1.primary_db\n"
] | [
"def wrapper_fn(*args, **kwargs):...\n",
"if conf.read_from_replica:\n",
"connect_replica()\n",
"retval = fn(*args, **get_newargs(fn, kwargs))\n",
"if local and hasattr(local, 'primary_db'):\n",
"return retval\n",
"local.db.close()\n",
"local.db = local.primary_db\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Return'",
"Expr'",
"Assign'"
] |
[
"def FUNC_2(self):...\n",
"VAR_9 = test.test_src_dir_path(VAR_0)\n",
"self.parser = saved_model_cli.create_parser()\n",
"VAR_10 = self.parser.parse_args(['show', '--dir', VAR_9, '--all'])\n",
"saved_model_cli.show(VAR_10)\n",
"VAR_11 = out.getvalue().strip()\n",
"VAR_12 = 'string'\n",
"self.maxDiff = ... | [
"def testShowCommandAll(self):...\n",
"base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n",
"self.parser = saved_model_cli.create_parser()\n",
"args = self.parser.parse_args(['show', '--dir', base_path, '--all'])\n",
"saved_model_cli.show(args)\n",
"output = out.getvalue().strip()\n",
"exp_out = \"\... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_18(VAR_5):...\n",
"if VAR_5 != '0':\n",
"if not calibre_db.session.query(db.Custom_Columns).filter(db.Custom_Columns\n",
"return True\n",
"return False\n"
] | [
"def check_valid_read_column(column):...\n",
"if column != '0':\n",
"if not calibre_db.session.query(db.Custom_Columns).filter(db.Custom_Columns\n",
"return True\n",
"return False\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_27(VAR_10, VAR_11):...\n",
"VAR_69 = VAR_11()\n",
"if VAR_69 == ['']:\n",
"VAR_69 = []\n",
"if not VAR_10['add_element'] in VAR_69:\n",
"VAR_69 += [VAR_10['add_element']]\n",
"return ','.join(VAR_69)\n"
] | [
"def restriction_addition(element, list_func):...\n",
"elementlist = list_func()\n",
"if elementlist == ['']:\n",
"elementlist = []\n",
"if not element['add_element'] in elementlist:\n",
"elementlist += [element['add_element']]\n",
"return ','.join(elementlist)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"AugAssign'",
"Return'"
] |
[
"@defer.inlineCallbacks...\n",
"VAR_4 = defer.ensureDeferred(self.handler.set_displayname(self.frank,\n synapse.types.create_requester(self.bob), 'Frank Jr.'))\n",
"yield self.assertFailure(VAR_4, AuthError)\n"
] | [
"@defer.inlineCallbacks...\n",
"d = defer.ensureDeferred(self.handler.set_displayname(self.frank, synapse.\n types.create_requester(self.bob), 'Frank Jr.'))\n",
"yield self.assertFailure(d, AuthError)\n"
] | [
0,
0,
0
] | [
"Condition",
"Assign'",
"Expr'"
] |
[
"@property...\n",
"return ''.join(self.rawLines)\n"
] | [
"@property...\n",
"return ''.join(self.rawLines)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def __repr__(self):...\n",
"return '<User %r>' % self.name\n"
] | [
"def __repr__(self):...\n",
"return '<User %r>' % self.name\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_35(self):...\n",
"self.login()\n",
"VAR_3 = self.client.post('/password_change/custom/', {'old_password':\n 'password', 'new_password1': 'password1', 'new_password2': 'password1'})\n",
"self.assertEqual(VAR_3.status_code, 302)\n",
"self.assertURLEqual(VAR_3.url, '/custom/')\n"
] | [
"def test_password_change_redirect_custom(self):...\n",
"self.login()\n",
"response = self.client.post('/password_change/custom/', {'old_password':\n 'password', 'new_password1': 'password1', 'new_password2': 'password1'})\n",
"self.assertEqual(response.status_code, 302)\n",
"self.assertURLEqual(response... | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = FUNC_1('/groups/%s/roles/%s', VAR_30, VAR_34)\n",
"return self.client.get_json(VAR_5=destination, VAR_2=path, VAR_3={\n 'requester_user_id': requester_user_id}, VAR_15=True)\n"
] | [
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"path = _create_v1_path('/groups/%s/roles/%s', group_id, role_id)\n",
"return self.client.get_json(destination=destination, path=path, args={\n 'requester_user_id': requester_user_id}, ignore_backoff=True)\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'"
] |
[
"def FUNC_74(self, VAR_44=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_77 = self.get_signature()\n",
"if file_lock.lock_exists(VAR_77):\n",
"VAR_96 = True\n",
"file_lock.create_lock(VAR_77)\n",
"if VAR_44:\n",
"for i in range(VAR_44):\n",
"if VAR_96:\n",
"time.sleep(1)\n",
"if not file_lock.loc... | [
"def lock(self, timeout=None):...\n",
"\"\"\"docstring\"\"\"\n",
"signature = self.get_signature()\n",
"if file_lock.lock_exists(signature):\n",
"lock_exists = True\n",
"file_lock.create_lock(signature)\n",
"if timeout:\n",
"for i in range(timeout):\n",
"if lock_exists:\n",
"time.sleep(1)\n",
"i... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"For",
"Condition",
"Expr'",
"Condition",
"Assign'"
] |
[
"@defer.inlineCallbacks...\n",
"VAR_50 = yield VAR_4.verify_json_for_server(*VAR_2)\n",
"return VAR_50\n"
] | [
"@defer.inlineCallbacks...\n",
"rv1 = yield kr.verify_json_for_server(*args)\n",
"return rv1\n"
] | [
0,
0,
0
] | [
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_25():...\n",
"return ''\n"
] | [
"def keepalive():...\n",
"return ''\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_24(self, VAR_47: str) ->str:...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.instances:\n",
"return 'master'\n",
"if len(self.instances) == 1:\n",
"return self.instances[0]\n",
"VAR_70 = sha256(VAR_47.encode('utf8')).digest()\n",
"VAR_71 = int.from_bytes(VAR_70, byteorder='little')\n",
"VAR... | [
"def get_instance(self, key: str) ->str:...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.instances:\n",
"return 'master'\n",
"if len(self.instances) == 1:\n",
"return self.instances[0]\n",
"dest_hash = sha256(key.encode('utf8')).digest()\n",
"dest_int = int.from_bytes(dest_hash, byteorder='little')\n",... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_11(VAR_37):...\n",
"VAR_4, VAR_39 = VAR_37\n",
"VAR_25.write(VAR_4)\n",
"return VAR_39\n"
] | [
"def write_to(r):...\n",
"data, response = r\n",
"output_stream.write(data)\n",
"return response\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Return'"
] |
[
"@VAR_2.route('/get_tags_json', methods=['GET'])...\n",
"return calibre_db.get_typeahead(db.Tags, request.args.get('q'), tag_filter=\n tags_filters())\n"
] | [
"@web.route('/get_tags_json', methods=['GET'])...\n",
"return calibre_db.get_typeahead(db.Tags, request.args.get('q'), tag_filter=\n tags_filters())\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_142 = VAR_5.getObject('Image', VAR_26)\n",
"if VAR_142 is None:\n",
"VAR_181 = VAR_142.loadOriginalMetadata()\n",
"VAR_182 = ['[Global Metadata]']\n",
"VAR_182.extend([('%s=%s' % (kv[0], kv[1])) for kv in VAR_181[1]])\n",
"VAR_182.append('[Seri... | [
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"image = conn.getObject('Image', imageId)\n",
"if image is None:\n",
"om = image.loadOriginalMetadata()\n",
"txtLines = ['[Global Metadata]']\n",
"txtLines.extend([('%s=%s' % (kv[0], kv[1])) for kv in om[1]])\n",
"txtLines.append('[Series Metadata]'... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@VAR_1.url_value_preprocessor...\n",
"g.beancount_file_slug = VAR_9.pop('bfile', None) if VAR_9 else None\n",
"if not VAR_1.config.get('LEDGERS'):\n",
"FUNC_2()\n",
"if g.beancount_file_slug:\n",
"if g.beancount_file_slug not in VAR_1.config['LEDGERS']:\n",
"if not any(g.beancount_file_slug == FUNC_0(V... | [
"@app.url_value_preprocessor...\n",
"g.beancount_file_slug = values.pop('bfile', None) if values else None\n",
"if not app.config.get('LEDGERS'):\n",
"_load_file()\n",
"if g.beancount_file_slug:\n",
"if g.beancount_file_slug not in app.config['LEDGERS']:\n",
"if not any(g.beancount_file_slug == ledger_s... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Condition",
"For",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'"
] |
[
"@CLASS_4('backend-warning')...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_20 = jinja.render('backend-warning.html', distribution=version.\n distribution(), Distribution=version.Distribution, version=\n pkg_resources.parse_version, title='Legacy backend warning')\n",
"return 'text/html', VAR_20\n"
] | [
"@add_handler('backend-warning')...\n",
"\"\"\"docstring\"\"\"\n",
"src = jinja.render('backend-warning.html', distribution=version.\n distribution(), Distribution=version.Distribution, version=\n pkg_resources.parse_version, title='Legacy backend warning')\n",
"return 'text/html', src\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'"
] |
[
"def __init__(self, VAR_1=False, VAR_2=False, VAR_3=None, **VAR_4):...\n",
"\"\"\"docstring\"\"\"\n",
"super(CLASS_0, self).__init__(**kwargs)\n",
"self.ignore_login_fail = VAR_1\n",
"self.setGroupContext = VAR_2\n",
"self.login_redirect = VAR_3\n"
] | [
"def __init__(self, ignore_login_fail=False, setGroupContext=False,...\n",
"\"\"\"docstring\"\"\"\n",
"super(login_required, self).__init__(**kwargs)\n",
"self.ignore_login_fail = ignore_login_fail\n",
"self.setGroupContext = setGroupContext\n",
"self.login_redirect = login_redirect\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_34(self):...\n",
"if VAR_53.session['admin']:\n",
"VAR_105 = self.userdb.getUserList()\n",
"return json.dumps({'time': 0, 'userlist': []})\n",
"for VAR_51 in VAR_105:\n",
"if VAR_51['id'] == VAR_53.session['userid']:\n",
"VAR_106 = lambda VAR_51: VAR_51['last_time_online']\n",
"VAR_51['delet... | [
"def api_getuserlist(self):...\n",
"if cherrypy.session['admin']:\n",
"userlist = self.userdb.getUserList()\n",
"return json.dumps({'time': 0, 'userlist': []})\n",
"for user in userlist:\n",
"if user['id'] == cherrypy.session['userid']:\n",
"sortfunc = lambda user: user['last_time_online']\n",
"user['... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Return'",
"For",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"@CLASS_4('tabs')...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_21 = collections.defaultdict(list)\n",
"for win_id, window in objreg.window_registry.items():\n",
"if sip.isdeleted(window):\n",
"VAR_20 = jinja.render('tabs.html', title='Tabs', tab_list_by_window=tabs)\n",
"VAR_33 = objreg.get('tabbed-browser', ... | [
"@add_handler('tabs')...\n",
"\"\"\"docstring\"\"\"\n",
"tabs = collections.defaultdict(list)\n",
"for win_id, window in objreg.window_registry.items():\n",
"if sip.isdeleted(window):\n",
"html = jinja.render('tabs.html', title='Tabs', tab_list_by_window=tabs)\n",
"tabbed_browser = objreg.get('tabbed-br... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"For",
"Condition",
"Assign'",
"Assign'",
"Return'",
"For",
"Condition",
"Assign'",
"Expr'"
] |
[
"def FUNC_14(self, VAR_36):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_36 = self._substitute_comments('', VAR_36)\n",
"VAR_36 = VAR_36.replace('\\\\', '')\n",
"VAR_36 = VAR_6('', VAR_36)\n",
"VAR_36 = VAR_36.lower()\n",
"if 'javascript:' in VAR_36:\n",
"return True\n",
"if 'expression(' in VAR_36:\n",
... | [
"def _has_sneaky_javascript(self, style):...\n",
"\"\"\"docstring\"\"\"\n",
"style = self._substitute_comments('', style)\n",
"style = style.replace('\\\\', '')\n",
"style = _substitute_whitespace('', style)\n",
"style = style.lower()\n",
"if 'javascript:' in style:\n",
"return True\n",
"if 'express... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_41(self, VAR_131=False):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.settings.allow_basic_login:\n",
"return False, False, False\n",
"VAR_258 = VAR_263.request.env.http_authorization\n",
"if VAR_131:\n",
"if callable(VAR_131):\n",
"if not VAR_258 or not VAR_258[:6].lower() == 'basic ':\n"... | [
"def basic(self, basic_auth_realm=False):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.settings.allow_basic_login:\n",
"return False, False, False\n",
"basic = current.request.env.http_authorization\n",
"if basic_auth_realm:\n",
"if callable(basic_auth_realm):\n",
"if not basic or not basic[:6].lowe... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_59(self, VAR_142=100):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.user:\n",
"redirect(self.settings.login_url)\n",
"if not self.settings.bulk_register_enabled:\n",
"return HTTP(404)\n",
"VAR_7 = SQLFORM.factory(VAR_1('subject', 'string', VAR_5=self.messages.\n bulk_invite_subject, VAR_2... | [
"def bulk_register(self, max_emails=100):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.user:\n",
"redirect(self.settings.login_url)\n",
"if not self.settings.bulk_register_enabled:\n",
"return HTTP(404)\n",
"form = SQLFORM.factory(Field('subject', 'string', default=self.messages.\n bulk_invite_subj... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"AugAssign'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_20(VAR_56, VAR_46):...\n",
"return os.path.exists(VAR_56) and os.access(VAR_56, VAR_46\n ) and not os.path.isdir(VAR_56)\n"
] | [
"def _access_check(fn, mode):...\n",
"return os.path.exists(fn) and os.access(fn, mode) and not os.path.isdir(fn)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_11(self):...\n",
"VAR_5 = self._makeContext()\n",
"self.assertTrue(VAR_5.evaluate('x | nothing') is None)\n"
] | [
"def test_evaluate_alternative_first_missing(self):...\n",
"ec = self._makeContext()\n",
"self.assertTrue(ec.evaluate('x | nothing') is None)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_31():...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_3 = FUNC_5()\n",
"VAR_5 = '/'.join(request.args)\n",
"VAR_43.title = request.args[-1]\n",
"VAR_71 = read_dict(apath(VAR_5, VAR_122=request))\n",
"if '__corrupted__' in VAR_71:\n",
"VAR_26 = SPAN(VAR_71['__corrupted__'], VAR_144='error')\n",
"VAR... | [
"def edit_language():...\n",
"\"\"\"docstring\"\"\"\n",
"app = get_app()\n",
"filename = '/'.join(request.args)\n",
"response.title = request.args[-1]\n",
"strings = read_dict(apath(filename, r=request))\n",
"if '__corrupted__' in strings:\n",
"form = SPAN(strings['__corrupted__'], _class='error')\n",... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Expr'",
"For",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Assign'",
... |
[
"def FUNC_17(VAR_16, VAR_17, VAR_18):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_42 = {}\n",
"VAR_43 = FUNC_13(VAR_16)\n",
"VAR_44 = FUNC_14(VAR_17)\n",
"VAR_45 = FUNC_15(VAR_18)\n",
"for VAR_71, (filename, variable_name) in VAR_43.items():\n",
"VAR_70 = np.load(file_io.FileIO(filename, mode='rb'), allow_... | [
"def load_inputs_from_input_arg_string(inputs_str, input_exprs_str,...\n",
"\"\"\"docstring\"\"\"\n",
"tensor_key_feed_dict = {}\n",
"inputs = preprocess_inputs_arg_string(inputs_str)\n",
"input_exprs = preprocess_input_exprs_arg_string(input_exprs_str)\n",
"input_examples = preprocess_input_examples_arg_... | [
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"For",
"Condition",
"Condition",
"For",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Return'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"As... |
[
"def FUNC_9(self, *VAR_4, **VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_54 = VAR_4[0] if VAR_4 else ''\n",
"if not VAR_54 in self.handlers:\n",
"return \"Error: no such action. '%s'\" % VAR_54\n",
"VAR_55 = self.handlers[VAR_54]\n",
"VAR_56 = not ('noauth' in dir(VAR_55) and VAR_55.noauth)\n",
"if ... | [
"def api(self, *args, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"action = args[0] if args else ''\n",
"if not action in self.handlers:\n",
"return \"Error: no such action. '%s'\" % action\n",
"handler = self.handlers[action]\n",
"needsAuth = not ('noauth' in dir(handler) and handler.noauth)\n",
"if... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_29 = oai.OpenAPI.parse_obj(VAR_13)\n",
"return GeneratorError(header='Failed to parse OpenAPI document', detail=str(e))\n",
"if VAR_29.components is None or VAR_29.components.schemas is None:\n",
"VAR_12 = CLASS_4()\n",
"VAR_12 = CLASS_4.build(VAR_12... | [
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"openapi = oai.OpenAPI.parse_obj(d)\n",
"return GeneratorError(header='Failed to parse OpenAPI document', detail=str(e))\n",
"if openapi.components is None or openapi.components.schemas is None:\n",
"schemas = Schemas()\n",
"schemas = Schemas.build(schema... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_23(self, VAR_0):...\n",
"import pathlib\n",
"from jinja2 import Template\n",
"from openapi_python_client import GeneratorData, Project\n",
"VAR_3 = VAR_0.MagicMock(autospec=GeneratorData, title='My Test API')\n",
"VAR_52 = VAR_0.MagicMock(autospec=str)\n",
"VAR_53 = VAR_0.MagicMock(autospec=st... | [
"def test__build_api(self, mocker):...\n",
"import pathlib\n",
"from jinja2 import Template\n",
"from openapi_python_client import GeneratorData, Project\n",
"openapi = mocker.MagicMock(autospec=GeneratorData, title='My Test API')\n",
"tag_1 = mocker.MagicMock(autospec=str)\n",
"tag_2 = mocker.MagicMock... | [
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Ass... |
[
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = FUNC_1('/groups/%s/categories/%s', VAR_30, VAR_33)\n",
"return self.client.post_json(VAR_5=destination, VAR_2=path, VAR_3={\n 'requester_user_id': requester_user_id}, VAR_39=content, VAR_15=True)\n"
] | [
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"path = _create_v1_path('/groups/%s/categories/%s', group_id, category_id)\n",
"return self.client.post_json(destination=destination, path=path, args={\n 'requester_user_id': requester_user_id}, data=content, ignore_backoff=True)\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'"
] |
[
"def FUNC_33(self):...\n",
"VAR_39 = 's0_0_0_0_0_0_0_0_0'\n",
"VAR_22, VAR_23 = self.make_request('GET', \n '/rooms/%s/messages?access_token=x&from=%s' % (self.room_id, VAR_39))\n",
"self.assertEquals(200, VAR_23.code)\n",
"self.assertTrue('start' in VAR_23.json_body)\n",
"self.assertEquals(VAR_39, VAR... | [
"def test_stream_token_is_accepted_for_fwd_pagianation(self):...\n",
"token = 's0_0_0_0_0_0_0_0_0'\n",
"request, channel = self.make_request('GET', \n '/rooms/%s/messages?access_token=x&from=%s' % (self.room_id, token))\n",
"self.assertEquals(200, channel.code)\n",
"self.assertTrue('start' in channel.jso... | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(self, VAR_5, VAR_6, VAR_3=None):...\n",
"if VAR_3 is None:\n",
"VAR_3 = {}\n",
"if self.rel.to in self.admin_site._registry:\n",
"VAR_3['class'] = 'vManyToManyRawIdAdminField'\n",
"if VAR_6:\n",
"VAR_6 = ','.join([force_text(VAR_39) for VAR_39 in VAR_6])\n",
"VAR_6 = ''\n",
"return super... | [
"def render(self, name, value, attrs=None):...\n",
"if attrs is None:\n",
"attrs = {}\n",
"if self.rel.to in self.admin_site._registry:\n",
"attrs['class'] = 'vManyToManyRawIdAdminField'\n",
"if value:\n",
"value = ','.join([force_text(v) for v in value])\n",
"value = ''\n",
"return super(ManyToMany... | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"@CLASS_4('spawn-output')...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_20 = jinja.render('pre.html', title='spawn output', content=spawn_output)\n",
"return 'text/html', VAR_20\n"
] | [
"@add_handler('spawn-output')...\n",
"\"\"\"docstring\"\"\"\n",
"html = jinja.render('pre.html', title='spawn output', content=spawn_output)\n",
"return 'text/html', html\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'"
] |
[
"def FUNC_9():...\n",
"VAR_16 = 0\n",
"for _ in f.readlines():\n",
"VAR_16 += 1\n",
"yield '<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\\n'\n",
"if VAR_8 is not None and VAR_16 >= VAR_8:\n",
"if VAR_1:\n",
"yield '<?xml-stylesheet type=\"text/xsl\" href=\"/scopelist.xsl\" ?>\\n'\n",
"yield '<objectl... | [
"def generate():...\n",
"num_entries = 0\n",
"for _ in f.readlines():\n",
"num_entries += 1\n",
"yield '<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\\n'\n",
"if limit is not None and num_entries >= limit:\n",
"if STYLE:\n",
"yield '<?xml-stylesheet type=\"text/xsl\" href=\"/scopelist.xsl\" ?>\\n'\n",
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"AugAssign'",
"Expr'",
"Condition",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"For",
"Assign'",
"Expr'",
"Expr'",
"AugAssign'",
"Condition"
] |
[
"def FUNC_51(VAR_62, VAR_9, VAR_109=0):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_12.exists(VAR_62, VAR_9):\n",
"FUNC_50(VAR_62, VAR_9, VAR_109=force)\n"
] | [
"def delete_doc_if_exists(doctype, name, force=0):...\n",
"\"\"\"docstring\"\"\"\n",
"if db.exists(doctype, name):\n",
"delete_doc(doctype, name, force=force)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'"
] |
[
"def __init__(self, VAR_198=None, **VAR_182):...\n",
"if not VAR_198:\n",
"self.__dict__.clear()\n",
"VAR_222 = self.__getattr__(VAR_198)\n",
"VAR_222.installed = True\n",
"VAR_222.update((VAR_346, v) for VAR_346, v in VAR_182.items() if VAR_346 not in\n VAR_222)\n"
] | [
"def __init__(self, plugin=None, **defaults):...\n",
"if not plugin:\n",
"self.__dict__.clear()\n",
"settings = self.__getattr__(plugin)\n",
"settings.installed = True\n",
"settings.update((k, v) for k, v in defaults.items() if k not in settings)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"@FUNC_0...\n",
"return Keyring(self)\n"
] | [
"@cache_in_self...\n",
"return Keyring(self)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"@VAR_1.route('/ajax/xchange', methods=['POST'])...\n",
"VAR_79 = VAR_32.get_json().get('xchange')\n",
"if VAR_79:\n",
"for val in VAR_79:\n",
"return ''\n",
"VAR_39 = False\n",
"return json.dumps({'success': True})\n",
"VAR_17 = calibre_db.get_book(val)\n",
"VAR_115 = VAR_17.title\n",
"VAR_116 = ... | [
"@editbook.route('/ajax/xchange', methods=['POST'])...\n",
"vals = request.get_json().get('xchange')\n",
"if vals:\n",
"for val in vals:\n",
"return ''\n",
"modif_date = False\n",
"return json.dumps({'success': True})\n",
"book = calibre_db.get_book(val)\n",
"authors = book.title\n",
"entries = ca... | [
0,
0,
0,
0,
0,
0,
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'",
"Condition",
"For",
"Return'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Expr'... |
[
"async def FUNC_15(VAR_20):...\n",
""
] | [
"async def get_key(key_server):...\n",
""
] | [
0,
0
] | [
"AsyncFunctionDef'",
"Condition"
] |
[
"def FUNC_14(self, VAR_30: bytes) ->None:...\n",
"self.stream.write(VAR_30)\n",
"self.length += len(VAR_30)\n",
"if self.max_size is not None and self.length >= self.max_size:\n",
"self.deferred.errback(SynapseError(502, \n 'Requested file is too large > %r bytes' % (self.max_size,), Codes.\n TOO_LARG... | [
"def dataReceived(self, data: bytes) ->None:...\n",
"self.stream.write(data)\n",
"self.length += len(data)\n",
"if self.max_size is not None and self.length >= self.max_size:\n",
"self.deferred.errback(SynapseError(502, \n 'Requested file is too large > %r bytes' % (self.max_size,), Codes.\n TOO_LARGE... | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"AugAssign'",
"Condition",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_16(self):...\n",
"VAR_5 = self._makeContext()\n",
"self.assertEqual(VAR_5.evaluate('x | string:x'), 'x')\n"
] | [
"def test_hybrid_with_string_expression(self):...\n",
"ec = self._makeContext()\n",
"self.assertEqual(ec.evaluate('x | string:x'), 'x')\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_38(self, VAR_2='password'):...\n",
"VAR_17 = reverse('login')\n",
"for bad_url in ('http://example.com', 'https://example.com',\n",
"VAR_30 = '%(url)s?%(next)s=%(bad_url)s' % {'url': VAR_17, 'next':\n REDIRECT_FIELD_NAME, 'bad_url': urlquote(bad_url)}\n",
"for good_url in ('/view/?param=http://... | [
"def test_security_check(self, password='password'):...\n",
"login_url = reverse('login')\n",
"for bad_url in ('http://example.com', 'https://example.com',\n",
"nasty_url = '%(url)s?%(next)s=%(bad_url)s' % {'url': login_url, 'next':\n REDIRECT_FIELD_NAME, 'bad_url': urlquote(bad_url)}\n",
"for good_url i... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Assign'",
"For",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_19(self, VAR_6, VAR_8, VAR_10=False):...\n",
"VAR_13, VAR_15 = [], []\n",
"VAR_25 = frappe.desk.query_report.run(self.name, VAR_6=filters, VAR_8=user,\n VAR_10=ignore_prepared_report)\n",
"for d in VAR_25.get('columns'):\n",
"if isinstance(d, dict):\n",
"VAR_15 += VAR_25.get('result')\n",
"... | [
"def run_query_report(self, filters, user, ignore_prepared_report=False):...\n",
"columns, result = [], []\n",
"data = frappe.desk.query_report.run(self.name, filters=filters, user=user,\n ignore_prepared_report=ignore_prepared_report)\n",
"for d in data.get('columns'):\n",
"if isinstance(d, dict):\n",
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"For",
"Condition",
"AugAssign'",
"Assign'",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Assign'"
] |
[
"def FUNC_1(VAR_2):...\n",
"if VAR_2.is_public:\n",
"return True\n",
"if current_user.is_anonymous or VAR_2.user_id != current_user.id:\n",
"VAR_1.error('User is unauthorized to view non-public shelf: %s', VAR_2)\n",
"return True\n",
"return False\n"
] | [
"def check_shelf_view_permissions(cur_shelf):...\n",
"if cur_shelf.is_public:\n",
"return True\n",
"if current_user.is_anonymous or cur_shelf.user_id != current_user.id:\n",
"log.error('User is unauthorized to view non-public shelf: %s', cur_shelf)\n",
"return True\n",
"return False\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Condition",
"Expr'",
"Return'",
"Return'"
] |
[
"def __init__(self, VAR_58, *VAR_6, **VAR_7):...\n",
"self.project = VAR_58\n",
"super().__init__(*VAR_6, **kwargs)\n",
"self.fields['group'].queryset = VAR_58.defined_groups.all()\n"
] | [
"def __init__(self, project, *args, **kwargs):...\n",
"self.project = project\n",
"super().__init__(*args, **kwargs)\n",
"self.fields['group'].queryset = project.defined_groups.all()\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'"
] |
[
"def FUNC_13(self, VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_8 = getattr(self, 'create_%s_field' % VAR_5, None)\n",
"if VAR_8:\n",
"return VAR_8\n",
"import inspect\n",
"VAR_10 = [f[0] for f in inspect.getmembers(self.__class__, inspect.\n isfunction) if f[0].startswith('create_') and f[0].endsw... | [
"def get_create_field_function(self, type):...\n",
"\"\"\"docstring\"\"\"\n",
"create_field_function = getattr(self, 'create_%s_field' % type, None)\n",
"if create_field_function:\n",
"return create_field_function\n",
"import inspect\n",
"method_list = [f[0] for f in inspect.getmembers(self.__class__, i... | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Import'",
"Assign'"
] |
[
"def FUNC_4(VAR_14):...\n",
"VAR_23 = []\n",
"for r in VAR_14:\n",
"VAR_25 = {'value': r[0], 'description': ', '.join(unique(cstr(d) for d in r if\n d)[1:])}\n",
"return VAR_23\n",
"VAR_23.append(VAR_25)\n"
] | [
"def build_for_autosuggest(res):...\n",
"results = []\n",
"for r in res:\n",
"out = {'value': r[0], 'description': ', '.join(unique(cstr(d) for d in r if\n d)[1:])}\n",
"return results\n",
"results.append(out)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Assign'",
"Return'",
"Expr'"
] |
[
"def FUNC_1(VAR_1):...\n",
"VAR_8 = magic.from_buffer(VAR_1, mime=True)\n",
"if VAR_8[:5] != 'image':\n",
"return VAR_1, False\n",
"return VAR_1, True\n"
] | [
"def allowed_file(enc_data):...\n",
"mimetype = magic.from_buffer(enc_data, mime=True)\n",
"if mimetype[:5] != 'image':\n",
"return enc_data, False\n",
"return enc_data, True\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_8(self, VAR_3, VAR_4):...\n",
"VAR_17 = self.default_config()\n",
"VAR_17['require_auth_for_profile_requests'] = True\n",
"VAR_17['limit_profile_requests_to_users_who_share_rooms'] = True\n",
"self.hs = self.setup_test_homeserver(VAR_17=config)\n",
"return self.hs\n"
] | [
"def make_homeserver(self, reactor, clock):...\n",
"config = self.default_config()\n",
"config['require_auth_for_profile_requests'] = True\n",
"config['limit_profile_requests_to_users_who_share_rooms'] = True\n",
"self.hs = self.setup_test_homeserver(config=config)\n",
"return self.hs\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_20(self, VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_3 or not self.index_urls:\n",
"return None\n",
"for u in self.index_urls:\n",
"VAR_94 = remove_auth_from_url(u).rstrip('/') + '/'\n",
"if VAR_3.startswith(VAR_94):\n",
"return u\n"
] | [
"def _get_index_url(self, url):...\n",
"\"\"\"docstring\"\"\"\n",
"if not url or not self.index_urls:\n",
"return None\n",
"for u in self.index_urls:\n",
"prefix = remove_auth_from_url(u).rstrip('/') + '/'\n",
"if url.startswith(prefix):\n",
"return u\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"For",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_0(self, VAR_3, VAR_4):...\n",
"self.push_attempts = []\n",
"VAR_5 = Mock()\n",
"def FUNC_9(VAR_6, VAR_7):...\n",
"VAR_25 = Deferred()\n",
"self.push_attempts.append((VAR_25, VAR_6, VAR_7))\n",
"return make_deferred_yieldable(VAR_25)\n"
] | [
"def make_homeserver(self, reactor, clock):...\n",
"self.push_attempts = []\n",
"m = Mock()\n",
"def post_json_get_json(url, body):...\n",
"d = Deferred()\n",
"self.push_attempts.append((d, url, body))\n",
"return make_deferred_yieldable(d)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_16(self, VAR_1):...\n",
"VAR_5 = VAR_1.MagicMock()\n",
"VAR_26 = VAR_1.MagicMock()\n",
"VAR_23 = oai.Schema(anyOf=[{'type': 'number', 'default': '0.0'}, {'type':\n 'integer', 'default': '0'}])\n",
"VAR_33 = VAR_1.patch(f'{VAR_0}.UnionProperty')\n",
"VAR_32 = VAR_1.patch(f'{VAR_0}.FloatPropert... | [
"def test_property_from_data_union(self, mocker):...\n",
"name = mocker.MagicMock()\n",
"required = mocker.MagicMock()\n",
"data = oai.Schema(anyOf=[{'type': 'number', 'default': '0.0'}, {'type':\n 'integer', 'default': '0'}])\n",
"UnionProperty = mocker.patch(f'{MODULE_NAME}.UnionProperty')\n",
"Float... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"ImportFrom'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assert'"
] |
[
"async def FUNC_5(self):...\n",
"return '1a2b3c4d5e6f'\n"
] | [
"async def get_resolved_ref(self):...\n",
"return '1a2b3c4d5e6f'\n"
] | [
0,
0
] | [
"AsyncFunctionDef'",
"Return'"
] |
[
"@VAR_5.route('/scope/<gididx>')...\n",
"VAR_12 = 'GIDIDX' + VAR_6.upper()\n",
"def FUNC_9():...\n",
"yield '<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\\n'\n",
"if VAR_1:\n",
"yield '<?xml-stylesheet type=\"text/xsl\" href=\"/scopelist.xsl\" ?>\\n'\n",
"yield '<objectlist>\\n'\n",
"for line in f:\n",... | [
"@scope_blueprint.route('/scope/<gididx>')...\n",
"index = 'GIDIDX' + gididx.upper()\n",
"def generate():...\n",
"yield '<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\\n'\n",
"if STYLE:\n",
"yield '<?xml-stylesheet type=\"text/xsl\" href=\"/scopelist.xsl\" ?>\\n'\n",
"yield '<objectlist>\\n'\n",
"for li... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"FunctionDef'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"For",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"For",
"Expr'"
] |
[
"def FUNC_23(VAR_9, VAR_5, VAR_10):...\n",
"VAR_13 = calibre_db.session.query(db.Ratings).filter(db.Ratings.id == VAR_5\n ).first()\n",
"VAR_63, VAR_68, VAR_65 = calibre_db.fill_indexpage(VAR_9, 0, db.Books, db.\n Books.ratings.any(db.Ratings.id == VAR_5), [VAR_10[0][0]])\n",
"if VAR_13 and VAR_13.ratin... | [
"def render_ratings_books(page, book_id, order):...\n",
"name = calibre_db.session.query(db.Ratings).filter(db.Ratings.id == book_id\n ).first()\n",
"entries, random, pagination = calibre_db.fill_indexpage(page, 0, db.Books,\n db.Books.ratings.any(db.Ratings.id == book_id), [order[0][0]])\n",
"if name a... | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Expr'"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.