lines
sequencelengths
1
383
raw_lines
sequencelengths
1
383
label
sequencelengths
1
383
type
sequencelengths
1
383
[ "def FUNC_2(self, VAR_3, VAR_4):...\n", "\"\"\"docstring\"\"\"\n", "VAR_10 = list(itertools.chain(*VAR_3.context['form'].errors.values()))\n", "self.assertIn(force_text(VAR_4), VAR_10)\n" ]
[ "def assertFormError(self, response, error):...\n", "\"\"\"docstring\"\"\"\n", "form_errors = list(itertools.chain(*response.context['form'].errors.values()))\n", "self.assertIn(force_text(error), form_errors)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'" ]
[ "@VAR_2.user_loader...\n", "return CLASS_0.query.get(int(VAR_4))\n" ]
[ "@login.user_loader...\n", "return User.query.get(int(user_id))\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_8(VAR_13):...\n", "\"\"\"docstring\"\"\"\n", "VAR_28 = VAR_13.get('max_open_files', 100000)\n", "if sys.platform.startswith('win'):\n", "VAR_46 = VAR_47 = win32file._getmaxstdio()\n", "VAR_46, VAR_47 = resource.getrlimit(resource.RLIMIT_NOFILE)\n", "VAR_29 = VAR_54.path.join(VAR_13.get('pki_dir'), 'minions')\n", "VAR_30 = len(VAR_54.listdir(VAR_29))\n", "VAR_0.debug('This salt-master instance has accepted {0} minion keys.'.\n format(VAR_30))\n", "VAR_31 = logging.INFO\n", "if VAR_30 * 4 <= VAR_46:\n", "return\n", "VAR_32 = 'string'.format(VAR_30, VAR_46)\n", "if VAR_30 >= VAR_46:\n", "VAR_32 += 'salt-master will crash pretty soon! '\n", "if VAR_30 * 2 >= VAR_46:\n", "VAR_31 = logging.CRITICAL\n", "VAR_31 = logging.CRITICAL\n", "if VAR_30 * 3 >= VAR_46:\n", "if VAR_28 < VAR_47:\n", "VAR_31 = logging.WARNING\n", "if VAR_30 * 4 >= VAR_46:\n", "VAR_32 += 'string'.format(VAR_47 - VAR_28)\n", "VAR_32 += 'Please consider raising this value.'\n", "VAR_31 = logging.INFO\n", "VAR_0.log(VAR_31=level, VAR_32=msg)\n" ]
[ "def check_max_open_files(opts):...\n", "\"\"\"docstring\"\"\"\n", "mof_c = opts.get('max_open_files', 100000)\n", "if sys.platform.startswith('win'):\n", "mof_s = mof_h = win32file._getmaxstdio()\n", "mof_s, mof_h = resource.getrlimit(resource.RLIMIT_NOFILE)\n", "accepted_keys_dir = os.path.join(opts.get('pki_dir'), 'minions')\n", "accepted_count = len(os.listdir(accepted_keys_dir))\n", "log.debug('This salt-master instance has accepted {0} minion keys.'.format(\n accepted_count))\n", "level = logging.INFO\n", "if accepted_count * 4 <= mof_s:\n", "return\n", "msg = (\n 'The number of accepted minion keys({0}) should be lower than 1/4 of the max open files soft setting({1}). '\n .format(accepted_count, mof_s))\n", "if accepted_count >= mof_s:\n", "msg += 'salt-master will crash pretty soon! '\n", "if accepted_count * 2 >= mof_s:\n", "level = logging.CRITICAL\n", "level = logging.CRITICAL\n", "if accepted_count * 3 >= mof_s:\n", "if mof_c < mof_h:\n", "level = logging.WARNING\n", "if accepted_count * 4 >= mof_s:\n", "msg += (\n \"According to the system's hard limit, there's still a margin of {0} to raise the salt's max_open_files setting. \"\n .format(mof_h - mof_c))\n", "msg += 'Please consider raising this value.'\n", "level = logging.INFO\n", "log.log(level=level, msg=msg)\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", "Assign'", "For", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Return'", "Assign'", "Condition", "AugAssign'", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Condition", "AugAssign'", "AugAssign'", "Assign'", "Expr'" ]
[ "def FUNC_13(self):...\n", "self.assertFormfield(models.Band, 'members', forms.SelectMultiple)\n" ]
[ "def testManyToMany(self):...\n", "self.assertFormfield(models.Band, 'members', forms.SelectMultiple)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_61(self):...\n", "User.objects.filter(username='testclient').update(is_staff=True,\n is_superuser=True)\n", "self.login()\n", "self.admin = User.objects.get(pk=1)\n" ]
[ "def setUp(self):...\n", "User.objects.filter(username='testclient').update(is_staff=True,\n is_superuser=True)\n", "self.login()\n", "self.admin = User.objects.get(pk=1)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Assign'" ]
[ "def __call__(VAR_20, VAR_21):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_20(VAR_2, *VAR_23, **VAR_24):...\n", "\"\"\"docstring\"\"\"\n", "VAR_22 = VAR_21(VAR_2, *VAR_23, **kwargs)\n", "if isinstance(VAR_22, HttpResponseBase):\n", "return VAR_22\n", "VAR_37 = 'template' in VAR_22 and VAR_22['template'] or None\n", "VAR_37 = VAR_24.get('template', VAR_37)\n", "VAR_0.debug('Rendering template: %s' % VAR_37)\n", "if VAR_37 is None or VAR_37 == 'json':\n", "VAR_40 = type(VAR_22) is dict\n", "VAR_20.prepare_context(VAR_2, VAR_22, *VAR_23, **kwargs)\n", "return JsonResponse(VAR_22, VAR_40=safe)\n", "return render(VAR_2, VAR_37, VAR_22)\n" ]
[ "def __call__(ctx, f):...\n", "\"\"\"docstring\"\"\"\n", "def wrapper(request, *args, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "context = f(request, *args, **kwargs)\n", "if isinstance(context, HttpResponseBase):\n", "return context\n", "template = 'template' in context and context['template'] or None\n", "template = kwargs.get('template', template)\n", "logger.debug('Rendering template: %s' % template)\n", "if template is None or template == 'json':\n", "safe = type(context) is dict\n", "ctx.prepare_context(request, context, *args, **kwargs)\n", "return JsonResponse(context, safe=safe)\n", "return render(request, template, context)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Docstring", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Expr'", "Return'", "Return'" ]
[ "def FUNC_13(self, VAR_8):...\n", "VAR_14 = re.search('https?://[^/]*(/.*reset/\\\\S*)', VAR_8.body)\n", "self.assertTrue(VAR_14 is not None, 'No URL found in sent email')\n", "return VAR_14.group(), VAR_14.groups()[0]\n" ]
[ "def _read_signup_email(self, email):...\n", "urlmatch = re.search('https?://[^/]*(/.*reset/\\\\S*)', email.body)\n", "self.assertTrue(urlmatch is not None, 'No URL found in sent email')\n", "return urlmatch.group(), urlmatch.groups()[0]\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_44(self, **VAR_133):...\n", "\"\"\"docstring\"\"\"\n", "VAR_222 = self._get_login_settings()\n", "if VAR_133.get(VAR_222.passfield):\n", "VAR_133[VAR_222.passfield] = VAR_222.table_user[VAR_222.passfield].validate(\n VAR_133[VAR_222.passfield], None)[0]\n", "if not VAR_133.get(VAR_222.userfield):\n", "VAR_141 = self.get_or_create_user(VAR_133, VAR_33=False, VAR_130=False,\n VAR_129=self.settings.update_fields)\n", "if not VAR_141:\n", "return False\n", "return VAR_141\n" ]
[ "def register_bare(self, **fields):...\n", "\"\"\"docstring\"\"\"\n", "settings = self._get_login_settings()\n", "if fields.get(settings.passfield):\n", "fields[settings.passfield] = settings.table_user[settings.passfield].validate(\n fields[settings.passfield], None)[0]\n", "if not fields.get(settings.userfield):\n", "user = self.get_or_create_user(fields, login=False, get=False,\n update_fields=self.settings.update_fields)\n", "if not user:\n", "return False\n", "return user\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Return'", "Return'" ]
[ "async def FUNC_8(self, VAR_16):...\n", "\"\"\"docstring\"\"\"\n", "VAR_26 = {}\n", "async def FUNC_15(VAR_41):...\n", "VAR_2, VAR_6 = VAR_41\n", "VAR_31 = await self.get_server_verify_key_v2_direct(VAR_2, VAR_6)\n", "VAR_0.warning('Error looking up keys %s from %s: %s', VAR_6, VAR_2, e)\n", "await yieldable_gather_results(FUNC_15, VAR_16.items())\n", "VAR_26[VAR_2] = VAR_31\n", "VAR_0.exception('Error getting keys %s from %s', VAR_6, VAR_2)\n", "return VAR_26\n" ]
[ "async def get_keys(self, keys_to_fetch):...\n", "\"\"\"docstring\"\"\"\n", "results = {}\n", "async def get_key(key_to_fetch_item):...\n", "server_name, key_ids = key_to_fetch_item\n", "keys = await self.get_server_verify_key_v2_direct(server_name, key_ids)\n", "logger.warning('Error looking up keys %s from %s: %s', key_ids, server_name, e)\n", "await yieldable_gather_results(get_key, keys_to_fetch.items())\n", "results[server_name] = keys\n", "logger.exception('Error getting keys %s from %s', key_ids, server_name)\n", "return results\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Docstring", "Assign'", "AsyncFunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_12(VAR_30: Fingerprint, VAR_31: Fingerprint, VAR_32: Section) ->bool:...\n", "\"\"\"docstring\"\"\"\n", "for k in VAR_32.relevant_keys:\n", "if VAR_30.get(k) != VAR_31.get(k):\n", "return False\n", "VAR_0.info(f'Data ({k}) for {VAR_32.name} section changed.')\n", "return True\n" ]
[ "def did_section_fingerprint_change(fingerprint1: Fingerprint, fingerprint2:...\n", "\"\"\"docstring\"\"\"\n", "for k in section.relevant_keys:\n", "if fingerprint1.get(k) != fingerprint2.get(k):\n", "return False\n", "logger.info(f'Data ({k}) for {section.name} section changed.')\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "For", "Condition", "Return'", "Expr'", "Return'" ]
[ "def FUNC_145(self):...\n", "if not self.can_manage():\n", "return self.not_authorized()\n", "self.auth.db.wiki_page.slug.represent = lambda VAR_156, VAR_266: SPAN(\n '@////%s' % VAR_156)\n", "self.auth.db.wiki_page.title.represent = lambda VAR_441, VAR_266: A(VAR_441,\n _href=URL(args=row.slug))\n", "VAR_339 = self.auth.db.wiki_page\n", "VAR_229 = SQLFORM.grid(VAR_339, VAR_133=[wiki_table.slug, wiki_table.title,\n wiki_table.tags, wiki_table.can_read, wiki_table.can_edit], VAR_335=[lambda\n row: A('edit', _href=URL(args=('_edit', row.slug)), _class='btn'), lambda\n row: A('media', _href=URL(args=('_editmedia', row.slug)), _class='btn')\n ], details=False, editable=False, VAR_170=False, VAR_337=False, VAR_174\n =self.auth.db.wiki_page.title, VAR_11=['_pages'], user_signature=False)\n", "return dict(VAR_229=content)\n" ]
[ "def pages(self):...\n", "if not self.can_manage():\n", "return self.not_authorized()\n", "self.auth.db.wiki_page.slug.represent = lambda slug, row: SPAN('@////%s' % slug\n )\n", "self.auth.db.wiki_page.title.represent = lambda title, row: A(title, _href=\n URL(args=row.slug))\n", "wiki_table = self.auth.db.wiki_page\n", "content = SQLFORM.grid(wiki_table, fields=[wiki_table.slug, wiki_table.\n title, wiki_table.tags, wiki_table.can_read, wiki_table.can_edit],\n links=[lambda row: A('edit', _href=URL(args=('_edit', row.slug)),\n _class='btn'), lambda row: A('media', _href=URL(args=('_editmedia', row\n .slug)), _class='btn')], details=False, editable=False, deletable=False,\n create=False, orderby=self.auth.db.wiki_page.title, args=['_pages'],\n user_signature=False)\n", "return dict(content=content)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_9(VAR_21):...\n", "\"\"\"docstring\"\"\"\n", "if len(VAR_21) > 13:\n", "VAR_28 = int(VAR_21, 36)\n", "if six.PY2 and VAR_28 > sys.maxint:\n", "return VAR_28\n" ]
[ "def base36_to_int(s):...\n", "\"\"\"docstring\"\"\"\n", "if len(s) > 13:\n", "value = int(s, 36)\n", "if six.PY2 and value > sys.maxint:\n", "return value\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Return'" ]
[ "def FUNC_67(VAR_125, VAR_46, VAR_105):...\n", "\"\"\"docstring\"\"\"\n", "if isinstance(VAR_105, dict):\n", "VAR_125.setdefault(VAR_46, {})\n", "VAR_125.setdefault(VAR_46, [])\n", "for inkey in VAR_105:\n", "if not isinstance(VAR_105, list):\n", "FUNC_67(VAR_125[VAR_46], inkey, VAR_105[inkey])\n", "VAR_105 = [VAR_105]\n", "VAR_125[VAR_46].extend(VAR_105)\n" ]
[ "def append_hook(target, key, value):...\n", "\"\"\"docstring\"\"\"\n", "if isinstance(value, dict):\n", "target.setdefault(key, {})\n", "target.setdefault(key, [])\n", "for inkey in value:\n", "if not isinstance(value, list):\n", "append_hook(target[key], inkey, value[inkey])\n", "value = [value]\n", "target[key].extend(value)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'", "Expr'", "For", "Condition", "Expr'", "Assign'", "Expr'" ]
[ "\"\"\"\nMirrorManager2 xmlrpc controller.\n\"\"\"\n", "import base64\n", "import pickle\n", "import bz2\n", "import flask\n", "from flaskext.xmlrpc import XMLRPCHandler, Fault\n", "from mirrormanager2.app import APP, ADMIN, SESSION\n", "from mirrormanager2.lib import model\n", "from mirrormanager2.lib.hostconfig import read_host_config\n", "VAR_0 = XMLRPCHandler('xmlrpc')\n", "VAR_0.connect(APP, '/xmlrpc')\n", "@VAR_0.register...\n", "VAR_2 = pickle.loads(bz2.decompress(base64.urlsafe_b64decode(VAR_1)))\n", "VAR_3, VAR_4 = read_host_config(SESSION, VAR_2)\n", "if VAR_3 is not None:\n", "return VAR_4 + 'checked in successful'\n", "return VAR_4 + 'error checking in'\n" ]
[ "\"\"\"\nMirrorManager2 xmlrpc controller.\n\"\"\"\n", "import base64\n", "import pickle\n", "import bz2\n", "import flask\n", "from flaskext.xmlrpc import XMLRPCHandler, Fault\n", "from mirrormanager2.app import APP, ADMIN, SESSION\n", "from mirrormanager2.lib import model\n", "from mirrormanager2.lib.hostconfig import read_host_config\n", "XMLRPC = XMLRPCHandler('xmlrpc')\n", "XMLRPC.connect(APP, '/xmlrpc')\n", "@XMLRPC.register...\n", "config = pickle.loads(bz2.decompress(base64.urlsafe_b64decode(pickledata)))\n", "r, message = read_host_config(SESSION, config)\n", "if r is not None:\n", "return message + 'checked in successful'\n", "return message + 'error checking in'\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Return'", "Return'" ]
[ "async def FUNC_7(VAR_25: 'TrainingDataImporter') ->VAR_1:...\n", "\"\"\"docstring\"\"\"\n", "import time\n", "VAR_26 = await VAR_25.get_config()\n", "VAR_52 = await VAR_25.get_domain()\n", "VAR_53 = await VAR_25.get_stories()\n", "VAR_54 = await VAR_25.get_nlu_data()\n", "VAR_55 = VAR_52.responses\n", "VAR_52 = copy.copy(VAR_52)\n", "VAR_52.responses = {}\n", "return {VAR_3: FUNC_8(VAR_26, VAR_28=CONFIG_KEYS), VAR_4: FUNC_8(VAR_26,\n VAR_27=CONFIG_KEYS_CORE), VAR_5: FUNC_8(VAR_26, VAR_27=CONFIG_KEYS_NLU),\n VAR_6: FUNC_9(VAR_26), VAR_7: VAR_52.fingerprint(), VAR_8: rasa.shared.\n utils.io.deep_container_fingerprint(VAR_55), VAR_13: FUNC_6(), VAR_11:\n VAR_54.fingerprint(), VAR_12: VAR_54.label_fingerprint(), VAR_10:\n VAR_53.fingerprint(), VAR_14: time.time(), VAR_9: rasa.__version__}\n" ]
[ "async def model_fingerprint(file_importer: 'TrainingDataImporter'...\n", "\"\"\"docstring\"\"\"\n", "import time\n", "config = await file_importer.get_config()\n", "domain = await file_importer.get_domain()\n", "stories = await file_importer.get_stories()\n", "nlu_data = await file_importer.get_nlu_data()\n", "responses = domain.responses\n", "domain = copy.copy(domain)\n", "domain.responses = {}\n", "return {FINGERPRINT_CONFIG_KEY: _get_fingerprint_of_config(config,\n exclude_keys=CONFIG_KEYS), FINGERPRINT_CONFIG_CORE_KEY:\n _get_fingerprint_of_config(config, include_keys=CONFIG_KEYS_CORE),\n FINGERPRINT_CONFIG_NLU_KEY: _get_fingerprint_of_config(config,\n include_keys=CONFIG_KEYS_NLU), FINGERPRINT_CONFIG_WITHOUT_EPOCHS_KEY:\n _get_fingerprint_of_config_without_epochs(config),\n FINGERPRINT_DOMAIN_WITHOUT_NLG_KEY: domain.fingerprint(),\n FINGERPRINT_NLG_KEY: rasa.shared.utils.io.deep_container_fingerprint(\n responses), FINGERPRINT_PROJECT: project_fingerprint(),\n FINGERPRINT_NLU_DATA_KEY: nlu_data.fingerprint(),\n FINGERPRINT_NLU_LABELS_KEY: nlu_data.label_fingerprint(),\n FINGERPRINT_STORIES_KEY: stories.fingerprint(),\n FINGERPRINT_TRAINED_AT_KEY: time.time(), FINGERPRINT_RASA_VERSION_KEY:\n rasa.__version__}\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Docstring", "Import'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_4():...\n", "assert utils.spinal_case('keep_alive') == 'keep-alive'\n" ]
[ "def test_spinal_case():...\n", "assert utils.spinal_case('keep_alive') == 'keep-alive'\n" ]
[ 0, 1 ]
[ "FunctionDef'", "Assert'" ]
[ "def FUNC_14(VAR_21: Text) ->bool:...\n", "return VAR_21 is not None and VAR_21.strip() != ''\n" ]
[ "def is_valid(input: Text) ->bool:...\n", "return input is not None and input.strip() != ''\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "import sys\n", "import os\n", "from setuptools import setup, find_packages\n", "from setuptools.command.test import test as TestCommand\n", "def FUNC_0(VAR_0):...\n", "VAR_1 = os.path.dirname(os.path.abspath(__file__))\n", "return open(os.path.join(VAR_1, VAR_0)).read()\n" ]
[ "import sys\n", "import os\n", "from setuptools import setup, find_packages\n", "from setuptools.command.test import test as TestCommand\n", "def _read(fname):...\n", "here = os.path.dirname(os.path.abspath(__file__))\n", "return open(os.path.join(here, fname)).read()\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "Return'" ]
[ "@ensure_csrf_cookie...\n", "\"\"\"docstring\"\"\"\n", "VAR_10 = SlashSeparatedCourseKey.from_deprecated_string(VAR_10)\n", "VAR_57 = VAR_9.POST.get('action')\n", "VAR_58 = VAR_9.POST.get('identifiers')\n", "VAR_59 = FUNC_64(VAR_58)\n", "VAR_60 = VAR_9.POST.get('auto_enroll') in ['true', 'True', True]\n", "VAR_61 = VAR_9.POST.get('email_students') in ['true', 'True', True]\n", "VAR_62 = CourseMode.is_white_label(VAR_10)\n", "VAR_22 = VAR_9.POST.get('reason')\n", "if VAR_62:\n", "if not VAR_22:\n", "VAR_55 = None\n", "return JsonResponse({'action': VAR_57, 'results': [{'error': True}],\n 'auto_enroll': VAR_60}, status=400)\n", "VAR_23 = DEFAULT_TRANSITION_STATE\n", "VAR_25 = {}\n", "if VAR_61:\n", "VAR_65 = get_course_by_id(VAR_10)\n", "VAR_51 = []\n", "VAR_25 = get_email_params(VAR_65, VAR_60, VAR_168=request.is_secure())\n", "for identifier in VAR_59:\n", "VAR_19 = None\n", "VAR_63 = {'action': VAR_57, 'results': VAR_51, 'auto_enroll': VAR_60}\n", "VAR_14 = None\n", "return JsonResponse(VAR_63)\n", "VAR_167 = None\n", "VAR_19 = get_student_from_identifier(identifier)\n", "VAR_14 = identifier\n", "VAR_14 = VAR_19.email\n", "validate_email(VAR_14)\n", "VAR_51.append({'identifier': identifier, 'invalidIdentifier': True})\n", "ManualEnrollmentAudit.create_manual_enrollment_audit(VAR_9.user, VAR_14,\n VAR_23, VAR_22, VAR_55)\n", "VAR_167 = get_user_email_language(VAR_19)\n", "if VAR_57 == 'enroll':\n", "VAR_0.exception(u'Error while #{}ing student')\n", "VAR_51.append({'identifier': identifier, 'before': VAR_200.to_dict(),\n 'after': VAR_201.to_dict()})\n", "VAR_200, VAR_201, VAR_55 = enroll_email(VAR_10, VAR_14, VAR_60, VAR_61,\n VAR_25, VAR_167=language)\n", "if VAR_57 == 'unenroll':\n", "VAR_0.exception(exc)\n", "VAR_202 = VAR_200.to_dict()['enrollment']\n", "VAR_200, VAR_201 = unenroll_email(VAR_10, VAR_14, VAR_61, VAR_25, VAR_167=\n language)\n", "return HttpResponseBadRequest(strip_tags(\"Unrecognized action '{}'\".format(\n VAR_57)))\n", "VAR_51.append({'identifier': identifier, 'error': True})\n", "VAR_203 = VAR_200.to_dict()['user']\n", "VAR_202 = VAR_200.to_dict()['enrollment']\n", "VAR_204 = VAR_200.to_dict()['allowed']\n", "VAR_204 = VAR_200.to_dict()['allowed']\n", "VAR_205 = VAR_201.to_dict()['enrollment']\n", "VAR_55 = CourseEnrollment.get_enrollment(VAR_19, VAR_10)\n", "VAR_206 = VAR_201.to_dict()['allowed']\n", "if VAR_202:\n", "if VAR_203:\n", "VAR_23 = ENROLLED_TO_UNENROLLED\n", "if VAR_204:\n", "if VAR_205:\n", "if VAR_206:\n", "VAR_23 = ALLOWEDTOENROLL_TO_UNENROLLED\n", "VAR_23 = UNENROLLED_TO_UNENROLLED\n", "if VAR_202:\n", "VAR_23 = UNENROLLED_TO_ALLOWEDTOENROLL\n", "VAR_23 = ENROLLED_TO_ENROLLED\n", "if VAR_204:\n", "VAR_23 = ALLOWEDTOENROLL_TO_ENROLLED\n", "VAR_23 = UNENROLLED_TO_ENROLLED\n" ]
[ "@ensure_csrf_cookie...\n", "\"\"\"docstring\"\"\"\n", "course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n", "action = request.POST.get('action')\n", "identifiers_raw = request.POST.get('identifiers')\n", "identifiers = _split_input_list(identifiers_raw)\n", "auto_enroll = request.POST.get('auto_enroll') in ['true', 'True', True]\n", "email_students = request.POST.get('email_students') in ['true', 'True', True]\n", "is_white_label = CourseMode.is_white_label(course_id)\n", "reason = request.POST.get('reason')\n", "if is_white_label:\n", "if not reason:\n", "enrollment_obj = None\n", "return JsonResponse({'action': action, 'results': [{'error': True}],\n 'auto_enroll': auto_enroll}, status=400)\n", "state_transition = DEFAULT_TRANSITION_STATE\n", "email_params = {}\n", "if email_students:\n", "course = get_course_by_id(course_id)\n", "results = []\n", "email_params = get_email_params(course, auto_enroll, secure=request.is_secure()\n )\n", "for identifier in identifiers:\n", "user = None\n", "response_payload = {'action': action, 'results': results, 'auto_enroll':\n auto_enroll}\n", "email = None\n", "return JsonResponse(response_payload)\n", "language = None\n", "user = get_student_from_identifier(identifier)\n", "email = identifier\n", "email = user.email\n", "validate_email(email)\n", "results.append({'identifier': identifier, 'invalidIdentifier': True})\n", "ManualEnrollmentAudit.create_manual_enrollment_audit(request.user, email,\n state_transition, reason, enrollment_obj)\n", "language = get_user_email_language(user)\n", "if action == 'enroll':\n", "log.exception(u'Error while #{}ing student')\n", "results.append({'identifier': identifier, 'before': before.to_dict(),\n 'after': after.to_dict()})\n", "before, after, enrollment_obj = enroll_email(course_id, email, auto_enroll,\n email_students, email_params, language=language)\n", "if action == 'unenroll':\n", "log.exception(exc)\n", "before_enrollment = before.to_dict()['enrollment']\n", "before, after = unenroll_email(course_id, email, email_students,\n email_params, language=language)\n", "return HttpResponseBadRequest(strip_tags(\"Unrecognized action '{}'\".format(\n action)))\n", "results.append({'identifier': identifier, 'error': True})\n", "before_user_registered = before.to_dict()['user']\n", "before_enrollment = before.to_dict()['enrollment']\n", "before_allowed = before.to_dict()['allowed']\n", "before_allowed = before.to_dict()['allowed']\n", "after_enrollment = after.to_dict()['enrollment']\n", "enrollment_obj = CourseEnrollment.get_enrollment(user, course_id)\n", "after_allowed = after.to_dict()['allowed']\n", "if before_enrollment:\n", "if before_user_registered:\n", "state_transition = ENROLLED_TO_UNENROLLED\n", "if before_allowed:\n", "if after_enrollment:\n", "if after_allowed:\n", "state_transition = ALLOWEDTOENROLL_TO_UNENROLLED\n", "state_transition = UNENROLLED_TO_UNENROLLED\n", "if before_enrollment:\n", "state_transition = UNENROLLED_TO_ALLOWEDTOENROLL\n", "state_transition = ENROLLED_TO_ENROLLED\n", "if before_allowed:\n", "state_transition = ALLOWEDTOENROLL_TO_ENROLLED\n", "state_transition = UNENROLLED_TO_ENROLLED\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Return'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Return'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_0(VAR_0, VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "VAR_13 = apps.get_model(app_label='acls', model_name='AccessControlList')\n", "VAR_14 = ['<div class=\"tag-container\">']\n", "VAR_15 = VAR_13.objects.filter_by_access(permission_tag_view, VAR_1,\n queryset=document.attached_tags().all())\n", "for VAR_2 in VAR_15:\n", "VAR_14.append(FUNC_1(VAR_2))\n", "VAR_14.append('</div>')\n", "return mark_safe(''.join(VAR_14))\n" ]
[ "def widget_document_tags(document, user):...\n", "\"\"\"docstring\"\"\"\n", "AccessControlList = apps.get_model(app_label='acls', model_name=\n 'AccessControlList')\n", "result = ['<div class=\"tag-container\">']\n", "tags = AccessControlList.objects.filter_by_access(permission_tag_view, user,\n queryset=document.attached_tags().all())\n", "for tag in tags:\n", "result.append(widget_single_tag(tag))\n", "result.append('</div>')\n", "return mark_safe(''.join(result))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "For", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_32(self):...\n", "from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver\n", "from Products.PageTemplates.unicodeconflictresolver import StrictUnicodeEncodingConflictResolver\n", "from zope.component import getUtility\n", "from zope.component import provideUtility\n", "provideUtility(StrictUnicodeEncodingConflictResolver,\n IUnicodeEncodingConflictResolver)\n", "VAR_12 = getUtility(IUnicodeEncodingConflictResolver)\n", "VAR_13 = 'äüä'\n", "self.assertEqual(VAR_12.resolve(None, VAR_13, None), VAR_13)\n" ]
[ "def testStrictResolver(self):...\n", "from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver\n", "from Products.PageTemplates.unicodeconflictresolver import StrictUnicodeEncodingConflictResolver\n", "from zope.component import getUtility\n", "from zope.component import provideUtility\n", "provideUtility(StrictUnicodeEncodingConflictResolver,\n IUnicodeEncodingConflictResolver)\n", "resolver = getUtility(IUnicodeEncodingConflictResolver)\n", "text = 'äüä'\n", "self.assertEqual(resolver.resolve(None, text, None), text)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_38(self):...\n", "if self.flags.ignore_validate_update_after_submit:\n", "return\n", "self._validate_update_after_submit()\n", "for VAR_21 in self.get_all_children():\n", "if VAR_21.is_new() and self.meta.get_field(VAR_21.parentfield).allow_on_submit:\n", "VAR_21._validate_update_after_submit()\n" ]
[ "def validate_update_after_submit(self):...\n", "if self.flags.ignore_validate_update_after_submit:\n", "return\n", "self._validate_update_after_submit()\n", "for d in self.get_all_children():\n", "if d.is_new() and self.meta.get_field(d.parentfield).allow_on_submit:\n", "d._validate_update_after_submit()\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Expr'", "For", "Condition", "Expr'" ]
[ "@FUNC_0...\n", "return Ratelimiter(clock=self.get_clock(), rate_hz=self.config.\n rc_registration.per_second, burst_count=self.config.rc_registration.\n burst_count)\n" ]
[ "@cache_in_self...\n", "return Ratelimiter(clock=self.get_clock(), rate_hz=self.config.\n rc_registration.per_second, burst_count=self.config.rc_registration.\n burst_count)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_10(VAR_16):...\n", "\"\"\"docstring\"\"\"\n", "if re.search('\\\\.\\\\.\\\\{sep}'.format(sep=os.sep), VAR_16):\n", "return False\n", "return True\n" ]
[ "def clean_id(id_):...\n", "\"\"\"docstring\"\"\"\n", "if re.search('\\\\.\\\\.\\\\{sep}'.format(sep=os.sep), id_):\n", "return False\n", "return True\n" ]
[ 0, 0, 1, 1, 1 ]
[ "FunctionDef'", "Docstring", "For", "Return'", "Return'" ]
[ "def FUNC_6(self, VAR_26='XXX ERROR MESSAGE NEEDED'):...\n", "self.errors.append(VAR_26)\n", "if self.strict:\n" ]
[ "def serializeError(self, data='XXX ERROR MESSAGE NEEDED'):...\n", "self.errors.append(data)\n", "if self.strict:\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Condition" ]
[ "@expose('/login/', methods=['GET', 'POST'])...\n", "" ]
[ "@expose('/login/', methods=['GET', 'POST'])...\n", "" ]
[ 0, 0 ]
[ "Condition", "Condition" ]
[ "@VAR_1.route('/<bfile>/holdings/by_<aggregation_key>/')...\n", "\"\"\"docstring\"\"\"\n", "if VAR_18 in ['account', 'currency', 'cost_currency']:\n", "return render_template('_layout.html', active_page='holdings', VAR_18=\n aggregation_key)\n", "return abort(404)\n" ]
[ "@app.route('/<bfile>/holdings/by_<aggregation_key>/')...\n", "\"\"\"docstring\"\"\"\n", "if aggregation_key in ['account', 'currency', 'cost_currency']:\n", "return render_template('_layout.html', active_page='holdings',\n aggregation_key=aggregation_key)\n", "return abort(404)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Return'", "Return'" ]
[ "@VAR_0.route('/query/<int:query_id>')...\n", "VAR_14 = g.conn.session.query(Query).filter(Query.id == VAR_4).one()\n", "VAR_17 = get_user() is not None and get_user().id == VAR_14.user_id\n", "VAR_18 = False\n", "if get_user():\n", "VAR_18 = g.conn.session.query(func.count(Star.id)).filter(Star.user_id ==\n get_user().id).filter(Star.query_id == VAR_4).scalar() == 1\n", "VAR_19 = {'query_id': VAR_14.id, 'can_edit': VAR_17, 'is_starred': VAR_18,\n 'published': VAR_14.published, 'preferences': VAR_31()}\n", "if VAR_14.latest_rev and VAR_14.latest_rev.latest_run_id:\n", "VAR_19['qrun_id'] = VAR_14.latest_rev.latest_run_id\n", "return render_template('query/view.html', user=get_user(), VAR_14=query,\n VAR_19=jsvars, latest_rev=query.latest_rev)\n" ]
[ "@app.route('/query/<int:query_id>')...\n", "query = g.conn.session.query(Query).filter(Query.id == query_id).one()\n", "can_edit = get_user() is not None and get_user().id == query.user_id\n", "is_starred = False\n", "if get_user():\n", "is_starred = g.conn.session.query(func.count(Star.id)).filter(Star.user_id ==\n get_user().id).filter(Star.query_id == query_id).scalar() == 1\n", "jsvars = {'query_id': query.id, 'can_edit': can_edit, 'is_starred':\n is_starred, 'published': query.published, 'preferences': get_preferences()}\n", "if query.latest_rev and query.latest_rev.latest_run_id:\n", "jsvars['qrun_id'] = query.latest_rev.latest_run_id\n", "return render_template('query/view.html', user=get_user(), query=query,\n jsvars=jsvars, latest_rev=query.latest_rev)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Return'" ]
[ "def FUNC_85(VAR_19):...\n", "\"\"\"docstring\"\"\"\n", "return {'username': VAR_19.username, 'email': VAR_19.email, 'first_name':\n VAR_19.first_name, 'last_name': VAR_19.last_name}\n" ]
[ "def extract_user_info(user):...\n", "\"\"\"docstring\"\"\"\n", "return {'username': user.username, 'email': user.email, 'first_name': user.\n first_name, 'last_name': user.last_name}\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_112(self):...\n", "VAR_56 = VAR_263.request\n", "VAR_244 = VAR_263.response\n", "VAR_313 = list(self.xmlrpc_procedures.values())\n", "return VAR_244.xmlrpc(VAR_56, VAR_313)\n" ]
[ "def serve_xmlrpc(self):...\n", "request = current.request\n", "response = current.response\n", "services = list(self.xmlrpc_procedures.values())\n", "return response.xmlrpc(request, services)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_44(self, VAR_25):...\n", "\"\"\"docstring\"\"\"\n", "if frappe.flags.in_import and frappe.flags.mute_emails or frappe.flags.in_patch or frappe.flags.in_install:\n", "return\n", "if self.flags.notifications_executed == None:\n", "self.flags.notifications_executed = []\n", "from frappe.email.doctype.notification.notification import evaluate_alert\n", "if self.flags.notifications == None:\n", "VAR_88 = frappe.cache().hget('notifications', self.doctype)\n", "if not self.flags.notifications:\n", "if VAR_88 == None:\n", "return\n", "def FUNC_82(VAR_67):...\n", "VAR_88 = frappe.get_all('Notification', fields=['name', 'event', 'method'],\n filters={'enabled': 1, 'document_type': self.doctype})\n", "self.flags.notifications = VAR_88\n", "if not VAR_67.name in self.flags.notifications_executed:\n", "frappe.cache().hset('notifications', self.doctype, VAR_88)\n", "evaluate_alert(self, VAR_67.name, VAR_67.event)\n", "VAR_68 = {'on_update': 'Save', 'after_insert': 'New', 'on_submit': 'Submit',\n 'on_cancel': 'Cancel'}\n", "self.flags.notifications_executed.append(VAR_67.name)\n", "if not self.flags.in_insert:\n", "VAR_68['on_change'] = 'Value Change'\n", "for VAR_67 in self.flags.notifications:\n", "VAR_89 = VAR_68.get(VAR_25, None)\n", "if VAR_89 and VAR_67.event == VAR_89:\n", "FUNC_82(VAR_67)\n", "if VAR_67.event == 'Method' and VAR_25 == VAR_67.method:\n", "FUNC_82(VAR_67)\n" ]
[ "def run_notifications(self, method):...\n", "\"\"\"docstring\"\"\"\n", "if frappe.flags.in_import and frappe.flags.mute_emails or frappe.flags.in_patch or frappe.flags.in_install:\n", "return\n", "if self.flags.notifications_executed == None:\n", "self.flags.notifications_executed = []\n", "from frappe.email.doctype.notification.notification import evaluate_alert\n", "if self.flags.notifications == None:\n", "alerts = frappe.cache().hget('notifications', self.doctype)\n", "if not self.flags.notifications:\n", "if alerts == None:\n", "return\n", "def _evaluate_alert(alert):...\n", "alerts = frappe.get_all('Notification', fields=['name', 'event', 'method'],\n filters={'enabled': 1, 'document_type': self.doctype})\n", "self.flags.notifications = alerts\n", "if not alert.name in self.flags.notifications_executed:\n", "frappe.cache().hset('notifications', self.doctype, alerts)\n", "evaluate_alert(self, alert.name, alert.event)\n", "event_map = {'on_update': 'Save', 'after_insert': 'New', 'on_submit':\n 'Submit', 'on_cancel': 'Cancel'}\n", "self.flags.notifications_executed.append(alert.name)\n", "if not self.flags.in_insert:\n", "event_map['on_change'] = 'Value Change'\n", "for alert in self.flags.notifications:\n", "event = event_map.get(method, None)\n", "if event and alert.event == event:\n", "_evaluate_alert(alert)\n", "if alert.event == 'Method' and method == alert.method:\n", "_evaluate_alert(alert)\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 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "Assign'", "ImportFrom'", "Condition", "Assign'", "Condition", "Condition", "Return'", "FunctionDef'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Assign'", "Expr'", "Condition", "Assign'", "For", "Assign'", "Condition", "Expr'", "Condition", "Expr'" ]
[ "def FUNC_3(VAR_3):...\n", "if VAR_25.session['user'] == 'Guest':\n", "if VAR_3 not in VAR_25.guest_methods:\n", "if not VAR_3 in VAR_25.whitelisted:\n", "VAR_25.throw(_('Not permitted'), VAR_25.PermissionError)\n", "if VAR_3 not in VAR_25.xss_safe_methods:\n", "VAR_25.throw(_('Not permitted'), VAR_25.PermissionError)\n", "for VAR_29, value in VAR_25.form_dict.items():\n", "if isinstance(value, string_types):\n", "VAR_25.form_dict[VAR_29] = VAR_25.utils.sanitize_html(value)\n" ]
[ "def is_whitelisted(method):...\n", "if frappe.session['user'] == 'Guest':\n", "if method not in frappe.guest_methods:\n", "if not method in frappe.whitelisted:\n", "frappe.throw(_('Not permitted'), frappe.PermissionError)\n", "if method not in frappe.xss_safe_methods:\n", "frappe.throw(_('Not permitted'), frappe.PermissionError)\n", "for key, value in frappe.form_dict.items():\n", "if isinstance(value, string_types):\n", "frappe.form_dict[key] = frappe.utils.sanitize_html(value)\n" ]
[ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]
[ "FunctionDef'", "Condition", "Condition", "Condition", "Expr'", "Condition", "Expr'", "For", "Condition", "Assign'" ]
[ "@property...\n", "VAR_26 = ['core.js', 'SelectBox.js', 'SelectFilter2.js']\n", "return forms.Media(VAR_26=[static('admin/js/%s' % path) for path in js])\n" ]
[ "@property...\n", "js = ['core.js', 'SelectBox.js', 'SelectFilter2.js']\n", "return forms.Media(js=[static('admin/js/%s' % path) for path in js])\n" ]
[ 0, 0, 0 ]
[ "Condition", "Assign'", "Return'" ]
[ "import json\n", "from django.http.response import HttpResponse, HttpResponseRedirect\n", "from django.middleware.csrf import get_token\n", "from django.utils.http import urlencode\n", "from django.utils.translation import ugettext_lazy as _\n", "from django.views.generic import TemplateView\n", "from shuup.utils.excs import Problem\n", "from shuup.xtheme import XTHEME_GLOBAL_VIEW_NAME\n", "from shuup.xtheme._theme import get_theme_by_identifier\n", "from shuup.xtheme.editing import could_edit\n", "from shuup.xtheme.layout import Layout\n", "from shuup.xtheme.layout.utils import get_provided_layouts\n", "from shuup.xtheme.view_config import ViewConfig\n", "from shuup.xtheme.views.forms import LayoutCellFormGroup\n", "VAR_0 = 4\n", "VAR_1 = 'shuup/xtheme/editor.jinja'\n", "VAR_2 = False\n", "VAR_3 = False\n", "def FUNC_0(self):...\n", "return json.loads(self.request.GET['default_config'])\n", "return None\n", "def FUNC_1(self, **VAR_4):...\n", "VAR_15 = super(CLASS_0, self).get_context_data(**kwargs)\n", "VAR_15['layout'] = self.layout\n", "VAR_15['csrf_token_str'] = get_token(self.request)\n", "VAR_15['current_cell_coords'] = self.current_cell_coords\n", "VAR_15['current_cell'] = self.current_cell\n", "VAR_15['form'] = self.form\n", "VAR_15['changed'] = self.changed\n", "VAR_15['cell_limit'] = VAR_0\n", "return VAR_15\n" ]
[ "import json\n", "from django.http.response import HttpResponse, HttpResponseRedirect\n", "from django.middleware.csrf import get_token\n", "from django.utils.http import urlencode\n", "from django.utils.translation import ugettext_lazy as _\n", "from django.views.generic import TemplateView\n", "from shuup.utils.excs import Problem\n", "from shuup.xtheme import XTHEME_GLOBAL_VIEW_NAME\n", "from shuup.xtheme._theme import get_theme_by_identifier\n", "from shuup.xtheme.editing import could_edit\n", "from shuup.xtheme.layout import Layout\n", "from shuup.xtheme.layout.utils import get_provided_layouts\n", "from shuup.xtheme.view_config import ViewConfig\n", "from shuup.xtheme.views.forms import LayoutCellFormGroup\n", "ROW_CELL_LIMIT = 4\n", "template_name = 'shuup/xtheme/editor.jinja'\n", "xtheme_injection = False\n", "changed = False\n", "def _get_default_layout(self):...\n", "return json.loads(self.request.GET['default_config'])\n", "return None\n", "def get_context_data(self, **kwargs):...\n", "ctx = super(EditorView, self).get_context_data(**kwargs)\n", "ctx['layout'] = self.layout\n", "ctx['csrf_token_str'] = get_token(self.request)\n", "ctx['current_cell_coords'] = self.current_cell_coords\n", "ctx['current_cell'] = self.current_cell\n", "ctx['form'] = self.form\n", "ctx['changed'] = self.changed\n", "ctx['cell_limit'] = ROW_CELL_LIMIT\n", "return ctx\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 ]
[ "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Return'", "Return'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_83(self, VAR_71):...\n", "if isinstance(VAR_71, dict):\n", "if not self.get('_return_value'):\n", "self._return_value = VAR_71 or self.get('_return_value')\n", "self._return_value = {}\n", "self._return_value.update(VAR_71)\n", "def FUNC_84(VAR_72, *VAR_73):...\n", "def FUNC_86(self, VAR_25, *VAR_0, **VAR_1):...\n", "FUNC_83(self, VAR_72(self, *VAR_0, **kwargs))\n", "for VAR_6 in VAR_73:\n", "FUNC_83(self, VAR_6(self, VAR_25, *VAR_0, **kwargs))\n", "return self._return_value\n" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "def add_to_return_value(self, new_return_value):...\n", "if isinstance(new_return_value, dict):\n", "if not self.get('_return_value'):\n", "self._return_value = new_return_value or self.get('_return_value')\n", "self._return_value = {}\n", "self._return_value.update(new_return_value)\n", "def compose(fn, *hooks):...\n", "def runner(self, method, *args, **kwargs):...\n", "add_to_return_value(self, fn(self, *args, **kwargs))\n", "for f in hooks:\n", "add_to_return_value(self, f(self, method, *args, **kwargs))\n", "return self._return_value\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "FunctionDef'", "Condition", "Condition", "Assign'", "Assign'", "Expr'", "FunctionDef'", "FunctionDef'", "Expr'", "For", "Expr'", "Return'" ]
[ "import time\n", "from mock import Mock\n", "import canonicaljson\n", "import signedjson.key\n", "import signedjson.sign\n", "from nacl.signing import SigningKey\n", "from signedjson.key import encode_verify_key_base64, get_verify_key\n", "from twisted.internet import defer\n", "from twisted.internet.defer import Deferred, ensureDeferred\n", "from synapse.api.errors import SynapseError\n", "from synapse.crypto import keyring\n", "from synapse.crypto.keyring import PerspectivesKeyFetcher, ServerKeyFetcher, StoreKeyFetcher\n", "from synapse.logging.context import LoggingContext, current_context, make_deferred_yieldable\n", "from synapse.storage.keys import FetchKeyResult\n", "from tests import unittest\n", "from tests.test_utils import make_awaitable\n", "from tests.unittest import logcontext_clean\n", "def __init__(self):...\n", "self.server_name = 'mock_server'\n", "self.key = signedjson.key.generate_signing_key(0)\n", "def FUNC_3(self):...\n", "VAR_17 = signedjson.key.get_verify_key(self.key)\n", "return {('%s:%s' % (VAR_17.alg, VAR_17.version)): encode_verify_key_base64(\n VAR_17)}\n" ]
[ "import time\n", "from mock import Mock\n", "import canonicaljson\n", "import signedjson.key\n", "import signedjson.sign\n", "from nacl.signing import SigningKey\n", "from signedjson.key import encode_verify_key_base64, get_verify_key\n", "from twisted.internet import defer\n", "from twisted.internet.defer import Deferred, ensureDeferred\n", "from synapse.api.errors import SynapseError\n", "from synapse.crypto import keyring\n", "from synapse.crypto.keyring import PerspectivesKeyFetcher, ServerKeyFetcher, StoreKeyFetcher\n", "from synapse.logging.context import LoggingContext, current_context, make_deferred_yieldable\n", "from synapse.storage.keys import FetchKeyResult\n", "from tests import unittest\n", "from tests.test_utils import make_awaitable\n", "from tests.unittest import logcontext_clean\n", "def __init__(self):...\n", "self.server_name = 'mock_server'\n", "self.key = signedjson.key.generate_signing_key(0)\n", "def get_verify_keys(self):...\n", "vk = signedjson.key.get_verify_key(self.key)\n", "return {('%s:%s' % (vk.alg, vk.version)): encode_verify_key_base64(vk)}\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "ImportFrom'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3):...\n", "VAR_4 = VAR_0.rsplit(VAR_1, VAR_3)\n", "return VAR_2.join(VAR_4)\n" ]
[ "def rreplace(s, old, new, occurrence):...\n", "li = s.rsplit(old, occurrence)\n", "return new.join(li)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "@abstractmethod...\n", "\"\"\"docstring\"\"\"\n" ]
[ "@abstractmethod...\n", "\"\"\"docstring\"\"\"\n" ]
[ 0, 0 ]
[ "Condition", "Docstring" ]
[ "@VAR_6.route('/meta/<path:object_path>')...\n", "VAR_13 = FUNC_6(VAR_9)\n", "VAR_14 = dict()\n", "for VAR_18, value in attributes:\n", "return jsonify(VAR_14)\n", "VAR_14[VAR_18] = value\n" ]
[ "@scope_blueprint.route('/meta/<path:object_path>')...\n", "path = _get_obj_absolute_path(object_path)\n", "attrs = dict()\n", "for key, value in attributes:\n", "return jsonify(attrs)\n", "attrs[key] = value\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "For", "Return'", "Assign'" ]
[ "def FUNC_52(VAR_62, VAR_109=False, VAR_115=False):...\n", "\"\"\"docstring\"\"\"\n", "FUNC_53(FUNC_56(VAR_12.get_value('DocType', VAR_62, 'module')), 'doctype',\n FUNC_56(VAR_62), VAR_109=force, VAR_115=reset_permissions)\n" ]
[ "def reload_doctype(doctype, force=False, reset_permissions=False):...\n", "\"\"\"docstring\"\"\"\n", "reload_doc(scrub(db.get_value('DocType', doctype, 'module')), 'doctype',\n scrub(doctype), force=force, reset_permissions=reset_permissions)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'" ]
[ "def FUNC_29(self):...\n", "self.parser = saved_model_cli.create_parser()\n", "VAR_9 = test.test_src_dir_path(VAR_0)\n", "VAR_41 = os.path.join(test.get_temp_dir(), 'new_dir')\n", "VAR_10 = self.parser.parse_args(['run', '--dir', VAR_9, '--tag_set',\n 'serve', '--signature_def', 'regress_x_to_y', '--input_examples',\n 'inputs=[{\"x\":8.0,\"x2\":5.0}]', '--outdir', VAR_41])\n", "saved_model_cli.run(VAR_10)\n" ]
[ "def testRunCommandInputExamplesFeatureValueNotListError(self):...\n", "self.parser = saved_model_cli.create_parser()\n", "base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n", "output_dir = os.path.join(test.get_temp_dir(), 'new_dir')\n", "args = self.parser.parse_args(['run', '--dir', base_path, '--tag_set',\n 'serve', '--signature_def', 'regress_x_to_y', '--input_examples',\n 'inputs=[{\"x\":8.0,\"x2\":5.0}]', '--outdir', output_dir])\n", "saved_model_cli.run(args)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_9(VAR_6, VAR_7):...\n", "VAR_25 = Deferred()\n", "self.push_attempts.append((VAR_25, VAR_6, VAR_7))\n", "return make_deferred_yieldable(VAR_25)\n" ]
[ "def post_json_get_json(url, body):...\n", "d = Deferred()\n", "self.push_attempts.append((d, url, body))\n", "return make_deferred_yieldable(d)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Return'" ]
[ "def __init__(self, VAR_12=True, **VAR_7):...\n", "VAR_21 = {'type': 'date'}\n", "if VAR_12:\n", "VAR_21['data-provide'] = 'datepicker'\n", "super().__init__(VAR_21=attrs, VAR_36='%Y-%m-%d', **kwargs)\n", "VAR_21['data-date-format'] = 'yyyy-mm-dd'\n" ]
[ "def __init__(self, datepicker=True, **kwargs):...\n", "attrs = {'type': 'date'}\n", "if datepicker:\n", "attrs['data-provide'] = 'datepicker'\n", "super().__init__(attrs=attrs, format='%Y-%m-%d', **kwargs)\n", "attrs['data-date-format'] = 'yyyy-mm-dd'\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_72(self):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_263.request.ajax:\n", "return self.messages.access_denied\n" ]
[ "def not_authorized(self):...\n", "\"\"\"docstring\"\"\"\n", "if current.request.ajax:\n", "return self.messages.access_denied\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'" ]
[ "def FUNC_9(VAR_14, VAR_11, VAR_15=False):...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_54.path.isabs(VAR_14):\n", "return ''\n", "if not VAR_54.path.isabs(VAR_11):\n", "VAR_11 = VAR_54.path.join(VAR_14, VAR_11)\n", "VAR_11 = VAR_54.path.normpath(VAR_11)\n", "if VAR_15:\n", "if VAR_11.startswith(VAR_14):\n", "if VAR_54.path.dirname(VAR_11) == VAR_54.path.normpath(VAR_14):\n", "return VAR_11\n", "return ''\n", "return VAR_11\n" ]
[ "def clean_path(root, path, subdir=False):...\n", "\"\"\"docstring\"\"\"\n", "if not os.path.isabs(root):\n", "return ''\n", "if not os.path.isabs(path):\n", "path = os.path.join(root, path)\n", "path = os.path.normpath(path)\n", "if subdir:\n", "if path.startswith(root):\n", "if os.path.dirname(path) == os.path.normpath(root):\n", "return path\n", "return ''\n", "return path\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Return'", "Return'", "Return'" ]
[ "@defer.inlineCallbacks...\n", "self.mock_federation_resource = MockHttpResource()\n", "self.mock_http_client = Mock(spec=[])\n", "self.mock_http_client.put_json = DeferredMockCallable()\n", "VAR_2 = yield setup_test_homeserver(self.addCleanup, http_client=self.\n mock_http_client, keyring=Mock())\n", "self.filtering = VAR_2.get_filtering()\n", "self.datastore = VAR_2.get_datastore()\n" ]
[ "@defer.inlineCallbacks...\n", "self.mock_federation_resource = MockHttpResource()\n", "self.mock_http_client = Mock(spec=[])\n", "self.mock_http_client.put_json = DeferredMockCallable()\n", "hs = yield setup_test_homeserver(self.addCleanup, http_client=self.\n mock_http_client, keyring=Mock())\n", "self.filtering = hs.get_filtering()\n", "self.datastore = hs.get_datastore()\n" ]
[ 0, 0, 0, 0, 4, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_56(VAR_35, VAR_36, VAR_37, VAR_38, VAR_39, VAR_40, VAR_41, VAR_24,...\n", "VAR_35.extend((VAR_36.replace('|', ','), VAR_37, VAR_38))\n", "if VAR_39:\n", "if VAR_40:\n", "VAR_35.extend([_(u'Published after ') + format_date(datetime.strptime(\n VAR_39, '%Y-%m-%d'), format='medium', locale=get_locale())])\n", "VAR_39 = u''\n", "VAR_92 = {'tag': db.Tags, 'serie': db.Series, 'shelf': ub.Shelf}\n", "VAR_35.extend([_(u'Published before ') + format_date(datetime.strptime(\n VAR_40, '%Y-%m-%d'), format='medium', locale=get_locale())])\n", "VAR_39 = u''\n", "for key, db_element in VAR_92.items():\n", "VAR_112 = calibre_db.session.query(db_element).filter(db_element.id.in_(\n VAR_41['include_' + key])).all()\n", "VAR_57 = calibre_db.session.query(db.Languages).filter(db.Languages.id.in_(\n VAR_41['include_language'])).all()\n", "VAR_35.extend(tag.name for tag in VAR_112)\n", "if VAR_57:\n", "VAR_112 = calibre_db.session.query(db_element).filter(db_element.id.in_(\n VAR_41['exclude_' + key])).all()\n", "VAR_57 = calibre_db.speaking_language(VAR_57)\n", "VAR_35.extend(language.name for language in VAR_57)\n", "VAR_35.extend(tag.name for tag in VAR_112)\n", "VAR_57 = calibre_db.session.query(db.Languages).filter(db.Languages.id.in_(\n VAR_41['exclude_language'])).all()\n", "if VAR_57:\n", "VAR_57 = calibre_db.speaking_language(VAR_57)\n", "VAR_35.extend(language.name for language in VAR_57)\n", "if VAR_24:\n", "VAR_35.extend([_(u'Rating <= %(rating)s', rating=rating_high)])\n", "if VAR_25:\n", "VAR_35.extend([_(u'Rating >= %(rating)s', rating=rating_low)])\n", "if VAR_26:\n", "VAR_35.extend([_(u'Read Status = %(status)s', status=read_status)])\n", "VAR_35.extend(ext for ext in VAR_41['include_extension'])\n", "VAR_35.extend(ext for ext in VAR_41['exclude_extension'])\n", "VAR_35 = ' + '.join(filter(None, VAR_35))\n", "return VAR_35, VAR_39, VAR_40\n" ]
[ "def extend_search_term(searchterm, author_name, book_title, publisher,...\n", "searchterm.extend((author_name.replace('|', ','), book_title, publisher))\n", "if pub_start:\n", "if pub_end:\n", "searchterm.extend([_(u'Published after ') + format_date(datetime.strptime(\n pub_start, '%Y-%m-%d'), format='medium', locale=get_locale())])\n", "pub_start = u''\n", "elements = {'tag': db.Tags, 'serie': db.Series, 'shelf': ub.Shelf}\n", "searchterm.extend([_(u'Published before ') + format_date(datetime.strptime(\n pub_end, '%Y-%m-%d'), format='medium', locale=get_locale())])\n", "pub_start = u''\n", "for key, db_element in elements.items():\n", "tag_names = calibre_db.session.query(db_element).filter(db_element.id.in_(\n tags['include_' + key])).all()\n", "language_names = calibre_db.session.query(db.Languages).filter(db.Languages\n .id.in_(tags['include_language'])).all()\n", "searchterm.extend(tag.name for tag in tag_names)\n", "if language_names:\n", "tag_names = calibre_db.session.query(db_element).filter(db_element.id.in_(\n tags['exclude_' + key])).all()\n", "language_names = calibre_db.speaking_language(language_names)\n", "searchterm.extend(language.name for language in language_names)\n", "searchterm.extend(tag.name for tag in tag_names)\n", "language_names = calibre_db.session.query(db.Languages).filter(db.Languages\n .id.in_(tags['exclude_language'])).all()\n", "if language_names:\n", "language_names = calibre_db.speaking_language(language_names)\n", "searchterm.extend(language.name for language in language_names)\n", "if rating_high:\n", "searchterm.extend([_(u'Rating <= %(rating)s', rating=rating_high)])\n", "if rating_low:\n", "searchterm.extend([_(u'Rating >= %(rating)s', rating=rating_low)])\n", "if read_status:\n", "searchterm.extend([_(u'Read Status = %(status)s', status=read_status)])\n", "searchterm.extend(ext for ext in tags['include_extension'])\n", "searchterm.extend(ext for ext in tags['exclude_extension'])\n", "searchterm = ' + '.join(filter(None, searchterm))\n", "return searchterm, pub_start, pub_end\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "For", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_113(self):...\n", "return CLASS_0(dict(self).copy())\n" ]
[ "def copy(self):...\n", "return _dict(dict(self).copy())\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_1(self, VAR_0, VAR_1, VAR_2):...\n", "self.store = VAR_2.get_datastore()\n", "self.storage = VAR_2.get_storage()\n", "self.event_builder_factory = VAR_2.get_event_builder_factory()\n", "self.event_creation_handler = VAR_2.get_event_creation_handler()\n", "self.u_alice = UserID.from_string('@alice:test')\n", "self.u_bob = UserID.from_string('@bob:test')\n", "self.room1 = RoomID.from_string('!abc123:test')\n", "self.get_success(create_room(VAR_2, self.room1.to_string(), self.u_alice.\n to_string()))\n", "self.depth = 1\n" ]
[ "def prepare(self, reactor, clock, hs):...\n", "self.store = hs.get_datastore()\n", "self.storage = hs.get_storage()\n", "self.event_builder_factory = hs.get_event_builder_factory()\n", "self.event_creation_handler = hs.get_event_creation_handler()\n", "self.u_alice = UserID.from_string('@alice:test')\n", "self.u_bob = UserID.from_string('@bob:test')\n", "self.room1 = RoomID.from_string('!abc123:test')\n", "self.get_success(create_room(hs, self.room1.to_string(), self.u_alice.\n to_string()))\n", "self.depth = 1\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_2(self):...\n", "VAR_4 = generate_credits(None, timezone.now() - timedelta(days=1), timezone\n .now() + timedelta(days=1), translation__component=self.component)\n", "self.assertEqual(VAR_4, [])\n" ]
[ "def test_credits_empty(self):...\n", "data = generate_credits(None, timezone.now() - timedelta(days=1), timezone.\n now() + timedelta(days=1), translation__component=self.component)\n", "self.assertEqual(data, [])\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_107(VAR_169, VAR_7='utf-8'):...\n", "" ]
[ "def safe_encode(param, encoding='utf-8'):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_154(*VAR_9, **VAR_13):...\n", "VAR_13['_rel'] = 'nofollow'\n", "return A(*VAR_9, **b)\n" ]
[ "def Anr(*a, **b):...\n", "b['_rel'] = 'nofollow'\n", "return A(*a, **b)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_36(self, VAR_1=None, VAR_2=None):...\n", "if VAR_1 is None:\n", "VAR_1 = self._makeEngine()\n", "if VAR_2 is None:\n", "VAR_2 = {}\n", "return self._getTargetClass()(VAR_1, VAR_2)\n" ]
[ "def _makeOne(self, engine=None, contexts=None):...\n", "if engine is None:\n", "engine = self._makeEngine()\n", "if contexts is None:\n", "contexts = {}\n", "return self._getTargetClass()(engine, contexts)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Condition", "Assign'", "Return'" ]
[ "\"\"\"Contains handlers for federation events.\"\"\"\n", "import itertools\n", "import logging\n", "from collections.abc import Container\n", "from http import HTTPStatus\n", "from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Sequence, Tuple, Union\n", "import attr\n", "from signedjson.key import decode_verify_key_bytes\n", "from signedjson.sign import verify_signed_json\n", "from unpaddedbase64 import decode_base64\n", "from twisted.internet import defer\n", "from synapse import event_auth\n", "from synapse.api.constants import EventTypes, Membership, RejectedReason, RoomEncryptionAlgorithms\n", "from synapse.api.errors import AuthError, CodeMessageException, Codes, FederationDeniedError, FederationError, HttpResponseException, NotFoundError, RequestSendFailed, SynapseError\n", "from synapse.api.room_versions import KNOWN_ROOM_VERSIONS, RoomVersion, RoomVersions\n", "from synapse.crypto.event_signing import compute_event_signature\n", "from synapse.event_auth import auth_types_for_event\n", "from synapse.events import EventBase\n", "from synapse.events.snapshot import EventContext\n", "from synapse.events.validator import EventValidator\n", "from synapse.handlers._base import BaseHandler\n", "from synapse.http.servlet import assert_params_in_dict\n", "from synapse.logging.context import make_deferred_yieldable, nested_logging_context, preserve_fn, run_in_background\n", "from synapse.logging.utils import log_function\n", "from synapse.metrics.background_process_metrics import run_as_background_process\n", "from synapse.replication.http.devices import ReplicationUserDevicesResyncRestServlet\n", "from synapse.replication.http.federation import ReplicationCleanRoomRestServlet, ReplicationFederationSendEventsRestServlet, ReplicationStoreRoomOnOutlierMembershipRestServlet\n", "from synapse.state import StateResolutionStore\n", "from synapse.storage.databases.main.events_worker import EventRedactBehaviour\n", "from synapse.types import JsonDict, MutableStateMap, PersistedEventPosition, RoomStreamToken, StateMap, UserID, get_domain_from_id\n", "from synapse.util.async_helpers import Linearizer, concurrently_execute\n", "from synapse.util.retryutils import NotRetryingDestination\n", "from synapse.util.stringutils import shortstr\n", "from synapse.visibility import filter_events_for_server\n", "if TYPE_CHECKING:\n", "from synapse.server import HomeServer\n", "VAR_0 = logging.getLogger(__name__)\n", "\"\"\"string\"\"\"\n", "VAR_1 = attr.ib(type=EventBase)\n", "VAR_2 = attr.ib(type=Optional[Sequence[EventBase]], default=None)\n", "VAR_3 = attr.ib(type=Optional[MutableStateMap[EventBase]], default=None)\n", "\"\"\"string\"\"\"\n", "def __init__(self, VAR_4: 'HomeServer'):...\n", "super().__init__(VAR_4)\n", "self.hs = VAR_4\n", "self.store = VAR_4.get_datastore()\n", "self.storage = VAR_4.get_storage()\n", "self.state_store = self.storage.state\n", "self.federation_client = VAR_4.get_federation_client()\n", "self.state_handler = VAR_4.get_state_handler()\n", "self._state_resolution_handler = VAR_4.get_state_resolution_handler()\n", "self.server_name = VAR_4.hostname\n", "self.keyring = VAR_4.get_keyring()\n", "self.action_generator = VAR_4.get_action_generator()\n", "self.is_mine_id = VAR_4.is_mine_id\n", "self.spam_checker = VAR_4.get_spam_checker()\n", "self.event_creation_handler = VAR_4.get_event_creation_handler()\n", "self._message_handler = VAR_4.get_message_handler()\n", "self._server_notices_mxid = VAR_4.config.server_notices_mxid\n", "self.config = VAR_4.config\n", "self.http_client = VAR_4.get_simple_http_client()\n", "self._instance_name = VAR_4.get_instance_name()\n", "self._replication = VAR_4.get_replication_data_handler()\n", "self._send_events = ReplicationFederationSendEventsRestServlet.make_client(\n VAR_4)\n", "self._clean_room_for_join_client = ReplicationCleanRoomRestServlet.make_client(\n VAR_4)\n", "if VAR_4.config.worker_app:\n", "self._user_device_resync = ReplicationUserDevicesResyncRestServlet.make_client(\n VAR_4)\n", "self._device_list_updater = VAR_4.get_device_handler().device_list_updater\n", "self._maybe_store_room_on_outlier_membership = (\n ReplicationStoreRoomOnOutlierMembershipRestServlet.make_client(VAR_4))\n", "self._maybe_store_room_on_outlier_membership = (self.store.\n maybe_store_room_on_outlier_membership)\n", "self.room_queues = {}\n", "self._room_pdu_linearizer = Linearizer('fed_room_pdu')\n", "self.third_party_event_rules = VAR_4.get_third_party_event_rules()\n", "self._ephemeral_messages_enabled = VAR_4.config.enable_ephemeral_messages\n", "async def FUNC_0(self, VAR_5, VAR_6, VAR_7=False) ->None:...\n", "\"\"\"docstring\"\"\"\n", "VAR_11 = VAR_6.room_id\n", "VAR_12 = VAR_6.event_id\n", "VAR_0.info('handling received PDU: %s', VAR_6)\n", "VAR_51 = await self.store.get_event(VAR_12, allow_none=True, allow_rejected\n =True)\n", "VAR_52 = VAR_51 and (not VAR_51.internal_metadata.is_outlier() or VAR_6.\n internal_metadata.is_outlier())\n", "if VAR_52:\n", "VAR_0.debug('[%s %s]: Already seen pdu', VAR_11, VAR_12)\n", "self._sanity_check_event(VAR_6)\n", "VAR_0.warning('[%s %s] Received event failed sanity checks', VAR_11, VAR_12)\n", "if VAR_11 in self.room_queues:\n", "return\n", "VAR_0.info('[%s %s] Queuing PDU from %s for now: join in progress', VAR_11,\n VAR_12, VAR_5)\n", "VAR_53 = await self.auth.check_host_in_room(VAR_11, self.server_name)\n", "self.room_queues[VAR_11].append((VAR_6, VAR_5))\n", "if not VAR_53:\n", "return\n", "VAR_0.info(\"[%s %s] Ignoring PDU from %s as we're not in the room\", VAR_11,\n VAR_12, VAR_5)\n", "VAR_2 = None\n", "return None\n", "if not VAR_6.internal_metadata.is_outlier():\n", "VAR_9 = await self.get_min_depth_for_context(VAR_6.room_id)\n", "await self._process_received_pdu(VAR_5, VAR_6, VAR_2=state)\n", "VAR_0.debug('[%s %s] min_depth: %d', VAR_11, VAR_12, VAR_9)\n", "async def FUNC_1(self, VAR_5, VAR_6, VAR_8, VAR_9):...\n", "VAR_8 = set(VAR_6.prev_event_ids())\n", "\"\"\"docstring\"\"\"\n", "VAR_54 = await self.store.have_events_in_timeline(VAR_8)\n", "VAR_11 = VAR_6.room_id\n", "if VAR_9 is not None and VAR_6.depth < VAR_9:\n", "VAR_12 = VAR_6.event_id\n", "VAR_6.internal_metadata.outlier = True\n", "if VAR_9 is not None and VAR_6.depth > VAR_9:\n", "VAR_54 = await self.store.have_events_in_timeline(VAR_8)\n", "if VAR_8 - VAR_54:\n", "VAR_191 = VAR_8 - VAR_54\n", "if not VAR_8 - VAR_54:\n", "if VAR_7:\n", "if VAR_7 and VAR_191:\n", "return\n", "VAR_55 = await self.store.get_latest_event_ids_in_room(VAR_11)\n", "VAR_0.warning('[%s %s] Rejecting: failed to fetch %d prev events: %s',\n VAR_11, VAR_12, len(VAR_8 - VAR_54), shortstr(VAR_8 - VAR_54))\n", "VAR_0.info(\n 'Event %s is missing prev_events: calculating state for a backwards extremity'\n , VAR_12)\n", "VAR_0.info('[%s %s] Acquiring room lock to fetch %d missing prev_events: %s',\n VAR_11, VAR_12, len(VAR_191), shortstr(VAR_191))\n", "VAR_56 = set(VAR_55)\n", "VAR_60 = {VAR_12: VAR_6}\n", "VAR_0.info('[%s %s] Acquired room lock to fetch %d missing prev_events',\n VAR_11, VAR_12, len(VAR_191))\n", "VAR_56 |= VAR_54\n", "VAR_192 = await self.state_store.get_state_groups_ids(VAR_11, VAR_54)\n", "VAR_0.warning(\n '[%s %s] Error attempting to resolve state at missing prev_events',\n VAR_11, VAR_12, exc_info=True)\n", "await self._get_missing_events_for_pdu(VAR_5, VAR_6, VAR_8, VAR_9)\n", "VAR_54 = await self.store.have_events_in_timeline(VAR_8)\n", "VAR_0.info('[%s %s]: Requesting missing events between %s and %s', VAR_11,\n VAR_12, shortstr(VAR_56), VAR_12)\n", "VAR_193 = list(VAR_192.values())\n", "if not VAR_8 - VAR_54:\n", "VAR_65 = await self.federation_client.get_missing_events(VAR_5, VAR_11,\n earliest_events_ids=list(latest), VAR_39=[pdu], VAR_17=10, VAR_9=\n min_depth, timeout=60000)\n", "VAR_0.warning('[%s %s]: Failed to get prev_events: %s', VAR_11, VAR_12, VAR_170\n )\n", "VAR_0.info('[%s %s]: Got %d prev_events: %s', VAR_11, VAR_12, len(VAR_65),\n shortstr(VAR_65))\n", "for p in (VAR_8 - VAR_54):\n", "VAR_0.info('[%s %s] Found all missing prev_events', VAR_11, VAR_12)\n", "return\n", "VAR_65.sort(VAR_144=lambda x: x.depth)\n", "VAR_0.info('Requesting state at missing prev_event %s', VAR_12)\n", "VAR_28 = await self.store.get_room_version_id(VAR_11)\n", "for VAR_21 in VAR_65:\n", "VAR_62, VAR_166 = await self._get_state_for_room(VAR_5, VAR_11, p, VAR_13=True)\n", "VAR_87 = await self._state_resolution_handler.resolve_events_with_store(VAR_11,\n VAR_28, VAR_193, VAR_60, state_res_store=StateResolutionStore(self.store))\n", "VAR_0.info('[%s %s] Handling received prev_event %s', VAR_11, VAR_12,\n VAR_21.event_id)\n", "async def FUNC_2(self, VAR_10: str, VAR_11: str, VAR_12: str, VAR_13: bool=...\n", "VAR_202 = {(VAR_204.type, VAR_204.state_key): VAR_204.event_id for VAR_204 in\n VAR_62}\n", "VAR_194 = await self.store.get_events(list(VAR_87.values()),\n get_prev_content=False, redact_behaviour=EventRedactBehaviour.AS_IS)\n", "await self.on_receive_pdu(VAR_5, VAR_21, VAR_7=False)\n", "if VAR_170.code == 403:\n", "\"\"\"docstring\"\"\"\n", "VAR_193.append(VAR_202)\n", "VAR_60.update(VAR_194)\n", "VAR_0.warning('[%s %s] Received prev_event %s failed history check.',\n VAR_11, VAR_12, VAR_21.event_id)\n", "VAR_57, VAR_58 = await self.federation_client.get_room_state_ids(VAR_10,\n VAR_11, VAR_12=event_id)\n", "for VAR_204 in VAR_62:\n", "VAR_2 = [VAR_60[VAR_170] for VAR_170 in VAR_87.values()]\n", "VAR_59 = set(VAR_57 + VAR_58)\n", "VAR_60[VAR_204.event_id] = VAR_204\n", "if VAR_13:\n", "VAR_59.add(VAR_12)\n", "VAR_60 = await self._get_events_from_store_or_dest(VAR_10, VAR_11, VAR_59)\n", "VAR_61 = VAR_59 - VAR_60.keys()\n", "if VAR_61:\n", "VAR_0.warning('Failed to fetch missing state/auth events for %s %s', VAR_12,\n VAR_61)\n", "VAR_62 = [VAR_60[VAR_160] for VAR_160 in VAR_57 if VAR_160 in VAR_60]\n", "if VAR_13:\n", "VAR_154 = VAR_60.get(VAR_12)\n", "VAR_63 = [VAR_60[VAR_160] for VAR_160 in VAR_58 if VAR_160 in VAR_60]\n", "if not VAR_154:\n", "VAR_63.sort(VAR_144=lambda e: e.depth)\n", "if VAR_154.is_state() and VAR_154.rejected_reason is None:\n", "return VAR_62, VAR_63\n", "VAR_62.append(VAR_154)\n" ]
[ "\"\"\"Contains handlers for federation events.\"\"\"\n", "import itertools\n", "import logging\n", "from collections.abc import Container\n", "from http import HTTPStatus\n", "from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Sequence, Tuple, Union\n", "import attr\n", "from signedjson.key import decode_verify_key_bytes\n", "from signedjson.sign import verify_signed_json\n", "from unpaddedbase64 import decode_base64\n", "from twisted.internet import defer\n", "from synapse import event_auth\n", "from synapse.api.constants import EventTypes, Membership, RejectedReason, RoomEncryptionAlgorithms\n", "from synapse.api.errors import AuthError, CodeMessageException, Codes, FederationDeniedError, FederationError, HttpResponseException, NotFoundError, RequestSendFailed, SynapseError\n", "from synapse.api.room_versions import KNOWN_ROOM_VERSIONS, RoomVersion, RoomVersions\n", "from synapse.crypto.event_signing import compute_event_signature\n", "from synapse.event_auth import auth_types_for_event\n", "from synapse.events import EventBase\n", "from synapse.events.snapshot import EventContext\n", "from synapse.events.validator import EventValidator\n", "from synapse.handlers._base import BaseHandler\n", "from synapse.http.servlet import assert_params_in_dict\n", "from synapse.logging.context import make_deferred_yieldable, nested_logging_context, preserve_fn, run_in_background\n", "from synapse.logging.utils import log_function\n", "from synapse.metrics.background_process_metrics import run_as_background_process\n", "from synapse.replication.http.devices import ReplicationUserDevicesResyncRestServlet\n", "from synapse.replication.http.federation import ReplicationCleanRoomRestServlet, ReplicationFederationSendEventsRestServlet, ReplicationStoreRoomOnOutlierMembershipRestServlet\n", "from synapse.state import StateResolutionStore\n", "from synapse.storage.databases.main.events_worker import EventRedactBehaviour\n", "from synapse.types import JsonDict, MutableStateMap, PersistedEventPosition, RoomStreamToken, StateMap, UserID, get_domain_from_id\n", "from synapse.util.async_helpers import Linearizer, concurrently_execute\n", "from synapse.util.retryutils import NotRetryingDestination\n", "from synapse.util.stringutils import shortstr\n", "from synapse.visibility import filter_events_for_server\n", "if TYPE_CHECKING:\n", "from synapse.server import HomeServer\n", "logger = logging.getLogger(__name__)\n", "\"\"\"Holds information about a received event, ready for passing to _handle_new_events\n\n Attributes:\n event: the received event\n\n state: the state at that event\n\n auth_events: the auth_event map for that event\n \"\"\"\n", "event = attr.ib(type=EventBase)\n", "state = attr.ib(type=Optional[Sequence[EventBase]], default=None)\n", "auth_events = attr.ib(type=Optional[MutableStateMap[EventBase]], default=None)\n", "\"\"\"Handles events that originated from federation.\n Responsible for:\n a) handling received Pdus before handing them on as Events to the rest\n of the homeserver (including auth and state conflict resolutions)\n b) converting events that were produced by local clients that may need\n to be sent to remote homeservers.\n c) doing the necessary dances to invite remote users and join remote\n rooms.\n \"\"\"\n", "def __init__(self, hs: 'HomeServer'):...\n", "super().__init__(hs)\n", "self.hs = hs\n", "self.store = hs.get_datastore()\n", "self.storage = hs.get_storage()\n", "self.state_store = self.storage.state\n", "self.federation_client = hs.get_federation_client()\n", "self.state_handler = hs.get_state_handler()\n", "self._state_resolution_handler = hs.get_state_resolution_handler()\n", "self.server_name = hs.hostname\n", "self.keyring = hs.get_keyring()\n", "self.action_generator = hs.get_action_generator()\n", "self.is_mine_id = hs.is_mine_id\n", "self.spam_checker = hs.get_spam_checker()\n", "self.event_creation_handler = hs.get_event_creation_handler()\n", "self._message_handler = hs.get_message_handler()\n", "self._server_notices_mxid = hs.config.server_notices_mxid\n", "self.config = hs.config\n", "self.http_client = hs.get_simple_http_client()\n", "self._instance_name = hs.get_instance_name()\n", "self._replication = hs.get_replication_data_handler()\n", "self._send_events = ReplicationFederationSendEventsRestServlet.make_client(hs)\n", "self._clean_room_for_join_client = ReplicationCleanRoomRestServlet.make_client(\n hs)\n", "if hs.config.worker_app:\n", "self._user_device_resync = ReplicationUserDevicesResyncRestServlet.make_client(\n hs)\n", "self._device_list_updater = hs.get_device_handler().device_list_updater\n", "self._maybe_store_room_on_outlier_membership = (\n ReplicationStoreRoomOnOutlierMembershipRestServlet.make_client(hs))\n", "self._maybe_store_room_on_outlier_membership = (self.store.\n maybe_store_room_on_outlier_membership)\n", "self.room_queues = {}\n", "self._room_pdu_linearizer = Linearizer('fed_room_pdu')\n", "self.third_party_event_rules = hs.get_third_party_event_rules()\n", "self._ephemeral_messages_enabled = hs.config.enable_ephemeral_messages\n", "async def on_receive_pdu(self, origin, pdu, sent_to_us_directly=False) ->None:...\n", "\"\"\"docstring\"\"\"\n", "room_id = pdu.room_id\n", "event_id = pdu.event_id\n", "logger.info('handling received PDU: %s', pdu)\n", "existing = await self.store.get_event(event_id, allow_none=True,\n allow_rejected=True)\n", "already_seen = existing and (not existing.internal_metadata.is_outlier() or\n pdu.internal_metadata.is_outlier())\n", "if already_seen:\n", "logger.debug('[%s %s]: Already seen pdu', room_id, event_id)\n", "self._sanity_check_event(pdu)\n", "logger.warning('[%s %s] Received event failed sanity checks', room_id, event_id\n )\n", "if room_id in self.room_queues:\n", "return\n", "logger.info('[%s %s] Queuing PDU from %s for now: join in progress',\n room_id, event_id, origin)\n", "is_in_room = await self.auth.check_host_in_room(room_id, self.server_name)\n", "self.room_queues[room_id].append((pdu, origin))\n", "if not is_in_room:\n", "return\n", "logger.info(\"[%s %s] Ignoring PDU from %s as we're not in the room\",\n room_id, event_id, origin)\n", "state = None\n", "return None\n", "if not pdu.internal_metadata.is_outlier():\n", "min_depth = await self.get_min_depth_for_context(pdu.room_id)\n", "await self._process_received_pdu(origin, pdu, state=state)\n", "logger.debug('[%s %s] min_depth: %d', room_id, event_id, min_depth)\n", "async def _get_missing_events_for_pdu(self, origin, pdu, prevs, min_depth):...\n", "prevs = set(pdu.prev_event_ids())\n", "\"\"\"docstring\"\"\"\n", "seen = await self.store.have_events_in_timeline(prevs)\n", "room_id = pdu.room_id\n", "if min_depth is not None and pdu.depth < min_depth:\n", "event_id = pdu.event_id\n", "pdu.internal_metadata.outlier = True\n", "if min_depth is not None and pdu.depth > min_depth:\n", "seen = await self.store.have_events_in_timeline(prevs)\n", "if prevs - seen:\n", "missing_prevs = prevs - seen\n", "if not prevs - seen:\n", "if sent_to_us_directly:\n", "if sent_to_us_directly and missing_prevs:\n", "return\n", "latest_list = await self.store.get_latest_event_ids_in_room(room_id)\n", "logger.warning('[%s %s] Rejecting: failed to fetch %d prev events: %s',\n room_id, event_id, len(prevs - seen), shortstr(prevs - seen))\n", "logger.info(\n 'Event %s is missing prev_events: calculating state for a backwards extremity'\n , event_id)\n", "logger.info('[%s %s] Acquiring room lock to fetch %d missing prev_events: %s',\n room_id, event_id, len(missing_prevs), shortstr(missing_prevs))\n", "latest = set(latest_list)\n", "event_map = {event_id: pdu}\n", "logger.info('[%s %s] Acquired room lock to fetch %d missing prev_events',\n room_id, event_id, len(missing_prevs))\n", "latest |= seen\n", "ours = await self.state_store.get_state_groups_ids(room_id, seen)\n", "logger.warning(\n '[%s %s] Error attempting to resolve state at missing prev_events',\n room_id, event_id, exc_info=True)\n", "await self._get_missing_events_for_pdu(origin, pdu, prevs, min_depth)\n", "seen = await self.store.have_events_in_timeline(prevs)\n", "logger.info('[%s %s]: Requesting missing events between %s and %s', room_id,\n event_id, shortstr(latest), event_id)\n", "state_maps = list(ours.values())\n", "if not prevs - seen:\n", "missing_events = await self.federation_client.get_missing_events(origin,\n room_id, earliest_events_ids=list(latest), latest_events=[pdu], limit=\n 10, min_depth=min_depth, timeout=60000)\n", "logger.warning('[%s %s]: Failed to get prev_events: %s', room_id, event_id, e)\n", "logger.info('[%s %s]: Got %d prev_events: %s', room_id, event_id, len(\n missing_events), shortstr(missing_events))\n", "for p in (prevs - seen):\n", "logger.info('[%s %s] Found all missing prev_events', room_id, event_id)\n", "return\n", "missing_events.sort(key=lambda x: x.depth)\n", "logger.info('Requesting state at missing prev_event %s', event_id)\n", "room_version = await self.store.get_room_version_id(room_id)\n", "for ev in missing_events:\n", "remote_state, _ = await self._get_state_for_room(origin, room_id, p,\n include_event_in_state=True)\n", "state_map = await self._state_resolution_handler.resolve_events_with_store(\n room_id, room_version, state_maps, event_map, state_res_store=\n StateResolutionStore(self.store))\n", "logger.info('[%s %s] Handling received prev_event %s', room_id, event_id,\n ev.event_id)\n", "async def _get_state_for_room(self, destination: str, room_id: str,...\n", "remote_state_map = {(x.type, x.state_key): x.event_id for x in remote_state}\n", "evs = await self.store.get_events(list(state_map.values()),\n get_prev_content=False, redact_behaviour=EventRedactBehaviour.AS_IS)\n", "await self.on_receive_pdu(origin, ev, sent_to_us_directly=False)\n", "if e.code == 403:\n", "\"\"\"docstring\"\"\"\n", "state_maps.append(remote_state_map)\n", "event_map.update(evs)\n", "logger.warning('[%s %s] Received prev_event %s failed history check.',\n room_id, event_id, ev.event_id)\n", "state_event_ids, auth_event_ids = (await self.federation_client.\n get_room_state_ids(destination, room_id, event_id=event_id))\n", "for x in remote_state:\n", "state = [event_map[e] for e in state_map.values()]\n", "desired_events = set(state_event_ids + auth_event_ids)\n", "event_map[x.event_id] = x\n", "if include_event_in_state:\n", "desired_events.add(event_id)\n", "event_map = await self._get_events_from_store_or_dest(destination, room_id,\n desired_events)\n", "failed_to_fetch = desired_events - event_map.keys()\n", "if failed_to_fetch:\n", "logger.warning('Failed to fetch missing state/auth events for %s %s',\n event_id, failed_to_fetch)\n", "remote_state = [event_map[e_id] for e_id in state_event_ids if e_id in\n event_map]\n", "if include_event_in_state:\n", "remote_event = event_map.get(event_id)\n", "auth_chain = [event_map[e_id] for e_id in auth_event_ids if e_id in event_map]\n", "if not remote_event:\n", "auth_chain.sort(key=lambda e: e.depth)\n", "if remote_event.is_state() and remote_event.rejected_reason is None:\n", "return remote_state, auth_chain\n", "remote_state.append(remote_event)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Condition", "ImportFrom'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "AsyncFunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Condition", "Return'", "Expr'", "Assign'", "Expr'", "Condition", "Return'", "Expr'", "Assign'", "Return'", "Condition", "Assign'", "Expr'", "Expr'", "AsyncFunctionDef'", "Assign'", "Docstring", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Condition", "Return'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "AugAssign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "For", "Expr'", "Return'", "Expr'", "Expr'", "Assign'", "For", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Expr'", "Condition", "Docstring", "Expr'", "Expr'", "Expr'", "Assign'", "For", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Return'", "Expr'" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "if VAR_2.method != 'POST':\n", "VAR_154 = FUNC_42(VAR_2, VAR_5)\n", "VAR_114 = FUNC_43(VAR_2)\n", "VAR_115 = {'selected': VAR_114, 'images': VAR_154['image'], 'datasets':\n VAR_154['dataset'], 'projects': VAR_154['project'], 'screens': VAR_154[\n 'screen'], 'plates': VAR_154['plate'], 'acquisitions': VAR_154[\n 'acquisition'], 'wells': VAR_154['well'], 'shares': VAR_154['share']}\n", "if len(VAR_154['share']) < 1:\n", "for obs in VAR_154.values():\n", "VAR_157 = CommentAnnotationForm(VAR_115=initial, VAR_158=request.POST.copy())\n", "if len(obs) > 0:\n", "if VAR_157.is_valid():\n", "VAR_5.SERVICE_OPTS.setOmeroGroup(obs[0].getDetails().group.id.val)\n", "VAR_286 = VAR_157.cleaned_data['comment']\n", "return HttpResponse(VAR_345(VAR_157.errors))\n", "if VAR_286 is not None and VAR_286 != '':\n", "if VAR_154['share'] is not None and len(VAR_154['share']) > 0:\n", "VAR_400 = VAR_154['share'][0].id\n", "VAR_104 = BaseContainer(VAR_5)\n", "VAR_104 = BaseShare(VAR_5, VAR_400)\n", "VAR_34 = VAR_104.createCommentAnnotations(VAR_286, VAR_154)\n", "VAR_401 = '%s?server=%i' % (VAR_2.build_absolute_uri(VAR_350(\n 'load_template', args=['public'])), int(VAR_5.server_id))\n", "VAR_53 = {'annId': VAR_34, 'added_by': VAR_5.getUserId()}\n", "VAR_402 = VAR_104.addComment(VAR_401, VAR_286)\n", "return VAR_53\n", "VAR_53 = {'tann': VAR_402, 'added_by': VAR_5.getUserId(), 'template':\n 'webclient/annotations/comment.html'}\n" ]
[ "@login_required()...\n", "\"\"\"docstring\"\"\"\n", "if request.method != 'POST':\n", "oids = getObjects(request, conn)\n", "selected = getIds(request)\n", "initial = {'selected': selected, 'images': oids['image'], 'datasets': oids[\n 'dataset'], 'projects': oids['project'], 'screens': oids['screen'],\n 'plates': oids['plate'], 'acquisitions': oids['acquisition'], 'wells':\n oids['well'], 'shares': oids['share']}\n", "if len(oids['share']) < 1:\n", "for obs in oids.values():\n", "form_multi = CommentAnnotationForm(initial=initial, data=request.POST.copy())\n", "if len(obs) > 0:\n", "if form_multi.is_valid():\n", "conn.SERVICE_OPTS.setOmeroGroup(obs[0].getDetails().group.id.val)\n", "content = form_multi.cleaned_data['comment']\n", "return HttpResponse(str(form_multi.errors))\n", "if content is not None and content != '':\n", "if oids['share'] is not None and len(oids['share']) > 0:\n", "sid = oids['share'][0].id\n", "manager = BaseContainer(conn)\n", "manager = BaseShare(conn, sid)\n", "annId = manager.createCommentAnnotations(content, oids)\n", "host = '%s?server=%i' % (request.build_absolute_uri(reverse('load_template',\n args=['public'])), int(conn.server_id))\n", "context = {'annId': annId, 'added_by': conn.getUserId()}\n", "textAnn = manager.addComment(host, content)\n", "return context\n", "context = {'tann': textAnn, 'added_by': conn.getUserId(), 'template':\n 'webclient/annotations/comment.html'}\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", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "For", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Return'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Assign'" ]
[ "def FUNC_30(self, VAR_8):...\n", "" ]
[ "def get(self, id):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_50(VAR_62=None, VAR_9=None, VAR_109=0, VAR_110=None, VAR_111=False,...\n", "\"\"\"docstring\"\"\"\n", "import frappe.model.delete_doc\n", "frappe.model.delete_doc.delete_doc(VAR_62, VAR_9, VAR_109, VAR_110, VAR_111,\n VAR_92, VAR_19, VAR_112, VAR_113, VAR_114)\n" ]
[ "def delete_doc(doctype=None, name=None, force=0, ignore_doctypes=None,...\n", "\"\"\"docstring\"\"\"\n", "import frappe.model.delete_doc\n", "frappe.model.delete_doc.delete_doc(doctype, name, force, ignore_doctypes,\n for_reload, ignore_permissions, flags, ignore_on_trash, ignore_missing,\n delete_permanently)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Import'", "Expr'" ]
[ "def FUNC_11(VAR_11):...\n", "return os.path.join(VAR_3, VAR_11)\n" ]
[ "def _get_index_absolute_path(index):...\n", "return os.path.join(INDEXDIR, index)\n" ]
[ 0, 1 ]
[ "FunctionDef'", "Return'" ]
[ "@login_required...\n", "VAR_7 = Topic.objects.for_update_or_404(VAR_2, VAR_0.user)\n", "VAR_1 = VAR_7.category_id\n", "VAR_5 = TopicForm(VAR_4=request.user, data=post_data(request), instance=topic)\n", "if is_post(VAR_0) and VAR_5.is_valid():\n", "VAR_7 = VAR_5.save()\n", "return render(VAR_0=request, template_name='spirit/topic/update.html',\n context={'form': form})\n", "if VAR_7.category_id != VAR_1:\n", "Comment.create_moderation_action(VAR_4=request.user, VAR_7=topic, action=\n Comment.MOVED)\n", "return redirect(VAR_0.POST.get('next', VAR_7.get_absolute_url()))\n" ]
[ "@login_required...\n", "topic = Topic.objects.for_update_or_404(pk, request.user)\n", "category_id = topic.category_id\n", "form = TopicForm(user=request.user, data=post_data(request), instance=topic)\n", "if is_post(request) and form.is_valid():\n", "topic = form.save()\n", "return render(request=request, template_name='spirit/topic/update.html',\n context={'form': form})\n", "if topic.category_id != category_id:\n", "Comment.create_moderation_action(user=request.user, topic=topic, action=\n Comment.MOVED)\n", "return redirect(request.POST.get('next', topic.get_absolute_url()))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Return'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_23(self, VAR_17):...\n", "" ]
[ "def api_listdir(self, directory):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_41(self, VAR_24=None):...\n", "\"\"\"docstring\"\"\"\n", "VAR_65 = []\n", "for VAR_19 in self.meta.get('fields', {'fieldtype': ['in', VAR_81]}):\n", "if VAR_24:\n", "return VAR_65\n", "if VAR_19.options == VAR_24:\n", "VAR_26 = self.get(VAR_19.fieldname)\n", "return self.get(VAR_19.fieldname)\n", "if isinstance(VAR_26, list):\n", "VAR_65.extend(VAR_26)\n" ]
[ "def get_all_children(self, parenttype=None):...\n", "\"\"\"docstring\"\"\"\n", "ret = []\n", "for df in self.meta.get('fields', {'fieldtype': ['in', table_fields]}):\n", "if parenttype:\n", "return ret\n", "if df.options == parenttype:\n", "value = self.get(df.fieldname)\n", "return self.get(df.fieldname)\n", "if isinstance(value, list):\n", "ret.extend(value)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "For", "Condition", "Return'", "Condition", "Assign'", "Return'", "Condition", "Expr'" ]
[ "def FUNC_25(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(),\n 'testRunCommandOutOverwrite_inputs.npz')\n", "np.savez(VAR_31, VAR_26=x, VAR_27=x_notused)\n", "VAR_46 = os.path.join(test.get_temp_dir(), 'y.npy')\n", "open(VAR_46, 'a').close()\n", "VAR_10 = self.parser.parse_args(['run', '--dir', VAR_9, '--tag_set',\n 'serve', '--signature_def', 'serving_default', '--inputs', 'x=' +\n VAR_31 + '[x0]', '--outdir', test.get_temp_dir(), '--overwrite'])\n", "saved_model_cli.run(VAR_10)\n", "VAR_42 = np.load(VAR_46)\n", "VAR_43 = np.array([[2.5], [3.0]])\n", "self.assertAllClose(VAR_43, VAR_42)\n" ]
[ "def testRunCommandOutOverwrite(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(),\n 'testRunCommandOutOverwrite_inputs.npz')\n", "np.savez(input_path, x0=x, x1=x_notused)\n", "output_file = os.path.join(test.get_temp_dir(), 'y.npy')\n", "open(output_file, 'a').close()\n", "args = self.parser.parse_args(['run', '--dir', base_path, '--tag_set',\n 'serve', '--signature_def', 'serving_default', '--inputs', 'x=' +\n input_path + '[x0]', '--outdir', test.get_temp_dir(), '--overwrite'])\n", "saved_model_cli.run(args)\n", "y_actual = np.load(output_file)\n", "y_expected = np.array([[2.5], [3.0]])\n", "self.assertAllClose(y_expected, y_actual)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "import logging\n", "from django.template.response import TemplateResponse\n", "from django.utils.safestring import mark_safe\n", "import orjson\n", "from bs4 import BeautifulSoup\n", "from bs4.element import Tag\n", "from bs4.formatter import HTMLFormatter\n", "from django_unicorn.utils import sanitize_html\n", "from ..decorators import timed\n", "from ..utils import generate_checksum\n", "VAR_0 = logging.getLogger(__name__)\n", "\"\"\"\n Prevent beautifulsoup from re-ordering attributes.\n \"\"\"\n", "def FUNC_1(self, VAR_2: Tag):...\n", "for k, v in VAR_2.attrs.items():\n", "yield k, v\n", "def __init__(self, VAR_3, VAR_4, VAR_5=None, VAR_6=None, VAR_7=None, VAR_8=...\n", "super().__init__(VAR_3=template, VAR_4=request, VAR_5=context, VAR_6=\n content_type, VAR_7=status, VAR_8=charset, VAR_9=using)\n", "self.component = VAR_10\n", "self.init_js = VAR_11\n", "@timed...\n", "VAR_13 = super().render()\n", "if not self.component or not self.component.component_id:\n", "return VAR_13\n", "VAR_14 = VAR_13.content.decode('utf-8')\n", "VAR_15 = self.component.get_frontend_context_variables()\n", "VAR_16 = orjson.loads(VAR_15)\n", "VAR_17 = generate_checksum(orjson.dumps(VAR_16))\n", "VAR_1 = BeautifulSoup(VAR_14, features='html.parser')\n", "VAR_18 = FUNC_0(VAR_1)\n", "VAR_18['unicorn:id'] = self.component.component_id\n", "VAR_18['unicorn:name'] = self.component.component_name\n", "VAR_18['unicorn:key'] = self.component.component_key\n", "VAR_18['unicorn:checksum'] = VAR_17\n", "VAR_19 = generate_checksum(CLASS_1._desoupify(VAR_1))\n", "if self.init_js:\n", "VAR_21 = {'id': self.component.component_id, 'name': self.component.\n component_name, 'key': self.component.component_key, 'data': orjson.\n loads(VAR_15), 'calls': self.component.calls, 'hash': VAR_19}\n", "VAR_20 = CLASS_1._desoupify(VAR_1)\n", "VAR_21 = orjson.dumps(VAR_21).decode('utf-8')\n", "VAR_20 = mark_safe(VAR_20)\n", "VAR_22 = f'unicorn:data:{self.component.component_id}'\n", "self.component.rendered(VAR_20)\n", "VAR_23 = (\n f\"Unicorn.componentInit(JSON.parse(document.getElementById('{VAR_22}').textContent));\"\n )\n", "VAR_13.content = VAR_20\n", "VAR_24 = VAR_1.new_tag('script')\n", "return VAR_13\n", "VAR_24['type'] = 'application/json'\n", "VAR_24['id'] = VAR_22\n", "VAR_24.string = sanitize_html(VAR_21)\n", "if self.component.parent:\n", "self.component._init_script = VAR_23\n", "VAR_25 = []\n", "self.component._json_tag = VAR_24\n", "VAR_25.append(VAR_24)\n", "for child in self.component.children:\n", "VAR_23 = f'{VAR_23} {child._init_script}'\n", "VAR_26 = VAR_1.new_tag('script')\n", "VAR_25.append(child._json_tag)\n", "VAR_26['type'] = 'module'\n", "VAR_26.string = f'string{VAR_23} }}'\n", "VAR_18.insert_after(VAR_26)\n", "for t in VAR_25:\n", "VAR_18.insert_after(t)\n" ]
[ "import logging\n", "from django.template.response import TemplateResponse\n", "from django.utils.safestring import mark_safe\n", "import orjson\n", "from bs4 import BeautifulSoup\n", "from bs4.element import Tag\n", "from bs4.formatter import HTMLFormatter\n", "from django_unicorn.utils import sanitize_html\n", "from ..decorators import timed\n", "from ..utils import generate_checksum\n", "logger = logging.getLogger(__name__)\n", "\"\"\"\n Prevent beautifulsoup from re-ordering attributes.\n \"\"\"\n", "def attributes(self, tag: Tag):...\n", "for k, v in tag.attrs.items():\n", "yield k, v\n", "def __init__(self, template, request, context=None, content_type=None,...\n", "super().__init__(template=template, request=request, context=context,\n content_type=content_type, status=status, charset=charset, using=using)\n", "self.component = component\n", "self.init_js = init_js\n", "@timed...\n", "response = super().render()\n", "if not self.component or not self.component.component_id:\n", "return response\n", "content = response.content.decode('utf-8')\n", "frontend_context_variables = self.component.get_frontend_context_variables()\n", "frontend_context_variables_dict = orjson.loads(frontend_context_variables)\n", "checksum = generate_checksum(orjson.dumps(frontend_context_variables_dict))\n", "soup = BeautifulSoup(content, features='html.parser')\n", "root_element = get_root_element(soup)\n", "root_element['unicorn:id'] = self.component.component_id\n", "root_element['unicorn:name'] = self.component.component_name\n", "root_element['unicorn:key'] = self.component.component_key\n", "root_element['unicorn:checksum'] = checksum\n", "hash = generate_checksum(UnicornTemplateResponse._desoupify(soup))\n", "if self.init_js:\n", "init = {'id': self.component.component_id, 'name': self.component.\n component_name, 'key': self.component.component_key, 'data': orjson.\n loads(frontend_context_variables), 'calls': self.component.calls,\n 'hash': hash}\n", "rendered_template = UnicornTemplateResponse._desoupify(soup)\n", "init = orjson.dumps(init).decode('utf-8')\n", "rendered_template = mark_safe(rendered_template)\n", "json_element_id = f'unicorn:data:{self.component.component_id}'\n", "self.component.rendered(rendered_template)\n", "init_script = (\n f\"Unicorn.componentInit(JSON.parse(document.getElementById('{json_element_id}').textContent));\"\n )\n", "response.content = rendered_template\n", "json_tag = soup.new_tag('script')\n", "return response\n", "json_tag['type'] = 'application/json'\n", "json_tag['id'] = json_element_id\n", "json_tag.string = sanitize_html(init)\n", "if self.component.parent:\n", "self.component._init_script = init_script\n", "json_tags = []\n", "self.component._json_tag = json_tag\n", "json_tags.append(json_tag)\n", "for child in self.component.children:\n", "init_script = f'{init_script} {child._init_script}'\n", "script_tag = soup.new_tag('script')\n", "json_tags.append(child._json_tag)\n", "script_tag['type'] = 'module'\n", "script_tag.string = (\n f\"if (typeof Unicorn === 'undefined') {{ console.error('Unicorn is missing. Do you need {{% load unicorn %}} or {{% unicorn_scripts %}}?') }} else {{ {init_script} }}\"\n )\n", "root_element.insert_after(script_tag)\n", "for t in json_tags:\n", "root_element.insert_after(t)\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, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Expr'", "FunctionDef'", "For", "Expr'", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "For", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "For", "Expr'" ]
[ "def FUNC_15():...\n", "random.seed(VAR_24)\n", "return list(map(lambda x: x + VAR_5 * VAR_45, sorted(random.sample(list(\n range(VAR_5)), VAR_44))))\n" ]
[ "def generate_mix_indices():...\n", "random.seed(seed)\n", "return list(map(lambda x: x + ITEMS_PER_ITERATION * iteration_count, sorted\n (random.sample(list(range(ITEMS_PER_ITERATION)), mix_per_iteration))))\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Return'" ]
[ "@login_required()...\n", "" ]
[ "@login_required()...\n", "" ]
[ 0, 0 ]
[ "Condition", "Condition" ]
[ "def FUNC_17(VAR_9, VAR_5):...\n", "if VAR_87.check_visibility(constants.SIDEBAR_RANDOM):\n", "VAR_63, VAR_64, VAR_65 = calibre_db.fill_indexpage(VAR_9, 0, db.Books, True,\n [func.randomblob(2)])\n", "abort(404)\n", "VAR_65 = Pagination(1, config.config_books_per_page, config.\n config_books_per_page)\n", "return render_title_template('discover.html', VAR_63=entries, VAR_65=\n pagination, id=book_id, VAR_149=_(u'Discover (Random Books)'), VAR_9=\n 'discover')\n" ]
[ "def render_discover_books(page, book_id):...\n", "if current_user.check_visibility(constants.SIDEBAR_RANDOM):\n", "entries, __, pagination = calibre_db.fill_indexpage(page, 0, db.Books, True,\n [func.randomblob(2)])\n", "abort(404)\n", "pagination = Pagination(1, config.config_books_per_page, config.\n config_books_per_page)\n", "return render_title_template('discover.html', entries=entries, pagination=\n pagination, id=book_id, title=_(u'Discover (Random Books)'), page=\n 'discover')\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Expr'", "Assign'", "Return'" ]
[ "@VAR_4.route('/result', methods=['GET', 'POST'])...\n", "VAR_23 = VAR_17['result']\n", "VAR_16 = {'is_success': VAR_23, 'solved_count': VAR_17['quiz_count'],\n 'correct': VAR_17['correct'], 'current_munhak': VAR_17['current_munhak']}\n", "VAR_17['quiz_count'] = 0\n", "VAR_17['solved_quiz'] = []\n", "VAR_17['current_munhak'] = None\n", "print(VAR_16)\n", "return render_template('quiz/result.html', VAR_16=data)\n" ]
[ "@app.route('/result', methods=['GET', 'POST'])...\n", "is_success = session['result']\n", "data = {'is_success': is_success, 'solved_count': session['quiz_count'],\n 'correct': session['correct'], 'current_munhak': session['current_munhak']}\n", "session['quiz_count'] = 0\n", "session['solved_quiz'] = []\n", "session['current_munhak'] = None\n", "print(data)\n", "return render_template('quiz/result.html', data=data)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "@VAR_2.route('/admin/logdownload/<int:logtype>')...\n", "if VAR_26 == 0:\n", "VAR_113 = logger.get_logfile(config.config_logfile)\n", "if VAR_26 == 1:\n", "if logger.is_valid_logfile(VAR_113):\n", "VAR_113 = logger.get_accesslogfile(config.config_access_logfile)\n", "abort(404)\n", "return debug_info.assemble_logfiles(VAR_113)\n", "abort(404)\n" ]
[ "@admi.route('/admin/logdownload/<int:logtype>')...\n", "if logtype == 0:\n", "file_name = logger.get_logfile(config.config_logfile)\n", "if logtype == 1:\n", "if logger.is_valid_logfile(file_name):\n", "file_name = logger.get_accesslogfile(config.config_access_logfile)\n", "abort(404)\n", "return debug_info.assemble_logfiles(file_name)\n", "abort(404)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Expr'", "Return'", "Expr'" ]
[ "def FUNC_24(self):...\n", "VAR_29 = coreapi.Document(VAR_5='', title='Example API', content={'users':\n {'create': coreapi.Link(url='/users/', action='post', fields=[]),\n 'list': coreapi.Link(url='/users/', action='get', fields=[]), 'read':\n coreapi.Link(url='/users/{id}/', action='get', fields=[coreapi.Field(\n 'id', required=True, location='path', schema=coreschema.String())]),\n 'update': coreapi.Link(url='/users/{id}/', action='patch', fields=[\n coreapi.Field('id', required=True, location='path', schema=coreschema.\n String())]), 'friends': coreapi.Link(url='/users/{id}/friends', action=\n 'get', fields=[coreapi.Field('id', required=True, location='path',\n schema=coreschema.String())])}})\n", "VAR_30 = VAR_29['users']\n", "VAR_31 = schema_links(VAR_30)\n", "assert len(VAR_31) is 5\n", "assert 'list' in VAR_31\n", "assert 'create' in VAR_31\n", "assert 'read' in VAR_31\n", "assert 'update' in VAR_31\n", "assert 'friends' in VAR_31\n" ]
[ "def test_default_actions_and_single_custom_action(self):...\n", "schema = coreapi.Document(url='', title='Example API', content={'users': {\n 'create': coreapi.Link(url='/users/', action='post', fields=[]), 'list':\n coreapi.Link(url='/users/', action='get', fields=[]), 'read': coreapi.\n Link(url='/users/{id}/', action='get', fields=[coreapi.Field('id',\n required=True, location='path', schema=coreschema.String())]), 'update':\n coreapi.Link(url='/users/{id}/', action='patch', fields=[coreapi.Field(\n 'id', required=True, location='path', schema=coreschema.String())]),\n 'friends': coreapi.Link(url='/users/{id}/friends', action='get', fields\n =[coreapi.Field('id', required=True, location='path', schema=coreschema\n .String())])}})\n", "section = schema['users']\n", "flat_links = schema_links(section)\n", "assert len(flat_links) is 5\n", "assert 'list' in flat_links\n", "assert 'create' in flat_links\n", "assert 'read' in flat_links\n", "assert 'update' in flat_links\n", "assert 'friends' in flat_links\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assert'", "Assert'", "Assert'", "Assert'", "Assert'", "Assert'" ]
[ "def FUNC_9(self, VAR_12, VAR_1, VAR_2):...\n", "VAR_2 = VAR_2.__name__\n", "if self.acl.is_exempt(VAR_2):\n", "return True\n", "if not self.acl.seted:\n", "self._setup_acl()\n", "VAR_20 = set()\n", "VAR_21 = {'*', VAR_1}\n", "VAR_22 = {None, VAR_2}\n", "VAR_20.add(anonymous)\n", "VAR_20.update(VAR_12)\n", "for r, m, res in itertools.product(VAR_20, VAR_21, VAR_22):\n", "if self.acl.is_allowed(r.name, m, res):\n", "return False\n", "return True\n" ]
[ "def _check_permission(self, roles, method, resource):...\n", "resource = resource.__name__\n", "if self.acl.is_exempt(resource):\n", "return True\n", "if not self.acl.seted:\n", "self._setup_acl()\n", "_roles = set()\n", "_methods = {'*', method}\n", "_resources = {None, resource}\n", "_roles.add(anonymous)\n", "_roles.update(roles)\n", "for r, m, res in itertools.product(_roles, _methods, _resources):\n", "if self.acl.is_allowed(r.name, m, res):\n", "return False\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "For", "Condition", "Return'", "Return'" ]
[ "def FUNC_28(VAR_17, VAR_34, VAR_35=True):...\n", "VAR_62 = VAR_34.split('&')\n", "VAR_62 = list(map(lambda it: it.strip().replace(',', '|'), VAR_62))\n", "VAR_62 = helper.uniq(VAR_62)\n", "if VAR_62 == ['']:\n", "VAR_62 = [_(u'Unknown')]\n", "VAR_63 = FUNC_7(VAR_62, VAR_17.authors, db.Authors, calibre_db.session,\n 'author')\n", "VAR_64 = list()\n", "for inp in VAR_62:\n", "VAR_89 = calibre_db.session.query(db.Authors).filter(db.Authors.name == inp\n ).first()\n", "VAR_65 = ' & '.join(VAR_64)\n", "if not VAR_89:\n", "if VAR_17.author_sort != VAR_65 and VAR_35:\n", "VAR_89 = helper.get_sorted_author(inp)\n", "VAR_89 = VAR_89.sort\n", "VAR_17.author_sort = VAR_65\n", "return VAR_62, VAR_63\n", "VAR_64.append(helper.get_sorted_author(VAR_89))\n", "VAR_63 = True\n" ]
[ "def handle_author_on_edit(book, author_name, update_stored=True):...\n", "input_authors = author_name.split('&')\n", "input_authors = list(map(lambda it: it.strip().replace(',', '|'),\n input_authors))\n", "input_authors = helper.uniq(input_authors)\n", "if input_authors == ['']:\n", "input_authors = [_(u'Unknown')]\n", "change = modify_database_object(input_authors, book.authors, db.Authors,\n calibre_db.session, 'author')\n", "sort_authors_list = list()\n", "for inp in input_authors:\n", "stored_author = calibre_db.session.query(db.Authors).filter(db.Authors.name ==\n inp).first()\n", "sort_authors = ' & '.join(sort_authors_list)\n", "if not stored_author:\n", "if book.author_sort != sort_authors and update_stored:\n", "stored_author = helper.get_sorted_author(inp)\n", "stored_author = stored_author.sort\n", "book.author_sort = sort_authors\n", "return input_authors, change\n", "sort_authors_list.append(helper.get_sorted_author(stored_author))\n", "change = True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Return'", "Expr'", "Assign'" ]
[ "def FUNC_6(self):...\n", "VAR_5 = {'types': ['m.*', 'org.matrix.foo.bar']}\n", "VAR_6 = FUNC_0(sender='@foo:bar', type='m.room.message', room_id='!foo:bar')\n", "self.assertTrue(Filter(VAR_5).check(VAR_6))\n" ]
[ "def test_definition_types_works_with_wildcards(self):...\n", "definition = {'types': ['m.*', 'org.matrix.foo.bar']}\n", "event = MockEvent(sender='@foo:bar', type='m.room.message', room_id='!foo:bar')\n", "self.assertTrue(Filter(definition).check(event))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_0(VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_14 = VAR_3.adjusted(QUrl.NormalizePathSegments | QUrl.StripTrailingSlash)\n", "if VAR_14 != VAR_3:\n", "VAR_15 = VAR_3.path()\n", "VAR_16 = VAR_3.host()\n", "VAR_17 = urlutils.query_string(VAR_3)\n", "log.misc.debug('url: {}, path: {}, host {}'.format(VAR_3.toDisplayString(),\n VAR_15, VAR_16))\n", "if not VAR_15 or not VAR_16:\n", "VAR_29 = QUrl()\n", "VAR_30 = VAR_2[VAR_16]\n", "VAR_31, VAR_32 = VAR_30(VAR_3)\n", "assert VAR_31 is not None, VAR_3\n", "VAR_29.setScheme('qute')\n", "if VAR_31 == 'text/html' and isinstance(VAR_32, str):\n", "if VAR_16:\n", "VAR_32 = VAR_32.encode('utf-8', errors='xmlcharrefreplace')\n", "return VAR_31, VAR_32\n", "VAR_29.setHost(VAR_16)\n", "VAR_29.setHost(VAR_15)\n", "VAR_29.setPath('/')\n", "if VAR_17:\n", "VAR_29.setQuery(VAR_17)\n", "if VAR_29.host():\n" ]
[ "def data_for_url(url):...\n", "\"\"\"docstring\"\"\"\n", "norm_url = url.adjusted(QUrl.NormalizePathSegments | QUrl.StripTrailingSlash)\n", "if norm_url != url:\n", "path = url.path()\n", "host = url.host()\n", "query = urlutils.query_string(url)\n", "log.misc.debug('url: {}, path: {}, host {}'.format(url.toDisplayString(),\n path, host))\n", "if not path or not host:\n", "new_url = QUrl()\n", "handler = _HANDLERS[host]\n", "mimetype, data = handler(url)\n", "assert mimetype is not None, url\n", "new_url.setScheme('qute')\n", "if mimetype == 'text/html' and isinstance(data, str):\n", "if host:\n", "data = data.encode('utf-8', errors='xmlcharrefreplace')\n", "return mimetype, data\n", "new_url.setHost(host)\n", "new_url.setHost(path)\n", "new_url.setPath('/')\n", "if query:\n", "new_url.setQuery(query)\n", "if new_url.host():\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 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Assign'", "Assert'", "Expr'", "Condition", "Condition", "Assign'", "Return'", "Expr'", "Expr'", "Expr'", "Condition", "Expr'", "Condition" ]
[ "def FUNC_8(VAR_26: Optional[Dict[Text, Any]], VAR_27: Optional[List[Text]]=...\n", "if not VAR_26:\n", "return ''\n", "VAR_56 = VAR_27 or list(filter(lambda k: k not in VAR_28, VAR_26.keys()))\n", "VAR_57 = {k: VAR_26[k] for k in VAR_56 if k in VAR_26}\n", "return rasa.shared.utils.io.deep_container_fingerprint(VAR_57)\n" ]
[ "def _get_fingerprint_of_config(config: Optional[Dict[Text, Any]],...\n", "if not config:\n", "return ''\n", "keys = include_keys or list(filter(lambda k: k not in exclude_keys, config.\n keys()))\n", "sub_config = {k: config[k] for k in keys if k in config}\n", "return rasa.shared.utils.io.deep_container_fingerprint(sub_config)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Return'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_56(self):...\n", "self.login()\n", "VAR_3 = self.client.get('/logout/next_page/')\n", "self.assertEqual(VAR_3.status_code, 302)\n", "self.assertURLEqual(VAR_3.url, '/somewhere/')\n", "VAR_3 = self.client.get('/logout/next_page/?next=/login/')\n", "self.assertEqual(VAR_3.status_code, 302)\n", "self.assertURLEqual(VAR_3.url, '/login/')\n", "self.confirm_logged_out()\n" ]
[ "def test_logout_with_overridden_redirect_url(self):...\n", "self.login()\n", "response = self.client.get('/logout/next_page/')\n", "self.assertEqual(response.status_code, 302)\n", "self.assertURLEqual(response.url, '/somewhere/')\n", "response = self.client.get('/logout/next_page/?next=/login/')\n", "self.assertEqual(response.status_code, 302)\n", "self.assertURLEqual(response.url, '/login/')\n", "self.confirm_logged_out()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_11(self, VAR_39):...\n", "return self.doc_links[VAR_39.name]\n" ]
[ "def get_field_doc(self, field):...\n", "return self.doc_links[field.name]\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_31(VAR_20, VAR_17):...\n", "\"\"\"docstring\"\"\"\n", "VAR_66 = 'identifier-type-'\n", "VAR_67 = 'identifier-val-'\n", "VAR_68 = []\n", "for type_key, type_value in VAR_20.items():\n", "if not type_key.startswith(VAR_66):\n", "return VAR_68\n", "VAR_94 = VAR_67 + type_key[len(VAR_66):]\n", "if VAR_94 not in VAR_20.keys():\n", "VAR_68.append(db.Identifiers(VAR_20[VAR_94], type_value, VAR_17.id))\n" ]
[ "def identifier_list(to_save, book):...\n", "\"\"\"docstring\"\"\"\n", "id_type_prefix = 'identifier-type-'\n", "id_val_prefix = 'identifier-val-'\n", "result = []\n", "for type_key, type_value in to_save.items():\n", "if not type_key.startswith(id_type_prefix):\n", "return result\n", "val_key = id_val_prefix + type_key[len(id_type_prefix):]\n", "if val_key not in to_save.keys():\n", "result.append(db.Identifiers(to_save[val_key], type_value, book.id))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "For", "Condition", "Return'", "Assign'", "Condition", "Expr'" ]
[ "def FUNC_17(VAR_5):...\n", "VAR_19 = filescheme.dirbrowser_html(VAR_5).decode('utf-8')\n", "VAR_20 = bs4.BeautifulSoup(VAR_19, 'html.parser')\n", "print(VAR_20.prettify())\n", "VAR_21 = VAR_20('div', id='dirbrowserContainer')[0]\n", "VAR_42 = VAR_21('ul', class_='parent')\n", "if not VAR_42:\n", "VAR_11 = None\n", "VAR_11 = VAR_42[0].li.a.string\n", "VAR_15 = []\n", "VAR_16 = []\n", "for li in VAR_21('ul', class_='folders')[0]('li'):\n", "VAR_8 = self.Item(VAR_17=li.a['href'], VAR_18=str(li.a.string))\n", "for li in VAR_21('ul', class_='files')[0]('li'):\n", "VAR_15.append(VAR_8)\n", "VAR_8 = self.Item(VAR_17=li.a['href'], VAR_18=str(li.a.string))\n", "return self.Parsed(VAR_11=parent, VAR_15=folders, VAR_16=files)\n", "VAR_16.append(VAR_8)\n" ]
[ "def parse(path):...\n", "html = filescheme.dirbrowser_html(path).decode('utf-8')\n", "soup = bs4.BeautifulSoup(html, 'html.parser')\n", "print(soup.prettify())\n", "container = soup('div', id='dirbrowserContainer')[0]\n", "parent_elem = container('ul', class_='parent')\n", "if not parent_elem:\n", "parent = None\n", "parent = parent_elem[0].li.a.string\n", "folders = []\n", "files = []\n", "for li in container('ul', class_='folders')[0]('li'):\n", "item = self.Item(link=li.a['href'], text=str(li.a.string))\n", "for li in container('ul', class_='files')[0]('li'):\n", "folders.append(item)\n", "item = self.Item(link=li.a['href'], text=str(li.a.string))\n", "return self.Parsed(parent=parent, folders=folders, files=files)\n", "files.append(item)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "For", "Expr'", "Assign'", "Return'", "Expr'" ]
[ "@VAR_0.route('/ajax/editbooks/<param>', methods=['POST'])...\n", "VAR_81 = VAR_33.form.to_dict()\n", "VAR_16 = calibre_db.get_book(VAR_81['pk'])\n", "VAR_80 = ''\n", "if VAR_44 == 'series_index':\n", "FUNC_18(VAR_81['value'], VAR_16)\n", "if VAR_44 == 'tags':\n", "VAR_80 = Response(json.dumps({'success': True, 'newValue': VAR_16.\n series_index}), mimetype='application/json')\n", "FUNC_16(VAR_81['value'], VAR_16)\n", "if VAR_44 == 'series':\n", "VAR_16.last_modified = datetime.utcnow()\n", "VAR_80 = Response(json.dumps({'success': True, 'newValue': ', '.join([tag.\n name for tag in VAR_16.tags])}), mimetype='application/json')\n", "FUNC_17(VAR_81['value'], VAR_16)\n", "if VAR_44 == 'publishers':\n", "calibre_db.session.commit()\n", "calibre_db.session.rollback()\n", "return VAR_80\n", "VAR_80 = Response(json.dumps({'success': True, 'newValue': ', '.join([serie\n .name for serie in VAR_16.series])}), mimetype='application/json')\n", "FUNC_21(VAR_81['value'], VAR_16)\n", "if VAR_44 == 'languages':\n", "if VAR_44 == 'title' and VAR_81.get('checkT') == 'false':\n", "VAR_1.error('Database error: %s', e)\n", "VAR_80 = Response(json.dumps({'success': True, 'newValue': ', '.join([\n VAR_87.name for VAR_87 in VAR_16.publishers])}), mimetype=\n 'application/json')\n", "VAR_26 = list()\n", "if VAR_44 == 'author_sort':\n", "VAR_16.sort = VAR_124\n", "FUNC_20(VAR_81['value'], VAR_16, VAR_26=invalid)\n", "VAR_16.author_sort = VAR_81['value']\n", "if VAR_44 == 'title':\n", "calibre_db.session.commit()\n", "if VAR_26:\n", "VAR_80 = Response(json.dumps({'success': True, 'newValue': VAR_16.\n author_sort}), mimetype='application/json')\n", "VAR_124 = VAR_16.sort\n", "if VAR_44 == 'sort':\n", "VAR_80 = Response(json.dumps({'success': False, 'msg':\n 'Invalid languages in request: {}'.format(','.join(VAR_26))}), mimetype\n ='application/json')\n", "VAR_121 = list()\n", "FUNC_29(VAR_16, VAR_81.get('value', ''))\n", "VAR_16.sort = VAR_81['value']\n", "if VAR_44 == 'comments':\n", "for lang in VAR_16.languages:\n", "helper.update_dir_stucture(VAR_16.id, config.config_calibre_dir)\n", "VAR_80 = Response(json.dumps({'success': True, 'newValue': VAR_16.sort}),\n mimetype='application/json')\n", "FUNC_19(VAR_81['value'], VAR_16)\n", "if VAR_44 == 'authors':\n", "VAR_121.append(isoLanguages.get_language_name(get_locale(), lang.lang_code))\n", "VAR_80 = Response(json.dumps({'success': True, 'newValue': ', '.join(\n VAR_121)}), mimetype='application/json')\n", "VAR_80 = Response(json.dumps({'success': True, 'newValue': VAR_16.title}),\n mimetype='application/json')\n", "VAR_80 = Response(json.dumps({'success': True, 'newValue': VAR_16.comments[\n 0].text}), mimetype='application/json')\n", "VAR_63, VAR_125 = FUNC_30(VAR_16, VAR_81['value'], VAR_81.get('checkA',\n None) == 'true')\n", "if VAR_44.startswith('custom_column_'):\n", "helper.update_dir_stucture(VAR_16.id, config.config_calibre_dir, VAR_63[0])\n", "VAR_126 = dict()\n", "VAR_80 = Response(json.dumps({'success': True, 'newValue': ' & '.join([\n author.replace('|', ',') for author in VAR_63])}), mimetype=\n 'application/json')\n", "VAR_126[VAR_44] = VAR_81['value']\n", "FUNC_24(VAR_16.id, VAR_16, VAR_44[14:], VAR_126)\n", "VAR_80 = Response(json.dumps({'success': True, 'newValue': VAR_81['value']}\n ), mimetype='application/json')\n" ]
[ "@editbook.route('/ajax/editbooks/<param>', methods=['POST'])...\n", "vals = request.form.to_dict()\n", "book = calibre_db.get_book(vals['pk'])\n", "ret = ''\n", "if param == 'series_index':\n", "edit_book_series_index(vals['value'], book)\n", "if param == 'tags':\n", "ret = Response(json.dumps({'success': True, 'newValue': book.series_index}),\n mimetype='application/json')\n", "edit_book_tags(vals['value'], book)\n", "if param == 'series':\n", "book.last_modified = datetime.utcnow()\n", "ret = Response(json.dumps({'success': True, 'newValue': ', '.join([tag.name for\n tag in book.tags])}), mimetype='application/json')\n", "edit_book_series(vals['value'], book)\n", "if param == 'publishers':\n", "calibre_db.session.commit()\n", "calibre_db.session.rollback()\n", "return ret\n", "ret = Response(json.dumps({'success': True, 'newValue': ', '.join([serie.\n name for serie in book.series])}), mimetype='application/json')\n", "edit_book_publisher(vals['value'], book)\n", "if param == 'languages':\n", "if param == 'title' and vals.get('checkT') == 'false':\n", "log.error('Database error: %s', e)\n", "ret = Response(json.dumps({'success': True, 'newValue': ', '.join([\n publisher.name for publisher in book.publishers])}), mimetype=\n 'application/json')\n", "invalid = list()\n", "if param == 'author_sort':\n", "book.sort = sort\n", "edit_book_languages(vals['value'], book, invalid=invalid)\n", "book.author_sort = vals['value']\n", "if param == 'title':\n", "calibre_db.session.commit()\n", "if invalid:\n", "ret = Response(json.dumps({'success': True, 'newValue': book.author_sort}),\n mimetype='application/json')\n", "sort = book.sort\n", "if param == 'sort':\n", "ret = Response(json.dumps({'success': False, 'msg':\n 'Invalid languages in request: {}'.format(','.join(invalid))}),\n mimetype='application/json')\n", "lang_names = list()\n", "handle_title_on_edit(book, vals.get('value', ''))\n", "book.sort = vals['value']\n", "if param == 'comments':\n", "for lang in book.languages:\n", "helper.update_dir_stucture(book.id, config.config_calibre_dir)\n", "ret = Response(json.dumps({'success': True, 'newValue': book.sort}),\n mimetype='application/json')\n", "edit_book_comments(vals['value'], book)\n", "if param == 'authors':\n", "lang_names.append(isoLanguages.get_language_name(get_locale(), lang.lang_code))\n", "ret = Response(json.dumps({'success': True, 'newValue': ', '.join(\n lang_names)}), mimetype='application/json')\n", "ret = Response(json.dumps({'success': True, 'newValue': book.title}),\n mimetype='application/json')\n", "ret = Response(json.dumps({'success': True, 'newValue': book.comments[0].\n text}), mimetype='application/json')\n", "input_authors, __ = handle_author_on_edit(book, vals['value'], vals.get(\n 'checkA', None) == 'true')\n", "if param.startswith('custom_column_'):\n", "helper.update_dir_stucture(book.id, config.config_calibre_dir, input_authors[0]\n )\n", "new_val = dict()\n", "ret = Response(json.dumps({'success': True, 'newValue': ' & '.join([author.\n replace('|', ',') for author in input_authors])}), mimetype=\n 'application/json')\n", "new_val[param] = vals['value']\n", "edit_single_cc_data(book.id, book, param[14:], new_val)\n", "ret = Response(json.dumps({'success': True, 'newValue': vals['value']}),\n mimetype='application/json')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Expr'", "Condition", "Expr'", "Expr'", "Return'", "Assign'", "Expr'", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "For", "Expr'", "Assign'", "Expr'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_39(VAR_15, VAR_16, VAR_17={}, VAR_3=None):...\n", "VAR_98 = (VAR_15, VAR_16) if 'app' in VAR_17 else (VAR_3, VAR_15, VAR_16)\n", "VAR_99 = URL('edit', VAR_98=args, VAR_17=vars)\n", "return A(VAR_16, VAR_144='editor_filelink', _href=url, _style=\n 'word-wrap: nowrap;')\n" ]
[ "def editfile(path, file, vars={}, app=None):...\n", "args = (path, file) if 'app' in vars else (app, path, file)\n", "url = URL('edit', args=args, vars=vars)\n", "return A(file, _class='editor_filelink', _href=url, _style='word-wrap: nowrap;'\n )\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_53(VAR_91, VAR_116=None, VAR_117=None, VAR_109=False, VAR_115=False):...\n", "\"\"\"docstring\"\"\"\n", "import frappe.modules\n", "return frappe.modules.reload_doc(VAR_91, VAR_116, VAR_117, VAR_109=force,\n VAR_115=reset_permissions)\n" ]
[ "def reload_doc(module, dt=None, dn=None, force=False, reset_permissions=False):...\n", "\"\"\"docstring\"\"\"\n", "import frappe.modules\n", "return frappe.modules.reload_doc(module, dt, dn, force=force,\n reset_permissions=reset_permissions)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Import'", "Return'" ]
[ "@parameterized.expand([(['federation'], 'auth_fail'), ([], 'no_resource'),...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = {'port': 8080, 'type': 'http', 'bind_addresses': ['0.0.0.0'],\n 'resources': [{'names': VAR_2}]}\n", "self.hs._listen_http(parse_listener_def(VAR_6))\n", "VAR_7 = self.reactor.tcpServers[0][1]\n", "VAR_7.resource.children[b'_matrix'].children[b'federation']\n", "if VAR_3 == 'no_resource':\n", "VAR_8, VAR_9 = make_request(self.reactor, VAR_7, 'GET',\n '/_matrix/federation/v1/openid/userinfo')\n", "return\n", "self.assertEqual(VAR_9.code, 401)\n" ]
[ "@parameterized.expand([(['federation'], 'auth_fail'), ([], 'no_resource'),...\n", "\"\"\"docstring\"\"\"\n", "config = {'port': 8080, 'type': 'http', 'bind_addresses': ['0.0.0.0'],\n 'resources': [{'names': names}]}\n", "self.hs._listen_http(parse_listener_def(config))\n", "site = self.reactor.tcpServers[0][1]\n", "site.resource.children[b'_matrix'].children[b'federation']\n", "if expectation == 'no_resource':\n", "_, channel = make_request(self.reactor, site, 'GET',\n '/_matrix/federation/v1/openid/userinfo')\n", "return\n", "self.assertEqual(channel.code, 401)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Expr'", "Assign'", "Expr'", "Condition", "Assign'", "Return'", "Expr'" ]
[ "@VAR_2.route('/formats')...\n", "if VAR_87.check_visibility(constants.SIDEBAR_FORMAT):\n", "if VAR_87.get_view_property('ratings', 'dir') == 'desc':\n", "abort(404)\n", "VAR_10 = db.Data.format.desc()\n", "VAR_10 = db.Data.format.asc()\n", "VAR_109 = 0\n", "VAR_109 = 1\n", "VAR_63 = calibre_db.session.query(db.Data, func.count('data.book').label(\n 'count'), db.Data.format.label('format')).join(db.Books).filter(calibre_db\n .common_filters()).group_by(db.Data.format).order_by(VAR_10).all()\n", "return render_title_template('list.html', VAR_63=entries, folder=\n 'web.books_list', VAR_107=list(), VAR_150=_(u'File formats list'),\n VAR_9='formatslist', VAR_8='formats', VAR_10=order_no)\n" ]
[ "@web.route('/formats')...\n", "if current_user.check_visibility(constants.SIDEBAR_FORMAT):\n", "if current_user.get_view_property('ratings', 'dir') == 'desc':\n", "abort(404)\n", "order = db.Data.format.desc()\n", "order = db.Data.format.asc()\n", "order_no = 0\n", "order_no = 1\n", "entries = calibre_db.session.query(db.Data, func.count('data.book').label(\n 'count'), db.Data.format.label('format')).join(db.Books).filter(calibre_db\n .common_filters()).group_by(db.Data.format).order_by(order).all()\n", "return render_title_template('list.html', entries=entries, folder=\n 'web.books_list', charlist=list(), title=_(u'File formats list'), page=\n 'formatslist', data='formats', order=order_no)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "For", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_7(self, VAR_16, VAR_15, VAR_17, VAR_18, VAR_19):...\n", "\"\"\"docstring\"\"\"\n", "VAR_105 = self.profile\n", "VAR_101 = []\n", "VAR_102 = [VAR_0.format('specialchar', VAR_20, 'data-value=\"{}\"'.format(\n VAR_13.encode('ascii', 'xmlcharrefreplace').decode('ascii')), char) for\n VAR_20, char, VAR_13 in get_special_chars(VAR_16, VAR_105.special_chars,\n VAR_17.source)]\n", "VAR_101.append(VAR_2.format('', '\\n'.join(VAR_102)))\n", "VAR_43 = VAR_3.format('\\n'.join(VAR_101))\n", "if VAR_16.direction == 'rtl':\n", "VAR_43 = self.get_rtl_toolbar(VAR_15) + VAR_43\n", "return mark_safe(VAR_43)\n" ]
[ "def get_toolbar(self, language, fieldname, unit, idx, source):...\n", "\"\"\"docstring\"\"\"\n", "profile = self.profile\n", "groups = []\n", "chars = [BUTTON_TEMPLATE.format('specialchar', name, 'data-value=\"{}\"'.\n format(value.encode('ascii', 'xmlcharrefreplace').decode('ascii')),\n char) for name, char, value in get_special_chars(language, profile.\n special_chars, unit.source)]\n", "groups.append(GROUP_TEMPLATE.format('', '\\n'.join(chars)))\n", "result = TOOLBAR_TEMPLATE.format('\\n'.join(groups))\n", "if language.direction == 'rtl':\n", "result = self.get_rtl_toolbar(fieldname) + result\n", "return mark_safe(result)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Return'" ]
[ "@pytest.mark.windows...\n", "assert filescheme.is_root(VAR_9) == VAR_10\n" ]
[ "@pytest.mark.windows...\n", "assert filescheme.is_root(directory) == is_root\n" ]
[ 0, 0 ]
[ "Condition", "Assert'" ]
[ "def FUNC_1(VAR_3, VAR_4, VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "VAR_12 = getattr(VAR_5, 'request', None)\n", "VAR_4 = list(VAR_4)\n", "VAR_4.reverse()\n", "while VAR_4:\n", "VAR_19 = VAR_4.pop()\n", "return VAR_3\n", "if OFS.interfaces.ITraversable.providedBy(VAR_3):\n", "VAR_3 = VAR_3.unrestrictedTraverse(VAR_19)\n", "VAR_3 = traversePathElement(VAR_3, VAR_19, VAR_4, VAR_12=request)\n" ]
[ "def trustedBoboAwareZopeTraverse(object, path_items, econtext):...\n", "\"\"\"docstring\"\"\"\n", "request = getattr(econtext, 'request', None)\n", "path_items = list(path_items)\n", "path_items.reverse()\n", "while path_items:\n", "name = path_items.pop()\n", "return object\n", "if OFS.interfaces.ITraversable.providedBy(object):\n", "object = object.unrestrictedTraverse(name)\n", "object = traversePathElement(object, name, path_items, request=request)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_13(self):...\n", "VAR_20 = as_string(None)\n", "assert VAR_20 == ''\n" ]
[ "def test_as_string_with_none(self):...\n", "result = as_string(None)\n", "assert result == ''\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assert'" ]
[ "def FUNC_22(VAR_22):...\n", "\"\"\"docstring\"\"\"\n", "VAR_50 = VAR_22.checkpoint_path or os.path.join(VAR_22.dir,\n 'variables/variables')\n", "if not VAR_22.variables_to_feed:\n", "VAR_78 = []\n", "if VAR_22.variables_to_feed.lower() == 'all':\n", "saved_model_aot_compile.freeze_model(VAR_50=checkpoint_path, VAR_4=\n saved_model_utils.get_meta_graph_def(args.dir, args.tag_set), VAR_5=\n args.signature_def_key, VAR_78=variables_to_feed, output_prefix=args.\n output_prefix)\n", "VAR_78 = None\n", "VAR_78 = VAR_22.variables_to_feed.split(',')\n" ]
[ "def freeze_model(args):...\n", "\"\"\"docstring\"\"\"\n", "checkpoint_path = args.checkpoint_path or os.path.join(args.dir,\n 'variables/variables')\n", "if not args.variables_to_feed:\n", "variables_to_feed = []\n", "if args.variables_to_feed.lower() == 'all':\n", "saved_model_aot_compile.freeze_model(checkpoint_path=checkpoint_path,\n meta_graph_def=saved_model_utils.get_meta_graph_def(args.dir, args.\n tag_set), signature_def_key=args.signature_def_key, variables_to_feed=\n variables_to_feed, output_prefix=args.output_prefix)\n", "variables_to_feed = None\n", "variables_to_feed = args.variables_to_feed.split(',')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Assign'" ]
[ "def FUNC_144(self, VAR_156):...\n", "VAR_63 = self.auth\n", "VAR_101 = VAR_63.db\n", "VAR_212 = VAR_101.wiki_page(VAR_156=slug)\n", "if not (VAR_212 and self.can_edit(VAR_212)):\n", "return self.not_authorized(VAR_212)\n", "self.auth.db.wiki_media.id.represent = (lambda VAR_215, VAR_266: VAR_215 if\n not VAR_266.filename else SPAN('@////%i/%s.%s' % (VAR_215, IS_SLUG.\n urlify(VAR_266.title.split('.')[0]), VAR_266.filename.split('.')[-1])))\n", "self.auth.db.wiki_media.wiki_page.default = VAR_212.id\n", "self.auth.db.wiki_media.wiki_page.writable = False\n", "VAR_335 = []\n", "VAR_336 = True\n", "VAR_337 = True\n", "if VAR_263.request.vars.embedded:\n", "VAR_334 = (\n \"var c = jQuery('#wiki_page_body'); c.val(c.val() + jQuery('%s').text()); return false;\"\n )\n", "VAR_229 = SQLFORM.grid(self.auth.db.wiki_media.wiki_page == VAR_212.id,\n VAR_174=self.auth.db.wiki_media.title, VAR_335=links, VAR_336=csv,\n VAR_337=create, VAR_11=['_editmedia', slug], user_signature=False)\n", "VAR_409 = self.auth.db.wiki_media.id.represent\n", "return dict(VAR_229=content)\n", "VAR_336 = False\n", "VAR_337 = False\n", "VAR_335 = [lambda VAR_266: A('copy into source', _href='#', _onclick=script %\n fragment(row.id, row))]\n" ]
[ "def editmedia(self, slug):...\n", "auth = self.auth\n", "db = auth.db\n", "page = db.wiki_page(slug=slug)\n", "if not (page and self.can_edit(page)):\n", "return self.not_authorized(page)\n", "self.auth.db.wiki_media.id.represent = (lambda id, row: id if not row.\n filename else SPAN('@////%i/%s.%s' % (id, IS_SLUG.urlify(row.title.\n split('.')[0]), row.filename.split('.')[-1])))\n", "self.auth.db.wiki_media.wiki_page.default = page.id\n", "self.auth.db.wiki_media.wiki_page.writable = False\n", "links = []\n", "csv = True\n", "create = True\n", "if current.request.vars.embedded:\n", "script = (\n \"var c = jQuery('#wiki_page_body'); c.val(c.val() + jQuery('%s').text()); return false;\"\n )\n", "content = SQLFORM.grid(self.auth.db.wiki_media.wiki_page == page.id,\n orderby=self.auth.db.wiki_media.title, links=links, csv=csv, create=\n create, args=['_editmedia', slug], user_signature=False)\n", "fragment = self.auth.db.wiki_media.id.represent\n", "return dict(content=content)\n", "csv = False\n", "create = False\n", "links = [lambda row: A('copy into source', _href='#', _onclick=script %\n fragment(row.id, row))]\n" ]
[ 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", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Return'", "Assign'", "Assign'", "Assign'" ]
[ "def __init__(self):...\n", "self.called = False\n" ]
[ "def __init__(self):...\n", "self.called = False\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "def FUNC_51(self):...\n", "def FUNC_52():...\n", "self.http_server.stop()\n", "self.io_loop.stop()\n", "self.io_loop.add_callback(FUNC_52)\n" ]
[ "def stop(self):...\n", "def _stop():...\n", "self.http_server.stop()\n", "self.io_loop.stop()\n", "self.io_loop.add_callback(_stop)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Expr'", "Expr'", "Expr'" ]
[ "@VAR_0.route('/jobs/<int:job_id>/subjobs', methods=['GET', 'POST'])...\n", "\"\"\"docstring\"\"\"\n", "if request.method == 'POST':\n", "VAR_84['subjobs_per_page'] = int(request.form.get('subjobs-per-page'))\n", "VAR_51 = int(request.args.get('page')) if request.args.get('page'\n ) is not None else 0\n", "VAR_84['subjobs_filter'] = {key: request.form.get(form_name) for key,\n form_name in zip(['status', 'application', 'backend'], ['subjob-status',\n 'subjob-application', 'subjob-backend'])}\n", "VAR_62 = VAR_84['subjobs_per_page']\n", "VAR_101 = FUNC_58(f'/internal/jobs/{VAR_9}/subjobs/length', 'get', VAR_73=\n session['subjobs_filter'])\n", "flash(str(err), 'danger')\n", "return render_template('subjobs.html', title=f'Subjobs - Job {job_id}',\n VAR_5=status_color, VAR_91=number_of_pages, VAR_51=current_page,\n backends=plugins['backends'], applications=plugins['applications'],\n VAR_102=subjobs_info, VAR_9=job_id)\n", "VAR_91 = int(VAR_101) // int(VAR_62) + 1\n", "return redirect(url_for('job_page', VAR_9=job_id))\n", "if VAR_51 >= VAR_91:\n", "return redirect(url_for('subjobs_page', page=number_of_pages - 1, VAR_9=job_id)\n )\n", "VAR_73 = VAR_84['subjobs_filter'].copy()\n", "VAR_73.update({'recent': True, 'length': VAR_62, 'offset': VAR_51})\n", "VAR_102 = FUNC_58(f'/internal/jobs/{VAR_9}/subjobs', 'get', VAR_73=params)\n" ]
[ "@gui.route('/jobs/<int:job_id>/subjobs', methods=['GET', 'POST'])...\n", "\"\"\"docstring\"\"\"\n", "if request.method == 'POST':\n", "session['subjobs_per_page'] = int(request.form.get('subjobs-per-page'))\n", "current_page = int(request.args.get('page')) if request.args.get('page'\n ) is not None else 0\n", "session['subjobs_filter'] = {key: request.form.get(form_name) for key,\n form_name in zip(['status', 'application', 'backend'], ['subjob-status',\n 'subjob-application', 'subjob-backend'])}\n", "subjobs_per_page = session['subjobs_per_page']\n", "subjobs_length = query_internal_api(f'/internal/jobs/{job_id}/subjobs/length',\n 'get', params=session['subjobs_filter'])\n", "flash(str(err), 'danger')\n", "return render_template('subjobs.html', title=f'Subjobs - Job {job_id}',\n status_color=status_color, number_of_pages=number_of_pages,\n current_page=current_page, backends=plugins['backends'], applications=\n plugins['applications'], subjobs_info=subjobs_info, job_id=job_id)\n", "number_of_pages = int(subjobs_length) // int(subjobs_per_page) + 1\n", "return redirect(url_for('job_page', job_id=job_id))\n", "if current_page >= number_of_pages:\n", "return redirect(url_for('subjobs_page', page=number_of_pages - 1, job_id=\n job_id))\n", "params = session['subjobs_filter'].copy()\n", "params.update({'recent': True, 'length': subjobs_per_page, 'offset':\n current_page})\n", "subjobs_info = query_internal_api(f'/internal/jobs/{job_id}/subjobs', 'get',\n params=params)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Return'", "Assign'", "Return'", "Condition", "Return'", "Assign'", "Expr'", "Assign'" ]
[ "async def FUNC_6(self, VAR_3: str, VAR_4: str) ->dict:...\n", "\"\"\"docstring\"\"\"\n", "if self.federation_domain_whitelist is not None and VAR_3 not in self.federation_domain_whitelist:\n", "VAR_31 = VAR_3, VAR_4\n", "VAR_30, VAR_28 = await self._get_remote_media_impl(VAR_3, VAR_4)\n", "if VAR_30:\n", "return VAR_28\n" ]
[ "async def get_remote_media_info(self, server_name: str, media_id: str) ->dict:...\n", "\"\"\"docstring\"\"\"\n", "if self.federation_domain_whitelist is not None and server_name not in self.federation_domain_whitelist:\n", "key = server_name, media_id\n", "responder, media_info = await self._get_remote_media_impl(server_name, media_id\n )\n", "if responder:\n", "return media_info\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Docstring", "Condition", "Assign'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_9(VAR_25):...\n", "return VAR_25[:-1] if VAR_25.endswith('_') else VAR_25\n" ]
[ "def norm(k):...\n", "return k[:-1] if k.endswith('_') else k\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_20(VAR_66: DecoratedCallable) ->DecoratedCallable:...\n", "self.add_api_websocket_route(VAR_26, VAR_66, VAR_28=name)\n", "return VAR_66\n" ]
[ "def decorator(func: DecoratedCallable) ->DecoratedCallable:...\n", "self.add_api_websocket_route(path, func, name=name)\n", "return func\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Return'" ]
[ "def FUNC_43(VAR_62, VAR_9):...\n", "FUNC_10().hdel('last_modified', VAR_62)\n", "VAR_46 = FUNC_42(VAR_62, VAR_9)\n", "if VAR_46 in VAR_1.document_cache:\n", "FUNC_10().hdel('document_cache', VAR_46)\n" ]
[ "def clear_document_cache(doctype, name):...\n", "cache().hdel('last_modified', doctype)\n", "key = get_document_cache_key(doctype, name)\n", "if key in local.document_cache:\n", "cache().hdel('document_cache', key)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Condition", "Expr'" ]
[ "def FUNC_164(VAR_179):...\n", "if isinstance(VAR_179, unicodeT):\n", "return VAR_179.encode('utf8')\n", "if hasattr(VAR_179, 'isoformat'):\n", "return VAR_179.isoformat()[:19].replace('T', ' ')\n", "if VAR_179 is None:\n", "return '<NULL>'\n", "return VAR_179\n" ]
[ "def none_exception(value):...\n", "if isinstance(value, unicodeT):\n", "return value.encode('utf8')\n", "if hasattr(value, 'isoformat'):\n", "return value.isoformat()[:19].replace('T', ' ')\n", "if value is None:\n", "return '<NULL>'\n", "return value\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "For", "Return'", "Condition", "Return'", "Return'" ]
[ "def FUNC_73(self, VAR_4, **VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.utils.background_jobs import enqueue\n", "if hasattr(self, '_' + VAR_4):\n", "VAR_4 = '_' + VAR_4\n", "if file_lock.lock_exists(self.get_signature()):\n", "frappe.throw(_(\n 'This document is currently queued for execution. Please try again'),\n title=_('Document Queued'))\n", "self.lock()\n", "enqueue('frappe.model.document.execute_action', VAR_2=self.doctype, VAR_3=\n self.name, VAR_4=action, **kwargs)\n" ]
[ "def queue_action(self, action, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.utils.background_jobs import enqueue\n", "if hasattr(self, '_' + action):\n", "action = '_' + action\n", "if file_lock.lock_exists(self.get_signature()):\n", "frappe.throw(_(\n 'This document is currently queued for execution. Please try again'),\n title=_('Document Queued'))\n", "self.lock()\n", "enqueue('frappe.model.document.execute_action', doctype=self.doctype, name=\n self.name, action=action, **kwargs)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "ImportFrom'", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Expr'" ]
[ "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" ]
[ "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, 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_172(VAR_354):...\n", "return VAR_354 + ' ' + VAR_354.replace('icon', 'glyphicon')\n" ]
[ "def rename(icon):...\n", "return icon + ' ' + icon.replace('icon', 'glyphicon')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]