lines
sequencelengths
1
383
raw_lines
sequencelengths
1
383
label
sequencelengths
1
383
type
sequencelengths
1
383
[ "def FUNC_28(self):...\n", "return self._has_role(constants.ROLE_ANONYMOUS)\n" ]
[ "def role_anonymous(self):...\n", "return self._has_role(constants.ROLE_ANONYMOUS)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@require_POST...\n", "\"\"\"docstring\"\"\"\n", "VAR_19 = VAR_2.session['connector'].server_id\n", "VAR_64 = FUNC_13(VAR_2, VAR_6, VAR_19=server_id, VAR_8=conn, VAR_20=True)\n", "if VAR_64 is None:\n", "VAR_139 = 'false'\n", "VAR_58 = VAR_64[0]._conn.getEventContext().userId\n", "if VAR_2.GET.get('callback', None):\n", "webgateway_cache.invalidateObject(VAR_19, VAR_58, VAR_64[0])\n", "VAR_139 = '%s(%s)' % (VAR_2.GET['callback'], VAR_139)\n", "return HttpJavascriptResponse(VAR_139)\n", "VAR_64[0].getThumbnail()\n", "VAR_139 = 'true'\n" ]
[ "@require_POST...\n", "\"\"\"docstring\"\"\"\n", "server_id = request.session['connector'].server_id\n", "pi = _get_prepared_image(request, iid, server_id=server_id, conn=conn,\n saveDefs=True)\n", "if pi is None:\n", "json_data = 'false'\n", "user_id = pi[0]._conn.getEventContext().userId\n", "if request.GET.get('callback', None):\n", "webgateway_cache.invalidateObject(server_id, user_id, pi[0])\n", "json_data = '%s(%s)' % (request.GET['callback'], json_data)\n", "return HttpJavascriptResponse(json_data)\n", "pi[0].getThumbnail()\n", "json_data = 'true'\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Return'", "Expr'", "Assign'" ]
[ "def FUNC_157(VAR_262=False):...\n", "VAR_266 = VAR_153(VAR_364=session._cas_service, VAR_143=self.user.id)\n", "if VAR_266:\n", "VAR_264 = VAR_266.ticket\n", "VAR_264 = 'ST-' + web2py_uuid()\n", "VAR_364 = VAR_139._cas_service\n", "VAR_153.insert(VAR_364=session._cas_service, VAR_143=self.user.id, VAR_264=\n ticket, created_on=request.now, VAR_265=interactivelogin)\n", "VAR_365 = '&' if '?' in VAR_364 else '?'\n", "if 'warn' in VAR_56.vars and not VAR_262:\n", "VAR_244.headers['refresh'\n ] = '5;URL=%s' % VAR_364 + VAR_365 + 'ticket=' + VAR_264\n", "redirect(VAR_364 + VAR_365 + 'ticket=' + VAR_264)\n", "return A('Continue to %s' % VAR_364, _href=service + query_sep + 'ticket=' +\n ticket)\n" ]
[ "def allow_access(interactivelogin=False):...\n", "row = table(service=session._cas_service, user_id=self.user.id)\n", "if row:\n", "ticket = row.ticket\n", "ticket = 'ST-' + web2py_uuid()\n", "service = session._cas_service\n", "table.insert(service=session._cas_service, user_id=self.user.id, ticket=\n ticket, created_on=request.now, renew=interactivelogin)\n", "query_sep = '&' if '?' in service else '?'\n", "if 'warn' in request.vars and not interactivelogin:\n", "response.headers['refresh'\n ] = '5;URL=%s' % service + query_sep + 'ticket=' + ticket\n", "redirect(service + query_sep + 'ticket=' + ticket)\n", "return A('Continue to %s' % service, _href=service + query_sep + 'ticket=' +\n ticket)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Return'" ]
[ "@VAR_0.route('/admin/book/<int:book_id>', methods=['GET', 'POST'])...\n", "VAR_40 = False\n", "calibre_db.update_title_sort(config)\n", "VAR_1.debug_or_exception(e)\n", "if VAR_33.method != 'POST':\n", "calibre_db.session.rollback()\n", "return FUNC_14(VAR_14)\n", "VAR_16 = calibre_db.get_filtered_book(VAR_14, allow_show_archived=True)\n", "if not VAR_16:\n", "flash(_(\n u'Oops! Selected book title is unavailable. File does not exist or is not accessible'\n ), category='error')\n", "VAR_37 = FUNC_27(VAR_33, VAR_16, VAR_14)\n", "return redirect(url_for('web.index'))\n", "if FUNC_28(VAR_33, VAR_16) is True:\n", "VAR_16.has_cover = 1\n", "VAR_19 = VAR_33.form.to_dict()\n", "calibre_db.session.rollback()\n", "VAR_40 = True\n", "FUNC_32(VAR_19, VAR_37)\n", "flash(str(e), category='error')\n", "VAR_91 = None\n", "return redirect(url_for('web.show_book', VAR_14=book.id))\n", "VAR_92 = FUNC_29(VAR_16, VAR_19['book_title'])\n", "VAR_63, VAR_93 = FUNC_30(VAR_16, VAR_19['author_name'])\n", "if VAR_93 or VAR_92:\n", "VAR_91 = VAR_16.id\n", "if config.config_use_google_drive:\n", "VAR_40 = True\n", "gdriveutils.updateGdriveCalibreFromLocal()\n", "VAR_51 = False\n", "if VAR_91:\n", "VAR_51 = helper.update_dir_stucture(VAR_91, config.config_calibre_dir,\n VAR_63[0])\n", "if not VAR_51:\n", "if 'cover_url' in VAR_19:\n", "calibre_db.session.rollback()\n", "if VAR_19['cover_url']:\n", "VAR_40 |= FUNC_18(VAR_19['series_index'], VAR_16)\n", "flash(VAR_51, category='error')\n", "if not current_user.role_upload():\n", "VAR_40 |= FUNC_19(Markup(VAR_19['description']).unescape(), VAR_16)\n", "return FUNC_14(VAR_14)\n", "return '', 403\n", "if VAR_19['cover_url'].endswith('/static/generic_cover.jpg'):\n", "VAR_12 = FUNC_33(VAR_19, VAR_16)\n", "VAR_16.has_cover = 0\n", "VAR_69, VAR_51 = helper.save_cover_from_url(VAR_19['cover_url'], VAR_16.path)\n", "VAR_112, VAR_18 = FUNC_8(VAR_12, VAR_16.identifiers, calibre_db.session)\n", "if VAR_69 is True:\n", "if VAR_18:\n", "VAR_16.has_cover = 1\n", "flash(VAR_51, category='error')\n", "flash(_('Identifiers are not Case Sensitive, Overwriting Old Identifier'),\n category='warning')\n", "VAR_40 |= VAR_112\n", "VAR_40 = True\n", "VAR_40 |= FUNC_16(VAR_19['tags'], VAR_16)\n", "VAR_40 |= FUNC_17(VAR_19['series'], VAR_16)\n", "VAR_40 |= FUNC_21(VAR_19['publisher'], VAR_16)\n", "VAR_40 |= FUNC_20(VAR_19['languages'], VAR_16)\n", "VAR_40 |= FUNC_15(VAR_19, VAR_16)\n", "VAR_40 |= FUNC_25(VAR_14, VAR_16, VAR_19)\n", "if VAR_19['pubdate']:\n", "VAR_16.pubdate = db.Books.DEFAULT_PUBDATE\n", "VAR_16.pubdate = datetime.strptime(VAR_19['pubdate'], '%Y-%m-%d')\n", "VAR_16.pubdate = db.Books.DEFAULT_PUBDATE\n", "if VAR_40:\n", "VAR_16.last_modified = datetime.utcnow()\n", "calibre_db.session.merge(VAR_16)\n", "kobo_sync_status.remove_synced_book(VAR_91)\n", "calibre_db.session.commit()\n", "if config.config_use_google_drive:\n", "gdriveutils.updateGdriveCalibreFromLocal()\n", "if 'detail_view' in VAR_19:\n", "return redirect(url_for('web.show_book', VAR_14=book.id))\n", "flash(_('Metadata successfully updated'), category='success')\n", "return FUNC_14(VAR_14)\n" ]
[ "@editbook.route('/admin/book/<int:book_id>', methods=['GET', 'POST'])...\n", "modif_date = False\n", "calibre_db.update_title_sort(config)\n", "log.debug_or_exception(e)\n", "if request.method != 'POST':\n", "calibre_db.session.rollback()\n", "return render_edit_book(book_id)\n", "book = calibre_db.get_filtered_book(book_id, allow_show_archived=True)\n", "if not book:\n", "flash(_(\n u'Oops! Selected book title is unavailable. File does not exist or is not accessible'\n ), category='error')\n", "meta = upload_single_file(request, book, book_id)\n", "return redirect(url_for('web.index'))\n", "if upload_cover(request, book) is True:\n", "book.has_cover = 1\n", "to_save = request.form.to_dict()\n", "calibre_db.session.rollback()\n", "modif_date = True\n", "merge_metadata(to_save, meta)\n", "flash(str(e), category='error')\n", "edited_books_id = None\n", "return redirect(url_for('web.show_book', book_id=book.id))\n", "title_change = handle_title_on_edit(book, to_save['book_title'])\n", "input_authors, authorchange = handle_author_on_edit(book, to_save[\n 'author_name'])\n", "if authorchange or title_change:\n", "edited_books_id = book.id\n", "if config.config_use_google_drive:\n", "modif_date = True\n", "gdriveutils.updateGdriveCalibreFromLocal()\n", "error = False\n", "if edited_books_id:\n", "error = helper.update_dir_stucture(edited_books_id, config.\n config_calibre_dir, input_authors[0])\n", "if not error:\n", "if 'cover_url' in to_save:\n", "calibre_db.session.rollback()\n", "if to_save['cover_url']:\n", "modif_date |= edit_book_series_index(to_save['series_index'], book)\n", "flash(error, category='error')\n", "if not current_user.role_upload():\n", "modif_date |= edit_book_comments(Markup(to_save['description']).unescape(),\n book)\n", "return render_edit_book(book_id)\n", "return '', 403\n", "if to_save['cover_url'].endswith('/static/generic_cover.jpg'):\n", "input_identifiers = identifier_list(to_save, book)\n", "book.has_cover = 0\n", "result, error = helper.save_cover_from_url(to_save['cover_url'], book.path)\n", "modification, warning = modify_identifiers(input_identifiers, book.\n identifiers, calibre_db.session)\n", "if result is True:\n", "if warning:\n", "book.has_cover = 1\n", "flash(error, category='error')\n", "flash(_('Identifiers are not Case Sensitive, Overwriting Old Identifier'),\n category='warning')\n", "modif_date |= modification\n", "modif_date = True\n", "modif_date |= edit_book_tags(to_save['tags'], book)\n", "modif_date |= edit_book_series(to_save['series'], book)\n", "modif_date |= edit_book_publisher(to_save['publisher'], book)\n", "modif_date |= edit_book_languages(to_save['languages'], book)\n", "modif_date |= edit_book_ratings(to_save, book)\n", "modif_date |= edit_all_cc_data(book_id, book, to_save)\n", "if to_save['pubdate']:\n", "book.pubdate = db.Books.DEFAULT_PUBDATE\n", "book.pubdate = datetime.strptime(to_save['pubdate'], '%Y-%m-%d')\n", "book.pubdate = db.Books.DEFAULT_PUBDATE\n", "if modif_date:\n", "book.last_modified = datetime.utcnow()\n", "calibre_db.session.merge(book)\n", "kobo_sync_status.remove_synced_book(edited_books_id)\n", "calibre_db.session.commit()\n", "if config.config_use_google_drive:\n", "gdriveutils.updateGdriveCalibreFromLocal()\n", "if 'detail_view' in to_save:\n", "return redirect(url_for('web.show_book', book_id=book.id))\n", "flash(_('Metadata successfully updated'), category='success')\n", "return render_edit_book(book_id)\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 ]
[ "Condition", "Assign'", "Expr'", "Expr'", "Condition", "Expr'", "Return'", "Assign'", "Condition", "Expr'", "Assign'", "Return'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Return'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Expr'", "Condition", "AugAssign'", "Expr'", "Condition", "AugAssign'", "Return'", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Expr'", "Expr'", "AugAssign'", "Assign'", "AugAssign'", "AugAssign'", "AugAssign'", "AugAssign'", "AugAssign'", "AugAssign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "Expr'", "Condition", "Expr'", "Condition", "Return'", "Expr'", "Return'" ]
[ "@VAR_2.route('/oauth/google_callback', endpoint='callback')...\n", "VAR_14 = FUNC_0().authorized_response()\n", "VAR_3 = VAR_14['access_token']\n", "if VAR_3 is None:\n", "VAR_0.warning('Access token missing in call back request.')\n", "VAR_5 = FUNC_1(VAR_3)\n", "flash('Validation error. Please retry.')\n", "if VAR_5 is None:\n", "return redirect(url_for('redash.login'))\n", "flash('Validation error. Please retry.')\n", "if 'org_slug' in VAR_11:\n", "return redirect(url_for('redash.login'))\n", "VAR_4 = models.Organization.get_by_slug(VAR_11.pop('org_slug'))\n", "VAR_4 = current_org\n", "if not FUNC_2(VAR_4, VAR_5):\n", "VAR_0.warning('User tried to login with unauthorized domain name: %s (org: %s)'\n , VAR_5['email'], VAR_4)\n", "VAR_15 = '%s?sz=40' % VAR_5['picture']\n", "flash(\"Your Google Apps account ({}) isn't allowed.\".format(VAR_5['email']))\n", "VAR_16 = create_and_login_user(VAR_4, VAR_5['name'], VAR_5['email'], VAR_15)\n", "return redirect(url_for('redash.login', VAR_6=org.slug))\n", "if VAR_16 is None:\n", "return logout_and_redirect_to_index()\n", "VAR_17 = request.args.get('state') or url_for('redash.index', VAR_6=org.slug)\n", "VAR_13 = get_next_path(VAR_17)\n", "return redirect(VAR_13)\n" ]
[ "@blueprint.route('/oauth/google_callback', endpoint='callback')...\n", "resp = google_remote_app().authorized_response()\n", "access_token = resp['access_token']\n", "if access_token is None:\n", "logger.warning('Access token missing in call back request.')\n", "profile = get_user_profile(access_token)\n", "flash('Validation error. Please retry.')\n", "if profile is None:\n", "return redirect(url_for('redash.login'))\n", "flash('Validation error. Please retry.')\n", "if 'org_slug' in session:\n", "return redirect(url_for('redash.login'))\n", "org = models.Organization.get_by_slug(session.pop('org_slug'))\n", "org = current_org\n", "if not verify_profile(org, profile):\n", "logger.warning(\n 'User tried to login with unauthorized domain name: %s (org: %s)',\n profile['email'], org)\n", "picture_url = '%s?sz=40' % profile['picture']\n", "flash(\"Your Google Apps account ({}) isn't allowed.\".format(profile['email']))\n", "user = create_and_login_user(org, profile['name'], profile['email'],\n picture_url)\n", "return redirect(url_for('redash.login', org_slug=org.slug))\n", "if user is None:\n", "return logout_and_redirect_to_index()\n", "unsafe_next_path = request.args.get('state') or url_for('redash.index',\n org_slug=org.slug)\n", "next_path = get_next_path(unsafe_next_path)\n", "return redirect(next_path)\n" ]
[ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ]
[ "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Condition", "Return'", "Expr'", "Condition", "Return'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Assign'", "Return'", "Condition", "Return'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_30(self, VAR_8):...\n", "" ]
[ "def get(self, id):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_23(VAR_0, VAR_1, VAR_3):...\n", "VAR_15 = 'a' * 300\n", "assert os.pathconf('/', 'PC_NAME_MAX') < len(VAR_15)\n", "VAR_3.add(GET, 'https://example.com', f'<title>{VAR_15}</title>')\n", "VAR_9 = {'url': 'https://example.com', 'submit': 'true'}\n", "VAR_8 = VAR_1.post('/bookmarks/new', data=bookmark_data)\n", "assert VAR_8.status_code == 200\n" ]
[ "def test_bookmark_with_long_title_gets_truncated(test_app, client,...\n", "long_title = 'a' * 300\n", "assert os.pathconf('/', 'PC_NAME_MAX') < len(long_title)\n", "mocked_responses.add(GET, 'https://example.com', f'<title>{long_title}</title>'\n )\n", "bookmark_data = {'url': 'https://example.com', 'submit': 'true'}\n", "resp = client.post('/bookmarks/new', data=bookmark_data)\n", "assert resp.status_code == 200\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assert'", "Expr'", "Assign'", "Assign'", "Assert'" ]
[ "def FUNC_5(self):...\n", "self.add_change()\n", "VAR_4 = generate_counts(None, timezone.now() - timedelta(days=1), timezone.\n now() + timedelta(days=1), component=self.component)\n", "self.assertEqual(VAR_4, VAR_0)\n" ]
[ "def test_counts_one(self):...\n", "self.add_change()\n", "data = generate_counts(None, timezone.now() - timedelta(days=1), timezone.\n now() + timedelta(days=1), component=self.component)\n", "self.assertEqual(data, COUNTS_DATA)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_33(self):...\n", "return self.filter(VAR_78=True)\n" ]
[ "def public_followups(self):...\n", "return self.filter(public=True)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_10(VAR_2, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_33 = saved_model_utils.get_meta_graph_def(VAR_2, VAR_3)\n", "return VAR_33.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 __call__(self, VAR_14, VAR_43=None):...\n", "return self.output(VAR_14, VAR_43)\n" ]
[ "def __call__(self, text, rules=None):...\n", "return self.output(text, rules)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "async def FUNC_8(self):...\n", "VAR_36 = await self.get_resolved_spec()\n", "return f'https://doi.org/{VAR_36}'\n" ]
[ "async def get_resolved_ref_url(self):...\n", "resolved_spec = await self.get_resolved_spec()\n", "return f'https://doi.org/{resolved_spec}'\n" ]
[ 0, 0, 0 ]
[ "AsyncFunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_14(self, VAR_0):...\n", "VAR_13 = VAR_0.patch('httpx.get')\n", "VAR_15 = VAR_0.patch('yaml.safe_load', side_effect=yaml.YAMLError)\n", "from openapi_python_client import _get_document\n", "VAR_7 = VAR_0.MagicMock()\n", "VAR_11 = VAR_2(VAR_6=None, VAR_7=path)\n", "VAR_13.assert_not_called()\n", "VAR_7.read_bytes.assert_called_once()\n", "VAR_15.assert_called_once_with(VAR_7.read_bytes())\n", "assert VAR_11 == GeneratorError(header='Invalid YAML from provided source')\n" ]
[ "def test__get_document_bad_yaml(self, mocker):...\n", "get = mocker.patch('httpx.get')\n", "loads = mocker.patch('yaml.safe_load', side_effect=yaml.YAMLError)\n", "from openapi_python_client import _get_document\n", "path = mocker.MagicMock()\n", "result = _get_document(url=None, path=path)\n", "get.assert_not_called()\n", "path.read_bytes.assert_called_once()\n", "loads.assert_called_once_with(path.read_bytes())\n", "assert result == GeneratorError(header='Invalid YAML from provided source')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "ImportFrom'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assert'" ]
[ "def FUNC_86(VAR_123, VAR_86, VAR_124):...\n", "\"\"\"docstring\"\"\"\n", "VAR_185 = HttpResponse(content_type='text/csv')\n", "VAR_185['Content-Disposition'] = 'attachment; filename={0}'.format(unicode(\n VAR_123).encode('utf-8'))\n", "VAR_186 = VAR_26.writer(VAR_185, dialect='excel', quotechar='\"', quoting=\n csv.QUOTE_ALL)\n", "VAR_187 = [unicode(s).encode('utf-8') for s in VAR_86]\n", "VAR_186.writerow(VAR_187)\n", "for row in VAR_124:\n", "VAR_187 = [unicode(s).encode('utf-8') for s in row]\n", "return VAR_185\n", "VAR_186.writerow(VAR_187)\n" ]
[ "def csv_response(filename, header, rows):...\n", "\"\"\"docstring\"\"\"\n", "response = HttpResponse(content_type='text/csv')\n", "response['Content-Disposition'] = 'attachment; filename={0}'.format(unicode\n (filename).encode('utf-8'))\n", "writer = csv.writer(response, dialect='excel', quotechar='\"', quoting=csv.\n QUOTE_ALL)\n", "encoded = [unicode(s).encode('utf-8') for s in header]\n", "writer.writerow(encoded)\n", "for row in rows:\n", "encoded = [unicode(s).encode('utf-8') for s in row]\n", "return response\n", "writer.writerow(encoded)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "For", "Assign'", "Return'", "Expr'" ]
[ "def FUNC_7(VAR_8):...\n", "VAR_9 = FUNC_6(VAR_8)\n", "if VAR_8.view_args is not None:\n", "VAR_10 = VAR_8.view_args.get('query_id', None)\n", "VAR_12 = None\n", "VAR_12 = FUNC_5(VAR_9, VAR_10)\n", "return VAR_12\n" ]
[ "def api_key_load_user_from_request(request):...\n", "api_key = get_api_key_from_request(request)\n", "if request.view_args is not None:\n", "query_id = request.view_args.get('query_id', None)\n", "user = None\n", "user = get_user_from_api_key(api_key, query_id)\n", "return user\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def __repr__(self) ->str:...\n", "return util.repr_(self)\n" ]
[ "def __repr__(self) ->str:...\n", "return util.repr_(self)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_13(VAR_1):...\n", "VAR_81 = datetime.datetime.now()\n", "VAR_1.query(CLASS_16).filter(VAR_81 > CLASS_16.expiration).filter(CLASS_16.\n token_type != 1).delete()\n", "VAR_1.commit()\n" ]
[ "def clean_database(session):...\n", "now = datetime.datetime.now()\n", "session.query(RemoteAuthToken).filter(now > RemoteAuthToken.expiration).filter(\n RemoteAuthToken.token_type != 1).delete()\n", "session.commit()\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_8(VAR_11):...\n", "\"\"\"docstring\"\"\"\n", "VAR_52 = [char for char in string.ascii_uppercase + string.digits + string.\n ascii_lowercase if char not in 'aAeEiIoOuU1l']\n", "return string.join((random.choice(VAR_52) for VAR_72 in range(VAR_11)), '')\n" ]
[ "def generate_random_string(length):...\n", "\"\"\"docstring\"\"\"\n", "chars = [char for char in string.ascii_uppercase + string.digits + string.\n ascii_lowercase if char not in 'aAeEiIoOuU1l']\n", "return string.join((random.choice(chars) for __ in range(length)), '')\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_16(VAR_1):...\n", "VAR_6 = CLASS_1()\n", "VAR_6.name = 'Guest'\n", "VAR_6.email = 'no@email'\n", "VAR_6.role = constants.ROLE_ANONYMOUS\n", "VAR_6.password = ''\n", "VAR_1.add(VAR_6)\n", "VAR_1.commit()\n", "VAR_1.rollback()\n" ]
[ "def create_anonymous_user(session):...\n", "user = User()\n", "user.name = 'Guest'\n", "user.email = 'no@email'\n", "user.role = constants.ROLE_ANONYMOUS\n", "user.password = ''\n", "session.add(user)\n", "session.commit()\n", "session.rollback()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_5(VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_83(VAR_9, VAR_10):...\n", "VAR_38 = CourseKey.from_string(VAR_10)\n", "VAR_0.error(u'Unable to find course with course key %s', VAR_10)\n", "VAR_165 = auth.user_has_role(VAR_9.user, CourseSalesAdminRole(VAR_38))\n", "return HttpResponseNotFound()\n", "if VAR_165:\n", "return VAR_1(VAR_9, VAR_10)\n", "return HttpResponseForbidden()\n" ]
[ "def require_sales_admin(func):...\n", "\"\"\"docstring\"\"\"\n", "def wrapped(request, course_id):...\n", "course_key = CourseKey.from_string(course_id)\n", "log.error(u'Unable to find course with course key %s', course_id)\n", "access = auth.user_has_role(request.user, CourseSalesAdminRole(course_key))\n", "return HttpResponseNotFound()\n", "if access:\n", "return func(request, course_id)\n", "return HttpResponseForbidden()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Assign'", "Expr'", "Assign'", "Return'", "Condition", "Return'", "Return'" ]
[ "def FUNC_2(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_8 = Mock(spec=['put_json'])\n", "VAR_8.put_json.return_value = make_awaitable({})\n", "self.make_worker_hs('synapse.app.federation_sender', {'send_federation': \n True, 'worker_name': 'sender1', 'federation_sender_instances': [\n 'sender1', 'sender2']}, http_client=mock_client1)\n", "VAR_9 = Mock(spec=['put_json'])\n", "VAR_9.put_json.return_value = make_awaitable({})\n", "self.make_worker_hs('synapse.app.federation_sender', {'send_federation': \n True, 'worker_name': 'sender2', 'federation_sender_instances': [\n 'sender1', 'sender2']}, http_client=mock_client2)\n", "VAR_2 = self.register_user('user2', 'pass')\n", "VAR_3 = self.login('user2', 'pass')\n", "VAR_10 = False\n", "VAR_11 = False\n", "for i in range(20):\n", "VAR_22 = 'other_server_%d' % (i,)\n", "self.assertTrue(VAR_10)\n", "VAR_7 = self.create_room_with_remote_server(VAR_2, VAR_3, VAR_22)\n", "self.assertTrue(VAR_11)\n", "VAR_8.reset_mock()\n", "VAR_9.reset_mock()\n", "self.create_and_send_event(VAR_7, UserID.from_string(VAR_2))\n", "self.replicate()\n", "if VAR_8.put_json.called:\n", "VAR_10 = True\n", "if VAR_9.put_json.called:\n", "VAR_9.put_json.assert_not_called()\n", "VAR_11 = True\n", "if VAR_10 and VAR_11:\n", "self.assertEqual(VAR_8.put_json.call_args[0][0], VAR_22)\n", "VAR_8.put_json.assert_not_called()\n", "self.assertTrue(VAR_8.put_json.call_args[1]['data'].get('pdus'))\n", "self.assertEqual(VAR_9.put_json.call_args[0][0], VAR_22)\n", "self.assertTrue(VAR_9.put_json.call_args[1]['data'].get('pdus'))\n" ]
[ "def test_send_event_sharded(self):...\n", "\"\"\"docstring\"\"\"\n", "mock_client1 = Mock(spec=['put_json'])\n", "mock_client1.put_json.return_value = make_awaitable({})\n", "self.make_worker_hs('synapse.app.federation_sender', {'send_federation': \n True, 'worker_name': 'sender1', 'federation_sender_instances': [\n 'sender1', 'sender2']}, http_client=mock_client1)\n", "mock_client2 = Mock(spec=['put_json'])\n", "mock_client2.put_json.return_value = make_awaitable({})\n", "self.make_worker_hs('synapse.app.federation_sender', {'send_federation': \n True, 'worker_name': 'sender2', 'federation_sender_instances': [\n 'sender1', 'sender2']}, http_client=mock_client2)\n", "user = self.register_user('user2', 'pass')\n", "token = self.login('user2', 'pass')\n", "sent_on_1 = False\n", "sent_on_2 = False\n", "for i in range(20):\n", "server_name = 'other_server_%d' % (i,)\n", "self.assertTrue(sent_on_1)\n", "room = self.create_room_with_remote_server(user, token, server_name)\n", "self.assertTrue(sent_on_2)\n", "mock_client1.reset_mock()\n", "mock_client2.reset_mock()\n", "self.create_and_send_event(room, UserID.from_string(user))\n", "self.replicate()\n", "if mock_client1.put_json.called:\n", "sent_on_1 = True\n", "if mock_client2.put_json.called:\n", "mock_client2.put_json.assert_not_called()\n", "sent_on_2 = True\n", "if sent_on_1 and sent_on_2:\n", "self.assertEqual(mock_client1.put_json.call_args[0][0], server_name)\n", "mock_client1.put_json.assert_not_called()\n", "self.assertTrue(mock_client1.put_json.call_args[1]['data'].get('pdus'))\n", "self.assertEqual(mock_client2.put_json.call_args[0][0], server_name)\n", "self.assertTrue(mock_client2.put_json.call_args[1]['data'].get('pdus'))\n" ]
[ 0, 0, 0, 0, 4, 0, 0, 4, 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'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_84(VAR_72, *VAR_73):...\n", "def FUNC_86(self, VAR_25, *VAR_0, **VAR_1):...\n", "FUNC_83(self, VAR_72(self, *VAR_0, **kwargs))\n", "for VAR_6 in VAR_73:\n", "FUNC_83(self, VAR_6(self, VAR_25, *VAR_0, **kwargs))\n", "return self._return_value\n" ]
[ "def compose(fn, *hooks):...\n", "def runner(self, method, *args, **kwargs):...\n", "add_to_return_value(self, fn(self, *args, **kwargs))\n", "for f in hooks:\n", "add_to_return_value(self, f(self, method, *args, **kwargs))\n", "return self._return_value\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Expr'", "For", "Expr'", "Return'" ]
[ "async def FUNC_18(VAR_3):...\n", "VAR_3.write(b'response')\n", "VAR_3.finish()\n" ]
[ "async def callback(request):...\n", "request.write(b'response')\n", "request.finish()\n" ]
[ 0, 0, 0 ]
[ "AsyncFunctionDef'", "Expr'", "Expr'" ]
[ "def FUNC_0(VAR_2):...\n", "\"\"\"docstring\"\"\"\n" ]
[ "def SerializeError(Exception):...\n", "\"\"\"docstring\"\"\"\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Docstring" ]
[ "def FUNC_11(self):...\n", "super().after_script_executed()\n", "VAR_36, VAR_34 = tempfile.mkstemp(dir=self.temp_dir(), prefix=self.key)\n", "VAR_37 = self.file_path\n", "self.file_path = VAR_34\n", "VAR_0.info(f'Zipping {self.key} to {VAR_34}')\n", "self.file_path = shutil.make_archive(self.file_path, 'zip', VAR_37)\n", "VAR_0.info(f'Zip file created {self.file_path}')\n", "self.generate_download_link = True\n" ]
[ "def after_script_executed(self):...\n", "super().after_script_executed()\n", "fd, filename = tempfile.mkstemp(dir=self.temp_dir(), prefix=self.key)\n", "folder_path = self.file_path\n", "self.file_path = filename\n", "logger.info(f'Zipping {self.key} to {filename}')\n", "self.file_path = shutil.make_archive(self.file_path, 'zip', folder_path)\n", "logger.info(f'Zip file created {self.file_path}')\n", "self.generate_download_link = True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_29(self):...\n", "\"\"\"docstring\"\"\"\n", "if self.flags.ignore_permissions or frappe.flags.in_install:\n", "return\n", "if frappe.session.user == 'Administrator':\n", "return\n", "VAR_57 = self.get_permlevel_access()\n", "VAR_58 = self.meta.get_high_permlevel_fields()\n", "if VAR_58:\n", "self.reset_values_if_no_permlevel_access(VAR_57, VAR_58)\n", "if self.is_new():\n", "return\n", "for VAR_19 in self.meta.get_table_fields():\n", "VAR_58 = frappe.get_meta(VAR_19.options).get_high_permlevel_fields()\n", "if VAR_58:\n", "for VAR_21 in self.get(VAR_19.fieldname):\n", "VAR_21.reset_values_if_no_permlevel_access(VAR_57, VAR_58)\n" ]
[ "def validate_higher_perm_levels(self):...\n", "\"\"\"docstring\"\"\"\n", "if self.flags.ignore_permissions or frappe.flags.in_install:\n", "return\n", "if frappe.session.user == 'Administrator':\n", "return\n", "has_access_to = self.get_permlevel_access()\n", "high_permlevel_fields = self.meta.get_high_permlevel_fields()\n", "if high_permlevel_fields:\n", "self.reset_values_if_no_permlevel_access(has_access_to, high_permlevel_fields)\n", "if self.is_new():\n", "return\n", "for df in self.meta.get_table_fields():\n", "high_permlevel_fields = frappe.get_meta(df.options).get_high_permlevel_fields()\n", "if high_permlevel_fields:\n", "for d in self.get(df.fieldname):\n", "d.reset_values_if_no_permlevel_access(has_access_to, high_permlevel_fields)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "Return'", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Return'", "For", "Assign'", "Condition", "For", "Expr'" ]
[ "def FUNC_5(VAR_23, *VAR_24, **VAR_25):...\n", "VAR_66 = type(VAR_23)\n", "VAR_56 = fromstring(VAR_23)\n", "FUNC_4(VAR_56, *VAR_24, **kw)\n", "return _transform_result(VAR_66, VAR_56)\n" ]
[ "def word_break_html(html, *args, **kw):...\n", "result_type = type(html)\n", "doc = fromstring(html)\n", "word_break(doc, *args, **kw)\n", "return _transform_result(result_type, doc)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_0(VAR_4):...\n", "VAR_2 = VAR_4.indexdir\n", "VAR_3 = VAR_4.dataroot\n" ]
[ "def init(config):...\n", "INDEXDIR = config.indexdir\n", "DATAROOT = config.dataroot\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'" ]
[ "def FUNC_7(self, VAR_22):...\n", "VAR_29 = VAR_22.encode('utf-8')\n", "VAR_18 = FUNC_7(VAR_29, mode='eval')\n", "self.restricted_python_transformer.visit(VAR_18)\n", "self.page_templates_expression_transformer.visit(VAR_18)\n", "return VAR_18\n" ]
[ "def parse(self, string):...\n", "encoded = string.encode('utf-8')\n", "node = parse(encoded, mode='eval')\n", "self.restricted_python_transformer.visit(node)\n", "self.page_templates_expression_transformer.visit(node)\n", "return node\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_167(VAR_17):...\n", "\"\"\"docstring\"\"\"\n", "VAR_395 = set(VAR_17.keys())\n", "VAR_396 = set(['jsonrpc', 'method'])\n", "VAR_397 = VAR_396 - VAR_395\n", "if VAR_397:\n", "if VAR_17['jsonrpc'] != '2.0':\n", "if 'id' not in VAR_395:\n", "return False\n", "return True\n" ]
[ "def validate(data):...\n", "\"\"\"docstring\"\"\"\n", "iparms = set(data.keys())\n", "mandatory_args = set(['jsonrpc', 'method'])\n", "missing_args = mandatory_args - iparms\n", "if missing_args:\n", "if data['jsonrpc'] != '2.0':\n", "if 'id' not in iparms:\n", "return False\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Return'", "Return'" ]
[ "def __init__(self, VAR_8):...\n", "super().__init__(VAR_8)\n", "self.clock = VAR_8.get_clock()\n", "self.client = VAR_8.get_http_client()\n", "self.key_servers = self.config.key_servers\n" ]
[ "def __init__(self, hs):...\n", "super().__init__(hs)\n", "self.clock = hs.get_clock()\n", "self.client = hs.get_http_client()\n", "self.key_servers = self.config.key_servers\n" ]
[ 0, 0, 0, 4, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'" ]
[ "@app.route('/reconnect')...\n", "calibre_db.reconnect_db(config, ub.app_DB_path)\n", "return json.dumps({})\n" ]
[ "@app.route('/reconnect')...\n", "calibre_db.reconnect_db(config, ub.app_DB_path)\n", "return json.dumps({})\n" ]
[ 0, 0, 0 ]
[ "Condition", "Expr'", "Return'" ]
[ "def FUNC_7(self, VAR_3, VAR_4):...\n", "VAR_4['choices'] = map(lambda x: (x.strip(), x.strip()), VAR_3.choices.\n split(','))\n", "return django.forms.ChoiceField(**options)\n" ]
[ "def create_dropdown_field(self, field, options):...\n", "options['choices'] = map(lambda x: (x.strip(), x.strip()), field.choices.\n split(','))\n", "return django.forms.ChoiceField(**options)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_24(self):...\n", "self.parser = saved_model_cli.create_parser()\n", "VAR_9 = test.test_src_dir_path(VAR_0)\n", "VAR_44 = np.array([[1], [2]])\n", "VAR_45 = np.zeros((6, 3))\n", "VAR_31 = os.path.join(test.get_temp_dir(), 'testRunCommandNewOutdir_inputs.npz'\n )\n", "VAR_41 = os.path.join(test.get_temp_dir(), 'new_dir')\n", "if os.path.isdir(VAR_41):\n", "shutil.rmtree(VAR_41)\n", "np.savez(VAR_31, VAR_26=x, VAR_27=x_notused)\n", "VAR_10 = self.parser.parse_args(['run', '--dir', VAR_9, '--tag_set',\n 'serve', '--signature_def', 'serving_default', '--inputs', 'x=' +\n VAR_31 + '[x0]', '--outdir', VAR_41])\n", "saved_model_cli.run(VAR_10)\n", "VAR_42 = np.load(os.path.join(VAR_41, 'y.npy'))\n", "VAR_43 = np.array([[2.5], [3.0]])\n", "self.assertAllClose(VAR_43, VAR_42)\n" ]
[ "def testRunCommandNewOutdir(self):...\n", "self.parser = saved_model_cli.create_parser()\n", "base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n", "x = np.array([[1], [2]])\n", "x_notused = np.zeros((6, 3))\n", "input_path = os.path.join(test.get_temp_dir(),\n 'testRunCommandNewOutdir_inputs.npz')\n", "output_dir = os.path.join(test.get_temp_dir(), 'new_dir')\n", "if os.path.isdir(output_dir):\n", "shutil.rmtree(output_dir)\n", "np.savez(input_path, x0=x, x1=x_notused)\n", "args = self.parser.parse_args(['run', '--dir', base_path, '--tag_set',\n 'serve', '--signature_def', 'serving_default', '--inputs', 'x=' +\n input_path + '[x0]', '--outdir', output_dir])\n", "saved_model_cli.run(args)\n", "y_actual = np.load(os.path.join(output_dir, 'y.npy'))\n", "y_expected = np.array([[2.5], [3.0]])\n", "self.assertAllClose(y_expected, y_actual)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_7(VAR_2: Directive, VAR_13: int, VAR_5: int) ->str:...\n", "\"\"\"docstring\"\"\"\n", "VAR_25 = {VAR_6: VAR_2.meta[VAR_6] for VAR_6 in VAR_2.meta if not VAR_6.\n startswith('_')}\n", "VAR_2 = VAR_2._replace(VAR_25=meta)\n", "VAR_26 = align(format_entry(VAR_2, prefix=' ' * indent), VAR_13)\n", "VAR_26 = VAR_26.replace(\"<class 'beancount.core.number.MISSING'>\", '')\n", "return '\\n'.join(VAR_33.rstrip() for VAR_33 in VAR_26.split('\\n'))\n" ]
[ "def _format_entry(entry: Directive, currency_column: int, indent: int) ->str:...\n", "\"\"\"docstring\"\"\"\n", "meta = {key: entry.meta[key] for key in entry.meta if not key.startswith('_')}\n", "entry = entry._replace(meta=meta)\n", "string = align(format_entry(entry, prefix=' ' * indent), currency_column)\n", "string = string.replace(\"<class 'beancount.core.number.MISSING'>\", '')\n", "return '\\n'.join(line.rstrip() for line in string.split('\\n'))\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_54(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_54 = json.dumps({'search_categories': {'room_events': {'search_term':\n 'label', 'filter': self.FILTER_LABELS}}})\n", "self._send_labelled_messages_in_room()\n", "VAR_22, VAR_23 = self.make_request('POST', '/search?access_token=%s' % self\n .tok, VAR_54)\n", "VAR_49 = VAR_23.json_body['search_categories']['room_events']['results']\n", "self.assertEqual(len(VAR_49), 2, [result['result']['content'] for result in\n VAR_49])\n", "self.assertEqual(VAR_49[0]['result']['content']['body'], 'with right label',\n VAR_49[0]['result']['content']['body'])\n", "self.assertEqual(VAR_49[1]['result']['content']['body'], 'with right label',\n VAR_49[1]['result']['content']['body'])\n" ]
[ "def test_search_filter_labels(self):...\n", "\"\"\"docstring\"\"\"\n", "request_data = json.dumps({'search_categories': {'room_events': {\n 'search_term': 'label', 'filter': self.FILTER_LABELS}}})\n", "self._send_labelled_messages_in_room()\n", "request, channel = self.make_request('POST', '/search?access_token=%s' %\n self.tok, request_data)\n", "results = channel.json_body['search_categories']['room_events']['results']\n", "self.assertEqual(len(results), 2, [result['result']['content'] for result in\n results])\n", "self.assertEqual(results[0]['result']['content']['body'],\n 'with right label', results[0]['result']['content']['body'])\n", "self.assertEqual(results[1]['result']['content']['body'],\n 'with right label', results[1]['result']['content']['body'])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_14():...\n", "VAR_43 = f.readline()\n", "VAR_43 = '/'.join(VAR_43.split('/')[:-2])\n", "VAR_33 = []\n", "for c in VAR_32:\n", "VAR_33.append(FUNC_10(VAR_43 + '/' + c.strip()))\n", "return VAR_33\n" ]
[ "def get_class_path():...\n", "dataset_path = f.readline()\n", "dataset_path = '/'.join(dataset_path.split('/')[:-2])\n", "class_paths = []\n", "for c in classes_list:\n", "class_paths.append(_get_obj_absolute_path(dataset_path + '/' + c.strip()))\n", "return class_paths\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "For", "Expr'", "Return'" ]
[ "def FUNC_2(VAR_6):...\n", "return chain(*get_provide_objects(VAR_6))\n" ]
[ "def _get_extension_urlpatterns(provide_category):...\n", "return chain(*get_provide_objects(provide_category))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_37(self, VAR_15):...\n", "VAR_76 = VAR_53.session['userid'] == VAR_15\n", "if VAR_53.session['admin'] and not VAR_76:\n", "VAR_109 = self.userdb.deleteUser(VAR_15)\n", "return \"You didn't think that would work, did you?\"\n", "return 'success' if VAR_109 else 'failed'\n" ]
[ "def api_userdelete(self, userid):...\n", "is_self = cherrypy.session['userid'] == userid\n", "if cherrypy.session['admin'] and not is_self:\n", "deleted = self.userdb.deleteUser(userid)\n", "return \"You didn't think that would work, did you?\"\n", "return 'success' if deleted else 'failed'\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Return'", "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.GET.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.GET.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, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 ]
[ "FunctionDef'", "FunctionDef'", "Assign'", "Assign'", "For", "Assign'", "Condition", "Condition", "Return'", "Return'", "Expr'", "Assign'" ]
[ "def FUNC_21(VAR_12, VAR_13, VAR_14, VAR_16):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_12 == 'experimenter':\n", "if VAR_14 == 'dataset' or VAR_14 == 'plate':\n", "if VAR_12 == 'project':\n", "return 'orphan'\n", "VAR_254 = ProjectI(VAR_241(VAR_13), False)\n", "if VAR_12 == 'dataset':\n", "if VAR_14 == 'dataset':\n", "VAR_343 = DatasetI(VAR_241(VAR_13), False)\n", "if VAR_12 == 'screen':\n", "VAR_343 = DatasetI(VAR_241(VAR_16), False)\n", "return None\n", "if VAR_14 == 'image':\n", "VAR_384 = ScreenI(VAR_241(VAR_13), False)\n", "if VAR_12 == 'tagset':\n", "VAR_344 = ProjectDatasetLinkI()\n", "VAR_142 = ImageI(VAR_241(VAR_16), False)\n", "if VAR_14 == 'plate':\n", "if VAR_14 == 'tag':\n", "VAR_344.setParent(VAR_254)\n", "VAR_344 = DatasetImageLinkI()\n", "VAR_421 = PlateI(VAR_241(VAR_16), False)\n", "VAR_344 = AnnotationAnnotationLinkI()\n", "VAR_344.setChild(VAR_343)\n", "VAR_344.setParent(VAR_343)\n", "VAR_344 = ScreenPlateLinkI()\n", "VAR_344.setParent(TagAnnotationI(VAR_241(VAR_13), False))\n", "return VAR_344\n", "VAR_344.setChild(VAR_142)\n", "VAR_344.setParent(VAR_384)\n", "VAR_344.setChild(TagAnnotationI(VAR_241(VAR_16), False))\n", "return VAR_344\n", "VAR_344.setChild(VAR_421)\n", "return VAR_344\n", "return VAR_344\n" ]
[ "def create_link(parent_type, parent_id, child_type, child_id):...\n", "\"\"\"docstring\"\"\"\n", "if parent_type == 'experimenter':\n", "if child_type == 'dataset' or child_type == 'plate':\n", "if parent_type == 'project':\n", "return 'orphan'\n", "project = ProjectI(long(parent_id), False)\n", "if parent_type == 'dataset':\n", "if child_type == 'dataset':\n", "dataset = DatasetI(long(parent_id), False)\n", "if parent_type == 'screen':\n", "dataset = DatasetI(long(child_id), False)\n", "return None\n", "if child_type == 'image':\n", "screen = ScreenI(long(parent_id), False)\n", "if parent_type == 'tagset':\n", "link = ProjectDatasetLinkI()\n", "image = ImageI(long(child_id), False)\n", "if child_type == 'plate':\n", "if child_type == 'tag':\n", "link.setParent(project)\n", "link = DatasetImageLinkI()\n", "plate = PlateI(long(child_id), False)\n", "link = AnnotationAnnotationLinkI()\n", "link.setChild(dataset)\n", "link.setParent(dataset)\n", "link = ScreenPlateLinkI()\n", "link.setParent(TagAnnotationI(long(parent_id), False))\n", "return link\n", "link.setChild(image)\n", "link.setParent(screen)\n", "link.setChild(TagAnnotationI(long(child_id), False))\n", "return link\n", "link.setChild(plate)\n", "return link\n", "return link\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 ]
[ "FunctionDef'", "Docstring", "Condition", "Condition", "Condition", "Return'", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Return'", "Expr'", "Expr'", "Expr'", "Return'", "Expr'", "Return'", "Return'" ]
[ "@VAR_0.route('/ajax/simulatemerge', methods=['POST'])...\n", "VAR_81 = VAR_33.get_json().get('Merge_books')\n", "if VAR_81:\n", "VAR_99 = calibre_db.get_book(VAR_81[0]).title\n", "return ''\n", "VAR_81.pop(0)\n", "if VAR_99:\n", "for VAR_14 in VAR_81:\n", "VAR_118 = []\n", "return json.dumps({'to': VAR_99, 'from': VAR_118})\n", "VAR_118.append(calibre_db.get_book(VAR_14).title)\n" ]
[ "@editbook.route('/ajax/simulatemerge', methods=['POST'])...\n", "vals = request.get_json().get('Merge_books')\n", "if vals:\n", "to_book = calibre_db.get_book(vals[0]).title\n", "return ''\n", "vals.pop(0)\n", "if to_book:\n", "for book_id in vals:\n", "from_book = []\n", "return json.dumps({'to': to_book, 'from': from_book})\n", "from_book.append(calibre_db.get_book(book_id).title)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Assign'", "Return'", "Expr'", "Condition", "For", "Assign'", "Return'", "Expr'" ]
[ "def FUNC_7(self):...\n", "if self.is_standard == 'Yes' and not cint(getattr(frappe.local.conf,\n", "frappe.throw(_('You are not allowed to delete Standard Report'))\n", "delete_custom_role('report', self.name)\n" ]
[ "def on_trash(self):...\n", "if self.is_standard == 'Yes' and not cint(getattr(frappe.local.conf,\n", "frappe.throw(_('You are not allowed to delete Standard Report'))\n", "delete_custom_role('report', self.name)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_6(self):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_15(VAR_3, **VAR_4):...\n", "return 200, {'result': True}\n" ]
[ "def test_head_request(self):...\n", "\"\"\"docstring\"\"\"\n", "def _callback(request, **kwargs):...\n", "return 200, {'result': True}\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Return'" ]
[ "@handle_dashboard_error...\n", "\"\"\"docstring\"\"\"\n", "VAR_65 = get_course_by_id(SlashSeparatedCourseKey.from_deprecated_string(\n VAR_10))\n", "VAR_36 = find_unit(VAR_65, VAR_9.GET.get('url'))\n", "return JsonResponse(dump_module_extensions(VAR_65, VAR_36))\n" ]
[ "@handle_dashboard_error...\n", "\"\"\"docstring\"\"\"\n", "course = get_course_by_id(SlashSeparatedCourseKey.from_deprecated_string(\n course_id))\n", "unit = find_unit(course, request.GET.get('url'))\n", "return JsonResponse(dump_module_extensions(course, unit))\n" ]
[ 0, 0, 0, 3, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Return'" ]
[ "from __future__ import unicode_literals\n", "import frappe\n", "from frappe import _\n", "import frappe.utils\n", "import frappe.sessions\n", "import frappe.desk.form.run_method\n", "from frappe.utils.response import build_response\n", "from frappe.api import validate_auth\n", "from frappe.utils import cint\n", "from frappe.core.doctype.server_script.server_script_utils import run_server_script_api\n", "from werkzeug.wrappers import Response\n", "from six import string_types\n", "VAR_0 = ('image/png', 'image/jpeg', 'application/pdf', 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'application/vnd.ms-excel',\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.oasis.opendocument.text',\n 'application/vnd.oasis.opendocument.spreadsheet')\n", "def FUNC_0():...\n", "\"\"\"docstring\"\"\"\n", "validate_auth()\n", "VAR_1 = VAR_25.local.form_dict.cmd\n", "VAR_12 = None\n", "if VAR_1 != 'login':\n", "VAR_12 = FUNC_1(VAR_1)\n", "if VAR_12 is not None:\n", "if isinstance(VAR_12, Response):\n", "return build_response('json')\n", "return VAR_12\n", "VAR_25.response['message'] = VAR_12\n" ]
[ "from __future__ import unicode_literals\n", "import frappe\n", "from frappe import _\n", "import frappe.utils\n", "import frappe.sessions\n", "import frappe.desk.form.run_method\n", "from frappe.utils.response import build_response\n", "from frappe.api import validate_auth\n", "from frappe.utils import cint\n", "from frappe.core.doctype.server_script.server_script_utils import run_server_script_api\n", "from werkzeug.wrappers import Response\n", "from six import string_types\n", "ALLOWED_MIMETYPES = ('image/png', 'image/jpeg', 'application/pdf',\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'application/vnd.ms-excel',\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'application/vnd.oasis.opendocument.text',\n 'application/vnd.oasis.opendocument.spreadsheet')\n", "def handle():...\n", "\"\"\"docstring\"\"\"\n", "validate_auth()\n", "cmd = frappe.local.form_dict.cmd\n", "data = None\n", "if cmd != 'login':\n", "data = execute_cmd(cmd)\n", "if data is not None:\n", "if isinstance(data, Response):\n", "return build_response('json')\n", "return data\n", "frappe.response['message'] = data\n" ]
[ 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Import'", "ImportFrom'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Return'", "Return'", "Assign'" ]
[ "from __future__ import unicode_literals\n", "import inspect\n", "import json\n", "import six\n", "import warnings\n", "from django.conf import settings\n", "from django.contrib.auth.views import redirect_to_login\n", "from django.core.exceptions import ImproperlyConfigured\n", "from django.http.response import HttpResponseForbidden\n", "from django.utils.encoding import force_str, force_text\n", "from django.utils.http import urlencode\n", "from django.utils.translation import ugettext_lazy as _\n", "from shuup.admin.module_registry import get_modules\n", "from shuup.admin.shop_provider import get_shop\n", "from shuup.admin.utils.permissions import get_missing_permissions\n", "from shuup.utils import importing\n", "from shuup.utils.django_compat import NoReverseMatch, URLPattern, get_callable, is_authenticated, reverse\n", "from shuup.utils.excs import Problem\n", "from urllib.parse import parse_qsl\n", "from urlparse import parse_qsl\n", "def __init__(self, VAR_0, VAR_22, VAR_23=None, VAR_3=None, VAR_5=True, VAR_6=()...\n", "self.permissions = tuple(VAR_6)\n", "self.require_authentication = VAR_5\n", "if callable(VAR_22):\n", "VAR_22 = self.wrap_with_permissions(VAR_22)\n", "from django.urls import re_path\n", "VAR_30 = re_path(VAR_0, VAR_22, VAR_23, VAR_3)\n", "VAR_31 = VAR_30.pattern\n", "super(CLASS_0, self).__init__(VAR_31, VAR_22, VAR_23, VAR_3)\n", "def FUNC_7(self, VAR_20, VAR_24):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_20.is_ajax():\n", "return HttpResponseForbidden(json.dumps({'error': force_text(VAR_24)}))\n", "VAR_32 = urlencode({'error': force_text(VAR_24)})\n", "VAR_33 = force_str(reverse('shuup_admin:login') + '?' + VAR_32)\n", "VAR_34 = redirect_to_login(next=request.path, VAR_33=login_url)\n", "if is_authenticated(VAR_20.user):\n", "return VAR_34\n" ]
[ "from __future__ import unicode_literals\n", "import inspect\n", "import json\n", "import six\n", "import warnings\n", "from django.conf import settings\n", "from django.contrib.auth.views import redirect_to_login\n", "from django.core.exceptions import ImproperlyConfigured\n", "from django.http.response import HttpResponseForbidden\n", "from django.utils.encoding import force_str, force_text\n", "from django.utils.http import urlencode\n", "from django.utils.translation import ugettext_lazy as _\n", "from shuup.admin.module_registry import get_modules\n", "from shuup.admin.shop_provider import get_shop\n", "from shuup.admin.utils.permissions import get_missing_permissions\n", "from shuup.utils import importing\n", "from shuup.utils.django_compat import NoReverseMatch, URLPattern, get_callable, is_authenticated, reverse\n", "from shuup.utils.excs import Problem\n", "from urllib.parse import parse_qsl\n", "from urlparse import parse_qsl\n", "def __init__(self, regex, callback, default_args=None, name=None,...\n", "self.permissions = tuple(permissions)\n", "self.require_authentication = require_authentication\n", "if callable(callback):\n", "callback = self.wrap_with_permissions(callback)\n", "from django.urls import re_path\n", "repath = re_path(regex, callback, default_args, name)\n", "pattern = repath.pattern\n", "super(AdminRegexURLPattern, self).__init__(pattern, callback, default_args,\n name)\n", "def _get_unauth_response(self, request, reason):...\n", "\"\"\"docstring\"\"\"\n", "if request.is_ajax():\n", "return HttpResponseForbidden(json.dumps({'error': force_text(reason)}))\n", "error_params = urlencode({'error': force_text(reason)})\n", "login_url = force_str(reverse('shuup_admin:login') + '?' + error_params)\n", "resp = redirect_to_login(next=request.path, login_url=login_url)\n", "if is_authenticated(request.user):\n", "return resp\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 ]
[ "ImportFrom'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "ImportFrom'", "Assign'", "Assign'", "Expr'", "FunctionDef'", "Docstring", "Condition", "Return'", "Assign'", "Assign'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_5():...\n", "return VAR_10\n" ]
[ "def getEngine():...\n", "return _engine\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@VAR_2.route('/get_update_status', methods=['GET'])...\n", "if VAR_1['updater']:\n", "VAR_0.info(u'Update status requested')\n", "return ''\n", "return updater_thread.get_available_updates(request.method, VAR_58=get_locale()\n )\n" ]
[ "@admi.route('/get_update_status', methods=['GET'])...\n", "if feature_support['updater']:\n", "log.info(u'Update status requested')\n", "return ''\n", "return updater_thread.get_available_updates(request.method, locale=get_locale()\n )\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Expr'", "Return'", "Return'" ]
[ "def FUNC_12(self):...\n", "VAR_20 = (\n 'inputx=C:\\\\Program Files\\\\data.npz[v:0];input:0=c:\\\\PROGRA~1\\\\data.npy')\n", "VAR_22 = saved_model_cli.preprocess_inputs_arg_string(VAR_20)\n", "self.assertTrue(VAR_22['inputx'] == ('C:\\\\Program Files\\\\data.npz', 'v:0'))\n", "self.assertTrue(VAR_22['input:0'] == ('c:\\\\PROGRA~1\\\\data.npy', None))\n" ]
[ "def testInputPreProcessFileNames(self):...\n", "input_str = (\n 'inputx=C:\\\\Program Files\\\\data.npz[v:0];input:0=c:\\\\PROGRA~1\\\\data.npy')\n", "input_dict = saved_model_cli.preprocess_inputs_arg_string(input_str)\n", "self.assertTrue(input_dict['inputx'] == ('C:\\\\Program Files\\\\data.npz', 'v:0'))\n", "self.assertTrue(input_dict['input:0'] == ('c:\\\\PROGRA~1\\\\data.npy', None))\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_10(self):...\n", "\"\"\"docstring\"\"\"\n", "self._record_users()\n", "VAR_15 = {'display_name': 'a' * (synapse.handlers.device.\n MAX_DEVICE_DISPLAY_NAME_LEN + 1)}\n", "self.get_failure(self.handler.update_device(VAR_0, 'abc', VAR_15), synapse.\n api.errors.SynapseError)\n", "VAR_10 = self.get_success(self.handler.get_device(VAR_0, 'abc'))\n", "self.assertEqual(VAR_10['display_name'], 'display 2')\n" ]
[ "def test_update_device_too_long_display_name(self):...\n", "\"\"\"docstring\"\"\"\n", "self._record_users()\n", "update = {'display_name': 'a' * (synapse.handlers.device.\n MAX_DEVICE_DISPLAY_NAME_LEN + 1)}\n", "self.get_failure(self.handler.update_device(user1, 'abc', update), synapse.\n api.errors.SynapseError)\n", "res = self.get_success(self.handler.get_device(user1, 'abc'))\n", "self.assertEqual(res['display_name'], 'display 2')\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "@VAR_1.route('/<bfile>/download-journal/')...\n", "\"\"\"docstring\"\"\"\n", "VAR_31 = datetime.datetime.now().replace(microsecond=0)\n", "VAR_10 = f'journal_{VAR_31.isoformat()}.beancount'\n", "VAR_30 = BytesIO(bytes(render_template('beancount_file'), 'utf8'))\n", "return send_file(VAR_30, as_attachment=True, download_name=filename)\n" ]
[ "@app.route('/<bfile>/download-journal/')...\n", "\"\"\"docstring\"\"\"\n", "now = datetime.datetime.now().replace(microsecond=0)\n", "filename = f'journal_{now.isoformat()}.beancount'\n", "data = BytesIO(bytes(render_template('beancount_file'), 'utf8'))\n", "return send_file(data, as_attachment=True, download_name=filename)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "async def FUNC_14(self, VAR_19):...\n", "VAR_38 = await self.store.get_remote_media_before(VAR_19)\n", "VAR_39 = 0\n", "for media in VAR_38:\n", "VAR_47 = media['media_origin']\n", "return {'deleted': VAR_39}\n", "VAR_4 = media['media_id']\n", "VAR_18 = media['filesystem_id']\n", "VAR_31 = VAR_47, VAR_4\n", "VAR_0.info('Deleting: %r', VAR_31)\n", "VAR_48 = self.filepaths.remote_media_filepath(VAR_47, VAR_18)\n", "os.remove(VAR_48)\n", "VAR_0.warning('Failed to remove file: %r', VAR_48)\n", "VAR_49 = self.filepaths.remote_media_thumbnail_dir(VAR_47, VAR_18)\n", "if e.errno == errno.ENOENT:\n", "shutil.rmtree(VAR_49, ignore_errors=True)\n", "await self.store.delete_remote_media(VAR_47, VAR_4)\n", "VAR_39 += 1\n" ]
[ "async def delete_old_remote_media(self, before_ts):...\n", "old_media = await self.store.get_remote_media_before(before_ts)\n", "deleted = 0\n", "for media in old_media:\n", "origin = media['media_origin']\n", "return {'deleted': deleted}\n", "media_id = media['media_id']\n", "file_id = media['filesystem_id']\n", "key = origin, media_id\n", "logger.info('Deleting: %r', key)\n", "full_path = self.filepaths.remote_media_filepath(origin, file_id)\n", "os.remove(full_path)\n", "logger.warning('Failed to remove file: %r', full_path)\n", "thumbnail_dir = self.filepaths.remote_media_thumbnail_dir(origin, file_id)\n", "if e.errno == errno.ENOENT:\n", "shutil.rmtree(thumbnail_dir, ignore_errors=True)\n", "await self.store.delete_remote_media(origin, media_id)\n", "deleted += 1\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Assign'", "Assign'", "For", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "AugAssign'" ]
[ "def FUNC_21(self, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_20 = jinja.render('error.html', title='Error while opening qute://url',\n VAR_3=url.toDisplayString(), VAR_8=\n '{} is not available with this backend'.format(url.toDisplayString()))\n", "return 'text/html', VAR_20\n" ]
[ "def wrong_backend_handler(self, url):...\n", "\"\"\"docstring\"\"\"\n", "html = jinja.render('error.html', title='Error while opening qute://url',\n url=url.toDisplayString(), error=\n '{} is not available with this backend'.format(url.toDisplayString()))\n", "return 'text/html', html\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_60(VAR_5, VAR_38):...\n", "\"\"\"docstring\"\"\"\n", "VAR_194 = VAR_350(viewname='load_template', args=['userdata'])\n", "if isinstance(VAR_38, omero.model.FileAnnotationI):\n", "VAR_308 = VAR_5.getObject('Annotation', VAR_38.id.val)\n", "if VAR_38.__class__.__name__ in ('ImageI', 'DatasetI', 'ProjectI',\n", "for VAR_255 in ['project', 'dataset', 'image']:\n", "VAR_309 = VAR_38.__class__.__name__[:-1].lower()\n", "VAR_240 = list(VAR_308.getParentLinks(VAR_255))\n", "VAR_194 += '?show=%s-%s' % (VAR_309, VAR_38.id.val)\n", "if len(VAR_240) > 0:\n", "return VAR_194\n", "VAR_38 = VAR_240[0].parent\n" ]
[ "def getObjectUrl(conn, obj):...\n", "\"\"\"docstring\"\"\"\n", "base_url = reverse(viewname='load_template', args=['userdata'])\n", "if isinstance(obj, omero.model.FileAnnotationI):\n", "fa = conn.getObject('Annotation', obj.id.val)\n", "if obj.__class__.__name__ in ('ImageI', 'DatasetI', 'ProjectI', 'ScreenI',\n", "for ptype in ['project', 'dataset', 'image']:\n", "otype = obj.__class__.__name__[:-1].lower()\n", "links = list(fa.getParentLinks(ptype))\n", "base_url += '?show=%s-%s' % (otype, obj.id.val)\n", "if len(links) > 0:\n", "return base_url\n", "obj = links[0].parent\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Condition", "For", "Assign'", "Assign'", "AugAssign'", "Condition", "Return'", "Assign'" ]
[ "def FUNC_4(VAR_10):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_7(self):...\n", "FUNC_3(self.package_data)\n", "VAR_10.run(self)\n", "return CLASS_5\n" ]
[ "def check_package_data_first(command):...\n", "\"\"\"docstring\"\"\"\n", "def run(self):...\n", "check_package_data(self.package_data)\n", "command.run(self)\n", "return DecoratedCommand\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Expr'", "Expr'", "Return'" ]
[ "async def FUNC_41(self, VAR_46, VAR_47):...\n", "\"\"\"docstring\"\"\"\n", "VAR_183 = await self.http_client.get_json(VAR_47, {'public_key': VAR_46})\n", "if 'valid' not in VAR_183 or not VAR_183['valid']:\n" ]
[ "async def _check_key_revocation(self, public_key, url):...\n", "\"\"\"docstring\"\"\"\n", "response = await self.http_client.get_json(url, {'public_key': public_key})\n", "if 'valid' not in response or not response['valid']:\n" ]
[ 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Docstring", "Assign'", "Condition" ]
[ "async def FUNC_6(VAR_6):...\n", "VAR_7 = await VAR_4(VAR_6)\n", "VAR_10 = 'public; max-age={}'.format(VAR_2)\n", "if VAR_6.path in VAR_3 or VAR_2 <= 0:\n", "VAR_10 = 'no-cache'\n", "VAR_7.headers.setdefault('Cache-Control', VAR_10)\n", "return VAR_7\n" ]
[ "async def middleware_handler(request):...\n", "response = await handler(request)\n", "cache_control_value = 'public; max-age={}'.format(CACHE_MAX_AGE)\n", "if request.path in NO_CACHE_ENDPOINTS or CACHE_MAX_AGE <= 0:\n", "cache_control_value = 'no-cache'\n", "response.headers.setdefault('Cache-Control', cache_control_value)\n", "return response\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Return'" ]
[ "@VAR_0.simple_tag...\n", "import coreschema\n", "VAR_37 = OrderedDict([(VAR_11.name, VAR_11.schema or coreschema.String()) for\n VAR_11 in VAR_6.fields])\n", "VAR_38 = [VAR_11.name for VAR_11 in VAR_6.fields if VAR_11.required]\n", "VAR_39 = coreschema.Object(VAR_37=properties, VAR_38=required)\n", "return mark_safe(coreschema.render_to_form(VAR_39))\n" ]
[ "@register.simple_tag...\n", "import coreschema\n", "properties = OrderedDict([(field.name, field.schema or coreschema.String()) for\n field in link.fields])\n", "required = [field.name for field in link.fields if field.required]\n", "schema = coreschema.Object(properties=properties, required=required)\n", "return mark_safe(coreschema.render_to_form(schema))\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Import'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_88(VAR_176, VAR_177):...\n", "\"\"\"docstring\"\"\"\n", "VAR_207 = unicodecsv.reader(UniversalNewlineIterator(f), encoding='utf-8')\n", "VAR_210 = next(VAR_207)\n", "VAR_210 = []\n", "VAR_180 = None\n", "if 'cohort' not in VAR_210:\n", "VAR_180 = _(\"The file must contain a 'cohort' column containing cohort names.\")\n", "if 'email' not in VAR_210 and 'username' not in VAR_210:\n", "if VAR_180:\n", "VAR_180 = _(\n \"The file must contain a 'username' column, an 'email' column, or both.\")\n" ]
[ "def validator(file_storage, file_to_validate):...\n", "\"\"\"docstring\"\"\"\n", "reader = unicodecsv.reader(UniversalNewlineIterator(f), encoding='utf-8')\n", "fieldnames = next(reader)\n", "fieldnames = []\n", "msg = None\n", "if 'cohort' not in fieldnames:\n", "msg = _(\"The file must contain a 'cohort' column containing cohort names.\")\n", "if 'email' not in fieldnames and 'username' not in fieldnames:\n", "if msg:\n", "msg = _(\n \"The file must contain a 'username' column, an 'email' column, or both.\")\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Assign'" ]
[ "@VAR_2.route('/admin/user/<int:user_id>', methods=['GET', 'POST'])...\n", "VAR_22 = ub.session.query(ub.User).filter(ub.User.id == VAR_119(VAR_9)).first()\n", "if not VAR_22 or not config.config_anonbrowse and VAR_22.name == 'Guest':\n", "flash(_(u'User not found'), category='error')\n", "VAR_23 = calibre_db.speaking_language(return_all_languages=True)\n", "return redirect(url_for('admin.admin'))\n", "VAR_24 = babel.list_translations() + [LC('en')]\n", "VAR_25 = VAR_1['kobo'] and config.config_kobo_sync\n", "if request.method == 'POST':\n", "VAR_16 = request.form.to_dict()\n", "return render_title_template('user_edit.html', VAR_24=translations, VAR_23=\n languages, new_user=0, VAR_22=content, config=config, registered_oauth=\n oauth_check, mail_configured=config.get_mail_server_configured(),\n VAR_25=kobo_support, title=_(u'Edit User %(nick)s', nick=content.name),\n page='edituser')\n", "VAR_86 = FUNC_54(VAR_16, VAR_22, VAR_23, VAR_24, VAR_25)\n", "if VAR_86:\n", "return VAR_86\n" ]
[ "@admi.route('/admin/user/<int:user_id>', methods=['GET', 'POST'])...\n", "content = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()\n", "if not content or not config.config_anonbrowse and content.name == 'Guest':\n", "flash(_(u'User not found'), category='error')\n", "languages = calibre_db.speaking_language(return_all_languages=True)\n", "return redirect(url_for('admin.admin'))\n", "translations = babel.list_translations() + [LC('en')]\n", "kobo_support = feature_support['kobo'] and config.config_kobo_sync\n", "if request.method == 'POST':\n", "to_save = request.form.to_dict()\n", "return render_title_template('user_edit.html', translations=translations,\n languages=languages, new_user=0, content=content, config=config,\n registered_oauth=oauth_check, mail_configured=config.\n get_mail_server_configured(), kobo_support=kobo_support, title=_(\n u'Edit User %(nick)s', nick=content.name), page='edituser')\n", "resp = _handle_edit_user(to_save, content, languages, translations,\n kobo_support)\n", "if resp:\n", "return resp\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Return'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_37(self):...\n", "VAR_3 = self.client.get(reverse('login'))\n", "self.assertEqual(VAR_3.status_code, 200)\n", "if Site._meta.installed:\n", "VAR_29 = Site.objects.get_current()\n", "self.assertIsInstance(VAR_3.context['site'], RequestSite)\n", "self.assertEqual(VAR_3.context['site'], VAR_29)\n", "self.assertTrue(isinstance(VAR_3.context['form'], AuthenticationForm),\n 'Login form is not an AuthenticationForm')\n", "self.assertEqual(VAR_3.context['site_name'], VAR_29.name)\n" ]
[ "def test_current_site_in_context_after_login(self):...\n", "response = self.client.get(reverse('login'))\n", "self.assertEqual(response.status_code, 200)\n", "if Site._meta.installed:\n", "site = Site.objects.get_current()\n", "self.assertIsInstance(response.context['site'], RequestSite)\n", "self.assertEqual(response.context['site'], site)\n", "self.assertTrue(isinstance(response.context['form'], AuthenticationForm),\n 'Login form is not an AuthenticationForm')\n", "self.assertEqual(response.context['site_name'], site.name)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Condition", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_2(VAR_14, VAR_15=False, VAR_16=True):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_16:\n", "VAR_14 = VAR_2.sub('&amp;', VAR_14)\n", "VAR_14 = VAR_14.replace('&', '&amp;')\n", "VAR_14 = VAR_14.replace('<', '&lt;')\n", "VAR_14 = VAR_14.replace('>', '&gt;')\n", "if VAR_15:\n", "VAR_14 = VAR_14.replace('\"', '&quot;')\n", "return VAR_14\n", "VAR_14 = VAR_14.replace(\"'\", '&#39;')\n" ]
[ "def escape(text, quote=False, smart_amp=True):...\n", "\"\"\"docstring\"\"\"\n", "if smart_amp:\n", "text = _escape_pattern.sub('&amp;', text)\n", "text = text.replace('&', '&amp;')\n", "text = text.replace('<', '&lt;')\n", "text = text.replace('>', '&gt;')\n", "if quote:\n", "text = text.replace('\"', '&quot;')\n", "return text\n", "text = text.replace(\"'\", '&#39;')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Assign'" ]
[ "def FUNC_6(VAR_8: str) ->Dict[str, str]:...\n", "VAR_25 = None\n", "VAR_26 = ''\n", "VAR_27 = {}\n", "for line in VAR_8.split('\\n'):\n", "VAR_37 = line.lstrip()\n", "return VAR_27\n", "if not VAR_37:\n", "VAR_38 = len(line) - len(VAR_37)\n", "if VAR_37.startswith(('Args:', 'Arguments:', 'Parameters:')):\n", "VAR_25 = VAR_38 + 4\n", "if VAR_25 is None:\n", "if VAR_38 < VAR_25:\n", "if VAR_38 == VAR_25:\n", "VAR_26, VAR_44 = VAR_37.split(':', maxsplit=1)\n", "if VAR_38 > VAR_25:\n", "VAR_27[VAR_26] = VAR_44.lstrip()\n", "VAR_27[VAR_26] += f' {VAR_37}'\n" ]
[ "def _parse_args_from_docstring(docstring: str) ->Dict[str, str]:...\n", "arg_block_indent = None\n", "current_arg = ''\n", "parsed = {}\n", "for line in docstring.split('\\n'):\n", "stripped = line.lstrip()\n", "return parsed\n", "if not stripped:\n", "line_indent = len(line) - len(stripped)\n", "if stripped.startswith(('Args:', 'Arguments:', 'Parameters:')):\n", "arg_block_indent = line_indent + 4\n", "if arg_block_indent is None:\n", "if line_indent < arg_block_indent:\n", "if line_indent == arg_block_indent:\n", "current_arg, arg_description = stripped.split(':', maxsplit=1)\n", "if line_indent > arg_block_indent:\n", "parsed[current_arg] = arg_description.lstrip()\n", "parsed[current_arg] += f' {stripped}'\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Assign'", "AugAssign'" ]
[ "def __call__(self, VAR_56):...\n", "\"\"\"docstring\"\"\"\n", "VAR_95 = VAR_56.getroot\n", "VAR_56 = VAR_95()\n", "xhtml_to_html(VAR_56)\n", "for VAR_16 in VAR_56.iter('image'):\n", "VAR_16.tag = 'img'\n", "if not self.comments:\n", "self.kill_conditional_comments(VAR_56)\n", "VAR_48 = set(self.kill_tags or ())\n", "VAR_46 = set(self.remove_tags or ())\n", "VAR_47 = set(self.allow_tags or ())\n", "if self.scripts:\n", "VAR_48.add('script')\n", "if self.safe_attrs_only:\n", "VAR_51 = set(self.safe_attrs)\n", "if self.javascript:\n", "for VAR_16 in VAR_56.iter(etree.Element):\n", "if not (self.safe_attrs_only and self.safe_attrs == defs.safe_attrs):\n", "if self.comments:\n", "VAR_100 = VAR_16.attrib\n", "for VAR_16 in VAR_56.iter(etree.Element):\n", "VAR_56.rewrite_links(self._remove_javascript_link, resolve_base_href=False)\n", "VAR_48.add(etree.Comment)\n", "if self.processing_instructions:\n", "for aname in VAR_100.keys():\n", "VAR_100 = VAR_16.attrib\n", "if not self.inline_style:\n", "VAR_48.add(etree.ProcessingInstruction)\n", "if self.style:\n", "if aname not in VAR_51:\n", "for aname in VAR_100.keys():\n", "for VAR_16 in VAR_8(VAR_56):\n", "if not self.style:\n", "VAR_48.add('style')\n", "if self.inline_style:\n", "if aname.startswith('on'):\n", "VAR_105 = VAR_16.get('style')\n", "for VAR_16 in list(VAR_56.iter('style')):\n", "etree.strip_attributes(VAR_56, 'style')\n", "if self.links:\n", "VAR_84 = VAR_0('', VAR_105)\n", "if VAR_16.get('type', '').lower().strip() == 'text/javascript':\n", "VAR_48.add('link')\n", "if self.style or self.javascript:\n", "VAR_84 = VAR_1('', VAR_84)\n", "VAR_16.drop_tree()\n", "VAR_105 = VAR_16.text or ''\n", "if self.meta:\n", "for VAR_16 in list(VAR_56.iter('link')):\n", "if self._has_sneaky_javascript(VAR_84):\n", "VAR_84 = VAR_0('', VAR_105)\n", "VAR_48.add('meta')\n", "if self.page_structure:\n", "if 'stylesheet' in VAR_16.get('rel', '').lower():\n", "if VAR_84 != VAR_105:\n", "VAR_84 = VAR_1('', VAR_84)\n", "VAR_46.update(('head', 'html', 'title'))\n", "if self.embedded:\n", "if not self.allow_element(VAR_16):\n", "VAR_16.set('style', VAR_84)\n", "if self._has_sneaky_javascript(VAR_84):\n", "for VAR_16 in list(VAR_56.iter('param')):\n", "if self.frames:\n", "VAR_16.drop_tree()\n", "VAR_16.text = '/* deleted */'\n", "if VAR_84 != VAR_105:\n", "VAR_101 = VAR_16.getparent()\n", "VAR_48.update(('applet',))\n", "VAR_48.update(defs.frame_tags)\n", "if self.forms:\n", "VAR_16.text = VAR_84\n", "while VAR_101 is not None and VAR_101.tag not in ('applet', 'object'):\n", "VAR_46.update(('iframe', 'embed', 'layer', 'object', 'param'))\n", "VAR_46.add('form')\n", "if self.annoying_tags:\n", "VAR_101 = VAR_101.getparent()\n", "if VAR_101 is None:\n", "VAR_48.update(('button', 'input', 'select', 'textarea'))\n", "VAR_46.update(('blink', 'marquee'))\n", "VAR_74 = []\n", "VAR_16.drop_tree()\n", "VAR_75 = []\n", "for VAR_16 in VAR_56.iter():\n", "if VAR_16.tag in VAR_48:\n", "if VAR_74 and VAR_74[0] == VAR_56:\n", "if self.allow_element(VAR_16):\n", "if VAR_16.tag in VAR_46:\n", "VAR_16 = VAR_74.pop(0)\n", "if VAR_75 and VAR_75[0] == VAR_56:\n", "VAR_75.append(VAR_16)\n", "if self.allow_element(VAR_16):\n", "VAR_16.tag = 'div'\n", "VAR_16 = VAR_75.pop(0)\n", "VAR_75.reverse()\n", "VAR_74.append(VAR_16)\n", "VAR_16.attrib.clear()\n", "if VAR_16.tag != 'html':\n", "for VAR_16 in VAR_75:\n", "VAR_16.tag = 'div'\n", "VAR_16.clear()\n", "VAR_16.drop_tree()\n", "for VAR_16 in VAR_74:\n", "VAR_16.drop_tag()\n", "if self.remove_unknown_tags:\n", "if VAR_47:\n", "if VAR_47:\n", "VAR_47 = set(defs.tags)\n", "if not self.comments:\n", "if self.add_nofollow:\n", "VAR_47.add(etree.Comment)\n", "if not self.processing_instructions:\n", "for VAR_16 in VAR_9(VAR_56):\n", "VAR_47.add(etree.ProcessingInstruction)\n", "VAR_83 = []\n", "if not self.allow_follow(VAR_16):\n", "for VAR_16 in VAR_56.iter():\n", "VAR_106 = VAR_16.get('rel')\n", "if VAR_16.tag not in VAR_47:\n", "if VAR_83:\n", "if VAR_106:\n", "VAR_83.append(VAR_16)\n", "if VAR_83[0] is VAR_56:\n", "if 'nofollow' in VAR_106 and ' nofollow ' in ' %s ' % VAR_106:\n", "VAR_106 = 'nofollow'\n", "VAR_16 = VAR_83.pop(0)\n", "for VAR_16 in VAR_83:\n", "VAR_106 = '%s nofollow' % VAR_106\n", "VAR_16.set('rel', VAR_106)\n", "VAR_16.tag = 'div'\n", "VAR_16.drop_tag()\n", "VAR_16.attrib.clear()\n" ]
[ "def __call__(self, doc):...\n", "\"\"\"docstring\"\"\"\n", "getroot = doc.getroot\n", "doc = getroot()\n", "xhtml_to_html(doc)\n", "for el in doc.iter('image'):\n", "el.tag = 'img'\n", "if not self.comments:\n", "self.kill_conditional_comments(doc)\n", "kill_tags = set(self.kill_tags or ())\n", "remove_tags = set(self.remove_tags or ())\n", "allow_tags = set(self.allow_tags or ())\n", "if self.scripts:\n", "kill_tags.add('script')\n", "if self.safe_attrs_only:\n", "safe_attrs = set(self.safe_attrs)\n", "if self.javascript:\n", "for el in doc.iter(etree.Element):\n", "if not (self.safe_attrs_only and self.safe_attrs == defs.safe_attrs):\n", "if self.comments:\n", "attrib = el.attrib\n", "for el in doc.iter(etree.Element):\n", "doc.rewrite_links(self._remove_javascript_link, resolve_base_href=False)\n", "kill_tags.add(etree.Comment)\n", "if self.processing_instructions:\n", "for aname in attrib.keys():\n", "attrib = el.attrib\n", "if not self.inline_style:\n", "kill_tags.add(etree.ProcessingInstruction)\n", "if self.style:\n", "if aname not in safe_attrs:\n", "for aname in attrib.keys():\n", "for el in _find_styled_elements(doc):\n", "if not self.style:\n", "kill_tags.add('style')\n", "if self.inline_style:\n", "if aname.startswith('on'):\n", "old = el.get('style')\n", "for el in list(doc.iter('style')):\n", "etree.strip_attributes(doc, 'style')\n", "if self.links:\n", "new = _replace_css_javascript('', old)\n", "if el.get('type', '').lower().strip() == 'text/javascript':\n", "kill_tags.add('link')\n", "if self.style or self.javascript:\n", "new = _replace_css_import('', new)\n", "el.drop_tree()\n", "old = el.text or ''\n", "if self.meta:\n", "for el in list(doc.iter('link')):\n", "if self._has_sneaky_javascript(new):\n", "new = _replace_css_javascript('', old)\n", "kill_tags.add('meta')\n", "if self.page_structure:\n", "if 'stylesheet' in el.get('rel', '').lower():\n", "if new != old:\n", "new = _replace_css_import('', new)\n", "remove_tags.update(('head', 'html', 'title'))\n", "if self.embedded:\n", "if not self.allow_element(el):\n", "el.set('style', new)\n", "if self._has_sneaky_javascript(new):\n", "for el in list(doc.iter('param')):\n", "if self.frames:\n", "el.drop_tree()\n", "el.text = '/* deleted */'\n", "if new != old:\n", "parent = el.getparent()\n", "kill_tags.update(('applet',))\n", "kill_tags.update(defs.frame_tags)\n", "if self.forms:\n", "el.text = new\n", "while parent is not None and parent.tag not in ('applet', 'object'):\n", "remove_tags.update(('iframe', 'embed', 'layer', 'object', 'param'))\n", "remove_tags.add('form')\n", "if self.annoying_tags:\n", "parent = parent.getparent()\n", "if parent is None:\n", "kill_tags.update(('button', 'input', 'select', 'textarea'))\n", "remove_tags.update(('blink', 'marquee'))\n", "_remove = []\n", "el.drop_tree()\n", "_kill = []\n", "for el in doc.iter():\n", "if el.tag in kill_tags:\n", "if _remove and _remove[0] == doc:\n", "if self.allow_element(el):\n", "if el.tag in remove_tags:\n", "el = _remove.pop(0)\n", "if _kill and _kill[0] == doc:\n", "_kill.append(el)\n", "if self.allow_element(el):\n", "el.tag = 'div'\n", "el = _kill.pop(0)\n", "_kill.reverse()\n", "_remove.append(el)\n", "el.attrib.clear()\n", "if el.tag != 'html':\n", "for el in _kill:\n", "el.tag = 'div'\n", "el.clear()\n", "el.drop_tree()\n", "for el in _remove:\n", "el.drop_tag()\n", "if self.remove_unknown_tags:\n", "if allow_tags:\n", "if allow_tags:\n", "allow_tags = set(defs.tags)\n", "if not self.comments:\n", "if self.add_nofollow:\n", "allow_tags.add(etree.Comment)\n", "if not self.processing_instructions:\n", "for el in _find_external_links(doc):\n", "allow_tags.add(etree.ProcessingInstruction)\n", "bad = []\n", "if not self.allow_follow(el):\n", "for el in doc.iter():\n", "rel = el.get('rel')\n", "if el.tag not in allow_tags:\n", "if bad:\n", "if rel:\n", "bad.append(el)\n", "if bad[0] is doc:\n", "if 'nofollow' in rel and ' nofollow ' in ' %s ' % rel:\n", "rel = 'nofollow'\n", "el = bad.pop(0)\n", "for el in bad:\n", "rel = '%s nofollow' % rel\n", "el.set('rel', rel)\n", "el.tag = 'div'\n", "el.drop_tag()\n", "el.attrib.clear()\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, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "For", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Condition", "For", "Condition", "Condition", "Assign'", "For", "Expr'", "Expr'", "Condition", "For", "Assign'", "Condition", "Expr'", "Condition", "Condition", "For", "For", "Condition", "Expr'", "Condition", "Condition", "Assign'", "For", "Expr'", "Condition", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Expr'", "Assign'", "Condition", "For", "Condition", "Assign'", "Expr'", "Condition", "Condition", "Condition", "Assign'", "Expr'", "Condition", "Condition", "Expr'", "Condition", "For", "Condition", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "For", "Assign'", "Condition", "Expr'", "Expr'", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "For", "Condition", "Condition", "Condition", "Condition", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Condition", "For", "Assign'", "Expr'", "Expr'", "For", "Expr'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Condition", "Expr'", "Condition", "For", "Expr'", "Assign'", "Condition", "For", "Assign'", "Condition", "Condition", "Condition", "Expr'", "Condition", "Condition", "Assign'", "Assign'", "For", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_1(VAR_7: str) ->str:...\n", "\"\"\"docstring\"\"\"\n", "return FUNC_3(VAR_7, VAR_0)\n" ]
[ "def validate_html_strict(html: str) ->str:...\n", "\"\"\"docstring\"\"\"\n", "return base_validate_html(html, allowed_tags_strict)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "import os\n", "from datetime import datetime\n", "import json\n", "from shutil import copyfile\n", "from uuid import uuid4\n", "from markupsafe import escape\n", "from lxml.html.clean import clean_html\n", "from scholarly import scholarly\n", "VAR_47 = False\n", "from flask import Blueprint, request, flash, redirect, url_for, abort, Markup, Response\n", "VAR_47 = True\n", "from flask_babel import gettext as _\n", "from flask_login import current_user, login_required\n", "from sqlalchemy.exc import OperationalError, IntegrityError\n", "from sqlite3 import OperationalError as sqliteOperationalError\n", "from . import constants, logger, isoLanguages, gdriveutils, uploader, helper, kobo_sync_status\n", "from . import config, get_locale, ub, db\n", "from . import calibre_db\n", "from .services.worker import WorkerThread\n", "from .tasks.upload import TaskUpload\n", "from .render_template import render_title_template\n", "from .usermanagement import login_required_if_no_ano\n", "from functools import wraps\n", "VAR_0 = Blueprint('editbook', __name__)\n", "VAR_1 = logger.create()\n", "def FUNC_0(VAR_2):...\n", "@wraps(VAR_2)...\n", "if current_user.role_upload():\n", "return VAR_2(*VAR_48, **kwargs)\n", "abort(403)\n", "return FUNC_46\n" ]
[ "import os\n", "from datetime import datetime\n", "import json\n", "from shutil import copyfile\n", "from uuid import uuid4\n", "from markupsafe import escape\n", "from lxml.html.clean import clean_html\n", "from scholarly import scholarly\n", "have_scholar = False\n", "from flask import Blueprint, request, flash, redirect, url_for, abort, Markup, Response\n", "have_scholar = True\n", "from flask_babel import gettext as _\n", "from flask_login import current_user, login_required\n", "from sqlalchemy.exc import OperationalError, IntegrityError\n", "from sqlite3 import OperationalError as sqliteOperationalError\n", "from . import constants, logger, isoLanguages, gdriveutils, uploader, helper, kobo_sync_status\n", "from . import config, get_locale, ub, db\n", "from . import calibre_db\n", "from .services.worker import WorkerThread\n", "from .tasks.upload import TaskUpload\n", "from .render_template import render_title_template\n", "from .usermanagement import login_required_if_no_ano\n", "from functools import wraps\n", "editbook = Blueprint('editbook', __name__)\n", "log = logger.create()\n", "def upload_required(f):...\n", "@wraps(f)...\n", "if current_user.role_upload():\n", "return f(*args, **kwargs)\n", "abort(403)\n", "return inner\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 ]
[ "Import'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "ImportFrom'", "Assign'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "FunctionDef'", "Condition", "Condition", "Return'", "Expr'", "Return'" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "endpoints_by_tag: Dict[str, CLASS_1] = {}\n", "VAR_14 = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace']\n", "for VAR_8, path_data in VAR_5.items():\n", "for VAR_9 in VAR_14:\n", "return endpoints_by_tag\n", "operation: Optional[oai.Operation] = getattr(path_data, VAR_9)\n", "if operation is None:\n", "VAR_10 = (operation.tags or ['default'])[0]\n", "VAR_30 = endpoints_by_tag.setdefault(VAR_10, CLASS_1(VAR_10=tag))\n", "VAR_7 = CLASS_2.from_data(VAR_5=operation, VAR_8=path, VAR_9=method, VAR_10=tag\n )\n", "if isinstance(VAR_7, ParseError):\n", "VAR_7.header = (\n f'ERROR parsing {VAR_9.upper()} {VAR_8} within {VAR_10}. Endpoint will not be generated.'\n )\n", "VAR_30.endpoints.append(VAR_7)\n", "VAR_30.parse_errors.append(VAR_7)\n", "VAR_30.relative_imports.update(VAR_7.relative_imports)\n" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "endpoints_by_tag: Dict[str, EndpointCollection] = {}\n", "methods = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace']\n", "for path, path_data in data.items():\n", "for method in methods:\n", "return endpoints_by_tag\n", "operation: Optional[oai.Operation] = getattr(path_data, method)\n", "if operation is None:\n", "tag = (operation.tags or ['default'])[0]\n", "collection = endpoints_by_tag.setdefault(tag, EndpointCollection(tag=tag))\n", "endpoint = Endpoint.from_data(data=operation, path=path, method=method, tag=tag\n )\n", "if isinstance(endpoint, ParseError):\n", "endpoint.header = (\n f'ERROR parsing {method.upper()} {path} within {tag}. Endpoint will not be generated.'\n )\n", "collection.endpoints.append(endpoint)\n", "collection.parse_errors.append(endpoint)\n", "collection.relative_imports.update(endpoint.relative_imports)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "AnnAssign'", "Assign'", "For", "For", "Return'", "AnnAssign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_110(self):...\n", "def FUNC_165(VAR_215, VAR_224):...\n", "return serializers.json({'version': '1.1', 'id': VAR_215, 'result': VAR_224,\n 'error': None})\n" ]
[ "def serve_jsonrpc(self):...\n", "def return_response(id, result):...\n", "return serializers.json({'version': '1.1', 'id': id, 'result': result,\n 'error': None})\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Return'" ]
[ "def FUNC_83(self, VAR_71):...\n", "if isinstance(VAR_71, dict):\n", "if not self.get('_return_value'):\n", "self._return_value = VAR_71 or self.get('_return_value')\n", "self._return_value = {}\n", "self._return_value.update(VAR_71)\n" ]
[ "def add_to_return_value(self, new_return_value):...\n", "if isinstance(new_return_value, dict):\n", "if not self.get('_return_value'):\n", "self._return_value = new_return_value or self.get('_return_value')\n", "self._return_value = {}\n", "self._return_value.update(new_return_value)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_53(self):...\n", "frappe.clear_document_cache(self.doctype, self.name)\n" ]
[ "def clear_cache(self):...\n", "frappe.clear_document_cache(self.doctype, self.name)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "async def FUNC_5(VAR_25: WebSocket) ->None:...\n", "VAR_53 = await solve_dependencies(VAR_24=websocket, VAR_10=dependant,\n VAR_22=dependency_overrides_provider)\n", "VAR_11, VAR_51, VAR_56, VAR_57, VAR_58 = VAR_53\n", "if VAR_51:\n", "await VAR_25.close(code=WS_1008_POLICY_VIOLATION)\n", "assert VAR_10.call is not None, 'dependant.call must be a function'\n", "await VAR_10.call(**values)\n" ]
[ "async def app(websocket: WebSocket) ->None:...\n", "solved_result = await solve_dependencies(request=websocket, dependant=\n dependant, dependency_overrides_provider=dependency_overrides_provider)\n", "values, errors, _, _2, _3 = solved_result\n", "if errors:\n", "await websocket.close(code=WS_1008_POLICY_VIOLATION)\n", "assert dependant.call is not None, 'dependant.call must be a function'\n", "await dependant.call(**values)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Assign'", "Assign'", "Condition", "Expr'", "Assert'", "Expr'" ]
[ "def FUNC_42(self):...\n", "\"\"\"docstring\"\"\"\n", "from selenium.webdriver.common.keys import Keys\n", "self.admin_login(username='super', password='secret', login_url='/')\n", "self.selenium.get('%s%s' % (self.live_server_url, '/admin_widgets/member/add/')\n )\n", "self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'none')\n", "self.selenium.find_element_by_id('calendarlink0').click()\n", "self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'block')\n", "self.selenium.find_element_by_tag_name('body').send_keys([Keys.ESCAPE])\n", "self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'none')\n", "self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'none')\n", "self.selenium.find_element_by_id('clocklink0').click()\n", "self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'block')\n", "self.selenium.find_element_by_tag_name('body').send_keys([Keys.ESCAPE])\n", "self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'none')\n" ]
[ "def test_show_hide_date_time_picker_widgets(self):...\n", "\"\"\"docstring\"\"\"\n", "from selenium.webdriver.common.keys import Keys\n", "self.admin_login(username='super', password='secret', login_url='/')\n", "self.selenium.get('%s%s' % (self.live_server_url, '/admin_widgets/member/add/')\n )\n", "self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'none')\n", "self.selenium.find_element_by_id('calendarlink0').click()\n", "self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'block')\n", "self.selenium.find_element_by_tag_name('body').send_keys([Keys.ESCAPE])\n", "self.assertEqual(self.get_css_value('#calendarbox0', 'display'), 'none')\n", "self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'none')\n", "self.selenium.find_element_by_id('clocklink0').click()\n", "self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'block')\n", "self.selenium.find_element_by_tag_name('body').send_keys([Keys.ESCAPE])\n", "self.assertEqual(self.get_css_value('#clockbox0', 'display'), 'none')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "ImportFrom'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_12(self, VAR_1: str) ->Optional[str]:...\n", "\"\"\"docstring\"\"\"\n", "VAR_14 = self._components.get(VAR_1, None)\n", "return VAR_14.abspath if VAR_14 is not None else None\n" ]
[ "def get_component_path(self, name: str) ->Optional[str]:...\n", "\"\"\"docstring\"\"\"\n", "component = self._components.get(name, None)\n", "return component.abspath if component is not None else None\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_33(VAR_30):...\n", "print(VAR_29 + VAR_30)\n" ]
[ "def in_print(s):...\n", "print(indent_str + s)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "async def FUNC_11(self, VAR_4: str, VAR_19: str, VAR_20: str) ->Optional[str]:...\n", "\"\"\"docstring\"\"\"\n", "VAR_46 = await self.blacklisting_http_client.get_json(\n '%s%s/_matrix/identity/api/v1/lookup' % (VAR_1, VAR_4), {'medium':\n VAR_19, 'address': VAR_20})\n", "VAR_0.warning('Error from v1 identity server lookup: %s' % (e,))\n", "return None\n", "if 'mxid' in VAR_46:\n", "return VAR_46['mxid']\n" ]
[ "async def _lookup_3pid_v1(self, id_server: str, medium: str, address: str...\n", "\"\"\"docstring\"\"\"\n", "data = await self.blacklisting_http_client.get_json(\n '%s%s/_matrix/identity/api/v1/lookup' % (id_server_scheme, id_server),\n {'medium': medium, 'address': address})\n", "logger.warning('Error from v1 identity server lookup: %s' % (e,))\n", "return None\n", "if 'mxid' in data:\n", "return data['mxid']\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Docstring", "Assign'", "Expr'", "Return'", "Condition", "Return'" ]
[ "def FUNC_12(self, VAR_56, VAR_59, VAR_60=None):...\n", "VAR_83 = []\n", "for VAR_16 in VAR_56.iter(VAR_60):\n", "if VAR_59(VAR_16):\n", "for VAR_16 in VAR_83:\n", "VAR_83.append(VAR_16)\n", "VAR_16.drop_tree()\n" ]
[ "def _kill_elements(self, doc, condition, iterate=None):...\n", "bad = []\n", "for el in doc.iter(iterate):\n", "if condition(el):\n", "for el in bad:\n", "bad.append(el)\n", "el.drop_tree()\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Condition", "For", "Expr'", "Expr'" ]
[ "@VAR_0.tag...\n", "\"\"\"docstring\"\"\"\n", "return get_gravatar_url_for_email(VAR_1['request'], VAR_4, VAR_3)\n" ]
[ "@register.tag...\n", "\"\"\"docstring\"\"\"\n", "return get_gravatar_url_for_email(context['request'], email, size)\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def FUNC_22():...\n", "return VAR_43.get('state')\n" ]
[ "def get_state():...\n", "return session.get('state')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_14(self, VAR_26: str, *, VAR_29: Optional[Type[Any]]=None, VAR_13:...\n", "return self.api_route(VAR_26=path, VAR_29=response_model, VAR_13=\n status_code, VAR_30=tags, VAR_31=dependencies, VAR_32=summary, VAR_33=\n description, VAR_34=response_description, VAR_35=responses, VAR_36=\n deprecated, VAR_37=['POST'], VAR_38=operation_id, VAR_16=\n response_model_include, VAR_17=response_model_exclude, VAR_18=\n response_model_by_alias, VAR_19=response_model_exclude_unset, VAR_20=\n response_model_exclude_defaults, VAR_21=response_model_exclude_none,\n VAR_39=include_in_schema, VAR_14=response_class, VAR_28=name, VAR_40=\n callbacks)\n" ]
[ "def post(self, path: str, *, response_model: Optional[Type[Any]]=None,...\n", "return self.api_route(path=path, response_model=response_model, status_code\n =status_code, tags=tags, dependencies=dependencies, summary=summary,\n description=description, response_description=response_description,\n responses=responses, deprecated=deprecated, methods=['POST'],\n operation_id=operation_id, response_model_include=\n response_model_include, response_model_exclude=response_model_exclude,\n response_model_by_alias=response_model_by_alias,\n response_model_exclude_unset=response_model_exclude_unset,\n response_model_exclude_defaults=response_model_exclude_defaults,\n response_model_exclude_none=response_model_exclude_none,\n include_in_schema=include_in_schema, response_class=response_class,\n name=name, callbacks=callbacks)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_29(VAR_66):...\n", "VAR_105 = FUNC_28(VAR_66._identifier, VAR_66.on_ui_render, VAR_15=p.\n get_ui_additional_key_data_for_cache, VAR_61=p.\n get_ui_additional_tracked_files, VAR_63=p.get_ui_custom_tracked_files,\n VAR_64=p.get_ui_custom_etag, VAR_65=p.get_ui_custom_lastmodified,\n VAR_62=p.get_ui_additional_etag(default_additional_etag))\n", "if VAR_46 and VAR_66.get_ui_preemptive_caching_enabled():\n", "VAR_60 = FUNC_27(VAR_66._identifier, VAR_105, VAR_66.\n get_ui_data_for_preemptive_caching, VAR_66.\n get_ui_additional_request_data_for_preemptive_caching, VAR_66.\n get_ui_preemptive_caching_additional_unless)\n", "VAR_60 = VAR_105\n", "VAR_30 = VAR_66.get_ui_custom_template_filter(FUNC_26)\n", "if VAR_30 is not None and callable(VAR_30):\n", "VAR_82 = FUNC_13(VAR_1[VAR_14], VAR_30)\n", "VAR_82 = VAR_1[VAR_14]\n", "VAR_43 = FUNC_9(VAR_82, VAR_2, VAR_3, VAR_21)\n", "return VAR_60(VAR_21, request, VAR_43)\n" ]
[ "def plugin_view(p):...\n", "cached = get_cached_view(p._identifier, p.on_ui_render, additional_key_data\n =p.get_ui_additional_key_data_for_cache, additional_files=p.\n get_ui_additional_tracked_files, custom_files=p.\n get_ui_custom_tracked_files, custom_etag=p.get_ui_custom_etag,\n custom_lastmodified=p.get_ui_custom_lastmodified, additional_etag=p.\n get_ui_additional_etag(default_additional_etag))\n", "if preemptive_cache_enabled and p.get_ui_preemptive_caching_enabled():\n", "view = get_preemptively_cached_view(p._identifier, cached, p.\n get_ui_data_for_preemptive_caching, p.\n get_ui_additional_request_data_for_preemptive_caching, p.\n get_ui_preemptive_caching_additional_unless)\n", "view = cached\n", "template_filter = p.get_ui_custom_template_filter(default_template_filter)\n", "if template_filter is not None and callable(template_filter):\n", "filtered_templates = _filter_templates(_templates[locale], template_filter)\n", "filtered_templates = _templates[locale]\n", "render_kwargs = _get_render_kwargs(filtered_templates, _plugin_names,\n _plugin_vars, now)\n", "return view(now, request, render_kwargs)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_44(VAR_62, VAR_9, VAR_97, VAR_103=False):...\n", "VAR_94 = FUNC_41(VAR_62, VAR_9)\n", "if isinstance(VAR_97, string_types):\n", "if VAR_103:\n", "VAR_188 = [VAR_94.get(f) for f in VAR_97]\n", "VAR_96('Cannot make dict for single fieldname')\n", "return VAR_94.get(VAR_97)\n", "if VAR_103:\n", "return CLASS_0(zip(VAR_97, VAR_188))\n", "return VAR_188\n" ]
[ "def get_cached_value(doctype, name, fieldname, as_dict=False):...\n", "doc = get_cached_doc(doctype, name)\n", "if isinstance(fieldname, string_types):\n", "if as_dict:\n", "values = [doc.get(f) for f in fieldname]\n", "throw('Cannot make dict for single fieldname')\n", "return doc.get(fieldname)\n", "if as_dict:\n", "return _dict(zip(fieldname, values))\n", "return values\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Condition", "Assign'", "Expr'", "Return'", "Condition", "Return'", "Return'" ]
[ "@VAR_0.route(...\n", "\"\"\"docstring\"\"\"\n", "VAR_47 = InfluxDBClient(INFLUXDB_HOST, INFLUXDB_PORT, INFLUXDB_USER,\n INFLUXDB_PASSWORD, INFLUXDB_DATABASE)\n", "if VAR_17 == '0' and VAR_18 == '0':\n", "VAR_61 = query_string(VAR_21, VAR_19, VAR_22=channel, VAR_94='COUNT')\n", "if VAR_17 != '0' and VAR_18 == '0':\n", "if VAR_61 == 1:\n", "VAR_51 = datetime.datetime.utcfromtimestamp(float(VAR_17))\n", "VAR_51 = datetime.datetime.utcfromtimestamp(float(VAR_17))\n", "return '', 204\n", "VAR_62 = VAR_47.query(VAR_61).raw\n", "VAR_59 = VAR_51.strftime('%Y-%m-%dT%H:%M:%S.%fZ')\n", "VAR_59 = VAR_51.strftime('%Y-%m-%dT%H:%M:%S.%fZ')\n", "VAR_84 = VAR_62['series'][0]['values'][0][1]\n", "VAR_52 = datetime.datetime.utcnow()\n", "VAR_52 = datetime.datetime.utcfromtimestamp(float(VAR_18))\n", "VAR_61 = query_string(VAR_21, VAR_19, VAR_22=channel, limit=1)\n", "VAR_60 = VAR_52.strftime('%Y-%m-%dT%H:%M:%S.%fZ')\n", "VAR_60 = VAR_52.strftime('%Y-%m-%dT%H:%M:%S.%fZ')\n", "if VAR_61 == 1:\n", "VAR_61 = query_string(VAR_21, VAR_19, VAR_22=channel, VAR_94='COUNT',\n VAR_59=start_str, VAR_60=end_str)\n", "VAR_61 = query_string(VAR_21, VAR_19, VAR_22=channel, VAR_94='COUNT',\n VAR_59=start_str, VAR_60=end_str)\n", "return '', 204\n", "VAR_62 = VAR_47.query(VAR_61).raw\n", "if VAR_61 == 1:\n", "if VAR_61 == 1:\n", "VAR_87 = VAR_62['series'][0]['values'][0][0]\n", "return '', 204\n", "VAR_62 = VAR_47.query(VAR_61).raw\n", "return '', 204\n", "VAR_62 = VAR_47.query(VAR_61).raw\n", "VAR_52 = datetime.datetime.utcnow()\n", "VAR_84 = VAR_62['series'][0]['values'][0][1]\n", "VAR_84 = VAR_62['series'][0]['values'][0][1]\n", "VAR_60 = VAR_52.strftime('%Y-%m-%dT%H:%M:%S.%fZ')\n", "VAR_61 = query_string(VAR_21, VAR_19, VAR_22=channel, VAR_59=start_str,\n VAR_60=end_str, limit=1)\n", "VAR_61 = query_string(VAR_21, VAR_19, VAR_22=channel, VAR_59=start_str,\n VAR_60=end_str, limit=1)\n", "VAR_51 = datetime.datetime.strptime(influx_time_str_to_milliseconds(VAR_87),\n '%Y-%m-%dT%H:%M:%S.%f')\n", "if VAR_61 == 1:\n", "if VAR_61 == 1:\n", "VAR_59 = VAR_51.strftime('%Y-%m-%dT%H:%M:%S.%fZ')\n", "return '', 204\n", "VAR_62 = VAR_47.query(VAR_61).raw\n", "return '', 204\n", "VAR_62 = VAR_47.query(VAR_61).raw\n", "VAR_1.debug('Count = {}'.format(VAR_84))\n", "VAR_87 = VAR_62['series'][0]['values'][0][0]\n", "VAR_87 = VAR_62['series'][0]['values'][0][0]\n", "VAR_1.debug('Start = {}'.format(VAR_51))\n", "VAR_1.debug('End = {}'.format(VAR_52))\n", "VAR_68 = (VAR_52 - VAR_51).total_seconds()\n", "VAR_1.debug('Difference seconds = {}'.format(VAR_68))\n", "if VAR_84 > 700:\n", "VAR_85 = VAR_68 / VAR_84\n", "VAR_61 = query_string(VAR_21, VAR_19, VAR_22=channel, VAR_59=start_str,\n VAR_60=end_str)\n", "VAR_1.error(\"URL for 'async_usage' raised and error: {err}\".format(err=e))\n", "VAR_1.debug('Seconds per point = {}'.format(VAR_85))\n", "if VAR_61 == 1:\n", "return '', 204\n", "VAR_86 = int(VAR_68 / 700)\n", "return '', 204\n", "VAR_62 = VAR_47.query(VAR_61).raw\n", "VAR_1.debug('Group seconds = {}'.format(VAR_86))\n", "return jsonify(VAR_62['series'][0]['values'])\n", "VAR_61 = query_string(VAR_21, VAR_19, VAR_22=channel, VAR_94='MEAN', VAR_59\n =start_str, VAR_60=end_str, group_sec=group_seconds)\n", "VAR_1.error(\"URL for 'async_data' raised and error: {err}\".format(err=e))\n", "if VAR_61 == 1:\n", "return '', 204\n", "return '', 204\n", "VAR_62 = VAR_47.query(VAR_61).raw\n", "return jsonify(VAR_62['series'][0]['values'])\n" ]
[ "@blueprint.route(...\n", "\"\"\"docstring\"\"\"\n", "dbcon = InfluxDBClient(INFLUXDB_HOST, INFLUXDB_PORT, INFLUXDB_USER,\n INFLUXDB_PASSWORD, INFLUXDB_DATABASE)\n", "if start_seconds == '0' and end_seconds == '0':\n", "query_str = query_string(unit, device_id, channel=channel, value='COUNT')\n", "if start_seconds != '0' and end_seconds == '0':\n", "if query_str == 1:\n", "start = datetime.datetime.utcfromtimestamp(float(start_seconds))\n", "start = datetime.datetime.utcfromtimestamp(float(start_seconds))\n", "return '', 204\n", "raw_data = dbcon.query(query_str).raw\n", "start_str = start.strftime('%Y-%m-%dT%H:%M:%S.%fZ')\n", "start_str = start.strftime('%Y-%m-%dT%H:%M:%S.%fZ')\n", "count_points = raw_data['series'][0]['values'][0][1]\n", "end = datetime.datetime.utcnow()\n", "end = datetime.datetime.utcfromtimestamp(float(end_seconds))\n", "query_str = query_string(unit, device_id, channel=channel, limit=1)\n", "end_str = end.strftime('%Y-%m-%dT%H:%M:%S.%fZ')\n", "end_str = end.strftime('%Y-%m-%dT%H:%M:%S.%fZ')\n", "if query_str == 1:\n", "query_str = query_string(unit, device_id, channel=channel, value='COUNT',\n start_str=start_str, end_str=end_str)\n", "query_str = query_string(unit, device_id, channel=channel, value='COUNT',\n start_str=start_str, end_str=end_str)\n", "return '', 204\n", "raw_data = dbcon.query(query_str).raw\n", "if query_str == 1:\n", "if query_str == 1:\n", "first_point = raw_data['series'][0]['values'][0][0]\n", "return '', 204\n", "raw_data = dbcon.query(query_str).raw\n", "return '', 204\n", "raw_data = dbcon.query(query_str).raw\n", "end = datetime.datetime.utcnow()\n", "count_points = raw_data['series'][0]['values'][0][1]\n", "count_points = raw_data['series'][0]['values'][0][1]\n", "end_str = end.strftime('%Y-%m-%dT%H:%M:%S.%fZ')\n", "query_str = query_string(unit, device_id, channel=channel, start_str=\n start_str, end_str=end_str, limit=1)\n", "query_str = query_string(unit, device_id, channel=channel, start_str=\n start_str, end_str=end_str, limit=1)\n", "start = datetime.datetime.strptime(influx_time_str_to_milliseconds(\n first_point), '%Y-%m-%dT%H:%M:%S.%f')\n", "if query_str == 1:\n", "if query_str == 1:\n", "start_str = start.strftime('%Y-%m-%dT%H:%M:%S.%fZ')\n", "return '', 204\n", "raw_data = dbcon.query(query_str).raw\n", "return '', 204\n", "raw_data = dbcon.query(query_str).raw\n", "logger.debug('Count = {}'.format(count_points))\n", "first_point = raw_data['series'][0]['values'][0][0]\n", "first_point = raw_data['series'][0]['values'][0][0]\n", "logger.debug('Start = {}'.format(start))\n", "logger.debug('End = {}'.format(end))\n", "time_difference_seconds = (end - start).total_seconds()\n", "logger.debug('Difference seconds = {}'.format(time_difference_seconds))\n", "if count_points > 700:\n", "seconds_per_point = time_difference_seconds / count_points\n", "query_str = query_string(unit, device_id, channel=channel, start_str=\n start_str, end_str=end_str)\n", "logger.error(\"URL for 'async_usage' raised and error: {err}\".format(err=e))\n", "logger.debug('Seconds per point = {}'.format(seconds_per_point))\n", "if query_str == 1:\n", "return '', 204\n", "group_seconds = int(time_difference_seconds / 700)\n", "return '', 204\n", "raw_data = dbcon.query(query_str).raw\n", "logger.debug('Group seconds = {}'.format(group_seconds))\n", "return jsonify(raw_data['series'][0]['values'])\n", "query_str = query_string(unit, device_id, channel=channel, value='MEAN',\n start_str=start_str, end_str=end_str, group_sec=group_seconds)\n", "logger.error(\"URL for 'async_data' raised and error: {err}\".format(err=e))\n", "if query_str == 1:\n", "return '', 204\n", "return '', 204\n", "raw_data = dbcon.query(query_str).raw\n", "return jsonify(raw_data['series'][0]['values'])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Return'", "Assign'", "Condition", "Condition", "Assign'", "Return'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Return'", "Assign'", "Return'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Expr'", "Expr'", "Condition", "Return'", "Assign'", "Return'", "Assign'", "Expr'", "Return'", "Assign'", "Expr'", "Condition", "Return'", "Return'", "Assign'", "Return'" ]
[ "def FUNC_1(VAR_2, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_23 = FUNC_10(VAR_2, VAR_3)\n", "print(\n 'The given SavedModel MetaGraphDef contains SignatureDefs with the following keys:'\n )\n", "for VAR_5 in sorted(VAR_23.keys()):\n", "print('SignatureDef key: \"%s\"' % VAR_5)\n" ]
[ "def _show_signature_def_map_keys(saved_model_dir, tag_set):...\n", "\"\"\"docstring\"\"\"\n", "signature_def_map = get_signature_def_map(saved_model_dir, tag_set)\n", "print(\n 'The given SavedModel MetaGraphDef contains SignatureDefs with the following keys:'\n )\n", "for signature_def_key in sorted(signature_def_map.keys()):\n", "print('SignatureDef key: \"%s\"' % signature_def_key)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "For", "Expr'" ]
[ "def FUNC_38(VAR_3, VAR_13, VAR_14='.*\\\\.py$'):...\n", "VAR_45 = sorted(listdir(apath('%(app)s/%(dir)s/' % {'app': VAR_3, 'dir':\n VAR_13}, VAR_122=request), VAR_14))\n", "VAR_45 = [x.replace(os.path.sep, '/') for x in VAR_45 if not x.endswith('.bak')\n ]\n", "return VAR_45\n" ]
[ "def listfiles(app, dir, regexp='.*\\\\.py$'):...\n", "files = sorted(listdir(apath('%(app)s/%(dir)s/' % {'app': app, 'dir': dir},\n r=request), regexp))\n", "files = [x.replace(os.path.sep, '/') for x in files if not x.endswith('.bak')]\n", "return files\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_7(self):...\n", "self._record_users()\n", "VAR_10 = self.get_success(self.handler.get_device(VAR_0, 'abc'))\n", "self.assertDictContainsSubset({'user_id': VAR_0, 'device_id': 'abc',\n 'display_name': 'display 2', 'last_seen_ip': 'ip3', 'last_seen_ts': \n 3000000}, VAR_10)\n" ]
[ "def test_get_device(self):...\n", "self._record_users()\n", "res = self.get_success(self.handler.get_device(user1, 'abc'))\n", "self.assertDictContainsSubset({'user_id': user1, 'device_id': 'abc',\n 'display_name': 'display 2', 'last_seen_ip': 'ip3', 'last_seen_ts': \n 3000000}, res)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_6(self) ->twisted.internet.base.ReactorBase:...\n", "\"\"\"docstring\"\"\"\n", "return self._reactor\n" ]
[ "def get_reactor(self) ->twisted.internet.base.ReactorBase:...\n", "\"\"\"docstring\"\"\"\n", "return self._reactor\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_27(self, VAR_15, **VAR_14):...\n", "\"\"\"docstring\"\"\"\n", "assert VAR_69 is not None, 'should never reach here without keyring'\n", "if not VAR_69:\n", "return\n", "VAR_78 = self._credentials_to_save\n", "self._credentials_to_save = None\n", "if VAR_78 and VAR_15.status_code < 400:\n", "VAR_1.info('Saving credentials to keyring')\n", "VAR_1.exception('Failed to save credentials')\n", "VAR_69.set_password(*VAR_78)\n" ]
[ "def save_credentials(self, resp, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "assert keyring is not None, 'should never reach here without keyring'\n", "if not keyring:\n", "return\n", "creds = self._credentials_to_save\n", "self._credentials_to_save = None\n", "if creds and resp.status_code < 400:\n", "logger.info('Saving credentials to keyring')\n", "logger.exception('Failed to save credentials')\n", "keyring.set_password(*creds)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assert'", "Condition", "Return'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_1(VAR_4: str) ->str:...\n", "return ensure_str(VAR_4.replace('&amp;', '&').replace('&quot;', '\"').\n replace('&lt;', '<').replace('&gt;', '>'))\n" ]
[ "def unescape_attributes(value: str) ->str:...\n", "return ensure_str(value.replace('&amp;', '&').replace('&quot;', '\"').\n replace('&lt;', '<').replace('&gt;', '>'))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "async def FUNC_3(self, VAR_10: str, VAR_11: str, VAR_14: Iterable[str]) ->Dict[...\n", "\"\"\"docstring\"\"\"\n", "VAR_64 = await self.store.get_events(VAR_14, allow_rejected=True)\n", "VAR_65 = set(VAR_14) - VAR_64.keys()\n", "if VAR_65:\n", "VAR_0.debug('Fetching unknown state/auth events %s for room %s', VAR_65, VAR_11\n )\n", "VAR_66 = [(VAR_12, VAR_1.room_id) for VAR_12, VAR_1 in VAR_64.items() if \n VAR_1.room_id != VAR_11]\n", "await self._get_events_and_persist(VAR_10=destination, VAR_11=room_id,\n VAR_20=missing_events)\n", "for bad_event_id, bad_room_id in VAR_66:\n", "VAR_64.update(await self.store.get_events(VAR_65, allow_rejected=True))\n", "VAR_0.warning(\n 'Remote server %s claims event %s in room %s is an auth/state event in room %s'\n , VAR_10, bad_event_id, bad_room_id, VAR_11)\n", "return VAR_64\n" ]
[ "async def _get_events_from_store_or_dest(self, destination: str, room_id:...\n", "\"\"\"docstring\"\"\"\n", "fetched_events = await self.store.get_events(event_ids, allow_rejected=True)\n", "missing_events = set(event_ids) - fetched_events.keys()\n", "if missing_events:\n", "logger.debug('Fetching unknown state/auth events %s for room %s',\n missing_events, room_id)\n", "bad_events = [(event_id, event.room_id) for event_id, event in\n fetched_events.items() if event.room_id != room_id]\n", "await self._get_events_and_persist(destination=destination, room_id=room_id,\n events=missing_events)\n", "for bad_event_id, bad_room_id in bad_events:\n", "fetched_events.update(await self.store.get_events(missing_events,\n allow_rejected=True))\n", "logger.warning(\n 'Remote server %s claims event %s in room %s is an auth/state event in room %s'\n , destination, bad_event_id, bad_room_id, room_id)\n", "return fetched_events\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "For", "Expr'", "Expr'", "Return'" ]
[ "@FUNC_0...\n", "return EventBuilderFactory(self)\n" ]
[ "@cache_in_self...\n", "return EventBuilderFactory(self)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def __init__(self, VAR_200=None, VAR_201=None, VAR_202=None, VAR_203=True,...\n", "\"\"\"docstring\"\"\"\n", "self.follow_symlink_out = VAR_204\n", "self.base = self.normalize_path(VAR_200 or VAR_418.path.join(VAR_263.\n request.folder, 'static'))\n", "self.basename = VAR_201 or VAR_263.request.function\n", "self.base = VAR_200 = VAR_418.path.realpath(VAR_200 or VAR_418.path.join(\n VAR_263.request.folder, 'static'))\n", "VAR_201 = VAR_201 or VAR_263.request.function\n", "self.basename = VAR_201\n", "if VAR_263.request.raw_args:\n", "self.args = [arg for arg in VAR_263.request.raw_args.split('/') if arg]\n", "self.args = [arg for arg in VAR_263.request.args if arg]\n", "VAR_94 = VAR_418.path.join(self.base, *self.args)\n", "if not VAR_418.path.exists(VAR_94):\n", "if not self.in_base(VAR_94):\n", "if VAR_203 and not VAR_418.path.isdir(VAR_94):\n", "VAR_263.response.headers['Content-Type'] = contenttype(VAR_94)\n", "self.path = VAR_324 = VAR_418.path.join(VAR_94, '*')\n", "VAR_325 = len(VAR_324) - 1\n", "VAR_326 = [VAR_10 for VAR_10 in sorted(glob.glob(VAR_324)) if not any([self\n .isprivate(VAR_10), self.issymlink_out(VAR_10)])]\n", "self.folders = [VAR_10[VAR_325:] for VAR_10 in VAR_326 if VAR_418.path.\n isdir(VAR_10)]\n", "self.filenames = [VAR_10[VAR_325:] for VAR_10 in VAR_326 if not VAR_418.\n path.isdir(VAR_10)]\n", "if 'README' in self.filenames:\n", "VAR_439 = VAR_10.read()\n", "self.paragraph = None\n", "self.paragraph = MARKMIN(VAR_439)\n", "if VAR_202:\n", "self.filenames = [VAR_10 for VAR_10 in self.filenames if VAR_418.path.\n splitext(VAR_10)[-1] in VAR_202]\n" ]
[ "def __init__(self, base=None, basename=None, extensions=None,...\n", "\"\"\"docstring\"\"\"\n", "self.follow_symlink_out = follow_symlink_out\n", "self.base = self.normalize_path(base or os.path.join(current.request.folder,\n 'static'))\n", "self.basename = basename or current.request.function\n", "self.base = base = os.path.realpath(base or os.path.join(current.request.\n folder, 'static'))\n", "basename = basename or current.request.function\n", "self.basename = basename\n", "if current.request.raw_args:\n", "self.args = [arg for arg in current.request.raw_args.split('/') if arg]\n", "self.args = [arg for arg in current.request.args if arg]\n", "filename = os.path.join(self.base, *self.args)\n", "if not os.path.exists(filename):\n", "if not self.in_base(filename):\n", "if allow_download and not os.path.isdir(filename):\n", "current.response.headers['Content-Type'] = contenttype(filename)\n", "self.path = path = os.path.join(filename, '*')\n", "dirname_len = len(path) - 1\n", "allowed = [f for f in sorted(glob.glob(path)) if not any([self.isprivate(f),\n self.issymlink_out(f)])]\n", "self.folders = [f[dirname_len:] for f in allowed if os.path.isdir(f)]\n", "self.filenames = [f[dirname_len:] for f in allowed if not os.path.isdir(f)]\n", "if 'README' in self.filenames:\n", "readme = f.read()\n", "self.paragraph = None\n", "self.paragraph = MARKMIN(readme)\n", "if extensions:\n", "self.filenames = [f for f in self.filenames if os.path.splitext(f)[-1] in\n extensions]\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 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'" ]
[ "def FUNC_17(self, VAR_20=False, VAR_15=None, VAR_16=True):...\n", "\"\"\"docstring\"\"\"\n", "if self.flags.name_set and not VAR_20:\n", "return\n", "if self.get('__newname'):\n", "self.name = self.get('__newname')\n", "if VAR_15:\n", "self.flags.name_set = True\n", "self.name = VAR_15\n", "FUNC_17(self)\n", "return\n", "if VAR_16:\n", "for VAR_21 in self.get_all_children():\n", "self.flags.name_set = True\n", "FUNC_17(VAR_21)\n" ]
[ "def set_new_name(self, force=False, set_name=None, set_child_names=True):...\n", "\"\"\"docstring\"\"\"\n", "if self.flags.name_set and not force:\n", "return\n", "if self.get('__newname'):\n", "self.name = self.get('__newname')\n", "if set_name:\n", "self.flags.name_set = True\n", "self.name = set_name\n", "set_new_name(self)\n", "return\n", "if set_child_names:\n", "for d in self.get_all_children():\n", "self.flags.name_set = True\n", "set_new_name(d)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Return'", "Condition", "For", "Assign'", "Expr'" ]
[ "def FUNC_7(self, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "self.current_value = VAR_3.id\n" ]
[ "def visit_Name(self, node):...\n", "\"\"\"docstring\"\"\"\n", "self.current_value = node.id\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'" ]
[ "def FUNC_31(self):...\n", "self.inline._in_footnote = True\n", "VAR_67 = self.renderer.placeholder()\n", "VAR_13 = self.token['key']\n", "while self.pop()['type'] != 'footnote_end':\n", "VAR_67 += self.tok()\n", "self.footnotes.append({'key': VAR_13, 'text': VAR_67})\n", "self.inline._in_footnote = False\n", "return self.renderer.placeholder()\n" ]
[ "def output_footnote(self):...\n", "self.inline._in_footnote = True\n", "body = self.renderer.placeholder()\n", "key = self.token['key']\n", "while self.pop()['type'] != 'footnote_end':\n", "body += self.tok()\n", "self.footnotes.append({'key': key, 'text': body})\n", "self.inline._in_footnote = False\n", "return self.renderer.placeholder()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "AugAssign'", "Expr'", "Assign'", "Return'" ]
[ "@VAR_8.route('/static/<path:path>', methods=['GET'])...\n", "if VAR_8.interface.share:\n", "return redirect(VAR_39 + VAR_17)\n", "return send_file(safe_join(VAR_6, VAR_17))\n" ]
[ "@app.route('/static/<path:path>', methods=['GET'])...\n", "if app.interface.share:\n", "return redirect(GRADIO_STATIC_ROOT + path)\n", "return send_file(safe_join(STATIC_PATH_LIB, path))\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Condition", "Return'", "Return'" ]
[ "def FUNC_45(self):...\n", "VAR_12 = 'hello'\n", "VAR_22, VAR_23 = self.make_request('POST',\n '/_matrix/client/r0/rooms/{}/invite'.format(self.room_id), VAR_19={\n 'reason': reason, 'user_id': self.second_user_id}, VAR_16=self.creator_tok)\n", "self.assertEqual(VAR_23.code, 200, VAR_23.result)\n", "self._check_for_reason(VAR_12)\n" ]
[ "def test_invite_reason(self):...\n", "reason = 'hello'\n", "request, channel = self.make_request('POST',\n '/_matrix/client/r0/rooms/{}/invite'.format(self.room_id), content={\n 'reason': reason, 'user_id': self.second_user_id}, access_token=self.\n creator_tok)\n", "self.assertEqual(channel.code, 200, channel.result)\n", "self._check_for_reason(reason)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "from __future__ import unicode_literals, print_function\n", "import frappe\n", "import time\n", "from frappe import _, msgprint\n", "from frappe.utils import flt, cstr, now, get_datetime_str, file_lock, date_diff\n", "from frappe.model.base_document import BaseDocument, get_controller\n", "from frappe.model.naming import set_new_name\n", "from six import iteritems, string_types\n", "from werkzeug.exceptions import NotFound, Forbidden\n", "import hashlib, json\n", "from frappe.model import optional_fields, table_fields\n", "from frappe.model.workflow import validate_workflow\n", "from frappe.model.workflow import set_workflow_state_on_action\n", "from frappe.utils.global_search import update_global_search\n", "from frappe.integrations.doctype.webhook import run_webhooks\n", "from frappe.desk.form.document_follow import follow_document\n", "from frappe.core.doctype.server_script.server_script_utils import run_server_script_for_doc_event\n", "def FUNC_0(*VAR_0, **VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_0:\n", "if isinstance(VAR_0[0], BaseDocument):\n", "if len(VAR_0) < 2 and VAR_1:\n", "return VAR_0[0]\n", "if isinstance(VAR_0[0], string_types):\n", "if 'doctype' in VAR_1:\n", "VAR_5 = get_controller(VAR_2)\n", "VAR_2 = VAR_0[0]\n", "if isinstance(VAR_0[0], dict):\n", "VAR_2 = VAR_1['doctype']\n", "if VAR_5:\n", "VAR_1 = VAR_0[0]\n", "return VAR_5(*VAR_0, **kwargs)\n", "\"\"\"All controllers inherit from `Document`.\"\"\"\n", "def __init__(self, *VAR_0, **VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "self.doctype = self.name = None\n", "self._default_new_docs = {}\n", "self.flags = frappe._dict()\n", "if VAR_0 and VAR_0[0] and isinstance(VAR_0[0], string_types):\n", "if len(VAR_0) == 1:\n", "if VAR_0 and VAR_0[0] and isinstance(VAR_0[0], dict):\n", "self.doctype = self.name = VAR_0[0]\n", "self.doctype = VAR_0[0]\n", "VAR_1 = VAR_0[0]\n", "if VAR_1:\n", "self.load_from_db()\n", "if isinstance(VAR_0[1], dict):\n", "super(CLASS_0, self).__init__(VAR_1)\n", "@staticmethod...\n", "return\n", "self.name = frappe.db.get_value(VAR_0[0], VAR_0[1], 'name')\n", "self.name = VAR_0[1]\n", "self.init_valid_columns()\n", "\"\"\"docstring\"\"\"\n", "if self.name is None:\n", "if 'for_update' in VAR_1:\n", "VAR_6.whitelisted = True\n", "frappe.throw(_('{0} {1} not found').format(_(VAR_0[0]), VAR_0[1]), frappe.\n DoesNotExistError)\n", "self.flags.for_update = VAR_1.get('for_update')\n", "return VAR_6\n" ]
[ "from __future__ import unicode_literals, print_function\n", "import frappe\n", "import time\n", "from frappe import _, msgprint\n", "from frappe.utils import flt, cstr, now, get_datetime_str, file_lock, date_diff\n", "from frappe.model.base_document import BaseDocument, get_controller\n", "from frappe.model.naming import set_new_name\n", "from six import iteritems, string_types\n", "from werkzeug.exceptions import NotFound, Forbidden\n", "import hashlib, json\n", "from frappe.model import optional_fields, table_fields\n", "from frappe.model.workflow import validate_workflow\n", "from frappe.model.workflow import set_workflow_state_on_action\n", "from frappe.utils.global_search import update_global_search\n", "from frappe.integrations.doctype.webhook import run_webhooks\n", "from frappe.desk.form.document_follow import follow_document\n", "from frappe.core.doctype.server_script.server_script_utils import run_server_script_for_doc_event\n", "def get_doc(*args, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "if args:\n", "if isinstance(args[0], BaseDocument):\n", "if len(args) < 2 and kwargs:\n", "return args[0]\n", "if isinstance(args[0], string_types):\n", "if 'doctype' in kwargs:\n", "controller = get_controller(doctype)\n", "doctype = args[0]\n", "if isinstance(args[0], dict):\n", "doctype = kwargs['doctype']\n", "if controller:\n", "kwargs = args[0]\n", "return controller(*args, **kwargs)\n", "\"\"\"All controllers inherit from `Document`.\"\"\"\n", "def __init__(self, *args, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "self.doctype = self.name = None\n", "self._default_new_docs = {}\n", "self.flags = frappe._dict()\n", "if args and args[0] and isinstance(args[0], string_types):\n", "if len(args) == 1:\n", "if args and args[0] and isinstance(args[0], dict):\n", "self.doctype = self.name = args[0]\n", "self.doctype = args[0]\n", "kwargs = args[0]\n", "if kwargs:\n", "self.load_from_db()\n", "if isinstance(args[1], dict):\n", "super(Document, self).__init__(kwargs)\n", "@staticmethod...\n", "return\n", "self.name = frappe.db.get_value(args[0], args[1], 'name')\n", "self.name = args[1]\n", "self.init_valid_columns()\n", "\"\"\"docstring\"\"\"\n", "if self.name is None:\n", "if 'for_update' in kwargs:\n", "f.whitelisted = True\n", "frappe.throw(_('{0} {1} not found').format(_(args[0]), args[1]), frappe.\n DoesNotExistError)\n", "self.flags.for_update = kwargs.get('for_update')\n", "return f\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, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2 ]
[ "ImportFrom'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Docstring", "Condition", "Condition", "Condition", "Return'", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Return'", "Expr'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Return'", "Assign'", "Assign'", "Expr'", "Docstring", "Condition", "For", "Assign'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_16(self):...\n", "VAR_3 = self.client.get('/reset/123456/1-1/')\n", "self.assertContains(VAR_3, 'The password reset link was invalid')\n" ]
[ "def test_confirm_invalid_user(self):...\n", "response = self.client.get('/reset/123456/1-1/')\n", "self.assertContains(response, 'The password reset link was invalid')\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "@override_settings(DEBUG_PROPAGATE_EXCEPTIONS=True)...\n", "\"\"\"docstring\"\"\"\n", "VAR_3 = self.client.post('/admin_password_reset/', {'email':\n 'staffmember@example.com'}, HTTP_HOST=\n 'www.example:dr.frankenstein@evil.tld')\n", "self.assertEqual(VAR_3.status_code, 400)\n", "self.assertEqual(len(mail.outbox), 0)\n", "self.assertEqual(len(logger_calls), 1)\n" ]
[ "@override_settings(DEBUG_PROPAGATE_EXCEPTIONS=True)...\n", "\"\"\"docstring\"\"\"\n", "response = self.client.post('/admin_password_reset/', {'email':\n 'staffmember@example.com'}, HTTP_HOST=\n 'www.example:dr.frankenstein@evil.tld')\n", "self.assertEqual(response.status_code, 400)\n", "self.assertEqual(len(mail.outbox), 0)\n", "self.assertEqual(len(logger_calls), 1)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Expr'", "Expr'", "Expr'" ]