lines
sequencelengths
1
383
raw_lines
sequencelengths
1
383
label
sequencelengths
1
383
type
sequencelengths
1
383
[ "def FUNC_14(self, VAR_6):...\n", "if not self.query:\n", "frappe.throw(_('Must specify a Query to run'), title=_('Report Document Error')\n )\n", "if not self.query.lower().startswith('select'):\n", "frappe.throw(_('Query must be a SELECT'), title=_('Report Document Error'))\n", "VAR_15 = [list(t) for t in frappe.db.sql(self.query, VAR_6, debug=True)]\n", "VAR_13 = self.get_columns() or [cstr(c[0]) for c in frappe.db.get_description()\n ]\n", "return [VAR_13, VAR_15]\n" ]
[ "def execute_query_report(self, filters):...\n", "if not self.query:\n", "frappe.throw(_('Must specify a Query to run'), title=_('Report Document Error')\n )\n", "if not self.query.lower().startswith('select'):\n", "frappe.throw(_('Query must be a SELECT'), title=_('Report Document Error'))\n", "result = [list(t) for t in frappe.db.sql(self.query, filters, debug=True)]\n", "columns = self.get_columns() or [cstr(c[0]) for c in frappe.db.\n get_description()]\n", "return [columns, result]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Condition", "Expr'", "Assign'", "Assign'", "Return'" ]
[ "@pytest.fixture...\n", "VAR_3 = tempfile.mkdtemp()\n", "VAR_4 = os.path.join(VAR_3, 'another_%s.txt' % VAR_0.node.name)\n", "f.write(VAR_0.node.name)\n", "return VAR_4\n" ]
[ "@pytest.fixture...\n", "path = tempfile.mkdtemp()\n", "file_name = os.path.join(path, 'another_%s.txt' % request.node.name)\n", "f.write(request.node.name)\n", "return file_name\n" ]
[ 1, 1, 1, 0, 1 ]
[ "Condition", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "@FUNC_0...\n", "return ApplicationServiceScheduler(self)\n" ]
[ "@cache_in_self...\n", "return ApplicationServiceScheduler(self)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_25(VAR_9, VAR_5, VAR_10):...\n", "VAR_13 = calibre_db.session.query(db.Tags).filter(db.Tags.id == VAR_5).first()\n", "if VAR_13:\n", "VAR_63, VAR_68, VAR_65 = calibre_db.fill_indexpage(VAR_9, 0, db.Books, db.\n Books.tags.any(db.Tags.id == VAR_5), [VAR_10[0][0], db.Series.name, db.\n Books.series_index], db.books_series_link, db.Books.id == db.\n books_series_link.c.book, db.Series)\n", "abort(404)\n", "return render_title_template('index.html', VAR_68=random, VAR_63=entries,\n VAR_65=pagination, id=book_id, VAR_150=_(u'Category: %(name)s', name=\n name.name), VAR_9='category', VAR_10=order[1])\n" ]
[ "def render_category_books(page, book_id, order):...\n", "name = calibre_db.session.query(db.Tags).filter(db.Tags.id == book_id).first()\n", "if name:\n", "entries, random, pagination = calibre_db.fill_indexpage(page, 0, db.Books,\n db.Books.tags.any(db.Tags.id == book_id), [order[0][0], db.Series.name,\n db.Books.series_index], db.books_series_link, db.Books.id == db.\n books_series_link.c.book, db.Series)\n", "abort(404)\n", "return render_title_template('index.html', random=random, entries=entries,\n pagination=pagination, id=book_id, title=_(u'Category: %(name)s', name=\n name.name), page='category', order=order[1])\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Expr'", "Return'" ]
[ "@VAR_0.route('/api/jobs/<int:job_id>/unpin', methods=['PUT'])...\n", "\"\"\"docstring\"\"\"\n", "VAR_72 = current_user\n", "VAR_40 = json.loads(VAR_72.pinned_jobs\n ) if VAR_72.pinned_jobs is not None else []\n", "if VAR_9 in VAR_40:\n", "VAR_40.remove(VAR_9)\n", "VAR_72.pinned_jobs = json.dumps(VAR_40)\n", "VAR_1.session.add(VAR_72)\n", "VAR_1.session.commit()\n", "return jsonify({'success': True, 'message':\n f'Successfully unpinned Job (ID={VAR_9}).'})\n" ]
[ "@gui.route('/api/jobs/<int:job_id>/unpin', methods=['PUT'])...\n", "\"\"\"docstring\"\"\"\n", "u = current_user\n", "pinned_jobs = json.loads(u.pinned_jobs) if u.pinned_jobs is not None else []\n", "if job_id in pinned_jobs:\n", "pinned_jobs.remove(job_id)\n", "u.pinned_jobs = json.dumps(pinned_jobs)\n", "db.session.add(u)\n", "db.session.commit()\n", "return jsonify({'success': True, 'message':\n f'Successfully unpinned Job (ID={job_id}).'})\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_44(VAR_121, VAR_8, VAR_122=None):...\n", "if isinstance(VAR_121, dict) and VAR_8 in VAR_121:\n", "return VAR_121[VAR_8] if VAR_8 in VAR_121 else VAR_122\n", "if isinstance(VAR_121, tuple) and len(VAR_121) > 1 and isinstance(VAR_121[1\n", "return VAR_121[1][VAR_8] if VAR_8 in VAR_121[1] else VAR_122\n", "return VAR_122\n" ]
[ "def config_extractor(item, key, default_value=None):...\n", "if isinstance(item, dict) and key in item:\n", "return item[key] if key in item else default_value\n", "if isinstance(item, tuple) and len(item) > 1 and isinstance(item[1], dict\n", "return item[1][key] if key in item[1] else default_value\n", "return default_value\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "VAR_0 = True\n", "VAR_1 = 1000\n", "if VAR_0:\n", "if is_mobile:\n", "import re\n", "VAR_43.view = VAR_43.view.replace('default/', 'default.mobile/')\n", "from gluon.admin import *\n", "VAR_43.menu = []\n", "from gluon.fileutils import abspath, read_file, write_file\n", "from gluon.utils import web2py_uuid\n", "from gluon.tools import Config\n", "from gluon.compileapp import find_exposed_functions\n", "from glob import glob\n", "from gluon._compat import iteritems, PY2, pickle, xrange, urlopen, to_bytes, StringIO, to_native, reload\n", "import gluon.rewrite\n", "import shutil\n", "import platform\n", "import git\n", "VAR_19 = False\n", "from gluon.languages import read_possible_languages, read_dict, write_dict, read_plural_dict, write_plural_dict\n", "if git.__version__ < '0.3.1':\n", "VAR_117 = (\n 'Requires gitpython module, but not installed or incompatible version: %s'\n % VAR_114)\n", "if DEMO_MODE and request.function in ['change_password', 'pack',\n", "VAR_19 = True\n", "session.flash = T('disabled in demo mode')\n", "if is_gae and request.function in ('edit', 'edit_language', 'edit_plurals',\n", "redirect(URL('site'))\n", "session.flash = T('disabled in GAE mode')\n", "if not is_manager() and request.function in ['change_password',\n", "redirect(URL('site'))\n", "session.flash = T('disabled in multi user mode')\n", "if FILTER_APPS and request.args(0) and not request.args(0) in FILTER_APPS:\n", "redirect(URL('site'))\n", "session.flash = T('disabled in demo mode')\n", "if not session.token:\n", "redirect(URL('site'))\n", "session.token = web2py_uuid()\n", "def FUNC_0(VAR_2):...\n", "return len([VAR_69 for VAR_69 in VAR_2.split('\\n') if VAR_69.strip() and \n not VAR_69.startswith('#')])\n" ]
[ "EXPERIMENTAL_STUFF = True\n", "MAXNFILES = 1000\n", "if EXPERIMENTAL_STUFF:\n", "if is_mobile:\n", "import re\n", "response.view = response.view.replace('default/', 'default.mobile/')\n", "from gluon.admin import *\n", "response.menu = []\n", "from gluon.fileutils import abspath, read_file, write_file\n", "from gluon.utils import web2py_uuid\n", "from gluon.tools import Config\n", "from gluon.compileapp import find_exposed_functions\n", "from glob import glob\n", "from gluon._compat import iteritems, PY2, pickle, xrange, urlopen, to_bytes, StringIO, to_native, reload\n", "import gluon.rewrite\n", "import shutil\n", "import platform\n", "import git\n", "have_git = False\n", "from gluon.languages import read_possible_languages, read_dict, write_dict, read_plural_dict, write_plural_dict\n", "if git.__version__ < '0.3.1':\n", "GIT_MISSING = (\n 'Requires gitpython module, but not installed or incompatible version: %s'\n % e)\n", "if DEMO_MODE and request.function in ['change_password', 'pack',\n", "have_git = True\n", "session.flash = T('disabled in demo mode')\n", "if is_gae and request.function in ('edit', 'edit_language', 'edit_plurals',\n", "redirect(URL('site'))\n", "session.flash = T('disabled in GAE mode')\n", "if not is_manager() and request.function in ['change_password',\n", "redirect(URL('site'))\n", "session.flash = T('disabled in multi user mode')\n", "if FILTER_APPS and request.args(0) and not request.args(0) in FILTER_APPS:\n", "redirect(URL('site'))\n", "session.flash = T('disabled in demo mode')\n", "if not session.token:\n", "redirect(URL('site'))\n", "session.token = web2py_uuid()\n", "def count_lines(data):...\n", "return len([line for line in data.split('\\n') if line.strip() and not line.\n startswith('#')])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Assign'", "Assign'", "Condition", "Condition", "Import'", "Assign'", "ImportFrom'", "Assign'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Import'", "Import'", "Import'", "Assign'", "ImportFrom'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "FunctionDef'", "Return'" ]
[ "def FUNC_65(self):...\n", "" ]
[ "def close(self):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_68(self, VAR_42=None):...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_42:\n", "VAR_42 = frappe.session.user\n", "if hasattr(self.meta, 'track_views') and self.meta.track_views:\n", "frappe.get_doc({'doctype': 'View Log', 'viewed_by': frappe.session.user,\n 'reference_doctype': self.doctype, 'reference_name': self.name}).insert(\n VAR_11=True)\n", "frappe.local.flags.commit = True\n" ]
[ "def add_viewed(self, user=None):...\n", "\"\"\"docstring\"\"\"\n", "if not user:\n", "user = frappe.session.user\n", "if hasattr(self.meta, 'track_views') and self.meta.track_views:\n", "frappe.get_doc({'doctype': 'View Log', 'viewed_by': frappe.session.user,\n 'reference_doctype': self.doctype, 'reference_name': self.name}).insert(\n ignore_permissions=True)\n", "frappe.local.flags.commit = True\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Expr'", "Assign'" ]
[ "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_11(self):...\n", "VAR_11, VAR_12, VAR_13, VAR_14 = self._makeTree()\n", "VAR_16 = CLASS_1()\n", "VAR_19 = 'http://test'\n", "VAR_17 = FauxRequest(RESPONSE=response, URL=testURL, ACTUAL_URL=testURL)\n", "VAR_12.REQUEST = VAR_17\n", "VAR_15 = self._makeOne().__of__(VAR_12)\n", "VAR_15.challenge(VAR_17, VAR_16)\n", "self.assertEqual(VAR_16.status, 302)\n", "self.assertEqual(len(VAR_16.headers), 3)\n", "self.assertTrue(VAR_16.headers['Location'].endswith(quote(VAR_19)))\n", "self.assertEqual(VAR_16.headers['Cache-Control'], 'no-cache')\n", "self.assertEqual(VAR_16.headers['Expires'], 'Sat, 01 Jan 2000 00:00:00 GMT')\n" ]
[ "def test_challenge(self):...\n", "rc, root, folder, object = self._makeTree()\n", "response = FauxCookieResponse()\n", "testURL = 'http://test'\n", "request = FauxRequest(RESPONSE=response, URL=testURL, ACTUAL_URL=testURL)\n", "root.REQUEST = request\n", "helper = self._makeOne().__of__(root)\n", "helper.challenge(request, response)\n", "self.assertEqual(response.status, 302)\n", "self.assertEqual(len(response.headers), 3)\n", "self.assertTrue(response.headers['Location'].endswith(quote(testURL)))\n", "self.assertEqual(response.headers['Cache-Control'], 'no-cache')\n", "self.assertEqual(response.headers['Expires'], 'Sat, 01 Jan 2000 00:00:00 GMT')\n" ]
[ 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 4, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_24(VAR_9, VAR_5, VAR_10):...\n", "VAR_13 = calibre_db.session.query(db.Data).filter(db.Data.format == VAR_5.\n upper()).first()\n", "if VAR_13:\n", "VAR_63, VAR_68, VAR_65 = calibre_db.fill_indexpage(VAR_9, 0, db.Books, db.\n Books.data.any(db.Data.format == VAR_5.upper()), [VAR_10[0][0]])\n", "abort(404)\n", "return render_title_template('index.html', VAR_68=random, VAR_65=pagination,\n VAR_63=entries, id=book_id, VAR_150=_(u'File format: %(format)s',\n format=name.format), VAR_9='formats', VAR_10=order[1])\n" ]
[ "def render_formats_books(page, book_id, order):...\n", "name = calibre_db.session.query(db.Data).filter(db.Data.format == book_id.\n upper()).first()\n", "if name:\n", "entries, random, pagination = calibre_db.fill_indexpage(page, 0, db.Books,\n db.Books.data.any(db.Data.format == book_id.upper()), [order[0][0]])\n", "abort(404)\n", "return render_title_template('index.html', random=random, pagination=\n pagination, entries=entries, id=book_id, title=_(\n u'File format: %(format)s', format=name.format), page='formats', order=\n order[1])\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_16(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_24 = ['asdf.com', 'asdf.net', 'www.as_df.org', 'as.d8f.ghj8.gov']\n", "for i in VAR_24:\n", "VAR_32 = urlize_quoted_links(i)\n", "VAR_25 = ['mailto://asdf@fdf.com', 'asdf.netnet']\n", "self.assertNotEqual(VAR_32, i)\n", "for i in VAR_25:\n", "self.assertIn(i, VAR_32)\n", "VAR_32 = urlize_quoted_links(i)\n", "urlize_quoted_links('asdf:[/p]zxcv.com')\n", "self.assertEqual(i, VAR_32)\n" ]
[ "def test_issue_1386(self):...\n", "\"\"\"docstring\"\"\"\n", "correct_urls = ['asdf.com', 'asdf.net', 'www.as_df.org', 'as.d8f.ghj8.gov']\n", "for i in correct_urls:\n", "res = urlize_quoted_links(i)\n", "incorrect_urls = ['mailto://asdf@fdf.com', 'asdf.netnet']\n", "self.assertNotEqual(res, i)\n", "for i in incorrect_urls:\n", "self.assertIn(i, res)\n", "res = urlize_quoted_links(i)\n", "urlize_quoted_links('asdf:[/p]zxcv.com')\n", "self.assertEqual(i, res)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "For", "Assign'", "Assign'", "Expr'", "For", "Expr'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_2(VAR_0: str) ->str:...\n", "return stringcase.snakecase(FUNC_1(FUNC_0(VAR_0)))\n" ]
[ "def snake_case(value: str) ->str:...\n", "return stringcase.snakecase(group_title(_sanitize(value)))\n" ]
[ 0, 5 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_0(VAR_0):...\n", "\"\"\"docstring\"\"\"\n", "VAR_12 = {}\n", "if VAR_0 and hasattr(VAR_0, 'items'):\n", "VAR_30 = []\n", "return VAR_12\n", "for k, VAR_39 in VAR_0.items():\n", "if callable(VAR_39):\n", "VAR_12.update(dict(VAR_30))\n", "VAR_39 = VAR_39()\n", "if isinstance(VAR_39, (tuple, list)):\n", "VAR_39 = ','.join([str(x) for x in VAR_39])\n", "if isinstance(VAR_39, bool):\n", "VAR_30.append((k, VAR_39))\n", "VAR_39 = ('0', '1')[VAR_39]\n", "VAR_39 = six.text_type(VAR_39)\n" ]
[ "def url_params_from_lookup_dict(lookups):...\n", "\"\"\"docstring\"\"\"\n", "params = {}\n", "if lookups and hasattr(lookups, 'items'):\n", "items = []\n", "return params\n", "for k, v in lookups.items():\n", "if callable(v):\n", "params.update(dict(items))\n", "v = v()\n", "if isinstance(v, (tuple, list)):\n", "v = ','.join([str(x) for x in v])\n", "if isinstance(v, bool):\n", "items.append((k, v))\n", "v = ('0', '1')[v]\n", "v = six.text_type(v)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Return'", "For", "Condition", "Expr'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Assign'" ]
[ "def FUNC_4(VAR_0, VAR_1):...\n", "return FUNC_0(VAR_0=request, VAR_1=pk, VAR_2='is_closed', VAR_3=False,\n VAR_4=Comment.UNCLOSED, VAR_5=_('The topic has been unlocked'))\n" ]
[ "def unlock(request, pk):...\n", "return _moderate(request=request, pk=pk, field_name='is_closed', to_value=\n False, action=Comment.UNCLOSED, message=_('The topic has been unlocked'))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@VAR_0.filter...\n", "if isinstance(VAR_17, dict):\n", "return 'class=nested'\n", "if isinstance(VAR_17, list) and any([isinstance(item, (list, dict)) for\n", "return 'class=nested'\n", "return ''\n" ]
[ "@register.filter...\n", "if isinstance(value, dict):\n", "return 'class=nested'\n", "if isinstance(value, list) and any([isinstance(item, (list, dict)) for item in\n", "return 'class=nested'\n", "return ''\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Return'", "For", "Return'", "Return'" ]
[ "def FUNC_9(self, VAR_8, **VAR_4):...\n", "self.layout.delete_row(VAR_8)\n", "self.save_layout()\n" ]
[ "def dispatch_del_row(self, y, **kwargs):...\n", "self.layout.delete_row(y)\n", "self.save_layout()\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'" ]
[ "@VAR_0.route('/api/templates/<int:template_id>/full-print', methods=['GET'])...\n", "\"\"\"docstring\"\"\"\n", "VAR_95 = FUNC_58(f'/internal/templates/{VAR_19}/full-print', 'get')\n", "return jsonify({'success': False, 'message': str(err)}), 400\n", "return jsonify(VAR_95)\n" ]
[ "@gui.route('/api/templates/<int:template_id>/full-print', methods=['GET'])...\n", "\"\"\"docstring\"\"\"\n", "full_print_info = query_internal_api(\n f'/internal/templates/{template_id}/full-print', 'get')\n", "return jsonify({'success': False, 'message': str(err)}), 400\n", "return jsonify(full_print_info)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Return'", "Return'" ]
[ "@VAR_2.route('/cover/<int:book_id>')...\n", "return get_book_cover(VAR_5)\n" ]
[ "@web.route('/cover/<int:book_id>')...\n", "return get_book_cover(book_id)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_9(self, VAR_11=None, VAR_12=None, VAR_13=False, VAR_14=None,...\n", "\"\"\"docstring\"\"\"\n", "if self.flags.in_print:\n", "return\n", "self.flags.notifications_executed = []\n", "if VAR_11 != None:\n", "self.flags.ignore_permissions = VAR_11\n", "if VAR_12 != None:\n", "self.flags.ignore_links = VAR_12\n", "if VAR_14 != None:\n", "self.flags.ignore_mandatory = VAR_14\n", "self.set('__islocal', True)\n", "self.check_permission('create')\n", "self._set_defaults()\n", "self.set_user_and_timestamp()\n", "self.set_docstatus()\n", "self.check_if_latest()\n", "self.run_method('before_insert')\n", "self._validate_links()\n", "self.set_new_name(VAR_15=set_name, VAR_16=set_child_names)\n", "self.set_parent_in_children()\n", "self.validate_higher_perm_levels()\n", "self.flags.in_insert = True\n", "self.run_before_save_methods()\n", "self._validate()\n", "self.set_docstatus()\n", "self.flags.in_insert = False\n", "if getattr(self.meta, 'issingle', 0):\n", "self.update_single(self.get_valid_dict())\n", "self.db_insert()\n", "if not VAR_13:\n", "for VAR_21 in self.get_all_children():\n", "VAR_21.db_insert()\n", "self.run_method('after_insert')\n", "self.flags.in_insert = True\n", "if self.get('amended_from'):\n", "self.copy_attachments_from_amended_from()\n", "self.flags.update_log_for_doc_creation = True\n", "self.run_post_save_methods()\n", "self.flags.in_insert = False\n", "if hasattr(self, '__islocal'):\n", "delattr(self, '__islocal')\n", "if hasattr(self, '__unsaved'):\n", "delattr(self, '__unsaved')\n", "if not (frappe.flags.in_migrate or frappe.local.flags.in_install or frappe.\n", "follow_document(self.doctype, self.name, frappe.session.user)\n", "return self\n" ]
[ "def insert(self, ignore_permissions=None, ignore_links=None,...\n", "\"\"\"docstring\"\"\"\n", "if self.flags.in_print:\n", "return\n", "self.flags.notifications_executed = []\n", "if ignore_permissions != None:\n", "self.flags.ignore_permissions = ignore_permissions\n", "if ignore_links != None:\n", "self.flags.ignore_links = ignore_links\n", "if ignore_mandatory != None:\n", "self.flags.ignore_mandatory = ignore_mandatory\n", "self.set('__islocal', True)\n", "self.check_permission('create')\n", "self._set_defaults()\n", "self.set_user_and_timestamp()\n", "self.set_docstatus()\n", "self.check_if_latest()\n", "self.run_method('before_insert')\n", "self._validate_links()\n", "self.set_new_name(set_name=set_name, set_child_names=set_child_names)\n", "self.set_parent_in_children()\n", "self.validate_higher_perm_levels()\n", "self.flags.in_insert = True\n", "self.run_before_save_methods()\n", "self._validate()\n", "self.set_docstatus()\n", "self.flags.in_insert = False\n", "if getattr(self.meta, 'issingle', 0):\n", "self.update_single(self.get_valid_dict())\n", "self.db_insert()\n", "if not ignore_if_duplicate:\n", "for d in self.get_all_children():\n", "d.db_insert()\n", "self.run_method('after_insert')\n", "self.flags.in_insert = True\n", "if self.get('amended_from'):\n", "self.copy_attachments_from_amended_from()\n", "self.flags.update_log_for_doc_creation = True\n", "self.run_post_save_methods()\n", "self.flags.in_insert = False\n", "if hasattr(self, '__islocal'):\n", "delattr(self, '__islocal')\n", "if hasattr(self, '__unsaved'):\n", "delattr(self, '__unsaved')\n", "if not (frappe.flags.in_migrate or frappe.local.flags.in_install or frappe.\n", "follow_document(self.doctype, self.name, frappe.session.user)\n", "return self\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Condition", "For", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_76(VAR_43):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.core.doctype.data_import.data_import import import_doc\n", "FUNC_76(VAR_43)\n" ]
[ "def import_doc(path):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.core.doctype.data_import.data_import import import_doc\n", "import_doc(path)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "ImportFrom'", "Expr'" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "VAR_195 = 0\n", "VAR_196 = 0\n", "VAR_197 = []\n", "_purgeCallback(VAR_2)\n", "VAR_198 = VAR_2.GET.get('jobId', None)\n", "if VAR_198 is not None:\n", "VAR_198 = VAR_345(VAR_198)\n", "if VAR_2.method == 'DELETE':\n", "VAR_367 = omero.cmd.HandlePrx.checkedCast(VAR_5.c.ic.stringToProxy(VAR_198))\n", "VAR_172 = {'finished': True}\n", "return VAR_172\n", "VAR_17 = json.loads(VAR_2.body)\n", "VAR_17 = json.loads(bytes_to_native_str(VAR_2.body))\n", "VAR_198 = VAR_17.get('jobId', None)\n", "for VAR_39 in VAR_2.session.get('callback').keys():\n", "VAR_313 = VAR_367.getStatus()\n", "if VAR_198 is not None:\n", "VAR_311 = VAR_2.session['callback'][VAR_39]\n", "VAR_172 = {}\n", "VAR_0.debug('job status: %s', VAR_313)\n", "VAR_198 = VAR_345(VAR_198)\n", "return VAR_172\n", "VAR_312 = VAR_311['job_type']\n", "for VAR_39 in VAR_2.session.get('callback').keys():\n", "VAR_174 = VAR_367.getResponse()\n", "VAR_172 = {'jobId': VAR_198}\n", "VAR_313 = VAR_311['status']\n", "VAR_172[VAR_39] = copy.copy(VAR_2.session['callback'][VAR_39])\n", "if 'template' in VAR_6 and VAR_6['template'] == 'json':\n", "if VAR_174 is not None:\n", "VAR_367 = omero.cmd.HandlePrx.checkedCast(VAR_5.c.ic.stringToProxy(VAR_198))\n", "VAR_0.info('Timeout on prx.cancel()')\n", "if VAR_313 == 'failed':\n", "for VAR_39 in VAR_2.session.get('callback').keys():\n", "VAR_199 = []\n", "VAR_172 = graphResponseMarshal(VAR_5, VAR_174)\n", "VAR_172 = {'finished': False}\n", "VAR_313 = VAR_367.getStatus()\n", "VAR_196 += 1\n", "VAR_2.session.modified = True\n", "VAR_172[VAR_39]['start_time'] = VAR_345(VAR_2.session['callback'][VAR_39][\n 'start_time'])\n", "VAR_172['inprogress'] = VAR_195\n", "VAR_200 = False\n", "VAR_172['finished'] = True\n", "VAR_172['status'] = {'currentStep': VAR_313.currentStep, 'steps': VAR_313.\n steps, 'startTime': VAR_313.startTime, 'stopTime': VAR_313.stopTime}\n", "VAR_0.debug('pre-cancel() job status: %s', VAR_313)\n", "if VAR_312 in ('chgrp', 'chown'):\n", "VAR_172['failure'] = VAR_196\n", "for VAR_310, VAR_158 in VAR_172.items():\n", "VAR_172['status'] = {'currentStep': VAR_313.currentStep, 'steps': VAR_313.\n steps, 'startTime': VAR_313.startTime, 'stopTime': VAR_313.stopTime}\n", "if VAR_313 not in ('failed', 'finished'):\n", "if VAR_312 == 'send_email':\n", "VAR_172['jobs'] = len(VAR_2.session['callback'])\n", "if len(VAR_310.split(' ')) > 0:\n", "VAR_199.sort(VAR_310=lambda x: x['start_time'], VAR_350=True)\n", "VAR_367.cancel()\n", "VAR_174 = None\n", "if VAR_313 not in ('failed', 'finished'):\n", "if VAR_312 == 'delete':\n", "return JsonResponse(VAR_172)\n", "VAR_368 = VAR_310.split(' ')[0]\n", "VAR_172[VAR_310]['id'] = VAR_368\n", "VAR_53 = {'sizeOfJobs': len(VAR_2.session['callback']), 'jobs': VAR_199,\n 'inprogress': VAR_195, 'new_results': len(VAR_197), 'new_errors':\n VAR_200, 'failure': VAR_196}\n", "VAR_367 = omero.cmd.HandlePrx.checkedCast(VAR_5.c.ic.stringToProxy(VAR_39))\n", "VAR_0.info('Activities %s handle not found: %s' % (VAR_312, VAR_39))\n", "VAR_174 = None\n", "if VAR_313 not in ('failed', 'finished'):\n", "if VAR_312 == 'script':\n", "if len(VAR_368.split('/')) > 1:\n", "VAR_172[VAR_310]['key'] = VAR_310\n", "VAR_53['template'] = 'webclient/activities/activitiesContent.html'\n", "VAR_174 = VAR_367.getResponse()\n", "VAR_367 = omero.cmd.HandlePrx.checkedCast(VAR_5.c.ic.stringToProxy(VAR_39))\n", "VAR_0.error(traceback.format_exc())\n", "VAR_84 = omero.cmd.HandlePrx.checkedCast(VAR_5.c.ic.stringToProxy(VAR_39))\n", "FUNC_61(VAR_2, VAR_39, VAR_57=0, VAR_313='finished', dreport=None)\n", "if not VAR_39.startswith('ProcessCallback'):\n", "VAR_368 = VAR_368.split('/')[1]\n", "if VAR_310 in VAR_197:\n", "return VAR_53\n", "VAR_431 = False\n", "VAR_445 = omero.callbacks.CmdCallbackI(VAR_5.c, VAR_367, foreground_poll=True)\n", "VAR_0.info('Activities send_email handle not found: %s' % VAR_39)\n", "VAR_446 = omero.callbacks.CmdCallbackI(VAR_5.c, VAR_84, foreground_poll=True)\n", "VAR_0.error(traceback.format_exc())\n", "if VAR_313 not in ('failed', 'finished'):\n", "VAR_172[VAR_310]['new'] = True\n", "VAR_199.append(VAR_172[VAR_310])\n", "if VAR_174 is not None:\n", "VAR_367.close(VAR_431)\n", "VAR_174 = VAR_445.getResponse()\n", "VAR_174 = VAR_446.getResponse()\n", "VAR_0.error(\"Status job '%s'error:\" % VAR_39)\n", "VAR_0.info('Check callback on script: %s' % VAR_39)\n", "if 'error' in VAR_158 and VAR_158['error'] > 0:\n", "VAR_431 = True\n", "VAR_195 += 1\n", "VAR_431 = False\n", "VAR_431 = False\n", "FUNC_61(VAR_2, VAR_39, VAR_57=1, VAR_313='failed', dreport=str(x))\n", "VAR_449 = omero.grid.ScriptProcessPrx.checkedCast(VAR_5.c.ic.stringToProxy(\n VAR_39))\n", "FUNC_61(VAR_2, VAR_39, VAR_313='failed', Message='No process found for job',\n VAR_57=1)\n", "VAR_446 = omero.scripts.ProcessCallbackI(VAR_5.c, VAR_449)\n", "VAR_200 = True\n", "VAR_197.append(VAR_39)\n", "if VAR_174 is not None:\n", "VAR_445.close(VAR_431)\n", "if not VAR_174:\n", "VAR_446.close(VAR_431)\n", "VAR_196 += 1\n", "if VAR_446.block(0):\n", "if isinstance(VAR_174, omero.cmd.ERR):\n", "VAR_431 = True\n", "VAR_195 += 1\n", "FUNC_61(VAR_2, VAR_39, VAR_57=0, VAR_313='in progress', dreport=\n _formatReport(handle))\n", "VAR_431 = True\n", "VAR_446.close()\n", "VAR_195 += 1\n", "VAR_448 = ', '.join([('%s: %s' % (VAR_415, VAR_416)) for VAR_415, VAR_416 in\n VAR_174.parameters.items()])\n", "if isinstance(VAR_174, omero.cmd.OK):\n", "VAR_197.append(VAR_39)\n", "VAR_195 += 1\n", "VAR_197.append(VAR_39)\n", "VAR_453 = VAR_449.getResults(0, VAR_5.SERVICE_OPTS)\n", "FUNC_61(VAR_2, VAR_39, VAR_313='finished', Message='Failed to get results')\n", "VAR_450 = {}\n", "VAR_0.error('%s failed with: %s' % (VAR_312, VAR_448))\n", "FUNC_61(VAR_2, VAR_39, VAR_313='finished')\n", "if isinstance(VAR_174, omero.cmd.ERR):\n", "VAR_174 = VAR_446.getResponse()\n", "FUNC_61(VAR_2, VAR_39, VAR_313='finished')\n", "VAR_0.info('Failed on proc.getResults() for OMERO.script')\n", "for VAR_310, VAR_375 in VAR_453.items():\n", "FUNC_61(VAR_2, VAR_39, VAR_313='failed', report='%s %s' % (rsp.name,\n rsp_params), VAR_57=1)\n", "VAR_448 = ', '.join([('%s: %s' % (VAR_415, VAR_416)) for VAR_415, VAR_416 in\n VAR_174.parameters.items()])\n", "VAR_451 = VAR_174.success + len(VAR_174.invalidusers) + len(VAR_174.\n invalidemails)\n", "VAR_452 = isinstance(VAR_174, omero.cmd.ERR)\n", "VAR_197.append(VAR_39)\n", "VAR_416 = VAR_375.getValue()\n", "FUNC_61(VAR_2, VAR_39, VAR_453=rMap)\n", "VAR_0.error('send_email failed with: %s' % VAR_448)\n", "FUNC_61(VAR_2, VAR_39, VAR_313='finished', VAR_174={'success': rsp.success,\n 'total': total})\n", "if VAR_452:\n", "if VAR_310 in ('stdout', 'stderr', 'Message'):\n", "FUNC_61(VAR_2, VAR_39, VAR_313='failed', report={'error': rsp_params}, VAR_57=1\n )\n", "if len(VAR_174.invalidusers) > 0 or len(VAR_174.invalidemails) > 0:\n", "FUNC_61(VAR_2, VAR_39, VAR_57=1, VAR_313='failed', dreport=_formatReport(\n handle))\n", "FUNC_61(VAR_2, VAR_39, VAR_57=0, VAR_313='finished', dreport=_formatReport(\n handle))\n", "if VAR_310 in ('stderr', 'stdout'):\n", "if hasattr(VAR_416, 'id'):\n", "VAR_454 = [e.getFullName() for e in list(VAR_5.getObjects('Experimenter',\n VAR_174.invalidusers))]\n", "VAR_196 += 1\n", "VAR_416 = VAR_416.id.val\n", "VAR_455 = {VAR_310: VAR_416}\n", "VAR_456 = {'id': VAR_416.id.val, 'type': VAR_416.__class__.__name__[:-1]}\n", "VAR_450[VAR_310] = unwrap(VAR_416)\n", "FUNC_61(VAR_2, VAR_39, report={'invalidusers': invalidusers,\n 'invalidemails': rsp.invalidemails})\n", "FUNC_61(VAR_2, VAR_39, **update_kwargs)\n", "VAR_456['browse_url'] = FUNC_60(VAR_5, VAR_416)\n", "if VAR_416.isLoaded() and hasattr(VAR_416, 'file'):\n", "VAR_458 = {'image/png': 'png', 'image/jpeg': 'jpeg', 'text/plain': 'text'}\n", "if VAR_416.isLoaded() and hasattr(VAR_416, 'name'):\n", "if VAR_416.file.mimetype.val in VAR_458:\n", "VAR_3 = unwrap(VAR_416.name)\n", "VAR_450[VAR_310] = VAR_456\n", "VAR_456['fileType'] = VAR_458[VAR_416.file.mimetype.val]\n", "VAR_456['name'] = VAR_416.file.name.val\n", "if VAR_3 is not None:\n", "VAR_456['fileId'] = VAR_416.file.id.val\n", "VAR_456['name'] = VAR_3\n" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "in_progress = 0\n", "failure = 0\n", "new_results = []\n", "_purgeCallback(request)\n", "jobId = request.GET.get('jobId', None)\n", "if jobId is not None:\n", "jobId = str(jobId)\n", "if request.method == 'DELETE':\n", "prx = omero.cmd.HandlePrx.checkedCast(conn.c.ic.stringToProxy(jobId))\n", "rv = {'finished': True}\n", "return rv\n", "json_data = json.loads(request.body)\n", "json_data = json.loads(bytes_to_native_str(request.body))\n", "jobId = json_data.get('jobId', None)\n", "for cbString in request.session.get('callback').keys():\n", "status = prx.getStatus()\n", "if jobId is not None:\n", "callbackDict = request.session['callback'][cbString]\n", "rv = {}\n", "logger.debug('job status: %s', status)\n", "jobId = str(jobId)\n", "return rv\n", "job_type = callbackDict['job_type']\n", "for cbString in request.session.get('callback').keys():\n", "rsp = prx.getResponse()\n", "rv = {'jobId': jobId}\n", "status = callbackDict['status']\n", "rv[cbString] = copy.copy(request.session['callback'][cbString])\n", "if 'template' in kwargs and kwargs['template'] == 'json':\n", "if rsp is not None:\n", "prx = omero.cmd.HandlePrx.checkedCast(conn.c.ic.stringToProxy(jobId))\n", "logger.info('Timeout on prx.cancel()')\n", "if status == 'failed':\n", "for cbString in request.session.get('callback').keys():\n", "jobs = []\n", "rv = graphResponseMarshal(conn, rsp)\n", "rv = {'finished': False}\n", "status = prx.getStatus()\n", "failure += 1\n", "request.session.modified = True\n", "rv[cbString]['start_time'] = str(request.session['callback'][cbString][\n 'start_time'])\n", "rv['inprogress'] = in_progress\n", "new_errors = False\n", "rv['finished'] = True\n", "rv['status'] = {'currentStep': status.currentStep, 'steps': status.steps,\n 'startTime': status.startTime, 'stopTime': status.stopTime}\n", "logger.debug('pre-cancel() job status: %s', status)\n", "if job_type in ('chgrp', 'chown'):\n", "rv['failure'] = failure\n", "for key, data in rv.items():\n", "rv['status'] = {'currentStep': status.currentStep, 'steps': status.steps,\n 'startTime': status.startTime, 'stopTime': status.stopTime}\n", "if status not in ('failed', 'finished'):\n", "if job_type == 'send_email':\n", "rv['jobs'] = len(request.session['callback'])\n", "if len(key.split(' ')) > 0:\n", "jobs.sort(key=lambda x: x['start_time'], reverse=True)\n", "prx.cancel()\n", "rsp = None\n", "if status not in ('failed', 'finished'):\n", "if job_type == 'delete':\n", "return JsonResponse(rv)\n", "htmlId = key.split(' ')[0]\n", "rv[key]['id'] = htmlId\n", "context = {'sizeOfJobs': len(request.session['callback']), 'jobs': jobs,\n 'inprogress': in_progress, 'new_results': len(new_results),\n 'new_errors': new_errors, 'failure': failure}\n", "prx = omero.cmd.HandlePrx.checkedCast(conn.c.ic.stringToProxy(cbString))\n", "logger.info('Activities %s handle not found: %s' % (job_type, cbString))\n", "rsp = None\n", "if status not in ('failed', 'finished'):\n", "if job_type == 'script':\n", "if len(htmlId.split('/')) > 1:\n", "rv[key]['key'] = key\n", "context['template'] = 'webclient/activities/activitiesContent.html'\n", "rsp = prx.getResponse()\n", "prx = omero.cmd.HandlePrx.checkedCast(conn.c.ic.stringToProxy(cbString))\n", "logger.error(traceback.format_exc())\n", "handle = omero.cmd.HandlePrx.checkedCast(conn.c.ic.stringToProxy(cbString))\n", "update_callback(request, cbString, error=0, status='finished', dreport=None)\n", "if not cbString.startswith('ProcessCallback'):\n", "htmlId = htmlId.split('/')[1]\n", "if key in new_results:\n", "return context\n", "close_handle = False\n", "callback = omero.callbacks.CmdCallbackI(conn.c, prx, foreground_poll=True)\n", "logger.info('Activities send_email handle not found: %s' % cbString)\n", "cb = omero.callbacks.CmdCallbackI(conn.c, handle, foreground_poll=True)\n", "logger.error(traceback.format_exc())\n", "if status not in ('failed', 'finished'):\n", "rv[key]['new'] = True\n", "jobs.append(rv[key])\n", "if rsp is not None:\n", "prx.close(close_handle)\n", "rsp = callback.getResponse()\n", "rsp = cb.getResponse()\n", "logger.error(\"Status job '%s'error:\" % cbString)\n", "logger.info('Check callback on script: %s' % cbString)\n", "if 'error' in data and data['error'] > 0:\n", "close_handle = True\n", "in_progress += 1\n", "close_handle = False\n", "close_handle = False\n", "update_callback(request, cbString, error=1, status='failed', dreport=str(x))\n", "proc = omero.grid.ScriptProcessPrx.checkedCast(conn.c.ic.stringToProxy(\n cbString))\n", "update_callback(request, cbString, status='failed', Message=\n 'No process found for job', error=1)\n", "cb = omero.scripts.ProcessCallbackI(conn.c, proc)\n", "new_errors = True\n", "new_results.append(cbString)\n", "if rsp is not None:\n", "callback.close(close_handle)\n", "if not rsp:\n", "cb.close(close_handle)\n", "failure += 1\n", "if cb.block(0):\n", "if isinstance(rsp, omero.cmd.ERR):\n", "close_handle = True\n", "in_progress += 1\n", "update_callback(request, cbString, error=0, status='in progress', dreport=\n _formatReport(handle))\n", "close_handle = True\n", "cb.close()\n", "in_progress += 1\n", "rsp_params = ', '.join([('%s: %s' % (k, v)) for k, v in rsp.parameters.items()]\n )\n", "if isinstance(rsp, omero.cmd.OK):\n", "new_results.append(cbString)\n", "in_progress += 1\n", "new_results.append(cbString)\n", "results = proc.getResults(0, conn.SERVICE_OPTS)\n", "update_callback(request, cbString, status='finished', Message=\n 'Failed to get results')\n", "rMap = {}\n", "logger.error('%s failed with: %s' % (job_type, rsp_params))\n", "update_callback(request, cbString, status='finished')\n", "if isinstance(rsp, omero.cmd.ERR):\n", "rsp = cb.getResponse()\n", "update_callback(request, cbString, status='finished')\n", "logger.info('Failed on proc.getResults() for OMERO.script')\n", "for key, value in results.items():\n", "update_callback(request, cbString, status='failed', report='%s %s' % (rsp.\n name, rsp_params), error=1)\n", "rsp_params = ', '.join([('%s: %s' % (k, v)) for k, v in rsp.parameters.items()]\n )\n", "total = rsp.success + len(rsp.invalidusers) + len(rsp.invalidemails)\n", "err = isinstance(rsp, omero.cmd.ERR)\n", "new_results.append(cbString)\n", "v = value.getValue()\n", "update_callback(request, cbString, results=rMap)\n", "logger.error('send_email failed with: %s' % rsp_params)\n", "update_callback(request, cbString, status='finished', rsp={'success': rsp.\n success, 'total': total})\n", "if err:\n", "if key in ('stdout', 'stderr', 'Message'):\n", "update_callback(request, cbString, status='failed', report={'error':\n rsp_params}, error=1)\n", "if len(rsp.invalidusers) > 0 or len(rsp.invalidemails) > 0:\n", "update_callback(request, cbString, error=1, status='failed', dreport=\n _formatReport(handle))\n", "update_callback(request, cbString, error=0, status='finished', dreport=\n _formatReport(handle))\n", "if key in ('stderr', 'stdout'):\n", "if hasattr(v, 'id'):\n", "invalidusers = [e.getFullName() for e in list(conn.getObjects(\n 'Experimenter', rsp.invalidusers))]\n", "failure += 1\n", "v = v.id.val\n", "update_kwargs = {key: v}\n", "obj_data = {'id': v.id.val, 'type': v.__class__.__name__[:-1]}\n", "rMap[key] = unwrap(v)\n", "update_callback(request, cbString, report={'invalidusers': invalidusers,\n 'invalidemails': rsp.invalidemails})\n", "update_callback(request, cbString, **update_kwargs)\n", "obj_data['browse_url'] = getObjectUrl(conn, v)\n", "if v.isLoaded() and hasattr(v, 'file'):\n", "mimetypes = {'image/png': 'png', 'image/jpeg': 'jpeg', 'text/plain': 'text'}\n", "if v.isLoaded() and hasattr(v, 'name'):\n", "if v.file.mimetype.val in mimetypes:\n", "name = unwrap(v.name)\n", "rMap[key] = obj_data\n", "obj_data['fileType'] = mimetypes[v.file.mimetype.val]\n", "obj_data['name'] = v.file.name.val\n", "if name is not None:\n", "obj_data['fileId'] = v.file.id.val\n", "obj_data['name'] = name\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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'", "Expr'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Return'", "Assign'", "For", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Expr'", "Condition", "For", "Assign'", "Assign'", "Assign'", "Assign'", "AugAssign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "For", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Assign'", "Condition", "Condition", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Condition", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Condition", "Assign'", "Expr'", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Condition", "Assign'", "AugAssign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "AugAssign'", "Condition", "Condition", "Assign'", "AugAssign'", "Expr'", "Assign'", "Expr'", "AugAssign'", "Assign'", "Condition", "Expr'", "AugAssign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Condition", "Assign'", "Expr'", "Expr'", "For", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Condition", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Condition", "Condition", "Assign'", "AugAssign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_0(self):...\n", "from zope.component import provideAdapter\n", "from zope.traversing.adapters import DefaultTraversable\n", "PlacelessSetup.setUp(self)\n", "provideAdapter(DefaultTraversable, (None,))\n" ]
[ "def setUp(self):...\n", "from zope.component import provideAdapter\n", "from zope.traversing.adapters import DefaultTraversable\n", "PlacelessSetup.setUp(self)\n", "provideAdapter(DefaultTraversable, (None,))\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "ImportFrom'", "Expr'", "Expr'" ]
[ "@FUNC_0...\n", "return StateResolutionHandler(self)\n" ]
[ "@cache_in_self...\n", "return StateResolutionHandler(self)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_2(VAR_2, VAR_3):...\n", "warnings.warn('Deprecated. Use omeroweb.webgateway.util.get_longs()',\n DeprecationWarning)\n", "return webgateway_get_longs(VAR_2, VAR_3)\n" ]
[ "def get_longs(request, name):...\n", "warnings.warn('Deprecated. Use omeroweb.webgateway.util.get_longs()',\n DeprecationWarning)\n", "return webgateway_get_longs(request, name)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Return'" ]
[ "def FUNC_25(VAR_21):...\n", "\"\"\"docstring\"\"\"\n", "VAR_52 = 'string'\n", "VAR_53 = VAR_21.add_parser('scan', description=scan_msg, formatter_class=\n argparse.RawTextHelpFormatter)\n", "VAR_53.add_argument('--dir', type=str, required=True, help=\n 'directory containing the SavedModel to execute')\n", "VAR_53.add_argument('--tag_set', type=str, help=\n \"tag-set of graph in SavedModel to scan, separated by ','\")\n", "VAR_53.set_defaults(func=scan)\n" ]
[ "def add_scan_subparser(subparsers):...\n", "\"\"\"docstring\"\"\"\n", "scan_msg = \"\"\"Usage example:\nTo scan for denylisted ops in SavedModel:\n$saved_model_cli scan --dir /tmp/saved_model\nTo scan a specific MetaGraph, pass in --tag_set\n\"\"\"\n", "parser_scan = subparsers.add_parser('scan', description=scan_msg,\n formatter_class=argparse.RawTextHelpFormatter)\n", "parser_scan.add_argument('--dir', type=str, required=True, help=\n 'directory containing the SavedModel to execute')\n", "parser_scan.add_argument('--tag_set', type=str, help=\n \"tag-set of graph in SavedModel to scan, separated by ','\")\n", "parser_scan.set_defaults(func=scan)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "@VAR_1.route('/<bfile>/extension/<report_name>/')...\n", "\"\"\"docstring\"\"\"\n", "VAR_41, VAR_42 = g.ledger.extensions.template_and_extension(VAR_19)\n", "return abort(404)\n", "VAR_43 = render_template_string(VAR_41, VAR_42=extension)\n", "return render_template('_layout.html', VAR_43=content, page_title=extension\n .report_title)\n" ]
[ "@app.route('/<bfile>/extension/<report_name>/')...\n", "\"\"\"docstring\"\"\"\n", "template, extension = g.ledger.extensions.template_and_extension(report_name)\n", "return abort(404)\n", "content = render_template_string(template, extension=extension)\n", "return render_template('_layout.html', content=content, page_title=\n extension.report_title)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Return'", "Assign'", "Return'" ]
[ "def FUNC_15(self):...\n", "VAR_5 = self._makeContext()\n", "self.assertEqual(VAR_5.evaluate('x | python:int'), int)\n" ]
[ "def test_hybrid_with_python_expression_type_value_not_called(self):...\n", "ec = self._makeContext()\n", "self.assertEqual(ec.evaluate('x | python:int'), int)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_1():...\n", "\"\"\"docstring\"\"\"\n", "VAR_7 = QSslSocket.defaultCiphers()\n", "log.init.debug('Default Qt ciphers: {}'.format(', '.join(c.name() for c in\n VAR_7)))\n", "VAR_8 = []\n", "VAR_9 = []\n", "for VAR_2 in VAR_7:\n", "if FUNC_0(VAR_2):\n", "log.init.debug('Disabling bad ciphers: {}'.format(', '.join(c.name() for c in\n VAR_9)))\n", "VAR_8.append(VAR_2)\n", "VAR_9.append(VAR_2)\n", "QSslSocket.setDefaultCiphers(VAR_8)\n" ]
[ "def init():...\n", "\"\"\"docstring\"\"\"\n", "default_ciphers = QSslSocket.defaultCiphers()\n", "log.init.debug('Default Qt ciphers: {}'.format(', '.join(c.name() for c in\n default_ciphers)))\n", "good_ciphers = []\n", "bad_ciphers = []\n", "for cipher in default_ciphers:\n", "if _is_secure_cipher(cipher):\n", "log.init.debug('Disabling bad ciphers: {}'.format(', '.join(c.name() for c in\n bad_ciphers)))\n", "good_ciphers.append(cipher)\n", "bad_ciphers.append(cipher)\n", "QSslSocket.setDefaultCiphers(good_ciphers)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Assign'", "Assign'", "For", "Condition", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_8(VAR_0, VAR_7, VAR_3=False):...\n", "if VAR_3:\n", "VAR_22 = ub.Shelf.id != VAR_3\n", "VAR_22 = true()\n", "if VAR_0.is_public == 1:\n", "VAR_23 = ub.session.query(ub.Shelf).filter((ub.Shelf.name == VAR_7) & (ub.\n Shelf.is_public == 1)).filter(VAR_22).first() is None\n", "VAR_23 = ub.session.query(ub.Shelf).filter((ub.Shelf.name == VAR_7) & (ub.\n Shelf.is_public == 0) & (ub.Shelf.user_id == int(current_user.id))).filter(\n VAR_22).first() is None\n", "if not VAR_23:\n", "if not VAR_23:\n", "VAR_1.error(\"A public shelf with the name '{}' already exists.\".format(VAR_7))\n", "return VAR_23\n", "VAR_1.error(\"A private shelf with the name '{}' already exists.\".format(VAR_7))\n", "flash(_(u\"A public shelf with the name '%(title)s' already exists.\", VAR_7=\n title), category='error')\n", "flash(_(u\"A private shelf with the name '%(title)s' already exists.\", VAR_7\n =title), category='error')\n" ]
[ "def check_shelf_is_unique(shelf, title, shelf_id=False):...\n", "if shelf_id:\n", "ident = ub.Shelf.id != shelf_id\n", "ident = true()\n", "if shelf.is_public == 1:\n", "is_shelf_name_unique = ub.session.query(ub.Shelf).filter((ub.Shelf.name ==\n title) & (ub.Shelf.is_public == 1)).filter(ident).first() is None\n", "is_shelf_name_unique = ub.session.query(ub.Shelf).filter((ub.Shelf.name ==\n title) & (ub.Shelf.is_public == 0) & (ub.Shelf.user_id == int(\n current_user.id))).filter(ident).first() is None\n", "if not is_shelf_name_unique:\n", "if not is_shelf_name_unique:\n", "log.error(\"A public shelf with the name '{}' already exists.\".format(title))\n", "return is_shelf_name_unique\n", "log.error(\"A private shelf with the name '{}' already exists.\".format(title))\n", "flash(_(u\"A public shelf with the name '%(title)s' already exists.\", title=\n title), category='error')\n", "flash(_(u\"A private shelf with the name '%(title)s' already exists.\", title\n =title), category='error')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Expr'", "Return'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_11(VAR_19, VAR_10, VAR_20, VAR_21, VAR_22, VAR_23):...\n", "\"\"\"docstring\"\"\"\n", "VAR_55 = CourseEnrollment.enroll(VAR_19, VAR_10, VAR_20=mode)\n", "ManualEnrollmentAudit.create_manual_enrollment_audit(VAR_21, VAR_19.email,\n VAR_23, VAR_22, VAR_55)\n", "VAR_0.info(u'user %s enrolled in the course %s', VAR_19.username, VAR_10)\n", "return VAR_55\n" ]
[ "def create_manual_course_enrollment(user, course_id, mode, enrolled_by,...\n", "\"\"\"docstring\"\"\"\n", "enrollment_obj = CourseEnrollment.enroll(user, course_id, mode=mode)\n", "ManualEnrollmentAudit.create_manual_enrollment_audit(enrolled_by, user.\n email, state_transition, reason, enrollment_obj)\n", "log.info(u'user %s enrolled in the course %s', user.username, course_id)\n", "return enrollment_obj\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "async def FUNC_7(VAR_1, VAR_4):...\n", "async def FUNC_6(VAR_6):...\n", "VAR_7 = await VAR_4(VAR_6)\n", "VAR_11 = VAR_5.get(ex.status)\n", "return FUNC_6\n", "VAR_11 = VAR_5.get(VAR_7.status)\n", "if VAR_11 is None:\n", "if VAR_11 is None:\n", "return await FUNC_3(VAR_6, ex)\n", "return await VAR_11(VAR_6, ex)\n", "return VAR_7\n", "return await VAR_11(VAR_6, VAR_7)\n" ]
[ "async def middleware(app, handler):...\n", "async def middleware_handler(request):...\n", "response = await handler(request)\n", "override = overrides.get(ex.status)\n", "return middleware_handler\n", "override = overrides.get(response.status)\n", "if override is None:\n", "if override is None:\n", "return await handle_any(request, ex)\n", "return await override(request, ex)\n", "return response\n", "return await override(request, response)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "AsyncFunctionDef'", "Assign'", "Assign'", "Return'", "Assign'", "Condition", "Condition", "Return'", "Return'", "Return'", "Return'" ]
[ "def FUNC_27(self):...\n", "if self.file_to_run:\n", "return os.path.dirname(os.path.abspath(self.file_to_run))\n", "return py3compat.getcwd()\n" ]
[ "def _notebook_dir_default(self):...\n", "if self.file_to_run:\n", "return os.path.dirname(os.path.abspath(self.file_to_run))\n", "return py3compat.getcwd()\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_8(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_14 = self.get_success(self.store.get_event(VAR_16.event_id))\n", "self.assertObjectHasAttributes({'type': EventTypes.Message, 'user_id': self\n .u_alice.to_string(), 'content': {'body': 't', 'msgtype': 'message'}},\n VAR_14)\n", "self.assertFalse('redacted_because' in VAR_14.unsigned)\n", "VAR_10 = 'Because I said so'\n", "self.get_success(self.inject_redaction(self.room1, VAR_16.event_id, self.\n u_alice, VAR_10))\n", "VAR_14 = self.get_success(self.store.get_event(VAR_16.event_id))\n", "self.assertTrue('redacted_because' in VAR_14.unsigned)\n", "self.assertObjectHasAttributes({'type': EventTypes.Message, 'user_id': self\n .u_alice.to_string(), 'content': {}}, VAR_14)\n", "VAR_24 = self.get_success(self.store.db_pool.simple_select_one_onecol(table\n ='event_json', keyvalues={'event_id': msg_event.event_id}, retcol='json'))\n", "self.assert_dict({'content': {'body': 't', 'msgtype': 'message'}}, json.\n loads(VAR_24))\n", "self.reactor.advance(60 * 60 * 24 * 31)\n", "self.reactor.advance(60 * 60 * 2)\n", "VAR_24 = self.get_success(self.store.db_pool.simple_select_one_onecol(table\n ='event_json', keyvalues={'event_id': msg_event.event_id}, retcol='json'))\n", "self.assert_dict({'content': {}}, json.loads(VAR_24))\n" ]
[ "def test_redact_censor(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", "event = self.get_success(self.store.get_event(msg_event.event_id))\n", "self.assertObjectHasAttributes({'type': EventTypes.Message, 'user_id': self\n .u_alice.to_string(), 'content': {'body': 't', 'msgtype': 'message'}},\n event)\n", "self.assertFalse('redacted_because' in event.unsigned)\n", "reason = 'Because I said so'\n", "self.get_success(self.inject_redaction(self.room1, msg_event.event_id, self\n .u_alice, reason))\n", "event = self.get_success(self.store.get_event(msg_event.event_id))\n", "self.assertTrue('redacted_because' in event.unsigned)\n", "self.assertObjectHasAttributes({'type': EventTypes.Message, 'user_id': self\n .u_alice.to_string(), 'content': {}}, event)\n", "event_json = self.get_success(self.store.db_pool.simple_select_one_onecol(\n table='event_json', keyvalues={'event_id': msg_event.event_id}, retcol=\n 'json'))\n", "self.assert_dict({'content': {'body': 't', 'msgtype': 'message'}}, json.\n loads(event_json))\n", "self.reactor.advance(60 * 60 * 24 * 31)\n", "self.reactor.advance(60 * 60 * 2)\n", "event_json = self.get_success(self.store.db_pool.simple_select_one_onecol(\n table='event_json', keyvalues={'event_id': msg_event.event_id}, retcol=\n 'json'))\n", "self.assert_dict({'content': {}}, json.loads(event_json))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_39(VAR_16, VAR_17):...\n", "return config.set_from_dictionary(VAR_16, VAR_17, lambda y: y == 'on', False)\n" ]
[ "def _config_checkbox(to_save, x):...\n", "return config.set_from_dictionary(to_save, x, lambda y: y == 'on', False)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_12(self, VAR_13, VAR_8, **VAR_4):...\n", "self.layout.delete_cell(VAR_13, VAR_8)\n", "self.save_layout()\n" ]
[ "def dispatch_del_cell(self, x, y, **kwargs):...\n", "self.layout.delete_cell(x, y)\n", "self.save_layout()\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'" ]
[ "def FUNC_85(VAR_144, VAR_145=1):...\n", "from frappe.utils.response import json_handler\n", "return json.dumps(VAR_144, VAR_145=indent, sort_keys=True, VAR_47=\n json_handler, separators=(',', ': '))\n" ]
[ "def as_json(obj, indent=1):...\n", "from frappe.utils.response import json_handler\n", "return json.dumps(obj, indent=indent, sort_keys=True, default=json_handler,\n separators=(',', ': '))\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "Return'" ]
[ "def FUNC_153(VAR_114):...\n", "def FUNC_118(*VAR_9, **VAR_13):...\n", "VAR_431, VAR_432, VAR_141 = self.basic()\n", "VAR_141 = VAR_141 or self.user\n", "VAR_433 = VAR_145\n", "if callable(VAR_433):\n", "VAR_433 = VAR_433()\n", "if VAR_433:\n", "if not VAR_141:\n", "if callable(VAR_144):\n", "if VAR_263.request.ajax:\n", "VAR_453 = VAR_144()\n", "VAR_453 = VAR_144\n", "if VAR_90 is not None:\n", "if not VAR_453:\n", "if callable(VAR_90):\n", "if self.settings.allow_basic_login_only or VAR_432 or VAR_263.request.is_restful:\n", "VAR_263.session.flash = self.messages.access_denied\n", "return VAR_114(*VAR_9, **b)\n", "return VAR_90()\n", "redirect(VAR_90)\n", "VAR_112 = self.here()\n", "return FUNC_3(self.settings.on_failed_authorization)\n", "VAR_263.session.flash = VAR_263.response.flash\n", "return FUNC_3(self.settings.on_failed_authentication, self.settings.\n login_url + '?_next=' + urllib_quote(VAR_112))\n" ]
[ "def decorator(action):...\n", "def f(*a, **b):...\n", "basic_allowed, basic_accepted, user = self.basic()\n", "user = user or self.user\n", "login_required = requires_login\n", "if callable(login_required):\n", "login_required = login_required()\n", "if login_required:\n", "if not user:\n", "if callable(condition):\n", "if current.request.ajax:\n", "flag = condition()\n", "flag = condition\n", "if otherwise is not None:\n", "if not flag:\n", "if callable(otherwise):\n", "if self.settings.allow_basic_login_only or basic_accepted or current.request.is_restful:\n", "current.session.flash = self.messages.access_denied\n", "return action(*a, **b)\n", "return otherwise()\n", "redirect(otherwise)\n", "next = self.here()\n", "return call_or_redirect(self.settings.on_failed_authorization)\n", "current.session.flash = current.response.flash\n", "return call_or_redirect(self.settings.on_failed_authentication, self.\n settings.login_url + '?_next=' + urllib_quote(next))\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 ]
[ "FunctionDef'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Condition", "Assign'", "Return'", "Return'", "Expr'", "Assign'", "Return'", "Assign'", "Return'" ]
[ "def FUNC_29(self):...\n", "self.called = True\n" ]
[ "def to_html(self):...\n", "self.called = True\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "def FUNC_115(VAR_129):...\n", "VAR_83.append(VAR_129)\n", "VAR_86[VAR_129] = VAR_89\n", "if VAR_87:\n", "VAR_84.append(VAR_129)\n", "return VAR_129\n", "if VAR_88:\n", "VAR_85.append(VAR_129)\n" ]
[ "def innerfn(fn):...\n", "whitelisted.append(fn)\n", "allowed_http_methods_for_whitelisted_func[fn] = methods\n", "if allow_guest:\n", "guest_methods.append(fn)\n", "return fn\n", "if xss_safe:\n", "xss_safe_methods.append(fn)\n" ]
[ 0, 2, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Condition", "Expr'", "Return'", "Condition", "Expr'" ]
[ "def FUNC_22(self):...\n", "self.parser = saved_model_cli.create_parser()\n", "VAR_9 = test.test_src_dir_path(VAR_0)\n", "VAR_41 = os.path.join(test.get_temp_dir(), 'new_dir')\n", "VAR_10 = self.parser.parse_args(['run', '--dir', VAR_9, '--tag_set',\n 'serve', '--signature_def', 'regress_x_to_y', '--input_examples',\n 'inputs=[{\"x\":[8.0],\"x2\":[5.0]}, {\"x\":[4.0],\"x2\":[3.0]}]', '--outdir',\n VAR_41])\n", "saved_model_cli.run(VAR_10)\n", "VAR_42 = np.load(os.path.join(VAR_41, 'outputs.npy'))\n", "VAR_43 = np.array([[6.0], [4.0]])\n", "self.assertAllEqual(VAR_43, VAR_42)\n" ]
[ "def testRunCommandInputExamples(self):...\n", "self.parser = saved_model_cli.create_parser()\n", "base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n", "output_dir = os.path.join(test.get_temp_dir(), 'new_dir')\n", "args = self.parser.parse_args(['run', '--dir', base_path, '--tag_set',\n 'serve', '--signature_def', 'regress_x_to_y', '--input_examples',\n 'inputs=[{\"x\":[8.0],\"x2\":[5.0]}, {\"x\":[4.0],\"x2\":[3.0]}]', '--outdir',\n output_dir])\n", "saved_model_cli.run(args)\n", "y_actual = np.load(os.path.join(output_dir, 'outputs.npy'))\n", "y_expected = np.array([[6.0], [4.0]])\n", "self.assertAllEqual(y_expected, y_actual)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_12(self):...\n", "VAR_5 = {'senders': ['@flibble:wibble']}\n", "VAR_6 = FUNC_0(sender='@flibble:wibble', type='com.nom.nom.nom', room_id=\n '!foo:bar')\n", "self.assertTrue(Filter(VAR_5).check(VAR_6))\n" ]
[ "def test_definition_senders_works_with_literals(self):...\n", "definition = {'senders': ['@flibble:wibble']}\n", "event = MockEvent(sender='@flibble:wibble', type='com.nom.nom.nom', room_id\n ='!foo:bar')\n", "self.assertTrue(Filter(definition).check(event))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_54(self, VAR_14):...\n", "\"\"\"docstring\"\"\"\n", "return '<strong>%s</strong>' % VAR_14\n" ]
[ "def double_emphasis(self, text):...\n", "\"\"\"docstring\"\"\"\n", "return '<strong>%s</strong>' % text\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_15(self, VAR_24: str) ->str:...\n", "if self.hs.config.email_riot_base_url:\n", "VAR_70 = '%s/#/room' % self.hs.config.email_riot_base_url\n", "if self.app_name == 'Vector':\n", "return '%s/%s' % (VAR_70, VAR_24)\n", "VAR_70 = 'https://vector.im/beta/#/room'\n", "VAR_70 = 'https://matrix.to/#'\n" ]
[ "def make_room_link(self, room_id: str) ->str:...\n", "if self.hs.config.email_riot_base_url:\n", "base_url = '%s/#/room' % self.hs.config.email_riot_base_url\n", "if self.app_name == 'Vector':\n", "return '%s/%s' % (base_url, room_id)\n", "base_url = 'https://vector.im/beta/#/room'\n", "base_url = 'https://matrix.to/#'\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Condition", "Return'", "Assign'", "Assign'" ]
[ "async def FUNC_3(self):...\n", "VAR_17 = await push_tools.get_badge_count(self.hs.get_datastore(), self.\n user_id, group_by_room=self._group_unread_count_by_room)\n", "await self._send_badge(VAR_17)\n" ]
[ "async def _update_badge(self):...\n", "badge = await push_tools.get_badge_count(self.hs.get_datastore(), self.\n user_id, group_by_room=self._group_unread_count_by_room)\n", "await self._send_badge(badge)\n" ]
[ 0, 0, 0 ]
[ "AsyncFunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_114(self, VAR_137='1.1'):...\n", "" ]
[ "def serve_soap(self, version='1.1'):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_68():...\n", "VAR_54 = []\n", "if VAR_136['grabData'] and VAR_136['ctx'] == 'imgs':\n", "VAR_284 = min(VAR_136['start'], len(VAR_283) - 1)\n", "return [VAR_30.simpleMarshal(VAR_121=xtra, parents=opts['parents']) for\n VAR_30 in VAR_283]\n", "if VAR_136['limit'] == 0:\n", "VAR_317 = len(VAR_283)\n", "VAR_317 = min(len(VAR_283), VAR_284 + VAR_136['limit'])\n", "for VAR_212 in range(VAR_284, VAR_317):\n", "VAR_318 = VAR_283[VAR_212]\n", "return VAR_54\n", "VAR_54.append(FUNC_23(VAR_2, VAR_19, VAR_6=e.id, VAR_79=opts['key'], VAR_8=\n conn, VAR_31=True))\n", "VAR_1.debug('(iid %i) ignoring Attribute Error: %s' % (VAR_318.id, str(VAR_30))\n )\n", "VAR_1.debug('(iid %i) ignoring Server Error: %s' % (VAR_318.id, str(VAR_30)))\n" ]
[ "def marshal():...\n", "rv = []\n", "if opts['grabData'] and opts['ctx'] == 'imgs':\n", "bottom = min(opts['start'], len(sr) - 1)\n", "return [x.simpleMarshal(xtra=xtra, parents=opts['parents']) for x in sr]\n", "if opts['limit'] == 0:\n", "top = len(sr)\n", "top = min(len(sr), bottom + opts['limit'])\n", "for i in range(bottom, top):\n", "e = sr[i]\n", "return rv\n", "rv.append(imageData_json(request, server_id, iid=e.id, key=opts['key'],\n conn=conn, _internal=True))\n", "logger.debug('(iid %i) ignoring Attribute Error: %s' % (e.id, str(x)))\n", "logger.debug('(iid %i) ignoring Server Error: %s' % (e.id, str(x)))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Assign'", "For", "Assign'", "Return'", "Expr'", "Expr'", "Expr'" ]
[ "@VAR_2.route('/admin/ajaxconfig', methods=['POST'])...\n", "return FUNC_49()\n" ]
[ "@admi.route('/admin/ajaxconfig', methods=['POST'])...\n", "return _configuration_update_helper()\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_1(VAR_3, VAR_4='EDIT', VAR_5=None, VAR_6=0):...\n", "VAR_20 = os.path.join(apath(VAR_3, VAR_122=request), 'progress.log')\n", "VAR_21 = str(request.now)[:19]\n", "if not os.path.exists(VAR_20):\n", "FUNC_2(VAR_20, 'w').write('[%s] START\\n' % VAR_21)\n", "if VAR_5:\n", "FUNC_2(VAR_20, 'a').write('[%s] %s %s: %s\\n' % (VAR_21, VAR_4, VAR_5, VAR_6))\n" ]
[ "def log_progress(app, mode='EDIT', filename=None, progress=0):...\n", "progress_file = os.path.join(apath(app, r=request), 'progress.log')\n", "now = str(request.now)[:19]\n", "if not os.path.exists(progress_file):\n", "safe_open(progress_file, 'w').write('[%s] START\\n' % now)\n", "if filename:\n", "safe_open(progress_file, 'a').write('[%s] %s %s: %s\\n' % (now, mode,\n filename, progress))\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Expr'" ]
[ "def FUNC_28(VAR_10, VAR_11):...\n", "VAR_69 = VAR_11()\n", "if VAR_10['Element'] in VAR_69:\n", "VAR_69.remove(VAR_10['Element'])\n", "return ','.join(VAR_69)\n" ]
[ "def restriction_deletion(element, list_func):...\n", "elementlist = list_func()\n", "if element['Element'] in elementlist:\n", "elementlist.remove(element['Element'])\n", "return ','.join(elementlist)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_4(VAR_7, VAR_6, VAR_8=False, VAR_9='', VAR_10=False):...\n", "\"\"\"docstring\"\"\"\n", "if salt.utils.is_windows():\n", "return FUNC_14(VAR_7, VAR_8, VAR_9, VAR_10)\n", "import pwd\n", "VAR_38 = pwd.getpwnam(VAR_6)\n", "VAR_49 = (\n 'Failed to prepare the Salt environment for user {0}. The user is not available.\\n'\n .format(VAR_6))\n", "for dir_ in VAR_7:\n", "VAR_39 = VAR_38[2]\n", "sys.stderr.write(VAR_49)\n", "if not dir_:\n", "if VAR_10 is False:\n", "VAR_42 = VAR_38[3]\n", "sys.exit(salt.defaults.exitcodes.EX_NOUSER)\n", "if not VAR_54.path.isdir(dir_):\n", "FUNC_0()\n", "VAR_43 = salt.utils.get_gid_list(VAR_6, include_default=False)\n", "VAR_44 = VAR_54.stat(dir_)\n", "VAR_52 = VAR_54.umask(18)\n", "VAR_32 = 'Failed to create directory path \"{0}\" - {1}\\n'\n", "if VAR_54.getuid() == 0:\n", "VAR_54.makedirs(dir_)\n", "sys.stderr.write(VAR_32.format(dir_, VAR_49))\n", "VAR_50 = VAR_54.stat(dir_)\n", "if dir_ == VAR_9:\n", "if VAR_54.getuid() == 0:\n", "sys.exit(VAR_49.errno)\n", "if VAR_50.st_uid != VAR_39 or VAR_50.st_gid != VAR_42:\n", "VAR_51 = stat.S_IMODE(VAR_44.st_mode)\n", "VAR_54.chown(dir_, VAR_39, VAR_42)\n", "VAR_54.umask(VAR_52)\n", "if VAR_8 and VAR_50.st_gid in VAR_43:\n", "for VAR_15 in [a for a in VAR_54.listdir(dir_) if 'jobs' not in a]:\n", "if VAR_51 != 448 and VAR_51 != 488:\n", "VAR_54.chown(dir_, VAR_39, VAR_42)\n", "VAR_53 = VAR_54.path.join(dir_, VAR_15)\n", "if VAR_54.access(dir_, VAR_54.W_OK):\n", "if '{0}jobs'.format(VAR_54.path.sep) in VAR_53:\n", "VAR_54.chmod(dir_, 448)\n", "VAR_32 = 'Unable to securely set the permissions of \"{0}\".'\n", "for VAR_14, VAR_7, VAR_5 in VAR_54.walk(VAR_53):\n", "VAR_32 = VAR_32.format(dir_)\n", "for name in VAR_5:\n", "if is_console_configured():\n", "if name.startswith('.'):\n", "for name in VAR_7:\n", "VAR_0.critical(VAR_32)\n", "sys.stderr.write('CRITICAL: {0}\\n'.format(VAR_32))\n", "VAR_11 = VAR_54.path.join(VAR_14, name)\n", "VAR_11 = VAR_54.path.join(VAR_14, name)\n", "VAR_50 = VAR_54.stat(VAR_11)\n", "if VAR_50.st_uid != VAR_39 or VAR_50.st_gid != VAR_42:\n", "VAR_50 = VAR_54.stat(VAR_11)\n", "if VAR_8 and VAR_50.st_gid in VAR_43:\n", "if VAR_50.st_uid != VAR_39 or VAR_50.st_gid != VAR_42:\n", "VAR_54.chown(VAR_11, VAR_39, VAR_42)\n", "if VAR_8 and VAR_50.st_gid in VAR_43:\n", "VAR_54.chown(VAR_11, VAR_39, VAR_42)\n" ]
[ "def verify_env(dirs, user, permissive=False, pki_dir='', skip_extra=False):...\n", "\"\"\"docstring\"\"\"\n", "if salt.utils.is_windows():\n", "return win_verify_env(dirs, permissive, pki_dir, skip_extra)\n", "import pwd\n", "pwnam = pwd.getpwnam(user)\n", "err = (\n 'Failed to prepare the Salt environment for user {0}. The user is not available.\\n'\n .format(user))\n", "for dir_ in dirs:\n", "uid = pwnam[2]\n", "sys.stderr.write(err)\n", "if not dir_:\n", "if skip_extra is False:\n", "gid = pwnam[3]\n", "sys.exit(salt.defaults.exitcodes.EX_NOUSER)\n", "if not os.path.isdir(dir_):\n", "zmq_version()\n", "groups = salt.utils.get_gid_list(user, include_default=False)\n", "mode = os.stat(dir_)\n", "cumask = os.umask(18)\n", "msg = 'Failed to create directory path \"{0}\" - {1}\\n'\n", "if os.getuid() == 0:\n", "os.makedirs(dir_)\n", "sys.stderr.write(msg.format(dir_, err))\n", "fmode = os.stat(dir_)\n", "if dir_ == pki_dir:\n", "if os.getuid() == 0:\n", "sys.exit(err.errno)\n", "if fmode.st_uid != uid or fmode.st_gid != gid:\n", "smode = stat.S_IMODE(mode.st_mode)\n", "os.chown(dir_, uid, gid)\n", "os.umask(cumask)\n", "if permissive and fmode.st_gid in groups:\n", "for subdir in [a for a in os.listdir(dir_) if 'jobs' not in a]:\n", "if smode != 448 and smode != 488:\n", "os.chown(dir_, uid, gid)\n", "fsubdir = os.path.join(dir_, subdir)\n", "if os.access(dir_, os.W_OK):\n", "if '{0}jobs'.format(os.path.sep) in fsubdir:\n", "os.chmod(dir_, 448)\n", "msg = 'Unable to securely set the permissions of \"{0}\".'\n", "for root, dirs, files in os.walk(fsubdir):\n", "msg = msg.format(dir_)\n", "for name in files:\n", "if is_console_configured():\n", "if name.startswith('.'):\n", "for name in dirs:\n", "log.critical(msg)\n", "sys.stderr.write('CRITICAL: {0}\\n'.format(msg))\n", "path = os.path.join(root, name)\n", "path = os.path.join(root, name)\n", "fmode = os.stat(path)\n", "if fmode.st_uid != uid or fmode.st_gid != gid:\n", "fmode = os.stat(path)\n", "if permissive and fmode.st_gid in groups:\n", "if fmode.st_uid != uid or fmode.st_gid != gid:\n", "os.chown(path, uid, gid)\n", "if permissive and fmode.st_gid in groups:\n", "os.chown(path, uid, gid)\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 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Import'", "Assign'", "Assign'", "For", "Assign'", "Expr'", "Condition", "Condition", "Assign'", "Expr'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Assign'", "Condition", "Condition", "Expr'", "Condition", "Assign'", "Expr'", "Expr'", "Condition", "For", "Condition", "Expr'", "Assign'", "Condition", "For", "Expr'", "Assign'", "For", "Assign'", "For", "Condition", "Condition", "For", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Expr'", "Condition", "Expr'" ]
[ "def FUNC_5():...\n", "yield FUNC_2(VAR_4)\n", "yield from FUNC_1(VAR_2, VAR_3)\n", "yield f\"\"\"\nERROR: Got exception when reading output from script: {type(e)}\n\"\"\"\n", "yield traceback.format_exc()\n" ]
[ "def _generate_output():...\n", "yield _create_cmd_header(commands)\n", "yield from _run_script_and_generate_stream(req_to_args, cmd)\n", "yield f\"\"\"\nERROR: Got exception when reading output from script: {type(e)}\n\"\"\"\n", "yield traceback.format_exc()\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "@VAR_0.route('/run/<int:qrun_id>/meta')...\n", "VAR_27 = g.conn.session.query(QueryRun).get(VAR_7)\n", "if not VAR_27:\n", "return Response('No such query run id', status=404)\n", "return Response(json.dumps({'run': VAR_27, 'rev': VAR_27.rev, 'query':\n VAR_27.rev.query}, default=json_formatter), mimetype='application/json',\n headers={'Access-Control-Allow-Origin': '*'})\n" ]
[ "@app.route('/run/<int:qrun_id>/meta')...\n", "qrun = g.conn.session.query(QueryRun).get(qrun_id)\n", "if not qrun:\n", "return Response('No such query run id', status=404)\n", "return Response(json.dumps({'run': qrun, 'rev': qrun.rev, 'query': qrun.rev\n .query}, default=json_formatter), mimetype='application/json', headers=\n {'Access-Control-Allow-Origin': '*'})\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_68(self, VAR_42=None):...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_42:\n", "VAR_42 = frappe.session.user\n", "if hasattr(self.meta, 'track_views') and self.meta.track_views:\n", "frappe.get_doc({'doctype': 'View Log', 'viewed_by': frappe.session.user,\n 'reference_doctype': self.doctype, 'reference_name': self.name}).insert(\n VAR_11=True)\n", "frappe.local.flags.commit = True\n" ]
[ "def add_viewed(self, user=None):...\n", "\"\"\"docstring\"\"\"\n", "if not user:\n", "user = frappe.session.user\n", "if hasattr(self.meta, 'track_views') and self.meta.track_views:\n", "frappe.get_doc({'doctype': 'View Log', 'viewed_by': frappe.session.user,\n 'reference_doctype': self.doctype, 'reference_name': self.name}).insert(\n ignore_permissions=True)\n", "frappe.local.flags.commit = True\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Expr'", "Assign'" ]
[ "def FUNC_5(self):...\n", "\"\"\"docstring\"\"\"\n", "self.streamer.on_notifier_poke()\n", "self.pump()\n" ]
[ "def replicate(self):...\n", "\"\"\"docstring\"\"\"\n", "self.streamer.on_notifier_poke()\n", "self.pump()\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Expr'" ]
[ "def FUNC_47(VAR_136, VAR_38):...\n", "" ]
[ "def f(x, k):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_5(VAR_7: Any, VAR_8: Text='', VAR_9: Text='w+') ->Text:...\n", "\"\"\"docstring\"\"\"\n", "VAR_17 = None if 'b' in VAR_9 else rasa.shared.utils.io.DEFAULT_ENCODING\n", "VAR_18 = tempfile.NamedTemporaryFile(VAR_9=mode, VAR_8=suffix, delete=False,\n VAR_17=encoding)\n", "VAR_18.write(VAR_7)\n", "VAR_18.close()\n", "return VAR_18.name\n" ]
[ "def create_temporary_file(data: Any, suffix: Text='', mode: Text='w+') ->Text:...\n", "\"\"\"docstring\"\"\"\n", "encoding = None if 'b' in mode else rasa.shared.utils.io.DEFAULT_ENCODING\n", "f = tempfile.NamedTemporaryFile(mode=mode, suffix=suffix, delete=False,\n encoding=encoding)\n", "f.write(data)\n", "f.close()\n", "return f.name\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_118():...\n", "VAR_14 = CLASS_6()\n", "VAR_194.acquire()\n", "VAR_195.acquire()\n", "VAR_14.x = 7\n", "VAR_194.release()\n", "VAR_195.release()\n" ]
[ "def f():...\n", "c = PluginManager()\n", "lock1.acquire()\n", "lock2.acquire()\n", "c.x = 7\n", "lock1.release()\n", "lock2.release()\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_47(VAR_136, VAR_38):...\n", "" ]
[ "def f(x, k):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_13():...\n", "yield '<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\\n'\n", "if VAR_1:\n", "yield '<?xml-stylesheet type=\"text/xsl\" href=\"/scopelist.xsl\" ?>\\n'\n", "yield '<objectlist count=\"{:d}\">\\n'.format(VAR_43)\n", "VAR_44 = 0\n", "VAR_45 = 0\n", "if VAR_27:\n", "VAR_44 = int(VAR_25 * VAR_5)\n", "VAR_46 = []\n", "VAR_49 = cycle(VAR_17)\n", "def FUNC_15():...\n", "random.seed(VAR_24)\n", "return list(map(lambda x: x + VAR_5 * VAR_45, sorted(random.sample(list(\n range(VAR_5)), VAR_44))))\n" ]
[ "def generate():...\n", "yield '<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\\n'\n", "if STYLE:\n", "yield '<?xml-stylesheet type=\"text/xsl\" href=\"/scopelist.xsl\" ?>\\n'\n", "yield '<objectlist count=\"{:d}\">\\n'.format(total_entries)\n", "mix_per_iteration = 0\n", "iteration_count = 0\n", "if make_cocktail:\n", "mix_per_iteration = int(percentage * ITEMS_PER_ITERATION)\n", "mix_indices = []\n", "pool = cycle(mixer_list)\n", "def generate_mix_indices():...\n", "random.seed(seed)\n", "return list(map(lambda x: x + ITEMS_PER_ITERATION * iteration_count, sorted\n (random.sample(list(range(ITEMS_PER_ITERATION)), mix_per_iteration))))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Condition", "Expr'", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Expr'", "Return'" ]
[ "@VAR_2.route('/get_matching_tags', methods=['GET'])...\n", "VAR_60 = {'tags': []}\n", "VAR_21 = calibre_db.session.query(db.Books).filter(calibre_db.\n common_filters(True))\n", "calibre_db.session.connection().connection.connection.create_function('lower',\n 1, db.lcase)\n", "VAR_61 = request.args.get('author_name') or ''\n", "VAR_62 = request.args.get('book_title') or ''\n", "VAR_29 = request.args.getlist('include_tag') or ''\n", "VAR_30 = request.args.getlist('exclude_tag') or ''\n", "VAR_21 = VAR_21.filter(db.Books.authors.any(func.lower(db.Authors.name).\n ilike('%' + VAR_61 + '%')), func.lower(db.Books.title).ilike('%' +\n VAR_62 + '%'))\n", "if len(VAR_29) > 0:\n", "for tag in VAR_29:\n", "if len(VAR_30) > 0:\n", "VAR_21 = VAR_21.filter(db.Books.tags.any(db.Tags.id == tag))\n", "for tag in VAR_30:\n", "for VAR_95 in VAR_21:\n", "VAR_21 = VAR_21.filter(not_(db.Books.tags.any(db.Tags.id == tag)))\n", "for tag in VAR_95.tags:\n", "VAR_59 = json.dumps(VAR_60)\n", "if tag.id not in VAR_60['tags']:\n", "return VAR_59\n", "VAR_60['tags'].append(tag.id)\n" ]
[ "@web.route('/get_matching_tags', methods=['GET'])...\n", "tag_dict = {'tags': []}\n", "q = calibre_db.session.query(db.Books).filter(calibre_db.common_filters(True))\n", "calibre_db.session.connection().connection.connection.create_function('lower',\n 1, db.lcase)\n", "author_input = request.args.get('author_name') or ''\n", "title_input = request.args.get('book_title') or ''\n", "include_tag_inputs = request.args.getlist('include_tag') or ''\n", "exclude_tag_inputs = request.args.getlist('exclude_tag') or ''\n", "q = q.filter(db.Books.authors.any(func.lower(db.Authors.name).ilike('%' +\n author_input + '%')), func.lower(db.Books.title).ilike('%' +\n title_input + '%'))\n", "if len(include_tag_inputs) > 0:\n", "for tag in include_tag_inputs:\n", "if len(exclude_tag_inputs) > 0:\n", "q = q.filter(db.Books.tags.any(db.Tags.id == tag))\n", "for tag in exclude_tag_inputs:\n", "for book in q:\n", "q = q.filter(not_(db.Books.tags.any(db.Tags.id == tag)))\n", "for tag in book.tags:\n", "json_dumps = json.dumps(tag_dict)\n", "if tag.id not in tag_dict['tags']:\n", "return json_dumps\n", "tag_dict['tags'].append(tag.id)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "For", "Condition", "Assign'", "For", "For", "Assign'", "For", "Assign'", "Condition", "Return'", "Expr'" ]
[ "@classmethod...\n", "\"\"\"docstring\"\"\"\n", "VAR_65 = VAR_15()\n", "VAR_67 = VAR_42.parse_args(VAR_40)\n", "VAR_8 = FUNC_4(VAR_9=config_args.config_path)\n", "if not VAR_8:\n", "VAR_42.error('Must supply a config file.')\n", "if VAR_67.keys_directory:\n", "VAR_29 = VAR_67.keys_directory\n", "VAR_29 = os.path.dirname(VAR_8[-1])\n", "VAR_29 = os.path.abspath(VAR_29)\n", "VAR_30 = os.getcwd()\n", "VAR_43 = FUNC_3(VAR_8)\n", "VAR_65.parse_config_dict(VAR_43, VAR_29=config_dir_path, VAR_30=data_dir_path)\n", "VAR_65.invoke_all('read_arguments', VAR_67)\n", "return VAR_65, VAR_67\n" ]
[ "@classmethod...\n", "\"\"\"docstring\"\"\"\n", "obj = cls()\n", "config_args = parser.parse_args(argv)\n", "config_files = find_config_files(search_paths=config_args.config_path)\n", "if not config_files:\n", "parser.error('Must supply a config file.')\n", "if config_args.keys_directory:\n", "config_dir_path = config_args.keys_directory\n", "config_dir_path = os.path.dirname(config_files[-1])\n", "config_dir_path = os.path.abspath(config_dir_path)\n", "data_dir_path = os.getcwd()\n", "config_dict = read_config_files(config_files)\n", "obj.parse_config_dict(config_dict, config_dir_path=config_dir_path,\n data_dir_path=data_dir_path)\n", "obj.invoke_all('read_arguments', config_args)\n", "return obj, config_args\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_0(VAR_11, VAR_12='/'):...\n", "\"\"\"docstring\"\"\"\n", "return force_text(urllib_parse.quote(force_str(VAR_11), force_str(VAR_12)))\n" ]
[ "def urlquote(url, safe='/'):...\n", "\"\"\"docstring\"\"\"\n", "return force_text(urllib_parse.quote(force_str(url), force_str(safe)))\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_32(self):...\n", "\"\"\"docstring\"\"\"\n", "self.tornado_settings['allow_origin'] = self.allow_origin\n", "if self.allow_origin_pat:\n", "self.tornado_settings['allow_origin_pat'] = re.compile(self.allow_origin_pat)\n", "self.tornado_settings['allow_credentials'] = self.allow_credentials\n", "if not self.default_url.startswith(self.base_url):\n", "self.default_url = url_path_join(self.base_url, self.default_url)\n", "self.web_app = CLASS_1(self, self.kernel_manager, self.contents_manager,\n self.session_manager, self.kernel_spec_manager, self.config_manager,\n self.log, self.base_url, self.default_url, self.tornado_settings, self.\n jinja_environment_options)\n", "VAR_52 = self.ssl_options\n", "if self.certfile:\n", "VAR_52['certfile'] = self.certfile\n", "if self.keyfile:\n", "VAR_52['keyfile'] = self.keyfile\n", "if not VAR_52:\n", "VAR_52 = None\n", "VAR_52['ssl_version'] = ssl.PROTOCOL_TLSv1\n", "self.login_handler_class.validate_security(self, VAR_52=ssl_options)\n", "self.http_server = httpserver.HTTPServer(self.web_app, VAR_52=ssl_options,\n xheaders=self.trust_xheaders)\n", "VAR_90 = None\n", "for VAR_2 in FUNC_0(self.port, self.port_retries + 1):\n", "if not VAR_90:\n", "self.http_server.listen(VAR_2, self.ip)\n", "if e.errno == errno.EADDRINUSE:\n", "self.port = VAR_2\n", "self.log.critical(\n 'ERROR: the notebook server could not be started because no available port could be found.'\n )\n", "self.log.info('The port %i is already in use, trying another random port.' %\n VAR_2)\n", "if e.errno in (errno.EACCES, getattr(errno, 'WSAEACCES', errno.EACCES)):\n", "VAR_90 = True\n", "self.exit(1)\n", "self.log.warn('Permission to listen on port %i denied' % VAR_2)\n" ]
[ "def init_webapp(self):...\n", "\"\"\"docstring\"\"\"\n", "self.tornado_settings['allow_origin'] = self.allow_origin\n", "if self.allow_origin_pat:\n", "self.tornado_settings['allow_origin_pat'] = re.compile(self.allow_origin_pat)\n", "self.tornado_settings['allow_credentials'] = self.allow_credentials\n", "if not self.default_url.startswith(self.base_url):\n", "self.default_url = url_path_join(self.base_url, self.default_url)\n", "self.web_app = NotebookWebApplication(self, self.kernel_manager, self.\n contents_manager, self.session_manager, self.kernel_spec_manager, self.\n config_manager, self.log, self.base_url, self.default_url, self.\n tornado_settings, self.jinja_environment_options)\n", "ssl_options = self.ssl_options\n", "if self.certfile:\n", "ssl_options['certfile'] = self.certfile\n", "if self.keyfile:\n", "ssl_options['keyfile'] = self.keyfile\n", "if not ssl_options:\n", "ssl_options = None\n", "ssl_options['ssl_version'] = ssl.PROTOCOL_TLSv1\n", "self.login_handler_class.validate_security(self, ssl_options=ssl_options)\n", "self.http_server = httpserver.HTTPServer(self.web_app, ssl_options=\n ssl_options, xheaders=self.trust_xheaders)\n", "success = None\n", "for port in random_ports(self.port, self.port_retries + 1):\n", "if not success:\n", "self.http_server.listen(port, self.ip)\n", "if e.errno == errno.EADDRINUSE:\n", "self.port = port\n", "self.log.critical(\n 'ERROR: the notebook server could not be started because no available port could be found.'\n )\n", "self.log.info('The port %i is already in use, trying another random port.' %\n port)\n", "if e.errno in (errno.EACCES, getattr(errno, 'WSAEACCES', errno.EACCES)):\n", "success = True\n", "self.exit(1)\n", "self.log.warn('Permission to listen on port %i denied' % port)\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", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "For", "Condition", "Expr'", "Condition", "Assign'", "Expr'", "Expr'", "Condition", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_32(VAR_87):...\n", "VAR_86.update(to_bytes(VAR_87, encoding='utf-8', errors='replace'))\n" ]
[ "def hash_update(value):...\n", "hash.update(to_bytes(value, encoding='utf-8', errors='replace'))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_0(VAR_1, VAR_2, *VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "return VAR_1 + VAR_2 % tuple(urllib.parse.quote(arg, '') for arg in VAR_3)\n" ]
[ "def _create_path(federation_prefix, path, *args):...\n", "\"\"\"docstring\"\"\"\n", "return federation_prefix + path % tuple(urllib.parse.quote(arg, '') for arg in\n args)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_119(VAR_174):...\n", "for df in VAR_174.meta.get('fields', {'no_copy': 1}):\n", "if hasattr(VAR_174, df.fieldname):\n", "VAR_174.set(df.fieldname, None)\n" ]
[ "def remove_no_copy_fields(d):...\n", "for df in d.meta.get('fields', {'no_copy': 1}):\n", "if hasattr(d, df.fieldname):\n", "d.set(df.fieldname, None)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Condition", "Expr'" ]
[ "def FUNC_0(VAR_2):...\n", "if not VAR_2.is_public and not VAR_2.user_id == int(current_user.id):\n", "VAR_1.error('User %s not allowed to edit shelf %s', current_user, VAR_2)\n", "if VAR_2.is_public and not current_user.role_edit_shelfs():\n", "return False\n", "VAR_1.info('User %s not allowed to edit public shelves', current_user)\n", "return True\n", "return False\n" ]
[ "def check_shelf_edit_permissions(cur_shelf):...\n", "if not cur_shelf.is_public and not cur_shelf.user_id == int(current_user.id):\n", "log.error('User %s not allowed to edit shelf %s', current_user, cur_shelf)\n", "if cur_shelf.is_public and not current_user.role_edit_shelfs():\n", "return False\n", "log.info('User %s not allowed to edit public shelves', current_user)\n", "return True\n", "return False\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Condition", "Return'", "Expr'", "Return'", "Return'" ]
[ "import json\n", "from django.contrib.auth.decorators import login_required\n", "from django.shortcuts import render, redirect, get_object_or_404\n", "from django.views.decorators.http import require_POST\n", "from django.http import Http404, HttpResponse\n", "from django.contrib import messages\n", "from django.utils.html import escape\n", "from django.urls import reverse\n", "from djconfig import config\n", "from infinite_scroll_pagination.serializers import to_page_key\n", "from spirit.core.conf import settings\n", "from spirit.core import utils\n", "from spirit.core.utils.paginator import yt_paginate\n", "from spirit.core.utils.paginator.infinite_paginator import paginate\n", "from spirit.core.utils.views import is_ajax\n", "from spirit.topic.models import Topic\n", "from .models import TopicNotification\n", "from .forms import NotificationForm, NotificationCreationForm\n", "@require_POST...\n", "VAR_3 = get_object_or_404(Topic.objects.for_access(VAR_0.user), VAR_2=topic_id)\n", "VAR_4 = NotificationCreationForm(user=request.user, VAR_3=topic, data=\n request.POST)\n", "if VAR_4.is_valid():\n", "VAR_4.save()\n", "messages.error(VAR_0, utils.render_form_errors(VAR_4))\n", "return redirect(VAR_0.POST.get('next', VAR_3.get_absolute_url()))\n" ]
[ "import json\n", "from django.contrib.auth.decorators import login_required\n", "from django.shortcuts import render, redirect, get_object_or_404\n", "from django.views.decorators.http import require_POST\n", "from django.http import Http404, HttpResponse\n", "from django.contrib import messages\n", "from django.utils.html import escape\n", "from django.urls import reverse\n", "from djconfig import config\n", "from infinite_scroll_pagination.serializers import to_page_key\n", "from spirit.core.conf import settings\n", "from spirit.core import utils\n", "from spirit.core.utils.paginator import yt_paginate\n", "from spirit.core.utils.paginator.infinite_paginator import paginate\n", "from spirit.core.utils.views import is_ajax\n", "from spirit.topic.models import Topic\n", "from .models import TopicNotification\n", "from .forms import NotificationForm, NotificationCreationForm\n", "@require_POST...\n", "topic = get_object_or_404(Topic.objects.for_access(request.user), pk=topic_id)\n", "form = NotificationCreationForm(user=request.user, topic=topic, data=\n request.POST)\n", "if form.is_valid():\n", "form.save()\n", "messages.error(request, utils.render_form_errors(form))\n", "return redirect(request.POST.get('next', topic.get_absolute_url()))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 ]
[ "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Return'" ]
[ "async def FUNC_8(self, VAR_23: str, VAR_16: Optional[Mapping[str, Union[str,...\n", "\"\"\"docstring\"\"\"\n", "VAR_0.debug('post_urlencoded_get_json args: %s', VAR_16)\n", "VAR_45 = FUNC_4(VAR_16)\n", "VAR_46 = {b'Content-Type': [b'application/x-www-form-urlencoded'],\n b'User-Agent': [self.user_agent], b'Accept': [b'application/json']}\n", "if VAR_24:\n", "VAR_46.update(VAR_24)\n", "VAR_13 = await self.request('POST', VAR_23, VAR_24=Headers(actual_headers),\n VAR_30=query_bytes)\n", "VAR_47 = await make_deferred_yieldable(readBody(VAR_13))\n", "if 200 <= VAR_13.code < 300:\n", "return json_decoder.decode(VAR_47.decode('utf-8'))\n" ]
[ "async def post_urlencoded_get_json(self, uri: str, args: Optional[Mapping[...\n", "\"\"\"docstring\"\"\"\n", "logger.debug('post_urlencoded_get_json args: %s', args)\n", "query_bytes = encode_query_args(args)\n", "actual_headers = {b'Content-Type': [b'application/x-www-form-urlencoded'],\n b'User-Agent': [self.user_agent], b'Accept': [b'application/json']}\n", "if headers:\n", "actual_headers.update(headers)\n", "response = await self.request('POST', uri, headers=Headers(actual_headers),\n data=query_bytes)\n", "body = await make_deferred_yieldable(readBody(response))\n", "if 200 <= response.code < 300:\n", "return json_decoder.decode(body.decode('utf-8'))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Expr'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_22(self):...\n", "if self.docstatus == None:\n", "self.docstatus = 0\n", "for VAR_21 in self.get_all_children():\n", "VAR_21.docstatus = self.docstatus\n" ]
[ "def set_docstatus(self):...\n", "if self.docstatus == None:\n", "self.docstatus = 0\n", "for d in self.get_all_children():\n", "d.docstatus = self.docstatus\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "For", "Assign'" ]
[ "@FUNC_0...\n", "return SyncHandler(self)\n" ]
[ "@cache_in_self...\n", "return SyncHandler(self)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_9(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = self._make_request(b'OPTIONS', b'/res/')\n", "self.assertEqual(VAR_6.result['code'], b'204')\n", "self.assertNotIn('body', VAR_6.result)\n", "self.assertTrue(VAR_6.headers.hasHeader(b'Access-Control-Allow-Origin'),\n 'has CORS Origin header')\n", "self.assertTrue(VAR_6.headers.hasHeader(b'Access-Control-Allow-Methods'),\n 'has CORS Methods header')\n", "self.assertTrue(VAR_6.headers.hasHeader(b'Access-Control-Allow-Headers'),\n 'has CORS Headers header')\n" ]
[ "def test_known_options_request(self):...\n", "\"\"\"docstring\"\"\"\n", "channel = self._make_request(b'OPTIONS', b'/res/')\n", "self.assertEqual(channel.result['code'], b'204')\n", "self.assertNotIn('body', channel.result)\n", "self.assertTrue(channel.headers.hasHeader(b'Access-Control-Allow-Origin'),\n 'has CORS Origin header')\n", "self.assertTrue(channel.headers.hasHeader(b'Access-Control-Allow-Methods'),\n 'has CORS Methods header')\n", "self.assertTrue(channel.headers.hasHeader(b'Access-Control-Allow-Headers'),\n 'has CORS Headers header')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_19(VAR_5):...\n", "if VAR_5 != '0':\n", "if not calibre_db.session.query(db.Custom_Columns).filter(db.Custom_Columns\n", "return True\n", "return False\n" ]
[ "def check_valid_restricted_column(column):...\n", "if column != '0':\n", "if not calibre_db.session.query(db.Custom_Columns).filter(db.Custom_Columns\n", "return True\n", "return False\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Return'", "Return'" ]
[ "def FUNC_38(self):...\n", "if self.project != self.cleaned_data['project']:\n", "return self.cleaned_data['project']\n" ]
[ "def clean_project(self):...\n", "if self.project != self.cleaned_data['project']:\n", "return self.cleaned_data['project']\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'" ]
[ "@staticmethod...\n", "if VAR_10.startswith('/private/'):\n", "VAR_10 = VAR_10[8:]\n", "return 'private' in VAR_10 or VAR_10.startswith('.') or VAR_10.endswith('~')\n" ]
[ "@staticmethod...\n", "if f.startswith('/private/'):\n", "f = f[8:]\n", "return 'private' in f or f.startswith('.') or f.endswith('~')\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Condition", "Assign'", "Return'" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "return FUNC_6(VAR_2, VAR_6, VAR_10=size, **kwargs)\n" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "return render_thumbnail(request, iid, w=size, **kwargs)\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def FUNC_27(self, VAR_44):...\n", "VAR_14 = VAR_44.group(1)\n", "return self.renderer.escape(VAR_14)\n" ]
[ "def output_escape(self, m):...\n", "text = m.group(1)\n", "return self.renderer.escape(text)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_14(self):...\n", "return self.cleaned_data['q']\n" ]
[ "def get_search_query(self):...\n", "return self.cleaned_data['q']\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_8(self):...\n", "VAR_5 = self.get_credits('json')\n", "self.assertEqual(VAR_5.status_code, 200)\n", "self.assertJSONEqual(VAR_5.content.decode(), [{'Czech': [[\n 'weblate@example.org', 'Weblate Test', 1]]}])\n" ]
[ "def test_credits_view_json(self):...\n", "response = self.get_credits('json')\n", "self.assertEqual(response.status_code, 200)\n", "self.assertJSONEqual(response.content.decode(), [{'Czech': [[\n 'weblate@example.org', 'Weblate Test', 1]]}])\n" ]
[ 0, 0, 0, 2 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_2(VAR_4, *VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "@defer.inlineCallbacks...\n", "VAR_50 = yield VAR_4.verify_json_for_server(*VAR_2)\n", "return VAR_50\n" ]
[ "def _verify_json_for_server(kr, *args):...\n", "\"\"\"docstring\"\"\"\n", "@defer.inlineCallbacks...\n", "rv1 = yield kr.verify_json_for_server(*args)\n", "return rv1\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Return'" ]
[ "@transaction.non_atomic_requests...\n", "\"\"\"docstring\"\"\"\n", "VAR_38 = SlashSeparatedCourseKey.from_deprecated_string(VAR_10)\n", "instructor_task.api.submit_executive_summary_report(VAR_9, VAR_38)\n", "VAR_178 = _('string')\n", "return JsonResponse({'status': VAR_178})\n", "VAR_178 = _('string')\n" ]
[ "@transaction.non_atomic_requests...\n", "\"\"\"docstring\"\"\"\n", "course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n", "instructor_task.api.submit_executive_summary_report(request, course_key)\n", "status_response = _(\n 'The executive summary report is currently being created. To view the status of the report, see Pending Tasks below. You will be able to download the report when it is complete.'\n )\n", "return JsonResponse({'status': status_response})\n", "status_response = _(\n 'The executive summary report is being created. To view the status of the report, see Pending Tasks below.'\n )\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Expr'", "Assign'", "Return'", "Assign'" ]
[ "def FUNC_18(self, VAR_2, VAR_22, *VAR_23, **VAR_24):...\n", "\"\"\"docstring\"\"\"\n" ]
[ "def prepare_context(self, request, context, *args, **kwargs):...\n", "\"\"\"docstring\"\"\"\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Docstring" ]
[ "def FUNC_28(VAR_0, VAR_1):...\n", "VAR_8 = VAR_1.get('/config')\n", "assert VAR_8.status_code == 200\n", "assert b'Edit Config' in VAR_8.data\n" ]
[ "def test_get_config_page(test_app, client):...\n", "resp = client.get('/config')\n", "assert resp.status_code == 200\n", "assert b'Edit Config' in resp.data\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assert'", "Assert'" ]
[ "def FUNC_39(VAR_62, VAR_101=None, VAR_102=None, VAR_103=False):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.model.create_new import get_new_doc\n", "return get_new_doc(VAR_62, VAR_101, VAR_102, VAR_103=as_dict)\n" ]
[ "def new_doc(doctype, parent_doc=None, parentfield=None, as_dict=False):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.model.create_new import get_new_doc\n", "return get_new_doc(doctype, parent_doc, parentfield, as_dict=as_dict)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "ImportFrom'", "Return'" ]
[ "@VAR_0.route('/api/jobs/<int:job_id>/subjobs/<int:subjob_id>/copy', methods...\n", "\"\"\"docstring\"\"\"\n", "VAR_98 = FUNC_58(f'/internal/jobs/{VAR_9}/subjobs/{VAR_11}/copy', 'put')\n", "return jsonify({'success': False, 'message': str(err)}), 400\n", "return jsonify(VAR_98)\n" ]
[ "@gui.route('/api/jobs/<int:job_id>/subjobs/<int:subjob_id>/copy', methods=[...\n", "\"\"\"docstring\"\"\"\n", "response_info = query_internal_api(\n f'/internal/jobs/{job_id}/subjobs/{subjob_id}/copy', 'put')\n", "return jsonify({'success': False, 'message': str(err)}), 400\n", "return jsonify(response_info)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Return'", "Return'" ]
[ "@VAR_0.filter(needs_autoescape=True)...\n", "\"\"\"docstring\"\"\"\n", "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" ]
[ "@register.filter(needs_autoescape=True)...\n", "\"\"\"docstring\"\"\"\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, 0, 0 ]
[ "Condition", "Docstring", "FunctionDef'", "Return'" ]
[ "def FUNC_28(VAR_24):...\n", "\"\"\"docstring\"\"\"\n", "VAR_24.add_argument('--dir', type=str, required=True, help=\n 'directory containing the SavedModel to convert')\n", "VAR_24.add_argument('--output_prefix', type=str, required=True, help=\n 'output directory + filename prefix for the resulting header(s) and object file(s)'\n )\n", "VAR_24.add_argument('--tag_set', type=str, required=True, help=\n \"tag-set of graph in SavedModel to convert, separated by ','\")\n", "VAR_24.add_argument('--signature_def_key', type=str, default=\n signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY, help=\n 'signature_def key to use. default: DEFAULT_SERVING_SIGNATURE_DEF_KEY')\n", "VAR_24.add_argument('--checkpoint_path', type=str, default=None, help=\n 'Custom checkpoint to use (default: use the SavedModel variables)')\n", "VAR_24.add_argument('--variables_to_feed', type=str, default='', help=\n \"The names of variables that will be fed into the network. Options are: empty (default; all variables are frozen, none may be fed), 'all' (all variables may be fed), or a comma-delimited list of names of variables that may be fed. In the last case, the non-fed variables will be frozen in the graph.**NOTE** Any variables passed to `variables_to_feed` *must be set by the user*. These variables will NOT be frozen and their values will be uninitialized in the compiled object (this applies to all input arguments from the signature as well).\"\n )\n" ]
[ "def _parse_common_freeze_and_aot(parser_compile):...\n", "\"\"\"docstring\"\"\"\n", "parser_compile.add_argument('--dir', type=str, required=True, help=\n 'directory containing the SavedModel to convert')\n", "parser_compile.add_argument('--output_prefix', type=str, required=True,\n help=\n 'output directory + filename prefix for the resulting header(s) and object file(s)'\n )\n", "parser_compile.add_argument('--tag_set', type=str, required=True, help=\n \"tag-set of graph in SavedModel to convert, separated by ','\")\n", "parser_compile.add_argument('--signature_def_key', type=str, default=\n signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY, help=\n 'signature_def key to use. default: DEFAULT_SERVING_SIGNATURE_DEF_KEY')\n", "parser_compile.add_argument('--checkpoint_path', type=str, default=None,\n help='Custom checkpoint to use (default: use the SavedModel variables)')\n", "parser_compile.add_argument('--variables_to_feed', type=str, default='',\n help=\n \"The names of variables that will be fed into the network. Options are: empty (default; all variables are frozen, none may be fed), 'all' (all variables may be fed), or a comma-delimited list of names of variables that may be fed. In the last case, the non-fed variables will be frozen in the graph.**NOTE** Any variables passed to `variables_to_feed` *must be set by the user*. These variables will NOT be frozen and their values will be uninitialized in the compiled object (this applies to all input arguments from the signature as well).\"\n )\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_81(VAR_62, VAR_143=True):...\n", "\"\"\"docstring\"\"\"\n", "import frappe.desk.reportview\n", "return frappe.desk.reportview.build_match_conditions(VAR_62, VAR_143=\n as_condition)\n" ]
[ "def build_match_conditions(doctype, as_condition=True):...\n", "\"\"\"docstring\"\"\"\n", "import frappe.desk.reportview\n", "return frappe.desk.reportview.build_match_conditions(doctype, as_condition=\n as_condition)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Import'", "Return'" ]
[ "def FUNC_45(self, VAR_54, VAR_55):...\n", "return VAR_54 * VAR_55\n" ]
[ "def multiply(self, a, b):...\n", "return a * b\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_0():...\n", "\"\"\"docstring\"\"\"\n", "VAR_53.session.save()\n", "VAR_40 = VAR_53.serving.request.hooks['before_finalize']\n", "VAR_41 = VAR_53.lib.sessions.save\n", "VAR_40[:] = [h for h in VAR_40 if h.callback is not VAR_41]\n" ]
[ "def _save_and_release_session():...\n", "\"\"\"docstring\"\"\"\n", "cherrypy.session.save()\n", "hooks = cherrypy.serving.request.hooks['before_finalize']\n", "forbidden = cherrypy.lib.sessions.save\n", "hooks[:] = [h for h in hooks if h.callback is not forbidden]\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_64(VAR_37):...\n", "\"\"\"docstring\"\"\"\n", "VAR_146 = re.split('[\\\\n\\\\r\\\\s,]', VAR_37)\n", "VAR_146 = [s.strip() for s in VAR_146]\n", "VAR_146 = [s for s in VAR_146 if s != '']\n", "return VAR_146\n" ]
[ "def _split_input_list(str_list):...\n", "\"\"\"docstring\"\"\"\n", "new_list = re.split('[\\\\n\\\\r\\\\s,]', str_list)\n", "new_list = [s.strip() for s in new_list]\n", "new_list = [s for s in new_list if s != '']\n", "return new_list\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_30(self):...\n", "VAR_22 = models.Band.objects.create(name='Linkin Park')\n", "VAR_36 = models.Member.objects.create(name='Chester')\n", "VAR_37 = models.Member.objects.create(name='Mike')\n", "VAR_22.members.add(VAR_36, VAR_37)\n", "VAR_29 = models.Band._meta.get_field('members').rel\n", "VAR_27 = widgets.ManyToManyRawIdWidget(VAR_29, widget_admin_site)\n", "self.assertHTMLEqual(conditional_escape(VAR_27.render('test', [VAR_36.pk,\n VAR_37.pk], attrs={})), 'string' % dict(VAR_0(), m1pk=m1.pk, m2pk=m2.pk))\n", "self.assertHTMLEqual(conditional_escape(VAR_27.render('test', [VAR_36.pk])),\n 'string' % dict(VAR_0(), m1pk=m1.pk))\n" ]
[ "def test_render(self):...\n", "band = models.Band.objects.create(name='Linkin Park')\n", "m1 = models.Member.objects.create(name='Chester')\n", "m2 = models.Member.objects.create(name='Mike')\n", "band.members.add(m1, m2)\n", "rel = models.Band._meta.get_field('members').rel\n", "w = widgets.ManyToManyRawIdWidget(rel, widget_admin_site)\n", "self.assertHTMLEqual(conditional_escape(w.render('test', [m1.pk, m2.pk],\n attrs={})), \n '<input type=\"text\" name=\"test\" value=\"%(m1pk)s,%(m2pk)s\" class=\"vManyToManyRawIdAdminField\" /><a href=\"/widget_admin/admin_widgets/member/\" class=\"related-lookup\" id=\"lookup_id_test\" onclick=\"return showRelatedObjectLookupPopup(this);\"> <img src=\"/static/admin/img/selector-search.gif\" width=\"16\" height=\"16\" alt=\"Lookup\" /></a>'\n % dict(admin_static_prefix(), m1pk=m1.pk, m2pk=m2.pk))\n", "self.assertHTMLEqual(conditional_escape(w.render('test', [m1.pk])), \n '<input type=\"text\" name=\"test\" value=\"%(m1pk)s\" class=\"vManyToManyRawIdAdminField\" /><a href=\"/widget_admin/admin_widgets/member/\" class=\"related-lookup\" id=\"lookup_id_test\" onclick=\"return showRelatedObjectLookupPopup(this);\"> <img src=\"%(ADMIN_STATIC_PREFIX)simg/selector-search.gif\" width=\"16\" height=\"16\" alt=\"Lookup\" /></a>'\n % dict(admin_static_prefix(), m1pk=m1.pk))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "__version__ = '4.6.2'\n", "def FUNC_0():...\n", "\"\"\"docstring\"\"\"\n", "import os\n", "VAR_0 = __path__[0]\n", "VAR_1 = os.path.join(VAR_0, 'includes')\n", "VAR_2 = [VAR_1, VAR_0]\n", "for name in os.listdir(VAR_1):\n", "VAR_3 = os.path.join(VAR_1, name)\n", "return VAR_2\n", "if os.path.isdir(VAR_3):\n", "VAR_2.append(VAR_3)\n" ]
[ "__version__ = '4.6.2'\n", "def get_include():...\n", "\"\"\"docstring\"\"\"\n", "import os\n", "lxml_path = __path__[0]\n", "include_path = os.path.join(lxml_path, 'includes')\n", "includes = [include_path, lxml_path]\n", "for name in os.listdir(include_path):\n", "path = os.path.join(include_path, name)\n", "return includes\n", "if os.path.isdir(path):\n", "includes.append(path)\n" ]
[ 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Assign'", "FunctionDef'", "Docstring", "Import'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Return'", "Condition", "Expr'" ]
[ "@FUNC_0...\n", "return ReplicationCommandHandler(self)\n" ]
[ "@cache_in_self...\n", "return ReplicationCommandHandler(self)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "@log_function...\n", "\"\"\"docstring\"\"\"\n", "VAR_2 = FUNC_1('/groups/%s/roles/%s', VAR_30, VAR_34)\n", "return self.client.delete_json(VAR_5=destination, VAR_2=path, VAR_3={\n 'requester_user_id': requester_user_id}, VAR_15=True)\n" ]
[ "@log_function...\n", "\"\"\"docstring\"\"\"\n", "path = _create_v1_path('/groups/%s/roles/%s', group_id, role_id)\n", "return self.client.delete_json(destination=destination, path=path, args={\n 'requester_user_id': requester_user_id}, ignore_backoff=True)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Return'" ]
[ "from django.contrib.auth.decorators import login_required\n", "from django.shortcuts import render, redirect, get_object_or_404\n", "from django.http import HttpResponsePermanentRedirect\n", "from djconfig import config\n", "from spirit.core.utils.views import is_post, post_data\n", "from spirit.core.utils.paginator import paginate, yt_paginate\n", "from spirit.core.utils.ratelimit.decorators import ratelimit\n", "from spirit.category.models import Category\n", "from spirit.comment.forms import CommentForm\n", "from spirit.comment.utils import comment_posted\n", "from spirit.comment.models import Comment\n", "from .models import Topic\n", "from .forms import TopicForm\n", "from . import utils\n", "@login_required...\n", "if VAR_1:\n", "get_object_or_404(Category.objects.visible(), VAR_2=category_id)\n", "VAR_4 = VAR_0.user\n", "VAR_5 = TopicForm(VAR_4=user, data=post_data(request), initial={'category':\n category_id})\n", "VAR_6 = CommentForm(VAR_4=user, data=post_data(request))\n", "if is_post(VAR_0) and all([VAR_5.is_valid(), VAR_6.is_valid()]\n", "if not VAR_4.st.update_post_hash(VAR_5.get_topic_hash()):\n", "return render(VAR_0=request, template_name='spirit/topic/publish.html',\n context={'form': form, 'cform': cform})\n", "return redirect(VAR_0.POST.get('next', None) or VAR_5.get_category().\n get_absolute_url())\n", "VAR_7 = VAR_5.save()\n", "VAR_6.topic = VAR_7\n", "VAR_11 = VAR_6.save()\n", "comment_posted(VAR_11=comment, mentions=cform.mentions)\n", "return redirect(VAR_7.get_absolute_url())\n" ]
[ "from django.contrib.auth.decorators import login_required\n", "from django.shortcuts import render, redirect, get_object_or_404\n", "from django.http import HttpResponsePermanentRedirect\n", "from djconfig import config\n", "from spirit.core.utils.views import is_post, post_data\n", "from spirit.core.utils.paginator import paginate, yt_paginate\n", "from spirit.core.utils.ratelimit.decorators import ratelimit\n", "from spirit.category.models import Category\n", "from spirit.comment.forms import CommentForm\n", "from spirit.comment.utils import comment_posted\n", "from spirit.comment.models import Comment\n", "from .models import Topic\n", "from .forms import TopicForm\n", "from . import utils\n", "@login_required...\n", "if category_id:\n", "get_object_or_404(Category.objects.visible(), pk=category_id)\n", "user = request.user\n", "form = TopicForm(user=user, data=post_data(request), initial={'category':\n category_id})\n", "cform = CommentForm(user=user, data=post_data(request))\n", "if is_post(request) and all([form.is_valid(), cform.is_valid()]\n", "if not user.st.update_post_hash(form.get_topic_hash()):\n", "return render(request=request, template_name='spirit/topic/publish.html',\n context={'form': form, 'cform': cform})\n", "return redirect(request.POST.get('next', None) or form.get_category().\n get_absolute_url())\n", "topic = form.save()\n", "cform.topic = topic\n", "comment = cform.save()\n", "comment_posted(comment=comment, mentions=cform.mentions)\n", "return redirect(topic.get_absolute_url())\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Return'", "Return'", "Assign'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "async def FUNC_27(VAR_40, VAR_41, **VAR_3):...\n", "self.assertEqual(VAR_40, VAR_34)\n", "self.assertEqual(VAR_41, '/_matrix/key/v2/server/key1')\n", "return VAR_16\n" ]
[ "async def get_json(destination, path, **kwargs):...\n", "self.assertEqual(destination, SERVER_NAME)\n", "self.assertEqual(path, '/_matrix/key/v2/server/key1')\n", "return response\n" ]
[ 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Expr'", "Expr'", "Return'" ]
[ "def __init__(self):...\n", "VAR_56 = def_function.function(self.multiply, input_signature=[tensor_spec.\n TensorSpec(shape=(), dtype=dtypes.float32), tensor_spec.TensorSpec(\n shape=(), dtype=dtypes.float32)])\n", "self.pure_concrete_function = VAR_56.get_concrete_function()\n", "super(CLASS_2, self).__init__()\n" ]
[ "def __init__(self):...\n", "function = def_function.function(self.multiply, input_signature=[\n tensor_spec.TensorSpec(shape=(), dtype=dtypes.float32), tensor_spec.\n TensorSpec(shape=(), dtype=dtypes.float32)])\n", "self.pure_concrete_function = function.get_concrete_function()\n", "super(DummyModel, self).__init__()\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'" ]