lines
sequencelengths 1
383
| raw_lines
sequencelengths 1
383
| label
sequencelengths 1
383
| type
sequencelengths 1
383
|
---|---|---|---|
[
"def FUNC_34(VAR_9, VAR_14, VAR_31):...\n",
"VAR_83 = {}\n",
"VAR_85 = read_po(FUNC_47, VAR_14=locale, VAR_31=domain)\n",
"for message in VAR_85:\n",
"VAR_141 = message.id\n",
"return VAR_83, VAR_85.plural_expr\n",
"if isinstance(VAR_141, (list, tuple)):\n",
"VAR_141 = VAR_141[0]\n",
"if message.string:\n",
"VAR_83[VAR_141] = message.string\n"
] | [
"def messages_from_po(path, locale, domain):...\n",
"messages = {}\n",
"catalog = read_po(f, locale=locale, domain=domain)\n",
"for message in catalog:\n",
"message_id = message.id\n",
"return messages, catalog.plural_expr\n",
"if isinstance(message_id, (list, tuple)):\n",
"message_id = message_id[0]\n",
"if message.string:\n",
"messages[message_id] = message.string\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Condition",
"Assign'"
] |
[
"@internationalizeDocstring...\n",
"\"\"\"docstring\"\"\"\n",
"if self._calc_match_forbidden_chars.match(VAR_18):\n",
"VAR_3.error(VAR_0('string'))\n",
"VAR_18 = self._calc_remover(VAR_18)\n",
"return\n",
"if 'lambda' in VAR_18:\n",
"VAR_3.error(VAR_0(\"You can't use lambda in this command.\"))\n",
"VAR_18 = VAR_18.replace('lambda', '')\n",
"return\n",
"self.log.info('evaluating %q from %s', VAR_18, VAR_4.prefix)\n",
"VAR_37 = math.ldexp(0.9999999999999999, 1024)\n",
"VAR_3.reply(str(eval(VAR_18, self._mathEnv, self._mathEnv)))\n",
"VAR_3.error(VAR_0('The answer exceeded %s or so.') % VAR_37)\n",
"VAR_3.error(VAR_0(\"Something in there wasn't a valid number.\"))\n",
"VAR_3.error(VAR_0('%s is not a defined function.') % str(e).split()[1])\n",
"VAR_3.error(utils.exnToString(e))\n"
] | [
"@internationalizeDocstring...\n",
"\"\"\"docstring\"\"\"\n",
"if self._calc_match_forbidden_chars.match(text):\n",
"irc.error(_(\n \"There's really no reason why you should have underscores or brackets in your mathematical expression. Please remove them.\"\n ))\n",
"text = self._calc_remover(text)\n",
"return\n",
"if 'lambda' in text:\n",
"irc.error(_(\"You can't use lambda in this command.\"))\n",
"text = text.replace('lambda', '')\n",
"return\n",
"self.log.info('evaluating %q from %s', text, msg.prefix)\n",
"maxFloat = math.ldexp(0.9999999999999999, 1024)\n",
"irc.reply(str(eval(text, self._mathEnv, self._mathEnv)))\n",
"irc.error(_('The answer exceeded %s or so.') % maxFloat)\n",
"irc.error(_(\"Something in there wasn't a valid number.\"))\n",
"irc.error(_('%s is not a defined function.') % str(e).split()[1])\n",
"irc.error(utils.exnToString(e))\n"
] | [
0,
0,
5,
5,
5,
5,
5,
5,
5,
5,
0,
0,
5,
0,
5,
0,
0
] | [
"Condition",
"Docstring",
"For",
"Expr'",
"Assign'",
"Return'",
"Condition",
"Expr'",
"Assign'",
"Return'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_1(VAR_0, VAR_3='djangojs'):...\n",
"from shuup.utils.i18n import javascript_catalog_all\n",
"return javascript_catalog_all(VAR_0, VAR_3)\n"
] | [
"def front_javascript_catalog_all(request, domain='djangojs'):...\n",
"from shuup.utils.i18n import javascript_catalog_all\n",
"return javascript_catalog_all(request, domain)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"ImportFrom'",
"Return'"
] |
[
"def FUNC_12(VAR_17):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_33 = 'import', ';', 'subprocess', 'eval', 'open', 'file', 'exec', 'input'\n",
"for bad in VAR_33:\n",
"if VAR_17.count(bad):\n",
"return True\n",
"return False\n"
] | [
"def safe_py_code(code):...\n",
"\"\"\"docstring\"\"\"\n",
"bads = 'import', ';', 'subprocess', 'eval', 'open', 'file', 'exec', 'input'\n",
"for bad in bads:\n",
"if code.count(bad):\n",
"return True\n",
"return False\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"For",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_43(VAR_62, VAR_9):...\n",
"FUNC_10().hdel('last_modified', VAR_62)\n",
"VAR_46 = FUNC_42(VAR_62, VAR_9)\n",
"if VAR_46 in VAR_1.document_cache:\n",
"FUNC_10().hdel('document_cache', VAR_46)\n"
] | [
"def clear_document_cache(doctype, name):...\n",
"cache().hdel('last_modified', doctype)\n",
"key = get_document_cache_key(doctype, name)\n",
"if key in local.document_cache:\n",
"cache().hdel('document_cache', key)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Condition",
"Expr'"
] |
[
"def FUNC_7(self, VAR_22):...\n",
"VAR_29 = VAR_22.encode('utf-8')\n",
"VAR_18 = FUNC_7(VAR_29, mode='eval')\n",
"self.restricted_python_transformer.visit(VAR_18)\n",
"self.page_templates_expression_transformer.visit(VAR_18)\n",
"return VAR_18\n"
] | [
"def parse(self, string):...\n",
"encoded = string.encode('utf-8')\n",
"node = parse(encoded, mode='eval')\n",
"self.restricted_python_transformer.visit(node)\n",
"self.page_templates_expression_transformer.visit(node)\n",
"return node\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_172(VAR_354):...\n",
"return VAR_354 + ' ' + VAR_354.replace('icon', 'glyphicon')\n"
] | [
"def rename(icon):...\n",
"return icon + ' ' + icon.replace('icon', 'glyphicon')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@VAR_0.route('/api/queue', methods=['GET'])...\n",
""
] | [
"@gui.route('/api/queue', methods=['GET'])...\n",
""
] | [
0,
0
] | [
"Condition",
"Condition"
] |
[
"def __init__(self, VAR_27, *VAR_6, **VAR_7):...\n",
"self.unit_set = VAR_27\n",
"super().__init__(*VAR_6, **kwargs)\n"
] | [
"def __init__(self, unit_set, *args, **kwargs):...\n",
"self.unit_set = unit_set\n",
"super().__init__(*args, **kwargs)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"@def_function.function(input_signature=[tensor_spec.TensorSpec(shape=(2, 2),...\n",
"return {'res': VAR_45 + self.var}\n"
] | [
"@def_function.function(input_signature=[tensor_spec.TensorSpec(shape=(2, 2),...\n",
"return {'res': x + self.var}\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_0(self, VAR_1):...\n",
"from openapi_python_client.parser.properties import UnionProperty\n",
"VAR_13 = VAR_1.MagicMock()\n",
"VAR_13.get_type_string.return_value = 'inner_type_string_1'\n",
"VAR_14 = VAR_1.MagicMock()\n",
"VAR_14.get_type_string.return_value = 'inner_type_string_2'\n",
"VAR_4 = VAR_33(VAR_5='test', VAR_26=True, default=None, inner_properties=[\n inner_property_1, inner_property_2])\n",
"assert VAR_4.get_type_string(\n ) == 'Union[inner_type_string_1, inner_type_string_2]'\n",
"VAR_4.required = False\n",
"assert VAR_4.get_type_string(\n ) == 'Optional[Union[inner_type_string_1, inner_type_string_2]]'\n"
] | [
"def test_get_type_string(self, mocker):...\n",
"from openapi_python_client.parser.properties import UnionProperty\n",
"inner_property_1 = mocker.MagicMock()\n",
"inner_property_1.get_type_string.return_value = 'inner_type_string_1'\n",
"inner_property_2 = mocker.MagicMock()\n",
"inner_property_2.get_type_string.return_value = 'inner_type_string_2'\n",
"p = UnionProperty(name='test', required=True, default=None,\n inner_properties=[inner_property_1, inner_property_2])\n",
"assert p.get_type_string() == 'Union[inner_type_string_1, inner_type_string_2]'\n",
"p.required = False\n",
"assert p.get_type_string(\n ) == 'Optional[Union[inner_type_string_1, inner_type_string_2]]'\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assert'",
"Assign'",
"Assert'"
] |
[
"@FUNC_0...\n",
"return ApplicationServicesHandler(self)\n"
] | [
"@cache_in_self...\n",
"return ApplicationServicesHandler(self)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_64(self, VAR_2):...\n",
""
] | [
"def write(self, data):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"@VAR_2.route('/', defaults={'page': 1})...\n",
"VAR_20 = (request.args.get('sort') or 'stored').lower()\n",
"return FUNC_15('newest', VAR_20, 1, VAR_9)\n"
] | [
"@web.route('/', defaults={'page': 1})...\n",
"sort_param = (request.args.get('sort') or 'stored').lower()\n",
"return render_books_list('newest', sort_param, 1, page)\n"
] | [
0,
0,
0
] | [
"Condition",
"Assign'",
"Return'"
] |
[
"@login_required...\n",
"VAR_5 = get_object_or_404(CommentPollChoice.objects.unremoved().\n select_related('poll'), VAR_1=pk)\n",
"if not VAR_5.poll.can_show_results:\n",
"VAR_6 = CommentPollVote.objects.unremoved().for_choice(VAR_5=choice\n ).select_related('voter__st')\n",
"VAR_6 = yt_paginate(VAR_6, per_page=config.topics_per_page, page_number=\n request.GET.get('page', 1))\n",
"VAR_7 = {'choice': VAR_5, 'votes': VAR_6}\n",
"return render(VAR_0, 'spirit/comment/poll/voters.html', VAR_7)\n"
] | [
"@login_required...\n",
"choice = get_object_or_404(CommentPollChoice.objects.unremoved().\n select_related('poll'), pk=pk)\n",
"if not choice.poll.can_show_results:\n",
"choice_votes = CommentPollVote.objects.unremoved().for_choice(choice=choice\n ).select_related('voter__st')\n",
"choice_votes = yt_paginate(choice_votes, per_page=config.topics_per_page,\n page_number=request.GET.get('page', 1))\n",
"context = {'choice': choice, 'votes': choice_votes}\n",
"return render(request, 'spirit/comment/poll/voters.html', context)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_21(VAR_23, VAR_24, VAR_25):...\n",
"if VAR_23 != 'SECRET_KEY':\n",
"if type(VAR_24) is dict:\n",
"for k, v in VAR_24.items():\n",
"VAR_25[VAR_23] = VAR_24\n",
"FUNC_21(k, v, VAR_25[VAR_23])\n"
] | [
"def update_config_value(key, val, dictionary):...\n",
"if key != 'SECRET_KEY':\n",
"if type(val) is dict:\n",
"for k, v in val.items():\n",
"dictionary[key] = val\n",
"update_config_value(k, v, dictionary[key])\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"For",
"Assign'",
"Expr'"
] |
[
"def FUNC_32(VAR_37, VAR_38):...\n",
"if VAR_37 != _(u'Unknown') and VAR_38 != _(u'Unknown'):\n",
"VAR_95 = calibre_db.check_exists_book(VAR_38, VAR_37)\n",
"VAR_62 = VAR_38.split('&')\n",
"if VAR_95:\n",
"VAR_62 = list(map(lambda it: it.strip().replace(',', '|'), VAR_62))\n",
"VAR_2.info('Uploaded book probably exists in library')\n",
"VAR_62 = helper.uniq(VAR_62)\n",
"flash(_(\n u'Uploaded book probably exists in the library, consider to change before upload new: '\n ) + Markup(render_title_template('book_exists_flash.html', VAR_95=entry\n )), category='warning')\n",
"if VAR_62 == ['']:\n",
"VAR_62 = [_(u'Unknown')]\n",
"VAR_64 = list()\n",
"VAR_69 = None\n",
"for inp in VAR_62:\n",
"VAR_89 = calibre_db.session.query(db.Authors).filter(db.Authors.name == inp\n ).first()\n",
"VAR_65 = ' & '.join(VAR_64)\n",
"if not VAR_89:\n",
"return VAR_65, VAR_62, VAR_69\n",
"if not VAR_69:\n",
"if not VAR_69:\n",
"VAR_69 = db.Authors(inp, helper.get_sorted_author(inp), '')\n",
"VAR_113 = helper.get_sorted_author(inp)\n",
"VAR_69 = VAR_89\n",
"VAR_113 = VAR_89.sort\n",
"calibre_db.session.add(VAR_69)\n",
"VAR_64.append(VAR_113)\n",
"calibre_db.session.commit()\n"
] | [
"def prepare_authors_on_upload(title, authr):...\n",
"if title != _(u'Unknown') and authr != _(u'Unknown'):\n",
"entry = calibre_db.check_exists_book(authr, title)\n",
"input_authors = authr.split('&')\n",
"if entry:\n",
"input_authors = list(map(lambda it: it.strip().replace(',', '|'),\n input_authors))\n",
"log.info('Uploaded book probably exists in library')\n",
"input_authors = helper.uniq(input_authors)\n",
"flash(_(\n u'Uploaded book probably exists in the library, consider to change before upload new: '\n ) + Markup(render_title_template('book_exists_flash.html', entry=entry)\n ), category='warning')\n",
"if input_authors == ['']:\n",
"input_authors = [_(u'Unknown')]\n",
"sort_authors_list = list()\n",
"db_author = None\n",
"for inp in input_authors:\n",
"stored_author = calibre_db.session.query(db.Authors).filter(db.Authors.name ==\n inp).first()\n",
"sort_authors = ' & '.join(sort_authors_list)\n",
"if not stored_author:\n",
"return sort_authors, input_authors, db_author\n",
"if not db_author:\n",
"if not db_author:\n",
"db_author = db.Authors(inp, helper.get_sorted_author(inp), '')\n",
"sort_author = helper.get_sorted_author(inp)\n",
"db_author = stored_author\n",
"sort_author = stored_author.sort\n",
"calibre_db.session.add(db_author)\n",
"sort_authors_list.append(sort_author)\n",
"calibre_db.session.commit()\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
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@VAR_2.route('/ajax/deleterestriction/<int:res_type>/<int:user_id>',...\n",
"VAR_10 = request.form.to_dict()\n",
"if VAR_8 == 0:\n",
"if VAR_10['id'].startswith('a'):\n",
"if VAR_8 == 1:\n",
"config.config_allowed_tags = FUNC_28(VAR_10, config.list_allowed_tags)\n",
"if VAR_10['id'].startswith('d'):\n",
"if VAR_10['id'].startswith('a'):\n",
"if VAR_8 == 2:\n",
"config.save()\n",
"config.config_denied_tags = FUNC_28(VAR_10, config.list_denied_tags)\n",
"return ''\n",
"config.config_allowed_column_value = FUNC_28(VAR_10, config.\n list_allowed_column_values)\n",
"if VAR_10['id'].startswith('d'):\n",
"if isinstance(VAR_9, VAR_119):\n",
"if VAR_8 == 3:\n",
"config.save()\n",
"config.save()\n",
"config.config_denied_column_value = FUNC_28(VAR_10, config.\n list_denied_column_values)\n",
"VAR_120 = ub.session.query(ub.User).filter(ub.User.id == VAR_119(VAR_9)).first(\n )\n",
"VAR_120 = VAR_62\n",
"if isinstance(VAR_9, VAR_119):\n",
"config.save()\n",
"if VAR_10['id'].startswith('a'):\n",
"VAR_120 = ub.session.query(ub.User).filter(ub.User.id == VAR_119(VAR_9)).first(\n )\n",
"VAR_120 = VAR_62\n",
"VAR_120.allowed_tags = FUNC_28(VAR_10, VAR_120.list_allowed_tags)\n",
"if VAR_10['id'].startswith('d'):\n",
"if VAR_10['id'].startswith('a'):\n",
"ub.session_commit('Deleted allowed tags of user {}: {}'.format(VAR_120.name,\n VAR_120.list_allowed_tags))\n",
"VAR_120.denied_tags = FUNC_28(VAR_10, VAR_120.list_denied_tags)\n",
"VAR_120.allowed_column_value = FUNC_28(VAR_10, VAR_120.\n list_allowed_column_values)\n",
"if VAR_10['id'].startswith('d'):\n",
"ub.session_commit('Deleted denied tags of user {}: {}'.format(VAR_120.name,\n VAR_120.list_allowed_tags))\n",
"ub.session_commit('Deleted allowed columns of user {}: {}'.format(VAR_120.\n name, VAR_120.list_allowed_column_values))\n",
"VAR_120.denied_column_value = FUNC_28(VAR_10, VAR_120.list_denied_column_values\n )\n",
"ub.session_commit('Deleted denied columns of user {}: {}'.format(VAR_120.\n name, VAR_120.list_denied_column_values))\n"
] | [
"@admi.route('/ajax/deleterestriction/<int:res_type>/<int:user_id>', methods...\n",
"element = request.form.to_dict()\n",
"if res_type == 0:\n",
"if element['id'].startswith('a'):\n",
"if res_type == 1:\n",
"config.config_allowed_tags = restriction_deletion(element, config.\n list_allowed_tags)\n",
"if element['id'].startswith('d'):\n",
"if element['id'].startswith('a'):\n",
"if res_type == 2:\n",
"config.save()\n",
"config.config_denied_tags = restriction_deletion(element, config.\n list_denied_tags)\n",
"return ''\n",
"config.config_allowed_column_value = restriction_deletion(element, config.\n list_allowed_column_values)\n",
"if element['id'].startswith('d'):\n",
"if isinstance(user_id, int):\n",
"if res_type == 3:\n",
"config.save()\n",
"config.save()\n",
"config.config_denied_column_value = restriction_deletion(element, config.\n list_denied_column_values)\n",
"usr = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()\n",
"usr = current_user\n",
"if isinstance(user_id, int):\n",
"config.save()\n",
"if element['id'].startswith('a'):\n",
"usr = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()\n",
"usr = current_user\n",
"usr.allowed_tags = restriction_deletion(element, usr.list_allowed_tags)\n",
"if element['id'].startswith('d'):\n",
"if element['id'].startswith('a'):\n",
"ub.session_commit('Deleted allowed tags of user {}: {}'.format(usr.name,\n usr.list_allowed_tags))\n",
"usr.denied_tags = restriction_deletion(element, usr.list_denied_tags)\n",
"usr.allowed_column_value = restriction_deletion(element, usr.\n list_allowed_column_values)\n",
"if element['id'].startswith('d'):\n",
"ub.session_commit('Deleted denied tags of user {}: {}'.format(usr.name, usr\n .list_allowed_tags))\n",
"ub.session_commit('Deleted allowed columns of user {}: {}'.format(usr.name,\n usr.list_allowed_column_values))\n",
"usr.denied_column_value = restriction_deletion(element, usr.\n list_denied_column_values)\n",
"ub.session_commit('Deleted denied columns of user {}: {}'.format(usr.name,\n usr.list_denied_column_values))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def __str__(self):...\n",
"VAR_151 = '%s ' % self.field\n",
"if not self.new_value:\n",
"VAR_151 += ugettext('removed')\n",
"if not self.old_value:\n",
"return VAR_151\n",
"VAR_151 += ugettext('set to %s') % self.new_value\n",
"VAR_151 += ugettext('changed from \"%(old_value)s\" to \"%(new_value)s\"') % {\n 'old_value': self.old_value, 'new_value': self.new_value}\n"
] | [
"def __str__(self):...\n",
"out = '%s ' % self.field\n",
"if not self.new_value:\n",
"out += ugettext('removed')\n",
"if not self.old_value:\n",
"return out\n",
"out += ugettext('set to %s') % self.new_value\n",
"out += ugettext('changed from \"%(old_value)s\" to \"%(new_value)s\"') % {\n 'old_value': self.old_value, 'new_value': self.new_value}\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"AugAssign'",
"Condition",
"Return'",
"AugAssign'",
"AugAssign'"
] |
[
"def FUNC_21(self, VAR_43, VAR_29=None, VAR_30=None):...\n",
"\"\"\"docstring\"\"\"\n",
"self.invoke_all('read_config', VAR_43, VAR_29=config_dir_path, VAR_30=\n data_dir_path)\n"
] | [
"def parse_config_dict(self, config_dict, config_dir_path=None,...\n",
"\"\"\"docstring\"\"\"\n",
"self.invoke_all('read_config', config_dict, config_dir_path=config_dir_path,\n data_dir_path=data_dir_path)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'"
] |
[
"def __init__(self, VAR_14: BinaryIO, VAR_35: defer.Deferred, VAR_15:...\n",
"self.stream = VAR_14\n",
"self.deferred = VAR_35\n",
"self.length = 0\n",
"self.max_size = VAR_15\n"
] | [
"def __init__(self, stream: BinaryIO, deferred: defer.Deferred, max_size:...\n",
"self.stream = stream\n",
"self.deferred = deferred\n",
"self.length = 0\n",
"self.max_size = max_size\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"@defer.inlineCallbacks...\n",
"VAR_18 = yield FUNC_7(VAR_11)\n",
"for member in VAR_18:\n",
"if VAR_14 is not None and member == VAR_14:\n",
"if VAR_6.is_mine(member):\n",
"if VAR_12 is not None:\n",
"if VAR_13 is not None:\n",
"VAR_12.add(member)\n",
"VAR_13.add(member.domain)\n"
] | [
"@defer.inlineCallbacks...\n",
"members = yield get_room_members(room_id)\n",
"for member in members:\n",
"if ignore_user is not None and member == ignore_user:\n",
"if hs.is_mine(member):\n",
"if localusers is not None:\n",
"if remotedomains is not None:\n",
"localusers.add(member)\n",
"remotedomains.add(member.domain)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"For",
"Condition",
"Condition",
"Condition",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(self, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11=None, VAR_12=None):...\n",
"VAR_14 = super(CLASS_0, self).create_option(VAR_6=name, VAR_7=value, VAR_8=\n label, VAR_9=selected, VAR_10=index, VAR_11=subindex, VAR_12=attrs)\n",
"VAR_14['attrs']['data-color'] = self.queryset.get(pk=value).color\n",
"return VAR_14\n"
] | [
"def create_option(self, name, value, label, selected, index, subindex=None,...\n",
"result = super(TagFormWidget, self).create_option(name=name, value=value,\n label=label, selected=selected, index=index, subindex=subindex, attrs=attrs\n )\n",
"result['attrs']['data-color'] = self.queryset.get(pk=value).color\n",
"return result\n"
] | [
0,
2,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@transaction.non_atomic_requests...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_10 = SlashSeparatedCourseKey.from_deprecated_string(VAR_10)\n",
"if not BulkEmailFlag.feature_enabled(VAR_10):\n",
"return HttpResponseForbidden('Email is not enabled for this course.')\n",
"VAR_138 = json.loads(VAR_9.POST.get('send_to'))\n",
"VAR_115 = VAR_9.POST.get('subject')\n",
"VAR_74 = VAR_9.POST.get('message')\n",
"VAR_139 = microsite.get_value('course_email_template_name')\n",
"VAR_140 = microsite.get_value('course_email_from_addr')\n",
"VAR_14 = CourseEmail.create(VAR_10, VAR_9.user, VAR_138, VAR_115, VAR_74,\n VAR_139=template_name, VAR_140=from_addr)\n",
"return HttpResponseBadRequest(repr(err))\n",
"instructor_task.api.submit_bulk_course_email(VAR_9, VAR_10, VAR_14.id)\n",
"VAR_63 = {'course_id': VAR_10.to_deprecated_string(), 'success': True}\n",
"return JsonResponse(VAR_63)\n"
] | [
"@transaction.non_atomic_requests...\n",
"\"\"\"docstring\"\"\"\n",
"course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n",
"if not BulkEmailFlag.feature_enabled(course_id):\n",
"return HttpResponseForbidden('Email is not enabled for this course.')\n",
"targets = json.loads(request.POST.get('send_to'))\n",
"subject = request.POST.get('subject')\n",
"message = request.POST.get('message')\n",
"template_name = microsite.get_value('course_email_template_name')\n",
"from_addr = microsite.get_value('course_email_from_addr')\n",
"email = CourseEmail.create(course_id, request.user, targets, subject,\n message, template_name=template_name, from_addr=from_addr)\n",
"return HttpResponseBadRequest(repr(err))\n",
"instructor_task.api.submit_bulk_course_email(request, course_id, email.id)\n",
"response_payload = {'course_id': course_id.to_deprecated_string(),\n 'success': True}\n",
"return JsonResponse(response_payload)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def __getattr__(self, VAR_14: str) ->Any:...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_14 in ['generate_config_section', 'read_config']:\n",
"if self.root is None:\n",
"return self.root._get_unclassed_config(self.section, VAR_14)\n"
] | [
"def __getattr__(self, item: str) ->Any:...\n",
"\"\"\"docstring\"\"\"\n",
"if item in ['generate_config_section', 'read_config']:\n",
"if self.root is None:\n",
"return self.root._get_unclassed_config(self.section, item)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Condition",
"Return'"
] |
[
"async def FUNC_3(self, VAR_5: str, VAR_6: Optional[str], VAR_7: IO, VAR_8:...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_4 = random_string(24)\n",
"VAR_26 = FileInfo(VAR_3=None, VAR_18=media_id)\n",
"VAR_27 = await self.media_storage.store_file(VAR_7, VAR_26)\n",
"VAR_0.info('Stored local media in file %r', VAR_27)\n",
"await self.store.store_local_media(VAR_4=media_id, VAR_5=media_type, VAR_45\n =self.clock.time_msec(), VAR_6=upload_name, VAR_29=content_length,\n user_id=auth_user)\n",
"await self._generate_thumbnails(None, VAR_4, VAR_4, VAR_5)\n",
"return 'mxc://%s/%s' % (self.server_name, VAR_4)\n"
] | [
"async def create_content(self, media_type: str, upload_name: Optional[str],...\n",
"\"\"\"docstring\"\"\"\n",
"media_id = random_string(24)\n",
"file_info = FileInfo(server_name=None, file_id=media_id)\n",
"fname = await self.media_storage.store_file(content, file_info)\n",
"logger.info('Stored local media in file %r', fname)\n",
"await self.store.store_local_media(media_id=media_id, media_type=media_type,\n time_now_ms=self.clock.time_msec(), upload_name=upload_name,\n media_length=content_length, user_id=auth_user)\n",
"await self._generate_thumbnails(None, media_id, media_id, media_type)\n",
"return 'mxc://%s/%s' % (self.server_name, media_id)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_20(self):...\n",
"VAR_22, VAR_23 = self.make_request('POST', '/createRoom',\n b'{\"invite\":[\"@alice:example.com \"]}')\n",
"self.assertEquals(400, VAR_23.code)\n"
] | [
"def test_post_room_invitees_invalid_mxid(self):...\n",
"request, channel = self.make_request('POST', '/createRoom',\n b'{\"invite\":[\"@alice:example.com \"]}')\n",
"self.assertEquals(400, channel.code)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def __init__(self, *VAR_6, **VAR_7):...\n",
"VAR_7['auto_id'] = 'id_branch_%s'\n",
"super().__init__(*VAR_6, **kwargs)\n"
] | [
"def __init__(self, *args, **kwargs):...\n",
"kwargs['auto_id'] = 'id_branch_%s'\n",
"super().__init__(*args, **kwargs)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_7(self, VAR_3) ->Optional[bool]:...\n",
"\"\"\"docstring\"\"\"\n",
"return None\n"
] | [
"def cheaplyExists(self, _) ->Optional[bool]:...\n",
"\"\"\"docstring\"\"\"\n",
"return None\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_13(VAR_17):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_43 = {}\n",
"VAR_44 = VAR_17.split(';')\n",
"for input_raw in filter(bool, VAR_44):\n",
"VAR_70 = re.match('([^=]+)=([^\\\\[\\\\]]+)\\\\[([^\\\\[\\\\]]+)\\\\]$', input_raw)\n",
"return VAR_43\n",
"if VAR_70:\n",
"VAR_43[VAR_70.group(1)] = VAR_70.group(2), VAR_70.group(3)\n",
"VAR_70 = re.match('([^=]+)=([^\\\\[\\\\]]+)$', input_raw)\n",
"if VAR_70:\n",
"VAR_43[VAR_70.group(1)] = VAR_70.group(2), None\n"
] | [
"def preprocess_inputs_arg_string(inputs_str):...\n",
"\"\"\"docstring\"\"\"\n",
"input_dict = {}\n",
"inputs_raw = inputs_str.split(';')\n",
"for input_raw in filter(bool, inputs_raw):\n",
"match = re.match('([^=]+)=([^\\\\[\\\\]]+)\\\\[([^\\\\[\\\\]]+)\\\\]$', input_raw)\n",
"return input_dict\n",
"if match:\n",
"input_dict[match.group(1)] = match.group(2), match.group(3)\n",
"match = re.match('([^=]+)=([^\\\\[\\\\]]+)$', input_raw)\n",
"if match:\n",
"input_dict[match.group(1)] = match.group(2), None\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"For",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'"
] |
[
"@pytest.fixture...\n",
"from tests.testapp.models import FileModel\n",
"return FileModel.objects.create(file=ContentFile(request.node.name, \n '%s.txt' % request.node.name))\n"
] | [
"@pytest.fixture...\n",
"from tests.testapp.models import FileModel\n",
"return FileModel.objects.create(file=ContentFile(request.node.name, \n '%s.txt' % request.node.name))\n"
] | [
0,
0,
0
] | [
"Condition",
"ImportFrom'",
"Return'"
] |
[
"def __init__(self, VAR_5, VAR_4, *VAR_6, **VAR_7):...\n",
"super().__init__(VAR_5, VAR_4, *VAR_6, **kwargs)\n",
"self.fields['context'].widget.attrs['tabindex'] = 99\n",
"self.fields['source'].widget.attrs['tabindex'] = 100\n",
"self.fields['source'].widget.profile = VAR_4.profile\n",
"self.fields['source'].initial = Unit(VAR_5=translation, id_hash=0)\n"
] | [
"def __init__(self, translation, user, *args, **kwargs):...\n",
"super().__init__(translation, user, *args, **kwargs)\n",
"self.fields['context'].widget.attrs['tabindex'] = 99\n",
"self.fields['source'].widget.attrs['tabindex'] = 100\n",
"self.fields['source'].widget.profile = user.profile\n",
"self.fields['source'].initial = Unit(translation=translation, id_hash=0)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"import yaml\n",
"from ansible.utils.vault import VaultLib\n",
"from ansible.parsing.vault import VaultLib\n",
"\"\"\"R/W an ansible-vault yaml file\"\"\"\n",
"def __init__(self, VAR_0):...\n",
"self.password = VAR_0\n",
"self.vault = VaultLib(VAR_0)\n",
"def FUNC_0(self, VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"return yaml.load(self.vault.decrypt(VAR_1))\n"
] | [
"import yaml\n",
"from ansible.utils.vault import VaultLib\n",
"from ansible.parsing.vault import VaultLib\n",
"\"\"\"R/W an ansible-vault yaml file\"\"\"\n",
"def __init__(self, password):...\n",
"self.password = password\n",
"self.vault = VaultLib(password)\n",
"def load(self, stream):...\n",
"\"\"\"docstring\"\"\"\n",
"return yaml.load(self.vault.decrypt(stream))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
5
] | [
"Import'",
"ImportFrom'",
"ImportFrom'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_15():...\n",
"VAR_3 = FUNC_5()\n",
"VAR_11 = apath(VAR_3, VAR_122=request)\n",
"def FUNC_58(VAR_44):...\n",
"return [VAR_221 for VAR_221 in VAR_44 if not (VAR_221[:1] in '#' or VAR_221\n .endswith('~') or VAR_221.endswith('.bak'))]\n"
] | [
"def pack_custom():...\n",
"app = get_app()\n",
"base = apath(app, r=request)\n",
"def ignore(fs):...\n",
"return [f for f in fs if not (f[:1] in '#' or f.endswith('~') or f.endswith\n ('.bak'))]\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_5(self):...\n",
"if self.timed_call:\n",
"self.timed_call.cancel()\n",
"self.timed_call = None\n"
] | [
"def on_stop(self):...\n",
"if self.timed_call:\n",
"self.timed_call.cancel()\n",
"self.timed_call = None\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Assign'"
] |
[
"def FUNC_2(VAR_18: Text=DEFAULT_MODELS_PATH) ->Optional[Text]:...\n",
"\"\"\"docstring\"\"\"\n",
"if not os.path.exists(VAR_18) or os.path.isfile(VAR_18):\n",
"VAR_18 = os.path.dirname(VAR_18)\n",
"VAR_49 = glob.glob(os.path.join(VAR_18, '*.tar.gz'))\n",
"if len(VAR_49) == 0:\n",
"return None\n",
"return max(VAR_49, key=os.path.getctime)\n"
] | [
"def get_latest_model(model_path: Text=DEFAULT_MODELS_PATH) ->Optional[Text]:...\n",
"\"\"\"docstring\"\"\"\n",
"if not os.path.exists(model_path) or os.path.isfile(model_path):\n",
"model_path = os.path.dirname(model_path)\n",
"list_of_files = glob.glob(os.path.join(model_path, '*.tar.gz'))\n",
"if len(list_of_files) == 0:\n",
"return None\n",
"return max(list_of_files, key=os.path.getctime)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def __init__(self, VAR_8, *VAR_6, **VAR_7):...\n",
"super().__init__(*VAR_6, **kwargs)\n",
"self.helper = FormHelper()\n",
"self.helper.form_tag = False\n",
"self.request = VAR_8\n"
] | [
"def __init__(self, request, *args, **kwargs):...\n",
"super().__init__(*args, **kwargs)\n",
"self.helper = FormHelper()\n",
"self.helper.form_tag = False\n",
"self.request = request\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_118(*VAR_9, **VAR_13):...\n",
"VAR_431, VAR_432, VAR_141 = self.basic()\n",
"VAR_141 = VAR_141 or self.user\n",
"VAR_433 = VAR_145\n",
"if callable(VAR_433):\n",
"VAR_433 = VAR_433()\n",
"if VAR_433:\n",
"if not VAR_141:\n",
"if callable(VAR_144):\n",
"if VAR_263.request.ajax:\n",
"VAR_453 = VAR_144()\n",
"VAR_453 = VAR_144\n",
"if VAR_90 is not None:\n",
"if not VAR_453:\n",
"if callable(VAR_90):\n",
"if self.settings.allow_basic_login_only or VAR_432 or VAR_263.request.is_restful:\n",
"VAR_263.session.flash = self.messages.access_denied\n",
"return VAR_114(*VAR_9, **b)\n",
"return VAR_90()\n",
"redirect(VAR_90)\n",
"VAR_112 = self.here()\n",
"return FUNC_3(self.settings.on_failed_authorization)\n",
"VAR_263.session.flash = VAR_263.response.flash\n",
"return FUNC_3(self.settings.on_failed_authentication, self.settings.\n login_url + '?_next=' + urllib_quote(VAR_112))\n"
] | [
"def f(*a, **b):...\n",
"basic_allowed, basic_accepted, user = self.basic()\n",
"user = user or self.user\n",
"login_required = requires_login\n",
"if callable(login_required):\n",
"login_required = login_required()\n",
"if login_required:\n",
"if not user:\n",
"if callable(condition):\n",
"if current.request.ajax:\n",
"flag = condition()\n",
"flag = condition\n",
"if otherwise is not None:\n",
"if not flag:\n",
"if callable(otherwise):\n",
"if self.settings.allow_basic_login_only or basic_accepted or current.request.is_restful:\n",
"current.session.flash = self.messages.access_denied\n",
"return action(*a, **b)\n",
"return otherwise()\n",
"redirect(otherwise)\n",
"next = self.here()\n",
"return call_or_redirect(self.settings.on_failed_authorization)\n",
"current.session.flash = current.response.flash\n",
"return call_or_redirect(self.settings.on_failed_authentication, self.\n settings.login_url + '?_next=' + urllib_quote(next))\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
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Condition",
"Assign'",
"Return'",
"Return'",
"Expr'",
"Assign'",
"Return'",
"Assign'",
"Return'"
] |
[
"def FUNC_23(self):...\n",
"self.client.login(username='super', password='secret')\n"
] | [
"def setUp(self):...\n",
"self.client.login(username='super', password='secret')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@app.route('/tags')...\n",
"if not app.config['SEARCH_CONF']['engine'] == 'ripgrep' and not which('rg'):\n",
"flash('Ripgrep must be installed to view pages about embedded tags.', 'error')\n",
"VAR_10 = sorted(get_all_tags(force=True))\n",
"return redirect('/')\n",
"return render_template('tags/all.html', title='All Tags', VAR_10=tags)\n"
] | [
"@app.route('/tags')...\n",
"if not app.config['SEARCH_CONF']['engine'] == 'ripgrep' and not which('rg'):\n",
"flash('Ripgrep must be installed to view pages about embedded tags.', 'error')\n",
"tags = sorted(get_all_tags(force=True))\n",
"return redirect('/')\n",
"return render_template('tags/all.html', title='All Tags', tags=tags)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Expr'",
"Assign'",
"Return'",
"Return'"
] |
[
"def FUNC_17(self):...\n",
"VAR_27 = np.ones([2, 10])\n",
"VAR_38 = np.array([[1], [2], [3]])\n",
"VAR_39 = np.mgrid[0:5, 0:5]\n",
"VAR_40 = [[3], [4]]\n",
"VAR_21 = (\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_30 = saved_model_cli.load_inputs_from_input_arg_string('', VAR_21, '')\n",
"self.assertTrue(np.all(VAR_30['x1'] == VAR_27))\n",
"self.assertTrue(np.all(VAR_30['x2'] == VAR_38))\n",
"self.assertTrue(np.all(VAR_30['x3'] == VAR_39))\n",
"self.assertTrue(np.all(VAR_30['x4'] == VAR_40))\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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_23(self, VAR_17):...\n",
""
] | [
"def api_listdir(self, directory):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"@login_required...\n",
"VAR_11 = TopicPrivate.objects.for_create_or_404(VAR_3, VAR_1.user)\n",
"VAR_14 = TopicPrivateInviteForm(VAR_12=topic_private.topic, data=post_data(\n request))\n",
"if VAR_14.is_valid():\n",
"VAR_14.save()\n",
"messages.error(VAR_1, utils.render_form_errors(VAR_14))\n",
"notify_access(VAR_7=form.get_user(), VAR_11=topic_private)\n",
"return redirect(VAR_1.POST.get('next', VAR_11.get_absolute_url()))\n"
] | [
"@login_required...\n",
"topic_private = TopicPrivate.objects.for_create_or_404(topic_id, request.user)\n",
"form = TopicPrivateInviteForm(topic=topic_private.topic, data=post_data(\n request))\n",
"if form.is_valid():\n",
"form.save()\n",
"messages.error(request, utils.render_form_errors(form))\n",
"notify_access(user=form.get_user(), topic_private=topic_private)\n",
"return redirect(request.POST.get('next', topic_private.get_absolute_url()))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
4
] | [
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_63(VAR_121=True, VAR_24=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_24:\n",
"VAR_24 = VAR_1.sites_path\n",
"VAR_189 = FUNC_69(os.path.join(VAR_24, 'apps.txt'), VAR_126=True)\n",
"if VAR_121:\n",
"for VAR_219 in FUNC_69(os.path.join(VAR_1.site_path, 'apps.txt')):\n",
"if 'frappe' in VAR_189:\n",
"if VAR_219 not in VAR_189:\n",
"VAR_189.remove('frappe')\n",
"VAR_189.insert(0, 'frappe')\n",
"VAR_189.append(VAR_219)\n",
"return VAR_189\n"
] | [
"def get_all_apps(with_internal_apps=True, sites_path=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if not sites_path:\n",
"sites_path = local.sites_path\n",
"apps = get_file_items(os.path.join(sites_path, 'apps.txt'), raise_not_found\n =True)\n",
"if with_internal_apps:\n",
"for app in get_file_items(os.path.join(local.site_path, 'apps.txt')):\n",
"if 'frappe' in apps:\n",
"if app not in apps:\n",
"apps.remove('frappe')\n",
"apps.insert(0, 'frappe')\n",
"apps.append(app)\n",
"return apps\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Condition",
"For",
"Condition",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"@override_config({'send_federation': True})...\n",
"self.room_members = [VAR_0, VAR_2]\n",
"self.get_success(self.handler.started_typing(target_user=U_APPLE, requester\n =create_requester(U_APPLE), VAR_16=ROOM_ID, timeout=20000))\n",
"VAR_19 = self.hs.get_http_client().put_json\n",
"VAR_19.assert_called_once_with('farm', path=\n '/_matrix/federation/v1/send/1000000', data=_expect_edu_transaction(\n 'm.typing', content={'room_id': ROOM_ID, 'user_id': U_APPLE.to_string(),\n 'typing': True}), json_data_callback=ANY, long_retries=True,\n backoff_on_404=True, try_trailing_slash_on_400=True)\n"
] | [
"@override_config({'send_federation': True})...\n",
"self.room_members = [U_APPLE, U_ONION]\n",
"self.get_success(self.handler.started_typing(target_user=U_APPLE, requester\n =create_requester(U_APPLE), room_id=ROOM_ID, timeout=20000))\n",
"put_json = self.hs.get_http_client().put_json\n",
"put_json.assert_called_once_with('farm', path=\n '/_matrix/federation/v1/send/1000000', data=_expect_edu_transaction(\n 'm.typing', content={'room_id': ROOM_ID, 'user_id': U_APPLE.to_string(),\n 'typing': True}), json_data_callback=ANY, long_retries=True,\n backoff_on_404=True, try_trailing_slash_on_400=True)\n"
] | [
0,
0,
0,
4,
0
] | [
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"@require_POST...\n",
"if not is_ajax(VAR_0):\n",
"return Http404()\n",
"VAR_7 = CommentImageForm(VAR_5=request.user, data=request.POST, files=\n request.FILES)\n",
"if VAR_7.is_valid():\n",
"VAR_13 = VAR_7.save()\n",
"return json_response({'error': dict(VAR_7.errors.items())})\n",
"return json_response({'url': VAR_13.url})\n"
] | [
"@require_POST...\n",
"if not is_ajax(request):\n",
"return Http404()\n",
"form = CommentImageForm(user=request.user, data=request.POST, files=request\n .FILES)\n",
"if form.is_valid():\n",
"image = form.save()\n",
"return json_response({'error': dict(form.errors.items())})\n",
"return json_response({'url': image.url})\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Return'"
] |
[
"def FUNC_3(VAR_4):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_7 = 'Browse directory: {}'.format(VAR_4)\n",
"if FUNC_1(VAR_4):\n",
"VAR_12 = None\n",
"VAR_12 = FUNC_2(VAR_4)\n",
"VAR_1 = os.listdir(VAR_4)\n",
"VAR_10 = jinja.render('error.html', VAR_7='Error while reading directory',\n url='file:///{}'.format(path), error=str(e))\n",
"VAR_8 = FUNC_0(VAR_4, VAR_1, os.path.isfile)\n",
"return VAR_10.encode('UTF-8', errors='xmlcharrefreplace')\n",
"VAR_9 = FUNC_0(VAR_4, VAR_1, os.path.isdir)\n",
"VAR_10 = jinja.render('dirbrowser.html', VAR_7=title, url=path, VAR_12=\n parent, VAR_8=files, VAR_9=directories)\n",
"return VAR_10.encode('UTF-8', errors='xmlcharrefreplace')\n"
] | [
"def dirbrowser_html(path):...\n",
"\"\"\"docstring\"\"\"\n",
"title = 'Browse directory: {}'.format(path)\n",
"if is_root(path):\n",
"parent = None\n",
"parent = parent_dir(path)\n",
"all_files = os.listdir(path)\n",
"html = jinja.render('error.html', title='Error while reading directory',\n url='file:///{}'.format(path), error=str(e))\n",
"files = get_file_list(path, all_files, os.path.isfile)\n",
"return html.encode('UTF-8', errors='xmlcharrefreplace')\n",
"directories = get_file_list(path, all_files, os.path.isdir)\n",
"html = jinja.render('dirbrowser.html', title=title, url=path, parent=parent,\n files=files, directories=directories)\n",
"return html.encode('UTF-8', errors='xmlcharrefreplace')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_37(self, VAR_113='Welcome', VAR_114=None, VAR_115=(' [ ', ' | ',...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_250 = []\n",
"self.bar = ''\n",
"VAR_28 = VAR_263.T\n",
"VAR_117 = [] if not VAR_117 else VAR_117\n",
"if not VAR_114:\n",
"VAR_114 = self.url(self.settings.function)\n",
"VAR_56 = VAR_263.request\n",
"if URL() == VAR_114:\n",
"VAR_112 = ''\n",
"VAR_112 = '?_next=' + urllib_quote(URL(VAR_11=request.args, VAR_96=request.\n get_vars))\n",
"VAR_251 = lambda VAR_105: '%s/%s%s' % (VAR_114, VAR_105, VAR_112 if VAR_117 is\n VAR_3 or VAR_105 in VAR_117 else '')\n",
"if isinstance(VAR_113, str):\n",
"VAR_113 = VAR_28(VAR_113)\n",
"if VAR_113:\n",
"VAR_113 = VAR_113.strip() + ' '\n",
"def FUNC_154(*VAR_9, **VAR_13):...\n",
"VAR_13['_rel'] = 'nofollow'\n",
"return A(*VAR_9, **b)\n"
] | [
"def navbar(self, prefix='Welcome', action=None, separators=(' [ ', ' | ',...\n",
"\"\"\"docstring\"\"\"\n",
"items = []\n",
"self.bar = ''\n",
"T = current.T\n",
"referrer_actions = [] if not referrer_actions else referrer_actions\n",
"if not action:\n",
"action = self.url(self.settings.function)\n",
"request = current.request\n",
"if URL() == action:\n",
"next = ''\n",
"next = '?_next=' + urllib_quote(URL(args=request.args, vars=request.get_vars))\n",
"href = lambda function: '%s/%s%s' % (action, function, next if \n referrer_actions is DEFAULT or function in referrer_actions else '')\n",
"if isinstance(prefix, str):\n",
"prefix = T(prefix)\n",
"if prefix:\n",
"prefix = prefix.strip() + ' '\n",
"def Anr(*a, **b):...\n",
"b['_rel'] = 'nofollow'\n",
"return A(*a, **b)\n"
] | [
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'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_4(self):...\n",
"VAR_4 = self._makeEngine()\n",
"for p in ('x', 'x/y', 'x/y/z'):\n",
"VAR_4.compile(p)\n",
"VAR_4.compile('path:a|b|c/d/e')\n",
"VAR_4.compile('string:Fred')\n",
"VAR_4.compile('string:A$B')\n",
"VAR_4.compile('string:a ${x/y} b ${y/z} c')\n",
"VAR_4.compile('python: 2 + 2')\n",
"VAR_4.compile(\"\"\"python: 2 \n+\n 2\n\"\"\")\n"
] | [
"def test_compile(self):...\n",
"e = self._makeEngine()\n",
"for p in ('x', 'x/y', 'x/y/z'):\n",
"e.compile(p)\n",
"e.compile('path:a|b|c/d/e')\n",
"e.compile('string:Fred')\n",
"e.compile('string:A$B')\n",
"e.compile('string:a ${x/y} b ${y/z} c')\n",
"e.compile('python: 2 + 2')\n",
"e.compile(\"\"\"python: 2 \n+\n 2\n\"\"\")\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@VAR_2.route('/ajax/listrestriction/<int:res_type>', defaults={'user_id': 0})...\n",
"if VAR_8 == 0:\n",
"VAR_103 = [{'Element': VAR_17, 'type': _('Deny'), 'id': 'd' + str(i)} for i,\n VAR_17 in enumerate(config.list_denied_tags()) if VAR_17 != '']\n",
"if VAR_8 == 1:\n",
"VAR_7 = [{'Element': VAR_17, 'type': _('Allow'), 'id': 'a' + str(i)} for i,\n VAR_17 in enumerate(config.list_allowed_tags()) if VAR_17 != '']\n",
"VAR_103 = [{'Element': VAR_17, 'type': _('Deny'), 'id': 'd' + str(i)} for i,\n VAR_17 in enumerate(config.list_denied_column_values()) if VAR_17 != '']\n",
"if VAR_8 == 2:\n",
"VAR_67 = VAR_103 + VAR_7\n",
"VAR_7 = [{'Element': VAR_17, 'type': _('Allow'), 'id': 'a' + str(i)} for i,\n VAR_17 in enumerate(config.list_allowed_column_values()) if VAR_17 != '']\n",
"if isinstance(VAR_9, VAR_119):\n",
"if VAR_8 == 3:\n",
"VAR_68 = json.dumps(VAR_67)\n",
"VAR_67 = VAR_103 + VAR_7\n",
"VAR_120 = ub.session.query(ub.User).filter(ub.User.id == VAR_9).first()\n",
"VAR_120 = VAR_62\n",
"if isinstance(VAR_9, VAR_119):\n",
"VAR_67 = ''\n",
"VAR_52 = make_response(VAR_68)\n",
"VAR_103 = [{'Element': VAR_17, 'type': _('Deny'), 'id': 'd' + str(i)} for i,\n VAR_17 in enumerate(VAR_120.list_denied_tags()) if VAR_17 != '']\n",
"VAR_120 = ub.session.query(ub.User).filter(ub.User.id == VAR_9).first()\n",
"VAR_120 = VAR_62\n",
"VAR_52.headers['Content-Type'] = 'application/json; charset=utf-8'\n",
"VAR_7 = [{'Element': VAR_17, 'type': _('Allow'), 'id': 'a' + str(i)} for i,\n VAR_17 in enumerate(VAR_120.list_allowed_tags()) if VAR_17 != '']\n",
"VAR_103 = [{'Element': VAR_17, 'type': _('Deny'), 'id': 'd' + str(i)} for i,\n VAR_17 in enumerate(VAR_120.list_denied_column_values()) if VAR_17 != '']\n",
"return VAR_52\n",
"VAR_67 = VAR_103 + VAR_7\n",
"VAR_7 = [{'Element': VAR_17, 'type': _('Allow'), 'id': 'a' + str(i)} for i,\n VAR_17 in enumerate(VAR_120.list_allowed_column_values()) if VAR_17 != '']\n",
"VAR_67 = VAR_103 + VAR_7\n"
] | [
"@admi.route('/ajax/listrestriction/<int:res_type>', defaults={'user_id': 0})...\n",
"if res_type == 0:\n",
"restrict = [{'Element': x, 'type': _('Deny'), 'id': 'd' + str(i)} for i, x in\n enumerate(config.list_denied_tags()) if x != '']\n",
"if res_type == 1:\n",
"allow = [{'Element': x, 'type': _('Allow'), 'id': 'a' + str(i)} for i, x in\n enumerate(config.list_allowed_tags()) if x != '']\n",
"restrict = [{'Element': x, 'type': _('Deny'), 'id': 'd' + str(i)} for i, x in\n enumerate(config.list_denied_column_values()) if x != '']\n",
"if res_type == 2:\n",
"json_dumps = restrict + allow\n",
"allow = [{'Element': x, 'type': _('Allow'), 'id': 'a' + str(i)} for i, x in\n enumerate(config.list_allowed_column_values()) if x != '']\n",
"if isinstance(user_id, int):\n",
"if res_type == 3:\n",
"js = json.dumps(json_dumps)\n",
"json_dumps = restrict + allow\n",
"usr = ub.session.query(ub.User).filter(ub.User.id == user_id).first()\n",
"usr = current_user\n",
"if isinstance(user_id, int):\n",
"json_dumps = ''\n",
"response = make_response(js)\n",
"restrict = [{'Element': x, 'type': _('Deny'), 'id': 'd' + str(i)} for i, x in\n enumerate(usr.list_denied_tags()) if x != '']\n",
"usr = ub.session.query(ub.User).filter(ub.User.id == user_id).first()\n",
"usr = current_user\n",
"response.headers['Content-Type'] = 'application/json; charset=utf-8'\n",
"allow = [{'Element': x, 'type': _('Allow'), 'id': 'a' + str(i)} for i, x in\n enumerate(usr.list_allowed_tags()) if x != '']\n",
"restrict = [{'Element': x, 'type': _('Deny'), 'id': 'd' + str(i)} for i, x in\n enumerate(usr.list_denied_column_values()) if x != '']\n",
"return response\n",
"json_dumps = restrict + allow\n",
"allow = [{'Element': x, 'type': _('Allow'), 'id': 'a' + str(i)} for i, x in\n enumerate(usr.list_allowed_column_values()) if x != '']\n",
"json_dumps = restrict + allow\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
] | [
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_13(self):...\n",
"if self.report_type == 'Script Report':\n",
"make_boilerplate('controller.py', self, {'name': self.name})\n",
"make_boilerplate('controller.js', self, {'name': self.name})\n"
] | [
"def create_report_py(self):...\n",
"if self.report_type == 'Script Report':\n",
"make_boilerplate('controller.py', self, {'name': self.name})\n",
"make_boilerplate('controller.js', self, {'name': self.name})\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_118(*VAR_9, **VAR_13):...\n",
"VAR_431, VAR_432, VAR_141 = self.basic()\n",
"VAR_141 = VAR_141 or self.user\n",
"VAR_433 = VAR_145\n",
"if callable(VAR_433):\n",
"VAR_433 = VAR_433()\n",
"if VAR_433:\n",
"if not VAR_141:\n",
"if callable(VAR_144):\n",
"if VAR_263.request.ajax:\n",
"VAR_453 = VAR_144()\n",
"VAR_453 = VAR_144\n",
"if VAR_90 is not None:\n",
"if not VAR_453:\n",
"if callable(VAR_90):\n",
"if self.settings.allow_basic_login_only or VAR_432 or VAR_263.request.is_restful:\n",
"VAR_263.session.flash = self.messages.access_denied\n",
"return VAR_114(*VAR_9, **b)\n",
"return VAR_90()\n",
"redirect(VAR_90)\n",
"VAR_112 = self.here()\n",
"return FUNC_3(self.settings.on_failed_authorization)\n",
"VAR_263.session.flash = VAR_263.response.flash\n",
"return FUNC_3(self.settings.on_failed_authentication, self.settings.\n login_url + '?_next=' + urllib_quote(VAR_112))\n"
] | [
"def f(*a, **b):...\n",
"basic_allowed, basic_accepted, user = self.basic()\n",
"user = user or self.user\n",
"login_required = requires_login\n",
"if callable(login_required):\n",
"login_required = login_required()\n",
"if login_required:\n",
"if not user:\n",
"if callable(condition):\n",
"if current.request.ajax:\n",
"flag = condition()\n",
"flag = condition\n",
"if otherwise is not None:\n",
"if not flag:\n",
"if callable(otherwise):\n",
"if self.settings.allow_basic_login_only or basic_accepted or current.request.is_restful:\n",
"current.session.flash = self.messages.access_denied\n",
"return action(*a, **b)\n",
"return otherwise()\n",
"redirect(otherwise)\n",
"next = self.here()\n",
"return call_or_redirect(self.settings.on_failed_authorization)\n",
"current.session.flash = current.response.flash\n",
"return call_or_redirect(self.settings.on_failed_authentication, self.\n settings.login_url + '?_next=' + urllib_quote(next))\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
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Condition",
"Assign'",
"Return'",
"Return'",
"Expr'",
"Assign'",
"Return'",
"Assign'",
"Return'"
] |
[
"def FUNC_1(VAR_3):...\n",
"return unicode(VAR_3).encode('utf-8')\n"
] | [
"def _safestr(s):...\n",
"return unicode(s).encode('utf-8')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_87(VAR_62):...\n",
"\"\"\"docstring\"\"\"\n",
"from frappe.modules import get_doctype_module, get_module_path\n",
"VAR_43 = os.path.join(FUNC_58(get_doctype_module(VAR_62)), 'doctype',\n FUNC_56(VAR_62), 'test_records.json')\n",
"if os.path.exists(VAR_43):\n",
"return json.loads(f.read())\n",
"return []\n"
] | [
"def get_test_records(doctype):...\n",
"\"\"\"docstring\"\"\"\n",
"from frappe.modules import get_doctype_module, get_module_path\n",
"path = os.path.join(get_module_path(get_doctype_module(doctype)), 'doctype',\n scrub(doctype), 'test_records.json')\n",
"if os.path.exists(path):\n",
"return json.loads(f.read())\n",
"return []\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"ImportFrom'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def __attrs_post_init__(self):...\n",
"self.key_ids = signature_ids(self.json_object, self.server_name)\n"
] | [
"def __attrs_post_init__(self):...\n",
"self.key_ids = signature_ids(self.json_object, self.server_name)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"def FUNC_15(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_139 = 'queue_access_%s' % self.slug\n",
"self.permission_name = 'helpdesk.%s' % VAR_139\n",
"return VAR_139\n"
] | [
"def prepare_permission_name(self):...\n",
"\"\"\"docstring\"\"\"\n",
"basename = 'queue_access_%s' % self.slug\n",
"self.permission_name = 'helpdesk.%s' % basename\n",
"return basename\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_29(VAR_66):...\n",
"VAR_105 = FUNC_28(VAR_66._identifier, VAR_66.on_ui_render, VAR_15=p.\n get_ui_additional_key_data_for_cache, VAR_61=p.\n get_ui_additional_tracked_files, VAR_63=p.get_ui_custom_tracked_files,\n VAR_64=p.get_ui_custom_etag, VAR_65=p.get_ui_custom_lastmodified,\n VAR_62=p.get_ui_additional_etag(default_additional_etag))\n",
"if VAR_46 and VAR_66.get_ui_preemptive_caching_enabled():\n",
"VAR_60 = FUNC_27(VAR_66._identifier, VAR_105, VAR_66.\n get_ui_data_for_preemptive_caching, VAR_66.\n get_ui_additional_request_data_for_preemptive_caching, VAR_66.\n get_ui_preemptive_caching_additional_unless)\n",
"VAR_60 = VAR_105\n",
"VAR_30 = VAR_66.get_ui_custom_template_filter(FUNC_26)\n",
"if VAR_30 is not None and callable(VAR_30):\n",
"VAR_82 = FUNC_13(VAR_1[VAR_14], VAR_30)\n",
"VAR_82 = VAR_1[VAR_14]\n",
"VAR_43 = FUNC_9(VAR_82, VAR_2, VAR_3, VAR_21)\n",
"return VAR_60(VAR_21, request, VAR_43)\n"
] | [
"def plugin_view(p):...\n",
"cached = get_cached_view(p._identifier, p.on_ui_render, additional_key_data\n =p.get_ui_additional_key_data_for_cache, additional_files=p.\n get_ui_additional_tracked_files, custom_files=p.\n get_ui_custom_tracked_files, custom_etag=p.get_ui_custom_etag,\n custom_lastmodified=p.get_ui_custom_lastmodified, additional_etag=p.\n get_ui_additional_etag(default_additional_etag))\n",
"if preemptive_cache_enabled and p.get_ui_preemptive_caching_enabled():\n",
"view = get_preemptively_cached_view(p._identifier, cached, p.\n get_ui_data_for_preemptive_caching, p.\n get_ui_additional_request_data_for_preemptive_caching, p.\n get_ui_preemptive_caching_additional_unless)\n",
"view = cached\n",
"template_filter = p.get_ui_custom_template_filter(default_template_filter)\n",
"if template_filter is not None and callable(template_filter):\n",
"filtered_templates = _filter_templates(_templates[locale], template_filter)\n",
"filtered_templates = _templates[locale]\n",
"render_kwargs = _get_render_kwargs(filtered_templates, _plugin_names,\n _plugin_vars, now)\n",
"return view(now, request, render_kwargs)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_21(self, VAR_9, VAR_20):...\n",
"f.write(VAR_20)\n"
] | [
"def albumartcache_save(self, path, data):...\n",
"f.write(data)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_26(VAR_21):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_54 = 'string'\n",
"VAR_55 = VAR_21.add_parser('convert', description=convert_msg,\n formatter_class=argparse.RawTextHelpFormatter)\n",
"VAR_55.add_argument('--dir', type=str, required=True, help=\n 'directory containing the SavedModel to convert')\n",
"VAR_55.add_argument('--output_dir', type=str, required=True, help=\n 'output directory for the converted SavedModel')\n",
"VAR_55.add_argument('--tag_set', type=str, required=True, help=\n \"tag-set of graph in SavedModel to convert, separated by ','\")\n",
"VAR_56 = VAR_55.add_subparsers(title='conversion methods', description=\n 'valid conversion methods', help=\n 'the conversion to run with the SavedModel')\n",
"VAR_57 = VAR_56.add_parser('tensorrt', description=\n 'Convert the SavedModel with Tensorflow-TensorRT integration',\n formatter_class=argparse.RawTextHelpFormatter)\n",
"VAR_57.add_argument('--max_workspace_size_bytes', type=int, default=2 << 20,\n help=\n 'the maximum GPU temporary memory which the TRT engine can use at execution time'\n )\n",
"VAR_57.add_argument('--precision_mode', type=str, default='FP32', help=\n 'one of FP32, FP16 and INT8')\n",
"VAR_57.add_argument('--minimum_segment_size', type=int, default=3, help=\n 'the minimum number of nodes required for a subgraph to be replacedin a TensorRT node'\n )\n",
"VAR_57.add_argument('--convert_tf1_model', type=bool, default=False, help=\n 'support TRT conversion for TF1 models')\n",
"VAR_57.set_defaults(func=convert_with_tensorrt)\n"
] | [
"def add_convert_subparser(subparsers):...\n",
"\"\"\"docstring\"\"\"\n",
"convert_msg = \"\"\"Usage example:\nTo convert the SavedModel to one that have TensorRT ops:\n$saved_model_cli convert \\\\\n --dir /tmp/saved_model \\\\\n --tag_set serve \\\\\n --output_dir /tmp/saved_model_trt \\\\\n tensorrt \n\"\"\"\n",
"parser_convert = subparsers.add_parser('convert', description=convert_msg,\n formatter_class=argparse.RawTextHelpFormatter)\n",
"parser_convert.add_argument('--dir', type=str, required=True, help=\n 'directory containing the SavedModel to convert')\n",
"parser_convert.add_argument('--output_dir', type=str, required=True, help=\n 'output directory for the converted SavedModel')\n",
"parser_convert.add_argument('--tag_set', type=str, required=True, help=\n \"tag-set of graph in SavedModel to convert, separated by ','\")\n",
"convert_subparsers = parser_convert.add_subparsers(title=\n 'conversion methods', description='valid conversion methods', help=\n 'the conversion to run with the SavedModel')\n",
"parser_convert_with_tensorrt = convert_subparsers.add_parser('tensorrt',\n description=\n 'Convert the SavedModel with Tensorflow-TensorRT integration',\n formatter_class=argparse.RawTextHelpFormatter)\n",
"parser_convert_with_tensorrt.add_argument('--max_workspace_size_bytes',\n type=int, default=2 << 20, help=\n 'the maximum GPU temporary memory which the TRT engine can use at execution time'\n )\n",
"parser_convert_with_tensorrt.add_argument('--precision_mode', type=str,\n default='FP32', help='one of FP32, FP16 and INT8')\n",
"parser_convert_with_tensorrt.add_argument('--minimum_segment_size', type=\n int, default=3, help=\n 'the minimum number of nodes required for a subgraph to be replacedin a TensorRT node'\n )\n",
"parser_convert_with_tensorrt.add_argument('--convert_tf1_model', type=bool,\n default=False, help='support TRT conversion for TF1 models')\n",
"parser_convert_with_tensorrt.set_defaults(func=convert_with_tensorrt)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"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'"
] |
[
"def FUNC_10(self, VAR_5, VAR_6):...\n",
"VAR_7 = self.get_image_uuid(VAR_5, VAR_6)\n",
"VAR_9 = self.service.show(VAR_5, VAR_7)\n",
"return self._translate_uuid_to_id(VAR_5, VAR_9)\n"
] | [
"def show(self, context, image_id):...\n",
"image_uuid = self.get_image_uuid(context, image_id)\n",
"image = self.service.show(context, image_uuid)\n",
"return self._translate_uuid_to_id(context, image)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_8(VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_25 = saved_model_utils.get_saved_model_tag_sets(VAR_2)\n",
"for VAR_3 in sorted(VAR_25):\n",
"print(\n \"\"\"\nMetaGraphDef with tag-set: '%s' contains the following SignatureDefs:\"\"\"\n % ', '.join(VAR_3))\n",
"FUNC_5(VAR_2)\n",
"VAR_3 = ','.join(VAR_3)\n",
"VAR_26 = FUNC_10(VAR_2, VAR_3)\n",
"for VAR_5 in sorted(VAR_26.keys()):\n",
"print(\"\\nsignature_def['\" + VAR_5 + \"']:\")\n",
"FUNC_4(VAR_2, VAR_3, VAR_5, VAR_6=1)\n"
] | [
"def _show_all(saved_model_dir):...\n",
"\"\"\"docstring\"\"\"\n",
"tag_sets = saved_model_utils.get_saved_model_tag_sets(saved_model_dir)\n",
"for tag_set in sorted(tag_sets):\n",
"print(\n \"\"\"\nMetaGraphDef with tag-set: '%s' contains the following SignatureDefs:\"\"\"\n % ', '.join(tag_set))\n",
"_show_defined_functions(saved_model_dir)\n",
"tag_set = ','.join(tag_set)\n",
"signature_def_map = get_signature_def_map(saved_model_dir, tag_set)\n",
"for signature_def_key in sorted(signature_def_map.keys()):\n",
"print(\"\\nsignature_def['\" + signature_def_key + \"']:\")\n",
"_show_inputs_outputs(saved_model_dir, tag_set, signature_def_key, indent=1)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"For",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"For",
"Expr'",
"Expr'"
] |
[
"@def_function.function(input_signature=[tensor_spec.TensorSpec(shape=(2048,...\n",
"return {'res': VAR_44 + self.var}\n"
] | [
"@def_function.function(input_signature=[tensor_spec.TensorSpec(shape=(2048,...\n",
"return {'res': x + self.var}\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_19(self):...\n",
"VAR_22, VAR_23 = self.make_request('POST', '/createRoom', b'{\"visibili')\n",
"self.assertEquals(400, VAR_23.code)\n",
"VAR_22, VAR_23 = self.make_request('POST', '/createRoom', b'[\"hello\"]')\n",
"self.assertEquals(400, VAR_23.code)\n"
] | [
"def test_post_room_invalid_content(self):...\n",
"request, channel = self.make_request('POST', '/createRoom', b'{\"visibili')\n",
"self.assertEquals(400, channel.code)\n",
"request, channel = self.make_request('POST', '/createRoom', b'[\"hello\"]')\n",
"self.assertEquals(400, channel.code)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_0(self):...\n",
"self.http_client = Mock()\n",
"self.reactor = ThreadedMemoryReactorClock()\n",
"self.hs_clock = Clock(self.reactor)\n",
"self.homeserver = setup_test_homeserver(self.addCleanup, http_client=self.\n http_client, clock=self.hs_clock, reactor=self.reactor)\n",
"VAR_0 = UserID('us', 'test')\n",
"VAR_1 = create_requester(VAR_0)\n",
"VAR_2 = self.homeserver.get_room_creation_handler()\n",
"self.room_id = self.get_success(VAR_2.create_room(VAR_1, VAR_2.\n _presets_dict['public_chat'], ratelimit=False))[0]['room_id']\n",
"self.store = self.homeserver.get_datastore()\n",
"VAR_3 = self.get_success(self.homeserver.get_datastore().\n get_latest_event_ids_in_room(self.room_id))[0]\n",
"VAR_4 = make_event_from_dict({'room_id': self.room_id, 'sender':\n '@baduser:test.serv', 'state_key': '@baduser:test.serv', 'event_id':\n '$join:test.serv', 'depth': 1000, 'origin_server_ts': 1, 'type':\n 'm.room.member', 'origin': 'test.servx', 'content': {'membership':\n 'join'}, 'auth_events': [], 'prev_state': [(VAR_3, {})], 'prev_events':\n [(VAR_3, {})]})\n",
"self.handler = self.homeserver.get_federation_handler()\n",
"self.handler.do_auth = lambda origin, event, context, auth_events: succeed(\n context)\n",
"self.client = self.homeserver.get_federation_client()\n",
"self.client._check_sigs_and_hash_and_fetch = lambda dest, pdus, **k: succeed(\n pdus)\n",
"self.assertEqual(self.get_success(self.handler.on_receive_pdu('test.serv',\n VAR_4, sent_to_us_directly=True)), None)\n",
"self.assertEqual(self.get_success(self.store.get_latest_event_ids_in_room(\n self.room_id))[0], '$join:test.serv')\n"
] | [
"def setUp(self):...\n",
"self.http_client = Mock()\n",
"self.reactor = ThreadedMemoryReactorClock()\n",
"self.hs_clock = Clock(self.reactor)\n",
"self.homeserver = setup_test_homeserver(self.addCleanup, http_client=self.\n http_client, clock=self.hs_clock, reactor=self.reactor)\n",
"user_id = UserID('us', 'test')\n",
"our_user = create_requester(user_id)\n",
"room_creator = self.homeserver.get_room_creation_handler()\n",
"self.room_id = self.get_success(room_creator.create_room(our_user,\n room_creator._presets_dict['public_chat'], ratelimit=False))[0]['room_id']\n",
"self.store = self.homeserver.get_datastore()\n",
"most_recent = self.get_success(self.homeserver.get_datastore().\n get_latest_event_ids_in_room(self.room_id))[0]\n",
"join_event = make_event_from_dict({'room_id': self.room_id, 'sender':\n '@baduser:test.serv', 'state_key': '@baduser:test.serv', 'event_id':\n '$join:test.serv', 'depth': 1000, 'origin_server_ts': 1, 'type':\n 'm.room.member', 'origin': 'test.servx', 'content': {'membership':\n 'join'}, 'auth_events': [], 'prev_state': [(most_recent, {})],\n 'prev_events': [(most_recent, {})]})\n",
"self.handler = self.homeserver.get_federation_handler()\n",
"self.handler.do_auth = lambda origin, event, context, auth_events: succeed(\n context)\n",
"self.client = self.homeserver.get_federation_client()\n",
"self.client._check_sigs_and_hash_and_fetch = lambda dest, pdus, **k: succeed(\n pdus)\n",
"self.assertEqual(self.get_success(self.handler.on_receive_pdu('test.serv',\n join_event, sent_to_us_directly=True)), None)\n",
"self.assertEqual(self.get_success(self.store.get_latest_event_ids_in_room(\n self.room_id))[0], '$join:test.serv')\n"
] | [
0,
0,
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"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"
] | [
"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
] | [
"AsyncFunctionDef'",
"Docstring",
"FunctionDef'",
"Assign'",
"Expr'",
"Return'"
] |
[
"@log_function...\n",
"VAR_2 = FUNC_1('/get_missing_events/%s', VAR_6)\n",
"VAR_19 = await self.client.post_json(VAR_5=destination, VAR_2=path, VAR_39=\n {'limit': int(limit), 'min_depth': int(min_depth), 'earliest_events':\n earliest_events, 'latest_events': latest_events}, VAR_8=timeout)\n",
"return VAR_19\n"
] | [
"@log_function...\n",
"path = _create_v1_path('/get_missing_events/%s', room_id)\n",
"content = await self.client.post_json(destination=destination, path=path,\n data={'limit': int(limit), 'min_depth': int(min_depth),\n 'earliest_events': earliest_events, 'latest_events': latest_events},\n timeout=timeout)\n",
"return content\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_15(VAR_0):...\n",
"VAR_0.DEBUG = True\n",
"VAR_6 = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentParent'\")\n",
"VAR_7 = unicorn(None, VAR_6)\n",
"VAR_8 = {}\n",
"VAR_12 = VAR_7.render(VAR_8)\n",
"assert '<script type=\"module\"' in VAR_12\n",
"assert len(re.findall('<script type=\"module\"', VAR_12)) == 1\n",
"assert '\"hash\":\"' in VAR_12\n",
"VAR_13 = VAR_12.index('<script')\n",
"VAR_14 = VAR_12[:VAR_13]\n",
"VAR_15 = generate_checksum(VAR_14)\n",
"assert f'\"hash\":\"{VAR_15}\"' in VAR_12\n"
] | [
"def test_unicorn_render_hash(settings):...\n",
"settings.DEBUG = True\n",
"token = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentParent'\")\n",
"unicorn_node = unicorn(None, token)\n",
"context = {}\n",
"html = unicorn_node.render(context)\n",
"assert '<script type=\"module\"' in html\n",
"assert len(re.findall('<script type=\"module\"', html)) == 1\n",
"assert '\"hash\":\"' in html\n",
"script_idx = html.index('<script')\n",
"rendered_content = html[:script_idx]\n",
"expected_hash = generate_checksum(rendered_content)\n",
"assert f'\"hash\":\"{expected_hash}\"' in html\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assert'",
"Assert'",
"Assert'",
"Assign'",
"Assign'",
"Assign'",
"Assert'"
] |
[
"def FUNC_16(VAR_11, VAR_28=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_11:\n",
"return False\n",
"VAR_37 = urllib_parse.urlparse(VAR_11)[1]\n",
"return not VAR_37 or VAR_37 == VAR_28\n"
] | [
"def is_safe_url(url, host=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if not url:\n",
"return False\n",
"netloc = urllib_parse.urlparse(url)[1]\n",
"return not netloc or netloc == host\n"
] | [
0,
0,
0,
0,
2,
2
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Return'"
] |
[
"def FUNC_7(self, VAR_44):...\n",
"VAR_77 = len(VAR_44.group(0))\n",
"if VAR_77 > 1:\n",
"self.tokens.append({'type': 'newline'})\n"
] | [
"def parse_newline(self, m):...\n",
"length = len(m.group(0))\n",
"if length > 1:\n",
"self.tokens.append({'type': 'newline'})\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Expr'"
] |
[
"def FUNC_14(self):...\n",
"if not FUNC_19('npm'):\n",
"print('npm unavailable', file=sys.stderr)\n",
"if not os.path.exists(self.node_modules):\n",
"return False\n",
"return True\n",
"return FUNC_6(self.node_modules) < FUNC_6(VAR_1(VAR_2, 'package.json'))\n"
] | [
"def should_run_npm(self):...\n",
"if not which('npm'):\n",
"print('npm unavailable', file=sys.stderr)\n",
"if not os.path.exists(self.node_modules):\n",
"return False\n",
"return True\n",
"return mtime(self.node_modules) < mtime(pjoin(repo_root, 'package.json'))\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Condition",
"Return'",
"Return'",
"Return'"
] |
[
"@VAR_1.route('/' + VAR_0.stats_path)...\n",
"return render_template('/login.html')\n"
] | [
"@app.route('/' + trape.stats_path)...\n",
"return render_template('/login.html')\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_50(VAR_21):...\n",
"return VAR_21.depth, VAR_21.event_id\n"
] | [
"def sort_fun(ev):...\n",
"return ev.depth, ev.event_id\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_12(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_18 = [[['item']], [{'item1': 'value1'}], {'item1': 'value1'}]\n",
"VAR_19 = [['list'], '', None, True, False]\n",
"for case in VAR_18:\n",
"self.assertEqual(add_nested_class(case), 'class=nested')\n",
"for case in VAR_19:\n",
"self.assertEqual(add_nested_class(case), '')\n"
] | [
"def test_add_nested_class(self):...\n",
"\"\"\"docstring\"\"\"\n",
"positive_cases = [[['item']], [{'item1': 'value1'}], {'item1': 'value1'}]\n",
"negative_cases = [['list'], '', None, True, False]\n",
"for case in positive_cases:\n",
"self.assertEqual(add_nested_class(case), 'class=nested')\n",
"for case in negative_cases:\n",
"self.assertEqual(add_nested_class(case), '')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"For",
"Expr'",
"For",
"Expr'"
] |
[
"from __future__ import unicode_literals\n",
"import six\n",
"from django.core.exceptions import ValidationError\n",
"from django.http import HttpResponseRedirect, JsonResponse\n",
"from django.shortcuts import redirect\n",
"from django.utils.translation import ugettext_lazy as _\n",
"from shuup.apps.provides import get_provide_objects\n",
"from shuup.core.basket import commands\n",
"from shuup.core.basket.command_middleware import BaseBasketCommandMiddleware\n",
"from shuup.core.signals import get_basket_command_handler\n",
"from shuup.utils.django_compat import force_text\n",
"from shuup.utils.excs import Problem\n",
"\"\"\"string\"\"\"\n",
"VAR_0 = commands\n",
"def __init__(self, VAR_1, VAR_2=None):...\n",
"\"\"\"docstring\"\"\"\n",
"self.request = VAR_1\n",
"self.ajax = self.request.is_ajax()\n",
"self.basket = VAR_2 or VAR_1.basket\n",
"def FUNC_0(self, VAR_3):...\n",
"VAR_6 = getattr(self.commands_module, 'handle_%s' % VAR_3.lower(), None)\n",
"if VAR_6 and callable(VAR_6):\n",
"return VAR_6\n",
"for receiver, VAR_6 in get_basket_command_handler.send(CLASS_0, VAR_3=\n",
"if VAR_6 and callable(VAR_6):\n",
"def FUNC_1(self, VAR_3, VAR_4=None):...\n",
"return VAR_6\n",
"\"\"\"docstring\"\"\"\n",
"VAR_4 = VAR_4 or dict(six.iteritems(self.request.POST))\n",
"VAR_6 = self.get_command_handler(VAR_3)\n",
"if not self.ajax:\n",
"VAR_5 = self.postprocess_response(VAR_3, VAR_4, VAR_5)\n",
"if not VAR_6 or not callable(VAR_6):\n",
"VAR_8 = exc.message if hasattr(exc, 'message') else exc\n",
"if self.ajax:\n",
"VAR_4.pop('csrfmiddlewaretoken', None)\n",
"VAR_5 = {'error': force_text(VAR_8, errors='ignore'), 'code': force_text(\n getattr(exc, 'code', None) or '', errors='ignore')}\n",
"return JsonResponse(VAR_5)\n",
"VAR_7 = VAR_5.get('return') or VAR_4.get('return')\n",
"VAR_4.pop('command', None)\n",
"if VAR_7 and VAR_7.startswith('/'):\n",
"VAR_4.update(VAR_1=self.request, VAR_2=self.basket)\n",
"return HttpResponseRedirect(VAR_7)\n",
"return redirect('shuup:basket')\n",
"VAR_4 = self.preprocess_kwargs(VAR_3, VAR_4)\n",
"VAR_5 = VAR_6(**kwargs) or {}\n"
] | [
"from __future__ import unicode_literals\n",
"import six\n",
"from django.core.exceptions import ValidationError\n",
"from django.http import HttpResponseRedirect, JsonResponse\n",
"from django.shortcuts import redirect\n",
"from django.utils.translation import ugettext_lazy as _\n",
"from shuup.apps.provides import get_provide_objects\n",
"from shuup.core.basket import commands\n",
"from shuup.core.basket.command_middleware import BaseBasketCommandMiddleware\n",
"from shuup.core.signals import get_basket_command_handler\n",
"from shuup.utils.django_compat import force_text\n",
"from shuup.utils.excs import Problem\n",
"\"\"\"\n BasketCommandDispatcher handles (usually AJAX) requests that somehow update the basket.\n You should never instantiate BasketCommandDispatcher yourself -- instead use\n `get_basket_command_dispatcher()`.\n\n All `handle_*` methods are expected to accept `**kwargs`.\n \"\"\"\n",
"commands_module = commands\n",
"def __init__(self, request, basket=None):...\n",
"\"\"\"docstring\"\"\"\n",
"self.request = request\n",
"self.ajax = self.request.is_ajax()\n",
"self.basket = basket or request.basket\n",
"def get_command_handler(self, command):...\n",
"handler = getattr(self.commands_module, 'handle_%s' % command.lower(), None)\n",
"if handler and callable(handler):\n",
"return handler\n",
"for receiver, handler in get_basket_command_handler.send(\n",
"if handler and callable(handler):\n",
"def handle(self, command, kwargs=None):...\n",
"return handler\n",
"\"\"\"docstring\"\"\"\n",
"kwargs = kwargs or dict(six.iteritems(self.request.POST))\n",
"handler = self.get_command_handler(command)\n",
"if not self.ajax:\n",
"response = self.postprocess_response(command, kwargs, response)\n",
"if not handler or not callable(handler):\n",
"msg = exc.message if hasattr(exc, 'message') else exc\n",
"if self.ajax:\n",
"kwargs.pop('csrfmiddlewaretoken', None)\n",
"response = {'error': force_text(msg, errors='ignore'), 'code': force_text(\n getattr(exc, 'code', None) or '', errors='ignore')}\n",
"return JsonResponse(response)\n",
"return_url = response.get('return') or kwargs.get('return')\n",
"kwargs.pop('command', None)\n",
"if return_url and return_url.startswith('/'):\n",
"kwargs.update(request=self.request, basket=self.basket)\n",
"return HttpResponseRedirect(return_url)\n",
"return redirect('shuup:basket')\n",
"kwargs = self.preprocess_kwargs(command, kwargs)\n",
"response = handler(**kwargs) or {}\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
] | [
"ImportFrom'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Expr'",
"Assign'",
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"For",
"Condition",
"FunctionDef'",
"Return'",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Return'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Return'",
"Return'",
"Assign'",
"Assign'"
] |
[
"import io\n",
"import os\n",
"import re\n",
"from setuptools import find_packages, setup\n",
"VAR_2 = re.search('__version__ = \\\\\"(.*?)\\\\\"', f.read()).group(1)\n",
"def FUNC_0(VAR_0):...\n",
"return os.path.join(os.path.dirname(__file__), VAR_0)\n"
] | [
"import io\n",
"import os\n",
"import re\n",
"from setuptools import find_packages, setup\n",
"version = re.search('__version__ = \\\\\"(.*?)\\\\\"', f.read()).group(1)\n",
"def fpath(name):...\n",
"return os.path.join(os.path.dirname(__file__), name)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"@FUNC_0...\n",
"return sendmail\n"
] | [
"@cache_in_self...\n",
"return sendmail\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_84(VAR_1):...\n",
"def FUNC_83(*VAR_2, **VAR_3):...\n",
"VAR_9 = VAR_2[0]\n",
"VAR_65 = get_course_by_id(CourseKey.from_string(VAR_3['course_id']))\n",
"if has_access(VAR_9.user, VAR_4, VAR_65):\n",
"return VAR_1(*VAR_2, **kwargs)\n",
"return HttpResponseForbidden()\n"
] | [
"def decorator(func):...\n",
"def wrapped(*args, **kwargs):...\n",
"request = args[0]\n",
"course = get_course_by_id(CourseKey.from_string(kwargs['course_id']))\n",
"if has_access(request.user, level, course):\n",
"return func(*args, **kwargs)\n",
"return HttpResponseForbidden()\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_4(VAR_8):...\n",
"VAR_19 = VAR_8.args.get('signature')\n",
"VAR_6 = float(VAR_8.args.get('expires') or 0)\n",
"VAR_10 = VAR_8.view_args.get('query_id', None)\n",
"VAR_20 = VAR_8.args.get('user_id', None)\n",
"if VAR_19 and time.time() < VAR_6 <= time.time() + 3600:\n",
"if VAR_20:\n",
"return None\n",
"VAR_12 = models.User.query.get(VAR_20)\n",
"if VAR_10:\n",
"VAR_34 = FUNC_1(VAR_12.api_key, VAR_8.path, VAR_6)\n",
"VAR_35 = models.Query.query.filter(models.Query.id == VAR_10).one()\n",
"if VAR_12.api_key and VAR_19 == VAR_34:\n",
"VAR_34 = FUNC_1(VAR_35.api_key, VAR_8.path, VAR_6)\n",
"return VAR_12\n",
"if VAR_35.api_key and VAR_19 == VAR_34:\n",
"return models.ApiUser(VAR_35.api_key, VAR_35.org, list(VAR_35.groups.keys()\n ), VAR_14='ApiKey: Query {}'.format(query.id))\n"
] | [
"def hmac_load_user_from_request(request):...\n",
"signature = request.args.get('signature')\n",
"expires = float(request.args.get('expires') or 0)\n",
"query_id = request.view_args.get('query_id', None)\n",
"user_id = request.args.get('user_id', None)\n",
"if signature and time.time() < expires <= time.time() + 3600:\n",
"if user_id:\n",
"return None\n",
"user = models.User.query.get(user_id)\n",
"if query_id:\n",
"calculated_signature = sign(user.api_key, request.path, expires)\n",
"query = models.Query.query.filter(models.Query.id == query_id).one()\n",
"if user.api_key and signature == calculated_signature:\n",
"calculated_signature = sign(query.api_key, request.path, expires)\n",
"return user\n",
"if query.api_key and signature == calculated_signature:\n",
"return models.ApiUser(query.api_key, query.org, list(query.groups.keys()),\n name='ApiKey: Query {}'.format(query.id))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Condition",
"Return'"
] |
[
"def FUNC_58(VAR_91, *VAR_119):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_91 = FUNC_56(VAR_91)\n",
"return FUNC_61(VAR_1.module_app[VAR_91] + '.' + VAR_91, *VAR_119)\n"
] | [
"def get_module_path(module, *joins):...\n",
"\"\"\"docstring\"\"\"\n",
"module = scrub(module)\n",
"return get_pymodule_path(local.module_app[module] + '.' + module, *joins)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Return'"
] |
[
"def FUNC_30(VAR_91):...\n",
""
] | [
"def get_domain_data(module):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"async def FUNC_15(self, VAR_4: str) ->Tuple[List[str], int]:...\n",
"\"\"\"docstring\"\"\"\n",
"return await self._remove_local_media_from_disk([VAR_4])\n"
] | [
"async def delete_local_media(self, media_id: str) ->Tuple[List[str], int]:...\n",
"\"\"\"docstring\"\"\"\n",
"return await self._remove_local_media_from_disk([media_id])\n"
] | [
0,
0,
0
] | [
"AsyncFunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_19(self, VAR_26: str, *, VAR_29: Optional[Type[Any]]=None, VAR_13:...\n",
"return self.api_route(VAR_26=path, VAR_29=response_model, VAR_13=\n status_code, VAR_30=tags, VAR_31=dependencies, VAR_32=summary, VAR_33=\n description, VAR_34=response_description, VAR_35=responses, VAR_36=\n deprecated, VAR_37=['TRACE'], VAR_38=operation_id, VAR_16=\n response_model_include, VAR_17=response_model_exclude, VAR_18=\n response_model_by_alias, VAR_19=response_model_exclude_unset, VAR_20=\n response_model_exclude_defaults, VAR_21=response_model_exclude_none,\n VAR_39=include_in_schema, VAR_14=response_class, VAR_28=name, VAR_40=\n callbacks)\n"
] | [
"def trace(self, path: str, *, response_model: Optional[Type[Any]]=None,...\n",
"return self.api_route(path=path, response_model=response_model, status_code\n =status_code, tags=tags, dependencies=dependencies, summary=summary,\n description=description, response_description=response_description,\n responses=responses, deprecated=deprecated, methods=['TRACE'],\n operation_id=operation_id, response_model_include=\n response_model_include, response_model_exclude=response_model_exclude,\n response_model_by_alias=response_model_by_alias,\n response_model_exclude_unset=response_model_exclude_unset,\n response_model_exclude_defaults=response_model_exclude_defaults,\n response_model_exclude_none=response_model_exclude_none,\n include_in_schema=include_in_schema, response_class=response_class,\n name=name, callbacks=callbacks)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_27(self, VAR_27):...\n",
"VAR_73 = self.playlistdb.deletePlaylist(VAR_27, self.getUserId(),\n override_owner=False)\n",
"if VAR_73 == 'success':\n",
"return VAR_73\n"
] | [
"def api_deleteplaylist(self, playlistid):...\n",
"res = self.playlistdb.deletePlaylist(playlistid, self.getUserId(),\n override_owner=False)\n",
"if res == 'success':\n",
"return res\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_19(VAR_3, VAR_40=ValidationError, VAR_31=None, VAR_38=None, VAR_39...\n",
"\"\"\"docstring\"\"\"\n",
"FUNC_15(VAR_3, VAR_32=exc, VAR_31=title, VAR_35='red', VAR_38=\n is_minimizable, VAR_39=wide, VAR_34=as_list)\n"
] | [
"def throw(msg, exc=ValidationError, title=None, is_minimizable=None, wide=...\n",
"\"\"\"docstring\"\"\"\n",
"msgprint(msg, raise_exception=exc, title=title, indicator='red',\n is_minimizable=is_minimizable, wide=wide, as_list=as_list)\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Expr'"
] |
[
"def FUNC_14(self):...\n",
"\"\"\"docstring\"\"\"\n",
"async def FUNC_18(VAR_3, **VAR_4):...\n",
"VAR_17 = RedirectException(b'/no/over/there', 304)\n",
"VAR_17.cookies.append(b'session=yespls')\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'304')\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'/no/over/there'])\n",
"VAR_14 = [v for k, v in VAR_12 if k == b'Set-Cookie']\n",
"self.assertEqual(VAR_14, [b'session=yespls'])\n"
] | [
"def test_redirect_exception_with_cookie(self):...\n",
"\"\"\"docstring\"\"\"\n",
"async def callback(request, **kwargs):...\n",
"e = RedirectException(b'/no/over/there', 304)\n",
"e.cookies.append(b'session=yespls')\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'304')\n",
"headers = channel.result['headers']\n",
"location_headers = [v for k, v in headers if k == b'Location']\n",
"self.assertEqual(location_headers, [b'/no/over/there'])\n",
"cookies_headers = [v for k, v in headers if k == b'Set-Cookie']\n",
"self.assertEqual(cookies_headers, [b'session=yespls'])\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"AsyncFunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"@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_18(self, VAR_44):...\n",
"VAR_79 = self._process_table(VAR_44)\n",
"VAR_80 = re.sub('(?: *\\\\| *)?\\\\n$', '', VAR_44.group(3))\n",
"VAR_80 = VAR_80.split('\\n')\n",
"for VAR_101, VAR_100 in enumerate(VAR_80):\n",
"VAR_100 = re.sub('^ *\\\\| *| *\\\\| *$', '', VAR_100)\n",
"VAR_79['cells'] = VAR_80\n",
"VAR_80[VAR_101] = re.split(' *\\\\| *', VAR_100)\n",
"self.tokens.append(VAR_79)\n"
] | [
"def parse_table(self, m):...\n",
"item = self._process_table(m)\n",
"cells = re.sub('(?: *\\\\| *)?\\\\n$', '', m.group(3))\n",
"cells = cells.split('\\n')\n",
"for i, v in enumerate(cells):\n",
"v = re.sub('^ *\\\\| *| *\\\\| *$', '', v)\n",
"item['cells'] = cells\n",
"cells[i] = re.split(' *\\\\| *', v)\n",
"self.tokens.append(item)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_13(self, VAR_8):...\n",
"VAR_14 = re.search('https?://[^/]*(/.*reset/\\\\S*)', VAR_8.body)\n",
"self.assertTrue(VAR_14 is not None, 'No URL found in sent email')\n",
"return VAR_14.group(), VAR_14.groups()[0]\n"
] | [
"def _read_signup_email(self, email):...\n",
"urlmatch = re.search('https?://[^/]*(/.*reset/\\\\S*)', email.body)\n",
"self.assertTrue(urlmatch is not None, 'No URL found in sent email')\n",
"return urlmatch.group(), urlmatch.groups()[0]\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_0(self):...\n",
"return self.post()\n"
] | [
"def get(self):...\n",
"return self.post()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_11(self, VAR_4, VAR_10):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_33 = self.reactor.tcpClients\n",
"self.assertGreaterEqual(len(VAR_33), 1)\n",
"VAR_34, VAR_35, VAR_36, VAR_37, VAR_38 = VAR_33.pop()\n",
"self.assertEqual(VAR_34, '1.2.3.4')\n",
"self.assertEqual(VAR_35, VAR_10)\n",
"VAR_39 = VAR_36.buildProtocol(None)\n",
"VAR_40 = CLASS_3()\n",
"VAR_20 = CLASS_4(self.reactor)\n",
"VAR_20.requestFactory = VAR_40\n",
"VAR_20.site = self._hs_to_site[VAR_4]\n",
"VAR_41 = FakeTransport(VAR_20, self.reactor, VAR_39)\n",
"VAR_39.makeConnection(VAR_41)\n",
"VAR_42 = FakeTransport(VAR_39, self.reactor, VAR_20)\n",
"VAR_20.makeConnection(VAR_42)\n"
] | [
"def _handle_http_replication_attempt(self, hs, repl_port):...\n",
"\"\"\"docstring\"\"\"\n",
"clients = self.reactor.tcpClients\n",
"self.assertGreaterEqual(len(clients), 1)\n",
"host, port, client_factory, _timeout, _bindAddress = clients.pop()\n",
"self.assertEqual(host, '1.2.3.4')\n",
"self.assertEqual(port, repl_port)\n",
"client_protocol = client_factory.buildProtocol(None)\n",
"request_factory = OneShotRequestFactory()\n",
"channel = _PushHTTPChannel(self.reactor)\n",
"channel.requestFactory = request_factory\n",
"channel.site = self._hs_to_site[hs]\n",
"client_to_server_transport = FakeTransport(channel, self.reactor,\n client_protocol)\n",
"client_protocol.makeConnection(client_to_server_transport)\n",
"server_to_client_transport = FakeTransport(client_protocol, self.reactor,\n channel)\n",
"channel.makeConnection(server_to_client_transport)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"@staticmethod...\n",
"VAR_7 = deepcopy(VAR_7)\n",
"if VAR_5.parameters is None:\n",
"return VAR_7\n",
"for param in VAR_5.parameters:\n",
"if isinstance(param, oai.Reference) or param.param_schema is None:\n",
"return VAR_7\n",
"VAR_25 = property_from_data(VAR_11=param.name, VAR_26=param.required, VAR_5\n =param.param_schema)\n",
"if isinstance(VAR_25, ParseError):\n",
"return ParseError(detail=\n f'cannot parse parameter of endpoint {endpoint.name}', VAR_5=prop.data)\n",
"VAR_7.relative_imports.update(VAR_25.get_imports(VAR_1='..models'))\n",
"if param.param_in == CLASS_0.QUERY:\n",
"VAR_7.query_parameters.append(VAR_25)\n",
"if param.param_in == CLASS_0.PATH:\n",
"VAR_7.path_parameters.append(VAR_25)\n",
"if param.param_in == CLASS_0.HEADER:\n",
"VAR_7.header_parameters.append(VAR_25)\n",
"return ParseError(VAR_5=param, detail=\n 'Parameter must be declared in path or query')\n"
] | [
"@staticmethod...\n",
"endpoint = deepcopy(endpoint)\n",
"if data.parameters is None:\n",
"return endpoint\n",
"for param in data.parameters:\n",
"if isinstance(param, oai.Reference) or param.param_schema is None:\n",
"return endpoint\n",
"prop = property_from_data(name=param.name, required=param.required, data=\n param.param_schema)\n",
"if isinstance(prop, ParseError):\n",
"return ParseError(detail=\n f'cannot parse parameter of endpoint {endpoint.name}', data=prop.data)\n",
"endpoint.relative_imports.update(prop.get_imports(prefix='..models'))\n",
"if param.param_in == ParameterLocation.QUERY:\n",
"endpoint.query_parameters.append(prop)\n",
"if param.param_in == ParameterLocation.PATH:\n",
"endpoint.path_parameters.append(prop)\n",
"if param.param_in == ParameterLocation.HEADER:\n",
"endpoint.header_parameters.append(prop)\n",
"return ParseError(data=param, detail=\n 'Parameter must be declared in path or query')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Return'",
"For",
"Condition",
"Return'",
"Assign'",
"Condition",
"Return'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Return'"
] |
[
"def __str__(self):...\n",
"return '%s / %s' % (self.ticket, self.field)\n"
] | [
"def __str__(self):...\n",
"return '%s / %s' % (self.ticket, self.field)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@FUNC_0...\n",
"if self.should_send_federation():\n",
"return FederationSender(self)\n",
"if not self.config.worker_app:\n",
"return FederationRemoteSendQueue(self)\n"
] | [
"@cache_in_self...\n",
"if self.should_send_federation():\n",
"return FederationSender(self)\n",
"if not self.config.worker_app:\n",
"return FederationRemoteSendQueue(self)\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Return'",
"Condition",
"Return'"
] |
[
"@transaction.non_atomic_requests...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_38 = CourseKey.from_string(VAR_10)\n",
"VAR_66 = VAR_9.GET.get('problem_location', '')\n",
"VAR_170 = UsageKey.from_string(VAR_66)\n",
"return JsonResponseBadRequest(_('Could not find problem with this location.'))\n",
"instructor_task.api.submit_calculate_problem_responses_csv(VAR_9, VAR_38,\n VAR_66)\n",
"VAR_196 = _('string')\n",
"VAR_171 = VAR_170.run\n",
"VAR_172 = _('string')\n",
"return JsonResponse({'status': VAR_196})\n",
"if not VAR_171:\n",
"return JsonResponse({'status': VAR_172})\n",
"VAR_170 = VAR_38.make_usage_key_from_deprecated_string(VAR_66)\n",
"if VAR_170.course_key != VAR_38:\n"
] | [
"@transaction.non_atomic_requests...\n",
"\"\"\"docstring\"\"\"\n",
"course_key = CourseKey.from_string(course_id)\n",
"problem_location = request.GET.get('problem_location', '')\n",
"problem_key = UsageKey.from_string(problem_location)\n",
"return JsonResponseBadRequest(_('Could not find problem with this location.'))\n",
"instructor_task.api.submit_calculate_problem_responses_csv(request,\n course_key, problem_location)\n",
"already_running_status = _(\n \"A problem responses report generation task is already in progress. Check the 'Pending Tasks' table for the status of the task. When completed, the report will be available for download in the table below.\"\n )\n",
"run = problem_key.run\n",
"success_status = _(\n 'The problem responses report is being created. To view the status of the report, see Pending Tasks below.'\n )\n",
"return JsonResponse({'status': already_running_status})\n",
"if not run:\n",
"return JsonResponse({'status': success_status})\n",
"problem_key = course_key.make_usage_key_from_deprecated_string(problem_location\n )\n",
"if problem_key.course_key != course_key:\n"
] | [
0,
0,
0,
3,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Condition",
"Return'",
"Assign'",
"Condition"
] |
[
"def FUNC_1(VAR_6, VAR_7, VAR_8=None):...\n",
"if VAR_6:\n",
"if VAR_8 and isinstance(VAR_6, dict):\n",
"VAR_6 = VAR_6.get(VAR_8, [])\n",
"if not isinstance(VAR_6, (list, tuple)):\n",
"VAR_6 = [VAR_6]\n",
"[VAR_114(VAR_7) for VAR_114 in VAR_6]\n"
] | [
"def callback(actions, form, tablename=None):...\n",
"if actions:\n",
"if tablename and isinstance(actions, dict):\n",
"actions = actions.get(tablename, [])\n",
"if not isinstance(actions, (list, tuple)):\n",
"actions = [actions]\n",
"[action(form) for action in actions]\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Expr'"
] |
[
"@VAR_0.route('/camera_latest_timelapse/<camera_unique_id>/<max_age>')...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_8 = Camera.query.filter(Camera.unique_id == VAR_4).first()\n",
"VAR_37, VAR_38 = utils_general.get_camera_paths(VAR_8)\n",
"VAR_39 = os.path.join(VAR_38, str(VAR_8.timelapse_last_file))\n",
"if VAR_8.timelapse_last_file is not None and os.path.exists(VAR_39):\n",
"VAR_36 = datetime.datetime.now() - datetime.timedelta(seconds=int(max_age))\n",
"VAR_74 = '[\"file_not_found\"]'\n",
"if datetime.datetime.fromtimestamp(VAR_8.timelapse_last_ts) > VAR_36:\n",
"return Response(VAR_74, mimetype='text/json')\n",
"VAR_106 = datetime.datetime.fromtimestamp(VAR_8.timelapse_last_ts).strftime(\n '%Y-%m-%d %H:%M:%S')\n",
"VAR_74 = '[\"max_age_exceeded\"]'\n",
"VAR_74 = '[\"{}\",\"{}\"]'.format(VAR_8.timelapse_last_file, VAR_106)\n"
] | [
"@blueprint.route('/camera_latest_timelapse/<camera_unique_id>/<max_age>')...\n",
"\"\"\"docstring\"\"\"\n",
"camera = Camera.query.filter(Camera.unique_id == camera_unique_id).first()\n",
"_, tl_path = utils_general.get_camera_paths(camera)\n",
"timelapse_file_path = os.path.join(tl_path, str(camera.timelapse_last_file))\n",
"if camera.timelapse_last_file is not None and os.path.exists(\n",
"time_max_age = datetime.datetime.now() - datetime.timedelta(seconds=int(\n max_age))\n",
"return_values = '[\"file_not_found\"]'\n",
"if datetime.datetime.fromtimestamp(camera.timelapse_last_ts) > time_max_age:\n",
"return Response(return_values, mimetype='text/json')\n",
"ts = datetime.datetime.fromtimestamp(camera.timelapse_last_ts).strftime(\n '%Y-%m-%d %H:%M:%S')\n",
"return_values = '[\"max_age_exceeded\"]'\n",
"return_values = '[\"{}\",\"{}\"]'.format(camera.timelapse_last_file, ts)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_11(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self._create_alias(self.test_user)\n",
"VAR_10 = self.get_success(self.handler.delete_association(create_requester(\n self.admin_user), self.room_alias))\n",
"self.assertEquals(self.room_id, VAR_10)\n",
"self.get_failure(self.handler.get_association(self.room_alias), synapse.api\n .errors.SynapseError)\n"
] | [
"def test_delete_alias_admin(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self._create_alias(self.test_user)\n",
"result = self.get_success(self.handler.delete_association(create_requester(\n self.admin_user), self.room_alias))\n",
"self.assertEquals(self.room_id, result)\n",
"self.get_failure(self.handler.get_association(self.room_alias), synapse.api\n .errors.SynapseError)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = FUNC_1('/groups/%s/profile', VAR_30)\n",
"return self.client.post_json(VAR_5=destination, VAR_2=path, VAR_3={\n 'requester_user_id': requester_user_id}, VAR_39=content, VAR_15=True)\n"
] | [
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"path = _create_v1_path('/groups/%s/profile', group_id)\n",
"return self.client.post_json(destination=destination, path=path, args={\n 'requester_user_id': requester_user_id}, data=content, ignore_backoff=True)\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'"
] |
[
"async def FUNC_25(VAR_23):...\n",
"self.assertEqual(VAR_23, {'server1': {FUNC_0(VAR_20): 1500}})\n",
"return {'server1': {FUNC_0(VAR_20): FetchKeyResult(get_verify_key(VAR_20), \n 800)}}\n"
] | [
"async def get_keys1(keys_to_fetch):...\n",
"self.assertEqual(keys_to_fetch, {'server1': {get_key_id(key1): 1500}})\n",
"return {'server1': {get_key_id(key1): FetchKeyResult(get_verify_key(key1), \n 800)}}\n"
] | [
0,
0,
0
] | [
"AsyncFunctionDef'",
"Expr'",
"Return'"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.