lines
sequencelengths 1
383
| raw_lines
sequencelengths 1
383
| label
sequencelengths 1
383
| type
sequencelengths 1
383
|
---|---|---|---|
[
"def FUNC_12(self):...\n",
"VAR_3 = self.client.post('/password_reset/', {'email':\n '[email protected]'})\n",
"self.assertEqual(VAR_3.status_code, 302)\n",
"self.assertEqual(len(mail.outbox), 1)\n",
"return self._read_signup_email(mail.outbox[0])\n"
] | [
"def _test_confirm_start(self):...\n",
"response = self.client.post('/password_reset/', {'email':\n '[email protected]'})\n",
"self.assertEqual(response.status_code, 302)\n",
"self.assertEqual(len(mail.outbox), 1)\n",
"return self._read_signup_email(mail.outbox[0])\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_10(self, VAR_2=None):...\n",
"VAR_6 = self.get_app()\n",
"if VAR_15.is_authenticated():\n",
"VAR_23 = 403\n",
"VAR_23 = 401\n",
"if VAR_6.config.get('FRONTED_BY_NGINX'):\n",
"VAR_24 = 'https://{}:{}{}'.format(VAR_6.config.get('FQDN'), VAR_6.config.\n get('NGINX_PORT'), '/login')\n",
"VAR_24 = 'http://{}:{}{}'.format(VAR_6.config.get('FQDN'), VAR_6.config.get\n ('API_PORT'), '/login')\n",
"if VAR_15.is_authenticated():\n",
"VAR_25 = {'authenticated': True, 'user': VAR_15.email, 'roles': VAR_15.role}\n",
"VAR_25 = {'authenticated': False, 'user': None, 'url': VAR_24}\n",
"return Response(response=json.dumps({'auth': auth_dict}), VAR_23=status,\n mimetype='application/json')\n"
] | [
"def _deny_hook(self, resource=None):...\n",
"app = self.get_app()\n",
"if current_user.is_authenticated():\n",
"status = 403\n",
"status = 401\n",
"if app.config.get('FRONTED_BY_NGINX'):\n",
"url = 'https://{}:{}{}'.format(app.config.get('FQDN'), app.config.get(\n 'NGINX_PORT'), '/login')\n",
"url = 'http://{}:{}{}'.format(app.config.get('FQDN'), app.config.get(\n 'API_PORT'), '/login')\n",
"if current_user.is_authenticated():\n",
"auth_dict = {'authenticated': True, 'user': current_user.email, 'roles':\n current_user.role}\n",
"auth_dict = {'authenticated': False, 'user': None, 'url': url}\n",
"return Response(response=json.dumps({'auth': auth_dict}), status=status,\n mimetype='application/json')\n"
] | [
0,
0,
4,
0,
0,
0,
0,
0,
4,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"@abc.abstractmethod...\n",
"\"\"\"docstring\"\"\"\n"
] | [
"@abc.abstractmethod...\n",
"\"\"\"docstring\"\"\"\n"
] | [
0,
0
] | [
"Condition",
"Docstring"
] |
[
"def FUNC_54(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if getattr(self.meta, 'track_seen', False):\n",
"frappe.db.set_value(self.doctype, self.name, '_seen', json.dumps([frappe.\n session.user]), VAR_27=False)\n"
] | [
"def reset_seen(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if getattr(self.meta, 'track_seen', False):\n",
"frappe.db.set_value(self.doctype, self.name, '_seen', json.dumps([frappe.\n session.user]), update_modified=False)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'"
] |
[
"@staticmethod...\n",
"if isinstance(VAR_5, int):\n",
"return VAR_5\n",
"VAR_51 = 1000\n",
"VAR_52 = 60 * VAR_51\n",
"VAR_53 = 60 * VAR_52\n",
"VAR_54 = 24 * VAR_53\n",
"VAR_55 = 7 * VAR_54\n",
"VAR_56 = 365 * VAR_54\n",
"VAR_48 = {'s': VAR_51, 'm': VAR_52, 'h': VAR_53, 'd': VAR_54, 'w': VAR_55,\n 'y': VAR_56}\n",
"VAR_49 = 1\n",
"VAR_50 = VAR_5[-1]\n",
"if VAR_50 in VAR_48:\n",
"VAR_5 = VAR_5[:-1]\n",
"return int(VAR_5) * VAR_49\n",
"VAR_49 = VAR_48[VAR_50]\n"
] | [
"@staticmethod...\n",
"if isinstance(value, int):\n",
"return value\n",
"second = 1000\n",
"minute = 60 * second\n",
"hour = 60 * minute\n",
"day = 24 * hour\n",
"week = 7 * day\n",
"year = 365 * day\n",
"sizes = {'s': second, 'm': minute, 'h': hour, 'd': day, 'w': week, 'y': year}\n",
"size = 1\n",
"suffix = value[-1]\n",
"if suffix in sizes:\n",
"value = value[:-1]\n",
"return int(value) * size\n",
"size = sizes[suffix]\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'"
] |
[
"@VAR_2.route('/ajax/toggleread/<int:book_id>', methods=['POST'])...\n",
"if not config.config_read_column:\n",
"VAR_95 = ub.session.query(ub.ReadBook).filter(and_(ub.ReadBook.user_id ==\n int(VAR_87.id), ub.ReadBook.book_id == VAR_5)).first()\n",
"calibre_db.update_title_sort(config)\n",
"VAR_3.error(u'Custom Column No.%d is not existing in calibre database',\n config.config_read_column)\n",
"return ''\n",
"if VAR_95:\n",
"VAR_95 = calibre_db.get_filtered_book(VAR_5)\n",
"return 'Custom Column No.{} is not existing in calibre database'.format(config\n .config_read_column), 400\n",
"if VAR_95.read_status == ub.ReadBook.STATUS_FINISHED:\n",
"VAR_123 = ub.ReadBook(VAR_11=current_user.id, VAR_5=book_id)\n",
"VAR_26 = getattr(VAR_95, 'custom_column_' + str(config.config_read_column))\n",
"VAR_95.read_status = ub.ReadBook.STATUS_UNREAD\n",
"VAR_95.read_status = ub.ReadBook.STATUS_FINISHED\n",
"VAR_123.read_status = ub.ReadBook.STATUS_FINISHED\n",
"if len(VAR_26):\n",
"if not VAR_95.kobo_reading_state:\n",
"VAR_95 = VAR_123\n",
"VAR_26[0].value = not VAR_26[0].value\n",
"VAR_144 = db.cc_classes[config.config_read_column]\n",
"VAR_124 = ub.KoboReadingState(VAR_11=current_user.id, VAR_5=book_id)\n",
"ub.session.merge(VAR_95)\n",
"calibre_db.session.commit()\n",
"VAR_145 = VAR_144(value=1, VAR_95=book_id)\n",
"VAR_124.current_bookmark = ub.KoboBookmark()\n",
"ub.session_commit('Book {} readbit toggled'.format(VAR_5))\n",
"calibre_db.session.add(VAR_145)\n",
"VAR_124.statistics = ub.KoboStatistics()\n",
"calibre_db.session.commit()\n",
"VAR_95.kobo_reading_state = VAR_124\n"
] | [
"@web.route('/ajax/toggleread/<int:book_id>', methods=['POST'])...\n",
"if not config.config_read_column:\n",
"book = ub.session.query(ub.ReadBook).filter(and_(ub.ReadBook.user_id == int\n (current_user.id), ub.ReadBook.book_id == book_id)).first()\n",
"calibre_db.update_title_sort(config)\n",
"log.error(u'Custom Column No.%d is not existing in calibre database',\n config.config_read_column)\n",
"return ''\n",
"if book:\n",
"book = calibre_db.get_filtered_book(book_id)\n",
"return 'Custom Column No.{} is not existing in calibre database'.format(config\n .config_read_column), 400\n",
"if book.read_status == ub.ReadBook.STATUS_FINISHED:\n",
"readBook = ub.ReadBook(user_id=current_user.id, book_id=book_id)\n",
"read_status = getattr(book, 'custom_column_' + str(config.config_read_column))\n",
"book.read_status = ub.ReadBook.STATUS_UNREAD\n",
"book.read_status = ub.ReadBook.STATUS_FINISHED\n",
"readBook.read_status = ub.ReadBook.STATUS_FINISHED\n",
"if len(read_status):\n",
"if not book.kobo_reading_state:\n",
"book = readBook\n",
"read_status[0].value = not read_status[0].value\n",
"cc_class = db.cc_classes[config.config_read_column]\n",
"kobo_reading_state = ub.KoboReadingState(user_id=current_user.id, book_id=\n book_id)\n",
"ub.session.merge(book)\n",
"calibre_db.session.commit()\n",
"new_cc = cc_class(value=1, book=book_id)\n",
"kobo_reading_state.current_bookmark = ub.KoboBookmark()\n",
"ub.session_commit('Book {} readbit toggled'.format(book_id))\n",
"calibre_db.session.add(new_cc)\n",
"kobo_reading_state.statistics = ub.KoboStatistics()\n",
"calibre_db.session.commit()\n",
"book.kobo_reading_state = kobo_reading_state\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
] | [
"Condition",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Return'",
"Condition",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'"
] |
[
"@utils.prevent_exceptions(False)...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_33 = objreg.get('proxy-factory', None)\n",
"if VAR_33 is not None:\n",
"VAR_46 = VAR_33.get_error()\n",
"VAR_34 = VAR_22.url().scheme()\n",
"if VAR_46 is not None:\n",
"if VAR_34 in self._scheme_handlers:\n",
"return networkreply.ErrorNetworkReply(VAR_22, VAR_46, QNetworkReply.\n UnknownProxyError, self)\n",
"VAR_47 = self._scheme_handlers[VAR_34](VAR_22)\n",
"for header, value in shared.custom_headers(VAR_18=req.url()):\n",
"if VAR_47 is not None:\n",
"VAR_22.setRawHeader(header, value)\n",
"VAR_35 = objreg.get('host-blocker')\n",
"VAR_47.setParent(self)\n",
"if VAR_35.is_blocked(VAR_22.url()):\n",
"return VAR_47\n",
"log.webview.info('Request to {} blocked by host blocker.'.format(VAR_22.url\n ().host()))\n",
"VAR_23 = QUrl()\n",
"return networkreply.ErrorNetworkReply(VAR_22, VAR_0, QNetworkReply.\n ContentAccessDenied, self)\n",
"if self._tab_id is not None:\n",
"assert self._win_id is not None\n",
"if 'log-requests' in self._args.debug_flags:\n",
"VAR_37 = objreg.get('tab', scope='tab', window=self._win_id, VAR_37=self.\n _tab_id)\n",
"VAR_23 = QUrl()\n",
"VAR_48 = debug.qenum_key(QNetworkAccessManager, VAR_24)\n",
"self.set_referer(VAR_22, VAR_23)\n",
"VAR_23 = VAR_37.url()\n",
"VAR_48 = VAR_48.replace('Operation', '').upper()\n",
"return super().createRequest(VAR_24, VAR_22, VAR_25)\n",
"log.webview.debug('{} {}, first-party {}'.format(VAR_48, VAR_22.url().\n toDisplayString(), VAR_23.toDisplayString()))\n"
] | [
"@utils.prevent_exceptions(False)...\n",
"\"\"\"docstring\"\"\"\n",
"proxy_factory = objreg.get('proxy-factory', None)\n",
"if proxy_factory is not None:\n",
"proxy_error = proxy_factory.get_error()\n",
"scheme = req.url().scheme()\n",
"if proxy_error is not None:\n",
"if scheme in self._scheme_handlers:\n",
"return networkreply.ErrorNetworkReply(req, proxy_error, QNetworkReply.\n UnknownProxyError, self)\n",
"result = self._scheme_handlers[scheme](req)\n",
"for header, value in shared.custom_headers(url=req.url()):\n",
"if result is not None:\n",
"req.setRawHeader(header, value)\n",
"host_blocker = objreg.get('host-blocker')\n",
"result.setParent(self)\n",
"if host_blocker.is_blocked(req.url()):\n",
"return result\n",
"log.webview.info('Request to {} blocked by host blocker.'.format(req.url().\n host()))\n",
"current_url = QUrl()\n",
"return networkreply.ErrorNetworkReply(req, HOSTBLOCK_ERROR_STRING,\n QNetworkReply.ContentAccessDenied, self)\n",
"if self._tab_id is not None:\n",
"assert self._win_id is not None\n",
"if 'log-requests' in self._args.debug_flags:\n",
"tab = objreg.get('tab', scope='tab', window=self._win_id, tab=self._tab_id)\n",
"current_url = QUrl()\n",
"operation = debug.qenum_key(QNetworkAccessManager, op)\n",
"self.set_referer(req, current_url)\n",
"current_url = tab.url()\n",
"operation = operation.replace('Operation', '').upper()\n",
"return super().createRequest(op, req, outgoing_data)\n",
"log.webview.debug('{} {}, first-party {}'.format(operation, req.url().\n toDisplayString(), current_url.toDisplayString()))\n"
] | [
0,
0,
0,
0,
0,
3,
0,
3,
0,
3,
0,
3,
0,
0,
3,
0,
3,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Return'",
"Assign'",
"For",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"Return'",
"Expr'",
"Assign'",
"Return'",
"Condition",
"Assert'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Return'",
"Expr'"
] |
[
"def FUNC_5(VAR_10: str) ->str:...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_24 = VAR_0 / VAR_10\n",
"VAR_39 = int(VAR_24.stat().st_mtime)\n",
"VAR_39 = 0\n",
"return FUNC_6('static', VAR_10=filename, VAR_39=mtime)\n"
] | [
"def static_url(filename: str) ->str:...\n",
"\"\"\"docstring\"\"\"\n",
"file_path = STATIC_FOLDER / filename\n",
"mtime = int(file_path.stat().st_mtime)\n",
"mtime = 0\n",
"return url_for('static', filename=filename, mtime=mtime)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_26(self):...\n",
"self.parser = saved_model_cli.create_parser()\n",
"VAR_9 = test.test_src_dir_path(VAR_0)\n",
"VAR_10 = self.parser.parse_args(['run', '--dir', VAR_9, '--tag_set',\n 'serve', '--signature_def', 'regress_x2_to_y3', '--input_exprs',\n 'x2=np.ones((3,1))'])\n",
"saved_model_cli.run(VAR_10)\n"
] | [
"def testRunCommandInvalidInputKeyError(self):...\n",
"self.parser = saved_model_cli.create_parser()\n",
"base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n",
"args = self.parser.parse_args(['run', '--dir', base_path, '--tag_set',\n 'serve', '--signature_def', 'regress_x2_to_y3', '--input_exprs',\n 'x2=np.ones((3,1))'])\n",
"saved_model_cli.run(args)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"@VAR_25.whitelist(allow_guest=True)...\n",
"return 'pong'\n"
] | [
"@frappe.whitelist(allow_guest=True)...\n",
"return 'pong'\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def __call__(self, VAR_5):...\n",
"VAR_45 = []\n",
"if isinstance(self._expr, str):\n",
"VAR_47 = VAR_5.evaluateText\n",
"VAR_47 = VAR_5.evaluate\n",
"for var in self._vars:\n",
"VAR_48 = VAR_47(var)\n",
"return self._expr % tuple(VAR_45)\n",
"VAR_45.append(VAR_48)\n"
] | [
"def __call__(self, econtext):...\n",
"vvals = []\n",
"if isinstance(self._expr, str):\n",
"evaluate = econtext.evaluateText\n",
"evaluate = econtext.evaluate\n",
"for var in self._vars:\n",
"v = evaluate(var)\n",
"return self._expr % tuple(vvals)\n",
"vvals.append(v)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"For",
"Assign'",
"Return'",
"Expr'"
] |
[
"from synapse.app.generic_worker import GenericWorkerServer\n",
"from tests.server import make_request\n",
"from tests.unittest import HomeserverTestCase\n",
"def FUNC_0(self, VAR_0, VAR_1):...\n",
"VAR_2 = self.setup_test_homeserver(http_client=None, homeserver_to_use=\n GenericWorkerServer)\n",
"return VAR_2\n"
] | [
"from synapse.app.generic_worker import GenericWorkerServer\n",
"from tests.server import make_request\n",
"from tests.unittest import HomeserverTestCase\n",
"def make_homeserver(self, reactor, clock):...\n",
"hs = self.setup_test_homeserver(http_client=None, homeserver_to_use=\n GenericWorkerServer)\n",
"return hs\n"
] | [
0,
0,
0,
0,
4,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_35():...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_87 = getattr(settings, 'REGISTRATION_CODE_LENGTH', 8)\n",
"return FUNC_8(VAR_87)\n"
] | [
"def random_code_generator():...\n",
"\"\"\"docstring\"\"\"\n",
"code_length = getattr(settings, 'REGISTRATION_CODE_LENGTH', 8)\n",
"return generate_random_string(code_length)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Return'"
] |
[
"import logging\n",
"import urllib\n",
"from typing import Any, Dict, Optional\n",
"from synapse.api.constants import Membership\n",
"from synapse.api.errors import Codes, HttpResponseException, SynapseError\n",
"from synapse.api.urls import FEDERATION_UNSTABLE_PREFIX, FEDERATION_V1_PREFIX, FEDERATION_V2_PREFIX\n",
"from synapse.logging.utils import log_function\n",
"VAR_0 = logging.getLogger(__name__)\n",
"\"\"\"Sends federation HTTP requests to other servers\"\"\"\n",
"def __init__(self, VAR_4):...\n",
"self.server_name = VAR_4.hostname\n",
"self.client = VAR_4.get_http_client()\n",
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_0.debug('get_room_state_ids dest=%s, room=%s', VAR_5, VAR_6)\n",
"VAR_2 = FUNC_1('/state_ids/%s', VAR_6)\n",
"return self.client.get_json(VAR_5, VAR_2=path, VAR_3={'event_id': event_id},\n try_trailing_slash_on_400=True)\n"
] | [
"import logging\n",
"import urllib\n",
"from typing import Any, Dict, Optional\n",
"from synapse.api.constants import Membership\n",
"from synapse.api.errors import Codes, HttpResponseException, SynapseError\n",
"from synapse.api.urls import FEDERATION_UNSTABLE_PREFIX, FEDERATION_V1_PREFIX, FEDERATION_V2_PREFIX\n",
"from synapse.logging.utils import log_function\n",
"logger = logging.getLogger(__name__)\n",
"\"\"\"Sends federation HTTP requests to other servers\"\"\"\n",
"def __init__(self, hs):...\n",
"self.server_name = hs.hostname\n",
"self.client = hs.get_http_client()\n",
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"logger.debug('get_room_state_ids dest=%s, room=%s', destination, room_id)\n",
"path = _create_v1_path('/state_ids/%s', room_id)\n",
"return self.client.get_json(destination, path=path, args={'event_id':\n event_id}, try_trailing_slash_on_400=True)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Docstring",
"Expr'",
"Assign'",
"Return'"
] |
[
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_0.debug('send_data dest=%s, txid=%s', VAR_11.destination, VAR_11.\n transaction_id)\n",
"if VAR_11.destination == self.server_name:\n",
"VAR_36 = VAR_11.get_dict()\n",
"VAR_2 = FUNC_1('/send/%s', VAR_11.transaction_id)\n",
"VAR_37 = await self.client.put_json(VAR_11.destination, VAR_2=path, VAR_39=\n json_data, VAR_12=json_data_callback, long_retries=True, backoff_on_404\n =True, try_trailing_slash_on_400=True)\n",
"return VAR_37\n"
] | [
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"logger.debug('send_data dest=%s, txid=%s', transaction.destination,\n transaction.transaction_id)\n",
"if transaction.destination == self.server_name:\n",
"json_data = transaction.get_dict()\n",
"path = _create_v1_path('/send/%s', transaction.transaction_id)\n",
"response = await self.client.put_json(transaction.destination, path=path,\n data=json_data, json_data_callback=json_data_callback, long_retries=\n True, backoff_on_404=True, try_trailing_slash_on_400=True)\n",
"return response\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_9(self, VAR_24):...\n",
"return self.widget.id_for_label(VAR_24)\n"
] | [
"def id_for_label(self, id_):...\n",
"return self.widget.id_for_label(id_)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@VAR_0.route('/api/credentials', methods=['GET'])...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_108 = FUNC_58('/internal/credentials', 'get')\n",
"return jsonify({'success': False, 'message': str(err)}), 400\n",
"return jsonify(VAR_108)\n"
] | [
"@gui.route('/api/credentials', methods=['GET'])...\n",
"\"\"\"docstring\"\"\"\n",
"credentials_info = query_internal_api('/internal/credentials', 'get')\n",
"return jsonify({'success': False, 'message': str(err)}), 400\n",
"return jsonify(credentials_info)\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'",
"Return'"
] |
[
"def FUNC_10(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_20 = signedjson.key.generate_signing_key(1)\n",
"async def FUNC_24(VAR_23):...\n",
"self.assertEqual(VAR_23, {'server1': {FUNC_0(VAR_20): 1500}})\n",
"return {'server1': {FUNC_0(VAR_20): FetchKeyResult(get_verify_key(VAR_20), \n 1200)}}\n"
] | [
"def test_verify_json_dedupes_key_requests(self):...\n",
"\"\"\"docstring\"\"\"\n",
"key1 = signedjson.key.generate_signing_key(1)\n",
"async def get_keys(keys_to_fetch):...\n",
"self.assertEqual(keys_to_fetch, {'server1': {get_key_id(key1): 1500}})\n",
"return {'server1': {get_key_id(key1): FetchKeyResult(get_verify_key(key1), \n 1200)}}\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"AsyncFunctionDef'",
"Expr'",
"Return'"
] |
[
"async def FUNC_9(self, VAR_17: str, VAR_16: str, VAR_30: bool=False, VAR_29:...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_10 = CLASS_0(VAR_15='DELETE', VAR_17=destination, VAR_16=path, VAR_20=args)\n",
"VAR_12 = self.clock.time_msec()\n",
"VAR_11 = await self._send_request(VAR_10, VAR_30=long_retries, VAR_29=\n timeout, VAR_31=ignore_backoff)\n",
"if VAR_29 is not None:\n",
"VAR_61 = VAR_29 / 1000\n",
"VAR_61 = self.default_timeout\n",
"VAR_47 = await FUNC_0(self.reactor, VAR_61, VAR_10, VAR_11, VAR_12)\n",
"return VAR_47\n"
] | [
"async def delete_json(self, destination: str, path: str, long_retries: bool...\n",
"\"\"\"docstring\"\"\"\n",
"request = MatrixFederationRequest(method='DELETE', destination=destination,\n path=path, query=args)\n",
"start_ms = self.clock.time_msec()\n",
"response = await self._send_request(request, long_retries=long_retries,\n timeout=timeout, ignore_backoff=ignore_backoff)\n",
"if timeout is not None:\n",
"_sec_timeout = timeout / 1000\n",
"_sec_timeout = self.default_timeout\n",
"body = await _handle_json_response(self.reactor, _sec_timeout, request,\n response, start_ms)\n",
"return body\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_30(self):...\n",
"self.parser = saved_model_cli.create_parser()\n",
"VAR_9 = test.test_src_dir_path(VAR_0)\n",
"VAR_41 = os.path.join(test.get_temp_dir(), 'new_dir')\n",
"VAR_10 = self.parser.parse_args(['run', '--dir', VAR_9, '--tag_set',\n 'serve', '--signature_def', 'regress_x_to_y', '--input_examples',\n 'inputs=[{\"x\":[[1],[2]]}]', '--outdir', VAR_41])\n",
"saved_model_cli.run(VAR_10)\n"
] | [
"def testRunCommandInputExamplesFeatureBadType(self):...\n",
"self.parser = saved_model_cli.create_parser()\n",
"base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n",
"output_dir = os.path.join(test.get_temp_dir(), 'new_dir')\n",
"args = self.parser.parse_args(['run', '--dir', base_path, '--tag_set',\n 'serve', '--signature_def', 'regress_x_to_y', '--input_examples',\n 'inputs=[{\"x\":[[1],[2]]}]', '--outdir', output_dir])\n",
"saved_model_cli.run(args)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"async def FUNC_5(self):...\n",
"if hasattr(self, 'resolved_ref'):\n",
"return self.resolved_ref\n",
"VAR_44 = urllib.parse.quote(self.namespace, safe='')\n",
"VAR_33 = AsyncHTTPClient()\n",
"VAR_28 = (\n 'https://{hostname}/api/v4/projects/{namespace}/repository/commits/{ref}'\n .format(VAR_19=self.hostname, VAR_44=namespace, ref=urllib.parse.quote(\n self.unresolved_ref, safe='')))\n",
"self.log.debug('Fetching %s', VAR_28)\n",
"if self.auth:\n",
"VAR_28 = url_concat(VAR_28, self.auth)\n",
"VAR_41 = await VAR_33.fetch(VAR_28, user_agent='BinderHub')\n",
"if e.code == 404:\n",
"VAR_45 = json.loads(VAR_41.body.decode('utf-8'))\n",
"return None\n",
"self.resolved_ref = VAR_45['id']\n",
"return self.resolved_ref\n"
] | [
"async def get_resolved_ref(self):...\n",
"if hasattr(self, 'resolved_ref'):\n",
"return self.resolved_ref\n",
"namespace = urllib.parse.quote(self.namespace, safe='')\n",
"client = AsyncHTTPClient()\n",
"api_url = (\n 'https://{hostname}/api/v4/projects/{namespace}/repository/commits/{ref}'\n .format(hostname=self.hostname, namespace=namespace, ref=urllib.parse.\n quote(self.unresolved_ref, safe='')))\n",
"self.log.debug('Fetching %s', api_url)\n",
"if self.auth:\n",
"api_url = url_concat(api_url, self.auth)\n",
"resp = await client.fetch(api_url, user_agent='BinderHub')\n",
"if e.code == 404:\n",
"ref_info = json.loads(resp.body.decode('utf-8'))\n",
"return None\n",
"self.resolved_ref = ref_info['id']\n",
"return self.resolved_ref\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"AsyncFunctionDef'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Return'"
] |
[
"def FUNC_3(self, VAR_1):...\n",
"from openapi_python_client.parser.properties import UnionProperty\n",
"VAR_13 = VAR_1.MagicMock()\n",
"VAR_15 = VAR_1.MagicMock()\n",
"VAR_13.get_imports.return_value = {VAR_15}\n",
"VAR_14 = VAR_1.MagicMock()\n",
"VAR_16 = VAR_1.MagicMock()\n",
"VAR_14.get_imports.return_value = {VAR_16}\n",
"VAR_9 = VAR_1.MagicMock()\n",
"VAR_4 = VAR_33(VAR_5='test', VAR_26=True, default=None, inner_properties=[\n inner_property_1, inner_property_2])\n",
"assert VAR_4.get_imports(VAR_9=prefix) == {VAR_15, VAR_16,\n 'from typing import Union'}\n",
"VAR_4.required = False\n",
"assert VAR_4.get_imports(VAR_9=prefix) == {VAR_15, VAR_16,\n 'from typing import Union', 'from typing import Optional'}\n"
] | [
"def test_get_type_imports(self, mocker):...\n",
"from openapi_python_client.parser.properties import UnionProperty\n",
"inner_property_1 = mocker.MagicMock()\n",
"inner_import_1 = mocker.MagicMock()\n",
"inner_property_1.get_imports.return_value = {inner_import_1}\n",
"inner_property_2 = mocker.MagicMock()\n",
"inner_import_2 = mocker.MagicMock()\n",
"inner_property_2.get_imports.return_value = {inner_import_2}\n",
"prefix = mocker.MagicMock()\n",
"p = UnionProperty(name='test', required=True, default=None,\n inner_properties=[inner_property_1, inner_property_2])\n",
"assert p.get_imports(prefix=prefix) == {inner_import_1, inner_import_2,\n 'from typing import Union'}\n",
"p.required = False\n",
"assert p.get_imports(prefix=prefix) == {inner_import_1, inner_import_2,\n 'from typing import Union', 'from typing import Optional'}\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assert'",
"Assign'",
"Assert'"
] |
[
"@VAR_1.route('/upload', methods=['GET', 'POST'])...\n",
"if not config.config_uploading:\n",
"abort(404)\n",
"if VAR_32.method == 'POST' and 'btn-upload' in VAR_32.files:\n",
"for VAR_40 in VAR_32.files.getlist('btn-upload'):\n",
"return Response(json.dumps({'location': url_for('web.index')}), mimetype=\n 'application/json')\n",
"VAR_39 = False\n",
"calibre_db.session.rollback()\n",
"calibre_db.update_title_sort(config)\n",
"VAR_2.error('Database error: %s', e)\n",
"calibre_db.session.connection().connection.connection.create_function('uuid4',\n 0, lambda : str(uuid4()))\n",
"flash(_(u'Database error: %(error)s.', VAR_49=e), category='error')\n",
"VAR_36, VAR_49 = FUNC_34(VAR_40)\n",
"if VAR_49:\n",
"return VAR_49\n",
"VAR_41, VAR_62, VAR_70 = FUNC_33(VAR_39, VAR_36)\n",
"VAR_39 |= FUNC_19(Markup(VAR_36.description).unescape(), VAR_41)\n",
"VAR_15 = VAR_41.id\n",
"VAR_37 = VAR_41.title\n",
"VAR_49 = helper.update_dir_structure_file(VAR_15, config.config_calibre_dir,\n VAR_62[0], VAR_36.file_path, VAR_70 + VAR_36.extension.lower())\n",
"FUNC_35(VAR_36, VAR_41)\n",
"calibre_db.session.commit()\n",
"if config.config_use_google_drive:\n",
"gdriveutils.updateGdriveCalibreFromLocal()\n",
"if VAR_49:\n",
"flash(VAR_49, category='error')\n",
"VAR_110 = _(u'File %(file)s uploaded', file=title)\n",
"WorkerThread.add(current_user.name, TaskUpload('<a href=\"' + url_for(\n 'web.show_book', VAR_15=book_id) + '\">' + VAR_110 + '</a>'))\n",
"if len(VAR_32.files.getlist('btn-upload')) < 2:\n",
"if current_user.role_edit() or current_user.role_admin():\n",
"VAR_120 = {'location': url_for('editbook.edit_book', VAR_15=book_id)}\n",
"VAR_120 = {'location': url_for('web.show_book', VAR_15=book_id)}\n",
"return Response(json.dumps(VAR_120), mimetype='application/json')\n",
"return Response(json.dumps(VAR_120), mimetype='application/json')\n"
] | [
"@editbook.route('/upload', methods=['GET', 'POST'])...\n",
"if not config.config_uploading:\n",
"abort(404)\n",
"if request.method == 'POST' and 'btn-upload' in request.files:\n",
"for requested_file in request.files.getlist('btn-upload'):\n",
"return Response(json.dumps({'location': url_for('web.index')}), mimetype=\n 'application/json')\n",
"modif_date = False\n",
"calibre_db.session.rollback()\n",
"calibre_db.update_title_sort(config)\n",
"log.error('Database error: %s', e)\n",
"calibre_db.session.connection().connection.connection.create_function('uuid4',\n 0, lambda : str(uuid4()))\n",
"flash(_(u'Database error: %(error)s.', error=e), category='error')\n",
"meta, error = file_handling_on_upload(requested_file)\n",
"if error:\n",
"return error\n",
"db_book, input_authors, title_dir = create_book_on_upload(modif_date, meta)\n",
"modif_date |= edit_book_comments(Markup(meta.description).unescape(), db_book)\n",
"book_id = db_book.id\n",
"title = db_book.title\n",
"error = helper.update_dir_structure_file(book_id, config.config_calibre_dir,\n input_authors[0], meta.file_path, title_dir + meta.extension.lower())\n",
"move_coverfile(meta, db_book)\n",
"calibre_db.session.commit()\n",
"if config.config_use_google_drive:\n",
"gdriveutils.updateGdriveCalibreFromLocal()\n",
"if error:\n",
"flash(error, category='error')\n",
"uploadText = _(u'File %(file)s uploaded', file=title)\n",
"WorkerThread.add(current_user.name, TaskUpload('<a href=\"' + url_for(\n 'web.show_book', book_id=book_id) + '\">' + uploadText + '</a>'))\n",
"if len(request.files.getlist('btn-upload')) < 2:\n",
"if current_user.role_edit() or current_user.role_admin():\n",
"resp = {'location': url_for('editbook.edit_book', book_id=book_id)}\n",
"resp = {'location': url_for('web.show_book', book_id=book_id)}\n",
"return Response(json.dumps(resp), mimetype='application/json')\n",
"return Response(json.dumps(resp), mimetype='application/json')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Expr'",
"Condition",
"For",
"Return'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"AugAssign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Return'"
] |
[
"@VAR_2.route('/ajax/pathchooser/')...\n",
"return FUNC_37()\n"
] | [
"@admi.route('/ajax/pathchooser/')...\n",
"return pathchooser()\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"@FUNC_0...\n",
"return EventHandler(self)\n"
] | [
"@cache_in_self...\n",
"return EventHandler(self)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_30(VAR_27):...\n",
"print(VAR_26 + VAR_27)\n"
] | [
"def in_print(s):...\n",
"print(indent_str + s)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_4(self):...\n",
"super().clean()\n",
"if 'merge' not in self.cleaned_data:\n",
"return None\n",
"VAR_17 = self.unit\n",
"return self.cleaned_data\n",
"VAR_5 = VAR_17.translation\n",
"VAR_58 = VAR_5.component.project\n",
"self.cleaned_data['merge_unit'] = VAR_135 = Unit.objects.get(pk=self.\n cleaned_data['merge'], translation__component__project=project,\n translation__language=translation.language)\n",
"if not VAR_5.is_source and VAR_17.source != VAR_135.source:\n"
] | [
"def clean(self):...\n",
"super().clean()\n",
"if 'merge' not in self.cleaned_data:\n",
"return None\n",
"unit = self.unit\n",
"return self.cleaned_data\n",
"translation = unit.translation\n",
"project = translation.component.project\n",
"self.cleaned_data['merge_unit'] = merge_unit = Unit.objects.get(pk=self.\n cleaned_data['merge'], translation__component__project=project,\n translation__language=translation.language)\n",
"if not translation.is_source and unit.source != merge_unit.source:\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Condition",
"Return'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Condition"
] |
[
"def FUNC_60(self):...\n",
"self.register_user('user', 'test')\n",
"VAR_65 = self.login('user', 'test')\n",
"VAR_61 = self._get_aliases(VAR_65, VAR_17=403)\n",
"self.assertEqual(VAR_61['errcode'], 'M_FORBIDDEN')\n"
] | [
"def test_not_in_room(self):...\n",
"self.register_user('user', 'test')\n",
"user_tok = self.login('user', 'test')\n",
"res = self._get_aliases(user_tok, expected_code=403)\n",
"self.assertEqual(res['errcode'], 'M_FORBIDDEN')\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_15(VAR_8, VAR_7, VAR_5, VAR_9):...\n",
"VAR_10 = FUNC_14(VAR_7, VAR_8)\n",
"if VAR_8 == 'rated':\n",
"return FUNC_16(VAR_9, VAR_5, VAR_10=order)\n",
"if VAR_8 == 'discover':\n",
"return FUNC_17(VAR_9, VAR_5)\n",
"if VAR_8 == 'unread':\n",
"return FUNC_27(VAR_9, False, VAR_10=order)\n",
"if VAR_8 == 'read':\n",
"return FUNC_27(VAR_9, True, VAR_10=order)\n",
"if VAR_8 == 'hot':\n",
"return FUNC_18(VAR_9, VAR_10)\n",
"if VAR_8 == 'download':\n",
"return FUNC_19(VAR_9, VAR_10, VAR_5)\n",
"if VAR_8 == 'author':\n",
"return FUNC_20(VAR_9, VAR_5, VAR_10)\n",
"if VAR_8 == 'publisher':\n",
"return FUNC_21(VAR_9, VAR_5, VAR_10)\n",
"if VAR_8 == 'series':\n",
"return FUNC_22(VAR_9, VAR_5, VAR_10)\n",
"if VAR_8 == 'ratings':\n",
"return FUNC_23(VAR_9, VAR_5, VAR_10)\n",
"if VAR_8 == 'formats':\n",
"return FUNC_24(VAR_9, VAR_5, VAR_10)\n",
"if VAR_8 == 'category':\n",
"return FUNC_25(VAR_9, VAR_5, VAR_10)\n",
"if VAR_8 == 'language':\n",
"return FUNC_26(VAR_9, VAR_5, VAR_10)\n",
"if VAR_8 == 'archived':\n",
"return FUNC_28(VAR_9, VAR_10)\n",
"if VAR_8 == 'search':\n",
"VAR_17 = request.args.get('query') or ''\n",
"if VAR_8 == 'advsearch':\n",
"VAR_18 = int(int(config.config_books_per_page) * (VAR_9 - 1))\n",
"VAR_17 = json.loads(VAR_91['query'])\n",
"VAR_151 = VAR_8 or 'newest'\n",
"return FUNC_30(VAR_17, VAR_18, VAR_10, config.config_books_per_page)\n",
"VAR_18 = int(int(config.config_books_per_page) * (VAR_9 - 1))\n",
"VAR_63, VAR_68, VAR_65 = calibre_db.fill_indexpage(VAR_9, 0, db.Books, True,\n VAR_10[0], db.books_series_link, db.Books.id == db.books_series_link.c.\n book, db.Series)\n",
"return FUNC_57(VAR_17, VAR_18, VAR_10, config.config_books_per_page)\n",
"return render_title_template('index.html', VAR_68=random, VAR_63=entries,\n VAR_65=pagination, VAR_150=_(u'Books'), VAR_9=website, VAR_10=order[1])\n"
] | [
"def render_books_list(data, sort, book_id, page):...\n",
"order = get_sort_function(sort, data)\n",
"if data == 'rated':\n",
"return render_rated_books(page, book_id, order=order)\n",
"if data == 'discover':\n",
"return render_discover_books(page, book_id)\n",
"if data == 'unread':\n",
"return render_read_books(page, False, order=order)\n",
"if data == 'read':\n",
"return render_read_books(page, True, order=order)\n",
"if data == 'hot':\n",
"return render_hot_books(page, order)\n",
"if data == 'download':\n",
"return render_downloaded_books(page, order, book_id)\n",
"if data == 'author':\n",
"return render_author_books(page, book_id, order)\n",
"if data == 'publisher':\n",
"return render_publisher_books(page, book_id, order)\n",
"if data == 'series':\n",
"return render_series_books(page, book_id, order)\n",
"if data == 'ratings':\n",
"return render_ratings_books(page, book_id, order)\n",
"if data == 'formats':\n",
"return render_formats_books(page, book_id, order)\n",
"if data == 'category':\n",
"return render_category_books(page, book_id, order)\n",
"if data == 'language':\n",
"return render_language_books(page, book_id, order)\n",
"if data == 'archived':\n",
"return render_archived_books(page, order)\n",
"if data == 'search':\n",
"term = request.args.get('query') or ''\n",
"if data == 'advsearch':\n",
"offset = int(int(config.config_books_per_page) * (page - 1))\n",
"term = json.loads(flask_session['query'])\n",
"website = data or 'newest'\n",
"return render_search_results(term, offset, order, config.config_books_per_page)\n",
"offset = int(int(config.config_books_per_page) * (page - 1))\n",
"entries, random, pagination = calibre_db.fill_indexpage(page, 0, db.Books, \n True, order[0], db.books_series_link, db.Books.id == db.\n books_series_link.c.book, db.Series)\n",
"return render_adv_search_results(term, offset, order, config.\n config_books_per_page)\n",
"return render_title_template('index.html', random=random, entries=entries,\n pagination=pagination, title=_(u'Books'), page=website, order=order[1])\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"For",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Return'",
"Return'"
] |
[
"def FUNC_19(self):...\n",
"VAR_9 = self.cleaned_data['component']\n",
"self.fields['branch'].choices = [(x, x) for x in self.branch_data[VAR_9.pk]]\n",
"return VAR_9\n"
] | [
"def clean_component(self):...\n",
"component = self.cleaned_data['component']\n",
"self.fields['branch'].choices = [(x, x) for x in self.branch_data[component.pk]\n ]\n",
"return component\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_9(self):...\n",
"return self.repo\n"
] | [
"def get_build_slug(self):...\n",
"return self.repo\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@VAR_2.route('/<org_slug>/oauth/google', endpoint='authorize_org')...\n",
"VAR_11['org_slug'] = current_org.slug\n",
"return redirect(url_for('.authorize', next=request.args.get('next', None)))\n"
] | [
"@blueprint.route('/<org_slug>/oauth/google', endpoint='authorize_org')...\n",
"session['org_slug'] = current_org.slug\n",
"return redirect(url_for('.authorize', next=request.args.get('next', None)))\n"
] | [
4,
4,
4
] | [
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_41(VAR_105):...\n",
"return VAR_50 or VAR_104 != VAR_105.get_etag()[0]\n"
] | [
"def validate_cache(cached):...\n",
"return force_refresh or current_etag != cached.get_etag()[0]\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_11(VAR_10):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_47 = FUNC_5(VAR_10.url_without_fragment)\n",
"return os.path.isdir(VAR_47)\n"
] | [
"def is_dir_url(link):...\n",
"\"\"\"docstring\"\"\"\n",
"link_path = url_to_path(link.url_without_fragment)\n",
"return os.path.isdir(link_path)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Return'"
] |
[
"def FUNC_33(self):...\n",
"VAR_27 = widgets.AdminSplitDateTime()\n",
"VAR_27.is_localized = True\n",
"self.assertHTMLEqual(conditional_escape(VAR_27.render('test', datetime(2007,\n 12, 1, 9, 30))), 'string')\n"
] | [
"def test_localization(self):...\n",
"w = widgets.AdminSplitDateTime()\n",
"w.is_localized = True\n",
"self.assertHTMLEqual(conditional_escape(w.render('test', datetime(2007, 12,\n 1, 9, 30))),\n '<p class=\"datetime\">Datum: <input value=\"01.12.2007\" type=\"text\" class=\"vDateField\" name=\"test_0\" size=\"10\" /><br />Zeit: <input value=\"09:30:00\" type=\"text\" class=\"vTimeField\" name=\"test_1\" size=\"8\" /></p>'\n )\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def __getattr__(VAR_59, VAR_60):...\n",
"if VAR_60 == 'nameResolver':\n",
"return VAR_55\n",
"return getattr(VAR_54, VAR_60)\n"
] | [
"def __getattr__(_self, attr):...\n",
"if attr == 'nameResolver':\n",
"return nameResolver\n",
"return getattr(real_reactor, attr)\n"
] | [
0,
4,
4,
4
] | [
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"@VAR_2.route('/get_languages_json', methods=['GET'])...\n",
"VAR_56 = (request.args.get('q') or '').lower()\n",
"VAR_57 = isoLanguages.get_language_names(get_locale())\n",
"VAR_58 = [s for key, s in VAR_57.items() if s.lower().startswith(VAR_56.\n lower())]\n",
"if len(VAR_58) < 5:\n",
"VAR_63 = [s for key, s in VAR_57.items() if VAR_56 in s.lower()]\n",
"VAR_59 = json.dumps([dict(VAR_13=r) for r in VAR_58[0:5]])\n",
"VAR_58.extend(VAR_63[0:5 - len(VAR_58)])\n",
"return VAR_59\n",
"VAR_58 = list(set(VAR_58))\n"
] | [
"@web.route('/get_languages_json', methods=['GET'])...\n",
"query = (request.args.get('q') or '').lower()\n",
"language_names = isoLanguages.get_language_names(get_locale())\n",
"entries_start = [s for key, s in language_names.items() if s.lower().\n startswith(query.lower())]\n",
"if len(entries_start) < 5:\n",
"entries = [s for key, s in language_names.items() if query in s.lower()]\n",
"json_dumps = json.dumps([dict(name=r) for r in entries_start[0:5]])\n",
"entries_start.extend(entries[0:5 - len(entries_start)])\n",
"return json_dumps\n",
"entries_start = list(set(entries_start))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Return'",
"Assign'"
] |
[
"@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"
] | [
"@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
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"AugAssign'",
"Return'"
] |
[
"def FUNC_21(self, VAR_0):...\n",
"from openapi_python_client import Project\n",
"VAR_8 = Project(VAR_3=mocker.MagicMock(title='My Test API'))\n",
"VAR_8.project_dir = VAR_0.MagicMock()\n",
"VAR_21 = VAR_0.MagicMock(autospec=pathlib.Path)\n",
"VAR_22 = VAR_0.MagicMock(autospec=pathlib.Path)\n",
"VAR_23 = VAR_0.MagicMock(autospec=pathlib.Path)\n",
"VAR_20 = {'pyproject.toml': VAR_21, 'README.md': VAR_22, '.gitignore': VAR_23}\n",
"VAR_8.project_dir.__truediv__.side_effect = lambda VAR_40: VAR_20[VAR_40]\n",
"VAR_24 = VAR_0.MagicMock(autospec=jinja2.Template)\n",
"VAR_25 = VAR_0.MagicMock(autospec=jinja2.Template)\n",
"VAR_26 = VAR_0.MagicMock(autospec=jinja2.Template)\n",
"VAR_8.env = VAR_0.MagicMock(autospec=jinja2.Environment)\n",
"VAR_27 = {'pyproject.toml': VAR_24, 'README.md': VAR_25, '.gitignore': VAR_26}\n",
"VAR_8.env.get_template.side_effect = lambda VAR_40: VAR_27[VAR_40]\n",
"VAR_8._build_metadata()\n",
"VAR_8.env.get_template.assert_has_calls([VAR_0.call('pyproject.toml'),\n VAR_0.call('README.md'), VAR_0.call('.gitignore')])\n",
"VAR_24.render.assert_called_once_with(project_name=project.project_name,\n package_name=project.package_name, version=project.version, description\n =project.package_description)\n",
"VAR_21.write_text.assert_called_once_with(VAR_24.render())\n",
"VAR_25.render.assert_called_once_with(description=project.\n package_description, project_name=project.project_name, package_name=\n project.package_name)\n",
"VAR_22.write_text.assert_called_once_with(VAR_25.render())\n",
"VAR_26.render.assert_called_once()\n",
"VAR_23.write_text.assert_called_once_with(VAR_26.render())\n"
] | [
"def test__build_metadata(self, mocker):...\n",
"from openapi_python_client import Project\n",
"project = Project(openapi=mocker.MagicMock(title='My Test API'))\n",
"project.project_dir = mocker.MagicMock()\n",
"pyproject_path = mocker.MagicMock(autospec=pathlib.Path)\n",
"readme_path = mocker.MagicMock(autospec=pathlib.Path)\n",
"git_ignore_path = mocker.MagicMock(autospec=pathlib.Path)\n",
"paths = {'pyproject.toml': pyproject_path, 'README.md': readme_path,\n '.gitignore': git_ignore_path}\n",
"project.project_dir.__truediv__.side_effect = lambda x: paths[x]\n",
"pyproject_template = mocker.MagicMock(autospec=jinja2.Template)\n",
"readme_template = mocker.MagicMock(autospec=jinja2.Template)\n",
"git_ignore_template = mocker.MagicMock(autospec=jinja2.Template)\n",
"project.env = mocker.MagicMock(autospec=jinja2.Environment)\n",
"templates = {'pyproject.toml': pyproject_template, 'README.md':\n readme_template, '.gitignore': git_ignore_template}\n",
"project.env.get_template.side_effect = lambda x: templates[x]\n",
"project._build_metadata()\n",
"project.env.get_template.assert_has_calls([mocker.call('pyproject.toml'),\n mocker.call('README.md'), mocker.call('.gitignore')])\n",
"pyproject_template.render.assert_called_once_with(project_name=project.\n project_name, package_name=project.package_name, version=project.\n version, description=project.package_description)\n",
"pyproject_path.write_text.assert_called_once_with(pyproject_template.render())\n",
"readme_template.render.assert_called_once_with(description=project.\n package_description, project_name=project.project_name, package_name=\n project.package_name)\n",
"readme_path.write_text.assert_called_once_with(readme_template.render())\n",
"git_ignore_template.render.assert_called_once()\n",
"git_ignore_path.write_text.assert_called_once_with(git_ignore_template.render()\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
] | [
"FunctionDef'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(self, VAR_3, VAR_4):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_3:\n",
"self.recently_accessed_remotes.add((VAR_3, VAR_4))\n",
"self.recently_accessed_locals.add(VAR_4)\n"
] | [
"def mark_recently_accessed(self, server_name, media_id):...\n",
"\"\"\"docstring\"\"\"\n",
"if server_name:\n",
"self.recently_accessed_remotes.add((server_name, media_id))\n",
"self.recently_accessed_locals.add(media_id)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_16(self):...\n",
"VAR_22, VAR_23 = self.make_request('POST', '/createRoom',\n b'{\"visibility\":\"private\"}')\n",
"self.assertEquals(200, VAR_23.code)\n",
"self.assertTrue('room_id' in VAR_23.json_body)\n"
] | [
"def test_post_room_visibility_key(self):...\n",
"request, channel = self.make_request('POST', '/createRoom',\n b'{\"visibility\":\"private\"}')\n",
"self.assertEquals(200, channel.code)\n",
"self.assertTrue('room_id' in channel.json_body)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_72(VAR_128):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_120 = VAR_128.split('.')[0]\n",
"if not VAR_1.flags.in_install and VAR_120 not in FUNC_64():\n",
"VAR_96(FUNC_0('App {0} is not installed').format(VAR_120), AppNotInstalledError\n )\n",
"VAR_118 = '.'.join(VAR_128.split('.')[:-1])\n",
"VAR_193 = VAR_128.split('.')[-1]\n",
"return getattr(FUNC_55(VAR_118), VAR_193)\n"
] | [
"def get_attr(method_string):...\n",
"\"\"\"docstring\"\"\"\n",
"app_name = method_string.split('.')[0]\n",
"if not local.flags.in_install and app_name not in get_installed_apps():\n",
"throw(_('App {0} is not installed').format(app_name), AppNotInstalledError)\n",
"modulename = '.'.join(method_string.split('.')[:-1])\n",
"methodname = method_string.split('.')[-1]\n",
"return getattr(get_module(modulename), methodname)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@FUNC_0...\n",
"return SearchHandler(self)\n"
] | [
"@cache_in_self...\n",
"return SearchHandler(self)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_79(VAR_31, VAR_136, VAR_137=None, VAR_138=None, VAR_5=None,...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_1.message_title = VAR_31\n",
"VAR_1.message = VAR_136\n",
"VAR_1.response['type'] = 'page'\n",
"VAR_1.response['route'] = VAR_78\n",
"VAR_1.no_cache = 1\n",
"if VAR_138:\n",
"VAR_1.response['http_status_code'] = VAR_138\n",
"if not VAR_5:\n",
"VAR_5 = {}\n",
"if not VAR_139:\n",
"if VAR_137:\n",
"VAR_5['indicator_color'] = VAR_139\n",
"VAR_139 = 'green'\n",
"if VAR_138 and VAR_138 > 300:\n",
"VAR_5['primary_label'] = VAR_140\n",
"VAR_139 = 'red'\n",
"VAR_139 = 'blue'\n",
"VAR_5['primary_action'] = VAR_37\n",
"VAR_5['error_code'] = VAR_138\n",
"VAR_5['fullpage'] = VAR_141\n",
"if VAR_142:\n",
"VAR_5['card_width'] = VAR_142\n",
"VAR_1.response['context'] = VAR_5\n"
] | [
"def respond_as_web_page(title, html, success=None, http_status_code=None,...\n",
"\"\"\"docstring\"\"\"\n",
"local.message_title = title\n",
"local.message = html\n",
"local.response['type'] = 'page'\n",
"local.response['route'] = template\n",
"local.no_cache = 1\n",
"if http_status_code:\n",
"local.response['http_status_code'] = http_status_code\n",
"if not context:\n",
"context = {}\n",
"if not indicator_color:\n",
"if success:\n",
"context['indicator_color'] = indicator_color\n",
"indicator_color = 'green'\n",
"if http_status_code and http_status_code > 300:\n",
"context['primary_label'] = primary_label\n",
"indicator_color = 'red'\n",
"indicator_color = 'blue'\n",
"context['primary_action'] = primary_action\n",
"context['error_code'] = http_status_code\n",
"context['fullpage'] = fullpage\n",
"if width:\n",
"context['card_width'] = width\n",
"local.response['context'] = context\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
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'"
] |
[
"import logging\n",
"from mock import Mock\n",
"from synapse.api.constants import EventTypes, Membership\n",
"from synapse.events.builder import EventBuilderFactory\n",
"from synapse.rest.admin import register_servlets_for_client_rest_resource\n",
"from synapse.rest.client.v1 import login, room\n",
"from synapse.types import UserID, create_requester\n",
"from tests.replication._base import BaseMultiWorkerStreamTestCase\n",
"from tests.test_utils import make_awaitable\n",
"VAR_0 = logging.getLogger(__name__)\n",
"VAR_1 = [login.register_servlets,\n register_servlets_for_client_rest_resource, VAR_7.register_servlets]\n",
"def FUNC_0(self):...\n",
"VAR_5 = super().default_config()\n",
"VAR_5['send_federation'] = False\n",
"return VAR_5\n"
] | [
"import logging\n",
"from mock import Mock\n",
"from synapse.api.constants import EventTypes, Membership\n",
"from synapse.events.builder import EventBuilderFactory\n",
"from synapse.rest.admin import register_servlets_for_client_rest_resource\n",
"from synapse.rest.client.v1 import login, room\n",
"from synapse.types import UserID, create_requester\n",
"from tests.replication._base import BaseMultiWorkerStreamTestCase\n",
"from tests.test_utils import make_awaitable\n",
"logger = logging.getLogger(__name__)\n",
"servlets = [login.register_servlets,\n register_servlets_for_client_rest_resource, room.register_servlets]\n",
"def default_config(self):...\n",
"conf = super().default_config()\n",
"conf['send_federation'] = False\n",
"return conf\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_0(VAR_2):...\n",
"return len([VAR_69 for VAR_69 in VAR_2.split('\\n') if VAR_69.strip() and \n not VAR_69.startswith('#')])\n"
] | [
"def count_lines(data):...\n",
"return len([line for line in data.split('\\n') if line.strip() and not line.\n startswith('#')])\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_14(VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_17 = QUrlQuery(VAR_3)\n",
"VAR_24 = VAR_17.queryItemValue('option', QUrl.FullyDecoded)\n",
"VAR_25 = VAR_17.queryItemValue('value', QUrl.FullyDecoded)\n",
"if VAR_24 == 'content.javascript.enabled' and VAR_25 == 'false':\n",
"VAR_40 = (\n 'Refusing to disable javascript via qute://settings as it needs javascript support.'\n )\n",
"config.instance.set_str(VAR_24, VAR_25, save_yaml=True)\n",
"message.error(str(e))\n",
"message.error(VAR_40)\n",
"return 'text/html', b'ok'\n",
"return 'text/html', b'error: ' + str(e).encode('utf-8')\n",
"return 'text/html', b'error: ' + VAR_40.encode('utf-8')\n"
] | [
"def _qute_settings_set(url):...\n",
"\"\"\"docstring\"\"\"\n",
"query = QUrlQuery(url)\n",
"option = query.queryItemValue('option', QUrl.FullyDecoded)\n",
"value = query.queryItemValue('value', QUrl.FullyDecoded)\n",
"if option == 'content.javascript.enabled' and value == 'false':\n",
"msg = (\n 'Refusing to disable javascript via qute://settings as it needs javascript support.'\n )\n",
"config.instance.set_str(option, value, save_yaml=True)\n",
"message.error(str(e))\n",
"message.error(msg)\n",
"return 'text/html', b'ok'\n",
"return 'text/html', b'error: ' + str(e).encode('utf-8')\n",
"return 'text/html', b'error: ' + msg.encode('utf-8')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Return'",
"Return'",
"Return'"
] |
[
"def FUNC_32(VAR_87):...\n",
"VAR_86.update(to_bytes(VAR_87, encoding='utf-8', errors='replace'))\n"
] | [
"def hash_update(value):...\n",
"hash.update(to_bytes(value, encoding='utf-8', errors='replace'))\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_16(self, VAR_0, VAR_1):...\n",
"VAR_2 = self.setup_test_homeserver('server', http_client=None,\n federation_sender=Mock())\n",
"return VAR_2\n"
] | [
"def make_homeserver(self, reactor, clock):...\n",
"hs = self.setup_test_homeserver('server', http_client=None,\n federation_sender=Mock())\n",
"return hs\n"
] | [
0,
4,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_6(VAR_21, VAR_28, VAR_29):...\n",
"VAR_67 = VAR_21.split()\n",
"for VAR_31 in VAR_67:\n",
"if len(VAR_31) > VAR_28:\n",
"return VAR_21\n",
"VAR_98 = FUNC_7(VAR_31, VAR_28, VAR_29)\n",
"VAR_21 = VAR_21.replace(VAR_31, VAR_98)\n"
] | [
"def _break_text(text, max_width, break_character):...\n",
"words = text.split()\n",
"for word in words:\n",
"if len(word) > max_width:\n",
"return text\n",
"replacement = _insert_break(word, max_width, break_character)\n",
"text = text.replace(word, replacement)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Condition",
"Return'",
"Assign'",
"Assign'"
] |
[
"def FUNC_3(self):...\n",
"import pytest\n",
"sys.exit(pytest.main(self.pytest_args))\n"
] | [
"def run_tests(self):...\n",
"import pytest\n",
"sys.exit(pytest.main(self.pytest_args))\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Import'",
"Expr'"
] |
[
"@expose('/show/<pk>', methods=['GET'])...\n",
"VAR_44 = dict()\n",
"VAR_44['resetpasswords'] = self.actions.get('resetpasswords')\n",
"VAR_21 = self.datamodel.get(VAR_23, self._base_filters)\n",
"if not VAR_21:\n",
"abort(404)\n",
"VAR_43 = self._get_show_widget(VAR_23, VAR_21, VAR_44=actions)\n",
"self.update_redirect()\n",
"return self.render_template(self.show_template, VAR_23=pk, VAR_37=self.\n show_title, VAR_43=widgets, appbuilder=self.appbuilder, related_views=\n self._related_views)\n"
] | [
"@expose('/show/<pk>', methods=['GET'])...\n",
"actions = dict()\n",
"actions['resetpasswords'] = self.actions.get('resetpasswords')\n",
"item = self.datamodel.get(pk, self._base_filters)\n",
"if not item:\n",
"abort(404)\n",
"widgets = self._get_show_widget(pk, item, actions=actions)\n",
"self.update_redirect()\n",
"return self.render_template(self.show_template, pk=pk, title=self.\n show_title, widgets=widgets, appbuilder=self.appbuilder, related_views=\n self._related_views)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"return CLASS_7()\n"
] | [
"def _makeEngine(self):...\n",
"return DummyEngine()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_23(self):...\n",
"assert join('/foo/bar/') == '/foo/bar'\n",
"assert join('/foo/bar/', None) == '/foo/bar'\n",
"assert join('/foo/bar/', '/') == '/foo/bar'\n",
"assert join('/foo', 'bar/') == '/foo/bar'\n"
] | [
"def test_it_strips_trailing_slash(self):...\n",
"assert join('/foo/bar/') == '/foo/bar'\n",
"assert join('/foo/bar/', None) == '/foo/bar'\n",
"assert join('/foo/bar/', '/') == '/foo/bar'\n",
"assert join('/foo', 'bar/') == '/foo/bar'\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assert'",
"Assert'",
"Assert'",
"Assert'"
] |
[
"\"\"\"string\"\"\"\n",
"import jwt\n",
"import base64\n",
"import requests\n",
"from flask import Blueprint, current_app, redirect, request\n",
"from flask.ext.restful import reqparse, Resource, Api\n",
"from flask.ext.principal import Identity, identity_changed\n",
"from flask_login import login_user\n",
"from onelogin.saml2.auth import OneLogin_Saml2_Auth\n",
"VAR_2 = False\n",
"from .service import fetch_token_header_payload, get_rsa_public_key\n",
"from onelogin.saml2.utils import OneLogin_Saml2_Utils\n",
"from security_monkey.datastore import User\n",
"VAR_2 = True\n",
"from security_monkey import db, rbac\n",
"from urlparse import urlparse\n",
"VAR_0 = Blueprint('sso', __name__)\n",
"VAR_1 = Api(VAR_0)\n",
"from flask_security.utils import validate_redirect_url\n",
"\"\"\"string\"\"\"\n",
"VAR_3 = [rbac.allow(['anonymous'], ['GET', 'POST'])]\n",
"def __init__(self):...\n",
"self.reqparse = reqparse.RequestParser()\n",
"super(CLASS_0, self).__init__()\n",
"def FUNC_0(self):...\n",
"return self.post()\n"
] | [
"\"\"\"\n.. module: security_monkey.sso.views\n :platform: Unix\n :copyright: (c) 2015 by Netflix Inc., see AUTHORS for more\n :license: Apache, see LICENSE for more details.\n.. moduleauthor:: Patrick Kelley <[email protected]>\n\"\"\"\n",
"import jwt\n",
"import base64\n",
"import requests\n",
"from flask import Blueprint, current_app, redirect, request\n",
"from flask.ext.restful import reqparse, Resource, Api\n",
"from flask.ext.principal import Identity, identity_changed\n",
"from flask_login import login_user\n",
"from onelogin.saml2.auth import OneLogin_Saml2_Auth\n",
"onelogin_import_success = False\n",
"from .service import fetch_token_header_payload, get_rsa_public_key\n",
"from onelogin.saml2.utils import OneLogin_Saml2_Utils\n",
"from security_monkey.datastore import User\n",
"onelogin_import_success = True\n",
"from security_monkey import db, rbac\n",
"from urlparse import urlparse\n",
"mod = Blueprint('sso', __name__)\n",
"api = Api(mod)\n",
"from flask_security.utils import validate_redirect_url\n",
"\"\"\"\n This class serves as an example of how one might implement an SSO provider for use with Security Monkey. In\n this example we use a OpenIDConnect authentication flow, that is essentially OAuth2 underneath.\n \"\"\"\n",
"decorators = [rbac.allow(['anonymous'], ['GET', 'POST'])]\n",
"def __init__(self):...\n",
"self.reqparse = reqparse.RequestParser()\n",
"super(Ping, self).__init__()\n",
"def get(self):...\n",
"return self.post()\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
] | [
"Expr'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"ImportFrom'",
"Expr'",
"Assign'",
"FunctionDef'",
"Assign'",
"Expr'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_1(*VAR_2, **VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_47 = []\n",
"VAR_47 += [(arg, None) for arg in VAR_2]\n",
"VAR_47 += [(VAR_160, VAR_3[VAR_160]) for VAR_160 in VAR_3]\n",
"def FUNC_84(VAR_1):...\n",
"def FUNC_83(*VAR_2, **VAR_3):...\n",
"VAR_9 = VAR_2[0]\n",
"VAR_193 = {'error': 'Missing required query parameter(s)', 'parameters': [],\n 'info': {}}\n",
"for VAR_209, extra in VAR_47:\n",
"VAR_199 = object()\n",
"if len(VAR_193['parameters']) > 0:\n",
"if VAR_9.GET.get(VAR_209, VAR_199) == VAR_199:\n",
"return JsonResponse(VAR_193, status=400)\n",
"return VAR_1(*VAR_2, **kwargs)\n",
"VAR_193['parameters'].append(VAR_209)\n",
"VAR_193['info'][VAR_209] = extra\n"
] | [
"def require_query_params(*args, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"required_params = []\n",
"required_params += [(arg, None) for arg in args]\n",
"required_params += [(key, kwargs[key]) for key in kwargs]\n",
"def decorator(func):...\n",
"def wrapped(*args, **kwargs):...\n",
"request = args[0]\n",
"error_response_data = {'error': 'Missing required query parameter(s)',\n 'parameters': [], 'info': {}}\n",
"for param, extra in required_params:\n",
"default = object()\n",
"if len(error_response_data['parameters']) > 0:\n",
"if request.GET.get(param, default) == default:\n",
"return JsonResponse(error_response_data, status=400)\n",
"return func(*args, **kwargs)\n",
"error_response_data['parameters'].append(param)\n",
"error_response_data['info'][param] = extra\n"
] | [
0,
0,
3,
3,
3,
0,
0,
3,
3,
3,
3,
3,
3,
3,
3,
3,
3
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"AugAssign'",
"AugAssign'",
"FunctionDef'",
"FunctionDef'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Condition",
"Condition",
"Return'",
"Return'",
"Expr'",
"Assign'"
] |
[
"def FUNC_83(VAR_9, VAR_10):...\n",
""
] | [
"def wrapped(request, course_id):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"@app.route('/dataobj/move/<int:dataobj_id>', methods=['POST'])...\n",
"VAR_9 = forms.MoveItemForm()\n",
"VAR_21 = VAR_9.path.data if VAR_9.path.data != '' else 'root directory'\n",
"if VAR_9.path.data == None:\n",
"flash('No path specified.')\n",
"if data.move_item(VAR_1, VAR_9.path.data):\n",
"flash('Data not found.', 'error')\n",
"return redirect(f'/dataobj/{VAR_1}')\n",
"flash(f'Data successfully moved to {VAR_21}.', 'success')\n",
"flash(f'Data could not be moved to {VAR_21}.', 'error')\n",
"return redirect('/')\n",
"return redirect(f'/dataobj/{VAR_1}')\n",
"return redirect(f'/dataobj/{VAR_1}')\n"
] | [
"@app.route('/dataobj/move/<int:dataobj_id>', methods=['POST'])...\n",
"form = forms.MoveItemForm()\n",
"out_dir = form.path.data if form.path.data != '' else 'root directory'\n",
"if form.path.data == None:\n",
"flash('No path specified.')\n",
"if data.move_item(dataobj_id, form.path.data):\n",
"flash('Data not found.', 'error')\n",
"return redirect(f'/dataobj/{dataobj_id}')\n",
"flash(f'Data successfully moved to {out_dir}.', 'success')\n",
"flash(f'Data could not be moved to {out_dir}.', 'error')\n",
"return redirect('/')\n",
"return redirect(f'/dataobj/{dataobj_id}')\n",
"return redirect(f'/dataobj/{dataobj_id}')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Return'",
"Expr'",
"Expr'",
"Return'",
"Return'",
"Return'"
] |
[
"def FUNC_10(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_86 = socket.socket()\n",
"VAR_86.bind(('localhost', 0))\n",
"self.log.warn(\"\"\"Cannot bind to localhost, using 127.0.0.1 as default ip\n%s\"\"\",\n e)\n",
"VAR_86.close()\n",
"return '127.0.0.1'\n",
"return 'localhost'\n"
] | [
"def _ip_default(self):...\n",
"\"\"\"docstring\"\"\"\n",
"s = socket.socket()\n",
"s.bind(('localhost', 0))\n",
"self.log.warn(\"\"\"Cannot bind to localhost, using 127.0.0.1 as default ip\n%s\"\"\",\n e)\n",
"s.close()\n",
"return '127.0.0.1'\n",
"return 'localhost'\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Return'",
"Return'"
] |
[
"def FUNC_11(VAR_13, VAR_16):...\n",
"\"\"\"docstring\"\"\"\n",
"return bool(FUNC_9(VAR_13['pki_dir'], VAR_16)) and FUNC_10(VAR_16)\n",
"return False\n"
] | [
"def valid_id(opts, id_):...\n",
"\"\"\"docstring\"\"\"\n",
"return bool(clean_path(opts['pki_dir'], id_)) and clean_id(id_)\n",
"return False\n"
] | [
0,
0,
1,
0
] | [
"FunctionDef'",
"Docstring",
"Return'",
"Return'"
] |
[
"def FUNC_1(self, VAR_3, VAR_4, VAR_11):...\n",
"self.room_owner = self.register_user('room_owner', 'test')\n",
"self.room_owner_tok = self.login('room_owner', 'test')\n",
"self.room_id = self.helper.create_room_as(self.room_owner, VAR_52=self.\n room_owner_tok)\n"
] | [
"def prepare(self, reactor, clock, homeserver):...\n",
"self.room_owner = self.register_user('room_owner', 'test')\n",
"self.room_owner_tok = self.login('room_owner', 'test')\n",
"self.room_id = self.helper.create_room_as(self.room_owner, tok=self.\n room_owner_tok)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"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\n",
"from archivy.helpers import get_db, write_config\n",
"from archivy.tags import get_all_tags\n",
"from archivy.search import search\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\n",
"from archivy.helpers import get_db, write_config\n",
"from archivy.tags import get_all_tags\n",
"from archivy.search import search\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_7(self, VAR_5: SynapseRequest, VAR_6: str):...\n",
"\"\"\"docstring\"\"\"\n",
"self.assertRegex(VAR_5.path, \n b'^/_synapse/replication/get_repl_stream_updates/%s/[^/]+$' % (VAR_6.\n encode('ascii'),))\n",
"self.assertEqual(VAR_5.method, b'GET')\n"
] | [
"def assert_request_is_get_repl_stream_updates(self, request: SynapseRequest,...\n",
"\"\"\"docstring\"\"\"\n",
"self.assertRegex(request.path, \n b'^/_synapse/replication/get_repl_stream_updates/%s/[^/]+$' % (\n stream_name.encode('ascii'),))\n",
"self.assertEqual(request.method, b'GET')\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Expr'"
] |
[
"def __init__(self, VAR_8, VAR_9):...\n",
"self.hs = VAR_8\n",
"self.store = self.hs.get_datastore()\n",
"self.storage = self.hs.get_storage()\n",
"self.clock = self.hs.get_clock()\n",
"self.state_handler = self.hs.get_state_handler()\n",
"self.user_id = VAR_9['user_name']\n",
"self.app_id = VAR_9['app_id']\n",
"self.app_display_name = VAR_9['app_display_name']\n",
"self.device_display_name = VAR_9['device_display_name']\n",
"self.pushkey = VAR_9['pushkey']\n",
"self.pushkey_ts = VAR_9['ts']\n",
"self.data = VAR_9['data']\n",
"self.last_stream_ordering = VAR_9['last_stream_ordering']\n",
"self.backoff_delay = CLASS_0.INITIAL_BACKOFF_SEC\n",
"self.failing_since = VAR_9['failing_since']\n",
"self.timed_call = None\n",
"self._is_processing = False\n",
"self._group_unread_count_by_room = VAR_8.config.push_group_unread_count_by_room\n",
"self.max_stream_ordering = None\n",
"if 'data' not in VAR_9:\n",
"self.data = VAR_9['data']\n",
"self.name = '%s/%s/%s' % (VAR_9['user_name'], VAR_9['app_id'], VAR_9['pushkey']\n )\n",
"if self.data is None:\n",
"if 'url' not in self.data:\n",
"self.url = self.data['url']\n",
"self.http_client = VAR_8.get_proxied_http_client()\n",
"self.data_minus_url = {}\n",
"self.data_minus_url.update(self.data)\n"
] | [
"def __init__(self, hs, pusherdict):...\n",
"self.hs = hs\n",
"self.store = self.hs.get_datastore()\n",
"self.storage = self.hs.get_storage()\n",
"self.clock = self.hs.get_clock()\n",
"self.state_handler = self.hs.get_state_handler()\n",
"self.user_id = pusherdict['user_name']\n",
"self.app_id = pusherdict['app_id']\n",
"self.app_display_name = pusherdict['app_display_name']\n",
"self.device_display_name = pusherdict['device_display_name']\n",
"self.pushkey = pusherdict['pushkey']\n",
"self.pushkey_ts = pusherdict['ts']\n",
"self.data = pusherdict['data']\n",
"self.last_stream_ordering = pusherdict['last_stream_ordering']\n",
"self.backoff_delay = HttpPusher.INITIAL_BACKOFF_SEC\n",
"self.failing_since = pusherdict['failing_since']\n",
"self.timed_call = None\n",
"self._is_processing = False\n",
"self._group_unread_count_by_room = hs.config.push_group_unread_count_by_room\n",
"self.max_stream_ordering = None\n",
"if 'data' not in pusherdict:\n",
"self.data = pusherdict['data']\n",
"self.name = '%s/%s/%s' % (pusherdict['user_name'], pusherdict['app_id'],\n pusherdict['pushkey'])\n",
"if self.data is None:\n",
"if 'url' not in self.data:\n",
"self.url = self.data['url']\n",
"self.http_client = hs.get_proxied_http_client()\n",
"self.data_minus_url = {}\n",
"self.data_minus_url.update(self.data)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_3(VAR_1: Any) ->List[Tuple[str, Tuple, Any]]:...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_20 = inspect.signature(VAR_1).parameters\n",
"VAR_21 = []\n",
"for arg in VAR_20:\n",
"VAR_31 = VAR_20[arg].annotation\n",
"return VAR_21\n",
"VAR_32 = VAR_20[arg].default\n",
"VAR_36 = tuple(VAR_31.__args__)\n",
"VAR_36 = VAR_31,\n",
"VAR_21.append((arg, VAR_36, VAR_32))\n"
] | [
"def get_init_arguments_and_types(cls: Any) ->List[Tuple[str, Tuple, Any]]:...\n",
"\"\"\"docstring\"\"\"\n",
"cls_default_params = inspect.signature(cls).parameters\n",
"name_type_default = []\n",
"for arg in cls_default_params:\n",
"arg_type = cls_default_params[arg].annotation\n",
"return name_type_default\n",
"arg_default = cls_default_params[arg].default\n",
"arg_types = tuple(arg_type.__args__)\n",
"arg_types = arg_type,\n",
"name_type_default.append((arg, arg_types, arg_default))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"For",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_61(self, VAR_49, VAR_62, VAR_14):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_49 = FUNC_3(VAR_49)\n",
"if not VAR_62:\n",
"return '<a href=\"%s\">%s</a>' % (VAR_49, VAR_14)\n",
"VAR_62 = VAR_19(VAR_62, VAR_15=True)\n",
"return '<a href=\"%s\" title=\"%s\">%s</a>' % (VAR_49, VAR_62, VAR_14)\n"
] | [
"def link(self, link, title, text):...\n",
"\"\"\"docstring\"\"\"\n",
"link = escape_link(link)\n",
"if not title:\n",
"return '<a href=\"%s\">%s</a>' % (link, text)\n",
"title = escape(title, quote=True)\n",
"return '<a href=\"%s\" title=\"%s\">%s</a>' % (link, title, text)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Return'"
] |
[
"def FUNC_7(self, VAR_8, **VAR_4):...\n",
"VAR_8 = int(VAR_8)\n",
"if len(self.layout.rows[VAR_8].cells) >= VAR_0:\n",
"if not 0 <= VAR_8 < len(self.layout.rows):\n",
"return\n",
"self.layout.rows[VAR_8].add_cell()\n",
"self.save_layout()\n"
] | [
"def dispatch_add_cell(self, y, **kwargs):...\n",
"y = int(y)\n",
"if len(self.layout.rows[y].cells) >= ROW_CELL_LIMIT:\n",
"if not 0 <= y < len(self.layout.rows):\n",
"return\n",
"self.layout.rows[y].add_cell()\n",
"self.save_layout()\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Condition",
"Return'",
"Expr'",
"Expr'"
] |
[
"def FUNC_94(VAR_153, VAR_46, VAR_154, VAR_155=False):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_153 not in VAR_1.cache:\n",
"VAR_1.cache[VAR_153] = {}\n",
"if VAR_46 not in VAR_1.cache[VAR_153]:\n",
"VAR_1.cache[VAR_153][VAR_46] = VAR_154()\n",
"if VAR_1.cache[VAR_153][VAR_46] == None and VAR_155:\n",
"return VAR_1.cache[VAR_153][VAR_46]\n",
"VAR_1.cache[VAR_153][VAR_46] = VAR_154()\n"
] | [
"def local_cache(namespace, key, generator, regenerate_if_none=False):...\n",
"\"\"\"docstring\"\"\"\n",
"if namespace not in local.cache:\n",
"local.cache[namespace] = {}\n",
"if key not in local.cache[namespace]:\n",
"local.cache[namespace][key] = generator()\n",
"if local.cache[namespace][key] == None and regenerate_if_none:\n",
"return local.cache[namespace][key]\n",
"local.cache[namespace][key] = generator()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Assign'"
] |
[
"def __init__(self, **VAR_7):...\n",
"VAR_7['attrs'] = {'dir': 'auto', 'class':\n 'markdown-editor highlight-editor', 'data-mode': 'markdown'}\n",
"super().__init__(**kwargs)\n"
] | [
"def __init__(self, **kwargs):...\n",
"kwargs['attrs'] = {'dir': 'auto', 'class':\n 'markdown-editor highlight-editor', 'data-mode': 'markdown'}\n",
"super().__init__(**kwargs)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_90(VAR_62=None, VAR_9=None, VAR_146=None, VAR_147=None, VAR_136=...\n",
"\"\"\"docstring\"\"\"\n",
"from frappe.website.render import build_page\n",
"from frappe.utils.pdf import get_pdf\n",
"VAR_1.form_dict.doctype = VAR_62\n",
"VAR_1.form_dict.name = VAR_9\n",
"VAR_1.form_dict.format = VAR_146\n",
"VAR_1.form_dict.style = VAR_147\n",
"VAR_1.form_dict.doc = VAR_94\n",
"VAR_1.form_dict.no_letterhead = VAR_150\n",
"VAR_198 = None\n",
"if VAR_151:\n",
"VAR_198 = {'password': VAR_151}\n",
"if not VAR_136:\n",
"VAR_136 = build_page('printview')\n",
"if VAR_148:\n",
"return get_pdf(VAR_136, VAR_149=output, VAR_198=options)\n",
"return VAR_136\n"
] | [
"def get_print(doctype=None, name=None, print_format=None, style=None, html=...\n",
"\"\"\"docstring\"\"\"\n",
"from frappe.website.render import build_page\n",
"from frappe.utils.pdf import get_pdf\n",
"local.form_dict.doctype = doctype\n",
"local.form_dict.name = name\n",
"local.form_dict.format = print_format\n",
"local.form_dict.style = style\n",
"local.form_dict.doc = doc\n",
"local.form_dict.no_letterhead = no_letterhead\n",
"options = None\n",
"if password:\n",
"options = {'password': password}\n",
"if not html:\n",
"html = build_page('printview')\n",
"if as_pdf:\n",
"return get_pdf(html, output=output, options=options)\n",
"return html\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_82(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if hasattr(self, '_wiki'\n",
"self._wiki.automenu()\n"
] | [
"def wikimenu(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if hasattr(self, '_wiki'\n",
"self._wiki.automenu()\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'"
] |
[
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = FUNC_1('/user/devices/%s', VAR_16)\n",
"VAR_19 = await self.client.get_json(VAR_5=destination, VAR_2=path, VAR_8=\n timeout)\n",
"return VAR_19\n"
] | [
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"path = _create_v1_path('/user/devices/%s', user_id)\n",
"content = await self.client.get_json(destination=destination, path=path,\n timeout=timeout)\n",
"return content\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_17(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.reactor.advance(100)\n",
"VAR_35 = PerspectivesKeyFetcher(self.hs)\n",
"VAR_34 = self.mock_perspective_server.server_name\n",
"VAR_36 = signedjson.key.generate_signing_key('ver1')\n",
"VAR_37 = signedjson.key.get_verify_key(VAR_36)\n",
"VAR_38 = 'ed25519:ver1'\n",
"VAR_39 = 200 * 1000\n",
"VAR_16 = self.build_perspectives_response(VAR_34, VAR_36, VAR_39)\n",
"self.expect_outgoing_key_query(VAR_34, 'key1', VAR_16)\n",
"VAR_23 = {VAR_34: {'key1': 0}}\n",
"VAR_42 = self.get_success(VAR_35.get_keys(VAR_23))\n",
"self.assertIn(VAR_34, VAR_42)\n",
"VAR_43 = VAR_42[VAR_34][VAR_38]\n",
"self.assertEqual(VAR_43.valid_until_ts, VAR_39)\n",
"self.assertEqual(VAR_43.verify_key, VAR_37)\n",
"self.assertEqual(VAR_43.verify_key.alg, 'ed25519')\n",
"self.assertEqual(VAR_43.verify_key.version, 'ver1')\n",
"VAR_44 = VAR_34, VAR_38, None\n",
"VAR_45 = self.get_success(self.hs.get_datastore().get_server_keys_json([\n VAR_44]))\n",
"VAR_7 = VAR_45[VAR_44]\n",
"self.assertEqual(len(VAR_7), 1)\n",
"VAR_7 = VAR_7[0]\n",
"self.assertEqual(VAR_7['key_id'], VAR_38)\n",
"self.assertEqual(VAR_7['from_server'], self.mock_perspective_server.server_name\n )\n",
"self.assertEqual(VAR_7['ts_added_ms'], self.reactor.seconds() * 1000)\n",
"self.assertEqual(VAR_7['ts_valid_until_ms'], VAR_39)\n",
"self.assertEqual(bytes(VAR_7['key_json']), canonicaljson.\n encode_canonical_json(VAR_16))\n"
] | [
"def test_get_perspectives_own_key(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.reactor.advance(100)\n",
"fetcher = PerspectivesKeyFetcher(self.hs)\n",
"SERVER_NAME = self.mock_perspective_server.server_name\n",
"testkey = signedjson.key.generate_signing_key('ver1')\n",
"testverifykey = signedjson.key.get_verify_key(testkey)\n",
"testverifykey_id = 'ed25519:ver1'\n",
"VALID_UNTIL_TS = 200 * 1000\n",
"response = self.build_perspectives_response(SERVER_NAME, testkey,\n VALID_UNTIL_TS)\n",
"self.expect_outgoing_key_query(SERVER_NAME, 'key1', response)\n",
"keys_to_fetch = {SERVER_NAME: {'key1': 0}}\n",
"keys = self.get_success(fetcher.get_keys(keys_to_fetch))\n",
"self.assertIn(SERVER_NAME, keys)\n",
"k = keys[SERVER_NAME][testverifykey_id]\n",
"self.assertEqual(k.valid_until_ts, VALID_UNTIL_TS)\n",
"self.assertEqual(k.verify_key, testverifykey)\n",
"self.assertEqual(k.verify_key.alg, 'ed25519')\n",
"self.assertEqual(k.verify_key.version, 'ver1')\n",
"lookup_triplet = SERVER_NAME, testverifykey_id, None\n",
"key_json = self.get_success(self.hs.get_datastore().get_server_keys_json([\n lookup_triplet]))\n",
"res = key_json[lookup_triplet]\n",
"self.assertEqual(len(res), 1)\n",
"res = res[0]\n",
"self.assertEqual(res['key_id'], testverifykey_id)\n",
"self.assertEqual(res['from_server'], self.mock_perspective_server.server_name)\n",
"self.assertEqual(res['ts_added_ms'], self.reactor.seconds() * 1000)\n",
"self.assertEqual(res['ts_valid_until_ms'], VALID_UNTIL_TS)\n",
"self.assertEqual(bytes(res['key_json']), canonicaljson.\n encode_canonical_json(response))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(self):...\n",
"\"\"\"docstring\"\"\"\n",
"for banned in self.banned_specs:\n",
"if re.match(banned, self.spec, re.IGNORECASE):\n",
"return False\n",
"return True\n"
] | [
"def is_banned(self):...\n",
"\"\"\"docstring\"\"\"\n",
"for banned in self.banned_specs:\n",
"if re.match(banned, self.spec, re.IGNORECASE):\n",
"return False\n",
"return True\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"For",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_10(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self._create_alias(self.test_user)\n",
"VAR_10 = self.get_success(self.handler.delete_association(create_requester(\n self.test_user), self.room_alias))\n",
"self.assertEquals(self.room_id, VAR_10)\n",
"self.get_failure(self.handler.get_association(self.room_alias), synapse.api\n .errors.SynapseError)\n"
] | [
"def test_delete_alias_creator(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self._create_alias(self.test_user)\n",
"result = self.get_success(self.handler.delete_association(create_requester(\n self.test_user), self.room_alias))\n",
"self.assertEquals(self.room_id, result)\n",
"self.get_failure(self.handler.get_association(self.room_alias), synapse.api\n .errors.SynapseError)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_12(self):...\n",
"self._record_user(VAR_0, 'xyz', 'display 0')\n",
"self._record_user(VAR_0, 'fco', 'display 1', 'token1', 'ip1')\n",
"self._record_user(VAR_0, 'abc', 'display 2', 'token2', 'ip2')\n",
"self._record_user(VAR_0, 'abc', 'display 2', 'token3', 'ip3')\n",
"self._record_user(VAR_1, 'def', 'dispkay', 'token4', 'ip4')\n",
"self.reactor.advance(10000)\n"
] | [
"def _record_users(self):...\n",
"self._record_user(user1, 'xyz', 'display 0')\n",
"self._record_user(user1, 'fco', 'display 1', 'token1', 'ip1')\n",
"self._record_user(user1, 'abc', 'display 2', 'token2', 'ip2')\n",
"self._record_user(user1, 'abc', 'display 2', 'token3', 'ip3')\n",
"self._record_user(user2, 'def', 'dispkay', 'token4', 'ip4')\n",
"self.reactor.advance(10000)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_21(self):...\n",
"VAR_26 = np.array([[1], [2]])\n",
"VAR_27 = np.array(range(5))\n",
"VAR_31 = os.path.join(test.get_temp_dir(), 'input.npz')\n",
"np.savez(VAR_31, VAR_53=x0, VAR_54=x1)\n",
"VAR_20 = 'x=' + VAR_31 + '[c]'\n",
"saved_model_cli.load_inputs_from_input_arg_string(VAR_20, '', '')\n"
] | [
"def testInputParserErrorWrongName(self):...\n",
"x0 = np.array([[1], [2]])\n",
"x1 = np.array(range(5))\n",
"input_path = os.path.join(test.get_temp_dir(), 'input.npz')\n",
"np.savez(input_path, a=x0, b=x1)\n",
"input_str = 'x=' + input_path + '[c]'\n",
"saved_model_cli.load_inputs_from_input_arg_string(input_str, '', '')\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_1(VAR_0):...\n",
"@wraps(VAR_0)...\n",
"VAR_4 = VAR_1.user\n",
"if not VAR_4.is_authenticated:\n",
"return redirect_to_login(next=request.get_full_path(), login_url=settings.\n LOGIN_URL)\n",
"if not VAR_4.st.is_administrator:\n",
"return VAR_0(VAR_1, *VAR_2, **kwargs)\n"
] | [
"def administrator_required(view_func):...\n",
"@wraps(view_func)...\n",
"user = request.user\n",
"if not user.is_authenticated:\n",
"return redirect_to_login(next=request.get_full_path(), login_url=settings.\n LOGIN_URL)\n",
"if not user.st.is_administrator:\n",
"return view_func(request, *args, **kwargs)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'"
] |
[
"def FUNC_66(self, VAR_36='Comment', VAR_37=None, VAR_38=None, VAR_39=None,...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_66 = frappe.get_doc({'doctype': 'Comment', 'comment_type': VAR_36,\n 'comment_email': VAR_38 or frappe.session.user, 'comment_by': VAR_41,\n 'reference_doctype': self.doctype, 'reference_name': self.name,\n 'content': VAR_37 or VAR_36, 'link_doctype': VAR_39, 'link_name': VAR_40}\n ).insert(VAR_11=True)\n",
"return VAR_66\n"
] | [
"def add_comment(self, comment_type='Comment', text=None, comment_email=None,...\n",
"\"\"\"docstring\"\"\"\n",
"out = frappe.get_doc({'doctype': 'Comment', 'comment_type': comment_type,\n 'comment_email': comment_email or frappe.session.user, 'comment_by':\n comment_by, 'reference_doctype': self.doctype, 'reference_name': self.\n name, 'content': text or comment_type, 'link_doctype': link_doctype,\n 'link_name': link_name}).insert(ignore_permissions=True)\n",
"return out\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'"
] |
[
"@staticmethod...\n",
"VAR_42.append(VAR_53)\n"
] | [
"@staticmethod...\n",
"addresses.append(address)\n"
] | [
0,
0
] | [
"Condition",
"Expr'"
] |
[
"def FUNC_49(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_27.dump(self.server_info(), VAR_102, indent=2)\n"
] | [
"def write_server_info_file(self):...\n",
"\"\"\"docstring\"\"\"\n",
"json.dump(self.server_info(), f, indent=2)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'"
] |
[
"def FUNC_1(VAR_1):...\n",
"if not VAR_1:\n",
"return ''\n",
"VAR_10 = f'([\\\\[\\\\s\\\\S\\\\]]*?)\\\\(([\\\\s\\\\S]*?):([\\\\[\\\\s\\\\S\\\\]]*?)\\\\)'\n",
"if re.match(VAR_10, VAR_1):\n",
"VAR_135 = re.search(VAR_10, VAR_1, re.IGNORECASE).group(2)\n",
"return mark_safe(markdown(VAR_1, extensions=[EscapeHtml(),\n 'markdown.extensions.nl2br', 'markdown.extensions.fenced_code']))\n",
"if VAR_135 in helpdesk_settings.ALLOWED_URL_SCHEMES:\n",
"VAR_160 = '\\\\1(\\\\2:\\\\3)'\n",
"VAR_160 = '\\\\1(\\\\3)'\n",
"VAR_1 = re.sub(VAR_10, VAR_160, VAR_1, flags=re.IGNORECASE)\n"
] | [
"def get_markdown(text):...\n",
"if not text:\n",
"return ''\n",
"pattern = f'([\\\\[\\\\s\\\\S\\\\]]*?)\\\\(([\\\\s\\\\S]*?):([\\\\[\\\\s\\\\S\\\\]]*?)\\\\)'\n",
"if re.match(pattern, text):\n",
"scheme = re.search(pattern, text, re.IGNORECASE).group(2)\n",
"return mark_safe(markdown(text, extensions=[EscapeHtml(),\n 'markdown.extensions.nl2br', 'markdown.extensions.fenced_code']))\n",
"if scheme in helpdesk_settings.ALLOWED_URL_SCHEMES:\n",
"replacement = '\\\\1(\\\\2:\\\\3)'\n",
"replacement = '\\\\1(\\\\3)'\n",
"text = re.sub(pattern, replacement, text, flags=re.IGNORECASE)\n"
] | [
0,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Assign'",
"Assign'"
] |
[
"async def FUNC_8(self, VAR_16):...\n",
"\"\"\"docstring\"\"\"\n"
] | [
"async def get_keys(self, keys_to_fetch):...\n",
"\"\"\"docstring\"\"\"\n"
] | [
0,
0
] | [
"AsyncFunctionDef'",
"Docstring"
] |
[
"def FUNC_2(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 - LAST_ACTIVE_GRANULARITY - 10, currently_active=True)\n",
"VAR_9 = VAR_8.copy_and_replace(VAR_10=PresenceState.ONLINE, last_active_ts=now)\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.assertFalse(VAR_11)\n",
"self.assertTrue(VAR_12)\n",
"self.assertTrue(VAR_10.currently_active)\n",
"self.assertEquals(VAR_9.state, VAR_10.state)\n",
"self.assertEquals(VAR_9.status_msg, VAR_10.status_msg)\n",
"self.assertEquals(VAR_10.last_federation_update_ts, VAR_7)\n",
"self.assertEquals(VAR_6.insert.call_count, 3)\n",
"VAR_6.insert.assert_has_calls([call(VAR_7=now, obj=user_id, then=new_state.\n last_active_ts + IDLE_TIMER), call(VAR_7=now, obj=user_id, then=\n new_state.last_user_sync_ts + SYNC_ONLINE_TIMEOUT), call(VAR_7=now, obj\n =user_id, then=new_state.last_active_ts + LAST_ACTIVE_GRANULARITY)],\n any_order=True)\n"
] | [
"def test_online_to_online_last_active_noop(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 - LAST_ACTIVE_GRANULARITY - 10, currently_active=True)\n",
"new_state = prev_state.copy_and_replace(state=PresenceState.ONLINE,\n last_active_ts=now)\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.assertFalse(persist_and_notify)\n",
"self.assertTrue(federation_ping)\n",
"self.assertTrue(state.currently_active)\n",
"self.assertEquals(new_state.state, state.state)\n",
"self.assertEquals(new_state.status_msg, state.status_msg)\n",
"self.assertEquals(state.last_federation_update_ts, now)\n",
"self.assertEquals(wheel_timer.insert.call_count, 3)\n",
"wheel_timer.insert.assert_has_calls([call(now=now, obj=user_id, then=\n new_state.last_active_ts + IDLE_TIMER), call(now=now, obj=user_id, then\n =new_state.last_user_sync_ts + SYNC_ONLINE_TIMEOUT), call(now=now, obj=\n user_id, then=new_state.last_active_ts + LAST_ACTIVE_GRANULARITY)],\n any_order=True)\n"
] | [
0,
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'",
"Expr'"
] |
[
"def FUNC_19(self):...\n",
"VAR_5 = self.get_counts('html')\n",
"self.assertEqual(VAR_5.status_code, 200)\n",
"self.assertHTMLEqual(VAR_5.content.decode(), 'string')\n"
] | [
"def test_counts_view_html(self):...\n",
"response = self.get_counts('html')\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertHTMLEqual(response.content.decode(),\n \"\"\"\n<table>\n <tr>\n <th>Name</th>\n <th>Email</th>\n <th>Count total</th>\n <th>Edits total</th>\n <th>Source words total</th>\n <th>Source chars total</th>\n <th>Target words total</th>\n <th>Target chars total</th>\n <th>Count new</th>\n <th>Edits new</th>\n <th>Source words new</th>\n <th>Source chars new</th>\n <th>Target words new</th>\n <th>Target chars new</th>\n <th>Count approved</th>\n <th>Edits approved</th>\n <th>Source words approved</th>\n <th>Source chars approved</th>\n <th>Target words approved</th>\n <th>Target chars approved</th>\n <th>Count edited</th>\n <th>Edits edited</th>\n <th>Source words edited</th>\n <th>Source chars edited</th>\n <th>Target words edited</th>\n <th>Target chars edited</th>\n </tr>\n <tr>\n <td>Weblate Test</td>\n <td>[email protected]</td>\n <td>1</td>\n <td>14</td>\n <td>2</td>\n <td>14</td>\n <td>2</td>\n <td>14</td>\n <td>1</td>\n <td>14</td>\n <td>2</td>\n <td>14</td>\n <td>2</td>\n <td>14</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n <td>0</td>\n </tr>\n</table>\n\"\"\"\n )\n"
] | [
0,
0,
0,
2
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_23(self, VAR_19):...\n",
"\"\"\"docstring\"\"\"\n",
"self._subscribers.add(VAR_19)\n"
] | [
"def add_subscriber(self, conn):...\n",
"\"\"\"docstring\"\"\"\n",
"self._subscribers.add(conn)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'"
] |
[
"def __init__(self, VAR_58, *VAR_6, **VAR_7):...\n",
"super().__init__(*VAR_6, **kwargs)\n",
"if not VAR_58.source_review:\n",
"self.fields['scope'].choices = self.fields['scope'].choices[1:]\n"
] | [
"def __init__(self, project, *args, **kwargs):...\n",
"super().__init__(*args, **kwargs)\n",
"if not project.source_review:\n",
"self.fields['scope'].choices = self.fields['scope'].choices[1:]\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Condition",
"Assign'"
] |
[
"def FUNC_4(VAR_13, VAR_18):...\n",
"return os.path.join(VAR_3, VAR_13, VAR_18)\n"
] | [
"def _get_obj_abosolute_path(dataset, rel_path):...\n",
"return os.path.join(DATAROOT, dataset, rel_path)\n"
] | [
0,
1
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_5(self) ->None:...\n",
"\"\"\"docstring\"\"\"\n",
"for i in self.REQUIRED_ON_BACKGROUND_TASK_STARTUP:\n",
"getattr(self, 'get_' + i + '_handler')()\n"
] | [
"def setup_background_tasks(self) ->None:...\n",
"\"\"\"docstring\"\"\"\n",
"for i in self.REQUIRED_ON_BACKGROUND_TASK_STARTUP:\n",
"getattr(self, 'get_' + i + '_handler')()\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"For",
"Expr'"
] |
[
"def FUNC_10(self, VAR_44):...\n",
"self.tokens.append({'type': 'heading', 'level': len(VAR_44.group(1)),\n 'text': VAR_44.group(2)})\n"
] | [
"def parse_heading(self, m):...\n",
"self.tokens.append({'type': 'heading', 'level': len(m.group(1)), 'text': m.\n group(2)})\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_32(VAR_87):...\n",
"VAR_86.update(to_bytes(VAR_87, encoding='utf-8', errors='replace'))\n"
] | [
"def hash_update(value):...\n",
"hash.update(to_bytes(value, encoding='utf-8', errors='replace'))\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_2(self, VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"if not (isinstance(VAR_3.value, ast.Compare) or isinstance(VAR_3.value, ast\n",
"self.generic_visit(VAR_3)\n"
] | [
"def visit_Expr(self, node):...\n",
"\"\"\"docstring\"\"\"\n",
"if not (isinstance(node.value, ast.Compare) or isinstance(node.value, ast.\n",
"self.generic_visit(node)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'"
] |
[
"def FUNC_78(self):...\n",
"VAR_68 = self.token['ordered']\n",
"VAR_67 = self.renderer.placeholder()\n",
"while self.pop()['type'] != 'list_end':\n",
"VAR_67 += self.tok()\n",
"return self.renderer.list(VAR_67, VAR_68)\n"
] | [
"def output_list(self):...\n",
"ordered = self.token['ordered']\n",
"body = self.renderer.placeholder()\n",
"while self.pop()['type'] != 'list_end':\n",
"body += self.tok()\n",
"return self.renderer.list(body, ordered)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"AugAssign'",
"Return'"
] |
[
"def FUNC_14(self, VAR_5: str, VAR_12: SigningKey, VAR_13: int) ->dict:...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = signedjson.key.get_verify_key(VAR_12)\n",
"VAR_47 = '%s:%s' % (VAR_6.alg, VAR_6.version)\n",
"VAR_16 = {'server_name': VAR_5, 'old_verify_keys': {}, 'valid_until_ts':\n VAR_13, 'verify_keys': {VAR_47: {'key': signedjson.key.\n encode_verify_key_base64(VAR_6)}}}\n",
"signedjson.sign.sign_json(VAR_16, VAR_5, VAR_12)\n",
"self.mock_perspective_server.sign_response(VAR_16)\n",
"return VAR_16\n"
] | [
"def build_perspectives_response(self, server_name: str, signing_key:...\n",
"\"\"\"docstring\"\"\"\n",
"verify_key = signedjson.key.get_verify_key(signing_key)\n",
"verifykey_id = '%s:%s' % (verify_key.alg, verify_key.version)\n",
"response = {'server_name': server_name, 'old_verify_keys': {},\n 'valid_until_ts': valid_until_ts, 'verify_keys': {verifykey_id: {'key':\n signedjson.key.encode_verify_key_base64(verify_key)}}}\n",
"signedjson.sign.sign_json(response, server_name, signing_key)\n",
"self.mock_perspective_server.sign_response(response)\n",
"return response\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_98(VAR_91=None, VAR_158=False, VAR_159=True, VAR_160=None, VAR_161...\n",
"\"\"\"docstring\"\"\"\n",
"from frappe.utils.logger import get_logger\n",
"return get_logger(VAR_91=module, VAR_158=with_more_info, VAR_159=allow_site,\n VAR_160=filter, VAR_161=max_size, VAR_162=file_count)\n"
] | [
"def logger(module=None, with_more_info=False, allow_site=True, filter=None,...\n",
"\"\"\"docstring\"\"\"\n",
"from frappe.utils.logger import get_logger\n",
"return get_logger(module=module, with_more_info=with_more_info, allow_site=\n allow_site, filter=filter, max_size=max_size, file_count=file_count)\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"ImportFrom'",
"Return'"
] |
[
"def FUNC_15():...\n",
"random.seed(VAR_24)\n",
"return list(map(lambda x: x + VAR_5 * VAR_45, sorted(random.sample(list(\n range(VAR_5)), VAR_44))))\n"
] | [
"def generate_mix_indices():...\n",
"random.seed(seed)\n",
"return list(map(lambda x: x + ITEMS_PER_ITERATION * iteration_count, sorted\n (random.sample(list(range(ITEMS_PER_ITERATION)), mix_per_iteration))))\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Return'"
] |
[
"def FUNC_2(VAR_0):...\n",
"@wraps(VAR_0)...\n",
"if VAR_1.user.is_authenticated:\n",
"return redirect(VAR_1.GET.get('next', VAR_1.user.st.get_absolute_url()))\n",
"return VAR_0(VAR_1, *VAR_2, **kwargs)\n"
] | [
"def guest_only(view_func):...\n",
"@wraps(view_func)...\n",
"if request.user.is_authenticated:\n",
"return redirect(request.GET.get('next', request.user.st.get_absolute_url()))\n",
"return view_func(request, *args, **kwargs)\n"
] | [
0,
0,
0,
4,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_18(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if self._looping_call:\n",
"self._looping_call.stop()\n",
"self._looping_call = None\n"
] | [
"def stop(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if self._looping_call:\n",
"self._looping_call.stop()\n",
"self._looping_call = None\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Assign'"
] |
[
"def FUNC_1(self, VAR_11: RoomStreamToken):...\n",
"VAR_18 = VAR_11.stream\n",
"self.max_stream_ordering = max(VAR_18, self.max_stream_ordering or 0)\n",
"self._start_processing()\n"
] | [
"def on_new_notifications(self, max_token: RoomStreamToken):...\n",
"max_stream_ordering = max_token.stream\n",
"self.max_stream_ordering = max(max_stream_ordering, self.\n max_stream_ordering or 0)\n",
"self._start_processing()\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.