lines
sequencelengths
1
383
raw_lines
sequencelengths
1
383
label
sequencelengths
1
383
type
sequencelengths
1
383
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "VAR_15 = VAR_8.getObject('Image', VAR_6)\n", "if VAR_15 is None:\n", "VAR_159, VAR_160 = VAR_8.getMaxPlaneSize()\n", "VAR_86 = VAR_15.getSizeX()\n", "VAR_87 = VAR_15.getSizeY()\n", "if VAR_86 * VAR_87 > VAR_159 * VAR_160:\n", "VAR_231 = \"Histogram not supported for 'big' images (over %s * %s pixels)\" % (\n VAR_159, VAR_160)\n", "VAR_74 = int(VAR_2.GET.get('theZ', 0))\n", "return JsonResponse({'error': VAR_231})\n", "VAR_73 = int(VAR_2.GET.get('theT', 0))\n", "VAR_37 = int(VAR_37)\n", "VAR_161 = int(VAR_2.GET.get('bins', 256))\n", "VAR_162 = VAR_15.getHistogram([VAR_37], VAR_161, VAR_74=theZ, VAR_73=theT)\n", "VAR_163 = VAR_162[VAR_37]\n", "return JsonResponse({'data': VAR_163})\n" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "image = conn.getObject('Image', iid)\n", "if image is None:\n", "maxW, maxH = conn.getMaxPlaneSize()\n", "sizeX = image.getSizeX()\n", "sizeY = image.getSizeY()\n", "if sizeX * sizeY > maxW * maxH:\n", "msg = \"Histogram not supported for 'big' images (over %s * %s pixels)\" % (maxW,\n maxH)\n", "theZ = int(request.GET.get('theZ', 0))\n", "return JsonResponse({'error': msg})\n", "theT = int(request.GET.get('theT', 0))\n", "theC = int(theC)\n", "binCount = int(request.GET.get('bins', 256))\n", "data = image.getHistogram([theC], binCount, theZ=theZ, theT=theT)\n", "histogram = data[theC]\n", "return JsonResponse({'data': histogram})\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_7(VAR_19):...\n", "VAR_36 = FUNC_10(VAR_19)\n", "VAR_38 = '/'.join(VAR_36.split('/')[:-2]) + '/classes.txt'\n", "if os.path.isfile(VAR_38):\n", "return '<object id={} src={} meta={} />'.format(quoteattr(url_for(\n '.get_object_id', VAR_19=object_path)), quoteattr(FUNC_8(VAR_19)),\n quoteattr(url_for('.get_object_meta', VAR_19=object_path)))\n", "return '<object id={} src={} />'.format(quoteattr(url_for('.get_object_id',\n VAR_19=object_path)), quoteattr(FUNC_8(VAR_19)))\n" ]
[ "def _get_object_element(object_path):...\n", "path = _get_obj_absolute_path(object_path)\n", "class_text = '/'.join(path.split('/')[:-2]) + '/classes.txt'\n", "if os.path.isfile(class_text):\n", "return '<object id={} src={} meta={} />'.format(quoteattr(url_for(\n '.get_object_id', object_path=object_path)), quoteattr(\n _get_object_src_uri(object_path)), quoteattr(url_for('.get_object_meta',\n object_path=object_path)))\n", "return '<object id={} src={} />'.format(quoteattr(url_for('.get_object_id',\n object_path=object_path)), quoteattr(_get_object_src_uri(object_path)))\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Return'", "Return'" ]
[ "@VAR_0.route('/output_mod/<output_id>/<channel>/<state>/<output_type>/<amount>'...\n", "\"\"\"docstring\"\"\"\n", "if not utils_general.user_has_permission('edit_controllers'):\n", "return 'Insufficient user permissions to manipulate outputs'\n", "if is_int(VAR_22):\n", "VAR_88 = int(VAR_22)\n", "VAR_89 = db_retrieve_table(OutputChannel).filter(OutputChannel.unique_id ==\n VAR_22).first()\n", "VAR_69 = DaemonControl()\n", "if VAR_89:\n", "if VAR_24 in ['on', 'off'] and str_is_float(VAR_26) and (VAR_25 in ['sec',\n", "VAR_88 = VAR_89.channel\n", "return \"Could not determine channel number from channel ID '{}'\".format(VAR_22)\n", "VAR_90 = VAR_69.output_on_off(VAR_23, VAR_24, VAR_25=output_type, VAR_26=\n float(amount), VAR_88=output_channel)\n", "return 'ERROR: unknown parameters: output_id: {}, channel: {}, state: {}, output_type: {}, amount: {}'.format(\n VAR_23, VAR_22, VAR_24, VAR_25, VAR_26)\n", "if VAR_90[0]:\n", "return 'ERROR: {}'.format(VAR_90[1])\n", "return 'SUCCESS: {}'.format(VAR_90[1])\n" ]
[ "@blueprint.route(...\n", "\"\"\"docstring\"\"\"\n", "if not utils_general.user_has_permission('edit_controllers'):\n", "return 'Insufficient user permissions to manipulate outputs'\n", "if is_int(channel):\n", "output_channel = int(channel)\n", "channel_dev = db_retrieve_table(OutputChannel).filter(OutputChannel.\n unique_id == channel).first()\n", "daemon = DaemonControl()\n", "if channel_dev:\n", "if state in ['on', 'off'] and str_is_float(amount) and (output_type in [\n", "output_channel = channel_dev.channel\n", "return \"Could not determine channel number from channel ID '{}'\".format(channel\n )\n", "out_status = daemon.output_on_off(output_id, state, output_type=output_type,\n amount=float(amount), output_channel=output_channel)\n", "return 'ERROR: unknown parameters: output_id: {}, channel: {}, state: {}, output_type: {}, amount: {}'.format(\n output_id, channel, state, output_type, amount)\n", "if out_status[0]:\n", "return 'ERROR: {}'.format(out_status[1])\n", "return 'SUCCESS: {}'.format(out_status[1])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Return'", "Assign'", "Return'", "Condition", "Return'", "Return'" ]
[ "def FUNC_13(self):...\n", "super().save()\n", "self.file_path = tempfile.mkdtemp(dir=self.temp_dir())\n" ]
[ "def save(self):...\n", "super().save()\n", "self.file_path = tempfile.mkdtemp(dir=self.temp_dir())\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'" ]
[ "def FUNC_30(self):...\n", "VAR_27 = widgets.AdminURLFieldWidget()\n", "self.assertHTMLEqual(conditional_escape(VAR_27.render('test', '')),\n '<input class=\"vURLField\" name=\"test\" type=\"url\" />')\n", "self.assertHTMLEqual(conditional_escape(VAR_27.render('test',\n 'http://example.com')), 'string')\n" ]
[ "def test_render(self):...\n", "w = widgets.AdminURLFieldWidget()\n", "self.assertHTMLEqual(conditional_escape(w.render('test', '')),\n '<input class=\"vURLField\" name=\"test\" type=\"url\" />')\n", "self.assertHTMLEqual(conditional_escape(w.render('test',\n 'http://example.com')),\n '<p class=\"url\">Currently:<a href=\"http://example.com\">http://example.com</a><br />Change:<input class=\"vURLField\" name=\"test\" type=\"url\" value=\"http://example.com\" /></p>'\n )\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_11(VAR_22):...\n", "\"\"\"docstring\"\"\"\n", "return base64.urlsafe_b64encode(VAR_22).rstrip(b'\\n=')\n" ]
[ "def urlsafe_base64_encode(s):...\n", "\"\"\"docstring\"\"\"\n", "return base64.urlsafe_b64encode(s).rstrip(b'\\n=')\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_66(VAR_12, VAR_27):...\n", "VAR_91 = FUNC_69(VAR_12, config.config_ldap_user_object)\n", "VAR_114 = VAR_27[VAR_91][0].decode('utf-8')\n", "VAR_0.error('Failed to extract LDAP user: %s - %s', VAR_12, ex)\n", "if ub.session.query(ub.User).filter(VAR_18.lower(ub.User.name) == VAR_114.\n", "VAR_71 = _(u'Failed to extract at least One LDAP User')\n", "VAR_0.warning('LDAP User %s Already in Database', VAR_27)\n", "VAR_92 = ''\n", "return 0, VAR_71\n", "return 0, None\n", "if 'mail' in VAR_27:\n", "VAR_115 = VAR_27['mail'][0].decode('utf-8')\n", "VAR_0.debug('No Mail Field Found in LDAP Response')\n", "if len(VAR_27['mail']) > 1:\n", "VAR_115 = VAR_114 + '@email.com'\n", "VAR_92 = VAR_27['mail'][1].decode('utf-8')\n", "VAR_115 = check_email(VAR_115)\n", "VAR_0.warning('LDAP Email Error: {}, {}'.format(VAR_27, ex))\n", "VAR_22 = ub.User()\n", "return 0, None\n", "VAR_22.name = VAR_114\n", "VAR_22.password = ''\n", "VAR_22.email = VAR_115\n", "VAR_22.kindle_mail = VAR_92\n", "VAR_22.default_language = config.config_default_language\n", "VAR_22.locale = config.config_default_locale\n", "VAR_22.role = config.config_default_role\n", "VAR_22.sidebar_view = config.config_default_show\n", "VAR_22.allowed_tags = config.config_allowed_tags\n", "VAR_22.denied_tags = config.config_denied_tags\n", "VAR_22.allowed_column_value = config.config_allowed_column_value\n", "VAR_22.denied_column_value = config.config_denied_column_value\n", "ub.session.add(VAR_22)\n", "ub.session.commit()\n", "VAR_0.warning('Failed to create LDAP user: %s - %s', VAR_12, ex)\n", "return 1, None\n", "ub.session.rollback()\n", "VAR_71 = _(u'Failed to Create at Least One LDAP User')\n", "return 0, VAR_71\n" ]
[ "def ldap_import_create_user(user, user_data):...\n", "user_login_field = extract_dynamic_field_from_filter(user, config.\n config_ldap_user_object)\n", "username = user_data[user_login_field][0].decode('utf-8')\n", "log.error('Failed to extract LDAP user: %s - %s', user, ex)\n", "if ub.session.query(ub.User).filter(func.lower(ub.User.name) == username.\n", "message = _(u'Failed to extract at least One LDAP User')\n", "log.warning('LDAP User %s Already in Database', user_data)\n", "kindlemail = ''\n", "return 0, message\n", "return 0, None\n", "if 'mail' in user_data:\n", "useremail = user_data['mail'][0].decode('utf-8')\n", "log.debug('No Mail Field Found in LDAP Response')\n", "if len(user_data['mail']) > 1:\n", "useremail = username + '@email.com'\n", "kindlemail = user_data['mail'][1].decode('utf-8')\n", "useremail = check_email(useremail)\n", "log.warning('LDAP Email Error: {}, {}'.format(user_data, ex))\n", "content = ub.User()\n", "return 0, None\n", "content.name = username\n", "content.password = ''\n", "content.email = useremail\n", "content.kindle_mail = kindlemail\n", "content.default_language = config.config_default_language\n", "content.locale = config.config_default_locale\n", "content.role = config.config_default_role\n", "content.sidebar_view = config.config_default_show\n", "content.allowed_tags = config.config_allowed_tags\n", "content.denied_tags = config.config_denied_tags\n", "content.allowed_column_value = config.config_allowed_column_value\n", "content.denied_column_value = config.config_denied_column_value\n", "ub.session.add(content)\n", "ub.session.commit()\n", "log.warning('Failed to create LDAP user: %s - %s', user, ex)\n", "return 1, None\n", "ub.session.rollback()\n", "message = _(u'Failed to Create at Least One LDAP User')\n", "return 0, message\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Expr'", "Assign'", "Return'", "Return'", "Condition", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Return'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_26(self, VAR_23, VAR_24, VAR_25, VAR_26=False):...\n", "VAR_73 = self.playlistdb.savePlaylist(VAR_15=self.getUserId(), VAR_24=1 if\n public else 0, VAR_23=playlist, playlisttitle=playlistname, VAR_26=\n overwrite)\n", "if VAR_73 == 'success':\n", "return VAR_73\n" ]
[ "def api_saveplaylist(self, playlist, public, playlistname, overwrite=False):...\n", "res = self.playlistdb.savePlaylist(userid=self.getUserId(), public=1 if\n public else 0, playlist=playlist, playlisttitle=playlistname, overwrite\n =overwrite)\n", "if res == 'success':\n", "return res\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_11(VAR_16):...\n", "return {VAR_22.domain for VAR_22 in self.room_members}\n" ]
[ "def get_joined_hosts_for_room(room_id):...\n", "return {member.domain for member in self.room_members}\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_103(VAR_46):...\n", "if VAR_46 not in VAR_1.system_settings:\n", "VAR_1.system_settings.update({VAR_46: VAR_12.get_single_value(\n 'System Settings', VAR_46)})\n", "return VAR_1.system_settings.get(VAR_46)\n" ]
[ "def get_system_settings(key):...\n", "if key not in local.system_settings:\n", "local.system_settings.update({key: db.get_single_value('System Settings', key)}\n )\n", "return local.system_settings.get(key)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Return'" ]
[ "@VAR_2.route('/series')...\n", "if VAR_87.check_visibility(constants.SIDEBAR_SERIES):\n", "if VAR_87.get_view_property('series', 'dir') == 'desc':\n", "abort(404)\n", "VAR_10 = db.Series.sort.desc()\n", "VAR_10 = db.Series.sort.asc()\n", "VAR_109 = 0\n", "VAR_109 = 1\n", "if VAR_87.get_view_property('series', 'series_view') == 'list':\n", "VAR_63 = calibre_db.session.query(db.Series, func.count(\n 'books_series_link.book').label('count')).join(db.books_series_link).join(\n db.Books).filter(calibre_db.common_filters()).group_by(text(\n 'books_series_link.series')).order_by(VAR_10).all()\n", "VAR_63 = calibre_db.session.query(db.Books, func.count('books_series_link')\n .label('count'), func.max(db.Books.series_index), db.Books.id).join(db.\n books_series_link).join(db.Series).filter(calibre_db.common_filters()\n ).group_by(text('books_series_link.series')).order_by(VAR_10).all()\n", "VAR_107 = calibre_db.session.query(func.upper(func.substr(db.Series.sort, 1,\n 1)).label('char')).join(db.books_series_link).join(db.Books).filter(\n calibre_db.common_filters()).group_by(func.upper(func.substr(db.Series.\n sort, 1, 1))).all()\n", "VAR_107 = calibre_db.session.query(func.upper(func.substr(db.Series.sort, 1,\n 1)).label('char')).join(db.books_series_link).join(db.Books).filter(\n calibre_db.common_filters()).group_by(func.upper(func.substr(db.Series.\n sort, 1, 1))).all()\n", "return render_title_template('list.html', VAR_63=entries, folder=\n 'web.books_list', VAR_107=charlist, VAR_150=_(u'Series'), VAR_9=\n 'serieslist', VAR_8='series', VAR_10=order_no)\n", "return render_title_template('grid.html', VAR_63=entries, folder=\n 'web.books_list', VAR_107=charlist, VAR_150=_(u'Series'), VAR_9=\n 'serieslist', VAR_8='series', bodyClass='grid-view', VAR_10=order_no)\n" ]
[ "@web.route('/series')...\n", "if current_user.check_visibility(constants.SIDEBAR_SERIES):\n", "if current_user.get_view_property('series', 'dir') == 'desc':\n", "abort(404)\n", "order = db.Series.sort.desc()\n", "order = db.Series.sort.asc()\n", "order_no = 0\n", "order_no = 1\n", "if current_user.get_view_property('series', 'series_view') == 'list':\n", "entries = calibre_db.session.query(db.Series, func.count(\n 'books_series_link.book').label('count')).join(db.books_series_link).join(\n db.Books).filter(calibre_db.common_filters()).group_by(text(\n 'books_series_link.series')).order_by(order).all()\n", "entries = calibre_db.session.query(db.Books, func.count('books_series_link'\n ).label('count'), func.max(db.Books.series_index), db.Books.id).join(db\n .books_series_link).join(db.Series).filter(calibre_db.common_filters()\n ).group_by(text('books_series_link.series')).order_by(order).all()\n", "charlist = calibre_db.session.query(func.upper(func.substr(db.Series.sort, \n 1, 1)).label('char')).join(db.books_series_link).join(db.Books).filter(\n calibre_db.common_filters()).group_by(func.upper(func.substr(db.Series.\n sort, 1, 1))).all()\n", "charlist = calibre_db.session.query(func.upper(func.substr(db.Series.sort, \n 1, 1)).label('char')).join(db.books_series_link).join(db.Books).filter(\n calibre_db.common_filters()).group_by(func.upper(func.substr(db.Series.\n sort, 1, 1))).all()\n", "return render_title_template('list.html', entries=entries, folder=\n 'web.books_list', charlist=charlist, title=_(u'Series'), page=\n 'serieslist', data='series', order=order_no)\n", "return render_title_template('grid.html', entries=entries, folder=\n 'web.books_list', charlist=charlist, title=_(u'Series'), page=\n 'serieslist', data='series', bodyClass='grid-view', order=order_no)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Return'" ]
[ "@login_required...\n", "VAR_11 = TopicPrivate.objects.for_delete_or_404(VAR_5, VAR_1.user)\n", "if VAR_1.method == 'POST':\n", "VAR_11.delete()\n", "return render(VAR_1=request, template_name=\n 'spirit/topic/private/delete.html', context={'topic_private':\n topic_private})\n", "if VAR_1.user.pk == VAR_11.user_id:\n", "return redirect(reverse('spirit:topic:private:index'))\n", "return redirect(VAR_1.POST.get('next', VAR_11.get_absolute_url()))\n" ]
[ "@login_required...\n", "topic_private = TopicPrivate.objects.for_delete_or_404(pk, request.user)\n", "if request.method == 'POST':\n", "topic_private.delete()\n", "return render(request=request, template_name=\n 'spirit/topic/private/delete.html', context={'topic_private':\n topic_private})\n", "if request.user.pk == topic_private.user_id:\n", "return redirect(reverse('spirit:topic:private:index'))\n", "return redirect(request.POST.get('next', topic_private.get_absolute_url()))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 4 ]
[ "Condition", "Assign'", "Condition", "Expr'", "Return'", "Condition", "Return'", "Return'" ]
[ "def __getattr__(self, VAR_12):...\n", "if VAR_12 == '__name__':\n", "return self.__class__.__name__\n", "return super(CLASS_2, self).getattr(VAR_12)\n" ]
[ "def __getattr__(self, name):...\n", "if name == '__name__':\n", "return self.__class__.__name__\n", "return super(login_required, self).getattr(name)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_18(self, VAR_6=None, VAR_7=None, VAR_8=None, VAR_9=False, VAR_10=False...\n", "if self.report_type in ('Query Report', 'Script Report', 'Custom Report'):\n", "VAR_13, VAR_15 = self.run_query_report(VAR_6, VAR_8, VAR_10)\n", "VAR_13, VAR_15 = self.run_standard_report(VAR_6, VAR_7, VAR_8)\n", "if VAR_9:\n", "VAR_15 = self.build_data_dict(VAR_15, VAR_13)\n", "return VAR_13, VAR_15\n" ]
[ "def get_data(self, filters=None, limit=None, user=None, as_dict=False,...\n", "if self.report_type in ('Query Report', 'Script Report', 'Custom Report'):\n", "columns, result = self.run_query_report(filters, user, ignore_prepared_report)\n", "columns, result = self.run_standard_report(filters, limit, user)\n", "if as_dict:\n", "result = self.build_data_dict(result, columns)\n", "return columns, result\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Return'" ]
[ "@Document.whitelist...\n", "self.db_set('disabled', cint(VAR_16))\n" ]
[ "@Document.whitelist...\n", "self.db_set('disabled', cint(disable))\n" ]
[ 0, 0 ]
[ "Condition", "Expr'" ]
[ "@staticmethod...\n", "VAR_24 = '.tar.gz' if VAR_8 else ''\n", "return f'{VAR_3}{VAR_24}'\n" ]
[ "@staticmethod...\n", "ext = '.tar.gz' if include_extension else ''\n", "return f'{model_name}{ext}'\n" ]
[ 0, 0, 0 ]
[ "Condition", "Assign'", "Return'" ]
[ "def FUNC_17(self, VAR_6, VAR_8='', VAR_7=None):...\n", "VAR_9, VAR_15 = self.make_request('GET', self.profile_url + VAR_8, VAR_7=\n access_token)\n", "self.assertEqual(VAR_15.code, VAR_6, VAR_15.result)\n" ]
[ "def request_profile(self, expected_code, url_suffix='', access_token=None):...\n", "request, channel = self.make_request('GET', self.profile_url + url_suffix,\n access_token=access_token)\n", "self.assertEqual(channel.code, expected_code, channel.result)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_62(self, VAR_9):...\n", "return {'username': VAR_9.username, 'password': VAR_9.password, 'email':\n VAR_9.email, 'is_active': VAR_9.is_active, 'is_staff': VAR_9.is_staff,\n 'is_superuser': VAR_9.is_superuser, 'last_login_0': VAR_9.last_login.\n strftime('%Y-%m-%d'), 'last_login_1': VAR_9.last_login.strftime(\n '%H:%M:%S'), 'initial-last_login_0': VAR_9.last_login.strftime(\n '%Y-%m-%d'), 'initial-last_login_1': VAR_9.last_login.strftime(\n '%H:%M:%S'), 'date_joined_0': VAR_9.date_joined.strftime('%Y-%m-%d'),\n 'date_joined_1': VAR_9.date_joined.strftime('%H:%M:%S'),\n 'initial-date_joined_0': VAR_9.date_joined.strftime('%Y-%m-%d'),\n 'initial-date_joined_1': VAR_9.date_joined.strftime('%H:%M:%S'),\n 'first_name': VAR_9.first_name, 'last_name': VAR_9.last_name}\n" ]
[ "def get_user_data(self, user):...\n", "return {'username': user.username, 'password': user.password, 'email': user\n .email, 'is_active': user.is_active, 'is_staff': user.is_staff,\n 'is_superuser': user.is_superuser, 'last_login_0': user.last_login.\n strftime('%Y-%m-%d'), 'last_login_1': user.last_login.strftime(\n '%H:%M:%S'), 'initial-last_login_0': user.last_login.strftime(\n '%Y-%m-%d'), 'initial-last_login_1': user.last_login.strftime(\n '%H:%M:%S'), 'date_joined_0': user.date_joined.strftime('%Y-%m-%d'),\n 'date_joined_1': user.date_joined.strftime('%H:%M:%S'),\n 'initial-date_joined_0': user.date_joined.strftime('%Y-%m-%d'),\n 'initial-date_joined_1': user.date_joined.strftime('%H:%M:%S'),\n 'first_name': user.first_name, 'last_name': user.last_name}\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_5(VAR_0, VAR_1: FlaskClient):...\n", "VAR_5 = VAR_1.get('/dataobj/1')\n", "assert VAR_5.status_code == 302\n" ]
[ "def test_get_dataobj_not_found(test_app, client: FlaskClient):...\n", "response = client.get('/dataobj/1')\n", "assert response.status_code == 302\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assert'" ]
[ "def FUNC_3(self):...\n", "\"\"\"docstring\"\"\"\n", "for higher_quota in self.high_quota_specs:\n", "if re.match(higher_quota, self.spec, re.IGNORECASE):\n", "return False\n", "return True\n" ]
[ "def has_higher_quota(self):...\n", "\"\"\"docstring\"\"\"\n", "for higher_quota in self.high_quota_specs:\n", "if re.match(higher_quota, self.spec, re.IGNORECASE):\n", "return False\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "For", "Condition", "Return'", "Return'" ]
[ "from twisted.internet import defer\n", "from synapse.api.errors import NotFoundError\n", "from synapse.rest.client.v1 import room\n", "from tests.unittest import HomeserverTestCase\n", "VAR_0 = '@red:server'\n", "VAR_1 = [room.register_servlets]\n", "def FUNC_0(self, VAR_2, VAR_3):...\n", "VAR_4 = self.setup_test_homeserver('server', http_client=None)\n", "return VAR_4\n" ]
[ "from twisted.internet import defer\n", "from synapse.api.errors import NotFoundError\n", "from synapse.rest.client.v1 import room\n", "from tests.unittest import HomeserverTestCase\n", "user_id = '@red:server'\n", "servlets = [room.register_servlets]\n", "def make_homeserver(self, reactor, clock):...\n", "hs = self.setup_test_homeserver('server', http_client=None)\n", "return hs\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 4, 0 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_12(self, VAR_19, VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "if settings.PUBLIC_ENABLED:\n", "if not hasattr(settings, 'PUBLIC_USER'):\n", "return False\n", "VAR_0.warn(\n 'OMERO.webpublic enabled but public user (omero.web.public.user) not set, disabling OMERO.webpublic.'\n )\n", "if not hasattr(settings, 'PUBLIC_PASSWORD'):\n", "settings.PUBLIC_ENABLED = False\n", "VAR_0.warn('string')\n", "if settings.PUBLIC_GET_ONLY and VAR_2.method != 'GET':\n", "return False\n", "settings.PUBLIC_ENABLED = False\n", "return False\n", "if self.allowPublic is None:\n", "return False\n", "return settings.PUBLIC_URL_FILTER.search(VAR_2.path) is not None\n", "return self.allowPublic\n" ]
[ "def is_valid_public_url(self, server_id, request):...\n", "\"\"\"docstring\"\"\"\n", "if settings.PUBLIC_ENABLED:\n", "if not hasattr(settings, 'PUBLIC_USER'):\n", "return False\n", "logger.warn(\n 'OMERO.webpublic enabled but public user (omero.web.public.user) not set, disabling OMERO.webpublic.'\n )\n", "if not hasattr(settings, 'PUBLIC_PASSWORD'):\n", "settings.PUBLIC_ENABLED = False\n", "logger.warn(\n 'OMERO.webpublic enabled but public user password (omero.web.public.password) not set, disabling OMERO.webpublic.'\n )\n", "if settings.PUBLIC_GET_ONLY and request.method != 'GET':\n", "return False\n", "settings.PUBLIC_ENABLED = False\n", "return False\n", "if self.allowPublic is None:\n", "return False\n", "return settings.PUBLIC_URL_FILTER.search(request.path) is not None\n", "return self.allowPublic\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Condition", "Return'", "Expr'", "Condition", "Assign'", "Expr'", "Condition", "Return'", "Assign'", "Return'", "Condition", "Return'", "Return'", "Return'" ]
[ "def FUNC_71(VAR_43, VAR_126=False):...\n", "\"\"\"docstring\"\"\"\n", "if isinstance(VAR_43, text_type):\n", "VAR_43 = VAR_43.encode('utf-8')\n", "if os.path.exists(VAR_43):\n", "return FUNC_1(f.read())\n", "if VAR_126:\n", "return None\n" ]
[ "def read_file(path, raise_not_found=False):...\n", "\"\"\"docstring\"\"\"\n", "if isinstance(path, text_type):\n", "path = path.encode('utf-8')\n", "if os.path.exists(path):\n", "return as_unicode(f.read())\n", "if raise_not_found:\n", "return None\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Return'", "Condition", "Return'" ]
[ "def FUNC_8():...\n", "\"\"\"docstring\"\"\"\n", "session.authorized = None\n", "if MULTI_USER_MODE:\n", "redirect(URL('user/logout'))\n", "redirect(URL('index'))\n" ]
[ "def logout():...\n", "\"\"\"docstring\"\"\"\n", "session.authorized = None\n", "if MULTI_USER_MODE:\n", "redirect(URL('user/logout'))\n", "redirect(URL('index'))\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Expr'", "Expr'" ]
[ "@pytest.mark.linux...\n", "\"\"\"docstring\"\"\"\n", "VAR_11 = ['--temp-basedir'] + FUNC_0(VAR_4.config)\n", "VAR_6.start(VAR_11, VAR_16={'LC_ALL': 'C'})\n", "VAR_6.set_setting('downloads.location.directory', str(VAR_2))\n", "VAR_6.set_setting('downloads.location.prompt', 'false')\n", "VAR_7 = 'http://localhost:{port}/data/downloads/ä-issue908.bin'.format(VAR_24\n =server.port)\n", "VAR_6.send_cmd(':download {}'.format(VAR_7))\n", "VAR_6.wait_for(category='downloads', message='Download ?-issue908.bin finished'\n )\n", "VAR_6.set_setting('downloads.location.prompt', 'true')\n", "VAR_6.send_cmd(':download {}'.format(VAR_7))\n", "VAR_6.send_cmd(':prompt-open-download \"{}\" -c pass'.format(sys.executable))\n", "VAR_6.wait_for(category='downloads', message='Download ä-issue908.bin finished'\n )\n", "VAR_6.wait_for(category='misc', message='Opening * with [*python*]')\n", "assert len(VAR_2.listdir()) == 1\n", "assert (VAR_2 / '?-issue908.bin').exists()\n" ]
[ "@pytest.mark.linux...\n", "\"\"\"docstring\"\"\"\n", "args = ['--temp-basedir'] + _base_args(request.config)\n", "quteproc_new.start(args, env={'LC_ALL': 'C'})\n", "quteproc_new.set_setting('downloads.location.directory', str(tmpdir))\n", "quteproc_new.set_setting('downloads.location.prompt', 'false')\n", "url = 'http://localhost:{port}/data/downloads/ä-issue908.bin'.format(port=\n server.port)\n", "quteproc_new.send_cmd(':download {}'.format(url))\n", "quteproc_new.wait_for(category='downloads', message=\n 'Download ?-issue908.bin finished')\n", "quteproc_new.set_setting('downloads.location.prompt', 'true')\n", "quteproc_new.send_cmd(':download {}'.format(url))\n", "quteproc_new.send_cmd(':prompt-open-download \"{}\" -c pass'.format(sys.\n executable))\n", "quteproc_new.wait_for(category='downloads', message=\n 'Download ä-issue908.bin finished')\n", "quteproc_new.wait_for(category='misc', message='Opening * with [*python*]')\n", "assert len(tmpdir.listdir()) == 1\n", "assert (tmpdir / '?-issue908.bin').exists()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assert'", "Assert'" ]
[ "def FUNC_6():...\n", "yield '<!-- CLICK_WEB START HEADER -->'\n", "yield '<div class=\"command-line\">Executing: {}</div>'.format('/'.join(VAR_4))\n", "yield '<!-- CLICK_WEB END HEADER -->'\n" ]
[ "def generate():...\n", "yield '<!-- CLICK_WEB START HEADER -->'\n", "yield '<div class=\"command-line\">Executing: {}</div>'.format('/'.join(commands)\n )\n", "yield '<!-- CLICK_WEB END HEADER -->'\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_0(self, VAR_0, VAR_1):...\n", "self.http_client = Mock()\n", "return self.setup_test_homeserver(http_client=self.http_client)\n" ]
[ "def make_homeserver(self, reactor, clock):...\n", "self.http_client = Mock()\n", "return self.setup_test_homeserver(http_client=self.http_client)\n" ]
[ 0, 0, 4 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_33(self):...\n", "if frappe.flags.in_import:\n", "return\n", "VAR_60 = frappe.new_doc(self.doctype, as_dict=True)\n", "self.update_if_missing(VAR_60)\n", "for VAR_19 in self.meta.get_table_fields():\n", "VAR_60 = frappe.new_doc(VAR_19.options, as_dict=True)\n", "VAR_26 = self.get(VAR_19.fieldname)\n", "if isinstance(VAR_26, list):\n", "for VAR_21 in VAR_26:\n", "VAR_21.update_if_missing(VAR_60)\n" ]
[ "def _set_defaults(self):...\n", "if frappe.flags.in_import:\n", "return\n", "new_doc = frappe.new_doc(self.doctype, as_dict=True)\n", "self.update_if_missing(new_doc)\n", "for df in self.meta.get_table_fields():\n", "new_doc = frappe.new_doc(df.options, as_dict=True)\n", "value = self.get(df.fieldname)\n", "if isinstance(value, list):\n", "for d in value:\n", "d.update_if_missing(new_doc)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "Expr'", "For", "Assign'", "Assign'", "Condition", "For", "Expr'" ]
[ "def __init__(self, VAR_4: 'HomeServer'):...\n", "super().__init__(VAR_4)\n", "self.hs = VAR_4\n", "self.store = VAR_4.get_datastore()\n", "self.storage = VAR_4.get_storage()\n", "self.state_store = self.storage.state\n", "self.federation_client = VAR_4.get_federation_client()\n", "self.state_handler = VAR_4.get_state_handler()\n", "self._state_resolution_handler = VAR_4.get_state_resolution_handler()\n", "self.server_name = VAR_4.hostname\n", "self.keyring = VAR_4.get_keyring()\n", "self.action_generator = VAR_4.get_action_generator()\n", "self.is_mine_id = VAR_4.is_mine_id\n", "self.spam_checker = VAR_4.get_spam_checker()\n", "self.event_creation_handler = VAR_4.get_event_creation_handler()\n", "self._message_handler = VAR_4.get_message_handler()\n", "self._server_notices_mxid = VAR_4.config.server_notices_mxid\n", "self.config = VAR_4.config\n", "self.http_client = VAR_4.get_simple_http_client()\n", "self._instance_name = VAR_4.get_instance_name()\n", "self._replication = VAR_4.get_replication_data_handler()\n", "self._send_events = ReplicationFederationSendEventsRestServlet.make_client(\n VAR_4)\n", "self._clean_room_for_join_client = ReplicationCleanRoomRestServlet.make_client(\n VAR_4)\n", "if VAR_4.config.worker_app:\n", "self._user_device_resync = ReplicationUserDevicesResyncRestServlet.make_client(\n VAR_4)\n", "self._device_list_updater = VAR_4.get_device_handler().device_list_updater\n", "self._maybe_store_room_on_outlier_membership = (\n ReplicationStoreRoomOnOutlierMembershipRestServlet.make_client(VAR_4))\n", "self._maybe_store_room_on_outlier_membership = (self.store.\n maybe_store_room_on_outlier_membership)\n", "self.room_queues = {}\n", "self._room_pdu_linearizer = Linearizer('fed_room_pdu')\n", "self.third_party_event_rules = VAR_4.get_third_party_event_rules()\n", "self._ephemeral_messages_enabled = VAR_4.config.enable_ephemeral_messages\n" ]
[ "def __init__(self, hs: 'HomeServer'):...\n", "super().__init__(hs)\n", "self.hs = hs\n", "self.store = hs.get_datastore()\n", "self.storage = hs.get_storage()\n", "self.state_store = self.storage.state\n", "self.federation_client = hs.get_federation_client()\n", "self.state_handler = hs.get_state_handler()\n", "self._state_resolution_handler = hs.get_state_resolution_handler()\n", "self.server_name = hs.hostname\n", "self.keyring = hs.get_keyring()\n", "self.action_generator = hs.get_action_generator()\n", "self.is_mine_id = hs.is_mine_id\n", "self.spam_checker = hs.get_spam_checker()\n", "self.event_creation_handler = hs.get_event_creation_handler()\n", "self._message_handler = hs.get_message_handler()\n", "self._server_notices_mxid = hs.config.server_notices_mxid\n", "self.config = hs.config\n", "self.http_client = hs.get_simple_http_client()\n", "self._instance_name = hs.get_instance_name()\n", "self._replication = hs.get_replication_data_handler()\n", "self._send_events = ReplicationFederationSendEventsRestServlet.make_client(hs)\n", "self._clean_room_for_join_client = ReplicationCleanRoomRestServlet.make_client(\n hs)\n", "if hs.config.worker_app:\n", "self._user_device_resync = ReplicationUserDevicesResyncRestServlet.make_client(\n hs)\n", "self._device_list_updater = hs.get_device_handler().device_list_updater\n", "self._maybe_store_room_on_outlier_membership = (\n ReplicationStoreRoomOnOutlierMembershipRestServlet.make_client(hs))\n", "self._maybe_store_room_on_outlier_membership = (self.store.\n maybe_store_room_on_outlier_membership)\n", "self.room_queues = {}\n", "self._room_pdu_linearizer = Linearizer('fed_room_pdu')\n", "self.third_party_event_rules = hs.get_third_party_event_rules()\n", "self._ephemeral_messages_enabled = hs.config.enable_ephemeral_messages\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "async def FUNC_5(VAR_7=None, VAR_8=False):...\n", "return {'user': UserID.from_string(self.auth_user_id), 'token_id': 1,\n 'is_guest': False}\n" ]
[ "async def get_user_by_access_token(token=None, allow_guest=False):...\n", "return {'user': UserID.from_string(self.auth_user_id), 'token_id': 1,\n 'is_guest': False}\n" ]
[ 0, 0 ]
[ "AsyncFunctionDef'", "Return'" ]
[ "def FUNC_3(VAR_5, VAR_6=None):...\n", "\"\"\"docstring\"\"\"\n", "VAR_5 = int(VAR_5)\n", "VAR_22 = objreg.get('web-history')\n", "if VAR_6 is not None:\n", "VAR_34 = VAR_22.entries_before(VAR_5, limit=1000, VAR_6=offset)\n", "VAR_35 = VAR_5 - 24 * 60 * 60\n", "return [{'url': e.url, 'title': html.escape(e.title) or html.escape(e.url),\n 'time': e.atime} for e in VAR_34]\n", "VAR_34 = VAR_22.entries_between(VAR_35, VAR_5)\n" ]
[ "def history_data(start_time, offset=None):...\n", "\"\"\"docstring\"\"\"\n", "start_time = int(start_time)\n", "hist = objreg.get('web-history')\n", "if offset is not None:\n", "entries = hist.entries_before(start_time, limit=1000, offset=offset)\n", "end_time = start_time - 24 * 60 * 60\n", "return [{'url': e.url, 'title': html.escape(e.title) or html.escape(e.url),\n 'time': e.atime} for e in entries]\n", "entries = hist.entries_between(end_time, start_time)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Return'", "Assign'" ]
[ "def FUNC_30(self):...\n", "VAR_5 = self._makeContext()\n", "self.assertIs(VAR_5.evaluate('nocall: list'), list)\n" ]
[ "def test_list_in_path_expr(self):...\n", "ec = self._makeContext()\n", "self.assertIs(ec.evaluate('nocall: list'), list)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_134(self):...\n", "if isinstance(self.settings.render, basestring):\n", "VAR_391 = getattr(self, '%s_render' % self.settings.render)\n", "if callable(self.settings.render):\n", "return VAR_391\n", "VAR_391 = self.settings.render\n", "if isinstance(self.settings.render, dict):\n", "def FUNC_174(VAR_212):...\n", "if VAR_212.render:\n", "if VAR_212.render in self.settings.render.keys():\n", "VAR_472 = self.markmin_render\n", "VAR_472 = self.settings.render[VAR_212.render]\n", "VAR_472 = getattr(self, '%s_render' % VAR_212.render)\n", "return VAR_472(VAR_212)\n" ]
[ "def get_renderer(self):...\n", "if isinstance(self.settings.render, basestring):\n", "r = getattr(self, '%s_render' % self.settings.render)\n", "if callable(self.settings.render):\n", "return r\n", "r = self.settings.render\n", "if isinstance(self.settings.render, dict):\n", "def custom_render(page):...\n", "if page.render:\n", "if page.render in self.settings.render.keys():\n", "my_render = self.markmin_render\n", "my_render = self.settings.render[page.render]\n", "my_render = getattr(self, '%s_render' % page.render)\n", "return my_render(page)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Condition", "Return'", "Assign'", "Condition", "FunctionDef'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "@ensure_csrf_cookie...\n", "\"\"\"docstring\"\"\"\n", "VAR_10 = SlashSeparatedCourseKey.from_deprecated_string(VAR_10)\n", "VAR_68 = [('id', 'Order Id'), ('company_name', 'Company Name'), (\n 'company_contact_name', 'Company Contact Name'), (\n 'company_contact_email', 'Company Contact Email'), (\n 'logged_in_username', 'Login Username'), ('logged_in_email',\n 'Login User Email'), ('purchase_time', 'Date of Sale'), (\n 'customer_reference_number', 'Customer Reference Number'), (\n 'recipient_name', 'Recipient Name'), ('recipient_email',\n 'Recipient Email'), ('bill_to_street1', 'Street 1'), ('bill_to_street2',\n 'Street 2'), ('bill_to_city', 'City'), ('bill_to_state', 'State'), (\n 'bill_to_postalcode', 'Postal Code'), ('bill_to_country', 'Country'), (\n 'order_type', 'Order Type'), ('status', 'Order Item Status'), (\n 'coupon_code', 'Coupon Code'), ('list_price', 'List Price'), (\n 'unit_cost', 'Unit Price'), ('quantity', 'Quantity'), ('total_discount',\n 'Total Discount'), ('total_amount', 'Total Amount Paid')]\n", "VAR_70 = [x[0] for x in VAR_68]\n", "VAR_71 = [x[1] for x in VAR_68]\n", "VAR_69 = instructor_analytics.basic.sale_order_record_features(VAR_10, VAR_70)\n", "VAR_72, VAR_73 = instructor_analytics.csvs.format_dictlist(VAR_69, VAR_70)\n", "return instructor_analytics.csvs.create_csv_response(\n 'e-commerce_sale_order_records.csv', VAR_71, VAR_73)\n" ]
[ "@ensure_csrf_cookie...\n", "\"\"\"docstring\"\"\"\n", "course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n", "query_features = [('id', 'Order Id'), ('company_name', 'Company Name'), (\n 'company_contact_name', 'Company Contact Name'), (\n 'company_contact_email', 'Company Contact Email'), (\n 'logged_in_username', 'Login Username'), ('logged_in_email',\n 'Login User Email'), ('purchase_time', 'Date of Sale'), (\n 'customer_reference_number', 'Customer Reference Number'), (\n 'recipient_name', 'Recipient Name'), ('recipient_email',\n 'Recipient Email'), ('bill_to_street1', 'Street 1'), ('bill_to_street2',\n 'Street 2'), ('bill_to_city', 'City'), ('bill_to_state', 'State'), (\n 'bill_to_postalcode', 'Postal Code'), ('bill_to_country', 'Country'), (\n 'order_type', 'Order Type'), ('status', 'Order Item Status'), (\n 'coupon_code', 'Coupon Code'), ('list_price', 'List Price'), (\n 'unit_cost', 'Unit Price'), ('quantity', 'Quantity'), ('total_discount',\n 'Total Discount'), ('total_amount', 'Total Amount Paid')]\n", "db_columns = [x[0] for x in query_features]\n", "csv_columns = [x[1] for x in query_features]\n", "sale_data = instructor_analytics.basic.sale_order_record_features(course_id,\n db_columns)\n", "__, datarows = instructor_analytics.csvs.format_dictlist(sale_data, db_columns)\n", "return instructor_analytics.csvs.create_csv_response(\n 'e-commerce_sale_order_records.csv', csv_columns, datarows)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "import re\n", "import secrets\n", "from typing import Any, Dict, Optional, Tuple\n", "from urllib.parse import urlparse\n", "from django.conf import settings\n", "from django.http import HttpRequest, JsonResponse\n", "from django.views.decorators.csrf import csrf_exempt\n", "from rest_framework import status\n", "from sentry_sdk import capture_exception\n", "from statshog.defaults.django import statsd\n", "from posthog.api.utils import get_token\n", "from posthog.exceptions import RequestParsingError, generate_exception_response\n", "from posthog.models import Team, User\n", "from posthog.models.feature_flag import get_overridden_feature_flags\n", "from posthog.utils import cors_response, load_data_from_request\n", "from .utils import get_project_id\n", "def FUNC_0(VAR_0: Team, VAR_1: HttpRequest) ->bool:...\n", "VAR_3 = ['127.0.0.1', 'localhost']\n", "for VAR_2 in VAR_0.app_urls:\n", "VAR_7 = FUNC_2(VAR_2)\n", "VAR_4 = FUNC_2(VAR_1.headers.get('Origin'))\n", "if VAR_7:\n", "VAR_5 = FUNC_2(VAR_1.headers.get('Referer'))\n", "VAR_3.append(VAR_7)\n", "for permitted_domain in VAR_3:\n", "if '*' in permitted_domain:\n", "return False\n", "VAR_12 = '^{}$'.format(permitted_domain.replace('.', '\\\\.').replace('*',\n '(.*)'))\n", "if permitted_domain == VAR_4 or permitted_domain == VAR_5:\n", "if VAR_4 and re.search(VAR_12, VAR_4) or VAR_5 and re.search(VAR_12, VAR_5):\n", "return True\n", "return True\n" ]
[ "import re\n", "import secrets\n", "from typing import Any, Dict, Optional, Tuple\n", "from urllib.parse import urlparse\n", "from django.conf import settings\n", "from django.http import HttpRequest, JsonResponse\n", "from django.views.decorators.csrf import csrf_exempt\n", "from rest_framework import status\n", "from sentry_sdk import capture_exception\n", "from statshog.defaults.django import statsd\n", "from posthog.api.utils import get_token\n", "from posthog.exceptions import RequestParsingError, generate_exception_response\n", "from posthog.models import Team, User\n", "from posthog.models.feature_flag import get_overridden_feature_flags\n", "from posthog.utils import cors_response, load_data_from_request\n", "from .utils import get_project_id\n", "def on_permitted_domain(team: Team, request: HttpRequest) ->bool:...\n", "permitted_domains = ['127.0.0.1', 'localhost']\n", "for url in team.app_urls:\n", "hostname = parse_domain(url)\n", "origin = parse_domain(request.headers.get('Origin'))\n", "if hostname:\n", "referer = parse_domain(request.headers.get('Referer'))\n", "permitted_domains.append(hostname)\n", "for permitted_domain in permitted_domains:\n", "if '*' in permitted_domain:\n", "return False\n", "pattern = '^{}$'.format(permitted_domain.replace('.', '\\\\.').replace('*',\n '(.*)'))\n", "if permitted_domain == origin or permitted_domain == referer:\n", "if origin and re.search(pattern, origin) or referer and re.search(pattern,\n", "return True\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 0, 0, 0, 4, 4, 4, 0, 4 ]
[ "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "For", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "For", "Condition", "Return'", "Assign'", "Condition", "Condition", "Return'", "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'" ]
[ "@login_required...\n", "VAR_12 = get_object_or_404(Topic, VAR_5=topic_id, VAR_7=request.user,\n category_id=settings.ST_TOPIC_PRIVATE_CATEGORY_PK)\n", "VAR_14 = TopicPrivateJoinForm(VAR_12=topic, VAR_7=request.user, data=\n post_data(request))\n", "if is_post(VAR_1) and VAR_14.is_valid():\n", "VAR_11 = VAR_14.save()\n", "return render(VAR_1=request, template_name='spirit/topic/private/join.html',\n context={'topic': topic, 'form': form})\n", "notify_access(VAR_7=form.get_user(), VAR_11=topic_private)\n", "return redirect(VAR_1.POST.get('next', VAR_12.get_absolute_url()))\n" ]
[ "@login_required...\n", "topic = get_object_or_404(Topic, pk=topic_id, user=request.user,\n category_id=settings.ST_TOPIC_PRIVATE_CATEGORY_PK)\n", "form = TopicPrivateJoinForm(topic=topic, user=request.user, data=post_data(\n request))\n", "if is_post(request) and form.is_valid():\n", "topic_private = form.save()\n", "return render(request=request, template_name=\n 'spirit/topic/private/join.html', context={'topic': topic, 'form': form})\n", "notify_access(user=form.get_user(), topic_private=topic_private)\n", "return redirect(request.POST.get('next', topic.get_absolute_url()))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 4 ]
[ "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Expr'", "Return'" ]
[ "def FUNC_2(VAR_3: str, VAR_4: int, VAR_5: int, VAR_6: str, VAR_7: str) ->None:...\n", "\"\"\"docstring\"\"\"\n", "VAR_28 = file.readlines()\n", "VAR_28.insert(VAR_4, f'{\\' \\' * VAR_5}{VAR_6}: \"{VAR_7}\"\\n')\n", "file.write(''.join(VAR_28))\n" ]
[ "def insert_metadata_in_file(filename: str, lineno: int, indent: int, key:...\n", "\"\"\"docstring\"\"\"\n", "contents = file.readlines()\n", "contents.insert(lineno, f'{\\' \\' * indent}{key}: \"{value}\"\\n')\n", "file.write(''.join(contents))\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Expr'" ]
[ "def FUNC_10(self, *VAR_0, **VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "return self._save(*VAR_0, **kwargs)\n" ]
[ "def save(self, *args, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "return self._save(*args, **kwargs)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "@property...\n", "return storage.connection.meta.client\n" ]
[ "@property...\n", "return storage.connection.meta.client\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_7(self):...\n", "from openapi_python_client.parser import properties\n", "properties._existing_enums = {'test': 'an enum'}\n", "assert properties.EnumProperty.get_enum('test') == 'an enum'\n", "properties._existing_enums = {}\n" ]
[ "def test_get_enum(self):...\n", "from openapi_python_client.parser import properties\n", "properties._existing_enums = {'test': 'an enum'}\n", "assert properties.EnumProperty.get_enum('test') == 'an enum'\n", "properties._existing_enums = {}\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "Assign'", "Assert'", "Assign'" ]
[ "def FUNC_21(self, VAR_19=None):...\n", "if self.start:\n", "return True\n", "return not self.same_part(VAR_19, self._last_item, self.item)\n" ]
[ "def first(self, name=None):...\n", "if self.start:\n", "return True\n", "return not self.same_part(name, self._last_item, self.item)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_17():...\n", "VAR_180 = []\n", "for msg_out in VAR_1.message_log:\n", "VAR_180.append(json.loads(msg_out))\n", "return VAR_180\n" ]
[ "def get_message_log():...\n", "log = []\n", "for msg_out in local.message_log:\n", "log.append(json.loads(msg_out))\n", "return log\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Expr'", "Return'" ]
[ "@VAR_0.route('/api/plugins', methods=['GET'])...\n", "\"\"\"docstring\"\"\"\n", "VAR_110 = FUNC_58('/internal/plugins', 'get')\n", "return jsonify({'success': False, 'message': str(err)}), 400\n", "return jsonify(VAR_110)\n" ]
[ "@gui.route('/api/plugins', methods=['GET'])...\n", "\"\"\"docstring\"\"\"\n", "plugins_info = query_internal_api('/internal/plugins', 'get')\n", "return jsonify({'success': False, 'message': str(err)}), 400\n", "return jsonify(plugins_info)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Return'", "Return'" ]
[ "@ensure_csrf_cookie...\n", "\"\"\"docstring\"\"\"\n", "VAR_10 = SlashSeparatedCourseKey.from_deprecated_string(VAR_10)\n", "VAR_65 = get_course_with_access(VAR_9.user, 'instructor', VAR_10, depth=None)\n", "VAR_19 = get_student_from_identifier(VAR_9.GET.get('unique_student_identifier')\n )\n", "VAR_63 = {'unique_student_identifier': VAR_9.GET.get(\n 'unique_student_identifier'), 'userDoesNotExist': True}\n", "if not VAR_19.is_active:\n", "return JsonResponse(VAR_63)\n", "VAR_63 = {'unique_student_identifier': VAR_19.username, 'inactiveUser': True}\n", "VAR_64 = VAR_9.GET.get('rolename')\n", "return JsonResponse(VAR_63)\n", "VAR_57 = VAR_9.GET.get('action')\n", "if VAR_64 not in ROLES:\n", "VAR_169 = strip_tags(\"unknown rolename '{}'\".format(VAR_64))\n", "if VAR_64 == 'instructor' and VAR_19 == VAR_9.user and VAR_57 != 'allow':\n", "VAR_0.error(VAR_169)\n", "VAR_63 = {'unique_student_identifier': VAR_19.username, 'rolename': VAR_64,\n 'action': VAR_57, 'removingSelfAsInstructor': True}\n", "if VAR_57 == 'allow':\n", "return HttpResponseBadRequest(VAR_169)\n", "return JsonResponse(VAR_63)\n", "allow_access(VAR_65, VAR_19, VAR_64)\n", "if VAR_57 == 'revoke':\n", "VAR_63 = {'unique_student_identifier': VAR_19.username, 'rolename': VAR_64,\n 'action': VAR_57, 'success': 'yes'}\n", "revoke_access(VAR_65, VAR_19, VAR_64)\n", "return HttpResponseBadRequest(strip_tags(\"unrecognized action '{}'\".format(\n VAR_57)))\n", "return JsonResponse(VAR_63)\n" ]
[ "@ensure_csrf_cookie...\n", "\"\"\"docstring\"\"\"\n", "course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n", "course = get_course_with_access(request.user, 'instructor', course_id,\n depth=None)\n", "user = get_student_from_identifier(request.GET.get('unique_student_identifier')\n )\n", "response_payload = {'unique_student_identifier': request.GET.get(\n 'unique_student_identifier'), 'userDoesNotExist': True}\n", "if not user.is_active:\n", "return JsonResponse(response_payload)\n", "response_payload = {'unique_student_identifier': user.username,\n 'inactiveUser': True}\n", "rolename = request.GET.get('rolename')\n", "return JsonResponse(response_payload)\n", "action = request.GET.get('action')\n", "if rolename not in ROLES:\n", "error = strip_tags(\"unknown rolename '{}'\".format(rolename))\n", "if rolename == 'instructor' and user == request.user and action != 'allow':\n", "log.error(error)\n", "response_payload = {'unique_student_identifier': user.username, 'rolename':\n rolename, 'action': action, 'removingSelfAsInstructor': True}\n", "if action == 'allow':\n", "return HttpResponseBadRequest(error)\n", "return JsonResponse(response_payload)\n", "allow_access(course, user, rolename)\n", "if action == 'revoke':\n", "response_payload = {'unique_student_identifier': user.username, 'rolename':\n rolename, 'action': action, 'success': 'yes'}\n", "revoke_access(course, user, rolename)\n", "return HttpResponseBadRequest(strip_tags(\"unrecognized action '{}'\".format(\n action)))\n", "return JsonResponse(response_payload)\n" ]
[ 0, 0, 0, 0, 3, 3, 0, 0, 0, 3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "Return'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Return'", "Return'", "Expr'", "Condition", "Assign'", "Expr'", "Return'", "Return'" ]
[ "@property...\n", "return reverse('upload')\n" ]
[ "@property...\n", "return reverse('upload')\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "from pathlib import Path\n", "from os.path import sep\n", "from pkg_resources import require\n", "from shutil import which\n", "import frontmatter\n", "from flask import render_template, flash, redirect, request, url_for, send_file, send_from_directory\n", "from flask_login import login_user, current_user, logout_user\n", "from tinydb import Query\n", "from werkzeug.security import check_password_hash, generate_password_hash\n", "from archivy.models import DataObj, User\n", "from archivy import data, app, forms, csrf\n", "from archivy.helpers import get_db, write_config\n", "from archivy.tags import get_all_tags\n", "from archivy.search import search, search_frontmatter_tags\n", "from archivy.config import Config\n", "import re\n", "@app.context_processor...\n", "VAR_3 = data.get_items(load_content=False)\n", "VAR_4 = require('archivy')[0].version\n", "VAR_5 = sep\n", "if VAR_5 == '\\\\':\n", "VAR_5 += '\\\\'\n", "return dict(VAR_3=dataobjs, VAR_5=SEP, VAR_4=version)\n" ]
[ "from pathlib import Path\n", "from os.path import sep\n", "from pkg_resources import require\n", "from shutil import which\n", "import frontmatter\n", "from flask import render_template, flash, redirect, request, url_for, send_file, send_from_directory\n", "from flask_login import login_user, current_user, logout_user\n", "from tinydb import Query\n", "from werkzeug.security import check_password_hash, generate_password_hash\n", "from archivy.models import DataObj, User\n", "from archivy import data, app, forms, csrf\n", "from archivy.helpers import get_db, write_config\n", "from archivy.tags import get_all_tags\n", "from archivy.search import search, search_frontmatter_tags\n", "from archivy.config import Config\n", "import re\n", "@app.context_processor...\n", "dataobjs = data.get_items(load_content=False)\n", "version = require('archivy')[0].version\n", "SEP = sep\n", "if SEP == '\\\\':\n", "SEP += '\\\\'\n", "return dict(dataobjs=dataobjs, SEP=SEP, version=version)\n" ]
[ 0, 0, 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'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "AugAssign'", "Return'" ]
[ "def FUNC_13(VAR_18, VAR_30):...\n", "VAR_82 = {}\n", "for VAR_57, template_collection in VAR_18.items():\n", "VAR_124 = {}\n", "return VAR_82\n", "for VAR_58, template_entry in template_collection['entries'].items():\n", "if VAR_30(VAR_57, VAR_58):\n", "VAR_82[VAR_57] = {'order': list(filter(lambda VAR_136: VAR_136 in VAR_124,\n template_collection['order'])), 'entries': VAR_124}\n", "VAR_124[VAR_58] = template_entry\n" ]
[ "def _filter_templates(templates, template_filter):...\n", "filtered_templates = {}\n", "for template_type, template_collection in templates.items():\n", "filtered_entries = {}\n", "return filtered_templates\n", "for template_key, template_entry in template_collection['entries'].items():\n", "if template_filter(template_type, template_key):\n", "filtered_templates[template_type] = {'order': list(filter(lambda x: x in\n filtered_entries, template_collection['order'])), 'entries':\n filtered_entries}\n", "filtered_entries[template_key] = template_entry\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Assign'", "Return'", "For", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_21(self):...\n", "assert join('/', '/foo', '/', '/bar') == '/foo/bar'\n" ]
[ "def test_it_strips_neighboring_slashes(self):...\n", "assert join('/', '/foo', '/', '/bar') == '/foo/bar'\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assert'" ]
[ "async def FUNC_5(VAR_6, VAR_7=None, VAR_8=None):...\n", "VAR_0.exception(VAR_8)\n", "return web.json_response({'status': 503, 'message':\n 'Service currently unavailable'}, status=503)\n" ]
[ "async def handle_500(request, response=None, error=None):...\n", "logger.exception(error)\n", "return web.json_response({'status': 503, 'message':\n 'Service currently unavailable'}, status=503)\n" ]
[ 0, 0, 0 ]
[ "AsyncFunctionDef'", "Expr'", "Return'" ]
[ "def FUNC_29(self):...\n", "def FUNC_50():...\n", "return 'works'\n" ]
[ "def test_url_params_from_lookup_dict_callable(self):...\n", "def my_callable():...\n", "return 'works'\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Return'" ]
[ "import re\n", "import random\n", "import datetime\n", "from django.utils.translation import ugettext as _\n", "from django.utils.translation import ungettext\n", "def FUNC_0(VAR_0, VAR_1):...\n", "return VAR_0[VAR_1]\n", "return getattr(VAR_0, VAR_1)\n", "def FUNC_1(VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "VAR_19 = enumerate(VAR_2, start=1)\n", "return [('%d) %s' % item) for item in VAR_19]\n" ]
[ "import re\n", "import random\n", "import datetime\n", "from django.utils.translation import ugettext as _\n", "from django.utils.translation import ungettext\n", "def get_from_dict_or_object(source, key):...\n", "return source[key]\n", "return getattr(source, key)\n", "def enumerate_string_list(strings):...\n", "\"\"\"docstring\"\"\"\n", "numbered_strings = enumerate(strings, start=1)\n", "return [('%d) %s' % item) for item in numbered_strings]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Return'", "Return'", "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_1(VAR_0):...\n", "VAR_1 = VAR_0.MagicMock()\n", "VAR_2 = VAR_0.patch('openapi_python_client._get_document', return_value=\n data_dict)\n", "VAR_9 = GeneratorError()\n", "VAR_4 = VAR_0.patch('openapi_python_client.parser.GeneratorData.from_dict',\n return_value=error)\n", "VAR_5 = VAR_0.patch('openapi_python_client.Project')\n", "VAR_6 = VAR_0.MagicMock()\n", "VAR_7 = VAR_0.MagicMock()\n", "from openapi_python_client import _get_project_for_url_or_path\n", "VAR_8 = VAR_10(VAR_6=url, VAR_7=path)\n", "VAR_2.assert_called_once_with(VAR_6=url, VAR_7=path)\n", "VAR_4.assert_called_once_with(VAR_1)\n", "VAR_5.assert_not_called()\n", "assert VAR_8 == VAR_9\n" ]
[ "def test__get_project_for_url_or_path_generator_error(mocker):...\n", "data_dict = mocker.MagicMock()\n", "_get_document = mocker.patch('openapi_python_client._get_document',\n return_value=data_dict)\n", "error = GeneratorError()\n", "from_dict = mocker.patch('openapi_python_client.parser.GeneratorData.from_dict'\n , return_value=error)\n", "_Project = mocker.patch('openapi_python_client.Project')\n", "url = mocker.MagicMock()\n", "path = mocker.MagicMock()\n", "from openapi_python_client import _get_project_for_url_or_path\n", "project = _get_project_for_url_or_path(url=url, path=path)\n", "_get_document.assert_called_once_with(url=url, path=path)\n", "from_dict.assert_called_once_with(data_dict)\n", "_Project.assert_not_called()\n", "assert project == error\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "ImportFrom'", "Assign'", "Expr'", "Expr'", "Expr'", "Assert'" ]
[ "@csrf_exempt...\n", "\"\"\"docstring\"\"\"\n", "VAR_156 = 0\n", "VAR_157 = 1\n", "VAR_158 = ['data_format_error', 'user_not_exist',\n 'user_already_white_listed', 'user_not_enrolled']\n", "VAR_38 = CourseKey.from_string(VAR_10)\n", "VAR_125, VAR_50, VAR_159 = [], [], []\n", "VAR_49 = {VAR_160: [] for VAR_160 in VAR_158}\n", "def FUNC_87(VAR_160, VAR_161, VAR_162):...\n", "\"\"\"docstring\"\"\"\n", "VAR_49[VAR_160].append(_('user \"{user}\" in row# {row}').format(VAR_19=_user,\n row=row_count))\n", "if 'students_list' in VAR_9.FILES:\n", "VAR_50.append(_('File is not attached.'))\n", "VAR_194 = VAR_9.FILES.get('students_list')\n", "VAR_50.append(_('Could not read uploaded file.'))\n", "VAR_194.close()\n", "VAR_166 = 0\n", "VAR_51 = {'general_errors': VAR_50, 'row_errors': VAR_49, 'success': VAR_159}\n", "if VAR_194.name.endswith('.csv'):\n", "for VAR_40 in VAR_125:\n", "return JsonResponse(VAR_51)\n", "VAR_125 = [row for row in VAR_26.reader(VAR_194.read().splitlines())]\n", "VAR_50.append(_(\n 'Make sure that the file you upload is in CSV format with no extraneous characters or rows.'\n ))\n", "VAR_166 += 1\n", "if len(VAR_40) != 2:\n", "if len(VAR_40) > 0:\n", "VAR_19 = VAR_40[VAR_156]\n", "FUNC_87('data_format_error', VAR_40[VAR_156], VAR_166)\n", "VAR_19 = get_user_by_username_or_email(VAR_19)\n", "FUNC_87('user_not_exist', VAR_19, VAR_166)\n", "if len(CertificateWhitelist.get_certificate_white_list(VAR_38, VAR_19)) > 0:\n", "VAR_0.info(u'invalid data/format in csv row# %s', VAR_166)\n", "VAR_0.info(u'student %s does not exist', VAR_19)\n", "FUNC_87('user_already_white_listed', VAR_19, VAR_166)\n", "if not CourseEnrollment.is_enrolled(VAR_19, VAR_38):\n", "VAR_0.warning(u'student %s already exist.', VAR_19.username)\n", "FUNC_87('user_not_enrolled', VAR_19, VAR_166)\n", "CertificateWhitelist.objects.create(VAR_19=user, VAR_10=course_key,\n whitelist=True, notes=student[notes_index])\n", "VAR_0.warning(u'student %s is not enrolled in course.', VAR_19.username)\n", "VAR_159.append(_('user \"{username}\" in row# {row}').format(VAR_15=user.\n username, row=row_num))\n" ]
[ "@csrf_exempt...\n", "\"\"\"docstring\"\"\"\n", "user_index = 0\n", "notes_index = 1\n", "row_errors_key = ['data_format_error', 'user_not_exist',\n 'user_already_white_listed', 'user_not_enrolled']\n", "course_key = CourseKey.from_string(course_id)\n", "students, general_errors, success = [], [], []\n", "row_errors = {key: [] for key in row_errors_key}\n", "def build_row_errors(key, _user, row_count):...\n", "\"\"\"docstring\"\"\"\n", "row_errors[key].append(_('user \"{user}\" in row# {row}').format(user=_user,\n row=row_count))\n", "if 'students_list' in request.FILES:\n", "general_errors.append(_('File is not attached.'))\n", "upload_file = request.FILES.get('students_list')\n", "general_errors.append(_('Could not read uploaded file.'))\n", "upload_file.close()\n", "row_num = 0\n", "results = {'general_errors': general_errors, 'row_errors': row_errors,\n 'success': success}\n", "if upload_file.name.endswith('.csv'):\n", "for student in students:\n", "return JsonResponse(results)\n", "students = [row for row in csv.reader(upload_file.read().splitlines())]\n", "general_errors.append(_(\n 'Make sure that the file you upload is in CSV format with no extraneous characters or rows.'\n ))\n", "row_num += 1\n", "if len(student) != 2:\n", "if len(student) > 0:\n", "user = student[user_index]\n", "build_row_errors('data_format_error', student[user_index], row_num)\n", "user = get_user_by_username_or_email(user)\n", "build_row_errors('user_not_exist', user, row_num)\n", "if len(CertificateWhitelist.get_certificate_white_list(course_key, user)) > 0:\n", "log.info(u'invalid data/format in csv row# %s', row_num)\n", "log.info(u'student %s does not exist', user)\n", "build_row_errors('user_already_white_listed', user, row_num)\n", "if not CourseEnrollment.is_enrolled(user, course_key):\n", "log.warning(u'student %s already exist.', user.username)\n", "build_row_errors('user_not_enrolled', user, row_num)\n", "CertificateWhitelist.objects.create(user=user, course_id=course_key,\n whitelist=True, notes=student[notes_index])\n", "log.warning(u'student %s is not enrolled in course.', user.username)\n", "success.append(_('user \"{username}\" in row# {row}').format(username=user.\n username, row=row_num))\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 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Docstring", "Expr'", "Condition", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Condition", "For", "Return'", "Assign'", "Expr'", "AugAssign'", "Condition", "Condition", "Assign'", "Expr'", "Assign'", "Expr'", "Condition", "Expr'", "Expr'", "Expr'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_6(self, VAR_6):...\n", "return ''\n" ]
[ "def label_for_value(self, value):...\n", "return ''\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@VAR_2.route('/register', methods=['GET', 'POST'])...\n", "if not config.config_public_reg:\n", "abort(404)\n", "if VAR_87 is not None and VAR_87.is_authenticated:\n", "return redirect(url_for('web.index'))\n", "if not config.get_mail_server_configured():\n", "flash(_(\n u'E-Mail server is not configured, please contact your administrator!'),\n category='error')\n", "if request.method == 'POST':\n", "return render_title_template('register.html', VAR_150=_('Register'), VAR_9=\n 'register')\n", "VAR_55 = request.form.to_dict()\n", "if VAR_0['oauth']:\n", "VAR_114 = VAR_55['email'].strip(\n ) if config.config_register_email else VAR_55.get('name')\n", "register_user_with_oauth()\n", "return render_title_template('register.html', config=config, VAR_150=_(\n 'Register'), VAR_9='register')\n", "if not VAR_114 or not VAR_55.get('email'):\n", "flash(_(u'Please fill out all fields!'), category='error')\n", "VAR_114 = check_username(VAR_114)\n", "flash(str(ex), category='error')\n", "VAR_115 = ub.User()\n", "return render_title_template('register.html', VAR_150=_('Register'), VAR_9=\n 'register')\n", "VAR_137 = check_email(VAR_55['email'])\n", "return render_title_template('register.html', VAR_150=_('Register'), VAR_9=\n 'register')\n", "if check_valid_domain(VAR_137):\n", "VAR_115.name = VAR_114\n", "flash(_(u'Your e-mail is not allowed to register'), category='error')\n", "VAR_115.email = VAR_137\n", "VAR_3.warning('Registering failed for user \"%s\" e-mail address: %s',\n VAR_114, VAR_55['email'])\n", "VAR_138 = generate_random_password()\n", "return render_title_template('register.html', VAR_150=_('Register'), VAR_9=\n 'register')\n", "VAR_115.password = generate_password_hash(VAR_138)\n", "VAR_115.role = config.config_default_role\n", "VAR_115.sidebar_view = config.config_default_show\n", "ub.session.add(VAR_115)\n", "ub.session.rollback()\n", "flash(_(u'Confirmation e-mail was send to your e-mail account.'), category=\n 'success')\n", "ub.session.commit()\n", "flash(_(u'An unknown error occurred. Please try again later.'), category=\n 'error')\n", "return redirect(url_for('web.login'))\n", "if VAR_0['oauth']:\n", "return render_title_template('register.html', VAR_150=_('Register'), VAR_9=\n 'register')\n", "register_user_with_oauth(VAR_115)\n", "send_registration_mail(VAR_55['email'].strip(), VAR_114, VAR_138)\n" ]
[ "@web.route('/register', methods=['GET', 'POST'])...\n", "if not config.config_public_reg:\n", "abort(404)\n", "if current_user is not None and current_user.is_authenticated:\n", "return redirect(url_for('web.index'))\n", "if not config.get_mail_server_configured():\n", "flash(_(\n u'E-Mail server is not configured, please contact your administrator!'),\n category='error')\n", "if request.method == 'POST':\n", "return render_title_template('register.html', title=_('Register'), page=\n 'register')\n", "to_save = request.form.to_dict()\n", "if feature_support['oauth']:\n", "nickname = to_save['email'].strip(\n ) if config.config_register_email else to_save.get('name')\n", "register_user_with_oauth()\n", "return render_title_template('register.html', config=config, title=_(\n 'Register'), page='register')\n", "if not nickname or not to_save.get('email'):\n", "flash(_(u'Please fill out all fields!'), category='error')\n", "nickname = check_username(nickname)\n", "flash(str(ex), category='error')\n", "content = ub.User()\n", "return render_title_template('register.html', title=_('Register'), page=\n 'register')\n", "email = check_email(to_save['email'])\n", "return render_title_template('register.html', title=_('Register'), page=\n 'register')\n", "if check_valid_domain(email):\n", "content.name = nickname\n", "flash(_(u'Your e-mail is not allowed to register'), category='error')\n", "content.email = email\n", "log.warning('Registering failed for user \"%s\" e-mail address: %s', nickname,\n to_save['email'])\n", "password = generate_random_password()\n", "return render_title_template('register.html', title=_('Register'), page=\n 'register')\n", "content.password = generate_password_hash(password)\n", "content.role = config.config_default_role\n", "content.sidebar_view = config.config_default_show\n", "ub.session.add(content)\n", "ub.session.rollback()\n", "flash(_(u'Confirmation e-mail was send to your e-mail account.'), category=\n 'success')\n", "ub.session.commit()\n", "flash(_(u'An unknown error occurred. Please try again later.'), category=\n 'error')\n", "return redirect(url_for('web.login'))\n", "if feature_support['oauth']:\n", "return render_title_template('register.html', title=_('Register'), page=\n 'register')\n", "register_user_with_oauth(content)\n", "send_registration_mail(to_save['email'].strip(), nickname, password)\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 ]
[ "Condition", "Condition", "Expr'", "Condition", "Return'", "Condition", "Expr'", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Expr'", "Return'", "Condition", "Expr'", "Assign'", "Expr'", "Assign'", "Return'", "Assign'", "Return'", "Condition", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Return'", "Condition", "Return'", "Expr'", "Expr'" ]
[ "def FUNC_10(self):...\n", "VAR_5 = self._makeContext()\n", "self.assertEqual(VAR_5.evaluate('dummy2'), 'dummy')\n" ]
[ "def test_evaluate_with_render_DTML_template(self):...\n", "ec = self._makeContext()\n", "self.assertEqual(ec.evaluate('dummy2'), 'dummy')\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_19(self) ->bool:...\n", "\"\"\"docstring\"\"\"\n", "return any([self.nlg, self.nlu, self.core, self.force_training])\n" ]
[ "def is_training_required(self) ->bool:...\n", "\"\"\"docstring\"\"\"\n", "return any([self.nlg, self.nlu, self.core, self.force_training])\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def __exit__(self, VAR_171, VAR_105, VAR_178):...\n", "FUNC_9()\n" ]
[ "def __exit__(self, type, value, traceback):...\n", "destroy()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "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_10(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_16 = \"\"\"Dear user, \n this is a message \n from,\nsomeone\"\"\"\n", "self.assertEqual(format_value(VAR_16),\n \"\"\"<pre>Dear user, \n this is a message \n from,\nsomeone</pre>\"\"\")\n" ]
[ "def test_format_value_string_newlines(self):...\n", "\"\"\"docstring\"\"\"\n", "text = \"\"\"Dear user, \n this is a message \n from,\nsomeone\"\"\"\n", "self.assertEqual(format_value(text),\n \"\"\"<pre>Dear user, \n this is a message \n from,\nsomeone</pre>\"\"\")\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'" ]
[ "@login_required(setGroupContext=True)...\n", "\"\"\"docstring\"\"\"\n", "VAR_54 = None\n", "VAR_104 = None\n", "if VAR_28 in ('dataset', 'project', 'image', 'screen', 'plate',\n", "VAR_94 = {}\n", "if VAR_28 in ('share', 'sharecomment', 'chat'):\n", "if VAR_28 is not None and int(VAR_29) > 0:\n", "VAR_104 = BaseShare(VAR_5, VAR_29)\n", "VAR_104 = BaseContainer(VAR_5)\n", "VAR_29 = int(VAR_29)\n", "VAR_104 = BaseContainer(VAR_5, **kw)\n", "return handlerInternalError(VAR_2, x)\n", "VAR_22 = None\n", "VAR_94[VAR_345(VAR_28)] = VAR_29\n", "if VAR_27 == 'addnewcontainer':\n", "if not VAR_2.method == 'POST':\n", "if VAR_27 == 'add':\n", "return JsonResponse({'Error': 'Must use POST to create container'}, VAR_313=405\n )\n", "VAR_22 = ContainerForm(VAR_158=request.POST.copy())\n", "VAR_54 = 'webclient/public/share_form.html'\n", "if VAR_27 == 'edit':\n", "if VAR_22.is_valid():\n", "VAR_363 = list(VAR_5.getExperimenters())\n", "if VAR_29 is None:\n", "if VAR_27 == 'save':\n", "VAR_0.debug('Create new in %s: %s' % (VAR_28, VAR_345(VAR_22.cleaned_data)))\n", "VAR_362 = dict()\n", "VAR_363.sort(VAR_310=lambda x: x.getOmeName().lower())\n", "if VAR_28 == 'share' and int(VAR_29) > 0:\n", "if not VAR_2.method == 'POST':\n", "if VAR_27 == 'editname':\n", "VAR_3 = VAR_22.cleaned_data['name']\n", "for e in VAR_22.errors.items():\n", "if VAR_28 == 'share':\n", "VAR_54 = 'webclient/public/share_form.html'\n", "VAR_53['template'] = VAR_54\n", "return HttpResponseRedirect(VAR_350('manage_action_containers', args=[\n 'edit', o_type, o_id]))\n", "if VAR_28 == 'share':\n", "if hasattr(VAR_104, VAR_28) and VAR_29 > 0:\n", "if VAR_27 == 'savename':\n", "VAR_360 = VAR_22.cleaned_data['description']\n", "VAR_362.update({e[0]: unicode(e[1])})\n", "VAR_361 = {'bad': 'true', 'errs': VAR_362}\n", "VAR_404 = VAR_2.GET.getlist('image', VAR_2.POST.getlist('image'))\n", "VAR_54 = 'webclient/public/share_form.html'\n", "VAR_104.getMembers(VAR_29)\n", "return VAR_53\n", "VAR_363 = list(VAR_5.getExperimenters())\n", "return HttpResponseServerError('Object does not exist')\n", "VAR_38 = getattr(VAR_104, VAR_28)\n", "return HttpResponseServerError('Object does not exist')\n", "if not VAR_2.method == 'POST':\n", "if VAR_27 == 'editdescription':\n", "VAR_103 = VAR_22.cleaned_data['owner']\n", "return JsonResponse(VAR_361)\n", "if VAR_2.method == 'GET' and len(VAR_404) == 0:\n", "VAR_53 = {'manager': VAR_104, 'form': VAR_22}\n", "VAR_104.getComments(VAR_29)\n", "VAR_363.sort(VAR_310=lambda x: x.getOmeName().lower())\n", "VAR_54 = 'webclient/ajax_form/container_form_ajax.html'\n", "return HttpResponseRedirect(VAR_350('manage_action_containers', args=[\n 'edit', o_type, o_id]))\n", "if hasattr(VAR_104, VAR_28) and VAR_29 > 0:\n", "if hasattr(VAR_104, VAR_28) and VAR_29 > 0:\n", "if VAR_27 == 'savedescription':\n", "if VAR_28 == 'project' and hasattr(VAR_104, VAR_28) and VAR_29 > 0:\n", "return HttpResponse('No images specified')\n", "VAR_405 = list(VAR_5.getObjects('Image', VAR_404))\n", "VAR_363 = list(VAR_5.getExperimenters())\n", "VAR_22 = ShareForm(VAR_115={'experimenters': experimenters}, VAR_158=\n request.POST.copy())\n", "if VAR_28 == 'tag':\n", "VAR_22 = ContainerNameForm(VAR_158=request.POST.copy())\n", "return HttpResponseServerError('Object does not exist')\n", "VAR_38 = getattr(VAR_104, VAR_28)\n", "return HttpResponseServerError('Object does not exist')\n", "if not VAR_2.method == 'POST':\n", "if VAR_27 == 'remove':\n", "VAR_40 = VAR_104.createDataset(VAR_3, VAR_360, VAR_103=owner)\n", "if VAR_28 == 'tagset' and VAR_29 > 0:\n", "if VAR_2.method == 'POST':\n", "VAR_363.sort(VAR_310=lambda x: x.getOmeName().lower())\n", "if VAR_22.is_valid():\n", "VAR_447 = VAR_38.textValue\n", "VAR_447 = VAR_38.getName()\n", "if VAR_22.is_valid():\n", "VAR_54 = 'webclient/ajax_form/container_form_ajax.html'\n", "return HttpResponseServerError(\n \"Action '%s' on the '%s' id:%s cannot be complited\" % (VAR_27, VAR_28,\n VAR_29))\n", "if hasattr(VAR_104, VAR_28) and VAR_29 > 0:\n", "VAR_82 = VAR_2.POST['parent']\n", "if VAR_27 == 'removefromshare':\n", "VAR_361 = {'bad': 'false', 'id': VAR_40}\n", "VAR_40 = VAR_104.createTag(VAR_3, VAR_360, VAR_103=owner)\n", "if VAR_2.POST.get('folder_type') in ('project', 'screen', 'dataset', 'tag',\n", "VAR_22 = BasketShareForm(VAR_115={'experimenters': experimenters, 'images':\n images_to_share}, VAR_158=request.POST.copy())\n", "VAR_115 = {'experimenters': VAR_363, 'images': VAR_405, 'enable': True,\n 'selected': VAR_2.GET.getlist('image')}\n", "VAR_115 = {'message': VAR_104.share.message, 'expiration': '',\n 'shareMembers': VAR_104.membersInShare, 'enable': VAR_104.share.active,\n 'experimenters': VAR_363}\n", "VAR_0.debug('Update share: %s' % VAR_345(VAR_22.cleaned_data))\n", "VAR_54 = 'webclient/public/share_form.html'\n", "VAR_22 = ContainerNameForm(VAR_115={'name': txtValue})\n", "VAR_0.debug('Update name form:' + VAR_345(VAR_22.cleaned_data))\n", "VAR_362 = dict()\n", "VAR_22 = ContainerDescriptionForm(VAR_115={'description': obj.description})\n", "VAR_22 = ContainerDescriptionForm(VAR_158=request.POST.copy())\n", "return HttpResponseServerError('Object does not exist')\n", "VAR_104.remove(VAR_82.split('|'))\n", "VAR_0.error(traceback.format_exc())\n", "VAR_361 = {'bad': 'false'}\n", "VAR_257 = VAR_2.POST.get('source')\n", "if VAR_27 == 'delete':\n", "return JsonResponse(VAR_361)\n", "VAR_441 = VAR_2.POST.get('folder_type')\n", "return HttpResponseServerError('Object does not exist')\n", "if VAR_22.is_valid():\n", "VAR_22 = BasketShareForm(VAR_115=initial)\n", "if VAR_104.share.getExpireDate() is not None:\n", "VAR_382 = VAR_22.cleaned_data['message']\n", "VAR_53 = {'share': VAR_104, 'form': VAR_22}\n", "VAR_53 = {'manager': VAR_104, 'form': VAR_22}\n", "VAR_3 = VAR_22.cleaned_data['name']\n", "for e in VAR_22.errors.items():\n", "VAR_53 = {'manager': VAR_104, 'form': VAR_22}\n", "if VAR_22.is_valid():\n", "VAR_361 = {'bad': 'true', 'errs': VAR_345(x)}\n", "return JsonResponse(VAR_361)\n", "VAR_104.removeImage(VAR_257)\n", "VAR_0.error(traceback.format_exc())\n", "VAR_361 = {'bad': 'false'}\n", "VAR_457 = toBoolean(VAR_2.POST.get('child'))\n", "if VAR_27 == 'deletemany':\n", "if VAR_441 == 'dataset':\n", "VAR_106 = VAR_22.cleaned_data['image']\n", "VAR_115['expiration'] = VAR_104.share.getExpireDate().strftime('%Y-%m-%d')\n", "VAR_22 = ShareForm(VAR_115=initial)\n", "VAR_442 = VAR_22.cleaned_data['expiration']\n", "VAR_361 = {'bad': 'false', 'o_type': VAR_28}\n", "VAR_362.update({e[0]: unicode(e[1])})\n", "VAR_361 = {'bad': 'true', 'errs': VAR_362}\n", "VAR_0.debug('Update name form:' + VAR_345(VAR_22.cleaned_data))\n", "VAR_362 = dict()\n", "return JsonResponse(VAR_361)\n", "VAR_361 = {'bad': 'true', 'errs': VAR_345(x)}\n", "return JsonResponse(VAR_361)\n", "VAR_91 = toBoolean(VAR_2.POST.get('anns'))\n", "VAR_459 = {'Image': VAR_2.POST.getlist('image'), 'Dataset': VAR_2.POST.\n getlist('dataset'), 'Project': VAR_2.POST.getlist('project'),\n 'Annotation': VAR_2.POST.getlist('tag'), 'Screen': VAR_2.POST.getlist(\n 'screen'), 'Plate': VAR_2.POST.getlist('plate'), 'Well': VAR_2.POST.\n getlist('well'), 'PlateAcquisition': VAR_2.POST.getlist('acquisition')}\n", "VAR_40 = VAR_104.createDataset(VAR_3, VAR_360, VAR_103=owner, VAR_404=\n request.POST.getlist('image', None))\n", "VAR_40 = VAR_5.createContainer(VAR_441, VAR_3, VAR_360, VAR_103=owner)\n", "VAR_382 = VAR_22.cleaned_data['message']\n", "VAR_53 = {'manager': VAR_104, 'form': VAR_22}\n", "VAR_64 = VAR_22.cleaned_data['members']\n", "VAR_104.updateName(VAR_28, VAR_3)\n", "return JsonResponse(VAR_361)\n", "VAR_360 = VAR_22.cleaned_data['description']\n", "for e in VAR_22.errors.items():\n", "return JsonResponse(VAR_361)\n", "VAR_84 = VAR_104.deleteItem(VAR_457, VAR_91)\n", "VAR_0.error('Failed to delete: %r' % {'did': VAR_29, 'dtype': VAR_28},\n exc_info=True)\n", "VAR_361 = {'bad': 'false'}\n", "VAR_457 = toBoolean(VAR_2.POST.get('child'))\n", "VAR_442 = VAR_22.cleaned_data['expiration']\n", "VAR_443 = VAR_22.cleaned_data['enable']\n", "return JsonResponse(VAR_361)\n", "VAR_104.updateDescription(VAR_28, VAR_360)\n", "VAR_362.update({e[0]: unicode(e[1])})\n", "VAR_361 = {'bad': 'true', 'errs': VAR_362}\n", "VAR_2.session['callback'][VAR_345(VAR_84)] = {'job_type': 'delete',\n 'delmany': False, 'did': VAR_29, 'dtype': VAR_28, 'status':\n 'in progress', 'error': 0, 'dreport': _formatReport(VAR_84),\n 'start_time': datetime.datetime.now()}\n", "VAR_361 = {'bad': 'true', 'errs': VAR_345(x)}\n", "return JsonResponse(VAR_361)\n", "VAR_91 = toBoolean(VAR_2.POST.get('anns'))\n", "VAR_64 = VAR_22.cleaned_data['members']\n", "VAR_401 = '%s?server=%i' % (VAR_2.build_absolute_uri(VAR_350(\n 'load_template', args=['public'])), int(VAR_5.server_id))\n", "VAR_361 = {'bad': 'false'}\n", "return JsonResponse(VAR_361)\n", "VAR_2.session.modified = True\n", "VAR_0.debug('Delete many: child? %s anns? %s object_ids %s' % (VAR_457,\n VAR_91, VAR_459))\n", "VAR_443 = VAR_22.cleaned_data['enable']\n", "VAR_104.updateShareOrDiscussion(VAR_401, VAR_382, VAR_64, VAR_443, VAR_442)\n", "return JsonResponse(VAR_361)\n", "for VAR_310, VAR_187 in VAR_459.items():\n", "VAR_0.error('Failed to delete: %r' % {'did': VAR_187, 'dtype': VAR_310},\n exc_info=True)\n", "VAR_361 = {'bad': 'false'}\n", "VAR_401 = '%s?server=%i' % (VAR_2.build_absolute_uri(VAR_350(\n 'load_template', args=['public'])), int(VAR_5.server_id))\n", "VAR_71 = 'enable' if VAR_443 else 'disable'\n", "if VAR_187 is not None and len(VAR_187) > 0:\n", "VAR_2.session.modified = True\n", "return JsonResponse(VAR_361)\n", "VAR_444 = VAR_104.createShare(VAR_401, VAR_106, VAR_382, VAR_64, VAR_443,\n VAR_442)\n", "return HttpResponse(VAR_71)\n", "VAR_84 = VAR_104.deleteObjects(VAR_310, VAR_187, VAR_457, VAR_91)\n", "return HttpResponse('shareId:%s' % VAR_444)\n", "if VAR_310 == 'PlateAcquisition':\n", "VAR_310 = 'Plate Run'\n", "VAR_460 = {'job_type': 'delete', 'start_time': datetime.datetime.now(),\n 'status': 'in progress', 'error': 0, 'dreport': _formatReport(VAR_84),\n 'dtype': VAR_310}\n", "if len(VAR_187) > 1:\n", "VAR_460['delmany'] = len(VAR_187)\n", "VAR_460['delmany'] = False\n", "VAR_460['did'] = VAR_187\n", "VAR_460['did'] = VAR_187[0]\n", "VAR_2.session['callback'][VAR_345(VAR_84)] = VAR_460\n" ]
[ "@login_required(setGroupContext=True)...\n", "\"\"\"docstring\"\"\"\n", "template = None\n", "manager = None\n", "if o_type in ('dataset', 'project', 'image', 'screen', 'plate',\n", "kw = {}\n", "if o_type in ('share', 'sharecomment', 'chat'):\n", "if o_type is not None and int(o_id) > 0:\n", "manager = BaseShare(conn, o_id)\n", "manager = BaseContainer(conn)\n", "o_id = int(o_id)\n", "manager = BaseContainer(conn, **kw)\n", "return handlerInternalError(request, x)\n", "form = None\n", "kw[str(o_type)] = o_id\n", "if action == 'addnewcontainer':\n", "if not request.method == 'POST':\n", "if action == 'add':\n", "return JsonResponse({'Error': 'Must use POST to create container'}, status=405)\n", "form = ContainerForm(data=request.POST.copy())\n", "template = 'webclient/public/share_form.html'\n", "if action == 'edit':\n", "if form.is_valid():\n", "experimenters = list(conn.getExperimenters())\n", "if o_id is None:\n", "if action == 'save':\n", "logger.debug('Create new in %s: %s' % (o_type, str(form.cleaned_data)))\n", "d = dict()\n", "experimenters.sort(key=lambda x: x.getOmeName().lower())\n", "if o_type == 'share' and int(o_id) > 0:\n", "if not request.method == 'POST':\n", "if action == 'editname':\n", "name = form.cleaned_data['name']\n", "for e in form.errors.items():\n", "if o_type == 'share':\n", "template = 'webclient/public/share_form.html'\n", "context['template'] = template\n", "return HttpResponseRedirect(reverse('manage_action_containers', args=[\n 'edit', o_type, o_id]))\n", "if o_type == 'share':\n", "if hasattr(manager, o_type) and o_id > 0:\n", "if action == 'savename':\n", "description = form.cleaned_data['description']\n", "d.update({e[0]: unicode(e[1])})\n", "rdict = {'bad': 'true', 'errs': d}\n", "img_ids = request.GET.getlist('image', request.POST.getlist('image'))\n", "template = 'webclient/public/share_form.html'\n", "manager.getMembers(o_id)\n", "return context\n", "experimenters = list(conn.getExperimenters())\n", "return HttpResponseServerError('Object does not exist')\n", "obj = getattr(manager, o_type)\n", "return HttpResponseServerError('Object does not exist')\n", "if not request.method == 'POST':\n", "if action == 'editdescription':\n", "owner = form.cleaned_data['owner']\n", "return JsonResponse(rdict)\n", "if request.method == 'GET' and len(img_ids) == 0:\n", "context = {'manager': manager, 'form': form}\n", "manager.getComments(o_id)\n", "experimenters.sort(key=lambda x: x.getOmeName().lower())\n", "template = 'webclient/ajax_form/container_form_ajax.html'\n", "return HttpResponseRedirect(reverse('manage_action_containers', args=[\n 'edit', o_type, o_id]))\n", "if hasattr(manager, o_type) and o_id > 0:\n", "if hasattr(manager, o_type) and o_id > 0:\n", "if action == 'savedescription':\n", "if o_type == 'project' and hasattr(manager, o_type) and o_id > 0:\n", "return HttpResponse('No images specified')\n", "images_to_share = list(conn.getObjects('Image', img_ids))\n", "experimenters = list(conn.getExperimenters())\n", "form = ShareForm(initial={'experimenters': experimenters}, data=request.\n POST.copy())\n", "if o_type == 'tag':\n", "form = ContainerNameForm(data=request.POST.copy())\n", "return HttpResponseServerError('Object does not exist')\n", "obj = getattr(manager, o_type)\n", "return HttpResponseServerError('Object does not exist')\n", "if not request.method == 'POST':\n", "if action == 'remove':\n", "oid = manager.createDataset(name, description, owner=owner)\n", "if o_type == 'tagset' and o_id > 0:\n", "if request.method == 'POST':\n", "experimenters.sort(key=lambda x: x.getOmeName().lower())\n", "if form.is_valid():\n", "txtValue = obj.textValue\n", "txtValue = obj.getName()\n", "if form.is_valid():\n", "template = 'webclient/ajax_form/container_form_ajax.html'\n", "return HttpResponseServerError(\n \"Action '%s' on the '%s' id:%s cannot be complited\" % (action, o_type,\n o_id))\n", "if hasattr(manager, o_type) and o_id > 0:\n", "parents = request.POST['parent']\n", "if action == 'removefromshare':\n", "rdict = {'bad': 'false', 'id': oid}\n", "oid = manager.createTag(name, description, owner=owner)\n", "if request.POST.get('folder_type') in ('project', 'screen', 'dataset',\n", "form = BasketShareForm(initial={'experimenters': experimenters, 'images':\n images_to_share}, data=request.POST.copy())\n", "initial = {'experimenters': experimenters, 'images': images_to_share,\n 'enable': True, 'selected': request.GET.getlist('image')}\n", "initial = {'message': manager.share.message, 'expiration': '',\n 'shareMembers': manager.membersInShare, 'enable': manager.share.active,\n 'experimenters': experimenters}\n", "logger.debug('Update share: %s' % str(form.cleaned_data))\n", "template = 'webclient/public/share_form.html'\n", "form = ContainerNameForm(initial={'name': txtValue})\n", "logger.debug('Update name form:' + str(form.cleaned_data))\n", "d = dict()\n", "form = ContainerDescriptionForm(initial={'description': obj.description})\n", "form = ContainerDescriptionForm(data=request.POST.copy())\n", "return HttpResponseServerError('Object does not exist')\n", "manager.remove(parents.split('|'))\n", "logger.error(traceback.format_exc())\n", "rdict = {'bad': 'false'}\n", "image_id = request.POST.get('source')\n", "if action == 'delete':\n", "return JsonResponse(rdict)\n", "folder_type = request.POST.get('folder_type')\n", "return HttpResponseServerError('Object does not exist')\n", "if form.is_valid():\n", "form = BasketShareForm(initial=initial)\n", "if manager.share.getExpireDate() is not None:\n", "message = form.cleaned_data['message']\n", "context = {'share': manager, 'form': form}\n", "context = {'manager': manager, 'form': form}\n", "name = form.cleaned_data['name']\n", "for e in form.errors.items():\n", "context = {'manager': manager, 'form': form}\n", "if form.is_valid():\n", "rdict = {'bad': 'true', 'errs': str(x)}\n", "return JsonResponse(rdict)\n", "manager.removeImage(image_id)\n", "logger.error(traceback.format_exc())\n", "rdict = {'bad': 'false'}\n", "child = toBoolean(request.POST.get('child'))\n", "if action == 'deletemany':\n", "if folder_type == 'dataset':\n", "images = form.cleaned_data['image']\n", "initial['expiration'] = manager.share.getExpireDate().strftime('%Y-%m-%d')\n", "form = ShareForm(initial=initial)\n", "expiration = form.cleaned_data['expiration']\n", "rdict = {'bad': 'false', 'o_type': o_type}\n", "d.update({e[0]: unicode(e[1])})\n", "rdict = {'bad': 'true', 'errs': d}\n", "logger.debug('Update name form:' + str(form.cleaned_data))\n", "d = dict()\n", "return JsonResponse(rdict)\n", "rdict = {'bad': 'true', 'errs': str(x)}\n", "return JsonResponse(rdict)\n", "anns = toBoolean(request.POST.get('anns'))\n", "object_ids = {'Image': request.POST.getlist('image'), 'Dataset': request.\n POST.getlist('dataset'), 'Project': request.POST.getlist('project'),\n 'Annotation': request.POST.getlist('tag'), 'Screen': request.POST.\n getlist('screen'), 'Plate': request.POST.getlist('plate'), 'Well':\n request.POST.getlist('well'), 'PlateAcquisition': request.POST.getlist(\n 'acquisition')}\n", "oid = manager.createDataset(name, description, owner=owner, img_ids=request\n .POST.getlist('image', None))\n", "oid = conn.createContainer(folder_type, name, description, owner=owner)\n", "message = form.cleaned_data['message']\n", "context = {'manager': manager, 'form': form}\n", "members = form.cleaned_data['members']\n", "manager.updateName(o_type, name)\n", "return JsonResponse(rdict)\n", "description = form.cleaned_data['description']\n", "for e in form.errors.items():\n", "return JsonResponse(rdict)\n", "handle = manager.deleteItem(child, anns)\n", "logger.error('Failed to delete: %r' % {'did': o_id, 'dtype': o_type},\n exc_info=True)\n", "rdict = {'bad': 'false'}\n", "child = toBoolean(request.POST.get('child'))\n", "expiration = form.cleaned_data['expiration']\n", "enable = form.cleaned_data['enable']\n", "return JsonResponse(rdict)\n", "manager.updateDescription(o_type, description)\n", "d.update({e[0]: unicode(e[1])})\n", "rdict = {'bad': 'true', 'errs': d}\n", "request.session['callback'][str(handle)] = {'job_type': 'delete', 'delmany':\n False, 'did': o_id, 'dtype': o_type, 'status': 'in progress', 'error': \n 0, 'dreport': _formatReport(handle), 'start_time': datetime.datetime.now()}\n", "rdict = {'bad': 'true', 'errs': str(x)}\n", "return JsonResponse(rdict)\n", "anns = toBoolean(request.POST.get('anns'))\n", "members = form.cleaned_data['members']\n", "host = '%s?server=%i' % (request.build_absolute_uri(reverse('load_template',\n args=['public'])), int(conn.server_id))\n", "rdict = {'bad': 'false'}\n", "return JsonResponse(rdict)\n", "request.session.modified = True\n", "logger.debug('Delete many: child? %s anns? %s object_ids %s' % (child, anns,\n object_ids))\n", "enable = form.cleaned_data['enable']\n", "manager.updateShareOrDiscussion(host, message, members, enable, expiration)\n", "return JsonResponse(rdict)\n", "for key, ids in object_ids.items():\n", "logger.error('Failed to delete: %r' % {'did': ids, 'dtype': key}, exc_info=True\n )\n", "rdict = {'bad': 'false'}\n", "host = '%s?server=%i' % (request.build_absolute_uri(reverse('load_template',\n args=['public'])), int(conn.server_id))\n", "r = 'enable' if enable else 'disable'\n", "if ids is not None and len(ids) > 0:\n", "request.session.modified = True\n", "return JsonResponse(rdict)\n", "shareId = manager.createShare(host, images, message, members, enable,\n expiration)\n", "return HttpResponse(r)\n", "handle = manager.deleteObjects(key, ids, child, anns)\n", "return HttpResponse('shareId:%s' % shareId)\n", "if key == 'PlateAcquisition':\n", "key = 'Plate Run'\n", "dMap = {'job_type': 'delete', 'start_time': datetime.datetime.now(),\n 'status': 'in progress', 'error': 0, 'dreport': _formatReport(handle),\n 'dtype': key}\n", "if len(ids) > 1:\n", "dMap['delmany'] = len(ids)\n", "dMap['delmany'] = False\n", "dMap['did'] = ids\n", "dMap['did'] = ids[0]\n", "request.session['callback'][str(handle)] = dMap\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 4, 0, 0, 4, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 4, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Return'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Expr'", "Condition", "Condition", "Condition", "Assign'", "For", "Condition", "Assign'", "Assign'", "Return'", "Condition", "Condition", "Condition", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Return'", "Assign'", "Return'", "Assign'", "Return'", "Condition", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Expr'", "Expr'", "Assign'", "Return'", "Condition", "Condition", "Condition", "Condition", "Return'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Assign'", "Return'", "Condition", "Condition", "Assign'", "Condition", "Condition", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Return'", "Expr'", "Expr'", "Assign'", "Assign'", "Condition", "Return'", "Assign'", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Condition", "Assign'", "Return'", "Expr'", "Expr'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Return'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Return'", "Assign'", "For", "Return'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Assign'", "Expr'", "Assign'", "Expr'", "Return'", "For", "Expr'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Assign'", "Return'", "Assign'", "Return'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_130(self, VAR_211):...\n", "return DIV(*[A(VAR_445.strip(), _href=URL(args='_search', vars=dict(q=t))) for\n VAR_445 in VAR_211 or [] if VAR_445.strip()], _class='w2p_wiki_tags')\n" ]
[ "def render_tags(self, tags):...\n", "return DIV(*[A(t.strip(), _href=URL(args='_search', vars=dict(q=t))) for t in\n tags or [] if t.strip()], _class='w2p_wiki_tags')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "\"\"\"string\"\"\"\n", "from MoinMoin import config, wikiutil\n", "from MoinMoin.action.AttachFile import _get_files\n", "from MoinMoin.Page import Page\n", "import re\n", "def FUNC_0(VAR_0):...\n", "VAR_2 = FUNC_2(VAR_0)\n", "VAR_0.write('string' % VAR_0.cfg.url_prefix_static)\n", "VAR_3 = []\n", "for macro in FUNC_1(VAR_0):\n", "if macro == 'BR':\n", "VAR_0.write('\\n'.join(VAR_3))\n", "VAR_35 = ' selected=\"selected\"'\n", "VAR_35 = ''\n", "VAR_0.write(\"\"\"\n </select>\n </td>\n <td id=\"help\">\"\"\")\n", "if macro in VAR_2:\n", "VAR_4 = []\n", "VAR_3.append('<option value=\"%s\"%s>%s</option>' % (VAR_2[macro].group(\n 'prototype'), VAR_35, macro))\n", "VAR_3.append('<option value=\"%s\"%s>%s</option>' % (macro, VAR_35, macro))\n", "for macro in FUNC_1(VAR_0):\n", "if macro in VAR_2:\n", "VAR_0.write(''.join(VAR_4))\n", "VAR_29 = VAR_2[macro]\n", "VAR_36 = macro\n", "VAR_0.write(\n \"\"\"\n </td>\n </tr>\n </table>\n </td>\n </tr>\n</table>\n</body>\n</html>\n\"\"\"\n )\n", "VAR_36 = VAR_29.group('prototype')\n", "VAR_37 = ''\n", "def FUNC_1(VAR_0):...\n", "VAR_37 = VAR_29.group('help')\n", "VAR_4.append('string' % (VAR_36, VAR_36, VAR_37))\n", "from MoinMoin import macro\n", "VAR_3 = macro.getNames(VAR_0.cfg)\n", "VAR_3.sort()\n", "return VAR_3\n" ]
[ "\"\"\"\n MoinMoin - feed some FCKeditor dialogues\n\n @copyright: 2005-2006 Bastian Blank, Florian Festi, Thomas Waldmann\n @license: GNU GPL, see COPYING for details.\n\"\"\"\n", "from MoinMoin import config, wikiutil\n", "from MoinMoin.action.AttachFile import _get_files\n", "from MoinMoin.Page import Page\n", "import re\n", "def macro_dialog(request):...\n", "help = get_macro_help(request)\n", "request.write(\n \"\"\"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n<html>\n <head>\n <title>Insert Macro</title>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n <meta content=\"noindex,nofollow\" name=\"robots\">\n <script src=\"%s/applets/FCKeditor/editor/dialog/common/fck_dialog_common.js\" type=\"text/javascript\"></script>\n <script language=\"javascript\">\n\nvar oEditor = window.parent.InnerDialogLoaded() ;\nvar FCKLang = oEditor.FCKLang ;\nvar FCKMacros = oEditor.FCKMacros ;\n\nwindow.onload = function ()\n{\n // First of all, translate the dialog box texts\n oEditor.FCKLanguageManager.TranslatePage( document ) ;\n\n OnChange( \"BR\" );\n\n // Show the \"Ok\" button.\n window.parent.SetOkButton( true ) ;\n}\n\nfunction Ok()\n{\n if ( document.getElementById('txtName').value.length == 0 )\n {\n alert( FCKLang.MacroErrNoName ) ;\n return false ;\n }\n\n FCKMacros.Add( txtName.value ) ;\n return true ;\n}\n\nfunction OnChange( sMacro )\n{\n // sMacro = GetE(\"txtName\").value;\n oHelp = GetE(\"help\");\n for (var i=0; i<oHelp.childNodes.length; i++)\n {\n var oDiv = oHelp.childNodes[i];\n if (oDiv.nodeType==1)\n {\n // oDiv.style.display = (GetAttribute(oDiv, \"id\", \"\")==sMacro) ? '' : 'none';\n if (GetAttribute(oDiv, \"id\", \"\") == sMacro)\n {\n oDiv.style.display = '' ;\n // alert(\"enabled div id \" + sMacro) ;\n }\n else\n {\n oDiv.style.display = 'none' ;\n }\n }\n }\n}\n\n </script>\n </head>\n <body scroll=\"no\" style=\"OVERFLOW: hidden\">\n <table height=\"100%%\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%%\" border=\"0\">\n <tr>\n <td>\n <table cellSpacing=\"0\" cellPadding=\"0\" align=\"center\" border=\"0\">\n <tr>\n <td valign=\"top\">\n <span fckLang=\"MacroDlgName\">Macro Name</span><br>\n <select id=\"txtName\" size=\"10\" onchange=\"OnChange(this.value);\">\n\"\"\"\n % request.cfg.url_prefix_static)\n", "macros = []\n", "for macro in macro_list(request):\n", "if macro == 'BR':\n", "request.write('\\n'.join(macros))\n", "selected = ' selected=\"selected\"'\n", "selected = ''\n", "request.write(\"\"\"\n </select>\n </td>\n <td id=\"help\">\"\"\")\n", "if macro in help:\n", "helptexts = []\n", "macros.append('<option value=\"%s\"%s>%s</option>' % (help[macro].group(\n 'prototype'), selected, macro))\n", "macros.append('<option value=\"%s\"%s>%s</option>' % (macro, selected, macro))\n", "for macro in macro_list(request):\n", "if macro in help:\n", "request.write(''.join(helptexts))\n", "match = help[macro]\n", "prototype = macro\n", "request.write(\n \"\"\"\n </td>\n </tr>\n </table>\n </td>\n </tr>\n</table>\n</body>\n</html>\n\"\"\"\n )\n", "prototype = match.group('prototype')\n", "helptext = ''\n", "def macro_list(request):...\n", "helptext = match.group('help')\n", "helptexts.append(\n \"\"\"<div id=\"%s\" style=\"DISPLAY: none\">\n <b>&lt;&lt;%s&gt;&gt;</b>\n <br/>\n <textarea style=\"color:#000000\" cols=\"37\" rows=\"10\" disabled=\"disabled\">%s</textarea>\n </div>\"\"\"\n % (prototype, prototype, helptext))\n", "from MoinMoin import macro\n", "macros = macro.getNames(request.cfg)\n", "macros.sort()\n", "return macros\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 ]
[ "Expr'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "FunctionDef'", "Assign'", "Expr'", "Assign'", "For", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Expr'", "Expr'", "For", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Expr'", "ImportFrom'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_59(self):...\n", "\"\"\"docstring\"\"\"\n", "if not getattr(self.meta, 'track_changes', False\n", "return\n", "VAR_70 = frappe.new_doc('Version')\n", "if not self._doc_before_save:\n", "VAR_70.for_insert(self)\n", "if VAR_70.set_diff(self._doc_before_save, self):\n", "VAR_70.insert(VAR_11=True)\n", "VAR_70.insert(VAR_11=True)\n", "if not frappe.flags.in_migrate:\n", "follow_document(self.doctype, self.name, frappe.session.user)\n" ]
[ "def save_version(self):...\n", "\"\"\"docstring\"\"\"\n", "if not getattr(self.meta, 'track_changes', False\n", "return\n", "version = frappe.new_doc('Version')\n", "if not self._doc_before_save:\n", "version.for_insert(self)\n", "if version.set_diff(self._doc_before_save, self):\n", "version.insert(ignore_permissions=True)\n", "version.insert(ignore_permissions=True)\n", "if not frappe.flags.in_migrate:\n", "follow_document(self.doctype, self.name, frappe.session.user)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Assign'", "For", "Expr'", "For", "Expr'", "Expr'", "Condition", "Expr'" ]
[ "def __repr__(self):...\n", "return '<Shelf %d:%r>' % (self.id, self.name)\n" ]
[ "def __repr__(self):...\n", "return '<Shelf %d:%r>' % (self.id, self.name)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_36(VAR_51):...\n", "for VAR_105 in VAR_51:\n", "VAR_16.write(VAR_105)\n", "yield VAR_105\n" ]
[ "def written_chunks(chunks):...\n", "for chunk in chunks:\n", "content_file.write(chunk)\n", "yield chunk\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Expr'", "Expr'" ]
[ "def FUNC_1(self, VAR_2: Text, VAR_3: Text) ->None:...\n", "\"\"\"docstring\"\"\"\n", "if not os.path.isdir(VAR_2):\n", "VAR_13, VAR_14 = self._compress(VAR_2, VAR_3)\n", "self._persist_tar(VAR_13, VAR_14)\n" ]
[ "def persist(self, model_directory: Text, model_name: Text) ->None:...\n", "\"\"\"docstring\"\"\"\n", "if not os.path.isdir(model_directory):\n", "file_key, tar_path = self._compress(model_directory, model_name)\n", "self._persist_tar(file_key, tar_path)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Expr'" ]
[ "def FUNC_9(self, VAR_11=None, VAR_12=None, VAR_13=False, VAR_14=None,...\n", "\"\"\"docstring\"\"\"\n", "if self.flags.in_print:\n", "return\n", "self.flags.notifications_executed = []\n", "if VAR_11 != None:\n", "self.flags.ignore_permissions = VAR_11\n", "if VAR_12 != None:\n", "self.flags.ignore_links = VAR_12\n", "if VAR_14 != None:\n", "self.flags.ignore_mandatory = VAR_14\n", "self.set('__islocal', True)\n", "self.check_permission('create')\n", "self._set_defaults()\n", "self.set_user_and_timestamp()\n", "self.set_docstatus()\n", "self.check_if_latest()\n", "self.run_method('before_insert')\n", "self._validate_links()\n", "self.set_new_name(VAR_15=set_name, VAR_16=set_child_names)\n", "self.set_parent_in_children()\n", "self.validate_higher_perm_levels()\n", "self.flags.in_insert = True\n", "self.run_before_save_methods()\n", "self._validate()\n", "self.set_docstatus()\n", "self.flags.in_insert = False\n", "if getattr(self.meta, 'issingle', 0):\n", "self.update_single(self.get_valid_dict())\n", "self.db_insert()\n", "if not VAR_13:\n", "for VAR_21 in self.get_all_children():\n", "VAR_21.db_insert()\n", "self.run_method('after_insert')\n", "self.flags.in_insert = True\n", "if self.get('amended_from'):\n", "self.copy_attachments_from_amended_from()\n", "self.flags.update_log_for_doc_creation = True\n", "self.run_post_save_methods()\n", "self.flags.in_insert = False\n", "if hasattr(self, '__islocal'):\n", "delattr(self, '__islocal')\n", "if hasattr(self, '__unsaved'):\n", "delattr(self, '__unsaved')\n", "if not (frappe.flags.in_migrate or frappe.local.flags.in_install or frappe.\n", "follow_document(self.doctype, self.name, frappe.session.user)\n", "return self\n" ]
[ "def insert(self, ignore_permissions=None, ignore_links=None,...\n", "\"\"\"docstring\"\"\"\n", "if self.flags.in_print:\n", "return\n", "self.flags.notifications_executed = []\n", "if ignore_permissions != None:\n", "self.flags.ignore_permissions = ignore_permissions\n", "if ignore_links != None:\n", "self.flags.ignore_links = ignore_links\n", "if ignore_mandatory != None:\n", "self.flags.ignore_mandatory = ignore_mandatory\n", "self.set('__islocal', True)\n", "self.check_permission('create')\n", "self._set_defaults()\n", "self.set_user_and_timestamp()\n", "self.set_docstatus()\n", "self.check_if_latest()\n", "self.run_method('before_insert')\n", "self._validate_links()\n", "self.set_new_name(set_name=set_name, set_child_names=set_child_names)\n", "self.set_parent_in_children()\n", "self.validate_higher_perm_levels()\n", "self.flags.in_insert = True\n", "self.run_before_save_methods()\n", "self._validate()\n", "self.set_docstatus()\n", "self.flags.in_insert = False\n", "if getattr(self.meta, 'issingle', 0):\n", "self.update_single(self.get_valid_dict())\n", "self.db_insert()\n", "if not ignore_if_duplicate:\n", "for d in self.get_all_children():\n", "d.db_insert()\n", "self.run_method('after_insert')\n", "self.flags.in_insert = True\n", "if self.get('amended_from'):\n", "self.copy_attachments_from_amended_from()\n", "self.flags.update_log_for_doc_creation = True\n", "self.run_post_save_methods()\n", "self.flags.in_insert = False\n", "if hasattr(self, '__islocal'):\n", "delattr(self, '__islocal')\n", "if hasattr(self, '__unsaved'):\n", "delattr(self, '__unsaved')\n", "if not (frappe.flags.in_migrate or frappe.local.flags.in_install or frappe.\n", "follow_document(self.doctype, self.name, frappe.session.user)\n", "return self\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Condition", "For", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_50():...\n", "return 'works'\n" ]
[ "def my_callable():...\n", "return 'works'\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_52(VAR_2, VAR_39, VAR_40, VAR_8=None, **VAR_9):...\n", "\"\"\"docstring\"\"\"\n", "VAR_164 = VAR_8.getQueryService()\n", "VAR_39 = VAR_39.split('.')\n", "VAR_66 = omero.sys.ParametersI()\n", "VAR_66.addId(VAR_40)\n", "VAR_66.addString('ns', NSBULKANNOTATIONS)\n", "VAR_66.addString('mt', 'OMERO.tables')\n", "VAR_43 = 'select obj0 from %s obj0\\n' % VAR_39[0]\n", "for VAR_212, VAR_23 in enumerate(VAR_39[1:]):\n", "VAR_43 += 'join fetch obj%d.%s obj%d\\n' % (VAR_212, VAR_23, VAR_212 + 1)\n", "VAR_43 += 'string' % (len(VAR_39) - 1)\n", "VAR_24 = VAR_8.createServiceOptsDict()\n", "VAR_24.setOmeroGroup('-1')\n", "VAR_245 = VAR_164.findAllByQuery(VAR_43, VAR_66, VAR_24)\n", "return dict(VAR_176='%s cannot be queried' % objtype, VAR_43=query)\n", "VAR_162 = []\n", "VAR_165 = [link for VAR_202 in VAR_245 for link in VAR_202.\n copyAnnotationLinks()]\n", "for link in VAR_165:\n", "VAR_246 = link.child\n", "return dict(VAR_162=data)\n", "if not isinstance(VAR_246, omero.model.FileAnnotation):\n", "VAR_247 = VAR_246.details.owner\n", "VAR_248 = '%s %s' % (unwrap(VAR_247.firstName), unwrap(VAR_247.lastName))\n", "VAR_249 = link.details.owner\n", "VAR_250 = '%s %s' % (unwrap(VAR_249.firstName), unwrap(VAR_249.lastName))\n", "VAR_162.append(dict(id=annotation.id.val, file=annotation.file.id.val,\n parentType=objtype[0], parentId=link.parent.id.val, VAR_247=ownerName,\n VAR_249=addedByName, addedOn=unwrap(link.details.creationEvent._time)))\n" ]
[ "def _bulk_file_annotations(request, objtype, objid, conn=None, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "q = conn.getQueryService()\n", "objtype = objtype.split('.')\n", "params = omero.sys.ParametersI()\n", "params.addId(objid)\n", "params.addString('ns', NSBULKANNOTATIONS)\n", "params.addString('mt', 'OMERO.tables')\n", "query = 'select obj0 from %s obj0\\n' % objtype[0]\n", "for i, t in enumerate(objtype[1:]):\n", "query += 'join fetch obj%d.%s obj%d\\n' % (i, t, i + 1)\n", "query += (\n \"\"\"\n left outer join fetch obj0.annotationLinks links\n left outer join fetch links.child as f\n left outer join fetch links.parent\n left outer join fetch f.file\n join fetch links.details.owner\n join fetch links.details.creationEvent\n where obj%d.id=:id and\n (f.ns=:ns or f.file.mimetype=:mt)\"\"\"\n % (len(objtype) - 1))\n", "ctx = conn.createServiceOptsDict()\n", "ctx.setOmeroGroup('-1')\n", "objs = q.findAllByQuery(query, params, ctx)\n", "return dict(error='%s cannot be queried' % objtype, query=query)\n", "data = []\n", "links = [link for obj in objs for link in obj.copyAnnotationLinks()]\n", "for link in links:\n", "annotation = link.child\n", "return dict(data=data)\n", "if not isinstance(annotation, omero.model.FileAnnotation):\n", "owner = annotation.details.owner\n", "ownerName = '%s %s' % (unwrap(owner.firstName), unwrap(owner.lastName))\n", "addedBy = link.details.owner\n", "addedByName = '%s %s' % (unwrap(addedBy.firstName), unwrap(addedBy.lastName))\n", "data.append(dict(id=annotation.id.val, file=annotation.file.id.val,\n parentType=objtype[0], parentId=link.parent.id.val, owner=ownerName,\n addedBy=addedByName, addedOn=unwrap(link.details.creationEvent._time)))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "For", "AugAssign'", "AugAssign'", "Assign'", "Expr'", "Assign'", "Return'", "Assign'", "Assign'", "For", "Assign'", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_35(VAR_62):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_117():...\n", "return VAR_12.sql_list('select name from tabDocType where istable=1')\n" ]
[ "def is_table(doctype):...\n", "\"\"\"docstring\"\"\"\n", "def get_tables():...\n", "return db.sql_list('select name from tabDocType where istable=1')\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Return'" ]
[ "def FUNC_3(self, VAR_5):...\n", "VAR_5.process_response()\n", "VAR_29 = VAR_5.get_errors()\n", "if not VAR_29:\n", "if VAR_5.is_authenticated():\n", "current_app.logger.error('Error processing %s' % ', '.join(VAR_29))\n", "return True\n", "return False\n", "return False\n" ]
[ "def _consumer(self, auth):...\n", "auth.process_response()\n", "errors = auth.get_errors()\n", "if not errors:\n", "if auth.is_authenticated():\n", "current_app.logger.error('Error processing %s' % ', '.join(errors))\n", "return True\n", "return False\n", "return False\n" ]
[ 0, 0, 0, 0, 4, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Condition", "Condition", "Expr'", "Return'", "Return'", "Return'" ]
[ "@VAR_0.route('/shelf/edit/<int:shelf_id>', methods=['GET', 'POST'])...\n", "VAR_0 = ub.session.query(ub.Shelf).filter(ub.Shelf.id == VAR_3).first()\n", "if not FUNC_0(VAR_0):\n", "flash(_(u'Sorry you are not allowed to edit this shelf'), category='error')\n", "return FUNC_7(VAR_0, VAR_5=_(u'Edit a shelf'), VAR_6='shelfedit', VAR_3=\n shelf_id)\n", "return redirect(url_for('web.index'))\n" ]
[ "@shelf.route('/shelf/edit/<int:shelf_id>', methods=['GET', 'POST'])...\n", "shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()\n", "if not check_shelf_edit_permissions(shelf):\n", "flash(_(u'Sorry you are not allowed to edit this shelf'), category='error')\n", "return create_edit_shelf(shelf, page_title=_(u'Edit a shelf'), page=\n 'shelfedit', shelf_id=shelf_id)\n", "return redirect(url_for('web.index'))\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Expr'", "Return'", "Return'" ]
[ "def FUNC_34(self):...\n", "from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver\n", "from Products.PageTemplates.unicodeconflictresolver import ReplacingUnicodeEncodingConflictResolver\n", "from zope.component import getUtility\n", "from zope.component import provideUtility\n", "provideUtility(ReplacingUnicodeEncodingConflictResolver,\n IUnicodeEncodingConflictResolver)\n", "VAR_12 = getUtility(IUnicodeEncodingConflictResolver)\n", "self.assertEqual(VAR_12.resolve(None, b'\\xe4\\xfc\\xf6', None), '���')\n" ]
[ "def testReplacingResolver(self):...\n", "from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver\n", "from Products.PageTemplates.unicodeconflictresolver import ReplacingUnicodeEncodingConflictResolver\n", "from zope.component import getUtility\n", "from zope.component import provideUtility\n", "provideUtility(ReplacingUnicodeEncodingConflictResolver,\n IUnicodeEncodingConflictResolver)\n", "resolver = getUtility(IUnicodeEncodingConflictResolver)\n", "self.assertEqual(resolver.resolve(None, b'\\xe4\\xfc\\xf6', None), '���')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_11(self):...\n", "VAR_24 = 'inputs=[{\"text\":[\"foo\"], \"bytes\":[b\"bar\"]}]'\n", "VAR_22 = saved_model_cli.preprocess_input_examples_arg_string(VAR_24)\n", "VAR_25 = example_pb2.Example.FromString(VAR_22['inputs'][0])\n", "self.assertProtoEquals('string', VAR_25)\n" ]
[ "def testInputPreProcessExamplesWithStrAndBytes(self):...\n", "input_examples_str = 'inputs=[{\"text\":[\"foo\"], \"bytes\":[b\"bar\"]}]'\n", "input_dict = saved_model_cli.preprocess_input_examples_arg_string(\n input_examples_str)\n", "feature = example_pb2.Example.FromString(input_dict['inputs'][0])\n", "self.assertProtoEquals(\n \"\"\"\n features {\n feature {\n key: \"bytes\"\n value {\n bytes_list {\n value: \"bar\"\n }\n }\n }\n feature {\n key: \"text\"\n value {\n bytes_list {\n value: \"foo\"\n }\n }\n }\n }\n \"\"\"\n , feature)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "@VAR_2.route('/ajax/loaddialogtexts/<element_id>', methods=['POST'])...\n", "VAR_63 = {'header': '', 'main': '', 'valid': 1}\n", "if VAR_6 == 'config_delete_kobo_token':\n", "VAR_63['main'] = _('Do you really want to delete the Kobo Token?')\n", "if VAR_6 == 'btndeletedomain':\n", "return json.dumps(VAR_63)\n", "VAR_63['main'] = _('Do you really want to delete this domain?')\n", "if VAR_6 == 'btndeluser':\n", "VAR_63['main'] = _('Do you really want to delete this user?')\n", "if VAR_6 == 'delete_shelf':\n", "VAR_63['main'] = _('Are you sure you want to delete this shelf?')\n", "if VAR_6 == 'select_locale':\n", "VAR_63['main'] = _(\n 'Are you sure you want to change locales of selected user(s)?')\n", "if VAR_6 == 'select_default_language':\n", "VAR_63['main'] = _(\n 'Are you sure you want to change visible book languages for selected user(s)?'\n )\n", "if VAR_6 == 'role':\n", "VAR_63['main'] = _(\n 'Are you sure you want to change the selected role for the selected user(s)?'\n )\n", "if VAR_6 == 'restrictions':\n", "VAR_63['main'] = _(\n 'Are you sure you want to change the selected restrictions for the selected user(s)?'\n )\n", "if VAR_6 == 'sidebar_view':\n", "VAR_63['main'] = _(\n 'Are you sure you want to change the selected visibility restrictions for the selected user(s)?'\n )\n", "if VAR_6 == 'kobo_only_shelves_sync':\n", "VAR_63['main'] = _(\n 'Are you sure you want to change shelf sync behavior for the selected user(s)?'\n )\n", "if VAR_6 == 'db_submit':\n", "VAR_63['main'] = _('Are you sure you want to change Calibre library location?')\n", "if VAR_6 == 'btnfullsync':\n", "VAR_63['main'] = _('string')\n" ]
[ "@admi.route('/ajax/loaddialogtexts/<element_id>', methods=['POST'])...\n", "texts = {'header': '', 'main': '', 'valid': 1}\n", "if element_id == 'config_delete_kobo_token':\n", "texts['main'] = _('Do you really want to delete the Kobo Token?')\n", "if element_id == 'btndeletedomain':\n", "return json.dumps(texts)\n", "texts['main'] = _('Do you really want to delete this domain?')\n", "if element_id == 'btndeluser':\n", "texts['main'] = _('Do you really want to delete this user?')\n", "if element_id == 'delete_shelf':\n", "texts['main'] = _('Are you sure you want to delete this shelf?')\n", "if element_id == 'select_locale':\n", "texts['main'] = _(\n 'Are you sure you want to change locales of selected user(s)?')\n", "if element_id == 'select_default_language':\n", "texts['main'] = _(\n 'Are you sure you want to change visible book languages for selected user(s)?'\n )\n", "if element_id == 'role':\n", "texts['main'] = _(\n 'Are you sure you want to change the selected role for the selected user(s)?'\n )\n", "if element_id == 'restrictions':\n", "texts['main'] = _(\n 'Are you sure you want to change the selected restrictions for the selected user(s)?'\n )\n", "if element_id == 'sidebar_view':\n", "texts['main'] = _(\n 'Are you sure you want to change the selected visibility restrictions for the selected user(s)?'\n )\n", "if element_id == 'kobo_only_shelves_sync':\n", "texts['main'] = _(\n 'Are you sure you want to change shelf sync behavior for the selected user(s)?'\n )\n", "if element_id == 'db_submit':\n", "texts['main'] = _('Are you sure you want to change Calibre library location?')\n", "if element_id == 'btnfullsync':\n", "texts['main'] = _(\n \"Are you sure you want delete Calibre-Web's sync database to force a full sync with your Kobo Reader?\"\n )\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Assign'", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'" ]
[ "def FUNC_81(VAR_19):...\n", "if self.parentfield:\n", "return '{} {} #{}: {} {}'.format(frappe.bold(_(self.doctype)), _('Row'),\n self.idx, _('Value cannot be negative for'), frappe.bold(_(VAR_19.label)))\n", "return _('Value cannot be negative for {0}: {1}').format(_(VAR_19.parent),\n frappe.bold(_(VAR_19.label)))\n" ]
[ "def get_msg(df):...\n", "if self.parentfield:\n", "return '{} {} #{}: {} {}'.format(frappe.bold(_(self.doctype)), _('Row'),\n self.idx, _('Value cannot be negative for'), frappe.bold(_(df.label)))\n", "return _('Value cannot be negative for {0}: {1}').format(_(df.parent),\n frappe.bold(_(df.label)))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_12(self, VAR_0, VAR_8):...\n", "VAR_0.get(VAR_8 + self.url)\n", "VAR_19 = VAR_0.find_element(By.XPATH, '//body[@JSError]')\n", "pytest.fail(VAR_19.get_attribute('JSError'))\n" ]
[ "def test_no_js_error(self, driver, live_server):...\n", "driver.get(live_server + self.url)\n", "error = driver.find_element(By.XPATH, '//body[@JSError]')\n", "pytest.fail(error.get_attribute('JSError'))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_0(self, VAR_5, VAR_6):...\n", "\"\"\"docstring\"\"\"\n", "super(CLASS_0, self).on_logged_in(VAR_5, VAR_6)\n", "self.prepare_session(VAR_5)\n", "if self.setGroupContext:\n", "if VAR_5.session.get('active_group'):\n", "VAR_6.SERVICE_OPTS.setOmeroGroup(VAR_5.session.get('active_group'))\n", "VAR_6.SERVICE_OPTS.setOmeroGroup(VAR_6.getEventContext().groupId)\n" ]
[ "def on_logged_in(self, request, conn):...\n", "\"\"\"docstring\"\"\"\n", "super(login_required, self).on_logged_in(request, conn)\n", "self.prepare_session(request)\n", "if self.setGroupContext:\n", "if request.session.get('active_group'):\n", "conn.SERVICE_OPTS.setOmeroGroup(request.session.get('active_group'))\n", "conn.SERVICE_OPTS.setOmeroGroup(conn.getEventContext().groupId)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Expr'", "Condition", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_46(self, VAR_14, VAR_65, VAR_66=None):...\n", "\"\"\"docstring\"\"\"\n", "return '<h%d>%s</h%d>\\n' % (VAR_65, VAR_14, VAR_65)\n" ]
[ "def header(self, text, level, raw=None):...\n", "\"\"\"docstring\"\"\"\n", "return '<h%d>%s</h%d>\\n' % (level, text, level)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_7(self):...\n", "self.assertFormfield(models.Member, 'name', widgets.AdminTextInputWidget)\n" ]
[ "def testCharField(self):...\n", "self.assertFormfield(models.Member, 'name', widgets.AdminTextInputWidget)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_27(self, VAR_24):...\n", "self._reader.feed(VAR_24)\n", "while True:\n", "VAR_21 = self._reader.gets()\n", "if VAR_21 is False:\n", "return\n", "if not isinstance(VAR_21, list):\n", "self.handle_command(VAR_21[0], *VAR_21[1:])\n" ]
[ "def dataReceived(self, data):...\n", "self._reader.feed(data)\n", "while True:\n", "msg = self._reader.gets()\n", "if msg is False:\n", "return\n", "if not isinstance(msg, list):\n", "self.handle_command(msg[0], *msg[1:])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Condition", "Assign'", "Condition", "Return'", "Condition", "Expr'" ]
[ "def FUNC_2():...\n", "return FUNC_1('README.rst')\n" ]
[ "def desc():...\n", "return read('README.rst')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_7(VAR_5, VAR_3, VAR_8, VAR_6, VAR_4):...\n", "if not isinstance(VAR_5, list):\n", "VAR_5 = [x for x in VAR_5 if x != '']\n", "VAR_7 = FUNC_2(VAR_3, VAR_4, VAR_5)\n", "VAR_9 = FUNC_3(VAR_3, VAR_4, VAR_5)\n", "VAR_50 = FUNC_4(VAR_3, VAR_6, VAR_7)\n", "if len(VAR_9) > 0:\n", "VAR_50 |= FUNC_5(VAR_3, VAR_8, VAR_6, VAR_4, VAR_9)\n", "return VAR_50\n" ]
[ "def modify_database_object(input_elements, db_book_object, db_object,...\n", "if not isinstance(input_elements, list):\n", "input_elements = [x for x in input_elements if x != '']\n", "del_elements = search_objects_remove(db_book_object, db_type, input_elements)\n", "add_elements = search_objects_add(db_book_object, db_type, input_elements)\n", "changed = remove_objects(db_book_object, db_session, del_elements)\n", "if len(add_elements) > 0:\n", "changed |= add_objects(db_book_object, db_object, db_session, db_type,\n add_elements)\n", "return changed\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "AugAssign'", "Return'" ]
[ "@app.route('/folders/create', methods=['POST'])...\n", "VAR_9 = forms.NewFolderForm()\n", "if VAR_9.validate_on_submit():\n", "VAR_7 = Path(VAR_9.parent_dir.data.strip('/')) / VAR_9.new_dir.data\n", "flash('Could not create folder.', 'error')\n", "VAR_33 = data.create_dir(str(VAR_7))\n", "return redirect(request.referrer or '/')\n", "flash('Folder successfully created.', 'success')\n", "return redirect(f'/?path={VAR_33}')\n" ]
[ "@app.route('/folders/create', methods=['POST'])...\n", "form = forms.NewFolderForm()\n", "if form.validate_on_submit():\n", "path = Path(form.parent_dir.data.strip('/')) / form.new_dir.data\n", "flash('Could not create folder.', 'error')\n", "new_path = data.create_dir(str(path))\n", "return redirect(request.referrer or '/')\n", "flash('Folder successfully created.', 'success')\n", "return redirect(f'/?path={new_path}')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Return'", "Expr'", "Return'" ]
[ "@VAR_2.route('/admin/ajaxdbconfig', methods=['POST'])...\n", "return FUNC_48()\n" ]
[ "@admi.route('/admin/ajaxdbconfig', methods=['POST'])...\n", "return _db_configuration_update_helper()\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_15(self):...\n", "VAR_5 = {'not_senders': ['@flibble:wibble']}\n", "VAR_6 = FUNC_0(sender='@challenger:appears', type='com.nom.nom.nom',\n room_id='!foo:bar')\n", "self.assertTrue(Filter(VAR_5).check(VAR_6))\n" ]
[ "def test_definition_not_senders_works_with_unknowns(self):...\n", "definition = {'not_senders': ['@flibble:wibble']}\n", "event = MockEvent(sender='@challenger:appears', type='com.nom.nom.nom',\n room_id='!foo:bar')\n", "self.assertTrue(Filter(definition).check(event))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'" ]
[ "__version__ = '2.6.0b0'\n", "if __name__ == '__main__':\n", "print(__version__)\n" ]
[ "__version__ = '2.6.0b0'\n", "if __name__ == '__main__':\n", "print(__version__)\n" ]
[ 2, 0, 0 ]
[ "Assign'", "Condition", "Expr'" ]
[ "def FUNC_6(self):...\n", "VAR_6 = Mock()\n", "VAR_3 = '@foo:bar'\n", "VAR_7 = 5000000\n", "VAR_8 = UserPresenceState.default(VAR_3)\n", "VAR_8 = VAR_8.copy_and_replace(VAR_10=PresenceState.ONLINE, last_active_ts=\n now, currently_active=True)\n", "VAR_9 = VAR_8.copy_and_replace(VAR_10=PresenceState.UNAVAILABLE)\n", "VAR_10, VAR_11, VAR_12 = handle_update(VAR_8, VAR_9, is_mine=True, VAR_6=\n wheel_timer, VAR_7=now)\n", "self.assertTrue(VAR_11)\n", "self.assertEquals(VAR_9.state, VAR_10.state)\n", "self.assertEquals(VAR_10.last_federation_update_ts, VAR_7)\n", "self.assertEquals(VAR_9.state, VAR_10.state)\n", "self.assertEquals(VAR_9.status_msg, VAR_10.status_msg)\n", "self.assertEquals(VAR_6.insert.call_count, 1)\n", "VAR_6.insert.assert_has_calls([call(VAR_7=now, obj=user_id, then=new_state.\n last_user_sync_ts + SYNC_ONLINE_TIMEOUT)], any_order=True)\n" ]
[ "def test_online_to_idle(self):...\n", "wheel_timer = Mock()\n", "user_id = '@foo:bar'\n", "now = 5000000\n", "prev_state = UserPresenceState.default(user_id)\n", "prev_state = prev_state.copy_and_replace(state=PresenceState.ONLINE,\n last_active_ts=now, currently_active=True)\n", "new_state = prev_state.copy_and_replace(state=PresenceState.UNAVAILABLE)\n", "state, persist_and_notify, federation_ping = handle_update(prev_state,\n new_state, is_mine=True, wheel_timer=wheel_timer, now=now)\n", "self.assertTrue(persist_and_notify)\n", "self.assertEquals(new_state.state, state.state)\n", "self.assertEquals(state.last_federation_update_ts, now)\n", "self.assertEquals(new_state.state, state.state)\n", "self.assertEquals(new_state.status_msg, state.status_msg)\n", "self.assertEquals(wheel_timer.insert.call_count, 1)\n", "wheel_timer.insert.assert_has_calls([call(now=now, obj=user_id, then=\n new_state.last_user_sync_ts + SYNC_ONLINE_TIMEOUT)], any_order=True)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_80(self):...\n", "VAR_67 = self.renderer.placeholder()\n", "while self.pop()['type'] != 'list_item_end':\n", "VAR_67 += self.tok()\n", "return self.renderer.list_item(VAR_67)\n" ]
[ "def output_loose_item(self):...\n", "body = self.renderer.placeholder()\n", "while self.pop()['type'] != 'list_item_end':\n", "body += self.tok()\n", "return self.renderer.list_item(body)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "AugAssign'", "Return'" ]
[ "@internationalizeDocstring...\n", "\"\"\"docstring\"\"\"\n", "VAR_27 = len(str(VAR_8).split('.')[1])\n", "VAR_27 = 0\n", "VAR_34 = convertcore.convert(VAR_8, VAR_22, VAR_23)\n", "VAR_3.error(str(ude))\n", "if isinstance(VAR_34, float):\n", "VAR_38 = 0\n", "VAR_34 = self._floatToString(VAR_34)\n", "for char in str(VAR_34).split('.')[1]:\n", "VAR_3.reply(str(VAR_34))\n", "if char != '0':\n", "VAR_34 = round(VAR_34, VAR_27 + 1 + VAR_38)\n", "VAR_38 += 1\n" ]
[ "@internationalizeDocstring...\n", "\"\"\"docstring\"\"\"\n", "digits = len(str(number).split('.')[1])\n", "digits = 0\n", "newNum = convertcore.convert(number, unit1, unit2)\n", "irc.error(str(ude))\n", "if isinstance(newNum, float):\n", "zeros = 0\n", "newNum = self._floatToString(newNum)\n", "for char in str(newNum).split('.')[1]:\n", "irc.reply(str(newNum))\n", "if char != '0':\n", "newNum = round(newNum, digits + 1 + zeros)\n", "zeros += 1\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "For", "Expr'", "Condition", "Assign'", "AugAssign'" ]
[ "@override_settings(LOGIN_URL='http://remote.example.com/login')...\n", "VAR_25 = urlquote('http://testserver/login_required/')\n", "VAR_6 = 'http://remote.example.com/login?next=%s' % VAR_25\n", "self.assertLoginURLEquals(VAR_6)\n" ]
[ "@override_settings(LOGIN_URL='http://remote.example.com/login')...\n", "quoted_next = urlquote('http://testserver/login_required/')\n", "expected = 'http://remote.example.com/login?next=%s' % quoted_next\n", "self.assertLoginURLEquals(expected)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_12(VAR_4):...\n", "VAR_21 = [m.upper() for m in VAR_13]\n", "for r, m, v in itertools.product(VAR_12, VAR_21, [VAR_4.__name__]):\n", "self.before_acl.append((r, m, v, VAR_3))\n", "return VAR_4\n" ]
[ "def decorator(view_func):...\n", "_methods = [m.upper() for m in methods]\n", "for r, m, v in itertools.product(roles, _methods, [view_func.__name__]):\n", "self.before_acl.append((r, m, v, with_children))\n", "return view_func\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Expr'", "Return'" ]
[ "def FUNC_157(VAR_262=False):...\n", "VAR_266 = VAR_153(VAR_364=session._cas_service, VAR_143=self.user.id)\n", "if VAR_266:\n", "VAR_264 = VAR_266.ticket\n", "VAR_264 = 'ST-' + web2py_uuid()\n", "VAR_364 = VAR_139._cas_service\n", "VAR_153.insert(VAR_364=session._cas_service, VAR_143=self.user.id, VAR_264=\n ticket, created_on=request.now, VAR_265=interactivelogin)\n", "VAR_365 = '&' if '?' in VAR_364 else '?'\n", "if 'warn' in VAR_56.vars and not VAR_262:\n", "VAR_244.headers['refresh'\n ] = '5;URL=%s' % VAR_364 + VAR_365 + 'ticket=' + VAR_264\n", "redirect(VAR_364 + VAR_365 + 'ticket=' + VAR_264)\n", "return A('Continue to %s' % VAR_364, _href=service + query_sep + 'ticket=' +\n ticket)\n" ]
[ "def allow_access(interactivelogin=False):...\n", "row = table(service=session._cas_service, user_id=self.user.id)\n", "if row:\n", "ticket = row.ticket\n", "ticket = 'ST-' + web2py_uuid()\n", "service = session._cas_service\n", "table.insert(service=session._cas_service, user_id=self.user.id, ticket=\n ticket, created_on=request.now, renew=interactivelogin)\n", "query_sep = '&' if '?' in service else '?'\n", "if 'warn' in request.vars and not interactivelogin:\n", "response.headers['refresh'\n ] = '5;URL=%s' % service + query_sep + 'ticket=' + ticket\n", "redirect(service + query_sep + 'ticket=' + ticket)\n", "return A('Continue to %s' % service, _href=service + query_sep + 'ticket=' +\n ticket)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_31(self, VAR_27):...\n", "self._server.remove_subscriber(self)\n" ]
[ "def connectionLost(self, reason):...\n", "self._server.remove_subscriber(self)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_14(self, VAR_30, VAR_20):...\n", "if VAR_30 is self.getDefault() or VAR_30 is None:\n", "return VAR_30\n", "if isinstance(VAR_30, str):\n", "return VAR_30\n", "if isinstance(VAR_30, bytes):\n", "VAR_49 = queryUtility(IUnicodeEncodingConflictResolver)\n", "return str(VAR_30)\n", "if VAR_49 is None:\n", "return VAR_30.decode('ascii')\n", "return VAR_49.resolve(self.contexts.get('context'), VAR_30, VAR_20)\n", "VAR_1.error('string' % (VAR_20, VAR_49.__class__, VAR_39, self.contexts[\n 'template'].absolute_url(1), VAR_30))\n" ]
[ "def _handleText(self, text, expr):...\n", "if text is self.getDefault() or text is None:\n", "return text\n", "if isinstance(text, str):\n", "return text\n", "if isinstance(text, bytes):\n", "resolver = queryUtility(IUnicodeEncodingConflictResolver)\n", "return str(text)\n", "if resolver is None:\n", "return text.decode('ascii')\n", "return resolver.resolve(self.contexts.get('context'), text, expr)\n", "LOG.error(\n \"\"\"UnicodeDecodeError detected for expression \"%s\"\nResolver class: %s\nException text: %s\nTemplate: %s\nRendered text: %r\"\"\"\n % (expr, resolver.__class__, e, self.contexts['template'].absolute_url\n (1), text))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Condition", "Return'", "Condition", "Assign'", "Return'", "Condition", "Return'", "Return'", "Expr'" ]
[ "def FUNC_19(VAR_15, VAR_46=os.F_OK | os.X_OK, VAR_14=None):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_20(VAR_56, VAR_46):...\n", "return os.path.exists(VAR_56) and os.access(VAR_56, VAR_46\n ) and not os.path.isdir(VAR_56)\n" ]
[ "def which(cmd, mode=os.F_OK | os.X_OK, path=None):...\n", "\"\"\"docstring\"\"\"\n", "def _access_check(fn, mode):...\n", "return os.path.exists(fn) and os.access(fn, mode) and not os.path.isdir(fn)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Return'" ]
[ "def FUNC_3(self, VAR_4):...\n", "\"\"\"docstring\"\"\"\n", "return VAR_4 in self._exempt\n" ]
[ "def is_exempt(self, view_func):...\n", "\"\"\"docstring\"\"\"\n", "return view_func in self._exempt\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_20(self, VAR_19):...\n", "if os.path.exists(VAR_19):\n", "return f.read()\n" ]
[ "def albumartcache_load(self, imgb64path):...\n", "if os.path.exists(imgb64path):\n", "return f.read()\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'" ]