lines
sequencelengths
1
383
raw_lines
sequencelengths
1
383
label
sequencelengths
1
383
type
sequencelengths
1
383
[ "@VAR_2.route('/table')...\n", "VAR_78 = VAR_87.view_settings.get('table', {})\n", "return render_title_template('book_table.html', VAR_149=_(u'Books List'),\n VAR_9='book_table', visiblility=visibility)\n" ]
[ "@web.route('/table')...\n", "visibility = current_user.view_settings.get('table', {})\n", "return render_title_template('book_table.html', title=_(u'Books List'),\n page='book_table', visiblility=visibility)\n" ]
[ 0, 0, 0 ]
[ "Condition", "Assign'", "Return'" ]
[ "def FUNC_43(self, VAR_53, VAR_54):...\n", "return VAR_53 * VAR_54\n" ]
[ "def multiply(self, a, b):...\n", "return a * b\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_87(self):...\n", "if not self.can_edit():\n", "return self.not_authorized()\n", "VAR_101 = self.auth.db\n", "VAR_338 = VAR_101(VAR_101.wiki_page.id > 0).select(VAR_101.wiki_page.id,\n VAR_101.wiki_page.slug)\n", "VAR_61 = [OPTION(VAR_266.slug, _value=row.id) for VAR_266 in VAR_338]\n", "VAR_61.insert(0, OPTION('', _value=''))\n", "VAR_133 = [VAR_1('slug', VAR_5=current.request.args(1) or self.settings.\n force_prefix, VAR_279=(IS_SLUG(), IS_NOT_IN_DB(db, db.wiki_page.slug)))]\n", "if self.settings.templates:\n", "VAR_133.append(VAR_1('from_template', 'reference wiki_page', VAR_279=\n IS_EMPTY_OR(IS_IN_DB(db(self.settings.templates), db.wiki_page._id,\n '%(slug)s')), VAR_62=current.T('Choose Template or empty for new Page')))\n", "VAR_7 = SQLFORM.factory(*VAR_133, **dict(_class='well'))\n", "VAR_7.element('[type=submit]').attributes['_value'] = VAR_263.T(\n 'Create Page from Slug')\n", "if VAR_7.process().accepted:\n", "VAR_7.vars.from_template = (0 if not VAR_7.vars.from_template else VAR_7.\n vars.from_template)\n", "return dict(VAR_229=form)\n", "redirect(URL(VAR_11=('_edit', form.vars.slug, form.vars.from_template or 0)))\n" ]
[ "def create(self):...\n", "if not self.can_edit():\n", "return self.not_authorized()\n", "db = self.auth.db\n", "slugs = db(db.wiki_page.id > 0).select(db.wiki_page.id, db.wiki_page.slug)\n", "options = [OPTION(row.slug, _value=row.id) for row in slugs]\n", "options.insert(0, OPTION('', _value=''))\n", "fields = [Field('slug', default=current.request.args(1) or self.settings.\n force_prefix, requires=(IS_SLUG(), IS_NOT_IN_DB(db, db.wiki_page.slug)))]\n", "if self.settings.templates:\n", "fields.append(Field('from_template', 'reference wiki_page', requires=\n IS_EMPTY_OR(IS_IN_DB(db(self.settings.templates), db.wiki_page._id,\n '%(slug)s')), comment=current.T('Choose Template or empty for new Page')))\n", "form = SQLFORM.factory(*fields, **dict(_class='well'))\n", "form.element('[type=submit]').attributes['_value'] = current.T(\n 'Create Page from Slug')\n", "if form.process().accepted:\n", "form.vars.from_template = (0 if not form.vars.from_template else form.vars.\n from_template)\n", "return dict(content=form)\n", "redirect(URL(args=('_edit', form.vars.slug, form.vars.from_template or 0)))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Expr'" ]
[ "@VAR_0.route('/api/preferences/get/<key>')...\n", "if get_user() is None:\n", "return 'Authentication required', 401\n", "if VAR_10 in VAR_31():\n", "return Response(json.dumps({'key': VAR_10, 'value': VAR_31()[VAR_10]}))\n", "return Response(json.dumps({'key': VAR_10, 'error': 'novalue'}))\n" ]
[ "@app.route('/api/preferences/get/<key>')...\n", "if get_user() is None:\n", "return 'Authentication required', 401\n", "if key in get_preferences():\n", "return Response(json.dumps({'key': key, 'value': get_preferences()[key]}))\n", "return Response(json.dumps({'key': key, 'error': 'novalue'}))\n" ]
[ 0, 0, 0, 0, 2, 2 ]
[ "Condition", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "def FUNC_13():...\n", "yield '<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\\n'\n", "if VAR_1:\n", "yield '<?xml-stylesheet type=\"text/xsl\" href=\"/scopelist.xsl\" ?>\\n'\n", "yield '<objectlist count=\"{:d}\">\\n'.format(VAR_43)\n", "VAR_44 = 0\n", "VAR_45 = 0\n", "if VAR_27:\n", "VAR_44 = int(VAR_25 * VAR_5)\n", "VAR_46 = []\n", "VAR_49 = cycle(VAR_17)\n", "def FUNC_15():...\n", "random.seed(VAR_24)\n", "return list(map(lambda x: x + VAR_5 * VAR_45, sorted(random.sample(list(\n range(VAR_5)), VAR_44))))\n" ]
[ "def generate():...\n", "yield '<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\\n'\n", "if STYLE:\n", "yield '<?xml-stylesheet type=\"text/xsl\" href=\"/scopelist.xsl\" ?>\\n'\n", "yield '<objectlist count=\"{:d}\">\\n'.format(total_entries)\n", "mix_per_iteration = 0\n", "iteration_count = 0\n", "if make_cocktail:\n", "mix_per_iteration = int(percentage * ITEMS_PER_ITERATION)\n", "mix_indices = []\n", "pool = cycle(mixer_list)\n", "def generate_mix_indices():...\n", "random.seed(seed)\n", "return list(map(lambda x: x + ITEMS_PER_ITERATION * iteration_count, sorted\n (random.sample(list(range(ITEMS_PER_ITERATION)), mix_per_iteration))))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Condition", "Expr'", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Expr'", "Return'" ]
[ "def __str__(self):...\n", "return '%s' % self.name\n" ]
[ "def __str__(self):...\n", "return '%s' % self.name\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@wraps(VAR_14)...\n", "VAR_112 = None\n", "if 'X-Access-Token' in request.headers:\n", "VAR_112 = request.headers['X-Access-Token']\n", "if not VAR_112:\n", "return jsonify({'success': False, 'message': 'Token is missing'}), 401\n", "VAR_13 = jwt.decode(VAR_112, VAR_0.config['SECRET_KEY'], algorithms=['HS256'])\n", "return jsonify({'success': False, 'message': 'Token is expired'}), 401\n", "return VAR_14(VAR_15, *VAR_25, **kwargs)\n", "VAR_15 = CLASS_0.query.filter_by(VAR_36=data['public_id']).first()\n", "if VAR_15 is None:\n", "return jsonify({'success': False, 'message': 'Token is old. Please renew'}\n ), 401\n" ]
[ "@wraps(f)...\n", "token = None\n", "if 'X-Access-Token' in request.headers:\n", "token = request.headers['X-Access-Token']\n", "if not token:\n", "return jsonify({'success': False, 'message': 'Token is missing'}), 401\n", "data = jwt.decode(token, gui.config['SECRET_KEY'], algorithms=['HS256'])\n", "return jsonify({'success': False, 'message': 'Token is expired'}), 401\n", "return f(current_api_user, *args, **kwargs)\n", "current_api_user = User.query.filter_by(public_id=data['public_id']).first()\n", "if current_api_user is None:\n", "return jsonify({'success': False, 'message': 'Token is old. Please renew'}\n ), 401\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Assign'", "Condition", "Return'", "Assign'", "Return'", "Return'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_15():...\n", "random.seed(VAR_24)\n", "return list(map(lambda x: x + VAR_5 * VAR_45, sorted(random.sample(list(\n range(VAR_5)), VAR_44))))\n" ]
[ "def generate_mix_indices():...\n", "random.seed(seed)\n", "return list(map(lambda x: x + ITEMS_PER_ITERATION * iteration_count, sorted\n (random.sample(list(range(ITEMS_PER_ITERATION)), mix_per_iteration))))\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Return'" ]
[ "@ensure_csrf_cookie...\n", "\"\"\"docstring\"\"\"\n", "VAR_10 = SlashSeparatedCourseKey.from_deprecated_string(VAR_10)\n", "VAR_135 = ReportStore.from_config(config_name='FINANCIAL_REPORTS')\n", "VAR_63 = {'downloads': [dict(VAR_16=name, VAR_147=url, link=HTML(\n '<a href=\"{}\">{}</a>').format(HTML(url), Text(name))) for VAR_16,\n VAR_147 in VAR_135.links_for(VAR_10)]}\n", "return JsonResponse(VAR_63)\n" ]
[ "@ensure_csrf_cookie...\n", "\"\"\"docstring\"\"\"\n", "course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n", "report_store = ReportStore.from_config(config_name='FINANCIAL_REPORTS')\n", "response_payload = {'downloads': [dict(name=name, url=url, link=HTML(\n '<a href=\"{}\">{}</a>').format(HTML(url), Text(name))) for name, url in\n report_store.links_for(course_id)]}\n", "return JsonResponse(response_payload)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_5(self, VAR_5) ->CLASS_4:...\n", "return CLASS_4(os.path.join(self.directory(), VAR_5))\n" ]
[ "def relative(self, relativePath) ->FileInputSource:...\n", "return FileInputSource(os.path.join(self.directory(), relativePath))\n" ]
[ 0, 1 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_0(VAR_0):...\n", "return os.path.join(os.path.dirname(__file__), VAR_0)\n" ]
[ "def fpath(name):...\n", "return os.path.join(os.path.dirname(__file__), name)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "async def FUNC_16(self, VAR_19: int, VAR_20: int=0, VAR_21: bool=True) ->Tuple[...\n", "\"\"\"docstring\"\"\"\n", "VAR_38 = await self.store.get_local_media_before(VAR_19, VAR_20, VAR_21)\n", "return await self._remove_local_media_from_disk(VAR_38)\n" ]
[ "async def delete_old_local_media(self, before_ts: int, size_gt: int=0,...\n", "\"\"\"docstring\"\"\"\n", "old_media = await self.store.get_local_media_before(before_ts, size_gt,\n keep_profiles)\n", "return await self._remove_local_media_from_disk(old_media)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_0():...\n", "VAR_6 = gspread.authorize(VAR_14).open('문학따먹기')\n", "VAR_7 = VAR_6.get_worksheet(0)\n", "VAR_8 = VAR_7.get_all_values()\n", "print(VAR_8)\n", "VAR_16 = []\n", "VAR_3 = VAR_16\n", "for row in VAR_8[1:]:\n", "print(VAR_16)\n", "VAR_31 = namedtuple('Munhak', VAR_8[0])(*row)\n", "return\n", "VAR_31 = VAR_31._replace(keywords=json.loads(row_tuple.keywords))\n", "if VAR_31.is_available == 'TRUE':\n", "VAR_16.append(VAR_31)\n" ]
[ "def update():...\n", "gc = gspread.authorize(credentials).open('문학따먹기')\n", "wks = gc.get_worksheet(0)\n", "rows = wks.get_all_values()\n", "print(rows)\n", "data = []\n", "munhak_rows_data = data\n", "for row in rows[1:]:\n", "print(data)\n", "row_tuple = namedtuple('Munhak', rows[0])(*row)\n", "return\n", "row_tuple = row_tuple._replace(keywords=json.loads(row_tuple.keywords))\n", "if row_tuple.is_available == 'TRUE':\n", "data.append(row_tuple)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "For", "Expr'", "Assign'", "Return'", "Assign'", "Condition", "Expr'" ]
[ "@VAR_0.route('/shelf/order/<int:shelf_id>', methods=['GET', 'POST'])...\n", "if request.method == 'POST':\n", "VAR_20 = request.form.to_dict()\n", "VAR_0 = ub.session.query(ub.Shelf).filter(ub.Shelf.id == VAR_3).first()\n", "VAR_18 = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == VAR_3\n ).order_by(ub.BookShelf.order.asc()).all()\n", "VAR_16 = list()\n", "VAR_24 = 0\n", "if VAR_0 and FUNC_1(VAR_0):\n", "for VAR_25 in VAR_18:\n", "VAR_16 = calibre_db.session.query(db.Books).join(ub.BookShelf, ub.BookShelf\n .book_id == db.Books.id, isouter=True).add_columns(calibre_db.\n common_filters().label('visible')).filter(ub.BookShelf.shelf == VAR_3\n ).order_by(ub.BookShelf.order.asc()).all()\n", "return render_title_template('shelf_order.html', entries=result, VAR_7=_(\n u\"Change order of Shelf: '%(name)s'\", name=shelf.name), VAR_0=shelf,\n VAR_6='shelforder')\n", "setattr(VAR_25, 'order', VAR_20[str(VAR_25.book_id)])\n", "ub.session.commit()\n", "ub.session.rollback()\n", "VAR_24 += 1\n", "VAR_1.error('Settings DB is not Writeable')\n", "flash(_('Settings DB is not Writeable'), category='error')\n" ]
[ "@shelf.route('/shelf/order/<int:shelf_id>', methods=['GET', 'POST'])...\n", "if request.method == 'POST':\n", "to_save = request.form.to_dict()\n", "shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()\n", "books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf ==\n shelf_id).order_by(ub.BookShelf.order.asc()).all()\n", "result = list()\n", "counter = 0\n", "if shelf and check_shelf_view_permissions(shelf):\n", "for book in books_in_shelf:\n", "result = calibre_db.session.query(db.Books).join(ub.BookShelf, ub.BookShelf\n .book_id == db.Books.id, isouter=True).add_columns(calibre_db.\n common_filters().label('visible')).filter(ub.BookShelf.shelf == shelf_id\n ).order_by(ub.BookShelf.order.asc()).all()\n", "return render_title_template('shelf_order.html', entries=result, title=_(\n u\"Change order of Shelf: '%(name)s'\", name=shelf.name), shelf=shelf,\n page='shelforder')\n", "setattr(book, 'order', to_save[str(book.book_id)])\n", "ub.session.commit()\n", "ub.session.rollback()\n", "counter += 1\n", "log.error('Settings DB is not Writeable')\n", "flash(_('Settings DB is not Writeable'), category='error')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "For", "Assign'", "Return'", "Expr'", "Expr'", "Expr'", "AugAssign'", "Expr'", "Expr'" ]
[ "def FUNC_41(self, VAR_44):...\n", "VAR_14 = VAR_44.group(0)\n", "return self.renderer.text(VAR_14)\n" ]
[ "def output_text(self, m):...\n", "text = m.group(0)\n", "return self.renderer.text(text)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_3(self):...\n", "self.assertFormfield(models.Event, 'start_time', widgets.AdminTimeWidget)\n" ]
[ "def testTimeField(self):...\n", "self.assertFormfield(models.Event, 'start_time', widgets.AdminTimeWidget)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_84(self, VAR_148, VAR_153, VAR_168=0):...\n", "if not self.settings.auth:\n", "return True\n", "VAR_150 = VAR_168.id\n", "VAR_150 = VAR_168\n", "return self.settings.auth.has_permission(VAR_148, str(VAR_153), VAR_150)\n" ]
[ "def has_permission(self, name, table, record=0):...\n", "if not self.settings.auth:\n", "return True\n", "record_id = record.id\n", "record_id = record\n", "return self.settings.auth.has_permission(name, str(table), record_id)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_31(VAR_31):...\n", "VAR_63 = \"'\" * isinstance(VAR_31, str)\n", "return VAR_63 + str(VAR_31) + VAR_63\n" ]
[ "def _maybe_add_quotes(value):...\n", "is_quotes = \"'\" * isinstance(value, str)\n", "return is_quotes + str(value) + is_quotes\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def __call__(self, VAR_11):...\n", "self._function = VAR_11\n", "VAR_2[self._name] = self.wrapper\n", "return VAR_11\n" ]
[ "def __call__(self, function):...\n", "self._function = function\n", "_HANDLERS[self._name] = self.wrapper\n", "return function\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_6(VAR_12, VAR_1):...\n", "if not VAR_12.dialect.has_table(VAR_12.connect(), 'book_read_link'):\n", "CLASS_8.__table__.create(bind=engine)\n", "if not VAR_12.dialect.has_table(VAR_12.connect(), 'bookmark'):\n", "CLASS_9.__table__.create(bind=engine)\n", "if not VAR_12.dialect.has_table(VAR_12.connect(), 'kobo_reading_state'):\n", "CLASS_11.__table__.create(bind=engine)\n", "if not VAR_12.dialect.has_table(VAR_12.connect(), 'kobo_bookmark'):\n", "CLASS_12.__table__.create(bind=engine)\n", "if not VAR_12.dialect.has_table(VAR_12.connect(), 'kobo_statistics'):\n", "CLASS_13.__table__.create(bind=engine)\n", "if not VAR_12.dialect.has_table(VAR_12.connect(), 'archived_book'):\n", "CLASS_10.__table__.create(bind=engine)\n", "if not VAR_12.dialect.has_table(VAR_12.connect(), 'registration'):\n", "CLASS_15.__table__.create(bind=engine)\n", "conn.execute(\"insert into registration (domain, allow) values('%.%',1)\")\n", "VAR_1.commit()\n" ]
[ "def add_missing_tables(engine, session):...\n", "if not engine.dialect.has_table(engine.connect(), 'book_read_link'):\n", "ReadBook.__table__.create(bind=engine)\n", "if not engine.dialect.has_table(engine.connect(), 'bookmark'):\n", "Bookmark.__table__.create(bind=engine)\n", "if not engine.dialect.has_table(engine.connect(), 'kobo_reading_state'):\n", "KoboReadingState.__table__.create(bind=engine)\n", "if not engine.dialect.has_table(engine.connect(), 'kobo_bookmark'):\n", "KoboBookmark.__table__.create(bind=engine)\n", "if not engine.dialect.has_table(engine.connect(), 'kobo_statistics'):\n", "KoboStatistics.__table__.create(bind=engine)\n", "if not engine.dialect.has_table(engine.connect(), 'archived_book'):\n", "ArchivedBook.__table__.create(bind=engine)\n", "if not engine.dialect.has_table(engine.connect(), 'registration'):\n", "Registration.__table__.create(bind=engine)\n", "conn.execute(\"insert into registration (domain, allow) values('%.%',1)\")\n", "session.commit()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_2(self, VAR_0, VAR_1, VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "return (VAR_0, VAR_1, VAR_2) in self._allowed\n" ]
[ "def is_allowed(self, role, method, resource):...\n", "\"\"\"docstring\"\"\"\n", "return (role, method, resource) in self._allowed\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_13(self):...\n", "VAR_29 = self.helper.create_room_as('@some_other_guy:red')\n", "VAR_22, VAR_23 = self.make_request('GET', '/rooms/%s/members' % VAR_29)\n", "self.assertEquals(403, VAR_23.code, msg=channel.result['body'])\n" ]
[ "def test_get_member_list_no_permission(self):...\n", "room_id = self.helper.create_room_as('@some_other_guy:red')\n", "request, channel = self.make_request('GET', '/rooms/%s/members' % room_id)\n", "self.assertEquals(403, channel.code, msg=channel.result['body'])\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'" ]
[ "@VAR_0.route('/shelf/create', methods=['GET', 'POST'])...\n", "VAR_0 = ub.Shelf()\n", "return FUNC_7(VAR_0, VAR_5=_(u'Create a Shelf'), VAR_6='shelfcreate')\n" ]
[ "@shelf.route('/shelf/create', methods=['GET', 'POST'])...\n", "shelf = ub.Shelf()\n", "return create_edit_shelf(shelf, page_title=_(u'Create a Shelf'), page=\n 'shelfcreate')\n" ]
[ 0, 0, 0 ]
[ "Condition", "Assign'", "Return'" ]
[ "import os\n", "import re\n", "from flask.testing import FlaskClient\n", "from flask import request\n", "from flask_login import current_user\n", "from responses import RequestsMock, GET\n", "from werkzeug.security import generate_password_hash\n", "from archivy.helpers import get_max_id, get_db\n", "from archivy.data import get_dirs, create_dir, get_items, get_item\n", "def FUNC_0(VAR_0, VAR_1: FlaskClient):...\n", "VAR_5 = VAR_1.get('/')\n", "assert VAR_5.status_code == 200\n", "def FUNC_1(VAR_0, VAR_1: FlaskClient):...\n", "VAR_0.config['THEME_CONF']['use_custom_css'] = True\n", "VAR_6 = 'custom.css'\n", "VAR_7 = \"\"\"\n body {\n color: red\n }\n \"\"\"\n", "os.mkdir(f\"{VAR_0.config['USER_DIR']}/css/\")\n", "f.write(VAR_7)\n", "VAR_0.config['THEME_CONF']['custom_css_file'] = VAR_6\n", "VAR_8 = VAR_1.get('/static/custom.css')\n", "assert VAR_7.encode('utf-8') in VAR_8.data\n", "VAR_0.config['THEME_CONF']['use_custom_css'] = False\n", "def FUNC_2(VAR_0, VAR_1: FlaskClient):...\n", "VAR_5 = VAR_1.get('/bookmarks/new')\n", "assert VAR_5.status_code == 200\n", "def FUNC_3(VAR_0, VAR_1: FlaskClient):...\n", "VAR_5 = VAR_1.post('/bookmarks/new', data={'submit': True})\n", "assert VAR_5.status_code == 200\n", "assert b'This field is required' in VAR_5.data\n", "def FUNC_4(VAR_0, VAR_1: FlaskClient):...\n", "VAR_5 = VAR_1.get('/notes/new')\n", "assert VAR_5.status_code == 200\n", "def FUNC_5(VAR_0, VAR_1: FlaskClient):...\n", "VAR_5 = VAR_1.get('/dataobj/1')\n", "assert VAR_5.status_code == 302\n", "def FUNC_6(VAR_0, VAR_1: FlaskClient, VAR_2):...\n", "VAR_5 = VAR_1.get('/dataobj/1')\n", "assert VAR_5.status_code == 200\n", "def FUNC_7(VAR_0, VAR_1: FlaskClient):...\n", "VAR_5 = VAR_1.get('/dataobj/delete/1')\n", "assert VAR_5.status_code == 302\n", "def FUNC_8(VAR_0, VAR_1: FlaskClient, VAR_2):...\n", "VAR_5 = VAR_1.get('/dataobj/delete/1')\n", "assert VAR_5.status_code == 302\n", "def FUNC_9(VAR_0, VAR_1: FlaskClient, VAR_3: RequestsMock):...\n", "VAR_3.add(GET, 'https://example.com/', body=\n \"\"\"<html>\n <head><title>Random</title></head><body><p>\n Lorem ipsum dolor sit amet, consectetur adipiscing elit\n </p></body></html>\n \"\"\"\n )\n", "VAR_9 = {'url': 'https://example.com', 'tags': 'testing,bookmark', 'path':\n '', 'submit': 'true'}\n", "VAR_8 = VAR_1.post('/bookmarks/new', data=bookmark_data)\n", "assert VAR_8.status_code == 302\n", "assert not b'invalid' in VAR_8.data\n", "VAR_8 = VAR_1.post('/bookmarks/new', data=bookmark_data, follow_redirects=True)\n", "assert VAR_8.status_code == 200\n", "assert b'<span class=\"post-tag\">bookmark</span>' in VAR_8.data\n", "assert b'<span class=\"post-tag\">testing</span>' in VAR_8.data\n", "assert b'https://example.com' in VAR_8.data\n", "assert b'Random' in VAR_8.data\n", "def FUNC_10(VAR_0, VAR_1, VAR_3):...\n", "VAR_3.add(GET, 'http://example.org', body='Example\\n')\n", "VAR_10 = 'bookmarks'\n", "VAR_0.config['DEFAULT_BOOKMARKS_DIR'] = VAR_10\n", "create_dir(VAR_10)\n", "VAR_8 = VAR_1.post('/bookmarks/new', data={'url': 'http://example.org',\n 'submit': 'true'})\n", "VAR_11 = get_items(structured=False)[0]\n", "assert 'bookmarks' in VAR_11['path']\n", "def FUNC_11(VAR_0, VAR_1: FlaskClient):...\n", "VAR_12 = {'title': 'Testing the create route', 'tags': 'testing,note',\n 'path': '', 'submit': 'true'}\n", "VAR_8 = VAR_1.post('/notes/new', data=note_data)\n", "assert VAR_8.status_code == 302\n", "assert not b'invalid' in VAR_8.data\n", "VAR_8 = VAR_1.post('/notes/new', data=note_data, follow_redirects=True)\n", "assert VAR_8.status_code == 200\n", "assert b'<span class=\"post-tag\">note</span>' in VAR_8.data\n", "assert b'<span class=\"post-tag\">testing</span>' in VAR_8.data\n", "assert b'Testing the create route' in VAR_8.data\n", "def FUNC_12(VAR_0, VAR_1: FlaskClient):...\n", "VAR_8 = VAR_1.post('/login', data={'username': 'halcyon', 'password':\n 'password'}, follow_redirects=True)\n", "assert VAR_8.status_code == 200\n", "assert request.path == '/'\n", "assert current_user\n", "def FUNC_13(VAR_0, VAR_1: FlaskClient):...\n", "VAR_8 = VAR_1.post('/login', data={'username': 'invalid', 'password':\n 'dasdasd'}, follow_redirects=True)\n", "assert VAR_8.status_code == 200\n", "assert request.path == '/login'\n", "assert b'Invalid credentials' in VAR_8.data\n", "def FUNC_14(VAR_0, VAR_1: FlaskClient):...\n", "\"\"\"docstring\"\"\"\n", "VAR_13 = 'new_halcyon'\n", "VAR_14 = 'password2'\n", "VAR_8 = VAR_1.post('/user/edit', data={'username': new_user, 'password':\n new_pass}, follow_redirects=True)\n", "assert request.path == '/'\n", "VAR_1.delete('/logout')\n", "VAR_8 = VAR_1.post('/login', data={'username': new_user, 'password':\n new_pass}, follow_redirects=True)\n", "assert VAR_8.status_code == 200\n", "assert request.path == '/'\n", "def FUNC_15(VAR_0, VAR_1: FlaskClient):...\n", "\"\"\"docstring\"\"\"\n", "VAR_1.delete('/logout')\n", "VAR_8 = VAR_1.get('/', follow_redirects=True)\n", "assert request.path == '/login'\n", "def FUNC_16(VAR_0, VAR_1: FlaskClient):...\n", "\"\"\"docstring\"\"\"\n", "VAR_8 = VAR_1.post('/folders/create', data={'parent_dir': '', 'new_dir':\n 'testing'}, follow_redirects=True)\n", "assert VAR_8.status_code == 200\n", "assert request.args.get('path') == 'testing'\n", "assert 'testing' in get_dirs()\n", "assert b'Folder successfully created' in VAR_8.data\n", "def FUNC_17(VAR_0, VAR_1: FlaskClient):...\n", "VAR_8 = VAR_1.post('/folders/create', data={'parent_dir': ''},\n follow_redirects=True)\n", "assert VAR_8.status_code == 200\n", "assert request.path == '/'\n", "assert b'Could not create folder.' in VAR_8.data\n", "def FUNC_18(VAR_0, VAR_1: FlaskClient):...\n", "VAR_8 = VAR_1.get('/?path=nonexistent_dir', follow_redirects=True)\n", "assert b'Directory does not exist.' in VAR_8.data\n", "def FUNC_19(VAR_0, VAR_1: FlaskClient):...\n", "create_dir('testing')\n", "assert 'testing' in get_dirs()\n", "VAR_8 = VAR_1.post('/folders/delete', data={'dir_name': 'testing'},\n follow_redirects=True)\n", "assert not 'testing' in get_dirs()\n", "assert b'Folder successfully deleted.' in VAR_8.data\n", "def FUNC_20(VAR_0, VAR_1: FlaskClient):...\n", "VAR_8 = VAR_1.post('/folders/delete', data={'dir_name': 'testing'})\n", "assert VAR_8.status_code == 404\n", "def FUNC_21(VAR_0, VAR_1: FlaskClient):...\n", "VAR_8 = VAR_1.get('/bookmarklet')\n", "assert VAR_8.status_code == 200\n", "def FUNC_22(VAR_0, VAR_1: FlaskClient, VAR_2, VAR_4):...\n", "VAR_0.config['SEARCH_CONF']['enabled'] = 1\n", "VAR_0.config['SEARCH_CONF']['engine'] = 'ripgrep'\n", "VAR_8 = VAR_1.put(f'/api/dataobjs/{VAR_2.id}', json={'content':\n f'[[{bookmark_fixture.title}|{bookmark_fixture.id}]]'})\n", "assert VAR_8.status_code == 200\n", "VAR_8 = VAR_1.get(f'/dataobj/{VAR_4.id}')\n", "assert b'Backlinks' in VAR_8.data\n", "VAR_0.config['SEARCH_CONF']['enabled'] = 0\n", "def 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 FUNC_24(VAR_0, VAR_2, VAR_1):...\n", "create_dir('random')\n", "VAR_8 = VAR_1.post('/dataobj/move/1', data={'path': 'random', 'submit':\n 'true'}, follow_redirects=True)\n", "assert VAR_8.status_code == 200\n", "assert b'Data successfully moved to random.' in VAR_8.data\n", "assert get_item(1)['dir'] == 'random'\n", "def FUNC_25(VAR_0, VAR_2, VAR_1):...\n", "VAR_8 = VAR_1.post('/dataobj/move/1', follow_redirects=True)\n", "assert b'No path specified.' in VAR_8.data\n", "VAR_8 = VAR_1.post('/dataobj/move/2', data={'path': 'aaa', 'submit': 'true'\n }, follow_redirects=True)\n", "assert b'Data not found' in VAR_8.data\n", "VAR_8 = VAR_1.post('/dataobj/move/1', data={'path': '', 'submit': 'true'},\n follow_redirects=True)\n", "assert b'Data already in target directory' in VAR_8.data\n", "VAR_16 = ['../adarnad', '~/adasd', 'ssss']\n", "for p in VAR_16:\n", "VAR_8 = VAR_1.post('/dataobj/move/1', data={'path': p, 'submit': 'true'},\n follow_redirects=True)\n", "def FUNC_26(VAR_0, VAR_1):...\n", "assert b'Data could not be moved to ' + bytes(p, 'utf-8') in VAR_8.data\n", "create_dir('random')\n", "VAR_8 = VAR_1.post('/folders/rename', data={'current_path': 'random',\n 'new_name': 'renamed_random'}, follow_redirects=True)\n", "assert VAR_8.status_code == 200\n", "assert b'Renamed successfully' in VAR_8.data\n", "def FUNC_27(VAR_0, VAR_1):...\n", "create_dir('random')\n", "create_dir('random2')\n", "VAR_8 = VAR_1.post('/folders/rename', data={'current_path': 'inexisting',\n 'new_name': 'random3'}, follow_redirects=True)\n", "assert b'Directory not found' in VAR_8.data\n", "VAR_8 = VAR_1.post('/folders/rename', data={'current_path': 'random',\n 'new_name': 'random2'}, follow_redirects=True)\n", "assert b'Target directory exists.' in VAR_8.data\n", "VAR_16 = ['../adarnad', '~/adasd', '/illegal_dir', '.']\n", "for p in VAR_16:\n", "print(p)\n", "def FUNC_28(VAR_0, VAR_1):...\n", "VAR_8 = VAR_1.post('/folders/rename', data={'current_path': 'random',\n 'new_name': p}, follow_redirects=True)\n", "VAR_8 = VAR_1.get('/config')\n", "assert b'Invalid input' in VAR_8.data\n", "assert VAR_8.status_code == 200\n", "assert b'Edit Config' in VAR_8.data\n", "def FUNC_29(VAR_0, VAR_1):...\n", "VAR_17 = VAR_0.config['THEME_CONF']['use_theme_dark']\n", "VAR_8 = VAR_1.post('/config', data={'submit': True,\n 'THEME_CONF-use_theme_dark': not dark_theme})\n", "assert VAR_0.config['THEME_CONF']['use_theme_dark'] == (not VAR_17)\n", "def FUNC_30(VAR_0, VAR_1, VAR_4):...\n", "VAR_8 = VAR_1.get('/tags')\n", "VAR_18 = ['embedded-tag', 'tag2']\n", "assert VAR_8.status_code == 200\n", "for tag in VAR_18:\n", "assert f'#{tag}' in str(VAR_8.data)\n", "def FUNC_31(VAR_0, VAR_1, VAR_4):...\n", "VAR_8 = VAR_1.get('/tags/tag2')\n", "assert VAR_8.status_code == 200\n", "assert VAR_4.title in str(VAR_8.data)\n", "assert str(VAR_4.id) in str(VAR_8.data)\n" ]
[ "import os\n", "import re\n", "from flask.testing import FlaskClient\n", "from flask import request\n", "from flask_login import current_user\n", "from responses import RequestsMock, GET\n", "from werkzeug.security import generate_password_hash\n", "from archivy.helpers import get_max_id, get_db\n", "from archivy.data import get_dirs, create_dir, get_items, get_item\n", "def test_get_index(test_app, client: FlaskClient):...\n", "response = client.get('/')\n", "assert response.status_code == 200\n", "def test_get_custom_css(test_app, client: FlaskClient):...\n", "test_app.config['THEME_CONF']['use_custom_css'] = True\n", "css_file = 'custom.css'\n", "css_contents = \"\"\"\n body {\n color: red\n }\n \"\"\"\n", "os.mkdir(f\"{test_app.config['USER_DIR']}/css/\")\n", "f.write(css_contents)\n", "test_app.config['THEME_CONF']['custom_css_file'] = css_file\n", "resp = client.get('/static/custom.css')\n", "assert css_contents.encode('utf-8') in resp.data\n", "test_app.config['THEME_CONF']['use_custom_css'] = False\n", "def test_get_new_bookmark(test_app, client: FlaskClient):...\n", "response = client.get('/bookmarks/new')\n", "assert response.status_code == 200\n", "def test_post_new_bookmark_missing_fields(test_app, client: FlaskClient):...\n", "response = client.post('/bookmarks/new', data={'submit': True})\n", "assert response.status_code == 200\n", "assert b'This field is required' in response.data\n", "def test_get_new_note(test_app, client: FlaskClient):...\n", "response = client.get('/notes/new')\n", "assert response.status_code == 200\n", "def test_get_dataobj_not_found(test_app, client: FlaskClient):...\n", "response = client.get('/dataobj/1')\n", "assert response.status_code == 302\n", "def test_get_dataobj(test_app, client: FlaskClient, note_fixture):...\n", "response = client.get('/dataobj/1')\n", "assert response.status_code == 200\n", "def test_get_delete_dataobj_not_found(test_app, client: FlaskClient):...\n", "response = client.get('/dataobj/delete/1')\n", "assert response.status_code == 302\n", "def test_get_delete_dataobj(test_app, client: FlaskClient, note_fixture):...\n", "response = client.get('/dataobj/delete/1')\n", "assert response.status_code == 302\n", "def test_create_new_bookmark(test_app, client: FlaskClient,...\n", "mocked_responses.add(GET, 'https://example.com/', body=\n \"\"\"<html>\n <head><title>Random</title></head><body><p>\n Lorem ipsum dolor sit amet, consectetur adipiscing elit\n </p></body></html>\n \"\"\"\n )\n", "bookmark_data = {'url': 'https://example.com', 'tags': 'testing,bookmark',\n 'path': '', 'submit': 'true'}\n", "resp = client.post('/bookmarks/new', data=bookmark_data)\n", "assert resp.status_code == 302\n", "assert not b'invalid' in resp.data\n", "resp = client.post('/bookmarks/new', data=bookmark_data, follow_redirects=True)\n", "assert resp.status_code == 200\n", "assert b'<span class=\"post-tag\">bookmark</span>' in resp.data\n", "assert b'<span class=\"post-tag\">testing</span>' in resp.data\n", "assert b'https://example.com' in resp.data\n", "assert b'Random' in resp.data\n", "def test_creating_bookmark_without_passing_path_saves_to_default_dir(test_app,...\n", "mocked_responses.add(GET, 'http://example.org', body='Example\\n')\n", "bookmarks_dir = 'bookmarks'\n", "test_app.config['DEFAULT_BOOKMARKS_DIR'] = bookmarks_dir\n", "create_dir(bookmarks_dir)\n", "resp = client.post('/bookmarks/new', data={'url': 'http://example.org',\n 'submit': 'true'})\n", "bookmark = get_items(structured=False)[0]\n", "assert 'bookmarks' in bookmark['path']\n", "def test_create_note(test_app, client: FlaskClient):...\n", "note_data = {'title': 'Testing the create route', 'tags': 'testing,note',\n 'path': '', 'submit': 'true'}\n", "resp = client.post('/notes/new', data=note_data)\n", "assert resp.status_code == 302\n", "assert not b'invalid' in resp.data\n", "resp = client.post('/notes/new', data=note_data, follow_redirects=True)\n", "assert resp.status_code == 200\n", "assert b'<span class=\"post-tag\">note</span>' in resp.data\n", "assert b'<span class=\"post-tag\">testing</span>' in resp.data\n", "assert b'Testing the create route' in resp.data\n", "def test_logging_in(test_app, client: FlaskClient):...\n", "resp = client.post('/login', data={'username': 'halcyon', 'password':\n 'password'}, follow_redirects=True)\n", "assert resp.status_code == 200\n", "assert request.path == '/'\n", "assert current_user\n", "def test_logging_in_with_invalid_creds(test_app, client: FlaskClient):...\n", "resp = client.post('/login', data={'username': 'invalid', 'password':\n 'dasdasd'}, follow_redirects=True)\n", "assert resp.status_code == 200\n", "assert request.path == '/login'\n", "assert b'Invalid credentials' in resp.data\n", "def test_edit_user(test_app, client: FlaskClient):...\n", "\"\"\"docstring\"\"\"\n", "new_user = 'new_halcyon'\n", "new_pass = 'password2'\n", "resp = client.post('/user/edit', data={'username': new_user, 'password':\n new_pass}, follow_redirects=True)\n", "assert request.path == '/'\n", "client.delete('/logout')\n", "resp = client.post('/login', data={'username': new_user, 'password':\n new_pass}, follow_redirects=True)\n", "assert resp.status_code == 200\n", "assert request.path == '/'\n", "def test_logging_out(test_app, client: FlaskClient):...\n", "\"\"\"docstring\"\"\"\n", "client.delete('/logout')\n", "resp = client.get('/', follow_redirects=True)\n", "assert request.path == '/login'\n", "def test_create_dir(test_app, client: FlaskClient):...\n", "\"\"\"docstring\"\"\"\n", "resp = client.post('/folders/create', data={'parent_dir': '', 'new_dir':\n 'testing'}, follow_redirects=True)\n", "assert resp.status_code == 200\n", "assert request.args.get('path') == 'testing'\n", "assert 'testing' in get_dirs()\n", "assert b'Folder successfully created' in resp.data\n", "def test_creating_without_dirname_fails(test_app, client: FlaskClient):...\n", "resp = client.post('/folders/create', data={'parent_dir': ''},\n follow_redirects=True)\n", "assert resp.status_code == 200\n", "assert request.path == '/'\n", "assert b'Could not create folder.' in resp.data\n", "def test_visiting_nonexistent_dir_fails(test_app, client: FlaskClient):...\n", "resp = client.get('/?path=nonexistent_dir', follow_redirects=True)\n", "assert b'Directory does not exist.' in resp.data\n", "def test_deleting_dir(test_app, client: FlaskClient):...\n", "create_dir('testing')\n", "assert 'testing' in get_dirs()\n", "resp = client.post('/folders/delete', data={'dir_name': 'testing'},\n follow_redirects=True)\n", "assert not 'testing' in get_dirs()\n", "assert b'Folder successfully deleted.' in resp.data\n", "def test_deleting_nonexisting_folder_fails(test_app, client: FlaskClient):...\n", "resp = client.post('/folders/delete', data={'dir_name': 'testing'})\n", "assert resp.status_code == 404\n", "def test_bookmarklet(test_app, client: FlaskClient):...\n", "resp = client.get('/bookmarklet')\n", "assert resp.status_code == 200\n", "def test_backlinks_are_saved(test_app, client: FlaskClient, note_fixture,...\n", "test_app.config['SEARCH_CONF']['enabled'] = 1\n", "test_app.config['SEARCH_CONF']['engine'] = 'ripgrep'\n", "resp = client.put(f'/api/dataobjs/{note_fixture.id}', json={'content':\n f'[[{bookmark_fixture.title}|{bookmark_fixture.id}]]'})\n", "assert resp.status_code == 200\n", "resp = client.get(f'/dataobj/{bookmark_fixture.id}')\n", "assert b'Backlinks' in resp.data\n", "test_app.config['SEARCH_CONF']['enabled'] = 0\n", "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", "def test_move_data(test_app, note_fixture, client):...\n", "create_dir('random')\n", "resp = client.post('/dataobj/move/1', data={'path': 'random', 'submit':\n 'true'}, follow_redirects=True)\n", "assert resp.status_code == 200\n", "assert b'Data successfully moved to random.' in resp.data\n", "assert get_item(1)['dir'] == 'random'\n", "def test_invalid_inputs_fail_move_data(test_app, note_fixture, client):...\n", "resp = client.post('/dataobj/move/1', follow_redirects=True)\n", "assert b'No path specified.' in resp.data\n", "resp = client.post('/dataobj/move/2', data={'path': 'aaa', 'submit': 'true'\n }, follow_redirects=True)\n", "assert b'Data not found' in resp.data\n", "resp = client.post('/dataobj/move/1', data={'path': '', 'submit': 'true'},\n follow_redirects=True)\n", "assert b'Data already in target directory' in resp.data\n", "faulty_paths = ['../adarnad', '~/adasd', 'ssss']\n", "for p in faulty_paths:\n", "resp = client.post('/dataobj/move/1', data={'path': p, 'submit': 'true'},\n follow_redirects=True)\n", "def test_rename_dir(test_app, client):...\n", "assert b'Data could not be moved to ' + bytes(p, 'utf-8') in resp.data\n", "create_dir('random')\n", "resp = client.post('/folders/rename', data={'current_path': 'random',\n 'new_name': 'renamed_random'}, follow_redirects=True)\n", "assert resp.status_code == 200\n", "assert b'Renamed successfully' in resp.data\n", "def test_invalid_inputs_fail_renaming(test_app, client):...\n", "create_dir('random')\n", "create_dir('random2')\n", "resp = client.post('/folders/rename', data={'current_path': 'inexisting',\n 'new_name': 'random3'}, follow_redirects=True)\n", "assert b'Directory not found' in resp.data\n", "resp = client.post('/folders/rename', data={'current_path': 'random',\n 'new_name': 'random2'}, follow_redirects=True)\n", "assert b'Target directory exists.' in resp.data\n", "faulty_paths = ['../adarnad', '~/adasd', '/illegal_dir', '.']\n", "for p in faulty_paths:\n", "print(p)\n", "def test_get_config_page(test_app, client):...\n", "resp = client.post('/folders/rename', data={'current_path': 'random',\n 'new_name': p}, follow_redirects=True)\n", "resp = client.get('/config')\n", "assert b'Invalid input' in resp.data\n", "assert resp.status_code == 200\n", "assert b'Edit Config' in resp.data\n", "def test_post_updated_config(test_app, client):...\n", "dark_theme = test_app.config['THEME_CONF']['use_theme_dark']\n", "resp = client.post('/config', data={'submit': True,\n 'THEME_CONF-use_theme_dark': not dark_theme})\n", "assert test_app.config['THEME_CONF']['use_theme_dark'] == (not dark_theme)\n", "def test_getting_all_tags(test_app, client, bookmark_fixture):...\n", "resp = client.get('/tags')\n", "bookmark_tags = ['embedded-tag', 'tag2']\n", "assert resp.status_code == 200\n", "for tag in bookmark_tags:\n", "assert f'#{tag}' in str(resp.data)\n", "def test_getting_matches_for_specific_tag(test_app, client, bookmark_fixture):...\n", "resp = client.get('/tags/tag2')\n", "assert resp.status_code == 200\n", "assert bookmark_fixture.title in str(resp.data)\n", "assert str(bookmark_fixture.id) in str(resp.data)\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, 3, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "Assert'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assert'", "Assign'", "FunctionDef'", "Assign'", "Assert'", "FunctionDef'", "Assign'", "Assert'", "Assert'", "FunctionDef'", "Assign'", "Assert'", "FunctionDef'", "Assign'", "Assert'", "FunctionDef'", "Assign'", "Assert'", "FunctionDef'", "Assign'", "Assert'", "FunctionDef'", "Assign'", "Assert'", "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assert'", "Assert'", "Assign'", "Assert'", "Assert'", "Assert'", "Assert'", "Assert'", "FunctionDef'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assert'", "FunctionDef'", "Assign'", "Assign'", "Assert'", "Assert'", "Assign'", "Assert'", "Assert'", "Assert'", "Assert'", "FunctionDef'", "Assign'", "Assert'", "Assert'", "Assert'", "FunctionDef'", "Assign'", "Assert'", "Assert'", "Assert'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assert'", "Expr'", "Assign'", "Assert'", "Assert'", "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assert'", "FunctionDef'", "Docstring", "Assign'", "Assert'", "Assert'", "Assert'", "Assert'", "FunctionDef'", "Assign'", "Assert'", "Assert'", "Assert'", "FunctionDef'", "Assign'", "Assert'", "FunctionDef'", "Expr'", "Assert'", "Assign'", "Assert'", "Assert'", "FunctionDef'", "Assign'", "Assert'", "FunctionDef'", "Assign'", "Assert'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assert'", "Assign'", "Assert'", "Assign'", "FunctionDef'", "Assign'", "Assert'", "Expr'", "Assign'", "Assign'", "Assert'", "FunctionDef'", "Expr'", "Assign'", "Assert'", "Assert'", "Assert'", "FunctionDef'", "Assign'", "Assert'", "Assign'", "Assert'", "Assign'", "Assert'", "Assign'", "For", "Assign'", "FunctionDef'", "Assert'", "Expr'", "Assign'", "Assert'", "Assert'", "FunctionDef'", "Expr'", "Expr'", "Assign'", "Assert'", "Assign'", "Assert'", "Assign'", "For", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Assert'", "Assert'", "Assert'", "FunctionDef'", "Assign'", "Assign'", "Assert'", "FunctionDef'", "Assign'", "Assign'", "Assert'", "For", "Assert'", "FunctionDef'", "Assign'", "Assert'", "Assert'", "Assert'" ]
[ "import logging\n", "from unittest import TestCase\n", "from synapse.api.constants import EventTypes\n", "from synapse.api.errors import AuthError, Codes, SynapseError\n", "from synapse.api.room_versions import RoomVersions\n", "from synapse.events import EventBase\n", "from synapse.federation.federation_base import event_from_pdu_json\n", "from synapse.logging.context import LoggingContext, run_in_background\n", "from synapse.rest import admin\n", "from synapse.rest.client.v1 import login, room\n", "from tests import unittest\n", "VAR_0 = logging.getLogger(__name__)\n", "VAR_1 = [admin.register_servlets, login.register_servlets, room.\n register_servlets]\n", "def FUNC_0(self, VAR_2, VAR_3):...\n", "VAR_7 = self.setup_test_homeserver(http_client=None)\n", "self.handler = VAR_7.get_federation_handler()\n", "self.store = VAR_7.get_datastore()\n", "return VAR_7\n" ]
[ "import logging\n", "from unittest import TestCase\n", "from synapse.api.constants import EventTypes\n", "from synapse.api.errors import AuthError, Codes, SynapseError\n", "from synapse.api.room_versions import RoomVersions\n", "from synapse.events import EventBase\n", "from synapse.federation.federation_base import event_from_pdu_json\n", "from synapse.logging.context import LoggingContext, run_in_background\n", "from synapse.rest import admin\n", "from synapse.rest.client.v1 import login, room\n", "from tests import unittest\n", "logger = logging.getLogger(__name__)\n", "servlets = [admin.register_servlets, login.register_servlets, room.\n register_servlets]\n", "def make_homeserver(self, reactor, clock):...\n", "hs = self.setup_test_homeserver(http_client=None)\n", "self.handler = hs.get_federation_handler()\n", "self.store = hs.get_datastore()\n", "return hs\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0 ]
[ "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_7(self, VAR_5, VAR_6, VAR_10, VAR_11=None):...\n", "VAR_7 = self.get_image_uuid(VAR_5, VAR_6)\n", "VAR_9 = self.service.update(VAR_5, VAR_7, VAR_10, VAR_11)\n", "return self._translate_uuid_to_id(VAR_5, VAR_9)\n" ]
[ "def update(self, context, image_id, metadata, data=None):...\n", "image_uuid = self.get_image_uuid(context, image_id)\n", "image = self.service.update(context, image_uuid, metadata, data)\n", "return self._translate_uuid_to_id(context, image)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_25(self):...\n", "\"\"\"docstring\"\"\"\n", "if frappe.flags.in_install == 'frappe':\n", "return\n", "VAR_51 = self.meta.get_workflow()\n", "if VAR_51:\n", "FUNC_25(self)\n", "if not self._action == 'save':\n", "set_workflow_state_on_action(self, VAR_51, self._action)\n" ]
[ "def validate_workflow(self):...\n", "\"\"\"docstring\"\"\"\n", "if frappe.flags.in_install == 'frappe':\n", "return\n", "workflow = self.meta.get_workflow()\n", "if workflow:\n", "validate_workflow(self)\n", "if not self._action == 'save':\n", "set_workflow_state_on_action(self, workflow, self._action)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Assign'", "Condition", "Expr'", "Condition", "Expr'" ]
[ "def FUNC_1(VAR_1: HttpRequest) ->Tuple[Dict[str, Any], bool]:...\n", "if VAR_1.user.is_anonymous:\n", "return {}, False\n", "VAR_0 = VAR_1.user.team\n", "if VAR_0 and FUNC_0(VAR_0, VAR_1):\n", "VAR_6: Dict[str, Any] = {'isAuthenticated': True}\n", "return {}, False\n", "VAR_8 = {}\n", "if VAR_1.user.toolbar_mode != 'disabled':\n", "VAR_8['toolbarVersion'] = 'toolbar'\n", "if settings.JS_URL:\n", "VAR_8['jsURL'] = settings.JS_URL\n", "VAR_6['editorParams'] = VAR_8\n", "return VAR_6, not VAR_1.user.temporary_token\n" ]
[ "def decide_editor_params(request: HttpRequest) ->Tuple[Dict[str, Any], bool]:...\n", "if request.user.is_anonymous:\n", "return {}, False\n", "team = request.user.team\n", "if team and on_permitted_domain(team, request):\n", "response: Dict[str, Any] = {'isAuthenticated': True}\n", "return {}, False\n", "editor_params = {}\n", "if request.user.toolbar_mode != 'disabled':\n", "editor_params['toolbarVersion'] = 'toolbar'\n", "if settings.JS_URL:\n", "editor_params['jsURL'] = settings.JS_URL\n", "response['editorParams'] = editor_params\n", "return response, not request.user.temporary_token\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "Condition", "AnnAssign'", "Return'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_12(VAR_12, *VAR_13, **VAR_14):...\n", "return VAR_12\n" ]
[ "def _progress_indicator(iterable, *args, **kwargs):...\n", "return iterable\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_34(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_61 = False\n", "self._action = 'save'\n", "if not self.get('__islocal'):\n", "if self.meta.issingle:\n", "self.check_docstatus_transition(0)\n", "VAR_100 = frappe.db.sql(\n \"\"\"select value from tabSingles\n\t\t\t\t\twhere doctype=%s and field='modified' for update\"\"\"\n , self.doctype)\n", "VAR_101 = frappe.db.sql(\n \"\"\"select modified, docstatus from `tab{0}`\n\t\t\t\t\twhere name = %s for update\"\"\"\n .format(self.doctype), self.name, as_dict=True)\n", "VAR_100 = VAR_100 and VAR_100[0][0]\n", "if not VAR_101:\n", "if VAR_100 and VAR_100 != cstr(self._original_modified):\n", "frappe.throw(_('Record does not exist'))\n", "VAR_101 = VAR_101[0]\n", "VAR_61 = True\n", "if VAR_61:\n", "VAR_100 = cstr(VAR_101.modified)\n", "frappe.msgprint(_(\n 'Error: Document has been modified after you have opened it') + \n ' (%s, %s). ' % (VAR_100, self.modified) + _(\n 'Please refresh to get the latest document.'), VAR_33=frappe.\n TimestampMismatchError)\n", "if VAR_100 and VAR_100 != cstr(self._original_modified):\n", "VAR_61 = True\n", "self.check_docstatus_transition(VAR_101.docstatus)\n" ]
[ "def check_if_latest(self):...\n", "\"\"\"docstring\"\"\"\n", "conflict = False\n", "self._action = 'save'\n", "if not self.get('__islocal'):\n", "if self.meta.issingle:\n", "self.check_docstatus_transition(0)\n", "modified = frappe.db.sql(\n \"\"\"select value from tabSingles\n\t\t\t\t\twhere doctype=%s and field='modified' for update\"\"\"\n , self.doctype)\n", "tmp = frappe.db.sql(\n \"\"\"select modified, docstatus from `tab{0}`\n\t\t\t\t\twhere name = %s for update\"\"\"\n .format(self.doctype), self.name, as_dict=True)\n", "modified = modified and modified[0][0]\n", "if not tmp:\n", "if modified and modified != cstr(self._original_modified):\n", "frappe.throw(_('Record does not exist'))\n", "tmp = tmp[0]\n", "conflict = True\n", "if conflict:\n", "modified = cstr(tmp.modified)\n", "frappe.msgprint(_(\n 'Error: Document has been modified after you have opened it') + \n ' (%s, %s). ' % (modified, self.modified) + _(\n 'Please refresh to get the latest document.'), raise_exception=frappe.\n TimestampMismatchError)\n", "if modified and modified != cstr(self._original_modified):\n", "conflict = True\n", "self.check_docstatus_transition(tmp.docstatus)\n" ]
[ 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'", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Condition", "Assign'", "Expr'" ]
[ "@VAR_25.whitelist(allow_guest=True)...\n", "return VAR_25.__version__\n" ]
[ "@frappe.whitelist(allow_guest=True)...\n", "return frappe.__version__\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "@VAR_25.whitelist(allow_guest=True)...\n", "VAR_16 = None\n", "if VAR_25.session.user == 'Guest':\n", "if VAR_25.get_system_settings('allow_guests_to_upload_files'):\n", "VAR_16 = VAR_25.get_doc('User', VAR_25.session.user)\n", "VAR_26 = True\n", "return\n", "VAR_26 = False\n", "VAR_17 = VAR_25.request.files\n", "VAR_18 = VAR_25.form_dict.is_private\n", "VAR_9 = VAR_25.form_dict.doctype\n", "VAR_19 = VAR_25.form_dict.docname\n", "VAR_20 = VAR_25.form_dict.fieldname\n", "VAR_21 = VAR_25.form_dict.file_url\n", "VAR_22 = VAR_25.form_dict.folder or 'Home'\n", "VAR_3 = VAR_25.form_dict.method\n", "VAR_23 = None\n", "VAR_24 = None\n", "if 'file' in VAR_17:\n", "VAR_27 = VAR_17['file']\n", "VAR_25.local.uploaded_file = VAR_23\n", "VAR_23 = VAR_27.stream.read()\n", "VAR_25.local.uploaded_filename = VAR_24\n", "VAR_24 = VAR_27.filename\n", "if VAR_25.session.user == 'Guest' or VAR_16 and not VAR_16.has_desk_access():\n", "import mimetypes\n", "if VAR_3:\n", "VAR_28 = mimetypes.guess_type(VAR_24)[0]\n", "VAR_3 = VAR_25.get_attr(VAR_3)\n", "VAR_15 = VAR_25.get_doc({'doctype': 'File', 'attached_to_doctype': VAR_9,\n 'attached_to_name': VAR_19, 'attached_to_field': VAR_20, 'folder':\n VAR_22, 'file_name': VAR_24, 'file_url': VAR_21, 'is_private': cint(\n VAR_18), 'content': VAR_23})\n", "if VAR_28 not in VAR_0:\n", "FUNC_3(VAR_3)\n", "VAR_15.save(VAR_26=ignore_permissions)\n", "VAR_25.throw(_('You can only upload JPG, PNG, PDF, or Microsoft documents.'))\n", "return VAR_3()\n", "return VAR_15\n" ]
[ "@frappe.whitelist(allow_guest=True)...\n", "user = None\n", "if frappe.session.user == 'Guest':\n", "if frappe.get_system_settings('allow_guests_to_upload_files'):\n", "user = frappe.get_doc('User', frappe.session.user)\n", "ignore_permissions = True\n", "return\n", "ignore_permissions = False\n", "files = frappe.request.files\n", "is_private = frappe.form_dict.is_private\n", "doctype = frappe.form_dict.doctype\n", "docname = frappe.form_dict.docname\n", "fieldname = frappe.form_dict.fieldname\n", "file_url = frappe.form_dict.file_url\n", "folder = frappe.form_dict.folder or 'Home'\n", "method = frappe.form_dict.method\n", "content = None\n", "filename = None\n", "if 'file' in files:\n", "file = files['file']\n", "frappe.local.uploaded_file = content\n", "content = file.stream.read()\n", "frappe.local.uploaded_filename = filename\n", "filename = file.filename\n", "if frappe.session.user == 'Guest' or user and not user.has_desk_access():\n", "import mimetypes\n", "if method:\n", "filetype = mimetypes.guess_type(filename)[0]\n", "method = frappe.get_attr(method)\n", "ret = frappe.get_doc({'doctype': 'File', 'attached_to_doctype': doctype,\n 'attached_to_name': docname, 'attached_to_field': fieldname, 'folder':\n folder, 'file_name': filename, 'file_url': file_url, 'is_private': cint\n (is_private), 'content': content})\n", "if filetype not in ALLOWED_MIMETYPES:\n", "is_whitelisted(method)\n", "ret.save(ignore_permissions=ignore_permissions)\n", "frappe.throw(_('You can only upload JPG, PNG, PDF, or Microsoft documents.'))\n", "return method()\n", "return ret\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 ]
[ "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Import'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Return'", "Return'" ]
[ "def FUNC_22(self, VAR_62: bool=True):...\n", "super().save(VAR_62=commit)\n", "if self.changed_access:\n", "Change.objects.create(VAR_58=self.instance, VAR_98=Change.\n ACTION_ACCESS_EDIT, VAR_4=self.user, details={'access_control': self.\n instance.access_control})\n" ]
[ "def save(self, commit: bool=True):...\n", "super().save(commit=commit)\n", "if self.changed_access:\n", "Change.objects.create(project=self.instance, action=Change.\n ACTION_ACCESS_EDIT, user=self.user, details={'access_control': self.\n instance.access_control})\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Condition", "Expr'" ]
[ "def __init__(self, VAR_6, VAR_7=False, VAR_8=None, VAR_9=False, VAR_10=None,...\n", "self.valid = False\n", "self.lineNumbers = VAR_9\n", "if VAR_9:\n", "constants.dryRun = True\n", "if VAR_6 is None:\n", "VAR_6 = FUNC_0()\n", "if VAR_6 is None:\n", "die('string')\n", "self.inputSource = InputSource(VAR_6)\n", "return\n", "self.transitiveDependencies = set()\n", "self.debug = VAR_7\n", "self.token = VAR_8\n", "self.testing = VAR_11\n", "if VAR_10 is None:\n", "self.dataFile = config.defaultRequester\n", "self.dataFile = VAR_10\n", "self.md = None\n", "self.mdBaseline = None\n", "self.mdDocument = None\n", "self.mdCommandLine = None\n", "self.mdDefaults = None\n", "self.mdOverridingDefaults = None\n", "self.lines = []\n", "self.document = None\n", "self.html = None\n", "self.head = None\n", "self.body = None\n", "self.fillContainers = None\n", "self.valid = self.initializeState()\n" ]
[ "def __init__(self, inputFilename, debug=False, token=None, lineNumbers=...\n", "self.valid = False\n", "self.lineNumbers = lineNumbers\n", "if lineNumbers:\n", "constants.dryRun = True\n", "if inputFilename is None:\n", "inputFilename = findImplicitInputFile()\n", "if inputFilename is None:\n", "die(\"\"\"No input file specified, and no *.bs or *.src.html files found in current directory.\nPlease specify an input file, or use - to pipe from STDIN.\"\"\"\n )\n", "self.inputSource = InputSource(inputFilename)\n", "return\n", "self.transitiveDependencies = set()\n", "self.debug = debug\n", "self.token = token\n", "self.testing = testing\n", "if fileRequester is None:\n", "self.dataFile = config.defaultRequester\n", "self.dataFile = fileRequester\n", "self.md = None\n", "self.mdBaseline = None\n", "self.mdDocument = None\n", "self.mdCommandLine = None\n", "self.mdDefaults = None\n", "self.mdOverridingDefaults = None\n", "self.lines = []\n", "self.document = None\n", "self.html = None\n", "self.head = None\n", "self.body = None\n", "self.fillContainers = None\n", "self.valid = self.initializeState()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "async def FUNC_14(self, VAR_5: str, VAR_11: str, VAR_27: str) ->EventBase:...\n", "\"\"\"docstring\"\"\"\n", "if get_domain_from_id(VAR_27) != VAR_5:\n", "VAR_0.info(\n 'Got /make_join request for user %r from different origin %s, ignoring',\n VAR_27, VAR_5)\n", "VAR_28 = await self.store.get_room_version_id(VAR_11)\n", "VAR_53 = await self.auth.check_host_in_room(VAR_11, self.server_name)\n", "if not VAR_53:\n", "VAR_0.info('Got /make_join request for room %s we are no longer in', VAR_11)\n", "VAR_92 = {'membership': Membership.JOIN}\n", "VAR_93 = self.event_builder_factory.new(VAR_28, {'type': VAR_188.Member,\n 'content': VAR_92, 'room_id': VAR_11, 'sender': VAR_27, 'state_key':\n VAR_27})\n", "VAR_1, VAR_32 = await self.event_creation_handler.create_new_client_event(\n VAR_93=builder)\n", "VAR_0.warning('Failed to create join to %s because %s', VAR_11, VAR_170)\n", "await self.auth.check_from_context(VAR_28, VAR_1, VAR_32, do_sig_check=False)\n", "return VAR_1\n" ]
[ "async def on_make_join_request(self, origin: str, room_id: str, user_id: str...\n", "\"\"\"docstring\"\"\"\n", "if get_domain_from_id(user_id) != origin:\n", "logger.info(\n 'Got /make_join request for user %r from different origin %s, ignoring',\n user_id, origin)\n", "room_version = await self.store.get_room_version_id(room_id)\n", "is_in_room = await self.auth.check_host_in_room(room_id, self.server_name)\n", "if not is_in_room:\n", "logger.info('Got /make_join request for room %s we are no longer in', room_id)\n", "event_content = {'membership': Membership.JOIN}\n", "builder = self.event_builder_factory.new(room_version, {'type': EventTypes.\n Member, 'content': event_content, 'room_id': room_id, 'sender': user_id,\n 'state_key': user_id})\n", "event, context = await self.event_creation_handler.create_new_client_event(\n builder=builder)\n", "logger.warning('Failed to create join to %s because %s', room_id, e)\n", "await self.auth.check_from_context(room_version, event, context,\n do_sig_check=False)\n", "return event\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Docstring", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "@VAR_2.route('/admin/alive', methods=['GET'])...\n", "return '', 200\n" ]
[ "@admi.route('/admin/alive', methods=['GET'])...\n", "return '', 200\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_52(self, VAR_70):...\n", "\"\"\"docstring\"\"\"\n", "return '<tr>\\n%s</tr>\\n' % VAR_70\n" ]
[ "def table_row(self, content):...\n", "\"\"\"docstring\"\"\"\n", "return '<tr>\\n%s</tr>\\n' % content\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_3(VAR_7: str, VAR_8: List[str]) ->str:...\n", "\"\"\"docstring\"\"\"\n", "VAR_7 = VAR_7.replace('\\t', '')\n", "return bleach.clean(VAR_7, tags=allowed_tags, attributes=allowed_attributes,\n styles=allowed_styles)\n" ]
[ "def base_validate_html(html: str, allowed_tags: List[str]) ->str:...\n", "\"\"\"docstring\"\"\"\n", "html = html.replace('\\t', '')\n", "return bleach.clean(html, tags=allowed_tags, attributes=allowed_attributes,\n styles=allowed_styles)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "\"\"\"QtWebEngine specific qute://* handlers and glue code.\"\"\"\n", "from PyQt5.QtCore import QBuffer, QIODevice\n", "from PyQt5.QtWebEngineCore import QWebEngineUrlSchemeHandler, QWebEngineUrlRequestJob\n", "from qutebrowser.browser import qutescheme\n", "from qutebrowser.utils import log, qtutils\n", "\"\"\"Handle qute://* requests on QtWebEngine.\"\"\"\n", "def FUNC_0(self, VAR_0):...\n", "\"\"\"docstring\"\"\"\n", "VAR_0.installUrlSchemeHandler(b'qute', self)\n", "if qtutils.version_check('5.11', compiled=False):\n", "VAR_0.installUrlSchemeHandler(b'chrome-error', self)\n", "def FUNC_1(self, VAR_1):...\n", "VAR_0.installUrlSchemeHandler(b'chrome-extension', self)\n", "\"\"\"docstring\"\"\"\n", "VAR_2 = VAR_1.requestUrl()\n", "if VAR_2.scheme() in ['chrome-error', 'chrome-extension']:\n", "VAR_1.fail(QWebEngineUrlRequestJob.UrlInvalid)\n", "assert VAR_1.requestMethod() == b'GET'\n", "return\n", "assert VAR_2.scheme() == 'qute'\n", "log.misc.debug('Got request for {}'.format(VAR_2.toDisplayString()))\n", "VAR_3, VAR_4 = qutescheme.data_for_url(VAR_2)\n", "log.misc.debug('No handler found for {}'.format(VAR_2.toDisplayString()))\n", "log.misc.debug('Returning {} data'.format(VAR_3))\n", "VAR_1.fail(QWebEngineUrlRequestJob.UrlNotFound)\n", "VAR_5 = QBuffer(parent=self)\n", "log.misc.exception('OSError while handling qute://* URL')\n", "VAR_5.open(QIODevice.WriteOnly)\n", "VAR_1.fail(QWebEngineUrlRequestJob.UrlNotFound)\n", "VAR_5.write(VAR_4)\n", "log.misc.exception('Error while handling qute://* URL')\n", "VAR_5.seek(0)\n", "VAR_1.fail(QWebEngineUrlRequestJob.RequestFailed)\n", "VAR_5.close()\n", "qtutils.ensure_valid(e.url)\n", "VAR_1.reply(VAR_3.encode('ascii'), VAR_5)\n", "VAR_1.redirect(e.url)\n" ]
[ "\"\"\"QtWebEngine specific qute://* handlers and glue code.\"\"\"\n", "from PyQt5.QtCore import QBuffer, QIODevice\n", "from PyQt5.QtWebEngineCore import QWebEngineUrlSchemeHandler, QWebEngineUrlRequestJob\n", "from qutebrowser.browser import qutescheme\n", "from qutebrowser.utils import log, qtutils\n", "\"\"\"Handle qute://* requests on QtWebEngine.\"\"\"\n", "def install(self, profile):...\n", "\"\"\"docstring\"\"\"\n", "profile.installUrlSchemeHandler(b'qute', self)\n", "if qtutils.version_check('5.11', compiled=False):\n", "profile.installUrlSchemeHandler(b'chrome-error', self)\n", "def requestStarted(self, job):...\n", "profile.installUrlSchemeHandler(b'chrome-extension', self)\n", "\"\"\"docstring\"\"\"\n", "url = job.requestUrl()\n", "if url.scheme() in ['chrome-error', 'chrome-extension']:\n", "job.fail(QWebEngineUrlRequestJob.UrlInvalid)\n", "assert job.requestMethod() == b'GET'\n", "return\n", "assert url.scheme() == 'qute'\n", "log.misc.debug('Got request for {}'.format(url.toDisplayString()))\n", "mimetype, data = qutescheme.data_for_url(url)\n", "log.misc.debug('No handler found for {}'.format(url.toDisplayString()))\n", "log.misc.debug('Returning {} data'.format(mimetype))\n", "job.fail(QWebEngineUrlRequestJob.UrlNotFound)\n", "buf = QBuffer(parent=self)\n", "log.misc.exception('OSError while handling qute://* URL')\n", "buf.open(QIODevice.WriteOnly)\n", "job.fail(QWebEngineUrlRequestJob.UrlNotFound)\n", "buf.write(data)\n", "log.misc.exception('Error while handling qute://* URL')\n", "buf.seek(0)\n", "job.fail(QWebEngineUrlRequestJob.RequestFailed)\n", "buf.close()\n", "qtutils.ensure_valid(e.url)\n", "job.reply(mimetype.encode('ascii'), buf)\n", "job.redirect(e.url)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Expr'", "FunctionDef'", "Docstring", "Expr'", "Condition", "Expr'", "FunctionDef'", "Expr'", "Docstring", "Assign'", "Condition", "Expr'", "Assert'", "Return'", "Assert'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "@VAR_0.route('/last/<unique_id>/<measure_type>/<measurement_id>/<period>')...\n", "\"\"\"docstring\"\"\"\n", "if not str_is_float(VAR_14):\n", "return '', 204\n", "if VAR_12 in ['input', 'math', 'function', 'output', 'pid']:\n", "VAR_47 = InfluxDBClient(INFLUXDB_HOST, INFLUXDB_PORT, INFLUXDB_USER,\n INFLUXDB_PASSWORD, INFLUXDB_DATABASE)\n", "if VAR_12 in ['input', 'math', 'function', 'output', 'pid']:\n", "VAR_83 = DeviceMeasurements.query.filter(DeviceMeasurements.unique_id == VAR_13\n ).first()\n", "return '', 204\n", "if VAR_83:\n", "VAR_80 = Conversion.query.filter(Conversion.unique_id == VAR_83.conversion_id\n ).first()\n", "VAR_80 = None\n", "VAR_22, VAR_21, VAR_29 = return_measurement_info(VAR_83, VAR_80)\n", "if hasattr(VAR_83, 'measurement_type'\n", "VAR_107 = PID.query.filter(PID.unique_id == VAR_83.device_id).first()\n", "if VAR_14 != '0':\n", "VAR_1.debug('No Data returned form influxdb')\n", "if VAR_107 and ',' in VAR_107.measurement:\n", "VAR_61 = query_string(VAR_21, VAR_9, VAR_83=measurement, VAR_22=channel,\n VAR_94='LAST', past_sec=period)\n", "VAR_61 = query_string(VAR_21, VAR_9, VAR_83=measurement, VAR_22=channel,\n VAR_94='LAST')\n", "return '', 204\n", "VAR_110 = VAR_107.measurement.split(',')[1]\n", "if VAR_61 == 1:\n", "VAR_111 = DeviceMeasurements.query.filter(DeviceMeasurements.unique_id ==\n VAR_110).first()\n", "return '', 204\n", "VAR_62 = VAR_47.query(VAR_61).raw\n", "if VAR_111:\n", "VAR_92 = len(VAR_62['series'][0]['values'])\n", "VAR_80 = Conversion.query.filter(Conversion.unique_id == VAR_111.conversion_id\n ).first()\n", "VAR_93 = VAR_62['series'][0]['values'][VAR_92 - 1][0]\n", "VAR_37, VAR_21, VAR_29 = return_measurement_info(VAR_111, VAR_80)\n", "VAR_94 = VAR_62['series'][0]['values'][VAR_92 - 1][1]\n", "VAR_94 = float(VAR_94)\n", "VAR_95 = date_parse(VAR_93)\n", "VAR_16 = calendar.timegm(VAR_95.timetuple()) * 1000\n", "VAR_104 = '[{},{}]'.format(VAR_16, VAR_94)\n", "return Response(VAR_104, mimetype='text/json')\n" ]
[ "@blueprint.route('/last/<unique_id>/<measure_type>/<measurement_id>/<period>')...\n", "\"\"\"docstring\"\"\"\n", "if not str_is_float(period):\n", "return '', 204\n", "if measure_type in ['input', 'math', 'function', 'output', 'pid']:\n", "dbcon = InfluxDBClient(INFLUXDB_HOST, INFLUXDB_PORT, INFLUXDB_USER,\n INFLUXDB_PASSWORD, INFLUXDB_DATABASE)\n", "if measure_type in ['input', 'math', 'function', 'output', 'pid']:\n", "measure = DeviceMeasurements.query.filter(DeviceMeasurements.unique_id ==\n measurement_id).first()\n", "return '', 204\n", "if measure:\n", "conversion = Conversion.query.filter(Conversion.unique_id == measure.\n conversion_id).first()\n", "conversion = None\n", "channel, unit, measurement = return_measurement_info(measure, conversion)\n", "if hasattr(measure, 'measurement_type'\n", "setpoint_pid = PID.query.filter(PID.unique_id == measure.device_id).first()\n", "if period != '0':\n", "logger.debug('No Data returned form influxdb')\n", "if setpoint_pid and ',' in setpoint_pid.measurement:\n", "query_str = query_string(unit, unique_id, measure=measurement, channel=\n channel, value='LAST', past_sec=period)\n", "query_str = query_string(unit, unique_id, measure=measurement, channel=\n channel, value='LAST')\n", "return '', 204\n", "pid_measurement = setpoint_pid.measurement.split(',')[1]\n", "if query_str == 1:\n", "setpoint_measurement = DeviceMeasurements.query.filter(DeviceMeasurements.\n unique_id == pid_measurement).first()\n", "return '', 204\n", "raw_data = dbcon.query(query_str).raw\n", "if setpoint_measurement:\n", "number = len(raw_data['series'][0]['values'])\n", "conversion = Conversion.query.filter(Conversion.unique_id ==\n setpoint_measurement.conversion_id).first()\n", "time_raw = raw_data['series'][0]['values'][number - 1][0]\n", "_, unit, measurement = return_measurement_info(setpoint_measurement, conversion\n )\n", "value = raw_data['series'][0]['values'][number - 1][1]\n", "value = float(value)\n", "dt = date_parse(time_raw)\n", "timestamp = calendar.timegm(dt.timetuple()) * 1000\n", "live_data = '[{},{}]'.format(timestamp, value)\n", "return Response(live_data, mimetype='text/json')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Assign'", "Return'", "Assign'", "Condition", "Assign'", "Return'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_7(self, VAR_15) ->List[str]:...\n", "\"\"\"docstring\"\"\"\n", "VAR_24 = []\n", "VAR_25 = [fi for fi in self.field_infos if fi.param.command_index == VAR_15]\n", "VAR_25 = sorted(VAR_25)\n", "for fi in VAR_25:\n", "fi.before_script_execute()\n", "return VAR_24\n", "if fi.cmd_opt.startswith('--'):\n", "VAR_24.extend(self._process_option(fi))\n", "if isinstance(fi, CLASS_2):\n", "VAR_24.append(fi.file_path)\n", "VAR_39 = request.form.getlist(fi.key)\n", "VAR_40 = bool(''.join(VAR_39))\n", "if VAR_40:\n", "if fi.param.nargs == -1:\n", "for value in VAR_39:\n", "VAR_0.info(f'arg_value: \"{VAR_39}\"')\n", "VAR_44 = value.splitlines()\n", "VAR_24.extend(VAR_39)\n", "VAR_0.info(f'variadic arguments, split into: \"{VAR_44}\"')\n", "VAR_24.extend(VAR_44)\n" ]
[ "def command_args(self, command_index) ->List[str]:...\n", "\"\"\"docstring\"\"\"\n", "args = []\n", "commands_field_infos = [fi for fi in self.field_infos if fi.param.\n command_index == command_index]\n", "commands_field_infos = sorted(commands_field_infos)\n", "for fi in commands_field_infos:\n", "fi.before_script_execute()\n", "return args\n", "if fi.cmd_opt.startswith('--'):\n", "args.extend(self._process_option(fi))\n", "if isinstance(fi, FieldFileInfo):\n", "args.append(fi.file_path)\n", "arg_values = request.form.getlist(fi.key)\n", "has_values = bool(''.join(arg_values))\n", "if has_values:\n", "if fi.param.nargs == -1:\n", "for value in arg_values:\n", "logger.info(f'arg_value: \"{arg_values}\"')\n", "values = value.splitlines()\n", "args.extend(arg_values)\n", "logger.info(f'variadic arguments, split into: \"{values}\"')\n", "args.extend(values)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "For", "Expr'", "Return'", "Condition", "Expr'", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Condition", "For", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "async def FUNC_8(self):...\n", "return self.get_repo_url()\n" ]
[ "async def get_resolved_ref_url(self):...\n", "return self.get_repo_url()\n" ]
[ 0, 0 ]
[ "AsyncFunctionDef'", "Return'" ]
[ "def FUNC_2(self, VAR_1, VAR_2=None):...\n", "" ]
[ "def get(self, arg, word=None):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_48(self):...\n", "VAR_86 = {'transcodingenabled': cherry.config['media.transcode'],\n 'fetchalbumart': cherry.config['media.fetch_album_art'], 'isadmin':\n VAR_53.session['admin'], 'username': VAR_53.session['username'],\n 'servepath': 'serve/', 'transcodepath': 'trans/', 'auto_login': self.\n autoLoginActive(), 'version': cherry.REPO_VERSION or cherry.VERSION}\n", "if cherry.config['media.transcode']:\n", "VAR_112 = list(self.model.transcoder.available_decoder_formats())\n", "VAR_86['getdecoders'] = []\n", "VAR_86['getdecoders'] = VAR_112\n", "VAR_86['getencoders'] = []\n", "VAR_113 = list(self.model.transcoder.available_encoder_formats())\n", "return VAR_86\n", "VAR_86['getencoders'] = VAR_113\n" ]
[ "def api_getconfiguration(self):...\n", "clientconfigkeys = {'transcodingenabled': cherry.config['media.transcode'],\n 'fetchalbumart': cherry.config['media.fetch_album_art'], 'isadmin':\n cherrypy.session['admin'], 'username': cherrypy.session['username'],\n 'servepath': 'serve/', 'transcodepath': 'trans/', 'auto_login': self.\n autoLoginActive(), 'version': cherry.REPO_VERSION or cherry.VERSION}\n", "if cherry.config['media.transcode']:\n", "decoders = list(self.model.transcoder.available_decoder_formats())\n", "clientconfigkeys['getdecoders'] = []\n", "clientconfigkeys['getdecoders'] = decoders\n", "clientconfigkeys['getencoders'] = []\n", "encoders = list(self.model.transcoder.available_encoder_formats())\n", "return clientconfigkeys\n", "clientconfigkeys['getencoders'] = encoders\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Assign'" ]
[ "def FUNC_30(self):...\n", "VAR_5 = self._makeContext()\n", "self.assertIs(VAR_5.evaluate('nocall: list'), safe_builtins['list'])\n" ]
[ "def test_list_in_path_expr(self):...\n", "ec = self._makeContext()\n", "self.assertIs(ec.evaluate('nocall: list'), safe_builtins['list'])\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_1(VAR_0):...\n", "if not VAR_0.GET.get('redirect'):\n", "return HttpResponse('You need to pass a url to ?redirect=', status=401)\n", "if not VAR_0.META.get('HTTP_REFERER'):\n", "return HttpResponse(\n 'You need to make a request that includes the \"Referer\" header.',\n status=400)\n", "VAR_8 = urlparse(VAR_0.META['HTTP_REFERER'])\n", "VAR_9 = urlparse(VAR_0.GET['redirect'])\n", "if VAR_8.hostname != VAR_9.hostname:\n", "return HttpResponse(\n f'Can only redirect to the same domain as the referer: {VAR_8.hostname}',\n status=400)\n", "if VAR_8.scheme != VAR_9.scheme:\n", "return HttpResponse(\n f'Can only redirect to the same scheme as the referer: {VAR_8.scheme}',\n status=400)\n", "if VAR_8.port != VAR_9.port:\n", "return HttpResponse(\n f\"Can only redirect to the same port as the referer: {VAR_8.port or 'no port in URL'}\"\n , status=400)\n", "return render_template('authorize_and_redirect.html', VAR_0=request,\n context={'domain': redirect_url.hostname, 'redirect_url': request.GET[\n 'redirect']})\n" ]
[ "def authorize_and_redirect(request):...\n", "if not request.GET.get('redirect'):\n", "return HttpResponse('You need to pass a url to ?redirect=', status=401)\n", "if not request.META.get('HTTP_REFERER'):\n", "return HttpResponse(\n 'You need to make a request that includes the \"Referer\" header.',\n status=400)\n", "referer_url = urlparse(request.META['HTTP_REFERER'])\n", "redirect_url = urlparse(request.GET['redirect'])\n", "if referer_url.hostname != redirect_url.hostname:\n", "return HttpResponse(\n f'Can only redirect to the same domain as the referer: {referer_url.hostname}'\n , status=400)\n", "if referer_url.scheme != redirect_url.scheme:\n", "return HttpResponse(\n f'Can only redirect to the same scheme as the referer: {referer_url.scheme}'\n , status=400)\n", "if referer_url.port != redirect_url.port:\n", "return HttpResponse(\n f\"Can only redirect to the same port as the referer: {referer_url.port or 'no port in URL'}\"\n , status=400)\n", "return render_template('authorize_and_redirect.html', request=request,\n context={'domain': redirect_url.hostname, 'redirect_url': request.GET[\n 'redirect']})\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Condition", "Return'", "Assign'", "Assign'", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "def FUNC_9(VAR_10):...\n", "return bool(FUNC_8(VAR_10))\n" ]
[ "def is_vcs_url(link):...\n", "return bool(_get_used_vcs_backend(link))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@VAR_2.route('/logout')...\n", "if VAR_87 is not None and VAR_87.is_authenticated:\n", "ub.delete_user_session(VAR_87.id, VAR_91.get('_id', ''))\n", "VAR_3.debug(u'User logged out')\n", "logout_user()\n", "return redirect(url_for('web.login'))\n", "if VAR_0['oauth'] and (config.config_login_type == 2 or config.\n", "logout_oauth_user()\n" ]
[ "@web.route('/logout')...\n", "if current_user is not None and current_user.is_authenticated:\n", "ub.delete_user_session(current_user.id, flask_session.get('_id', ''))\n", "log.debug(u'User logged out')\n", "logout_user()\n", "return redirect(url_for('web.login'))\n", "if feature_support['oauth'] and (config.config_login_type == 2 or config.\n", "logout_oauth_user()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Expr'", "Expr'", "Expr'", "Return'", "Condition", "Expr'" ]
[ "def FUNC_22(self, VAR_0):...\n", "from openapi_python_client import GeneratorData, Project\n", "VAR_3 = VAR_0.MagicMock(autospec=GeneratorData, title='My Test API')\n", "VAR_28 = VAR_0.MagicMock()\n", "VAR_29 = VAR_0.MagicMock()\n", "VAR_3.schemas.models = {'1': VAR_28, '2': VAR_29}\n", "VAR_30 = VAR_0.MagicMock()\n", "VAR_31 = VAR_0.MagicMock()\n", "VAR_3.enums = {'1': VAR_30, '2': VAR_31}\n", "VAR_8 = Project(VAR_3=openapi)\n", "VAR_8.package_dir = VAR_0.MagicMock()\n", "VAR_32 = VAR_0.MagicMock()\n", "VAR_33 = VAR_0.MagicMock()\n", "VAR_34 = VAR_0.MagicMock()\n", "VAR_35 = VAR_0.MagicMock()\n", "VAR_36 = VAR_0.MagicMock()\n", "VAR_37 = VAR_0.MagicMock()\n", "VAR_38 = VAR_0.MagicMock()\n", "VAR_39 = {'__init__.py': VAR_32, 'types.py': VAR_33,\n f'{VAR_28.reference.module_name}.py': VAR_35,\n f'{VAR_29.reference.module_name}.py': VAR_36,\n f'{VAR_30.reference.module_name}.py': VAR_37,\n f'{VAR_31.reference.module_name}.py': VAR_38}\n", "def FUNC_24(VAR_40):...\n", "return VAR_39[VAR_40]\n" ]
[ "def test__build_models(self, mocker):...\n", "from openapi_python_client import GeneratorData, Project\n", "openapi = mocker.MagicMock(autospec=GeneratorData, title='My Test API')\n", "model_1 = mocker.MagicMock()\n", "model_2 = mocker.MagicMock()\n", "openapi.schemas.models = {'1': model_1, '2': model_2}\n", "enum_1 = mocker.MagicMock()\n", "enum_2 = mocker.MagicMock()\n", "openapi.enums = {'1': enum_1, '2': enum_2}\n", "project = Project(openapi=openapi)\n", "project.package_dir = mocker.MagicMock()\n", "models_init = mocker.MagicMock()\n", "types_py = mocker.MagicMock()\n", "models_dir = mocker.MagicMock()\n", "model_1_module_path = mocker.MagicMock()\n", "model_2_module_path = mocker.MagicMock()\n", "enum_1_module_path = mocker.MagicMock()\n", "enum_2_module_path = mocker.MagicMock()\n", "module_paths = {'__init__.py': models_init, 'types.py': types_py,\n f'{model_1.reference.module_name}.py': model_1_module_path,\n f'{model_2.reference.module_name}.py': model_2_module_path,\n f'{enum_1.reference.module_name}.py': enum_1_module_path,\n f'{enum_2.reference.module_name}.py': enum_2_module_path}\n", "def models_dir_get(x):...\n", "return module_paths[x]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Return'" ]
[ "def FUNC_37():...\n", "VAR_72 = 'folder'\n", "VAR_73 = request.args.get('folder', False) == 'true'\n", "VAR_74 = request.args.get('filter', '')\n", "VAR_75 = os.path.normpath(request.args.get('path', ''))\n", "if os.path.isfile(VAR_75):\n", "VAR_104 = VAR_75\n", "VAR_104 = ''\n", "VAR_75 = os.path.dirname(VAR_75)\n", "VAR_76 = False\n", "if os.path.isdir(VAR_75):\n", "VAR_77 = os.path.realpath(VAR_75)\n", "VAR_77 = os.getcwd()\n", "VAR_76 = True\n", "VAR_77 = os.path.normpath(os.path.realpath(VAR_77))\n", "VAR_78 = os.path.dirname(VAR_77)\n", "if not VAR_76:\n", "if os.path.realpath(VAR_77) == os.path.realpath('/'):\n", "if os.path.realpath(VAR_77) == os.path.realpath('/'):\n", "VAR_77 = os.path.relpath(VAR_77)\n", "VAR_77 = os.path.relpath(VAR_77) + os.path.sep\n", "VAR_78 = ''\n", "VAR_105 = os.listdir(VAR_77)\n", "VAR_105 = []\n", "VAR_79 = []\n", "VAR_78 = os.path.relpath(VAR_78) + os.path.sep\n", "for VAR_3 in VAR_105:\n", "VAR_79 = sorted(VAR_79, key=operator.itemgetter('type', 'sort'))\n", "VAR_121 = {'name': VAR_3, 'fullpath': os.path.join(VAR_77, VAR_3)}\n", "if os.path.isfile(os.path.join(VAR_77, VAR_3)):\n", "VAR_80 = {'cwd': VAR_77, 'files': VAR_79, 'parentdir': VAR_78, 'type':\n VAR_72, 'oldfile': VAR_104, 'absolute': VAR_76}\n", "VAR_121['sort'] = VAR_121['fullpath'].lower()\n", "if VAR_73:\n", "VAR_121['type'] = 'dir'\n", "return json.dumps(VAR_80)\n", "if VAR_74 != '' and VAR_74 != VAR_3:\n", "VAR_121['size'] = ''\n", "VAR_121['type'] = 'file'\n", "VAR_79.append(VAR_121)\n", "VAR_121['size'] = os.path.getsize(os.path.join(VAR_77, VAR_3))\n", "VAR_122 = 0\n", "while VAR_121['size'] >> 10 > 0.3:\n", "VAR_122 += 1\n", "VAR_123 = '', 'K', 'M', 'G', 'T'\n", "VAR_121['size'] >>= 10\n", "VAR_121['size'] = str(VAR_121['size']) + ' ' + VAR_123[VAR_122] + 'Byte'\n" ]
[ "def pathchooser():...\n", "browse_for = 'folder'\n", "folder_only = request.args.get('folder', False) == 'true'\n", "file_filter = request.args.get('filter', '')\n", "path = os.path.normpath(request.args.get('path', ''))\n", "if os.path.isfile(path):\n", "oldfile = path\n", "oldfile = ''\n", "path = os.path.dirname(path)\n", "absolute = False\n", "if os.path.isdir(path):\n", "cwd = os.path.realpath(path)\n", "cwd = os.getcwd()\n", "absolute = True\n", "cwd = os.path.normpath(os.path.realpath(cwd))\n", "parentdir = os.path.dirname(cwd)\n", "if not absolute:\n", "if os.path.realpath(cwd) == os.path.realpath('/'):\n", "if os.path.realpath(cwd) == os.path.realpath('/'):\n", "cwd = os.path.relpath(cwd)\n", "cwd = os.path.relpath(cwd) + os.path.sep\n", "parentdir = ''\n", "folders = os.listdir(cwd)\n", "folders = []\n", "files = []\n", "parentdir = os.path.relpath(parentdir) + os.path.sep\n", "for f in folders:\n", "files = sorted(files, key=operator.itemgetter('type', 'sort'))\n", "data = {'name': f, 'fullpath': os.path.join(cwd, f)}\n", "if os.path.isfile(os.path.join(cwd, f)):\n", "context = {'cwd': cwd, 'files': files, 'parentdir': parentdir, 'type':\n browse_for, 'oldfile': oldfile, 'absolute': absolute}\n", "data['sort'] = data['fullpath'].lower()\n", "if folder_only:\n", "data['type'] = 'dir'\n", "return json.dumps(context)\n", "if file_filter != '' and file_filter != f:\n", "data['size'] = ''\n", "data['type'] = 'file'\n", "files.append(data)\n", "data['size'] = os.path.getsize(os.path.join(cwd, f))\n", "power = 0\n", "while data['size'] >> 10 > 0.3:\n", "power += 1\n", "units = '', 'K', 'M', 'G', 'T'\n", "data['size'] >>= 10\n", "data['size'] = str(data['size']) + ' ' + units[power] + 'Byte'\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 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Condition", "AugAssign'", "Assign'", "AugAssign'", "Assign'" ]
[ "def FUNC_3(self, VAR_3, VAR_4, VAR_8):...\n", "self.depth += 1\n", "VAR_13 = self.event_builder_factory.for_room_version(RoomVersions.V1, {\n 'type': EventTypes.Message, 'sender': VAR_4.to_string(), 'state_key':\n VAR_4.to_string(), 'room_id': VAR_3.to_string(), 'content': {'body':\n VAR_8, 'msgtype': 'message'}})\n", "VAR_14, VAR_15 = self.get_success(self.event_creation_handler.\n create_new_client_event(VAR_13))\n", "self.get_success(self.storage.persistence.persist_event(VAR_14, VAR_15))\n", "return VAR_14\n" ]
[ "def inject_message(self, room, user, body):...\n", "self.depth += 1\n", "builder = self.event_builder_factory.for_room_version(RoomVersions.V1, {\n 'type': EventTypes.Message, 'sender': user.to_string(), 'state_key':\n user.to_string(), 'room_id': room.to_string(), 'content': {'body': body,\n 'msgtype': 'message'}})\n", "event, context = self.get_success(self.event_creation_handler.\n create_new_client_event(builder))\n", "self.get_success(self.storage.persistence.persist_event(event, context))\n", "return event\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "AugAssign'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def __init__(self, VAR_10: Text) ->None:...\n", "from google.cloud import storage\n", "super().__init__()\n", "self.storage_client = storage.Client()\n", "self._ensure_bucket_exists(VAR_10)\n", "self.bucket_name = VAR_10\n", "self.bucket = self.storage_client.bucket(VAR_10)\n" ]
[ "def __init__(self, bucket_name: Text) ->None:...\n", "from google.cloud import storage\n", "super().__init__()\n", "self.storage_client = storage.Client()\n", "self._ensure_bucket_exists(bucket_name)\n", "self.bucket_name = bucket_name\n", "self.bucket = self.storage_client.bucket(bucket_name)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'" ]
[ "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'" ]
[ "def FUNC_15(self, VAR_6):...\n", "VAR_19 = 30\n", "VAR_20 = []\n", "VAR_21 = datetime.datetime.now()\n", "if self.is_standard == 'Yes':\n", "VAR_20 = self.execute_module(VAR_6)\n", "VAR_20 = self.execute_script(VAR_6)\n", "VAR_22 = (datetime.datetime.now() - VAR_21).total_seconds()\n", "if VAR_22 > VAR_19 and not self.prepared_report:\n", "self.db_set('prepared_report', 1)\n", "frappe.cache().hset('report_execution_time', self.name, VAR_22)\n", "return VAR_20\n" ]
[ "def execute_script_report(self, filters):...\n", "threshold = 30\n", "res = []\n", "start_time = datetime.datetime.now()\n", "if self.is_standard == 'Yes':\n", "res = self.execute_module(filters)\n", "res = self.execute_script(filters)\n", "execution_time = (datetime.datetime.now() - start_time).total_seconds()\n", "if execution_time > threshold and not self.prepared_report:\n", "self.db_set('prepared_report', 1)\n", "frappe.cache().hset('report_execution_time', self.name, execution_time)\n", "return res\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Return'" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "VAR_128 = VAR_8.getObject('Dataset', VAR_34)\n", "if VAR_128 is None:\n", "return HttpJavascriptResponseServerError('\"\"')\n", "VAR_120 = VAR_9.get('thumbprefix', 'webgateway_render_thumbnail')\n", "def FUNC_65(VAR_6):...\n", "return reverse(VAR_120, VAR_116=(iid,))\n" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "dataset = conn.getObject('Dataset', did)\n", "if dataset is None:\n", "return HttpJavascriptResponseServerError('\"\"')\n", "prefix = kwargs.get('thumbprefix', 'webgateway_render_thumbnail')\n", "def urlprefix(iid):...\n", "return reverse(prefix, args=(iid,))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Condition", "Return'", "Assign'", "FunctionDef'", "Return'" ]
[ "@wraps(VAR_2)...\n", "if current_user.role_edit() or current_user.role_admin():\n", "return VAR_2(*VAR_48, **kwargs)\n", "abort(403)\n" ]
[ "@wraps(f)...\n", "if current_user.role_edit() or current_user.role_admin():\n", "return f(*args, **kwargs)\n", "abort(403)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Condition", "Return'", "Expr'" ]
[ "def FUNC_25(VAR_18):...\n", "return VAR_18 is not None and bool(VAR_18['wizard']['order'])\n" ]
[ "def wizard_active(templates):...\n", "return templates is not None and bool(templates['wizard']['order'])\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_27(self):...\n", "VAR_146 = get_user_model()\n", "return VAR_146.objects.get(VAR_73=self.submitter_email)\n", "return None\n" ]
[ "def get_submitter_userprofile(self):...\n", "User = get_user_model()\n", "return User.objects.get(email=self.submitter_email)\n", "return None\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'", "Return'" ]
[ "def FUNC_60():...\n", "\"\"\"docstring\"\"\"\n", "VAR_78 = 0\n", "while True:\n", "VAR_126 = FUNC_58('/ping', 'get')\n", "time.sleep(2)\n", "print(\n 'Internal API server not online (mostly because Ganga is booting up), retrying...'\n )\n", "if VAR_126 is True:\n", "VAR_78 += 1\n", "return True\n", "if VAR_78 > 20:\n", "return False\n" ]
[ "def ping_internal():...\n", "\"\"\"docstring\"\"\"\n", "trials = 0\n", "while True:\n", "ping = query_internal_api('/ping', 'get')\n", "time.sleep(2)\n", "print(\n 'Internal API server not online (mostly because Ganga is booting up), retrying...'\n )\n", "if ping is True:\n", "trials += 1\n", "return True\n", "if trials > 20:\n", "return False\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "Condition", "AugAssign'", "Return'", "Condition", "Return'" ]
[ "@login_required...\n", "\"\"\"docstring\"\"\"\n", "if request.method == 'POST':\n", "if 'loadfile' in request.files:\n", "VAR_88 = FUNC_58('/internal/templates', 'get', VAR_73={'recent': True,\n 'length': '6'})\n", "flash(str(err), 'danger')\n", "return render_template('create.html', title='Create', VAR_88=templates_info)\n", "VAR_119 = request.files['loadfile']\n", "if 'runfile' in request.files:\n", "return redirect(url_for('dashboard'))\n", "if VAR_119.filename == '':\n", "VAR_120 = request.files['runfile']\n", "flash('No file, retry!', 'warning')\n", "flash('No file selected', 'warning')\n", "if VAR_119 and FUNC_57(VAR_119.filename):\n", "if VAR_120.filename == '':\n", "return redirect(request.url)\n", "return redirect(request.url)\n", "VAR_130 = os.path.join(VAR_0.config['UPLOAD_FOLDER'], 'loadfile.txt')\n", "flash('No file selected', 'warning')\n", "if VAR_120 and FUNC_57(VAR_120.filename):\n", "VAR_119.save(VAR_130)\n", "return redirect(request.url)\n", "VAR_130 = os.path.join(VAR_0.config['UPLOAD_FOLDER'], 'runfile.py')\n", "VAR_98 = FUNC_58('/internal/load', 'get', VAR_73={'path': save_path})\n", "flash(str(err), 'danger')\n", "flash(VAR_98.get('message'), 'success')\n", "VAR_120.save(VAR_130)\n", "return redirect(request.url)\n", "return redirect(request.url)\n", "VAR_98 = FUNC_58('/internal/runfile', 'get', VAR_73={'path': save_path})\n", "flash(str(err), 'danger')\n", "flash(VAR_98.get('message'), 'success')\n", "return redirect(request.url)\n", "return redirect(request.url)\n" ]
[ "@login_required...\n", "\"\"\"docstring\"\"\"\n", "if request.method == 'POST':\n", "if 'loadfile' in request.files:\n", "templates_info = query_internal_api('/internal/templates', 'get', params={\n 'recent': True, 'length': '6'})\n", "flash(str(err), 'danger')\n", "return render_template('create.html', title='Create', templates_info=\n templates_info)\n", "loadfile = request.files['loadfile']\n", "if 'runfile' in request.files:\n", "return redirect(url_for('dashboard'))\n", "if loadfile.filename == '':\n", "runfile = request.files['runfile']\n", "flash('No file, retry!', 'warning')\n", "flash('No file selected', 'warning')\n", "if loadfile and allowed_file(loadfile.filename):\n", "if runfile.filename == '':\n", "return redirect(request.url)\n", "return redirect(request.url)\n", "save_path = os.path.join(gui.config['UPLOAD_FOLDER'], 'loadfile.txt')\n", "flash('No file selected', 'warning')\n", "if runfile and allowed_file(runfile.filename):\n", "loadfile.save(save_path)\n", "return redirect(request.url)\n", "save_path = os.path.join(gui.config['UPLOAD_FOLDER'], 'runfile.py')\n", "response_info = query_internal_api('/internal/load', 'get', params={'path':\n save_path})\n", "flash(str(err), 'danger')\n", "flash(response_info.get('message'), 'success')\n", "runfile.save(save_path)\n", "return redirect(request.url)\n", "return redirect(request.url)\n", "response_info = query_internal_api('/internal/runfile', 'get', params={\n 'path': save_path})\n", "flash(str(err), 'danger')\n", "flash(response_info.get('message'), 'success')\n", "return redirect(request.url)\n", "return redirect(request.url)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Condition", "Assign'", "Expr'", "Return'", "Assign'", "Condition", "Return'", "Condition", "Assign'", "Expr'", "Expr'", "Condition", "Condition", "Return'", "Return'", "Assign'", "Expr'", "Condition", "Expr'", "Return'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Return'", "Return'", "Assign'", "Expr'", "Expr'", "Return'", "Return'" ]
[ "def FUNC_31(self):...\n", "self.log.propagate = False\n", "for VAR_19 in (app_log, access_log, gen_log):\n", "VAR_19.name = self.log.name\n", "VAR_89 = logging.getLogger('tornado')\n", "VAR_89.propagate = True\n", "VAR_89.parent = self.log\n", "VAR_89.setLevel(self.log.level)\n" ]
[ "def init_logging(self):...\n", "self.log.propagate = False\n", "for log in (app_log, access_log, gen_log):\n", "log.name = self.log.name\n", "logger = logging.getLogger('tornado')\n", "logger.propagate = True\n", "logger.parent = self.log\n", "logger.setLevel(self.log.level)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "@CLASS_4('backend-warning')...\n", "\"\"\"docstring\"\"\"\n", "VAR_20 = jinja.render('backend-warning.html', distribution=version.\n distribution(), Distribution=version.Distribution, version=\n pkg_resources.parse_version, title='Legacy backend warning')\n", "return 'text/html', VAR_20\n" ]
[ "@add_handler('backend-warning')...\n", "\"\"\"docstring\"\"\"\n", "html = jinja.render('backend-warning.html', distribution=version.\n distribution(), Distribution=version.Distribution, version=\n pkg_resources.parse_version, title='Legacy backend warning')\n", "return 'text/html', html\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_75(VAR_9):...\n", "\"\"\"docstring\"\"\"\n", "VAR_192 = json.loads(VAR_9.body or '{}')\n", "return VAR_192\n" ]
[ "def parse_request_data(request):...\n", "\"\"\"docstring\"\"\"\n", "data = json.loads(request.body or '{}')\n", "return data\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "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" ]
[ "def __init__(self, hs):...\n", "super().__init__(hs)\n", "self.clock = hs.get_clock()\n", "self.client = hs.get_http_client()\n" ]
[ 0, 0, 0, 4 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'" ]
[ "def FUNC_67(VAR_125, VAR_46, VAR_105):...\n", "\"\"\"docstring\"\"\"\n", "if isinstance(VAR_105, dict):\n", "VAR_125.setdefault(VAR_46, {})\n", "VAR_125.setdefault(VAR_46, [])\n", "for inkey in VAR_105:\n", "if not isinstance(VAR_105, list):\n", "FUNC_67(VAR_125[VAR_46], inkey, VAR_105[inkey])\n", "VAR_105 = [VAR_105]\n", "VAR_125[VAR_46].extend(VAR_105)\n" ]
[ "def append_hook(target, key, value):...\n", "\"\"\"docstring\"\"\"\n", "if isinstance(value, dict):\n", "target.setdefault(key, {})\n", "target.setdefault(key, [])\n", "for inkey in value:\n", "if not isinstance(value, list):\n", "append_hook(target[key], inkey, value[inkey])\n", "value = [value]\n", "target[key].extend(value)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'", "Expr'", "For", "Condition", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_3(VAR_4, VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "return VAR_4.signature_def[VAR_5].outputs\n" ]
[ "def _get_outputs_tensor_info_from_meta_graph_def(meta_graph_def,...\n", "\"\"\"docstring\"\"\"\n", "return meta_graph_def.signature_def[signature_def_key].outputs\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "@log_function...\n", "\"\"\"docstring\"\"\"\n", "VAR_2 = FUNC_1('/user/keys/claim')\n", "VAR_19 = await self.client.post_json(VAR_5=destination, VAR_2=path, VAR_39=\n query_content, VAR_8=timeout)\n", "return VAR_19\n" ]
[ "@log_function...\n", "\"\"\"docstring\"\"\"\n", "path = _create_v1_path('/user/keys/claim')\n", "content = await self.client.post_json(destination=destination, path=path,\n data=query_content, timeout=timeout)\n", "return content\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_62(VAR_120):...\n", "\"\"\"docstring\"\"\"\n", "return FUNC_69(os.path.join(os.path.dirname(FUNC_55(VAR_120).__file__),\n 'modules.txt'))\n" ]
[ "def get_module_list(app_name):...\n", "\"\"\"docstring\"\"\"\n", "return get_file_items(os.path.join(os.path.dirname(get_module(app_name).\n __file__), 'modules.txt'))\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_2(VAR_7=None):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_7 is None:\n", "VAR_7 = jupyter_runtime_dir()\n", "if not os.path.isdir(VAR_7):\n", "return\n", "for file in os.listdir(VAR_7):\n", "if file.startswith('nbserver-'):\n", "VAR_93 = VAR_27.load(VAR_102)\n", "if 'pid' in VAR_93 and check_pid(VAR_93['pid']):\n", "yield VAR_93\n", "os.unlink(file)\n" ]
[ "def list_running_servers(runtime_dir=None):...\n", "\"\"\"docstring\"\"\"\n", "if runtime_dir is None:\n", "runtime_dir = jupyter_runtime_dir()\n", "if not os.path.isdir(runtime_dir):\n", "return\n", "for file in os.listdir(runtime_dir):\n", "if file.startswith('nbserver-'):\n", "info = json.load(f)\n", "if 'pid' in info and check_pid(info['pid']):\n", "yield info\n", "os.unlink(file)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Return'", "For", "Condition", "Assign'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_10(VAR_23, VAR_24, VAR_25, VAR_26=None, VAR_27=None):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_11(VAR_37):...\n", "VAR_4, VAR_39 = VAR_37\n", "VAR_25.write(VAR_4)\n", "return VAR_39\n" ]
[ "def get_file(destination, path, output_stream, args=None, max_size=None):...\n", "\"\"\"docstring\"\"\"\n", "def write_to(r):...\n", "data, response = r\n", "output_stream.write(data)\n", "return response\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_11(self) ->DataStore:...\n", "if not self.datastores:\n", "return self.datastores.main\n" ]
[ "def get_datastore(self) ->DataStore:...\n", "if not self.datastores:\n", "return self.datastores.main\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'" ]
[ "async def FUNC_7(self, VAR_4: str, VAR_16: str, VAR_17: str, VAR_6: str,...\n", "\"\"\"docstring\"\"\"\n", "VAR_45 = {'country': VAR_16, 'phone_number': VAR_17, 'client_secret': VAR_6,\n 'send_attempt': VAR_12}\n", "if VAR_14:\n", "VAR_45['next_link'] = VAR_14\n", "if self.hs.config.using_identity_server_from_trusted_list:\n", "VAR_0.warning('string')\n", "VAR_46 = await self.http_client.post_json_get_json(VAR_4 +\n '/_matrix/identity/api/v1/validate/msisdn/requestToken', VAR_45)\n", "VAR_0.info('Proxied requestToken failed: %r', e)\n", "assert self.hs.config.public_baseurl\n", "VAR_46['submit_url'] = (self.hs.config.public_baseurl +\n '_matrix/client/unstable/add_threepid/msisdn/submit_token')\n", "return VAR_46\n" ]
[ "async def requestMsisdnToken(self, id_server: str, country: str,...\n", "\"\"\"docstring\"\"\"\n", "params = {'country': country, 'phone_number': phone_number, 'client_secret':\n client_secret, 'send_attempt': send_attempt}\n", "if next_link:\n", "params['next_link'] = next_link\n", "if self.hs.config.using_identity_server_from_trusted_list:\n", "logger.warning(\n 'The config option \"trust_identity_server_for_password_resets\" has been replaced by \"account_threepid_delegate\". Please consult the sample config at docs/sample_config.yaml for details and update your config file.'\n )\n", "data = await self.http_client.post_json_get_json(id_server +\n '/_matrix/identity/api/v1/validate/msisdn/requestToken', params)\n", "logger.info('Proxied requestToken failed: %r', e)\n", "assert self.hs.config.public_baseurl\n", "data['submit_url'] = (self.hs.config.public_baseurl +\n '_matrix/client/unstable/add_threepid/msisdn/submit_token')\n", "return data\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Assert'", "Assign'", "Return'" ]
[ "def FUNC_38(VAR_33):...\n", "if callable(VAR_65):\n", "return FUNC_19(VAR_33)\n", "VAR_34 = VAR_65()\n", "VAR_0.exception(\n 'Error while trying to retrieve custom LastModified value for plugin {}'\n .format(VAR_8))\n", "if VAR_34:\n", "return VAR_34\n" ]
[ "def compute_lastmodified(files):...\n", "if callable(custom_lastmodified):\n", "return _compute_date(files)\n", "lastmodified = custom_lastmodified()\n", "_logger.exception(\n 'Error while trying to retrieve custom LastModified value for plugin {}'\n .format(key))\n", "if lastmodified:\n", "return lastmodified\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "Expr'", "Condition", "Return'" ]
[ "async def FUNC_1(self):...\n", "VAR_24 = self.recently_accessed_remotes\n", "self.recently_accessed_remotes = set()\n", "VAR_25 = self.recently_accessed_locals\n", "self.recently_accessed_locals = set()\n", "await self.store.update_cached_last_access_time(VAR_25, VAR_24, self.clock.\n time_msec())\n" ]
[ "async def _update_recently_accessed(self):...\n", "remote_media = self.recently_accessed_remotes\n", "self.recently_accessed_remotes = set()\n", "local_media = self.recently_accessed_locals\n", "self.recently_accessed_locals = set()\n", "await self.store.update_cached_last_access_time(local_media, remote_media,\n self.clock.time_msec())\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def __str__(self):...\n", "return '%s' % self.filename\n" ]
[ "def __str__(self):...\n", "return '%s' % self.filename\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_9(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_19 = keyring.KeyFetcher()\n", "VAR_19.get_keys = Mock(return_value=make_awaitable({}))\n", "VAR_4 = keyring.Keyring(self.hs, key_fetchers=(StoreKeyFetcher(self.hs),\n mock_fetcher))\n", "VAR_20 = signedjson.key.generate_signing_key(1)\n", "VAR_27 = self.hs.get_datastore().store_server_verify_keys('server9', time.\n time() * 1000, [('server9', FUNC_0(VAR_20), FetchKeyResult(\n get_verify_key(VAR_20), None))])\n", "self.get_success(VAR_27)\n", "VAR_21 = {}\n", "signedjson.sign.sign_json(VAR_21, 'server9', VAR_20)\n", "VAR_28 = FUNC_2(VAR_4, 'server9', {}, 0, 'test unsigned')\n", "self.get_failure(VAR_28, SynapseError)\n", "VAR_28 = FUNC_2(VAR_4, 'server9', VAR_21, 500, 'test signed non-zero min')\n", "self.get_failure(VAR_28, SynapseError)\n", "VAR_19.get_keys.assert_called_once_with({'server9': {FUNC_0(VAR_20): 500}})\n", "VAR_28 = FUNC_2(VAR_4, 'server9', VAR_21, 0, 'test signed with zero min')\n", "self.get_success(VAR_28)\n" ]
[ "def test_verify_json_for_server_with_null_valid_until_ms(self):...\n", "\"\"\"docstring\"\"\"\n", "mock_fetcher = keyring.KeyFetcher()\n", "mock_fetcher.get_keys = Mock(return_value=make_awaitable({}))\n", "kr = keyring.Keyring(self.hs, key_fetchers=(StoreKeyFetcher(self.hs),\n mock_fetcher))\n", "key1 = signedjson.key.generate_signing_key(1)\n", "r = self.hs.get_datastore().store_server_verify_keys('server9', time.time() *\n 1000, [('server9', get_key_id(key1), FetchKeyResult(get_verify_key(key1\n ), None))])\n", "self.get_success(r)\n", "json1 = {}\n", "signedjson.sign.sign_json(json1, 'server9', key1)\n", "d = _verify_json_for_server(kr, 'server9', {}, 0, 'test unsigned')\n", "self.get_failure(d, SynapseError)\n", "d = _verify_json_for_server(kr, 'server9', json1, 500,\n 'test signed non-zero min')\n", "self.get_failure(d, SynapseError)\n", "mock_fetcher.get_keys.assert_called_once_with({'server9': {get_key_id(key1):\n 500}})\n", "d = _verify_json_for_server(kr, 'server9', json1, 0,\n 'test signed with zero min')\n", "self.get_success(d)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_35(self, VAR_6, VAR_7, VAR_30):...\n", "if VAR_53.session['admin']:\n", "if self.userdb.addUser(VAR_6, VAR_7, VAR_30):\n", "return \"You didn't think that would work, did you?\"\n", "return 'added new user: %s' % VAR_6\n", "return 'error, cannot add new user!' % VAR_6\n" ]
[ "def api_adduser(self, username, password, isadmin):...\n", "if cherrypy.session['admin']:\n", "if self.userdb.addUser(username, password, isadmin):\n", "return \"You didn't think that would work, did you?\"\n", "return 'added new user: %s' % username\n", "return 'error, cannot add new user!' % username\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Return'", "Return'", "Return'" ]
[ "def FUNC_18(self, VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "for original, urlized in VAR_2.items():\n", "assert urlize_quoted_links(original, nofollow=False) == urlized\n" ]
[ "def _urlize_dict_check(self, data):...\n", "\"\"\"docstring\"\"\"\n", "for original, urlized in data.items():\n", "assert urlize_quoted_links(original, nofollow=False) == urlized\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "For", "Assert'" ]
[ "@property...\n", "return False\n" ]
[ "@property...\n", "return False\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "@VAR_0.route('/<path:path>', methods=['GET'])...\n", "" ]
[ "@app.route('/<path:path>', methods=['GET'])...\n", "" ]
[ 0, 0 ]
[ "Condition", "Condition" ]
[ "@VAR_2.route('/import_ldap_users')...\n", "VAR_33 = {}\n", "VAR_116 = services.ldap.get_group_members(config.config_ldap_group_name)\n", "VAR_0.debug_or_exception(e)\n", "if not VAR_116:\n", "VAR_33['text'] = _(u'Error: %(ldaperror)s', ldaperror=e)\n", "VAR_0.debug('LDAP empty response')\n", "VAR_93 = 0\n", "return json.dumps(VAR_33)\n", "VAR_33['text'] = _(u'Error: No user returned in response of LDAP server')\n", "for VAR_114 in VAR_116:\n", "return json.dumps(VAR_33)\n", "VAR_12 = VAR_114.decode('utf-8')\n", "if not VAR_33:\n", "if '=' in VAR_12:\n", "VAR_33['text'] = _(u'{} User Successfully Imported'.format(VAR_93))\n", "return json.dumps(VAR_33)\n", "if config.config_ldap_member_user_object:\n", "VAR_127 = VAR_12\n", "VAR_128 = config.config_ldap_member_user_object\n", "VAR_128 = config.config_ldap_user_object\n", "VAR_128 = None\n", "VAR_127 = FUNC_70(VAR_12, VAR_128)\n", "VAR_0.warning(ex)\n", "VAR_27 = services.ldap.get_object_details(VAR_12=user_identifier, VAR_128=\n query_filter)\n", "VAR_0.debug_or_exception(ex)\n", "if VAR_27:\n", "VAR_129, VAR_71 = FUNC_66(VAR_12, VAR_27)\n", "VAR_0.warning('LDAP User: %s Not Found', VAR_12)\n", "if VAR_71:\n", "VAR_33['text'] = _(u'At Least One LDAP User Not Found in Database')\n", "VAR_33['text'] = VAR_71\n", "VAR_93 += VAR_129\n" ]
[ "@admi.route('/import_ldap_users')...\n", "showtext = {}\n", "new_users = services.ldap.get_group_members(config.config_ldap_group_name)\n", "log.debug_or_exception(e)\n", "if not new_users:\n", "showtext['text'] = _(u'Error: %(ldaperror)s', ldaperror=e)\n", "log.debug('LDAP empty response')\n", "imported = 0\n", "return json.dumps(showtext)\n", "showtext['text'] = _(u'Error: No user returned in response of LDAP server')\n", "for username in new_users:\n", "return json.dumps(showtext)\n", "user = username.decode('utf-8')\n", "if not showtext:\n", "if '=' in user:\n", "showtext['text'] = _(u'{} User Successfully Imported'.format(imported))\n", "return json.dumps(showtext)\n", "if config.config_ldap_member_user_object:\n", "user_identifier = user\n", "query_filter = config.config_ldap_member_user_object\n", "query_filter = config.config_ldap_user_object\n", "query_filter = None\n", "user_identifier = extract_user_identifier(user, query_filter)\n", "log.warning(ex)\n", "user_data = services.ldap.get_object_details(user=user_identifier,\n query_filter=query_filter)\n", "log.debug_or_exception(ex)\n", "if user_data:\n", "user_count, message = ldap_import_create_user(user, user_data)\n", "log.warning('LDAP User: %s Not Found', user)\n", "if message:\n", "showtext['text'] = _(u'At Least One LDAP User Not Found in Database')\n", "showtext['text'] = message\n", "imported += user_count\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 ]
[ "Condition", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Expr'", "Assign'", "Return'", "Assign'", "For", "Return'", "Assign'", "Condition", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Condition", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "AugAssign'" ]
[ "def FUNC_66(self, VAR_13, VAR_14):...\n", "\"\"\"docstring\"\"\"\n", "VAR_86 = '<a href=\"#fnref-%s\" class=\"footnote\">&#8617;</a>' % VAR_19(VAR_13)\n", "VAR_14 = VAR_14.rstrip()\n", "if VAR_14.endswith('</p>'):\n", "VAR_14 = re.sub('<\\\\/p>$', '%s</p>' % VAR_86, VAR_14)\n", "VAR_14 = '%s<p>%s</p>' % (VAR_14, VAR_86)\n", "VAR_64 = '<li id=\"fn-%s\">%s</li>\\n' % (VAR_19(VAR_13), VAR_14)\n", "return VAR_64\n" ]
[ "def footnote_item(self, key, text):...\n", "\"\"\"docstring\"\"\"\n", "back = '<a href=\"#fnref-%s\" class=\"footnote\">&#8617;</a>' % escape(key)\n", "text = text.rstrip()\n", "if text.endswith('</p>'):\n", "text = re.sub('<\\\\/p>$', '%s</p>' % back, text)\n", "text = '%s<p>%s</p>' % (text, back)\n", "html = '<li id=\"fn-%s\">%s</li>\\n' % (escape(key), text)\n", "return html\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_0(VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "VAR_1 = 'cli/' + VAR_1\n", "VAR_0 = click_web.logger\n", "VAR_6 = ['shell', 'run', 'routes', 'create-admin']\n", "VAR_7, *VAR_4 = VAR_1.split('/')\n", "VAR_3 = ['archivy']\n", "VAR_2 = CLASS_0()\n", "VAR_3.extend(VAR_2.command_args(0))\n", "for i, command in enumerate(VAR_4):\n", "if command in VAR_6:\n", "def FUNC_5():...\n", "return Response(status=400)\n", "VAR_3.append(command)\n", "yield FUNC_2(VAR_4)\n", "VAR_3.extend(VAR_2.command_args(i + 1))\n", "yield from FUNC_1(VAR_2, VAR_3)\n", "yield f\"\"\"\nERROR: Got exception when reading output from script: {type(e)}\n\"\"\"\n", "return Response(FUNC_5(), mimetype='text/plain')\n", "yield traceback.format_exc()\n" ]
[ "def exec(command_path):...\n", "\"\"\"docstring\"\"\"\n", "command_path = 'cli/' + command_path\n", "logger = click_web.logger\n", "omitted = ['shell', 'run', 'routes', 'create-admin']\n", "root_command, *commands = command_path.split('/')\n", "cmd = ['archivy']\n", "req_to_args = RequestToCommandArgs()\n", "cmd.extend(req_to_args.command_args(0))\n", "for i, command in enumerate(commands):\n", "if command in omitted:\n", "def _generate_output():...\n", "return Response(status=400)\n", "cmd.append(command)\n", "yield _create_cmd_header(commands)\n", "cmd.extend(req_to_args.command_args(i + 1))\n", "yield from _run_script_and_generate_stream(req_to_args, cmd)\n", "yield f\"\"\"\nERROR: Got exception when reading output from script: {type(e)}\n\"\"\"\n", "return Response(_generate_output(), mimetype='text/plain')\n", "yield traceback.format_exc()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "For", "Condition", "FunctionDef'", "Return'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Return'", "Expr'" ]
[ "@transaction.non_atomic_requests...\n", "\"\"\"docstring\"\"\"\n", "VAR_38 = SlashSeparatedCourseKey.from_deprecated_string(VAR_10)\n", "instructor_task.api.submit_calculate_grades_csv(VAR_9, VAR_38)\n", "VAR_196 = _('string')\n", "VAR_172 = _(\n 'The grade report is being created. To view the status of the report, see Pending Tasks below.'\n )\n", "return JsonResponse({'status': VAR_196})\n", "return JsonResponse({'status': VAR_172})\n" ]
[ "@transaction.non_atomic_requests...\n", "\"\"\"docstring\"\"\"\n", "course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n", "instructor_task.api.submit_calculate_grades_csv(request, course_key)\n", "already_running_status = _(\n 'The grade report is currently being created. To view the status of the report, see Pending Tasks below. You will be able to download the report when it is complete.'\n )\n", "success_status = _(\n 'The grade report is being created. To view the status of the report, see Pending Tasks below.'\n )\n", "return JsonResponse({'status': already_running_status})\n", "return JsonResponse({'status': success_status})\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Expr'", "Assign'", "Assign'", "Return'", "Return'" ]
[ "def FUNC_0(VAR_2, VAR_3, VAR_4):...\n", "\"\"\"docstring\"\"\"\n", "VAR_51 = None\n", "VAR_52 = VAR_2.GET.get(VAR_3, VAR_4)\n", "if VAR_52 is not None:\n", "VAR_51 = VAR_241(VAR_52)\n", "return VAR_51\n" ]
[ "def get_long_or_default(request, name, default):...\n", "\"\"\"docstring\"\"\"\n", "val = None\n", "val_raw = request.GET.get(name, default)\n", "if val_raw is not None:\n", "val = long(val_raw)\n", "return val\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Condition", "Assign'", "Return'" ]
[ "@FUNC_0...\n", "return RoomContextHandler(self)\n" ]
[ "@cache_in_self...\n", "return RoomContextHandler(self)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_63(self, VAR_34, VAR_33=None):...\n", "\"\"\"docstring\"\"\"\n", "if not (isinstance(self.get(VAR_34), list) and len(self.get(VAR_34)) > 0):\n", "VAR_93 = self.meta.get_label(VAR_34)\n", "frappe.throw(_('Table {0} cannot be empty').format(VAR_93), VAR_33 or\n frappe.EmptyTableError)\n" ]
[ "def validate_table_has_rows(self, parentfield, raise_exception=None):...\n", "\"\"\"docstring\"\"\"\n", "if not (isinstance(self.get(parentfield), list) and len(self.get(\n", "label = self.meta.get_label(parentfield)\n", "frappe.throw(_('Table {0} cannot be empty').format(label), raise_exception or\n frappe.EmptyTableError)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Expr'" ]
[ "def FUNC_5():...\n", "yield FUNC_2(VAR_4)\n", "yield from FUNC_1(VAR_2, VAR_3)\n", "yield f\"\"\"\nERROR: Got exception when reading output from script: {type(e)}\n\"\"\"\n", "yield traceback.format_exc()\n" ]
[ "def _generate_output():...\n", "yield _create_cmd_header(commands)\n", "yield from _run_script_and_generate_stream(req_to_args, cmd)\n", "yield f\"\"\"\nERROR: Got exception when reading output from script: {type(e)}\n\"\"\"\n", "yield traceback.format_exc()\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_22(self, VAR_36):...\n", "VAR_28 = self.nodelist.render(VAR_36)\n", "return pygments_highlight(VAR_28, self.lang, self.style)\n" ]
[ "def render(self, context):...\n", "text = self.nodelist.render(context)\n", "return pygments_highlight(text, self.lang, self.style)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "async def FUNC_20(VAR_9=None, VAR_10=False):...\n", "return synapse.types.create_requester(VAR_0)\n" ]
[ "async def _get_user_by_req(request=None, allow_guest=False):...\n", "return synapse.types.create_requester(myid)\n" ]
[ 0, 0 ]
[ "AsyncFunctionDef'", "Return'" ]
[ "async def FUNC_12(self, VAR_4: str, VAR_2: str, VAR_19: str, VAR_20: str...\n", "\"\"\"docstring\"\"\"\n", "VAR_59 = await self.blacklisting_http_client.get_json(\n '%s%s/_matrix/identity/v2/hash_details' % (VAR_1, VAR_4), {\n 'access_token': VAR_2})\n", "if not isinstance(VAR_59, dict):\n", "VAR_0.warning('Got non-dict object when checking hash details of %s%s: %s',\n VAR_1, VAR_4, VAR_59)\n", "VAR_50 = VAR_59.get('algorithms')\n", "VAR_51 = VAR_59.get('lookup_pepper')\n", "if not VAR_50 or not isinstance(VAR_50, list) or not VAR_51 or not isinstance(\n", "if CLASS_1.SHA256 in VAR_50:\n", "VAR_60 = CLASS_1.SHA256\n", "if CLASS_1.NONE in VAR_50:\n", "VAR_61 = '%s %s %s' % (VAR_20, VAR_19, VAR_51)\n", "VAR_60 = CLASS_1.NONE\n", "VAR_0.warning('None of the provided lookup algorithms of %s are supported: %s',\n VAR_4, VAR_50)\n", "VAR_62 = sha256_and_url_safe_base64(VAR_61)\n", "VAR_62 = '%s %s' % (VAR_20, VAR_19)\n", "VAR_36 = {'Authorization': FUNC_0(VAR_2)}\n", "VAR_63 = await self.blacklisting_http_client.post_json_get_json(\n '%s%s/_matrix/identity/v2/lookup' % (VAR_1, VAR_4), {'addresses': [\n VAR_62], 'algorithm': VAR_60, 'pepper': VAR_51}, VAR_36=headers)\n", "VAR_0.warning('Error when performing a v2 3pid lookup: %s', e)\n", "if 'mappings' not in VAR_63 or not isinstance(VAR_63['mappings'], dict):\n", "VAR_0.warning('No results from 3pid lookup')\n", "VAR_8 = VAR_63['mappings'].get(VAR_62)\n", "return None\n", "return VAR_8\n" ]
[ "async def _lookup_3pid_v2(self, id_server: str, id_access_token: str,...\n", "\"\"\"docstring\"\"\"\n", "hash_details = await self.blacklisting_http_client.get_json(\n '%s%s/_matrix/identity/v2/hash_details' % (id_server_scheme, id_server),\n {'access_token': id_access_token})\n", "if not isinstance(hash_details, dict):\n", "logger.warning('Got non-dict object when checking hash details of %s%s: %s',\n id_server_scheme, id_server, hash_details)\n", "supported_lookup_algorithms = hash_details.get('algorithms')\n", "lookup_pepper = hash_details.get('lookup_pepper')\n", "if not supported_lookup_algorithms or not isinstance(\n", "if LookupAlgorithm.SHA256 in supported_lookup_algorithms:\n", "lookup_algorithm = LookupAlgorithm.SHA256\n", "if LookupAlgorithm.NONE in supported_lookup_algorithms:\n", "to_hash = '%s %s %s' % (address, medium, lookup_pepper)\n", "lookup_algorithm = LookupAlgorithm.NONE\n", "logger.warning('None of the provided lookup algorithms of %s are supported: %s'\n , id_server, supported_lookup_algorithms)\n", "lookup_value = sha256_and_url_safe_base64(to_hash)\n", "lookup_value = '%s %s' % (address, medium)\n", "headers = {'Authorization': create_id_access_token_header(id_access_token)}\n", "lookup_results = await self.blacklisting_http_client.post_json_get_json(\n '%s%s/_matrix/identity/v2/lookup' % (id_server_scheme, id_server), {\n 'addresses': [lookup_value], 'algorithm': lookup_algorithm, 'pepper':\n lookup_pepper}, headers=headers)\n", "logger.warning('Error when performing a v2 3pid lookup: %s', e)\n", "if 'mappings' not in lookup_results or not isinstance(lookup_results[\n", "logger.warning('No results from 3pid lookup')\n", "mxid = lookup_results['mappings'].get(lookup_value)\n", "return None\n", "return mxid\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 ]
[ "Condition", "Docstring", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Expr'", "Assign'", "Return'", "Return'" ]
[ "def FUNC_16(self, VAR_18):...\n", "\"\"\"docstring\"\"\"\n", "VAR_49 = self.get_doc_before_save()\n", "return VAR_49.get(VAR_18) != self.get(VAR_18) if VAR_49 else True\n" ]
[ "def has_value_changed(self, fieldname):...\n", "\"\"\"docstring\"\"\"\n", "previous = self.get_doc_before_save()\n", "return previous.get(fieldname) != self.get(fieldname) if previous else True\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_17(self, VAR_6):...\n", "VAR_24 = {'filters': frappe._dict(VAR_6), 'data': None, 'result': None}\n", "safe_exec(self.report_script, None, VAR_24)\n", "if VAR_24['data']:\n", "return VAR_24['data']\n", "return self.get_columns(), VAR_24['result']\n" ]
[ "def execute_script(self, filters):...\n", "loc = {'filters': frappe._dict(filters), 'data': None, 'result': None}\n", "safe_exec(self.report_script, None, loc)\n", "if loc['data']:\n", "return loc['data']\n", "return self.get_columns(), loc['result']\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Condition", "Return'", "Return'" ]
[ "def FUNC_42(VAR_62, VAR_9):...\n", "return '{0}::{1}'.format(VAR_62, VAR_9)\n" ]
[ "def get_document_cache_key(doctype, name):...\n", "return '{0}::{1}'.format(doctype, name)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_2(self, VAR_8, VAR_9):...\n", "VAR_11 = Mock(spec=['verify_json_for_server'])\n", "VAR_11.verify_json_for_server.return_value = defer.succeed(True)\n", "VAR_12 = Mock(spec=['put_json'])\n", "VAR_12.put_json.return_value = defer.succeed((200, 'OK'))\n", "VAR_8.pump((1000,))\n", "VAR_10 = self.setup_test_homeserver(notifier=Mock(), http_client=\n mock_federation_client, keyring=mock_keyring, replication_streams={})\n", "return VAR_10\n" ]
[ "def make_homeserver(self, reactor, clock):...\n", "mock_keyring = Mock(spec=['verify_json_for_server'])\n", "mock_keyring.verify_json_for_server.return_value = defer.succeed(True)\n", "mock_federation_client = Mock(spec=['put_json'])\n", "mock_federation_client.put_json.return_value = defer.succeed((200, 'OK'))\n", "reactor.pump((1000,))\n", "hs = self.setup_test_homeserver(notifier=Mock(), http_client=\n mock_federation_client, keyring=mock_keyring, replication_streams={})\n", "return hs\n" ]
[ 0, 0, 0, 0, 0, 0, 4, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_21(VAR_8, VAR_9):...\n", "self.query_handlers[VAR_8] = VAR_9\n" ]
[ "def register_query_handler(query_type, handler):...\n", "self.query_handlers[query_type] = handler\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "def FUNC_35(self):...\n", "from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver\n", "from Products.PageTemplates.unicodeconflictresolver import ReplacingUnicodeEncodingConflictResolver\n", "from zope.component import getUtility\n", "from zope.component import provideUtility\n", "provideUtility(ReplacingUnicodeEncodingConflictResolver,\n IUnicodeEncodingConflictResolver)\n", "VAR_12 = getUtility(IUnicodeEncodingConflictResolver)\n", "self.assertEqual(VAR_12.resolve(None, b'\\xe4\\xfc\\xf6', None), '���')\n" ]
[ "def testReplacingResolver(self):...\n", "from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver\n", "from Products.PageTemplates.unicodeconflictresolver import ReplacingUnicodeEncodingConflictResolver\n", "from zope.component import getUtility\n", "from zope.component import provideUtility\n", "provideUtility(ReplacingUnicodeEncodingConflictResolver,\n IUnicodeEncodingConflictResolver)\n", "resolver = getUtility(IUnicodeEncodingConflictResolver)\n", "self.assertEqual(resolver.resolve(None, b'\\xe4\\xfc\\xf6', None), '���')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Expr'", "Assign'", "Expr'" ]
[ "async def FUNC_5(self, VAR_13) ->None:...\n", "\"\"\"docstring\"\"\"\n", "VAR_27 = 1\n", "while True:\n", "VAR_46 = [(VAR_2, self.key_downloads[VAR_2]) for VAR_2 in VAR_13 if VAR_2 in\n self.key_downloads]\n", "if not VAR_46:\n", "VAR_0.info('Waiting for existing lookups for %s to complete [loop %i]', [w[\n 0] for w in VAR_46], VAR_27)\n", "await defer.DeferredList(w[1] for w in VAR_46)\n", "VAR_27 += 1\n" ]
[ "async def wait_for_previous_lookups(self, server_names) ->None:...\n", "\"\"\"docstring\"\"\"\n", "loop_count = 1\n", "while True:\n", "wait_on = [(server_name, self.key_downloads[server_name]) for server_name in\n server_names if server_name in self.key_downloads]\n", "if not wait_on:\n", "logger.info('Waiting for existing lookups for %s to complete [loop %i]', [w\n [0] for w in wait_on], loop_count)\n", "await defer.DeferredList(w[1] for w in wait_on)\n", "loop_count += 1\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "AugAssign'" ]
[ "def FUNC_124(self, VAR_10):...\n", "if self.follow_symlink_out:\n", "return VAR_418.path.normpath(VAR_10)\n", "return VAR_418.path.realpath(VAR_10)\n" ]
[ "def normalize_path(self, f):...\n", "if self.follow_symlink_out:\n", "return os.path.normpath(f)\n", "return os.path.realpath(f)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_7(self):...\n", "\"\"\"docstring\"\"\"\n" ]
[ "def get_repo_url(self):...\n", "\"\"\"docstring\"\"\"\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Docstring" ]