lines
sequencelengths
1
383
raw_lines
sequencelengths
1
383
label
sequencelengths
1
383
type
sequencelengths
1
383
[ "def FUNC_5(self):...\n", "VAR_50 = VAR_53.request.remote.ip in ('127.0.0.1', '::1')\n", "if VAR_50 and cherry.config['server.localhost_auto_login']:\n", "return True\n", "return False\n" ]
[ "def autoLoginActive(self):...\n", "is_loopback = cherrypy.request.remote.ip in ('127.0.0.1', '::1')\n", "if is_loopback and cherry.config['server.localhost_auto_login']:\n", "return True\n", "return False\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_13(self, VAR_9, VAR_0, VAR_8, VAR_5, VAR_7):...\n", "VAR_0.get(VAR_8 + self.url)\n", "VAR_16 = VAR_0.find_element(By.XPATH, \"//input[@name='file']\")\n", "VAR_16.send_keys(VAR_5)\n", "assert VAR_16.get_attribute('name') == 'file'\n", "VAR_16.submit()\n", "assert storage.exists('tmp/%s.txt' % VAR_9.node.name)\n", "VAR_19 = VAR_0.find_element(By.XPATH, '//body[@JSError]')\n", "pytest.fail(VAR_19.get_attribute('JSError'))\n" ]
[ "def test_file_insert(self, request, driver, live_server, upload_file, freeze):...\n", "driver.get(live_server + self.url)\n", "file_input = driver.find_element(By.XPATH, \"//input[@name='file']\")\n", "file_input.send_keys(upload_file)\n", "assert file_input.get_attribute('name') == 'file'\n", "file_input.submit()\n", "assert storage.exists('tmp/%s.txt' % request.node.name)\n", "error = driver.find_element(By.XPATH, '//body[@JSError]')\n", "pytest.fail(error.get_attribute('JSError'))\n" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Expr'", "Assert'", "Expr'", "Assert'", "Assign'", "Expr'" ]
[ "def FUNC_0(VAR_2=False, VAR_3='/'):...\n", "if settings.MULTI_ORG and current_org == None:\n", "VAR_23 = '/'\n", "if settings.MULTI_ORG:\n", "return VAR_23\n", "VAR_23 = url_for('redash.login', org_slug=current_org.slug, VAR_3=next,\n _external=external)\n", "VAR_23 = url_for('redash.login', VAR_3=next, _external=external)\n" ]
[ "def get_login_url(external=False, next='/'):...\n", "if settings.MULTI_ORG and current_org == None:\n", "login_url = '/'\n", "if settings.MULTI_ORG:\n", "return login_url\n", "login_url = url_for('redash.login', org_slug=current_org.slug, next=next,\n _external=external)\n", "login_url = url_for('redash.login', next=next, _external=external)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Condition", "Return'", "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'" ]
[ "@wraps(VAR_13)...\n", "if VAR_8.auth:\n", "@login_required...\n", "return VAR_13(*VAR_41, **kwargs)\n", "return VAR_13(*VAR_41, **kwargs)\n" ]
[ "@wraps(func)...\n", "if app.auth:\n", "@login_required...\n", "return func(*args, **kwargs)\n", "return func(*args, **kwargs)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Condition", "Return'", "Return'" ]
[ "@FUNC_0...\n", "return ProfileHandler(self)\n" ]
[ "@cache_in_self...\n", "return ProfileHandler(self)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_64(self):...\n", "VAR_27 = self.get_user_data(self.admin)\n", "VAR_27['email'] = 'new_' + VAR_27['email']\n", "VAR_3 = self.client.post('/admin/auth/user/%s/' % self.admin.pk, VAR_27)\n", "self.assertRedirects(VAR_3, '/admin/auth/user/')\n", "VAR_28 = LogEntry.objects.latest('id')\n", "self.assertEqual(VAR_28.change_message, 'Changed email.')\n" ]
[ "def test_user_change_email(self):...\n", "data = self.get_user_data(self.admin)\n", "data['email'] = 'new_' + data['email']\n", "response = self.client.post('/admin/auth/user/%s/' % self.admin.pk, data)\n", "self.assertRedirects(response, '/admin/auth/user/')\n", "row = LogEntry.objects.latest('id')\n", "self.assertEqual(row.change_message, 'Changed email.')\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "@VAR_0.route('/jobs/<int:job_id>/export')...\n", "\"\"\"docstring\"\"\"\n", "VAR_56 = os.path.join(VAR_0.config['UPLOAD_FOLDER'], f'export.txt')\n", "VAR_98 = FUNC_58(f'/internal/jobs/{VAR_9}/export', 'get', VAR_73={'path':\n export_path})\n", "flash(str(err), 'danger')\n", "return redirect(url_for('job_page', VAR_9=job_id))\n", "return send_file(VAR_56, as_attachment=True, cache_timeout=0,\n attachment_filename=f'Job_{job_id}.txt')\n" ]
[ "@gui.route('/jobs/<int:job_id>/export')...\n", "\"\"\"docstring\"\"\"\n", "export_path = os.path.join(gui.config['UPLOAD_FOLDER'], f'export.txt')\n", "response_info = query_internal_api(f'/internal/jobs/{job_id}/export', 'get',\n params={'path': export_path})\n", "flash(str(err), 'danger')\n", "return redirect(url_for('job_page', job_id=job_id))\n", "return send_file(export_path, as_attachment=True, cache_timeout=0,\n attachment_filename=f'Job_{job_id}.txt')\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Expr'", "Return'", "Return'" ]
[ "def FUNC_29(VAR_16, VAR_34):...\n", "VAR_34 = VAR_34.rstrip().strip()\n", "if VAR_16.title != VAR_34:\n", "if VAR_34 == '':\n", "return False\n", "VAR_34 = _(u'Unknown')\n", "VAR_16.title = VAR_34\n", "return True\n" ]
[ "def handle_title_on_edit(book, book_title):...\n", "book_title = book_title.rstrip().strip()\n", "if book.title != book_title:\n", "if book_title == '':\n", "return False\n", "book_title = _(u'Unknown')\n", "book.title = book_title\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Condition", "Return'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_7(self):...\n", "self.resource_id = self._parse_resource_id(self.spec)\n", "return 'https://www.hydroshare.org/resource/{}'.format(self.resource_id)\n" ]
[ "def get_repo_url(self):...\n", "self.resource_id = self._parse_resource_id(self.spec)\n", "return 'https://www.hydroshare.org/resource/{}'.format(self.resource_id)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_38(VAR_33):...\n", "if callable(VAR_65):\n", "return FUNC_19(VAR_33)\n", "VAR_34 = VAR_65()\n", "VAR_0.exception(\n 'Error while trying to retrieve custom LastModified value for plugin {}'\n .format(VAR_8))\n", "if VAR_34:\n", "return VAR_34\n" ]
[ "def compute_lastmodified(files):...\n", "if callable(custom_lastmodified):\n", "return _compute_date(files)\n", "lastmodified = custom_lastmodified()\n", "_logger.exception(\n 'Error while trying to retrieve custom LastModified value for plugin {}'\n .format(key))\n", "if lastmodified:\n", "return lastmodified\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "Expr'", "Condition", "Return'" ]
[ "def FUNC_7(VAR_10, VAR_11):...\n", "VAR_46 = FUNC_8(VAR_10)\n", "VAR_46.unpack(VAR_11, VAR_3=link.url)\n" ]
[ "def unpack_vcs_link(link, location):...\n", "vcs_backend = _get_used_vcs_backend(link)\n", "vcs_backend.unpack(location, url=link.url)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def __attrs_post_init__(self) ->None:...\n", "VAR_21 = '%s-O-%s' % (self.method, VAR_6)\n", "VAR_6 = (VAR_6 + 1) % (VAR_5 - 1)\n", "object.__setattr__(self, 'txn_id', VAR_21)\n", "VAR_44 = self.destination.encode('ascii')\n", "VAR_45 = self.path.encode('ascii')\n", "if self.query:\n", "VAR_58 = encode_query_args(self.query)\n", "VAR_58 = b''\n", "VAR_22 = urllib.parse.urlunparse((b'matrix', VAR_44, VAR_45, None, VAR_58, b'')\n )\n", "object.__setattr__(self, 'uri', VAR_22)\n" ]
[ "def __attrs_post_init__(self) ->None:...\n", "txn_id = '%s-O-%s' % (self.method, _next_id)\n", "_next_id = (_next_id + 1) % (MAXINT - 1)\n", "object.__setattr__(self, 'txn_id', txn_id)\n", "destination_bytes = self.destination.encode('ascii')\n", "path_bytes = self.path.encode('ascii')\n", "if self.query:\n", "query_bytes = encode_query_args(self.query)\n", "query_bytes = b''\n", "uri = urllib.parse.urlunparse((b'matrix', destination_bytes, path_bytes,\n None, query_bytes, b''))\n", "object.__setattr__(self, 'uri', uri)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_77():...\n", "return '/rooms/%s/send/m.room.message/mid%s' % (self.created_rmid, str(next\n (VAR_25)))\n" ]
[ "def send_msg_path():...\n", "return '/rooms/%s/send/m.room.message/mid%s' % (self.created_rmid, str(next\n (seq)))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@login_required...\n", "VAR_8 = Comment.objects.for_update_or_404(VAR_2, VAR_0.user)\n", "VAR_7 = CommentForm(data=post_data(request), instance=comment)\n", "if is_post(VAR_0) and VAR_7.is_valid():\n", "pre_comment_update(VAR_8=Comment.objects.get(pk=comment.pk))\n", "return render(VAR_0=request, template_name='spirit/comment/update.html',\n context={'form': form})\n", "VAR_8 = VAR_7.save()\n", "post_comment_update(VAR_8=comment)\n", "return redirect(VAR_0.POST.get('next', VAR_8.get_absolute_url()))\n" ]
[ "@login_required...\n", "comment = Comment.objects.for_update_or_404(pk, request.user)\n", "form = CommentForm(data=post_data(request), instance=comment)\n", "if is_post(request) and form.is_valid():\n", "pre_comment_update(comment=Comment.objects.get(pk=comment.pk))\n", "return render(request=request, template_name='spirit/comment/update.html',\n context={'form': form})\n", "comment = form.save()\n", "post_comment_update(comment=comment)\n", "return redirect(request.POST.get('next', comment.get_absolute_url()))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 4 ]
[ "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Return'", "Assign'", "Expr'", "Return'" ]
[ "from __future__ import annotations\n", "import email.utils\n", "import errno\n", "import os\n", "import sys\n", "import urllib.parse\n", "from abc import abstractmethod\n", "from datetime import datetime\n", "from typing import List, Optional\n", "import attr\n", "import requests\n", "import tenacity\n", "from .Line import Line\n", "rawLines: List[str]\n", "VAR_7: Optional[datetime.date]\n", "@property...\n", "return [Line(i, line) for i, line in enumerate(self.rawLines, 1)]\n" ]
[ "from __future__ import annotations\n", "import email.utils\n", "import errno\n", "import os\n", "import sys\n", "import urllib.parse\n", "from abc import abstractmethod\n", "from datetime import datetime\n", "from typing import List, Optional\n", "import attr\n", "import requests\n", "import tenacity\n", "from .Line import Line\n", "rawLines: List[str]\n", "date: Optional[datetime.date]\n", "@property...\n", "return [Line(i, line) for i, line in enumerate(self.rawLines, 1)]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Import'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Import'", "Import'", "ImportFrom'", "AnnAssign'", "AnnAssign'", "Condition", "Return'" ]
[ "def FUNC_18(self, VAR_4, VAR_39, VAR_40):...\n", "self.log.warn('base_project_url is deprecated, use base_url')\n", "self.base_url = VAR_40\n" ]
[ "def _base_project_url_changed(self, name, old, new):...\n", "self.log.warn('base_project_url is deprecated, use base_url')\n", "self.base_url = new\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'" ]
[ "@login_required...\n", "VAR_15 = Topic.objects.with_bookmarks(VAR_7=request.user).filter(\n topics_private__user=request.user)\n", "VAR_15 = yt_paginate(VAR_15, per_page=config.topics_per_page, page_number=\n request.GET.get('page', 1))\n", "return render(VAR_1=request, template_name=\n 'spirit/topic/private/index.html', context={'topics': topics})\n" ]
[ "@login_required...\n", "topics = Topic.objects.with_bookmarks(user=request.user).filter(\n topics_private__user=request.user)\n", "topics = yt_paginate(topics, per_page=config.topics_per_page, page_number=\n request.GET.get('page', 1))\n", "return render(request=request, template_name=\n 'spirit/topic/private/index.html', context={'topics': topics})\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_8(VAR_5):...\n", "import os\n", "VAR_28 = os.path.dirname(__file__)\n", "VAR_29 = VAR_5\n", "VAR_30 = os.path.join(VAR_28, VAR_29)\n", "return VAR_30\n" ]
[ "def get_absolute_path(path):...\n", "import os\n", "script_dir = os.path.dirname(__file__)\n", "rel_path = path\n", "abs_file_path = os.path.join(script_dir, rel_path)\n", "return abs_file_path\n" ]
[ 0, 0, 0, 0, 1, 0 ]
[ "FunctionDef'", "Import'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_72(self):...\n", "VAR_14 = self.token['text']\n", "while self.peek()['type'] == 'text':\n", "VAR_14 += '\\n' + self.pop()['text']\n", "return self.inline(VAR_14)\n" ]
[ "def tok_text(self):...\n", "text = self.token['text']\n", "while self.peek()['type'] == 'text':\n", "text += '\\n' + self.pop()['text']\n", "return self.inline(text)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "AugAssign'", "Return'" ]
[ "def FUNC_10(self, VAR_15: str, VAR_16: str, VAR_10: str) ->str:...\n", "\"\"\"docstring\"\"\"\n", "VAR_29, VAR_30 = self.get_source(VAR_15)\n", "if VAR_30 != VAR_10:\n", "VAR_28 = encode(VAR_16, encoding='utf-8')\n", "file.write(VAR_28)\n", "self.ledger.extensions.after_write_source(VAR_15, VAR_16)\n", "self.ledger.load_file()\n", "return sha256(VAR_28).hexdigest()\n" ]
[ "def set_source(self, path: str, source: str, sha256sum: str) ->str:...\n", "\"\"\"docstring\"\"\"\n", "_, original_sha256sum = self.get_source(path)\n", "if original_sha256sum != sha256sum:\n", "contents = encode(source, encoding='utf-8')\n", "file.write(contents)\n", "self.ledger.extensions.after_write_source(path, source)\n", "self.ledger.load_file()\n", "return sha256(contents).hexdigest()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_21(self, VAR_44):...\n", "VAR_82 = VAR_44.group(1)\n", "if not VAR_82:\n", "VAR_14 = VAR_44.group(0)\n", "VAR_102 = VAR_44.group(2)\n", "self.tokens.append({'type': 'close_html', 'text': VAR_14})\n", "VAR_14 = VAR_44.group(3)\n", "self.tokens.append({'type': 'open_html', 'tag': VAR_82, 'extra': VAR_102,\n 'text': VAR_14})\n" ]
[ "def parse_block_html(self, m):...\n", "tag = m.group(1)\n", "if not tag:\n", "text = m.group(0)\n", "attr = m.group(2)\n", "self.tokens.append({'type': 'close_html', 'text': text})\n", "text = m.group(3)\n", "self.tokens.append({'type': 'open_html', 'tag': tag, 'extra': attr, 'text':\n text})\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "import os\n", "import re\n", "import glob\n", "from urllib import quote\n", "import json\n", "from twisted.web import static, resource, http\n", "from Components.config import config\n", "from Tools.Directories import fileExists\n", "def FUNC_0(self):...\n", "VAR_0 = self.getHeader(b'host')\n", "if VAR_0:\n", "if VAR_0[0] == '[':\n", "return self.getHost().host.encode('ascii')\n", "return VAR_0.split(']', 1)[0] + ']'\n", "return VAR_0.split(':', 1)[0].encode('ascii')\n" ]
[ "import os\n", "import re\n", "import glob\n", "from urllib import quote\n", "import json\n", "from twisted.web import static, resource, http\n", "from Components.config import config\n", "from Tools.Directories import fileExists\n", "def new_getRequestHostname(self):...\n", "host = self.getHeader(b'host')\n", "if host:\n", "if host[0] == '[':\n", "return self.getHost().host.encode('ascii')\n", "return host.split(']', 1)[0] + ']'\n", "return host.split(':', 1)[0].encode('ascii')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "Import'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "Condition", "Condition", "Return'", "Return'", "Return'" ]
[ "def FUNC_15(self, VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "yield VAR_1(VAR_2, 'tools', 'build-main.js')\n", "yield VAR_1(VAR_12, VAR_5, 'js', 'main.js')\n", "for sec in [VAR_5, 'base', 'auth']:\n", "for f in glob(VAR_1(VAR_12, sec, 'js', '*.js')):\n", "yield VAR_1(VAR_12, 'services', 'config.js')\n", "if not f.endswith('.min.js'):\n", "if VAR_5 == 'notebook':\n", "yield f\n", "for f in glob(VAR_1(VAR_12, 'services', '*', '*.js')):\n", "for parent, VAR_54, VAR_65 in os.walk(VAR_1(VAR_12, 'components')):\n", "yield f\n", "if os.path.basename(parent) == 'MathJax':\n", "VAR_54[:] = []\n", "for f in VAR_65:\n", "yield VAR_1(parent, f)\n" ]
[ "def sources(self, name):...\n", "\"\"\"docstring\"\"\"\n", "yield pjoin(repo_root, 'tools', 'build-main.js')\n", "yield pjoin(static, name, 'js', 'main.js')\n", "for sec in [name, 'base', 'auth']:\n", "for f in glob(pjoin(static, sec, 'js', '*.js')):\n", "yield pjoin(static, 'services', 'config.js')\n", "if not f.endswith('.min.js'):\n", "if name == 'notebook':\n", "yield f\n", "for f in glob(pjoin(static, 'services', '*', '*.js')):\n", "for parent, dirs, files in os.walk(pjoin(static, 'components')):\n", "yield f\n", "if os.path.basename(parent) == 'MathJax':\n", "dirs[:] = []\n", "for f in files:\n", "yield pjoin(parent, f)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Expr'", "For", "For", "Expr'", "Condition", "Condition", "Expr'", "For", "For", "Expr'", "Condition", "Assign'", "For", "Expr'" ]
[ "def FUNC_65(VAR_38, VAR_39=None):...\n", "\"\"\"docstring\"\"\"\n", "VAR_147 = reverse('instructor_dashboard', VAR_3={'course_id': unicode(\n course_key)})\n", "if VAR_39 is not None:\n", "VAR_147 += u'#view-{section}'.format(VAR_39=section)\n", "return VAR_147\n" ]
[ "def _instructor_dash_url(course_key, section=None):...\n", "\"\"\"docstring\"\"\"\n", "url = reverse('instructor_dashboard', kwargs={'course_id': unicode(course_key)}\n )\n", "if section is not None:\n", "url += u'#view-{section}'.format(section=section)\n", "return url\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "AugAssign'", "Return'" ]
[ "def FUNC_21(self, VAR_86):...\n", "\"\"\"docstring\"\"\"\n", "VAR_193 = time.mktime(datetime.datetime.utcnow().timetuple())\n", "VAR_242 = VAR_193 + self.expiration\n", "VAR_81 = dict(VAR_103=session_auth['hmac_key'], user_groups=session_auth[\n 'user_groups'], VAR_141=session_auth['user'].as_dict(), iat=now, exp=\n expires)\n", "return VAR_81\n" ]
[ "def serialize_auth_session(self, session_auth):...\n", "\"\"\"docstring\"\"\"\n", "now = time.mktime(datetime.datetime.utcnow().timetuple())\n", "expires = now + self.expiration\n", "payload = dict(hmac_key=session_auth['hmac_key'], user_groups=session_auth[\n 'user_groups'], user=session_auth['user'].as_dict(), iat=now, exp=expires)\n", "return payload\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_8(self):...\n", "self._test_thumbnail('scale', self.test_image.expected_scaled, self.\n test_image.expected_found)\n" ]
[ "def test_thumbnail_scale(self):...\n", "self._test_thumbnail('scale', self.test_image.expected_scaled, self.\n test_image.expected_found)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "@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" ]
[ "@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, 4, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Return'", "Return'", "Assign'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_8(self, VAR_3, VAR_4):...\n", "VAR_4['choices'] = map(lambda x: (x.strip(), x.strip()), VAR_3.choices.\n split(','))\n", "return django.forms.MultipleChoiceField(**options)\n" ]
[ "def create_multiselect_field(self, field, options):...\n", "options['choices'] = map(lambda x: (x.strip(), x.strip()), field.choices.\n split(','))\n", "return django.forms.MultipleChoiceField(**options)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_2(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_5 = self.helper.send(self.room_id, body='test1')\n", "VAR_6 = self.helper.send(self.room_id, body='test2')\n", "VAR_7 = self.helper.send(self.room_id, body='test3')\n", "VAR_8 = self.helper.send(self.room_id, body='test4')\n", "VAR_9 = self.hs.get_datastore()\n", "VAR_10 = self.hs.get_storage()\n", "VAR_11 = self.get_success(VAR_9.get_topological_token_for_event(VAR_8[\n 'event_id']))\n", "VAR_12 = self.get_success(VAR_11.to_string(self.hs.get_datastore()))\n", "self.get_success(VAR_10.purge_events.purge_history(self.room_id, VAR_12, True))\n", "self.get_failure(VAR_9.get_event(VAR_5['event_id']), NotFoundError)\n", "self.get_failure(VAR_9.get_event(VAR_6['event_id']), NotFoundError)\n", "self.get_failure(VAR_9.get_event(VAR_7['event_id']), NotFoundError)\n", "self.get_success(VAR_9.get_event(VAR_8['event_id']))\n" ]
[ "def test_purge(self):...\n", "\"\"\"docstring\"\"\"\n", "first = self.helper.send(self.room_id, body='test1')\n", "second = self.helper.send(self.room_id, body='test2')\n", "third = self.helper.send(self.room_id, body='test3')\n", "last = self.helper.send(self.room_id, body='test4')\n", "store = self.hs.get_datastore()\n", "storage = self.hs.get_storage()\n", "token = self.get_success(store.get_topological_token_for_event(last[\n 'event_id']))\n", "token_str = self.get_success(token.to_string(self.hs.get_datastore()))\n", "self.get_success(storage.purge_events.purge_history(self.room_id, token_str,\n True))\n", "self.get_failure(store.get_event(first['event_id']), NotFoundError)\n", "self.get_failure(store.get_event(second['event_id']), NotFoundError)\n", "self.get_failure(store.get_event(third['event_id']), NotFoundError)\n", "self.get_success(store.get_event(last['event_id']))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_9(VAR_0):...\n", "VAR_0.DEBUG = True\n", "VAR_6 = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs'\")\n", "VAR_7 = unicorn(None, VAR_6)\n", "VAR_8 = {}\n", "VAR_12 = VAR_7.render(VAR_8)\n", "assert '<script type=\"module\"' in VAR_12\n", "assert len(re.findall('<script type=\"module\"', VAR_12)) == 1\n" ]
[ "def test_unicorn_render_component_one_script_tag(settings):...\n", "settings.DEBUG = True\n", "token = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs'\")\n", "unicorn_node = unicorn(None, token)\n", "context = {}\n", "html = unicorn_node.render(context)\n", "assert '<script type=\"module\"' in html\n", "assert len(re.findall('<script type=\"module\"', html)) == 1\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assert'", "Assert'" ]
[ "def FUNC_153(VAR_114):...\n", "def FUNC_118(*VAR_11, **VAR_351):...\n", "VAR_85 = self.get_jwt_token_from_request(VAR_88=token_param)\n", "if VAR_91:\n", "if VAR_85 and len(VAR_85) < self.max_header_length:\n", "VAR_85 = None\n", "VAR_447 = self.verify_expiration\n", "return VAR_114(*VAR_11, **kwargs)\n", "self.verify_expiration = VAR_66\n", "self.verify_expiration = VAR_447\n", "self.inject_token(VAR_89)\n", "VAR_89 = self.load_token(VAR_85)\n" ]
[ "def decorator(action):...\n", "def f(*args, **kwargs):...\n", "token = self.get_jwt_token_from_request(token_param=token_param)\n", "if required:\n", "if token and len(token) < self.max_header_length:\n", "token = None\n", "old_verify_expiration = self.verify_expiration\n", "return action(*args, **kwargs)\n", "self.verify_expiration = verify_expiration\n", "self.verify_expiration = old_verify_expiration\n", "self.inject_token(tokend)\n", "tokend = self.load_token(token)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_24(self, VAR_19):...\n", "\"\"\"docstring\"\"\"\n", "self._subscribers.discard(VAR_19)\n" ]
[ "def remove_subscriber(self, conn):...\n", "\"\"\"docstring\"\"\"\n", "self._subscribers.discard(conn)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'" ]
[ "def FUNC_4(self, VAR_13):...\n", "VAR_13 = super().clean(VAR_13)\n", "if not VAR_13 or self.required and not any(VAR_13):\n", "return VAR_13\n" ]
[ "def clean(self, value):...\n", "value = super().clean(value)\n", "if not value or self.required and not any(value):\n", "return value\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_1(VAR_6, VAR_7='utf-8'):...\n", "\"\"\"docstring\"\"\"\n", "if isinstance(VAR_6, text_type):\n", "return VAR_6\n", "if VAR_6 == None:\n", "return ''\n", "if isinstance(VAR_6, binary_type):\n", "return text_type(VAR_6, VAR_7)\n", "return text_type(VAR_6)\n" ]
[ "def as_unicode(text, encoding='utf-8'):...\n", "\"\"\"docstring\"\"\"\n", "if isinstance(text, text_type):\n", "return text\n", "if text == None:\n", "return ''\n", "if isinstance(text, binary_type):\n", "return text_type(text, encoding)\n", "return text_type(text)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "def FUNC_9():...\n", "\"\"\"docstring\"\"\"\n", "if VAR_12:\n", "VAR_12.close()\n", "release_local(VAR_1)\n" ]
[ "def destroy():...\n", "\"\"\"docstring\"\"\"\n", "if db:\n", "db.close()\n", "release_local(local)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_4(self):...\n", "self.clean_instance(self.cleaned_data)\n" ]
[ "def clean(self):...\n", "self.clean_instance(self.cleaned_data)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "async def FUNC_23():...\n", "context_12.request = 'context_12'\n", "VAR_53 = VAR_4.verify_json_objects_for_server([('server10', VAR_21, 0, 'test')]\n )\n", "VAR_53[0].addBoth(self.check_context, None)\n", "VAR_25[0] = 1\n", "await make_deferred_yieldable(VAR_53[0])\n", "VAR_25[0] = 2\n" ]
[ "async def second_lookup():...\n", "context_12.request = 'context_12'\n", "res_deferreds_2 = kr.verify_json_objects_for_server([('server10', json1, 0,\n 'test')])\n", "res_deferreds_2[0].addBoth(self.check_context, None)\n", "second_lookup_state[0] = 1\n", "await make_deferred_yieldable(res_deferreds_2[0])\n", "second_lookup_state[0] = 2\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_16(self):...\n", "VAR_5 = {'not_senders': ['@misspiggy:muppets'], 'senders': [\n '@kermit:muppets', '@misspiggy:muppets']}\n", "VAR_6 = FUNC_0(sender='@misspiggy:muppets', type='m.room.topic', room_id=\n '!foo:bar')\n", "self.assertFalse(Filter(VAR_5).check(VAR_6))\n" ]
[ "def test_definition_not_senders_takes_priority_over_senders(self):...\n", "definition = {'not_senders': ['@misspiggy:muppets'], 'senders': [\n '@kermit:muppets', '@misspiggy:muppets']}\n", "event = MockEvent(sender='@misspiggy:muppets', type='m.room.topic', room_id\n ='!foo:bar')\n", "self.assertFalse(Filter(definition).check(event))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_4(self, VAR_6):...\n", "if not hasattr(VAR_6, 'extensions'):\n", "VAR_6.extensions = {}\n", "VAR_6.extensions['rbac'] = CLASS_1(self, VAR_6)\n", "self.acl.allow(anonymous, 'GET', VAR_6.view_functions['static'].__name__)\n", "VAR_6.before_first_request(self._setup_acl)\n", "VAR_6.before_request(self._authenticate)\n" ]
[ "def init_app(self, app):...\n", "if not hasattr(app, 'extensions'):\n", "app.extensions = {}\n", "app.extensions['rbac'] = _RBACState(self, app)\n", "self.acl.allow(anonymous, 'GET', app.view_functions['static'].__name__)\n", "app.before_first_request(self._setup_acl)\n", "app.before_request(self._authenticate)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_12(self):...\n", "if frappe.flags.in_import:\n", "return\n", "if self.is_standard == 'Yes' and (frappe.local.conf.get('developer_mode') or 0\n", "export_to_files(record_list=[['Report', self.name]], record_module=self.\n module, create_init=True)\n", "self.create_report_py()\n" ]
[ "def export_doc(self):...\n", "if frappe.flags.in_import:\n", "return\n", "if self.is_standard == 'Yes' and (frappe.local.conf.get('developer_mode') or 0\n", "export_to_files(record_list=[['Report', self.name]], record_module=self.\n module, create_init=True)\n", "self.create_report_py()\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_10(VAR_15: str) ->str:...\n", "\"\"\"docstring\"\"\"\n", "VAR_21 = re.search(ACCOUNT_RE, VAR_15)\n", "if not VAR_21:\n", "return VAR_15\n", "VAR_10 = VAR_21.group()\n", "VAR_22 = flask.url_for('account', name=account)\n", "return VAR_15.replace(VAR_10, f'<a href=\"{VAR_22}\">{VAR_10}</a>').replace(\n \"for '\", 'for ').replace(\"': \", ': ')\n" ]
[ "def format_errormsg(message: str) ->str:...\n", "\"\"\"docstring\"\"\"\n", "match = re.search(ACCOUNT_RE, message)\n", "if not match:\n", "return message\n", "account = match.group()\n", "url = flask.url_for('account', name=account)\n", "return message.replace(account, f'<a href=\"{url}\">{account}</a>').replace(\n \"for '\", 'for ').replace(\"': \", ': ')\n" ]
[ 0, 0, 0, 0, 2, 0, 2, 2 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_51(self):...\n", "\"\"\"docstring\"\"\"\n", "self._send_labelled_messages_in_room()\n", "VAR_39 = 's0_0_0_0_0_0_0_0_0'\n", "VAR_22, VAR_23 = self.make_request('GET', \n '/rooms/%s/messages?access_token=%s&from=%s&filter=%s' % (self.room_id,\n self.tok, VAR_39, json.dumps(self.FILTER_LABELS)))\n", "VAR_60 = VAR_23.json_body['chunk']\n", "self.assertEqual(len(VAR_60), 2, [event['content'] for event in VAR_60])\n", "self.assertEqual(VAR_60[0]['content']['body'], 'with right label', VAR_60[0])\n", "self.assertEqual(VAR_60[1]['content']['body'], 'with right label', VAR_60[1])\n" ]
[ "def test_messages_filter_labels(self):...\n", "\"\"\"docstring\"\"\"\n", "self._send_labelled_messages_in_room()\n", "token = 's0_0_0_0_0_0_0_0_0'\n", "request, channel = self.make_request('GET', \n '/rooms/%s/messages?access_token=%s&from=%s&filter=%s' % (self.room_id,\n self.tok, token, json.dumps(self.FILTER_LABELS)))\n", "events = channel.json_body['chunk']\n", "self.assertEqual(len(events), 2, [event['content'] for event in events])\n", "self.assertEqual(events[0]['content']['body'], 'with right label', events[0])\n", "self.assertEqual(events[1]['content']['body'], 'with right label', events[1])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_99(VAR_51=None, VAR_31=FUNC_0('Error')):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_51:\n", "if '\\n' in VAR_31:\n", "VAR_215 = FUNC_11()\n", "VAR_215, VAR_31 = VAR_31, VAR_51\n", "VAR_215 = VAR_51\n", "return FUNC_45(dict(VAR_62='Error Log', VAR_215=as_unicode(error), method=\n title)).insert(VAR_92=True)\n" ]
[ "def log_error(message=None, title=_('Error')):...\n", "\"\"\"docstring\"\"\"\n", "if message:\n", "if '\\n' in title:\n", "error = get_traceback()\n", "error, title = title, message\n", "error = message\n", "return get_doc(dict(doctype='Error Log', error=as_unicode(error), method=title)\n ).insert(ignore_permissions=True)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_66(VAR_6):...\n", "if VAR_122 is not None:\n", "return reverse(VAR_120, VAR_116=(iid, thumbsize))\n", "return reverse(VAR_120, VAR_116=(iid,))\n" ]
[ "def get_thumb_url(iid):...\n", "if thumbsize is not None:\n", "return reverse(prefix, args=(iid, thumbsize))\n", "return reverse(prefix, args=(iid,))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "@CLASS_4('configdiff')...\n", "\"\"\"docstring\"\"\"\n", "if VAR_3.path() == '/old':\n", "VAR_32 = config.instance.dump_userconfig().encode('utf-8')\n", "return 'text/html', configdiff.get_diff()\n", "VAR_8 = b'Failed to read old config: ' + str(e.strerror).encode('utf-8')\n", "return 'text/plain', VAR_32\n", "return 'text/plain', VAR_8\n" ]
[ "@add_handler('configdiff')...\n", "\"\"\"docstring\"\"\"\n", "if url.path() == '/old':\n", "data = config.instance.dump_userconfig().encode('utf-8')\n", "return 'text/html', configdiff.get_diff()\n", "error = b'Failed to read old config: ' + str(e.strerror).encode('utf-8')\n", "return 'text/plain', data\n", "return 'text/plain', error\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Assign'", "Return'", "Assign'", "Return'", "Return'" ]
[ "def FUNC_83(VAR_101):...\n", "VAR_256 = VAR_101.getDetails().permissions\n", "return {'write': VAR_256.isGroupWrite(), 'annotate': VAR_256.\n isGroupAnnotate(), 'read': VAR_256.isGroupRead()}\n" ]
[ "def getPerms(group):...\n", "p = group.getDetails().permissions\n", "return {'write': p.isGroupWrite(), 'annotate': p.isGroupAnnotate(), 'read':\n p.isGroupRead()}\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_52(VAR_21, VAR_27, VAR_28):...\n", "for extension in VAR_27:\n", "VAR_21 = VAR_21.filter(db.Books.data.any(db.Data.format == extension))\n", "for extension in VAR_28:\n", "VAR_21 = VAR_21.filter(not_(db.Books.data.any(db.Data.format == extension)))\n", "return VAR_21\n" ]
[ "def adv_search_extension(q, include_extension_inputs, exclude_extension_inputs...\n", "for extension in include_extension_inputs:\n", "q = q.filter(db.Books.data.any(db.Data.format == extension))\n", "for extension in exclude_extension_inputs:\n", "q = q.filter(not_(db.Books.data.any(db.Data.format == extension)))\n", "return q\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Assign'", "For", "Assign'", "Return'" ]
[ "@FUNC_2.__func__...\n", "\"\"\"docstring\"\"\"\n", "self.docstatus = 1\n", "self.save()\n" ]
[ "@whitelist.__func__...\n", "\"\"\"docstring\"\"\"\n", "self.docstatus = 1\n", "self.save()\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Expr'" ]
[ "def FUNC_0(VAR_1):...\n", "VAR_9 = FUNC_2({(404): FUNC_4, (500): FUNC_5})\n", "VAR_1.middlewares.append(VAR_9)\n", "VAR_1.middlewares.append(FUNC_1)\n" ]
[ "def setup_middlewares(app):...\n", "error_middleware = error_pages({(404): handle_404, (500): handle_500})\n", "app.middlewares.append(error_middleware)\n", "app.middlewares.append(cache_control_middleware)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_72(VAR_128):...\n", "\"\"\"docstring\"\"\"\n", "VAR_120 = VAR_128.split('.')[0]\n", "if not VAR_1.flags.in_install and VAR_120 not in FUNC_64():\n", "VAR_96(FUNC_0('App {0} is not installed').format(VAR_120), AppNotInstalledError\n )\n", "VAR_118 = '.'.join(VAR_128.split('.')[:-1])\n", "VAR_193 = VAR_128.split('.')[-1]\n", "return getattr(FUNC_55(VAR_118), VAR_193)\n" ]
[ "def get_attr(method_string):...\n", "\"\"\"docstring\"\"\"\n", "app_name = method_string.split('.')[0]\n", "if not local.flags.in_install and app_name not in get_installed_apps():\n", "throw(_('App {0} is not installed').format(app_name), AppNotInstalledError)\n", "modulename = '.'.join(method_string.split('.')[:-1])\n", "methodname = method_string.split('.')[-1]\n", "return getattr(get_module(modulename), methodname)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_0(VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "VAR_11 = ['--debug', '--json-logging', '--no-err-windows']\n", "if VAR_1.webengine:\n", "VAR_11 += ['--backend', 'webengine']\n", "VAR_11 += ['--backend', 'webkit']\n", "if qVersion() == '5.7.1':\n", "VAR_11 += ['--qt-flag', 'disable-seccomp-filter-sandbox']\n", "VAR_11.append('about:blank')\n", "return VAR_11\n" ]
[ "def _base_args(config):...\n", "\"\"\"docstring\"\"\"\n", "args = ['--debug', '--json-logging', '--no-err-windows']\n", "if config.webengine:\n", "args += ['--backend', 'webengine']\n", "args += ['--backend', 'webkit']\n", "if qVersion() == '5.7.1':\n", "args += ['--qt-flag', 'disable-seccomp-filter-sandbox']\n", "args.append('about:blank')\n", "return args\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "AugAssign'", "AugAssign'", "Condition", "AugAssign'", "Expr'", "Return'" ]
[ "def FUNC_12(self, VAR_0):...\n", "VAR_13 = VAR_0.patch('httpx.get')\n", "VAR_14 = VAR_0.patch('openapi_python_client.Path')\n", "VAR_15 = VAR_0.patch('yaml.safe_load')\n", "from openapi_python_client import _get_document\n", "VAR_6 = VAR_0.MagicMock()\n", "VAR_2(VAR_6=url, VAR_7=None)\n", "VAR_13.assert_called_once_with(VAR_6)\n", "VAR_14.assert_not_called()\n", "VAR_15.assert_called_once_with(VAR_13().content)\n" ]
[ "def test__get_document_url_no_path(self, mocker):...\n", "get = mocker.patch('httpx.get')\n", "Path = mocker.patch('openapi_python_client.Path')\n", "loads = mocker.patch('yaml.safe_load')\n", "from openapi_python_client import _get_document\n", "url = mocker.MagicMock()\n", "_get_document(url=url, path=None)\n", "get.assert_called_once_with(url)\n", "Path.assert_not_called()\n", "loads.assert_called_once_with(get().content)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "ImportFrom'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_5(VAR_13, VAR_17, VAR_18, VAR_19):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_18 is None:\n", "VAR_20 = ('SELECT rel_path, download_link FROM ' + VAR_13 +\n ' WHERE sequence_no = %s')\n", "if VAR_2:\n", "VAR_26 = mysql.connector.connect(user=DB_USER, password=DB_PASSWORD, host=\n DB_HOST, database=DB_DBNAME, port=DB_PORT)\n", "VAR_29 = 'file://' + os.path.join(VAR_3, VAR_13, VAR_18)\n", "VAR_29 = url_for('.get_object_src_http', VAR_13=dataset, VAR_18=rel_path)\n", "VAR_27 = VAR_26.cursor()\n", "return '<object id={} src={} hyperfind.external-link={} />'.format(quoteattr\n (url_for('.get_object_id', VAR_13=dataset, VAR_17=seq_no)), quoteattr(\n VAR_29), quoteattr(VAR_19))\n", "VAR_27.execute(VAR_20, (VAR_17,))\n", "VAR_28 = VAR_27.fetchone()\n", "if not VAR_28:\n", "return None\n", "VAR_18, VAR_19 = VAR_28[0], VAR_28[1]\n" ]
[ "def _get_object_element(dataset, seq_no, rel_path, download_link):...\n", "\"\"\"docstring\"\"\"\n", "if rel_path is None:\n", "query = ('SELECT rel_path, download_link FROM ' + dataset +\n ' WHERE sequence_no = %s')\n", "if LOCAL_OBJ_URI:\n", "cnx = mysql.connector.connect(user=DB_USER, password=DB_PASSWORD, host=\n DB_HOST, database=DB_DBNAME, port=DB_PORT)\n", "src_uri = 'file://' + os.path.join(DATAROOT, dataset, rel_path)\n", "src_uri = url_for('.get_object_src_http', dataset=dataset, rel_path=rel_path)\n", "cursor = cnx.cursor()\n", "return '<object id={} src={} hyperfind.external-link={} />'.format(quoteattr\n (url_for('.get_object_id', dataset=dataset, seq_no=seq_no)), quoteattr(\n src_uri), quoteattr(download_link))\n", "cursor.execute(query, (seq_no,))\n", "row = cursor.fetchone()\n", "if not row:\n", "return None\n", "rel_path, download_link = row[0], row[1]\n" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Expr'", "Assign'", "Condition", "Return'", "Assign'" ]
[ "def FUNC_26(self, VAR_5, VAR_30, VAR_31, VAR_6, VAR_19):...\n", "\"\"\"docstring\"\"\"\n", "VAR_2 = FUNC_1('/groups/%s/room/%s', VAR_30, VAR_6)\n", "return self.client.post_json(VAR_5=destination, VAR_2=path, VAR_3={\n 'requester_user_id': requester_user_id}, VAR_39=content, VAR_15=True)\n" ]
[ "def add_room_to_group(self, destination, group_id, requester_user_id,...\n", "\"\"\"docstring\"\"\"\n", "path = _create_v1_path('/groups/%s/room/%s', group_id, room_id)\n", "return self.client.post_json(destination=destination, path=path, args={\n 'requester_user_id': requester_user_id}, data=content, ignore_backoff=True)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_19(VAR_22):...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_22.inputs and not VAR_22.input_exprs and not VAR_22.input_examples:\n", "VAR_46 = FUNC_17(VAR_22.inputs, VAR_22.input_exprs, VAR_22.input_examples)\n", "FUNC_12(VAR_22.dir, VAR_22.tag_set, VAR_22.signature_def, VAR_46, VAR_22.\n outdir, VAR_22.overwrite, VAR_13=args.worker, VAR_14=args.init_tpu,\n VAR_15=args.use_tfrt, VAR_16=args.tf_debug)\n" ]
[ "def run(args):...\n", "\"\"\"docstring\"\"\"\n", "if not args.inputs and not args.input_exprs and not args.input_examples:\n", "tensor_key_feed_dict = load_inputs_from_input_arg_string(args.inputs, args.\n input_exprs, args.input_examples)\n", "run_saved_model_with_feed_dict(args.dir, args.tag_set, args.signature_def,\n tensor_key_feed_dict, args.outdir, args.overwrite, worker=args.worker,\n init_tpu=args.init_tpu, use_tfrt=args.use_tfrt, tf_debug=args.tf_debug)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Expr'" ]
[ "def FUNC_3(self, *, VAR_4: str) ->Set[str]:...\n", "\"\"\"docstring\"\"\"\n", "VAR_8 = super().get_imports(VAR_4=prefix)\n", "VAR_8.update({'from datetime import datetime', 'from typing import cast'})\n", "return VAR_8\n" ]
[ "def get_imports(self, *, prefix: str) ->Set[str]:...\n", "\"\"\"docstring\"\"\"\n", "imports = super().get_imports(prefix=prefix)\n", "imports.update({'from datetime import datetime', 'from typing import cast'})\n", "return imports\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_45(*VAR_79, **VAR_42):...\n", "\"\"\"docstring\"\"\"\n", "import frappe.model.document\n", "VAR_94 = frappe.model.document.get_doc(*VAR_79, **kwargs)\n", "if VAR_79 and len(VAR_79) > 1:\n", "VAR_46 = FUNC_42(VAR_79[0], VAR_79[1])\n", "return VAR_94\n", "VAR_1.document_cache[VAR_46] = VAR_94\n", "FUNC_10().hset('document_cache', VAR_46, VAR_94.as_dict())\n" ]
[ "def get_doc(*args, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "import frappe.model.document\n", "doc = frappe.model.document.get_doc(*args, **kwargs)\n", "if args and len(args) > 1:\n", "key = get_document_cache_key(args[0], args[1])\n", "return doc\n", "local.document_cache[key] = doc\n", "cache().hset('document_cache', key, doc.as_dict())\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Import'", "Assign'", "Condition", "Assign'", "Return'", "Assign'", "Expr'" ]
[ "def FUNC_5(self) ->Sequence[GeneratorError]:...\n", "\"\"\"docstring\"\"\"\n", "if not self.package_dir.is_dir():\n", "print(f'Updating {self.project_name}')\n", "shutil.rmtree(self.package_dir)\n", "self._create_package()\n", "self._build_models()\n", "self._build_api()\n", "self._reformat()\n", "return self._get_errors()\n" ]
[ "def update(self) ->Sequence[GeneratorError]:...\n", "\"\"\"docstring\"\"\"\n", "if not self.package_dir.is_dir():\n", "print(f'Updating {self.project_name}')\n", "shutil.rmtree(self.package_dir)\n", "self._create_package()\n", "self._build_models()\n", "self._build_api()\n", "self._reformat()\n", "return self._get_errors()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_4(self, VAR_5, VAR_9):...\n", "def FUNC_19(VAR_7):...\n", "if VAR_7 is None:\n", "return\n", "return self.get_image_id(VAR_5, VAR_7)\n", "return self._create_image_id(VAR_5, VAR_7)\n", "VAR_23 = VAR_9.copy()\n", "VAR_6 = VAR_23['id']\n", "VAR_23['id'] = FUNC_19(VAR_6)\n", "for VAR_48 in ['kernel_id', 'ramdisk_id']:\n", "return VAR_23\n", "VAR_7 = VAR_23['properties'][VAR_48]\n", "VAR_23['properties'][VAR_48] = FUNC_19(VAR_7)\n" ]
[ "def _translate_uuid_to_id(self, context, image):...\n", "def _find_or_create(image_uuid):...\n", "if image_uuid is None:\n", "return\n", "return self.get_image_id(context, image_uuid)\n", "return self._create_image_id(context, image_uuid)\n", "image_copy = image.copy()\n", "image_id = image_copy['id']\n", "image_copy['id'] = _find_or_create(image_id)\n", "for prop in ['kernel_id', 'ramdisk_id']:\n", "return image_copy\n", "image_uuid = image_copy['properties'][prop]\n", "image_copy['properties'][prop] = _find_or_create(image_uuid)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Condition", "Return'", "Return'", "Return'", "Assign'", "Assign'", "Assign'", "For", "Return'", "Assign'", "Assign'" ]
[ "def FUNC_15(self):...\n", "VAR_27 = np.array([[1], [2]])\n", "VAR_28 = np.array(range(6)).reshape(2, 3)\n", "VAR_29 = os.path.join(test.get_temp_dir(), 'input0.npy')\n", "VAR_30 = os.path.join(test.get_temp_dir(), 'input1.npy')\n", "np.save(VAR_29, VAR_27)\n", "np.save(VAR_30, VAR_28)\n", "VAR_21 = 'x0=' + VAR_29 + '[x0];x1=' + VAR_30\n", "VAR_31 = saved_model_cli.load_inputs_from_input_arg_string(VAR_21, '', '')\n", "self.assertTrue(np.all(VAR_31['x0'] == VAR_27))\n", "self.assertTrue(np.all(VAR_31['x1'] == VAR_28))\n" ]
[ "def testInputParserNPY(self):...\n", "x0 = np.array([[1], [2]])\n", "x1 = np.array(range(6)).reshape(2, 3)\n", "input0_path = os.path.join(test.get_temp_dir(), 'input0.npy')\n", "input1_path = os.path.join(test.get_temp_dir(), 'input1.npy')\n", "np.save(input0_path, x0)\n", "np.save(input1_path, x1)\n", "input_str = 'x0=' + input0_path + '[x0];x1=' + input1_path\n", "feed_dict = saved_model_cli.load_inputs_from_input_arg_string(input_str, '', ''\n )\n", "self.assertTrue(np.all(feed_dict['x0'] == x0))\n", "self.assertTrue(np.all(feed_dict['x1'] == x1))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def __init__(self, VAR_2: IReactorTime, VAR_15: IPullProducer, VAR_18:...\n", "self._clock = Clock(VAR_2)\n", "self._producer = VAR_15\n", "self._consumer = VAR_18\n", "self._looping_call = None\n", "self._start_loop()\n" ]
[ "def __init__(self, reactor: IReactorTime, producer: IPullProducer, consumer:...\n", "self._clock = Clock(reactor)\n", "self._producer = producer\n", "self._consumer = consumer\n", "self._looping_call = None\n", "self._start_loop()\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "import unittest\n", "import warnings\n", "from AccessControl import safe_builtins\n", "from zExceptions import NotFound\n", "from zope.component.testing import PlacelessSetup\n", "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 FUNC_1(self):...\n", "PlacelessSetup.tearDown(self)\n", "def FUNC_2(self):...\n", "def FUNC_3(self, VAR_0=None):...\n", "__allow_access_to_unprotected_subobjects__ = 1\n", "def __call__(self):...\n", "return 'dummy'\n" ]
[ "import unittest\n", "import warnings\n", "from AccessControl import safe_builtins\n", "from zExceptions import NotFound\n", "from zope.component.testing import PlacelessSetup\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", "def tearDown(self):...\n", "PlacelessSetup.tearDown(self)\n", "def _makeEngine(self):...\n", "def _makeContext(self, bindings=None):...\n", "__allow_access_to_unprotected_subobjects__ = 1\n", "def __call__(self):...\n", "return 'dummy'\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "ImportFrom'", "ImportFrom'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "FunctionDef'", "Assign'", "FunctionDef'", "Return'" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "VAR_7 = deepcopy(VAR_7)\n", "if VAR_5.requestBody is None or isinstance(VAR_5.requestBody, oai.Reference):\n", "return VAR_7\n", "VAR_7.form_body_reference = CLASS_2.parse_request_form_body(VAR_5.requestBody)\n", "VAR_17 = CLASS_2.parse_request_json_body(VAR_5.requestBody)\n", "if isinstance(VAR_17, ParseError):\n", "return ParseError(detail=f'cannot parse body of endpoint {endpoint.name}',\n VAR_5=json_body.data)\n", "VAR_7.multipart_body_reference = CLASS_2.parse_multipart_body(VAR_5.requestBody\n )\n", "if VAR_7.form_body_reference:\n", "VAR_7.relative_imports.add(FUNC_0(VAR_7.form_body_reference, VAR_1='..models'))\n", "if VAR_7.multipart_body_reference:\n", "VAR_7.relative_imports.add(FUNC_0(VAR_7.multipart_body_reference, VAR_1=\n '..models'))\n", "if VAR_17 is not None:\n", "VAR_7.json_body = VAR_17\n", "return VAR_7\n", "VAR_7.relative_imports.update(VAR_7.json_body.get_imports(VAR_1='..models'))\n" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "endpoint = deepcopy(endpoint)\n", "if data.requestBody is None or isinstance(data.requestBody, oai.Reference):\n", "return endpoint\n", "endpoint.form_body_reference = Endpoint.parse_request_form_body(data.\n requestBody)\n", "json_body = Endpoint.parse_request_json_body(data.requestBody)\n", "if isinstance(json_body, ParseError):\n", "return ParseError(detail=f'cannot parse body of endpoint {endpoint.name}',\n data=json_body.data)\n", "endpoint.multipart_body_reference = Endpoint.parse_multipart_body(data.\n requestBody)\n", "if endpoint.form_body_reference:\n", "endpoint.relative_imports.add(import_string_from_reference(endpoint.\n form_body_reference, prefix='..models'))\n", "if endpoint.multipart_body_reference:\n", "endpoint.relative_imports.add(import_string_from_reference(endpoint.\n multipart_body_reference, prefix='..models'))\n", "if json_body is not None:\n", "endpoint.json_body = json_body\n", "return endpoint\n", "endpoint.relative_imports.update(endpoint.json_body.get_imports(prefix=\n '..models'))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "Condition", "Return'", "Assign'", "For", "Expr'", "Condition", "Expr'", "Condition", "Assign'", "Return'", "Expr'" ]
[ "def FUNC_59(VAR_120, *VAR_119):...\n", "\"\"\"docstring\"\"\"\n", "return FUNC_61(VAR_120, *VAR_119)\n" ]
[ "def get_app_path(app_name, *joins):...\n", "\"\"\"docstring\"\"\"\n", "return get_pymodule_path(app_name, *joins)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "@app.route('/static/custom.css')...\n", "if not app.config['THEME_CONF'].get('use_custom_css', False):\n", "return ''\n", "return send_from_directory(Path(app.config['USER_DIR']) / 'css', app.config\n ['THEME_CONF']['custom_css_file'])\n" ]
[ "@app.route('/static/custom.css')...\n", "if not app.config['THEME_CONF'].get('use_custom_css', False):\n", "return ''\n", "return send_from_directory(Path(app.config['USER_DIR']) / 'css', app.config\n ['THEME_CONF']['custom_css_file'])\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Condition", "Return'", "Return'" ]
[ "def FUNC_3(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_14 = Mock(spec_set=['post_json_get_json'])\n", "VAR_14.post_json_get_json.side_effect = lambda *_, **__: defer.succeed({})\n", "self.make_worker_hs('synapse.app.pusher', {'start_pushers': True},\n proxied_http_client=http_client_mock)\n", "VAR_13 = self._create_pusher_and_send_msg('user')\n", "self.pump()\n", "VAR_14.post_json_get_json.assert_called_once()\n", "self.assertEqual(VAR_14.post_json_get_json.call_args[0][0],\n 'https://push.example.com/push')\n", "self.assertEqual(VAR_13, VAR_14.post_json_get_json.call_args[0][1][\n 'notification']['event_id'])\n" ]
[ "def test_send_push_single_worker(self):...\n", "\"\"\"docstring\"\"\"\n", "http_client_mock = Mock(spec_set=['post_json_get_json'])\n", "http_client_mock.post_json_get_json.side_effect = (lambda *_, **__: defer.\n succeed({}))\n", "self.make_worker_hs('synapse.app.pusher', {'start_pushers': True},\n proxied_http_client=http_client_mock)\n", "event_id = self._create_pusher_and_send_msg('user')\n", "self.pump()\n", "http_client_mock.post_json_get_json.assert_called_once()\n", "self.assertEqual(http_client_mock.post_json_get_json.call_args[0][0],\n 'https://push.example.com/push')\n", "self.assertEqual(event_id, http_client_mock.post_json_get_json.call_args[0]\n [1]['notification']['event_id'])\n" ]
[ 0, 0, 0, 0, 4, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_12(VAR_2, VAR_3, VAR_5, VAR_10, VAR_11, VAR_12, VAR_13=None,...\n", "\"\"\"docstring\"\"\"\n", "VAR_4 = saved_model_utils.get_meta_graph_def(VAR_2, VAR_3)\n", "VAR_27 = FUNC_2(VAR_4, VAR_5)\n", "for input_key_name in VAR_10.keys():\n", "if input_key_name not in VAR_27:\n", "VAR_39 = {VAR_27[key].name: tensor for key, tensor in VAR_10.items()}\n", "VAR_28 = FUNC_3(VAR_4, VAR_5)\n", "VAR_40 = sorted(VAR_28.keys())\n", "VAR_41 = [VAR_28[tensor_key].name for tensor_key in VAR_40]\n", "VAR_42 = None\n", "if VAR_15:\n", "logging.info('Using TFRT session.')\n", "if VAR_14:\n", "VAR_42 = config_pb2.ConfigProto(experimental=config_pb2.ConfigProto.\n Experimental(use_tfrt=True))\n", "print('Initializing TPU System ...')\n", "loader.load(VAR_80, VAR_3.split(','), VAR_2)\n", "VAR_80.run(tpu.initialize_system())\n", "if VAR_16:\n", "VAR_80 = local_cli_wrapper.LocalCLIDebugWrapperSession(VAR_80)\n", "VAR_69 = VAR_80.run(VAR_41, feed_dict=inputs_feed_dict)\n", "for i, output in enumerate(VAR_69):\n", "VAR_81 = VAR_40[i]\n", "print(\"\"\"Result for output key %s:\n%s\"\"\" % (VAR_81, output))\n", "if VAR_11:\n", "if not os.path.isdir(VAR_11):\n", "os.makedirs(VAR_11)\n", "VAR_82 = os.path.join(VAR_11, VAR_81 + '.npy')\n", "if not VAR_12 and os.path.exists(VAR_82):\n", "np.save(VAR_82, output)\n", "print('Output %s is saved to %s' % (VAR_81, VAR_82))\n" ]
[ "def run_saved_model_with_feed_dict(saved_model_dir, tag_set,...\n", "\"\"\"docstring\"\"\"\n", "meta_graph_def = saved_model_utils.get_meta_graph_def(saved_model_dir, tag_set)\n", "inputs_tensor_info = _get_inputs_tensor_info_from_meta_graph_def(meta_graph_def\n , signature_def_key)\n", "for input_key_name in input_tensor_key_feed_dict.keys():\n", "if input_key_name not in inputs_tensor_info:\n", "inputs_feed_dict = {inputs_tensor_info[key].name: tensor for key, tensor in\n input_tensor_key_feed_dict.items()}\n", "outputs_tensor_info = _get_outputs_tensor_info_from_meta_graph_def(\n meta_graph_def, signature_def_key)\n", "output_tensor_keys_sorted = sorted(outputs_tensor_info.keys())\n", "output_tensor_names_sorted = [outputs_tensor_info[tensor_key].name for\n tensor_key in output_tensor_keys_sorted]\n", "config = None\n", "if use_tfrt:\n", "logging.info('Using TFRT session.')\n", "if init_tpu:\n", "config = config_pb2.ConfigProto(experimental=config_pb2.ConfigProto.\n Experimental(use_tfrt=True))\n", "print('Initializing TPU System ...')\n", "loader.load(sess, tag_set.split(','), saved_model_dir)\n", "sess.run(tpu.initialize_system())\n", "if tf_debug:\n", "sess = local_cli_wrapper.LocalCLIDebugWrapperSession(sess)\n", "outputs = sess.run(output_tensor_names_sorted, feed_dict=inputs_feed_dict)\n", "for i, output in enumerate(outputs):\n", "output_tensor_key = output_tensor_keys_sorted[i]\n", "print(\"\"\"Result for output key %s:\n%s\"\"\" % (output_tensor_key, output))\n", "if outdir:\n", "if not os.path.isdir(outdir):\n", "os.makedirs(outdir)\n", "output_full_path = os.path.join(outdir, output_tensor_key + '.npy')\n", "if not overwrite_flag and os.path.exists(output_full_path):\n", "np.save(output_full_path, output)\n", "print('Output %s is saved to %s' % (output_tensor_key, output_full_path))\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 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "For", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Expr'", "Expr'", "Expr'", "Condition", "Assign'", "Assign'", "For", "Assign'", "Expr'", "Condition", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_73(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_69 = '#second:test'\n", "self._set_alias_via_directory(VAR_69)\n", "self._set_canonical_alias({'alias': self.alias, 'alt_aliases': [self.alias]})\n", "self._set_canonical_alias({'alias': self.alias, 'alt_aliases': [self.alias,\n VAR_69]})\n", "VAR_61 = self._get_canonical_alias()\n", "self.assertEqual(VAR_61, {'alias': self.alias, 'alt_aliases': [self.alias,\n VAR_69]})\n" ]
[ "def test_add_alias(self):...\n", "\"\"\"docstring\"\"\"\n", "second_alias = '#second:test'\n", "self._set_alias_via_directory(second_alias)\n", "self._set_canonical_alias({'alias': self.alias, 'alt_aliases': [self.alias]})\n", "self._set_canonical_alias({'alias': self.alias, 'alt_aliases': [self.alias,\n second_alias]})\n", "res = self._get_canonical_alias()\n", "self.assertEqual(res, {'alias': self.alias, 'alt_aliases': [self.alias,\n second_alias]})\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "import json\n", "import os\n", "import urllib.parse\n", "from binascii import unhexlify\n", "from mock import Mock\n", "from twisted.internet.defer import Deferred\n", "import synapse.rest.admin\n", "from synapse.http.server import JsonResource\n", "from synapse.logging.context import make_deferred_yieldable\n", "from synapse.rest.admin import VersionServlet\n", "from synapse.rest.client.v1 import login, room\n", "from synapse.rest.client.v2_alpha import groups\n", "from tests import unittest\n", "from tests.server import FakeSite, make_request\n", "VAR_0 = '/_synapse/admin/v1/server_version'\n", "def FUNC_0(self):...\n", "VAR_11 = JsonResource(self.hs)\n", "VersionServlet(self.hs).register(VAR_11)\n", "return VAR_11\n" ]
[ "import json\n", "import os\n", "import urllib.parse\n", "from binascii import unhexlify\n", "from mock import Mock\n", "from twisted.internet.defer import Deferred\n", "import synapse.rest.admin\n", "from synapse.http.server import JsonResource\n", "from synapse.logging.context import make_deferred_yieldable\n", "from synapse.rest.admin import VersionServlet\n", "from synapse.rest.client.v1 import login, room\n", "from synapse.rest.client.v2_alpha import groups\n", "from tests import unittest\n", "from tests.server import FakeSite, make_request\n", "url = '/_synapse/admin/v1/server_version'\n", "def create_test_resource(self):...\n", "resource = JsonResource(self.hs)\n", "VersionServlet(self.hs).register(resource)\n", "return resource\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "FunctionDef'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_2(VAR_7: str) ->Callable:...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_12(VAR_5, VAR_21, VAR_22, VAR_23='crop'):...\n", "if VAR_5[0:6] != 'mxc://':\n", "return ''\n", "VAR_61 = VAR_5[6:]\n", "VAR_62 = None\n", "if '#' in VAR_61:\n", "VAR_61, VAR_62 = VAR_61.split('#', 1)\n", "VAR_63 = {'width': VAR_21, 'height': VAR_22, 'method': VAR_23}\n", "VAR_62 = '#' + VAR_62\n", "return '%s_matrix/media/v1/thumbnail/%s?%s%s' % (VAR_7, VAR_61, urllib.\n parse.urlencode(VAR_63), VAR_62 or '')\n" ]
[ "def _create_mxc_to_http_filter(public_baseurl: str) ->Callable:...\n", "\"\"\"docstring\"\"\"\n", "def mxc_to_http_filter(value, width, height, resize_method='crop'):...\n", "if value[0:6] != 'mxc://':\n", "return ''\n", "server_and_media_id = value[6:]\n", "fragment = None\n", "if '#' in server_and_media_id:\n", "server_and_media_id, fragment = server_and_media_id.split('#', 1)\n", "params = {'width': width, 'height': height, 'method': resize_method}\n", "fragment = '#' + fragment\n", "return '%s_matrix/media/v1/thumbnail/%s?%s%s' % (public_baseurl,\n server_and_media_id, urllib.parse.urlencode(params), fragment or '')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Condition", "Return'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "async def FUNC_28(VAR_40, VAR_41, VAR_48, **VAR_3):...\n", "self.assertEqual(VAR_40, self.mock_perspective_server.server_name)\n", "self.assertEqual(VAR_41, '/_matrix/key/v2/query')\n", "VAR_51 = VAR_48['server_keys']\n", "self.assertEqual(list(VAR_51[VAR_14].keys()), [VAR_15])\n", "return {'server_keys': [VAR_16]}\n" ]
[ "async def post_json(destination, path, data, **kwargs):...\n", "self.assertEqual(destination, self.mock_perspective_server.server_name)\n", "self.assertEqual(path, '/_matrix/key/v2/query')\n", "q = data['server_keys']\n", "self.assertEqual(list(q[expected_server_name].keys()), [expected_key_id])\n", "return {'server_keys': [response]}\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Expr'", "Expr'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_12(VAR_2, VAR_3, VAR_5, VAR_10, VAR_11, VAR_12, VAR_13=None,...\n", "\"\"\"docstring\"\"\"\n", "VAR_4 = saved_model_utils.get_meta_graph_def(VAR_2, VAR_3)\n", "VAR_24 = FUNC_2(VAR_4, VAR_5)\n", "for input_key_name in VAR_10.keys():\n", "if input_key_name not in VAR_24:\n", "VAR_36 = {VAR_24[key].name: tensor for key, tensor in VAR_10.items()}\n", "VAR_25 = FUNC_3(VAR_4, VAR_5)\n", "VAR_37 = sorted(VAR_25.keys())\n", "VAR_38 = [VAR_25[tensor_key].name for tensor_key in VAR_37]\n", "if VAR_14:\n", "print('Initializing TPU System ...')\n", "loader.load(VAR_77, VAR_3.split(','), VAR_2)\n", "VAR_77.run(tpu.initialize_system())\n", "if VAR_15:\n", "VAR_77 = local_cli_wrapper.LocalCLIDebugWrapperSession(VAR_77)\n", "VAR_66 = VAR_77.run(VAR_38, feed_dict=inputs_feed_dict)\n", "for i, output in enumerate(VAR_66):\n", "VAR_78 = VAR_37[i]\n", "print(\"\"\"Result for output key %s:\n%s\"\"\" % (VAR_78, output))\n", "if VAR_11:\n", "if not os.path.isdir(VAR_11):\n", "os.makedirs(VAR_11)\n", "VAR_79 = os.path.join(VAR_11, VAR_78 + '.npy')\n", "if not VAR_12 and os.path.exists(VAR_79):\n", "np.save(VAR_79, output)\n", "print('Output %s is saved to %s' % (VAR_78, VAR_79))\n" ]
[ "def run_saved_model_with_feed_dict(saved_model_dir, tag_set,...\n", "\"\"\"docstring\"\"\"\n", "meta_graph_def = saved_model_utils.get_meta_graph_def(saved_model_dir, tag_set)\n", "inputs_tensor_info = _get_inputs_tensor_info_from_meta_graph_def(meta_graph_def\n , signature_def_key)\n", "for input_key_name in input_tensor_key_feed_dict.keys():\n", "if input_key_name not in inputs_tensor_info:\n", "inputs_feed_dict = {inputs_tensor_info[key].name: tensor for key, tensor in\n input_tensor_key_feed_dict.items()}\n", "outputs_tensor_info = _get_outputs_tensor_info_from_meta_graph_def(\n meta_graph_def, signature_def_key)\n", "output_tensor_keys_sorted = sorted(outputs_tensor_info.keys())\n", "output_tensor_names_sorted = [outputs_tensor_info[tensor_key].name for\n tensor_key in output_tensor_keys_sorted]\n", "if init_tpu:\n", "print('Initializing TPU System ...')\n", "loader.load(sess, tag_set.split(','), saved_model_dir)\n", "sess.run(tpu.initialize_system())\n", "if tf_debug:\n", "sess = local_cli_wrapper.LocalCLIDebugWrapperSession(sess)\n", "outputs = sess.run(output_tensor_names_sorted, feed_dict=inputs_feed_dict)\n", "for i, output in enumerate(outputs):\n", "output_tensor_key = output_tensor_keys_sorted[i]\n", "print(\"\"\"Result for output key %s:\n%s\"\"\" % (output_tensor_key, output))\n", "if outdir:\n", "if not os.path.isdir(outdir):\n", "os.makedirs(outdir)\n", "output_full_path = os.path.join(outdir, output_tensor_key + '.npy')\n", "if not overwrite_flag and os.path.exists(output_full_path):\n", "np.save(output_full_path, output)\n", "print('Output %s is saved to %s' % (output_tensor_key, output_full_path))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "For", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Condition", "Assign'", "Assign'", "For", "Assign'", "Expr'", "Condition", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_6(VAR_20, VAR_27, VAR_28):...\n", "VAR_66 = VAR_20.split()\n", "for VAR_30 in VAR_66:\n", "if len(VAR_30) > VAR_27:\n", "return VAR_20\n", "VAR_94 = FUNC_7(VAR_30, VAR_27, VAR_28)\n", "VAR_20 = VAR_20.replace(VAR_30, VAR_94)\n" ]
[ "def _break_text(text, max_width, break_character):...\n", "words = text.split()\n", "for word in words:\n", "if len(word) > max_width:\n", "return text\n", "replacement = _insert_break(word, max_width, break_character)\n", "text = text.replace(word, replacement)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Condition", "Return'", "Assign'", "Assign'" ]
[ "def FUNC_12(self):...\n", "VAR_22, VAR_23 = self.make_request('GET', '/rooms/roomdoesnotexist/members')\n", "self.assertEquals(403, VAR_23.code, msg=channel.result['body'])\n" ]
[ "def test_get_member_list_no_room(self):...\n", "request, channel = self.make_request('GET', '/rooms/roomdoesnotexist/members')\n", "self.assertEquals(403, channel.code, msg=channel.result['body'])\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_38(self):...\n", "VAR_85 = self.denied_tags or ''\n", "return [t.strip() for t in VAR_85.split(',')]\n" ]
[ "def list_denied_tags(self):...\n", "mct = self.denied_tags or ''\n", "return [t.strip() for t in mct.split(',')]\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_5(self):...\n", "VAR_5 = {'types': ['m.room.message', 'org.matrix.foo.bar']}\n", "VAR_6 = FUNC_0(sender='@foo:bar', type='m.room.message', room_id='!foo:bar')\n", "self.assertTrue(Filter(VAR_5).check(VAR_6))\n" ]
[ "def test_definition_types_works_with_literals(self):...\n", "definition = {'types': ['m.room.message', 'org.matrix.foo.bar']}\n", "event = MockEvent(sender='@foo:bar', type='m.room.message', room_id='!foo:bar')\n", "self.assertTrue(Filter(definition).check(event))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_2(self):...\n", "" ]
[ "def _makeEngine(self):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_5(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_34 = parse.quote('☃'.encode('utf8')).encode('ascii')\n", "VAR_32 = self._req(b\"inline; filename*=utf-8''\" + VAR_34 + self.test_image.\n extension)\n", "VAR_33 = VAR_32.headers\n", "self.assertEqual(VAR_33.getRawHeaders(b'Content-Type'), [self.test_image.\n content_type])\n", "self.assertEqual(VAR_33.getRawHeaders(b'Content-Disposition'), [\n b\"inline; filename*=utf-8''\" + VAR_34 + self.test_image.extension])\n" ]
[ "def test_disposition_filenamestar_utf8escaped(self):...\n", "\"\"\"docstring\"\"\"\n", "filename = parse.quote('☃'.encode('utf8')).encode('ascii')\n", "channel = self._req(b\"inline; filename*=utf-8''\" + filename + self.\n test_image.extension)\n", "headers = channel.headers\n", "self.assertEqual(headers.getRawHeaders(b'Content-Type'), [self.test_image.\n content_type])\n", "self.assertEqual(headers.getRawHeaders(b'Content-Disposition'), [\n b\"inline; filename*=utf-8''\" + filename + self.test_image.extension])\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_10(VAR_19):...\n", "return ' '.join(map(pipes.quote, VAR_19))\n" ]
[ "def list2cmdline(cmd_list):...\n", "return ' '.join(map(pipes.quote, cmd_list))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_15(VAR_37):...\n", "VAR_39, VAR_23 = VAR_37\n", "VAR_16.write(VAR_39)\n", "return VAR_23\n" ]
[ "def write_to(r):...\n", "data, response = r\n", "output_stream.write(data)\n", "return response\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Return'" ]
[ "@property...\n", "return FUNC_0(self.time_spent)\n" ]
[ "@property...\n", "return format_time_spent(self.time_spent)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_16():...\n", "VAR_1.message_log = []\n" ]
[ "def clear_messages():...\n", "local.message_log = []\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "@VAR_0.route('/rev/<int:rev_id>/meta')...\n", "VAR_29 = g.conn.session.query(QueryRevision).get(VAR_8)\n", "if not VAR_29:\n", "return Response('No such query revision id', status=404)\n", "return Response(json.dumps({'latest_run': VAR_29.latest_run, 'rev': VAR_29,\n 'query': VAR_29.query}, default=json_formatter), mimetype=\n 'application/json', headers={'Access-Control-Allow-Origin': '*'})\n" ]
[ "@app.route('/rev/<int:rev_id>/meta')...\n", "rev = g.conn.session.query(QueryRevision).get(rev_id)\n", "if not rev:\n", "return Response('No such query revision id', status=404)\n", "return Response(json.dumps({'latest_run': rev.latest_run, 'rev': rev,\n 'query': rev.query}, default=json_formatter), mimetype=\n 'application/json', headers={'Access-Control-Allow-Origin': '*'})\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_42(self):...\n", "\"\"\"docstring\"\"\"\n", "return ''\n" ]
[ "def placeholder(self):...\n", "\"\"\"docstring\"\"\"\n", "return ''\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "@app.route('/notes/new', methods=['GET', 'POST'])...\n", "VAR_9 = forms.NewNoteForm()\n", "VAR_8 = 'root directory'\n", "VAR_9.path.choices = [('', VAR_8)] + [(pathname, pathname) for pathname in\n data.get_dirs()]\n", "if VAR_9.validate_on_submit():\n", "VAR_7 = VAR_9.path.data\n", "VAR_7 = request.args.get('path', VAR_8).strip('/')\n", "VAR_10 = VAR_9.tags.data.split(',') if VAR_9.tags.data != '' else []\n", "VAR_9.path.data = VAR_7\n", "VAR_10 = [tag.strip() for tag in VAR_10]\n", "return render_template('/dataobjs/new.html', title='New Note', VAR_9=form)\n", "VAR_31 = DataObj(title=form.title.data, VAR_7=path, VAR_10=tags, type='note')\n", "VAR_32 = VAR_31.insert()\n", "if VAR_32:\n", "flash('Note Saved!', 'success')\n", "return redirect(f'/dataobj/{VAR_32}')\n" ]
[ "@app.route('/notes/new', methods=['GET', 'POST'])...\n", "form = forms.NewNoteForm()\n", "default_dir = 'root directory'\n", "form.path.choices = [('', default_dir)] + [(pathname, pathname) for\n pathname in data.get_dirs()]\n", "if form.validate_on_submit():\n", "path = form.path.data\n", "path = request.args.get('path', default_dir).strip('/')\n", "tags = form.tags.data.split(',') if form.tags.data != '' else []\n", "form.path.data = path\n", "tags = [tag.strip() for tag in tags]\n", "return render_template('/dataobjs/new.html', title='New Note', form=form)\n", "note = DataObj(title=form.title.data, path=path, tags=tags, type='note')\n", "note_id = note.insert()\n", "if note_id:\n", "flash('Note Saved!', 'success')\n", "return redirect(f'/dataobj/{note_id}')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_35(self):...\n", "from Products.PageTemplates.Expressions import ZopeContext\n", "return ZopeContext\n" ]
[ "def _getTargetClass(self):...\n", "from Products.PageTemplates.Expressions import ZopeContext\n", "return ZopeContext\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "Return'" ]
[ "@VAR_2.route('/get_authors_json', methods=['GET'])...\n", "return calibre_db.get_typeahead(db.Authors, request.args.get('q'), ('|', ','))\n" ]
[ "@web.route('/get_authors_json', methods=['GET'])...\n", "return calibre_db.get_typeahead(db.Authors, request.args.get('q'), ('|', ','))\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "async def FUNC_20(self, VAR_5, VAR_6):...\n", "\"\"\"docstring\"\"\"\n", "VAR_1 = VAR_6\n", "VAR_0.debug('on_send_leave_request: Got event: %s, signatures: %s', VAR_1.\n event_id, VAR_1.signatures)\n", "if get_domain_from_id(VAR_1.sender) != VAR_5:\n", "VAR_0.info('Got /send_leave request for user %r from different origin %s',\n VAR_1.sender, VAR_5)\n", "VAR_1.internal_metadata.outlier = False\n", "await self._handle_new_event(VAR_5, VAR_1)\n", "VAR_0.debug('on_send_leave_request: After _handle_new_event: %s, sigs: %s',\n VAR_1.event_id, VAR_1.signatures)\n", "return None\n" ]
[ "async def on_send_leave_request(self, origin, pdu):...\n", "\"\"\"docstring\"\"\"\n", "event = pdu\n", "logger.debug('on_send_leave_request: Got event: %s, signatures: %s', event.\n event_id, event.signatures)\n", "if get_domain_from_id(event.sender) != origin:\n", "logger.info('Got /send_leave request for user %r from different origin %s',\n event.sender, origin)\n", "event.internal_metadata.outlier = False\n", "await self._handle_new_event(origin, event)\n", "logger.debug('on_send_leave_request: After _handle_new_event: %s, sigs: %s',\n event.event_id, event.signatures)\n", "return None\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Docstring", "Assign'", "Expr'", "Condition", "Expr'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_1(self, VAR_2, VAR_3, VAR_4):...\n", "self.cookies[VAR_2, VAR_4] = VAR_3\n" ]
[ "def setCookie(self, cookie_name, cookie_value, path):...\n", "self.cookies[cookie_name, path] = cookie_value\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "def FUNC_3(VAR_8):...\n", "VAR_12 = None\n", "if settings.AUTH_TYPE == 'hmac':\n", "VAR_12 = FUNC_4(VAR_8)\n", "if settings.AUTH_TYPE == 'api_key':\n", "if org_settings['auth_jwt_login_enabled'] and VAR_12 is None:\n", "VAR_12 = FUNC_7(VAR_8)\n", "VAR_1.warning('Unknown authentication type ({}). Using default (HMAC).'.\n format(settings.AUTH_TYPE))\n", "VAR_12 = FUNC_8(VAR_8)\n", "return VAR_12\n", "VAR_12 = FUNC_4(VAR_8)\n" ]
[ "def request_loader(request):...\n", "user = None\n", "if settings.AUTH_TYPE == 'hmac':\n", "user = hmac_load_user_from_request(request)\n", "if settings.AUTH_TYPE == 'api_key':\n", "if org_settings['auth_jwt_login_enabled'] and user is None:\n", "user = api_key_load_user_from_request(request)\n", "logger.warning('Unknown authentication type ({}). Using default (HMAC).'.\n format(settings.AUTH_TYPE))\n", "user = jwt_token_load_user_from_request(request)\n", "return user\n", "user = hmac_load_user_from_request(request)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Expr'", "Assign'", "Return'", "Assign'" ]
[ "def FUNC_13(VAR_23):...\n", "\"\"\"docstring\"\"\"\n", "VAR_31 = VAR_0.findall(VAR_23)\n", "if not VAR_31:\n", "return [VAR_23]\n", "VAR_31 = [e.encode('ascii').decode('unicode_escape') for e in VAR_31]\n", "return VAR_31\n" ]
[ "def parse_etags(etag_str):...\n", "\"\"\"docstring\"\"\"\n", "etags = ETAG_MATCH.findall(etag_str)\n", "if not etags:\n", "return [etag_str]\n", "etags = [e.encode('ascii').decode('unicode_escape') for e in etags]\n", "return etags\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Return'", "Assign'", "Return'" ]
[ "def FUNC_76(self, VAR_45, VAR_46):...\n", "\"\"\"docstring\"\"\"\n", "if date_diff(self.get(VAR_46), self.get(VAR_45)) < 0:\n", "frappe.throw(_('{0} must be after {1}').format(frappe.bold(self.meta.\n get_label(VAR_46)), frappe.bold(self.meta.get_label(VAR_45))), frappe.\n exceptions.InvalidDates)\n" ]
[ "def validate_from_to_dates(self, from_date_field, to_date_field):...\n", "\"\"\"docstring\"\"\"\n", "if date_diff(self.get(to_date_field), self.get(from_date_field)) < 0:\n", "frappe.throw(_('{0} must be after {1}').format(frappe.bold(self.meta.\n get_label(to_date_field)), frappe.bold(self.meta.get_label(\n from_date_field))), frappe.exceptions.InvalidDates)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'" ]
[ "def FUNC_30(self):...\n", "VAR_27 = widgets.AdminSplitDateTime()\n", "self.assertHTMLEqual(conditional_escape(VAR_27.render('test', datetime(2007,\n 12, 1, 9, 30))), 'string')\n" ]
[ "def test_render(self):...\n", "w = widgets.AdminSplitDateTime()\n", "self.assertHTMLEqual(conditional_escape(w.render('test', datetime(2007, 12,\n 1, 9, 30))),\n '<p class=\"datetime\">Date: <input value=\"2007-12-01\" type=\"text\" class=\"vDateField\" name=\"test_0\" size=\"10\" /><br />Time: <input value=\"09:30:00\" type=\"text\" class=\"vTimeField\" name=\"test_1\" size=\"8\" /></p>'\n )\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_3(VAR_12, VAR_13):...\n", "VAR_22 = ['name']\n", "if VAR_12.search_fields:\n", "for d in VAR_12.search_fields.split(','):\n", "if VAR_12.title_field and VAR_12.title_field not in VAR_22:\n", "if d.strip() not in VAR_22:\n", "VAR_22.append(VAR_12.title_field)\n", "if VAR_13 not in VAR_22:\n", "VAR_22.append(d.strip())\n", "VAR_22.append(VAR_13)\n", "return VAR_22\n" ]
[ "def get_std_fields_list(meta, key):...\n", "sflist = ['name']\n", "if meta.search_fields:\n", "for d in meta.search_fields.split(','):\n", "if meta.title_field and meta.title_field not in sflist:\n", "if d.strip() not in sflist:\n", "sflist.append(meta.title_field)\n", "if key not in sflist:\n", "sflist.append(d.strip())\n", "sflist.append(key)\n", "return sflist\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "For", "Condition", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Return'" ]
[ "@defer.inlineCallbacks...\n", "VAR_7 = {'presence': {'types': ['m.*']}}\n", "VAR_8 = yield defer.ensureDeferred(self.datastore.add_user_filter(VAR_0=\n user_localpart + '2', VAR_10=user_filter_json))\n", "VAR_6 = FUNC_0(event_id='$asdasd:localhost', sender='@foo:bar', type=\n 'custom.avatar.3d.crazy')\n", "VAR_9 = [VAR_6]\n", "VAR_10 = yield defer.ensureDeferred(self.filtering.get_user_filter(VAR_0=\n user_localpart + '2', VAR_8=filter_id))\n", "VAR_11 = VAR_10.filter_presence(VAR_9=events)\n", "self.assertEquals([], VAR_11)\n" ]
[ "@defer.inlineCallbacks...\n", "user_filter_json = {'presence': {'types': ['m.*']}}\n", "filter_id = yield defer.ensureDeferred(self.datastore.add_user_filter(\n user_localpart=user_localpart + '2', user_filter=user_filter_json))\n", "event = MockEvent(event_id='$asdasd:localhost', sender='@foo:bar', type=\n 'custom.avatar.3d.crazy')\n", "events = [event]\n", "user_filter = yield defer.ensureDeferred(self.filtering.get_user_filter(\n user_localpart=user_localpart + '2', filter_id=filter_id))\n", "results = user_filter.filter_presence(events=events)\n", "self.assertEquals([], results)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "@staticmethod...\n", "FUNC_18()\n" ]
[ "@staticmethod...\n", "_callback()\n" ]
[ 0, 0 ]
[ "Condition", "Expr'" ]
[ "def FUNC_0():...\n", "VAR_3 = open('config', 'r')\n", "VAR_4 = ast.literal_eval(VAR_3.read())\n", "VAR_3.close()\n", "VAR_5 = VAR_4['max_cache_size']\n", "VAR_6 = VAR_4['host']\n", "VAR_7 = VAR_4['port']\n", "return VAR_5, VAR_6, VAR_7\n" ]
[ "def get_config():...\n", "f = open('config', 'r')\n", "conf = ast.literal_eval(f.read())\n", "f.close()\n", "cache_size = conf['max_cache_size']\n", "host = conf['host']\n", "port = conf['port']\n", "return cache_size, host, port\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_48(VAR_62, VAR_108=True):...\n", "\"\"\"docstring\"\"\"\n", "import frappe.model.meta\n", "return frappe.model.meta.get_meta(VAR_62, VAR_108=cached)\n" ]
[ "def get_meta(doctype, cached=True):...\n", "\"\"\"docstring\"\"\"\n", "import frappe.model.meta\n", "return frappe.model.meta.get_meta(doctype, cached=cached)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Import'", "Return'" ]
[ "def FUNC_42(self, VAR_25, *VAR_0, **VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "if 'flags' in VAR_1:\n", "if hasattr(self, VAR_25) and hasattr(getattr(self, VAR_25), '__call__'):\n", "VAR_72 = lambda self, *VAR_0, **VAR_1: getattr(self, VAR_25)(*VAR_0, **kwargs)\n", "VAR_72 = lambda self, *VAR_0, **VAR_1: None\n", "VAR_72.__name__ = str(VAR_25)\n", "VAR_66 = CLASS_0.hook(VAR_72)(self, *VAR_0, **kwargs)\n", "self.run_notifications(VAR_25)\n", "run_webhooks(self, VAR_25)\n", "run_server_script_for_doc_event(self, VAR_25)\n", "return VAR_66\n" ]
[ "def run_method(self, method, *args, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "if 'flags' in kwargs:\n", "if hasattr(self, method) and hasattr(getattr(self, method), '__call__'):\n", "fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)\n", "fn = lambda self, *args, **kwargs: None\n", "fn.__name__ = str(method)\n", "out = Document.hook(fn)(self, *args, **kwargs)\n", "self.run_notifications(method)\n", "run_webhooks(self, method)\n", "run_server_script_for_doc_event(self, method)\n", "return out\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Return'" ]