lines
sequencelengths 1
383
| raw_lines
sequencelengths 1
383
| label
sequencelengths 1
383
| type
sequencelengths 1
383
|
---|---|---|---|
[
"def FUNC_16(self, VAR_28: Dict[str, str]) ->str:...\n",
"if self.hs.config.email_riot_base_url:\n",
"return '%s/#/room/%s/%s' % (self.hs.config.email_riot_base_url, VAR_28[\n 'room_id'], VAR_28['event_id'])\n",
"if self.app_name == 'Vector':\n",
"return 'https://vector.im/beta/#/room/%s/%s' % (VAR_28['room_id'], VAR_28[\n 'event_id'])\n",
"return 'https://matrix.to/#/%s/%s' % (VAR_28['room_id'], VAR_28['event_id'])\n"
] | [
"def make_notif_link(self, notif: Dict[str, str]) ->str:...\n",
"if self.hs.config.email_riot_base_url:\n",
"return '%s/#/room/%s/%s' % (self.hs.config.email_riot_base_url, notif[\n 'room_id'], notif['event_id'])\n",
"if self.app_name == 'Vector':\n",
"return 'https://vector.im/beta/#/room/%s/%s' % (notif['room_id'], notif[\n 'event_id'])\n",
"return 'https://matrix.to/#/%s/%s' % (notif['room_id'], notif['event_id'])\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_32(self):...\n",
"VAR_112 = VAR_263.request.vars._next\n",
"VAR_98 = VAR_263.request.env.http_host\n",
"if isinstance(VAR_112, (list, tuple)):\n",
"VAR_112 = VAR_112[0]\n",
"if VAR_112 and self.settings.prevent_open_redirect_attacks:\n",
"return self.prevent_open_redirect(VAR_112, VAR_98)\n",
"return VAR_112 or None\n"
] | [
"def get_vars_next(self):...\n",
"next = current.request.vars._next\n",
"host = current.request.env.http_host\n",
"if isinstance(next, (list, tuple)):\n",
"next = next[0]\n",
"if next and self.settings.prevent_open_redirect_attacks:\n",
"return self.prevent_open_redirect(next, host)\n",
"return next or None\n"
] | [
0,
0,
4,
0,
0,
0,
4,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_8(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_3 = self.client.post('/password_reset_from_email/', {'email':\n '[email protected]'})\n",
"self.assertEqual(VAR_3.status_code, 302)\n",
"self.assertEqual(len(mail.outbox), 1)\n",
"self.assertEqual('[email protected]', mail.outbox[0].from_email)\n"
] | [
"def test_email_found_custom_from(self):...\n",
"\"\"\"docstring\"\"\"\n",
"response = self.client.post('/password_reset_from_email/', {'email':\n '[email protected]'})\n",
"self.assertEqual(response.status_code, 302)\n",
"self.assertEqual(len(mail.outbox), 1)\n",
"self.assertEqual('[email protected]', mail.outbox[0].from_email)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_21(VAR_28, VAR_17):...\n",
"VAR_48 = False\n",
"if VAR_28:\n",
"VAR_86 = VAR_28.rstrip().strip()\n",
"if len(VAR_17.publishers):\n",
"if len(VAR_17.publishers) == 0 or len(VAR_17.publishers\n",
"VAR_48 |= FUNC_7([], VAR_17.publishers, db.Publishers, calibre_db.session,\n 'publisher')\n",
"return VAR_48\n",
"VAR_48 |= FUNC_7([VAR_86], VAR_17.publishers, db.Publishers, calibre_db.\n session, 'publisher')\n"
] | [
"def edit_book_publisher(publishers, book):...\n",
"changed = False\n",
"if publishers:\n",
"publisher = publishers.rstrip().strip()\n",
"if len(book.publishers):\n",
"if len(book.publishers) == 0 or len(book.publishers\n",
"changed |= modify_database_object([], book.publishers, db.Publishers,\n calibre_db.session, 'publisher')\n",
"return changed\n",
"changed |= modify_database_object([publisher], book.publishers, db.\n Publishers, calibre_db.session, 'publisher')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"AugAssign'",
"Return'",
"AugAssign'"
] |
[
"def FUNC_59(self):...\n",
"VAR_61 = self._get_aliases(self.room_owner_tok)\n",
"self.assertEqual(VAR_61['aliases'], [])\n"
] | [
"def test_no_aliases(self):...\n",
"res = self._get_aliases(self.room_owner_tok)\n",
"self.assertEqual(res['aliases'], [])\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_0(VAR_0: Any, *, VAR_1: bool, VAR_2: bool=False, VAR_3: bool=False...\n",
"if isinstance(VAR_0, BaseModel):\n",
"return VAR_0.dict(VAR_8=True, VAR_1=exclude_unset, VAR_2=exclude_defaults,\n VAR_3=exclude_none)\n",
"if isinstance(VAR_0, list):\n",
"return [FUNC_0(item, VAR_1=exclude_unset, VAR_2=exclude_defaults, VAR_3=\n exclude_none) for item in VAR_0]\n",
"if isinstance(VAR_0, dict):\n",
"return {k: FUNC_0(v, VAR_1=exclude_unset, VAR_2=exclude_defaults, VAR_3=\n exclude_none) for k, v in VAR_0.items()}\n",
"return VAR_0\n"
] | [
"def _prepare_response_content(res: Any, *, exclude_unset: bool,...\n",
"if isinstance(res, BaseModel):\n",
"return res.dict(by_alias=True, exclude_unset=exclude_unset,\n exclude_defaults=exclude_defaults, exclude_none=exclude_none)\n",
"if isinstance(res, list):\n",
"return [_prepare_response_content(item, exclude_unset=exclude_unset,\n exclude_defaults=exclude_defaults, exclude_none=exclude_none) for item in\n res]\n",
"if isinstance(res, dict):\n",
"return {k: _prepare_response_content(v, exclude_unset=exclude_unset,\n exclude_defaults=exclude_defaults, exclude_none=exclude_none) for k, v in\n res.items()}\n",
"return res\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"@VAR_0.route('/query/<int:query_id>/meta')...\n",
"VAR_14 = g.conn.session.query(Query).get(VAR_4)\n",
"if not VAR_14:\n",
"return Response('No such query id', status=404)\n",
"return Response(json.dumps({'latest_run': VAR_14.latest_rev.latest_run,\n 'latest_rev': VAR_14.latest_rev, 'query': VAR_14}, default=\n json_formatter), mimetype='application/json', headers={\n 'Access-Control-Allow-Origin': '*'})\n"
] | [
"@app.route('/query/<int:query_id>/meta')...\n",
"query = g.conn.session.query(Query).get(query_id)\n",
"if not query:\n",
"return Response('No such query id', status=404)\n",
"return Response(json.dumps({'latest_run': query.latest_rev.latest_run,\n 'latest_rev': query.latest_rev, 'query': query}, default=json_formatter\n ), mimetype='application/json', headers={'Access-Control-Allow-Origin':\n '*'})\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_20(VAR_2, *VAR_23, **VAR_24):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_22 = VAR_21(VAR_2, *VAR_23, **kwargs)\n",
"if isinstance(VAR_22, HttpResponseBase):\n",
"return VAR_22\n",
"VAR_37 = 'template' in VAR_22 and VAR_22['template'] or None\n",
"VAR_37 = VAR_24.get('template', VAR_37)\n",
"VAR_0.debug('Rendering template: %s' % VAR_37)\n",
"if VAR_37 is None or VAR_37 == 'json':\n",
"VAR_40 = type(VAR_22) is dict\n",
"VAR_20.prepare_context(VAR_2, VAR_22, *VAR_23, **kwargs)\n",
"return JsonResponse(VAR_22, VAR_40=safe)\n",
"return render(VAR_2, VAR_37, VAR_22)\n"
] | [
"def wrapper(request, *args, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"context = f(request, *args, **kwargs)\n",
"if isinstance(context, HttpResponseBase):\n",
"return context\n",
"template = 'template' in context and context['template'] or None\n",
"template = kwargs.get('template', template)\n",
"logger.debug('Rendering template: %s' % template)\n",
"if template is None or template == 'json':\n",
"safe = type(context) is dict\n",
"ctx.prepare_context(request, context, *args, **kwargs)\n",
"return JsonResponse(context, safe=safe)\n",
"return render(request, template, context)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Return'",
"Return'"
] |
[
"def FUNC_12(VAR_14, VAR_15, VAR_16, VAR_17, VAR_18, VAR_10, VAR_24, VAR_21,...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_56 = list()\n",
"VAR_19 = FUNC_10(VAR_14, VAR_15, VAR_16, VAR_17, VAR_18)\n",
"VAR_56.append({'username': VAR_15, 'email': VAR_14, 'response': _(\n 'Username {user} already exists.').format(VAR_19=username)})\n",
"VAR_25.update({'message': 'account_creation_and_enrollment',\n 'email_address': VAR_14, 'password': VAR_18, 'platform_name': microsite\n .get_value('platform_name', settings.PLATFORM_NAME)})\n",
"VAR_0.exception(\n \"Exception '{exception}' raised while sending email to new user.\".\n format(VAR_154=type(ex).__name__))\n",
"VAR_0.info(u'email sent to new created user at %s', VAR_14)\n",
"FUNC_11(VAR_19=user, VAR_10=course_id, VAR_20=course_mode, VAR_21=\n enrolled_by, VAR_22='Enrolling via csv upload', VAR_23=\n UNENROLLED_TO_ENROLLED)\n",
"VAR_0.exception(type(ex).__name__)\n",
"send_mail_to_student(VAR_14, VAR_25)\n",
"VAR_56.append({'username': VAR_15, 'email': VAR_14, 'response': _('string')\n .format(VAR_169=type(ex).__name__, VAR_14=email)})\n",
"return VAR_56\n",
"VAR_56.append({'username': VAR_15, 'email': VAR_14, 'response': type(ex).\n __name__})\n"
] | [
"def create_and_enroll_user(email, username, name, country, password,...\n",
"\"\"\"docstring\"\"\"\n",
"errors = list()\n",
"user = create_user_and_user_profile(email, username, name, country, password)\n",
"errors.append({'username': username, 'email': email, 'response': _(\n 'Username {user} already exists.').format(user=username)})\n",
"email_params.update({'message': 'account_creation_and_enrollment',\n 'email_address': email, 'password': password, 'platform_name':\n microsite.get_value('platform_name', settings.PLATFORM_NAME)})\n",
"log.exception(\"Exception '{exception}' raised while sending email to new user.\"\n .format(exception=type(ex).__name__))\n",
"log.info(u'email sent to new created user at %s', email)\n",
"create_manual_course_enrollment(user=user, course_id=course_id, mode=\n course_mode, enrolled_by=enrolled_by, reason='Enrolling via csv upload',\n state_transition=UNENROLLED_TO_ENROLLED)\n",
"log.exception(type(ex).__name__)\n",
"send_mail_to_student(email, email_params)\n",
"errors.append({'username': username, 'email': email, 'response': _(\n \"Error '{error}' while sending email to new user (user email={email}). Without the email student would not be able to login. Please contact support for further information.\"\n ).format(error=type(ex).__name__, email=email)})\n",
"return errors\n",
"errors.append({'username': username, 'email': email, 'response': type(ex).\n __name__})\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Return'",
"Expr'"
] |
[
"def FUNC_23(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_143 = ''\n",
"if self.on_hold:\n",
"VAR_143 = _(' - On Hold')\n",
"VAR_144 = ''\n",
"if not self.can_be_resolved:\n",
"VAR_144 = _(' - Open dependencies')\n",
"return u'%s%s%s' % (self.get_status_display(), VAR_143, VAR_144)\n"
] | [
"def _get_status(self):...\n",
"\"\"\"docstring\"\"\"\n",
"held_msg = ''\n",
"if self.on_hold:\n",
"held_msg = _(' - On Hold')\n",
"dep_msg = ''\n",
"if not self.can_be_resolved:\n",
"dep_msg = _(' - Open dependencies')\n",
"return u'%s%s%s' % (self.get_status_display(), held_msg, dep_msg)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_22(self):...\n",
"VAR_22, VAR_23 = self.make_request('GET', self.path)\n",
"self.assertEquals(404, VAR_23.code, msg=channel.result['body'])\n",
"VAR_19 = '{\"topic\":\"Topic name\"}'\n",
"VAR_22, VAR_23 = self.make_request('PUT', self.path, VAR_19)\n",
"self.assertEquals(200, VAR_23.code, msg=channel.result['body'])\n",
"VAR_22, VAR_23 = self.make_request('GET', self.path)\n",
"self.assertEquals(200, VAR_23.code, msg=channel.result['body'])\n",
"self.assert_dict(json.loads(VAR_19), VAR_23.json_body)\n"
] | [
"def test_rooms_topic(self):...\n",
"request, channel = self.make_request('GET', self.path)\n",
"self.assertEquals(404, channel.code, msg=channel.result['body'])\n",
"content = '{\"topic\":\"Topic name\"}'\n",
"request, channel = self.make_request('PUT', self.path, content)\n",
"self.assertEquals(200, channel.code, msg=channel.result['body'])\n",
"request, channel = self.make_request('GET', self.path)\n",
"self.assertEquals(200, channel.code, msg=channel.result['body'])\n",
"self.assert_dict(json.loads(content), channel.json_body)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_31(VAR_10=None, VAR_62=None):...\n",
"\"\"\"docstring\"\"\"\n",
"import frappe.cache_manager\n",
"if VAR_62:\n",
"frappe.cache_manager.clear_doctype_cache(VAR_62)\n",
"if VAR_10:\n",
"FUNC_38()\n",
"frappe.cache_manager.clear_user_cache(VAR_10)\n",
"from frappe import translate\n",
"VAR_1.role_permissions = {}\n",
"frappe.cache_manager.clear_user_cache()\n",
"frappe.cache_manager.clear_domain_cache()\n",
"translate.clear_cache()\n",
"FUNC_38()\n",
"VAR_1.cache = {}\n",
"VAR_1.new_doc_templates = {}\n",
"for VAR_129 in FUNC_66('clear_cache'):\n",
"FUNC_72(VAR_129)()\n"
] | [
"def clear_cache(user=None, doctype=None):...\n",
"\"\"\"docstring\"\"\"\n",
"import frappe.cache_manager\n",
"if doctype:\n",
"frappe.cache_manager.clear_doctype_cache(doctype)\n",
"if user:\n",
"reset_metadata_version()\n",
"frappe.cache_manager.clear_user_cache(user)\n",
"from frappe import translate\n",
"local.role_permissions = {}\n",
"frappe.cache_manager.clear_user_cache()\n",
"frappe.cache_manager.clear_domain_cache()\n",
"translate.clear_cache()\n",
"reset_metadata_version()\n",
"local.cache = {}\n",
"local.new_doc_templates = {}\n",
"for fn in get_hooks('clear_cache'):\n",
"get_attr(fn)()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Import'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"ImportFrom'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"For",
"Expr'"
] |
[
"def FUNC_31(self):...\n",
"from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver\n",
"from Products.PageTemplates.unicodeconflictresolver import DefaultUnicodeEncodingConflictResolver\n",
"from zope.component import getUtility\n",
"from zope.component import provideUtility\n",
"provideUtility(DefaultUnicodeEncodingConflictResolver,\n IUnicodeEncodingConflictResolver)\n",
"VAR_12 = getUtility(IUnicodeEncodingConflictResolver)\n",
"self.assertRaises(UnicodeDecodeError, VAR_12.resolve, None, b'\\xe4\\xfc\\xf6',\n None)\n"
] | [
"def testDefaultResolver(self):...\n",
"from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver\n",
"from Products.PageTemplates.unicodeconflictresolver import DefaultUnicodeEncodingConflictResolver\n",
"from zope.component import getUtility\n",
"from zope.component import provideUtility\n",
"provideUtility(DefaultUnicodeEncodingConflictResolver,\n IUnicodeEncodingConflictResolver)\n",
"resolver = getUtility(IUnicodeEncodingConflictResolver)\n",
"self.assertRaises(UnicodeDecodeError, resolver.resolve, None,\n b'\\xe4\\xfc\\xf6', None)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"@VAR_0.errorhandler(404)...\n",
"return abort(401)\n"
] | [
"@app.errorhandler(404)...\n",
"return abort(401)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_111(self, VAR_17=None, VAR_192=False):...\n",
"def FUNC_165(VAR_215, VAR_224):...\n",
"if not VAR_399:\n",
"return None\n",
"return serializers.json({'jsonrpc': '2.0', 'id': VAR_215, 'result': VAR_224})\n"
] | [
"def serve_jsonrpc2(self, data=None, batch_element=False):...\n",
"def return_response(id, result):...\n",
"if not must_respond:\n",
"return None\n",
"return serializers.json({'jsonrpc': '2.0', 'id': id, 'result': result})\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"\"\"\"string\"\"\"\n",
"from __future__ import unicode_literals, print_function\n",
"from six import iteritems, binary_type, text_type, string_types, PY2\n",
"from werkzeug.local import Local, release_local\n",
"import os, sys, importlib, inspect, json\n",
"from past.builtins import cmp\n",
"import click\n",
"from .exceptions import *\n",
"from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template, get_jloader\n",
"from .utils.lazy_loader import lazy_import\n",
"VAR_0 = lazy_import('faker')\n",
"if PY2:\n",
"reload(sys)\n",
"__version__ = '13.0.0-dev'\n",
"sys.setdefaultencoding('utf-8')\n",
"__title__ = 'Frappe Framework'\n",
"VAR_1 = Local()\n",
"VAR_2 = {}\n",
"\"\"\"dict like object that exposes keys as attributes\"\"\"\n",
"def __getattr__(self, VAR_46):...\n",
"VAR_205 = self.get(VAR_46)\n",
"if not VAR_205 and VAR_46.startswith('__'):\n",
"return VAR_205\n"
] | [
"\"\"\"\nFrappe - Low Code Open Source Framework in Python and JS\n\nFrappe, pronounced fra-pay, is a full stack, batteries-included, web\nframework written in Python and Javascript with MariaDB as the database.\nIt is the framework which powers ERPNext. It is pretty generic and can\nbe used to build database driven apps.\n\nRead the documentation: https://frappeframework.com/docs\n\"\"\"\n",
"from __future__ import unicode_literals, print_function\n",
"from six import iteritems, binary_type, text_type, string_types, PY2\n",
"from werkzeug.local import Local, release_local\n",
"import os, sys, importlib, inspect, json\n",
"from past.builtins import cmp\n",
"import click\n",
"from .exceptions import *\n",
"from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template, get_jloader\n",
"from .utils.lazy_loader import lazy_import\n",
"faker = lazy_import('faker')\n",
"if PY2:\n",
"reload(sys)\n",
"__version__ = '13.0.0-dev'\n",
"sys.setdefaultencoding('utf-8')\n",
"__title__ = 'Frappe Framework'\n",
"local = Local()\n",
"controllers = {}\n",
"\"\"\"dict like object that exposes keys as attributes\"\"\"\n",
"def __getattr__(self, key):...\n",
"ret = self.get(key)\n",
"if not ret and key.startswith('__'):\n",
"return ret\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Expr'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"ImportFrom'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"FunctionDef'",
"Assign'",
"Condition",
"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'"
] |
[
"async def FUNC_17(self, VAR_22: List[str]) ->Tuple[List[str], int]:...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_40 = []\n",
"for VAR_4 in VAR_22:\n",
"VAR_0.info(\"Deleting media with ID '%s'\", VAR_4)\n",
"return VAR_40, len(VAR_40)\n",
"VAR_48 = self.filepaths.local_media_filepath(VAR_4)\n",
"os.remove(VAR_48)\n",
"VAR_0.warning('Failed to remove file: %r: %s', VAR_48, e)\n",
"VAR_49 = self.filepaths.local_media_thumbnail_dir(VAR_4)\n",
"if e.errno == errno.ENOENT:\n",
"shutil.rmtree(VAR_49, ignore_errors=True)\n",
"await self.store.delete_remote_media(self.server_name, VAR_4)\n",
"await self.store.delete_url_cache((VAR_4,))\n",
"await self.store.delete_url_cache_media((VAR_4,))\n",
"VAR_40.append(VAR_4)\n"
] | [
"async def _remove_local_media_from_disk(self, media_ids: List[str]) ->Tuple[...\n",
"\"\"\"docstring\"\"\"\n",
"removed_media = []\n",
"for media_id in media_ids:\n",
"logger.info(\"Deleting media with ID '%s'\", media_id)\n",
"return removed_media, len(removed_media)\n",
"full_path = self.filepaths.local_media_filepath(media_id)\n",
"os.remove(full_path)\n",
"logger.warning('Failed to remove file: %r: %s', full_path, e)\n",
"thumbnail_dir = self.filepaths.local_media_thumbnail_dir(media_id)\n",
"if e.errno == errno.ENOENT:\n",
"shutil.rmtree(thumbnail_dir, ignore_errors=True)\n",
"await self.store.delete_remote_media(self.server_name, media_id)\n",
"await self.store.delete_url_cache((media_id,))\n",
"await self.store.delete_url_cache_media((media_id,))\n",
"removed_media.append(media_id)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"AsyncFunctionDef'",
"Docstring",
"Assign'",
"For",
"Expr'",
"Return'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"async def FUNC_8(self, VAR_6: str, VAR_7: str) ->Optional[JsonDict]:...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_47 = {'client_secret': VAR_6, 'sid': VAR_7}\n",
"VAR_48 = None\n",
"if self.hs.config.threepid_behaviour_email == ThreepidBehaviour.REMOTE:\n",
"VAR_48 = await self.threepid_from_creds(self.hs.config.\n account_threepid_delegate_email, VAR_47)\n",
"if self.hs.config.threepid_behaviour_email == ThreepidBehaviour.LOCAL:\n",
"if VAR_48:\n",
"VAR_48 = await self.store.get_threepid_validation_session('email', VAR_6,\n VAR_7=sid, validated=True)\n",
"return VAR_48\n",
"if self.hs.config.account_threepid_delegate_msisdn:\n",
"VAR_48 = await self.threepid_from_creds(self.hs.config.\n account_threepid_delegate_msisdn, VAR_47)\n",
"return VAR_48\n"
] | [
"async def validate_threepid_session(self, client_secret: str, sid: str...\n",
"\"\"\"docstring\"\"\"\n",
"threepid_creds = {'client_secret': client_secret, 'sid': sid}\n",
"validation_session = None\n",
"if self.hs.config.threepid_behaviour_email == ThreepidBehaviour.REMOTE:\n",
"validation_session = await self.threepid_from_creds(self.hs.config.\n account_threepid_delegate_email, threepid_creds)\n",
"if self.hs.config.threepid_behaviour_email == ThreepidBehaviour.LOCAL:\n",
"if validation_session:\n",
"validation_session = await self.store.get_threepid_validation_session('email',\n client_secret, sid=sid, validated=True)\n",
"return validation_session\n",
"if self.hs.config.account_threepid_delegate_msisdn:\n",
"validation_session = await self.threepid_from_creds(self.hs.config.\n account_threepid_delegate_msisdn, threepid_creds)\n",
"return validation_session\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"AsyncFunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_2(VAR_7, VAR_8):...\n",
"if (DEMO_MODE or is_gae) and ('w' in VAR_8 or 'a' in VAR_8):\n",
"def FUNC_64(self, VAR_2):...\n",
"if PY2 or 'b' in VAR_8:\n",
"def FUNC_65(self):...\n",
"return open(VAR_7, VAR_8)\n",
"return open(VAR_7, VAR_8, encoding='utf8')\n",
"return CLASS_2()\n"
] | [
"def safe_open(a, b):...\n",
"if (DEMO_MODE or is_gae) and ('w' in b or 'a' in b):\n",
"def write(self, data):...\n",
"if PY2 or 'b' in b:\n",
"def close(self):...\n",
"return open(a, b)\n",
"return open(a, b, encoding='utf8')\n",
"return tmp()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"FunctionDef'",
"Condition",
"FunctionDef'",
"Return'",
"Return'",
"Return'"
] |
[
"def FUNC_20(VAR_5, VAR_12, VAR_13, VAR_14, VAR_15):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_12 == 'orphaned':\n",
"return None\n",
"VAR_72 = None\n",
"if VAR_12 == 'experimenter':\n",
"if VAR_14 in ['dataset', 'plate', 'tag']:\n",
"if VAR_12 == 'project':\n",
"return None\n",
"if not VAR_72:\n",
"if VAR_14 == 'dataset':\n",
"if VAR_12 == 'dataset':\n",
"VAR_73 = omero.sys.ParametersI()\n",
"VAR_72 = 'ProjectDatasetLink'\n",
"if VAR_14 == 'image':\n",
"if VAR_12 == 'screen':\n",
"VAR_73.addIds(VAR_15)\n",
"VAR_72 = 'DatasetImageLink'\n",
"if VAR_14 == 'plate':\n",
"if VAR_12 == 'tagset':\n",
"VAR_74 = VAR_5.getQueryService()\n",
"VAR_72 = 'ScreenPlateLink'\n",
"if VAR_14 == 'tag':\n",
"VAR_75 = 'string' % VAR_72\n",
"VAR_72 = 'AnnotationAnnotationLink'\n",
"if VAR_13:\n",
"VAR_73.add('pid', rlong(VAR_13))\n",
"VAR_76 = VAR_74.findAllByQuery(VAR_75, VAR_73, VAR_5.SERVICE_OPTS)\n",
"VAR_75 += ' and olink.parent.id = :pid'\n",
"if VAR_13 is not None and len(VAR_76) == 0:\n",
"return VAR_72, VAR_76\n"
] | [
"def get_object_links(conn, parent_type, parent_id, child_type, child_ids):...\n",
"\"\"\"docstring\"\"\"\n",
"if parent_type == 'orphaned':\n",
"return None\n",
"link_type = None\n",
"if parent_type == 'experimenter':\n",
"if child_type in ['dataset', 'plate', 'tag']:\n",
"if parent_type == 'project':\n",
"return None\n",
"if not link_type:\n",
"if child_type == 'dataset':\n",
"if parent_type == 'dataset':\n",
"params = omero.sys.ParametersI()\n",
"link_type = 'ProjectDatasetLink'\n",
"if child_type == 'image':\n",
"if parent_type == 'screen':\n",
"params.addIds(child_ids)\n",
"link_type = 'DatasetImageLink'\n",
"if child_type == 'plate':\n",
"if parent_type == 'tagset':\n",
"qs = conn.getQueryService()\n",
"link_type = 'ScreenPlateLink'\n",
"if child_type == 'tag':\n",
"q = (\n \"\"\"\n from %s olink join fetch olink.child join fetch olink.parent\n where olink.child.id in (:ids)\n \"\"\"\n % link_type)\n",
"link_type = 'AnnotationAnnotationLink'\n",
"if parent_id:\n",
"params.add('pid', rlong(parent_id))\n",
"res = qs.findAllByQuery(q, params, conn.SERVICE_OPTS)\n",
"q += ' and olink.parent.id = :pid'\n",
"if parent_id is not None and len(res) == 0:\n",
"return link_type, res\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
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Return'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"AugAssign'",
"Condition",
"Return'"
] |
[
"def FUNC_3(self, VAR_0=None):...\n",
"__allow_access_to_unprotected_subobjects__ = 1\n",
"def __call__(self):...\n",
"return 'dummy'\n"
] | [
"def _makeContext(self, bindings=None):...\n",
"__allow_access_to_unprotected_subobjects__ = 1\n",
"def __call__(self):...\n",
"return 'dummy'\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_2(VAR_12, VAR_13=None, VAR_14=None, VAR_15=None):...\n",
"if VAR_13 is None:\n",
"VAR_13 = request.base_url\n",
"if VAR_14 is None:\n",
"VAR_14 = g.locale.language if g.locale else 'en'\n",
"VAR_38 = f'ui:{VAR_12}:{VAR_13}:{VAR_14}'\n",
"if callable(VAR_15):\n",
"return VAR_38\n",
"VAR_127 = VAR_15()\n",
"VAR_0.exception(\n 'Error while trying to retrieve additional cache key parts for ui {}'.\n format(VAR_12))\n",
"if VAR_127:\n",
"if not isinstance(VAR_127, (list, tuple)):\n",
"VAR_127 = [VAR_127]\n",
"VAR_38 = '{}:{}'.format(VAR_38, ':'.join(VAR_127))\n"
] | [
"def _cache_key(ui, url=None, locale=None, additional_key_data=None):...\n",
"if url is None:\n",
"url = request.base_url\n",
"if locale is None:\n",
"locale = g.locale.language if g.locale else 'en'\n",
"k = f'ui:{ui}:{url}:{locale}'\n",
"if callable(additional_key_data):\n",
"return k\n",
"ak = additional_key_data()\n",
"_logger.exception(\n 'Error while trying to retrieve additional cache key parts for ui {}'.\n format(ui))\n",
"if ak:\n",
"if not isinstance(ak, (list, tuple)):\n",
"ak = [ak]\n",
"k = '{}:{}'.format(k, ':'.join(ak))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Condition",
"Condition",
"Assign'",
"Assign'"
] |
[
"def FUNC_7(VAR_9, VAR_6=0):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_26 = ' ' * VAR_6\n",
"def FUNC_30(VAR_27):...\n",
"print(VAR_26 + VAR_27)\n",
"FUNC_30(' dtype: ' + {VAR_31: key for key, VAR_31 in types_pb2.DataType.\n items()}[VAR_9.dtype])\n",
"if VAR_9.tensor_shape.unknown_rank:\n",
"VAR_64 = 'unknown_rank'\n",
"VAR_65 = [str(dim.size) for dim in VAR_9.tensor_shape.dim]\n",
"FUNC_30(' shape: ' + VAR_64)\n",
"VAR_64 = ', '.join(VAR_65)\n",
"FUNC_30(' name: ' + VAR_9.name)\n",
"VAR_64 = '(' + VAR_64 + ')'\n"
] | [
"def _print_tensor_info(tensor_info, indent=0):...\n",
"\"\"\"docstring\"\"\"\n",
"indent_str = ' ' * indent\n",
"def in_print(s):...\n",
"print(indent_str + s)\n",
"in_print(' dtype: ' + {value: key for key, value in types_pb2.DataType.\n items()}[tensor_info.dtype])\n",
"if tensor_info.tensor_shape.unknown_rank:\n",
"shape = 'unknown_rank'\n",
"dims = [str(dim.size) for dim in tensor_info.tensor_shape.dim]\n",
"in_print(' shape: ' + shape)\n",
"shape = ', '.join(dims)\n",
"in_print(' name: ' + tensor_info.name)\n",
"shape = '(' + shape + ')'\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"FunctionDef'",
"Expr'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'"
] |
[
"def FUNC_2(self):...\n",
"self.room = self.helper.create_room_as(self.u_alice, tok=self.t_alice)\n",
"VAR_5 = self.get_success(self.store.\n get_rooms_for_local_user_where_membership_is(self.u_alice, [Membership.\n JOIN]))\n",
"self.assertEquals([self.room], [m.room_id for m in VAR_5])\n"
] | [
"def test_one_member(self):...\n",
"self.room = self.helper.create_room_as(self.u_alice, tok=self.t_alice)\n",
"rooms_for_user = self.get_success(self.store.\n get_rooms_for_local_user_where_membership_is(self.u_alice, [Membership.\n JOIN]))\n",
"self.assertEquals([self.room], [m.room_id for m in rooms_for_user])\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_15():...\n",
"random.seed(VAR_24)\n",
"return list(map(lambda x: x + VAR_5 * VAR_41, sorted(random.sample(list(\n range(VAR_5)), VAR_40))))\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_38(VAR_33):...\n",
"if callable(VAR_65):\n",
"return FUNC_19(VAR_33)\n",
"VAR_34 = VAR_65()\n",
"VAR_0.exception(\n 'Error while trying to retrieve custom LastModified value for plugin {}'\n .format(VAR_8))\n",
"if VAR_34:\n",
"return VAR_34\n"
] | [
"def compute_lastmodified(files):...\n",
"if callable(custom_lastmodified):\n",
"return _compute_date(files)\n",
"lastmodified = custom_lastmodified()\n",
"_logger.exception(\n 'Error while trying to retrieve custom LastModified value for plugin {}'\n .format(key))\n",
"if lastmodified:\n",
"return lastmodified\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Condition",
"Return'"
] |
[
"def FUNC_57():...\n",
"VAR_3 = request.args(0)\n",
"VAR_116 = request.vars.source\n",
"VAR_96 = request.vars.plugin\n",
"if not (VAR_116 and VAR_3):\n",
"if not VAR_116.lower().split('://')[0] in ('http', 'https'):\n",
"VAR_26 = SQLFORM.factory()\n",
"VAR_110 = None\n",
"if VAR_26.process().accepted:\n",
"if 'web2py.plugin.' in VAR_116:\n",
"return dict(VAR_26=form, VAR_3=app, VAR_96=plugin, VAR_116=source)\n",
"VAR_5 = 'web2py.plugin.%s.w2p' % VAR_116.split('web2py.plugin.')[-1].split(\n '.w2p')[0]\n",
"VAR_5 = 'web2py.plugin.%s.w2p' % cleanpath(VAR_96)\n",
"if plugin_install(VAR_3, urlopen(VAR_116), request, VAR_5):\n",
"session.flash = T('New plugin installed: %s', VAR_5)\n",
"session.flash = T('unable to install plugin \"%s\"', VAR_5)\n",
"redirect(URL(VAR_221='plugins', VAR_98=[app]))\n"
] | [
"def install_plugin():...\n",
"app = request.args(0)\n",
"source = request.vars.source\n",
"plugin = request.vars.plugin\n",
"if not (source and app):\n",
"if not source.lower().split('://')[0] in ('http', 'https'):\n",
"form = SQLFORM.factory()\n",
"result = None\n",
"if form.process().accepted:\n",
"if 'web2py.plugin.' in source:\n",
"return dict(form=form, app=app, plugin=plugin, source=source)\n",
"filename = 'web2py.plugin.%s.w2p' % source.split('web2py.plugin.')[-1].split(\n '.w2p')[0]\n",
"filename = 'web2py.plugin.%s.w2p' % cleanpath(plugin)\n",
"if plugin_install(app, urlopen(source), request, filename):\n",
"session.flash = T('New plugin installed: %s', filename)\n",
"session.flash = T('unable to install plugin \"%s\"', filename)\n",
"redirect(URL(f='plugins', args=[app]))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_62(self):...\n",
"VAR_66 = self._random_alias()\n",
"VAR_67 = self._random_alias()\n",
"self._set_alias_via_directory(VAR_66)\n",
"self._set_alias_via_directory(VAR_67)\n",
"VAR_61 = self._get_aliases(self.room_owner_tok)\n",
"self.assertEqual(set(VAR_61['aliases']), {VAR_66, VAR_67})\n"
] | [
"def test_with_aliases(self):...\n",
"alias1 = self._random_alias()\n",
"alias2 = self._random_alias()\n",
"self._set_alias_via_directory(alias1)\n",
"self._set_alias_via_directory(alias2)\n",
"res = self._get_aliases(self.room_owner_tok)\n",
"self.assertEqual(set(res['aliases']), {alias1, alias2})\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"@def_function.function(input_signature=[tensor_spec.TensorSpec(shape=(2, 2),...\n",
"return VAR_44 + 2\n"
] | [
"@def_function.function(input_signature=[tensor_spec.TensorSpec(shape=(2, 2),...\n",
"return x + 2\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_40():...\n",
"VAR_90 = util.flask.check_lastmodified(VAR_103)\n",
"VAR_89 = util.flask.check_etag(VAR_104)\n",
"return VAR_90 and VAR_89\n"
] | [
"def check_etag_and_lastmodified():...\n",
"lastmodified_ok = util.flask.check_lastmodified(current_lastmodified)\n",
"etag_ok = util.flask.check_etag(current_etag)\n",
"return lastmodified_ok and etag_ok\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_21(VAR_43, VAR_44=False):...\n",
"\"\"\"docstring\"\"\"\n",
"from frappe.utils import touch_file\n",
"if not os.path.exists(VAR_43):\n",
"os.makedirs(VAR_43)\n",
"if VAR_44:\n",
"touch_file(os.path.join(VAR_43, '__init__.py'))\n"
] | [
"def create_folder(path, with_init=False):...\n",
"\"\"\"docstring\"\"\"\n",
"from frappe.utils import touch_file\n",
"if not os.path.exists(path):\n",
"os.makedirs(path)\n",
"if with_init:\n",
"touch_file(os.path.join(path, '__init__.py'))\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"ImportFrom'",
"Condition",
"Expr'",
"Condition",
"Expr'"
] |
[
"@app.route('/user/edit', methods=['GET', 'POST'])...\n",
"VAR_9 = forms.UserForm()\n",
"if VAR_9.validate_on_submit():\n",
"VAR_33 = get_db()\n",
"VAR_9.username.data = current_user.username\n",
"VAR_33.update({'username': VAR_9.username.data, 'hashed_password':\n generate_password_hash(VAR_9.password.data)}, doc_ids=[current_user.id])\n",
"return render_template('users/edit.html', VAR_9=form, title='Edit Profile')\n",
"flash('Information saved!', 'success')\n",
"return redirect('/')\n"
] | [
"@app.route('/user/edit', methods=['GET', 'POST'])...\n",
"form = forms.UserForm()\n",
"if form.validate_on_submit():\n",
"db = get_db()\n",
"form.username.data = current_user.username\n",
"db.update({'username': form.username.data, 'hashed_password':\n generate_password_hash(form.password.data)}, doc_ids=[current_user.id])\n",
"return render_template('users/edit.html', form=form, title='Edit Profile')\n",
"flash('Information saved!', 'success')\n",
"return redirect('/')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Return'",
"Expr'",
"Return'"
] |
[
"def FUNC_37(VAR_99=None, VAR_100=None):...\n",
"\"\"\"docstring\"\"\"\n",
"import hashlib, time\n",
"from .utils import random_string\n",
"VAR_186 = hashlib.sha224(((VAR_99 or '') + repr(time.time()) + repr(\n random_string(8))).encode()).hexdigest()\n",
"if VAR_100:\n",
"VAR_186 = VAR_186[:VAR_100]\n",
"return VAR_186\n"
] | [
"def generate_hash(txt=None, length=None):...\n",
"\"\"\"docstring\"\"\"\n",
"import hashlib, time\n",
"from .utils import random_string\n",
"digest = hashlib.sha224(((txt or '') + repr(time.time()) + repr(\n random_string(8))).encode()).hexdigest()\n",
"if length:\n",
"digest = digest[:length]\n",
"return digest\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Import'",
"ImportFrom'",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_7(self, VAR_16, VAR_17, VAR_5):...\n",
"return self.widget.value_from_datadict(VAR_16, VAR_17, VAR_5)\n"
] | [
"def value_from_datadict(self, data, files, name):...\n",
"return self.widget.value_from_datadict(data, files, name)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@VAR_0.route('/video_feed/<unique_id>')...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_40 = Camera.query.filter(Camera.unique_id == VAR_9).first()\n",
"VAR_41 = import_module('mycodo.mycodo_flask.camera.camera_' + VAR_40.library\n ).Camera\n",
"VAR_41.set_camera_options(VAR_40)\n",
"return Response(FUNC_7(VAR_41(VAR_9=unique_id)), mimetype=\n 'multipart/x-mixed-replace; boundary=frame')\n"
] | [
"@blueprint.route('/video_feed/<unique_id>')...\n",
"\"\"\"docstring\"\"\"\n",
"camera_options = Camera.query.filter(Camera.unique_id == unique_id).first()\n",
"camera_stream = import_module('mycodo.mycodo_flask.camera.camera_' +\n camera_options.library).Camera\n",
"camera_stream.set_camera_options(camera_options)\n",
"return Response(gen(camera_stream(unique_id=unique_id)), mimetype=\n 'multipart/x-mixed-replace; boundary=frame')\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_23(self, VAR_81):...\n",
"if self.additional_payload:\n",
"if callable(self.additional_payload):\n",
"return VAR_81\n",
"VAR_81 = self.additional_payload(VAR_81)\n",
"if isinstance(self.additional_payload, dict):\n",
"VAR_81.update(self.additional_payload)\n"
] | [
"def alter_payload(self, payload):...\n",
"if self.additional_payload:\n",
"if callable(self.additional_payload):\n",
"return payload\n",
"payload = self.additional_payload(payload)\n",
"if isinstance(self.additional_payload, dict):\n",
"payload.update(self.additional_payload)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"Return'",
"Assign'",
"Condition",
"Expr'"
] |
[
"@VAR_0.route('/api/query/run', methods=['POST'])...\n",
"if get_user() is None:\n",
"return 'Authentication required', 401\n",
"VAR_21 = request.form['text']\n",
"VAR_14 = g.conn.session.query(Query).filter(Query.id == request.form[\n 'query_id']).one()\n",
"if VAR_14.user_id != get_user().id or g.conn.session.query(UserGroup).filter(\n",
"return 'Authorization denied', 403\n",
"if VAR_14.latest_rev and VAR_14.latest_rev.latest_run:\n",
"VAR_35 = worker.run_query.AsyncResult(VAR_14.latest_rev.latest_run.task_id)\n",
"VAR_16 = QueryRevision(VAR_4=query.id, VAR_21=text)\n",
"if not VAR_35.ready():\n",
"VAR_14.latest_rev = VAR_16\n",
"VAR_35.revoke(terminate=True)\n",
"VAR_22 = QueryRun()\n",
"VAR_14.latest_rev.latest_run.status = QueryRun.STATUS_SUPERSEDED\n",
"VAR_22.rev = VAR_16\n",
"g.conn.session.add(VAR_14.latest_rev.latest_run)\n",
"VAR_22.status = QueryRun.STATUS_QUEUED\n",
"g.conn.session.commit()\n",
"g.conn.session.add(VAR_22)\n",
"g.conn.session.add(VAR_14)\n",
"g.conn.session.commit()\n",
"VAR_16.latest_run = VAR_22\n",
"VAR_22.task_id = worker.run_query.delay(VAR_22.id).task_id\n",
"g.conn.session.add(VAR_16)\n",
"g.conn.session.add(VAR_22)\n",
"g.conn.session.commit()\n",
"return json.dumps({'qrun_id': VAR_22.id})\n"
] | [
"@app.route('/api/query/run', methods=['POST'])...\n",
"if get_user() is None:\n",
"return 'Authentication required', 401\n",
"text = request.form['text']\n",
"query = g.conn.session.query(Query).filter(Query.id == request.form['query_id']\n ).one()\n",
"if query.user_id != get_user().id or g.conn.session.query(UserGroup).filter(\n",
"return 'Authorization denied', 403\n",
"if query.latest_rev and query.latest_rev.latest_run:\n",
"result = worker.run_query.AsyncResult(query.latest_rev.latest_run.task_id)\n",
"query_rev = QueryRevision(query_id=query.id, text=text)\n",
"if not result.ready():\n",
"query.latest_rev = query_rev\n",
"result.revoke(terminate=True)\n",
"query_run = QueryRun()\n",
"query.latest_rev.latest_run.status = QueryRun.STATUS_SUPERSEDED\n",
"query_run.rev = query_rev\n",
"g.conn.session.add(query.latest_rev.latest_run)\n",
"query_run.status = QueryRun.STATUS_QUEUED\n",
"g.conn.session.commit()\n",
"g.conn.session.add(query_run)\n",
"g.conn.session.add(query)\n",
"g.conn.session.commit()\n",
"query_rev.latest_run = query_run\n",
"query_run.task_id = worker.run_query.delay(query_run.id).task_id\n",
"g.conn.session.add(query_rev)\n",
"g.conn.session.add(query_run)\n",
"g.conn.session.commit()\n",
"return json.dumps({'qrun_id': query_run.id})\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"@method_decorator(sensitive_post_parameters('password', 'csrfmiddlewaretoken'))...\n",
"\"\"\"docstring\"\"\"\n",
"return super(CLASS_1, self).dispatch(*VAR_116, **kwargs)\n"
] | [
"@method_decorator(sensitive_post_parameters('password', 'csrfmiddlewaretoken'))...\n",
"\"\"\"docstring\"\"\"\n",
"return super(LoginView, self).dispatch(*args, **kwargs)\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_11(self, VAR_11):...\n",
"VAR_60 = self.download_check_files(VAR_11)\n",
"if VAR_60 == 'not_permitted':\n",
"return 'You are not allowed to download files.'\n",
"if VAR_60 == 'invalid_file':\n",
"return 'Error: invalid filename found in {list}'.format(list=filelist)\n",
"if VAR_60 == 'too_big':\n",
"VAR_59 = cherry.config['media.maximum_download_size']\n",
"if VAR_60 == 'ok':\n",
"return 'string'.format(maxsize=size_limit / 1024 / 1024)\n",
"return VAR_60\n",
"VAR_125 = 'Error status check for download: {status!r}'.format(VAR_60=status)\n",
"log.e(VAR_125)\n",
"return VAR_125\n"
] | [
"def api_downloadcheck(self, filelist):...\n",
"status = self.download_check_files(filelist)\n",
"if status == 'not_permitted':\n",
"return 'You are not allowed to download files.'\n",
"if status == 'invalid_file':\n",
"return 'Error: invalid filename found in {list}'.format(list=filelist)\n",
"if status == 'too_big':\n",
"size_limit = cherry.config['media.maximum_download_size']\n",
"if status == 'ok':\n",
"return \"\"\"Can't download: Playlist is bigger than {maxsize} mB.\n The server administrator can change this configuration.\n \"\"\".format(\n maxsize=size_limit / 1024 / 1024)\n",
"return status\n",
"message = 'Error status check for download: {status!r}'.format(status=status)\n",
"log.e(message)\n",
"return message\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Return'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_5(self):...\n",
"if not self.current_cell:\n",
"self.form = None\n",
"VAR_4 = {'layout_cell': self.current_cell, 'theme': self.view_config.theme,\n 'request': self.request}\n",
"return\n",
"if self.request.method == 'POST':\n",
"VAR_4['data'] = self.request.POST\n",
"self.form = LayoutCellFormGroup(**kwargs)\n",
"VAR_4['files'] = self.request.FILES\n"
] | [
"def build_form(self):...\n",
"if not self.current_cell:\n",
"self.form = None\n",
"kwargs = {'layout_cell': self.current_cell, 'theme': self.view_config.theme,\n 'request': self.request}\n",
"return\n",
"if self.request.method == 'POST':\n",
"kwargs['data'] = self.request.POST\n",
"self.form = LayoutCellFormGroup(**kwargs)\n",
"kwargs['files'] = self.request.FILES\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Assign'",
"Assign'"
] |
[
"from mock import Mock, patch\n",
"from parameterized import parameterized\n",
"from synapse.app.generic_worker import GenericWorkerServer\n",
"from synapse.app.homeserver import SynapseHomeServer\n",
"from synapse.config.server import parse_listener_def\n",
"from tests.server import make_request\n",
"from tests.unittest import HomeserverTestCase\n",
"def FUNC_0(self, VAR_0, VAR_1):...\n",
"VAR_4 = self.setup_test_homeserver(http_client=None, homeserver_to_use=\n GenericWorkerServer)\n",
"return VAR_4\n"
] | [
"from mock import Mock, patch\n",
"from parameterized import parameterized\n",
"from synapse.app.generic_worker import GenericWorkerServer\n",
"from synapse.app.homeserver import SynapseHomeServer\n",
"from synapse.config.server import parse_listener_def\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,
0,
0,
0,
0,
4,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"@ensure_csrf_cookie...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_10 = CourseKey.from_string(VAR_10)\n",
"VAR_89 = False\n",
"VAR_179 = int(VAR_9.POST['total_registration_codes'])\n",
"VAR_179 = int(float(VAR_9.POST['total_registration_codes']))\n",
"VAR_88 = VAR_9.POST['company_name']\n",
"VAR_90 = VAR_9.POST['company_contact_name']\n",
"VAR_91 = VAR_9.POST['company_contact_email']\n",
"VAR_92 = VAR_9.POST['unit_price']\n",
"VAR_92 = decimal.Decimal(VAR_92).quantize(decimal.Decimal('.01'), rounding=\n decimal.ROUND_DOWN)\n",
"return HttpResponse(status=400, content=_(\n u'Could not parse amount as a decimal'))\n",
"VAR_93 = VAR_9.POST['recipient_name']\n",
"VAR_94 = VAR_9.POST['recipient_email']\n",
"VAR_95 = VAR_9.POST['address_line_1']\n",
"VAR_96 = VAR_9.POST['address_line_2']\n",
"VAR_97 = VAR_9.POST['address_line_3']\n",
"VAR_98 = VAR_9.POST['city']\n",
"VAR_99 = VAR_9.POST['state']\n",
"VAR_100 = VAR_9.POST['zip']\n",
"VAR_17 = VAR_9.POST['country']\n",
"VAR_101 = VAR_9.POST['internal_reference']\n",
"VAR_102 = VAR_9.POST['customer_reference_number']\n",
"VAR_103 = [VAR_94]\n",
"if VAR_9.POST.get('invoice', False):\n",
"VAR_103.append(VAR_9.user.email)\n",
"VAR_104 = VAR_92 * VAR_179\n",
"VAR_89 = True\n",
"set_user_preference(VAR_9.user, INVOICE_KEY, VAR_89)\n",
"VAR_105 = Invoice.objects.create(total_amount=sale_price, VAR_88=\n company_name, VAR_91=company_contact_email, VAR_90=company_contact_name,\n VAR_10=course_id, VAR_93=recipient_name, VAR_94=recipient_email, VAR_95\n =address_line_1, VAR_96=address_line_2, VAR_97=address_line_3, VAR_98=\n city, VAR_99=state, zip=zip_code, VAR_17=country, VAR_101=\n internal_reference, VAR_102=customer_reference_number)\n",
"VAR_31 = CourseRegistrationCodeInvoiceItem.objects.create(VAR_29=\n sale_invoice, qty=course_code_number, VAR_92=unit_price, VAR_10=course_id)\n",
"VAR_65 = get_course_by_id(VAR_10, depth=0)\n",
"VAR_106 = CourseMode.paid_modes_for_course(VAR_10)\n",
"if len(VAR_106) != 1:\n",
"VAR_180 = u'string'.format(VAR_10=course_id, VAR_106=paid_modes)\n",
"VAR_24 = VAR_106[0]\n",
"VAR_0.error(VAR_180)\n",
"VAR_107 = VAR_24.min_price\n",
"return HttpResponse(status=500, content=_(\n u'Unable to generate redeem codes because of course misconfiguration.'))\n",
"VAR_85 = []\n",
"for VAR_72 in range(VAR_179):\n",
"VAR_181 = FUNC_33(VAR_9.user, VAR_10, VAR_24.slug, VAR_29=sale_invoice,\n VAR_30=None, VAR_31=invoice_item)\n",
"VAR_108 = microsite.get_value('SITE_NAME', 'localhost')\n",
"VAR_85.append(VAR_181)\n",
"VAR_109 = VAR_179\n",
"VAR_110 = float(VAR_109 * VAR_107) - float(VAR_104)\n",
"VAR_111 = '{base_url}{course_about}'.format(base_url=microsite.get_value(\n 'SITE_NAME', settings.SITE_NAME), course_about=reverse('about_course',\n kwargs={'course_id': course_id.to_deprecated_string()}))\n",
"VAR_112 = '{base_url}{dashboard}'.format(base_url=microsite.get_value(\n 'SITE_NAME', settings.SITE_NAME), dashboard=reverse('dashboard'))\n",
"VAR_182 = VAR_105.generate_pdf_invoice(VAR_65, VAR_107, int(VAR_109), float\n (VAR_104))\n",
"VAR_0.exception('Exception at creating pdf file.')\n",
"VAR_113 = theming_helpers.get_value('email_from_address', settings.\n DEFAULT_FROM_EMAIL)\n",
"VAR_182 = None\n",
"VAR_114 = {'invoice': VAR_105, 'site_name': VAR_108, 'course': VAR_65,\n 'course_price': VAR_107, 'sub_total': VAR_107 * VAR_109, 'discount':\n VAR_110, 'sale_price': VAR_104, 'quantity': VAR_109,\n 'registration_codes': VAR_85, 'currency_symbol': settings.\n PAID_COURSE_REGISTRATION_CURRENCY[1], 'course_url': VAR_111,\n 'platform_name': microsite.get_value('platform_name', settings.\n PLATFORM_NAME), 'dashboard_url': VAR_112, 'contact_email': VAR_113,\n 'corp_address': microsite.get_value('invoice_corp_address', settings.\n INVOICE_CORP_ADDRESS), 'payment_instructions': microsite.get_value(\n 'invoice_payment_instructions', settings.INVOICE_PAYMENT_INSTRUCTIONS),\n 'date': time.strftime('%m/%d/%Y')}\n",
"VAR_115 = u'Confirmation and Invoice for {course_name}'.format(course_name=\n course.display_name)\n",
"VAR_74 = render_to_string('emails/registration_codes_sale_email.txt', VAR_114)\n",
"VAR_116 = render_to_string(\n 'emails/registration_codes_sale_invoice_attachment.txt', VAR_114)\n",
"VAR_117 = StringIO.StringIO()\n",
"VAR_118 = VAR_26.writer(VAR_117)\n",
"for registration_code in VAR_85:\n",
"VAR_183 = 'http://{base_url}{redeem_code_url}'.format(base_url=microsite.\n get_value('SITE_NAME', settings.SITE_NAME), redeem_code_url=reverse(\n 'register_code_redemption', kwargs={'registration_code':\n registration_code.code}))\n",
"VAR_119 = microsite.get_value('finance_email', settings.FINANCE_EMAIL)\n",
"VAR_118.writerow([registration_code.code, VAR_183])\n",
"if VAR_119:\n",
"VAR_103.append(VAR_119)\n",
"for recipient in VAR_103:\n",
"VAR_14 = EmailMessage()\n",
"return FUNC_34('Registration_Codes.csv', VAR_85)\n",
"VAR_14.subject = VAR_115\n",
"VAR_14.body = VAR_74\n",
"VAR_14.from_email = VAR_113\n",
"VAR_14.to = [recipient]\n",
"VAR_14.attach(u'RegistrationCodes.csv', VAR_117.getvalue(), 'text/csv')\n",
"VAR_14.attach(u'Invoice.txt', VAR_116, 'text/plain')\n",
"if VAR_182 is not None:\n",
"VAR_14.attach(u'Invoice.pdf', VAR_182.getvalue(), 'application/pdf')\n",
"VAR_198 = StringIO.StringIO(_(\n 'pdf download unavailable right now, please contact support.'))\n",
"VAR_14.send()\n",
"VAR_14.attach(u'pdf_unavailable.txt', VAR_198.getvalue(), 'text/plain')\n"
] | [
"@ensure_csrf_cookie...\n",
"\"\"\"docstring\"\"\"\n",
"course_id = CourseKey.from_string(course_id)\n",
"invoice_copy = False\n",
"course_code_number = int(request.POST['total_registration_codes'])\n",
"course_code_number = int(float(request.POST['total_registration_codes']))\n",
"company_name = request.POST['company_name']\n",
"company_contact_name = request.POST['company_contact_name']\n",
"company_contact_email = request.POST['company_contact_email']\n",
"unit_price = request.POST['unit_price']\n",
"unit_price = decimal.Decimal(unit_price).quantize(decimal.Decimal('.01'),\n rounding=decimal.ROUND_DOWN)\n",
"return HttpResponse(status=400, content=_(\n u'Could not parse amount as a decimal'))\n",
"recipient_name = request.POST['recipient_name']\n",
"recipient_email = request.POST['recipient_email']\n",
"address_line_1 = request.POST['address_line_1']\n",
"address_line_2 = request.POST['address_line_2']\n",
"address_line_3 = request.POST['address_line_3']\n",
"city = request.POST['city']\n",
"state = request.POST['state']\n",
"zip_code = request.POST['zip']\n",
"country = request.POST['country']\n",
"internal_reference = request.POST['internal_reference']\n",
"customer_reference_number = request.POST['customer_reference_number']\n",
"recipient_list = [recipient_email]\n",
"if request.POST.get('invoice', False):\n",
"recipient_list.append(request.user.email)\n",
"sale_price = unit_price * course_code_number\n",
"invoice_copy = True\n",
"set_user_preference(request.user, INVOICE_KEY, invoice_copy)\n",
"sale_invoice = Invoice.objects.create(total_amount=sale_price, company_name\n =company_name, company_contact_email=company_contact_email,\n company_contact_name=company_contact_name, course_id=course_id,\n recipient_name=recipient_name, recipient_email=recipient_email,\n address_line_1=address_line_1, address_line_2=address_line_2,\n address_line_3=address_line_3, city=city, state=state, zip=zip_code,\n country=country, internal_reference=internal_reference,\n customer_reference_number=customer_reference_number)\n",
"invoice_item = CourseRegistrationCodeInvoiceItem.objects.create(invoice=\n sale_invoice, qty=course_code_number, unit_price=unit_price, course_id=\n course_id)\n",
"course = get_course_by_id(course_id, depth=0)\n",
"paid_modes = CourseMode.paid_modes_for_course(course_id)\n",
"if len(paid_modes) != 1:\n",
"msg = (\n u\"Generating Code Redeem Codes for Course '{course_id}', which must have a single paid course mode. This is a configuration issue. Current course modes with payment options: {paid_modes}\"\n .format(course_id=course_id, paid_modes=paid_modes))\n",
"course_mode = paid_modes[0]\n",
"log.error(msg)\n",
"course_price = course_mode.min_price\n",
"return HttpResponse(status=500, content=_(\n u'Unable to generate redeem codes because of course misconfiguration.'))\n",
"registration_codes = []\n",
"for __ in range(course_code_number):\n",
"generated_registration_code = save_registration_code(request.user,\n course_id, course_mode.slug, invoice=sale_invoice, order=None,\n invoice_item=invoice_item)\n",
"site_name = microsite.get_value('SITE_NAME', 'localhost')\n",
"registration_codes.append(generated_registration_code)\n",
"quantity = course_code_number\n",
"discount = float(quantity * course_price) - float(sale_price)\n",
"course_url = '{base_url}{course_about}'.format(base_url=microsite.get_value\n ('SITE_NAME', settings.SITE_NAME), course_about=reverse('about_course',\n kwargs={'course_id': course_id.to_deprecated_string()}))\n",
"dashboard_url = '{base_url}{dashboard}'.format(base_url=microsite.get_value\n ('SITE_NAME', settings.SITE_NAME), dashboard=reverse('dashboard'))\n",
"pdf_file = sale_invoice.generate_pdf_invoice(course, course_price, int(\n quantity), float(sale_price))\n",
"log.exception('Exception at creating pdf file.')\n",
"from_address = theming_helpers.get_value('email_from_address', settings.\n DEFAULT_FROM_EMAIL)\n",
"pdf_file = None\n",
"context = {'invoice': sale_invoice, 'site_name': site_name, 'course':\n course, 'course_price': course_price, 'sub_total': course_price *\n quantity, 'discount': discount, 'sale_price': sale_price, 'quantity':\n quantity, 'registration_codes': registration_codes, 'currency_symbol':\n settings.PAID_COURSE_REGISTRATION_CURRENCY[1], 'course_url': course_url,\n 'platform_name': microsite.get_value('platform_name', settings.\n PLATFORM_NAME), 'dashboard_url': dashboard_url, 'contact_email':\n from_address, 'corp_address': microsite.get_value(\n 'invoice_corp_address', settings.INVOICE_CORP_ADDRESS),\n 'payment_instructions': microsite.get_value(\n 'invoice_payment_instructions', settings.INVOICE_PAYMENT_INSTRUCTIONS),\n 'date': time.strftime('%m/%d/%Y')}\n",
"subject = u'Confirmation and Invoice for {course_name}'.format(course_name=\n course.display_name)\n",
"message = render_to_string('emails/registration_codes_sale_email.txt', context)\n",
"invoice_attachment = render_to_string(\n 'emails/registration_codes_sale_invoice_attachment.txt', context)\n",
"csv_file = StringIO.StringIO()\n",
"csv_writer = csv.writer(csv_file)\n",
"for registration_code in registration_codes:\n",
"full_redeem_code_url = 'http://{base_url}{redeem_code_url}'.format(base_url\n =microsite.get_value('SITE_NAME', settings.SITE_NAME), redeem_code_url=\n reverse('register_code_redemption', kwargs={'registration_code':\n registration_code.code}))\n",
"finance_email = microsite.get_value('finance_email', settings.FINANCE_EMAIL)\n",
"csv_writer.writerow([registration_code.code, full_redeem_code_url])\n",
"if finance_email:\n",
"recipient_list.append(finance_email)\n",
"for recipient in recipient_list:\n",
"email = EmailMessage()\n",
"return registration_codes_csv('Registration_Codes.csv', registration_codes)\n",
"email.subject = subject\n",
"email.body = message\n",
"email.from_email = from_address\n",
"email.to = [recipient]\n",
"email.attach(u'RegistrationCodes.csv', csv_file.getvalue(), 'text/csv')\n",
"email.attach(u'Invoice.txt', invoice_attachment, 'text/plain')\n",
"if pdf_file is not None:\n",
"email.attach(u'Invoice.pdf', pdf_file.getvalue(), 'application/pdf')\n",
"file_buffer = StringIO.StringIO(_(\n 'pdf download unavailable right now, please contact support.'))\n",
"email.send()\n",
"email.attach(u'pdf_unavailable.txt', file_buffer.getvalue(), 'text/plain')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"For",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_45(VAR_18):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_109 = VAR_18.split('\"')\n",
"VAR_110 = len(VAR_109) != 0 and VAR_109[0] or ''\n",
"VAR_111 = 1\n",
"while VAR_111 < len(VAR_109):\n",
"VAR_171 = FUNC_44(VAR_109[VAR_111])\n",
"return VAR_110\n",
"if VAR_171 == '':\n",
"VAR_110 += '\"' + VAR_109[VAR_111]\n",
"VAR_110 += VAR_171\n",
"VAR_111 = VAR_111 + 1\n",
"if VAR_111 + 1 < len(VAR_109):\n",
"VAR_110 += VAR_109[VAR_111 + 1]\n",
"VAR_111 = VAR_111 + 1\n"
] | [
"def make_links(traceback):...\n",
"\"\"\"docstring\"\"\"\n",
"lwords = traceback.split('\"')\n",
"result = len(lwords) != 0 and lwords[0] or ''\n",
"i = 1\n",
"while i < len(lwords):\n",
"link = make_link(lwords[i])\n",
"return result\n",
"if link == '':\n",
"result += '\"' + lwords[i]\n",
"result += link\n",
"i = i + 1\n",
"if i + 1 < len(lwords):\n",
"result += lwords[i + 1]\n",
"i = i + 1\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Condition",
"AugAssign'",
"AugAssign'",
"Assign'",
"Condition",
"AugAssign'",
"Assign'"
] |
[
"@VAR_3.on('connect', namespace='/pty')...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_0.config['CHILD_PID'] and current_user.is_authenticated:\n",
"VAR_3.start_background_task(target=read_and_forward_pty_output)\n",
"return\n"
] | [
"@socketio.on('connect', namespace='/pty')...\n",
"\"\"\"docstring\"\"\"\n",
"if gui.config['CHILD_PID'] and current_user.is_authenticated:\n",
"socketio.start_background_task(target=read_and_forward_pty_output)\n",
"return\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Condition",
"Expr'",
"Return'"
] |
[
"def FUNC_13(VAR_30=True):...\n",
"return FUNC_10().set_value('flag_print_sql', VAR_30)\n"
] | [
"def print_sql(enable=True):...\n",
"return cache().set_value('flag_print_sql', enable)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"async def FUNC_11(self, VAR_12: str) ->List[EventBase]:...\n",
"VAR_1 = await self.store.get_event(VAR_12)\n",
"VAR_89 = await self.store.get_auth_chain(list(VAR_1.auth_event_ids()),\n include_given=True)\n",
"return list(VAR_89)\n"
] | [
"async def on_event_auth(self, event_id: str) ->List[EventBase]:...\n",
"event = await self.store.get_event(event_id)\n",
"auth = await self.store.get_auth_chain(list(event.auth_event_ids()),\n include_given=True)\n",
"return list(auth)\n"
] | [
0,
0,
0,
0
] | [
"AsyncFunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_11(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_17 = object()\n",
"self.assertEqual(format_value(VAR_17), VAR_17.__str__())\n"
] | [
"def test_format_value_object(self):...\n",
"\"\"\"docstring\"\"\"\n",
"obj = object()\n",
"self.assertEqual(format_value(obj), obj.__str__())\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_2(VAR_20, VAR_16, VAR_18, VAR_21):...\n",
"VAR_63 = ''\n",
"VAR_37 = []\n",
"VAR_64 = 0\n",
"while 1:\n",
"VAR_84, VAR_85 = None, None\n",
"for regex in VAR_16:\n",
"VAR_93 = VAR_64\n",
"if VAR_84 is None:\n",
"while 1:\n",
"if VAR_37:\n",
"VAR_60 = VAR_84.group(0)\n",
"VAR_100 = regex.search(VAR_20, pos=regex_pos)\n",
"assert not VAR_37[-1].tail\n",
"assert not VAR_63\n",
"VAR_86 = VAR_84.end()\n",
"if VAR_100 is None:\n",
"VAR_37[-1].tail = VAR_20\n",
"VAR_63 = VAR_20\n",
"if VAR_60.endswith('.') or VAR_60.endswith(','):\n",
"VAR_101 = VAR_100.group('host')\n",
"if VAR_100 is None:\n",
"return VAR_63, VAR_37\n",
"VAR_86 -= 1\n",
"VAR_87 = VAR_20[:VAR_84.start()]\n",
"for host_regex in VAR_18:\n",
"if VAR_85 is None or VAR_100.start() < VAR_85:\n",
"VAR_60 = VAR_60[:-1]\n",
"if VAR_37:\n",
"if host_regex.search(VAR_101):\n",
"VAR_84 = VAR_100\n",
"assert not VAR_37[-1].tail\n",
"assert not VAR_63\n",
"VAR_93 = VAR_100.end()\n",
"VAR_85 = VAR_100.start()\n",
"VAR_37[-1].tail = VAR_87\n",
"VAR_63 = VAR_87\n",
"VAR_56 = VAR_21('a')\n",
"VAR_56.set('href', VAR_60)\n",
"VAR_88 = VAR_84.group('body')\n",
"if not VAR_88:\n",
"VAR_88 = VAR_60\n",
"if VAR_88.endswith('.') or VAR_88.endswith(','):\n",
"VAR_88 = VAR_88[:-1]\n",
"VAR_56.text = VAR_88\n",
"VAR_37.append(VAR_56)\n",
"VAR_20 = VAR_20[VAR_86:]\n"
] | [
"def _link_text(text, link_regexes, avoid_hosts, factory):...\n",
"leading_text = ''\n",
"links = []\n",
"last_pos = 0\n",
"while 1:\n",
"best_match, best_pos = None, None\n",
"for regex in link_regexes:\n",
"regex_pos = last_pos\n",
"if best_match is None:\n",
"while 1:\n",
"if links:\n",
"link = best_match.group(0)\n",
"match = regex.search(text, pos=regex_pos)\n",
"assert not links[-1].tail\n",
"assert not leading_text\n",
"end = best_match.end()\n",
"if match is None:\n",
"links[-1].tail = text\n",
"leading_text = text\n",
"if link.endswith('.') or link.endswith(','):\n",
"host = match.group('host')\n",
"if match is None:\n",
"return leading_text, links\n",
"end -= 1\n",
"prev_text = text[:best_match.start()]\n",
"for host_regex in avoid_hosts:\n",
"if best_pos is None or match.start() < best_pos:\n",
"link = link[:-1]\n",
"if links:\n",
"if host_regex.search(host):\n",
"best_match = match\n",
"assert not links[-1].tail\n",
"assert not leading_text\n",
"regex_pos = match.end()\n",
"best_pos = match.start()\n",
"links[-1].tail = prev_text\n",
"leading_text = prev_text\n",
"anchor = factory('a')\n",
"anchor.set('href', link)\n",
"body = best_match.group('body')\n",
"if not body:\n",
"body = link\n",
"if body.endswith('.') or body.endswith(','):\n",
"body = body[:-1]\n",
"anchor.text = body\n",
"links.append(anchor)\n",
"text = text[end:]\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"For",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assert'",
"Assert'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Return'",
"AugAssign'",
"Assign'",
"For",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assert'",
"Assert'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'"
] |
[
"def FUNC_0(VAR_1):...\n",
"VAR_19 = ['select', 'delete', 'drop', 'update', 'case', 'and', 'or', 'like']\n",
"def FUNC_7(VAR_1):...\n",
"VAR_20.throw(_('Invalid Search Field {0}').format(VAR_1), VAR_20.DataError)\n",
"if len(VAR_1) == 1:\n",
"VAR_24 = re.compile('^.*[=;*,\\\\\\'\"$\\\\-+%#@()_].*')\n",
"if len(VAR_1) >= 3:\n",
"if VAR_24.match(VAR_1):\n",
"if '=' in VAR_1:\n",
"FUNC_7(VAR_1)\n",
"FUNC_7(VAR_1)\n",
"if ' --' in VAR_1:\n",
"FUNC_7(VAR_1)\n",
"if any(' {0} '.format(keyword) in VAR_1.split() for keyword in VAR_19):\n",
"FUNC_7(VAR_1)\n",
"if any(keyword in VAR_1.split() for keyword in VAR_19):\n",
"FUNC_7(VAR_1)\n",
"VAR_24 = re.compile('^.*[=;*,\\\\\\'\"$\\\\-+%#@()].*')\n",
"if any(VAR_24.match(f) for f in VAR_1.split()):\n",
"FUNC_7(VAR_1)\n"
] | [
"def sanitize_searchfield(searchfield):...\n",
"blacklisted_keywords = ['select', 'delete', 'drop', 'update', 'case', 'and',\n 'or', 'like']\n",
"def _raise_exception(searchfield):...\n",
"frappe.throw(_('Invalid Search Field {0}').format(searchfield), frappe.\n DataError)\n",
"if len(searchfield) == 1:\n",
"regex = re.compile('^.*[=;*,\\\\\\'\"$\\\\-+%#@()_].*')\n",
"if len(searchfield) >= 3:\n",
"if regex.match(searchfield):\n",
"if '=' in searchfield:\n",
"_raise_exception(searchfield)\n",
"_raise_exception(searchfield)\n",
"if ' --' in searchfield:\n",
"_raise_exception(searchfield)\n",
"if any(' {0} '.format(keyword) in searchfield.split() for keyword in\n",
"_raise_exception(searchfield)\n",
"if any(keyword in searchfield.split() for keyword in blacklisted_keywords):\n",
"_raise_exception(searchfield)\n",
"regex = re.compile('^.*[=;*,\\\\\\'\"$\\\\-+%#@()].*')\n",
"if any(regex.match(f) for f in searchfield.split()):\n",
"_raise_exception(searchfield)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"FunctionDef'",
"Expr'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"For",
"Expr'",
"For",
"Expr'",
"Assign'",
"For",
"Expr'"
] |
[
"def FUNC_9(self):...\n",
"return 'zenodo-{}'.format(self.record_id)\n"
] | [
"def get_build_slug(self):...\n",
"return 'zenodo-{}'.format(self.record_id)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_0(VAR_0):...\n",
"assert escaping.escape_attribute('') == ''\n",
"assert escaping.escape_text('') == ''\n"
] | [
"def test_htmllib_integration(register_builtin_html):...\n",
"assert escaping.escape_attribute('') == ''\n",
"assert escaping.escape_text('') == ''\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assert'",
"Assert'"
] |
[
"@VAR_0.route('/ajax/xchange', methods=['POST'])...\n",
"VAR_81 = VAR_33.get_json().get('xchange')\n",
"if VAR_81:\n",
"for val in VAR_81:\n",
"return ''\n",
"VAR_40 = False\n",
"return json.dumps({'success': True})\n",
"VAR_16 = calibre_db.get_book(val)\n",
"VAR_115 = VAR_16.title\n",
"VAR_116 = calibre_db.order_authors(VAR_16)\n",
"VAR_54 = []\n",
"for VAR_39 in VAR_116.authors:\n",
"VAR_54.append(VAR_39.name.replace('|', ','))\n",
"VAR_92 = FUNC_29(VAR_16, ' '.join(VAR_54))\n",
"VAR_63, VAR_93 = FUNC_30(VAR_16, VAR_115)\n",
"if VAR_93 or VAR_92:\n",
"VAR_91 = VAR_16.id\n",
"if config.config_use_google_drive:\n",
"VAR_40 = True\n",
"gdriveutils.updateGdriveCalibreFromLocal()\n",
"if VAR_91:\n",
"helper.update_dir_stucture(VAR_91, config.config_calibre_dir, VAR_63[0])\n",
"if VAR_40:\n",
"VAR_16.last_modified = datetime.utcnow()\n",
"calibre_db.session.commit()\n",
"calibre_db.session.rollback()\n",
"if config.config_use_google_drive:\n",
"VAR_1.error('Database error: %s', e)\n",
"gdriveutils.updateGdriveCalibreFromLocal()\n",
"return json.dumps({'success': False})\n"
] | [
"@editbook.route('/ajax/xchange', methods=['POST'])...\n",
"vals = request.get_json().get('xchange')\n",
"if vals:\n",
"for val in vals:\n",
"return ''\n",
"modif_date = False\n",
"return json.dumps({'success': True})\n",
"book = calibre_db.get_book(val)\n",
"authors = book.title\n",
"entries = calibre_db.order_authors(book)\n",
"author_names = []\n",
"for authr in entries.authors:\n",
"author_names.append(authr.name.replace('|', ','))\n",
"title_change = handle_title_on_edit(book, ' '.join(author_names))\n",
"input_authors, authorchange = handle_author_on_edit(book, authors)\n",
"if authorchange or title_change:\n",
"edited_books_id = book.id\n",
"if config.config_use_google_drive:\n",
"modif_date = True\n",
"gdriveutils.updateGdriveCalibreFromLocal()\n",
"if edited_books_id:\n",
"helper.update_dir_stucture(edited_books_id, config.config_calibre_dir,\n input_authors[0])\n",
"if modif_date:\n",
"book.last_modified = datetime.utcnow()\n",
"calibre_db.session.commit()\n",
"calibre_db.session.rollback()\n",
"if config.config_use_google_drive:\n",
"log.error('Database error: %s', e)\n",
"gdriveutils.updateGdriveCalibreFromLocal()\n",
"return json.dumps({'success': False})\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",
"Assign'",
"Condition",
"For",
"Return'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_3(VAR_8=CLASS_3, VAR_9=True):...\n",
"VAR_39 = CLASS_8()\n",
"VAR_39.iteratorFactory = CLASS_10\n",
"for pt in VAR_8._default_type_names:\n",
"VAR_39.registerType(pt, VAR_8)\n",
"VAR_39.registerType('string', CLASS_11)\n",
"VAR_39.registerType('python', ZRPythonExpr.PythonExpr)\n",
"VAR_39.registerType('not', NotExpr)\n",
"VAR_39.registerType('defer', DeferExpr)\n",
"VAR_39.registerType('lazy', LazyExpr)\n",
"VAR_39.registerType('provider', TALESProviderExpression)\n",
"VAR_39.registerBaseName('modules', VAR_0)\n",
"VAR_39.untrusted = VAR_9\n",
"return VAR_39\n"
] | [
"def createZopeEngine(zpe=ZopePathExpr, untrusted=True):...\n",
"e = ZopeEngine()\n",
"e.iteratorFactory = PathIterator\n",
"for pt in zpe._default_type_names:\n",
"e.registerType(pt, zpe)\n",
"e.registerType('string', UnicodeAwareStringExpr)\n",
"e.registerType('python', ZRPythonExpr.PythonExpr)\n",
"e.registerType('not', NotExpr)\n",
"e.registerType('defer', DeferExpr)\n",
"e.registerType('lazy', LazyExpr)\n",
"e.registerType('provider', TALESProviderExpression)\n",
"e.registerBaseName('modules', SecureModuleImporter)\n",
"e.untrusted = untrusted\n",
"return e\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"For",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Return'"
] |
[
"async def FUNC_5(VAR_25: WebSocket) ->None:...\n",
"VAR_53 = await solve_dependencies(VAR_24=websocket, VAR_10=dependant,\n VAR_22=dependency_overrides_provider)\n",
"VAR_11, VAR_51, VAR_56, VAR_57, VAR_58 = VAR_53\n",
"if VAR_51:\n",
"await VAR_25.close(code=WS_1008_POLICY_VIOLATION)\n",
"assert VAR_10.call is not None, 'dependant.call must be a function'\n",
"await VAR_10.call(**values)\n"
] | [
"async def app(websocket: WebSocket) ->None:...\n",
"solved_result = await solve_dependencies(request=websocket, dependant=\n dependant, dependency_overrides_provider=dependency_overrides_provider)\n",
"values, errors, _, _2, _3 = solved_result\n",
"if errors:\n",
"await websocket.close(code=WS_1008_POLICY_VIOLATION)\n",
"assert dependant.call is not None, 'dependant.call must be a function'\n",
"await dependant.call(**values)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"AsyncFunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assert'",
"Expr'"
] |
[
"@VAR_0.route('/query/new')...\n",
"if get_user() is None:\n",
"return redirect('/login?next=/query/new')\n",
"VAR_14 = Query()\n",
"VAR_14.user = get_user()\n",
"g.conn.session.add(VAR_14)\n",
"g.conn.session.commit()\n",
"return redirect(url_for('query_show', VAR_4=query.id))\n"
] | [
"@app.route('/query/new')...\n",
"if get_user() is None:\n",
"return redirect('/login?next=/query/new')\n",
"query = Query()\n",
"query.user = get_user()\n",
"g.conn.session.add(query)\n",
"g.conn.session.commit()\n",
"return redirect(url_for('query_show', query_id=query.id))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_35(self, VAR_23):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.docstatus:\n",
"self.docstatus = 0\n",
"if VAR_23 == 0:\n",
"if self.docstatus == 0:\n",
"if VAR_23 == 1:\n",
"self._action = 'save'\n",
"if self.docstatus == 1:\n",
"if self.docstatus == 1:\n",
"if VAR_23 == 2:\n",
"self._action = 'submit'\n",
"self._action = 'update_after_submit'\n",
"if self.docstatus == 2:\n",
"self.check_permission('submit')\n",
"self.check_permission('submit')\n",
"self._action = 'cancel'\n",
"self.check_permission('cancel')\n"
] | [
"def check_docstatus_transition(self, docstatus):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.docstatus:\n",
"self.docstatus = 0\n",
"if docstatus == 0:\n",
"if self.docstatus == 0:\n",
"if docstatus == 1:\n",
"self._action = 'save'\n",
"if self.docstatus == 1:\n",
"if self.docstatus == 1:\n",
"if docstatus == 2:\n",
"self._action = 'submit'\n",
"self._action = 'update_after_submit'\n",
"if self.docstatus == 2:\n",
"self.check_permission('submit')\n",
"self.check_permission('submit')\n",
"self._action = 'cancel'\n",
"self.check_permission('cancel')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_61(VAR_24: int, VAR_25: str=''):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_79, VAR_26 = pty.fork()\n",
"if VAR_79 == 0:\n",
"VAR_118 = os.environ.copy()\n",
"VAR_0.config['FD'] = VAR_26\n",
"VAR_118['WEB_CLI'] = 'True'\n",
"VAR_0.config['CHILD_PID'] = VAR_79\n",
"VAR_118['INTERNAL_PORT'] = str(VAR_24)\n",
"FUNC_62(VAR_26, 50, 50)\n",
"subprocess.run(f'ganga --webgui {VAR_25}', shell=True, env=ganga_env)\n",
"print('Ganga started, PID: ', VAR_79)\n"
] | [
"def start_ganga(internal_port: int, args: str=''):...\n",
"\"\"\"docstring\"\"\"\n",
"child_pid, fd = pty.fork()\n",
"if child_pid == 0:\n",
"ganga_env = os.environ.copy()\n",
"gui.config['FD'] = fd\n",
"ganga_env['WEB_CLI'] = 'True'\n",
"gui.config['CHILD_PID'] = child_pid\n",
"ganga_env['INTERNAL_PORT'] = str(internal_port)\n",
"set_windowsize(fd, 50, 50)\n",
"subprocess.run(f'ganga --webgui {args}', shell=True, env=ganga_env)\n",
"print('Ganga started, PID: ', child_pid)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_3(VAR_8):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_44 = {}\n",
"for config_file in VAR_8:\n",
"VAR_76 = yaml.safe_load(file_stream)\n",
"if 'server_name' not in VAR_44:\n",
"if not isinstance(VAR_76, dict):\n",
"if 'report_stats' not in VAR_44:\n",
"VAR_77 = \"File %r is empty or doesn't parse into a key-value map. IGNORING.\"\n",
"VAR_44.update(VAR_76)\n",
"return VAR_44\n",
"print(VAR_77 % (config_file,))\n"
] | [
"def read_config_files(config_files):...\n",
"\"\"\"docstring\"\"\"\n",
"specified_config = {}\n",
"for config_file in config_files:\n",
"yaml_config = yaml.safe_load(file_stream)\n",
"if 'server_name' not in specified_config:\n",
"if not isinstance(yaml_config, dict):\n",
"if 'report_stats' not in specified_config:\n",
"err = \"File %r is empty or doesn't parse into a key-value map. IGNORING.\"\n",
"specified_config.update(yaml_config)\n",
"return specified_config\n",
"print(err % (config_file,))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"For",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Expr'",
"Return'",
"Expr'"
] |
[
"def FUNC_80():...\n",
"VAR_84 = self.as_dict()\n",
"for VAR_43, VAR_26 in iteritems(VAR_84):\n",
"if VAR_26 == None:\n",
"return VAR_84\n",
"VAR_84[VAR_43] = ''\n"
] | [
"def get_values():...\n",
"values = self.as_dict()\n",
"for key, value in iteritems(values):\n",
"if value == None:\n",
"return values\n",
"values[key] = ''\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Condition",
"Return'",
"Assign'"
] |
[
"def FUNC_37(self):...\n",
"for VAR_21 in self.get_all_children():\n",
"if not VAR_21.name:\n",
"FUNC_17(VAR_21)\n"
] | [
"def set_name_in_children(self):...\n",
"for d in self.get_all_children():\n",
"if not d.name:\n",
"set_new_name(d)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Condition",
"Expr'"
] |
[
"def FUNC_19(self, VAR_3):...\n",
"return VAR_3.path\n"
] | [
"def render(self, request):...\n",
"return request.path\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@FUNC_2.__func__...\n",
"\"\"\"docstring\"\"\"\n",
"self.docstatus = 2\n",
"self.save()\n"
] | [
"@whitelist.__func__...\n",
"\"\"\"docstring\"\"\"\n",
"self.docstatus = 2\n",
"self.save()\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_9(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_15 = '[email protected]'\n",
"self.assertEqual(format_value(VAR_15),\n '<a href=\"mailto:[email protected]\">[email protected]</a>')\n"
] | [
"def test_format_value_string_email(self):...\n",
"\"\"\"docstring\"\"\"\n",
"email = '[email protected]'\n",
"self.assertEqual(format_value(email),\n '<a href=\"mailto:[email protected]\">[email protected]</a>')\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_7(VAR_6, VAR_4, VAR_9, VAR_7, VAR_5):...\n",
"if not isinstance(VAR_6, list):\n",
"VAR_6 = [x for x in VAR_6 if x != '']\n",
"VAR_8 = FUNC_2(VAR_4, VAR_5, VAR_6)\n",
"VAR_10 = FUNC_3(VAR_4, VAR_5, VAR_6)\n",
"VAR_48 = FUNC_4(VAR_4, VAR_7, VAR_8)\n",
"if len(VAR_10) > 0:\n",
"VAR_48 |= FUNC_5(VAR_4, VAR_9, VAR_7, VAR_5, VAR_10)\n",
"return VAR_48\n"
] | [
"def modify_database_object(input_elements, db_book_object, db_object,...\n",
"if not isinstance(input_elements, list):\n",
"input_elements = [x for x in input_elements if x != '']\n",
"del_elements = search_objects_remove(db_book_object, db_type, input_elements)\n",
"add_elements = search_objects_add(db_book_object, db_type, input_elements)\n",
"changed = remove_objects(db_book_object, db_session, del_elements)\n",
"if len(add_elements) > 0:\n",
"changed |= add_objects(db_book_object, db_object, db_session, db_type,\n add_elements)\n",
"return changed\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"AugAssign'",
"Return'"
] |
[
"@VAR_0.route('/shelf/<int:shelf_id>', defaults={'sort_param': 'order',...\n",
"return FUNC_15(1, VAR_3, VAR_6, VAR_8)\n"
] | [
"@shelf.route('/shelf/<int:shelf_id>', defaults={'sort_param': 'order',...\n",
"return render_show_shelf(1, shelf_id, page, sort_param)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_80(VAR_31, VAR_136, VAR_138=None, VAR_5=None, VAR_139=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_67 = FUNC_37(VAR_100=8)\n",
"VAR_51 = {'context': VAR_5 or {}, 'http_status_code': VAR_138 or 200}\n",
"VAR_51['context'].update({'header': VAR_31, 'title': VAR_31, 'message':\n VAR_136})\n",
"if VAR_139:\n",
"VAR_51['context'].update({'indicator_color': VAR_139})\n",
"FUNC_10().set_value('message_id:{0}'.format(VAR_67), VAR_51, expires_in_sec=60)\n",
"VAR_197 = '/message?id={0}'.format(VAR_67)\n",
"if not getattr(VAR_1, 'is_ajax', False):\n",
"VAR_1.response['type'] = 'redirect'\n",
"return VAR_197\n",
"VAR_1.response['location'] = VAR_197\n"
] | [
"def redirect_to_message(title, html, http_status_code=None, context=None,...\n",
"\"\"\"docstring\"\"\"\n",
"message_id = generate_hash(length=8)\n",
"message = {'context': context or {}, 'http_status_code': http_status_code or\n 200}\n",
"message['context'].update({'header': title, 'title': title, 'message': html})\n",
"if indicator_color:\n",
"message['context'].update({'indicator_color': indicator_color})\n",
"cache().set_value('message_id:{0}'.format(message_id), message,\n expires_in_sec=60)\n",
"location = '/message?id={0}'.format(message_id)\n",
"if not getattr(local, 'is_ajax', False):\n",
"local.response['type'] = 'redirect'\n",
"return location\n",
"local.response['location'] = location\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'"
] |
[
"@FUNC_0...\n",
"return Secrets()\n"
] | [
"@cache_in_self...\n",
"return Secrets()\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_118(VAR_120=None):...\n",
"VAR_184 = {}\n",
"for VAR_219 in ([VAR_120] if VAR_120 else FUNC_64(VAR_122=True)):\n",
"VAR_219 = 'frappe' if VAR_219 == 'webnotes' else VAR_219\n",
"return VAR_184\n",
"VAR_226 = FUNC_55(VAR_219 + '.hooks')\n",
"if VAR_1.flags.in_install_app:\n",
"for VAR_46 in dir(VAR_226):\n",
"print('Could not find app \"{0}\"'.format(VAR_120))\n",
"if not VAR_46.startswith('_'):\n",
"if not VAR_16:\n",
"FUNC_67(VAR_184, VAR_46, getattr(VAR_226, VAR_46))\n",
"sys.exit(1)\n"
] | [
"def load_app_hooks(app_name=None):...\n",
"hooks = {}\n",
"for app in ([app_name] if app_name else get_installed_apps(sort=True)):\n",
"app = 'frappe' if app == 'webnotes' else app\n",
"return hooks\n",
"app_hooks = get_module(app + '.hooks')\n",
"if local.flags.in_install_app:\n",
"for key in dir(app_hooks):\n",
"print('Could not find app \"{0}\"'.format(app_name))\n",
"if not key.startswith('_'):\n",
"if not request:\n",
"append_hook(hooks, key, getattr(app_hooks, key))\n",
"sys.exit(1)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Assign'",
"Return'",
"Assign'",
"Condition",
"For",
"Expr'",
"Condition",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_81(VAR_9, VAR_38, VAR_44):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_46 = CertificateInvalidation.objects.get(VAR_44=generated_certificate)\n",
"VAR_46.deactivate()\n",
"VAR_40 = VAR_46.generated_certificate.user\n",
"instructor_task.api.generate_certificates_for_students(VAR_9, VAR_38,\n student_set='specific_student', specific_student_id=student.id)\n"
] | [
"def re_validate_certificate(request, course_key, generated_certificate):...\n",
"\"\"\"docstring\"\"\"\n",
"certificate_invalidation = CertificateInvalidation.objects.get(\n generated_certificate=generated_certificate)\n",
"certificate_invalidation.deactivate()\n",
"student = certificate_invalidation.generated_certificate.user\n",
"instructor_task.api.generate_certificates_for_students(request, course_key,\n student_set='specific_student', specific_student_id=student.id)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"\"\"\"string\"\"\"\n",
"from __future__ import unicode_literals, print_function\n",
"from six import iteritems, binary_type, text_type, string_types, PY2\n",
"from werkzeug.local import Local, release_local\n",
"import os, sys, importlib, inspect, json\n",
"from past.builtins import cmp\n",
"import click\n",
"from .exceptions import *\n",
"from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template, get_jloader\n",
"from .utils.lazy_loader import lazy_import\n",
"VAR_0 = lazy_import('faker')\n",
"if PY2:\n",
"reload(sys)\n",
"__version__ = '13.0.0-dev'\n",
"sys.setdefaultencoding('utf-8')\n",
"__title__ = 'Frappe Framework'\n",
"VAR_1 = Local()\n",
"VAR_2 = {}\n",
"\"\"\"dict like object that exposes keys as attributes\"\"\"\n",
"def __getattr__(self, VAR_46):...\n",
"VAR_205 = self.get(VAR_46)\n",
"if not VAR_205 and VAR_46.startswith('__'):\n",
"return VAR_205\n"
] | [
"\"\"\"\nFrappe - Low Code Open Source Framework in Python and JS\n\nFrappe, pronounced fra-pay, is a full stack, batteries-included, web\nframework written in Python and Javascript with MariaDB as the database.\nIt is the framework which powers ERPNext. It is pretty generic and can\nbe used to build database driven apps.\n\nRead the documentation: https://frappeframework.com/docs\n\"\"\"\n",
"from __future__ import unicode_literals, print_function\n",
"from six import iteritems, binary_type, text_type, string_types, PY2\n",
"from werkzeug.local import Local, release_local\n",
"import os, sys, importlib, inspect, json\n",
"from past.builtins import cmp\n",
"import click\n",
"from .exceptions import *\n",
"from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template, get_jloader\n",
"from .utils.lazy_loader import lazy_import\n",
"faker = lazy_import('faker')\n",
"if PY2:\n",
"reload(sys)\n",
"__version__ = '13.0.0-dev'\n",
"sys.setdefaultencoding('utf-8')\n",
"__title__ = 'Frappe Framework'\n",
"local = Local()\n",
"controllers = {}\n",
"\"\"\"dict like object that exposes keys as attributes\"\"\"\n",
"def __getattr__(self, key):...\n",
"ret = self.get(key)\n",
"if not ret and key.startswith('__'):\n",
"return ret\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Expr'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"ImportFrom'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"FunctionDef'",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_2(self, VAR_12, VAR_13):...\n",
"run_as_background_process('http_pusher.on_new_receipts', self._update_badge)\n"
] | [
"def on_new_receipts(self, min_stream_id, max_stream_id):...\n",
"run_as_background_process('http_pusher.on_new_receipts', self._update_badge)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_10(VAR_26):...\n",
"\"\"\"docstring\"\"\"\n",
"def FUNC_117(VAR_10):...\n",
"def FUNC_168(*VAR_9, **VAR_13):...\n",
"VAR_27 = None\n",
"VAR_27 = VAR_10(*VAR_9, **b)\n",
"thread.start_new_thread(VAR_26, (VAR_27,))\n",
"return FUNC_168\n",
"return VAR_27\n"
] | [
"def completion(callback):...\n",
"\"\"\"docstring\"\"\"\n",
"def _completion(f):...\n",
"def __completion(*a, **b):...\n",
"d = None\n",
"d = f(*a, **b)\n",
"thread.start_new_thread(callback, (d,))\n",
"return __completion\n",
"return d\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"FunctionDef'",
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Return'",
"Return'"
] |
[
"def __init__(self, VAR_1):...\n",
"self.config = VAR_1\n",
"VAR_42 = 'res/dist/main.html'\n",
"VAR_43 = 'res/login.html'\n",
"VAR_44 = 'res/firstrun.html'\n",
"self.mainpage = readRes(VAR_42)\n",
"self.loginpage = readRes(VAR_43)\n",
"self.firstrunpage = readRes(VAR_44)\n",
"self.handlers = {'search': self.api_search, 'rememberplaylist': self.\n api_rememberplaylist, 'saveplaylist': self.api_saveplaylist,\n 'loadplaylist': self.api_loadplaylist, 'generaterandomplaylist': self.\n api_generaterandomplaylist, 'deleteplaylist': self.api_deleteplaylist,\n 'getmotd': self.api_getmotd, 'restoreplaylist': self.\n api_restoreplaylist, 'getplayables': self.api_getplayables,\n 'getuserlist': self.api_getuserlist, 'adduser': self.api_adduser,\n 'userdelete': self.api_userdelete, 'userchangepassword': self.\n api_userchangepassword, 'showplaylists': self.api_showplaylists,\n 'logout': self.api_logout, 'downloadpls': self.api_downloadpls,\n 'downloadm3u': self.api_downloadm3u, 'getsonginfo': self.\n api_getsonginfo, 'getencoders': self.api_getencoders, 'getdecoders':\n self.api_getdecoders, 'transcodingenabled': self.api_transcodingenabled,\n 'updatedb': self.api_updatedb, 'getconfiguration': self.\n api_getconfiguration, 'compactlistdir': self.api_compactlistdir,\n 'listdir': self.api_listdir, 'fetchalbumart': self.api_fetchalbumart,\n 'fetchalbumarturls': self.api_fetchalbumarturls, 'albumart_set': self.\n api_albumart_set, 'heartbeat': self.api_heartbeat, 'getuseroptions':\n self.api_getuseroptions, 'setuseroption': self.api_setuseroption,\n 'changeplaylist': self.api_changeplaylist, 'downloadcheck': self.\n api_downloadcheck, 'setuseroptionfor': self.api_setuseroptionfor}\n"
] | [
"def __init__(self, config):...\n",
"self.config = config\n",
"template_main = 'res/dist/main.html'\n",
"template_login = 'res/login.html'\n",
"template_firstrun = 'res/firstrun.html'\n",
"self.mainpage = readRes(template_main)\n",
"self.loginpage = readRes(template_login)\n",
"self.firstrunpage = readRes(template_firstrun)\n",
"self.handlers = {'search': self.api_search, 'rememberplaylist': self.\n api_rememberplaylist, 'saveplaylist': self.api_saveplaylist,\n 'loadplaylist': self.api_loadplaylist, 'generaterandomplaylist': self.\n api_generaterandomplaylist, 'deleteplaylist': self.api_deleteplaylist,\n 'getmotd': self.api_getmotd, 'restoreplaylist': self.\n api_restoreplaylist, 'getplayables': self.api_getplayables,\n 'getuserlist': self.api_getuserlist, 'adduser': self.api_adduser,\n 'userdelete': self.api_userdelete, 'userchangepassword': self.\n api_userchangepassword, 'showplaylists': self.api_showplaylists,\n 'logout': self.api_logout, 'downloadpls': self.api_downloadpls,\n 'downloadm3u': self.api_downloadm3u, 'getsonginfo': self.\n api_getsonginfo, 'getencoders': self.api_getencoders, 'getdecoders':\n self.api_getdecoders, 'transcodingenabled': self.api_transcodingenabled,\n 'updatedb': self.api_updatedb, 'getconfiguration': self.\n api_getconfiguration, 'compactlistdir': self.api_compactlistdir,\n 'listdir': self.api_listdir, 'fetchalbumart': self.api_fetchalbumart,\n 'fetchalbumarturls': self.api_fetchalbumarturls, 'albumart_set': self.\n api_albumart_set, 'heartbeat': self.api_heartbeat, 'getuseroptions':\n self.api_getuseroptions, 'setuseroption': self.api_setuseroption,\n 'changeplaylist': self.api_changeplaylist, 'downloadcheck': self.\n api_downloadcheck, 'setuseroptionfor': self.api_setuseroptionfor}\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_21(self):...\n",
"self._original_modified = self.modified\n",
"self.modified = now()\n",
"self.modified_by = frappe.session.user\n",
"if not self.creation:\n",
"self.creation = self.modified\n",
"if not self.owner:\n",
"self.owner = self.modified_by\n",
"for VAR_21 in self.get_all_children():\n",
"VAR_21.modified = self.modified\n",
"frappe.flags.currently_saving.append((self.doctype, self.name))\n",
"VAR_21.modified_by = self.modified_by\n",
"if not VAR_21.owner:\n",
"VAR_21.owner = self.owner\n",
"if not VAR_21.creation:\n",
"VAR_21.creation = self.creation\n"
] | [
"def set_user_and_timestamp(self):...\n",
"self._original_modified = self.modified\n",
"self.modified = now()\n",
"self.modified_by = frappe.session.user\n",
"if not self.creation:\n",
"self.creation = self.modified\n",
"if not self.owner:\n",
"self.owner = self.modified_by\n",
"for d in self.get_all_children():\n",
"d.modified = self.modified\n",
"frappe.flags.currently_saving.append((self.doctype, self.name))\n",
"d.modified_by = self.modified_by\n",
"if not d.owner:\n",
"d.owner = self.owner\n",
"if not d.creation:\n",
"d.creation = self.creation\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"For",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'"
] |
[
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_132 = VAR_8.getObject('Dataset', VAR_34)\n",
"return VAR_132.simpleMarshal()\n"
] | [
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"ds = conn.getObject('Dataset', did)\n",
"return ds.simpleMarshal()\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'"
] |
[
"def FUNC_11(VAR_27, VAR_28=lambda VAR_30: VAR_30, VAR_29=False):...\n",
"VAR_193 = datetime.datetime.utcnow() if VAR_29 else datetime.datetime.now()\n",
"if isinstance(VAR_27, datetime.datetime):\n",
"VAR_321 = VAR_193 - VAR_27\n",
"if isinstance(VAR_27, datetime.date):\n",
"if VAR_321.days < 0:\n",
"VAR_321 = VAR_193.date() - VAR_27\n",
"if not VAR_27:\n",
"VAR_322 = ' from now'\n",
"VAR_322 = ' ago'\n",
"return ''\n",
"return '[invalid date]'\n",
"VAR_321 = -VAR_321\n",
"if VAR_321.days >= 2 * 365:\n",
"return VAR_28('%d years' + VAR_322) % int(VAR_321.days // 365)\n",
"if VAR_321.days >= 365:\n",
"return VAR_28('1 year' + VAR_322)\n",
"if VAR_321.days >= 60:\n",
"return VAR_28('%d months' + VAR_322) % int(VAR_321.days // 30)\n",
"if VAR_321.days >= 27:\n",
"return VAR_28('1 month' + VAR_322)\n",
"if VAR_321.days >= 14:\n",
"return VAR_28('%d weeks' + VAR_322) % int(VAR_321.days // 7)\n",
"if VAR_321.days >= 7:\n",
"return VAR_28('1 week' + VAR_322)\n",
"if VAR_321.days > 1:\n",
"return VAR_28('%d days' + VAR_322) % VAR_321.days\n",
"if VAR_321.days == 1:\n",
"return VAR_28('1 day' + VAR_322)\n",
"if VAR_321.seconds >= 2 * 60 * 60:\n",
"return VAR_28('%d hours' + VAR_322) % int(VAR_321.seconds // 3600)\n",
"if VAR_321.seconds >= 60 * 60:\n",
"return VAR_28('1 hour' + VAR_322)\n",
"if VAR_321.seconds >= 2 * 60:\n",
"return VAR_28('%d minutes' + VAR_322) % int(VAR_321.seconds // 60)\n",
"if VAR_321.seconds >= 60:\n",
"return VAR_28('1 minute' + VAR_322)\n",
"if VAR_321.seconds > 1:\n",
"return VAR_28('%d seconds' + VAR_322) % VAR_321.seconds\n",
"if VAR_321.seconds == 1:\n",
"return VAR_28('1 second' + VAR_322)\n",
"return VAR_28('now')\n"
] | [
"def prettydate(d, T=lambda x: x, utc=False):...\n",
"now = datetime.datetime.utcnow() if utc else datetime.datetime.now()\n",
"if isinstance(d, datetime.datetime):\n",
"dt = now - d\n",
"if isinstance(d, datetime.date):\n",
"if dt.days < 0:\n",
"dt = now.date() - d\n",
"if not d:\n",
"suffix = ' from now'\n",
"suffix = ' ago'\n",
"return ''\n",
"return '[invalid date]'\n",
"dt = -dt\n",
"if dt.days >= 2 * 365:\n",
"return T('%d years' + suffix) % int(dt.days // 365)\n",
"if dt.days >= 365:\n",
"return T('1 year' + suffix)\n",
"if dt.days >= 60:\n",
"return T('%d months' + suffix) % int(dt.days // 30)\n",
"if dt.days >= 27:\n",
"return T('1 month' + suffix)\n",
"if dt.days >= 14:\n",
"return T('%d weeks' + suffix) % int(dt.days // 7)\n",
"if dt.days >= 7:\n",
"return T('1 week' + suffix)\n",
"if dt.days > 1:\n",
"return T('%d days' + suffix) % dt.days\n",
"if dt.days == 1:\n",
"return T('1 day' + suffix)\n",
"if dt.seconds >= 2 * 60 * 60:\n",
"return T('%d hours' + suffix) % int(dt.seconds // 3600)\n",
"if dt.seconds >= 60 * 60:\n",
"return T('1 hour' + suffix)\n",
"if dt.seconds >= 2 * 60:\n",
"return T('%d minutes' + suffix) % int(dt.seconds // 60)\n",
"if dt.seconds >= 60:\n",
"return T('1 minute' + suffix)\n",
"if dt.seconds > 1:\n",
"return T('%d seconds' + suffix) % dt.seconds\n",
"if dt.seconds == 1:\n",
"return T('1 second' + suffix)\n",
"return T('now')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Return'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_5(self):...\n",
"self.assertFormfield(models.Event, 'link', widgets.AdminURLFieldWidget)\n"
] | [
"def testURLField(self):...\n",
"self.assertFormfield(models.Event, 'link', widgets.AdminURLFieldWidget)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@pytest.fixture(scope='session')...\n",
"from openapi_python_client import utils\n",
"VAR_0 = {'snakecase': utils.snake_case, 'spinalcase': utils.spinal_case}\n",
"VAR_1 = Environment(loader=PackageLoader('openapi_python_client'),\n trim_blocks=True, lstrip_blocks=True)\n",
"VAR_1.filters.update(VAR_0)\n",
"return VAR_1\n"
] | [
"@pytest.fixture(scope='session')...\n",
"from openapi_python_client import utils\n",
"TEMPLATE_FILTERS = {'snakecase': utils.snake_case, 'spinalcase': utils.\n spinal_case}\n",
"env = Environment(loader=PackageLoader('openapi_python_client'),\n trim_blocks=True, lstrip_blocks=True)\n",
"env.filters.update(TEMPLATE_FILTERS)\n",
"return env\n"
] | [
0,
0,
1,
0,
0,
0
] | [
"Condition",
"ImportFrom'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_11(self):...\n",
"VAR_7 = '/users/<int:user_id>/roles/<string:slug>'\n",
"assert get_param_tuples(VAR_7) == [('int', 'user_id'), ('string', 'slug')]\n"
] | [
"def test_multiple(self):...\n",
"path = '/users/<int:user_id>/roles/<string:slug>'\n",
"assert get_param_tuples(path) == [('int', 'user_id'), ('string', 'slug')]\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assert'"
] |
[
"def __post_init__(self) ->None:...\n",
"self.python_name = utils.snake_case(self.name)\n"
] | [
"def __post_init__(self) ->None:...\n",
"self.python_name = utils.snake_case(self.name)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"@property...\n",
"return FUNC_0(self.time_spent)\n"
] | [
"@property...\n",
"return format_time_spent(self.time_spent)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"@VAR_25.whitelist(allow_guest=True)...\n",
"VAR_25.local.login_manager.logout()\n",
"VAR_25.db.commit()\n",
"VAR_25.respond_as_web_page(_('Logged Out'), _(\n 'You have been successfully logged out'), indicator_color='green')\n"
] | [
"@frappe.whitelist(allow_guest=True)...\n",
"frappe.local.login_manager.logout()\n",
"frappe.db.commit()\n",
"frappe.respond_as_web_page(_('Logged Out'), _(\n 'You have been successfully logged out'), indicator_color='green')\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_3(self):...\n",
"\"\"\"Model with callable polymorphic functions specified.\"\"\"\n",
"@def_function.function...\n",
"if VAR_55:\n",
"return VAR_53 + VAR_54\n",
"return VAR_53 * VAR_54\n"
] | [
"def testShowAllWithFunctions(self):...\n",
"\"\"\"Model with callable polymorphic functions specified.\"\"\"\n",
"@def_function.function...\n",
"if c:\n",
"return a + b\n",
"return a * b\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Condition",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_30(self):...\n",
"self.kernel_spec_manager = self.kernel_spec_manager_class(parent=self)\n",
"self.kernel_manager = self.kernel_manager_class(parent=self, VAR_19=self.\n log, connection_dir=self.runtime_dir, VAR_17=self.kernel_spec_manager)\n",
"self.contents_manager = self.contents_manager_class(parent=self, VAR_19=\n self.log)\n",
"self.session_manager = self.session_manager_class(parent=self, VAR_19=self.\n log, VAR_14=self.kernel_manager, VAR_15=self.contents_manager)\n",
"self.config_manager = self.config_manager_class(parent=self, VAR_19=self.\n log, config_dir=os.path.join(self.config_dir, 'nbconfig'))\n"
] | [
"def init_configurables(self):...\n",
"self.kernel_spec_manager = self.kernel_spec_manager_class(parent=self)\n",
"self.kernel_manager = self.kernel_manager_class(parent=self, log=self.log,\n connection_dir=self.runtime_dir, kernel_spec_manager=self.\n kernel_spec_manager)\n",
"self.contents_manager = self.contents_manager_class(parent=self, log=self.log)\n",
"self.session_manager = self.session_manager_class(parent=self, log=self.log,\n kernel_manager=self.kernel_manager, contents_manager=self.contents_manager)\n",
"self.config_manager = self.config_manager_class(parent=self, log=self.log,\n config_dir=os.path.join(self.config_dir, 'nbconfig'))\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_21(VAR_20):...\n",
"\"\"\"docstring\"\"\"\n",
"from tensorflow.python.compiler.tensorrt import trt_convert as trt\n",
"if not VAR_20.convert_tf1_model:\n",
"VAR_73 = trt.DEFAULT_TRT_CONVERSION_PARAMS._replace(max_workspace_size_bytes\n =args.max_workspace_size_bytes, precision_mode=args.precision_mode,\n minimum_segment_size=args.minimum_segment_size)\n",
"trt.create_inference_graph(None, None, max_batch_size=1,\n max_workspace_size_bytes=args.max_workspace_size_bytes, precision_mode=\n args.precision_mode, minimum_segment_size=args.minimum_segment_size,\n is_dynamic_op=True, input_saved_model_dir=args.dir,\n input_saved_model_tags=args.tag_set.split(','), output_saved_model_dir=\n args.output_dir)\n",
"VAR_74 = trt.TrtGraphConverterV2(input_saved_model_dir=args.dir,\n input_saved_model_tags=args.tag_set.split(','), conversion_params=params)\n",
"VAR_74.convert()\n",
"VAR_74.save(output_saved_model_dir=args.output_dir)\n"
] | [
"def convert_with_tensorrt(args):...\n",
"\"\"\"docstring\"\"\"\n",
"from tensorflow.python.compiler.tensorrt import trt_convert as trt\n",
"if not args.convert_tf1_model:\n",
"params = trt.DEFAULT_TRT_CONVERSION_PARAMS._replace(max_workspace_size_bytes\n =args.max_workspace_size_bytes, precision_mode=args.precision_mode,\n minimum_segment_size=args.minimum_segment_size)\n",
"trt.create_inference_graph(None, None, max_batch_size=1,\n max_workspace_size_bytes=args.max_workspace_size_bytes, precision_mode=\n args.precision_mode, minimum_segment_size=args.minimum_segment_size,\n is_dynamic_op=True, input_saved_model_dir=args.dir,\n input_saved_model_tags=args.tag_set.split(','), output_saved_model_dir=\n args.output_dir)\n",
"converter = trt.TrtGraphConverterV2(input_saved_model_dir=args.dir,\n input_saved_model_tags=args.tag_set.split(','), conversion_params=params)\n",
"converter.convert()\n",
"converter.save(output_saved_model_dir=args.output_dir)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"ImportFrom'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@VAR_0.route('/jobs/<int:job_id>')...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_54 = None\n",
"VAR_55 = None\n",
"VAR_94 = FUNC_58(f'/internal/jobs/{VAR_9}', 'get')\n",
"flash(str(err), 'danger')\n",
"return render_template('job.html', title=f'Job {job_id}', VAR_94=job_info,\n VAR_5=status_color, attribute_actions=actions.get('attributes'),\n method_actions=actions.get('methods'), VAR_54=stdout, VAR_55=stderr,\n VAR_95=full_print_info)\n",
"VAR_95 = FUNC_58(f'/internal/jobs/{VAR_9}/full-print', 'get')\n",
"return redirect(url_for('jobs_page'))\n",
"VAR_96 = os.path.join(VAR_94['outputdir'], 'stdout')\n",
"VAR_97 = os.path.join(VAR_94['outputdir'], 'stderr')\n",
"if os.path.exists(VAR_96):\n",
"VAR_54 = VAR_14.read()\n",
"if os.path.exists(VAR_97):\n",
"VAR_55 = VAR_14.read()\n"
] | [
"@gui.route('/jobs/<int:job_id>')...\n",
"\"\"\"docstring\"\"\"\n",
"stdout = None\n",
"stderr = None\n",
"job_info = query_internal_api(f'/internal/jobs/{job_id}', 'get')\n",
"flash(str(err), 'danger')\n",
"return render_template('job.html', title=f'Job {job_id}', job_info=job_info,\n status_color=status_color, attribute_actions=actions.get('attributes'),\n method_actions=actions.get('methods'), stdout=stdout, stderr=stderr,\n full_print_info=full_print_info)\n",
"full_print_info = query_internal_api(f'/internal/jobs/{job_id}/full-print',\n 'get')\n",
"return redirect(url_for('jobs_page'))\n",
"stdout_path = os.path.join(job_info['outputdir'], 'stdout')\n",
"stderr_path = os.path.join(job_info['outputdir'], 'stderr')\n",
"if os.path.exists(stdout_path):\n",
"stdout = f.read()\n",
"if os.path.exists(stderr_path):\n",
"stderr = f.read()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Return'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'"
] |
[
"def FUNC_23(VAR_48, VAR_49=VAR_29):...\n",
"return VAR_49 is not None and (len(VAR_48) > VAR_49 and '%s...' % VAR_48[:\n max(0, VAR_49 - 3)]) or VAR_48\n"
] | [
"def trim_url(x, limit=trim_url_limit):...\n",
"return limit is not None and (len(x) > limit and '%s...' % x[:max(0, limit -\n 3)]) or x\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_11(VAR_37):...\n",
"VAR_4, VAR_39 = VAR_37\n",
"VAR_25.write(VAR_4)\n",
"return VAR_39\n"
] | [
"def write_to(r):...\n",
"data, response = r\n",
"output_stream.write(data)\n",
"return response\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_9(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.get_success(self.inject_room_member(self.room1, self.u_alice,\n Membership.JOIN))\n",
"VAR_16 = self.get_success(self.inject_message(self.room1, self.u_alice, 't'))\n",
"VAR_25 = self.get_success(self.inject_redaction(self.room1, VAR_16.event_id,\n self.u_alice, 'Redacting message'))\n",
"self.get_success(self.inject_redaction(self.room1, VAR_25.event_id, self.\n u_alice, 'Redacting redaction'))\n",
"self.reactor.advance(60 * 60 * 24 * 31)\n",
"self.get_success(self.store.get_event(VAR_25.event_id, allow_none=True))\n"
] | [
"def test_redact_redaction(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.get_success(self.inject_room_member(self.room1, self.u_alice,\n Membership.JOIN))\n",
"msg_event = self.get_success(self.inject_message(self.room1, self.u_alice, 't')\n )\n",
"first_redact_event = self.get_success(self.inject_redaction(self.room1,\n msg_event.event_id, self.u_alice, 'Redacting message'))\n",
"self.get_success(self.inject_redaction(self.room1, first_redact_event.\n event_id, self.u_alice, 'Redacting redaction'))\n",
"self.reactor.advance(60 * 60 * 24 * 31)\n",
"self.get_success(self.store.get_event(first_redact_event.event_id,\n allow_none=True))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_39(self):...\n",
"VAR_85 = self.allowed_tags or ''\n",
"return [t.strip() for t in VAR_85.split(',')]\n"
] | [
"def list_allowed_tags(self):...\n",
"mct = self.allowed_tags or ''\n",
"return [t.strip() for t in mct.split(',')]\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"import os\n",
"import jwt\n",
"import json\n",
"import requests\n",
"import time\n",
"import select\n",
"import termios\n",
"import struct\n",
"import fcntl\n",
"import subprocess\n",
"import pty\n",
"import sys\n",
"import datetime\n",
"from functools import wraps\n",
"from werkzeug.utils import secure_filename\n",
"from werkzeug.security import generate_password_hash, check_password_hash\n",
"from flask import Flask, request, jsonify, render_template, flash, redirect, url_for, session, send_file, make_response\n",
"from flask_login import login_user, login_required, logout_user, current_user, UserMixin\n",
"from flask_sqlalchemy import SQLAlchemy\n",
"from flask_login import LoginManager\n",
"from flask_socketio import SocketIO\n",
"from GangaGUI.gui.config import Config\n",
"VAR_0 = Flask(__name__)\n",
"VAR_0.config.from_object(Config)\n",
"VAR_1 = SQLAlchemy(VAR_0)\n",
"VAR_2 = LoginManager(VAR_0)\n",
"VAR_2.login_view = 'login'\n",
"VAR_2.login_message = 'Please Login to Access this Page.'\n",
"VAR_2.login_message_category = 'warning'\n",
"VAR_3 = SocketIO(VAR_0)\n",
"__tablename__ = 'users'\n",
"VAR_35 = VAR_1.Column(VAR_1.Integer, primary_key=True)\n",
"VAR_36 = VAR_1.Column(VAR_1.String(64), unique=True)\n",
"VAR_37 = VAR_1.Column(VAR_1.String(32), unique=True)\n",
"VAR_38 = VAR_1.Column(VAR_1.String(64))\n",
"VAR_39 = VAR_1.Column(VAR_1.String(32))\n",
"VAR_40 = VAR_1.Column(VAR_1.Text)\n",
"def FUNC_66(self, VAR_41: str):...\n",
"self.password_hash = generate_password_hash(VAR_41)\n",
"def FUNC_67(self, VAR_41: str) ->bool:...\n",
"return check_password_hash(self.password_hash, VAR_41)\n"
] | [
"import os\n",
"import jwt\n",
"import json\n",
"import requests\n",
"import time\n",
"import select\n",
"import termios\n",
"import struct\n",
"import fcntl\n",
"import subprocess\n",
"import pty\n",
"import sys\n",
"import datetime\n",
"from functools import wraps\n",
"from werkzeug.utils import secure_filename\n",
"from werkzeug.security import generate_password_hash, check_password_hash\n",
"from flask import Flask, request, jsonify, render_template, flash, redirect, url_for, session, send_file, make_response\n",
"from flask_login import login_user, login_required, logout_user, current_user, UserMixin\n",
"from flask_sqlalchemy import SQLAlchemy\n",
"from flask_login import LoginManager\n",
"from flask_socketio import SocketIO\n",
"from GangaGUI.gui.config import Config\n",
"gui = Flask(__name__)\n",
"gui.config.from_object(Config)\n",
"db = SQLAlchemy(gui)\n",
"login = LoginManager(gui)\n",
"login.login_view = 'login'\n",
"login.login_message = 'Please Login to Access this Page.'\n",
"login.login_message_category = 'warning'\n",
"socketio = SocketIO(gui)\n",
"__tablename__ = 'users'\n",
"id = db.Column(db.Integer, primary_key=True)\n",
"public_id = db.Column(db.String(64), unique=True)\n",
"user = db.Column(db.String(32), unique=True)\n",
"password_hash = db.Column(db.String(64))\n",
"role = db.Column(db.String(32))\n",
"pinned_jobs = db.Column(db.Text)\n",
"def store_password_hash(self, password: str):...\n",
"self.password_hash = generate_password_hash(password)\n",
"def verify_password(self, password: str) ->bool:...\n",
"return check_password_hash(self.password_hash, password)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_30(self, VAR_44):...\n",
"VAR_82 = VAR_44.group(1)\n",
"if self._parse_inline_html and VAR_82 in VAR_6:\n",
"VAR_14 = VAR_44.group(3)\n",
"VAR_64 = VAR_44.group(0)\n",
"if VAR_82 == 'a':\n",
"return self.renderer.inline_html(VAR_64)\n",
"self._in_link = True\n",
"VAR_14 = self.output(VAR_14, VAR_43=self.inline_html_rules)\n",
"VAR_14 = self.output(VAR_14, VAR_43=self.inline_html_rules)\n",
"VAR_93 = VAR_44.group(2) or ''\n",
"self._in_link = False\n",
"VAR_64 = '<%s%s>%s</%s>' % (VAR_82, VAR_93, VAR_14, VAR_82)\n"
] | [
"def output_inline_html(self, m):...\n",
"tag = m.group(1)\n",
"if self._parse_inline_html and tag in _inline_tags:\n",
"text = m.group(3)\n",
"html = m.group(0)\n",
"if tag == 'a':\n",
"return self.renderer.inline_html(html)\n",
"self._in_link = True\n",
"text = self.output(text, rules=self.inline_html_rules)\n",
"text = self.output(text, rules=self.inline_html_rules)\n",
"extra = m.group(2) or ''\n",
"self._in_link = False\n",
"html = '<%s%s>%s</%s>' % (tag, extra, text, tag)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"@VAR_1.route('/' + VAR_0.victim_path)...\n",
"VAR_3 = urllib2.build_opener()\n",
"VAR_4 = victim_headers()\n",
"VAR_3.addheaders = VAR_4\n",
"VAR_5 = victim_inject_code(VAR_3.open(VAR_0.url_to_clone).read(), 'lure')\n",
"return VAR_5\n"
] | [
"@app.route('/' + trape.victim_path)...\n",
"opener = urllib2.build_opener()\n",
"headers = victim_headers()\n",
"opener.addheaders = headers\n",
"html = victim_inject_code(opener.open(trape.url_to_clone).read(), 'lure')\n",
"return html\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_2():...\n",
"if 'auth_token' in g:\n",
"return g.get('auth_token')\n",
"return None\n"
] | [
"def get_auth_token():...\n",
"if 'auth_token' in g:\n",
"return g.get('auth_token')\n",
"return None\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_3(self) ->Optional[JsonDict]:...\n",
"if self.json_callback:\n",
"return self.json_callback()\n",
"return self.json\n"
] | [
"def get_json(self) ->Optional[JsonDict]:...\n",
"if self.json_callback:\n",
"return self.json_callback()\n",
"return self.json\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_165(VAR_215, VAR_224):...\n",
"if not VAR_399:\n",
"return None\n",
"return serializers.json({'jsonrpc': '2.0', 'id': VAR_215, 'result': VAR_224})\n"
] | [
"def return_response(id, result):...\n",
"if not must_respond:\n",
"return None\n",
"return serializers.json({'jsonrpc': '2.0', 'id': id, 'result': result})\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_1(VAR_7, VAR_8, VAR_9, VAR_6=()):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_6:\n",
"warnings.warn('string', DeprecationWarning)\n",
"return [FUNC_0('%s/(?P<pk>\\\\d+)/$' % VAR_7, VAR_8 % 'Edit', VAR_3=\n name_template % 'edit', VAR_6=(name_template % 'edit',)), FUNC_0(\n '%s/new/$' % VAR_7, VAR_8 % 'Edit', VAR_3=name_template % 'new', VAR_2=\n {'pk': None}, VAR_6=(name_template % 'new',)), FUNC_0('%s/$' % VAR_7, \n VAR_8 % 'List', VAR_3=name_template % 'list', VAR_6=(name_template %\n 'list',)), FUNC_0('%s/list-settings/' % VAR_7,\n 'shuup.admin.modules.settings.views.ListSettingsView', VAR_3=\n name_template % 'list_settings', VAR_6=(name_template % 'list_settings',))]\n"
] | [
"def get_edit_and_list_urls(url_prefix, view_template, name_template,...\n",
"\"\"\"docstring\"\"\"\n",
"if permissions:\n",
"warnings.warn(\n 'Warning! `get_edit_and_list_urls` permissions attribute will be deprecated in Shuup 2.0 as unused for this util.'\n , DeprecationWarning)\n",
"return [admin_url('%s/(?P<pk>\\\\d+)/$' % url_prefix, view_template % 'Edit',\n name=name_template % 'edit', permissions=(name_template % 'edit',)),\n admin_url('%s/new/$' % url_prefix, view_template % 'Edit', name=\n name_template % 'new', kwargs={'pk': None}, permissions=(name_template %\n 'new',)), admin_url('%s/$' % url_prefix, view_template % 'List', name=\n name_template % 'list', permissions=(name_template % 'list',)),\n admin_url('%s/list-settings/' % url_prefix,\n 'shuup.admin.modules.settings.views.ListSettingsView', name=\n name_template % 'list_settings', permissions=(name_template %\n 'list_settings',))]\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Return'"
] |
[
"def FUNC_172(VAR_354):...\n",
"return VAR_354 + ' ' + VAR_354.replace('icon', 'glyphicon')\n"
] | [
"def rename(icon):...\n",
"return icon + ' ' + icon.replace('icon', 'glyphicon')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_108(VAR_169, VAR_7='utf-8'):...\n",
""
] | [
"def safe_decode(param, encoding='utf-8'):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.