lines
sequencelengths
1
383
raw_lines
sequencelengths
1
383
label
sequencelengths
1
383
type
sequencelengths
1
383
[ "def FUNC_1(VAR_4):...\n", "\"\"\"docstring\"\"\"\n", "VAR_4 = 'notebook.' + VAR_4\n", "VAR_11 = __import__(VAR_4, fromlist=['default_handlers'])\n", "return VAR_11.default_handlers\n" ]
[ "def load_handlers(name):...\n", "\"\"\"docstring\"\"\"\n", "name = 'notebook.' + name\n", "mod = __import__(name, fromlist=['default_handlers'])\n", "return mod.default_handlers\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_1(self, VAR_3, VAR_4, VAR_11):...\n", "self.room_owner = self.register_user('room_owner', 'test')\n", "self.room_owner_tok = self.login('room_owner', 'test')\n", "self.room_id = self.helper.create_room_as(self.room_owner, VAR_52=self.\n room_owner_tok)\n", "self.alias = '#alias:test'\n", "self._set_alias_via_directory(self.alias)\n" ]
[ "def prepare(self, reactor, clock, homeserver):...\n", "self.room_owner = self.register_user('room_owner', 'test')\n", "self.room_owner_tok = self.login('room_owner', 'test')\n", "self.room_id = self.helper.create_room_as(self.room_owner, tok=self.\n room_owner_tok)\n", "self.alias = '#alias:test'\n", "self._set_alias_via_directory(self.alias)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_72(VAR_38, VAR_40, VAR_41):...\n", "\"\"\"docstring\"\"\"\n", "if len(CertificateWhitelist.get_certificate_white_list(VAR_38, VAR_40)) > 0:\n", "VAR_153, VAR_72 = CertificateWhitelist.objects.get_or_create(VAR_19=student,\n VAR_10=course_key, defaults={'whitelist': True, 'notes':\n certificate_exception.get('notes', '')})\n", "VAR_44 = GeneratedCertificate.eligible_certificates.filter(VAR_19=student,\n VAR_10=course_key, status=CertificateStatuses.downloadable).first()\n", "VAR_154 = dict({'id': VAR_153.id, 'user_email': VAR_40.email, 'user_name':\n VAR_40.username, 'user_id': VAR_40.id, 'certificate_generated': VAR_44 and\n VAR_44.created_date.strftime('%B %d, %Y'), 'created': VAR_153.created.\n strftime('%A, %B %d, %Y')})\n", "return VAR_154\n" ]
[ "def add_certificate_exception(course_key, student, certificate_exception):...\n", "\"\"\"docstring\"\"\"\n", "if len(CertificateWhitelist.get_certificate_white_list(course_key, student)\n", "certificate_white_list, __ = CertificateWhitelist.objects.get_or_create(user\n =student, course_id=course_key, defaults={'whitelist': True, 'notes':\n certificate_exception.get('notes', '')})\n", "generated_certificate = GeneratedCertificate.eligible_certificates.filter(user\n =student, course_id=course_key, status=CertificateStatuses.downloadable\n ).first()\n", "exception = dict({'id': certificate_white_list.id, 'user_email': student.\n email, 'user_name': student.username, 'user_id': student.id,\n 'certificate_generated': generated_certificate and\n generated_certificate.created_date.strftime('%B %d, %Y'), 'created':\n certificate_white_list.created.strftime('%A, %B %d, %Y')})\n", "return exception\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "async def FUNC_1(self, VAR_4: str, VAR_5: Dict[str, str]) ->Optional[JsonDict]:...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = VAR_5.get('client_secret') or VAR_5.get('clientSecret')\n", "if not VAR_6:\n", "assert_valid_client_secret(VAR_6)\n", "VAR_33 = VAR_5.get('sid')\n", "if not VAR_33:\n", "VAR_34 = {'sid': VAR_33, 'client_secret': VAR_6}\n", "VAR_35 = VAR_4 + '/_matrix/identity/api/v1/3pid/getValidated3pid'\n", "VAR_46 = await self.http_client.get_json(VAR_35, VAR_34)\n", "VAR_0.info('%s returned %i for threepid validation for: %s', VAR_4, e.code,\n VAR_5)\n", "if 'medium' in VAR_46:\n", "return None\n", "return VAR_46\n", "VAR_0.info('%s reported non-validated threepid: %s', VAR_4, VAR_5)\n", "return None\n" ]
[ "async def threepid_from_creds(self, id_server: str, creds: Dict[str, str]...\n", "\"\"\"docstring\"\"\"\n", "client_secret = creds.get('client_secret') or creds.get('clientSecret')\n", "if not client_secret:\n", "assert_valid_client_secret(client_secret)\n", "session_id = creds.get('sid')\n", "if not session_id:\n", "query_params = {'sid': session_id, 'client_secret': client_secret}\n", "url = id_server + '/_matrix/identity/api/v1/3pid/getValidated3pid'\n", "data = await self.http_client.get_json(url, query_params)\n", "logger.info('%s returned %i for threepid validation for: %s', id_server, e.\n code, creds)\n", "if 'medium' in data:\n", "return None\n", "return data\n", "logger.info('%s reported non-validated threepid: %s', id_server, creds)\n", "return None\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Docstring", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Return'", "Return'", "Expr'", "Return'" ]
[ "def FUNC_30(self, VAR_10):...\n", "VAR_126 = copy.copy(VAR_10)\n", "if 'discovery' in VAR_126:\n", "VAR_126.pop('discovery')\n", "VAR_61 = Component(**params)\n", "VAR_61.clean_fields(exclude=('filemask', 'file_format', 'license'))\n", "VAR_61.validate_unique()\n", "VAR_61.clean_repo()\n", "self.instance = VAR_61\n", "VAR_78 = VAR_61.suggest_repo_link()\n", "if VAR_78:\n", "VAR_10['repo'] = VAR_78\n", "VAR_10['branch'] = ''\n", "self.clean_instance(VAR_10)\n" ]
[ "def clean_instance(self, data):...\n", "params = copy.copy(data)\n", "if 'discovery' in params:\n", "params.pop('discovery')\n", "instance = Component(**params)\n", "instance.clean_fields(exclude=('filemask', 'file_format', 'license'))\n", "instance.validate_unique()\n", "instance.clean_repo()\n", "self.instance = instance\n", "repo = instance.suggest_repo_link()\n", "if repo:\n", "data['repo'] = repo\n", "data['branch'] = ''\n", "self.clean_instance(data)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_50():...\n", "return 'works'\n" ]
[ "def my_callable():...\n", "return 'works'\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_1(self, VAR_3, VAR_4, VAR_6):...\n", "self.room_id = self.helper.create_room_as(self.user_id)\n", "self.path = '/rooms/%s/state/m.room.topic' % (self.room_id,)\n" ]
[ "def prepare(self, reactor, clock, hs):...\n", "self.room_id = self.helper.create_room_as(self.user_id)\n", "self.path = '/rooms/%s/state/m.room.topic' % (self.room_id,)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'" ]
[ "def FUNC_117():...\n", "return VAR_12.sql_list('select name from tabDocType where istable=1')\n" ]
[ "def get_tables():...\n", "return db.sql_list('select name from tabDocType where istable=1')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_9(self):...\n", "VAR_7 = self.created_rmid\n", "self.helper.invite(VAR_7=room, src=self.rmcreator_id, targ=self.user_id)\n", "self.helper.join(VAR_7=room, user=self.user_id)\n", "self.helper.invite(VAR_7=room, src=self.user_id, targ=self.user_id, VAR_9=403)\n", "self.helper.join(VAR_7=room, user=self.user_id)\n", "VAR_28 = '@burgundy:red'\n", "self.helper.invite(VAR_7=room, src=self.user_id, targ=other, VAR_9=200)\n", "self.helper.change_membership(VAR_7=room, src=self.user_id, targ=other,\n membership=Membership.JOIN, VAR_9=403)\n", "self.helper.change_membership(VAR_7=room, src=self.user_id, targ=other,\n membership=Membership.LEAVE, VAR_9=403)\n", "self.helper.leave(VAR_7=room, user=self.user_id)\n" ]
[ "def test_joined_permissions(self):...\n", "room = self.created_rmid\n", "self.helper.invite(room=room, src=self.rmcreator_id, targ=self.user_id)\n", "self.helper.join(room=room, user=self.user_id)\n", "self.helper.invite(room=room, src=self.user_id, targ=self.user_id,\n expect_code=403)\n", "self.helper.join(room=room, user=self.user_id)\n", "other = '@burgundy:red'\n", "self.helper.invite(room=room, src=self.user_id, targ=other, expect_code=200)\n", "self.helper.change_membership(room=room, src=self.user_id, targ=other,\n membership=Membership.JOIN, expect_code=403)\n", "self.helper.change_membership(room=room, src=self.user_id, targ=other,\n membership=Membership.LEAVE, expect_code=403)\n", "self.helper.leave(room=room, user=self.user_id)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_42(self, VAR_36, VAR_37=False, VAR_35=''):...\n", "VAR_15 = self.getUserId()\n", "if not VAR_15:\n", "VAR_35 = (VAR_35.strip().rstrip('/') + cherry.config['server.rootpath']\n ).rstrip('/')\n", "VAR_36 = VAR_36.lower()\n", "if VAR_36 == 'm3u':\n", "VAR_111 = self.playlistdb.createM3U\n", "if VAR_36 == 'pls':\n", "VAR_77 = self.playlistdb.showPlaylists(VAR_15, include_public=all)\n", "VAR_111 = self.playlistdb.createPLS\n", "if not VAR_77:\n", "for VAR_110 in VAR_77:\n", "VAR_28 = VAR_110['plid']\n", "VAR_82 = 'application/x-zip-compressed'\n", "VAR_122 = VAR_111(VAR_28=plid, VAR_15=userid, addrstr=hostaddr)\n", "VAR_83 = 'attachment; filename=\"playlists.zip\"'\n", "VAR_81 = self.playlistdb.getName(VAR_28, VAR_15) + '.' + VAR_36\n", "VAR_53.response.headers['Content-Type'] = VAR_82\n", "if not VAR_110['owner']:\n", "VAR_53.response.headers['Content-Disposition'] = VAR_83\n", "VAR_6 = self.userdb.getNameById(VAR_110['userid'])\n", "zip.writestr(VAR_81, VAR_122)\n", "return zip.getbytes()\n", "VAR_81 = VAR_6 + '/' + VAR_81\n" ]
[ "def export_playlists(self, format, all=False, hostaddr=''):...\n", "userid = self.getUserId()\n", "if not userid:\n", "hostaddr = (hostaddr.strip().rstrip('/') + cherry.config['server.rootpath']\n ).rstrip('/')\n", "format = format.lower()\n", "if format == 'm3u':\n", "filemaker = self.playlistdb.createM3U\n", "if format == 'pls':\n", "playlists = self.playlistdb.showPlaylists(userid, include_public=all)\n", "filemaker = self.playlistdb.createPLS\n", "if not playlists:\n", "for pl in playlists:\n", "plid = pl['plid']\n", "zipmime = 'application/x-zip-compressed'\n", "plstr = filemaker(plid=plid, userid=userid, addrstr=hostaddr)\n", "zipname = 'attachment; filename=\"playlists.zip\"'\n", "name = self.playlistdb.getName(plid, userid) + '.' + format\n", "cherrypy.response.headers['Content-Type'] = zipmime\n", "if not pl['owner']:\n", "cherrypy.response.headers['Content-Disposition'] = zipname\n", "username = self.userdb.getNameById(pl['userid'])\n", "zip.writestr(name, plstr)\n", "return zip.getbytes()\n", "name = username + '/' + name\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "For", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Return'", "Assign'" ]
[ "def FUNC_17(self):...\n", "assert ClearableFileInput().media._js == ['s3file/js/s3file.js']\n" ]
[ "def test_media(self):...\n", "assert ClearableFileInput().media._js == ['s3file/js/s3file.js']\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assert'" ]
[ "def FUNC_23(self):...\n", "self.assert_expected(self.folder.t, 'CheckImportOldStyleClass.html')\n" ]
[ "def testImportOldStyleClass(self):...\n", "self.assert_expected(self.folder.t, 'CheckImportOldStyleClass.html')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "if VAR_2.method != 'POST':\n", "VAR_156 = getIntOrDefault(VAR_2, 'rating', 0)\n", "VAR_154 = FUNC_42(VAR_2, VAR_5)\n", "for VAR_309, VAR_143 in VAR_154.items():\n", "for o in VAR_143:\n", "return JsonResponse({'success': True})\n", "o.setRating(VAR_156)\n" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "if request.method != 'POST':\n", "rating = getIntOrDefault(request, 'rating', 0)\n", "oids = getObjects(request, conn)\n", "for otype, objs in oids.items():\n", "for o in objs:\n", "return JsonResponse({'success': True})\n", "o.setRating(rating)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Assign'", "Assign'", "For", "For", "Return'", "Expr'" ]
[ "import logging\n", "from aiohttp import web\n", "import os\n", "VAR_0 = logging.getLogger(__package__)\n", "def FUNC_0(VAR_1):...\n", "VAR_9 = FUNC_2({(404): FUNC_4, (500): FUNC_5})\n", "VAR_1.middlewares.append(VAR_9)\n", "VAR_1.middlewares.append(FUNC_1)\n", "VAR_2 = int(os.getenv('CACHE_MAX_AGE', '30'))\n", "VAR_3 = ['/v1/', '/v1/__version__', '/v1/__heartbeat__', '/v1/__lbheartbeat__']\n", "async def FUNC_1(VAR_1, VAR_4):...\n", "async def FUNC_6(VAR_6):...\n", "VAR_7 = await VAR_4(VAR_6)\n", "VAR_10 = 'public; max-age={}'.format(VAR_2)\n", "if VAR_6.path in VAR_3 or VAR_2 <= 0:\n", "VAR_10 = 'no-cache'\n", "VAR_7.headers.setdefault('Cache-Control', VAR_10)\n", "return VAR_7\n" ]
[ "import logging\n", "from aiohttp import web\n", "import os\n", "logger = logging.getLogger(__package__)\n", "def setup_middlewares(app):...\n", "error_middleware = error_pages({(404): handle_404, (500): handle_500})\n", "app.middlewares.append(error_middleware)\n", "app.middlewares.append(cache_control_middleware)\n", "CACHE_MAX_AGE = int(os.getenv('CACHE_MAX_AGE', '30'))\n", "NO_CACHE_ENDPOINTS = ['/v1/', '/v1/__version__', '/v1/__heartbeat__',\n '/v1/__lbheartbeat__']\n", "async def cache_control_middleware(app, handler):...\n", "async def middleware_handler(request):...\n", "response = await handler(request)\n", "cache_control_value = 'public; max-age={}'.format(CACHE_MAX_AGE)\n", "if request.path in NO_CACHE_ENDPOINTS or CACHE_MAX_AGE <= 0:\n", "cache_control_value = 'no-cache'\n", "response.headers.setdefault('Cache-Control', cache_control_value)\n", "return response\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "ImportFrom'", "Import'", "Assign'", "FunctionDef'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "AsyncFunctionDef'", "AsyncFunctionDef'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_4(VAR_2, VAR_3, VAR_5, VAR_6=0):...\n", "\"\"\"docstring\"\"\"\n", "VAR_4 = saved_model_utils.get_meta_graph_def(VAR_2, VAR_3)\n", "VAR_24 = FUNC_2(VAR_4, VAR_5)\n", "VAR_25 = FUNC_3(VAR_4, VAR_5)\n", "VAR_26 = ' ' * VAR_6\n", "def FUNC_30(VAR_27):...\n", "print(VAR_26 + VAR_27)\n", "FUNC_30('The given SavedModel SignatureDef contains the following input(s):')\n", "for VAR_68, input_tensor in sorted(VAR_24.items()):\n", "FUNC_30(\" inputs['%s'] tensor_info:\" % VAR_68)\n", "FUNC_30('The given SavedModel SignatureDef contains the following output(s):')\n", "FUNC_7(input_tensor, VAR_6 + 1)\n", "for output_key, output_tensor in sorted(VAR_25.items()):\n", "FUNC_30(\" outputs['%s'] tensor_info:\" % output_key)\n", "FUNC_30('Method name is: %s' % VAR_4.signature_def[VAR_5].method_name)\n", "FUNC_7(output_tensor, VAR_6 + 1)\n" ]
[ "def _show_inputs_outputs(saved_model_dir, tag_set, signature_def_key, indent=0...\n", "\"\"\"docstring\"\"\"\n", "meta_graph_def = saved_model_utils.get_meta_graph_def(saved_model_dir, tag_set)\n", "inputs_tensor_info = _get_inputs_tensor_info_from_meta_graph_def(meta_graph_def\n , signature_def_key)\n", "outputs_tensor_info = _get_outputs_tensor_info_from_meta_graph_def(\n meta_graph_def, signature_def_key)\n", "indent_str = ' ' * indent\n", "def in_print(s):...\n", "print(indent_str + s)\n", "in_print('The given SavedModel SignatureDef contains the following input(s):')\n", "for input_key, input_tensor in sorted(inputs_tensor_info.items()):\n", "in_print(\" inputs['%s'] tensor_info:\" % input_key)\n", "in_print('The given SavedModel SignatureDef contains the following output(s):')\n", "_print_tensor_info(input_tensor, indent + 1)\n", "for output_key, output_tensor in sorted(outputs_tensor_info.items()):\n", "in_print(\" outputs['%s'] tensor_info:\" % output_key)\n", "in_print('Method name is: %s' % meta_graph_def.signature_def[\n signature_def_key].method_name)\n", "_print_tensor_info(output_tensor, indent + 1)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Expr'", "Expr'", "For", "Expr'", "Expr'", "Expr'", "For", "Expr'", "Expr'", "Expr'" ]
[ "@VAR_2.route('/author')...\n", "if VAR_87.check_visibility(constants.SIDEBAR_AUTHOR):\n", "if VAR_87.get_view_property('author', 'dir') == 'desc':\n", "abort(404)\n", "VAR_10 = db.Authors.sort.desc()\n", "VAR_10 = db.Authors.sort.asc()\n", "VAR_109 = 0\n", "VAR_109 = 1\n", "VAR_63 = calibre_db.session.query(db.Authors, func.count(\n 'books_authors_link.book').label('count')).join(db.books_authors_link\n ).join(db.Books).filter(calibre_db.common_filters()).group_by(text(\n 'books_authors_link.author')).order_by(VAR_10).all()\n", "VAR_107 = calibre_db.session.query(func.upper(func.substr(db.Authors.sort, \n 1, 1)).label('char')).join(db.books_authors_link).join(db.Books).filter(\n calibre_db.common_filters()).group_by(func.upper(func.substr(db.Authors\n .sort, 1, 1))).all()\n", "VAR_108 = copy.deepcopy(VAR_63)\n", "for entry in VAR_108:\n", "entry.Authors.name = entry.Authors.name.replace('|', ',')\n", "return render_title_template('list.html', VAR_63=autor_copy, folder=\n 'web.books_list', VAR_107=charlist, VAR_149=u'Authors', VAR_9=\n 'authorlist', VAR_8='author', VAR_10=order_no)\n" ]
[ "@web.route('/author')...\n", "if current_user.check_visibility(constants.SIDEBAR_AUTHOR):\n", "if current_user.get_view_property('author', 'dir') == 'desc':\n", "abort(404)\n", "order = db.Authors.sort.desc()\n", "order = db.Authors.sort.asc()\n", "order_no = 0\n", "order_no = 1\n", "entries = calibre_db.session.query(db.Authors, func.count(\n 'books_authors_link.book').label('count')).join(db.books_authors_link\n ).join(db.Books).filter(calibre_db.common_filters()).group_by(text(\n 'books_authors_link.author')).order_by(order).all()\n", "charlist = calibre_db.session.query(func.upper(func.substr(db.Authors.sort,\n 1, 1)).label('char')).join(db.books_authors_link).join(db.Books).filter(\n calibre_db.common_filters()).group_by(func.upper(func.substr(db.Authors\n .sort, 1, 1))).all()\n", "autor_copy = copy.deepcopy(entries)\n", "for entry in autor_copy:\n", "entry.Authors.name = entry.Authors.name.replace('|', ',')\n", "return render_title_template('list.html', entries=autor_copy, folder=\n 'web.books_list', charlist=charlist, title=u'Authors', page=\n 'authorlist', data='author', order=order_no)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Return'" ]
[ "@VAR_0.route(...\n", "VAR_14 = g.conn.session.query(Query).filter(Query.id == VAR_4).one()\n", "VAR_7 = VAR_14.latest_rev.latest_run_id\n", "VAR_20 = redirect(url_for('output_result', VAR_7=qrun_id, VAR_5=\n resultset_id, VAR_6=format, _external=True, _scheme='https'))\n", "VAR_20.headers.add('Access-Control-Allow-Origin', '*')\n", "return VAR_20\n" ]
[ "@app.route(...\n", "query = g.conn.session.query(Query).filter(Query.id == query_id).one()\n", "qrun_id = query.latest_rev.latest_run_id\n", "resp = redirect(url_for('output_result', qrun_id=qrun_id, resultset_id=\n resultset_id, format=format, _external=True, _scheme='https'))\n", "resp.headers.add('Access-Control-Allow-Origin', '*')\n", "return resp\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_23(VAR_16, VAR_28, VAR_19, VAR_29, VAR_30):...\n", "VAR_50 = False\n", "if VAR_28.datatype == 'rating':\n", "VAR_19[VAR_30] = str(int(float(VAR_19[VAR_30]) * 2))\n", "if VAR_19[VAR_30].strip() != VAR_29:\n", "if VAR_29 is not None:\n", "return VAR_50, VAR_19\n", "VAR_104 = getattr(VAR_16, VAR_30)[0]\n", "VAR_88 = db.cc_classes[VAR_28.id]\n", "getattr(VAR_16, VAR_30).remove(VAR_104)\n", "VAR_89 = calibre_db.session.query(VAR_88).filter(VAR_88.value == VAR_19[\n VAR_30].strip()).first()\n", "if len(VAR_104.books) == 0:\n", "if VAR_89 is None:\n", "calibre_db.session.delete(VAR_104)\n", "VAR_89 = VAR_88(value=to_save[cc_string].strip())\n", "getattr(VAR_16, VAR_30).append(VAR_89)\n", "VAR_50 = True\n", "calibre_db.session.add(VAR_89)\n", "VAR_50 = True\n", "calibre_db.session.flush()\n", "VAR_89 = calibre_db.session.query(VAR_88).filter(VAR_88.value == VAR_19[\n VAR_30].strip()).first()\n" ]
[ "def edit_cc_data_string(book, c, to_save, cc_db_value, cc_string):...\n", "changed = False\n", "if c.datatype == 'rating':\n", "to_save[cc_string] = str(int(float(to_save[cc_string]) * 2))\n", "if to_save[cc_string].strip() != cc_db_value:\n", "if cc_db_value is not None:\n", "return changed, to_save\n", "del_cc = getattr(book, cc_string)[0]\n", "cc_class = db.cc_classes[c.id]\n", "getattr(book, cc_string).remove(del_cc)\n", "new_cc = calibre_db.session.query(cc_class).filter(cc_class.value ==\n to_save[cc_string].strip()).first()\n", "if len(del_cc.books) == 0:\n", "if new_cc is None:\n", "calibre_db.session.delete(del_cc)\n", "new_cc = cc_class(value=to_save[cc_string].strip())\n", "getattr(book, cc_string).append(new_cc)\n", "changed = True\n", "calibre_db.session.add(new_cc)\n", "changed = True\n", "calibre_db.session.flush()\n", "new_cc = calibre_db.session.query(cc_class).filter(cc_class.value ==\n to_save[cc_string].strip()).first()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Return'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_1(VAR_2: Directive) ->tuple[datetime.date, int]:...\n", "\"\"\"docstring\"\"\"\n", "return VAR_2.date, SORT_ORDER.get(type(VAR_2), 0)\n" ]
[ "def incomplete_sortkey(entry: Directive) ->tuple[datetime.date, int]:...\n", "\"\"\"docstring\"\"\"\n", "return entry.date, SORT_ORDER.get(type(entry), 0)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_3(self):...\n", "super(CLASS_0, self).close()\n", "VAR_0.debug('Closing OMERO connection in %r' % self)\n", "VAR_0.error('Failed to clean up connection.', exc_info=True)\n", "if self.conn is not None and self.conn.c is not None:\n", "self.conn.close(hard=False)\n" ]
[ "def close(self):...\n", "super(ConnCleaningHttpResponse, self).close()\n", "logger.debug('Closing OMERO connection in %r' % self)\n", "logger.error('Failed to clean up connection.', exc_info=True)\n", "if self.conn is not None and self.conn.c is not None:\n", "self.conn.close(hard=False)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'", "Condition", "Expr'" ]
[ "def FUNC_7(self):...\n", "if not self.should_run():\n", "print('bower dependencies up to date')\n", "if self.should_run_npm():\n", "return\n", "print('installing build dependencies with npm')\n", "VAR_48 = os.environ.copy()\n", "FUNC_7(['npm', 'install'], VAR_22=repo_root)\n", "VAR_48['PATH'] = VAR_13\n", "os.utime(self.node_modules, None)\n", "FUNC_7(['bower', 'install', '--allow-root', '--config.interactive=false'],\n VAR_22=repo_root, VAR_48=env)\n", "print('Failed to run bower: %s' % e, file=sys.stderr)\n", "os.utime(self.bower_dir, None)\n", "print('You can install js dependencies with `npm install`', file=sys.stderr)\n", "FUNC_5(self.distribution)\n" ]
[ "def run(self):...\n", "if not self.should_run():\n", "print('bower dependencies up to date')\n", "if self.should_run_npm():\n", "return\n", "print('installing build dependencies with npm')\n", "env = os.environ.copy()\n", "run(['npm', 'install'], cwd=repo_root)\n", "env['PATH'] = npm_path\n", "os.utime(self.node_modules, None)\n", "run(['bower', 'install', '--allow-root', '--config.interactive=false'], cwd\n =repo_root, env=env)\n", "print('Failed to run bower: %s' % e, file=sys.stderr)\n", "os.utime(self.bower_dir, None)\n", "print('You can install js dependencies with `npm install`', file=sys.stderr)\n", "update_package_data(self.distribution)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Condition", "Return'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_121(*VAR_79, **VAR_42):...\n", "if VAR_13.read_from_replica:\n", "FUNC_6()\n", "VAR_225 = VAR_129(*VAR_79, **get_newargs(fn, kwargs))\n", "if VAR_1 and hasattr(VAR_1, 'primary_db'):\n", "return VAR_225\n", "VAR_1.db.close()\n", "VAR_1.db = VAR_1.primary_db\n" ]
[ "def wrapper_fn(*args, **kwargs):...\n", "if conf.read_from_replica:\n", "connect_replica()\n", "retval = fn(*args, **get_newargs(fn, kwargs))\n", "if local and hasattr(local, 'primary_db'):\n", "return retval\n", "local.db.close()\n", "local.db = local.primary_db\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Assign'", "Condition", "Return'", "Expr'", "Assign'" ]
[ "def FUNC_1(self) ->dict:...\n", "VAR_32 = self.default_config()\n", "VAR_32['worker_replication_host'] = 'testserv'\n", "VAR_32['worker_replication_http_port'] = '8765'\n", "return VAR_32\n" ]
[ "def _get_worker_hs_config(self) ->dict:...\n", "config = self.default_config()\n", "config['worker_replication_host'] = 'testserv'\n", "config['worker_replication_http_port'] = '8765'\n", "return config\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_52():...\n", "if not (MULTI_USER_MODE and is_manager()):\n", "session.flash = T('Not Authorized')\n", "db.auth_user.registration_key.writable = True\n", "redirect(URL('site'))\n", "VAR_115 = SQLFORM.grid(db.auth_user)\n", "return locals()\n" ]
[ "def manage_students():...\n", "if not (MULTI_USER_MODE and is_manager()):\n", "session.flash = T('Not Authorized')\n", "db.auth_user.registration_key.writable = True\n", "redirect(URL('site'))\n", "grid = SQLFORM.grid(db.auth_user)\n", "return locals()\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_66(VAR_124=None, VAR_47=None, VAR_120=None):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_118(VAR_120=None):...\n", "VAR_184 = {}\n", "for VAR_219 in ([VAR_120] if VAR_120 else FUNC_64(VAR_122=True)):\n", "VAR_219 = 'frappe' if VAR_219 == 'webnotes' else VAR_219\n", "return VAR_184\n", "VAR_226 = FUNC_55(VAR_219 + '.hooks')\n", "if VAR_1.flags.in_install_app:\n", "for VAR_46 in dir(VAR_226):\n", "print('Could not find app \"{0}\"'.format(VAR_120))\n", "if not VAR_46.startswith('_'):\n", "if not VAR_16:\n", "FUNC_67(VAR_184, VAR_46, getattr(VAR_226, VAR_46))\n", "sys.exit(1)\n" ]
[ "def get_hooks(hook=None, default=None, app_name=None):...\n", "\"\"\"docstring\"\"\"\n", "def load_app_hooks(app_name=None):...\n", "hooks = {}\n", "for app in ([app_name] if app_name else get_installed_apps(sort=True)):\n", "app = 'frappe' if app == 'webnotes' else app\n", "return hooks\n", "app_hooks = get_module(app + '.hooks')\n", "if local.flags.in_install_app:\n", "for key in dir(app_hooks):\n", "print('Could not find app \"{0}\"'.format(app_name))\n", "if not key.startswith('_'):\n", "if not request:\n", "append_hook(hooks, key, getattr(app_hooks, key))\n", "sys.exit(1)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Assign'", "For", "Assign'", "Return'", "Assign'", "Condition", "For", "Expr'", "Condition", "Condition", "Expr'", "Expr'" ]
[ "@log_function...\n", "\"\"\"docstring\"\"\"\n", "VAR_2 = FUNC_1('/groups/%s/categories', VAR_30)\n", "return self.client.get_json(VAR_5=destination, VAR_2=path, VAR_3={\n 'requester_user_id': requester_user_id}, VAR_15=True)\n" ]
[ "@log_function...\n", "\"\"\"docstring\"\"\"\n", "path = _create_v1_path('/groups/%s/categories', group_id)\n", "return self.client.get_json(destination=destination, path=path, args={\n 'requester_user_id': requester_user_id}, ignore_backoff=True)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_12(VAR_22):...\n", "\"\"\"docstring\"\"\"\n", "VAR_22 = VAR_22.encode('utf-8')\n", "return base64.urlsafe_b64decode(VAR_22.ljust(len(VAR_22) + len(VAR_22) % 4,\n b'='))\n" ]
[ "def urlsafe_base64_decode(s):...\n", "\"\"\"docstring\"\"\"\n", "s = s.encode('utf-8')\n", "return base64.urlsafe_b64decode(s.ljust(len(s) + len(s) % 4, b'='))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_53():...\n", "if not (MULTI_USER_MODE and is_manager()):\n", "session.flash = T('Not Authorized')\n", "VAR_26 = SQLFORM.factory(Field('emails', 'text'))\n", "redirect(URL('site'))\n", "if VAR_26.process().accepted:\n", "VAR_172 = [x.strip() for x in VAR_26.vars.emails.split('\\n') if x.strip()]\n", "return locals()\n", "VAR_173 = 0\n", "for email in VAR_172:\n", "if not db.auth_user(email=email):\n", "session.flash = T('%s students registered', VAR_173)\n", "VAR_173 += db.auth_user.insert(email=email) and 1 or 0\n", "redirect(URL('site'))\n" ]
[ "def bulk_register():...\n", "if not (MULTI_USER_MODE and is_manager()):\n", "session.flash = T('Not Authorized')\n", "form = SQLFORM.factory(Field('emails', 'text'))\n", "redirect(URL('site'))\n", "if form.process().accepted:\n", "emails = [x.strip() for x in form.vars.emails.split('\\n') if x.strip()]\n", "return locals()\n", "n = 0\n", "for email in emails:\n", "if not db.auth_user(email=email):\n", "session.flash = T('%s students registered', n)\n", "n += db.auth_user.insert(email=email) and 1 or 0\n", "redirect(URL('site'))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Return'", "Assign'", "For", "Condition", "Assign'", "AugAssign'", "Expr'" ]
[ "def FUNC_3(VAR_4, VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "VAR_2 = getattr(VAR_4, 'theme', None) or get_current_theme(VAR_4.shop)\n", "VAR_7 = FUNC_2(VAR_2, VAR_5)\n", "if not VAR_7:\n", "VAR_8 = 'Error! %s/%s: Not found.' % (getattr(VAR_2, 'identifier', None), VAR_5\n )\n", "return VAR_7(VAR_4)\n", "return HttpResponseNotFound(VAR_8)\n" ]
[ "def extra_view_dispatch(request, view):...\n", "\"\"\"docstring\"\"\"\n", "theme = getattr(request, 'theme', None) or get_current_theme(request.shop)\n", "view_func = get_view_by_name(theme, view)\n", "if not view_func:\n", "msg = 'Error! %s/%s: Not found.' % (getattr(theme, 'identifier', None), view)\n", "return view_func(request)\n", "return HttpResponseNotFound(msg)\n" ]
[ 0, 0, 0, 0, 0, 2, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Return'" ]
[ "@transaction.non_atomic_requests...\n", "\"\"\"docstring\"\"\"\n", "VAR_38 = CourseKey.from_string(VAR_10)\n", "VAR_151 = VAR_9.POST.getlist('certificate_statuses', [])\n", "if not VAR_151:\n", "return JsonResponse({'message': _(\n 'Please select one or more certificate statuses that require certificate regeneration.'\n )}, status=400)\n", "VAR_152 = [CertificateStatuses.downloadable, CertificateStatuses.error,\n CertificateStatuses.notpassing]\n", "if not set(VAR_151).issubset(VAR_152):\n", "return JsonResponse({'message': _(\n 'Please select certificate statuses from the list only.')}, status=400)\n", "instructor_task.api.regenerate_certificates(VAR_9, VAR_38, VAR_151)\n", "return JsonResponse({'message': VAR_169.message}, status=400)\n", "VAR_63 = {'message': _('string'), 'success': True}\n", "return JsonResponse(VAR_63)\n" ]
[ "@transaction.non_atomic_requests...\n", "\"\"\"docstring\"\"\"\n", "course_key = CourseKey.from_string(course_id)\n", "certificates_statuses = request.POST.getlist('certificate_statuses', [])\n", "if not certificates_statuses:\n", "return JsonResponse({'message': _(\n 'Please select one or more certificate statuses that require certificate regeneration.'\n )}, status=400)\n", "allowed_statuses = [CertificateStatuses.downloadable, CertificateStatuses.\n error, CertificateStatuses.notpassing]\n", "if not set(certificates_statuses).issubset(allowed_statuses):\n", "return JsonResponse({'message': _(\n 'Please select certificate statuses from the list only.')}, status=400)\n", "instructor_task.api.regenerate_certificates(request, course_key,\n certificates_statuses)\n", "return JsonResponse({'message': error.message}, status=400)\n", "response_payload = {'message': _(\n 'Certificate regeneration task has been started. You can view the status of the generation task in the \"Pending Tasks\" section.'\n ), 'success': True}\n", "return JsonResponse(response_payload)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Condition", "Return'", "Assign'", "Condition", "Return'", "Expr'", "Return'", "Assign'", "Return'" ]
[ "@VAR_25.whitelist(allow_guest=True)...\n", "VAR_25.local.login_manager.logout()\n", "VAR_25.db.commit()\n" ]
[ "@frappe.whitelist(allow_guest=True)...\n", "frappe.local.login_manager.logout()\n", "frappe.db.commit()\n" ]
[ 0, 0, 0 ]
[ "Condition", "Expr'", "Expr'" ]
[ "@VAR_2.route('/admin/usertable')...\n", "VAR_39 = VAR_62.view_settings.get('useredit', {})\n", "VAR_23 = calibre_db.speaking_language()\n", "VAR_24 = babel.list_translations() + [LC('en')]\n", "VAR_35 = ub.session.query(ub.User)\n", "VAR_40 = calibre_db.session.query(db.Tags).join(db.books_tags_link).join(db\n .Books).filter(calibre_db.common_filters()).group_by(VAR_130(\n 'books_tags_link.tag')).order_by(db.Tags.name).all()\n", "if config.config_restricted_column:\n", "VAR_99 = calibre_db.session.query(db.cc_classes[config.\n config_restricted_column]).all()\n", "VAR_99 = []\n", "if not config.config_anonbrowse:\n", "VAR_35 = VAR_35.filter(ub.User.role.op('&')(constants.ROLE_ANONYMOUS) !=\n constants.ROLE_ANONYMOUS)\n", "VAR_25 = VAR_1['kobo'] and config.config_kobo_sync\n", "return render_title_template('user_table.html', VAR_54=allUser.all(),\n VAR_40=tags, VAR_99=custom_values, VAR_24=translations, VAR_23=\n languages, visiblility=visibility, all_roles=constants.ALL_ROLES,\n VAR_25=kobo_support, sidebar_settings=constants.sidebar_settings, title\n =_(u'Edit Users'), page='usertable')\n" ]
[ "@admi.route('/admin/usertable')...\n", "visibility = current_user.view_settings.get('useredit', {})\n", "languages = calibre_db.speaking_language()\n", "translations = babel.list_translations() + [LC('en')]\n", "allUser = ub.session.query(ub.User)\n", "tags = calibre_db.session.query(db.Tags).join(db.books_tags_link).join(db.Books\n ).filter(calibre_db.common_filters()).group_by(text('books_tags_link.tag')\n ).order_by(db.Tags.name).all()\n", "if config.config_restricted_column:\n", "custom_values = calibre_db.session.query(db.cc_classes[config.\n config_restricted_column]).all()\n", "custom_values = []\n", "if not config.config_anonbrowse:\n", "allUser = allUser.filter(ub.User.role.op('&')(constants.ROLE_ANONYMOUS) !=\n constants.ROLE_ANONYMOUS)\n", "kobo_support = feature_support['kobo'] and config.config_kobo_sync\n", "return render_title_template('user_table.html', users=allUser.all(), tags=\n tags, custom_values=custom_values, translations=translations, languages\n =languages, visiblility=visibility, all_roles=constants.ALL_ROLES,\n kobo_support=kobo_support, sidebar_settings=constants.sidebar_settings,\n title=_(u'Edit Users'), page='usertable')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_0(VAR_3, VAR_4=None, VAR_5=None):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.translate import get_full_dict\n", "from frappe.utils import strip_html_tags, is_html\n", "if not hasattr(VAR_1, 'lang'):\n", "VAR_1.lang = VAR_4 or 'en'\n", "if not VAR_4:\n", "VAR_4 = VAR_1.lang\n", "VAR_175 = VAR_3\n", "if is_html(VAR_3):\n", "VAR_3 = strip_html_tags(VAR_3)\n", "VAR_3 = FUNC_1(VAR_3).strip()\n", "VAR_176 = ''\n", "if VAR_5:\n", "VAR_206 = '{msg}:{context}'.format(VAR_3=msg, VAR_5=context)\n", "if not VAR_176:\n", "VAR_176 = get_full_dict(VAR_4).get(VAR_206)\n", "VAR_176 = get_full_dict(VAR_4).get(VAR_3)\n", "return VAR_176 or VAR_175\n" ]
[ "def _(msg, lang=None, context=None):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.translate import get_full_dict\n", "from frappe.utils import strip_html_tags, is_html\n", "if not hasattr(local, 'lang'):\n", "local.lang = lang or 'en'\n", "if not lang:\n", "lang = local.lang\n", "non_translated_string = msg\n", "if is_html(msg):\n", "msg = strip_html_tags(msg)\n", "msg = as_unicode(msg).strip()\n", "translated_string = ''\n", "if context:\n", "string_key = '{msg}:{context}'.format(msg=msg, context=context)\n", "if not translated_string:\n", "translated_string = get_full_dict(lang).get(string_key)\n", "translated_string = get_full_dict(lang).get(msg)\n", "return translated_string or non_translated_string\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "ImportFrom'", "ImportFrom'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Return'" ]
[ "@pytest.mark.parametrize('inp,out', [('&quot;&gt;alert(1)', '\">alert(1)'),...\n", "assert escaping.unescape_attributes(VAR_1) == VAR_2\n" ]
[ "@pytest.mark.parametrize('inp,out', [('&quot;&gt;alert(1)', '\">alert(1)'),...\n", "assert escaping.unescape_attributes(inp) == out\n" ]
[ 0, 0 ]
[ "Condition", "Assert'" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "return VAR_14.get(VAR_1)\n" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "return _existing_enums.get(name)\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def FUNC_3(VAR_4: datetime.date) ->str:...\n", "\"\"\"docstring\"\"\"\n", "if g.interval is Interval.YEAR:\n", "return VAR_4.strftime('%Y')\n", "if g.interval is Interval.QUARTER:\n", "return f'{VAR_4.year}Q{(VAR_4.month - 1) // 3 + 1}'\n", "if g.interval is Interval.WEEK:\n", "return VAR_4.strftime('%YW%W')\n", "if g.interval is Interval.DAY:\n", "return VAR_4.strftime('%Y-%m-%d')\n", "assert g.interval is Interval.MONTH\n", "return VAR_4.strftime('%b %Y')\n" ]
[ "def format_date(date: datetime.date) ->str:...\n", "\"\"\"docstring\"\"\"\n", "if g.interval is Interval.YEAR:\n", "return date.strftime('%Y')\n", "if g.interval is Interval.QUARTER:\n", "return f'{date.year}Q{(date.month - 1) // 3 + 1}'\n", "if g.interval is Interval.WEEK:\n", "return date.strftime('%YW%W')\n", "if g.interval is Interval.DAY:\n", "return date.strftime('%Y-%m-%d')\n", "assert g.interval is Interval.MONTH\n", "return date.strftime('%b %Y')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Assert'", "Return'" ]
[ "def FUNC_59(VAR_5, VAR_52):...\n", "VAR_5 = os.path.join(apath(VAR_3, VAR_122=request), VAR_5)\n", "if VAR_52 in read_file(VAR_5, 'r'):\n", "return True\n", "return False\n" ]
[ "def match(filename, keywords):...\n", "filename = os.path.join(apath(app, r=request), filename)\n", "if keywords in read_file(filename, 'r'):\n", "return True\n", "return False\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'", "Return'" ]
[ "@VAR_0.route('/api/jobs/<int:job_id>/copy', methods=['PUT'])...\n", "\"\"\"docstring\"\"\"\n", "VAR_98 = FUNC_58(f'/internal/jobs/{VAR_9}/copy', 'put')\n", "return jsonify({'success': False, 'message': str(err)}), 400\n", "return jsonify(VAR_98)\n" ]
[ "@gui.route('/api/jobs/<int:job_id>/copy', methods=['PUT'])...\n", "\"\"\"docstring\"\"\"\n", "response_info = query_internal_api(f'/internal/jobs/{job_id}/copy', 'put')\n", "return jsonify({'success': False, 'message': str(err)}), 400\n", "return jsonify(response_info)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Return'", "Return'" ]
[ "@VAR_0.route('/storage', defaults={'path': ''}, methods=['GET', 'POST'])...\n", "\"\"\"docstring\"\"\"\n", "VAR_66 = VAR_0.config['STORAGE_FOLDER']\n", "VAR_58 = os.path.join(VAR_66, VAR_10)\n", "if request.method == 'POST':\n", "if 'storagefile' in request.files:\n", "VAR_59 = os.path.dirname(VAR_58).replace(VAR_66, '')\n", "VAR_125 = request.files['storagefile']\n", "flash('No file, retry!', 'warning')\n", "if not os.path.exists(VAR_58):\n", "if VAR_125.filename == '':\n", "return redirect(request.url)\n", "flash('Directory does not exist.', 'warning')\n", "if os.path.isfile(VAR_58):\n", "flash('No file selected', 'warning')\n", "if VAR_125:\n", "return redirect(url_for('dashboard'))\n", "return send_file(VAR_58)\n", "VAR_60 = []\n", "return redirect(request.url)\n", "if not os.path.isdir(VAR_58):\n", "VAR_61 = os.listdir(VAR_58)\n", "flash('Error while uploading the file', 'danger')\n", "VAR_20 = secure_filename(VAR_125.filename)\n", "for file in VAR_61:\n", "return redirect(request.url)\n", "VAR_130 = os.path.join(VAR_58, VAR_20)\n", "VAR_60.append({'file': file, 'directory': os.path.isdir(os.path.join(VAR_58,\n file))})\n", "return render_template('storage.html', title='Storage', VAR_58=abs_path,\n VAR_60=files_info, VAR_59=back_path)\n", "VAR_125.save(VAR_130)\n", "flash('Successfully uploaded the file.', 'success')\n", "return redirect(request.url)\n" ]
[ "@gui.route('/storage', defaults={'path': ''}, methods=['GET', 'POST'])...\n", "\"\"\"docstring\"\"\"\n", "storage_folder = gui.config['STORAGE_FOLDER']\n", "abs_path = os.path.join(storage_folder, path)\n", "if request.method == 'POST':\n", "if 'storagefile' in request.files:\n", "back_path = os.path.dirname(abs_path).replace(storage_folder, '')\n", "storagefile = request.files['storagefile']\n", "flash('No file, retry!', 'warning')\n", "if not os.path.exists(abs_path):\n", "if storagefile.filename == '':\n", "return redirect(request.url)\n", "flash('Directory does not exist.', 'warning')\n", "if os.path.isfile(abs_path):\n", "flash('No file selected', 'warning')\n", "if storagefile:\n", "return redirect(url_for('dashboard'))\n", "return send_file(abs_path)\n", "files_info = []\n", "return redirect(request.url)\n", "if not os.path.isdir(abs_path):\n", "files = os.listdir(abs_path)\n", "flash('Error while uploading the file', 'danger')\n", "filename = secure_filename(storagefile.filename)\n", "for file in files:\n", "return redirect(request.url)\n", "save_path = os.path.join(abs_path, filename)\n", "files_info.append({'file': file, 'directory': os.path.isdir(os.path.join(\n abs_path, file))})\n", "return render_template('storage.html', title='Storage', abs_path=abs_path,\n files_info=files_info, back_path=back_path)\n", "storagefile.save(save_path)\n", "flash('Successfully uploaded the file.', 'success')\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 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Expr'", "Condition", "Condition", "Return'", "Expr'", "Condition", "Expr'", "Condition", "Return'", "Return'", "Assign'", "Return'", "Condition", "Assign'", "Expr'", "Assign'", "For", "Return'", "Assign'", "Expr'", "Return'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_28(self, VAR_2, VAR_3):...\n", "VAR_3.setattr('flask.request.host_url', 'http://example.com')\n", "VAR_9 = _validate_redirect_url('http://works.com', _external_host='works.com')\n", "assert VAR_9 is True\n", "VAR_3.undo()\n" ]
[ "def test_it_works_with_explicit_external_host(self, app, monkeypatch):...\n", "monkeypatch.setattr('flask.request.host_url', 'http://example.com')\n", "result = _validate_redirect_url('http://works.com', _external_host='works.com')\n", "assert result is True\n", "monkeypatch.undo()\n" ]
[ 0, 0, 4, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assert'", "Expr'" ]
[ "def FUNC_11(self) ->None:...\n", "VAR_24 = self.package_dir / 'client.py'\n", "VAR_25 = self.env.get_template('client.pyi')\n", "VAR_24.write_text(VAR_25.render())\n", "VAR_26 = self.package_dir / 'api'\n", "VAR_26.mkdir()\n", "VAR_27 = VAR_26 / '__init__.py'\n", "VAR_27.write_text('\"\"\" Contains synchronous methods for accessing the API \"\"\"')\n", "VAR_28 = self.package_dir / 'async_api'\n", "VAR_28.mkdir()\n", "VAR_29 = VAR_28 / '__init__.py'\n", "VAR_29.write_text('\"\"\" Contains async methods for accessing the API \"\"\"')\n", "VAR_30 = self.package_dir / 'errors.py'\n", "VAR_31 = self.env.get_template('errors.pyi')\n", "VAR_30.write_text(VAR_31.render())\n", "VAR_32 = self.env.get_template('endpoint_module.pyi')\n", "VAR_33 = self.env.get_template('async_endpoint_module.pyi')\n", "for tag, collection in self.openapi.endpoint_collections_by_tag.items():\n", "VAR_36 = VAR_26 / f'{tag}.py'\n", "VAR_36.write_text(VAR_32.render(collection=collection))\n", "VAR_37 = VAR_28 / f'{tag}.py'\n", "VAR_37.write_text(VAR_33.render(collection=collection))\n" ]
[ "def _build_api(self) ->None:...\n", "client_path = self.package_dir / 'client.py'\n", "client_template = self.env.get_template('client.pyi')\n", "client_path.write_text(client_template.render())\n", "api_dir = self.package_dir / 'api'\n", "api_dir.mkdir()\n", "api_init = api_dir / '__init__.py'\n", "api_init.write_text(\n '\"\"\" Contains synchronous methods for accessing the API \"\"\"')\n", "async_api_dir = self.package_dir / 'async_api'\n", "async_api_dir.mkdir()\n", "async_api_init = async_api_dir / '__init__.py'\n", "async_api_init.write_text(\n '\"\"\" Contains async methods for accessing the API \"\"\"')\n", "api_errors = self.package_dir / 'errors.py'\n", "errors_template = self.env.get_template('errors.pyi')\n", "api_errors.write_text(errors_template.render())\n", "endpoint_template = self.env.get_template('endpoint_module.pyi')\n", "async_endpoint_template = self.env.get_template('async_endpoint_module.pyi')\n", "for tag, collection in self.openapi.endpoint_collections_by_tag.items():\n", "module_path = api_dir / f'{tag}.py'\n", "module_path.write_text(endpoint_template.render(collection=collection))\n", "async_module_path = async_api_dir / f'{tag}.py'\n", "async_module_path.write_text(async_endpoint_template.render(collection=\n collection))\n" ]
[ 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'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "For", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_0(self, VAR_0, VAR_1):...\n", "self._dict[VAR_0] = VAR_1\n" ]
[ "def set(self, name, value):...\n", "self._dict[name] = value\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "def FUNC_1(self, VAR_8, VAR_9):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_8 == 0:\n", "return '0'\n", "if VAR_8 < 0:\n", "VAR_35 = True\n", "VAR_35 = False\n", "VAR_8 = -VAR_8\n", "VAR_27 = []\n", "while VAR_8 != 0:\n", "VAR_32 = VAR_8 % VAR_9\n", "VAR_27.reverse()\n", "if VAR_32 >= 10:\n", "return '-' * VAR_35 + ''.join(VAR_27)\n", "VAR_32 = string.ascii_uppercase[VAR_32 - 10]\n", "VAR_32 = str(VAR_32)\n", "VAR_27.append(VAR_32)\n", "VAR_8 = VAR_8 // VAR_9\n" ]
[ "def _convertDecimalToBase(self, number, base):...\n", "\"\"\"docstring\"\"\"\n", "if number == 0:\n", "return '0'\n", "if number < 0:\n", "negative = True\n", "negative = False\n", "number = -number\n", "digits = []\n", "while number != 0:\n", "digit = number % base\n", "digits.reverse()\n", "if digit >= 10:\n", "return '-' * negative + ''.join(digits)\n", "digit = string.ascii_uppercase[digit - 10]\n", "digit = str(digit)\n", "digits.append(digit)\n", "number = number // base\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Condition", "Return'", "Assign'", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_4(self):...\n", "VAR_10 = self.cleaned_data\n", "if settings.OFFER_HOSTING:\n", "VAR_10['contribute_shared_tm'] = VAR_10['use_shared_tm']\n", "if 'access_control' not in VAR_10 or VAR_10['access_control'\n", "VAR_10['access_control'] = self.instance.access_control\n", "VAR_127 = VAR_10['access_control']\n", "self.changed_access = VAR_127 != self.instance.access_control\n", "if self.changed_access and not self.user_can_change_access:\n", "if self.changed_access and VAR_127 in (Project.ACCESS_PUBLIC, Project.\n", "VAR_142 = self.instance.component_set.filter(license='')\n", "if VAR_142:\n" ]
[ "def clean(self):...\n", "data = self.cleaned_data\n", "if settings.OFFER_HOSTING:\n", "data['contribute_shared_tm'] = data['use_shared_tm']\n", "if 'access_control' not in data or data['access_control'] is None or data[\n", "data['access_control'] = self.instance.access_control\n", "access = data['access_control']\n", "self.changed_access = access != self.instance.access_control\n", "if self.changed_access and not self.user_can_change_access:\n", "if self.changed_access and access in (Project.ACCESS_PUBLIC, Project.\n", "unlicensed = self.instance.component_set.filter(license='')\n", "if unlicensed:\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Condition" ]
[ "def FUNC_2(VAR_2: Any) ->Optional[str]:...\n", "return urlparse(VAR_2).hostname\n" ]
[ "def parse_domain(url: Any) ->Optional[str]:...\n", "return urlparse(url).hostname\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_69(VAR_15):...\n", "VAR_54 = {}\n", "VAR_222 = []\n", "VAR_223 = []\n", "for VAR_212, ch in enumerate(VAR_15.getChannels()):\n", "VAR_287 = '' if ch.isActive() else '-'\n", "VAR_54['c'] = ','.join(VAR_222)\n", "VAR_288 = ch.getWindowStart()\n", "VAR_54['maps'] = VAR_223\n", "VAR_289 = ch.getWindowEnd()\n", "VAR_54['m'] = 'g' if VAR_15.isGreyscaleRenderingModel() else 'c'\n", "VAR_68 = ch.getLut()\n", "VAR_54['z'] = VAR_15.getDefaultZ() + 1\n", "VAR_223.append({'inverted': {'enabled': ch.isInverted()}})\n", "VAR_54['t'] = VAR_15.getDefaultT() + 1\n", "if not VAR_68 or len(VAR_68) == 0:\n", "return VAR_54\n", "VAR_68 = ch.getColor().getHtml()\n", "VAR_222.append('%s%s|%s:%s$%s' % (VAR_287, VAR_212 + 1, VAR_288, VAR_289,\n VAR_68))\n" ]
[ "def getRenderingSettings(image):...\n", "rv = {}\n", "chs = []\n", "maps = []\n", "for i, ch in enumerate(image.getChannels()):\n", "act = '' if ch.isActive() else '-'\n", "rv['c'] = ','.join(chs)\n", "start = ch.getWindowStart()\n", "rv['maps'] = maps\n", "end = ch.getWindowEnd()\n", "rv['m'] = 'g' if image.isGreyscaleRenderingModel() else 'c'\n", "color = ch.getLut()\n", "rv['z'] = image.getDefaultZ() + 1\n", "maps.append({'inverted': {'enabled': ch.isInverted()}})\n", "rv['t'] = image.getDefaultT() + 1\n", "if not color or len(color) == 0:\n", "return rv\n", "color = ch.getColor().getHtml()\n", "chs.append('%s%s|%s:%s$%s' % (act, i + 1, start, end, color))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Return'", "Assign'", "Expr'" ]
[ "def FUNC_0(VAR_4, VAR_5, VAR_6='test'):...\n", "return {'origin': VAR_6, 'origin_server_ts': 1000000, 'pdus': [], 'edus': [\n {'edu_type': VAR_4, 'content': VAR_5}]}\n" ]
[ "def _expect_edu_transaction(edu_type, content, origin='test'):...\n", "return {'origin': origin, 'origin_server_ts': 1000000, 'pdus': [], 'edus':\n [{'edu_type': edu_type, 'content': content}]}\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_167(VAR_17):...\n", "\"\"\"docstring\"\"\"\n", "VAR_395 = set(VAR_17.keys())\n", "VAR_396 = set(['jsonrpc', 'method'])\n", "VAR_397 = VAR_396 - VAR_395\n", "if VAR_397:\n", "if VAR_17['jsonrpc'] != '2.0':\n", "if 'id' not in VAR_395:\n", "return False\n", "return True\n" ]
[ "def validate(data):...\n", "\"\"\"docstring\"\"\"\n", "iparms = set(data.keys())\n", "mandatory_args = set(['jsonrpc', 'method'])\n", "missing_args = mandatory_args - iparms\n", "if missing_args:\n", "if data['jsonrpc'] != '2.0':\n", "if 'id' not in iparms:\n", "return False\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Return'", "Return'" ]
[ "def FUNC_1(VAR_4, VAR_5, VAR_6):...\n", "if not VAR_4:\n", "return None\n", "VAR_18 = hmac.new(VAR_4.encode(), msg=path.encode(), digestmod=hashlib.sha1)\n", "VAR_18.update(str(VAR_6).encode())\n", "return VAR_18.hexdigest()\n" ]
[ "def sign(key, path, expires):...\n", "if not key:\n", "return None\n", "h = hmac.new(key.encode(), msg=path.encode(), digestmod=hashlib.sha1)\n", "h.update(str(expires).encode())\n", "return h.hexdigest()\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_3(self):...\n", "" ]
[ "def close(self):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_4(self):...\n", "" ]
[ "def isAuthorized(self):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_44(VAR_62, VAR_9, VAR_97, VAR_103=False):...\n", "VAR_94 = FUNC_41(VAR_62, VAR_9)\n", "if isinstance(VAR_97, string_types):\n", "if VAR_103:\n", "VAR_188 = [VAR_94.get(f) for f in VAR_97]\n", "VAR_96('Cannot make dict for single fieldname')\n", "return VAR_94.get(VAR_97)\n", "if VAR_103:\n", "return CLASS_0(zip(VAR_97, VAR_188))\n", "return VAR_188\n" ]
[ "def get_cached_value(doctype, name, fieldname, as_dict=False):...\n", "doc = get_cached_doc(doctype, name)\n", "if isinstance(fieldname, string_types):\n", "if as_dict:\n", "values = [doc.get(f) for f in fieldname]\n", "throw('Cannot make dict for single fieldname')\n", "return doc.get(fieldname)\n", "if as_dict:\n", "return _dict(zip(fieldname, values))\n", "return values\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Condition", "Assign'", "Expr'", "Return'", "Condition", "Return'", "Return'" ]
[ "def FUNC_3(self):...\n", "if self._client_transport:\n", "self.client.close()\n", "if self._server_transport:\n", "self.server.close()\n", "self._client_transport = FakeTransport(self.server, self.reactor)\n", "self.client.makeConnection(self._client_transport)\n", "self._server_transport = FakeTransport(self.client, self.reactor)\n", "self.server.makeConnection(self._server_transport)\n" ]
[ "def reconnect(self):...\n", "if self._client_transport:\n", "self.client.close()\n", "if self._server_transport:\n", "self.server.close()\n", "self._client_transport = FakeTransport(self.server, self.reactor)\n", "self.client.makeConnection(self._client_transport)\n", "self._server_transport = FakeTransport(self.client, self.reactor)\n", "self.server.makeConnection(self._server_transport)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Condition", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_4(self):...\n", "if self.cleaned_data.get('confirm') != self.obj.full_slug:\n" ]
[ "def clean(self):...\n", "if self.cleaned_data.get('confirm') != self.obj.full_slug:\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "@FUNC_0...\n", "return SetPasswordHandler(self)\n" ]
[ "@cache_in_self...\n", "return SetPasswordHandler(self)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def __init__(self, *VAR_11: Any, **VAR_12: Any) ->None:...\n", "" ]
[ "def __init__(self, *_: Any, **__: Any) ->None:...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "from django.contrib.auth.decorators import login_required\n", "from django.http import HttpResponse, JsonResponse\n", "from django.views.decorators.http import require_POST\n", "from weblate.lang.models import Language\n", "from weblate.trans.forms import ReportsForm\n", "from weblate.trans.models.change import Change\n", "from weblate.trans.util import redirect_param\n", "from weblate.utils.views import get_component, get_project, show_form_errors\n", "VAR_0 = ' '.join(['=' * 40] * 2 + ['=' * 24] * 20)\n", "VAR_1 = \"\"\"<table>\n<tr>{0}</tr>\"\"\"\n", "def FUNC_0(VAR_2, VAR_3, VAR_4, **VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "VAR_10 = []\n", "VAR_11 = Change.objects.content()\n", "if VAR_2:\n", "VAR_11 = VAR_11.filter(author=user)\n", "for language in Language.objects.filter(**kwargs).distinct().iterator():\n", "VAR_17 = VAR_11.filter(language=language, **kwargs).authors_list((VAR_3, VAR_4)\n )\n", "return VAR_10\n", "if not VAR_17:\n", "VAR_10.append({language.name: sorted(VAR_17, key=lambda item: item[2])})\n" ]
[ "from django.contrib.auth.decorators import login_required\n", "from django.http import HttpResponse, JsonResponse\n", "from django.views.decorators.http import require_POST\n", "from weblate.lang.models import Language\n", "from weblate.trans.forms import ReportsForm\n", "from weblate.trans.models.change import Change\n", "from weblate.trans.util import redirect_param\n", "from weblate.utils.views import get_component, get_project, show_form_errors\n", "RST_HEADING = ' '.join(['=' * 40] * 2 + ['=' * 24] * 20)\n", "HTML_HEADING = \"\"\"<table>\n<tr>{0}</tr>\"\"\"\n", "def generate_credits(user, start_date, end_date, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "result = []\n", "base = Change.objects.content()\n", "if user:\n", "base = base.filter(author=user)\n", "for language in Language.objects.filter(**kwargs).distinct().iterator():\n", "authors = base.filter(language=language, **kwargs).authors_list((start_date,\n end_date))\n", "return result\n", "if not authors:\n", "result.append({language.name: sorted(authors, key=lambda item: item[2])})\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Condition", "Assign'", "For", "Assign'", "Return'", "Condition", "Expr'" ]
[ "@FUNC_0...\n", "return ThirdPartyEventRules(self)\n" ]
[ "@cache_in_self...\n", "return ThirdPartyEventRules(self)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_5(self):...\n", "VAR_50 = VAR_53.request.remote.ip in ('127.0.0.1', '::1')\n", "if VAR_50 and cherry.config['server.localhost_auto_login']:\n", "return True\n", "return False\n" ]
[ "def autoLoginActive(self):...\n", "is_loopback = cherrypy.request.remote.ip in ('127.0.0.1', '::1')\n", "if is_loopback and cherry.config['server.localhost_auto_login']:\n", "return True\n", "return False\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_46(VAR_62, VAR_106=None, VAR_107='creation desc'):...\n", "\"\"\"docstring\"\"\"\n", "VAR_174 = FUNC_83(VAR_62, VAR_106=filters, limit_page_length=1, VAR_107=\n order_by, pluck='name')\n", "if VAR_174:\n", "return FUNC_45(VAR_62, VAR_174[0])\n" ]
[ "def get_last_doc(doctype, filters=None, order_by='creation desc'):...\n", "\"\"\"docstring\"\"\"\n", "d = get_all(doctype, filters=filters, limit_page_length=1, order_by=\n order_by, pluck='name')\n", "if d:\n", "return get_doc(doctype, d[0])\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Return'" ]
[ "def FUNC_8(self):...\n", "self.register_user('nonadmin', 'pass', admin=False)\n", "VAR_22 = self.login('nonadmin', 'pass')\n", "VAR_0 = '/_synapse/admin/v1/media/quarantine/example.org/abcde12345'\n", "VAR_12, VAR_13 = self.make_request('POST', VAR_0.encode('ascii'), VAR_7=\n non_admin_user_tok)\n", "self.assertEqual(403, int(VAR_13.result['code']), msg=\n 'Expected forbidden on quarantining media as a non-admin')\n", "VAR_0 = '/_synapse/admin/v1/room/!room%3Aexample.com/media/quarantine'\n", "VAR_12, VAR_13 = self.make_request('POST', VAR_0.encode('ascii'), VAR_7=\n non_admin_user_tok)\n", "self.assertEqual(403, int(VAR_13.result['code']), msg=\n 'Expected forbidden on quarantining media as a non-admin')\n" ]
[ "def test_quarantine_media_requires_admin(self):...\n", "self.register_user('nonadmin', 'pass', admin=False)\n", "non_admin_user_tok = self.login('nonadmin', 'pass')\n", "url = '/_synapse/admin/v1/media/quarantine/example.org/abcde12345'\n", "request, channel = self.make_request('POST', url.encode('ascii'),\n access_token=non_admin_user_tok)\n", "self.assertEqual(403, int(channel.result['code']), msg=\n 'Expected forbidden on quarantining media as a non-admin')\n", "url = '/_synapse/admin/v1/room/!room%3Aexample.com/media/quarantine'\n", "request, channel = self.make_request('POST', url.encode('ascii'),\n access_token=non_admin_user_tok)\n", "self.assertEqual(403, int(channel.result['code']), msg=\n 'Expected forbidden on quarantining media as a non-admin')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "@VAR_1.route('/nr', methods=['POST'])...\n", "VAR_6 = request.form['vId']\n", "VAR_10 = request.form['ip']\n", "VAR_11 = request.form['red']\n", "if VAR_6 == '':\n", "VAR_6 = utils.generateToken(5)\n", "utils.Go(utils.Color['white'] + '[' + utils.Color['greenBold'] + '+' +\n utils.Color['white'] + ']' + utils.Color['whiteBold'] + ' ' + VAR_11 +\n utils.Color['white'] + ' session detected from ' + utils.Color['blue'] +\n VAR_10 + utils.Color['white'] + ' ' + 'with ID: ' + utils.Color['green'\n ] + VAR_6 + utils.Color['white'])\n", "VAR_9 = int(VAR_2.sentences_victim('count_victim_network', [VAR_6, VAR_11],\n 3, 0))\n", "if VAR_9 > 0:\n", "VAR_2.sentences_victim('update_network', [VAR_6, VAR_11, time.strftime(\n '%Y-%m-%d - %H:%M:%S')], 2)\n", "VAR_2.sentences_victim('insert_networks', [VAR_6, VAR_10, request.environ[\n 'REMOTE_ADDR'], VAR_11, time.strftime('%Y-%m-%d - %H:%M:%S')], 2)\n", "return json.dumps({'status': 'OK', 'vId': VAR_6})\n" ]
[ "@app.route('/nr', methods=['POST'])...\n", "vId = request.form['vId']\n", "vIp = request.form['ip']\n", "vnetwork = request.form['red']\n", "if vId == '':\n", "vId = utils.generateToken(5)\n", "utils.Go(utils.Color['white'] + '[' + utils.Color['greenBold'] + '+' +\n utils.Color['white'] + ']' + utils.Color['whiteBold'] + ' ' + vnetwork +\n utils.Color['white'] + ' session detected from ' + utils.Color['blue'] +\n vIp + utils.Color['white'] + ' ' + 'with ID: ' + utils.Color['green'] +\n vId + utils.Color['white'])\n", "cant = int(db.sentences_victim('count_victim_network', [vId, vnetwork], 3, 0))\n", "if cant > 0:\n", "db.sentences_victim('update_network', [vId, vnetwork, time.strftime(\n '%Y-%m-%d - %H:%M:%S')], 2)\n", "db.sentences_victim('insert_networks', [vId, vIp, request.environ[\n 'REMOTE_ADDR'], vnetwork, time.strftime('%Y-%m-%d - %H:%M:%S')], 2)\n", "return json.dumps({'status': 'OK', 'vId': vId})\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Return'" ]
[ "@VAR_0.route('/api/jobs/statistics', methods=['GET'])...\n", "\"\"\"docstring\"\"\"\n", "VAR_115 = FUNC_58('/internal/jobs/statistics', 'get')\n", "return jsonify({'success': False, 'message': str(err)}), 400\n", "return jsonify(VAR_115)\n" ]
[ "@gui.route('/api/jobs/statistics', methods=['GET'])...\n", "\"\"\"docstring\"\"\"\n", "statistics = query_internal_api('/internal/jobs/statistics', 'get')\n", "return jsonify({'success': False, 'message': str(err)}), 400\n", "return jsonify(statistics)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Return'", "Return'" ]
[ "def FUNC_16(self, VAR_4, VAR_39, VAR_40):...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_40:\n", "self.mathjax_url = u''\n" ]
[ "def _enable_mathjax_changed(self, name, old, new):...\n", "\"\"\"docstring\"\"\"\n", "if not new:\n", "self.mathjax_url = u''\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'" ]
[ "def __init__(self, VAR_9, VAR_10=None):...\n", "self._name = VAR_9\n", "self._backend = VAR_10\n", "self._function = None\n" ]
[ "def __init__(self, name, backend=None):...\n", "self._name = name\n", "self._backend = backend\n", "self._function = None\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_0(self):...\n", "self.reactor = ThreadedMemoryReactorClock()\n", "VAR_16 = True\n", "def FUNC_19(self, VAR_3):...\n", "return VAR_3.path\n" ]
[ "def setUp(self):...\n", "self.reactor = ThreadedMemoryReactorClock()\n", "isLeaf = True\n", "def render(self, request):...\n", "return request.path\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "FunctionDef'", "Return'" ]
[ "def FUNC_0():...\n", "VAR_10 = VAR_0.get('/openapi.json')\n", "assert VAR_10.status_code == 200, VAR_10.text\n", "assert VAR_10.json() == VAR_1\n" ]
[ "def test_openapi_schema():...\n", "response = client.get('/openapi.json')\n", "assert response.status_code == 200, response.text\n", "assert response.json() == openapi_schema\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assert'", "Assert'" ]
[ "def FUNC_36(self):...\n", "\"\"\"docstring\"\"\"\n", "for VAR_21 in self.get_all_children():\n", "VAR_21.parent = self.name\n", "VAR_21.parenttype = self.doctype\n" ]
[ "def set_parent_in_children(self):...\n", "\"\"\"docstring\"\"\"\n", "for d in self.get_all_children():\n", "d.parent = self.name\n", "d.parenttype = self.doctype\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "For", "Assign'", "Assign'" ]
[ "def FUNC_67(self, VAR_41: str) ->bool:...\n", "return check_password_hash(self.password_hash, VAR_41)\n" ]
[ "def verify_password(self, password: str) ->bool:...\n", "return check_password_hash(self.password_hash, password)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_37():...\n", "\"\"\"docstring\"\"\"\n", "if request.vars and not request.vars.token == session.token:\n", "redirect(URL('logout'))\n", "VAR_157 = '#' + request.vars.id if request.vars.id else ''\n", "if not isinstance(VAR_114, HTTP):\n", "if request.vars.dir:\n", "if request.vars.app:\n", "session.flash = T('cannot create file')\n", "VAR_43.flash = VAR_110\n", "redirect(request.vars.sender + VAR_157)\n", "VAR_3 = FUNC_5(request.vars.app)\n", "if request.vars.dir:\n", "VAR_43.headers['web2py-component-content'] = 'append'\n", "VAR_15 = abspath(request.vars.location)\n", "request.vars.location += request.vars.dir + '/'\n", "VAR_3 = FUNC_5(VAR_10=request.vars.location.split('/')[0])\n", "VAR_43.headers['web2py-component-command'] = '%s %s %s' % (\n \"$.web2py.invalidate('#files_menu');\", \"load_file('%s');\" % URL('edit',\n VAR_98=[app, request.vars.dir, filename]),\n \"$.web2py.enableElement($('#form form').find($.web2py.formInputClickSelector));\"\n )\n", "VAR_5 = re.sub('[^\\\\w./-]+', '_', request.vars.filename)\n", "VAR_15 = apath(request.vars.location, VAR_122=request)\n", "return ''\n", "if VAR_15[-7:] == '/rules/':\n", "if len(VAR_5) == 0:\n", "if VAR_15[-11:] == '/languages/':\n", "if not VAR_5[-3:] == '.py':\n", "if len(VAR_5) == 0:\n", "if VAR_15[-8:] == '/models/':\n", "VAR_5 += '.py'\n", "VAR_188 = re.match('^plural_rules-(.*)\\\\.py$', VAR_5).group(1)\n", "if not VAR_5[-3:] == '.py':\n", "if not VAR_5[-3:] == '.py':\n", "if VAR_15[-13:] == '/controllers/':\n", "VAR_189 = read_possible_languages(apath(VAR_3, VAR_122=request))[VAR_188]\n", "VAR_5 += '.py'\n", "VAR_15 = os.path.join(apath(VAR_3, VAR_122=request), 'languages', VAR_5)\n", "VAR_5 += '.py'\n", "if len(VAR_5) == 3:\n", "if not VAR_5[-3:] == '.py':\n", "if VAR_15[-7:] == '/views/':\n", "VAR_112 = dedent('string')[1:] % dict(VAR_188=langinfo[0], langname=langinfo[1]\n )\n", "if not os.path.exists(VAR_15):\n", "VAR_112 = '# -*- coding: utf-8 -*-\\n'\n", "VAR_5 += '.py'\n", "if len(VAR_5) == 3:\n", "if request.vars.plugin and not VAR_5.startswith('plugin_%s/' % request.vars\n", "if VAR_15[-9:] == '/modules/':\n", "VAR_158 = os.path.join(VAR_15, VAR_5)\n", "FUNC_4(VAR_15, '')\n", "findT(apath(VAR_3, VAR_122=request), VAR_5[:-3])\n", "VAR_112 = \"\"\"# -*- coding: utf-8 -*-\n# %s\ndef index(): return dict(message=\"hello from %s\")\"\"\"\n", "VAR_5 = 'plugin_%s/%s' % (request.vars.plugin, VAR_5)\n", "if VAR_5.find('.') < 0:\n", "if request.vars.plugin and not VAR_5.startswith('plugin_%s/' % request.vars\n", "if VAR_15[-8:] == '/static/' or VAR_15[-9:] == '/private/':\n", "VAR_159 = os.path.dirname(VAR_158)\n", "session.flash = T('language file \"%(filename)s\" created/updated', dict(\n VAR_5=filename))\n", "VAR_112 = VAR_112 % (T('try something like'), VAR_5)\n", "VAR_5 += '.html'\n", "VAR_50 = VAR_5.split('.')[-1].lower()\n", "VAR_5 = 'plugin_%s/%s' % (request.vars.plugin, VAR_5)\n", "if not VAR_5[-3:] == '.py':\n", "if request.vars.plugin and not VAR_5.startswith('plugin_%s/' % request.vars\n", "redirect(request.vars.sender + VAR_157)\n", "if not os.path.exists(VAR_159):\n", "redirect(request.vars.sender + VAR_157)\n", "if len(VAR_5) == 5:\n", "VAR_5 += '.py'\n", "if len(VAR_5) == 3:\n", "VAR_5 = 'plugin_%s/%s' % (request.vars.plugin, VAR_5)\n", "VAR_112 = ''\n", "os.makedirs(VAR_159)\n", "if os.path.exists(VAR_158):\n", "VAR_155 = T('This is the %(filename)s template', dict(VAR_5=filename))\n", "VAR_112 = dedent('string')[1:]\n", "FUNC_4(VAR_158, VAR_112)\n", "if VAR_50 == 'html':\n", "FUNC_1(VAR_3, 'CREATE', VAR_5)\n", "VAR_112 = dedent('string' % VAR_155)[1:]\n", "VAR_222 = os.path.join(VAR_15, 'generic.' + VAR_50)\n", "if request.vars.dir:\n", "if os.path.exists(VAR_222):\n", "VAR_110 = T('file \"%(filename)s\" created', dict(VAR_5=full_filename[len(\n path):]))\n", "session.flash = T('file \"%(filename)s\" created', dict(VAR_5=full_filename[\n len(path):]))\n", "VAR_112 = read_file(VAR_222)\n", "VAR_112 = ''\n", "VAR_17 = {}\n", "if request.vars.id:\n", "VAR_17['id'] = request.vars.id\n", "if request.vars.app:\n", "VAR_17['app'] = request.vars.app\n", "redirect(URL('edit', VAR_98=[os.path.join(request.vars.location, filename)],\n VAR_17=vars))\n" ]
[ "def create_file():...\n", "\"\"\"docstring\"\"\"\n", "if request.vars and not request.vars.token == session.token:\n", "redirect(URL('logout'))\n", "anchor = '#' + request.vars.id if request.vars.id else ''\n", "if not isinstance(e, HTTP):\n", "if request.vars.dir:\n", "if request.vars.app:\n", "session.flash = T('cannot create file')\n", "response.flash = result\n", "redirect(request.vars.sender + anchor)\n", "app = get_app(request.vars.app)\n", "if request.vars.dir:\n", "response.headers['web2py-component-content'] = 'append'\n", "path = abspath(request.vars.location)\n", "request.vars.location += request.vars.dir + '/'\n", "app = get_app(name=request.vars.location.split('/')[0])\n", "response.headers['web2py-component-command'] = '%s %s %s' % (\n \"$.web2py.invalidate('#files_menu');\", \"load_file('%s');\" % URL('edit',\n args=[app, request.vars.dir, filename]),\n \"$.web2py.enableElement($('#form form').find($.web2py.formInputClickSelector));\"\n )\n", "filename = re.sub('[^\\\\w./-]+', '_', request.vars.filename)\n", "path = apath(request.vars.location, r=request)\n", "return ''\n", "if path[-7:] == '/rules/':\n", "if len(filename) == 0:\n", "if path[-11:] == '/languages/':\n", "if not filename[-3:] == '.py':\n", "if len(filename) == 0:\n", "if path[-8:] == '/models/':\n", "filename += '.py'\n", "lang = re.match('^plural_rules-(.*)\\\\.py$', filename).group(1)\n", "if not filename[-3:] == '.py':\n", "if not filename[-3:] == '.py':\n", "if path[-13:] == '/controllers/':\n", "langinfo = read_possible_languages(apath(app, r=request))[lang]\n", "filename += '.py'\n", "path = os.path.join(apath(app, r=request), 'languages', filename)\n", "filename += '.py'\n", "if len(filename) == 3:\n", "if not filename[-3:] == '.py':\n", "if path[-7:] == '/views/':\n", "text = dedent(\n \"\"\"\n #!/usr/bin/env python\n # -*- coding: utf-8 -*-\n # Plural-Forms for %(lang)s (%(langname)s)\n\n nplurals=2 # for example, English language has 2 forms:\n # 1 singular and 1 plural\n\n # Determine plural_id for number *n* as sequence of positive\n # integers: 0,1,...\n # NOTE! For singular form ALWAYS return plural_id = 0\n get_plural_id = lambda n: int(n != 1)\n\n # Construct and return plural form of *word* using\n # *plural_id* (which ALWAYS>0). This function will be executed\n # for words (or phrases) not found in plural_dict dictionary.\n # By default this function simply returns word in singular:\n construct_plural_form = lambda word, plural_id: word\n \"\"\"\n )[1:] % dict(lang=langinfo[0], langname=langinfo[1])\n", "if not os.path.exists(path):\n", "text = '# -*- coding: utf-8 -*-\\n'\n", "filename += '.py'\n", "if len(filename) == 3:\n", "if request.vars.plugin and not filename.startswith('plugin_%s/' % request.\n", "if path[-9:] == '/modules/':\n", "full_filename = os.path.join(path, filename)\n", "safe_write(path, '')\n", "findT(apath(app, r=request), filename[:-3])\n", "text = \"\"\"# -*- coding: utf-8 -*-\n# %s\ndef index(): return dict(message=\"hello from %s\")\"\"\"\n", "filename = 'plugin_%s/%s' % (request.vars.plugin, filename)\n", "if filename.find('.') < 0:\n", "if request.vars.plugin and not filename.startswith('plugin_%s/' % request.\n", "if path[-8:] == '/static/' or path[-9:] == '/private/':\n", "dirpath = os.path.dirname(full_filename)\n", "session.flash = T('language file \"%(filename)s\" created/updated', dict(\n filename=filename))\n", "text = text % (T('try something like'), filename)\n", "filename += '.html'\n", "extension = filename.split('.')[-1].lower()\n", "filename = 'plugin_%s/%s' % (request.vars.plugin, filename)\n", "if not filename[-3:] == '.py':\n", "if request.vars.plugin and not filename.startswith('plugin_%s/' % request.\n", "redirect(request.vars.sender + anchor)\n", "if not os.path.exists(dirpath):\n", "redirect(request.vars.sender + anchor)\n", "if len(filename) == 5:\n", "filename += '.py'\n", "if len(filename) == 3:\n", "filename = 'plugin_%s/%s' % (request.vars.plugin, filename)\n", "text = ''\n", "os.makedirs(dirpath)\n", "if os.path.exists(full_filename):\n", "msg = T('This is the %(filename)s template', dict(filename=filename))\n", "text = dedent(\n \"\"\"\n #!/usr/bin/env python\n # -*- coding: utf-8 -*-\n from gluon import *\n\"\"\"\n )[1:]\n", "safe_write(full_filename, text)\n", "if extension == 'html':\n", "log_progress(app, 'CREATE', filename)\n", "text = dedent(\n \"\"\"\n {{extend 'layout.html'}}\n <h1>%s</h1>\n {{=BEAUTIFY(response._vars)}}\"\"\"\n % msg)[1:]\n", "generic = os.path.join(path, 'generic.' + extension)\n", "if request.vars.dir:\n", "if os.path.exists(generic):\n", "result = T('file \"%(filename)s\" created', dict(filename=full_filename[len(\n path):]))\n", "session.flash = T('file \"%(filename)s\" created', dict(filename=\n full_filename[len(path):]))\n", "text = read_file(generic)\n", "text = ''\n", "vars = {}\n", "if request.vars.id:\n", "vars['id'] = request.vars.id\n", "if request.vars.app:\n", "vars['app'] = request.vars.app\n", "redirect(URL('edit', args=[os.path.join(request.vars.location, filename)],\n vars=vars))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Assign'", "AugAssign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Condition", "Condition", "Condition", "Condition", "Condition", "Condition", "AugAssign'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "AugAssign'", "Assign'", "AugAssign'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Assign'", "AugAssign'", "Condition", "Condition", "Condition", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "AugAssign'", "Assign'", "Assign'", "Condition", "Condition", "Expr'", "Condition", "Expr'", "Condition", "AugAssign'", "Condition", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Expr'", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Expr'" ]
[ "@VAR_2.route('/ajax/addrestriction/<int:res_type>/<int:user_id>', methods=[...\n", "VAR_10 = request.form.to_dict()\n", "if VAR_8 == 0:\n", "if 'submit_allow' in VAR_10:\n", "if VAR_8 == 1:\n", "config.config_allowed_tags = FUNC_27(VAR_10, config.list_allowed_tags)\n", "if 'submit_deny' in VAR_10:\n", "if 'submit_allow' in VAR_10:\n", "if VAR_8 == 2:\n", "config.save()\n", "config.config_denied_tags = FUNC_27(VAR_10, config.list_denied_tags)\n", "config.config_allowed_column_value = FUNC_27(VAR_10, config.\n list_denied_column_values)\n", "if 'submit_deny' in VAR_10:\n", "if isinstance(VAR_9, VAR_119):\n", "if VAR_8 == 3:\n", "config.save()\n", "config.save()\n", "config.config_denied_column_value = FUNC_27(VAR_10, config.\n list_allowed_column_values)\n", "VAR_120 = ub.session.query(ub.User).filter(ub.User.id == VAR_119(VAR_9)).first(\n )\n", "VAR_120 = VAR_62\n", "if isinstance(VAR_9, VAR_119):\n", "return ''\n", "config.save()\n", "if 'submit_allow' in VAR_10:\n", "VAR_120 = ub.session.query(ub.User).filter(ub.User.id == VAR_119(VAR_9)).first(\n )\n", "VAR_120 = VAR_62\n", "VAR_120.allowed_tags = FUNC_27(VAR_10, VAR_120.list_allowed_tags)\n", "if 'submit_deny' in VAR_10:\n", "if 'submit_allow' in VAR_10:\n", "ub.session_commit('Changed allowed tags of user {} to {}'.format(VAR_120.\n name, VAR_120.list_allowed_tags()))\n", "VAR_120.denied_tags = FUNC_27(VAR_10, VAR_120.list_denied_tags)\n", "VAR_120.allowed_column_value = FUNC_27(VAR_10, VAR_120.\n list_allowed_column_values)\n", "if 'submit_deny' in VAR_10:\n", "ub.session_commit('Changed denied tags of user {} to {}'.format(VAR_120.\n name, VAR_120.list_denied_tags()))\n", "ub.session_commit('Changed allowed columns of user {} to {}'.format(VAR_120\n .name, VAR_120.list_allowed_column_values()))\n", "VAR_120.denied_column_value = FUNC_27(VAR_10, VAR_120.list_denied_column_values\n )\n", "ub.session_commit('Changed denied columns of user {} to {}'.format(VAR_120.\n name, VAR_120.list_denied_column_values()))\n" ]
[ "@admi.route('/ajax/addrestriction/<int:res_type>/<int:user_id>', methods=[...\n", "element = request.form.to_dict()\n", "if res_type == 0:\n", "if 'submit_allow' in element:\n", "if res_type == 1:\n", "config.config_allowed_tags = restriction_addition(element, config.\n list_allowed_tags)\n", "if 'submit_deny' in element:\n", "if 'submit_allow' in element:\n", "if res_type == 2:\n", "config.save()\n", "config.config_denied_tags = restriction_addition(element, config.\n list_denied_tags)\n", "config.config_allowed_column_value = restriction_addition(element, config.\n list_denied_column_values)\n", "if 'submit_deny' in element:\n", "if isinstance(user_id, int):\n", "if res_type == 3:\n", "config.save()\n", "config.save()\n", "config.config_denied_column_value = restriction_addition(element, config.\n list_allowed_column_values)\n", "usr = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()\n", "usr = current_user\n", "if isinstance(user_id, int):\n", "return ''\n", "config.save()\n", "if 'submit_allow' in element:\n", "usr = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()\n", "usr = current_user\n", "usr.allowed_tags = restriction_addition(element, usr.list_allowed_tags)\n", "if 'submit_deny' in element:\n", "if 'submit_allow' in element:\n", "ub.session_commit('Changed allowed tags of user {} to {}'.format(usr.name,\n usr.list_allowed_tags()))\n", "usr.denied_tags = restriction_addition(element, usr.list_denied_tags)\n", "usr.allowed_column_value = restriction_addition(element, usr.\n list_allowed_column_values)\n", "if 'submit_deny' in element:\n", "ub.session_commit('Changed denied tags of user {} to {}'.format(usr.name,\n usr.list_denied_tags()))\n", "ub.session_commit('Changed allowed columns of user {} to {}'.format(usr.\n name, usr.list_allowed_column_values()))\n", "usr.denied_column_value = restriction_addition(element, usr.\n list_denied_column_values)\n", "ub.session_commit('Changed denied columns of user {} to {}'.format(usr.name,\n usr.list_denied_column_values()))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Condition", "Return'", "Expr'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "\"\"\"Handler functions for file:... pages.\"\"\"\n", "import os\n", "from qutebrowser.browser.webkit.network import networkreply\n", "from qutebrowser.utils import jinja\n", "def FUNC_0(VAR_0, VAR_1, VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = []\n", "for filename in VAR_1:\n", "VAR_11 = os.path.join(VAR_0, filename)\n", "return sorted(VAR_6, key=lambda v: v['name'].lower())\n", "if VAR_2(VAR_11):\n", "VAR_6.append({'name': filename, 'absname': VAR_11})\n" ]
[ "\"\"\"Handler functions for file:... pages.\"\"\"\n", "import os\n", "from qutebrowser.browser.webkit.network import networkreply\n", "from qutebrowser.utils import jinja\n", "def get_file_list(basedir, all_files, filterfunc):...\n", "\"\"\"docstring\"\"\"\n", "items = []\n", "for filename in all_files:\n", "absname = os.path.join(basedir, filename)\n", "return sorted(items, key=lambda v: v['name'].lower())\n", "if filterfunc(absname):\n", "items.append({'name': filename, 'absname': absname})\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Docstring", "Assign'", "For", "Assign'", "Return'", "Condition", "Expr'" ]
[ "def FUNC_18(self):...\n", "\"\"\"docstring\"\"\"\n", "return self.get(self.meta.get_title_field())\n" ]
[ "def get_title(self):...\n", "\"\"\"docstring\"\"\"\n", "return self.get(self.meta.get_title_field())\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_1():...\n", "VAR_6 = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' test_kwarg=test_var.nested\"\n )\n", "VAR_7 = unicorn(None, VAR_6)\n", "VAR_8 = {'test_var': {'nested': 'variable!'}}\n", "VAR_9 = VAR_7.render(VAR_8)\n", "assert '->variable!<-' in VAR_9\n" ]
[ "def test_unicorn_render_context_variable():...\n", "token = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' test_kwarg=test_var.nested\"\n )\n", "unicorn_node = unicorn(None, token)\n", "context = {'test_var': {'nested': 'variable!'}}\n", "actual = unicorn_node.render(context)\n", "assert '->variable!<-' in actual\n" ]
[ 0, 0, 0, 0, 0, 2 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assert'" ]
[ "def FUNC_48():...\n", "\"\"\"docstring\"\"\"\n" ]
[ "def error():...\n", "\"\"\"docstring\"\"\"\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Docstring" ]
[ "def FUNC_43(VAR_3):...\n", "VAR_102 = apath('%s/private' % VAR_3, VAR_122=request)\n", "VAR_103 = os.path.join(VAR_102, 'ticket_storage.txt')\n", "if os.path.exists(VAR_103):\n", "VAR_166 = FUNC_3(VAR_103)\n", "if is_gae:\n", "VAR_166 = VAR_166.strip().replace('\\r', '').replace('\\n', '')\n", "VAR_166 = 'google:datastore'\n", "return False\n", "VAR_104 = 'web2py_ticket'\n", "VAR_105 = VAR_104 + '_' + VAR_3\n", "VAR_106 = apath('%s/databases' % VAR_3, VAR_122=request)\n", "VAR_107 = DAL(VAR_166, VAR_168=db_path, auto_import=True)\n", "if not VAR_107.get(VAR_105):\n", "VAR_167 = VAR_107.define_table(VAR_105, Field('ticket_id', length=100),\n Field('ticket_data', 'text'), Field('created_datetime', 'datetime'))\n", "return VAR_107, VAR_107.get(VAR_105)\n" ]
[ "def get_ticket_storage(app):...\n", "private_folder = apath('%s/private' % app, r=request)\n", "ticket_file = os.path.join(private_folder, 'ticket_storage.txt')\n", "if os.path.exists(ticket_file):\n", "db_string = safe_read(ticket_file)\n", "if is_gae:\n", "db_string = db_string.strip().replace('\\r', '').replace('\\n', '')\n", "db_string = 'google:datastore'\n", "return False\n", "tickets_table = 'web2py_ticket'\n", "tablename = tickets_table + '_' + app\n", "db_path = apath('%s/databases' % app, r=request)\n", "ticketsdb = DAL(db_string, folder=db_path, auto_import=True)\n", "if not ticketsdb.get(tablename):\n", "table = ticketsdb.define_table(tablename, Field('ticket_id', length=100),\n Field('ticket_data', 'text'), Field('created_datetime', 'datetime'))\n", "return ticketsdb, ticketsdb.get(tablename)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'" ]
[ "def FUNC_6(self, VAR_6, VAR_7):...\n", "VAR_51 = self.userdb.auth(VAR_6, VAR_7)\n", "VAR_52 = cherry.config['server.permit_remote_admin_login']\n", "VAR_50 = VAR_53.request.remote.ip in ('127.0.0.1', '::1')\n", "if not VAR_50 and VAR_51.isadmin and not VAR_52:\n", "log.i(_('Rejected remote admin login from user: {name}').format(VAR_81=user\n .name))\n", "VAR_53.session['username'] = VAR_51.name\n", "VAR_51 = userdb.User.nobody()\n", "VAR_53.session['userid'] = VAR_51.uid\n", "VAR_53.session['admin'] = VAR_51.isadmin\n" ]
[ "def session_auth(self, username, password):...\n", "user = self.userdb.auth(username, password)\n", "allow_remote = cherry.config['server.permit_remote_admin_login']\n", "is_loopback = cherrypy.request.remote.ip in ('127.0.0.1', '::1')\n", "if not is_loopback and user.isadmin and not allow_remote:\n", "log.i(_('Rejected remote admin login from user: {name}').format(name=user.name)\n )\n", "cherrypy.session['username'] = user.name\n", "user = userdb.User.nobody()\n", "cherrypy.session['userid'] = user.uid\n", "cherrypy.session['admin'] = user.isadmin\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_4():...\n", "return VAR_7\n" ]
[ "def getTrustedEngine():...\n", "return _trusted_engine\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_0(self, VAR_5, VAR_6):...\n", "return nova.db.api.s3_image_get(VAR_5, VAR_6)['uuid']\n" ]
[ "def get_image_uuid(self, context, image_id):...\n", "return nova.db.api.s3_image_get(context, image_id)['uuid']\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_10(self):...\n", "self.assertFormfield(models.Event, 'main_band', forms.Select)\n" ]
[ "def testForeignKey(self):...\n", "self.assertFormfield(models.Event, 'main_band', forms.Select)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_20(self):...\n", "self.assert_expected(self.folder.t, 'CheckBatchIteration.html')\n" ]
[ "def testBatchIteration(self):...\n", "self.assert_expected(self.folder.t, 'CheckBatchIteration.html')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "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 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" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assert'", "Assert'", "Assert'" ]
[ "def FUNC_14(VAR_3, VAR_11, VAR_12=None):...\n", "import urllib\n", "import zipfile\n", "VAR_38 = 'http://www.web2py.com/examples/static/web2py_win.zip'\n", "VAR_39 = StringIO()\n", "VAR_39.write(urlopen(VAR_38).read())\n", "VAR_40 = zipfile.ZipFile(VAR_39, VAR_4='a')\n", "VAR_41 = (\n u\"\"\"# -*- coding: utf-8 -*-\nrouters = dict(BASE=dict(default_application=\"%s\"))\"\"\"\n % VAR_3)\n", "VAR_40.writestr('web2py/routes.py', VAR_41.encode('utf-8'))\n", "VAR_42 = os.path.dirname(VAR_11)\n", "for VAR_5 in VAR_12:\n", "VAR_120 = os.path.join(VAR_11, VAR_5)\n", "VAR_40.close()\n", "VAR_121 = os.path.join('web2py/applications', VAR_3, VAR_5)\n", "VAR_43.headers['Content-Type'] = 'application/zip'\n", "VAR_40.write(VAR_120, VAR_121)\n", "VAR_43.headers['Content-Disposition'\n ] = 'attachment; filename=web2py.app.%s.zip' % VAR_3\n", "VAR_39.seek(0)\n", "return VAR_43.stream(VAR_39)\n" ]
[ "def pack_exe(app, base, filenames=None):...\n", "import urllib\n", "import zipfile\n", "download_url = 'http://www.web2py.com/examples/static/web2py_win.zip'\n", "out = StringIO()\n", "out.write(urlopen(download_url).read())\n", "web2py_win = zipfile.ZipFile(out, mode='a')\n", "routes = (\n u\"\"\"# -*- coding: utf-8 -*-\nrouters = dict(BASE=dict(default_application=\"%s\"))\"\"\"\n % app)\n", "web2py_win.writestr('web2py/routes.py', routes.encode('utf-8'))\n", "common_root = os.path.dirname(base)\n", "for filename in filenames:\n", "fname = os.path.join(base, filename)\n", "web2py_win.close()\n", "arcname = os.path.join('web2py/applications', app, filename)\n", "response.headers['Content-Type'] = 'application/zip'\n", "web2py_win.write(fname, arcname)\n", "response.headers['Content-Disposition'\n ] = 'attachment; filename=web2py.app.%s.zip' % app\n", "out.seek(0)\n", "return response.stream(out)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Import'", "Import'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "For", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_15(self, VAR_1):...\n", "VAR_5 = VAR_1.MagicMock()\n", "VAR_26 = VAR_1.MagicMock()\n", "VAR_23 = oai.Schema(type='array', items={})\n", "from openapi_python_client.parser.properties import property_from_data\n", "VAR_4 = property_from_data(VAR_5=name, VAR_26=required, VAR_23=data)\n", "assert VAR_4 == PropertyError(VAR_23=oai.Schema(), detail=\n f'invalid data in items of array {name}')\n" ]
[ "def test_property_from_data_array_invalid_items(self, mocker):...\n", "name = mocker.MagicMock()\n", "required = mocker.MagicMock()\n", "data = oai.Schema(type='array', items={})\n", "from openapi_python_client.parser.properties import property_from_data\n", "p = property_from_data(name=name, required=required, data=data)\n", "assert p == PropertyError(data=oai.Schema(), detail=\n f'invalid data in items of array {name}')\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "ImportFrom'", "Assign'", "Assert'" ]
[ "def __init__(self, **VAR_22):...\n", "\"\"\"docstring\"\"\"\n", "if 'quote_char' in VAR_22:\n", "self.use_best_quote_char = False\n", "for attr in self.options:\n", "setattr(self, attr, VAR_22.get(attr, getattr(self, attr)))\n", "self.errors = []\n", "self.strict = False\n" ]
[ "def __init__(self, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "if 'quote_char' in kwargs:\n", "self.use_best_quote_char = False\n", "for attr in self.options:\n", "setattr(self, attr, kwargs.get(attr, getattr(self, attr)))\n", "self.errors = []\n", "self.strict = False\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "For", "Expr'", "Assign'", "Assign'" ]
[ "def __init__(self, VAR_58, *VAR_6, **VAR_7):...\n", "self.project = VAR_58\n", "super().__init__(*VAR_6, **kwargs)\n", "self.fields['user'].widget = forms.HiddenInput()\n", "self.fields['groups'].queryset = VAR_58.defined_groups.all()\n" ]
[ "def __init__(self, project, *args, **kwargs):...\n", "self.project = project\n", "super().__init__(*args, **kwargs)\n", "self.fields['user'].widget = forms.HiddenInput()\n", "self.fields['groups'].queryset = project.defined_groups.all()\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Assign'", "Assign'" ]
[ "@transaction.non_atomic_requests...\n", "\"\"\"docstring\"\"\"\n", "VAR_38 = CourseKey.from_string(VAR_10)\n", "VAR_150 = instructor_task.api.generate_certificates_for_students(VAR_9, VAR_38)\n", "VAR_74 = _('string')\n", "VAR_63 = {'message': VAR_74, 'task_id': VAR_150.task_id}\n", "return JsonResponse(VAR_63)\n" ]
[ "@transaction.non_atomic_requests...\n", "\"\"\"docstring\"\"\"\n", "course_key = CourseKey.from_string(course_id)\n", "task = instructor_task.api.generate_certificates_for_students(request,\n course_key)\n", "message = _(\n 'Certificate generation task for all students of this course has been started. You can view the status of the generation task in the \"Pending Tasks\" section.'\n )\n", "response_payload = {'message': message, 'task_id': task.task_id}\n", "return JsonResponse(response_payload)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_4(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_1 = self.register_user('user', 'pass')\n", "VAR_10 = self.login('user', 'pass')\n", "VAR_11 = self.register_user('otheruser', 'pass')\n", "VAR_12 = self.login('otheruser', 'pass')\n", "VAR_18 = self.register_user('yetanotheruser', 'pass')\n", "VAR_19 = self.login('yetanotheruser', 'pass')\n", "VAR_15 = self.helper.create_room_as(VAR_1, tok=access_token)\n", "self.helper.join(VAR_15=room, user=other_user_id, tok=other_access_token)\n", "self.helper.join(VAR_15=room, user=yet_another_user_id, tok=\n yet_another_access_token)\n", "VAR_13 = self.get_success(self.hs.get_datastore().get_user_by_access_token(\n VAR_10))\n", "VAR_14 = VAR_13.token_id\n", "self.get_success(self.hs.get_pusherpool().add_pusher(VAR_1=user_id, VAR_10=\n token_id, kind='http', app_id='m.http', app_display_name=\n 'HTTP Push Notifications', device_display_name='pushy push', pushkey=\n '[email protected]', lang=None, data={'url': 'example.com'}))\n", "self.helper.send(VAR_15, VAR_7='Oh, user, hello!', tok=other_access_token)\n", "self.pump()\n", "self.push_attempts[0][0].callback({})\n", "self.pump()\n", "self.assertEqual(len(self.push_attempts), 1)\n", "self.assertEqual(self.push_attempts[0][1], 'example.com')\n", "self.assertEqual(self.push_attempts[0][2]['notification']['prio'], 'high')\n", "self.helper.send(VAR_15, VAR_7='Are you there?', tok=other_access_token)\n", "self.pump()\n", "self.assertEqual(len(self.push_attempts), 2)\n", "self.assertEqual(self.push_attempts[1][1], 'example.com')\n", "self.assertEqual(self.push_attempts[1][2]['notification']['prio'], 'low')\n" ]
[ "def test_sends_high_priority_for_mention(self):...\n", "\"\"\"docstring\"\"\"\n", "user_id = self.register_user('user', 'pass')\n", "access_token = self.login('user', 'pass')\n", "other_user_id = self.register_user('otheruser', 'pass')\n", "other_access_token = self.login('otheruser', 'pass')\n", "yet_another_user_id = self.register_user('yetanotheruser', 'pass')\n", "yet_another_access_token = self.login('yetanotheruser', 'pass')\n", "room = self.helper.create_room_as(user_id, tok=access_token)\n", "self.helper.join(room=room, user=other_user_id, tok=other_access_token)\n", "self.helper.join(room=room, user=yet_another_user_id, tok=\n yet_another_access_token)\n", "user_tuple = self.get_success(self.hs.get_datastore().\n get_user_by_access_token(access_token))\n", "token_id = user_tuple.token_id\n", "self.get_success(self.hs.get_pusherpool().add_pusher(user_id=user_id,\n access_token=token_id, kind='http', app_id='m.http', app_display_name=\n 'HTTP Push Notifications', device_display_name='pushy push', pushkey=\n '[email protected]', lang=None, data={'url': 'example.com'}))\n", "self.helper.send(room, body='Oh, user, hello!', tok=other_access_token)\n", "self.pump()\n", "self.push_attempts[0][0].callback({})\n", "self.pump()\n", "self.assertEqual(len(self.push_attempts), 1)\n", "self.assertEqual(self.push_attempts[0][1], 'example.com')\n", "self.assertEqual(self.push_attempts[0][2]['notification']['prio'], 'high')\n", "self.helper.send(room, body='Are you there?', tok=other_access_token)\n", "self.pump()\n", "self.assertEqual(len(self.push_attempts), 2)\n", "self.assertEqual(self.push_attempts[1][1], 'example.com')\n", "self.assertEqual(self.push_attempts[1][2]['notification']['prio'], 'low')\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 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_7(VAR_21):...\n", "\"\"\"docstring\"\"\"\n", "for regex in (VAR_8, VAR_9, VAR_10):\n", "VAR_38 = regex.match(VAR_21)\n", "VAR_39 = int(VAR_38.group('year'))\n", "six.reraise(ValueError, ValueError('%r is not a valid date' % VAR_21), sys.\n exc_info()[2])\n", "if VAR_38 is not None:\n", "if VAR_39 < 100:\n", "if VAR_39 < 70:\n", "VAR_40 = VAR_1.index(VAR_38.group('mon').lower()) + 1\n", "VAR_39 += 2000\n", "VAR_39 += 1900\n", "VAR_41 = int(VAR_38.group('day'))\n", "VAR_42 = int(VAR_38.group('hour'))\n", "VAR_43 = int(VAR_38.group('min'))\n", "VAR_44 = int(VAR_38.group('sec'))\n", "VAR_45 = datetime.datetime(VAR_39, VAR_40, VAR_41, VAR_42, VAR_43, VAR_44)\n", "return calendar.timegm(VAR_45.utctimetuple())\n" ]
[ "def parse_http_date(date):...\n", "\"\"\"docstring\"\"\"\n", "for regex in (RFC1123_DATE, RFC850_DATE, ASCTIME_DATE):\n", "m = regex.match(date)\n", "year = int(m.group('year'))\n", "six.reraise(ValueError, ValueError('%r is not a valid date' % date), sys.\n exc_info()[2])\n", "if m is not None:\n", "if year < 100:\n", "if year < 70:\n", "month = MONTHS.index(m.group('mon').lower()) + 1\n", "year += 2000\n", "year += 1900\n", "day = int(m.group('day'))\n", "hour = int(m.group('hour'))\n", "min = int(m.group('min'))\n", "sec = int(m.group('sec'))\n", "result = datetime.datetime(year, month, day, hour, min, sec)\n", "return calendar.timegm(result.utctimetuple())\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "For", "Assign'", "Assign'", "Expr'", "Condition", "Condition", "Condition", "Assign'", "AugAssign'", "AugAssign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_15(VAR_37):...\n", "VAR_39, VAR_23 = VAR_37\n", "VAR_16.write(VAR_39)\n", "return VAR_23\n" ]
[ "def write_to(r):...\n", "data, response = r\n", "output_stream.write(data)\n", "return response\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Return'" ]
[ "@FUNC_0...\n", "return ModuleApi(self, self.get_auth_handler())\n" ]
[ "@cache_in_self...\n", "return ModuleApi(self, self.get_auth_handler())\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "@ratelimit(rate='2/10s')...\n", "if VAR_7.user.is_authenticated:\n", "return redirect(VAR_7.GET.get('next', reverse('spirit:user:update')))\n", "VAR_17 = VAR_9(data=post_data(request))\n", "if is_post(VAR_7) and not VAR_7.is_limited() and VAR_17.is_valid():\n", "VAR_18 = VAR_17.save()\n", "return render(VAR_7=request, VAR_12='spirit/user/auth/register.html',\n context={'form': form})\n", "send_activation_email(VAR_7, VAR_18)\n", "messages.info(VAR_7, _(\n 'We have sent you an email to %(email)s so you can activate your account!'\n ) % {'email': VAR_17.get_email()})\n", "return redirect(reverse(settings.LOGIN_URL))\n" ]
[ "@ratelimit(rate='2/10s')...\n", "if request.user.is_authenticated:\n", "return redirect(request.GET.get('next', reverse('spirit:user:update')))\n", "form = registration_form(data=post_data(request))\n", "if is_post(request) and not request.is_limited() and form.is_valid():\n", "user = form.save()\n", "return render(request=request, template_name=\n 'spirit/user/auth/register.html', context={'form': form})\n", "send_activation_email(request, user)\n", "messages.info(request, _(\n 'We have sent you an email to %(email)s so you can activate your account!'\n ) % {'email': form.get_email()})\n", "return redirect(reverse(settings.LOGIN_URL))\n" ]
[ 0, 0, 4, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Return'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_13(self):...\n", "if self.force:\n", "return True\n", "if not os.path.exists(self.bower_dir):\n", "return True\n", "return FUNC_6(self.bower_dir) < FUNC_6(VAR_1(VAR_2, 'bower.json'))\n" ]
[ "def should_run(self):...\n", "if self.force:\n", "return True\n", "if not os.path.exists(self.bower_dir):\n", "return True\n", "return mtime(self.bower_dir) < mtime(pjoin(repo_root, 'bower.json'))\n" ]
[ 0, 0, 0, 0, 0, 2 ]
[ "FunctionDef'", "For", "Return'", "Condition", "Return'", "Return'" ]
[ "def FUNC_11(VAR_0):...\n", "VAR_0.DEBUG = True\n", "VAR_6 = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentParent'\")\n", "VAR_7 = unicorn(None, VAR_6)\n", "VAR_8 = {}\n", "VAR_12 = VAR_7.render(VAR_8)\n", "assert '<script type=\"module\"' in VAR_12\n", "assert len(re.findall('<script type=\"module\"', VAR_12)) == 1\n" ]
[ "def test_unicorn_render_parent_component_one_script_tag(settings):...\n", "settings.DEBUG = True\n", "token = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentParent'\")\n", "unicorn_node = unicorn(None, token)\n", "context = {}\n", "html = unicorn_node.render(context)\n", "assert '<script type=\"module\"' in html\n", "assert len(re.findall('<script type=\"module\"', html)) == 1\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assert'", "Assert'" ]
[ "@VAR_6.route('/<gididx>')...\n", "VAR_11 = 'GIDIDX' + VAR_7.upper()\n", "VAR_11 = FUNC_7(VAR_11)\n", "def FUNC_9():...\n", "VAR_16 = 0\n", "for _ in f.readlines():\n", "VAR_16 += 1\n", "yield '<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\\n'\n", "if VAR_8 is not None and VAR_16 >= VAR_8:\n", "if VAR_1:\n", "yield '<?xml-stylesheet type=\"text/xsl\" href=\"/scopelist.xsl\" ?>\\n'\n", "yield '<objectlist count=\"{:d}\">\\n'.format(VAR_16)\n", "VAR_17 = 0\n", "for VAR_13 in f.readlines():\n", "VAR_13 = VAR_13.strip()\n", "yield '</objectlist>\\n'\n", "yield FUNC_4(VAR_9=path) + '\\n'\n", "VAR_12 = Headers([('Content-Type', 'text/xml')])\n", "VAR_17 += 1\n", "return Response(stream_with_context(FUNC_9()), status='200 OK', VAR_12=headers)\n", "if VAR_8 is not None and VAR_17 >= VAR_8:\n" ]
[ "@scope_blueprint.route('/<gididx>')...\n", "index = 'GIDIDX' + gididx.upper()\n", "index = _get_index_absolute_path(index)\n", "def generate():...\n", "num_entries = 0\n", "for _ in f.readlines():\n", "num_entries += 1\n", "yield '<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\\n'\n", "if limit is not None and num_entries >= limit:\n", "if STYLE:\n", "yield '<?xml-stylesheet type=\"text/xsl\" href=\"/scopelist.xsl\" ?>\\n'\n", "yield '<objectlist count=\"{:d}\">\\n'.format(num_entries)\n", "count = 0\n", "for path in f.readlines():\n", "path = path.strip()\n", "yield '</objectlist>\\n'\n", "yield _get_object_element(object_path=path) + '\\n'\n", "headers = Headers([('Content-Type', 'text/xml')])\n", "count += 1\n", "return Response(stream_with_context(generate()), status='200 OK', headers=\n headers)\n", "if limit is not None and count >= limit:\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "FunctionDef'", "Assign'", "For", "AugAssign'", "Expr'", "Condition", "Condition", "Expr'", "Expr'", "Assign'", "For", "Assign'", "Expr'", "Expr'", "Assign'", "AugAssign'", "Return'", "Condition" ]
[ "@classmethod...\n", "\"\"\"docstring\"\"\"\n", "VAR_41.add_argument('-c', '--config-path', action='append', metavar=\n 'CONFIG_FILE', help=\n 'Specify config file. Can be given multiple times and may specify directories containing *.yaml files.'\n )\n", "VAR_41.add_argument('--keys-directory', metavar='DIRECTORY', help=\n 'Where files such as certs and signing keys are stored when their location is not given explicitly in the config. Defaults to the directory containing the last config file'\n )\n", "VAR_15.invoke_all_static('add_arguments', VAR_41)\n" ]
[ "@classmethod...\n", "\"\"\"docstring\"\"\"\n", "config_parser.add_argument('-c', '--config-path', action='append', metavar=\n 'CONFIG_FILE', help=\n 'Specify config file. Can be given multiple times and may specify directories containing *.yaml files.'\n )\n", "config_parser.add_argument('--keys-directory', metavar='DIRECTORY', help=\n 'Where files such as certs and signing keys are stored when their location is not given explicitly in the config. Defaults to the directory containing the last config file'\n )\n", "cls.invoke_all_static('add_arguments', config_parser)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_47():...\n", "VAR_4 = request.form.to_dict()\n", "VAR_16 = {}\n", "VAR_16['config_calibre_dir'] = re.sub('[\\\\\\\\/]metadata\\\\.db$', '', VAR_4[\n 'config_calibre_dir'], flags=re.IGNORECASE).strip()\n", "VAR_84 = config.config_calibre_dir != VAR_16['config_calibre_dir'\n ] and config.config_calibre_dir\n", "VAR_85 = calibre_db.check_valid_db(VAR_16['config_calibre_dir'], ub.app_DB_path\n )\n", "return VAR_84, VAR_85\n" ]
[ "def _db_simulate_change():...\n", "param = request.form.to_dict()\n", "to_save = {}\n", "to_save['config_calibre_dir'] = re.sub('[\\\\\\\\/]metadata\\\\.db$', '', param[\n 'config_calibre_dir'], flags=re.IGNORECASE).strip()\n", "db_change = config.config_calibre_dir != to_save['config_calibre_dir'\n ] and config.config_calibre_dir\n", "db_valid = calibre_db.check_valid_db(to_save['config_calibre_dir'], ub.\n app_DB_path)\n", "return db_change, db_valid\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_87(self, VAR_153, VAR_112=VAR_3, VAR_134=VAR_3, VAR_135=VAR_3,...\n", "if VAR_112 is VAR_3:\n", "VAR_112 = self.settings.create_next\n", "if VAR_134 is VAR_3:\n", "VAR_134 = self.settings.create_onvalidation\n", "if VAR_135 is VAR_3:\n", "VAR_135 = self.settings.create_onaccept\n", "if VAR_136 is VAR_3:\n", "VAR_136 = self.messages['create_log']\n", "if VAR_37 is VAR_3:\n", "VAR_37 = self.messages.record_created\n", "return self.update(VAR_153, None, VAR_112=next, VAR_134=onvalidation,\n VAR_135=onaccept, VAR_136=log, VAR_37=message, VAR_170=False, VAR_171=\n formname, **attributes)\n" ]
[ "def create(self, table, next=DEFAULT, onvalidation=DEFAULT, onaccept=...\n", "if next is DEFAULT:\n", "next = self.settings.create_next\n", "if onvalidation is DEFAULT:\n", "onvalidation = self.settings.create_onvalidation\n", "if onaccept is DEFAULT:\n", "onaccept = self.settings.create_onaccept\n", "if log is DEFAULT:\n", "log = self.messages['create_log']\n", "if message is DEFAULT:\n", "message = self.messages.record_created\n", "return self.update(table, None, next=next, onvalidation=onvalidation,\n onaccept=onaccept, log=log, message=message, deletable=False, formname=\n formname, **attributes)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Return'" ]
[ "@VAR_0.route('/widget_execute/<unique_id>')...\n", "\"\"\"docstring\"\"\"\n", "VAR_42 = DaemonControl()\n", "VAR_43 = VAR_42.widget_execute(VAR_9)\n", "return jsonify(VAR_43)\n" ]
[ "@blueprint.route('/widget_execute/<unique_id>')...\n", "\"\"\"docstring\"\"\"\n", "daemon_control = DaemonControl()\n", "return_value = daemon_control.widget_execute(unique_id)\n", "return jsonify(return_value)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Return'" ]
[ "@defer.inlineCallbacks...\n", "VAR_30 = yield defer.ensureDeferred(self._base_builder.build(VAR_28, VAR_29))\n", "VAR_30._event_id = self._event_id\n", "VAR_30._dict['event_id'] = self._event_id\n", "assert VAR_30.event_id == self._event_id\n", "return VAR_30\n" ]
[ "@defer.inlineCallbacks...\n", "built_event = yield defer.ensureDeferred(self._base_builder.build(\n prev_event_ids, auth_event_ids))\n", "built_event._event_id = self._event_id\n", "built_event._dict['event_id'] = self._event_id\n", "assert built_event.event_id == self._event_id\n", "return built_event\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assert'", "Return'" ]