lines
sequencelengths 1
383
| raw_lines
sequencelengths 1
383
| label
sequencelengths 1
383
| type
sequencelengths 1
383
|
---|---|---|---|
[
"def FUNC_27(self):...\n",
"VAR_9 = self._makeEngine()\n",
"VAR_5 = self._makeContext()\n",
"VAR_11 = VAR_9.compile('string:$eightbit')\n",
"self.assertRaises(UnicodeDecodeError, VAR_5.evaluate, VAR_11)\n",
"from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver\n",
"from Products.PageTemplates.unicodeconflictresolver import StrictUnicodeEncodingConflictResolver\n",
"from zope.component import provideUtility\n",
"provideUtility(StrictUnicodeEncodingConflictResolver,\n IUnicodeEncodingConflictResolver)\n",
"self.assertEqual(VAR_5.evaluate(VAR_11), 'äüö')\n"
] | [
"def test_mixed(self):...\n",
"eng = self._makeEngine()\n",
"ec = self._makeContext()\n",
"expr = eng.compile('string:$eightbit')\n",
"self.assertRaises(UnicodeDecodeError, ec.evaluate, expr)\n",
"from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver\n",
"from Products.PageTemplates.unicodeconflictresolver import StrictUnicodeEncodingConflictResolver\n",
"from zope.component import provideUtility\n",
"provideUtility(StrictUnicodeEncodingConflictResolver,\n IUnicodeEncodingConflictResolver)\n",
"self.assertEqual(ec.evaluate(expr), 'äüö')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Expr'",
"Expr'"
] |
[
"def FUNC_5(self, VAR_2, VAR_14, VAR_15):...\n",
""
] | [
"def get_share_connection(self, request, conn, share_id):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"async def FUNC_48(VAR_12: str):...\n",
""
] | [
"async def get_event(event_id: str):...\n",
""
] | [
0,
0
] | [
"AsyncFunctionDef'",
"Condition"
] |
[
"def FUNC_95(self, VAR_10):...\n",
"\"\"\"docstring\"\"\"\n",
"self.run_procedures[VAR_10.__name__] = VAR_10\n",
"return VAR_10\n"
] | [
"def run(self, f):...\n",
"\"\"\"docstring\"\"\"\n",
"self.run_procedures[f.__name__] = f\n",
"return f\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Return'"
] |
[
"@defer.inlineCallbacks...\n",
"VAR_14 = self.mock_handler.set_displayname\n",
"VAR_14.side_effect = SynapseError(400, 'message')\n",
"VAR_12, VAR_13 = yield self.mock_resource.trigger('PUT', \n '/profile/%s/displayname' % '@opaque:elsewhere', b'{\"displayname\":\"bob\"}')\n",
"self.assertTrue(400 <= VAR_12 <= 499, msg='code %d is in the 4xx range' % code)\n"
] | [
"@defer.inlineCallbacks...\n",
"mocked_set = self.mock_handler.set_displayname\n",
"mocked_set.side_effect = SynapseError(400, 'message')\n",
"code, response = yield self.mock_resource.trigger('PUT', \n '/profile/%s/displayname' % '@opaque:elsewhere', b'{\"displayname\":\"bob\"}')\n",
"self.assertTrue(400 <= code <= 499, msg='code %d is in the 4xx range' % code)\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"@FUNC_0...\n",
"return PusherPool(self)\n"
] | [
"@cache_in_self...\n",
"return PusherPool(self)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"@VAR_0.simple_tag...\n",
"if apply_markdown is None:\n",
"return VAR_7\n",
"return mark_safe(apply_markdown(VAR_7))\n"
] | [
"@register.simple_tag...\n",
"if apply_markdown is None:\n",
"return markdown_text\n",
"return mark_safe(apply_markdown(markdown_text))\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Return'",
"Return'"
] |
[
"def __new__(VAR_0, VAR_1: str):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_0 != CLASS_1:\n",
"return super().__new__(VAR_0)\n",
"if VAR_1 == '-':\n",
"return CLASS_2(VAR_1)\n",
"if VAR_1.startswith('https:'):\n",
"return CLASS_3(VAR_1)\n",
"return CLASS_4(VAR_1)\n"
] | [
"def __new__(cls, sourceName: str):...\n",
"\"\"\"docstring\"\"\"\n",
"if cls != InputSource:\n",
"return super().__new__(cls)\n",
"if sourceName == '-':\n",
"return StdinInputSource(sourceName)\n",
"if sourceName.startswith('https:'):\n",
"return UrlInputSource(sourceName)\n",
"return FileInputSource(sourceName)\n"
] | [
0,
0,
0,
0,
0,
1,
0,
1,
1
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_8(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, '--tag_set',\n 'serve', '--signature_def', 'serving_default'])\n",
"saved_model_cli.show(VAR_10)\n",
"VAR_11 = out.getvalue().strip()\n",
"VAR_18 = 'string'\n",
"self.assertEqual(VAR_11, VAR_18)\n",
"self.assertEqual(err.getvalue().strip(), '')\n"
] | [
"def testShowCommandInputsOutputs(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, '--tag_set',\n 'serve', '--signature_def', 'serving_default'])\n",
"saved_model_cli.show(args)\n",
"output = out.getvalue().strip()\n",
"expected_output = \"\"\"The given SavedModel SignatureDef contains the following input(s):\n inputs['x'] tensor_info:\n dtype: DT_FLOAT\n shape: (-1, 1)\n name: x:0\nThe given SavedModel SignatureDef contains the following output(s):\n outputs['y'] tensor_info:\n dtype: DT_FLOAT\n shape: (-1, 1)\n name: y:0\nMethod name is: tensorflow/serving/predict\"\"\"\n",
"self.assertEqual(output, expected_output)\n",
"self.assertEqual(err.getvalue().strip(), '')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_8(self, VAR_23):...\n",
""
] | [
"def compile(self, expression):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def __init__(self, VAR_63, VAR_64, VAR_65='HS256', VAR_66=True, VAR_67=30,...\n",
"self.secret_key = VAR_64\n",
"self.auth = VAR_63\n",
"self.algorithm = VAR_65\n",
"if self.algorithm not in ('HS256', 'HS384', 'HS512'):\n",
"self.verify_expiration = VAR_66\n",
"self.leeway = VAR_67\n",
"self.expiration = VAR_68\n",
"self.allow_refresh = VAR_69\n",
"self.refresh_expiration_delta = VAR_70\n",
"self.header_prefix = VAR_71\n",
"self.jwt_add_header = VAR_72 or {}\n",
"VAR_233 = {'alg': self.algorithm, 'typ': 'JWT'}\n",
"for VAR_346, v in iteritems(self.jwt_add_header):\n",
"VAR_233[VAR_346] = v\n",
"self.cached_b64h = self.jwt_b64e(FUNC_98.dumps(VAR_233))\n",
"VAR_234 = {'HS256': hashlib.sha256, 'HS384': hashlib.sha384, 'HS512':\n hashlib.sha512}\n",
"self.digestmod = VAR_234[VAR_65]\n",
"self.user_param = VAR_73\n",
"self.pass_param = VAR_74\n",
"self.realm = VAR_75\n",
"self.salt = VAR_76\n",
"self.additional_payload = VAR_77\n",
"self.before_authorization = VAR_78\n",
"self.max_header_length = VAR_79\n",
"self.recvd_token = None\n"
] | [
"def __init__(self, auth, secret_key, algorithm='HS256', verify_expiration=...\n",
"self.secret_key = secret_key\n",
"self.auth = auth\n",
"self.algorithm = algorithm\n",
"if self.algorithm not in ('HS256', 'HS384', 'HS512'):\n",
"self.verify_expiration = verify_expiration\n",
"self.leeway = leeway\n",
"self.expiration = expiration\n",
"self.allow_refresh = allow_refresh\n",
"self.refresh_expiration_delta = refresh_expiration_delta\n",
"self.header_prefix = header_prefix\n",
"self.jwt_add_header = jwt_add_header or {}\n",
"base_header = {'alg': self.algorithm, 'typ': 'JWT'}\n",
"for k, v in iteritems(self.jwt_add_header):\n",
"base_header[k] = v\n",
"self.cached_b64h = self.jwt_b64e(json.dumps(base_header))\n",
"digestmod_mapping = {'HS256': hashlib.sha256, 'HS384': hashlib.sha384,\n 'HS512': hashlib.sha512}\n",
"self.digestmod = digestmod_mapping[algorithm]\n",
"self.user_param = user_param\n",
"self.pass_param = pass_param\n",
"self.realm = realm\n",
"self.salt = salt\n",
"self.additional_payload = additional_payload\n",
"self.before_authorization = before_authorization\n",
"self.max_header_length = max_header_length\n",
"self.recvd_token = None\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
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_30(VAR_63):...\n",
"VAR_63 = io.StringIO(VAR_63)\n",
"VAR_82 = list(csv.reader(VAR_63))\n",
"VAR_83 = VAR_82[0]\n",
"VAR_84 = VAR_83.index('flag')\n",
"VAR_82[VAR_24][VAR_84] = VAR_23\n",
"VAR_47 = io.StringIO()\n",
"VAR_85 = csv.writer(VAR_47)\n",
"VAR_85.writerows(VAR_82)\n",
"return VAR_47.getvalue()\n"
] | [
"def replace_flag_at_index(file_content):...\n",
"file_content = io.StringIO(file_content)\n",
"content = list(csv.reader(file_content))\n",
"header = content[0]\n",
"flag_col_index = header.index('flag')\n",
"content[flag_index][flag_col_index] = flag_option\n",
"output = io.StringIO()\n",
"writer = csv.writer(output)\n",
"writer.writerows(content)\n",
"return output.getvalue()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"@VAR_0.unauthorized_handler...\n",
"if VAR_8.is_xhr or '/api/' in VAR_8.path:\n",
"VAR_30 = jsonify({'message':\n \"Couldn't find resource. Please login and try again.\"})\n",
"VAR_23 = FUNC_0(VAR_3=request.url, VAR_2=False)\n",
"VAR_30.status_code = 404\n",
"return redirect(VAR_23)\n",
"return VAR_30\n"
] | [
"@login_manager.unauthorized_handler...\n",
"if request.is_xhr or '/api/' in request.path:\n",
"response = jsonify({'message':\n \"Couldn't find resource. Please login and try again.\"})\n",
"login_url = get_login_url(next=request.url, external=False)\n",
"response.status_code = 404\n",
"return redirect(login_url)\n",
"return response\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Return'"
] |
[
"def FUNC_84(VAR_14):...\n",
"for VAR_13 in VAR_43:\n",
"VAR_104 = getattr(self.rules, VAR_13)\n",
"return False\n",
"VAR_44 = VAR_104.match(VAR_14)\n",
"if not VAR_44:\n",
"getattr(self, 'parse_%s' % VAR_13)(VAR_44)\n",
"return VAR_44\n"
] | [
"def manipulate(text):...\n",
"for key in rules:\n",
"rule = getattr(self.rules, key)\n",
"return False\n",
"m = rule.match(text)\n",
"if not m:\n",
"getattr(self, 'parse_%s' % key)(m)\n",
"return m\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Expr'",
"Return'"
] |
[
"def FUNC_0(self, VAR_12, VAR_13, VAR_3=True):...\n",
"\"\"\"docstring\"\"\"\n",
"def FUNC_12(VAR_4):...\n",
"VAR_21 = [m.upper() for m in VAR_13]\n",
"for r, m, v in itertools.product(VAR_12, VAR_21, [VAR_4.__name__]):\n",
"self.before_acl.append((r, m, v, VAR_3))\n",
"return VAR_4\n"
] | [
"def allow(self, roles, methods, with_children=True):...\n",
"\"\"\"docstring\"\"\"\n",
"def decorator(view_func):...\n",
"_methods = [m.upper() for m in methods]\n",
"for r, m, v in itertools.product(roles, _methods, [view_func.__name__]):\n",
"self.before_acl.append((r, m, v, with_children))\n",
"return view_func\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"FunctionDef'",
"Assign'",
"For",
"Expr'",
"Return'"
] |
[
"def FUNC_13(self):...\n",
"\"\"\"docstring\"\"\"\n",
"async def FUNC_18(VAR_3, **VAR_4):...\n",
"VAR_5 = CLASS_2.TestResource()\n",
"VAR_5.callback = VAR_10\n",
"VAR_7, VAR_6 = make_request(self.reactor, FakeSite(VAR_5), b'GET', b'/path')\n",
"self.assertEqual(VAR_6.result['code'], b'301')\n",
"VAR_12 = VAR_6.result['headers']\n",
"VAR_13 = [v for k, v in VAR_12 if k == b'Location']\n",
"self.assertEqual(VAR_13, [b'/look/an/eagle'])\n"
] | [
"def test_redirect_exception(self):...\n",
"\"\"\"docstring\"\"\"\n",
"async def callback(request, **kwargs):...\n",
"res = WrapHtmlRequestHandlerTests.TestResource()\n",
"res.callback = callback\n",
"_, channel = make_request(self.reactor, FakeSite(res), b'GET', b'/path')\n",
"self.assertEqual(channel.result['code'], b'301')\n",
"headers = channel.result['headers']\n",
"location_headers = [v for k, v in headers if k == b'Location']\n",
"self.assertEqual(location_headers, [b'/look/an/eagle'])\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"AsyncFunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_24(self):...\n",
"VAR_5 = {'not_senders': ['@misspiggy:muppets'], 'senders': [\n '@kermit:muppets'], 'rooms': ['!stage:unknown'], 'not_rooms': [\n '!piggyshouse:muppets'], 'types': ['m.room.message', 'muppets.kermit.*'\n ], 'not_types': ['muppets.misspiggy.*']}\n",
"VAR_6 = FUNC_0(sender='@kermit:muppets', type='m.room.message', room_id=\n '!piggyshouse:muppets')\n",
"self.assertFalse(Filter(VAR_5).check(VAR_6))\n"
] | [
"def test_definition_combined_event_bad_room(self):...\n",
"definition = {'not_senders': ['@misspiggy:muppets'], 'senders': [\n '@kermit:muppets'], 'rooms': ['!stage:unknown'], 'not_rooms': [\n '!piggyshouse:muppets'], 'types': ['m.room.message', 'muppets.kermit.*'\n ], 'not_types': ['muppets.misspiggy.*']}\n",
"event = MockEvent(sender='@kermit:muppets', type='m.room.message', room_id=\n '!piggyshouse:muppets')\n",
"self.assertFalse(Filter(definition).check(event))\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_8(self, VAR_23):...\n",
""
] | [
"def compile(self, expression):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_5(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_9 = {'a': 'b'}\n",
"VAR_10 = 'string'\n",
"self.assertEqual(FUNC_0(format_value(VAR_9)), FUNC_0(VAR_10))\n"
] | [
"def test_format_value_dict(self):...\n",
"\"\"\"docstring\"\"\"\n",
"test_dict = {'a': 'b'}\n",
"expected_dict_format = \"\"\"\n <table class=\"table table-striped\">\n <tbody>\n <tr>\n <th>a</th>\n <td>b</td>\n </tr>\n </tbody>\n </table>\"\"\"\n",
"self.assertEqual(format_html(format_value(test_dict)), format_html(\n expected_dict_format))\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Expr'"
] |
[
"async def FUNC_47(VAR_82):...\n",
"for VAR_196 in VAR_82:\n",
"return False\n",
"await self.backfill(VAR_196, VAR_11, VAR_17=100, VAR_18=extremities)\n",
"VAR_0.info('Failed to backfill from %s because %s', VAR_196, VAR_170)\n",
"return True\n",
"if 400 <= VAR_170.code < 500:\n",
"VAR_0.info('Failed to backfill from %s because %s', VAR_196, VAR_170)\n",
"if 400 <= VAR_170.code < 500:\n",
"VAR_0.info('Failed to backfill from %s because %s', VAR_196, VAR_170)\n",
"VAR_0.info(str(VAR_170))\n",
"VAR_0.info('Failed to get backfill from %s because %s', VAR_196, VAR_170)\n",
"VAR_0.info(VAR_170)\n",
"VAR_0.exception('Failed to backfill from %s because %s', VAR_196, VAR_170)\n"
] | [
"async def try_backfill(domains):...\n",
"for dom in domains:\n",
"return False\n",
"await self.backfill(dom, room_id, limit=100, extremities=extremities)\n",
"logger.info('Failed to backfill from %s because %s', dom, e)\n",
"return True\n",
"if 400 <= e.code < 500:\n",
"logger.info('Failed to backfill from %s because %s', dom, e)\n",
"if 400 <= e.code < 500:\n",
"logger.info('Failed to backfill from %s because %s', dom, e)\n",
"logger.info(str(e))\n",
"logger.info('Failed to get backfill from %s because %s', dom, e)\n",
"logger.info(e)\n",
"logger.exception('Failed to backfill from %s because %s', dom, e)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"AsyncFunctionDef'",
"For",
"Return'",
"Expr'",
"Expr'",
"Return'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"from django.contrib.auth.decorators import login_required\n",
"from django.shortcuts import render, redirect, get_object_or_404\n",
"from django.views.decorators.http import require_POST\n",
"from django.contrib import messages\n",
"from django.http import Http404\n",
"from djconfig import config\n",
"from spirit.core.utils.views import is_post, post_data, is_ajax\n",
"from spirit.core.utils.ratelimit.decorators import ratelimit\n",
"from spirit.core.utils.decorators import moderator_required\n",
"from spirit.core.utils import markdown, paginator, render_form_errors, json_response\n",
"from spirit.topic.models import Topic\n",
"from .models import Comment\n",
"from .forms import CommentForm, CommentMoveForm, CommentImageForm, CommentFileForm\n",
"from .utils import comment_posted, post_comment_update, pre_comment_update, post_comment_move\n",
"@login_required...\n",
"VAR_4 = None\n",
"if VAR_2:\n",
"VAR_8 = get_object_or_404(Comment.objects.for_access(VAR_5=request.user),\n VAR_2=pk)\n",
"VAR_5 = VAR_0.user\n",
"VAR_11 = markdown.quotify(VAR_8.comment, VAR_8.user.st.nickname)\n",
"VAR_6 = get_object_or_404(Topic.objects.opened().for_access(VAR_5), VAR_2=\n topic_id)\n",
"VAR_4 = {'comment': VAR_11}\n",
"VAR_7 = CommentForm(VAR_5=user, VAR_6=topic, data=post_data(request), VAR_4\n =initial)\n",
"if is_post(VAR_0) and not VAR_0.is_limited() and VAR_7.is_valid():\n",
"if not VAR_5.st.update_post_hash(VAR_7.get_comment_hash()):\n",
"return render(VAR_0=request, template_name='spirit/comment/publish.html',\n context={'form': form, 'topic': topic})\n",
"return redirect(VAR_0.POST.get('next', None) or Comment.get_last_for_topic(\n VAR_1).get_absolute_url())\n",
"VAR_8 = VAR_7.save()\n",
"comment_posted(VAR_8=comment, mentions=form.mentions)\n",
"return redirect(VAR_0.POST.get('next', VAR_8.get_absolute_url()))\n"
] | [
"from django.contrib.auth.decorators import login_required\n",
"from django.shortcuts import render, redirect, get_object_or_404\n",
"from django.views.decorators.http import require_POST\n",
"from django.contrib import messages\n",
"from django.http import Http404\n",
"from djconfig import config\n",
"from spirit.core.utils.views import is_post, post_data, is_ajax\n",
"from spirit.core.utils.ratelimit.decorators import ratelimit\n",
"from spirit.core.utils.decorators import moderator_required\n",
"from spirit.core.utils import markdown, paginator, render_form_errors, json_response\n",
"from spirit.topic.models import Topic\n",
"from .models import Comment\n",
"from .forms import CommentForm, CommentMoveForm, CommentImageForm, CommentFileForm\n",
"from .utils import comment_posted, post_comment_update, pre_comment_update, post_comment_move\n",
"@login_required...\n",
"initial = None\n",
"if pk:\n",
"comment = get_object_or_404(Comment.objects.for_access(user=request.user),\n pk=pk)\n",
"user = request.user\n",
"quote = markdown.quotify(comment.comment, comment.user.st.nickname)\n",
"topic = get_object_or_404(Topic.objects.opened().for_access(user), pk=topic_id)\n",
"initial = {'comment': quote}\n",
"form = CommentForm(user=user, topic=topic, data=post_data(request), initial\n =initial)\n",
"if is_post(request) and not request.is_limited() and form.is_valid():\n",
"if not user.st.update_post_hash(form.get_comment_hash()):\n",
"return render(request=request, template_name='spirit/comment/publish.html',\n context={'form': form, 'topic': topic})\n",
"return redirect(request.POST.get('next', None) or Comment.\n get_last_for_topic(topic_id).get_absolute_url())\n",
"comment = form.save()\n",
"comment_posted(comment=comment, mentions=form.mentions)\n",
"return redirect(request.POST.get('next', comment.get_absolute_url()))\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,
4,
0,
0,
4
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Return'",
"Return'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_34(self):...\n",
"self.login()\n",
"VAR_3 = self.client.post('/password_change/', {'old_password': 'password',\n 'new_password1': 'password1', 'new_password2': 'password1'})\n",
"self.assertEqual(VAR_3.status_code, 302)\n",
"self.assertURLEqual(VAR_3.url, '/password_change/done/')\n"
] | [
"def test_password_change_redirect_default(self):...\n",
"self.login()\n",
"response = self.client.post('/password_change/', {'old_password':\n 'password', 'new_password1': 'password1', 'new_password2': 'password1'})\n",
"self.assertEqual(response.status_code, 302)\n",
"self.assertURLEqual(response.url, '/password_change/done/')\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_3(VAR_16, VAR_17, VAR_10, VAR_11):...\n",
"\"\"\"docstring\"\"\"\n",
"if not (isinstance(VAR_10, VAR_16) or inspect.isclass(VAR_10) and\n",
"return\n",
"VAR_27 = {'detail': ('%s.detail' % VAR_17, '%s.edit' % VAR_17)}\n",
"VAR_28 = [{}]\n",
"if getattr(VAR_10, 'pk', None):\n",
"VAR_28.append({'pk': VAR_10.pk})\n",
"for urlname in VAR_27.get(VAR_11, ['%s.%s' % (VAR_17, VAR_11)]):\n",
"for VAR_2 in VAR_28:\n",
"return None\n",
"return reverse(urlname, VAR_2=kwargs)\n"
] | [
"def derive_model_url(model_class, urlname_prefix, object, kind):...\n",
"\"\"\"docstring\"\"\"\n",
"if not (isinstance(object, model_class) or inspect.isclass(object) and\n",
"return\n",
"kind_to_urlnames = {'detail': ('%s.detail' % urlname_prefix, '%s.edit' %\n urlname_prefix)}\n",
"kwarg_sets = [{}]\n",
"if getattr(object, 'pk', None):\n",
"kwarg_sets.append({'pk': object.pk})\n",
"for urlname in kind_to_urlnames.get(kind, ['%s.%s' % (urlname_prefix, kind)]):\n",
"for kwargs in kwarg_sets:\n",
"return None\n",
"return reverse(urlname, kwargs=kwargs)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"For",
"For",
"Return'",
"Return'"
] |
[
"def FUNC_2(VAR_8, VAR_9=None):...\n",
"\"\"\"docstring\"\"\"\n",
"from frappe.translate import get_dict\n",
"return get_dict(VAR_8, VAR_9)\n"
] | [
"def get_lang_dict(fortype, name=None):...\n",
"\"\"\"docstring\"\"\"\n",
"from frappe.translate import get_dict\n",
"return get_dict(fortype, name)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"ImportFrom'",
"Return'"
] |
[
"@VAR_2.route('/<data>/<sort_param>', defaults={'page': 1, 'book_id': 1})...\n",
"return FUNC_15(VAR_8, VAR_20, VAR_5, VAR_9)\n"
] | [
"@web.route('/<data>/<sort_param>', defaults={'page': 1, 'book_id': 1})...\n",
"return render_books_list(data, sort_param, book_id, page)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_7(VAR_11, VAR_6='root', VAR_12=False):...\n",
"\"\"\"docstring\"\"\"\n",
"for tpath in FUNC_6(VAR_11):\n",
"if not VAR_54.access(tpath, VAR_54.R_OK):\n",
"VAR_32 = 'Could not access {0}.'.format(tpath)\n",
"if not VAR_54.path.exists(tpath):\n",
"VAR_32 += ' Path does not exist.'\n",
"VAR_34 = salt.utils.get_user()\n",
"if VAR_12:\n",
"if VAR_6 != VAR_34:\n",
"return\n",
"VAR_32 += ' Try running as user {0}.'.format(VAR_6)\n",
"VAR_32 += ' Please give {0} read permissions.'.format(VAR_6)\n"
] | [
"def check_path_traversal(path, user='root', skip_perm_errors=False):...\n",
"\"\"\"docstring\"\"\"\n",
"for tpath in list_path_traversal(path):\n",
"if not os.access(tpath, os.R_OK):\n",
"msg = 'Could not access {0}.'.format(tpath)\n",
"if not os.path.exists(tpath):\n",
"msg += ' Path does not exist.'\n",
"current_user = salt.utils.get_user()\n",
"if skip_perm_errors:\n",
"if user != current_user:\n",
"return\n",
"msg += ' Try running as user {0}.'.format(user)\n",
"msg += ' Please give {0} read permissions.'.format(user)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"For",
"Condition",
"Assign'",
"Condition",
"AugAssign'",
"Assign'",
"Condition",
"Condition",
"Return'",
"AugAssign'",
"AugAssign'"
] |
[
"@VAR_0.route('/config_edit', methods=['GET', 'POST'])...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_49 = VAR_0.config['GANGA_RC']\n",
"VAR_86 = VAR_14.read()\n",
"if request.method == 'POST':\n",
"VAR_87 = request.form['config-data']\n",
"return render_template('config_edit.html', title='Edit gangarc', VAR_86=\n ganga_config)\n",
"f1.write(str(VAR_87))\n",
"flash('.gangarc Edited', 'success')\n",
"VAR_86 = f2.read()\n"
] | [
"@gui.route('/config_edit', methods=['GET', 'POST'])...\n",
"\"\"\"docstring\"\"\"\n",
"gui_rc = gui.config['GANGA_RC']\n",
"ganga_config = f.read()\n",
"if request.method == 'POST':\n",
"config_ganga = request.form['config-data']\n",
"return render_template('config_edit.html', title='Edit gangarc',\n ganga_config=ganga_config)\n",
"f1.write(str(config_ganga))\n",
"flash('.gangarc Edited', 'success')\n",
"ganga_config = f2.read()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Expr'",
"Expr'",
"Assign'"
] |
[
"@transaction.non_atomic_requests...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_68 = ['user_email', 'exam_name', 'attempt_code',\n 'allowed_time_limit_mins', 'is_sample_attempt', 'started_at',\n 'completed_at', 'status']\n",
"VAR_38 = CourseKey.from_string(VAR_10)\n",
"instructor_task.api.submit_proctored_exam_results_report(VAR_9, VAR_38, VAR_68)\n",
"VAR_178 = _('string')\n",
"return JsonResponse({'status': VAR_178})\n",
"VAR_178 = _('string')\n"
] | [
"@transaction.non_atomic_requests...\n",
"\"\"\"docstring\"\"\"\n",
"query_features = ['user_email', 'exam_name', 'attempt_code',\n 'allowed_time_limit_mins', 'is_sample_attempt', 'started_at',\n 'completed_at', 'status']\n",
"course_key = CourseKey.from_string(course_id)\n",
"instructor_task.api.submit_proctored_exam_results_report(request,\n course_key, query_features)\n",
"status_response = _(\n 'The proctored exam results report is currently being created. To view the status of the report, see Pending Tasks below. You will be able to download the report when it is complete.'\n )\n",
"return JsonResponse({'status': status_response})\n",
"status_response = _(\n 'The proctored exam results report is being created. To view the status of the report, see Pending Tasks below.'\n )\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'",
"Assign'"
] |
[
"def FUNC_7(self):...\n",
"FUNC_3(self.package_data)\n",
"VAR_10.run(self)\n"
] | [
"def run(self):...\n",
"check_package_data(self.package_data)\n",
"command.run(self)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'"
] |
[
"def FUNC_10(self, VAR_11):...\n",
"if not VAR_53.session['admin']:\n",
"VAR_62 = self.useroptions.forUser(self.getUserId())\n",
"for f in VAR_11:\n",
"if not VAR_62.getOptionValue('media.may_download'):\n",
"if '/../' in f:\n",
"VAR_59 = cherry.config['media.maximum_download_size']\n",
"return 'not_permitted'\n",
"return 'invalid_file'\n",
"if self.model.file_size_within_limit(VAR_11, VAR_59):\n",
"return str(e)\n",
"return 'ok'\n",
"return 'too_big'\n"
] | [
"def download_check_files(self, filelist):...\n",
"if not cherrypy.session['admin']:\n",
"uo = self.useroptions.forUser(self.getUserId())\n",
"for f in filelist:\n",
"if not uo.getOptionValue('media.may_download'):\n",
"if '/../' in f:\n",
"size_limit = cherry.config['media.maximum_download_size']\n",
"return 'not_permitted'\n",
"return 'invalid_file'\n",
"if self.model.file_size_within_limit(filelist, size_limit):\n",
"return str(e)\n",
"return 'ok'\n",
"return 'too_big'\n"
] | [
0,
0,
0,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"For",
"Condition",
"Condition",
"Assign'",
"Return'",
"Return'",
"Condition",
"Return'",
"Return'",
"Return'"
] |
[
"def FUNC_15(self):...\n",
"if self.cleaned_data.get('offset') is None:\n",
"self.cleaned_data['offset'] = 1\n",
"return self.cleaned_data['offset']\n"
] | [
"def clean_offset(self):...\n",
"if self.cleaned_data.get('offset') is None:\n",
"self.cleaned_data['offset'] = 1\n",
"return self.cleaned_data['offset']\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_13(self, VAR_19: Entries) ->Generator[str, None, None]:...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_5 = self.ledger.fava_options.indent\n",
"for VAR_2 in VAR_19:\n",
"if isinstance(VAR_2, (Balance, Transaction)):\n",
"if isinstance(VAR_2, Transaction) and VAR_2.flag in VAR_0:\n",
"yield FUNC_4(VAR_2)[0] + '\\n'\n",
"yield FUNC_7(VAR_2, self.ledger.fava_options.currency_column, VAR_5)\n"
] | [
"def render_entries(self, entries: Entries) ->Generator[str, None, None]:...\n",
"\"\"\"docstring\"\"\"\n",
"indent = self.ledger.fava_options.indent\n",
"for entry in entries:\n",
"if isinstance(entry, (Balance, Transaction)):\n",
"if isinstance(entry, Transaction) and entry.flag in EXCL_FLAGS:\n",
"yield get_entry_slice(entry)[0] + '\\n'\n",
"yield _format_entry(entry, self.ledger.fava_options.currency_column, indent)\n"
] | [
0,
0,
0,
0,
0,
0,
2,
2
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"For",
"Condition",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_13(self):...\n",
"super().save()\n",
"VAR_35 = tempfile.mkdtemp(dir=self.temp_dir())\n",
"VAR_0.info(f'Extracting: {self.file_path} to {VAR_35}')\n",
"shutil.unpack_archive(self.file_path, VAR_35, 'zip')\n",
"self.file_path = VAR_35\n"
] | [
"def save(self):...\n",
"super().save()\n",
"zip_extract_dir = tempfile.mkdtemp(dir=self.temp_dir())\n",
"logger.info(f'Extracting: {self.file_path} to {zip_extract_dir}')\n",
"shutil.unpack_archive(self.file_path, zip_extract_dir, 'zip')\n",
"self.file_path = zip_extract_dir\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'"
] |
[
"def FUNC_44(self, VAR_25):...\n",
"\"\"\"docstring\"\"\"\n",
"if frappe.flags.in_import and frappe.flags.mute_emails or frappe.flags.in_patch or frappe.flags.in_install:\n",
"return\n",
"if self.flags.notifications_executed == None:\n",
"self.flags.notifications_executed = []\n",
"from frappe.email.doctype.notification.notification import evaluate_alert\n",
"if self.flags.notifications == None:\n",
"VAR_88 = frappe.cache().hget('notifications', self.doctype)\n",
"if not self.flags.notifications:\n",
"if VAR_88 == None:\n",
"return\n",
"def FUNC_82(VAR_67):...\n",
"VAR_88 = frappe.get_all('Notification', fields=['name', 'event', 'method'],\n filters={'enabled': 1, 'document_type': self.doctype})\n",
"self.flags.notifications = VAR_88\n",
"if not VAR_67.name in self.flags.notifications_executed:\n",
"frappe.cache().hset('notifications', self.doctype, VAR_88)\n",
"evaluate_alert(self, VAR_67.name, VAR_67.event)\n",
"VAR_68 = {'on_update': 'Save', 'after_insert': 'New', 'on_submit': 'Submit',\n 'on_cancel': 'Cancel'}\n",
"self.flags.notifications_executed.append(VAR_67.name)\n",
"if not self.flags.in_insert:\n",
"VAR_68['on_change'] = 'Value Change'\n",
"for VAR_67 in self.flags.notifications:\n",
"VAR_89 = VAR_68.get(VAR_25, None)\n",
"if VAR_89 and VAR_67.event == VAR_89:\n",
"FUNC_82(VAR_67)\n",
"if VAR_67.event == 'Method' and VAR_25 == VAR_67.method:\n",
"FUNC_82(VAR_67)\n"
] | [
"def run_notifications(self, method):...\n",
"\"\"\"docstring\"\"\"\n",
"if frappe.flags.in_import and frappe.flags.mute_emails or frappe.flags.in_patch or frappe.flags.in_install:\n",
"return\n",
"if self.flags.notifications_executed == None:\n",
"self.flags.notifications_executed = []\n",
"from frappe.email.doctype.notification.notification import evaluate_alert\n",
"if self.flags.notifications == None:\n",
"alerts = frappe.cache().hget('notifications', self.doctype)\n",
"if not self.flags.notifications:\n",
"if alerts == None:\n",
"return\n",
"def _evaluate_alert(alert):...\n",
"alerts = frappe.get_all('Notification', fields=['name', 'event', 'method'],\n filters={'enabled': 1, 'document_type': self.doctype})\n",
"self.flags.notifications = alerts\n",
"if not alert.name in self.flags.notifications_executed:\n",
"frappe.cache().hset('notifications', self.doctype, alerts)\n",
"evaluate_alert(self, alert.name, alert.event)\n",
"event_map = {'on_update': 'Save', 'after_insert': 'New', 'on_submit':\n 'Submit', 'on_cancel': 'Cancel'}\n",
"self.flags.notifications_executed.append(alert.name)\n",
"if not self.flags.in_insert:\n",
"event_map['on_change'] = 'Value Change'\n",
"for alert in self.flags.notifications:\n",
"event = event_map.get(method, None)\n",
"if event and alert.event == event:\n",
"_evaluate_alert(alert)\n",
"if alert.event == 'Method' and method == alert.method:\n",
"_evaluate_alert(alert)\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
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Condition",
"Assign'",
"ImportFrom'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Return'",
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"For",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_7(self):...\n",
"VAR_5 = self._makeContext()\n",
"self.assertEqual(VAR_5.evaluate('d/b'), 'b')\n"
] | [
"def test_evaluate_simple_path_dict_key_string_value(self):...\n",
"ec = self._makeContext()\n",
"self.assertEqual(ec.evaluate('d/b'), 'b')\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_12(self):...\n",
"self.force = bool(self.force)\n"
] | [
"def finalize_options(self):...\n",
"self.force = bool(self.force)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"def FUNC_19(self, VAR_3):...\n",
"return VAR_3.path\n"
] | [
"def render(self, request):...\n",
"return request.path\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_16(self):...\n",
"VAR_5 = self.get_counts('json', period='year')\n",
"self.assertEqual(VAR_5.status_code, 200)\n",
"self.assertJSONEqual(VAR_5.content.decode(), [])\n"
] | [
"def test_counts_view_year(self):...\n",
"response = self.get_counts('json', period='year')\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertJSONEqual(response.content.decode(), [])\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_11(self, VAR_5, VAR_12):...\n",
"VAR_9 = self.service.show_by_name(VAR_5, VAR_12)\n",
"return self._translate_uuid_to_id(VAR_5, VAR_9)\n"
] | [
"def show_by_name(self, context, name):...\n",
"image = self.service.show_by_name(context, name)\n",
"return self._translate_uuid_to_id(context, image)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"@pytest.mark.parametrize('create_file, create_dir, filterfunc, expected', [...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_5 = VAR_0 / 'foo'\n",
"if VAR_1 or VAR_2:\n",
"VAR_5.ensure(dir=create_dir)\n",
"VAR_6 = os.listdir(str(VAR_0))\n",
"VAR_7 = filescheme.get_file_list(str(VAR_0), VAR_6, VAR_3)\n",
"VAR_8 = {'name': 'foo', 'absname': str(VAR_5)}\n",
"assert (VAR_8 in VAR_7) == VAR_4\n"
] | [
"@pytest.mark.parametrize('create_file, create_dir, filterfunc, expected', [...\n",
"\"\"\"docstring\"\"\"\n",
"path = tmpdir / 'foo'\n",
"if create_file or create_dir:\n",
"path.ensure(dir=create_dir)\n",
"all_files = os.listdir(str(tmpdir))\n",
"result = filescheme.get_file_list(str(tmpdir), all_files, filterfunc)\n",
"item = {'name': 'foo', 'absname': str(path)}\n",
"assert (item in result) == expected\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assert'"
] |
[
"def FUNC_9(self):...\n",
"VAR_25 = messageCounts['fatal']\n",
"VAR_26 = messageCounts['linkerror']\n",
"VAR_27 = messageCounts['warning']\n",
"if self.lineNumbers:\n",
"warn('Because --line-numbers was used, no output was saved.')\n",
"if VAR_25:\n",
"success('Successfully generated, but fatal errors were suppressed')\n",
"if VAR_26:\n",
"return\n",
"success('Successfully generated, with {0} linking errors', VAR_26)\n",
"if VAR_27:\n",
"return\n",
"success('Successfully generated, with warnings')\n",
"return\n"
] | [
"def printResultMessage(self):...\n",
"fatals = messageCounts['fatal']\n",
"links = messageCounts['linkerror']\n",
"warnings = messageCounts['warning']\n",
"if self.lineNumbers:\n",
"warn('Because --line-numbers was used, no output was saved.')\n",
"if fatals:\n",
"success('Successfully generated, but fatal errors were suppressed')\n",
"if links:\n",
"return\n",
"success('Successfully generated, with {0} linking errors', links)\n",
"if warnings:\n",
"return\n",
"success('Successfully generated, with warnings')\n",
"return\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Return'",
"Expr'",
"Condition",
"Return'",
"Expr'",
"Return'"
] |
[
"def FUNC_35(VAR_50):...\n",
""
] | [
"def resp_read(chunk_size):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_2(self, VAR_2, VAR_4):...\n",
"if (VAR_2, VAR_4) in self.cookies:\n"
] | [
"def expireCookie(self, cookie_name, path):...\n",
"if (cookie_name, path) in self.cookies:\n"
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_4(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.module:\n",
"self.module = frappe.db.get_value('DocType', self.ref_doctype, 'module')\n",
"if not self.is_standard:\n",
"self.is_standard = 'No'\n",
"if self.is_standard == 'No':\n",
"if frappe.session.user == 'Administrator' and getattr(frappe.local.conf,\n",
"if self.report_type != 'Report Builder':\n",
"if self.is_standard == 'Yes' and frappe.session.user != 'Administrator':\n",
"self.is_standard = 'Yes'\n",
"frappe.only_for('Script Manager', True)\n",
"if frappe.db.get_value('Report', self.name, 'is_standard') == 'Yes':\n",
"frappe.throw(_(\n 'Only Administrator can save a standard report. Please rename and save.'))\n",
"if self.report_type == 'Report Builder':\n",
"frappe.throw(_(\n 'Cannot edit a standard report. Please duplicate and create a new report'))\n",
"self.update_report_json()\n"
] | [
"def validate(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.module:\n",
"self.module = frappe.db.get_value('DocType', self.ref_doctype, 'module')\n",
"if not self.is_standard:\n",
"self.is_standard = 'No'\n",
"if self.is_standard == 'No':\n",
"if frappe.session.user == 'Administrator' and getattr(frappe.local.conf,\n",
"if self.report_type != 'Report Builder':\n",
"if self.is_standard == 'Yes' and frappe.session.user != 'Administrator':\n",
"self.is_standard = 'Yes'\n",
"frappe.only_for('Script Manager', True)\n",
"if frappe.db.get_value('Report', self.name, 'is_standard') == 'Yes':\n",
"frappe.throw(_(\n 'Only Administrator can save a standard report. Please rename and save.'))\n",
"if self.report_type == 'Report Builder':\n",
"frappe.throw(_(\n 'Cannot edit a standard report. Please duplicate and create a new report'))\n",
"self.update_report_json()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_9(VAR_2):...\n",
"if not VAR_2 or not FUNC_0(VAR_2):\n",
"return\n",
"VAR_3 = VAR_2.id\n",
"ub.session.delete(VAR_2)\n",
"ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == VAR_3).delete()\n",
"ub.session.add(ub.ShelfArchive(uuid=cur_shelf.uuid, user_id=cur_shelf.user_id))\n",
"ub.session_commit('successfully deleted Shelf {}'.format(VAR_2.name))\n"
] | [
"def delete_shelf_helper(cur_shelf):...\n",
"if not cur_shelf or not check_shelf_edit_permissions(cur_shelf):\n",
"return\n",
"shelf_id = cur_shelf.id\n",
"ub.session.delete(cur_shelf)\n",
"ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id).delete()\n",
"ub.session.add(ub.ShelfArchive(uuid=cur_shelf.uuid, user_id=cur_shelf.user_id))\n",
"ub.session_commit('successfully deleted Shelf {}'.format(cur_shelf.name))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_6(self, VAR_2, VAR_3):...\n",
"self.fetches = []\n",
"async def FUNC_14(VAR_14, VAR_15, VAR_16, VAR_17=None, VAR_18=None):...\n",
"\"\"\"docstring\"\"\"\n",
"def FUNC_15(VAR_37):...\n",
"VAR_39, VAR_23 = VAR_37\n",
"VAR_16.write(VAR_39)\n",
"return VAR_23\n"
] | [
"def make_homeserver(self, reactor, clock):...\n",
"self.fetches = []\n",
"async def get_file(destination, path, output_stream, args=None, max_size=None):...\n",
"\"\"\"docstring\"\"\"\n",
"def write_to(r):...\n",
"data, response = r\n",
"output_stream.write(data)\n",
"return response\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"AsyncFunctionDef'",
"Docstring",
"FunctionDef'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_7(self):...\n",
"if self.is_standard == 'Yes' and not cint(getattr(frappe.local.conf,\n",
"frappe.throw(_('You are not allowed to delete Standard Report'))\n",
"delete_custom_role('report', self.name)\n"
] | [
"def on_trash(self):...\n",
"if self.is_standard == 'Yes' and not cint(getattr(frappe.local.conf,\n",
"frappe.throw(_('You are not allowed to delete Standard Report'))\n",
"delete_custom_role('report', self.name)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_41(self, VAR_28, VAR_35):...\n",
"VAR_15 = self.getUserId()\n",
"VAR_80 = self.playlistdb.createM3U(VAR_28=plid, VAR_15=userid, addrstr=hostaddr\n )\n",
"VAR_81 = self.playlistdb.getName(VAR_28, VAR_15)\n",
"if VAR_80 and VAR_81:\n",
"return self.serve_string_as_file(VAR_80, VAR_81 + '.m3u')\n"
] | [
"def api_downloadm3u(self, plid, hostaddr):...\n",
"userid = self.getUserId()\n",
"pls = self.playlistdb.createM3U(plid=plid, userid=userid, addrstr=hostaddr)\n",
"name = self.playlistdb.getName(plid, userid)\n",
"if pls and name:\n",
"return self.serve_string_as_file(pls, name + '.m3u')\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_30(VAR_27):...\n",
"print(VAR_26 + VAR_27)\n"
] | [
"def in_print(s):...\n",
"print(indent_str + s)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_19 = VAR_2.session['connector'].server_id\n",
"VAR_139 = False\n",
"VAR_144 = VAR_2.GET.get('fromid', None)\n",
"VAR_140 = VAR_2.POST.getlist('toids')\n",
"VAR_141 = str(VAR_2.POST.get('to_type', 'image'))\n",
"VAR_145 = None\n",
"if VAR_141 not in ('dataset', 'plate', 'acquisition'):\n",
"VAR_141 = 'Image'\n",
"if VAR_144 is not None and len(VAR_140) == 0:\n",
"VAR_2.session.modified = True\n",
"VAR_53 = VAR_2.GET or VAR_2.POST\n",
"VAR_2.session['fromid'] = VAR_144\n",
"if VAR_53.get('c') is not None:\n",
"if VAR_2.session.get('rdef') is not None:\n",
"VAR_145 = {'c': str(VAR_53.get('c'))}\n",
"if VAR_144 is None:\n",
"return True\n",
"if VAR_53.get('maps'):\n",
"VAR_144 = VAR_2.session.get('fromid', None)\n",
"def FUNC_69(VAR_15):...\n",
"if VAR_53.get('pixel_range'):\n",
"VAR_145['maps'] = json.loads(VAR_53.get('maps'))\n",
"VAR_54 = {}\n",
"VAR_145['pixel_range'] = str(VAR_53.get('pixel_range'))\n",
"if VAR_53.get('m'):\n",
"VAR_222 = []\n",
"VAR_145['m'] = str(VAR_53.get('m'))\n",
"if VAR_53.get('z'):\n",
"VAR_223 = []\n",
"VAR_145['z'] = str(VAR_53.get('z'))\n",
"if VAR_53.get('t'):\n",
"for VAR_212, ch in enumerate(VAR_15.getChannels()):\n",
"VAR_145['t'] = str(VAR_53.get('t'))\n",
"VAR_36 = VAR_2.GET.get('imageId', VAR_2.POST.get('imageId', None))\n",
"VAR_287 = '' if ch.isActive() else '-'\n",
"VAR_54['c'] = ','.join(VAR_222)\n",
"if VAR_36:\n",
"VAR_288 = ch.getWindowStart()\n",
"VAR_54['maps'] = VAR_223\n",
"VAR_145['imageId'] = int(VAR_36)\n",
"if VAR_2.method == 'GET':\n",
"VAR_289 = ch.getWindowEnd()\n",
"VAR_54['m'] = 'g' if VAR_15.isGreyscaleRenderingModel() else 'c'\n",
"VAR_2.session.modified = True\n",
"VAR_68 = ch.getLut()\n",
"VAR_54['z'] = VAR_15.getDefaultZ() + 1\n",
"VAR_2.session['rdef'] = VAR_145\n",
"VAR_223.append({'inverted': {'enabled': ch.isInverted()}})\n",
"VAR_54['t'] = VAR_15.getDefaultT() + 1\n",
"if VAR_2.session.get('fromid') is not None:\n",
"if not VAR_68 or len(VAR_68) == 0:\n",
"return VAR_54\n",
"return True\n",
"VAR_68 = ch.getColor().getHtml()\n",
"VAR_222.append('%s%s|%s:%s$%s' % (VAR_287, VAR_212 + 1, VAR_288, VAR_289,\n VAR_68))\n"
] | [
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"server_id = request.session['connector'].server_id\n",
"json_data = False\n",
"fromid = request.GET.get('fromid', None)\n",
"toids = request.POST.getlist('toids')\n",
"to_type = str(request.POST.get('to_type', 'image'))\n",
"rdef = None\n",
"if to_type not in ('dataset', 'plate', 'acquisition'):\n",
"to_type = 'Image'\n",
"if fromid is not None and len(toids) == 0:\n",
"request.session.modified = True\n",
"r = request.GET or request.POST\n",
"request.session['fromid'] = fromid\n",
"if r.get('c') is not None:\n",
"if request.session.get('rdef') is not None:\n",
"rdef = {'c': str(r.get('c'))}\n",
"if fromid is None:\n",
"return True\n",
"if r.get('maps'):\n",
"fromid = request.session.get('fromid', None)\n",
"def getRenderingSettings(image):...\n",
"if r.get('pixel_range'):\n",
"rdef['maps'] = json.loads(r.get('maps'))\n",
"rv = {}\n",
"rdef['pixel_range'] = str(r.get('pixel_range'))\n",
"if r.get('m'):\n",
"chs = []\n",
"rdef['m'] = str(r.get('m'))\n",
"if r.get('z'):\n",
"maps = []\n",
"rdef['z'] = str(r.get('z'))\n",
"if r.get('t'):\n",
"for i, ch in enumerate(image.getChannels()):\n",
"rdef['t'] = str(r.get('t'))\n",
"imageId = request.GET.get('imageId', request.POST.get('imageId', None))\n",
"act = '' if ch.isActive() else '-'\n",
"rv['c'] = ','.join(chs)\n",
"if imageId:\n",
"start = ch.getWindowStart()\n",
"rv['maps'] = maps\n",
"rdef['imageId'] = int(imageId)\n",
"if request.method == 'GET':\n",
"end = ch.getWindowEnd()\n",
"rv['m'] = 'g' if image.isGreyscaleRenderingModel() else 'c'\n",
"request.session.modified = True\n",
"color = ch.getLut()\n",
"rv['z'] = image.getDefaultZ() + 1\n",
"request.session['rdef'] = rdef\n",
"maps.append({'inverted': {'enabled': ch.isInverted()}})\n",
"rv['t'] = image.getDefaultT() + 1\n",
"if request.session.get('fromid') is not None:\n",
"if not color or len(color) == 0:\n",
"return rv\n",
"return True\n",
"color = ch.getColor().getHtml()\n",
"chs.append('%s%s|%s:%s$%s' % (act, i + 1, start, end, color))\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
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Return'",
"Condition",
"Assign'",
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"For",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Condition",
"Return'",
"Return'",
"Assign'",
"Expr'"
] |
[
"@defer.inlineCallbacks...\n",
"VAR_14 = self.mock_handler.set_avatar_url\n",
"VAR_14.return_value = defer.succeed(())\n",
"VAR_12, VAR_13 = yield self.mock_resource.trigger('PUT', \n '/profile/%s/avatar_url' % VAR_0,\n b'{\"avatar_url\": \"http://my.server/pic.gif\"}')\n",
"self.assertEquals(200, VAR_12)\n",
"self.assertEquals(VAR_14.call_args[0][0].localpart, '1234ABCD')\n",
"self.assertEquals(VAR_14.call_args[0][1].user.localpart, '1234ABCD')\n",
"self.assertEquals(VAR_14.call_args[0][2], 'http://my.server/pic.gif')\n"
] | [
"@defer.inlineCallbacks...\n",
"mocked_set = self.mock_handler.set_avatar_url\n",
"mocked_set.return_value = defer.succeed(())\n",
"code, response = yield self.mock_resource.trigger('PUT', \n '/profile/%s/avatar_url' % myid,\n b'{\"avatar_url\": \"http://my.server/pic.gif\"}')\n",
"self.assertEquals(200, code)\n",
"self.assertEquals(mocked_set.call_args[0][0].localpart, '1234ABCD')\n",
"self.assertEquals(mocked_set.call_args[0][1].user.localpart, '1234ABCD')\n",
"self.assertEquals(mocked_set.call_args[0][2], 'http://my.server/pic.gif')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@VAR_0.route('/api/jobs/<int:job_id>/pin', methods=['PUT'])...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_72 = current_user\n",
"VAR_40 = json.loads(VAR_72.pinned_jobs\n ) if VAR_72.pinned_jobs is not None else []\n",
"if VAR_9 not in VAR_40:\n",
"VAR_40.append(VAR_9)\n",
"VAR_72.pinned_jobs = json.dumps(VAR_40)\n",
"VAR_1.session.add(VAR_72)\n",
"VAR_1.session.commit()\n",
"return jsonify({'success': True, 'message':\n f'Successfully pinned Job (ID={VAR_9}).'})\n"
] | [
"@gui.route('/api/jobs/<int:job_id>/pin', methods=['PUT'])...\n",
"\"\"\"docstring\"\"\"\n",
"u = current_user\n",
"pinned_jobs = json.loads(u.pinned_jobs) if u.pinned_jobs is not None else []\n",
"if job_id not in pinned_jobs:\n",
"pinned_jobs.append(job_id)\n",
"u.pinned_jobs = json.dumps(pinned_jobs)\n",
"db.session.add(u)\n",
"db.session.commit()\n",
"return jsonify({'success': True, 'message':\n f'Successfully pinned Job (ID={job_id}).'})\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_67(self):...\n",
"VAR_135 = self.settings.login_onaccept\n",
"if VAR_135:\n",
"VAR_7 = Storage(dict(VAR_96=self.user))\n",
"if not isinstance(VAR_135, (list, tuple)):\n",
"VAR_135 = [VAR_135]\n",
"for VAR_26 in VAR_135:\n",
"VAR_26(VAR_7)\n"
] | [
"def run_login_onaccept(self):...\n",
"onaccept = self.settings.login_onaccept\n",
"if onaccept:\n",
"form = Storage(dict(vars=self.user))\n",
"if not isinstance(onaccept, (list, tuple)):\n",
"onaccept = [onaccept]\n",
"for callback in onaccept:\n",
"callback(form)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"For",
"Expr'"
] |
[
"@VAR_2.route('/book/<int:book_id>')...\n",
"VAR_63 = calibre_db.get_filtered_book(VAR_5, allow_show_archived=True)\n",
"if VAR_63:\n",
"for FUNC_31 in range(0, len(VAR_63.languages)):\n",
"VAR_3.debug(\n u'Oops! Selected book title is unavailable. File does not exist or is not accessible'\n )\n",
"VAR_63.languages[FUNC_31].language_name = isoLanguages.get_language_name(\n get_locale(), VAR_63.languages[FUNC_31].lang_code)\n",
"VAR_16 = get_cc_columns(filter_config_custom_read=True)\n",
"flash(_(\n u'Oops! Selected book title is unavailable. File does not exist or is not accessible'\n ), category='error')\n",
"VAR_118 = []\n",
"return redirect(url_for('web.index'))\n",
"VAR_119 = ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == VAR_5\n ).all()\n",
"for entry in VAR_119:\n",
"VAR_118.append(entry.shelf)\n",
"if not VAR_87.is_anonymous:\n",
"if not config.config_read_column:\n",
"VAR_142 = None\n",
"VAR_146 = ub.session.query(ub.ReadBook).filter(and_(ub.ReadBook.user_id ==\n int(VAR_87.id), ub.ReadBook.book_id == VAR_5)).all()\n",
"VAR_146 = getattr(VAR_63, 'custom_column_' + str(config.config_read_column))\n",
"VAR_3.error('Custom Column No.%d is not existing in calibre database',\n config.config_read_column)\n",
"VAR_54 = ub.session.query(ub.ArchivedBook).filter(and_(ub.ArchivedBook.\n user_id == int(VAR_87.id), ub.ArchivedBook.book_id == VAR_5)).first()\n",
"VAR_141 = None\n",
"VAR_142 = len(VAR_146) > 0 and VAR_146[0\n ].read_status == ub.ReadBook.STATUS_FINISHED\n",
"VAR_142 = len(VAR_146) > 0 and VAR_146[0].value\n",
"VAR_142 = None\n",
"VAR_141 = VAR_54 and VAR_54.is_archived\n",
"VAR_63.tags = VAR_7(VAR_63.tags, key=lambda tag: tag.name)\n",
"VAR_63 = calibre_db.order_authors(VAR_63)\n",
"VAR_120 = check_send_to_kindle(VAR_63)\n",
"VAR_121 = check_read_formats(VAR_63)\n",
"VAR_122 = []\n",
"for media_format in VAR_63.data:\n",
"if media_format.format.lower() in constants.EXTENSIONS_AUDIO:\n",
"return render_title_template('detail.html', entry=entries, VAR_122=\n audioentries, VAR_16=cc, is_xhr=request.headers.get('X-Requested-With') ==\n 'XMLHttpRequest', VAR_149=entries.title, books_shelfs=book_in_shelfs,\n VAR_142=have_read, VAR_141=is_archived, VAR_120=kindle_list, VAR_121=\n reader_list, VAR_9='book')\n",
"VAR_122.append(media_format.format.lower())\n"
] | [
"@web.route('/book/<int:book_id>')...\n",
"entries = calibre_db.get_filtered_book(book_id, allow_show_archived=True)\n",
"if entries:\n",
"for index in range(0, len(entries.languages)):\n",
"log.debug(\n u'Oops! Selected book title is unavailable. File does not exist or is not accessible'\n )\n",
"entries.languages[index].language_name = isoLanguages.get_language_name(\n get_locale(), entries.languages[index].lang_code)\n",
"cc = get_cc_columns(filter_config_custom_read=True)\n",
"flash(_(\n u'Oops! Selected book title is unavailable. File does not exist or is not accessible'\n ), category='error')\n",
"book_in_shelfs = []\n",
"return redirect(url_for('web.index'))\n",
"shelfs = ub.session.query(ub.BookShelf).filter(ub.BookShelf.book_id == book_id\n ).all()\n",
"for entry in shelfs:\n",
"book_in_shelfs.append(entry.shelf)\n",
"if not current_user.is_anonymous:\n",
"if not config.config_read_column:\n",
"have_read = None\n",
"matching_have_read_book = ub.session.query(ub.ReadBook).filter(and_(ub.\n ReadBook.user_id == int(current_user.id), ub.ReadBook.book_id == book_id)\n ).all()\n",
"matching_have_read_book = getattr(entries, 'custom_column_' + str(config.\n config_read_column))\n",
"log.error('Custom Column No.%d is not existing in calibre database', config\n .config_read_column)\n",
"archived_book = ub.session.query(ub.ArchivedBook).filter(and_(ub.\n ArchivedBook.user_id == int(current_user.id), ub.ArchivedBook.book_id ==\n book_id)).first()\n",
"is_archived = None\n",
"have_read = len(matching_have_read_book) > 0 and matching_have_read_book[0\n ].read_status == ub.ReadBook.STATUS_FINISHED\n",
"have_read = len(matching_have_read_book) > 0 and matching_have_read_book[0\n ].value\n",
"have_read = None\n",
"is_archived = archived_book and archived_book.is_archived\n",
"entries.tags = sort(entries.tags, key=lambda tag: tag.name)\n",
"entries = calibre_db.order_authors(entries)\n",
"kindle_list = check_send_to_kindle(entries)\n",
"reader_list = check_read_formats(entries)\n",
"audioentries = []\n",
"for media_format in entries.data:\n",
"if media_format.format.lower() in constants.EXTENSIONS_AUDIO:\n",
"return render_title_template('detail.html', entry=entries, audioentries=\n audioentries, cc=cc, is_xhr=request.headers.get('X-Requested-With') ==\n 'XMLHttpRequest', title=entries.title, books_shelfs=book_in_shelfs,\n have_read=have_read, is_archived=is_archived, kindle_list=kindle_list,\n reader_list=reader_list, page='book')\n",
"audioentries.append(media_format.format.lower())\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
] | [
"Condition",
"Assign'",
"Condition",
"For",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'",
"Assign'",
"For",
"Expr'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"For",
"Return'",
"Expr'"
] |
[
"async def FUNC_38(self, VAR_45: JsonDict) ->None:...\n",
"\"\"\"docstring\"\"\"\n",
"assert_params_in_dict(VAR_45, ['room_id'])\n",
"VAR_28 = await self.store.get_room_version_id(VAR_45['room_id'])\n",
"VAR_93 = self.event_builder_factory.new(VAR_28, VAR_45)\n",
"VAR_1, VAR_32 = await self.event_creation_handler.create_new_client_event(\n VAR_93=builder)\n",
"VAR_1, VAR_32 = await self.add_display_name_to_third_party_invite(VAR_28,\n VAR_45, VAR_1, VAR_32)\n",
"await self.auth.check_from_context(VAR_28, VAR_1, VAR_32)\n",
"VAR_0.warning('Denying third party invite %r because %s', VAR_1, VAR_170)\n",
"await self._check_signature(VAR_1, VAR_32)\n",
"VAR_1.internal_metadata.send_on_behalf_of = get_domain_from_id(VAR_1.sender)\n",
"VAR_143 = self.hs.get_room_member_handler()\n",
"await VAR_143.send_membership_event(None, VAR_1, VAR_32)\n"
] | [
"async def on_exchange_third_party_invite_request(self, event_dict: JsonDict...\n",
"\"\"\"docstring\"\"\"\n",
"assert_params_in_dict(event_dict, ['room_id'])\n",
"room_version = await self.store.get_room_version_id(event_dict['room_id'])\n",
"builder = self.event_builder_factory.new(room_version, event_dict)\n",
"event, context = await self.event_creation_handler.create_new_client_event(\n builder=builder)\n",
"event, context = await self.add_display_name_to_third_party_invite(room_version\n , event_dict, event, context)\n",
"await self.auth.check_from_context(room_version, event, context)\n",
"logger.warning('Denying third party invite %r because %s', event, e)\n",
"await self._check_signature(event, context)\n",
"event.internal_metadata.send_on_behalf_of = get_domain_from_id(event.sender)\n",
"member_handler = self.hs.get_room_member_handler()\n",
"await member_handler.send_membership_event(None, event, context)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"AsyncFunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_2(self, VAR_1):...\n",
"VAR_17 = VAR_1.MagicMock(class_name='MyRefClass', module_name='my_test_enum')\n",
"VAR_9 = VAR_1.MagicMock()\n",
"from openapi_python_client.parser.properties import RefProperty\n",
"VAR_4 = VAR_28(VAR_5='test', VAR_26=True, default=None, reference=\n fake_reference)\n",
"assert VAR_4.get_imports(VAR_9=prefix) == {\n f'from {VAR_9}.{VAR_17.module_name} import {VAR_17.class_name}',\n 'from typing import Dict', 'from typing import cast'}\n",
"VAR_4.required = False\n",
"assert VAR_4.get_imports(VAR_9=prefix) == {\n f'from {VAR_9}.{VAR_17.module_name} import {VAR_17.class_name}',\n 'from typing import Dict', 'from typing import cast',\n 'from typing import Optional'}\n"
] | [
"def test_get_imports(self, mocker):...\n",
"fake_reference = mocker.MagicMock(class_name='MyRefClass', module_name=\n 'my_test_enum')\n",
"prefix = mocker.MagicMock()\n",
"from openapi_python_client.parser.properties import RefProperty\n",
"p = RefProperty(name='test', required=True, default=None, reference=\n fake_reference)\n",
"assert p.get_imports(prefix=prefix) == {\n f'from {prefix}.{fake_reference.module_name} import {fake_reference.class_name}'\n , 'from typing import Dict', 'from typing import cast'}\n",
"p.required = False\n",
"assert p.get_imports(prefix=prefix) == {\n f'from {prefix}.{fake_reference.module_name} import {fake_reference.class_name}'\n , 'from typing import Dict', 'from typing import cast',\n 'from typing import Optional'}\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"ImportFrom'",
"Assign'",
"Assert'",
"Assign'",
"Assert'"
] |
[
"def FUNC_3(VAR_0, VAR_1):...\n",
"return FUNC_0(VAR_0=request, VAR_1=pk, VAR_2='is_closed', VAR_3=True, VAR_4\n =Comment.CLOSED, VAR_5=_('The topic has been locked'))\n"
] | [
"def lock(request, pk):...\n",
"return _moderate(request=request, pk=pk, field_name='is_closed', to_value=\n True, action=Comment.CLOSED, message=_('The topic has been locked'))\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_0():...\n",
"VAR_6 = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' test_kwarg='tested!'\"\n )\n",
"VAR_7 = unicorn(None, VAR_6)\n",
"VAR_8 = {}\n",
"VAR_9 = VAR_7.render(VAR_8)\n",
"assert '->tested!<-' in VAR_9\n"
] | [
"def test_unicorn_render_kwarg():...\n",
"token = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' test_kwarg='tested!'\"\n )\n",
"unicorn_node = unicorn(None, token)\n",
"context = {}\n",
"actual = unicorn_node.render(context)\n",
"assert '->tested!<-' in actual\n"
] | [
0,
0,
0,
0,
0,
2
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assert'"
] |
[
"def FUNC_4(self):...\n",
"\"\"\"Model with a callable concrete function.\"\"\"\n",
"def __init__(self):...\n",
"VAR_57 = def_function.function(self.multiply, input_signature=[tensor_spec.\n TensorSpec(shape=(), dtype=dtypes.float32), tensor_spec.TensorSpec(\n shape=(), dtype=dtypes.float32)])\n",
"self.pure_concrete_function = VAR_57.get_concrete_function()\n",
"super(CLASS_2, self).__init__()\n",
"def FUNC_45(self, VAR_54, VAR_55):...\n",
"return VAR_54 * VAR_55\n"
] | [
"def testShowAllWithPureConcreteFunction(self):...\n",
"\"\"\"Model with a callable concrete function.\"\"\"\n",
"def __init__(self):...\n",
"function = def_function.function(self.multiply, input_signature=[\n tensor_spec.TensorSpec(shape=(), dtype=dtypes.float32), tensor_spec.\n TensorSpec(shape=(), dtype=dtypes.float32)])\n",
"self.pure_concrete_function = function.get_concrete_function()\n",
"super(DummyModel, self).__init__()\n",
"def multiply(self, a, b):...\n",
"return a * b\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_35(self, VAR_23):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.docstatus:\n",
"self.docstatus = 0\n",
"if VAR_23 == 0:\n",
"if self.docstatus == 0:\n",
"if VAR_23 == 1:\n",
"self._action = 'save'\n",
"if self.docstatus == 1:\n",
"if self.docstatus == 1:\n",
"if VAR_23 == 2:\n",
"self._action = 'submit'\n",
"self._action = 'update_after_submit'\n",
"if self.docstatus == 2:\n",
"self.check_permission('submit')\n",
"self.check_permission('submit')\n",
"self._action = 'cancel'\n",
"self.check_permission('cancel')\n"
] | [
"def check_docstatus_transition(self, docstatus):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.docstatus:\n",
"self.docstatus = 0\n",
"if docstatus == 0:\n",
"if self.docstatus == 0:\n",
"if docstatus == 1:\n",
"self._action = 'save'\n",
"if self.docstatus == 1:\n",
"if self.docstatus == 1:\n",
"if docstatus == 2:\n",
"self._action = 'submit'\n",
"self._action = 'update_after_submit'\n",
"if self.docstatus == 2:\n",
"self.check_permission('submit')\n",
"self.check_permission('submit')\n",
"self._action = 'cancel'\n",
"self.check_permission('cancel')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_19(self):...\n",
"VAR_19 = self.helper.create_room_as(self.user_id)\n",
"VAR_20, VAR_21 = self.make_request('PUT',\n b'directory/room/%23unofficial_test%3Atest', ('{\"room_id\":\"%s\"}' % (\n VAR_19,)).encode('ascii'))\n",
"self.assertEquals(200, VAR_21.code, VAR_21.result)\n"
] | [
"def test_allowed(self):...\n",
"room_id = self.helper.create_room_as(self.user_id)\n",
"request, channel = self.make_request('PUT',\n b'directory/room/%23unofficial_test%3Atest', ('{\"room_id\":\"%s\"}' % (\n room_id,)).encode('ascii'))\n",
"self.assertEquals(200, channel.code, channel.result)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"\"\"\"Test starting qutebrowser with special arguments/environments.\"\"\"\n",
"import subprocess\n",
"import socket\n",
"import sys\n",
"import logging\n",
"import re\n",
"import pytest\n",
"from PyQt5.QtCore import QProcess, qVersion\n",
"from helpers import utils\n",
"VAR_0 = pytest.mark.skipif(sys.hexversion >= 50790400, reason=\n \"Python >= 3.7 doesn't force ASCII locale with LC_ALL=C\")\n",
"def FUNC_0(VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_11 = ['--debug', '--json-logging', '--no-err-windows']\n",
"if VAR_1.webengine:\n",
"VAR_11 += ['--backend', 'webengine']\n",
"VAR_11 += ['--backend', 'webkit']\n",
"if qVersion() == '5.7.1':\n",
"VAR_11 += ['--qt-flag', 'disable-seccomp-filter-sandbox']\n",
"VAR_11.append('about:blank')\n",
"return VAR_11\n"
] | [
"\"\"\"Test starting qutebrowser with special arguments/environments.\"\"\"\n",
"import subprocess\n",
"import socket\n",
"import sys\n",
"import logging\n",
"import re\n",
"import pytest\n",
"from PyQt5.QtCore import QProcess, qVersion\n",
"from helpers import utils\n",
"ascii_locale = pytest.mark.skipif(sys.hexversion >= 50790400, reason=\n \"Python >= 3.7 doesn't force ASCII locale with LC_ALL=C\")\n",
"def _base_args(config):...\n",
"\"\"\"docstring\"\"\"\n",
"args = ['--debug', '--json-logging', '--no-err-windows']\n",
"if config.webengine:\n",
"args += ['--backend', 'webengine']\n",
"args += ['--backend', 'webkit']\n",
"if qVersion() == '5.7.1':\n",
"args += ['--qt-flag', 'disable-seccomp-filter-sandbox']\n",
"args.append('about:blank')\n",
"return args\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Expr'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"AugAssign'",
"AugAssign'",
"Condition",
"AugAssign'",
"Expr'",
"Return'"
] |
[
"@administrator_required...\n",
"VAR_3 = {'version': spirit.__version__, 'django_version': django.\n get_version(), 'category_count': Category.objects.all().count() - 1,\n 'topics_count': Topic.objects.all().count(), 'comments_count': Comment.\n objects.all().count(), 'users_count': VAR_0.objects.all().count(),\n 'flags_count': CommentFlag.objects.filter(is_closed=False).count(),\n 'likes_count': CommentLike.objects.all().count()}\n",
"return render(VAR_1, 'spirit/admin/dashboard.html', VAR_3)\n"
] | [
"@administrator_required...\n",
"context = {'version': spirit.__version__, 'django_version': django.\n get_version(), 'category_count': Category.objects.all().count() - 1,\n 'topics_count': Topic.objects.all().count(), 'comments_count': Comment.\n objects.all().count(), 'users_count': User.objects.all().count(),\n 'flags_count': CommentFlag.objects.filter(is_closed=False).count(),\n 'likes_count': CommentLike.objects.all().count()}\n",
"return render(request, 'spirit/admin/dashboard.html', context)\n"
] | [
0,
0,
0
] | [
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_43(VAR_110, VAR_111):...\n",
"if 'firstrunstart' in VAR_111:\n",
"VAR_111.remove('firstrunstart')\n",
"if 'firstrunend' in VAR_111:\n",
"VAR_111.remove('firstrunend')\n",
"return ['firstrunstart'] + VAR_110 + VAR_111 + ['firstrunend']\n"
] | [
"def custom_insert_order(existing, missing):...\n",
"if 'firstrunstart' in missing:\n",
"missing.remove('firstrunstart')\n",
"if 'firstrunend' in missing:\n",
"missing.remove('firstrunend')\n",
"return ['firstrunstart'] + existing + missing + ['firstrunend']\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Return'"
] |
[
"import itertools\n",
"from flask import request, abort, _app_ctx_stack, redirect\n",
"from flask_security.core import AnonymousUser\n",
"from security_monkey.datastore import User\n",
"from flask.ext.login import current_user\n",
"VAR_15 = None\n",
"from .models import RBACRole, RBACUserMixin\n",
"from . import anonymous\n",
"from flask import Response\n",
"import json\n",
"\"\"\"\n This class record rules for access controling.\n \"\"\"\n",
"def __init__(self):...\n",
"self._allowed = []\n",
"self._exempt = []\n",
"self.seted = False\n",
"def FUNC_0(self, VAR_0, VAR_1, VAR_2, VAR_3=True):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_3:\n",
"for r in VAR_0.get_children():\n",
"VAR_16 = VAR_0.name, VAR_1, VAR_2\n",
"VAR_16 = r.name, VAR_1, VAR_2\n",
"if VAR_16 not in self._allowed:\n",
"if VAR_16 not in self._allowed:\n",
"self._allowed.append(VAR_16)\n",
"def FUNC_1(self, VAR_4):...\n",
"self._allowed.append(VAR_16)\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_4 in self._exempt:\n",
"self._exempt.append(VAR_4)\n",
"def FUNC_2(self, VAR_0, VAR_1, VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"return (VAR_0, VAR_1, VAR_2) in self._allowed\n"
] | [
"import itertools\n",
"from flask import request, abort, _app_ctx_stack, redirect\n",
"from flask_security.core import AnonymousUser\n",
"from security_monkey.datastore import User\n",
"from flask.ext.login import current_user\n",
"current_user = None\n",
"from .models import RBACRole, RBACUserMixin\n",
"from . import anonymous\n",
"from flask import Response\n",
"import json\n",
"\"\"\"\n This class record rules for access controling.\n \"\"\"\n",
"def __init__(self):...\n",
"self._allowed = []\n",
"self._exempt = []\n",
"self.seted = False\n",
"def allow(self, role, method, resource, with_children=True):...\n",
"\"\"\"docstring\"\"\"\n",
"if with_children:\n",
"for r in role.get_children():\n",
"permission = role.name, method, resource\n",
"permission = r.name, method, resource\n",
"if permission not in self._allowed:\n",
"if permission not in self._allowed:\n",
"self._allowed.append(permission)\n",
"def exempt(self, view_func):...\n",
"self._allowed.append(permission)\n",
"\"\"\"docstring\"\"\"\n",
"if not view_func in self._exempt:\n",
"self._exempt.append(view_func)\n",
"def is_allowed(self, role, method, resource):...\n",
"\"\"\"docstring\"\"\"\n",
"return (role, method, resource) in self._allowed\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
] | [
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Docstring",
"Condition",
"For",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"FunctionDef'",
"Expr'",
"Docstring",
"Condition",
"Expr'",
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"@classmethod...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_12 = list(VAR_12)\n",
"VAR_12.reverse()\n",
"while VAR_12:\n",
"VAR_30 = VAR_12.pop()\n",
"return VAR_10\n",
"if ITraversable.providedBy(VAR_10):\n",
"VAR_10 = getattr(VAR_10, VAR_9.traverseMethod)(VAR_30)\n",
"VAR_10 = traversePathElement(VAR_10, VAR_30, VAR_12, VAR_11=request)\n"
] | [
"@classmethod...\n",
"\"\"\"docstring\"\"\"\n",
"path_items = list(path_items)\n",
"path_items.reverse()\n",
"while path_items:\n",
"name = path_items.pop()\n",
"return base\n",
"if ITraversable.providedBy(base):\n",
"base = getattr(base, cls.traverseMethod)(name)\n",
"base = traversePathElement(base, name, path_items, request=request)\n"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
1,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Assign'"
] |
[
"\"\"\"Tests REST events for /profile paths.\"\"\"\n",
"import json\n",
"from mock import Mock\n",
"from twisted.internet import defer\n",
"import synapse.types\n",
"from synapse.api.errors import AuthError, SynapseError\n",
"from synapse.rest import admin\n",
"from synapse.rest.client.v1 import login, profile, room\n",
"from tests import unittest\n",
"from ....utils import MockHttpResource, setup_test_homeserver\n",
"VAR_0 = '@1234ABCD:test'\n",
"VAR_1 = '/_matrix/client/r0'\n",
"\"\"\" Tests rest layer of profile management.\n\n Todo: move these into ProfileTestCase\n \"\"\"\n",
"@defer.inlineCallbacks...\n",
"self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)\n",
"self.mock_handler = Mock(spec=['get_displayname', 'set_displayname',\n 'get_avatar_url', 'set_avatar_url', 'check_profile_query_allowed'])\n",
"self.mock_handler.get_displayname.return_value = defer.succeed(Mock())\n",
"self.mock_handler.set_displayname.return_value = defer.succeed(Mock())\n",
"self.mock_handler.get_avatar_url.return_value = defer.succeed(Mock())\n",
"self.mock_handler.set_avatar_url.return_value = defer.succeed(Mock())\n",
"self.mock_handler.check_profile_query_allowed.return_value = defer.succeed(Mock\n ())\n",
"VAR_5 = yield setup_test_homeserver(self.addCleanup, 'test', http_client=\n None, resource_for_client=self.mock_resource, federation=Mock(),\n federation_client=Mock(), profile_handler=self.mock_handler)\n",
"async def FUNC_20(VAR_9=None, VAR_10=False):...\n",
"return synapse.types.create_requester(VAR_0)\n"
] | [
"\"\"\"Tests REST events for /profile paths.\"\"\"\n",
"import json\n",
"from mock import Mock\n",
"from twisted.internet import defer\n",
"import synapse.types\n",
"from synapse.api.errors import AuthError, SynapseError\n",
"from synapse.rest import admin\n",
"from synapse.rest.client.v1 import login, profile, room\n",
"from tests import unittest\n",
"from ....utils import MockHttpResource, setup_test_homeserver\n",
"myid = '@1234ABCD:test'\n",
"PATH_PREFIX = '/_matrix/client/r0'\n",
"\"\"\" Tests rest layer of profile management.\n\n Todo: move these into ProfileTestCase\n \"\"\"\n",
"@defer.inlineCallbacks...\n",
"self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)\n",
"self.mock_handler = Mock(spec=['get_displayname', 'set_displayname',\n 'get_avatar_url', 'set_avatar_url', 'check_profile_query_allowed'])\n",
"self.mock_handler.get_displayname.return_value = defer.succeed(Mock())\n",
"self.mock_handler.set_displayname.return_value = defer.succeed(Mock())\n",
"self.mock_handler.get_avatar_url.return_value = defer.succeed(Mock())\n",
"self.mock_handler.set_avatar_url.return_value = defer.succeed(Mock())\n",
"self.mock_handler.check_profile_query_allowed.return_value = defer.succeed(Mock\n ())\n",
"hs = yield setup_test_homeserver(self.addCleanup, 'test', http_client=None,\n resource_for_client=self.mock_resource, federation=Mock(),\n federation_client=Mock(), profile_handler=self.mock_handler)\n",
"async def _get_user_by_req(request=None, allow_guest=False):...\n",
"return synapse.types.create_requester(myid)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
0,
0
] | [
"Expr'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"AsyncFunctionDef'",
"Return'"
] |
[
"def FUNC_1(VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_23 = socket.AF_INET\n",
"VAR_35 = socket.getaddrinfo(VAR_1 or None, None, socket.AF_UNSPEC, socket.\n SOCK_STREAM)\n",
"return VAR_23\n",
"if not VAR_35:\n",
"return VAR_23\n",
"VAR_36 = VAR_35[0]\n",
"return VAR_36[0]\n"
] | [
"def lookup_family(hostname):...\n",
"\"\"\"docstring\"\"\"\n",
"fallback = socket.AF_INET\n",
"hostnames = socket.getaddrinfo(hostname or None, None, socket.AF_UNSPEC,\n socket.SOCK_STREAM)\n",
"return fallback\n",
"if not hostnames:\n",
"return fallback\n",
"h = hostnames[0]\n",
"return h[0]\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Return'",
"Condition",
"Return'",
"Assign'",
"Return'"
] |
[
"def __call__(self, VAR_17=None, VAR_18={}, VAR_19=None, **VAR_20):...\n",
"return 'dummy'\n"
] | [
"def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw):...\n",
"return 'dummy'\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_2.method == 'POST':\n",
"return JsonResponse({'Error': 'Need to POST to chgrp'}, VAR_313=405)\n",
"VAR_20 = getIntOrDefault(VAR_2, 'group_id', None)\n",
"if VAR_20 is None:\n",
"return JsonResponse({'Error': 'chgrp: No group_id specified'})\n",
"VAR_20 = VAR_241(VAR_20)\n",
"def FUNC_86(VAR_71):...\n",
"for VAR_433 in ['Dataset', 'Image', 'Plate']:\n",
"VAR_187 = VAR_71.POST.get(VAR_433, None)\n",
"VAR_101 = VAR_5.getObject('ExperimenterGroup', VAR_20)\n",
"if VAR_187 is not None:\n",
"VAR_226 = VAR_2.POST.get('new_container_name', None)\n",
"for o in list(VAR_5.getObjects(VAR_433, VAR_187.split(','))):\n",
"VAR_227 = VAR_2.POST.get('new_container_type', None)\n",
"return o.getDetails().owner.id.val\n",
"VAR_228 = None\n",
"VAR_229 = FUNC_86(VAR_2)\n",
"VAR_5.SERVICE_OPTS.setOmeroUser(VAR_229)\n",
"if VAR_226 is not None and len(VAR_226) > 0 and VAR_227 is not None:\n",
"VAR_5.SERVICE_OPTS.setOmeroGroup(VAR_20)\n",
"if VAR_228 is None:\n",
"VAR_228 = VAR_5.createContainer(VAR_227, VAR_226)\n",
"VAR_332 = VAR_2.POST.get('target_id', None)\n",
"VAR_225 = ['Project', 'Dataset', 'Image', 'Screen', 'Plate']\n",
"VAR_228 = VAR_332 is not None and VAR_332.split('-')[1] or None\n",
"for VAR_215 in VAR_225:\n",
"VAR_154 = VAR_2.POST.get(VAR_215, None)\n",
"VAR_44 = VAR_2.POST.get('Project', [])\n",
"if VAR_154 is not None:\n",
"VAR_45 = VAR_2.POST.get('Dataset', [])\n",
"VAR_144 = [int(VAR_40) for VAR_40 in VAR_154.split(',')]\n",
"VAR_46 = VAR_2.POST.get('Image', [])\n",
"VAR_305 = VAR_2.POST.getlist('fileset')\n",
"VAR_47 = VAR_2.POST.get('Screen', [])\n",
"if len(VAR_305) > 0:\n",
"VAR_48 = VAR_2.POST.get('Plate', [])\n",
"if VAR_215 == 'Dataset':\n",
"VAR_0.debug('chgrp to group:%s %s-%s' % (VAR_20, VAR_215, VAR_144))\n",
"if VAR_44:\n",
"VAR_5.regroupFilesets(dsIds=obj_ids, VAR_305=fsIds)\n",
"for VAR_365 in VAR_5.getObjects('Fileset', VAR_305):\n",
"VAR_84 = VAR_5.chgrpObjects(VAR_215, VAR_144, VAR_20, VAR_228)\n",
"VAR_44 = [VAR_241(x) for x in VAR_44.split(',')]\n",
"if VAR_45:\n",
"VAR_144.extend([VAR_318.id for VAR_318 in VAR_365.copyImages()])\n",
"VAR_144 = list(set(VAR_144))\n",
"VAR_198 = VAR_345(VAR_84)\n",
"VAR_45 = [VAR_241(x) for x in VAR_45.split(',')]\n",
"if VAR_46:\n",
"VAR_2.session['callback'][VAR_198] = {'job_type': 'chgrp', 'group': VAR_101\n .getName(), 'to_group_id': VAR_20, 'dtype': VAR_215, 'obj_ids': VAR_144,\n 'job_name': 'Change group', 'start_time': datetime.datetime.now(),\n 'status': 'in progress'}\n",
"VAR_46 = [VAR_241(x) for x in VAR_46.split(',')]\n",
"if VAR_47:\n",
"VAR_2.session.modified = True\n",
"VAR_47 = [VAR_241(x) for x in VAR_47.split(',')]\n",
"if VAR_48:\n",
"VAR_48 = [VAR_241(x) for x in VAR_48.split(',')]\n",
"VAR_230 = FUNC_70(VAR_5, VAR_44, VAR_45, VAR_46, VAR_47, VAR_48, VAR_2.\n session.get('user_id'))\n",
"return JsonResponse({'update': VAR_230})\n"
] | [
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"if not request.method == 'POST':\n",
"return JsonResponse({'Error': 'Need to POST to chgrp'}, status=405)\n",
"group_id = getIntOrDefault(request, 'group_id', None)\n",
"if group_id is None:\n",
"return JsonResponse({'Error': 'chgrp: No group_id specified'})\n",
"group_id = long(group_id)\n",
"def getObjectOwnerId(r):...\n",
"for t in ['Dataset', 'Image', 'Plate']:\n",
"ids = r.POST.get(t, None)\n",
"group = conn.getObject('ExperimenterGroup', group_id)\n",
"if ids is not None:\n",
"new_container_name = request.POST.get('new_container_name', None)\n",
"for o in list(conn.getObjects(t, ids.split(','))):\n",
"new_container_type = request.POST.get('new_container_type', None)\n",
"return o.getDetails().owner.id.val\n",
"container_id = None\n",
"ownerId = getObjectOwnerId(request)\n",
"conn.SERVICE_OPTS.setOmeroUser(ownerId)\n",
"if new_container_name is not None and len(new_container_name\n",
"conn.SERVICE_OPTS.setOmeroGroup(group_id)\n",
"if container_id is None:\n",
"container_id = conn.createContainer(new_container_type, new_container_name)\n",
"target_id = request.POST.get('target_id', None)\n",
"dtypes = ['Project', 'Dataset', 'Image', 'Screen', 'Plate']\n",
"container_id = target_id is not None and target_id.split('-')[1] or None\n",
"for dtype in dtypes:\n",
"oids = request.POST.get(dtype, None)\n",
"project_ids = request.POST.get('Project', [])\n",
"if oids is not None:\n",
"dataset_ids = request.POST.get('Dataset', [])\n",
"obj_ids = [int(oid) for oid in oids.split(',')]\n",
"image_ids = request.POST.get('Image', [])\n",
"fsIds = request.POST.getlist('fileset')\n",
"screen_ids = request.POST.get('Screen', [])\n",
"if len(fsIds) > 0:\n",
"plate_ids = request.POST.get('Plate', [])\n",
"if dtype == 'Dataset':\n",
"logger.debug('chgrp to group:%s %s-%s' % (group_id, dtype, obj_ids))\n",
"if project_ids:\n",
"conn.regroupFilesets(dsIds=obj_ids, fsIds=fsIds)\n",
"for fs in conn.getObjects('Fileset', fsIds):\n",
"handle = conn.chgrpObjects(dtype, obj_ids, group_id, container_id)\n",
"project_ids = [long(x) for x in project_ids.split(',')]\n",
"if dataset_ids:\n",
"obj_ids.extend([i.id for i in fs.copyImages()])\n",
"obj_ids = list(set(obj_ids))\n",
"jobId = str(handle)\n",
"dataset_ids = [long(x) for x in dataset_ids.split(',')]\n",
"if image_ids:\n",
"request.session['callback'][jobId] = {'job_type': 'chgrp', 'group': group.\n getName(), 'to_group_id': group_id, 'dtype': dtype, 'obj_ids': obj_ids,\n 'job_name': 'Change group', 'start_time': datetime.datetime.now(),\n 'status': 'in progress'}\n",
"image_ids = [long(x) for x in image_ids.split(',')]\n",
"if screen_ids:\n",
"request.session.modified = True\n",
"screen_ids = [long(x) for x in screen_ids.split(',')]\n",
"if plate_ids:\n",
"plate_ids = [long(x) for x in plate_ids.split(',')]\n",
"update = getAllObjects(conn, project_ids, dataset_ids, image_ids,\n screen_ids, plate_ids, request.session.get('user_id'))\n",
"return JsonResponse({'update': update})\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
] | [
"Condition",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"FunctionDef'",
"For",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"For",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"For",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_0(VAR_5, VAR_6):...\n",
"FUNC_1()\n"
] | [
"def signal_store_user_session(object, user):...\n",
"store_user_session()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"VAR_5 = super().default_config()\n",
"VAR_5['worker_app'] = 'yes'\n",
"return VAR_5\n"
] | [
"def default_config(self):...\n",
"conf = super().default_config()\n",
"conf['worker_app'] = 'yes'\n",
"return conf\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_168(*VAR_9, **VAR_13):...\n",
"VAR_27 = None\n",
"VAR_27 = VAR_10(*VAR_9, **b)\n",
"thread.start_new_thread(VAR_26, (VAR_27,))\n",
"return VAR_27\n"
] | [
"def __completion(*a, **b):...\n",
"d = None\n",
"d = f(*a, **b)\n",
"thread.start_new_thread(callback, (d,))\n",
"return d\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_10(self, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16):...\n",
"VAR_32 = VAR_12.width\n",
"VAR_33 = VAR_12.height\n",
"if VAR_32 * VAR_33 >= self.max_image_pixels:\n",
"VAR_0.info('Image too large to thumbnail %r x %r > %r', VAR_32, VAR_33,\n self.max_image_pixels)\n",
"if VAR_12.transpose_method is not None:\n",
"return\n",
"VAR_32, VAR_33 = VAR_12.transpose()\n",
"if VAR_15 == 'crop':\n",
"VAR_35 = VAR_12.crop(VAR_13, VAR_14, VAR_16)\n",
"if VAR_15 == 'scale':\n",
"return VAR_35\n",
"VAR_13, VAR_14 = VAR_12.aspect(VAR_13, VAR_14)\n",
"VAR_35 = None\n",
"VAR_13 = min(VAR_32, VAR_13)\n",
"VAR_14 = min(VAR_33, VAR_14)\n",
"VAR_35 = VAR_12.scale(VAR_13, VAR_14, VAR_16)\n"
] | [
"def _generate_thumbnail(self, thumbnailer, t_width, t_height, t_method, t_type...\n",
"m_width = thumbnailer.width\n",
"m_height = thumbnailer.height\n",
"if m_width * m_height >= self.max_image_pixels:\n",
"logger.info('Image too large to thumbnail %r x %r > %r', m_width, m_height,\n self.max_image_pixels)\n",
"if thumbnailer.transpose_method is not None:\n",
"return\n",
"m_width, m_height = thumbnailer.transpose()\n",
"if t_method == 'crop':\n",
"t_byte_source = thumbnailer.crop(t_width, t_height, t_type)\n",
"if t_method == 'scale':\n",
"return t_byte_source\n",
"t_width, t_height = thumbnailer.aspect(t_width, t_height)\n",
"t_byte_source = None\n",
"t_width = min(m_width, t_width)\n",
"t_height = min(m_height, t_height)\n",
"t_byte_source = thumbnailer.scale(t_width, t_height, t_type)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_17(VAR_10, VAR_11, VAR_20=None, VAR_21=False, VAR_6=None, VAR_17=...\n",
"\"\"\"docstring\"\"\"\n",
"if FUNC_9(VAR_10):\n",
"FUNC_7(VAR_10, VAR_11)\n",
"if FUNC_10(VAR_10):\n",
"if VAR_21:\n",
"FUNC_16(VAR_10, VAR_11, VAR_20, VAR_17=hashes)\n",
"if VAR_6 is None:\n",
"write_delete_marker_file(VAR_11)\n",
"VAR_6 = CLASS_4()\n",
"FUNC_15(VAR_10, VAR_11, VAR_20, VAR_6, VAR_17=hashes, VAR_18=progress_bar)\n"
] | [
"def unpack_url(link, location, download_dir=None, only_download=False,...\n",
"\"\"\"docstring\"\"\"\n",
"if is_vcs_url(link):\n",
"unpack_vcs_link(link, location)\n",
"if is_file_url(link):\n",
"if only_download:\n",
"unpack_file_url(link, location, download_dir, hashes=hashes)\n",
"if session is None:\n",
"write_delete_marker_file(location)\n",
"session = PipSession()\n",
"unpack_http_url(link, location, download_dir, session, hashes=hashes,\n progress_bar=progress_bar)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Condition",
"Expr'",
"Condition",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_2(self) ->str:...\n",
"\"\"\"docstring\"\"\"\n",
"if self.required:\n",
"return f'List[{self.inner_property.get_type_string()}]'\n",
"return f'Optional[List[{self.inner_property.get_type_string()}]]'\n"
] | [
"def get_type_string(self) ->str:...\n",
"\"\"\"docstring\"\"\"\n",
"if self.required:\n",
"return f'List[{self.inner_property.get_type_string()}]'\n",
"return f'Optional[List[{self.inner_property.get_type_string()}]]'\n"
] | [
0,
0,
5,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_5(self):...\n",
"VAR_6 = self.get_success(self.handler.check_device_registered(VAR_5=\n '@theresa:foo', VAR_6=None, initial_device_display_name='display'))\n",
"VAR_11 = self.get_success(self.handler.store.get_device('@theresa:foo', VAR_6))\n",
"self.assertEqual(VAR_11['display_name'], 'display')\n"
] | [
"def test_device_id_is_made_up_if_unspecified(self):...\n",
"device_id = self.get_success(self.handler.check_device_registered(user_id=\n '@theresa:foo', device_id=None, initial_device_display_name='display'))\n",
"dev = self.get_success(self.handler.store.get_device('@theresa:foo', device_id)\n )\n",
"self.assertEqual(dev['display_name'], 'display')\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"@VAR_6.route('/obj/<path:obj_path>')...\n",
"VAR_13 = FUNC_6(VAR_10)\n",
"VAR_12 = Headers()\n",
"VAR_15 = send_file(VAR_13, cache_timeout=datetime.timedelta(days=365).\n total_seconds(), add_etags=True, conditional=True)\n",
"VAR_15.headers.extend(VAR_12)\n",
"return VAR_15\n"
] | [
"@scope_blueprint.route('/obj/<path:obj_path>')...\n",
"path = _get_obj_absolute_path(obj_path)\n",
"headers = Headers()\n",
"response = send_file(path, cache_timeout=datetime.timedelta(days=365).\n total_seconds(), add_etags=True, conditional=True)\n",
"response.headers.extend(headers)\n",
"return response\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_18(VAR_10, VAR_6, VAR_22, VAR_17, VAR_18):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_64 = VAR_10.url.split('#', 1)[0]\n",
"VAR_15 = VAR_6.get(VAR_64, VAR_102={'Accept-Encoding': 'identity'}, VAR_34=True\n )\n",
"VAR_1.critical('HTTP error %s while getting %s', exc.response.status_code,\n VAR_10)\n",
"VAR_57 = VAR_15.headers.get('content-type', '')\n",
"VAR_15.raise_for_status()\n",
"VAR_19 = VAR_10.filename\n",
"VAR_65 = VAR_15.headers.get('content-disposition')\n",
"if VAR_65:\n",
"VAR_90, VAR_91 = cgi.parse_header(VAR_65)\n",
"VAR_45 = splitext(VAR_19)[1]\n",
"VAR_19 = VAR_91.get('filename') or VAR_19\n",
"if not VAR_45:\n",
"VAR_45 = mimetypes.guess_extension(VAR_57)\n",
"if not VAR_45 and VAR_10.url != VAR_15.url:\n",
"if VAR_45:\n",
"VAR_45 = os.path.splitext(VAR_15.url)[1]\n",
"VAR_66 = os.path.join(VAR_22, VAR_19)\n",
"VAR_19 += VAR_45\n",
"if VAR_45:\n",
"FUNC_13(VAR_15, VAR_10, VAR_16, VAR_17, VAR_18)\n",
"VAR_19 += VAR_45\n",
"return VAR_66, VAR_57\n"
] | [
"def _download_http_url(link, session, temp_dir, hashes, progress_bar):...\n",
"\"\"\"docstring\"\"\"\n",
"target_url = link.url.split('#', 1)[0]\n",
"resp = session.get(target_url, headers={'Accept-Encoding': 'identity'},\n stream=True)\n",
"logger.critical('HTTP error %s while getting %s', exc.response.status_code,\n link)\n",
"content_type = resp.headers.get('content-type', '')\n",
"resp.raise_for_status()\n",
"filename = link.filename\n",
"content_disposition = resp.headers.get('content-disposition')\n",
"if content_disposition:\n",
"type, params = cgi.parse_header(content_disposition)\n",
"ext = splitext(filename)[1]\n",
"filename = params.get('filename') or filename\n",
"if not ext:\n",
"ext = mimetypes.guess_extension(content_type)\n",
"if not ext and link.url != resp.url:\n",
"if ext:\n",
"ext = os.path.splitext(resp.url)[1]\n",
"file_path = os.path.join(temp_dir, filename)\n",
"filename += ext\n",
"if ext:\n",
"_download_url(resp, link, content_file, hashes, progress_bar)\n",
"filename += ext\n",
"return file_path, content_type\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"AugAssign'",
"Condition",
"Expr'",
"AugAssign'",
"Return'"
] |
[
"def FUNC_3(VAR_2: 'RequestToCommandArgs'):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_11 = [fi for fi in VAR_2.field_infos if fi.generate_download_link and\n fi.link_name]\n",
"VAR_12 = []\n",
"VAR_12.append('<!-- CLICK_WEB START FOOTER -->')\n",
"if VAR_11:\n",
"VAR_12.append('<b>Result files:</b><br>')\n",
"VAR_12.append('<b>DONE</b>')\n",
"for fi in VAR_11:\n",
"VAR_12.append('<!-- CLICK_WEB END FOOTER -->')\n",
"VAR_12.append('<ul> ')\n",
"VAR_10 = '\\n'.join(VAR_12)\n",
"VAR_12.append(f'<li>{FUNC_4(fi)}<br>')\n",
"yield VAR_10\n",
"VAR_12.append('</ul>')\n"
] | [
"def _create_result_footer(req_to_args: 'RequestToCommandArgs'):...\n",
"\"\"\"docstring\"\"\"\n",
"to_download = [fi for fi in req_to_args.field_infos if fi.\n generate_download_link and fi.link_name]\n",
"lines = []\n",
"lines.append('<!-- CLICK_WEB START FOOTER -->')\n",
"if to_download:\n",
"lines.append('<b>Result files:</b><br>')\n",
"lines.append('<b>DONE</b>')\n",
"for fi in to_download:\n",
"lines.append('<!-- CLICK_WEB END FOOTER -->')\n",
"lines.append('<ul> ')\n",
"html_str = '\\n'.join(lines)\n",
"lines.append(f'<li>{_get_download_link(fi)}<br>')\n",
"yield html_str\n",
"lines.append('</ul>')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"For",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(self, VAR_0):...\n",
"storage.save('tmp/s3file/s3_file.txt', ContentFile(b's3file'))\n",
"storage.save('tmp/s3file/s3_other_file.txt', ContentFile(b'other s3file'))\n",
"VAR_8 = VAR_0.post('/', data={'file': [\n 'custom/location/tmp/s3file/s3_file.txt',\n 'custom/location/tmp/s3file/s3_other_file.txt'], 's3file': ['file',\n 'other_file']})\n",
"S3FileMiddleware(lambda x: None)(VAR_8)\n",
"VAR_5 = VAR_8.FILES.getlist('file')\n",
"assert VAR_5[0].read() == b's3file'\n",
"assert VAR_5[1].read() == b'other s3file'\n"
] | [
"def test_process_request__multiple_files(self, rf):...\n",
"storage.save('tmp/s3file/s3_file.txt', ContentFile(b's3file'))\n",
"storage.save('tmp/s3file/s3_other_file.txt', ContentFile(b'other s3file'))\n",
"request = rf.post('/', data={'file': [\n 'custom/location/tmp/s3file/s3_file.txt',\n 'custom/location/tmp/s3file/s3_other_file.txt'], 's3file': ['file',\n 'other_file']})\n",
"S3FileMiddleware(lambda x: None)(request)\n",
"files = request.FILES.getlist('file')\n",
"assert files[0].read() == b's3file'\n",
"assert files[1].read() == b'other s3file'\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assert'",
"Assert'"
] |
[
"def FUNC_2(self, VAR_5, VAR_6, VAR_3=None, VAR_4=()):...\n",
"if VAR_3 is None:\n",
"VAR_3 = {}\n",
"VAR_3['class'] = 'selectfilter'\n",
"if self.is_stacked:\n",
"VAR_3['class'] += 'stacked'\n",
"VAR_27 = [super(CLASS_0, self).render(VAR_5, VAR_6, VAR_3, VAR_4)]\n",
"VAR_27.append(\n '<script type=\"text/javascript\">addEvent(window, \"load\", function(e) {')\n",
"VAR_27.append('SelectFilter.init(\"id_%s\", \"%s\", %s, \"%s\"); });</script>\\n' %\n (VAR_5, self.verbose_name.replace('\"', '\\\\\"'), int(self.is_stacked),\n static('admin/')))\n",
"return mark_safe(''.join(VAR_27))\n"
] | [
"def render(self, name, value, attrs=None, choices=()):...\n",
"if attrs is None:\n",
"attrs = {}\n",
"attrs['class'] = 'selectfilter'\n",
"if self.is_stacked:\n",
"attrs['class'] += 'stacked'\n",
"output = [super(FilteredSelectMultiple, self).render(name, value, attrs,\n choices)]\n",
"output.append(\n '<script type=\"text/javascript\">addEvent(window, \"load\", function(e) {')\n",
"output.append('SelectFilter.init(\"id_%s\", \"%s\", %s, \"%s\"); });</script>\\n' %\n (name, self.verbose_name.replace('\"', '\\\\\"'), int(self.is_stacked),\n static('admin/')))\n",
"return mark_safe(''.join(output))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"AugAssign'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"@VAR_1.route('/jump')...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_33 = werkzeug.urls.url_parse(request.referrer)\n",
"VAR_34 = VAR_33.decode_query()\n",
"for VAR_28, VAR_9 in request.args.lists():\n",
"if VAR_9 == ['']:\n",
"VAR_35 = VAR_33.replace(query=werkzeug.urls.url_encode(qs_dict, sort=True))\n",
"VAR_34.setlist(VAR_28, VAR_9)\n",
"return redirect(werkzeug.urls.url_unparse(VAR_35))\n"
] | [
"@app.route('/jump')...\n",
"\"\"\"docstring\"\"\"\n",
"url = werkzeug.urls.url_parse(request.referrer)\n",
"qs_dict = url.decode_query()\n",
"for key, values in request.args.lists():\n",
"if values == ['']:\n",
"redirect_url = url.replace(query=werkzeug.urls.url_encode(qs_dict, sort=True))\n",
"qs_dict.setlist(key, values)\n",
"return redirect(werkzeug.urls.url_unparse(redirect_url))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"For",
"Condition",
"Assign'",
"Expr'",
"Return'"
] |
[
"@unittest.override_config({'enable_metrics': True, 'metrics_flags': {...\n",
"\"\"\"docstring\"\"\"\n",
"self.assertEqual(self.store._known_servers_count, 1)\n",
"self.pump()\n",
"self.assertEqual(self.store._known_servers_count, 1)\n",
"self.room = self.helper.create_room_as(self.u_alice, tok=self.t_alice)\n",
"self.inject_room_member(self.room, self.u_bob, Membership.JOIN)\n",
"self.inject_room_member(self.room, self.u_charlie.to_string(), Membership.JOIN)\n",
"self.pump(1)\n",
"self.assertEqual(self.store._known_servers_count, 2)\n"
] | [
"@unittest.override_config({'enable_metrics': True, 'metrics_flags': {...\n",
"\"\"\"docstring\"\"\"\n",
"self.assertEqual(self.store._known_servers_count, 1)\n",
"self.pump()\n",
"self.assertEqual(self.store._known_servers_count, 1)\n",
"self.room = self.helper.create_room_as(self.u_alice, tok=self.t_alice)\n",
"self.inject_room_member(self.room, self.u_bob, Membership.JOIN)\n",
"self.inject_room_member(self.room, self.u_charlie.to_string(), Membership.JOIN)\n",
"self.pump(1)\n",
"self.assertEqual(self.store._known_servers_count, 2)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@handle_dashboard_error...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_40 = require_student_from_identifier(VAR_9.GET.get('student'))\n",
"VAR_65 = get_course_by_id(SlashSeparatedCourseKey.from_deprecated_string(\n VAR_10))\n",
"return JsonResponse(dump_student_extensions(VAR_65, VAR_40))\n"
] | [
"@handle_dashboard_error...\n",
"\"\"\"docstring\"\"\"\n",
"student = require_student_from_identifier(request.GET.get('student'))\n",
"course = get_course_by_id(SlashSeparatedCourseKey.from_deprecated_string(\n course_id))\n",
"return JsonResponse(dump_student_extensions(course, student))\n"
] | [
0,
0,
3,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_71(self, VAR_43, VAR_26):...\n",
"if not self.get('__onload'):\n",
"self.set('__onload', frappe._dict())\n",
"self.get('__onload')[VAR_43] = VAR_26\n"
] | [
"def set_onload(self, key, value):...\n",
"if not self.get('__onload'):\n",
"self.set('__onload', frappe._dict())\n",
"self.get('__onload')[key] = value\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Assign'"
] |
[
"def FUNC_72(self, VAR_43=None):...\n",
"if not VAR_43:\n",
"return self.get('__onload', frappe._dict())\n",
"return self.get('__onload')[VAR_43]\n"
] | [
"def get_onload(self, key=None):...\n",
"if not key:\n",
"return self.get('__onload', frappe._dict())\n",
"return self.get('__onload')[key]\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_66(VAR_124=None, VAR_47=None, VAR_120=None):...\n",
"\"\"\"docstring\"\"\"\n",
"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 dir(VAR_226):\n",
"print('Could not find app \"{0}\"'.format(VAR_120))\n",
"if not VAR_46.startswith('_'):\n",
"if not VAR_16:\n",
"FUNC_67(VAR_184, VAR_46, getattr(VAR_226, VAR_46))\n",
"sys.exit(1)\n"
] | [
"def get_hooks(hook=None, default=None, app_name=None):...\n",
"\"\"\"docstring\"\"\"\n",
"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(app_hooks):\n",
"print('Could not find app \"{0}\"'.format(app_name))\n",
"if not key.startswith('_'):\n",
"if not request:\n",
"append_hook(hooks, key, getattr(app_hooks, key))\n",
"sys.exit(1)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"FunctionDef'",
"Assign'",
"For",
"Assign'",
"Return'",
"Assign'",
"Condition",
"For",
"Expr'",
"Condition",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_18(self):...\n",
"VAR_28 = np.ones([2, 10])\n",
"VAR_39 = np.array([[1], [2], [3]])\n",
"VAR_40 = np.mgrid[0:5, 0:5]\n",
"VAR_41 = [[3], [4]]\n",
"VAR_22 = (\n 'x1=np.ones([2,10]);x2=np.array([[1],[2],[3]]);x3=np.mgrid[0:5,0:5];x4=[[3],[4]]'\n )\n",
"VAR_31 = saved_model_cli.load_inputs_from_input_arg_string('', VAR_22, '')\n",
"self.assertTrue(np.all(VAR_31['x1'] == VAR_28))\n",
"self.assertTrue(np.all(VAR_31['x2'] == VAR_39))\n",
"self.assertTrue(np.all(VAR_31['x3'] == VAR_40))\n",
"self.assertTrue(np.all(VAR_31['x4'] == VAR_41))\n"
] | [
"def testInputParserPythonExpression(self):...\n",
"x1 = np.ones([2, 10])\n",
"x2 = np.array([[1], [2], [3]])\n",
"x3 = np.mgrid[0:5, 0:5]\n",
"x4 = [[3], [4]]\n",
"input_expr_str = (\n 'x1=np.ones([2,10]);x2=np.array([[1],[2],[3]]);x3=np.mgrid[0:5,0:5];x4=[[3],[4]]'\n )\n",
"feed_dict = saved_model_cli.load_inputs_from_input_arg_string('',\n input_expr_str, '')\n",
"self.assertTrue(np.all(feed_dict['x1'] == x1))\n",
"self.assertTrue(np.all(feed_dict['x2'] == x2))\n",
"self.assertTrue(np.all(feed_dict['x3'] == x3))\n",
"self.assertTrue(np.all(feed_dict['x4'] == x4))\n"
] | [
0,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_33 = VAR_178(VAR_33 or 0)\n",
"VAR_33 = 0\n",
"VAR_120 = VAR_9.get('thumbprefix', 'webgateway_render_thumbnail')\n",
"VAR_122 = getIntOrDefault(VAR_2, 'size', None)\n",
"VAR_1.debug(VAR_122)\n",
"VAR_19 = VAR_9['server_id']\n",
"def FUNC_66(VAR_6):...\n",
"if VAR_122 is not None:\n",
"return reverse(VAR_120, VAR_116=(iid, thumbsize))\n",
"return reverse(VAR_120, VAR_116=(iid,))\n"
] | [
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"field = long(field or 0)\n",
"field = 0\n",
"prefix = kwargs.get('thumbprefix', 'webgateway_render_thumbnail')\n",
"thumbsize = getIntOrDefault(request, 'size', None)\n",
"logger.debug(thumbsize)\n",
"server_id = kwargs['server_id']\n",
"def get_thumb_url(iid):...\n",
"if thumbsize is not None:\n",
"return reverse(prefix, args=(iid, thumbsize))\n",
"return reverse(prefix, args=(iid,))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"@defer.inlineCallbacks...\n",
"yield defer.ensureDeferred(self.store.set_profile_displayname(self.frank.\n localpart, 'Frank'))\n",
"VAR_3 = yield defer.ensureDeferred(self.handler.get_displayname(self.frank))\n",
"self.assertEquals('Frank', VAR_3)\n"
] | [
"@defer.inlineCallbacks...\n",
"yield defer.ensureDeferred(self.store.set_profile_displayname(self.frank.\n localpart, 'Frank'))\n",
"displayname = yield defer.ensureDeferred(self.handler.get_displayname(self.\n frank))\n",
"self.assertEquals('Frank', displayname)\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_4(self):...\n",
"super().clean()\n",
"if 'revert' not in self.cleaned_data:\n",
"return None\n",
"self.cleaned_data['revert_change'] = Change.objects.get(pk=self.\n cleaned_data['revert'], VAR_17=self.unit)\n",
"return self.cleaned_data\n"
] | [
"def clean(self):...\n",
"super().clean()\n",
"if 'revert' not in self.cleaned_data:\n",
"return None\n",
"self.cleaned_data['revert_change'] = Change.objects.get(pk=self.\n cleaned_data['revert'], unit=self.unit)\n",
"return self.cleaned_data\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Condition",
"Return'",
"Assign'",
"Return'"
] |
[
"def FUNC_58(self, VAR_14):...\n",
"\"\"\"docstring\"\"\"\n",
"return '<del>%s</del>' % VAR_14\n"
] | [
"def strikethrough(self, text):...\n",
"\"\"\"docstring\"\"\"\n",
"return '<del>%s</del>' % text\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_5(VAR_19=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_27 = formatdate(VAR_19)\n",
"return '%s-%s-%s GMT' % (VAR_27[:7], VAR_27[8:11], VAR_27[12:25])\n"
] | [
"def cookie_date(epoch_seconds=None):...\n",
"\"\"\"docstring\"\"\"\n",
"rfcdate = formatdate(epoch_seconds)\n",
"return '%s-%s-%s GMT' % (rfcdate[:7], rfcdate[8:11], rfcdate[12:25])\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Return'"
] |
[
"@VAR_2.route('/admin/mailsettings')...\n",
"VAR_22 = config.get_mail_settings()\n",
"return render_title_template('email_edit.html', VAR_22=content, title=_(\n u'Edit E-mail Server Settings'), page='mailset', VAR_1=feature_support)\n"
] | [
"@admi.route('/admin/mailsettings')...\n",
"content = config.get_mail_settings()\n",
"return render_title_template('email_edit.html', content=content, title=_(\n u'Edit E-mail Server Settings'), page='mailset', feature_support=\n feature_support)\n"
] | [
0,
0,
0
] | [
"Condition",
"Assign'",
"Return'"
] |
[
"@defer.inlineCallbacks...\n",
"VAR_7 = {'presence': {'types': ['m.*']}}\n",
"VAR_8 = yield defer.ensureDeferred(self.datastore.add_user_filter(VAR_0=\n user_localpart, VAR_10=user_filter_json))\n",
"VAR_6 = FUNC_0(sender='@foo:bar', type='m.profile')\n",
"VAR_9 = [VAR_6]\n",
"VAR_10 = yield defer.ensureDeferred(self.filtering.get_user_filter(VAR_0=\n user_localpart, VAR_8=filter_id))\n",
"VAR_11 = VAR_10.filter_presence(VAR_9=events)\n",
"self.assertEquals(VAR_9, VAR_11)\n"
] | [
"@defer.inlineCallbacks...\n",
"user_filter_json = {'presence': {'types': ['m.*']}}\n",
"filter_id = yield defer.ensureDeferred(self.datastore.add_user_filter(\n user_localpart=user_localpart, user_filter=user_filter_json))\n",
"event = MockEvent(sender='@foo:bar', type='m.profile')\n",
"events = [event]\n",
"user_filter = yield defer.ensureDeferred(self.filtering.get_user_filter(\n user_localpart=user_localpart, filter_id=filter_id))\n",
"results = user_filter.filter_presence(events=events)\n",
"self.assertEquals(events, results)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_3(VAR_1):...\n",
"return FUNC_1(VAR_1, VAR_3=User.objects.filter(st__is_administrator=True),\n VAR_4='spirit/user/admin/admins.html')\n"
] | [
"def index_admins(request):...\n",
"return _index(request, queryset=User.objects.filter(st__is_administrator=\n True), template='spirit/user/admin/admins.html')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_25(self, VAR_89):...\n",
"\"\"\"docstring\"\"\"\n",
"self.auth.user = Storage(VAR_89['user'])\n",
"self.auth.user_groups = VAR_89['user_groups']\n",
"self.auth.hmac_key = VAR_89['hmac_key']\n"
] | [
"def inject_token(self, tokend):...\n",
"\"\"\"docstring\"\"\"\n",
"self.auth.user = Storage(tokend['user'])\n",
"self.auth.user_groups = tokend['user_groups']\n",
"self.auth.hmac_key = tokend['hmac_key']\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_31(self, *VAR_13, **VAR_14):...\n",
"if self.directory is None:\n",
"return\n",
"return super(CLASS_2, self).set(*VAR_13, **kwargs)\n"
] | [
"def set(self, *args, **kwargs):...\n",
"if self.directory is None:\n",
"return\n",
"return super(SafeFileCache, self).set(*args, **kwargs)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def __init__(self, *, VAR_11, VAR_12, VAR_13, VAR_14=None):...\n",
"log.init.debug('Initializing NetworkManager')\n",
"super().__init__(VAR_14)\n",
"log.init.debug('NetworkManager init done')\n",
"self.adopted_downloads = 0\n",
"self._args = objreg.get('args')\n",
"self._win_id = VAR_11\n",
"self._tab_id = VAR_12\n",
"self._private = VAR_13\n",
"self._scheme_handlers = {'qute': webkitqutescheme.handler, 'file':\n filescheme.handler}\n",
"self._set_cookiejar()\n",
"self._set_cache()\n",
"self.sslErrors.connect(self.on_ssl_errors)\n",
"self._rejected_ssl_errors = collections.defaultdict(list)\n",
"self._accepted_ssl_errors = collections.defaultdict(list)\n",
"self.authenticationRequired.connect(self.on_authentication_required)\n",
"self.proxyAuthenticationRequired.connect(self.on_proxy_authentication_required)\n",
"self.netrc_used = False\n"
] | [
"def __init__(self, *, win_id, tab_id, private, parent=None):...\n",
"log.init.debug('Initializing NetworkManager')\n",
"super().__init__(parent)\n",
"log.init.debug('NetworkManager init done')\n",
"self.adopted_downloads = 0\n",
"self._args = objreg.get('args')\n",
"self._win_id = win_id\n",
"self._tab_id = tab_id\n",
"self._private = private\n",
"self._scheme_handlers = {'qute': webkitqutescheme.handler, 'file':\n filescheme.handler}\n",
"self._set_cookiejar()\n",
"self._set_cache()\n",
"self.sslErrors.connect(self.on_ssl_errors)\n",
"self._rejected_ssl_errors = collections.defaultdict(list)\n",
"self._accepted_ssl_errors = collections.defaultdict(list)\n",
"self.authenticationRequired.connect(self.on_authentication_required)\n",
"self.proxyAuthenticationRequired.connect(self.on_proxy_authentication_required)\n",
"self.netrc_used = False\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.