lines
sequencelengths
1
383
raw_lines
sequencelengths
1
383
label
sequencelengths
1
383
type
sequencelengths
1
383
[ "def FUNC_41():...\n", "\"\"\"docstring\"\"\"\n", "if request.vars and not request.vars.token == session.token:\n", "redirect(URL('logout'))\n", "VAR_5 = None\n", "if VAR_5:\n", "redirect(request.vars.sender)\n", "VAR_3 = FUNC_5(VAR_10=request.vars.location.split('/')[0])\n", "VAR_68 = dict(VAR_5=filename[len(path):])\n", "VAR_68 = dict(VAR_5='unknown')\n", "VAR_15 = apath(request.vars.location, VAR_122=request)\n", "session.flash = T('cannot upload file \"%(filename)s\"', VAR_68)\n", "if request.vars.filename:\n", "VAR_5 = re.sub('[^\\\\w\\\\./]+', '_', request.vars.filename)\n", "VAR_5 = os.path.split(request.vars.file.filename)[-1]\n", "if VAR_15[-8:] == '/models/' and not VAR_5[-3:] == '.py':\n", "VAR_5 += '.py'\n", "if VAR_15[-9:] == '/modules/' and not VAR_5[-3:] == '.py':\n", "VAR_5 += '.py'\n", "if VAR_15[-13:] == '/controllers/' and not VAR_5[-3:] == '.py':\n", "VAR_5 += '.py'\n", "if VAR_15[-7:] == '/views/' and not VAR_5[-5:] == '.html':\n", "VAR_5 += '.html'\n", "if VAR_15[-11:] == '/languages/' and not VAR_5[-3:] == '.py':\n", "VAR_5 += '.py'\n", "VAR_5 = os.path.join(VAR_15, VAR_5)\n", "VAR_159 = os.path.dirname(VAR_5)\n", "if not os.path.exists(VAR_159):\n", "os.makedirs(VAR_159)\n", "VAR_2 = request.vars.file.file.read()\n", "VAR_160 = FUNC_0(VAR_2)\n", "FUNC_4(VAR_5, VAR_2, 'wb')\n", "FUNC_1(VAR_3, 'UPLOAD', VAR_5, VAR_160)\n", "session.flash = T('file \"%(filename)s\" uploaded', dict(VAR_5=filename[len(\n path):]))\n" ]
[ "def upload_file():...\n", "\"\"\"docstring\"\"\"\n", "if request.vars and not request.vars.token == session.token:\n", "redirect(URL('logout'))\n", "filename = None\n", "if filename:\n", "redirect(request.vars.sender)\n", "app = get_app(name=request.vars.location.split('/')[0])\n", "d = dict(filename=filename[len(path):])\n", "d = dict(filename='unknown')\n", "path = apath(request.vars.location, r=request)\n", "session.flash = T('cannot upload file \"%(filename)s\"', d)\n", "if request.vars.filename:\n", "filename = re.sub('[^\\\\w\\\\./]+', '_', request.vars.filename)\n", "filename = os.path.split(request.vars.file.filename)[-1]\n", "if path[-8:] == '/models/' and not filename[-3:] == '.py':\n", "filename += '.py'\n", "if path[-9:] == '/modules/' and not filename[-3:] == '.py':\n", "filename += '.py'\n", "if path[-13:] == '/controllers/' and not filename[-3:] == '.py':\n", "filename += '.py'\n", "if path[-7:] == '/views/' and not filename[-5:] == '.html':\n", "filename += '.html'\n", "if path[-11:] == '/languages/' and not filename[-3:] == '.py':\n", "filename += '.py'\n", "filename = os.path.join(path, filename)\n", "dirpath = os.path.dirname(filename)\n", "if not os.path.exists(dirpath):\n", "os.makedirs(dirpath)\n", "data = request.vars.file.file.read()\n", "lineno = count_lines(data)\n", "safe_write(filename, data, 'wb')\n", "log_progress(app, 'UPLOAD', filename, lineno)\n", "session.flash = T('file \"%(filename)s\" uploaded', dict(filename=filename[\n len(path):]))\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 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "AugAssign'", "Condition", "AugAssign'", "Condition", "AugAssign'", "Condition", "AugAssign'", "Condition", "AugAssign'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'" ]
[ "def FUNC_32(self):...\n", "self.parser = saved_model_cli.create_parser()\n", "VAR_9 = test.test_src_dir_path(VAR_0)\n", "VAR_10 = self.parser.parse_args(['run', '--dir', VAR_9, '--tag_set',\n 'serve', '--signature_def', 'serving_default'])\n", "saved_model_cli.run(VAR_10)\n" ]
[ "def testRunCommandInputNotGivenError(self):...\n", "self.parser = saved_model_cli.create_parser()\n", "base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n", "args = self.parser.parse_args(['run', '--dir', base_path, '--tag_set',\n 'serve', '--signature_def', 'serving_default'])\n", "saved_model_cli.run(args)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_39(self, VAR_44):...\n", "return self.renderer.linebreak()\n" ]
[ "def output_linebreak(self, m):...\n", "return self.renderer.linebreak()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@property...\n", "return [Line(i, line) for i, line in enumerate(self.rawLines, 1)]\n" ]
[ "@property...\n", "return [Line(i, line) for i, line in enumerate(self.rawLines, 1)]\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "@VAR_2.route('/ajax/listbooks')...\n", "VAR_79 = int(request.args.get('offset') or 0)\n", "VAR_19 = int(request.args.get('limit') or config.config_books_per_page)\n", "VAR_80 = request.args.get('search')\n", "VAR_7 = request.args.get('sort', 'id')\n", "VAR_10 = request.args.get('order', '').lower()\n", "VAR_81 = None\n", "VAR_76 = tuple()\n", "if VAR_7 == 'state':\n", "VAR_81 = json.loads(request.args.get('state', '[]'))\n", "if VAR_7 == 'tags':\n", "VAR_82 = VAR_83 = calibre_db.session.query(db.Books).count()\n", "VAR_10 = [db.Tags.name.asc()] if VAR_10 == 'asc' else [db.Tags.name.desc()]\n", "if VAR_7 == 'series':\n", "if VAR_81:\n", "VAR_76 = db.books_tags_link, db.Books.id == db.books_tags_link.c.book, db.Tags\n", "VAR_10 = [db.Series.name.asc()] if VAR_10 == 'asc' else [db.Series.name.desc()]\n", "if VAR_7 == 'publishers':\n", "if VAR_80:\n", "if VAR_80:\n", "VAR_76 = (db.books_series_link, db.Books.id == db.books_series_link.c.book,\n db.Series)\n", "VAR_10 = [db.Publishers.name.asc()] if VAR_10 == 'asc' else [db.Publishers.\n name.desc()]\n", "if VAR_7 == 'authors':\n", "VAR_127 = calibre_db.search_query(VAR_80).all()\n", "VAR_127 = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()\n ).all()\n", "VAR_63, VAR_83, VAR_64 = calibre_db.get_search_results(VAR_80, VAR_79,\n VAR_10, VAR_19, *VAR_76)\n", "VAR_63, VAR_64, VAR_64 = calibre_db.fill_indexpage(int(VAR_79) / int(VAR_19\n ) + 1, VAR_19, db.Books, True, VAR_10, *VAR_76)\n", "VAR_76 = (db.books_publishers_link, db.Books.id == db.books_publishers_link\n .c.book, db.Publishers)\n", "VAR_10 = [db.Authors.name.asc(), db.Series.name, db.Books.series_index\n ] if VAR_10 == 'asc' else [db.Authors.name.desc(), db.Series.name.desc(\n ), db.Books.series_index.desc()]\n", "if VAR_7 == 'languages':\n", "VAR_83 = len(VAR_127)\n", "VAR_63 = calibre_db.get_checkbox_sorted(VAR_127, VAR_81, VAR_79, VAR_19, VAR_10\n )\n", "for entry in VAR_63:\n", "VAR_76 = (db.books_authors_link, db.Books.id == db.books_authors_link.c.\n book, db.Authors, db.books_series_link, db.Books.id == db.\n books_series_link.c.book, db.Series)\n", "VAR_10 = [db.Languages.lang_code.asc()] if VAR_10 == 'asc' else [db.\n Languages.lang_code.desc()]\n", "if VAR_10 and VAR_7 in ['sort', 'title', 'authors_sort', 'series_index']:\n", "for FUNC_31 in range(0, len(entry.languages)):\n", "VAR_84 = {'totalNotFiltered': VAR_82, 'total': VAR_83, 'rows': VAR_63}\n", "VAR_76 = (db.books_languages_link, db.Books.id == db.books_languages_link.c\n .book, db.Languages)\n", "VAR_10 = [text(VAR_7 + ' ' + VAR_10)]\n", "if not VAR_81:\n", "entry.languages[FUNC_31].language_name = isoLanguages.get_language_name(\n get_locale(), entry.languages[FUNC_31].lang_code)\n", "VAR_85 = json.dumps(VAR_84, cls=db.AlchemyEncoder)\n", "VAR_10 = [db.Books.timestamp.desc()]\n", "VAR_86 = make_response(VAR_85)\n", "VAR_86.headers['Content-Type'] = 'application/json; charset=utf-8'\n", "return VAR_86\n" ]
[ "@web.route('/ajax/listbooks')...\n", "off = int(request.args.get('offset') or 0)\n", "limit = int(request.args.get('limit') or config.config_books_per_page)\n", "search = request.args.get('search')\n", "sort = request.args.get('sort', 'id')\n", "order = request.args.get('order', '').lower()\n", "state = None\n", "join = tuple()\n", "if sort == 'state':\n", "state = json.loads(request.args.get('state', '[]'))\n", "if sort == 'tags':\n", "total_count = filtered_count = calibre_db.session.query(db.Books).count()\n", "order = [db.Tags.name.asc()] if order == 'asc' else [db.Tags.name.desc()]\n", "if sort == 'series':\n", "if state:\n", "join = db.books_tags_link, db.Books.id == db.books_tags_link.c.book, db.Tags\n", "order = [db.Series.name.asc()] if order == 'asc' else [db.Series.name.desc()]\n", "if sort == 'publishers':\n", "if search:\n", "if search:\n", "join = (db.books_series_link, db.Books.id == db.books_series_link.c.book,\n db.Series)\n", "order = [db.Publishers.name.asc()] if order == 'asc' else [db.Publishers.\n name.desc()]\n", "if sort == 'authors':\n", "books = calibre_db.search_query(search).all()\n", "books = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()\n ).all()\n", "entries, filtered_count, __ = calibre_db.get_search_results(search, off,\n order, limit, *join)\n", "entries, __, __ = calibre_db.fill_indexpage(int(off) / int(limit) + 1,\n limit, db.Books, True, order, *join)\n", "join = (db.books_publishers_link, db.Books.id == db.books_publishers_link.c\n .book, db.Publishers)\n", "order = [db.Authors.name.asc(), db.Series.name, db.Books.series_index\n ] if order == 'asc' else [db.Authors.name.desc(), db.Series.name.desc(),\n db.Books.series_index.desc()]\n", "if sort == 'languages':\n", "filtered_count = len(books)\n", "entries = calibre_db.get_checkbox_sorted(books, state, off, limit, order)\n", "for entry in entries:\n", "join = (db.books_authors_link, db.Books.id == db.books_authors_link.c.book,\n db.Authors, db.books_series_link, db.Books.id == db.books_series_link.c\n .book, db.Series)\n", "order = [db.Languages.lang_code.asc()] if order == 'asc' else [db.Languages\n .lang_code.desc()]\n", "if order and sort in ['sort', 'title', 'authors_sort', 'series_index']:\n", "for index in range(0, len(entry.languages)):\n", "table_entries = {'totalNotFiltered': total_count, 'total': filtered_count,\n 'rows': entries}\n", "join = (db.books_languages_link, db.Books.id == db.books_languages_link.c.\n book, db.Languages)\n", "order = [text(sort + ' ' + order)]\n", "if not state:\n", "entry.languages[index].language_name = isoLanguages.get_language_name(\n get_locale(), entry.languages[index].lang_code)\n", "js_list = json.dumps(table_entries, cls=db.AlchemyEncoder)\n", "order = [db.Books.timestamp.desc()]\n", "response = make_response(js_list)\n", "response.headers['Content-Type'] = 'application/json; charset=utf-8'\n", "return response\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Condition", "For", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_84(VAR_1):...\n", "def FUNC_83(*VAR_2, **VAR_3):...\n", "VAR_9 = VAR_2[0]\n", "VAR_193 = {'error': 'Missing required query parameter(s)', 'parameters': [],\n 'info': {}}\n", "for VAR_209, extra in VAR_47:\n", "VAR_199 = object()\n", "if len(VAR_193['parameters']) > 0:\n", "if VAR_9.POST.get(VAR_209, VAR_199) == VAR_199:\n", "return JsonResponse(VAR_193, status=400)\n", "return VAR_1(*VAR_2, **kwargs)\n", "VAR_193['parameters'].append(VAR_209)\n", "VAR_193['info'][VAR_209] = extra\n" ]
[ "def decorator(func):...\n", "def wrapped(*args, **kwargs):...\n", "request = args[0]\n", "error_response_data = {'error': 'Missing required query parameter(s)',\n 'parameters': [], 'info': {}}\n", "for param, extra in required_params:\n", "default = object()\n", "if len(error_response_data['parameters']) > 0:\n", "if request.POST.get(param, default) == default:\n", "return JsonResponse(error_response_data, status=400)\n", "return func(*args, **kwargs)\n", "error_response_data['parameters'].append(param)\n", "error_response_data['info'][param] = extra\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Assign'", "Assign'", "For", "Assign'", "Condition", "Condition", "Return'", "Return'", "Expr'", "Assign'" ]
[ "def FUNC_32(self):...\n", "from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver\n", "from Products.PageTemplates.unicodeconflictresolver import DefaultUnicodeEncodingConflictResolver\n", "from zope.component import getUtility\n", "from zope.component import provideUtility\n", "provideUtility(DefaultUnicodeEncodingConflictResolver,\n IUnicodeEncodingConflictResolver)\n", "VAR_12 = getUtility(IUnicodeEncodingConflictResolver)\n", "self.assertRaises(UnicodeDecodeError, VAR_12.resolve, None, b'\\xe4\\xfc\\xf6',\n None)\n" ]
[ "def testDefaultResolver(self):...\n", "from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver\n", "from Products.PageTemplates.unicodeconflictresolver import DefaultUnicodeEncodingConflictResolver\n", "from zope.component import getUtility\n", "from zope.component import provideUtility\n", "provideUtility(DefaultUnicodeEncodingConflictResolver,\n IUnicodeEncodingConflictResolver)\n", "resolver = getUtility(IUnicodeEncodingConflictResolver)\n", "self.assertRaises(UnicodeDecodeError, resolver.resolve, None,\n b'\\xe4\\xfc\\xf6', None)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_4(self):...\n", "\"\"\"Model with a callable concrete function.\"\"\"\n", "def __init__(self):...\n", "VAR_56 = def_function.function(self.multiply, input_signature=[tensor_spec.\n TensorSpec(shape=(), dtype=dtypes.float32), tensor_spec.TensorSpec(\n shape=(), dtype=dtypes.float32)])\n", "self.pure_concrete_function = VAR_56.get_concrete_function()\n", "super(CLASS_2, self).__init__()\n", "def FUNC_43(self, VAR_53, VAR_54):...\n", "return VAR_53 * VAR_54\n" ]
[ "def testShowAllWithPureConcreteFunction(self):...\n", "\"\"\"Model with a callable concrete function.\"\"\"\n", "def __init__(self):...\n", "function = def_function.function(self.multiply, input_signature=[\n tensor_spec.TensorSpec(shape=(), dtype=dtypes.float32), tensor_spec.\n TensorSpec(shape=(), dtype=dtypes.float32)])\n", "self.pure_concrete_function = function.get_concrete_function()\n", "super(DummyModel, self).__init__()\n", "def multiply(self, a, b):...\n", "return a * b\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "FunctionDef'", "Return'" ]
[ "def FUNC_31(self):...\n", "VAR_27 = widgets.FilteredSelectMultiple('test', True)\n", "self.assertHTMLEqual(conditional_escape(VAR_27.render('test', 'test')), \n 'string' % VAR_0())\n" ]
[ "def test_stacked_render(self):...\n", "w = widgets.FilteredSelectMultiple('test', True)\n", "self.assertHTMLEqual(conditional_escape(w.render('test', 'test')), \n \"\"\"<select multiple=\"multiple\" name=\"test\" class=\"selectfilterstacked\">\n</select><script type=\"text/javascript\">addEvent(window, \"load\", function(e) {SelectFilter.init(\"id_test\", \"test\", 1, \"%(ADMIN_STATIC_PREFIX)s\"); });</script>\n\"\"\"\n % admin_static_prefix())\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "@log_function...\n", "\"\"\"docstring\"\"\"\n", "VAR_2 = FUNC_1('/groups/%s/summary', VAR_30)\n", "return self.client.get_json(VAR_5=destination, VAR_2=path, VAR_3={\n 'requester_user_id': requester_user_id}, VAR_15=True)\n" ]
[ "@log_function...\n", "\"\"\"docstring\"\"\"\n", "path = _create_v1_path('/groups/%s/summary', group_id)\n", "return self.client.get_json(destination=destination, path=path, args={\n 'requester_user_id': requester_user_id}, ignore_backoff=True)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_13(self):...\n", "if os.path.exists(self.cookie_secret_file):\n", "return VAR_102.read()\n", "VAR_46 = base64.encodestring(os.urandom(1024))\n", "self._write_cookie_secret_file(VAR_46)\n", "return VAR_46\n" ]
[ "def _cookie_secret_default(self):...\n", "if os.path.exists(self.cookie_secret_file):\n", "return f.read()\n", "secret = base64.encodestring(os.urandom(1024))\n", "self._write_cookie_secret_file(secret)\n", "return secret\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_0(VAR_2: str) ->List[str]:...\n", "\"\"\"docstring\"\"\"\n", "VAR_30 = 'Bearer %s' % VAR_2\n", "VAR_30.encode('ascii')\n", "return [VAR_30]\n" ]
[ "def create_id_access_token_header(id_access_token: str) ->List[str]:...\n", "\"\"\"docstring\"\"\"\n", "bearer_token = 'Bearer %s' % id_access_token\n", "bearer_token.encode('ascii')\n", "return [bearer_token]\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Return'" ]
[ "@log_function...\n", "VAR_2 = FUNC_2('/send_leave/%s/%s', VAR_6, VAR_7)\n", "VAR_37 = await self.client.put_json(VAR_5=destination, VAR_2=path, VAR_39=\n content, VAR_15=True)\n", "return VAR_37\n" ]
[ "@log_function...\n", "path = _create_v2_path('/send_leave/%s/%s', room_id, event_id)\n", "response = await self.client.put_json(destination=destination, path=path,\n data=content, ignore_backoff=True)\n", "return response\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_4(self, VAR_0, VAR_1):...\n", "self.headers[VAR_0] = VAR_1\n" ]
[ "def setHeader(self, name, value):...\n", "self.headers[name] = value\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "def FUNC_0():...\n", "VAR_1['ebook converter'] = _(converter.get_calibre_version())\n", "VAR_1['unrar'] = _(converter.get_unrar_version())\n", "VAR_1['kepubify'] = _(converter.get_kepubify_version())\n", "return VAR_1\n" ]
[ "def collect_stats():...\n", "_VERSIONS['ebook converter'] = _(converter.get_calibre_version())\n", "_VERSIONS['unrar'] = _(converter.get_unrar_version())\n", "_VERSIONS['kepubify'] = _(converter.get_kepubify_version())\n", "return _VERSIONS\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_5(self):...\n", "VAR_9 = test.test_src_dir_path(VAR_0)\n", "self.parser = saved_model_cli.create_parser()\n", "VAR_10 = self.parser.parse_args(['show', '--dir', VAR_9])\n", "saved_model_cli.show(VAR_10)\n", "VAR_11 = out.getvalue().strip()\n", "VAR_12 = \"\"\"The given SavedModel contains the following tag-sets:\n'serve'\"\"\"\n", "self.assertMultiLineEqual(VAR_11, VAR_12)\n", "self.assertEqual(err.getvalue().strip(), '')\n" ]
[ "def testShowCommandTags(self):...\n", "base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n", "self.parser = saved_model_cli.create_parser()\n", "args = self.parser.parse_args(['show', '--dir', base_path])\n", "saved_model_cli.show(args)\n", "output = out.getvalue().strip()\n", "exp_out = \"\"\"The given SavedModel contains the following tag-sets:\n'serve'\"\"\"\n", "self.assertMultiLineEqual(output, exp_out)\n", "self.assertEqual(err.getvalue().strip(), '')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_4(VAR_7, VAR_10, VAR_11):...\n", "VAR_18 = get_object_or_404(VAR_0, VAR_10=pk)\n", "VAR_19 = UserActivationTokenGenerator()\n", "if VAR_19.is_valid(VAR_18, VAR_11):\n", "VAR_18.st.is_verified = True\n", "return redirect(reverse(settings.LOGIN_URL))\n", "VAR_18.is_active = True\n", "VAR_18.save()\n", "messages.info(VAR_7, _('Your account has been activated!'))\n" ]
[ "def registration_activation(request, pk, token):...\n", "user = get_object_or_404(User, pk=pk)\n", "activation = UserActivationTokenGenerator()\n", "if activation.is_valid(user, token):\n", "user.st.is_verified = True\n", "return redirect(reverse(settings.LOGIN_URL))\n", "user.is_active = True\n", "user.save()\n", "messages.info(request, _('Your account has been activated!'))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_17():...\n", "VAR_3 = FUNC_5()\n", "VAR_46 = FORM.confirm(T('Uninstall'), {T('Cancel'): URL('site')})\n", "VAR_46['_id'] = 'confirm_form'\n", "VAR_46['_class'] = 'well'\n", "for VAR_126 in VAR_46.components:\n", "VAR_126['_class'] = 'btn'\n", "if VAR_46.accepted:\n", "if MULTI_USER_MODE:\n", "return dict(VAR_3=app, VAR_46=dialog)\n", "if is_manager() and db(db.app.name == VAR_3).delete():\n", "VAR_5 = app_pack(VAR_3, request, raise_ex=True)\n", "session.flash = T('unable to uninstall \"%s\"', VAR_3)\n", "if app_uninstall(VAR_3, request):\n", "if db(db.app.name == VAR_3)(db.app.owner == auth.user.id).delete():\n", "redirect(URL('site'))\n", "session.flash = T('application \"%s\" uninstalled', VAR_3)\n", "session.flash = T('unable to uninstall \"%s\"', VAR_3)\n", "session.flash = T('no permission to uninstall \"%s\"', VAR_3)\n", "redirect(URL('site'))\n" ]
[ "def uninstall():...\n", "app = get_app()\n", "dialog = FORM.confirm(T('Uninstall'), {T('Cancel'): URL('site')})\n", "dialog['_id'] = 'confirm_form'\n", "dialog['_class'] = 'well'\n", "for component in dialog.components:\n", "component['_class'] = 'btn'\n", "if dialog.accepted:\n", "if MULTI_USER_MODE:\n", "return dict(app=app, dialog=dialog)\n", "if is_manager() and db(db.app.name == app).delete():\n", "filename = app_pack(app, request, raise_ex=True)\n", "session.flash = T('unable to uninstall \"%s\"', app)\n", "if app_uninstall(app, request):\n", "if db(db.app.name == app)(db.app.owner == auth.user.id).delete():\n", "redirect(URL('site'))\n", "session.flash = T('application \"%s\" uninstalled', app)\n", "session.flash = T('unable to uninstall \"%s\"', app)\n", "session.flash = T('no permission to uninstall \"%s\"', app)\n", "redirect(URL('site'))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Condition", "Condition", "Return'", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_1(self, VAR_3, VAR_4=None):...\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" ]
[ "def handle(self, command, kwargs=None):...\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 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Return'", "Assign'", "Expr'", "Condition", "Expr'", "Return'", "Return'", "Assign'", "Assign'" ]
[ "@unittest.override_config({'rc_joins': {'local': {'per_second': 0.5,...\n", "\"\"\"docstring\"\"\"\n", "for i in range(3):\n", "self.helper.create_room_as(self.user_id)\n", "self.helper.create_room_as(self.user_id, VAR_9=429)\n" ]
[ "@unittest.override_config({'rc_joins': {'local': {'per_second': 0.5,...\n", "\"\"\"docstring\"\"\"\n", "for i in range(3):\n", "self.helper.create_room_as(self.user_id)\n", "self.helper.create_room_as(self.user_id, expect_code=429)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "For", "Expr'", "Expr'" ]
[ "@self.appbuilder.sm.oid.loginhandler...\n", "if g.user is not None and g.user.is_authenticated:\n", "return redirect(self.appbuilder.get_url_for_index)\n", "VAR_10 = LoginForm_oid()\n", "if VAR_10.validate_on_submit():\n", "VAR_53['remember_me'] = VAR_10.remember_me.data\n", "return self.render_template(self.login_template, VAR_37=self.title, VAR_10=\n form, providers=self.appbuilder.sm.openid_providers, appbuilder=self.\n appbuilder)\n", "return self.appbuilder.sm.oid.try_login(VAR_10.openid.data, ask_for=self.\n oid_ask_for, ask_for_optional=self.oid_ask_for_optional)\n" ]
[ "@self.appbuilder.sm.oid.loginhandler...\n", "if g.user is not None and g.user.is_authenticated:\n", "return redirect(self.appbuilder.get_url_for_index)\n", "form = LoginForm_oid()\n", "if form.validate_on_submit():\n", "session['remember_me'] = form.remember_me.data\n", "return self.render_template(self.login_template, title=self.title, form=\n form, providers=self.appbuilder.sm.openid_providers, appbuilder=self.\n appbuilder)\n", "return self.appbuilder.sm.oid.try_login(form.openid.data, ask_for=self.\n oid_ask_for, ask_for_optional=self.oid_ask_for_optional)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Return'", "Return'" ]
[ "def FUNC_5(VAR_0):...\n", "\"\"\"docstring\"\"\"\n", "\"\"\" Features: This dialog can... \"\"\"\n", "\"\"\" - list attachments in a drop down list \"\"\"\n", "\"\"\" - list attachments also for a different page than the current one \"\"\"\n", "\"\"\" - create new attachment \"\"\"\n", "VAR_16 = VAR_0.getText\n", "VAR_12 = VAR_0.cfg.url_prefix_static\n", "VAR_14 = VAR_0.script_root + '/'\n", "VAR_17 = wikiutil.escape(VAR_0.values.get('requestedPagename', ''), quote=True)\n", "VAR_18 = wikiutil.escape(VAR_0.values.get('destinationPagename', VAR_0.page\n .page_name), quote=True)\n", "VAR_19 = VAR_17 or wikiutil.escape(VAR_0.page.page_name)\n", "VAR_20 = _get_files(VAR_0, VAR_19)\n", "VAR_20.sort()\n", "VAR_21 = 'string' % '\\n'.join([('<option value=\"%s\">%s</option>' % (\n wikiutil.escape(attachment, quote=True), wikiutil.escape(attachment,\n quote=True))) for attachment in VAR_20])\n", "VAR_22 = VAR_16('Attachment location')\n", "VAR_23 = VAR_16('Page name')\n", "VAR_24 = VAR_16('Attachment name')\n", "VAR_25 = VAR_16('Refresh attachment list')\n", "VAR_26 = VAR_16('List of attachments')\n", "if len(VAR_19) > 50:\n", "VAR_34 = '%s ... %s' % (VAR_19[0:25], VAR_19[-25:])\n", "VAR_34 = VAR_19\n", "VAR_27 = '%s: %s' % (VAR_16('Available attachments for page'), VAR_34)\n", "VAR_0.write('string' % locals())\n" ]
[ "def attachment_dialog(request):...\n", "\"\"\"docstring\"\"\"\n", "\"\"\" Features: This dialog can... \"\"\"\n", "\"\"\" - list attachments in a drop down list \"\"\"\n", "\"\"\" - list attachments also for a different page than the current one \"\"\"\n", "\"\"\" - create new attachment \"\"\"\n", "_ = request.getText\n", "url_prefix_static = request.cfg.url_prefix_static\n", "action = request.script_root + '/'\n", "requestedPagename = wikiutil.escape(request.values.get('requestedPagename',\n ''), quote=True)\n", "destinationPagename = wikiutil.escape(request.values.get(\n 'destinationPagename', request.page.page_name), quote=True)\n", "attachmentsPagename = requestedPagename or wikiutil.escape(request.page.\n page_name)\n", "attachments = _get_files(request, attachmentsPagename)\n", "attachments.sort()\n", "attachmentList = (\n \"\"\"\n <select id=\"sctAttachments\" size=\"10\" style=\"width:100%%;visibility:hidden;\" onchange=\"OnAttachmentListChange();\">\n %s\n </select>\n\"\"\"\n % '\\n'.join([('<option value=\"%s\">%s</option>' % (wikiutil.escape(\n attachment, quote=True), wikiutil.escape(attachment, quote=True))) for\n attachment in attachments]))\n", "langAttachmentLocation = _('Attachment location')\n", "langPagename = _('Page name')\n", "langAttachmentname = _('Attachment name')\n", "langListAttachmentsButton = _('Refresh attachment list')\n", "langAttachmentList = _('List of attachments')\n", "if len(attachmentsPagename) > 50:\n", "shortenedPagename = '%s ... %s' % (attachmentsPagename[0:25],\n attachmentsPagename[-25:])\n", "shortenedPagename = attachmentsPagename\n", "langAvailableAttachments = '%s: %s' % (_('Available attachments for page'),\n shortenedPagename)\n", "request.write(\n \"\"\"\n<!--\n * FCKeditor - The text editor for internet\n * Copyright (C) 2003-2004 Frederico Caldeira Knabben\n *\n * Licensed under the terms of the GNU Lesser General Public License:\n * http://www.opensource.org/licenses/lgpl-license.php\n *\n * For further information visit:\n * http://www.fckeditor.net/\n *\n * File Name: fck_attachment.html\n * Attachment dialog window.\n *\n * Version: 2.0 FC (Preview)\n * Modified: 2005-02-18 23:55:22\n *\n * File Authors:\n * Frederico Caldeira Knabben (fredck@fckeditor.net)\n-->\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">\n<meta name=\"robots\" content=\"index,nofollow\">\n<html>\n <head>\n <title>Attachment Properties</title>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n <meta name=\"robots\" content=\"noindex,nofollow\" />\n <script src=\"%(url_prefix_static)s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js\" type=\"text/javascript\"></script>\n <script src=\"%(url_prefix_static)s/applets/moinFCKplugins/moinattachment/fck_attachment.js\" type=\"text/javascript\"></script>\n <script src=\"%(url_prefix_static)s/applets/moinFCKplugins/moinurllib.js\" type=\"text/javascript\"></script>\n </head>\n <body scroll=\"no\" style=\"OVERFLOW: hidden\">\n <form id=\"DlgAttachmentForm\" name=\"DlgAttachmentForm\" action=%(action)s method=\"GET\">\n <input type=\"hidden\" name=\"action\" value=\"fckdialog\">\n <input type=\"hidden\" name=\"dialog\" value=\"attachment\">\n <input type=\"hidden\" id=\"requestedPagename\" name=\"requestedPagename\" value=\"%(requestedPagename)s\">\n <input type=\"hidden\" id=\"attachmentsPagename\" name=\"attachmentsPagename\" value=\"%(attachmentsPagename)s\">\n <input type=\"hidden\" id=\"destinationPagename\" name=\"destinationPagename\" value=\"%(destinationPagename)s\">\n\n <div id=\"divInfo\" style=\"valign=top;\">\n <div id=\"divLinkTypeAttachment\">\n <fieldset>\n <legend>%(langAttachmentLocation)s</legend>\n <table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%%\" border=\"0\">\n <tr>\n <td valign=\"bottom\" style=\"width:90%%\" style=\"padding-bottom:10px\">\n <span>%(langPagename)s</span><br>\n </td>\n </tr>\n <tr>\n <td valign=\"bottom\" style=\"width:100%%\" style=\"padding-bottom:10px;padding-right:10px;\">\n <input id=\"txtPagename\" type=\"text\" onkeyup=\"OnPagenameChange();\" onchange=\"OnPagenameChange();\" style=\"width:98%%\">\n </td>\n </tr>\n <tr>\n <td valign=\"bottom\" style=\"width:90%%\" style=\"padding-bottom:10px;\">\n <span>%(langAttachmentname)s</span><br>\n </td>\n </tr>\n <tr valign=\"bottom\">\n <td valign=\"bottom\" style=\"width:100%%\" style=\"padding-bottom:10px;padding-right:10px;\">\n <input id=\"txtAttachmentname\" type=\"text\" onkeyup=\"OnAttachmentnameChange();\" onchange=\"OnPagenameChange();\" style=\"width:98%%\"><br>\n </td>\n </tr>\n </table>\n </fieldset>\n <fieldset>\n <legend>%(langAvailableAttachments)s</legend>\n <table cellSpacing=\"0\" cellPadding=\"0\" width=\"100%%\" border=\"0\">\n <tr>\n <td valign=\"bottom\" style=\"width:100%%\" style=\"padding-bottom:10px\">\n <input id=\"btnListAttachments\" type=\"submit\" value=\"%(langListAttachmentsButton)s\">\n </td>\n </tr>\n <tr>\n <td valign=\"top\" style=\"padding-top:10px\">\n <label for=\"sctAttachments\">%(langAttachmentList)s</label><br>\n %(attachmentList)s\n </td>\n </tr>\n </table>\n </fieldset>\n </div>\n </div>\n </form>\n </body>\n</html>\n\"\"\"\n % locals())\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 ]
[ "FunctionDef'", "Docstring", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_2(VAR_4, VAR_5):...\n", "if VAR_4.is_public:\n", "return True\n", "VAR_9 = VAR_5['email']\n", "VAR_10 = VAR_9.split('@')[-1]\n", "if VAR_10 in VAR_4.google_apps_domains:\n", "return True\n", "if VAR_4.has_user(VAR_9) == 1:\n", "return True\n", "return False\n" ]
[ "def verify_profile(org, profile):...\n", "if org.is_public:\n", "return True\n", "email = profile['email']\n", "domain = email.split('@')[-1]\n", "if domain in org.google_apps_domains:\n", "return True\n", "if org.has_user(email) == 1:\n", "return True\n", "return False\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "Assign'", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "import email.mime.multipart\n", "import email.utils\n", "import logging\n", "import urllib.parse\n", "from email.mime.multipart import MIMEMultipart\n", "from email.mime.text import MIMEText\n", "from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, TypeVar\n", "import bleach\n", "import jinja2\n", "from synapse.api.constants import EventTypes, Membership\n", "from synapse.api.errors import StoreError\n", "from synapse.config.emailconfig import EmailSubjectConfig\n", "from synapse.events import EventBase\n", "from synapse.logging.context import make_deferred_yieldable\n", "from synapse.push.presentable_names import calculate_room_name, descriptor_from_member_events, name_from_member_event\n", "from synapse.types import StateMap, UserID\n", "from synapse.util.async_helpers import concurrently_execute\n", "from synapse.visibility import filter_events_for_client\n", "if TYPE_CHECKING:\n", "from synapse.app.homeserver import HomeServer\n", "VAR_0 = logging.getLogger(__name__)\n", "VAR_1 = TypeVar('T')\n", "VAR_2 = 1\n", "VAR_3 = 1\n", "VAR_4 = ['font', 'del', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a',\n 'ul', 'ol', 'nl', 'li', 'b', 'i', 'u', 'strong', 'em', 'strike', 'code',\n 'hr', 'br', 'div', 'table', 'thead', 'caption', 'tbody', 'tr', 'th',\n 'td', 'pre']\n", "VAR_5 = {'font': ['color'], 'a': ['href', 'name', 'target'], 'img': ['src']}\n", "def __init__(self, VAR_10: 'HomeServer', VAR_11: str, VAR_12: jinja2....\n", "self.hs = VAR_10\n", "self.template_html = VAR_12\n", "self.template_text = VAR_13\n", "self.sendmail = self.hs.get_sendmail()\n", "self.store = self.hs.get_datastore()\n", "self.macaroon_gen = self.hs.get_macaroon_generator()\n", "self.state_handler = self.hs.get_state_handler()\n", "self.storage = VAR_10.get_storage()\n", "self.app_name = VAR_11\n", "self.email_subjects = VAR_10.config.email_subjects\n", "VAR_0.info('Created Mailer for app_name %s' % VAR_11)\n", "async def FUNC_4(self, VAR_14: str, VAR_15: str, VAR_16: str, VAR_17: str...\n", "\"\"\"docstring\"\"\"\n", "VAR_36 = {'token': VAR_15, 'client_secret': VAR_16, 'sid': VAR_17}\n", "VAR_37 = (self.hs.config.public_baseurl + \n '_synapse/client/password_reset/email/submit_token?%s' % urllib.parse.\n urlencode(VAR_36))\n", "VAR_38 = {'link': VAR_37}\n", "await self.send_email(VAR_14, self.email_subjects.password_reset % {\n 'server_name': self.hs.config.server_name}, VAR_38)\n", "async def FUNC_5(self, VAR_14: str, VAR_15: str, VAR_16: str, VAR_17: str...\n", "\"\"\"docstring\"\"\"\n", "VAR_36 = {'token': VAR_15, 'client_secret': VAR_16, 'sid': VAR_17}\n", "VAR_37 = (self.hs.config.public_baseurl + \n '_matrix/client/unstable/registration/email/submit_token?%s' % urllib.\n parse.urlencode(VAR_36))\n", "VAR_38 = {'link': VAR_37}\n", "await self.send_email(VAR_14, self.email_subjects.email_validation % {\n 'server_name': self.hs.config.server_name}, VAR_38)\n", "async def FUNC_6(self, VAR_14: str, VAR_15: str, VAR_16: str, VAR_17: str...\n", "\"\"\"docstring\"\"\"\n", "VAR_36 = {'token': VAR_15, 'client_secret': VAR_16, 'sid': VAR_17}\n", "VAR_37 = (self.hs.config.public_baseurl + \n '_matrix/client/unstable/add_threepid/email/submit_token?%s' % urllib.\n parse.urlencode(VAR_36))\n", "VAR_38 = {'link': VAR_37}\n", "await self.send_email(VAR_14, self.email_subjects.email_validation % {\n 'server_name': self.hs.config.server_name}, VAR_38)\n", "async def FUNC_7(self, VAR_18: str, VAR_19: str, VAR_14: str, VAR_20:...\n", "\"\"\"docstring\"\"\"\n", "VAR_39 = FUNC_2([pa['room_id'] for pa in VAR_20])\n", "VAR_26 = await self.store.get_events([pa['event_id'] for pa in VAR_20])\n", "VAR_32 = {}\n", "for pa in VAR_20:\n", "VAR_32.setdefault(pa['room_id'], []).append(pa)\n", "VAR_40 = {}\n", "VAR_64 = await self.store.get_profile_displayname(UserID.from_string(VAR_19\n ).localpart)\n", "VAR_64 = VAR_19\n", "async def FUNC_18(VAR_24):...\n", "if VAR_64 is None:\n", "VAR_65 = await self.store.get_current_state_ids(VAR_24)\n", "VAR_64 = VAR_19\n", "VAR_40[VAR_24] = VAR_65\n", "await concurrently_execute(FUNC_18, VAR_39, 3)\n", "VAR_39.sort(key=lambda r: -(notifs_by_room[r][-1]['received_ts'] or 0))\n", "VAR_41 = []\n", "for r in VAR_39:\n", "VAR_66 = await self.get_room_vars(r, VAR_19, VAR_32[r], VAR_26, VAR_40[r])\n", "VAR_21['room_name'] = await calculate_room_name(self.store, VAR_40[VAR_21[\n 'room_id']], VAR_19, fallback_to_members=True)\n", "VAR_41.append(VAR_66)\n", "VAR_42 = await self.make_summary_text(VAR_32, VAR_40, VAR_26, VAR_19, VAR_21)\n", "VAR_38 = {'user_display_name': VAR_64, 'unsubscribe_link': self.\n make_unsubscribe_link(VAR_19, VAR_18, VAR_14), 'summary_text': VAR_42,\n 'rooms': VAR_41, 'reason': VAR_21}\n", "await self.send_email(VAR_14, VAR_42, VAR_38)\n", "async def FUNC_8(self, VAR_14: str, VAR_22: str, VAR_23: Dict[str, Any]...\n", "\"\"\"docstring\"\"\"\n", "VAR_67 = self.hs.config.email_notif_from % {'app': self.app_name}\n", "VAR_67 = self.hs.config.email_notif_from\n", "VAR_43 = email.utils.parseaddr(VAR_67)[1]\n", "VAR_44 = email.utils.parseaddr(VAR_14)[1]\n", "if VAR_44 == '':\n", "VAR_38 = {'app_name': self.app_name, 'server_name': self.hs.config.server.\n server_name}\n", "VAR_38.update(VAR_23)\n", "VAR_45 = self.template_html.render(**template_vars)\n", "VAR_46 = MIMEText(VAR_45, 'html', 'utf8')\n", "VAR_47 = self.template_text.render(**template_vars)\n", "VAR_48 = MIMEText(VAR_47, 'plain', 'utf8')\n", "VAR_49 = MIMEMultipart('alternative')\n", "VAR_49['Subject'] = VAR_22\n", "VAR_49['From'] = VAR_67\n", "VAR_49['To'] = VAR_14\n", "VAR_49['Date'] = email.utils.formatdate()\n", "VAR_49['Message-ID'] = email.utils.make_msgid()\n", "VAR_49.attach(VAR_48)\n", "VAR_49.attach(VAR_46)\n", "VAR_0.info('Sending email to %s' % VAR_14)\n", "await make_deferred_yieldable(self.sendmail(self.hs.config.email_smtp_host,\n VAR_43, VAR_44, VAR_49.as_string().encode('utf8'), reactor=self.hs.\n get_reactor(), port=self.hs.config.email_smtp_port,\n requireAuthentication=self.hs.config.email_smtp_user is not None,\n username=self.hs.config.email_smtp_user, password=self.hs.config.\n email_smtp_pass, requireTransportSecurity=self.hs.config.\n require_transport_security))\n", "async def FUNC_9(self, VAR_24: str, VAR_19: str, VAR_25: Iterable[Dict[str,...\n", "VAR_50 = False\n", "for n in VAR_25:\n", "VAR_68 = VAR_26[n['event_id']]\n", "VAR_51 = await calculate_room_name(self.store, VAR_27, VAR_19)\n", "if VAR_68.type == EventTypes.Member and VAR_68.state_key == VAR_19:\n", "VAR_52 = {'title': VAR_51, 'hash': FUNC_3(VAR_24), 'notifs': [], 'invite':\n VAR_50, 'link': self.make_room_link(VAR_24)}\n", "if VAR_68.content.get('membership') == Membership.INVITE:\n", "if not VAR_50:\n", "VAR_50 = True\n", "for n in VAR_25:\n", "return VAR_52\n", "VAR_71 = await self.get_notif_vars(n, VAR_19, VAR_26[n['event_id']], VAR_27)\n", "VAR_72 = False\n", "if VAR_52['notifs'] and 'messages' in VAR_52['notifs'][-1]:\n", "VAR_77 = VAR_52['notifs'][-1]['messages']\n", "if not VAR_72:\n", "for message in VAR_71['messages']:\n", "VAR_52['notifs'].append(VAR_71)\n", "VAR_81 = list(filter(lambda VAR_81: VAR_81['id'] == message['id'], VAR_77))\n", "if VAR_81:\n", "if not message['is_historical']:\n", "if VAR_72:\n", "VAR_81[0]['is_historical'] = False\n", "VAR_72 = True\n", "VAR_77.append(message)\n" ]
[ "import email.mime.multipart\n", "import email.utils\n", "import logging\n", "import urllib.parse\n", "from email.mime.multipart import MIMEMultipart\n", "from email.mime.text import MIMEText\n", "from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, TypeVar\n", "import bleach\n", "import jinja2\n", "from synapse.api.constants import EventTypes, Membership\n", "from synapse.api.errors import StoreError\n", "from synapse.config.emailconfig import EmailSubjectConfig\n", "from synapse.events import EventBase\n", "from synapse.logging.context import make_deferred_yieldable\n", "from synapse.push.presentable_names import calculate_room_name, descriptor_from_member_events, name_from_member_event\n", "from synapse.types import StateMap, UserID\n", "from synapse.util.async_helpers import concurrently_execute\n", "from synapse.visibility import filter_events_for_client\n", "if TYPE_CHECKING:\n", "from synapse.app.homeserver import HomeServer\n", "logger = logging.getLogger(__name__)\n", "T = TypeVar('T')\n", "CONTEXT_BEFORE = 1\n", "CONTEXT_AFTER = 1\n", "ALLOWED_TAGS = ['font', 'del', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p',\n 'a', 'ul', 'ol', 'nl', 'li', 'b', 'i', 'u', 'strong', 'em', 'strike',\n 'code', 'hr', 'br', 'div', 'table', 'thead', 'caption', 'tbody', 'tr',\n 'th', 'td', 'pre']\n", "ALLOWED_ATTRS = {'font': ['color'], 'a': ['href', 'name', 'target'], 'img':\n ['src']}\n", "def __init__(self, hs: 'HomeServer', app_name: str, template_html: jinja2....\n", "self.hs = hs\n", "self.template_html = template_html\n", "self.template_text = template_text\n", "self.sendmail = self.hs.get_sendmail()\n", "self.store = self.hs.get_datastore()\n", "self.macaroon_gen = self.hs.get_macaroon_generator()\n", "self.state_handler = self.hs.get_state_handler()\n", "self.storage = hs.get_storage()\n", "self.app_name = app_name\n", "self.email_subjects = hs.config.email_subjects\n", "logger.info('Created Mailer for app_name %s' % app_name)\n", "async def send_password_reset_mail(self, email_address: str, token: str,...\n", "\"\"\"docstring\"\"\"\n", "params = {'token': token, 'client_secret': client_secret, 'sid': sid}\n", "link = (self.hs.config.public_baseurl + \n '_synapse/client/password_reset/email/submit_token?%s' % urllib.parse.\n urlencode(params))\n", "template_vars = {'link': link}\n", "await self.send_email(email_address, self.email_subjects.password_reset % {\n 'server_name': self.hs.config.server_name}, template_vars)\n", "async def send_registration_mail(self, email_address: str, token: str,...\n", "\"\"\"docstring\"\"\"\n", "params = {'token': token, 'client_secret': client_secret, 'sid': sid}\n", "link = (self.hs.config.public_baseurl + \n '_matrix/client/unstable/registration/email/submit_token?%s' % urllib.\n parse.urlencode(params))\n", "template_vars = {'link': link}\n", "await self.send_email(email_address, self.email_subjects.email_validation %\n {'server_name': self.hs.config.server_name}, template_vars)\n", "async def send_add_threepid_mail(self, email_address: str, token: str,...\n", "\"\"\"docstring\"\"\"\n", "params = {'token': token, 'client_secret': client_secret, 'sid': sid}\n", "link = (self.hs.config.public_baseurl + \n '_matrix/client/unstable/add_threepid/email/submit_token?%s' % urllib.\n parse.urlencode(params))\n", "template_vars = {'link': link}\n", "await self.send_email(email_address, self.email_subjects.email_validation %\n {'server_name': self.hs.config.server_name}, template_vars)\n", "async def send_notification_mail(self, app_id: str, user_id: str,...\n", "\"\"\"docstring\"\"\"\n", "rooms_in_order = deduped_ordered_list([pa['room_id'] for pa in push_actions])\n", "notif_events = await self.store.get_events([pa['event_id'] for pa in\n push_actions])\n", "notifs_by_room = {}\n", "for pa in push_actions:\n", "notifs_by_room.setdefault(pa['room_id'], []).append(pa)\n", "state_by_room = {}\n", "user_display_name = await self.store.get_profile_displayname(UserID.\n from_string(user_id).localpart)\n", "user_display_name = user_id\n", "async def _fetch_room_state(room_id):...\n", "if user_display_name is None:\n", "room_state = await self.store.get_current_state_ids(room_id)\n", "user_display_name = user_id\n", "state_by_room[room_id] = room_state\n", "await concurrently_execute(_fetch_room_state, rooms_in_order, 3)\n", "rooms_in_order.sort(key=lambda r: -(notifs_by_room[r][-1]['received_ts'] or 0))\n", "rooms = []\n", "for r in rooms_in_order:\n", "roomvars = await self.get_room_vars(r, user_id, notifs_by_room[r],\n notif_events, state_by_room[r])\n", "reason['room_name'] = await calculate_room_name(self.store, state_by_room[\n reason['room_id']], user_id, fallback_to_members=True)\n", "rooms.append(roomvars)\n", "summary_text = await self.make_summary_text(notifs_by_room, state_by_room,\n notif_events, user_id, reason)\n", "template_vars = {'user_display_name': user_display_name, 'unsubscribe_link':\n self.make_unsubscribe_link(user_id, app_id, email_address),\n 'summary_text': summary_text, 'rooms': rooms, 'reason': reason}\n", "await self.send_email(email_address, summary_text, template_vars)\n", "async def send_email(self, email_address: str, subject: str,...\n", "\"\"\"docstring\"\"\"\n", "from_string = self.hs.config.email_notif_from % {'app': self.app_name}\n", "from_string = self.hs.config.email_notif_from\n", "raw_from = email.utils.parseaddr(from_string)[1]\n", "raw_to = email.utils.parseaddr(email_address)[1]\n", "if raw_to == '':\n", "template_vars = {'app_name': self.app_name, 'server_name': self.hs.config.\n server.server_name}\n", "template_vars.update(extra_template_vars)\n", "html_text = self.template_html.render(**template_vars)\n", "html_part = MIMEText(html_text, 'html', 'utf8')\n", "plain_text = self.template_text.render(**template_vars)\n", "text_part = MIMEText(plain_text, 'plain', 'utf8')\n", "multipart_msg = MIMEMultipart('alternative')\n", "multipart_msg['Subject'] = subject\n", "multipart_msg['From'] = from_string\n", "multipart_msg['To'] = email_address\n", "multipart_msg['Date'] = email.utils.formatdate()\n", "multipart_msg['Message-ID'] = email.utils.make_msgid()\n", "multipart_msg.attach(text_part)\n", "multipart_msg.attach(html_part)\n", "logger.info('Sending email to %s' % email_address)\n", "await make_deferred_yieldable(self.sendmail(self.hs.config.email_smtp_host,\n raw_from, raw_to, multipart_msg.as_string().encode('utf8'), reactor=\n self.hs.get_reactor(), port=self.hs.config.email_smtp_port,\n requireAuthentication=self.hs.config.email_smtp_user is not None,\n username=self.hs.config.email_smtp_user, password=self.hs.config.\n email_smtp_pass, requireTransportSecurity=self.hs.config.\n require_transport_security))\n", "async def get_room_vars(self, room_id: str, user_id: str, notifs: Iterable[...\n", "is_invite = False\n", "for n in notifs:\n", "ev = notif_events[n['event_id']]\n", "room_name = await calculate_room_name(self.store, room_state_ids, user_id)\n", "if ev.type == EventTypes.Member and ev.state_key == user_id:\n", "room_vars = {'title': room_name, 'hash': string_ordinal_total(room_id),\n 'notifs': [], 'invite': is_invite, 'link': self.make_room_link(room_id)}\n", "if ev.content.get('membership') == Membership.INVITE:\n", "if not is_invite:\n", "is_invite = True\n", "for n in notifs:\n", "return room_vars\n", "notifvars = await self.get_notif_vars(n, user_id, notif_events[n['event_id'\n ]], room_state_ids)\n", "merge = False\n", "if room_vars['notifs'] and 'messages' in room_vars['notifs'][-1]:\n", "prev_messages = room_vars['notifs'][-1]['messages']\n", "if not merge:\n", "for message in notifvars['messages']:\n", "room_vars['notifs'].append(notifvars)\n", "pm = list(filter(lambda pm: pm['id'] == message['id'], prev_messages))\n", "if pm:\n", "if not message['is_historical']:\n", "if merge:\n", "pm[0]['is_historical'] = False\n", "merge = True\n", "prev_messages.append(message)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Condition", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "For", "Expr'", "Assign'", "Assign'", "Assign'", "AsyncFunctionDef'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "For", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Condition", "Assign'", "For", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "For", "Return'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "For", "Expr'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Expr'" ]
[ "@VAR_2.route('/get_tags_json', methods=['GET'])...\n", "return calibre_db.get_typeahead(db.Tags, request.args.get('q'), tag_filter=\n tags_filters())\n" ]
[ "@web.route('/get_tags_json', methods=['GET'])...\n", "return calibre_db.get_typeahead(db.Tags, request.args.get('q'), tag_filter=\n tags_filters())\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "@classmethod...\n", "if VAR_4 is None:\n", "os.stat(VAR_4)\n", "return VAR_15.abspath(VAR_4)\n" ]
[ "@classmethod...\n", "if file_path is None:\n", "os.stat(file_path)\n", "return cls.abspath(file_path)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Condition", "Expr'", "Return'" ]
[ "def FUNC_9(VAR_25):...\n", "return VAR_25[:-1] if VAR_25.endswith('_') else VAR_25\n" ]
[ "def norm(k):...\n", "return k[:-1] if k.endswith('_') else k\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "from django.core.exceptions import ValidationError\n", "from shuup.utils.django_compat import force_text\n", "\"\"\" User-visible exception. \"\"\"\n", "VAR_1 = property(lambda self: self.args[0] if self.args else None)\n", "def __init__(self, VAR_1, VAR_2=None):...\n", "super(CLASS_0, self).__init__(VAR_1)\n", "self.title = VAR_2\n", "self.links = []\n", "def FUNC_1(self, VAR_3, VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "self.links.append({'url': VAR_3, 'title': VAR_2})\n", "return self\n" ]
[ "from django.core.exceptions import ValidationError\n", "from shuup.utils.django_compat import force_text\n", "\"\"\" User-visible exception. \"\"\"\n", "message = property(lambda self: self.args[0] if self.args else None)\n", "def __init__(self, message, title=None):...\n", "super(Problem, self).__init__(message)\n", "self.title = title\n", "self.links = []\n", "def with_link(self, url, title):...\n", "\"\"\"docstring\"\"\"\n", "self.links.append({'url': url, 'title': title})\n", "return self\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "Expr'", "Assign'", "FunctionDef'", "Expr'", "Assign'", "Assign'", "FunctionDef'", "Docstring", "Expr'", "Return'" ]
[ "@FUNC_4...\n", "\"\"\"docstring\"\"\"\n", "VAR_38 = CourseKey.from_string(VAR_10)\n", "VAR_148 = VAR_9.POST.get('certificates-enabled', 'false') == 'true'\n", "certs_api.set_cert_generation_enabled(VAR_38, VAR_148)\n", "return redirect(FUNC_65(VAR_38, VAR_39='certificates'))\n" ]
[ "@require_global_staff...\n", "\"\"\"docstring\"\"\"\n", "course_key = CourseKey.from_string(course_id)\n", "is_enabled = request.POST.get('certificates-enabled', 'false') == 'true'\n", "certs_api.set_cert_generation_enabled(course_key, is_enabled)\n", "return redirect(_instructor_dash_url(course_key, section='certificates'))\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_19(self, VAR_6, VAR_8, VAR_10=False):...\n", "VAR_13, VAR_15 = [], []\n", "VAR_25 = frappe.desk.query_report.run(self.name, VAR_6=filters, VAR_8=user,\n VAR_10=ignore_prepared_report)\n", "for d in VAR_25.get('columns'):\n", "if isinstance(d, dict):\n", "VAR_15 += VAR_25.get('result')\n", "VAR_36 = frappe._dict(d)\n", "VAR_37, VAR_38 = 'Data', None\n", "return VAR_13, VAR_15\n", "if not VAR_36.fieldname:\n", "VAR_11 = d.split(':')\n", "VAR_36.fieldname = VAR_36.label\n", "VAR_13.append(VAR_36)\n", "if len(VAR_11) > 1:\n", "if VAR_11[1]:\n", "VAR_13.append(frappe._dict(VAR_32=parts[0], VAR_37=fieldtype, fieldname=\n parts[0], VAR_38=options))\n", "VAR_37, VAR_38 = VAR_11[1], None\n", "if VAR_37 and '/' in VAR_37:\n", "VAR_37, VAR_38 = VAR_37.split('/')\n" ]
[ "def run_query_report(self, filters, user, ignore_prepared_report=False):...\n", "columns, result = [], []\n", "data = frappe.desk.query_report.run(self.name, filters=filters, user=user,\n ignore_prepared_report=ignore_prepared_report)\n", "for d in data.get('columns'):\n", "if isinstance(d, dict):\n", "result += data.get('result')\n", "col = frappe._dict(d)\n", "fieldtype, options = 'Data', None\n", "return columns, result\n", "if not col.fieldname:\n", "parts = d.split(':')\n", "col.fieldname = col.label\n", "columns.append(col)\n", "if len(parts) > 1:\n", "if parts[1]:\n", "columns.append(frappe._dict(label=parts[0], fieldtype=fieldtype, fieldname=\n parts[0], options=options))\n", "fieldtype, options = parts[1], None\n", "if fieldtype and '/' in fieldtype:\n", "fieldtype, options = fieldtype.split('/')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "For", "Condition", "AugAssign'", "Assign'", "Assign'", "Return'", "Condition", "Assign'", "Assign'", "Expr'", "Condition", "Condition", "Expr'", "Assign'", "Condition", "Assign'" ]
[ "def __init__(self, *, VAR_41: str='', VAR_30: Optional[List[str]]=None,...\n", "super().__init__(VAR_43=routes, VAR_44=redirect_slashes, VAR_45=default,\n VAR_47=on_startup, VAR_48=on_shutdown)\n", "if VAR_41:\n", "assert VAR_41.startswith('/'), \"A path prefix must start with '/'\"\n", "self.prefix = VAR_41\n", "assert not VAR_41.endswith('/'\n ), \"A path prefix must not end with '/', as the routes will start with '/'\"\n", "self.tags: List[str] = VAR_30 or []\n", "self.dependencies = list(VAR_31 or []) or []\n", "self.deprecated = VAR_36\n", "self.include_in_schema = VAR_39\n", "self.responses = VAR_35 or {}\n", "self.callbacks = VAR_40 or []\n", "self.dependency_overrides_provider = VAR_22\n", "self.route_class = VAR_46\n", "self.default_response_class = VAR_42\n" ]
[ "def __init__(self, *, prefix: str='', tags: Optional[List[str]]=None,...\n", "super().__init__(routes=routes, redirect_slashes=redirect_slashes, default=\n default, on_startup=on_startup, on_shutdown=on_shutdown)\n", "if prefix:\n", "assert prefix.startswith('/'), \"A path prefix must start with '/'\"\n", "self.prefix = prefix\n", "assert not prefix.endswith('/'\n ), \"A path prefix must not end with '/', as the routes will start with '/'\"\n", "self.tags: List[str] = tags or []\n", "self.dependencies = list(dependencies or []) or []\n", "self.deprecated = deprecated\n", "self.include_in_schema = include_in_schema\n", "self.responses = responses or {}\n", "self.callbacks = callbacks or []\n", "self.dependency_overrides_provider = dependency_overrides_provider\n", "self.route_class = route_class\n", "self.default_response_class = default_response_class\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Condition", "Assert'", "Assign'", "Assert'", "AnnAssign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_2(VAR_2, *VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "return FUNC_0(FEDERATION_V2_PREFIX, VAR_2, *VAR_3)\n" ]
[ "def _create_v2_path(path, *args):...\n", "\"\"\"docstring\"\"\"\n", "return _create_path(FEDERATION_V2_PREFIX, path, *args)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_74(self, VAR_90=None):...\n", "\"\"\"docstring\"\"\"\n", "return self.requires(True, VAR_90=otherwise)\n" ]
[ "def requires_login(self, otherwise=None):...\n", "\"\"\"docstring\"\"\"\n", "return self.requires(True, otherwise=otherwise)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_22(VAR_0, VAR_1: FlaskClient, VAR_2, VAR_4):...\n", "VAR_0.config['SEARCH_CONF']['enabled'] = 1\n", "VAR_0.config['SEARCH_CONF']['engine'] = 'ripgrep'\n", "VAR_8 = VAR_1.put(f'/api/dataobjs/{VAR_2.id}', json={'content':\n f'[[{bookmark_fixture.title}|{bookmark_fixture.id}]]'})\n", "assert VAR_8.status_code == 200\n", "VAR_8 = VAR_1.get(f'/dataobj/{VAR_4.id}')\n", "assert b'Backlinks' in VAR_8.data\n", "VAR_0.config['SEARCH_CONF']['enabled'] = 0\n" ]
[ "def test_backlinks_are_saved(test_app, client: FlaskClient, note_fixture,...\n", "test_app.config['SEARCH_CONF']['enabled'] = 1\n", "test_app.config['SEARCH_CONF']['engine'] = 'ripgrep'\n", "resp = client.put(f'/api/dataobjs/{note_fixture.id}', json={'content':\n f'[[{bookmark_fixture.title}|{bookmark_fixture.id}]]'})\n", "assert resp.status_code == 200\n", "resp = client.get(f'/dataobj/{bookmark_fixture.id}')\n", "assert b'Backlinks' in resp.data\n", "test_app.config['SEARCH_CONF']['enabled'] = 0\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assert'", "Assign'", "Assert'", "Assign'" ]
[ "@VAR_0.route('/<path:path>', methods=['PUT'])...\n", "" ]
[ "@app.route('/<path:path>', methods=['PUT'])...\n", "" ]
[ 0, 0 ]
[ "Condition", "Condition" ]
[ "def FUNC_14(VAR_19, VAR_11, VAR_10):...\n", "VAR_54 = True\n", "VAR_55 = os.path.join(VAR_11, VAR_10.filename)\n", "if os.path.exists(VAR_55):\n", "VAR_86 = ask_path_exists(\n 'The file %s exists. (i)gnore, (w)ipe, (b)ackup, (a)abort' %\n display_path(VAR_55), ('i', 'w', 'b', 'a'))\n", "if VAR_54:\n", "if VAR_86 == 'i':\n", "shutil.copy(VAR_19, VAR_55)\n", "VAR_54 = False\n", "if VAR_86 == 'w':\n", "VAR_1.info('Saved %s', display_path(VAR_55))\n", "VAR_1.warning('Deleting %s', display_path(VAR_55))\n", "if VAR_86 == 'b':\n", "os.remove(VAR_55)\n", "VAR_106 = backup_dir(VAR_55)\n", "if VAR_86 == 'a':\n", "VAR_1.warning('Backing up %s to %s', display_path(VAR_55), display_path(\n VAR_106))\n", "sys.exit(-1)\n", "shutil.move(VAR_55, VAR_106)\n" ]
[ "def _copy_file(filename, location, link):...\n", "copy = True\n", "download_location = os.path.join(location, link.filename)\n", "if os.path.exists(download_location):\n", "response = ask_path_exists(\n 'The file %s exists. (i)gnore, (w)ipe, (b)ackup, (a)abort' %\n display_path(download_location), ('i', 'w', 'b', 'a'))\n", "if copy:\n", "if response == 'i':\n", "shutil.copy(filename, download_location)\n", "copy = False\n", "if response == 'w':\n", "logger.info('Saved %s', display_path(download_location))\n", "logger.warning('Deleting %s', display_path(download_location))\n", "if response == 'b':\n", "os.remove(download_location)\n", "dest_file = backup_dir(download_location)\n", "if response == 'a':\n", "logger.warning('Backing up %s to %s', display_path(download_location),\n display_path(dest_file))\n", "sys.exit(-1)\n", "shutil.move(download_location, dest_file)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_29():...\n", "logging.set_verbosity(logging.INFO)\n", "VAR_60 = FUNC_28()\n", "VAR_20 = VAR_60.parse_args()\n", "if not hasattr(VAR_20, 'func'):\n", "VAR_60.error('too few arguments')\n", "VAR_20.func(VAR_20)\n" ]
[ "def main():...\n", "logging.set_verbosity(logging.INFO)\n", "parser = create_parser()\n", "args = parser.parse_args()\n", "if not hasattr(args, 'func'):\n", "parser.error('too few arguments')\n", "args.func(args)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'" ]
[ "async def FUNC_10(self, VAR_22, VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = await self.federation_client.send_invite(VAR_10=target_host, VAR_11\n =event.room_id, VAR_12=event.event_id, VAR_6=event)\n", "return VAR_6\n" ]
[ "async def send_invite(self, target_host, event):...\n", "\"\"\"docstring\"\"\"\n", "pdu = await self.federation_client.send_invite(destination=target_host,\n room_id=event.room_id, event_id=event.event_id, pdu=event)\n", "return pdu\n" ]
[ 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_15(self, VAR_13, VAR_14):...\n", "VAR_62 = self.useroptions.forUser(self.getUserId())\n", "VAR_62.setOption(VAR_13, VAR_14)\n", "return 'success'\n" ]
[ "def api_setuseroption(self, optionkey, optionval):...\n", "uo = self.useroptions.forUser(self.getUserId())\n", "uo.setOption(optionkey, optionval)\n", "return 'success'\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_4(self, VAR_0, VAR_1, VAR_3):...\n", "self.store = VAR_3.get_datastore()\n", "self.handler = VAR_3.get_directory_handler()\n", "self.state_handler = VAR_3.get_state_handler()\n", "self.admin_user = self.register_user('admin', 'pass', admin=True)\n", "self.admin_user_tok = self.login('admin', 'pass')\n", "self.room_id = self.helper.create_room_as(self.admin_user, tok=self.\n admin_user_tok)\n", "self.test_alias = '#test:test'\n", "self.room_alias = RoomAlias.from_string(self.test_alias)\n", "self.test_user = self.register_user('user', 'pass', admin=False)\n", "self.test_user_tok = self.login('user', 'pass')\n", "self.helper.join(room=self.room_id, VAR_4=self.test_user, tok=self.\n test_user_tok)\n" ]
[ "def prepare(self, reactor, clock, hs):...\n", "self.store = hs.get_datastore()\n", "self.handler = hs.get_directory_handler()\n", "self.state_handler = hs.get_state_handler()\n", "self.admin_user = self.register_user('admin', 'pass', admin=True)\n", "self.admin_user_tok = self.login('admin', 'pass')\n", "self.room_id = self.helper.create_room_as(self.admin_user, tok=self.\n admin_user_tok)\n", "self.test_alias = '#test:test'\n", "self.room_alias = RoomAlias.from_string(self.test_alias)\n", "self.test_user = self.register_user('user', 'pass', admin=False)\n", "self.test_user_tok = self.login('user', 'pass')\n", "self.helper.join(room=self.room_id, user=self.test_user, tok=self.test_user_tok\n )\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "@transaction.non_atomic_requests...\n", "\"\"\"docstring\"\"\"\n", "VAR_38 = SlashSeparatedCourseKey.from_deprecated_string(VAR_10)\n", "instructor_task.api.submit_export_ora2_data(VAR_9, VAR_38)\n", "VAR_196 = _('string')\n", "VAR_172 = _('The ORA data report is being generated.')\n", "return JsonResponse({'status': VAR_196})\n", "return JsonResponse({'status': VAR_172})\n" ]
[ "@transaction.non_atomic_requests...\n", "\"\"\"docstring\"\"\"\n", "course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n", "instructor_task.api.submit_export_ora2_data(request, course_key)\n", "already_running_status = _(\n \"An ORA data 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", "success_status = _('The ORA data report is being generated.')\n", "return JsonResponse({'status': already_running_status})\n", "return JsonResponse({'status': success_status})\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Expr'", "Assign'", "Assign'", "Return'", "Return'" ]
[ "@defer.inlineCallbacks...\n", "self.mock_federation.make_query.return_value = make_awaitable({\n 'displayname': 'Alice'})\n", "VAR_3 = yield defer.ensureDeferred(self.handler.get_displayname(self.alice))\n", "self.assertEquals(VAR_3, 'Alice')\n", "self.mock_federation.make_query.assert_called_with(destination='remote',\n VAR_0='profile', args={'user_id': '@alice:remote', 'field':\n 'displayname'}, ignore_backoff=True)\n" ]
[ "@defer.inlineCallbacks...\n", "self.mock_federation.make_query.return_value = make_awaitable({\n 'displayname': 'Alice'})\n", "displayname = yield defer.ensureDeferred(self.handler.get_displayname(self.\n alice))\n", "self.assertEquals(displayname, 'Alice')\n", "self.mock_federation.make_query.assert_called_with(destination='remote',\n query_type='profile', args={'user_id': '@alice:remote', 'field':\n 'displayname'}, ignore_backoff=True)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_27(VAR_8, VAR_60, VAR_10=None, VAR_11=None, VAR_7=None):...\n", "if VAR_10 is None and VAR_11 is None or g.locale is None:\n", "return VAR_60\n", "VAR_37 = FUNC_1(VAR_8, VAR_10=data, VAR_11=additional_request_data)\n", "def FUNC_35():...\n", "return FUNC_0(VAR_6=request.url_root, VAR_7=additional_unless)\n" ]
[ "def get_preemptively_cached_view(key, view, data=None,...\n", "if data is None and additional_request_data is None or g.locale is None:\n", "return view\n", "d = _preemptive_data(key, data=data, additional_request_data=\n additional_request_data)\n", "def unless():...\n", "return _preemptive_unless(base_url=request.url_root, additional_unless=\n additional_unless)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "FunctionDef'", "Return'" ]
[ "@wraps(VAR_3)...\n", "if VAR_62.role_admin():\n", "return VAR_3(*VAR_30, **kwargs)\n", "abort(403)\n" ]
[ "@wraps(f)...\n", "if current_user.role_admin():\n", "return f(*args, **kwargs)\n", "abort(403)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Condition", "Return'", "Expr'" ]
[ "async def FUNC_13(self, VAR_26):...\n", "\"\"\"docstring\"\"\"\n", "for p, VAR_5 in VAR_26:\n", "VAR_0.info(\n 'Processing queued PDU %s which was received while we were joining %s',\n p.event_id, p.room_id)\n", "VAR_0.warning('Error handling queued PDU %s from %s: %s', p.event_id, VAR_5,\n VAR_170)\n", "await self.on_receive_pdu(VAR_5, p, VAR_7=True)\n" ]
[ "async def _handle_queued_pdus(self, room_queue):...\n", "\"\"\"docstring\"\"\"\n", "for p, origin in room_queue:\n", "logger.info(\n 'Processing queued PDU %s which was received while we were joining %s',\n p.event_id, p.room_id)\n", "logger.warning('Error handling queued PDU %s from %s: %s', p.event_id,\n origin, e)\n", "await self.on_receive_pdu(origin, p, sent_to_us_directly=True)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Docstring", "For", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_0(VAR_0, VAR_1='or'):...\n", "VAR_0 = list(VAR_0)\n", "if len(VAR_0) == 1:\n", "return VAR_0[0]\n", "if len(VAR_0) == 2:\n", "return '{0} {2} {1}'.format(VAR_0[0], VAR_0[1], VAR_1)\n", "return '{0}, {2} {1}'.format(', '.join(VAR_0[:-1]), VAR_0[-1], VAR_1)\n" ]
[ "def englishFromList(items, conjunction='or'):...\n", "items = list(items)\n", "if len(items) == 1:\n", "return items[0]\n", "if len(items) == 2:\n", "return '{0} {2} {1}'.format(items[0], items[1], conjunction)\n", "return '{0}, {2} {1}'.format(', '.join(items[:-1]), items[-1], conjunction)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "@log_function...\n", "VAR_2 = FUNC_1('/invite/%s/%s', VAR_6, VAR_7)\n", "VAR_37 = await self.client.put_json(VAR_5=destination, VAR_2=path, VAR_39=\n content, VAR_15=True)\n", "return VAR_37\n" ]
[ "@log_function...\n", "path = _create_v1_path('/invite/%s/%s', room_id, event_id)\n", "response = await self.client.put_json(destination=destination, path=path,\n data=content, ignore_backoff=True)\n", "return response\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Return'" ]
[ "@FUNC_0...\n", "return {stream.NAME: stream(self) for stream in STREAMS_MAP.values()}\n" ]
[ "@cache_in_self...\n", "return {stream.NAME: stream(self) for stream in STREAMS_MAP.values()}\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_16(self, VAR_29, VAR_30, VAR_31, VAR_32=False, VAR_33=None, VAR_34...\n", "\"\"\"docstring\"\"\"\n", "return VAR_3 + '\\n\\n'.join(dedent(VAR_78) for VAR_78 in self.invoke_all(\n 'generate_config_section', VAR_29=config_dir_path, VAR_30=data_dir_path,\n VAR_31=server_name, VAR_32=generate_secrets, VAR_33=report_stats,\n VAR_34=open_private_ports, VAR_35=listeners, VAR_36=\n tls_certificate_path, VAR_37=tls_private_key_path, VAR_38=acme_domain).\n values())\n" ]
[ "def generate_config(self, config_dir_path, data_dir_path, server_name,...\n", "\"\"\"docstring\"\"\"\n", "return CONFIG_FILE_HEADER + '\\n\\n'.join(dedent(conf) for conf in self.\n invoke_all('generate_config_section', config_dir_path=config_dir_path,\n data_dir_path=data_dir_path, server_name=server_name, generate_secrets=\n generate_secrets, report_stats=report_stats, open_private_ports=\n open_private_ports, listeners=listeners, tls_certificate_path=\n tls_certificate_path, tls_private_key_path=tls_private_key_path,\n acme_domain=acme_domain).values())\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def FUNC_30(self):...\n", "return URL(VAR_11=current.request.args, VAR_96=current.request.get_vars)\n" ]
[ "def here(self):...\n", "return URL(args=current.request.args, vars=current.request.get_vars)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_2(self):...\n", "VAR_24 = b'{\"msgtype\":\"m.text\",\"body\":\"hello\"}'\n", "VAR_25 = iter(range(100))\n", "def FUNC_77():...\n", "return '/rooms/%s/send/m.room.message/mid%s' % (self.created_rmid, str(next\n (VAR_25)))\n" ]
[ "def test_can_do_action(self):...\n", "msg_content = b'{\"msgtype\":\"m.text\",\"body\":\"hello\"}'\n", "seq = iter(range(100))\n", "def send_msg_path():...\n", "return '/rooms/%s/send/m.room.message/mid%s' % (self.created_rmid, str(next\n (seq)))\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "FunctionDef'", "Return'" ]
[ "def FUNC_26(self):...\n", "VAR_5 = {'org.matrix.labels': ['#fun']}\n", "VAR_6 = FUNC_0(sender='@foo:bar', type='m.room.message', room_id=\n '!secretbase:unknown', content={EventContentFields.LABELS: ['#fun']})\n", "self.assertTrue(Filter(VAR_5).check(VAR_6))\n", "VAR_6 = FUNC_0(sender='@foo:bar', type='m.room.message', room_id=\n '!secretbase:unknown', content={EventContentFields.LABELS: ['#notfun']})\n", "self.assertFalse(Filter(VAR_5).check(VAR_6))\n" ]
[ "def test_filter_labels(self):...\n", "definition = {'org.matrix.labels': ['#fun']}\n", "event = MockEvent(sender='@foo:bar', type='m.room.message', room_id=\n '!secretbase:unknown', content={EventContentFields.LABELS: ['#fun']})\n", "self.assertTrue(Filter(definition).check(event))\n", "event = MockEvent(sender='@foo:bar', type='m.room.message', room_id=\n '!secretbase:unknown', content={EventContentFields.LABELS: ['#notfun']})\n", "self.assertFalse(Filter(definition).check(event))\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_8(VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "VAR_22 = saved_model_utils.get_saved_model_tag_sets(VAR_2)\n", "for VAR_3 in sorted(VAR_22):\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_23 = FUNC_10(VAR_2, VAR_3)\n", "for VAR_5 in sorted(VAR_23.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 FUNC_5():...\n", "return FUNC_4('login_view_ticketlist')\n" ]
[ "def login_view_ticketlist_default():...\n", "return get_default_setting('login_view_ticketlist')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_62(self):...\n", "\"\"\"docstring\"\"\"\n", "return self._blitzcon.getUser().firstName or self.getName()\n" ]
[ "def getFirstName(self):...\n", "\"\"\"docstring\"\"\"\n", "return self._blitzcon.getUser().firstName or self.getName()\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "@property...\n", "return self.is_active\n" ]
[ "@property...\n", "return self.is_active\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_165(VAR_215, VAR_224):...\n", "if not VAR_399:\n", "return None\n", "return serializers.json({'jsonrpc': '2.0', 'id': VAR_215, 'result': VAR_224})\n" ]
[ "def return_response(id, result):...\n", "if not must_respond:\n", "return None\n", "return serializers.json({'jsonrpc': '2.0', 'id': id, 'result': result})\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_40(self):...\n", "if self.flags.ignore_links or self._action == 'cancel':\n", "return\n", "VAR_63, VAR_64 = self.get_invalid_links()\n", "for VAR_21 in self.get_all_children():\n", "VAR_86 = VAR_21.get_invalid_links(is_submittable=self.meta.is_submittable)\n", "if VAR_63:\n", "VAR_63.extend(VAR_86[0])\n", "VAR_87 = ', '.join(each[2] for each in VAR_63)\n", "if VAR_64:\n", "VAR_64.extend(VAR_86[1])\n", "frappe.throw(_('Could not find {0}').format(VAR_87), frappe.LinkValidationError\n )\n", "VAR_87 = ', '.join(each[2] for each in VAR_64)\n", "frappe.throw(_('Cannot link cancelled document: {0}').format(VAR_87),\n frappe.CancelledLinkError)\n" ]
[ "def _validate_links(self):...\n", "if self.flags.ignore_links or self._action == 'cancel':\n", "return\n", "invalid_links, cancelled_links = self.get_invalid_links()\n", "for d in self.get_all_children():\n", "result = d.get_invalid_links(is_submittable=self.meta.is_submittable)\n", "if invalid_links:\n", "invalid_links.extend(result[0])\n", "msg = ', '.join(each[2] for each in invalid_links)\n", "if cancelled_links:\n", "cancelled_links.extend(result[1])\n", "frappe.throw(_('Could not find {0}').format(msg), frappe.LinkValidationError)\n", "msg = ', '.join(each[2] for each in cancelled_links)\n", "frappe.throw(_('Cannot link cancelled document: {0}').format(msg), frappe.\n CancelledLinkError)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "For", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_9(self, VAR_5):...\n", "VAR_8 = self.service.detail(VAR_5, sort_dir='asc')\n", "return self._translate_uuids_to_ids(VAR_5, VAR_8)\n" ]
[ "def detail(self, context):...\n", "images = self.service.detail(context, sort_dir='asc')\n", "return self._translate_uuids_to_ids(context, images)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self.extra_static_paths + [DEFAULT_STATIC_FILES_PATH]\n" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self.extra_static_paths + [DEFAULT_STATIC_FILES_PATH]\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def FUNC_7(self):...\n", "self.run_command('jsdeps')\n", "VAR_48 = os.environ.copy()\n", "VAR_48['PATH'] = VAR_13\n", "FUNC_8()\n", "for src, dst in zip(self.sources, self.targets):\n", "FUNC_5(self.distribution)\n", "FUNC_7(['lessc', '--source-map', '--include-path=%s' % pipes.quote(VAR_12),\n src, dst], VAR_22=repo_root, VAR_48=env)\n", "print('Failed to build css: %s' % e, file=sys.stderr)\n", "print('You can install js dependencies with `npm install`', file=sys.stderr)\n" ]
[ "def run(self):...\n", "self.run_command('jsdeps')\n", "env = os.environ.copy()\n", "env['PATH'] = npm_path\n", "patch_out_bootstrap_bw_print()\n", "for src, dst in zip(self.sources, self.targets):\n", "update_package_data(self.distribution)\n", "run(['lessc', '--source-map', '--include-path=%s' % pipes.quote(static),\n src, dst], cwd=repo_root, env=env)\n", "print('Failed to build css: %s' % e, file=sys.stderr)\n", "print('You can install js dependencies with `npm install`', file=sys.stderr)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Expr'", "For", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "import logging\n", "from mock import Mock\n", "from twisted.internet import defer\n", "from synapse.rest import admin\n", "from synapse.rest.client.v1 import login, room\n", "from tests.replication._base import BaseMultiWorkerStreamTestCase\n", "VAR_0 = logging.getLogger(__name__)\n", "\"\"\"Checks pusher sharding works\n \"\"\"\n", "VAR_1 = [admin.register_servlets_for_client_rest_resource, VAR_11.\n register_servlets, login.register_servlets]\n", "def FUNC_0(self, VAR_2, VAR_3, VAR_4):...\n", "self.other_user_id = self.register_user('otheruser', 'pass')\n", "self.other_access_token = self.login('otheruser', 'pass')\n", "def FUNC_1(self):...\n", "VAR_6 = super().default_config()\n", "VAR_6['start_pushers'] = False\n", "return VAR_6\n" ]
[ "import logging\n", "from mock import Mock\n", "from twisted.internet import defer\n", "from synapse.rest import admin\n", "from synapse.rest.client.v1 import login, room\n", "from tests.replication._base import BaseMultiWorkerStreamTestCase\n", "logger = logging.getLogger(__name__)\n", "\"\"\"Checks pusher sharding works\n \"\"\"\n", "servlets = [admin.register_servlets_for_client_rest_resource, room.\n register_servlets, login.register_servlets]\n", "def prepare(self, reactor, clock, hs):...\n", "self.other_user_id = self.register_user('otheruser', 'pass')\n", "self.other_access_token = self.login('otheruser', 'pass')\n", "def default_config(self):...\n", "conf = super().default_config()\n", "conf['start_pushers'] = False\n", "return conf\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Expr'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_62(self, VAR_112=VAR_3, VAR_134=VAR_3, VAR_135=VAR_3, VAR_136=VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_254 = self.table_user()\n", "VAR_56 = VAR_263.request\n", "VAR_244 = VAR_263.response\n", "VAR_139 = VAR_263.session\n", "VAR_232 = (self.settings.retrieve_password_captcha or self.settings.\n retrieve_password_captcha is not False and self.settings.captcha)\n", "if VAR_112 is VAR_3:\n", "VAR_112 = self.get_vars_next() or self.settings.request_reset_password_next\n", "if not self.settings.mailer:\n", "VAR_244.flash = self.messages.function_disabled\n", "if VAR_134 is VAR_3:\n", "return ''\n", "VAR_134 = self.settings.request_reset_password_onvalidation\n", "if VAR_135 is VAR_3:\n", "VAR_135 = self.settings.request_reset_password_onaccept\n", "if VAR_136 is VAR_3:\n", "VAR_136 = self.messages['reset_password_log']\n", "VAR_260 = (self.settings.login_userfield or 'username' if self.settings.\n login_userfield or 'username' in VAR_254.fields else 'email')\n", "if VAR_260 == 'email':\n", "VAR_254.email.requires = [IS_EMAIL(VAR_59=self.messages.invalid_email),\n IS_IN_DB(self.db, VAR_254.email, VAR_59=self.messages.invalid_email)]\n", "if VAR_260 == 'username':\n", "if not self.settings.email_case_sensitive:\n", "VAR_254.username.requires = [IS_IN_DB(self.db, VAR_254.username, VAR_59=\n self.messages.invalid_username)]\n", "VAR_7 = SQLFORM(VAR_254, VAR_133=[userfield], hidden=dict(_next=next),\n showid=self.settings.showid, submit_button=self.messages.\n password_reset_button, delete_label=self.messages.delete_label, VAR_273\n =self.settings.formstyle, separator=self.settings.label_separator)\n", "VAR_254.email.requires.insert(0, IS_LOWER())\n", "if not self.settings.username_case_sensitive:\n", "if VAR_232:\n", "VAR_254.username.requires.insert(0, IS_LOWER())\n", "FUNC_5(VAR_7, VAR_232.label, VAR_232, VAR_232.comment, self.settings.\n formstyle, 'captcha__row')\n", "if VAR_7.accepts(VAR_56, VAR_139 if self.csrf_prevention else None, VAR_171\n", "VAR_141 = VAR_254(**{userfield: form.vars.get(userfield)})\n", "return VAR_7\n", "VAR_199 = VAR_141.registration_key\n", "if not VAR_141:\n", "VAR_139.flash = self.messages['invalid_%s' % VAR_260]\n", "if VAR_199 in ('pending', 'disabled', 'blocked') or (VAR_199 or '').startswith(\n", "redirect(self.url(VAR_11=request.args), client_side=self.settings.client_side)\n", "VAR_139.flash = self.messages.registration_pending\n", "if self.email_reset_password(VAR_141):\n", "redirect(self.url(VAR_11=request.args), client_side=self.settings.client_side)\n", "VAR_139.flash = self.messages.email_sent\n", "VAR_139.flash = self.messages.unable_send_email\n", "self.log_event(VAR_136, VAR_141)\n", "VAR_26(VAR_135, VAR_7)\n", "if not VAR_112:\n", "VAR_112 = self.url(VAR_11=request.args)\n", "VAR_112 = FUNC_4(VAR_112, VAR_7)\n", "redirect(VAR_112, client_side=self.settings.client_side)\n" ]
[ "def request_reset_password(self, next=DEFAULT, onvalidation=DEFAULT,...\n", "\"\"\"docstring\"\"\"\n", "table_user = self.table_user()\n", "request = current.request\n", "response = current.response\n", "session = current.session\n", "captcha = (self.settings.retrieve_password_captcha or self.settings.\n retrieve_password_captcha is not False and self.settings.captcha)\n", "if next is DEFAULT:\n", "next = self.get_vars_next() or self.settings.request_reset_password_next\n", "if not self.settings.mailer:\n", "response.flash = self.messages.function_disabled\n", "if onvalidation is DEFAULT:\n", "return ''\n", "onvalidation = self.settings.request_reset_password_onvalidation\n", "if onaccept is DEFAULT:\n", "onaccept = self.settings.request_reset_password_onaccept\n", "if log is DEFAULT:\n", "log = self.messages['reset_password_log']\n", "userfield = (self.settings.login_userfield or 'username' if self.settings.\n login_userfield or 'username' in table_user.fields else 'email')\n", "if userfield == 'email':\n", "table_user.email.requires = [IS_EMAIL(error_message=self.messages.\n invalid_email), IS_IN_DB(self.db, table_user.email, error_message=self.\n messages.invalid_email)]\n", "if userfield == 'username':\n", "if not self.settings.email_case_sensitive:\n", "table_user.username.requires = [IS_IN_DB(self.db, table_user.username,\n error_message=self.messages.invalid_username)]\n", "form = SQLFORM(table_user, fields=[userfield], hidden=dict(_next=next),\n showid=self.settings.showid, submit_button=self.messages.\n password_reset_button, delete_label=self.messages.delete_label,\n formstyle=self.settings.formstyle, separator=self.settings.label_separator)\n", "table_user.email.requires.insert(0, IS_LOWER())\n", "if not self.settings.username_case_sensitive:\n", "if captcha:\n", "table_user.username.requires.insert(0, IS_LOWER())\n", "addrow(form, captcha.label, captcha, captcha.comment, self.settings.\n formstyle, 'captcha__row')\n", "if form.accepts(request, session if self.csrf_prevention else None,\n", "user = table_user(**{userfield: form.vars.get(userfield)})\n", "return form\n", "key = user.registration_key\n", "if not user:\n", "session.flash = self.messages['invalid_%s' % userfield]\n", "if key in ('pending', 'disabled', 'blocked') or (key or '').startswith(\n", "redirect(self.url(args=request.args), client_side=self.settings.client_side)\n", "session.flash = self.messages.registration_pending\n", "if self.email_reset_password(user):\n", "redirect(self.url(args=request.args), client_side=self.settings.client_side)\n", "session.flash = self.messages.email_sent\n", "session.flash = self.messages.unable_send_email\n", "self.log_event(log, user)\n", "callback(onaccept, form)\n", "if not next:\n", "next = self.url(args=request.args)\n", "next = replace_id(next, form)\n", "redirect(next, client_side=self.settings.client_side)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Expr'", "Condition", "Condition", "Expr'", "Expr'", "Condition", "Assign'", "Return'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Condition", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_20(VAR_2, *VAR_23, **VAR_24):...\n", "\"\"\"docstring\"\"\"\n", "VAR_22 = VAR_21(VAR_2, *VAR_23, **kwargs)\n", "if isinstance(VAR_22, HttpResponseBase):\n", "return VAR_22\n", "VAR_37 = 'template' in VAR_22 and VAR_22['template'] or None\n", "VAR_37 = VAR_24.get('template', VAR_37)\n", "VAR_0.debug('Rendering template: %s' % VAR_37)\n", "if VAR_37 is None or VAR_37 == 'json':\n", "VAR_40 = type(VAR_22) is dict\n", "VAR_20.prepare_context(VAR_2, VAR_22, *VAR_23, **kwargs)\n", "return JsonResponse(VAR_22, VAR_40=safe)\n", "return render(VAR_2, VAR_37, VAR_22)\n" ]
[ "def wrapper(request, *args, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "context = f(request, *args, **kwargs)\n", "if isinstance(context, HttpResponseBase):\n", "return context\n", "template = 'template' in context and context['template'] or None\n", "template = kwargs.get('template', template)\n", "logger.debug('Rendering template: %s' % template)\n", "if template is None or template == 'json':\n", "safe = type(context) is dict\n", "ctx.prepare_context(request, context, *args, **kwargs)\n", "return JsonResponse(context, safe=safe)\n", "return render(request, template, context)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Expr'", "Return'", "Return'" ]
[ "def FUNC_14():...\n", "VAR_23.component_instance.json_args = VAR_34\n", "VAR_23.component_instance.special_args.extend(VAR_21)\n" ]
[ "def marshall_element_args():...\n", "element.component_instance.json_args = serialized_json_args\n", "element.component_instance.special_args.extend(special_args)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_9(self):...\n", "\"\"\"docstring\"\"\"\n", "self.expect_outgoing_key_request(self.hs.hostname, self.hs_signing_key)\n", "VAR_21 = 'ed25519:%s' % (self.hs_signing_key.version,)\n", "VAR_22 = PerspectivesKeyFetcher(self.hs2)\n", "VAR_23 = VAR_22.get_keys({self.hs.hostname: {VAR_21: 1000}})\n", "VAR_24 = self.get_success(VAR_23)\n", "self.assertIn(self.hs.hostname, VAR_24)\n", "VAR_25 = VAR_24[self.hs.hostname][VAR_21]\n", "assert isinstance(VAR_25, FetchKeyResult)\n", "self.assertEqual(signedjson.key.encode_verify_key_base64(VAR_25.verify_key),\n signedjson.key.encode_verify_key_base64(self.hs_signing_key.verify_key))\n" ]
[ "def test_get_notary_keyserver_key(self):...\n", "\"\"\"docstring\"\"\"\n", "self.expect_outgoing_key_request(self.hs.hostname, self.hs_signing_key)\n", "keyid = 'ed25519:%s' % (self.hs_signing_key.version,)\n", "fetcher = PerspectivesKeyFetcher(self.hs2)\n", "d = fetcher.get_keys({self.hs.hostname: {keyid: 1000}})\n", "res = self.get_success(d)\n", "self.assertIn(self.hs.hostname, res)\n", "keyres = res[self.hs.hostname][keyid]\n", "assert isinstance(keyres, FetchKeyResult)\n", "self.assertEqual(signedjson.key.encode_verify_key_base64(keyres.verify_key),\n signedjson.key.encode_verify_key_base64(self.hs_signing_key.verify_key))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assert'", "Expr'" ]
[ "def FUNC_45(self):...\n", "if self.user and not self.user.email:\n" ]
[ "def clean(self):...\n", "if self.user and not self.user.email:\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_84(self=self, VAR_148=VAR_148, VAR_149=VAR_149, VAR_150=VAR_150):...\n", "return self.has_permission(VAR_148, VAR_149, VAR_150)\n" ]
[ "def has_permission(self=self, name=name, table_name=table_name, record_id=...\n", "return self.has_permission(name, table_name, record_id)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_0(VAR_0: Reference, VAR_1: str='') ->str:...\n", "\"\"\"docstring\"\"\"\n", "return f'from {VAR_1}.{VAR_0.module_name} import {VAR_0.class_name}'\n" ]
[ "def import_string_from_reference(reference: Reference, prefix: str='') ->str:...\n", "\"\"\"docstring\"\"\"\n", "return f'from {prefix}.{reference.module_name} import {reference.class_name}'\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_58(self):...\n", "\"\"\"docstring\"\"\"\n", "self.helper.send(self.room_id, 'message 1', VAR_52=self.tok)\n", "self.helper.send(self.room_id, 'message 2', VAR_52=self.tok)\n", "VAR_55 = self.helper.send(self.room_id, 'message 3', VAR_52=self.tok)[\n 'event_id']\n", "self.helper.send(self.room_id, 'message 4', VAR_52=self.tok)\n", "self.helper.send(self.room_id, 'message 5', VAR_52=self.tok)\n", "VAR_22, VAR_23 = self.make_request('GET', \n '/rooms/%s/context/%s?filter={\"types\":[\"m.room.message\"]}' % (self.\n room_id, VAR_55), VAR_16=self.tok)\n", "self.assertEqual(VAR_23.code, 200, VAR_23.result)\n", "VAR_58 = VAR_23.json_body['events_before']\n", "self.assertEqual(len(VAR_58), 2, VAR_58)\n", "self.assertEqual(VAR_58[0].get('content', {}).get('body'), 'message 2',\n VAR_58[0])\n", "self.assertEqual(VAR_58[1].get('content', {}).get('body'), 'message 1',\n VAR_58[1])\n", "self.assertEqual(VAR_23.json_body['event'].get('content', {}).get('body'),\n 'message 3', VAR_23.json_body['event'])\n", "VAR_59 = VAR_23.json_body['events_after']\n", "self.assertEqual(len(VAR_59), 2, VAR_59)\n", "self.assertEqual(VAR_59[0].get('content', {}).get('body'), 'message 4',\n VAR_59[0])\n", "self.assertEqual(VAR_59[1].get('content', {}).get('body'), 'message 5',\n VAR_59[1])\n", "VAR_62 = self.hs.get_deactivate_account_handler()\n", "self.get_success(VAR_62.deactivate_account(self.user_id, erase_data=True))\n", "VAR_63 = self.register_user('user3', 'password')\n", "VAR_64 = self.login('user3', 'password')\n", "self.helper.invite(self.room_id, self.other_user_id, VAR_63, VAR_52=self.\n other_tok)\n", "self.helper.join(self.room_id, VAR_63, VAR_52=invited_tok)\n", "VAR_22, VAR_23 = self.make_request('GET', \n '/rooms/%s/context/%s?filter={\"types\":[\"m.room.message\"]}' % (self.\n room_id, VAR_55), VAR_16=invited_tok)\n", "self.assertEqual(VAR_23.code, 200, VAR_23.result)\n", "VAR_58 = VAR_23.json_body['events_before']\n", "self.assertEqual(len(VAR_58), 2, VAR_58)\n", "self.assertDictEqual(VAR_58[0].get('content'), {}, VAR_58[0])\n", "self.assertDictEqual(VAR_58[1].get('content'), {}, VAR_58[1])\n", "self.assertDictEqual(VAR_23.json_body['event'].get('content'), {}, VAR_23.\n json_body['event'])\n", "VAR_59 = VAR_23.json_body['events_after']\n", "self.assertEqual(len(VAR_59), 2, VAR_59)\n", "self.assertDictEqual(VAR_59[0].get('content'), {}, VAR_59[0])\n", "self.assertEqual(VAR_59[1].get('content'), {}, VAR_59[1])\n" ]
[ "def test_erased_sender(self):...\n", "\"\"\"docstring\"\"\"\n", "self.helper.send(self.room_id, 'message 1', tok=self.tok)\n", "self.helper.send(self.room_id, 'message 2', tok=self.tok)\n", "event_id = self.helper.send(self.room_id, 'message 3', tok=self.tok)['event_id'\n ]\n", "self.helper.send(self.room_id, 'message 4', tok=self.tok)\n", "self.helper.send(self.room_id, 'message 5', tok=self.tok)\n", "request, channel = self.make_request('GET', \n '/rooms/%s/context/%s?filter={\"types\":[\"m.room.message\"]}' % (self.\n room_id, event_id), access_token=self.tok)\n", "self.assertEqual(channel.code, 200, channel.result)\n", "events_before = channel.json_body['events_before']\n", "self.assertEqual(len(events_before), 2, events_before)\n", "self.assertEqual(events_before[0].get('content', {}).get('body'),\n 'message 2', events_before[0])\n", "self.assertEqual(events_before[1].get('content', {}).get('body'),\n 'message 1', events_before[1])\n", "self.assertEqual(channel.json_body['event'].get('content', {}).get('body'),\n 'message 3', channel.json_body['event'])\n", "events_after = channel.json_body['events_after']\n", "self.assertEqual(len(events_after), 2, events_after)\n", "self.assertEqual(events_after[0].get('content', {}).get('body'),\n 'message 4', events_after[0])\n", "self.assertEqual(events_after[1].get('content', {}).get('body'),\n 'message 5', events_after[1])\n", "deactivate_account_handler = self.hs.get_deactivate_account_handler()\n", "self.get_success(deactivate_account_handler.deactivate_account(self.user_id,\n erase_data=True))\n", "invited_user_id = self.register_user('user3', 'password')\n", "invited_tok = self.login('user3', 'password')\n", "self.helper.invite(self.room_id, self.other_user_id, invited_user_id, tok=\n self.other_tok)\n", "self.helper.join(self.room_id, invited_user_id, tok=invited_tok)\n", "request, channel = self.make_request('GET', \n '/rooms/%s/context/%s?filter={\"types\":[\"m.room.message\"]}' % (self.\n room_id, event_id), access_token=invited_tok)\n", "self.assertEqual(channel.code, 200, channel.result)\n", "events_before = channel.json_body['events_before']\n", "self.assertEqual(len(events_before), 2, events_before)\n", "self.assertDictEqual(events_before[0].get('content'), {}, events_before[0])\n", "self.assertDictEqual(events_before[1].get('content'), {}, events_before[1])\n", "self.assertDictEqual(channel.json_body['event'].get('content'), {}, channel\n .json_body['event'])\n", "events_after = channel.json_body['events_after']\n", "self.assertEqual(len(events_after), 2, events_after)\n", "self.assertDictEqual(events_after[0].get('content'), {}, events_after[0])\n", "self.assertEqual(events_after[1].get('content'), {}, events_after[1])\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 ]
[ "FunctionDef'", "Docstring", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def __init__(self, VAR_112):...\n", "\"\"\"docstring\"\"\"\n", "self.s = FUNC_45(CODE(VAR_112).xml())\n" ]
[ "def __init__(self, text):...\n", "\"\"\"docstring\"\"\"\n", "self.s = make_links(CODE(text).xml())\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'" ]
[ "def FUNC_10(VAR_2, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_36 = saved_model_utils.get_meta_graph_def(VAR_2, VAR_3)\n", "return VAR_36.signature_def\n" ]
[ "def get_signature_def_map(saved_model_dir, tag_set):...\n", "\"\"\"docstring\"\"\"\n", "meta_graph = saved_model_utils.get_meta_graph_def(saved_model_dir, tag_set)\n", "return meta_graph.signature_def\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_26(self, VAR_14, VAR_43=None):...\n", "self.tokens = self.block(VAR_14, VAR_43)\n", "self.tokens.reverse()\n", "self.inline.setup(self.block.def_links, self.block.def_footnotes)\n", "VAR_87 = self.renderer.placeholder()\n", "while self.pop():\n", "VAR_87 += self.tok()\n", "return VAR_87\n" ]
[ "def output(self, text, rules=None):...\n", "self.tokens = self.block(text, rules)\n", "self.tokens.reverse()\n", "self.inline.setup(self.block.def_links, self.block.def_footnotes)\n", "out = self.renderer.placeholder()\n", "while self.pop():\n", "out += self.tok()\n", "return out\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'", "Assign'", "Condition", "AugAssign'", "Return'" ]
[ "def FUNC_4(VAR_9, VAR_8, VAR_10):...\n", "return '<object id=\"{}\" src=\"{}\" />'.format(url_for('.get_object_id', VAR_9\n =start, VAR_8=span, VAR_10=video), url_for('.get_object', VAR_9=start,\n VAR_8=span, VAR_10=video))\n" ]
[ "def _get_object_element(start, span, video):...\n", "return '<object id=\"{}\" src=\"{}\" />'.format(url_for('.get_object_id', start\n =start, span=span, video=video), url_for('.get_object', start=start,\n span=span, video=video))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_5(self):...\n", "VAR_5 = self._makeContext()\n", "self.assertEqual(VAR_5.evaluate('one'), 1)\n" ]
[ "def test_evaluate_simple_path_binding(self):...\n", "ec = self._makeContext()\n", "self.assertEqual(ec.evaluate('one'), 1)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "VAR_80 = to_bytes(VAR_80, 'ascii', 'ignore')\n", "return base64.urlsafe_b64decode(VAR_80 + b'=' * (-len(VAR_80) % 4))\n" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "string = to_bytes(string, 'ascii', 'ignore')\n", "return base64.urlsafe_b64decode(string + b'=' * (-len(string) % 4))\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Return'" ]
[ "@login_required(isAdmin=True)...\n", "\"\"\"docstring\"\"\"\n", "if VAR_2.method == 'POST':\n", "VAR_8.setGroupNameForSession('system')\n", "VAR_244 = {'url': reverse('webgateway_su', VAR_116=[user]), 'submit': \n 'Do you want to su to %s' % VAR_38}\n", "VAR_175 = VAR_2.session['connector']\n", "VAR_230 = 'webgateway/base/includes/post_form.html'\n", "VAR_175 = Connector(VAR_175.server_id, VAR_175.is_secure)\n", "return render(VAR_2, VAR_230, VAR_244)\n", "VAR_242 = VAR_8.getSessionService().getSession(VAR_8._sessionUuid)\n", "VAR_243 = VAR_242.getTimeToIdle().val\n", "VAR_175.omero_session_key = VAR_8.suConn(VAR_38, VAR_243=ttl)._sessionUuid\n", "VAR_2.session['connector'] = VAR_175\n", "VAR_8.revertGroupForSession()\n", "VAR_8.close()\n", "return True\n" ]
[ "@login_required(isAdmin=True)...\n", "\"\"\"docstring\"\"\"\n", "if request.method == 'POST':\n", "conn.setGroupNameForSession('system')\n", "context = {'url': reverse('webgateway_su', args=[user]), 'submit': \n 'Do you want to su to %s' % user}\n", "connector = request.session['connector']\n", "template = 'webgateway/base/includes/post_form.html'\n", "connector = Connector(connector.server_id, connector.is_secure)\n", "return render(request, template, context)\n", "session = conn.getSessionService().getSession(conn._sessionUuid)\n", "ttl = session.getTimeToIdle().val\n", "connector.omero_session_key = conn.suConn(user, ttl=ttl)._sessionUuid\n", "request.session['connector'] = connector\n", "conn.revertGroupForSession()\n", "conn.close()\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "import datetime\n", "import logging\n", "import re\n", "from flask import abort, current_app, flash, g, redirect, request, session, url_for\n", "from flask_babel import lazy_gettext\n", "from flask_login import login_user, logout_user\n", "import jwt\n", "from werkzeug.security import generate_password_hash\n", "from wtforms import PasswordField, validators\n", "from wtforms.validators import EqualTo\n", "from .decorators import has_access\n", "from .forms import LoginForm_db, LoginForm_oid, ResetPasswordForm, UserInfoEdit\n", "from .._compat import as_unicode\n", "from ..actions import action\n", "from ..baseviews import BaseView\n", "from ..charts.views import DirectByChartView\n", "from ..fieldwidgets import BS3PasswordFieldWidget\n", "from ..utils.base import lazy_formatter_gettext\n", "from ..views import expose, ModelView, SimpleFormView\n", "from ..widgets import ListWidget, ShowWidget\n", "VAR_0 = logging.getLogger(__name__)\n", "VAR_2 = '/permissions'\n", "VAR_3 = ['can_list']\n", "VAR_4 = lazy_gettext('List Base Permissions')\n", "VAR_5 = lazy_gettext('Show Base Permission')\n", "VAR_6 = lazy_gettext('Add Base Permission')\n", "VAR_7 = lazy_gettext('Edit Base Permission')\n", "VAR_8 = {'name': lazy_gettext('Name')}\n", "VAR_2 = '/viewmenus'\n", "VAR_3 = ['can_list']\n", "VAR_4 = lazy_gettext('List View Menus')\n", "VAR_5 = lazy_gettext('Show View Menu')\n", "VAR_6 = lazy_gettext('Add View Menu')\n", "VAR_7 = lazy_gettext('Edit View Menu')\n", "VAR_8 = {'name': lazy_gettext('Name')}\n", "VAR_2 = '/permissionviews'\n", "VAR_3 = ['can_list']\n", "VAR_4 = lazy_gettext('List Permissions on Views/Menus')\n", "VAR_5 = lazy_gettext('Show Permission on Views/Menus')\n", "VAR_6 = lazy_gettext('Add Permission on Views/Menus')\n", "VAR_7 = lazy_gettext('Edit Permission on Views/Menus')\n", "VAR_8 = {'permission': lazy_gettext('Permission'), 'view_menu':\n lazy_gettext('View/Menu')}\n", "VAR_9 = ['permission', 'view_menu']\n", "\"\"\"\n View for resetting own user password\n \"\"\"\n", "VAR_2 = '/resetmypassword'\n", "VAR_10 = ResetPasswordForm\n", "VAR_11 = lazy_gettext('Reset Password Form')\n", "VAR_12 = '/'\n", "VAR_13 = lazy_gettext('Password Changed')\n", "def FUNC_1(self, VAR_10):...\n", "self.appbuilder.sm.reset_password(g.user.id, VAR_10.password.data)\n", "flash(as_unicode(self.message), 'info')\n", "\"\"\"\n View for reseting all users password\n \"\"\"\n", "VAR_2 = '/resetpassword'\n", "VAR_10 = ResetPasswordForm\n", "VAR_11 = lazy_gettext('Reset Password Form')\n", "VAR_12 = '/'\n", "VAR_13 = lazy_gettext('Password Changed')\n", "def FUNC_1(self, VAR_10):...\n", "VAR_23 = request.args.get('pk')\n", "self.appbuilder.sm.reset_password(VAR_23, VAR_10.password.data)\n", "flash(as_unicode(self.message), 'info')\n", "VAR_10 = UserInfoEdit\n", "VAR_11 = lazy_gettext('Edit User Information')\n", "VAR_12 = '/'\n", "VAR_13 = lazy_gettext('User information changed')\n", "def FUNC_2(self, VAR_10):...\n", "VAR_21 = self.appbuilder.sm.get_user_by_id(g.user.id)\n", "for key, value in VAR_10.data.items():\n", "if key == 'csrf_token':\n", "def FUNC_1(self, VAR_10):...\n", "VAR_48 = getattr(VAR_10, key)\n", "VAR_10 = self.form.refresh(request.form)\n", "VAR_48.data = getattr(VAR_21, key)\n", "VAR_21 = self.appbuilder.sm.get_user_by_id(g.user.id)\n", "VAR_10.populate_obj(VAR_21)\n", "self.appbuilder.sm.update_user(VAR_21)\n", "flash(as_unicode(self.message), 'info')\n", "def FUNC_0(VAR_1: str) ->str:...\n", "if current_app.config.get('AUTH_ROLES_SYNC_AT_LOGIN', False):\n", "VAR_1 += 'string'\n", "return VAR_1\n" ]
[ "import datetime\n", "import logging\n", "import re\n", "from flask import abort, current_app, flash, g, redirect, request, session, url_for\n", "from flask_babel import lazy_gettext\n", "from flask_login import login_user, logout_user\n", "import jwt\n", "from werkzeug.security import generate_password_hash\n", "from wtforms import PasswordField, validators\n", "from wtforms.validators import EqualTo\n", "from .decorators import has_access\n", "from .forms import LoginForm_db, LoginForm_oid, ResetPasswordForm, UserInfoEdit\n", "from .._compat import as_unicode\n", "from ..actions import action\n", "from ..baseviews import BaseView\n", "from ..charts.views import DirectByChartView\n", "from ..fieldwidgets import BS3PasswordFieldWidget\n", "from ..utils.base import lazy_formatter_gettext\n", "from ..views import expose, ModelView, SimpleFormView\n", "from ..widgets import ListWidget, ShowWidget\n", "log = logging.getLogger(__name__)\n", "route_base = '/permissions'\n", "base_permissions = ['can_list']\n", "list_title = lazy_gettext('List Base Permissions')\n", "show_title = lazy_gettext('Show Base Permission')\n", "add_title = lazy_gettext('Add Base Permission')\n", "edit_title = lazy_gettext('Edit Base Permission')\n", "label_columns = {'name': lazy_gettext('Name')}\n", "route_base = '/viewmenus'\n", "base_permissions = ['can_list']\n", "list_title = lazy_gettext('List View Menus')\n", "show_title = lazy_gettext('Show View Menu')\n", "add_title = lazy_gettext('Add View Menu')\n", "edit_title = lazy_gettext('Edit View Menu')\n", "label_columns = {'name': lazy_gettext('Name')}\n", "route_base = '/permissionviews'\n", "base_permissions = ['can_list']\n", "list_title = lazy_gettext('List Permissions on Views/Menus')\n", "show_title = lazy_gettext('Show Permission on Views/Menus')\n", "add_title = lazy_gettext('Add Permission on Views/Menus')\n", "edit_title = lazy_gettext('Edit Permission on Views/Menus')\n", "label_columns = {'permission': lazy_gettext('Permission'), 'view_menu':\n lazy_gettext('View/Menu')}\n", "list_columns = ['permission', 'view_menu']\n", "\"\"\"\n View for resetting own user password\n \"\"\"\n", "route_base = '/resetmypassword'\n", "form = ResetPasswordForm\n", "form_title = lazy_gettext('Reset Password Form')\n", "redirect_url = '/'\n", "message = lazy_gettext('Password Changed')\n", "def form_post(self, form):...\n", "self.appbuilder.sm.reset_password(g.user.id, form.password.data)\n", "flash(as_unicode(self.message), 'info')\n", "\"\"\"\n View for reseting all users password\n \"\"\"\n", "route_base = '/resetpassword'\n", "form = ResetPasswordForm\n", "form_title = lazy_gettext('Reset Password Form')\n", "redirect_url = '/'\n", "message = lazy_gettext('Password Changed')\n", "def form_post(self, form):...\n", "pk = request.args.get('pk')\n", "self.appbuilder.sm.reset_password(pk, form.password.data)\n", "flash(as_unicode(self.message), 'info')\n", "form = UserInfoEdit\n", "form_title = lazy_gettext('Edit User Information')\n", "redirect_url = '/'\n", "message = lazy_gettext('User information changed')\n", "def form_get(self, form):...\n", "item = self.appbuilder.sm.get_user_by_id(g.user.id)\n", "for key, value in form.data.items():\n", "if key == 'csrf_token':\n", "def form_post(self, form):...\n", "form_field = getattr(form, key)\n", "form = self.form.refresh(request.form)\n", "form_field.data = getattr(item, key)\n", "item = self.appbuilder.sm.get_user_by_id(g.user.id)\n", "form.populate_obj(item)\n", "self.appbuilder.sm.update_user(item)\n", "flash(as_unicode(self.message), 'info')\n", "def _roles_custom_formatter(string: str) ->str:...\n", "if current_app.config.get('AUTH_ROLES_SYNC_AT_LOGIN', False):\n", "string += (\n \". <div class='alert alert-warning' role='alert'>AUTH_ROLES_SYNC_AT_LOGIN is enabled, changes to this field will not persist between user logins.</div>\"\n )\n", "return string\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "For", "Condition", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Condition", "AugAssign'", "Return'" ]
[ "def FUNC_65(VAR_6):...\n", "return reverse('webgateway_render_thumbnail', VAR_116=(iid,))\n" ]
[ "def urlprefix(iid):...\n", "return reverse('webgateway_render_thumbnail', args=(iid,))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_12(self):...\n", "VAR_5 = self._makeContext()\n", "self.assertEqual(VAR_5.evaluate('d/_'), 'under')\n" ]
[ "def test_evaluate_dict_key_as_underscore(self):...\n", "ec = self._makeContext()\n", "self.assertEqual(ec.evaluate('d/_'), 'under')\n" ]
[ 0, 0, 1 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_0(self):...\n", "VAR_30 = []\n", "for VAR_33 in current_app.config.get('ACTIVE_PROVIDERS'):\n", "VAR_33 = VAR_33.lower()\n", "return VAR_30\n", "if VAR_33 == 'ping':\n", "VAR_30.append({'name': current_app.config.get('PING_NAME'), 'url':\n current_app.config.get('PING_REDIRECT_URI'), 'redirectUri': current_app\n .config.get('PING_REDIRECT_URI'), 'clientId': current_app.config.get(\n 'PING_CLIENT_ID'), 'responseType': 'code', 'scope': ['openid',\n 'profile', 'email'], 'scopeDelimiter': ' ', 'authorizationEndpoint':\n current_app.config.get('PING_AUTH_ENDPOINT'), 'requiredUrlParams': [\n 'scope'], 'type': '2.0'})\n", "if VAR_33 == 'google':\n", "VAR_38 = {'name': 'google', 'clientId': current_app.config.get(\n 'GOOGLE_CLIENT_ID'), 'url': VAR_1.url_for(CLASS_1, _external=True,\n _scheme='https'), 'redirectUri': VAR_1.url_for(CLASS_1, _external=True,\n _scheme='https'), 'authorizationEndpoint': current_app.config.get(\n 'GOOGLE_AUTH_ENDPOINT'), 'scope': ['openid email'], 'responseType': 'code'}\n", "if VAR_33 == 'onelogin':\n", "VAR_27 = current_app.config.get('GOOGLE_HOSTED_DOMAIN')\n", "VAR_30.append({'name': 'OneLogin', 'authorizationEndpoint': VAR_1.url_for(\n CLASS_2)})\n", "if VAR_27 is not None:\n", "VAR_38['hd'] = VAR_27\n", "VAR_30.append(VAR_38)\n" ]
[ "def get(self):...\n", "active_providers = []\n", "for provider in current_app.config.get('ACTIVE_PROVIDERS'):\n", "provider = provider.lower()\n", "return active_providers\n", "if provider == 'ping':\n", "active_providers.append({'name': current_app.config.get('PING_NAME'), 'url':\n current_app.config.get('PING_REDIRECT_URI'), 'redirectUri': current_app\n .config.get('PING_REDIRECT_URI'), 'clientId': current_app.config.get(\n 'PING_CLIENT_ID'), 'responseType': 'code', 'scope': ['openid',\n 'profile', 'email'], 'scopeDelimiter': ' ', 'authorizationEndpoint':\n current_app.config.get('PING_AUTH_ENDPOINT'), 'requiredUrlParams': [\n 'scope'], 'type': '2.0'})\n", "if provider == 'google':\n", "google_provider = {'name': 'google', 'clientId': current_app.config.get(\n 'GOOGLE_CLIENT_ID'), 'url': api.url_for(Google, _external=True, _scheme\n ='https'), 'redirectUri': api.url_for(Google, _external=True, _scheme=\n 'https'), 'authorizationEndpoint': current_app.config.get(\n 'GOOGLE_AUTH_ENDPOINT'), 'scope': ['openid email'], 'responseType': 'code'}\n", "if provider == 'onelogin':\n", "google_hosted_domain = current_app.config.get('GOOGLE_HOSTED_DOMAIN')\n", "active_providers.append({'name': 'OneLogin', 'authorizationEndpoint': api.\n url_for(OneLogin)})\n", "if google_hosted_domain is not None:\n", "google_provider['hd'] = google_hosted_domain\n", "active_providers.append(google_provider)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Assign'", "Return'", "Condition", "Expr'", "Condition", "Assign'", "Condition", "Assign'", "Expr'", "Condition", "Assign'", "Expr'" ]
[ "async def FUNC_2(*, VAR_0: Client, VAR_5: AModel) ->Union[None,...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = '{}/tests/json_body'.format(VAR_0.base_url)\n", "VAR_12: Dict[str, Any] = VAR_0.get_headers()\n", "VAR_8 = VAR_5.to_dict()\n", "VAR_11 = await _client.post(VAR_6=url, VAR_12=headers, json=json_json_body)\n", "if VAR_11.status_code == 200:\n", "return None\n", "if VAR_11.status_code == 422:\n", "return HTTPValidationError.from_dict(cast(Dict[str, Any], VAR_11.json()))\n" ]
[ "async def json_body_tests_json_body_post(*, client: Client, json_body: AModel...\n", "\"\"\"docstring\"\"\"\n", "url = '{}/tests/json_body'.format(client.base_url)\n", "headers: Dict[str, Any] = client.get_headers()\n", "json_json_body = json_body.to_dict()\n", "response = await _client.post(url=url, headers=headers, json=json_json_body)\n", "if response.status_code == 200:\n", "return None\n", "if response.status_code == 422:\n", "return HTTPValidationError.from_dict(cast(Dict[str, Any], response.json()))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "AnnAssign'", "Assign'", "Assign'", "Condition", "Return'", "Condition", "Return'" ]
[ "async def FUNC_18(VAR_24):...\n", "VAR_65 = await self.store.get_current_state_ids(VAR_24)\n", "VAR_40[VAR_24] = VAR_65\n" ]
[ "async def _fetch_room_state(room_id):...\n", "room_state = await self.store.get_current_state_ids(room_id)\n", "state_by_room[room_id] = room_state\n" ]
[ 0, 0, 0 ]
[ "AsyncFunctionDef'", "Assign'", "Assign'" ]
[ "def FUNC_25(VAR_46, VAR_47=None):...\n", "\"\"\"docstring\"\"\"\n", "return VAR_16.headers.get(VAR_46, VAR_47)\n" ]
[ "def get_request_header(key, default=None):...\n", "\"\"\"docstring\"\"\"\n", "return request.headers.get(key, default)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_0():...\n", "\"\"\"docstring\"\"\"\n", "VAR_53.session.save()\n", "VAR_40 = VAR_53.serving.request.hooks['before_finalize']\n", "VAR_41 = VAR_53.lib.sessions.save\n", "VAR_40[:] = [h for h in VAR_40 if h.callback is not VAR_41]\n" ]
[ "def _save_and_release_session():...\n", "\"\"\"docstring\"\"\"\n", "cherrypy.session.save()\n", "hooks = cherrypy.serving.request.hooks['before_finalize']\n", "forbidden = cherrypy.lib.sessions.save\n", "hooks[:] = [h for h in hooks if h.callback is not forbidden]\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_17(VAR_16, VAR_17, VAR_18):...\n", "\"\"\"docstring\"\"\"\n", "VAR_42 = {}\n", "VAR_43 = FUNC_13(VAR_16)\n", "VAR_44 = FUNC_14(VAR_17)\n", "VAR_45 = FUNC_15(VAR_18)\n", "for VAR_71, (filename, variable_name) in VAR_43.items():\n", "VAR_70 = np.load(file_io.FileIO(filename, mode='rb'), allow_pickle=True)\n", "for VAR_71, py_expr_evaluated in VAR_44.items():\n", "if variable_name:\n", "if VAR_71 in VAR_42:\n", "for VAR_71, VAR_41 in VAR_45.items():\n", "if isinstance(VAR_70, np.ndarray):\n", "if isinstance(VAR_70, np.lib.npyio.NpzFile):\n", "logging.warn('string' % VAR_71)\n", "VAR_42[VAR_71] = py_expr_evaluated\n", "if VAR_71 in VAR_42:\n", "return VAR_42\n", "logging.warn(\n 'Input file %s contains a single ndarray. Name key \"%s\" ignored.' % (\n filename, variable_name))\n", "if variable_name in VAR_70:\n", "VAR_80 = VAR_70.files\n", "VAR_42[VAR_71] = VAR_70\n", "logging.warn(\n 'input_key %s has been specified in multiple options. Value in --input_examples will be used.'\n % VAR_71)\n", "VAR_42[VAR_71] = VAR_41\n", "VAR_42[VAR_71] = VAR_70\n", "VAR_42[VAR_71] = VAR_70[variable_name]\n", "if len(VAR_80) != 1:\n", "VAR_42[VAR_71] = VAR_70[VAR_80[0]]\n" ]
[ "def load_inputs_from_input_arg_string(inputs_str, input_exprs_str,...\n", "\"\"\"docstring\"\"\"\n", "tensor_key_feed_dict = {}\n", "inputs = preprocess_inputs_arg_string(inputs_str)\n", "input_exprs = preprocess_input_exprs_arg_string(input_exprs_str)\n", "input_examples = preprocess_input_examples_arg_string(input_examples_str)\n", "for input_tensor_key, (filename, variable_name) in inputs.items():\n", "data = np.load(file_io.FileIO(filename, mode='rb'), allow_pickle=True)\n", "for input_tensor_key, py_expr_evaluated in input_exprs.items():\n", "if variable_name:\n", "if input_tensor_key in tensor_key_feed_dict:\n", "for input_tensor_key, example in input_examples.items():\n", "if isinstance(data, np.ndarray):\n", "if isinstance(data, np.lib.npyio.NpzFile):\n", "logging.warn(\n 'input_key %s has been specified with both --inputs and --input_exprs options. Value in --input_exprs will be used.'\n % input_tensor_key)\n", "tensor_key_feed_dict[input_tensor_key] = py_expr_evaluated\n", "if input_tensor_key in tensor_key_feed_dict:\n", "return tensor_key_feed_dict\n", "logging.warn(\n 'Input file %s contains a single ndarray. Name key \"%s\" ignored.' % (\n filename, variable_name))\n", "if variable_name in data:\n", "variable_name_list = data.files\n", "tensor_key_feed_dict[input_tensor_key] = data\n", "logging.warn(\n 'input_key %s has been specified in multiple options. Value in --input_examples will be used.'\n % input_tensor_key)\n", "tensor_key_feed_dict[input_tensor_key] = example\n", "tensor_key_feed_dict[input_tensor_key] = data\n", "tensor_key_feed_dict[input_tensor_key] = data[variable_name]\n", "if len(variable_name_list) != 1:\n", "tensor_key_feed_dict[input_tensor_key] = data[variable_name_list[0]]\n" ]
[ 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "For", "Condition", "Condition", "For", "Condition", "Condition", "Expr'", "Assign'", "Condition", "Return'", "Expr'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'" ]
[ "async def FUNC_4(self, VAR_10: MatrixFederationRequest, VAR_26: bool=False,...\n", "\"\"\"docstring\"\"\"\n", "VAR_11 = await self._send_request(VAR_10, **send_request_args)\n", "if not VAR_26:\n", "return VAR_11\n", "if VAR_13.code != 400 or VAR_13.to_synapse_error().errcode != 'M_UNRECOGNIZED':\n", "VAR_0.info('Retrying request with trailing slash')\n", "VAR_10 = VAR_60.evolve(VAR_10, VAR_16=request.path + '/')\n", "VAR_11 = await self._send_request(VAR_10, **send_request_args)\n" ]
[ "async def _send_request_with_optional_trailing_slash(self, request:...\n", "\"\"\"docstring\"\"\"\n", "response = await self._send_request(request, **send_request_args)\n", "if not try_trailing_slash_on_400:\n", "return response\n", "if e.code != 400 or e.to_synapse_error().errcode != 'M_UNRECOGNIZED':\n", "logger.info('Retrying request with trailing slash')\n", "request = attr.evolve(request, path=request.path + '/')\n", "response = await self._send_request(request, **send_request_args)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Condition", "Return'", "Condition", "Expr'", "Assign'", "Assign'" ]
[ "@FUNC_0...\n", "if self.config.worker_app:\n", "return WorkerServerNoticesSender(self)\n", "return ServerNoticesSender(self)\n" ]
[ "@cache_in_self...\n", "if self.config.worker_app:\n", "return WorkerServerNoticesSender(self)\n", "return ServerNoticesSender(self)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Condition", "Return'", "Return'" ]
[ "@defer.inlineCallbacks...\n", "self.hs.config.enable_set_avatar_url = False\n", "yield defer.ensureDeferred(self.store.set_profile_avatar_url(self.frank.\n localpart, 'http://my.server/me.png'))\n", "self.assertEquals((yield defer.ensureDeferred(self.store.\n get_profile_avatar_url(self.frank.localpart))), 'http://my.server/me.png')\n", "VAR_4 = defer.ensureDeferred(self.handler.set_avatar_url(self.frank,\n synapse.types.create_requester(self.frank), 'http://my.server/pic.gif'))\n", "yield self.assertFailure(VAR_4, SynapseError)\n" ]
[ "@defer.inlineCallbacks...\n", "self.hs.config.enable_set_avatar_url = False\n", "yield defer.ensureDeferred(self.store.set_profile_avatar_url(self.frank.\n localpart, 'http://my.server/me.png'))\n", "self.assertEquals((yield defer.ensureDeferred(self.store.\n get_profile_avatar_url(self.frank.localpart))), 'http://my.server/me.png')\n", "d = defer.ensureDeferred(self.handler.set_avatar_url(self.frank, synapse.\n types.create_requester(self.frank), 'http://my.server/pic.gif'))\n", "yield self.assertFailure(d, SynapseError)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "@login_required...\n", "VAR_2 = get_object_or_404(Comment, pk=comment_id)\n", "VAR_3 = FlagForm(user=request.user, VAR_2=comment, data=post_data(request))\n", "if is_post(VAR_0) and VAR_3.is_valid():\n", "VAR_3.save()\n", "return render(VAR_0=request, template_name=\n 'spirit/comment/flag/create.html', context={'form': form, 'comment':\n comment})\n", "return redirect(VAR_0.POST.get('next', VAR_2.get_absolute_url()))\n" ]
[ "@login_required...\n", "comment = get_object_or_404(Comment, pk=comment_id)\n", "form = FlagForm(user=request.user, comment=comment, data=post_data(request))\n", "if is_post(request) and form.is_valid():\n", "form.save()\n", "return render(request=request, template_name=\n 'spirit/comment/flag/create.html', context={'form': form, 'comment':\n comment})\n", "return redirect(request.POST.get('next', comment.get_absolute_url()))\n" ]
[ 0, 0, 0, 0, 0, 0, 4 ]
[ "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Return'", "Return'" ]
[ "def FUNC_23(self):...\n", "VAR_29 = coreapi.Document(VAR_5='', title='Example API', content={'users':\n {'create': coreapi.Link(url='/users/', action='post', fields=[]),\n 'list': coreapi.Link(url='/users/', action='get', fields=[]), 'read':\n coreapi.Link(url='/users/{id}/', action='get', fields=[coreapi.Field(\n 'id', required=True, location='path', schema=coreschema.String())]),\n 'update': coreapi.Link(url='/users/{id}/', action='patch', fields=[\n coreapi.Field('id', required=True, location='path', schema=coreschema.\n String())])}})\n", "VAR_30 = VAR_29['users']\n", "VAR_31 = schema_links(VAR_30)\n", "assert len(VAR_31) is 4\n", "assert 'list' in VAR_31\n", "assert 'create' in VAR_31\n", "assert 'read' in VAR_31\n", "assert 'update' in VAR_31\n" ]
[ "def test_default_actions(self):...\n", "schema = coreapi.Document(url='', title='Example API', content={'users': {\n 'create': coreapi.Link(url='/users/', action='post', fields=[]), 'list':\n coreapi.Link(url='/users/', action='get', fields=[]), 'read': coreapi.\n Link(url='/users/{id}/', action='get', fields=[coreapi.Field('id',\n required=True, location='path', schema=coreschema.String())]), 'update':\n coreapi.Link(url='/users/{id}/', action='patch', fields=[coreapi.Field(\n 'id', required=True, location='path', schema=coreschema.String())])}})\n", "section = schema['users']\n", "flat_links = schema_links(section)\n", "assert len(flat_links) is 4\n", "assert 'list' in flat_links\n", "assert 'create' in flat_links\n", "assert 'read' in flat_links\n", "assert 'update' in flat_links\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assert'", "Assert'", "Assert'", "Assert'", "Assert'" ]
[ "def FUNC_2(self):...\n", "return CLASS_2(self.worker_hs)\n" ]
[ "def _build_replication_data_handler(self):...\n", "return TestReplicationDataHandler(self.worker_hs)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_6(self, VAR_7='read', VAR_8=None):...\n", "\"\"\"docstring\"\"\"\n", "if not self.has_permission(VAR_7):\n", "self.raise_no_permission_to(VAR_8 or VAR_7)\n" ]
[ "def check_permission(self, permtype='read', permlevel=None):...\n", "\"\"\"docstring\"\"\"\n", "if not self.has_permission(permtype):\n", "self.raise_no_permission_to(permlevel or permtype)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'" ]
[ "@VAR_0.route('/stats')...\n", "VAR_4 = calibre_db.session.query(db.Books).count()\n", "VAR_5 = calibre_db.session.query(db.Authors).count()\n", "VAR_6 = calibre_db.session.query(db.Tags).count()\n", "VAR_7 = calibre_db.session.query(db.Series).count()\n", "return render_title_template('stats.html', bookcounter=counter,\n authorcounter=authors, versions=collect_stats(), categorycounter=\n categorys, seriecounter=series, title=_(u'Statistics'), page='stat')\n" ]
[ "@about.route('/stats')...\n", "counter = calibre_db.session.query(db.Books).count()\n", "authors = calibre_db.session.query(db.Authors).count()\n", "categorys = calibre_db.session.query(db.Tags).count()\n", "series = calibre_db.session.query(db.Series).count()\n", "return render_title_template('stats.html', bookcounter=counter,\n authorcounter=authors, versions=collect_stats(), categorycounter=\n categorys, seriecounter=series, title=_(u'Statistics'), page='stat')\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_38(self, VAR_44):...\n", "VAR_14 = VAR_44.group(2)\n", "return self.renderer.codespan(VAR_14)\n" ]
[ "def output_code(self, m):...\n", "text = m.group(2)\n", "return self.renderer.codespan(text)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_21(self, VAR_1):...\n", "VAR_5 = VAR_1.MagicMock()\n", "VAR_26 = VAR_1.MagicMock()\n", "VAR_23 = oai.Schema.construct(type='string', schema_format='date-time')\n", "VAR_36 = VAR_1.patch(f'{VAR_0}.DateTimeProperty')\n", "from openapi_python_client.parser.properties import _string_based_property\n", "VAR_4 = VAR_29(VAR_5=name, VAR_26=required, VAR_23=data)\n", "VAR_36.assert_called_once_with(VAR_5=name, VAR_26=required, default=None)\n", "assert VAR_4 == VAR_36.return_value\n", "VAR_36.reset_mock()\n", "VAR_23.default = VAR_1.MagicMock()\n", "VAR_29(VAR_5=name, VAR_26=required, VAR_23=data)\n", "VAR_36.assert_called_once_with(VAR_5=name, VAR_26=required, default=data.\n default)\n" ]
[ "def test__string_based_property_datetime_format(self, mocker):...\n", "name = mocker.MagicMock()\n", "required = mocker.MagicMock()\n", "data = oai.Schema.construct(type='string', schema_format='date-time')\n", "DateTimeProperty = mocker.patch(f'{MODULE_NAME}.DateTimeProperty')\n", "from openapi_python_client.parser.properties import _string_based_property\n", "p = _string_based_property(name=name, required=required, data=data)\n", "DateTimeProperty.assert_called_once_with(name=name, required=required,\n default=None)\n", "assert p == DateTimeProperty.return_value\n", "DateTimeProperty.reset_mock()\n", "data.default = mocker.MagicMock()\n", "_string_based_property(name=name, required=required, data=data)\n", "DateTimeProperty.assert_called_once_with(name=name, required=required,\n default=data.default)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "ImportFrom'", "Assign'", "Expr'", "Assert'", "Expr'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_2(self):...\n", "\"\"\"docstring\"\"\"\n", "if self._private:\n", "VAR_36 = objreg.get('ram-cookie-jar')\n", "VAR_36 = objreg.get('cookie-jar')\n", "self.setCookieJar(VAR_36)\n", "VAR_26 = QCoreApplication.instance()\n", "VAR_36.setParent(VAR_26)\n" ]
[ "def _set_cookiejar(self):...\n", "\"\"\"docstring\"\"\"\n", "if self._private:\n", "cookie_jar = objreg.get('ram-cookie-jar')\n", "cookie_jar = objreg.get('cookie-jar')\n", "self.setCookieJar(cookie_jar)\n", "app = QCoreApplication.instance()\n", "cookie_jar.setParent(app)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_6(VAR_11, VAR_12, VAR_5):...\n", "if VAR_5 == 'custom':\n", "if VAR_11.value != VAR_12:\n", "if VAR_5 == 'languages':\n", "VAR_11.value = VAR_12\n", "return VAR_11\n", "if VAR_11.lang_code != VAR_12:\n", "if VAR_5 == 'series':\n", "VAR_11.lang_code = VAR_12\n", "if VAR_11.name != VAR_12:\n", "if VAR_5 == 'author':\n", "VAR_11.name = VAR_12\n", "if VAR_11.name != VAR_12:\n", "if VAR_5 == 'publisher':\n", "VAR_11.sort = VAR_12\n", "VAR_11.name = VAR_12\n", "if VAR_11.name != VAR_12:\n", "if VAR_11.name != VAR_12:\n", "VAR_11.sort = VAR_12.replace('|', ',')\n", "VAR_11.name = VAR_12\n", "VAR_11.name = VAR_12\n", "VAR_11.sort = None\n" ]
[ "def create_objects_for_addition(db_element, add_element, db_type):...\n", "if db_type == 'custom':\n", "if db_element.value != add_element:\n", "if db_type == 'languages':\n", "db_element.value = add_element\n", "return db_element\n", "if db_element.lang_code != add_element:\n", "if db_type == 'series':\n", "db_element.lang_code = add_element\n", "if db_element.name != add_element:\n", "if db_type == 'author':\n", "db_element.name = add_element\n", "if db_element.name != add_element:\n", "if db_type == 'publisher':\n", "db_element.sort = add_element\n", "db_element.name = add_element\n", "if db_element.name != add_element:\n", "if db_element.name != add_element:\n", "db_element.sort = add_element.replace('|', ',')\n", "db_element.name = add_element\n", "db_element.name = add_element\n", "db_element.sort = None\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Condition", "Assign'", "Return'", "Condition", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_30(self, VAR_22='write'):...\n", "if not hasattr(self, '_has_access_to'):\n", "self._has_access_to = {}\n", "self._has_access_to[VAR_22] = []\n", "VAR_59 = frappe.get_roles()\n", "for perm in self.get_permissions():\n", "if perm.role in VAR_59 and perm.get(VAR_22):\n", "return self._has_access_to[VAR_22]\n", "if perm.permlevel not in self._has_access_to[VAR_22]:\n", "self._has_access_to[VAR_22].append(perm.permlevel)\n" ]
[ "def get_permlevel_access(self, permission_type='write'):...\n", "if not hasattr(self, '_has_access_to'):\n", "self._has_access_to = {}\n", "self._has_access_to[permission_type] = []\n", "roles = frappe.get_roles()\n", "for perm in self.get_permissions():\n", "if perm.role in roles and perm.get(permission_type):\n", "return self._has_access_to[permission_type]\n", "if perm.permlevel not in self._has_access_to[permission_type]:\n", "self._has_access_to[permission_type].append(perm.permlevel)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Assign'", "For", "Condition", "Return'", "Condition", "Expr'" ]
[ "@utils.skip_qt511...\n", "if not VAR_4.config.webengine:\n", "pytest.skip()\n", "VAR_11 = ['--temp-basedir', '--enable-webengine-inspector'] + FUNC_0(VAR_4.\n config)\n", "VAR_6.start(VAR_11)\n", "VAR_18 = VAR_6.wait_for(message=\n 'Remote debugging server started successfully. Try pointing a Chromium-based browser to http://127.0.0.1:*'\n )\n", "VAR_24 = int(VAR_18.message.split(':')[-1])\n", "VAR_25 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n", "VAR_25.connect(('127.0.0.1', VAR_24))\n", "VAR_25.close()\n" ]
[ "@utils.skip_qt511...\n", "if not request.config.webengine:\n", "pytest.skip()\n", "args = ['--temp-basedir', '--enable-webengine-inspector'] + _base_args(request\n .config)\n", "quteproc_new.start(args)\n", "line = quteproc_new.wait_for(message=\n 'Remote debugging server started successfully. Try pointing a Chromium-based browser to http://127.0.0.1:*'\n )\n", "port = int(line.message.split(':')[-1])\n", "s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n", "s.connect(('127.0.0.1', port))\n", "s.close()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'" ]