lines
sequencelengths
1
383
raw_lines
sequencelengths
1
383
label
sequencelengths
1
383
type
sequencelengths
1
383
[ "@VAR_0.route('/run/<int:qrun_id>/status')...\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({'status': VAR_27.status_message, 'extra': json.\n loads(VAR_27.extra_info or '{}'), 'timestamp': VAR_27.timestamp.\n strftime('%s')}), mimetype='application/json', headers={\n 'Access-Control-Allow-Origin': '*'})\n" ]
[ "@app.route('/run/<int:qrun_id>/status')...\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({'status': qrun.status_message, 'extra': json.\n loads(qrun.extra_info or '{}'), 'timestamp': qrun.timestamp.strftime(\n '%s')}), mimetype='application/json', headers={\n 'Access-Control-Allow-Origin': '*'})\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Return'", "Return'" ]
[ "async def FUNC_18(VAR_3):...\n", "VAR_3.write(b'response')\n", "VAR_3.finish()\n" ]
[ "async def callback(request):...\n", "request.write(b'response')\n", "request.finish()\n" ]
[ 0, 0, 0 ]
[ "AsyncFunctionDef'", "Expr'", "Expr'" ]
[ "def FUNC_9(self):...\n", "if not self.get('roles') and self.is_standard == 'No':\n", "VAR_5 = frappe.get_meta(self.ref_doctype)\n", "if not VAR_5.istable:\n", "VAR_35 = [{'role': d.role} for d in VAR_5.permissions if d.permlevel == 0]\n", "self.set('roles', VAR_35)\n" ]
[ "def set_doctype_roles(self):...\n", "if not self.get('roles') and self.is_standard == 'No':\n", "meta = frappe.get_meta(self.ref_doctype)\n", "if not meta.istable:\n", "roles = [{'role': d.role} for d in meta.permissions if d.permlevel == 0]\n", "self.set('roles', roles)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Condition", "Assign'", "Expr'" ]
[ "def FUNC_82(VAR_62, *VAR_79, **VAR_42):...\n", "\"\"\"docstring\"\"\"\n", "import frappe.model.db_query\n", "return frappe.model.db_query.DatabaseQuery(VAR_62).execute(None, *VAR_79,\n **kwargs)\n" ]
[ "def get_list(doctype, *args, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "import frappe.model.db_query\n", "return frappe.model.db_query.DatabaseQuery(doctype).execute(None, *args, **\n kwargs)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Import'", "Return'" ]
[ "@VAR_0.route('/api/preferences/set/<key>/<value>')...\n", "if get_user() is None:\n", "return 'Authentication required', 401\n", "VAR_31()[VAR_10] = None if VAR_11 == 'null' else VAR_11\n", "return Response(json.dumps({'key': VAR_10, 'success': ''})), 201\n" ]
[ "@app.route('/api/preferences/set/<key>/<value>')...\n", "if get_user() is None:\n", "return 'Authentication required', 401\n", "get_preferences()[key] = None if value == 'null' else value\n", "return Response(json.dumps({'key': key, 'success': ''})), 201\n" ]
[ 0, 0, 0, 0, 2 ]
[ "Condition", "Condition", "Return'", "Assign'", "Return'" ]
[ "def FUNC_4(self):...\n", "self.edit_unit('Hello, world!\\n', 'Nazdar svete2!\\n')\n", "self.test_credits_one(VAR_1=2)\n" ]
[ "def test_credits_more(self):...\n", "self.edit_unit('Hello, world!\\n', 'Nazdar svete2!\\n')\n", "self.test_credits_one(expected_count=2)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'" ]
[ "def FUNC_23(self):...\n", "self.parser = saved_model_cli.create_parser()\n", "VAR_9 = test.test_src_dir_path(VAR_0)\n", "VAR_44 = np.array([[1], [2]])\n", "VAR_45 = np.zeros((6, 3))\n", "VAR_31 = os.path.join(test.get_temp_dir(), 'testRunCommand_inputs.npz')\n", "np.savez(VAR_31, VAR_26=x, VAR_27=x_notused)\n", "VAR_46 = os.path.join(test.get_temp_dir(), 'outputs.npy')\n", "if os.path.exists(VAR_46):\n", "os.remove(VAR_46)\n", "VAR_10 = self.parser.parse_args(['run', '--dir', VAR_9, '--tag_set',\n 'serve', '--signature_def', 'regress_x2_to_y3', '--inputs', 'inputs=' +\n VAR_31 + '[x0]', '--outdir', test.get_temp_dir()])\n", "saved_model_cli.run(VAR_10)\n", "VAR_42 = np.load(VAR_46)\n", "VAR_43 = np.array([[3.5], [4.0]])\n", "self.assertAllClose(VAR_43, VAR_42)\n" ]
[ "def testRunCommandExistingOutdir(self):...\n", "self.parser = saved_model_cli.create_parser()\n", "base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n", "x = np.array([[1], [2]])\n", "x_notused = np.zeros((6, 3))\n", "input_path = os.path.join(test.get_temp_dir(), 'testRunCommand_inputs.npz')\n", "np.savez(input_path, x0=x, x1=x_notused)\n", "output_file = os.path.join(test.get_temp_dir(), 'outputs.npy')\n", "if os.path.exists(output_file):\n", "os.remove(output_file)\n", "args = self.parser.parse_args(['run', '--dir', base_path, '--tag_set',\n 'serve', '--signature_def', 'regress_x2_to_y3', '--inputs', 'inputs=' +\n input_path + '[x0]', '--outdir', test.get_temp_dir()])\n", "saved_model_cli.run(args)\n", "y_actual = np.load(output_file)\n", "y_expected = np.array([[3.5], [4.0]])\n", "self.assertAllClose(y_expected, y_actual)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_0(self, VAR_0, VAR_1):...\n", "VAR_4 = self.setup_test_homeserver(http_client=None, homeserver_to_use=\n GenericWorkerServer)\n", "return VAR_4\n" ]
[ "def make_homeserver(self, reactor, clock):...\n", "hs = self.setup_test_homeserver(http_client=None, homeserver_to_use=\n GenericWorkerServer)\n", "return hs\n" ]
[ 0, 4, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_3(VAR_5, VAR_6):...\n", "\"\"\"docstring\"\"\"\n", "if salt.utils.is_windows():\n", "return True\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 fn_ in VAR_5:\n", "VAR_39 = VAR_38[2]\n", "sys.stderr.write(VAR_49)\n", "VAR_40 = VAR_54.path.dirname(fn_)\n", "return True\n", "sys.exit(salt.defaults.exitcodes.EX_NOUSER)\n", "if VAR_40:\n", "if VAR_54.path.isfile(VAR_40):\n", "VAR_41 = VAR_54.stat(fn_)\n", "if not VAR_54.path.isfile(fn_):\n", "VAR_54.makedirs(VAR_40)\n", "if VAR_49.errno != errno.EEXIST:\n", "VAR_32 = 'Failed to create path {0}, is {1} a file?'.format(fn_, VAR_40)\n", "if VAR_49.errno != errno.EACCES:\n", "if VAR_39 != VAR_41.st_uid:\n", "fp_.write('')\n", "VAR_32 = (\n 'No permissions to access \"{0}\", are you running as the correct user?'.\n format(fn_))\n", "VAR_54.chown(fn_, VAR_39, -1)\n", "VAR_32 = 'Failed to create path \"{0}\" - {1}'.format(fn_, VAR_49)\n" ]
[ "def verify_files(files, user):...\n", "\"\"\"docstring\"\"\"\n", "if salt.utils.is_windows():\n", "return True\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 fn_ in files:\n", "uid = pwnam[2]\n", "sys.stderr.write(err)\n", "dirname = os.path.dirname(fn_)\n", "return True\n", "sys.exit(salt.defaults.exitcodes.EX_NOUSER)\n", "if dirname:\n", "if os.path.isfile(dirname):\n", "stats = os.stat(fn_)\n", "if not os.path.isfile(fn_):\n", "os.makedirs(dirname)\n", "if err.errno != errno.EEXIST:\n", "msg = 'Failed to create path {0}, is {1} a file?'.format(fn_, dirname)\n", "if err.errno != errno.EACCES:\n", "if uid != stats.st_uid:\n", "fp_.write('')\n", "msg = ('No permissions to access \"{0}\", are you running as the correct user?'\n .format(fn_))\n", "os.chown(fn_, uid, -1)\n", "msg = 'Failed to create path \"{0}\" - {1}'.format(fn_, err)\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 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Import'", "Assign'", "Assign'", "For", "Assign'", "Expr'", "Assign'", "Return'", "Expr'", "Condition", "Condition", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Expr'", "Assign'" ]
[ "def __init__(self, *VAR_6, **VAR_7):...\n", "VAR_7['widget'] = forms.HiddenInput\n", "super().__init__(*VAR_6, **kwargs)\n" ]
[ "def __init__(self, *args, **kwargs):...\n", "kwargs['widget'] = forms.HiddenInput\n", "super().__init__(*args, **kwargs)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_6(self):...\n", "VAR_5 = self._makeContext()\n", "self.assertEqual(VAR_5.evaluate('d/one'), 1)\n" ]
[ "def test_evaluate_simple_path_dict_key_int_value(self):...\n", "ec = self._makeContext()\n", "self.assertEqual(ec.evaluate('d/one'), 1)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "import argparse\n", "import errno\n", "import os\n", "import time\n", "import urllib.parse\n", "from collections import OrderedDict\n", "from hashlib import sha256\n", "from textwrap import dedent\n", "from typing import Any, Callable, Iterable, List, MutableMapping, Optional\n", "import attr\n", "import jinja2\n", "import pkg_resources\n", "import yaml\n", "\"\"\"string\"\"\"\n", "def __init__(self, VAR_10: str, VAR_11: Optional[Iterable[str]]=None):...\n", "self.msg = VAR_10\n", "self.path = VAR_11\n", "VAR_0 = 'string'\n", "VAR_1 = 'string'\n", "VAR_2 = 'Missing mandatory `server_name` config option.\\n'\n", "VAR_3 = 'string'\n", "def FUNC_0(VAR_4):...\n", "\"\"\"docstring\"\"\"\n", "os.stat(VAR_4)\n", "if e.errno != errno.ENOENT:\n", "\"\"\"string\"\"\"\n", "return True\n", "return False\n", "VAR_12 = None\n", "def __init__(self, VAR_13=None):...\n", "self.root = VAR_13\n", "self.default_template_dir = pkg_resources.resource_filename('synapse',\n 'res/templates')\n", "def __getattr__(self, VAR_14: str) ->Any:...\n", "\"\"\"docstring\"\"\"\n", "if VAR_14 in ['generate_config_section', 'read_config']:\n", "if self.root is None:\n", "return self.root._get_unclassed_config(self.section, VAR_14)\n", "@staticmethod...\n", "if isinstance(VAR_5, int):\n", "return VAR_5\n", "VAR_48 = {'K': 1024, 'M': 1024 * 1024}\n", "VAR_49 = 1\n", "VAR_50 = VAR_5[-1]\n", "if VAR_50 in VAR_48:\n", "VAR_5 = VAR_5[:-1]\n", "return int(VAR_5) * VAR_49\n", "VAR_49 = VAR_48[VAR_50]\n" ]
[ "import argparse\n", "import errno\n", "import os\n", "import time\n", "import urllib.parse\n", "from collections import OrderedDict\n", "from hashlib import sha256\n", "from textwrap import dedent\n", "from typing import Any, Callable, Iterable, List, MutableMapping, Optional\n", "import attr\n", "import jinja2\n", "import pkg_resources\n", "import yaml\n", "\"\"\"Represents a problem parsing the configuration\n\n Args:\n msg: A textual description of the error.\n path: Where appropriate, an indication of where in the configuration\n the problem lies.\n \"\"\"\n", "def __init__(self, msg: str, path: Optional[Iterable[str]]=None):...\n", "self.msg = msg\n", "self.path = path\n", "MISSING_REPORT_STATS_CONFIG_INSTRUCTIONS = \"\"\"Please opt in or out of reporting anonymized homeserver usage statistics, by\nsetting the `report_stats` key in your config file to either True or False.\n\"\"\"\n", "MISSING_REPORT_STATS_SPIEL = \"\"\"We would really appreciate it if you could help our project out by reporting\nanonymized usage statistics from your homeserver. Only very basic aggregate\ndata (e.g. number of users) will be reported, but it helps us to track the\ngrowth of the Matrix community, and helps us to make Matrix a success, as well\nas to convince other networks that they should peer with us.\n\nThank you.\n\"\"\"\n", "MISSING_SERVER_NAME = 'Missing mandatory `server_name` config option.\\n'\n", "CONFIG_FILE_HEADER = \"\"\"# Configuration file for Synapse.\n#\n# This is a YAML file: see [1] for a quick introduction. Note in particular\n# that *indentation is important*: all the elements of a list or dictionary\n# should have the same indentation.\n#\n# [1] https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html\n\n\"\"\"\n", "def path_exists(file_path):...\n", "\"\"\"docstring\"\"\"\n", "os.stat(file_path)\n", "if e.errno != errno.ENOENT:\n", "\"\"\"\n A configuration section, containing configuration keys and values.\n\n Attributes:\n section (str): The section title of this config object, such as\n \"tls\" or \"logger\". This is used to refer to it on the root\n logger (for example, `config.tls.some_option`). Must be\n defined in subclasses.\n \"\"\"\n", "return True\n", "return False\n", "section = None\n", "def __init__(self, root_config=None):...\n", "self.root = root_config\n", "self.default_template_dir = pkg_resources.resource_filename('synapse',\n 'res/templates')\n", "def __getattr__(self, item: str) ->Any:...\n", "\"\"\"docstring\"\"\"\n", "if item in ['generate_config_section', 'read_config']:\n", "if self.root is None:\n", "return self.root._get_unclassed_config(self.section, item)\n", "@staticmethod...\n", "if isinstance(value, int):\n", "return value\n", "sizes = {'K': 1024, 'M': 1024 * 1024}\n", "size = 1\n", "suffix = value[-1]\n", "if suffix in sizes:\n", "value = value[:-1]\n", "return int(value) * size\n", "size = sizes[suffix]\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Import'", "Import'", "Import'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Docstring", "Expr'", "Condition", "Expr'", "Return'", "Return'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "FunctionDef'", "Docstring", "Condition", "Condition", "Return'", "Condition", "Condition", "Return'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Assign'" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "VAR_145 = VAR_2.session.get('rdef')\n", "VAR_15 = None\n", "if VAR_145 is None:\n", "VAR_144 = VAR_2.session.get('fromid', None)\n", "return {'rdef': VAR_145}\n", "if VAR_144 is not None:\n", "VAR_15 = VAR_8.getObject('Image', VAR_144)\n", "if VAR_15 is not None:\n", "VAR_54 = imageMarshal(VAR_15, VAR_2=request)\n", "VAR_222 = []\n", "VAR_223 = []\n", "for VAR_212, ch in enumerate(VAR_54['channels']):\n", "VAR_287 = ch['active'] and str(VAR_212 + 1) or '-%s' % (VAR_212 + 1)\n", "VAR_145 = {'c': ','.join(VAR_222), 'm': VAR_54['rdefs']['model'],\n 'pixel_range': '%s:%s' % (VAR_54['pixel_range'][0], VAR_54[\n 'pixel_range'][1]), 'maps': VAR_223}\n", "VAR_68 = ch.get('lut') or ch['color']\n", "VAR_222.append('%s|%s:%s$%s' % (VAR_287, ch['window']['start'], ch['window'\n ]['end'], VAR_68))\n", "VAR_223.append({'inverted': {'enabled': ch['inverted']}, 'quantization': {\n 'coefficient': ch['coefficient'], 'family': ch['family']}})\n" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "rdef = request.session.get('rdef')\n", "image = None\n", "if rdef is None:\n", "fromid = request.session.get('fromid', None)\n", "return {'rdef': rdef}\n", "if fromid is not None:\n", "image = conn.getObject('Image', fromid)\n", "if image is not None:\n", "rv = imageMarshal(image, request=request)\n", "chs = []\n", "maps = []\n", "for i, ch in enumerate(rv['channels']):\n", "act = ch['active'] and str(i + 1) or '-%s' % (i + 1)\n", "rdef = {'c': ','.join(chs), 'm': rv['rdefs']['model'], 'pixel_range': \n '%s:%s' % (rv['pixel_range'][0], rv['pixel_range'][1]), 'maps': maps}\n", "color = ch.get('lut') or ch['color']\n", "chs.append('%s|%s:%s$%s' % (act, ch['window']['start'], ch['window']['end'],\n color))\n", "maps.append({'inverted': {'enabled': ch['inverted']}, 'quantization': {\n 'coefficient': ch['coefficient'], 'family': ch['family']}})\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_0(VAR_4):...\n", "if VAR_2(VAR_4):\n", "return None\n", "return VAR_3(VAR_4)\n" ]
[ "def _is_javascript_scheme(s):...\n", "if _is_image_dataurl(s):\n", "return None\n", "return _is_possibly_malicious_scheme(s)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_12(VAR_15, VAR_17, VAR_18, VAR_14):...\n", "if VAR_15:\n", "if VAR_17:\n", "if VAR_17:\n", "return json.dumps([VAR_18, {'location': url_for('editbook.edit_book',\n VAR_14=book_id), 'type': 'success', 'format': VAR_15, 'message': _(\n 'Book Format Successfully Deleted')}])\n", "flash(_('Book Format Successfully Deleted'), category='success')\n", "return json.dumps([VAR_18, {'location': url_for('web.index'), 'type':\n 'success', 'format': VAR_15, 'message': _('Book Successfully Deleted')}])\n", "flash(_('Book Successfully Deleted'), category='success')\n", "return redirect(url_for('editbook.edit_book', VAR_14=book_id))\n", "return redirect(url_for('web.index'))\n" ]
[ "def render_delete_book_result(book_format, jsonResponse, warning, book_id):...\n", "if book_format:\n", "if jsonResponse:\n", "if jsonResponse:\n", "return json.dumps([warning, {'location': url_for('editbook.edit_book',\n book_id=book_id), 'type': 'success', 'format': book_format, 'message':\n _('Book Format Successfully Deleted')}])\n", "flash(_('Book Format Successfully Deleted'), category='success')\n", "return json.dumps([warning, {'location': url_for('web.index'), 'type':\n 'success', 'format': book_format, 'message': _(\n 'Book Successfully Deleted')}])\n", "flash(_('Book Successfully Deleted'), category='success')\n", "return redirect(url_for('editbook.edit_book', book_id=book_id))\n", "return redirect(url_for('web.index'))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Condition", "Return'", "Expr'", "Return'", "Expr'", "Return'", "Return'" ]
[ "@VAR_0.route('/index_page')...\n", "\"\"\"docstring\"\"\"\n", "if not flask_login.current_user.index_page:\n", "VAR_1.error('User may not be logged in. Clearing cookie auth.')\n", "return clear_cookie_auth()\n", "return FUNC_0()\n", "if flask_login.current_user.index_page == 'landing':\n", "return FUNC_0()\n", "if flask_login.current_user.is_authenticated:\n", "if flask_login.current_user.index_page == 'live':\n", "return redirect(url_for('routes_page.page_live'))\n", "if flask_login.current_user.index_page == 'dashboard':\n", "return redirect(url_for('routes_dashboard.page_dashboard_default'))\n", "if flask_login.current_user.index_page == 'info':\n", "return redirect(url_for('routes_page.page_info'))\n", "return redirect(url_for('routes_page.page_live'))\n" ]
[ "@blueprint.route('/index_page')...\n", "\"\"\"docstring\"\"\"\n", "if not flask_login.current_user.index_page:\n", "logger.error('User may not be logged in. Clearing cookie auth.')\n", "return clear_cookie_auth()\n", "return home()\n", "if flask_login.current_user.index_page == 'landing':\n", "return home()\n", "if flask_login.current_user.is_authenticated:\n", "if flask_login.current_user.index_page == 'live':\n", "return redirect(url_for('routes_page.page_live'))\n", "if flask_login.current_user.index_page == 'dashboard':\n", "return redirect(url_for('routes_dashboard.page_dashboard_default'))\n", "if flask_login.current_user.index_page == 'info':\n", "return redirect(url_for('routes_page.page_info'))\n", "return redirect(url_for('routes_page.page_live'))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Expr'", "Return'", "Return'", "Condition", "Return'", "Condition", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "@contextmanager...\n", "VAR_2 = VAR_0.find_element(By.TAG_NAME, 'html')\n", "yield\n", "WebDriverWait(VAR_0, VAR_1).until(staleness_of(VAR_2))\n" ]
[ "@contextmanager...\n", "old_page = driver.find_element(By.TAG_NAME, 'html')\n", "yield\n", "WebDriverWait(driver, timeout).until(staleness_of(old_page))\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Expr'", "Expr'" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "VAR_93 = getIntOrDefault(VAR_2, 'index', 0)\n", "VAR_53 = dict()\n", "VAR_106 = VAR_23 == 'image' and list(VAR_5.getObjects('Image', [VAR_24])\n ) or list()\n", "VAR_107 = VAR_23 == 'dataset' and list(VAR_5.getObjects('Dataset', [VAR_24])\n ) or list()\n", "VAR_108 = VAR_23 == 'project' and list(VAR_5.getObjects('Project', [VAR_24])\n ) or list()\n", "VAR_109 = VAR_23 == 'screen' and list(VAR_5.getObjects('Screen', [VAR_24])\n ) or list()\n", "VAR_110 = VAR_23 == 'plate' and list(VAR_5.getObjects('Plate', [VAR_24])\n ) or list()\n", "VAR_111 = VAR_23 == 'acquisition' and list(VAR_5.getObjects(\n 'PlateAcquisition', [VAR_24])) or list()\n", "VAR_112 = (VAR_23 == 'share' or VAR_23 == 'discussion') and [VAR_5.getShare\n (VAR_24)] or list()\n", "VAR_113 = VAR_23 == 'well' and list(VAR_5.getObjects('Well', [VAR_24])\n ) or list()\n", "VAR_114 = {'images': VAR_23 == 'image' and [VAR_24] or [], 'datasets': \n VAR_23 == 'dataset' and [VAR_24] or [], 'projects': VAR_23 == 'project' and\n [VAR_24] or [], 'screens': VAR_23 == 'screen' and [VAR_24] or [],\n 'plates': VAR_23 == 'plate' and [VAR_24] or [], 'acquisitions': VAR_23 ==\n 'acquisition' and [VAR_24] or [], 'wells': VAR_23 == 'well' and [VAR_24\n ] or [], 'shares': (VAR_23 == 'share' or VAR_23 == 'discussion') and [\n VAR_24] or []}\n", "VAR_115 = {'selected': VAR_114, 'images': VAR_106, 'datasets': VAR_107,\n 'projects': VAR_108, 'screens': VAR_109, 'plates': VAR_110,\n 'acquisitions': VAR_111, 'wells': VAR_113, 'shares': VAR_112}\n", "VAR_116 = None\n", "VAR_117 = None\n", "if VAR_23 in ('share', 'discussion'):\n", "VAR_54 = 'webclient/annotations/annotations_share.html'\n", "VAR_104 = BaseContainer(VAR_5, **{str(c_type): long(c_id), 'index': index})\n", "return handlerInternalError(VAR_2, x)\n", "if VAR_25 is not None:\n", "VAR_104 = BaseShare(VAR_5, VAR_24)\n", "VAR_54 = 'webclient/annotations/annotations_share.html'\n", "VAR_54 = 'webclient/annotations/metadata_general.html'\n", "VAR_104.getAllUsers(VAR_24)\n", "VAR_53['share'] = BaseShare(VAR_5, VAR_25)\n", "VAR_53['canExportAsJpg'] = VAR_104.canExportAsJpg(VAR_2)\n", "VAR_104.getComments(VAR_24)\n", "VAR_53['manager'] = VAR_104\n", "VAR_53['annotationCounts'] = VAR_104.getAnnotationCounts()\n", "VAR_116 = CommentAnnotationForm(VAR_115=initial)\n", "if VAR_23 in ('tag', 'tagset'):\n", "VAR_117 = VAR_104.listFigureScripts()\n", "VAR_53['insight_ns'] = omero.rtypes.rstring(omero.constants.metadata.\n NSINSIGHTTAGSET).val\n", "if VAR_116 is not None:\n", "VAR_53['form_comment'] = VAR_116\n", "VAR_53['figScripts'] = VAR_117\n", "VAR_53['template'] = VAR_54\n", "VAR_53['webclient_path'] = VAR_350('webindex')\n", "return VAR_53\n" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "index = getIntOrDefault(request, 'index', 0)\n", "context = dict()\n", "images = c_type == 'image' and list(conn.getObjects('Image', [c_id])) or list()\n", "datasets = c_type == 'dataset' and list(conn.getObjects('Dataset', [c_id])\n ) or list()\n", "projects = c_type == 'project' and list(conn.getObjects('Project', [c_id])\n ) or list()\n", "screens = c_type == 'screen' and list(conn.getObjects('Screen', [c_id])\n ) or list()\n", "plates = c_type == 'plate' and list(conn.getObjects('Plate', [c_id])) or list()\n", "acquisitions = c_type == 'acquisition' and list(conn.getObjects(\n 'PlateAcquisition', [c_id])) or list()\n", "shares = (c_type == 'share' or c_type == 'discussion') and [conn.getShare(c_id)\n ] or list()\n", "wells = c_type == 'well' and list(conn.getObjects('Well', [c_id])) or list()\n", "selected = {'images': c_type == 'image' and [c_id] or [], 'datasets': \n c_type == 'dataset' and [c_id] or [], 'projects': c_type == 'project' and\n [c_id] or [], 'screens': c_type == 'screen' and [c_id] or [], 'plates':\n c_type == 'plate' and [c_id] or [], 'acquisitions': c_type ==\n 'acquisition' and [c_id] or [], 'wells': c_type == 'well' and [c_id] or\n [], 'shares': (c_type == 'share' or c_type == 'discussion') and [c_id] or\n []}\n", "initial = {'selected': selected, 'images': images, 'datasets': datasets,\n 'projects': projects, 'screens': screens, 'plates': plates,\n 'acquisitions': acquisitions, 'wells': wells, 'shares': shares}\n", "form_comment = None\n", "figScripts = None\n", "if c_type in ('share', 'discussion'):\n", "template = 'webclient/annotations/annotations_share.html'\n", "manager = BaseContainer(conn, **{str(c_type): long(c_id), 'index': index})\n", "return handlerInternalError(request, x)\n", "if share_id is not None:\n", "manager = BaseShare(conn, c_id)\n", "template = 'webclient/annotations/annotations_share.html'\n", "template = 'webclient/annotations/metadata_general.html'\n", "manager.getAllUsers(c_id)\n", "context['share'] = BaseShare(conn, share_id)\n", "context['canExportAsJpg'] = manager.canExportAsJpg(request)\n", "manager.getComments(c_id)\n", "context['manager'] = manager\n", "context['annotationCounts'] = manager.getAnnotationCounts()\n", "form_comment = CommentAnnotationForm(initial=initial)\n", "if c_type in ('tag', 'tagset'):\n", "figScripts = manager.listFigureScripts()\n", "context['insight_ns'] = omero.rtypes.rstring(omero.constants.metadata.\n NSINSIGHTTAGSET).val\n", "if form_comment is not None:\n", "context['form_comment'] = form_comment\n", "context['figScripts'] = figScripts\n", "context['template'] = template\n", "context['webclient_path'] = reverse('webindex')\n", "return context\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_17(self, VAR_26: str, *, VAR_29: Optional[Type[Any]]=None, VAR_13:...\n", "return self.api_route(VAR_26=path, VAR_29=response_model, VAR_13=\n status_code, VAR_30=tags, VAR_31=dependencies, VAR_32=summary, VAR_33=\n description, VAR_34=response_description, VAR_35=responses, VAR_36=\n deprecated, VAR_37=['HEAD'], VAR_38=operation_id, VAR_16=\n response_model_include, VAR_17=response_model_exclude, VAR_18=\n response_model_by_alias, VAR_19=response_model_exclude_unset, VAR_20=\n response_model_exclude_defaults, VAR_21=response_model_exclude_none,\n VAR_39=include_in_schema, VAR_14=response_class, VAR_28=name, VAR_40=\n callbacks)\n" ]
[ "def head(self, path: str, *, response_model: Optional[Type[Any]]=None,...\n", "return self.api_route(path=path, response_model=response_model, status_code\n =status_code, tags=tags, dependencies=dependencies, summary=summary,\n description=description, response_description=response_description,\n responses=responses, deprecated=deprecated, methods=['HEAD'],\n operation_id=operation_id, response_model_include=\n response_model_include, response_model_exclude=response_model_exclude,\n response_model_by_alias=response_model_by_alias,\n response_model_exclude_unset=response_model_exclude_unset,\n response_model_exclude_defaults=response_model_exclude_defaults,\n response_model_exclude_none=response_model_exclude_none,\n include_in_schema=include_in_schema, response_class=response_class,\n name=name, callbacks=callbacks)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "@VAR_0.filter...\n", "\"\"\"docstring\"\"\"\n", "if VAR_17 is None:\n", "return []\n", "return VAR_17.items()\n" ]
[ "@register.filter...\n", "\"\"\"docstring\"\"\"\n", "if value is None:\n", "return []\n", "return value.items()\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Return'", "Return'" ]
[ "@staticmethod...\n", "VAR_27 = FieldId.from_string(VAR_16)\n", "VAR_28 = VAR_27.click_type.startswith('file')\n", "VAR_29 = VAR_27.click_type.startswith('path')\n", "VAR_30 = VAR_16 in request.files\n", "if VAR_28:\n", "if VAR_30:\n", "if VAR_29:\n", "VAR_5 = CLASS_2(VAR_27)\n", "VAR_5 = CLASS_3(VAR_27)\n", "if VAR_30:\n", "VAR_5 = CLASS_1(VAR_27)\n", "return VAR_5\n", "VAR_5 = CLASS_4(VAR_27)\n", "VAR_5 = CLASS_5(VAR_27)\n" ]
[ "@staticmethod...\n", "field_id = FieldId.from_string(key)\n", "is_file = field_id.click_type.startswith('file')\n", "is_path = field_id.click_type.startswith('path')\n", "is_uploaded = key in request.files\n", "if is_file:\n", "if is_uploaded:\n", "if is_path:\n", "field_info = FieldFileInfo(field_id)\n", "field_info = FieldOutFileInfo(field_id)\n", "if is_uploaded:\n", "field_info = FieldInfo(field_id)\n", "return field_info\n", "field_info = FieldPathInfo(field_id)\n", "field_info = FieldPathOutInfo(field_id)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Assign'", "Assign'" ]
[ "def FUNC_19(VAR_43):...\n", "VAR_54 = json.loads(VAR_43)\n", "VAR_55 = next(item for item in VAR_54['dates'] if item['type'] == 'modified')[\n 'start_date']\n", "VAR_55 = VAR_55.split('.')[0]\n", "VAR_56 = datetime.strptime(VAR_55, '%Y-%m-%dT%H:%M:%S')\n", "VAR_57 = VAR_56.replace(tzinfo=timezone(timedelta(0))).timestamp()\n", "return str(int(VAR_57))\n" ]
[ "def parse_date(json_body):...\n", "json_response = json.loads(json_body)\n", "date = next(item for item in json_response['dates'] if item['type'] ==\n 'modified')['start_date']\n", "date = date.split('.')[0]\n", "parsed_date = datetime.strptime(date, '%Y-%m-%dT%H:%M:%S')\n", "epoch = parsed_date.replace(tzinfo=timezone(timedelta(0))).timestamp()\n", "return str(int(epoch))\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_2(self, VAR_2, VAR_3, VAR_4):...\n", "self.store = VAR_4.get_datastore()\n", "self.hs = VAR_4\n", "self.media_repo = VAR_4.get_media_repository_resource()\n", "self.download_resource = self.media_repo.children[b'download']\n", "self.upload_resource = self.media_repo.children[b'upload']\n", "self.image_data = unhexlify(\n b'89504e470d0a1a0a0000000d49484452000000010000000108060000001f15c4890000000a49444154789c63000100000500010d0a2db40000000049454e44ae426082'\n )\n" ]
[ "def prepare(self, reactor, clock, hs):...\n", "self.store = hs.get_datastore()\n", "self.hs = hs\n", "self.media_repo = hs.get_media_repository_resource()\n", "self.download_resource = self.media_repo.children[b'download']\n", "self.upload_resource = self.media_repo.children[b'upload']\n", "self.image_data = unhexlify(\n b'89504e470d0a1a0a0000000d49484452000000010000000108060000001f15c4890000000a49444154789c63000100000500010d0a2db40000000049454e44ae426082'\n )\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_97(self, VAR_10):...\n", "\"\"\"docstring\"\"\"\n", "self.rss_procedures[VAR_10.__name__] = VAR_10\n", "return VAR_10\n" ]
[ "def rss(self, f):...\n", "\"\"\"docstring\"\"\"\n", "self.rss_procedures[f.__name__] = f\n", "return f\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_128(self, VAR_208=160):...\n", "if self.filenames:\n", "return SPAN(H3('Files'), TABLE(*[TR(TD(A(VAR_10, _href=URL(args=self.args +\n [f]))), TD(IMG(_src=URL(args=self.args + [f]), _style='max-width:%spx' %\n width) if VAR_208 and self.isimage(VAR_10) else '')) for VAR_10 in self\n .filenames], **dict(_class='table')))\n", "return ''\n" ]
[ "def table_files(self, width=160):...\n", "if self.filenames:\n", "return SPAN(H3('Files'), TABLE(*[TR(TD(A(f, _href=URL(args=self.args + [f])\n )), TD(IMG(_src=URL(args=self.args + [f]), _style='max-width:%spx' %\n width) if width and self.isimage(f) else '')) for f in self.filenames],\n **dict(_class='table')))\n", "return ''\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_39(VAR_33, VAR_34, VAR_101=None):...\n", "if callable(VAR_64):\n", "if VAR_34 and not isinstance(VAR_34, str):\n", "VAR_143 = VAR_64()\n", "VAR_0.exception(\n 'Error while trying to retrieve custom ETag value for plugin {}'.format\n (VAR_8))\n", "from werkzeug.http import http_date\n", "if VAR_101 is None:\n", "if VAR_143:\n", "VAR_34 = http_date(VAR_34)\n", "VAR_101 = []\n", "import hashlib\n", "return VAR_143\n", "VAR_86 = hashlib.sha1()\n", "def FUNC_32(VAR_87):...\n", "VAR_86.update(to_bytes(VAR_87, encoding='utf-8', errors='replace'))\n", "FUNC_32(octoprint.__version__)\n", "FUNC_32(get_python_version_string())\n", "FUNC_32(','.join(sorted(VAR_33)))\n", "if VAR_34:\n", "FUNC_32(VAR_34)\n", "for add in VAR_101:\n", "FUNC_32(add)\n", "return VAR_86.hexdigest()\n" ]
[ "def compute_etag(files, lastmodified, additional=None):...\n", "if callable(custom_etag):\n", "if lastmodified and not isinstance(lastmodified, str):\n", "etag = custom_etag()\n", "_logger.exception(\n 'Error while trying to retrieve custom ETag value for plugin {}'.format\n (key))\n", "from werkzeug.http import http_date\n", "if additional is None:\n", "if etag:\n", "lastmodified = http_date(lastmodified)\n", "additional = []\n", "import hashlib\n", "return etag\n", "hash = hashlib.sha1()\n", "def hash_update(value):...\n", "hash.update(to_bytes(value, encoding='utf-8', errors='replace'))\n", "hash_update(octoprint.__version__)\n", "hash_update(get_python_version_string())\n", "hash_update(','.join(sorted(files)))\n", "if lastmodified:\n", "hash_update(lastmodified)\n", "for add in additional:\n", "hash_update(add)\n", "return hash.hexdigest()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Assign'", "Expr'", "ImportFrom'", "Condition", "Condition", "Assign'", "Assign'", "Import'", "Return'", "Assign'", "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'", "Condition", "Expr'", "For", "Expr'", "Return'" ]
[ "def FUNC_2(self, VAR_5):...\n", "VAR_7 = self.register_user(VAR_5, 'pass')\n", "VAR_8 = self.login(VAR_5, 'pass')\n", "VAR_9 = self.get_success(self.hs.get_datastore().get_user_by_access_token(\n VAR_8))\n", "VAR_10 = VAR_9.token_id\n", "self.get_success(self.hs.get_pusherpool().add_pusher(VAR_7=user_id, VAR_8=\n token_id, kind='http', app_id='m.http', app_display_name=\n 'HTTP Push Notifications', device_display_name='pushy push', pushkey=\n 'a@example.com', lang=None, data={'url': 'https://push.example.com/push'}))\n", "self.pump()\n", "VAR_11 = self.helper.create_room_as(VAR_7, tok=access_token)\n", "self.helper.join(VAR_11=room, user=self.other_user_id, tok=self.\n other_access_token)\n", "VAR_12 = self.helper.send(VAR_11, body='Hi!', tok=self.other_access_token)\n", "VAR_13 = VAR_12['event_id']\n", "return VAR_13\n" ]
[ "def _create_pusher_and_send_msg(self, localpart):...\n", "user_id = self.register_user(localpart, 'pass')\n", "access_token = self.login(localpart, 'pass')\n", "user_dict = self.get_success(self.hs.get_datastore().\n get_user_by_access_token(access_token))\n", "token_id = user_dict.token_id\n", "self.get_success(self.hs.get_pusherpool().add_pusher(user_id=user_id,\n access_token=token_id, kind='http', app_id='m.http', app_display_name=\n 'HTTP Push Notifications', device_display_name='pushy push', pushkey=\n 'a@example.com', lang=None, data={'url': 'https://push.example.com/push'}))\n", "self.pump()\n", "room = self.helper.create_room_as(user_id, tok=access_token)\n", "self.helper.join(room=room, user=self.other_user_id, tok=self.\n other_access_token)\n", "response = self.helper.send(room, body='Hi!', tok=self.other_access_token)\n", "event_id = response['event_id']\n", "return event_id\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_18(self):...\n", "" ]
[ "def ensure_requester_left_room(self):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_166(VAR_215, VAR_309, VAR_37=None, VAR_17=None):...\n", "VAR_394 = {'code': VAR_309}\n", "if VAR_309 in CLASS_5.jsonrpc_errors:\n", "VAR_394['message'] = CLASS_5.jsonrpc_errors[VAR_309][0]\n", "if VAR_37 is not None:\n", "VAR_394['data'] = CLASS_5.jsonrpc_errors[VAR_309][1]\n", "VAR_394['message'] = VAR_37\n", "if VAR_17 is not None:\n", "VAR_394['data'] = VAR_17\n", "return serializers.json({'jsonrpc': '2.0', 'id': VAR_215, 'error': VAR_394})\n" ]
[ "def return_error(id, code, message=None, data=None):...\n", "error = {'code': code}\n", "if code in Service.jsonrpc_errors:\n", "error['message'] = Service.jsonrpc_errors[code][0]\n", "if message is not None:\n", "error['data'] = Service.jsonrpc_errors[code][1]\n", "error['message'] = message\n", "if data is not None:\n", "error['data'] = data\n", "return serializers.json({'jsonrpc': '2.0', 'id': id, 'error': error})\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Return'" ]
[ "def FUNC_26(VAR_57, VAR_58):...\n", "if VAR_57 == 'tab':\n", "return VAR_58 != 'timelapse' or VAR_51\n", "return True\n" ]
[ "def default_template_filter(template_type, template_key):...\n", "if template_type == 'tab':\n", "return template_key != 'timelapse' or enable_timelapse\n", "return True\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_10(VAR_2, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_33 = saved_model_utils.get_meta_graph_def(VAR_2, VAR_3)\n", "return VAR_33.signature_def\n" ]
[ "def get_signature_def_map(saved_model_dir, tag_set):...\n", "\"\"\"docstring\"\"\"\n", "meta_graph = saved_model_utils.get_meta_graph_def(saved_model_dir, tag_set)\n", "return meta_graph.signature_def\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_17(self):...\n", "VAR_5 = {'rooms': ['!secretbase:unknown']}\n", "VAR_6 = FUNC_0(sender='@foo:bar', type='m.room.message', room_id=\n '!secretbase:unknown')\n", "self.assertTrue(Filter(VAR_5).check(VAR_6))\n" ]
[ "def test_definition_rooms_works_with_literals(self):...\n", "definition = {'rooms': ['!secretbase:unknown']}\n", "event = MockEvent(sender='@foo:bar', type='m.room.message', room_id=\n '!secretbase:unknown')\n", "self.assertTrue(Filter(definition).check(event))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_1(self, VAR_3, VAR_4, VAR_11):...\n", "self.user_id = self.register_user('test', 'test')\n", "self.tok = self.login('test', 'test')\n", "self.displayname = 'test user'\n", "VAR_53 = {'displayname': self.displayname}\n", "VAR_54 = json.dumps(VAR_53)\n", "VAR_22, VAR_23 = self.make_request('PUT', \n '/_matrix/client/r0/profile/%s/displayname' % (self.user_id,), VAR_54,\n VAR_16=self.tok)\n", "self.assertEqual(VAR_23.code, 200, VAR_23.result)\n", "self.room_id = self.helper.create_room_as(self.user_id, VAR_52=self.tok)\n" ]
[ "def prepare(self, reactor, clock, homeserver):...\n", "self.user_id = self.register_user('test', 'test')\n", "self.tok = self.login('test', 'test')\n", "self.displayname = 'test user'\n", "data = {'displayname': self.displayname}\n", "request_data = json.dumps(data)\n", "request, channel = self.make_request('PUT', \n '/_matrix/client/r0/profile/%s/displayname' % (self.user_id,),\n request_data, access_token=self.tok)\n", "self.assertEqual(channel.code, 200, channel.result)\n", "self.room_id = self.helper.create_room_as(self.user_id, tok=self.tok)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_24(VAR_45=None):...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_1.session:\n", "return ['Guest']\n", "import frappe.permissions\n", "return frappe.permissions.get_roles(VAR_45 or VAR_1.session.user)\n" ]
[ "def get_roles(username=None):...\n", "\"\"\"docstring\"\"\"\n", "if not local.session:\n", "return ['Guest']\n", "import frappe.permissions\n", "return frappe.permissions.get_roles(username or local.session.user)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Import'", "Return'" ]
[ "def FUNC_1(self):...\n", "VAR_6 = super().default_config()\n", "VAR_6['start_pushers'] = False\n", "return VAR_6\n" ]
[ "def default_config(self):...\n", "conf = super().default_config()\n", "conf['start_pushers'] = False\n", "return conf\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_155():...\n", "def FUNC_172(VAR_354):...\n", "return VAR_354 + ' ' + VAR_354.replace('icon', 'glyphicon')\n" ]
[ "def bootstrap3():...\n", "def rename(icon):...\n", "return icon + ' ' + icon.replace('icon', 'glyphicon')\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Return'" ]
[ "@property...\n", "return super().index()\n" ]
[ "@property...\n", "return super().index()\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "@staticmethod...\n", "return 'user/files', f'upload-{VAR_39.name}'\n" ]
[ "@staticmethod...\n", "return 'user/files', f'upload-{field.name}'\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_67(self, VAR_42=None):...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_42:\n", "VAR_42 = frappe.session.user\n", "if self.meta.track_seen:\n", "VAR_95 = self.get('_seen') or []\n", "VAR_95 = frappe.parse_json(VAR_95)\n", "if VAR_42 not in VAR_95:\n", "VAR_95.append(VAR_42)\n", "frappe.db.set_value(self.doctype, self.name, '_seen', json.dumps(VAR_95),\n VAR_27=False)\n", "frappe.local.flags.commit = True\n" ]
[ "def add_seen(self, user=None):...\n", "\"\"\"docstring\"\"\"\n", "if not user:\n", "user = frappe.session.user\n", "if self.meta.track_seen:\n", "_seen = self.get('_seen') or []\n", "_seen = frappe.parse_json(_seen)\n", "if user not in _seen:\n", "_seen.append(user)\n", "frappe.db.set_value(self.doctype, self.name, '_seen', json.dumps(_seen),\n update_modified=False)\n", "frappe.local.flags.commit = True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Assign'" ]
[ "def FUNC_43(self, VAR_25, *VAR_0, **VAR_1):...\n", "return self.run_method(VAR_25, *VAR_0, **kwargs)\n" ]
[ "def run_trigger(self, method, *args, **kwargs):...\n", "return self.run_method(method, *args, **kwargs)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_13(self, VAR_5: str) ->RoomAlias:...\n", "\"\"\"docstring\"\"\"\n", "VAR_13 = RoomAlias.from_string(VAR_5)\n", "self.get_success(self.store.create_room_alias_association(VAR_13, self.\n room_id, ['test'], self.admin_user))\n", "return VAR_13\n" ]
[ "def _add_alias(self, alias: str) ->RoomAlias:...\n", "\"\"\"docstring\"\"\"\n", "room_alias = RoomAlias.from_string(alias)\n", "self.get_success(self.store.create_room_alias_association(room_alias, self.\n room_id, ['test'], self.admin_user))\n", "return room_alias\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_4(self):...\n", "" ]
[ "def test_limits_are_applied(self):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_84(VAR_14):...\n", "for VAR_13 in VAR_43:\n", "VAR_21 = getattr(self.rules, VAR_13)\n", "return False\n", "VAR_44 = VAR_21.match(VAR_14)\n", "if not VAR_44:\n", "self.line_match = VAR_44\n", "VAR_87 = getattr(self, 'output_%s' % VAR_13)(VAR_44)\n", "if VAR_87 is not None:\n", "return VAR_44, VAR_87\n" ]
[ "def manipulate(text):...\n", "for key in rules:\n", "pattern = getattr(self.rules, key)\n", "return False\n", "m = pattern.match(text)\n", "if not m:\n", "self.line_match = m\n", "out = getattr(self, 'output_%s' % key)(m)\n", "if out is not None:\n", "return m, out\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Assign'", "Return'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Return'" ]
[ "def __init__(self, VAR_3):...\n", "super().__init__(VAR_3.toDisplayString())\n", "self.url = VAR_3\n" ]
[ "def __init__(self, url):...\n", "super().__init__(url.toDisplayString())\n", "self.url = url\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'" ]
[ "def FUNC_7(VAR_10: Text) ->None:...\n", "\"\"\"docstring\"\"\"\n", "VAR_19 = os.path.dirname(os.path.abspath(VAR_10))\n", "if not os.path.exists(VAR_19):\n", "os.makedirs(VAR_19)\n" ]
[ "def create_path(file_path: Text) ->None:...\n", "\"\"\"docstring\"\"\"\n", "parent_dir = os.path.dirname(os.path.abspath(file_path))\n", "if not os.path.exists(parent_dir):\n", "os.makedirs(parent_dir)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Expr'" ]
[ "@VAR_0.before_first_request...\n", "\"\"\"docstring\"\"\"\n", "if VAR_0.config['WEB_CLI'] is True:\n", "FUNC_61(VAR_0.config['INTERNAL_PORT'], VAR_25=gui.config['GANGA_ARGS'])\n", "if VAR_0.config['INTERNAL_PORT'] is None:\n", "VAR_84['WEB_CLI'] = True\n", "VAR_0.config['INTERNAL_PORT'] = os.environ['INTERNAL_PORT']\n", "if current_user.is_authenticated:\n", "logout_user()\n", "FUNC_59()\n", "if not FUNC_60():\n", "print('INTERNAL SERVER UNAVAILABLE, TERMINATING...')\n", "VAR_7 = FUNC_58('/internal/jobs/actions', 'get')\n", "flash(str(err), 'danger')\n", "sys.exit(1)\n", "VAR_8 = FUNC_58('/internal/plugins', 'get')\n", "return redirect(url_for('dashboard'))\n" ]
[ "@gui.before_first_request...\n", "\"\"\"docstring\"\"\"\n", "if gui.config['WEB_CLI'] is True:\n", "start_ganga(gui.config['INTERNAL_PORT'], args=gui.config['GANGA_ARGS'])\n", "if gui.config['INTERNAL_PORT'] is None:\n", "session['WEB_CLI'] = True\n", "gui.config['INTERNAL_PORT'] = os.environ['INTERNAL_PORT']\n", "if current_user.is_authenticated:\n", "logout_user()\n", "create_session_defaults()\n", "if not ping_internal():\n", "print('INTERNAL SERVER UNAVAILABLE, TERMINATING...')\n", "actions = query_internal_api('/internal/jobs/actions', 'get')\n", "flash(str(err), 'danger')\n", "sys.exit(1)\n", "plugins = query_internal_api('/internal/plugins', 'get')\n", "return redirect(url_for('dashboard'))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "For", "Docstring", "Condition", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Condition", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_21(self, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_20 = jinja.render('error.html', title='Error while opening qute://url',\n VAR_3=url.toDisplayString(), VAR_8=\n '{} is not available with this backend'.format(url.toDisplayString()))\n", "return 'text/html', VAR_20\n" ]
[ "def wrong_backend_handler(self, url):...\n", "\"\"\"docstring\"\"\"\n", "src = jinja.render('error.html', title='Error while opening qute://url',\n url=url.toDisplayString(), error=\n '{} is not available with this backend'.format(url.toDisplayString()))\n", "return 'text/html', src\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_62(self, VAR_18, VAR_30, VAR_31, VAR_32=None, VAR_33=None):...\n", "\"\"\"docstring\"\"\"\n", "VAR_74 = {'in': _('one of'), 'not in': _('none of'), '^': _('beginning with')}\n", "if not VAR_32:\n", "VAR_32 = self\n", "VAR_75 = VAR_32.get_value(VAR_18)\n", "VAR_19 = VAR_32.meta.get_field(VAR_18)\n", "VAR_31 = VAR_32.cast(VAR_31, VAR_19)\n", "if not frappe.compare(VAR_75, VAR_30, VAR_31):\n", "VAR_93 = VAR_32.meta.get_label(VAR_18)\n", "VAR_94 = VAR_74.get(VAR_30, VAR_30)\n", "if VAR_32.parentfield:\n", "VAR_87 = _('Incorrect value in row {0}: {1} must be {2} {3}').format(VAR_32\n .idx, VAR_93, VAR_94, VAR_31)\n", "VAR_87 = _('Incorrect value: {0} must be {1} {2}').format(VAR_93, VAR_94,\n VAR_31)\n", "msgprint(VAR_87, VAR_33=raise_exception or True)\n" ]
[ "def validate_value(self, fieldname, condition, val2, doc=None,...\n", "\"\"\"docstring\"\"\"\n", "error_condition_map = {'in': _('one of'), 'not in': _('none of'), '^': _(\n 'beginning with')}\n", "if not doc:\n", "doc = self\n", "val1 = doc.get_value(fieldname)\n", "df = doc.meta.get_field(fieldname)\n", "val2 = doc.cast(val2, df)\n", "if not frappe.compare(val1, condition, val2):\n", "label = doc.meta.get_label(fieldname)\n", "condition_str = error_condition_map.get(condition, condition)\n", "if doc.parentfield:\n", "msg = _('Incorrect value in row {0}: {1} must be {2} {3}').format(doc.idx,\n label, condition_str, val2)\n", "msg = _('Incorrect value: {0} must be {1} {2}').format(label, condition_str,\n val2)\n", "msgprint(msg, raise_exception=raise_exception or True)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_5(VAR_23=None, VAR_26=None, VAR_27=True):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.database import get_db\n", "if VAR_23:\n", "FUNC_4(VAR_23)\n", "VAR_1.db = get_db(VAR_10=db_name or local.conf.db_name)\n", "if VAR_27:\n", "FUNC_22('Administrator')\n" ]
[ "def connect(site=None, db_name=None, set_admin_as_user=True):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.database import get_db\n", "if site:\n", "init(site)\n", "local.db = get_db(user=db_name or local.conf.db_name)\n", "if set_admin_as_user:\n", "set_user('Administrator')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "ImportFrom'", "Condition", "Expr'", "Assign'", "Condition", "Expr'" ]
[ "async def FUNC_8(self):...\n", "return self.get_repo_url()\n" ]
[ "async def get_resolved_ref_url(self):...\n", "return self.get_repo_url()\n" ]
[ 0, 0 ]
[ "AsyncFunctionDef'", "Return'" ]
[ "def FUNC_14(self, VAR_36, *VAR_37):...\n", "" ]
[ "def log_message(self, format, *args):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_0(self, VAR_2, VAR_3, VAR_4):...\n", "VAR_30 = ReplicationStreamProtocolFactory(VAR_4)\n", "self.streamer = VAR_4.get_replication_streamer()\n", "self.server = VAR_30.buildProtocol(None)\n", "self.reactor.lookups['testserv'] = '1.2.3.4'\n", "self.worker_hs = self.setup_test_homeserver(http_client=None,\n homeserver_to_use=GenericWorkerServer, VAR_32=self.\n _get_worker_hs_config(), VAR_2=self.reactor)\n", "self.worker_hs.get_datastore().db_pool = VAR_4.get_datastore().db_pool\n", "self.test_handler = self._build_replication_data_handler()\n", "self.worker_hs._replication_data_handler = self.test_handler\n", "VAR_31 = ReplicationCommandHandler(self.worker_hs)\n", "self.client = ClientReplicationStreamProtocol(self.worker_hs, 'client',\n 'test', VAR_3, VAR_31)\n", "self._client_transport = None\n", "self._server_transport = None\n" ]
[ "def prepare(self, reactor, clock, hs):...\n", "server_factory = ReplicationStreamProtocolFactory(hs)\n", "self.streamer = hs.get_replication_streamer()\n", "self.server = server_factory.buildProtocol(None)\n", "self.reactor.lookups['testserv'] = '1.2.3.4'\n", "self.worker_hs = self.setup_test_homeserver(http_client=None,\n homeserver_to_use=GenericWorkerServer, config=self.\n _get_worker_hs_config(), reactor=self.reactor)\n", "self.worker_hs.get_datastore().db_pool = hs.get_datastore().db_pool\n", "self.test_handler = self._build_replication_data_handler()\n", "self.worker_hs._replication_data_handler = self.test_handler\n", "repl_handler = ReplicationCommandHandler(self.worker_hs)\n", "self.client = ClientReplicationStreamProtocol(self.worker_hs, 'client',\n 'test', clock, repl_handler)\n", "self._client_transport = None\n", "self._server_transport = None\n" ]
[ 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_22(self):...\n", "if self.page_key is None:\n", "return\n", "VAR_33 = g.conn.session.query(Query).get(self.page_key)\n", "if VAR_33:\n", "VAR_37 = VAR_33.latest_rev.latest_run.id\n", "if self.direction == 'prev':\n", "self.queryset = self.queryset.filter(QueryRun.id > VAR_37)\n", "self.queryset = self.queryset.filter(QueryRun.id < VAR_37)\n" ]
[ "def filter_queryset(self):...\n", "if self.page_key is None:\n", "return\n", "from_query = g.conn.session.query(Query).get(self.page_key)\n", "if from_query:\n", "from_qrun_id = from_query.latest_rev.latest_run.id\n", "if self.direction == 'prev':\n", "self.queryset = self.queryset.filter(QueryRun.id > from_qrun_id)\n", "self.queryset = self.queryset.filter(QueryRun.id < from_qrun_id)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_13(VAR_24):...\n", "\"\"\"docstring\"\"\"\n", "VAR_34 = VAR_0.findall(VAR_24)\n", "if not VAR_34:\n", "return [VAR_24]\n", "VAR_34 = [e.encode('ascii').decode('unicode_escape') for e in VAR_34]\n", "return VAR_34\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_25(VAR_46, VAR_47=None):...\n", "\"\"\"docstring\"\"\"\n", "return VAR_16.headers.get(VAR_46, VAR_47)\n" ]
[ "def get_request_header(key, default=None):...\n", "\"\"\"docstring\"\"\"\n", "return request.headers.get(key, default)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_3(VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_3 = VAR_3.replace(',', ' ').replace(';', ' ')\n", "return VAR_3.strip().split()\n" ]
[ "def split_list(text):...\n", "\"\"\"docstring\"\"\"\n", "text = text.replace(',', ' ').replace(';', ' ')\n", "return text.strip().split()\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_52(VAR_16, VAR_22, VAR_23, VAR_24, VAR_25):...\n", "VAR_22.default_language = VAR_16['default_language']\n", "VAR_22.locale = VAR_16.get('locale', VAR_22.locale)\n", "VAR_22.sidebar_view = sum(VAR_119(key[5:]) for key in VAR_16 if key.\n startswith('show_'))\n", "if 'show_detail_random' in VAR_16:\n", "VAR_22.sidebar_view |= constants.DETAIL_RANDOM\n", "VAR_22.role = constants.selected_roles(VAR_16)\n", "VAR_22.password = generate_password_hash(VAR_16['password'])\n", "if not VAR_16['name'] or not VAR_16['email'] or not VAR_16['password']:\n", "flash(str(ex), category='error')\n", "VAR_22.allowed_tags = config.config_allowed_tags\n", "ub.session.rollback()\n", "VAR_0.info('Missing entries on new user')\n", "VAR_22.email = check_email(VAR_16['email'])\n", "return render_title_template('user_edit.html', new_user=1, VAR_22=content,\n config=config, VAR_24=translations, VAR_23=languages, title=_(\n u'Add new user'), page='newuser', VAR_25=kobo_support, registered_oauth\n =oauth_check)\n", "VAR_22.denied_tags = config.config_denied_tags\n", "VAR_0.error('Found an existing account for {} or {}'.format(VAR_22.name,\n VAR_22.email))\n", "VAR_22.name = check_username(VAR_16['name'])\n", "VAR_22.allowed_column_value = config.config_allowed_column_value\n", "flash(_('Found an existing account for this e-mail address or name.'),\n category='error')\n", "if VAR_16.get('kindle_mail'):\n", "VAR_22.denied_column_value = config.config_denied_column_value\n", "ub.session.rollback()\n", "VAR_22.kindle_mail = valid_email(VAR_16['kindle_mail'])\n", "if config.config_public_reg and not check_valid_domain(VAR_22.email):\n", "VAR_22.kobo_only_shelves_sync = VAR_16.get('kobo_only_shelves_sync', 0) == 'on'\n", "VAR_0.error('Settings DB is not Writeable')\n", "VAR_0.info('E-mail: {} for new user is not from valid domain'.format(VAR_22\n .email))\n", "ub.session.add(VAR_22)\n", "flash(_('Settings DB is not Writeable'), category='error')\n", "ub.session.commit()\n", "flash(_(u\"User '%(user)s' created\", VAR_12=content.name), category='success')\n", "VAR_0.debug('User {} created'.format(VAR_22.name))\n", "return redirect(url_for('admin.admin'))\n" ]
[ "def _handle_new_user(to_save, content, languages, translations, kobo_support):...\n", "content.default_language = to_save['default_language']\n", "content.locale = to_save.get('locale', content.locale)\n", "content.sidebar_view = sum(int(key[5:]) for key in to_save if key.\n startswith('show_'))\n", "if 'show_detail_random' in to_save:\n", "content.sidebar_view |= constants.DETAIL_RANDOM\n", "content.role = constants.selected_roles(to_save)\n", "content.password = generate_password_hash(to_save['password'])\n", "if not to_save['name'] or not to_save['email'] or not to_save['password']:\n", "flash(str(ex), category='error')\n", "content.allowed_tags = config.config_allowed_tags\n", "ub.session.rollback()\n", "log.info('Missing entries on new user')\n", "content.email = check_email(to_save['email'])\n", "return render_title_template('user_edit.html', new_user=1, content=content,\n config=config, translations=translations, languages=languages, title=_(\n u'Add new user'), page='newuser', kobo_support=kobo_support,\n registered_oauth=oauth_check)\n", "content.denied_tags = config.config_denied_tags\n", "log.error('Found an existing account for {} or {}'.format(content.name,\n content.email))\n", "content.name = check_username(to_save['name'])\n", "content.allowed_column_value = config.config_allowed_column_value\n", "flash(_('Found an existing account for this e-mail address or name.'),\n category='error')\n", "if to_save.get('kindle_mail'):\n", "content.denied_column_value = config.config_denied_column_value\n", "ub.session.rollback()\n", "content.kindle_mail = valid_email(to_save['kindle_mail'])\n", "if config.config_public_reg and not check_valid_domain(content.email):\n", "content.kobo_only_shelves_sync = to_save.get('kobo_only_shelves_sync', 0\n ) == 'on'\n", "log.error('Settings DB is not Writeable')\n", "log.info('E-mail: {} for new user is not from valid domain'.format(content.\n email))\n", "ub.session.add(content)\n", "flash(_('Settings DB is not Writeable'), category='error')\n", "ub.session.commit()\n", "flash(_(u\"User '%(user)s' created\", user=content.name), category='success')\n", "log.debug('User {} created'.format(content.name))\n", "return redirect(url_for('admin.admin'))\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 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "AugAssign'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Return'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_46(VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "VAR_161 = [(state_key, int(VAR_1.depth)) for (e_type, state_key), VAR_1 in\n VAR_2.items() if e_type == VAR_188.Member and VAR_1.membership ==\n Membership.JOIN]\n", "VAR_162 = {}\n", "for u, d in VAR_161:\n", "return sorted(VAR_162.items(), VAR_144=lambda d: d[1])\n", "VAR_196 = get_domain_from_id(u)\n", "VAR_197 = VAR_162.get(VAR_196)\n", "if VAR_197:\n", "VAR_162[VAR_196] = min(d, VAR_197)\n", "VAR_162[VAR_196] = d\n" ]
[ "def get_domains_from_state(state):...\n", "\"\"\"docstring\"\"\"\n", "joined_users = [(state_key, int(event.depth)) for (e_type, state_key),\n event in state.items() if e_type == EventTypes.Member and event.\n membership == Membership.JOIN]\n", "joined_domains = {}\n", "for u, d in joined_users:\n", "return sorted(joined_domains.items(), key=lambda d: d[1])\n", "dom = get_domain_from_id(u)\n", "old_d = joined_domains.get(dom)\n", "if old_d:\n", "joined_domains[dom] = min(d, old_d)\n", "joined_domains[dom] = d\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "For", "Return'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'" ]
[ "@FUNC_0...\n", "return FederationHandlerRegistry(self)\n" ]
[ "@cache_in_self...\n", "return FederationHandlerRegistry(self)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def __init__(self, VAR_0, VAR_22, VAR_23=None, VAR_3=None, VAR_5=True, VAR_6=()...\n", "self.permissions = tuple(VAR_6)\n", "self.require_authentication = VAR_5\n", "if callable(VAR_22):\n", "VAR_22 = self.wrap_with_permissions(VAR_22)\n", "from django.urls import re_path\n", "VAR_30 = re_path(VAR_0, VAR_22, VAR_23, VAR_3)\n", "VAR_31 = VAR_30.pattern\n", "super(CLASS_0, self).__init__(VAR_31, VAR_22, VAR_23, VAR_3)\n" ]
[ "def __init__(self, regex, callback, default_args=None, name=None,...\n", "self.permissions = tuple(permissions)\n", "self.require_authentication = require_authentication\n", "if callable(callback):\n", "callback = self.wrap_with_permissions(callback)\n", "from django.urls import re_path\n", "repath = re_path(regex, callback, default_args, name)\n", "pattern = repath.pattern\n", "super(AdminRegexURLPattern, self).__init__(pattern, callback, default_args,\n name)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Condition", "Assign'", "ImportFrom'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_3(self, *, VAR_4: str) ->Set[str]:...\n", "\"\"\"docstring\"\"\"\n", "VAR_8 = super().get_imports(VAR_4=prefix)\n", "for VAR_21 in self.inner_properties:\n", "VAR_8.update(VAR_21.get_imports(VAR_4=prefix))\n", "VAR_8.add('from typing import Union')\n", "return VAR_8\n" ]
[ "def get_imports(self, *, prefix: str) ->Set[str]:...\n", "\"\"\"docstring\"\"\"\n", "imports = super().get_imports(prefix=prefix)\n", "for inner_prop in self.inner_properties:\n", "imports.update(inner_prop.get_imports(prefix=prefix))\n", "imports.add('from typing import Union')\n", "return imports\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "For", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_30(VAR_16):...\n", "VAR_35 = PerspectivesKeyFetcher(self.hs)\n", "VAR_23 = {VAR_34: {'key1': 0}}\n", "self.expect_outgoing_key_query(VAR_34, 'key1', VAR_16)\n", "return self.get_success(VAR_35.get_keys(VAR_23))\n" ]
[ "def get_key_from_perspectives(response):...\n", "fetcher = PerspectivesKeyFetcher(self.hs)\n", "keys_to_fetch = {SERVER_NAME: {'key1': 0}}\n", "self.expect_outgoing_key_query(SERVER_NAME, 'key1', response)\n", "return self.get_success(fetcher.get_keys(keys_to_fetch))\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_3(VAR_7, VAR_8='r'):...\n", "VAR_22 = FUNC_2(VAR_7, VAR_8)\n", "return VAR_22.read()\n", "VAR_22.close()\n" ]
[ "def safe_read(a, b='r'):...\n", "safe_file = safe_open(a, b)\n", "return safe_file.read()\n", "safe_file.close()\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'", "Expr'" ]
[ "def FUNC_166(VAR_215, VAR_309, VAR_37, VAR_17=None):...\n", "VAR_394 = {'name': 'JSONRPCError', 'code': VAR_309, 'message': VAR_37}\n", "if VAR_17 is not None:\n", "VAR_394['data'] = VAR_17\n", "return serializers.json({'id': VAR_215, 'version': '1.1', 'error': VAR_394})\n" ]
[ "def return_error(id, code, message, data=None):...\n", "error = {'name': 'JSONRPCError', 'code': code, 'message': message}\n", "if data is not None:\n", "error['data'] = data\n", "return serializers.json({'id': id, 'version': '1.1', 'error': error})\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Return'" ]
[ "def __init__(self, VAR_20):...\n", "super().__init__(VAR_20)\n", "self.mode = self.param.click_type.split('[')[1][:-1]\n", "self.generate_download_link = True if 'w' in self.mode else False\n", "self.link_name = f'{self.cmd_opt}.out'\n", "VAR_0.info(f'File mode for {self.key} is {self.mode}')\n" ]
[ "def __init__(self, fimeta):...\n", "super().__init__(fimeta)\n", "self.mode = self.param.click_type.split('[')[1][:-1]\n", "self.generate_download_link = True if 'w' in self.mode else False\n", "self.link_name = f'{self.cmd_opt}.out'\n", "logger.info(f'File mode for {self.key} is {self.mode}')\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "@VAR_2.route('/download/<int:book_id>/<book_format>', defaults={'anyname':...\n", "VAR_96 = 'kobo' if 'Kobo' in request.headers.get('User-Agent') else ''\n", "return get_download_link(VAR_5, VAR_6, VAR_96)\n" ]
[ "@web.route('/download/<int:book_id>/<book_format>', defaults={'anyname':...\n", "client = 'kobo' if 'Kobo' in request.headers.get('User-Agent') else ''\n", "return get_download_link(book_id, book_format, client)\n" ]
[ 0, 0, 0 ]
[ "For", "Assign'", "Return'" ]
[ "def FUNC_2(VAR_4):...\n", "@wraps(VAR_4)...\n", "if VAR_87.role_viewer():\n", "return VAR_4(*VAR_49, **kwargs)\n", "abort(403)\n", "return FUNC_71\n" ]
[ "def viewer_required(f):...\n", "@wraps(f)...\n", "if current_user.role_viewer():\n", "return f(*args, **kwargs)\n", "abort(403)\n", "return inner\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Return'", "Expr'", "Return'" ]
[ "@log_function...\n", "\"\"\"docstring\"\"\"\n", "VAR_2 = FUNC_1('/groups/%s/users/%s/join', VAR_30, VAR_16)\n", "return self.client.post_json(VAR_5=destination, VAR_2=path, VAR_39=content,\n VAR_15=True)\n" ]
[ "@log_function...\n", "\"\"\"docstring\"\"\"\n", "path = _create_v1_path('/groups/%s/users/%s/join', group_id, user_id)\n", "return self.client.post_json(destination=destination, path=path, data=\n content, ignore_backoff=True)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "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'" ]
[ "def FUNC_2(self, VAR_1, VAR_2=None):...\n", "if 1 == 1:\n", "VAR_8 = self.get_argument('limit')\n", "VAR_2 = self.get_argument('word')\n", "VAR_9 = self.get_argument('callback')\n", "VAR_10 = rtxcomplete.get_nodes_like(VAR_2, VAR_8)\n", "VAR_10 = VAR_9 + '(' + json.dumps(VAR_10) + ');'\n", "self.write(VAR_10)\n" ]
[ "def get(self, arg, word=None):...\n", "if 1 == 1:\n", "limit = self.get_argument('limit')\n", "word = self.get_argument('word')\n", "callback = self.get_argument('callback')\n", "result = rtxcomplete.get_nodes_like(word, limit)\n", "result = callback + '(' + json.dumps(result) + ');'\n", "self.write(result)\n" ]
[ 0, 2, 0, 0, 2, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def __init__(self, VAR_3=None):...\n", "VAR_28 = {'class': 'vURLField'}\n", "if VAR_3 is not None:\n", "VAR_28.update(VAR_3)\n", "super(CLASS_13, self).__init__(VAR_3=final_attrs)\n" ]
[ "def __init__(self, attrs=None):...\n", "final_attrs = {'class': 'vURLField'}\n", "if attrs is not None:\n", "final_attrs.update(attrs)\n", "super(AdminURLFieldWidget, self).__init__(attrs=final_attrs)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_13() ->Pattern:...\n", "\"\"\"docstring\"\"\"\n", "return re.compile('[πŸ˜€-πŸ™πŸŒ€-πŸ—ΏπŸš€-\\U0001f6ff\\U0001f1e0-πŸ‡Ώβœ‚-βž°β“‚-πŸ‰‘\\u200d\\u200c]+',\n flags=re.UNICODE)\n" ]
[ "def get_emoji_regex() ->Pattern:...\n", "\"\"\"docstring\"\"\"\n", "return re.compile('[πŸ˜€-πŸ™πŸŒ€-πŸ—ΏπŸš€-\\U0001f6ff\\U0001f1e0-πŸ‡Ώβœ‚-βž°β“‚-πŸ‰‘\\u200d\\u200c]+',\n flags=re.UNICODE)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_131(self, VAR_212):...\n", "return self.markmin_base(VAR_212.body) + self.render_tags(VAR_212.tags).xml()\n" ]
[ "def markmin_render(self, page):...\n", "return self.markmin_base(page.body) + self.render_tags(page.tags).xml()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "from typing import Optional\n", "from netaddr import IPSet\n", "from synapse.config._base import Config, ConfigError\n", "from synapse.config._util import validate_config\n", "VAR_1 = 'federation'\n", "def FUNC_0(self, VAR_2, **VAR_3):...\n", "self.federation_domain_whitelist = None\n", "VAR_6 = VAR_2.get('federation_domain_whitelist', None)\n", "if VAR_6 is not None:\n", "self.federation_domain_whitelist = {}\n", "self.federation_ip_range_blacklist = VAR_2.get('federation_ip_range_blacklist',\n [])\n", "for VAR_8 in VAR_6:\n", "self.federation_ip_range_blacklist = IPSet(self.federation_ip_range_blacklist)\n", "VAR_7 = VAR_2.get('federation_metrics_domains') or []\n", "self.federation_domain_whitelist[VAR_8] = True\n", "self.federation_ip_range_blacklist.update(['0.0.0.0', '::'])\n", "validate_config(VAR_0, VAR_7, ('federation_metrics_domains',))\n", "self.federation_metrics_domains = set(VAR_7)\n", "def FUNC_1(self, VAR_4, VAR_5, **VAR_3):...\n", "return 'string'\n" ]
[ "from typing import Optional\n", "from netaddr import IPSet\n", "from synapse.config._base import Config, ConfigError\n", "from synapse.config._util import validate_config\n", "section = 'federation'\n", "def read_config(self, config, **kwargs):...\n", "self.federation_domain_whitelist = None\n", "federation_domain_whitelist = config.get('federation_domain_whitelist', None)\n", "if federation_domain_whitelist is not None:\n", "self.federation_domain_whitelist = {}\n", "self.federation_ip_range_blacklist = config.get('federation_ip_range_blacklist'\n , [])\n", "for domain in federation_domain_whitelist:\n", "self.federation_ip_range_blacklist = IPSet(self.federation_ip_range_blacklist)\n", "federation_metrics_domains = config.get('federation_metrics_domains') or []\n", "self.federation_domain_whitelist[domain] = True\n", "self.federation_ip_range_blacklist.update(['0.0.0.0', '::'])\n", "validate_config(_METRICS_FOR_DOMAINS_SCHEMA, federation_metrics_domains, (\n 'federation_metrics_domains',))\n", "self.federation_metrics_domains = set(federation_metrics_domains)\n", "def generate_config_section(self, config_dir_path, server_name, **kwargs):...\n", "return \"\"\" ## Federation ##\n\n # Restrict federation to the following whitelist of domains.\n # N.B. we recommend also firewalling your federation listener to limit\n # inbound federation traffic as early as possible, rather than relying\n # purely on this application-layer restriction. If not specified, the\n # default is to whitelist everything.\n #\n #federation_domain_whitelist:\n # - lon.example.com\n # - nyc.example.com\n # - syd.example.com\n\n # Prevent federation requests from being sent to the following\n # blacklist IP address CIDR ranges. If this option is not specified, or\n # specified with an empty list, no ip range blacklist will be enforced.\n #\n # As of Synapse v1.4.0 this option also affects any outbound requests to identity\n # servers provided by user input.\n #\n # (0.0.0.0 and :: are always blacklisted, whether or not they are explicitly\n # listed here, since they correspond to unroutable addresses.)\n #\n federation_ip_range_blacklist:\n - '127.0.0.0/8'\n - '10.0.0.0/8'\n - '172.16.0.0/12'\n - '192.168.0.0/16'\n - '100.64.0.0/10'\n - '169.254.0.0/16'\n - '::1/128'\n - 'fe80::/64'\n - 'fc00::/7'\n\n # Report prometheus metrics on the age of PDUs being sent to and received from\n # the following domains. This can be used to give an idea of \"delay\" on inbound\n # and outbound federation, though be aware that any delay can be due to problems\n # at either end or with the intermediate network.\n #\n # By default, no domains are monitored in this way.\n #\n #federation_metrics_domains:\n # - matrix.org\n # - example.com\n \"\"\"\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 4, 0, 0, 4, 0, 0, 0, 4 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "FunctionDef'", "Return'" ]
[ "from __future__ import absolute_import, unicode_literals\n", "import re\n", "from collections import OrderedDict\n", "from django import template\n", "from django.template import loader\n", "from django.urls import NoReverseMatch, reverse\n", "from django.utils import six\n", "from django.utils.encoding import force_text, iri_to_uri\n", "from django.utils.html import escape, format_html, smart_urlquote\n", "from django.utils.safestring import SafeData, mark_safe\n", "from rest_framework.compat import apply_markdown, pygments_highlight\n", "from rest_framework.renderers import HTMLFormRenderer\n", "from rest_framework.utils.urls import replace_query_param\n", "VAR_0 = VAR_64.Library()\n", "VAR_1 = re.compile('(?<=class=[\"\\\\\\'])(.*)(?=[\"\\\\\\'])')\n", "@VAR_0.tag(VAR_55='code')...\n", "VAR_33 = VAR_3.split_contents()[-1]\n", "VAR_34 = VAR_2.parse(('endcode',))\n", "VAR_2.delete_first_token()\n", "return CLASS_0(VAR_33, VAR_34)\n" ]
[ "from __future__ import absolute_import, unicode_literals\n", "import re\n", "from collections import OrderedDict\n", "from django import template\n", "from django.template import loader\n", "from django.urls import NoReverseMatch, reverse\n", "from django.utils import six\n", "from django.utils.encoding import force_text, iri_to_uri\n", "from django.utils.html import escape, format_html, smart_urlquote\n", "from django.utils.safestring import SafeData, mark_safe\n", "from rest_framework.compat import apply_markdown, pygments_highlight\n", "from rest_framework.renderers import HTMLFormRenderer\n", "from rest_framework.utils.urls import replace_query_param\n", "register = template.Library()\n", "class_re = re.compile('(?<=class=[\"\\\\\\'])(.*)(?=[\"\\\\\\'])')\n", "@register.tag(name='code')...\n", "code = token.split_contents()[-1]\n", "nodelist = parser.parse(('endcode',))\n", "parser.delete_first_token()\n", "return CodeNode(code, nodelist)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_112(self, VAR_174):...\n", "\"\"\"docstring\"\"\"\n", "super(CLASS_0, self).update(VAR_174)\n", "return self\n" ]
[ "def update(self, d):...\n", "\"\"\"docstring\"\"\"\n", "super(_dict, self).update(d)\n", "return self\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Return'" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "VAR_250 = VAR_213.split('/')\n", "VAR_104, VAR_105, VAR_11 = VAR_250[0], VAR_250[1], VAR_250[2:]\n", "return LOAD(VAR_104, VAR_105, VAR_11=args, ajax=True).xml()\n" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "items = text.split('/')\n", "controller, function, args = items[0], items[1], items[2:]\n", "return LOAD(controller, function, args=args, ajax=True).xml()\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_7(self, VAR_0, VAR_1, VAR_5):...\n", "self.http_client2 = Mock()\n", "VAR_18 = FUNC_6(name='keyclient')\n", "VAR_18['trusted_key_servers'] = [{'server_name': self.hs.hostname,\n 'verify_keys': {('ed25519:%s' % (self.hs_signing_key.version,)):\n signedjson.key.encode_verify_key_base64(self.hs_signing_key.verify_key)}}]\n", "self.hs2 = self.setup_test_homeserver(http_client=self.http_client2, VAR_18\n =config)\n", "async def FUNC_11(VAR_6, VAR_7, VAR_20):...\n", "self.assertEqual(VAR_6, self.hs.hostname)\n", "self.assertEqual(VAR_7, '/_matrix/key/v2/query')\n", "VAR_10 = FakeChannel(self.site, self.reactor)\n", "VAR_11 = SynapseRequest(VAR_10)\n", "VAR_11.content = BytesIO(encode_canonical_json(VAR_20))\n", "VAR_11.requestReceived(b'POST', VAR_7.encode('utf-8'), b'1.1')\n", "VAR_10.await_result()\n", "self.assertEqual(VAR_10.code, 200)\n", "VAR_12 = VAR_10.json_body\n", "return VAR_12\n" ]
[ "def prepare(self, reactor, clock, homeserver):...\n", "self.http_client2 = Mock()\n", "config = default_config(name='keyclient')\n", "config['trusted_key_servers'] = [{'server_name': self.hs.hostname,\n 'verify_keys': {('ed25519:%s' % (self.hs_signing_key.version,)):\n signedjson.key.encode_verify_key_base64(self.hs_signing_key.verify_key)}}]\n", "self.hs2 = self.setup_test_homeserver(http_client=self.http_client2, config\n =config)\n", "async def post_json(destination, path, data):...\n", "self.assertEqual(destination, self.hs.hostname)\n", "self.assertEqual(path, '/_matrix/key/v2/query')\n", "channel = FakeChannel(self.site, self.reactor)\n", "req = SynapseRequest(channel)\n", "req.content = BytesIO(encode_canonical_json(data))\n", "req.requestReceived(b'POST', path.encode('utf-8'), b'1.1')\n", "channel.await_result()\n", "self.assertEqual(channel.code, 200)\n", "resp = channel.json_body\n", "return resp\n" ]
[ 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "AsyncFunctionDef'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_6(self, VAR_18):...\n", "VAR_28 = self.secured.get(VAR_18.id)\n", "if VAR_28 is not None:\n", "return Symbol(VAR_28)\n", "return VAR_18\n" ]
[ "def visit_Name(self, node):...\n", "value = self.secured.get(node.id)\n", "if value is not None:\n", "return Symbol(value)\n", "return node\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_5(self):...\n", "VAR_7 = self.uncreated_rmid\n", "self._test_get_membership(VAR_8=[self.user_id, self.rmcreator_id], VAR_7=\n room, VAR_9=403)\n", "self.helper.invite(VAR_7=room, src=self.user_id, targ=self.rmcreator_id,\n VAR_9=403)\n", "for usr in [self.user_id, self.rmcreator_id]:\n", "self.helper.join(VAR_7=room, user=usr, VAR_9=404)\n", "self.helper.leave(VAR_7=room, user=usr, VAR_9=404)\n" ]
[ "def test_membership_basic_room_perms(self):...\n", "room = self.uncreated_rmid\n", "self._test_get_membership(members=[self.user_id, self.rmcreator_id], room=\n room, expect_code=403)\n", "self.helper.invite(room=room, src=self.user_id, targ=self.rmcreator_id,\n expect_code=403)\n", "for usr in [self.user_id, self.rmcreator_id]:\n", "self.helper.join(room=room, user=usr, expect_code=404)\n", "self.helper.leave(room=room, user=usr, expect_code=404)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'", "For", "Expr'", "Expr'" ]
[ "async def FUNC_7(self, VAR_18: str, VAR_19: str, VAR_14: str, VAR_20:...\n", "\"\"\"docstring\"\"\"\n", "VAR_39 = FUNC_2([pa['room_id'] for pa in VAR_20])\n", "VAR_26 = await self.store.get_events([pa['event_id'] for pa in VAR_20])\n", "VAR_32 = {}\n", "for pa in VAR_20:\n", "VAR_32.setdefault(pa['room_id'], []).append(pa)\n", "VAR_40 = {}\n", "VAR_64 = await self.store.get_profile_displayname(UserID.from_string(VAR_19\n ).localpart)\n", "VAR_64 = VAR_19\n", "async def FUNC_18(VAR_24):...\n", "if VAR_64 is None:\n", "VAR_65 = await self.store.get_current_state_ids(VAR_24)\n", "VAR_64 = VAR_19\n", "VAR_40[VAR_24] = VAR_65\n", "await concurrently_execute(FUNC_18, VAR_39, 3)\n", "VAR_39.sort(key=lambda r: -(notifs_by_room[r][-1]['received_ts'] or 0))\n", "VAR_41 = []\n", "for r in VAR_39:\n", "VAR_66 = await self.get_room_vars(r, VAR_19, VAR_32[r], VAR_26, VAR_40[r])\n", "VAR_21['room_name'] = await calculate_room_name(self.store, VAR_40[VAR_21[\n 'room_id']], VAR_19, fallback_to_members=True)\n", "VAR_41.append(VAR_66)\n", "VAR_42 = await self.make_summary_text(VAR_32, VAR_40, VAR_26, VAR_19, VAR_21)\n", "VAR_38 = {'user_display_name': VAR_64, 'unsubscribe_link': self.\n make_unsubscribe_link(VAR_19, VAR_18, VAR_14), 'summary_text': VAR_42,\n 'rooms': VAR_41, 'reason': VAR_21}\n", "await self.send_email(VAR_14, VAR_42, VAR_38)\n" ]
[ "async def send_notification_mail(self, app_id: str, user_id: str,...\n", "\"\"\"docstring\"\"\"\n", "rooms_in_order = deduped_ordered_list([pa['room_id'] for pa in push_actions])\n", "notif_events = await self.store.get_events([pa['event_id'] for pa in\n push_actions])\n", "notifs_by_room = {}\n", "for pa in push_actions:\n", "notifs_by_room.setdefault(pa['room_id'], []).append(pa)\n", "state_by_room = {}\n", "user_display_name = await self.store.get_profile_displayname(UserID.\n from_string(user_id).localpart)\n", "user_display_name = user_id\n", "async def _fetch_room_state(room_id):...\n", "if user_display_name is None:\n", "room_state = await self.store.get_current_state_ids(room_id)\n", "user_display_name = user_id\n", "state_by_room[room_id] = room_state\n", "await concurrently_execute(_fetch_room_state, rooms_in_order, 3)\n", "rooms_in_order.sort(key=lambda r: -(notifs_by_room[r][-1]['received_ts'] or 0))\n", "rooms = []\n", "for r in rooms_in_order:\n", "roomvars = await self.get_room_vars(r, user_id, notifs_by_room[r],\n notif_events, state_by_room[r])\n", "reason['room_name'] = await calculate_room_name(self.store, state_by_room[\n reason['room_id']], user_id, fallback_to_members=True)\n", "rooms.append(roomvars)\n", "summary_text = await self.make_summary_text(notifs_by_room, state_by_room,\n notif_events, user_id, reason)\n", "template_vars = {'user_display_name': user_display_name, 'unsubscribe_link':\n self.make_unsubscribe_link(user_id, app_id, email_address),\n 'summary_text': summary_text, 'rooms': rooms, 'reason': reason}\n", "await self.send_email(email_address, summary_text, template_vars)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "For", "Expr'", "Assign'", "Assign'", "Assign'", "AsyncFunctionDef'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "For", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_4(self, VAR_2, VAR_3, VAR_4='other_server'):...\n", "VAR_7 = self.helper.create_room_as(VAR_2, tok=token)\n", "VAR_13 = self.hs.get_datastore()\n", "VAR_14 = self.hs.get_federation_handler()\n", "VAR_15 = self.get_success(VAR_13.get_latest_event_ids_in_room(VAR_7))\n", "VAR_16 = self.get_success(VAR_13.get_room_version(VAR_7))\n", "VAR_17 = EventBuilderFactory(self.hs)\n", "VAR_17.hostname = VAR_4\n", "VAR_18 = UserID('user', VAR_4).to_string()\n", "VAR_19 = {'type': EventTypes.Member, 'state_key': VAR_18, 'content': {\n 'membership': Membership.JOIN}, 'sender': VAR_18, 'room_id': VAR_7}\n", "VAR_20 = VAR_17.for_room_version(VAR_16, VAR_19)\n", "VAR_21 = self.get_success(VAR_20.build(VAR_15, None))\n", "self.get_success(VAR_14.on_send_join_request(VAR_4, VAR_21))\n", "self.replicate()\n", "return VAR_7\n" ]
[ "def create_room_with_remote_server(self, user, token, remote_server=...\n", "room = self.helper.create_room_as(user, tok=token)\n", "store = self.hs.get_datastore()\n", "federation = self.hs.get_federation_handler()\n", "prev_event_ids = self.get_success(store.get_latest_event_ids_in_room(room))\n", "room_version = self.get_success(store.get_room_version(room))\n", "factory = EventBuilderFactory(self.hs)\n", "factory.hostname = remote_server\n", "user_id = UserID('user', remote_server).to_string()\n", "event_dict = {'type': EventTypes.Member, 'state_key': user_id, 'content': {\n 'membership': Membership.JOIN}, 'sender': user_id, 'room_id': room}\n", "builder = factory.for_room_version(room_version, event_dict)\n", "join_event = self.get_success(builder.build(prev_event_ids, None))\n", "self.get_success(federation.on_send_join_request(remote_server, join_event))\n", "self.replicate()\n", "return room\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_24(VAR_35):...\n", "VAR_35.terminate()\n", "VAR_35.join()\n" ]
[ "def close_server(process):...\n", "process.terminate()\n", "process.join()\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'" ]
[ "def __init__(self):...\n", "self._configs = OrderedDict()\n", "for VAR_74 in self.config_classes:\n", "if VAR_74.section is None:\n", "VAR_78 = VAR_74(self)\n", "self._configs[VAR_74.section] = VAR_78\n" ]
[ "def __init__(self):...\n", "self._configs = OrderedDict()\n", "for config_class in self.config_classes:\n", "if config_class.section is None:\n", "conf = config_class(self)\n", "self._configs[config_class.section] = conf\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_15(self, VAR_14: str, VAR_15: str, VAR_16: dict) ->None:...\n", "\"\"\"docstring\"\"\"\n", "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" ]
[ "def expect_outgoing_key_query(self, expected_server_name: str,...\n", "\"\"\"docstring\"\"\"\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, 0, 0 ]
[ "FunctionDef'", "Docstring", "AsyncFunctionDef'", "Expr'", "Expr'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_58(self, VAR_36, VAR_82, VAR_141):...\n", "\"\"\"docstring\"\"\"\n", "VAR_275 = str(int(time.time())) + '-' + web2py_uuid()\n", "VAR_276 = self.url(self.settings.function, VAR_11=('confirm_registration',),\n VAR_96={'key': reset_password_key}, VAR_97=True)\n", "VAR_27 = dict(VAR_141)\n", "VAR_27.update(dict(VAR_199=reset_password_key, VAR_276=link, site=current.\n request.env.http_host))\n", "if self.settings.mailer and self.settings.mailer.send(VAR_35=user.email,\n", "VAR_141.update_record(VAR_275=reset_password_key)\n", "return False\n", "return True\n" ]
[ "def email_registration(self, subject, body, user):...\n", "\"\"\"docstring\"\"\"\n", "reset_password_key = str(int(time.time())) + '-' + web2py_uuid()\n", "link = self.url(self.settings.function, args=('confirm_registration',),\n vars={'key': reset_password_key}, scheme=True)\n", "d = dict(user)\n", "d.update(dict(key=reset_password_key, link=link, site=current.request.env.\n http_host))\n", "if self.settings.mailer and self.settings.mailer.send(to=user.email,\n", "user.update_record(reset_password_key=reset_password_key)\n", "return False\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Expr'", "Return'", "Return'" ]
[ "@app.route('/login')...\n", "from flask_login import current_user\n", "VAR_40 = request.args.get('redirect', request.script_root + url_for('index'))\n", "VAR_41 = sorted(filter(lambda VAR_136: VAR_136 is not None and isinstance(\n VAR_136, OctoPrintPermission), map(lambda VAR_136: getattr(Permissions,\n VAR_136.strip()), request.args.get('permissions', '').split(','))),\n VAR_8=lambda x: x.get_name())\n", "if not VAR_41:\n", "VAR_41 = [Permissions.STATUS, Permissions.SETTINGS_READ]\n", "VAR_42 = request.args.get('user_id', '')\n", "if (not VAR_42 or current_user.get_id() == VAR_42) and has_permissions(*VAR_41\n", "return redirect(VAR_40)\n", "VAR_43 = {'theming': [], 'redirect_url': VAR_40, 'permission_names': map(lambda\n VAR_136: VAR_136.get_name(), VAR_41), 'user_id': VAR_42, 'logged_in': \n not current_user.is_anonymous}\n", "VAR_99 = FUNC_4('octoprint.theming.login')\n", "VAR_0.exception('Error processing theming CSS, ignoring')\n", "return render_template('login.jinja2', **render_kwargs)\n", "VAR_99 += FUNC_4('octoprint.plugin.forcelogin.theming')\n", "VAR_99 += FUNC_4('octoprint.plugin.loginui.theming')\n", "VAR_43.update({'theming': VAR_99})\n" ]
[ "@app.route('/login')...\n", "from flask_login import current_user\n", "redirect_url = request.args.get('redirect', request.script_root + url_for(\n 'index'))\n", "permissions = sorted(filter(lambda x: x is not None and isinstance(x,\n OctoPrintPermission), map(lambda x: getattr(Permissions, x.strip()),\n request.args.get('permissions', '').split(','))), key=lambda x: x.\n get_name())\n", "if not permissions:\n", "permissions = [Permissions.STATUS, Permissions.SETTINGS_READ]\n", "user_id = request.args.get('user_id', '')\n", "if (not user_id or current_user.get_id() == user_id) and has_permissions(*\n", "return redirect(redirect_url)\n", "render_kwargs = {'theming': [], 'redirect_url': redirect_url,\n 'permission_names': map(lambda x: x.get_name(), permissions), 'user_id':\n user_id, 'logged_in': not current_user.is_anonymous}\n", "additional_assets = _add_additional_assets('octoprint.theming.login')\n", "_logger.exception('Error processing theming CSS, ignoring')\n", "return render_template('login.jinja2', **render_kwargs)\n", "additional_assets += _add_additional_assets(\n 'octoprint.plugin.forcelogin.theming')\n", "additional_assets += _add_additional_assets('octoprint.plugin.loginui.theming')\n", "render_kwargs.update({'theming': additional_assets})\n" ]
[ 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "ImportFrom'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "Expr'", "Return'", "AugAssign'", "AugAssign'", "Expr'" ]
[ "def FUNC_51(VAR_133, VAR_134=None):...\n", "" ]
[ "def get_next(it, opt=None):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_2(VAR_5, VAR_4, VAR_10=None, VAR_11=None):...\n", "if VAR_5.component.has_template():\n", "return CLASS_61(VAR_5, VAR_4, VAR_10=data, VAR_11=initial)\n", "if VAR_5.component.is_glossary:\n", "if VAR_5.is_source:\n", "if VAR_5.is_source:\n", "return CLASS_64(VAR_5, VAR_4, VAR_10=data, VAR_11=initial)\n", "return CLASS_65(VAR_5, VAR_4, VAR_10=data, VAR_11=initial)\n", "return CLASS_62(VAR_5, VAR_4, VAR_10=data, VAR_11=initial)\n", "return CLASS_63(VAR_5, VAR_4, VAR_10=data, VAR_11=initial)\n" ]
[ "def get_new_unit_form(translation, user, data=None, initial=None):...\n", "if translation.component.has_template():\n", "return NewMonolingualUnitForm(translation, user, data=data, initial=initial)\n", "if translation.component.is_glossary:\n", "if translation.is_source:\n", "if translation.is_source:\n", "return NewBilingualGlossarySourceUnitForm(translation, user, data=data,\n initial=initial)\n", "return NewBilingualGlossaryUnitForm(translation, user, data=data, initial=\n initial)\n", "return NewBilingualSourceUnitForm(translation, user, data=data, initial=initial\n )\n", "return NewBilingualUnitForm(translation, user, data=data, initial=initial)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Condition", "Condition", "Condition", "Return'", "Return'", "Return'", "Return'" ]
[ "def FUNC_9():...\n", "return FUNC_4('use_email_as_submitter')\n" ]
[ "def use_email_as_submitter_default():...\n", "return get_default_setting('use_email_as_submitter')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_5(VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "VAR_31 = saved_model_utils.read_saved_model(VAR_2).meta_graphs\n", "VAR_32 = False\n", "for VAR_4 in VAR_31:\n", "VAR_32 |= VAR_4.HasField('object_graph_def')\n", "if not VAR_32:\n", "return\n", "VAR_64 = load.load(VAR_2)\n", "print(\"\"\"\nConcrete Functions:\"\"\", VAR_35='')\n", "VAR_33 = list(save._AugmentedGraphView(VAR_64).list_children(VAR_64))\n", "VAR_33 = sorted(VAR_33, key=lambda x: x.name)\n", "for name, child in VAR_33:\n", "VAR_65 = []\n", "if isinstance(child, defun.ConcreteFunction):\n", "VAR_65.append(child)\n", "if isinstance(child, def_function.Function):\n", "print(\"\"\"\n Function Name: '%s'\"\"\" % name)\n", "VAR_65.extend(child._list_all_concrete_functions_for_serialization())\n", "VAR_65 = sorted(VAR_65, key=lambda x: x.name)\n", "for index, concrete_function in enumerate(VAR_65, 1):\n", "VAR_22, VAR_79 = None, None\n", "if concrete_function.structured_input_signature:\n", "VAR_22, VAR_79 = concrete_function.structured_input_signature\n", "if concrete_function._arg_keywords:\n", "if VAR_22:\n", "VAR_22 = concrete_function._arg_keywords\n", "print(' Option #%d' % index)\n", "if VAR_79:\n", "print(' Callable with:')\n", "FUNC_6(VAR_79, 'Named Argument', VAR_6=4)\n", "FUNC_6(VAR_22, VAR_6=4)\n" ]
[ "def _show_defined_functions(saved_model_dir):...\n", "\"\"\"docstring\"\"\"\n", "meta_graphs = saved_model_utils.read_saved_model(saved_model_dir).meta_graphs\n", "has_object_graph_def = False\n", "for meta_graph_def in meta_graphs:\n", "has_object_graph_def |= meta_graph_def.HasField('object_graph_def')\n", "if not has_object_graph_def:\n", "return\n", "trackable_object = load.load(saved_model_dir)\n", "print(\"\"\"\nConcrete Functions:\"\"\", end='')\n", "children = list(save._AugmentedGraphView(trackable_object).list_children(\n trackable_object))\n", "children = sorted(children, key=lambda x: x.name)\n", "for name, child in children:\n", "concrete_functions = []\n", "if isinstance(child, defun.ConcreteFunction):\n", "concrete_functions.append(child)\n", "if isinstance(child, def_function.Function):\n", "print(\"\"\"\n Function Name: '%s'\"\"\" % name)\n", "concrete_functions.extend(child.\n _list_all_concrete_functions_for_serialization())\n", "concrete_functions = sorted(concrete_functions, key=lambda x: x.name)\n", "for index, concrete_function in enumerate(concrete_functions, 1):\n", "args, kwargs = None, None\n", "if concrete_function.structured_input_signature:\n", "args, kwargs = concrete_function.structured_input_signature\n", "if concrete_function._arg_keywords:\n", "if args:\n", "args = concrete_function._arg_keywords\n", "print(' Option #%d' % index)\n", "if kwargs:\n", "print(' Callable with:')\n", "_print_args(kwargs, 'Named Argument', indent=4)\n", "_print_args(args, indent=4)\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 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "For", "AugAssign'", "Condition", "Return'", "Assign'", "Expr'", "Assign'", "Assign'", "For", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Assign'", "For", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Expr'", "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def test___post_init__(self):...\n", "from openapi_python_client.parser.properties import StringProperty\n", "VAR_8 = VAR_35(VAR_5='test', VAR_26=True, default='A Default Value')\n", "assert VAR_8.default == '\"A Default Value\"'\n" ]
[ "def test___post_init__(self):...\n", "from openapi_python_client.parser.properties import StringProperty\n", "sp = StringProperty(name='test', required=True, default='A Default Value')\n", "assert sp.default == '\"A Default Value\"'\n" ]
[ 0, 0, 5, 5 ]
[ "FunctionDef'", "ImportFrom'", "Assign'", "Assert'" ]
[ "def __init__(self, *VAR_6, **VAR_7):...\n", "self.profile = None\n", "super().__init__(*VAR_6, **kwargs)\n" ]
[ "def __init__(self, *args, **kwargs):...\n", "self.profile = None\n", "super().__init__(*args, **kwargs)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "@ensure_csrf_cookie...\n", "\"\"\"docstring\"\"\"\n", "VAR_10 = SlashSeparatedCourseKey.from_deprecated_string(VAR_10)\n", "VAR_65 = get_course_with_access(VAR_9.user, 'staff', VAR_10, depth=None)\n", "VAR_67 = instructor_analytics.basic.dump_grading_context(VAR_65)\n", "VAR_63 = {'course_id': VAR_10.to_deprecated_string(),\n 'grading_config_summary': VAR_67}\n", "return JsonResponse(VAR_63)\n" ]
[ "@ensure_csrf_cookie...\n", "\"\"\"docstring\"\"\"\n", "course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n", "course = get_course_with_access(request.user, 'staff', course_id, depth=None)\n", "grading_config_summary = instructor_analytics.basic.dump_grading_context(course\n )\n", "response_payload = {'course_id': course_id.to_deprecated_string(),\n 'grading_config_summary': grading_config_summary}\n", "return JsonResponse(response_payload)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_44(self):...\n", "VAR_12 = 'hello'\n", "VAR_22, VAR_23 = self.make_request('POST',\n '/_matrix/client/r0/rooms/{}/unban'.format(self.room_id), VAR_19={\n 'reason': reason, 'user_id': self.second_user_id}, VAR_16=self.creator_tok)\n", "self.assertEqual(VAR_23.code, 200, VAR_23.result)\n", "self._check_for_reason(VAR_12)\n" ]
[ "def test_unban_reason(self):...\n", "reason = 'hello'\n", "request, channel = self.make_request('POST',\n '/_matrix/client/r0/rooms/{}/unban'.format(self.room_id), content={\n 'reason': reason, 'user_id': self.second_user_id}, access_token=self.\n creator_tok)\n", "self.assertEqual(channel.code, 200, channel.result)\n", "self._check_for_reason(reason)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_79(self):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.desk.doctype.tag.tag import DocTags\n", "return DocTags(self.doctype).get_tags(self.name).split(',')[1:]\n" ]
[ "def get_tags(self):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.desk.doctype.tag.tag import DocTags\n", "return DocTags(self.doctype).get_tags(self.name).split(',')[1:]\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "ImportFrom'", "Return'" ]
[ "def FUNC_36(self, VAR_20):...\n", "if VAR_20 == constants.SIDEBAR_RECENT:\n", "return True\n", "return constants.has_flag(self.sidebar_view, VAR_20)\n" ]
[ "def check_visibility(self, value):...\n", "if value == constants.SIDEBAR_RECENT:\n", "return True\n", "return constants.has_flag(self.sidebar_view, value)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_18(VAR_9, VAR_10):...\n", "if VAR_87.check_visibility(constants.SIDEBAR_HOT):\n", "if VAR_10[1] not in ['hotasc', 'hotdesc']:\n", "abort(404)\n", "VAR_10 = [func.count(ub.Downloads.book_id).desc()], 'hotdesc'\n", "if VAR_87.show_detail_random():\n", "VAR_68 = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()\n ).order_by(func.random()).limit(config.config_random_books)\n", "VAR_68 = false()\n", "VAR_79 = int(int(config.config_books_per_page) * (VAR_9 - 1))\n", "VAR_101 = ub.session.query(ub.Downloads, func.count(ub.Downloads.book_id)\n ).order_by(*VAR_10[0]).group_by(ub.Downloads.book_id)\n", "VAR_102 = VAR_101.offset(VAR_79).limit(config.config_books_per_page)\n", "VAR_63 = list()\n", "for VAR_95 in VAR_102:\n", "VAR_125 = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()\n ).filter(db.Books.id == VAR_95.Downloads.book_id).first()\n", "VAR_103 = VAR_63.__len__()\n", "if VAR_125:\n", "VAR_65 = Pagination(VAR_9, config.config_books_per_page, VAR_103)\n", "VAR_63.append(VAR_125)\n", "ub.delete_download(VAR_95.Downloads.book_id)\n", "return render_title_template('index.html', VAR_68=random, VAR_63=entries,\n VAR_65=pagination, VAR_150=_(u'Hot Books (Most Downloaded)'), VAR_9=\n 'hot', VAR_10=order[1])\n" ]
[ "def render_hot_books(page, order):...\n", "if current_user.check_visibility(constants.SIDEBAR_HOT):\n", "if order[1] not in ['hotasc', 'hotdesc']:\n", "abort(404)\n", "order = [func.count(ub.Downloads.book_id).desc()], 'hotdesc'\n", "if current_user.show_detail_random():\n", "random = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()\n ).order_by(func.random()).limit(config.config_random_books)\n", "random = false()\n", "off = int(int(config.config_books_per_page) * (page - 1))\n", "all_books = ub.session.query(ub.Downloads, func.count(ub.Downloads.book_id)\n ).order_by(*order[0]).group_by(ub.Downloads.book_id)\n", "hot_books = all_books.offset(off).limit(config.config_books_per_page)\n", "entries = list()\n", "for book in hot_books:\n", "downloadBook = calibre_db.session.query(db.Books).filter(calibre_db.\n common_filters()).filter(db.Books.id == book.Downloads.book_id).first()\n", "numBooks = entries.__len__()\n", "if downloadBook:\n", "pagination = Pagination(page, config.config_books_per_page, numBooks)\n", "entries.append(downloadBook)\n", "ub.delete_download(book.Downloads.book_id)\n", "return render_title_template('index.html', random=random, entries=entries,\n pagination=pagination, title=_(u'Hot Books (Most Downloaded)'), page=\n 'hot', order=order[1])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Expr'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_2(self) ->str:...\n", "\"\"\"docstring\"\"\"\n", "if self.required:\n", "return self._type_string\n", "return f'Optional[{self._type_string}]'\n" ]
[ "def get_type_string(self) ->str:...\n", "\"\"\"docstring\"\"\"\n", "if self.required:\n", "return self._type_string\n", "return f'Optional[{self._type_string}]'\n" ]
[ 0, 0, 5, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Return'" ]
[ "def __init__(self, VAR_2, VAR_3):...\n", "self.app = VAR_2\n", "self.memcache_servers = VAR_3.get('memcache_servers')\n", "if not self.memcache_servers:\n", "VAR_6 = os.path.join(VAR_3.get('swift_dir', '/etc/swift'), 'memcache.conf')\n", "if not self.memcache_servers:\n", "VAR_7 = ConfigParser()\n", "self.memcache_servers = '127.0.0.1:11211'\n", "self.memcache = MemcacheRing([s.strip() for s in self.memcache_servers.\n split(',') if s.strip()])\n", "if VAR_7.read(VAR_6):\n", "self.memcache_servers = VAR_7.get('memcache', 'memcache_servers')\n" ]
[ "def __init__(self, app, conf):...\n", "self.app = app\n", "self.memcache_servers = conf.get('memcache_servers')\n", "if not self.memcache_servers:\n", "path = os.path.join(conf.get('swift_dir', '/etc/swift'), 'memcache.conf')\n", "if not self.memcache_servers:\n", "memcache_conf = ConfigParser()\n", "self.memcache_servers = '127.0.0.1:11211'\n", "self.memcache = MemcacheRing([s.strip() for s in self.memcache_servers.\n split(',') if s.strip()])\n", "if memcache_conf.read(path):\n", "self.memcache_servers = memcache_conf.get('memcache', 'memcache_servers')\n" ]
[ 0, 0, 0, 5, 0, 0, 0, 0, 5, 0, 5 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'" ]