lines
sequencelengths 1
383
| raw_lines
sequencelengths 1
383
| label
sequencelengths 1
383
| type
sequencelengths 1
383
|
---|---|---|---|
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_155 and not VAR_7.record:\n",
"return None\n",
"VAR_153 = VAR_7.table\n",
"if not VAR_154:\n",
"VAR_382 = '%s_archive' % VAR_153\n",
"VAR_286 = {VAR_122: VAR_7.vars.id}\n",
"if VAR_382 not in VAR_153._db:\n",
"for VAR_385 in VAR_154.fields:\n",
"VAR_153._db.define_table(VAR_382, VAR_1(VAR_122, VAR_153), *[VAR_177.clone(\n unique=False) for VAR_177 in VAR_153])\n",
"VAR_154 = VAR_153._db[VAR_382]\n",
"if VAR_385 not in ['id', VAR_122]:\n",
"if VAR_133:\n",
"if VAR_155 and VAR_385 in VAR_7.vars:\n",
"VAR_286.update(VAR_133)\n",
"VAR_215 = VAR_154.insert(**new_record)\n",
"VAR_286[VAR_385] = VAR_7.vars[VAR_385]\n",
"if VAR_7.record and VAR_385 in VAR_7.record:\n",
"return VAR_215\n",
"VAR_286[VAR_385] = VAR_7.record[VAR_385]\n"
] | [
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"if not archive_current and not form.record:\n",
"return None\n",
"table = form.table\n",
"if not archive_table:\n",
"archive_table_name = '%s_archive' % table\n",
"new_record = {current_record: form.vars.id}\n",
"if archive_table_name not in table._db:\n",
"for fieldname in archive_table.fields:\n",
"table._db.define_table(archive_table_name, Field(current_record, table), *[\n field.clone(unique=False) for field in table])\n",
"archive_table = table._db[archive_table_name]\n",
"if fieldname not in ['id', current_record]:\n",
"if fields:\n",
"if archive_current and fieldname in form.vars:\n",
"new_record.update(fields)\n",
"id = archive_table.insert(**new_record)\n",
"new_record[fieldname] = form.vars[fieldname]\n",
"if form.record and fieldname in form.record:\n",
"return id\n",
"new_record[fieldname] = form.record[fieldname]\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"For",
"Expr'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'"
] |
[
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = VAR_9['iid']\n",
"VAR_79 = VAR_9.get('key', None)\n",
"VAR_15 = VAR_8.getObject('Image', VAR_6)\n",
"if VAR_15 is None:\n",
"if is_public_user(VAR_2):\n",
"if VAR_2.GET.get('getDefaults') == 'true':\n",
"return HttpResponseForbidden()\n",
"return HttpResponseNotFound('Image:%s not found' % VAR_6)\n",
"VAR_15.resetDefaults(save=False)\n",
"VAR_54 = imageMarshal(VAR_15, VAR_79=key, VAR_2=request)\n",
"return VAR_54\n"
] | [
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"iid = kwargs['iid']\n",
"key = kwargs.get('key', None)\n",
"image = conn.getObject('Image', iid)\n",
"if image is None:\n",
"if is_public_user(request):\n",
"if request.GET.get('getDefaults') == 'true':\n",
"return HttpResponseForbidden()\n",
"return HttpResponseNotFound('Image:%s not found' % iid)\n",
"image.resetDefaults(save=False)\n",
"rv = imageMarshal(image, key=key, request=request)\n",
"return rv\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Return'",
"Return'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_41(VAR_105):...\n",
"return VAR_50 or VAR_104 != VAR_105.get_etag()[0]\n"
] | [
"def validate_cache(cached):...\n",
"return force_refresh or current_etag != cached.get_etag()[0]\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_16(self, VAR_0, VAR_8, VAR_7, VAR_5, VAR_10, VAR_11):...\n",
"VAR_0.get(VAR_8 + self.url)\n",
"VAR_16 = VAR_0.find_element(By.XPATH, \"//input[@name='file']\")\n",
"VAR_16.send_keys(' \\n '.join([VAR_5, VAR_10]))\n",
"VAR_16 = VAR_0.find_element(By.XPATH, \"//input[@name='other_file']\")\n",
"VAR_16.send_keys(VAR_11)\n",
"VAR_17 = VAR_0.find_element(By.XPATH, \"//input[@name='save']\")\n",
"VAR_17.click()\n",
"VAR_12 = json.loads(VAR_0.find_elements(By.CSS_SELECTOR, 'pre')[0].text)\n",
"assert VAR_12['FILES'] == {'file': [os.path.basename(VAR_5), os.path.\n basename(VAR_10)], 'other_file': [os.path.basename(VAR_11)]}\n"
] | [
"def test_multi_file(self, driver, live_server, freeze, upload_file,...\n",
"driver.get(live_server + self.url)\n",
"file_input = driver.find_element(By.XPATH, \"//input[@name='file']\")\n",
"file_input.send_keys(' \\n '.join([upload_file, another_upload_file]))\n",
"file_input = driver.find_element(By.XPATH, \"//input[@name='other_file']\")\n",
"file_input.send_keys(yet_another_upload_file)\n",
"save_button = driver.find_element(By.XPATH, \"//input[@name='save']\")\n",
"save_button.click()\n",
"response = json.loads(driver.find_elements(By.CSS_SELECTOR, 'pre')[0].text)\n",
"assert response['FILES'] == {'file': [os.path.basename(upload_file), os.\n path.basename(another_upload_file)], 'other_file': [os.path.basename(\n yet_another_upload_file)]}\n"
] | [
0,
0,
0,
1,
0,
1,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assert'"
] |
[
"def FUNC_32(self):...\n",
"VAR_74 = VAR_53.session.get('playlist', [])\n",
"return VAR_74\n"
] | [
"def api_restoreplaylist(self):...\n",
"session_playlist = cherrypy.session.get('playlist', [])\n",
"return session_playlist\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self, VAR_18):...\n",
"VAR_28 = self.secured.get(VAR_18.id)\n",
"if VAR_28 is not None:\n",
"return Symbol(VAR_28)\n",
"return VAR_18\n"
] | [
"def visit_Name(self, node):...\n",
"value = self.secured.get(node.id)\n",
"if value is not None:\n",
"return Symbol(value)\n",
"return node\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"self.get_failure(self.handler.check_device_registered(VAR_5='@boris:foo',\n VAR_6='foo', initial_device_display_name='a' * (synapse.handlers.device\n .MAX_DEVICE_DISPLAY_NAME_LEN + 1)), synapse.api.errors.SynapseError)\n"
] | [
"def test_device_is_created_with_invalid_name(self):...\n",
"self.get_failure(self.handler.check_device_registered(user_id='@boris:foo',\n device_id='foo', initial_device_display_name='a' * (synapse.handlers.\n device.MAX_DEVICE_DISPLAY_NAME_LEN + 1)), synapse.api.errors.SynapseError)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_73(VAR_129, *VAR_79, **VAR_42):...\n",
"\"\"\"docstring\"\"\"\n",
"if isinstance(VAR_129, string_types):\n",
"VAR_129 = FUNC_72(VAR_129)\n",
"VAR_194 = FUNC_74(VAR_129, VAR_42)\n",
"return VAR_129(*VAR_79, **newargs)\n"
] | [
"def call(fn, *args, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"if isinstance(fn, string_types):\n",
"fn = get_attr(fn)\n",
"newargs = get_newargs(fn, kwargs)\n",
"return fn(*args, **newargs)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_53(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self._send_labelled_messages_in_room()\n",
"VAR_39 = 's0_0_0_0_0_0_0_0_0'\n",
"VAR_22, VAR_23 = self.make_request('GET', \n '/rooms/%s/messages?access_token=%s&from=%s&filter=%s' % (self.room_id,\n self.tok, VAR_39, json.dumps(self.FILTER_LABELS_NOT_LABELS)))\n",
"VAR_60 = VAR_23.json_body['chunk']\n",
"self.assertEqual(len(VAR_60), 1, [event['content'] for event in VAR_60])\n",
"self.assertEqual(VAR_60[0]['content']['body'], 'with wrong label', VAR_60[0])\n"
] | [
"def test_messages_filter_labels_not_labels(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self._send_labelled_messages_in_room()\n",
"token = 's0_0_0_0_0_0_0_0_0'\n",
"request, channel = self.make_request('GET', \n '/rooms/%s/messages?access_token=%s&from=%s&filter=%s' % (self.room_id,\n self.tok, token, json.dumps(self.FILTER_LABELS_NOT_LABELS)))\n",
"events = channel.json_body['chunk']\n",
"self.assertEqual(len(events), 1, [event['content'] for event in events])\n",
"self.assertEqual(events[0]['content']['body'], 'with wrong label', events[0])\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_19(self):...\n",
"self.assertFormfield(models.Member, 'gender', widgets.AdminRadioSelect,\n radio_fields={'gender': admin.VERTICAL})\n"
] | [
"def testChoicesWithRadioFields(self):...\n",
"self.assertFormfield(models.Member, 'gender', widgets.AdminRadioSelect,\n radio_fields={'gender': admin.VERTICAL})\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"async def FUNC_18(self, VAR_23: Iterable[str], VAR_11: str, VAR_27: str,...\n",
"VAR_5, VAR_1, VAR_28 = await self.federation_client.make_membership_event(\n VAR_23, VAR_11, VAR_27, VAR_29, VAR_25, VAR_30=params)\n",
"VAR_0.debug('Got response to make_%s: %s', VAR_29, VAR_1)\n",
"assert VAR_1.type == VAR_188.Member\n",
"assert VAR_1.user_id == VAR_27\n",
"assert VAR_1.state_key == VAR_27\n",
"assert VAR_1.room_id == VAR_11\n",
"return VAR_5, VAR_1, VAR_28\n"
] | [
"async def _make_and_verify_event(self, target_hosts: Iterable[str], room_id:...\n",
"origin, event, room_version = (await self.federation_client.\n make_membership_event(target_hosts, room_id, user_id, membership,\n content, params=params))\n",
"logger.debug('Got response to make_%s: %s', membership, event)\n",
"assert event.type == EventTypes.Member\n",
"assert event.user_id == user_id\n",
"assert event.state_key == user_id\n",
"assert event.room_id == room_id\n",
"return origin, event, room_version\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Expr'",
"Assert'",
"Assert'",
"Assert'",
"Assert'",
"Return'"
] |
[
"def FUNC_7(VAR_24=None, VAR_28=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_177 = {}\n",
"VAR_24 = VAR_24 or getattr(VAR_1, 'sites_path', None)\n",
"VAR_28 = VAR_28 or getattr(VAR_1, 'site_path', None)\n",
"if VAR_24:\n",
"VAR_207 = os.path.join(VAR_24, 'common_site_config.json')\n",
"if VAR_28:\n",
"if os.path.exists(VAR_207):\n",
"VAR_208 = os.path.join(VAR_28, 'site_config.json')\n",
"return CLASS_0(VAR_177)\n",
"VAR_177.update(FUNC_70(VAR_207))\n",
"click.secho('common_site_config.json is invalid', fg='red')\n",
"if os.path.exists(VAR_208):\n",
"print(VAR_215)\n",
"if VAR_1.site and not VAR_1.flags.new_site:\n",
"VAR_177.update(FUNC_70(VAR_208))\n",
"click.secho('{0}/site_config.json is invalid'.format(VAR_1.site), fg='red')\n",
"print(VAR_215)\n"
] | [
"def get_site_config(sites_path=None, site_path=None):...\n",
"\"\"\"docstring\"\"\"\n",
"config = {}\n",
"sites_path = sites_path or getattr(local, 'sites_path', None)\n",
"site_path = site_path or getattr(local, 'site_path', None)\n",
"if sites_path:\n",
"common_site_config = os.path.join(sites_path, 'common_site_config.json')\n",
"if site_path:\n",
"if os.path.exists(common_site_config):\n",
"site_config = os.path.join(site_path, 'site_config.json')\n",
"return _dict(config)\n",
"config.update(get_file_json(common_site_config))\n",
"click.secho('common_site_config.json is invalid', fg='red')\n",
"if os.path.exists(site_config):\n",
"print(error)\n",
"if local.site and not local.flags.new_site:\n",
"config.update(get_file_json(site_config))\n",
"click.secho('{0}/site_config.json is invalid'.format(local.site), fg='red')\n",
"print(error)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Return'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@VAR_0.route('/api/credentials/renew', methods=['PUT'])...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_98 = FUNC_58('/internal/credentials/renew', 'put')\n",
"return jsonify({'success': False, 'message': str(err)}), 400\n",
"return jsonify(VAR_98)\n"
] | [
"@gui.route('/api/credentials/renew', methods=['PUT'])...\n",
"\"\"\"docstring\"\"\"\n",
"response_info = query_internal_api('/internal/credentials/renew', 'put')\n",
"return jsonify({'success': False, 'message': str(err)}), 400\n",
"return jsonify(response_info)\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'",
"Return'"
] |
[
"def FUNC_29(self):...\n",
"VAR_5 = self._makeContext()\n",
"self.assertIs(VAR_5.evaluate('nocall:open'), open)\n"
] | [
"def test_open_in_path_expr(self):...\n",
"ec = self._makeContext()\n",
"self.assertIs(ec.evaluate('nocall:open'), open)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_83(VAR_9, VAR_10):...\n",
""
] | [
"def wrapped(request, course_id):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_24(self):...\n",
"\"\"\"docstring\"\"\"\n",
"from django.contrib.sites.models import Site\n",
"from django.core.exceptions import ImproperlyConfigured\n",
"from django.urls import reverse\n",
"VAR_162 = Site.objects.get_current()\n",
"VAR_162 = Site(domain='configure-django-sites.com')\n",
"if helpdesk_settings.HELPDESK_USE_HTTPS_IN_EMAIL_LINK:\n",
"VAR_163 = 'https'\n",
"VAR_163 = 'http'\n",
"return u'%s://%s%s?ticket=%s&email=%s&key=%s' % (VAR_163, VAR_162.domain,\n reverse('helpdesk:public_view'), self.ticket_for_url, self.\n submitter_email, self.secret_key)\n"
] | [
"def _get_ticket_url(self):...\n",
"\"\"\"docstring\"\"\"\n",
"from django.contrib.sites.models import Site\n",
"from django.core.exceptions import ImproperlyConfigured\n",
"from django.urls import reverse\n",
"site = Site.objects.get_current()\n",
"site = Site(domain='configure-django-sites.com')\n",
"if helpdesk_settings.HELPDESK_USE_HTTPS_IN_EMAIL_LINK:\n",
"protocol = 'https'\n",
"protocol = 'http'\n",
"return u'%s://%s%s?ticket=%s&email=%s&key=%s' % (protocol, site.domain,\n reverse('helpdesk:public_view'), self.ticket_for_url, self.\n submitter_email, self.secret_key)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_5(VAR_13):...\n",
"if VAR_13 <= 10000:\n",
"return float(math.factorial(VAR_13))\n"
] | [
"def _factorial(x):...\n",
"if x <= 10000:\n",
"return float(math.factorial(x))\n"
] | [
0,
5,
5
] | [
"FunctionDef'",
"Condition",
"Return'"
] |
[
"def FUNC_0(VAR_0):...\n",
""
] | [
"def constructObject(data):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_4(self, VAR_13):...\n",
"if not VAR_13:\n",
"return None\n",
"return User.objects.get(Q(username=value) | Q(email=value))\n"
] | [
"def clean(self, value):...\n",
"if not value:\n",
"return None\n",
"return User.objects.get(Q(username=value) | Q(email=value))\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_18():...\n",
"if len(VAR_1.message_log) > 0:\n",
"VAR_1.message_log = VAR_1.message_log[:-1]\n"
] | [
"def clear_last_message():...\n",
"if len(local.message_log) > 0:\n",
"local.message_log = local.message_log[:-1]\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'"
] |
[
"def FUNC_7(self) ->Sequence[GeneratorError]:...\n",
"VAR_6 = []\n",
"for collection in self.openapi.endpoint_collections_by_tag.values():\n",
"VAR_6.extend(collection.parse_errors)\n",
"VAR_6.extend(self.openapi.schemas.errors)\n",
"return VAR_6\n"
] | [
"def _get_errors(self) ->Sequence[GeneratorError]:...\n",
"errors = []\n",
"for collection in self.openapi.endpoint_collections_by_tag.values():\n",
"errors.extend(collection.parse_errors)\n",
"errors.extend(self.openapi.schemas.errors)\n",
"return errors\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Expr'",
"Expr'",
"Return'"
] |
[
"@VAR_5.route('/id/start/<int:start>/span/<int:span>/<path:video>')...\n",
"VAR_16 = Headers([('Content-Type', 'text/xml')])\n",
"return Response(FUNC_4(VAR_9, VAR_8, VAR_10), '200 OK', VAR_16=headers)\n"
] | [
"@scope_blueprint.route('/id/start/<int:start>/span/<int:span>/<path:video>')...\n",
"headers = Headers([('Content-Type', 'text/xml')])\n",
"return Response(_get_object_element(start, span, video), '200 OK', headers=\n headers)\n"
] | [
0,
0,
0
] | [
"Condition",
"Assign'",
"Return'"
] |
[
"async def FUNC_7(self, VAR_11: str, VAR_19: int, VAR_17: int) ->bool:...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_18 = await self.store.get_oldest_events_with_depth_in_room(VAR_11)\n",
"if not VAR_18:\n",
"VAR_0.debug('Not backfilling as no extremeties found.')\n",
"VAR_73 = await self.store.get_successor_events(list(VAR_18))\n",
"return False\n",
"VAR_74 = await self.store.get_events(VAR_73, redact_behaviour=\n EventRedactBehaviour.AS_IS, get_prev_content=False)\n",
"VAR_75 = await filter_events_for_server(self.storage, self.server_name,\n list(VAR_74.values()), redact=False, check_history_visibility_only=True)\n",
"if not VAR_75:\n",
"return False\n",
"VAR_76 = sorted(VAR_18.items(), VAR_144=lambda e: -int(e[1]))\n",
"VAR_77 = VAR_76[0][1]\n",
"if VAR_19 - 2 * VAR_17 > VAR_77:\n",
"VAR_0.debug(\"Not backfilling as we don't need to. %d < %d - 2 * %d\", VAR_77,\n VAR_19, VAR_17)\n",
"VAR_0.debug(\n 'room_id: %s, backfill: current_depth: %s, max_depth: %s, extrems: %s',\n VAR_11, VAR_19, VAR_77, VAR_76)\n",
"return False\n",
"VAR_78 = [t for t in VAR_76 if int(t[1]) <= VAR_19]\n",
"if VAR_78:\n",
"VAR_76 = VAR_78\n",
"VAR_18 = dict(VAR_76[:5])\n",
"VAR_79 = await self.state_handler.get_current_state(VAR_11)\n",
"def FUNC_46(VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_161 = [(state_key, int(VAR_1.depth)) for (e_type, state_key), VAR_1 in\n VAR_2.items() if e_type == VAR_188.Member and VAR_1.membership ==\n Membership.JOIN]\n",
"VAR_162 = {}\n",
"for u, d in VAR_161:\n",
"return sorted(VAR_162.items(), VAR_144=lambda d: d[1])\n",
"VAR_196 = get_domain_from_id(u)\n",
"VAR_197 = VAR_162.get(VAR_196)\n",
"if VAR_197:\n",
"VAR_162[VAR_196] = min(d, VAR_197)\n",
"VAR_162[VAR_196] = d\n"
] | [
"async def maybe_backfill(self, room_id: str, current_depth: int, limit: int...\n",
"\"\"\"docstring\"\"\"\n",
"extremities = await self.store.get_oldest_events_with_depth_in_room(room_id)\n",
"if not extremities:\n",
"logger.debug('Not backfilling as no extremeties found.')\n",
"forward_events = await self.store.get_successor_events(list(extremities))\n",
"return False\n",
"extremities_events = await self.store.get_events(forward_events,\n redact_behaviour=EventRedactBehaviour.AS_IS, get_prev_content=False)\n",
"filtered_extremities = await filter_events_for_server(self.storage, self.\n server_name, list(extremities_events.values()), redact=False,\n check_history_visibility_only=True)\n",
"if not filtered_extremities:\n",
"return False\n",
"sorted_extremeties_tuple = sorted(extremities.items(), key=lambda e: -int(e[1])\n )\n",
"max_depth = sorted_extremeties_tuple[0][1]\n",
"if current_depth - 2 * limit > max_depth:\n",
"logger.debug(\"Not backfilling as we don't need to. %d < %d - 2 * %d\",\n max_depth, current_depth, limit)\n",
"logger.debug(\n 'room_id: %s, backfill: current_depth: %s, max_depth: %s, extrems: %s',\n room_id, current_depth, max_depth, sorted_extremeties_tuple)\n",
"return False\n",
"filtered_sorted_extremeties_tuple = [t for t in sorted_extremeties_tuple if\n int(t[1]) <= current_depth]\n",
"if filtered_sorted_extremeties_tuple:\n",
"sorted_extremeties_tuple = filtered_sorted_extremeties_tuple\n",
"extremities = dict(sorted_extremeties_tuple[:5])\n",
"curr_state = await self.state_handler.get_current_state(room_id)\n",
"def get_domains_from_state(state):...\n",
"\"\"\"docstring\"\"\"\n",
"joined_users = [(state_key, int(event.depth)) for (e_type, state_key),\n event in state.items() if e_type == EventTypes.Member and event.\n membership == Membership.JOIN]\n",
"joined_domains = {}\n",
"for u, d in joined_users:\n",
"return sorted(joined_domains.items(), key=lambda d: d[1])\n",
"dom = get_domain_from_id(u)\n",
"old_d = joined_domains.get(dom)\n",
"if old_d:\n",
"joined_domains[dom] = min(d, old_d)\n",
"joined_domains[dom] = d\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"AsyncFunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"For",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'"
] |
[
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_22:\n",
"VAR_2 = FUNC_1('/publicRooms')\n",
"VAR_2 = FUNC_1('/publicRooms')\n",
"VAR_39 = {'include_all_networks': 'true' if VAR_23 else 'false'}\n",
"VAR_3 = {'include_all_networks': 'true' if VAR_23 else 'false'}\n",
"if VAR_24:\n",
"if VAR_24:\n",
"VAR_39['third_party_instance_id'] = VAR_24\n",
"if VAR_10:\n",
"VAR_3['third_party_instance_id'] = VAR_24,\n",
"if VAR_10:\n",
"VAR_39['limit'] = str(VAR_10)\n",
"if VAR_21:\n",
"VAR_3['limit'] = [str(VAR_10)]\n",
"if VAR_21:\n",
"VAR_39['since'] = VAR_21\n",
"VAR_39['filter'] = VAR_22\n",
"VAR_3['since'] = [VAR_21]\n",
"VAR_37 = await self.client.get_json(VAR_5=remote_server, VAR_2=path, VAR_3=\n args, VAR_15=True)\n",
"if e.code == 403:\n",
"return VAR_37\n",
"VAR_37 = await self.client.post_json(VAR_5=remote_server, VAR_2=path,\n VAR_39=data, VAR_15=True)\n",
"if e.code == 403:\n"
] | [
"@log_function...\n",
"\"\"\"docstring\"\"\"\n",
"if search_filter:\n",
"path = _create_v1_path('/publicRooms')\n",
"path = _create_v1_path('/publicRooms')\n",
"data = {'include_all_networks': 'true' if include_all_networks else 'false'}\n",
"args = {'include_all_networks': 'true' if include_all_networks else 'false'}\n",
"if third_party_instance_id:\n",
"if third_party_instance_id:\n",
"data['third_party_instance_id'] = third_party_instance_id\n",
"if limit:\n",
"args['third_party_instance_id'] = third_party_instance_id,\n",
"if limit:\n",
"data['limit'] = str(limit)\n",
"if since_token:\n",
"args['limit'] = [str(limit)]\n",
"if since_token:\n",
"data['since'] = since_token\n",
"data['filter'] = search_filter\n",
"args['since'] = [since_token]\n",
"response = await self.client.get_json(destination=remote_server, path=path,\n args=args, ignore_backoff=True)\n",
"if e.code == 403:\n",
"return response\n",
"response = await self.client.post_json(destination=remote_server, path=path,\n data=data, ignore_backoff=True)\n",
"if e.code == 403:\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'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Condition"
] |
[
"def FUNC_30(self, VAR_22='write'):...\n",
"if not hasattr(self, '_has_access_to'):\n",
"self._has_access_to = {}\n",
"self._has_access_to[VAR_22] = []\n",
"VAR_59 = frappe.get_roles()\n",
"for perm in self.get_permissions():\n",
"if perm.role in VAR_59 and perm.get(VAR_22):\n",
"return self._has_access_to[VAR_22]\n",
"if perm.permlevel not in self._has_access_to[VAR_22]:\n",
"self._has_access_to[VAR_22].append(perm.permlevel)\n"
] | [
"def get_permlevel_access(self, permission_type='write'):...\n",
"if not hasattr(self, '_has_access_to'):\n",
"self._has_access_to = {}\n",
"self._has_access_to[permission_type] = []\n",
"roles = frappe.get_roles()\n",
"for perm in self.get_permissions():\n",
"if perm.role in roles and perm.get(permission_type):\n",
"return self._has_access_to[permission_type]\n",
"if perm.permlevel not in self._has_access_to[permission_type]:\n",
"self._has_access_to[permission_type].append(perm.permlevel)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Return'",
"Condition",
"Expr'"
] |
[
"def FUNC_6(self):...\n",
"VAR_10 = test.test_src_dir_path(VAR_0)\n",
"self.parser = saved_model_cli.create_parser()\n",
"VAR_11 = self.parser.parse_args(['show', '--dir', VAR_10, '--tag_set', 'serve']\n )\n",
"saved_model_cli.show(VAR_11)\n",
"VAR_12 = out.getvalue().strip()\n",
"VAR_16 = (\n 'The given SavedModel MetaGraphDef contains SignatureDefs with the following keys:'\n )\n",
"VAR_17 = 'SignatureDef key: '\n",
"VAR_18 = ['\"classify_x2_to_y3\"', '\"classify_x_to_y\"', '\"regress_x2_to_y3\"',\n '\"regress_x_to_y\"', '\"regress_x_to_y2\"', '\"serving_default\"']\n",
"self.assertMultiLineEqual(VAR_12, '\\n'.join([VAR_16] + [(VAR_17 + exp_key) for\n exp_key in VAR_18]))\n",
"self.assertEqual(err.getvalue().strip(), '')\n"
] | [
"def testShowCommandSignature(self):...\n",
"base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n",
"self.parser = saved_model_cli.create_parser()\n",
"args = self.parser.parse_args(['show', '--dir', base_path, '--tag_set',\n 'serve'])\n",
"saved_model_cli.show(args)\n",
"output = out.getvalue().strip()\n",
"exp_header = (\n 'The given SavedModel MetaGraphDef contains SignatureDefs with the following keys:'\n )\n",
"exp_start = 'SignatureDef key: '\n",
"exp_keys = ['\"classify_x2_to_y3\"', '\"classify_x_to_y\"',\n '\"regress_x2_to_y3\"', '\"regress_x_to_y\"', '\"regress_x_to_y2\"',\n '\"serving_default\"']\n",
"self.assertMultiLineEqual(output, '\\n'.join([exp_header] + [(exp_start +\n exp_key) for exp_key in exp_keys]))\n",
"self.assertEqual(err.getvalue().strip(), '')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@wraps(VAR_13)...\n",
"if VAR_8.auth:\n",
"@login_required...\n",
"return VAR_13(*VAR_41, **kwargs)\n",
"return VAR_13(*VAR_41, **kwargs)\n"
] | [
"@wraps(func)...\n",
"if app.auth:\n",
"@login_required...\n",
"return func(*args, **kwargs)\n",
"return func(*args, **kwargs)\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_9(self):...\n",
"def __call__(self):...\n",
"VAR_6 = CLASS_5()\n",
"VAR_5 = self._makeContext(VAR_0={'dummy': dummy})\n",
"self.assertIs(VAR_5.evaluate('dummy'), VAR_6)\n"
] | [
"def test_evaluate_with_unimplemented_call(self):...\n",
"def __call__(self):...\n",
"dummy = Dummy()\n",
"ec = self._makeContext(bindings={'dummy': dummy})\n",
"self.assertIs(ec.evaluate('dummy'), dummy)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"@transaction.non_atomic_requests...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_38 = CourseKey.from_string(VAR_10)\n",
"VAR_45 = FUNC_75(VAR_9)\n",
"return JsonResponse({'message': VAR_169.message}, status=400)\n",
"if VAR_9.method == 'POST':\n",
"VAR_163 = FUNC_82(VAR_45, VAR_38)\n",
"if VAR_9.method == 'DELETE':\n",
"VAR_46 = FUNC_80(VAR_9, VAR_163, VAR_45)\n",
"return JsonResponse({'message': VAR_169.message}, status=400)\n",
"return JsonResponse(VAR_46)\n",
"FUNC_81(VAR_9, VAR_38, VAR_163)\n",
"return JsonResponse({'message': VAR_169.message}, status=400)\n",
"return JsonResponse({}, status=204)\n"
] | [
"@transaction.non_atomic_requests...\n",
"\"\"\"docstring\"\"\"\n",
"course_key = CourseKey.from_string(course_id)\n",
"certificate_invalidation_data = parse_request_data(request)\n",
"return JsonResponse({'message': error.message}, status=400)\n",
"if request.method == 'POST':\n",
"certificate = validate_request_data_and_get_certificate(\n certificate_invalidation_data, course_key)\n",
"if request.method == 'DELETE':\n",
"certificate_invalidation = invalidate_certificate(request, certificate,\n certificate_invalidation_data)\n",
"return JsonResponse({'message': error.message}, status=400)\n",
"return JsonResponse(certificate_invalidation)\n",
"re_validate_certificate(request, course_key, certificate)\n",
"return JsonResponse({'message': error.message}, status=400)\n",
"return JsonResponse({}, status=204)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Return'",
"Expr'",
"Return'",
"Return'"
] |
[
"def FUNC_17(self, VAR_4, VAR_39, VAR_40):...\n",
"if not VAR_40.startswith('/'):\n",
"self.base_url = '/' + VAR_40\n",
"if not VAR_40.endswith('/'):\n",
"self.base_url = VAR_40 + '/'\n"
] | [
"def _base_url_changed(self, name, old, new):...\n",
"if not new.startswith('/'):\n",
"self.base_url = '/' + new\n",
"if not new.endswith('/'):\n",
"self.base_url = new + '/'\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Assign'"
] |
[
"def FUNC_25(self):...\n",
"self.other_id = '@zzsid1:red'\n",
"VAR_32 = '/rooms/%s/state/m.room.member/%s' % (urlparse.quote(self.room_id),\n self.other_id)\n",
"VAR_19 = '{\"membership\":\"%s\"}' % Membership.INVITE\n",
"VAR_22, VAR_23 = self.make_request('PUT', VAR_32, VAR_19)\n",
"self.assertEquals(200, VAR_23.code, msg=channel.result['body'])\n",
"VAR_22, VAR_23 = self.make_request('GET', VAR_32, None)\n",
"self.assertEquals(200, VAR_23.code, msg=channel.result['body'])\n",
"self.assertEquals(json.loads(VAR_19), VAR_23.json_body)\n"
] | [
"def test_rooms_members_other(self):...\n",
"self.other_id = '@zzsid1:red'\n",
"path = '/rooms/%s/state/m.room.member/%s' % (urlparse.quote(self.room_id),\n self.other_id)\n",
"content = '{\"membership\":\"%s\"}' % Membership.INVITE\n",
"request, channel = self.make_request('PUT', path, content)\n",
"self.assertEquals(200, channel.code, msg=channel.result['body'])\n",
"request, channel = self.make_request('GET', path, None)\n",
"self.assertEquals(200, channel.code, msg=channel.result['body'])\n",
"self.assertEquals(json.loads(content), channel.json_body)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_39(self, VAR_124=None, VAR_83=None, VAR_125=False, VAR_126=None,...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_101 = self.db\n",
"if VAR_126 is None:\n",
"VAR_126 = VAR_101._migrate\n",
"if VAR_127 is None:\n",
"VAR_127 = VAR_101._fake_migrate\n",
"VAR_222 = self.settings\n",
"VAR_222.enable_tokens = VAR_125\n",
"VAR_252 = super(CLASS_3, self).define_tables(VAR_124, VAR_83, VAR_126, VAR_127\n )._table_signature_list\n",
"VAR_193 = VAR_263.request.now\n",
"VAR_253 = 'reference %s' % VAR_222.table_user_name\n",
"if VAR_222.cas_domains:\n",
"if VAR_222.table_cas_name not in VAR_101.tables:\n",
"if VAR_222.enable_tokens:\n",
"VAR_101.define_table(VAR_222.table_cas_name, VAR_1('user_id', VAR_253,\n VAR_5=None, VAR_60=self.messages.label_user_id), VAR_1('created_on',\n 'datetime', VAR_5=now), VAR_1('service', VAR_279=IS_URL()), VAR_1(\n 'ticket'), VAR_1('renew', 'boolean', VAR_5=False), *VAR_222.\n extra_fields.get(VAR_222.table_cas_name, []), **dict(migrate=self.\n _get_migrate(settings.table_cas_name, migrate), fake_migrate=fake_migrate))\n",
"VAR_360 = VAR_222.extra_fields.get(VAR_222.table_token_name, []) + VAR_252\n",
"if not VAR_101._lazy_tables:\n",
"if VAR_222.table_token_name not in VAR_101.tables:\n",
"VAR_222.table_user = VAR_101[VAR_222.table_user_name]\n",
"if VAR_222.cas_provider:\n",
"VAR_101.define_table(VAR_222.table_token_name, VAR_1('user_id', VAR_253,\n VAR_5=None, VAR_60=self.messages.label_user_id), VAR_1('expires_on',\n 'datetime', VAR_5=datetime.datetime(2999, 12, 31)), VAR_1('token',\n writable=False, VAR_5=web2py_uuid, unique=True), *VAR_360, **dict(\n migrate=self._get_migrate(settings.table_token_name, migrate),\n fake_migrate=fake_migrate))\n",
"VAR_222.table_group = VAR_101[VAR_222.table_group_name]\n",
"VAR_222.actions_disabled = ['profile', 'register', 'change_password',\n 'request_reset_password', 'retrieve_username']\n",
"return self\n",
"VAR_222.table_membership = VAR_101[VAR_222.table_membership_name]\n",
"from gluon.contrib.login_methods.cas_auth import CasAuth\n",
"VAR_222.table_permission = VAR_101[VAR_222.table_permission_name]\n",
"VAR_361 = VAR_222.cas_maps\n",
"VAR_222.table_event = VAR_101[VAR_222.table_event_name]\n",
"if not VAR_361:\n",
"if VAR_222.cas_domains:\n",
"VAR_254 = self.table_user()\n",
"VAR_6 = [VAR_222.cas_actions['login'], VAR_222.cas_actions[\n 'servicevalidate'], VAR_222.cas_actions['logout']]\n",
"VAR_222.table_cas = VAR_101[VAR_222.table_cas_name]\n",
"VAR_361 = dict((VAR_148, lambda v, VAR_181=VAR_148: v.get(VAR_181, None)) for\n VAR_148 in VAR_254.fields if VAR_148 != 'id' and VAR_254[VAR_148].readable)\n",
"VAR_222.login_form = CasAuth(casversion=2, urlbase=settings.cas_provider,\n VAR_6=actions, VAR_361=maps)\n",
"VAR_361['registration_id'\n ] = lambda v, VAR_446=VAR_222.cas_provider: '%s/%s' % (VAR_446, v['user'])\n"
] | [
"def define_tables(self, username=None, signature=None, enable_tokens=False,...\n",
"\"\"\"docstring\"\"\"\n",
"db = self.db\n",
"if migrate is None:\n",
"migrate = db._migrate\n",
"if fake_migrate is None:\n",
"fake_migrate = db._fake_migrate\n",
"settings = self.settings\n",
"settings.enable_tokens = enable_tokens\n",
"signature_list = super(Auth, self).define_tables(username, signature,\n migrate, fake_migrate)._table_signature_list\n",
"now = current.request.now\n",
"reference_table_user = 'reference %s' % settings.table_user_name\n",
"if settings.cas_domains:\n",
"if settings.table_cas_name not in db.tables:\n",
"if settings.enable_tokens:\n",
"db.define_table(settings.table_cas_name, Field('user_id',\n reference_table_user, default=None, label=self.messages.label_user_id),\n Field('created_on', 'datetime', default=now), Field('service', requires\n =IS_URL()), Field('ticket'), Field('renew', 'boolean', default=False),\n *settings.extra_fields.get(settings.table_cas_name, []), **dict(migrate\n =self._get_migrate(settings.table_cas_name, migrate), fake_migrate=\n fake_migrate))\n",
"extra_fields = settings.extra_fields.get(settings.table_token_name, []\n ) + signature_list\n",
"if not db._lazy_tables:\n",
"if settings.table_token_name not in db.tables:\n",
"settings.table_user = db[settings.table_user_name]\n",
"if settings.cas_provider:\n",
"db.define_table(settings.table_token_name, Field('user_id',\n reference_table_user, default=None, label=self.messages.label_user_id),\n Field('expires_on', 'datetime', default=datetime.datetime(2999, 12, 31)\n ), Field('token', writable=False, default=web2py_uuid, unique=True), *\n extra_fields, **dict(migrate=self._get_migrate(settings.\n table_token_name, migrate), fake_migrate=fake_migrate))\n",
"settings.table_group = db[settings.table_group_name]\n",
"settings.actions_disabled = ['profile', 'register', 'change_password',\n 'request_reset_password', 'retrieve_username']\n",
"return self\n",
"settings.table_membership = db[settings.table_membership_name]\n",
"from gluon.contrib.login_methods.cas_auth import CasAuth\n",
"settings.table_permission = db[settings.table_permission_name]\n",
"maps = settings.cas_maps\n",
"settings.table_event = db[settings.table_event_name]\n",
"if not maps:\n",
"if settings.cas_domains:\n",
"table_user = self.table_user()\n",
"actions = [settings.cas_actions['login'], settings.cas_actions[\n 'servicevalidate'], settings.cas_actions['logout']]\n",
"settings.table_cas = db[settings.table_cas_name]\n",
"maps = dict((name, lambda v, n=name: v.get(n, None)) for name in table_user\n .fields if name != 'id' and table_user[name].readable)\n",
"settings.login_form = CasAuth(casversion=2, urlbase=settings.cas_provider,\n actions=actions, maps=maps)\n",
"maps['registration_id'] = lambda v, p=settings.cas_provider: '%s/%s' % (p,\n v['user'])\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
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2.session.modified = True\n",
"if VAR_27 == 'clean':\n",
"if 'jobKey' in VAR_2.POST:\n",
"return HttpResponse('OK')\n",
"VAR_198 = VAR_2.POST.get('jobKey')\n",
"VAR_199 = list(VAR_2.session['callback'].items())\n",
"VAR_172 = {}\n",
"for VAR_310, VAR_158 in VAR_199:\n",
"if VAR_198 in VAR_2.session['callback']:\n",
"if VAR_158['status'] != 'in progress':\n",
"VAR_2.session.modified = True\n",
"VAR_172['removed'] = False\n",
"VAR_172['removed'] = True\n",
"return JsonResponse(VAR_172)\n"
] | [
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"request.session.modified = True\n",
"if action == 'clean':\n",
"if 'jobKey' in request.POST:\n",
"return HttpResponse('OK')\n",
"jobId = request.POST.get('jobKey')\n",
"jobs = list(request.session['callback'].items())\n",
"rv = {}\n",
"for key, data in jobs:\n",
"if jobId in request.session['callback']:\n",
"if data['status'] != 'in progress':\n",
"request.session.modified = True\n",
"rv['removed'] = False\n",
"rv['removed'] = True\n",
"return JsonResponse(rv)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_10(self, VAR_27, VAR_28=None, VAR_29=None, VAR_15=None):...\n",
"VAR_42 = self.contexts.get('request')\n",
"return FUNC_10(VAR_27, VAR_28=domain, VAR_29=mapping, VAR_42=context,\n VAR_15=default)\n"
] | [
"def translate(self, msgid, domain=None, mapping=None, default=None):...\n",
"context = self.contexts.get('request')\n",
"return translate(msgid, domain=domain, mapping=mapping, context=context,\n default=default)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"@keep_lazy_text...\n",
"\"\"\"docstring\"\"\"\n",
"return force_text(quote_plus(force_str(VAR_14), force_str(VAR_15)))\n"
] | [
"@keep_lazy_text...\n",
"\"\"\"docstring\"\"\"\n",
"return force_text(quote_plus(force_str(url), force_str(safe)))\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"\"\"\"string\"\"\"\n",
"import argparse\n",
"import ast\n",
"import os\n",
"import re\n",
"import sys\n",
"from absl import app\n",
"import numpy as np\n",
"import six\n",
"from tensorflow.core.example import example_pb2\n",
"from tensorflow.core.framework import types_pb2\n",
"from tensorflow.core.protobuf import config_pb2\n",
"from tensorflow.python.client import session\n",
"from tensorflow.python.debug.wrappers import local_cli_wrapper\n",
"from tensorflow.python.eager import def_function\n",
"from tensorflow.python.eager import function as defun\n",
"from tensorflow.python.framework import meta_graph as meta_graph_lib\n",
"from tensorflow.python.framework import ops as ops_lib\n",
"from tensorflow.python.framework import tensor_spec\n",
"from tensorflow.python.lib.io import file_io\n",
"from tensorflow.python.platform import tf_logging as logging\n",
"from tensorflow.python.saved_model import load\n",
"from tensorflow.python.saved_model import loader\n",
"from tensorflow.python.saved_model import save\n",
"from tensorflow.python.saved_model import signature_constants\n",
"from tensorflow.python.tools import saved_model_aot_compile\n",
"from tensorflow.python.tools import saved_model_utils\n",
"from tensorflow.python.tpu import tpu\n",
"from tensorflow.python.util.compat import collections_abc\n",
"VAR_0 = (\n 'https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/xla/debug_options_flags.cc'\n )\n",
"VAR_1 = set(['WriteFile', 'ReadFile', 'PrintV2'])\n",
"def FUNC_0(VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_25 = saved_model_utils.get_saved_model_tag_sets(VAR_2)\n",
"print('The given SavedModel contains the following tag-sets:')\n",
"for VAR_3 in sorted(VAR_25):\n",
"print('%r' % ', '.join(sorted(VAR_3)))\n",
"def FUNC_1(VAR_2, VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_26 = FUNC_10(VAR_2, VAR_3)\n",
"print(\n 'The given SavedModel MetaGraphDef contains SignatureDefs with the following keys:'\n )\n",
"for VAR_5 in sorted(VAR_26.keys()):\n",
"print('SignatureDef key: \"%s\"' % VAR_5)\n",
"def FUNC_2(VAR_4, VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_5 not in VAR_4.signature_def:\n",
"return VAR_4.signature_def[VAR_5].inputs\n"
] | [
"\"\"\"Command-line interface to inspect and execute a graph in a SavedModel.\n\nFor detailed usages and examples, please refer to:\nhttps://www.tensorflow.org/guide/saved_model#cli_to_inspect_and_execute_savedmodel\n\n\"\"\"\n",
"import argparse\n",
"import ast\n",
"import os\n",
"import re\n",
"import sys\n",
"from absl import app\n",
"import numpy as np\n",
"import six\n",
"from tensorflow.core.example import example_pb2\n",
"from tensorflow.core.framework import types_pb2\n",
"from tensorflow.core.protobuf import config_pb2\n",
"from tensorflow.python.client import session\n",
"from tensorflow.python.debug.wrappers import local_cli_wrapper\n",
"from tensorflow.python.eager import def_function\n",
"from tensorflow.python.eager import function as defun\n",
"from tensorflow.python.framework import meta_graph as meta_graph_lib\n",
"from tensorflow.python.framework import ops as ops_lib\n",
"from tensorflow.python.framework import tensor_spec\n",
"from tensorflow.python.lib.io import file_io\n",
"from tensorflow.python.platform import tf_logging as logging\n",
"from tensorflow.python.saved_model import load\n",
"from tensorflow.python.saved_model import loader\n",
"from tensorflow.python.saved_model import save\n",
"from tensorflow.python.saved_model import signature_constants\n",
"from tensorflow.python.tools import saved_model_aot_compile\n",
"from tensorflow.python.tools import saved_model_utils\n",
"from tensorflow.python.tpu import tpu\n",
"from tensorflow.python.util.compat import collections_abc\n",
"_XLA_DEBUG_OPTIONS_URL = (\n 'https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/xla/debug_options_flags.cc'\n )\n",
"_OP_DENYLIST = set(['WriteFile', 'ReadFile', 'PrintV2'])\n",
"def _show_tag_sets(saved_model_dir):...\n",
"\"\"\"docstring\"\"\"\n",
"tag_sets = saved_model_utils.get_saved_model_tag_sets(saved_model_dir)\n",
"print('The given SavedModel contains the following tag-sets:')\n",
"for tag_set in sorted(tag_sets):\n",
"print('%r' % ', '.join(sorted(tag_set)))\n",
"def _show_signature_def_map_keys(saved_model_dir, tag_set):...\n",
"\"\"\"docstring\"\"\"\n",
"signature_def_map = get_signature_def_map(saved_model_dir, tag_set)\n",
"print(\n 'The given SavedModel MetaGraphDef contains SignatureDefs with the following keys:'\n )\n",
"for signature_def_key in sorted(signature_def_map.keys()):\n",
"print('SignatureDef key: \"%s\"' % signature_def_key)\n",
"def _get_inputs_tensor_info_from_meta_graph_def(meta_graph_def,...\n",
"\"\"\"docstring\"\"\"\n",
"if signature_def_key not in meta_graph_def.signature_def:\n",
"return meta_graph_def.signature_def[signature_def_key].inputs\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
] | [
"Expr'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"For",
"Expr'",
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"For",
"Expr'",
"FunctionDef'",
"Docstring",
"Condition",
"Return'"
] |
[
"def FUNC_8(self, VAR_56):...\n",
"\"\"\"docstring\"\"\"\n",
"return False\n"
] | [
"def allow_follow(self, anchor):...\n",
"\"\"\"docstring\"\"\"\n",
"return False\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_9(VAR_12, VAR_1):...\n",
""
] | [
"def migrate_shelfs(engine, session):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_23 in ('share', 'discussion'):\n",
"return handlerInternalError(VAR_2, x)\n",
"VAR_126 = None\n",
"VAR_54 = 'webclient/annotations/annotations_share.html'\n",
"VAR_54 = 'webclient/annotations/metadata_acquisition.html'\n",
"VAR_127 = None\n",
"VAR_104 = BaseShare(VAR_5, VAR_24)\n",
"VAR_104 = BaseContainer(VAR_5, **{str(c_type): long(c_id)})\n",
"VAR_128 = None\n",
"VAR_104.getAllUsers(VAR_24)\n",
"VAR_129 = list()\n",
"VAR_104.getComments(VAR_24)\n",
"VAR_130 = None\n",
"VAR_131 = list()\n",
"VAR_132 = list()\n",
"VAR_133 = list()\n",
"VAR_134 = list()\n",
"VAR_135 = list()\n",
"VAR_136 = list(VAR_5.getEnumerationEntries('LaserType'))\n",
"VAR_137 = list(VAR_5.getEnumerationEntries('ArcType'))\n",
"VAR_138 = list(VAR_5.getEnumerationEntries('FilamentType'))\n",
"VAR_139 = None\n",
"VAR_140 = None\n",
"VAR_141 = None\n",
"if VAR_23 == 'image':\n",
"if VAR_25 is None:\n",
"VAR_53 = {'manager': VAR_104, 'share_id': VAR_25}\n",
"VAR_104.companionFiles()\n",
"VAR_104.channelMetadata()\n",
"if VAR_23 not in ('share', 'discussion', 'tag'):\n",
"for theC, ch in enumerate(VAR_104.channel_metadata):\n",
"VAR_53['form_channels'] = VAR_134\n",
"VAR_53['template'] = VAR_54\n",
"VAR_351 = ch.getLogicalChannel()\n",
"VAR_142 = VAR_104.well.getWellSample().image()\n",
"VAR_142 = VAR_104.image\n",
"if VAR_25 is None:\n",
"VAR_53['form_environment'] = VAR_126\n",
"return VAR_53\n",
"if VAR_351 is not None:\n",
"if VAR_142.getObjectiveSettings() is not None:\n",
"VAR_53['form_objective'] = VAR_127\n",
"VAR_391 = dict()\n",
"if VAR_139 is None:\n",
"if VAR_142.getImagingEnvironment() is not None:\n",
"VAR_53['form_microscope'] = VAR_128\n",
"VAR_391['form'] = MetadataChannelForm(VAR_115={'logicalChannel':\n logicalChannel, 'exWave': ch.getExcitationWave(units=True), 'emWave':\n ch.getEmissionWave(units=True), 'illuminations': list(conn.\n getEnumerationEntries('IlluminationI')), 'contrastMethods': list(conn.\n getEnumerationEntries('ContrastMethodI')), 'modes': list(conn.\n getEnumerationEntries('AcquisitionModeI'))})\n",
"VAR_139 = list(VAR_5.getEnumerationEntries('MediumI'))\n",
"if VAR_140 is None:\n",
"VAR_126 = MetadataEnvironmentForm(VAR_115={'image': image})\n",
"if VAR_142.getStageLabel() is not None:\n",
"VAR_53['form_instrument_objectives'] = VAR_129\n",
"if VAR_25 is None:\n",
"VAR_140 = list(VAR_5.getEnumerationEntries('ImmersionI'))\n",
"if VAR_141 is None:\n",
"VAR_130 = MetadataStageLabelForm(VAR_115={'image': image})\n",
"VAR_352 = VAR_142.getInstrument()\n",
"VAR_53['form_filters'] = VAR_131\n",
"VAR_424 = VAR_351.getLightPath()\n",
"VAR_391['label'] = ch.getLabel()\n",
"VAR_141 = list(VAR_5.getEnumerationEntries('CorrectionI'))\n",
"VAR_127 = MetadataObjectiveSettingsForm(VAR_115={'objectiveSettings': image\n .getObjectiveSettings(), 'objective': image.getObjectiveSettings().\n getObjective(), 'mediums': mediums, 'immersions': immersions,\n 'corrections': corrections})\n",
"if VAR_352 is not None:\n",
"VAR_53['form_dichroics'] = VAR_132\n",
"if VAR_424 is not None:\n",
"VAR_349 = ch.getColor()\n",
"if VAR_352.getMicroscope() is not None:\n",
"VAR_53['form_detectors'] = VAR_133\n",
"VAR_391['form_dichroic'] = None\n",
"VAR_425 = VAR_351.getDetectorSettings()\n",
"VAR_391['color'] = VAR_349 is not None and VAR_349.getHtml() or None\n",
"VAR_128 = MetadataMicroscopeForm(VAR_115={'microscopeTypes': list(conn.\n getEnumerationEntries('MicroscopeTypeI')), 'microscope': instrument.\n getMicroscope()})\n",
"VAR_394 = VAR_352.getObjectives()\n",
"VAR_53['form_lasers'] = VAR_135\n",
"VAR_391['form_excitation_filters'] = list()\n",
"if VAR_425._obj is not None and VAR_425.getDetector():\n",
"VAR_392 = VAR_104.image and VAR_104.image.getPrimaryPixels().copyPlaneInfo(theC\n =theC, theZ=0)\n",
"for o in VAR_394:\n",
"VAR_53['form_stageLabel'] = VAR_130\n",
"VAR_391['form_emission_filters'] = list()\n",
"VAR_391['form_detector_settings'] = MetadataDetectorForm(VAR_115={\n 'detectorSettings': detectorSettings, 'detector': detectorSettings.\n getDetector(), 'types': list(conn.getEnumerationEntries('DetectorTypeI'\n )), 'binnings': list(conn.getEnumerationEntries('Binning'))})\n",
"VAR_426 = VAR_351.getLightSourceSettings()\n",
"VAR_393 = []\n",
"if VAR_139 is None:\n",
"VAR_395 = list(VAR_352.getFilters())\n",
"VAR_434 = VAR_424.getDichroic()\n",
"if VAR_426 is not None and VAR_426._obj is not None:\n",
"for pi in VAR_392:\n",
"VAR_139 = list(VAR_5.getEnumerationEntries('MediumI'))\n",
"if VAR_140 is None:\n",
"if len(VAR_395) > 0:\n",
"if VAR_434 is not None:\n",
"VAR_436 = VAR_426.getLightSource()\n",
"VAR_427 = pi.getDeltaT(units='SECOND')\n",
"VAR_391['plane_info'] = VAR_393\n",
"VAR_140 = list(VAR_5.getEnumerationEntries('ImmersionI'))\n",
"if VAR_141 is None:\n",
"for f in VAR_395:\n",
"VAR_396 = list(VAR_352.getDichroics())\n",
"VAR_391['form_dichroic'] = MetadataDichroicForm(VAR_115={'dichroic':\n lightPathDichroic})\n",
"VAR_435 = list(VAR_5.getEnumerationEntries('FilterTypeI'))\n",
"if VAR_436 is not None:\n",
"VAR_428 = pi.getExposureTime(units='SECOND')\n",
"VAR_134.append(VAR_391)\n",
"VAR_141 = list(VAR_5.getEnumerationEntries('CorrectionI'))\n",
"VAR_429 = MetadataObjectiveForm(VAR_115={'objective': o, 'mediums': mediums,\n 'immersions': immersions, 'corrections': corrections})\n",
"VAR_437 = MetadataFilterForm(VAR_115={'filter': f, 'types': list(conn.\n getEnumerationEntries('FilterTypeI'))})\n",
"for VAR_362 in VAR_396:\n",
"for f in VAR_424.getEmissionFilters():\n",
"VAR_439 = VAR_136\n",
"if VAR_427 is None and VAR_428 is None:\n",
"VAR_129.append(VAR_429)\n",
"VAR_131.append(VAR_437)\n",
"VAR_430 = MetadataDichroicForm(VAR_115={'dichroic': d})\n",
"VAR_397 = list(VAR_352.getDetectors())\n",
"VAR_391['form_emission_filters'].append(MetadataFilterForm(VAR_115={\n 'filter': f, 'types': filterTypes}))\n",
"for f in VAR_424.getExcitationFilters():\n",
"if VAR_436.OMERO_CLASS == 'Arc':\n",
"if VAR_427 is not None:\n",
"VAR_132.append(VAR_430)\n",
"if len(VAR_397) > 0:\n",
"VAR_391['form_excitation_filters'].append(MetadataFilterForm(VAR_115={\n 'filter': f, 'types': filterTypes}))\n",
"VAR_439 = VAR_137\n",
"if VAR_436.OMERO_CLASS == 'Filament':\n",
"VAR_427 = VAR_427.getValue()\n",
"if VAR_428 is not None:\n",
"for VAR_362 in VAR_397:\n",
"VAR_398 = list(VAR_352.getLightSources())\n",
"VAR_391['form_light_source'] = MetadataLightSourceForm(VAR_115={\n 'lightSource': lightSrc, 'lightSourceSettings': lightSourceSettings,\n 'lstypes': lstypes, 'mediums': list(conn.getEnumerationEntries(\n 'LaserMediumI')), 'pulses': list(conn.getEnumerationEntries('PulseI'))})\n",
"VAR_439 = VAR_138\n",
"VAR_428 = VAR_428.getValue()\n",
"VAR_393.append({'theT': pi.theT, 'deltaT': VAR_427, 'exposureTime': VAR_428})\n",
"VAR_438 = MetadataDetectorForm(VAR_115={'detectorSettings': None,\n 'detector': d, 'types': list(conn.getEnumerationEntries('DetectorTypeI'))})\n",
"if len(VAR_398) > 0:\n",
"VAR_133.append(VAR_438)\n",
"for laser in VAR_398:\n",
"VAR_439 = VAR_136\n",
"if laser.OMERO_CLASS == 'Arc':\n",
"VAR_439 = VAR_137\n",
"if laser.OMERO_CLASS == 'Filament':\n",
"VAR_440 = MetadataLightSourceForm(VAR_115={'lightSource': laser, 'lstypes':\n lstypes, 'mediums': list(conn.getEnumerationEntries('LaserMediumI')),\n 'pulses': list(conn.getEnumerationEntries('PulseI'))})\n",
"VAR_439 = VAR_138\n",
"VAR_135.append(VAR_440)\n"
] | [
"@login_required()...\n",
"\"\"\"docstring\"\"\"\n",
"if c_type in ('share', 'discussion'):\n",
"return handlerInternalError(request, x)\n",
"form_environment = None\n",
"template = 'webclient/annotations/annotations_share.html'\n",
"template = 'webclient/annotations/metadata_acquisition.html'\n",
"form_objective = None\n",
"manager = BaseShare(conn, c_id)\n",
"manager = BaseContainer(conn, **{str(c_type): long(c_id)})\n",
"form_microscope = None\n",
"manager.getAllUsers(c_id)\n",
"form_instrument_objectives = list()\n",
"manager.getComments(c_id)\n",
"form_stageLabel = None\n",
"form_filters = list()\n",
"form_dichroics = list()\n",
"form_detectors = list()\n",
"form_channels = list()\n",
"form_lasers = list()\n",
"lasertypes = list(conn.getEnumerationEntries('LaserType'))\n",
"arctypes = list(conn.getEnumerationEntries('ArcType'))\n",
"filamenttypes = list(conn.getEnumerationEntries('FilamentType'))\n",
"mediums = None\n",
"immersions = None\n",
"corrections = None\n",
"if c_type == 'image':\n",
"if share_id is None:\n",
"context = {'manager': manager, 'share_id': share_id}\n",
"manager.companionFiles()\n",
"manager.channelMetadata()\n",
"if c_type not in ('share', 'discussion', 'tag'):\n",
"for theC, ch in enumerate(manager.channel_metadata):\n",
"context['form_channels'] = form_channels\n",
"context['template'] = template\n",
"logicalChannel = ch.getLogicalChannel()\n",
"image = manager.well.getWellSample().image()\n",
"image = manager.image\n",
"if share_id is None:\n",
"context['form_environment'] = form_environment\n",
"return context\n",
"if logicalChannel is not None:\n",
"if image.getObjectiveSettings() is not None:\n",
"context['form_objective'] = form_objective\n",
"channel = dict()\n",
"if mediums is None:\n",
"if image.getImagingEnvironment() is not None:\n",
"context['form_microscope'] = form_microscope\n",
"channel['form'] = MetadataChannelForm(initial={'logicalChannel':\n logicalChannel, 'exWave': ch.getExcitationWave(units=True), 'emWave':\n ch.getEmissionWave(units=True), 'illuminations': list(conn.\n getEnumerationEntries('IlluminationI')), 'contrastMethods': list(conn.\n getEnumerationEntries('ContrastMethodI')), 'modes': list(conn.\n getEnumerationEntries('AcquisitionModeI'))})\n",
"mediums = list(conn.getEnumerationEntries('MediumI'))\n",
"if immersions is None:\n",
"form_environment = MetadataEnvironmentForm(initial={'image': image})\n",
"if image.getStageLabel() is not None:\n",
"context['form_instrument_objectives'] = form_instrument_objectives\n",
"if share_id is None:\n",
"immersions = list(conn.getEnumerationEntries('ImmersionI'))\n",
"if corrections is None:\n",
"form_stageLabel = MetadataStageLabelForm(initial={'image': image})\n",
"instrument = image.getInstrument()\n",
"context['form_filters'] = form_filters\n",
"lightPath = logicalChannel.getLightPath()\n",
"channel['label'] = ch.getLabel()\n",
"corrections = list(conn.getEnumerationEntries('CorrectionI'))\n",
"form_objective = MetadataObjectiveSettingsForm(initial={'objectiveSettings':\n image.getObjectiveSettings(), 'objective': image.getObjectiveSettings()\n .getObjective(), 'mediums': mediums, 'immersions': immersions,\n 'corrections': corrections})\n",
"if instrument is not None:\n",
"context['form_dichroics'] = form_dichroics\n",
"if lightPath is not None:\n",
"color = ch.getColor()\n",
"if instrument.getMicroscope() is not None:\n",
"context['form_detectors'] = form_detectors\n",
"channel['form_dichroic'] = None\n",
"detectorSettings = logicalChannel.getDetectorSettings()\n",
"channel['color'] = color is not None and color.getHtml() or None\n",
"form_microscope = MetadataMicroscopeForm(initial={'microscopeTypes': list(\n conn.getEnumerationEntries('MicroscopeTypeI')), 'microscope':\n instrument.getMicroscope()})\n",
"objectives = instrument.getObjectives()\n",
"context['form_lasers'] = form_lasers\n",
"channel['form_excitation_filters'] = list()\n",
"if detectorSettings._obj is not None and detectorSettings.getDetector():\n",
"planeInfo = manager.image and manager.image.getPrimaryPixels().copyPlaneInfo(\n theC=theC, theZ=0)\n",
"for o in objectives:\n",
"context['form_stageLabel'] = form_stageLabel\n",
"channel['form_emission_filters'] = list()\n",
"channel['form_detector_settings'] = MetadataDetectorForm(initial={\n 'detectorSettings': detectorSettings, 'detector': detectorSettings.\n getDetector(), 'types': list(conn.getEnumerationEntries('DetectorTypeI'\n )), 'binnings': list(conn.getEnumerationEntries('Binning'))})\n",
"lightSourceSettings = logicalChannel.getLightSourceSettings()\n",
"plane_info = []\n",
"if mediums is None:\n",
"filters = list(instrument.getFilters())\n",
"lightPathDichroic = lightPath.getDichroic()\n",
"if lightSourceSettings is not None and lightSourceSettings._obj is not None:\n",
"for pi in planeInfo:\n",
"mediums = list(conn.getEnumerationEntries('MediumI'))\n",
"if immersions is None:\n",
"if len(filters) > 0:\n",
"if lightPathDichroic is not None:\n",
"lightSrc = lightSourceSettings.getLightSource()\n",
"deltaT = pi.getDeltaT(units='SECOND')\n",
"channel['plane_info'] = plane_info\n",
"immersions = list(conn.getEnumerationEntries('ImmersionI'))\n",
"if corrections is None:\n",
"for f in filters:\n",
"dichroics = list(instrument.getDichroics())\n",
"channel['form_dichroic'] = MetadataDichroicForm(initial={'dichroic':\n lightPathDichroic})\n",
"filterTypes = list(conn.getEnumerationEntries('FilterTypeI'))\n",
"if lightSrc is not None:\n",
"exposure = pi.getExposureTime(units='SECOND')\n",
"form_channels.append(channel)\n",
"corrections = list(conn.getEnumerationEntries('CorrectionI'))\n",
"obj_form = MetadataObjectiveForm(initial={'objective': o, 'mediums':\n mediums, 'immersions': immersions, 'corrections': corrections})\n",
"form_filter = MetadataFilterForm(initial={'filter': f, 'types': list(conn.\n getEnumerationEntries('FilterTypeI'))})\n",
"for d in dichroics:\n",
"for f in lightPath.getEmissionFilters():\n",
"lstypes = lasertypes\n",
"if deltaT is None and exposure is None:\n",
"form_instrument_objectives.append(obj_form)\n",
"form_filters.append(form_filter)\n",
"form_dichroic = MetadataDichroicForm(initial={'dichroic': d})\n",
"detectors = list(instrument.getDetectors())\n",
"channel['form_emission_filters'].append(MetadataFilterForm(initial={\n 'filter': f, 'types': filterTypes}))\n",
"for f in lightPath.getExcitationFilters():\n",
"if lightSrc.OMERO_CLASS == 'Arc':\n",
"if deltaT is not None:\n",
"form_dichroics.append(form_dichroic)\n",
"if len(detectors) > 0:\n",
"channel['form_excitation_filters'].append(MetadataFilterForm(initial={\n 'filter': f, 'types': filterTypes}))\n",
"lstypes = arctypes\n",
"if lightSrc.OMERO_CLASS == 'Filament':\n",
"deltaT = deltaT.getValue()\n",
"if exposure is not None:\n",
"for d in detectors:\n",
"lasers = list(instrument.getLightSources())\n",
"channel['form_light_source'] = MetadataLightSourceForm(initial={\n 'lightSource': lightSrc, 'lightSourceSettings': lightSourceSettings,\n 'lstypes': lstypes, 'mediums': list(conn.getEnumerationEntries(\n 'LaserMediumI')), 'pulses': list(conn.getEnumerationEntries('PulseI'))})\n",
"lstypes = filamenttypes\n",
"exposure = exposure.getValue()\n",
"plane_info.append({'theT': pi.theT, 'deltaT': deltaT, 'exposureTime': exposure}\n )\n",
"form_detector = MetadataDetectorForm(initial={'detectorSettings': None,\n 'detector': d, 'types': list(conn.getEnumerationEntries('DetectorTypeI'))})\n",
"if len(lasers) > 0:\n",
"form_detectors.append(form_detector)\n",
"for laser in lasers:\n",
"lstypes = lasertypes\n",
"if laser.OMERO_CLASS == 'Arc':\n",
"lstypes = arctypes\n",
"if laser.OMERO_CLASS == 'Filament':\n",
"form_laser = MetadataLightSourceForm(initial={'lightSource': laser,\n 'lstypes': lstypes, 'mediums': list(conn.getEnumerationEntries(\n 'LaserMediumI')), 'pulses': list(conn.getEnumerationEntries('PulseI'))})\n",
"lstypes = filamenttypes\n",
"form_lasers.append(form_laser)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"For",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"For",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"For",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"For",
"For",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"For",
"Condition",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"For",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"For",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_8(self, VAR_10):...\n",
"\"\"\"docstring\"\"\"\n",
"frappe.flags.error_message = _('Insufficient Permission for {0}').format(self\n .doctype)\n"
] | [
"def raise_no_permission_to(self, perm_type):...\n",
"\"\"\"docstring\"\"\"\n",
"frappe.flags.error_message = _('Insufficient Permission for {0}').format(self\n .doctype)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'"
] |
[
"def FUNC_9(self):...\n",
"assert get_param_tuples('<int:id>') == [('int', 'id')]\n"
] | [
"def test_it_works(self):...\n",
"assert get_param_tuples('<int:id>') == [('int', 'id')]\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assert'"
] |
[
"def FUNC_9(self, VAR_0, VAR_13):...\n",
"VAR_30 = VAR_0 / 'foo&bar'\n",
"VAR_30.ensure()\n",
"VAR_25 = VAR_13(str(VAR_0))\n",
"VAR_8 = self.Item(FUNC_1(VAR_30), VAR_30.relto(VAR_0))\n",
"assert VAR_25.files == [VAR_8]\n"
] | [
"def test_html_special_chars(self, tmpdir, parser):...\n",
"special_file = tmpdir / 'foo&bar'\n",
"special_file.ensure()\n",
"parsed = parser(str(tmpdir))\n",
"item = self.Item(_file_url(special_file), special_file.relto(tmpdir))\n",
"assert parsed.files == [item]\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assert'"
] |
[
"def FUNC_53(VAR_2, VAR_42, VAR_8=None, VAR_43=None, VAR_44=False, **VAR_9):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_43 is None:\n",
"VAR_43 = VAR_2.GET.get('query')\n",
"if not VAR_43:\n",
"return dict(VAR_176='Must specify query parameter, use * to retrieve all')\n",
"VAR_166 = VAR_2.GET.getlist('col_names')\n",
"VAR_24 = VAR_8.createServiceOptsDict()\n",
"VAR_24.setOmeroGroup('-1')\n",
"VAR_53 = VAR_8.getSharedResources()\n",
"VAR_23 = VAR_53.openTable(omero.model.OriginalFileI(VAR_42), VAR_24)\n",
"if not VAR_23:\n",
"return dict(VAR_176='Table %s not found' % fileid)\n",
"VAR_251 = VAR_23.getHeaders()\n",
"if not VAR_44:\n",
"VAR_252 = range(len(VAR_251))\n",
"VAR_23.close()\n",
"if VAR_166:\n",
"VAR_296 = [(VAR_212, j) for VAR_212, j in enumerate(VAR_251) if j.name in\n VAR_166] if VAR_166 else [(VAR_212, j) for VAR_212, j in enumerate(VAR_251)\n ]\n",
"VAR_253 = VAR_23.getNumberOfRows()\n",
"VAR_251 = []\n",
"VAR_254 = VAR_9.get('offset', 0)\n",
"VAR_252 = []\n",
"VAR_255 = VAR_9.get('limit', None)\n",
"for col_name in VAR_166:\n",
"if not VAR_254:\n",
"for VAR_212, j in VAR_296:\n",
"VAR_254 = int(VAR_2.GET.get('offset', 0))\n",
"if not VAR_255:\n",
"if col_name == j.name:\n",
"VAR_255 = int(VAR_2.GET.get('limit')) if VAR_2.GET.get('limit'\n ) is not None else None\n",
"VAR_256 = VAR_254\n",
"VAR_252.append(VAR_212)\n",
"VAR_257 = VAR_9.get('limit', VAR_253)\n",
"VAR_251.append(j)\n",
"VAR_258 = min(VAR_253, VAR_256 + VAR_257)\n",
"if VAR_43 == '*':\n",
"VAR_297 = range(VAR_256, VAR_258)\n",
"VAR_299 = re.match('^(\\\\w+)-(\\\\d+)', VAR_43)\n",
"VAR_298 = VAR_253\n",
"if VAR_299:\n",
"def FUNC_78(VAR_259, VAR_11):...\n",
"VAR_43 = '(%s==%s)' % (VAR_299.group(1), VAR_299.group(2))\n",
"VAR_1.info(VAR_43)\n",
"return dict(VAR_176='Error executing query: %s' % query)\n",
"VAR_300 = 0\n",
"VAR_297 = VAR_23.getWhereList(VAR_43, None, 0, VAR_253, 1)\n",
"VAR_301 = 1000\n",
"VAR_298 = len(VAR_297)\n",
"while VAR_300 < len(VAR_11):\n",
"VAR_297 = VAR_297[VAR_256:VAR_258]\n",
"VAR_301 = min(VAR_301, len(VAR_11) - VAR_300)\n",
"VAR_260 = FUNC_78(VAR_23, VAR_297)\n",
"VAR_322 = VAR_259.slice(VAR_252, VAR_11[VAR_300:VAR_300 + VAR_301])\n",
"VAR_261 = {'data': {'column_types': [col.__class__.__name__ for col in\n VAR_251], 'columns': [col.name for col in VAR_251]}, 'meta': {\n 'rowCount': VAR_253, 'totalCount': VAR_298, 'limit': VAR_255, 'offset':\n VAR_254}}\n",
"VAR_300 += VAR_301\n",
"if not VAR_44:\n",
"yield [[col.values[row] for col in VAR_322.columns] for row in range(0, len\n (VAR_322.rowNumbers))]\n",
"VAR_302 = []\n",
"VAR_261['data']['lazy_rows'] = VAR_260\n",
"for VAR_253 in list(VAR_260):\n",
"VAR_261['table'] = VAR_23\n",
"VAR_302.extend(VAR_253)\n",
"VAR_261['data']['rows'] = VAR_302\n",
"return VAR_261\n"
] | [
"def _table_query(request, fileid, conn=None, query=None, lazy=False, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"if query is None:\n",
"query = request.GET.get('query')\n",
"if not query:\n",
"return dict(error='Must specify query parameter, use * to retrieve all')\n",
"col_names = request.GET.getlist('col_names')\n",
"ctx = conn.createServiceOptsDict()\n",
"ctx.setOmeroGroup('-1')\n",
"r = conn.getSharedResources()\n",
"t = r.openTable(omero.model.OriginalFileI(fileid), ctx)\n",
"if not t:\n",
"return dict(error='Table %s not found' % fileid)\n",
"cols = t.getHeaders()\n",
"if not lazy:\n",
"col_indices = range(len(cols))\n",
"t.close()\n",
"if col_names:\n",
"enumerated_columns = [(i, j) for i, j in enumerate(cols) if j.name in col_names\n ] if col_names else [(i, j) for i, j in enumerate(cols)]\n",
"rows = t.getNumberOfRows()\n",
"cols = []\n",
"offset = kwargs.get('offset', 0)\n",
"col_indices = []\n",
"limit = kwargs.get('limit', None)\n",
"for col_name in col_names:\n",
"if not offset:\n",
"for i, j in enumerated_columns:\n",
"offset = int(request.GET.get('offset', 0))\n",
"if not limit:\n",
"if col_name == j.name:\n",
"limit = int(request.GET.get('limit')) if request.GET.get('limit'\n ) is not None else None\n",
"range_start = offset\n",
"col_indices.append(i)\n",
"range_size = kwargs.get('limit', rows)\n",
"cols.append(j)\n",
"range_end = min(rows, range_start + range_size)\n",
"if query == '*':\n",
"hits = range(range_start, range_end)\n",
"match = re.match('^(\\\\w+)-(\\\\d+)', query)\n",
"totalCount = rows\n",
"if match:\n",
"def row_generator(table, h):...\n",
"query = '(%s==%s)' % (match.group(1), match.group(2))\n",
"logger.info(query)\n",
"return dict(error='Error executing query: %s' % query)\n",
"idx = 0\n",
"hits = t.getWhereList(query, None, 0, rows, 1)\n",
"batch = 1000\n",
"totalCount = len(hits)\n",
"while idx < len(h):\n",
"hits = hits[range_start:range_end]\n",
"batch = min(batch, len(h) - idx)\n",
"row_gen = row_generator(t, hits)\n",
"res = table.slice(col_indices, h[idx:idx + batch])\n",
"rsp_data = {'data': {'column_types': [col.__class__.__name__ for col in\n cols], 'columns': [col.name for col in cols]}, 'meta': {'rowCount':\n rows, 'totalCount': totalCount, 'limit': limit, 'offset': offset}}\n",
"idx += batch\n",
"if not lazy:\n",
"yield [[col.values[row] for col in res.columns] for row in range(0, len(res\n .rowNumbers))]\n",
"row_data = []\n",
"rsp_data['data']['lazy_rows'] = row_gen\n",
"for rows in list(row_gen):\n",
"rsp_data['table'] = t\n",
"row_data.extend(rows)\n",
"rsp_data['data']['rows'] = row_data\n",
"return rsp_data\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,
4,
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
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"For",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"FunctionDef'",
"Assign'",
"Expr'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"AugAssign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_166(VAR_215, VAR_309, VAR_37=None, VAR_17=None):...\n",
"VAR_394 = {'code': VAR_309}\n",
"if VAR_309 in CLASS_5.jsonrpc_errors:\n",
"VAR_394['message'] = CLASS_5.jsonrpc_errors[VAR_309][0]\n",
"if VAR_37 is not None:\n",
"VAR_394['data'] = CLASS_5.jsonrpc_errors[VAR_309][1]\n",
"VAR_394['message'] = VAR_37\n",
"if VAR_17 is not None:\n",
"VAR_394['data'] = VAR_17\n",
"return serializers.json({'jsonrpc': '2.0', 'id': VAR_215, 'error': VAR_394})\n"
] | [
"def return_error(id, code, message=None, data=None):...\n",
"error = {'code': code}\n",
"if code in Service.jsonrpc_errors:\n",
"error['message'] = Service.jsonrpc_errors[code][0]\n",
"if message is not None:\n",
"error['data'] = Service.jsonrpc_errors[code][1]\n",
"error['message'] = message\n",
"if data is not None:\n",
"error['data'] = data\n",
"return serializers.json({'jsonrpc': '2.0', 'id': id, 'error': error})\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_3(VAR_10, *VAR_11):...\n",
"if callable(VAR_10):\n",
"redirect(VAR_10(*VAR_11))\n",
"redirect(VAR_10)\n"
] | [
"def call_or_redirect(f, *args):...\n",
"if callable(f):\n",
"redirect(f(*args))\n",
"redirect(f)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_11(self):...\n",
"VAR_15 = {'display_name': 'new_display'}\n",
"self.get_failure(self.handler.update_device('user_id', 'unknown_device_id',\n VAR_15), synapse.api.errors.NotFoundError)\n"
] | [
"def test_update_unknown_device(self):...\n",
"update = {'display_name': 'new_display'}\n",
"self.get_failure(self.handler.update_device('user_id', 'unknown_device_id',\n update), synapse.api.errors.NotFoundError)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"@FUNC_0...\n",
"return PaginationHandler(self)\n"
] | [
"@cache_in_self...\n",
"return PaginationHandler(self)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_16(VAR_24: Fingerprint, VAR_43: Text, VAR_37: Text, VAR_44:...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_43 = create_output_path(VAR_43, prefix=model_prefix, fixed_name=\n fixed_model_name)\n",
"FUNC_5(VAR_37, VAR_43, VAR_24)\n",
"print_success(\"Your Rasa model is trained and saved at '{}'.\".format(os.\n path.abspath(VAR_43)))\n",
"return VAR_43\n"
] | [
"def package_model(fingerprint: Fingerprint, output_directory: Text,...\n",
"\"\"\"docstring\"\"\"\n",
"output_directory = create_output_path(output_directory, prefix=model_prefix,\n fixed_name=fixed_model_name)\n",
"create_package_rasa(train_path, output_directory, fingerprint)\n",
"print_success(\"Your Rasa model is trained and saved at '{}'.\".format(os.\n path.abspath(output_directory)))\n",
"return output_directory\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"\"\"\" Generate modern Python clients from OpenAPI \"\"\"\n",
"from __future__ import annotations\n",
"import shutil\n",
"import subprocess\n",
"import sys\n",
"from pathlib import Path\n",
"from typing import Any, Dict, Optional, Sequence, Union\n",
"import httpcore\n",
"import httpx\n",
"import yaml\n",
"from jinja2 import Environment, PackageLoader\n",
"from openapi_python_client import utils\n",
"from .parser import GeneratorData, import_string_from_reference\n",
"from .parser.errors import GeneratorError\n",
"if sys.version_info.minor == 7:\n",
"from importlib_metadata import version\n",
"from importlib.metadata import version\n",
"__version__ = version(__package__)\n",
"def FUNC_0(VAR_0: Optional[str], VAR_1: Optional[Path]) ->Union[CLASS_0,...\n",
"VAR_2 = FUNC_3(VAR_0=url, VAR_1=path)\n",
"if isinstance(VAR_2, GeneratorError):\n",
"return VAR_2\n",
"VAR_3 = GeneratorData.from_dict(VAR_2)\n",
"if isinstance(VAR_3, GeneratorError):\n",
"return VAR_3\n",
"return CLASS_0(VAR_3=openapi)\n"
] | [
"\"\"\" Generate modern Python clients from OpenAPI \"\"\"\n",
"from __future__ import annotations\n",
"import shutil\n",
"import subprocess\n",
"import sys\n",
"from pathlib import Path\n",
"from typing import Any, Dict, Optional, Sequence, Union\n",
"import httpcore\n",
"import httpx\n",
"import yaml\n",
"from jinja2 import Environment, PackageLoader\n",
"from openapi_python_client import utils\n",
"from .parser import GeneratorData, import_string_from_reference\n",
"from .parser.errors import GeneratorError\n",
"if sys.version_info.minor == 7:\n",
"from importlib_metadata import version\n",
"from importlib.metadata import version\n",
"__version__ = version(__package__)\n",
"def _get_project_for_url_or_path(url: Optional[str], path: Optional[Path]...\n",
"data_dict = _get_document(url=url, path=path)\n",
"if isinstance(data_dict, GeneratorError):\n",
"return data_dict\n",
"openapi = GeneratorData.from_dict(data_dict)\n",
"if isinstance(openapi, GeneratorError):\n",
"return openapi\n",
"return Project(openapi=openapi)\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
] | [
"Expr'",
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Condition",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_28(self, VAR_27):...\n",
"return [entry.to_dict() for entry in self.playlistdb.loadPlaylist(VAR_27=\n playlistid, VAR_15=self.getUserId())]\n"
] | [
"def api_loadplaylist(self, playlistid):...\n",
"return [entry.to_dict() for entry in self.playlistdb.loadPlaylist(\n playlistid=playlistid, userid=self.getUserId())]\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_57(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.options.get('use_xhtml'):\n",
"return '<br />\\n'\n",
"return '<br>\\n'\n"
] | [
"def linebreak(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.options.get('use_xhtml'):\n",
"return '<br />\\n'\n",
"return '<br>\\n'\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Return'"
] |
[
"@VAR_0.route('/api/jobs/<int:job_id>/<attribute>', methods=['GET'])...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_113 = FUNC_58(f'/internal/jobs/{VAR_9}/{VAR_16}', 'get')\n",
"return jsonify({'success': False, 'message': str(err)}), 400\n",
"return jsonify(VAR_113)\n"
] | [
"@gui.route('/api/jobs/<int:job_id>/<attribute>', methods=['GET'])...\n",
"\"\"\"docstring\"\"\"\n",
"job_attribute_info = query_internal_api(f'/internal/jobs/{job_id}/{attribute}',\n 'get')\n",
"return jsonify({'success': False, 'message': str(err)}), 400\n",
"return jsonify(job_attribute_info)\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'",
"Return'"
] |
[
"def FUNC_13(VAR_33: Text, VAR_34: Text) ->bool:...\n",
"\"\"\"docstring\"\"\"\n",
"shutil.move(VAR_33, VAR_34)\n",
"logging.debug(f'Could not merge model: {e}')\n",
"return True\n",
"return False\n"
] | [
"def move_model(source: Text, target: Text) ->bool:...\n",
"\"\"\"docstring\"\"\"\n",
"shutil.move(source, target)\n",
"logging.debug(f'Could not merge model: {e}')\n",
"return True\n",
"return False\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Expr'",
"Return'",
"Return'"
] |
[
"def FUNC_16(self, VAR_2):...\n",
"assert url_for('some.endpoint')\n",
"VAR_2.add_url_rule('/some-endpoint', endpoint='some.endpoint')\n",
"assert url_for('some.endpoint') == '/some-endpoint'\n"
] | [
"def test_it_works_with_endpoints(self, app):...\n",
"assert url_for('some.endpoint')\n",
"app.add_url_rule('/some-endpoint', endpoint='some.endpoint')\n",
"assert url_for('some.endpoint') == '/some-endpoint'\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assert'",
"Expr'",
"Assert'"
] |
[
"@app.route('/bookmarklet')...\n",
"return render_template('bookmarklet.html', title='Bookmarklet')\n"
] | [
"@app.route('/bookmarklet')...\n",
"return render_template('bookmarklet.html', title='Bookmarklet')\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_2(self, *VAR_4, VAR_5: Any=None, VAR_6: Optional[str]=None, **VAR_7...\n",
"\"\"\"docstring\"\"\"\n",
"if len(VAR_4) > 0:\n",
"import pyarrow\n",
"VAR_19 = dict(VAR_7, **{'default': default, 'key': key})\n",
"from streamlit.components.v1 import component_arrow\n",
"VAR_20 = {}\n",
"VAR_21 = []\n",
"for VAR_44, arg_val in VAR_19.items():\n",
"if type_util.is_bytes_like(arg_val):\n",
"VAR_34 = json.dumps(VAR_20)\n",
"def FUNC_13(VAR_22, VAR_23: Element) ->Union[Any, Type[NoValue]]:...\n",
"VAR_41 = SpecialArg()\n",
"if type_util.is_dataframe_like(arg_val):\n",
"VAR_23.component_instance.component_name = self.name\n",
"VAR_41.key = VAR_44\n",
"VAR_43 = SpecialArg()\n",
"VAR_20[VAR_44] = arg_val\n",
"VAR_23.component_instance.form_id = current_form_id(VAR_22)\n",
"VAR_41.bytes = to_bytes(arg_val)\n",
"VAR_43.key = VAR_44\n",
"if self.url is not None:\n",
"VAR_21.append(VAR_41)\n",
"component_arrow.marshall(VAR_43.arrow_dataframe.data, arg_val)\n",
"VAR_23.component_instance.url = self.url\n",
"def FUNC_14():...\n",
"VAR_21.append(VAR_43)\n",
"VAR_23.component_instance.json_args = VAR_34\n",
"VAR_23.component_instance.special_args.extend(VAR_21)\n",
"if VAR_6 is None:\n",
"FUNC_14()\n",
"def FUNC_15(VAR_35, VAR_36=''):...\n",
"return VAR_35\n"
] | [
"def create_instance(self, *args, default: Any=None, key: Optional[str]=None,...\n",
"\"\"\"docstring\"\"\"\n",
"if len(args) > 0:\n",
"import pyarrow\n",
"all_args = dict(kwargs, **{'default': default, 'key': key})\n",
"from streamlit.components.v1 import component_arrow\n",
"json_args = {}\n",
"special_args = []\n",
"for arg_name, arg_val in all_args.items():\n",
"if type_util.is_bytes_like(arg_val):\n",
"serialized_json_args = json.dumps(json_args)\n",
"def marshall_component(dg, element: Element) ->Union[Any, Type[NoValue]]:...\n",
"bytes_arg = SpecialArg()\n",
"if type_util.is_dataframe_like(arg_val):\n",
"element.component_instance.component_name = self.name\n",
"bytes_arg.key = arg_name\n",
"dataframe_arg = SpecialArg()\n",
"json_args[arg_name] = arg_val\n",
"element.component_instance.form_id = current_form_id(dg)\n",
"bytes_arg.bytes = to_bytes(arg_val)\n",
"dataframe_arg.key = arg_name\n",
"if self.url is not None:\n",
"special_args.append(bytes_arg)\n",
"component_arrow.marshall(dataframe_arg.arrow_dataframe.data, arg_val)\n",
"element.component_instance.url = self.url\n",
"def marshall_element_args():...\n",
"special_args.append(dataframe_arg)\n",
"element.component_instance.json_args = serialized_json_args\n",
"element.component_instance.special_args.extend(special_args)\n",
"if key is None:\n",
"marshall_element_args()\n",
"def deserialize_component(ui_value, widget_id=''):...\n",
"return ui_value\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
] | [
"Condition",
"Docstring",
"Condition",
"Import'",
"Assign'",
"ImportFrom'",
"Assign'",
"Assign'",
"For",
"Condition",
"Assign'",
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_11(self, VAR_17: str, VAR_18: str, VAR_7: str) ->None:...\n",
"\"\"\"docstring\"\"\"\n",
"self.ledger.changed()\n",
"VAR_2: Directive = self.ledger.get_entry(VAR_17)\n",
"VAR_6 = next_key(VAR_18, VAR_2.meta)\n",
"VAR_5 = self.ledger.fava_options.indent\n",
"FUNC_2(VAR_2.meta['filename'], VAR_2.meta['lineno'], VAR_5, VAR_6, VAR_7)\n",
"self.ledger.extensions.after_insert_metadata(VAR_2, VAR_6, VAR_7)\n"
] | [
"def insert_metadata(self, entry_hash: str, basekey: str, value: str) ->None:...\n",
"\"\"\"docstring\"\"\"\n",
"self.ledger.changed()\n",
"entry: Directive = self.ledger.get_entry(entry_hash)\n",
"key = next_key(basekey, entry.meta)\n",
"indent = self.ledger.fava_options.indent\n",
"insert_metadata_in_file(entry.meta['filename'], entry.meta['lineno'],\n indent, key, value)\n",
"self.ledger.extensions.after_insert_metadata(entry, key, value)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"AnnAssign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_40(self, VAR_21=0):...\n",
"VAR_22 = 'dummy'\n",
"if not VAR_21:\n",
"VAR_22 = 'http://server/' + VAR_22\n",
"return VAR_22\n"
] | [
"def absolute_url(self, relative=0):...\n",
"url = 'dummy'\n",
"if not relative:\n",
"url = 'http://server/' + url\n",
"return url\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_1(self, VAR_4=False, **VAR_3):...\n",
"if VAR_4:\n",
"VAR_13 = 'registration_shared_secret: \"%s\"' % (random_string_with_symbols(50),)\n",
"VAR_13 = '#registration_shared_secret: <PRIVATE STRING>'\n",
"return 'string' % locals()\n"
] | [
"def generate_config_section(self, generate_secrets=False, **kwargs):...\n",
"if generate_secrets:\n",
"registration_shared_secret = 'registration_shared_secret: \"%s\"' % (\n random_string_with_symbols(50),)\n",
"registration_shared_secret = '#registration_shared_secret: <PRIVATE STRING>'\n",
"return \"\"\" ## Registration ##\n #\n # Registration can be rate-limited using the parameters in the \"Ratelimiting\"\n # section of this file.\n\n # Enable registration for new users.\n #\n #enable_registration: false\n\n # Optional account validity configuration. This allows for accounts to be denied\n # any request after a given period.\n #\n # Once this feature is enabled, Synapse will look for registered users without an\n # expiration date at startup and will add one to every account it found using the\n # current settings at that time.\n # This means that, if a validity period is set, and Synapse is restarted (it will\n # then derive an expiration date from the current validity period), and some time\n # after that the validity period changes and Synapse is restarted, the users'\n # expiration dates won't be updated unless their account is manually renewed. This\n # date will be randomly selected within a range [now + period - d ; now + period],\n # where d is equal to 10%% of the validity period.\n #\n account_validity:\n # The account validity feature is disabled by default. Uncomment the\n # following line to enable it.\n #\n #enabled: true\n\n # The period after which an account is valid after its registration. When\n # renewing the account, its validity period will be extended by this amount\n # of time. This parameter is required when using the account validity\n # feature.\n #\n #period: 6w\n\n # The amount of time before an account's expiry date at which Synapse will\n # send an email to the account's email address with a renewal link. By\n # default, no such emails are sent.\n #\n # If you enable this setting, you will also need to fill out the 'email'\n # configuration section. You should also check that 'public_baseurl' is set\n # correctly.\n #\n #renew_at: 1w\n\n # The subject of the email sent out with the renewal link. '%%(app)s' can be\n # used as a placeholder for the 'app_name' parameter from the 'email'\n # section.\n #\n # Note that the placeholder must be written '%%(app)s', including the\n # trailing 's'.\n #\n # If this is not set, a default value is used.\n #\n #renew_email_subject: \"Renew your %%(app)s account\"\n\n # Directory in which Synapse will try to find templates for the HTML files to\n # serve to the user when trying to renew an account. If not set, default\n # templates from within the Synapse package will be used.\n #\n #template_dir: \"res/templates\"\n\n # File within 'template_dir' giving the HTML to be displayed to the user after\n # they successfully renewed their account. If not set, default text is used.\n #\n #account_renewed_html_path: \"account_renewed.html\"\n\n # File within 'template_dir' giving the HTML to be displayed when the user\n # tries to renew an account with an invalid renewal token. If not set,\n # default text is used.\n #\n #invalid_token_html_path: \"invalid_token.html\"\n\n # Time that a user's session remains valid for, after they log in.\n #\n # Note that this is not currently compatible with guest logins.\n #\n # Note also that this is calculated at login time: changes are not applied\n # retrospectively to users who have already logged in.\n #\n # By default, this is infinite.\n #\n #session_lifetime: 24h\n\n # The user must provide all of the below types of 3PID when registering.\n #\n #registrations_require_3pid:\n # - email\n # - msisdn\n\n # Explicitly disable asking for MSISDNs from the registration\n # flow (overrides registrations_require_3pid if MSISDNs are set as required)\n #\n #disable_msisdn_registration: true\n\n # Mandate that users are only allowed to associate certain formats of\n # 3PIDs with accounts on this server.\n #\n #allowed_local_3pids:\n # - medium: email\n # pattern: '.*@matrix\\\\.org'\n # - medium: email\n # pattern: '.*@vector\\\\.im'\n # - medium: msisdn\n # pattern: '\\\\+44'\n\n # Enable 3PIDs lookup requests to identity servers from this server.\n #\n #enable_3pid_lookup: true\n\n # If set, allows registration of standard or admin accounts by anyone who\n # has the shared secret, even if registration is otherwise disabled.\n #\n %(registration_shared_secret)s\n\n # Set the number of bcrypt rounds used to generate password hash.\n # Larger numbers increase the work factor needed to generate the hash.\n # The default number is 12 (which equates to 2^12 rounds).\n # N.B. that increasing this will exponentially increase the time required\n # to register or login - e.g. 24 => 2^24 rounds which will take >20 mins.\n #\n #bcrypt_rounds: 12\n\n # Allows users to register as guests without a password/email/etc, and\n # participate in rooms hosted on this server which have been made\n # accessible to anonymous users.\n #\n #allow_guest_access: false\n\n # The identity server which we suggest that clients should use when users log\n # in on this server.\n #\n # (By default, no suggestion is made, so it is left up to the client.)\n #\n #default_identity_server: https://matrix.org\n\n # Handle threepid (email/phone etc) registration and password resets through a set of\n # *trusted* identity servers. Note that this allows the configured identity server to\n # reset passwords for accounts!\n #\n # Be aware that if `email` is not set, and SMTP options have not been\n # configured in the email config block, registration and user password resets via\n # email will be globally disabled.\n #\n # Additionally, if `msisdn` is not set, registration and password resets via msisdn\n # will be disabled regardless, and users will not be able to associate an msisdn\n # identifier to their account. This is due to Synapse currently not supporting\n # any method of sending SMS messages on its own.\n #\n # To enable using an identity server for operations regarding a particular third-party\n # identifier type, set the value to the URL of that identity server as shown in the\n # examples below.\n #\n # Servers handling the these requests must answer the `/requestToken` endpoints defined\n # by the Matrix Identity Service API specification:\n # https://matrix.org/docs/spec/identity_service/latest\n #\n account_threepid_delegates:\n #email: https://example.com # Delegate email sending to example.com\n #msisdn: http://localhost:8090 # Delegate SMS sending to this local process\n\n # Whether users are allowed to change their displayname after it has\n # been initially set. Useful when provisioning users based on the\n # contents of a third-party directory.\n #\n # Does not apply to server administrators. Defaults to 'true'\n #\n #enable_set_displayname: false\n\n # Whether users are allowed to change their avatar after it has been\n # initially set. Useful when provisioning users based on the contents\n # of a third-party directory.\n #\n # Does not apply to server administrators. Defaults to 'true'\n #\n #enable_set_avatar_url: false\n\n # Whether users can change the 3PIDs associated with their accounts\n # (email address and msisdn).\n #\n # Defaults to 'true'\n #\n #enable_3pid_changes: false\n\n # Users who register on this homeserver will automatically be joined\n # to these rooms.\n #\n # By default, any room aliases included in this list will be created\n # as a publicly joinable room when the first user registers for the\n # homeserver. This behaviour can be customised with the settings below.\n #\n #auto_join_rooms:\n # - \"#example:example.com\"\n\n # Where auto_join_rooms are specified, setting this flag ensures that the\n # the rooms exist by creating them when the first user on the\n # homeserver registers.\n #\n # By default the auto-created rooms are publicly joinable from any federated\n # server. Use the autocreate_auto_join_rooms_federated and\n # autocreate_auto_join_room_preset settings below to customise this behaviour.\n #\n # Setting to false means that if the rooms are not manually created,\n # users cannot be auto-joined since they do not exist.\n #\n # Defaults to true. Uncomment the following line to disable automatically\n # creating auto-join rooms.\n #\n #autocreate_auto_join_rooms: false\n\n # Whether the auto_join_rooms that are auto-created are available via\n # federation. Only has an effect if autocreate_auto_join_rooms is true.\n #\n # Note that whether a room is federated cannot be modified after\n # creation.\n #\n # Defaults to true: the room will be joinable from other servers.\n # Uncomment the following to prevent users from other homeservers from\n # joining these rooms.\n #\n #autocreate_auto_join_rooms_federated: false\n\n # The room preset to use when auto-creating one of auto_join_rooms. Only has an\n # effect if autocreate_auto_join_rooms is true.\n #\n # This can be one of \"public_chat\", \"private_chat\", or \"trusted_private_chat\".\n # If a value of \"private_chat\" or \"trusted_private_chat\" is used then\n # auto_join_mxid_localpart must also be configured.\n #\n # Defaults to \"public_chat\", meaning that the room is joinable by anyone, including\n # federated servers if autocreate_auto_join_rooms_federated is true (the default).\n # Uncomment the following to require an invitation to join these rooms.\n #\n #autocreate_auto_join_room_preset: private_chat\n\n # The local part of the user id which is used to create auto_join_rooms if\n # autocreate_auto_join_rooms is true. If this is not provided then the\n # initial user account that registers will be used to create the rooms.\n #\n # The user id is also used to invite new users to any auto-join rooms which\n # are set to invite-only.\n #\n # It *must* be configured if autocreate_auto_join_room_preset is set to\n # \"private_chat\" or \"trusted_private_chat\".\n #\n # Note that this must be specified in order for new users to be correctly\n # invited to any auto-join rooms which have been set to invite-only (either\n # at the time of creation or subsequently).\n #\n # Note that, if the room already exists, this user must be joined and\n # have the appropriate permissions to invite new members.\n #\n #auto_join_mxid_localpart: system\n\n # When auto_join_rooms is specified, setting this flag to false prevents\n # guest accounts from being automatically joined to the rooms.\n #\n # Defaults to true.\n #\n #auto_join_rooms_for_guests: false\n \"\"\" % locals(\n )\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"@wraps(VAR_3)...\n",
"if current_user.role_edit() or current_user.role_admin():\n",
"return VAR_3(*VAR_46, **kwargs)\n",
"abort(403)\n"
] | [
"@wraps(f)...\n",
"if current_user.role_edit() or current_user.role_admin():\n",
"return f(*args, **kwargs)\n",
"abort(403)\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Return'",
"Expr'"
] |
[
"def FUNC_21(VAR_29, VAR_30, VAR_31=None, VAR_32=None, VAR_33=None):...\n",
"if VAR_31 is None:\n",
"VAR_31 = VAR_0\n",
"VAR_72 = FUNC_3(VAR_31, VAR_31 + VAR_1)\n",
"VAR_27 = 'http://{}:{}/'.format(VAR_30, VAR_72)\n",
"if VAR_32 is not None:\n",
"if not callable(VAR_32):\n",
"VAR_8.auth = None\n",
"VAR_8.auth = {account[0]: account[1] for account in VAR_32}\n",
"VAR_8.auth = VAR_32\n",
"VAR_8.interface = VAR_29\n",
"VAR_8.cwd = os.getcwd()\n",
"VAR_73 = logging.getLogger('werkzeug')\n",
"VAR_73.setLevel(logging.ERROR)\n",
"if VAR_8.interface.enable_queue:\n",
"if VAR_32 is not None or VAR_8.interface.encrypt:\n",
"if VAR_29.save_to is not None:\n",
"queue.init()\n",
"VAR_29.save_to['port'] = VAR_72\n",
"VAR_74 = {'port': VAR_72, 'host': VAR_30}\n",
"VAR_8.queue_thread = threading.Thread(target=queue_thread, VAR_41=(\n path_to_local_server,))\n",
"if VAR_33:\n",
"VAR_8.queue_thread.start()\n",
"VAR_74['ssl_context'] = VAR_33\n",
"VAR_75 = threading.Thread(target=app.run, VAR_42=app_kwargs, daemon=True)\n",
"VAR_75.start()\n",
"return VAR_72, VAR_27, VAR_8, VAR_75\n"
] | [
"def start_server(interface, server_name, server_port=None, auth=None, ssl=None...\n",
"if server_port is None:\n",
"server_port = INITIAL_PORT_VALUE\n",
"port = get_first_available_port(server_port, server_port + TRY_NUM_PORTS)\n",
"path_to_local_server = 'http://{}:{}/'.format(server_name, port)\n",
"if auth is not None:\n",
"if not callable(auth):\n",
"app.auth = None\n",
"app.auth = {account[0]: account[1] for account in auth}\n",
"app.auth = auth\n",
"app.interface = interface\n",
"app.cwd = os.getcwd()\n",
"log = logging.getLogger('werkzeug')\n",
"log.setLevel(logging.ERROR)\n",
"if app.interface.enable_queue:\n",
"if auth is not None or app.interface.encrypt:\n",
"if interface.save_to is not None:\n",
"queue.init()\n",
"interface.save_to['port'] = port\n",
"app_kwargs = {'port': port, 'host': server_name}\n",
"app.queue_thread = threading.Thread(target=queue_thread, args=(\n path_to_local_server,))\n",
"if ssl:\n",
"app.queue_thread.start()\n",
"app_kwargs['ssl_context'] = ssl\n",
"thread = threading.Thread(target=app.run, kwargs=app_kwargs, daemon=True)\n",
"thread.start()\n",
"return port, path_to_local_server, app, thread\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
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"import hashlib\n",
"import hmac\n",
"import logging\n",
"import time\n",
"from datetime import timedelta\n",
"from urllib.parse import urlsplit, urlunsplit\n",
"from flask import jsonify, redirect, request, url_for, session\n",
"from flask_login import LoginManager, login_user, logout_user, user_logged_in\n",
"from redash import models, settings\n",
"from redash.authentication import jwt_auth\n",
"from redash.authentication.org_resolving import current_org\n",
"from redash.settings.organization import settings as org_settings\n",
"from redash.tasks import record_event\n",
"from sqlalchemy.orm.exc import NoResultFound\n",
"from werkzeug.exceptions import Unauthorized\n",
"VAR_0 = LoginManager()\n",
"VAR_1 = logging.getLogger('authentication')\n",
"def FUNC_0(VAR_2=False, VAR_3='/'):...\n",
"if settings.MULTI_ORG and current_org == None:\n",
"VAR_23 = '/'\n",
"if settings.MULTI_ORG:\n",
"return VAR_23\n",
"VAR_23 = url_for('redash.login', org_slug=current_org.slug, VAR_3=next,\n _external=external)\n",
"VAR_23 = url_for('redash.login', VAR_3=next, _external=external)\n"
] | [
"import hashlib\n",
"import hmac\n",
"import logging\n",
"import time\n",
"from datetime import timedelta\n",
"from urllib.parse import urlsplit, urlunsplit\n",
"from flask import jsonify, redirect, request, url_for, session\n",
"from flask_login import LoginManager, login_user, logout_user, user_logged_in\n",
"from redash import models, settings\n",
"from redash.authentication import jwt_auth\n",
"from redash.authentication.org_resolving import current_org\n",
"from redash.settings.organization import settings as org_settings\n",
"from redash.tasks import record_event\n",
"from sqlalchemy.orm.exc import NoResultFound\n",
"from werkzeug.exceptions import Unauthorized\n",
"login_manager = LoginManager()\n",
"logger = logging.getLogger('authentication')\n",
"def get_login_url(external=False, next='/'):...\n",
"if settings.MULTI_ORG and current_org == None:\n",
"login_url = '/'\n",
"if settings.MULTI_ORG:\n",
"return login_url\n",
"login_url = url_for('redash.login', org_slug=current_org.slug, next=next,\n _external=external)\n",
"login_url = url_for('redash.login', next=next, _external=external)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'"
] |
[
"def FUNC_21(VAR_9, VAR_5, VAR_10):...\n",
"VAR_38 = calibre_db.session.query(db.Publishers).filter(db.Publishers.id ==\n VAR_5).first()\n",
"if VAR_38:\n",
"VAR_63, VAR_68, VAR_65 = calibre_db.fill_indexpage(VAR_9, 0, db.Books, db.\n Books.publishers.any(db.Publishers.id == VAR_5), [db.Series.name,\n VAR_10[0][0], db.Books.series_index], db.books_series_link, db.Books.id ==\n db.books_series_link.c.book, db.Series)\n",
"abort(404)\n",
"return render_title_template('index.html', VAR_68=random, VAR_63=entries,\n VAR_65=pagination, id=book_id, VAR_150=_(u'Publisher: %(name)s', name=\n publisher.name), VAR_9='publisher', VAR_10=order[1])\n"
] | [
"def render_publisher_books(page, book_id, order):...\n",
"publisher = calibre_db.session.query(db.Publishers).filter(db.Publishers.id ==\n book_id).first()\n",
"if publisher:\n",
"entries, random, pagination = calibre_db.fill_indexpage(page, 0, db.Books,\n db.Books.publishers.any(db.Publishers.id == book_id), [db.Series.name,\n order[0][0], db.Books.series_index], db.books_series_link, db.Books.id ==\n db.books_series_link.c.book, db.Series)\n",
"abort(404)\n",
"return render_title_template('index.html', random=random, entries=entries,\n pagination=pagination, id=book_id, title=_(u'Publisher: %(name)s', name\n =publisher.name), page='publisher', order=order[1])\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Return'"
] |
[
"import os\n",
"import tempfile\n",
"import pytest\n",
"from django.core.files.base import ContentFile\n",
"from django.utils.encoding import force_str\n",
"from selenium import webdriver\n",
"from selenium.common.exceptions import WebDriverException\n",
"@pytest.fixture(scope='session')...\n",
"VAR_2 = webdriver.ChromeOptions()\n",
"VAR_2.headless = True\n",
"VAR_5 = webdriver.Chrome(options=chrome_options)\n",
"pytest.skip(force_str(e))\n",
"yield VAR_5\n",
"@pytest.fixture...\n",
"VAR_5.quit()\n",
"VAR_3 = tempfile.mkdtemp()\n",
"VAR_4 = os.path.join(VAR_3, '%s.txt' % VAR_0.node.name)\n",
"f.write(VAR_0.node.name)\n",
"return VAR_4\n"
] | [
"import os\n",
"import tempfile\n",
"import pytest\n",
"from django.core.files.base import ContentFile\n",
"from django.utils.encoding import force_str\n",
"from selenium import webdriver\n",
"from selenium.common.exceptions import WebDriverException\n",
"@pytest.fixture(scope='session')...\n",
"chrome_options = webdriver.ChromeOptions()\n",
"chrome_options.headless = True\n",
"b = webdriver.Chrome(options=chrome_options)\n",
"pytest.skip(force_str(e))\n",
"yield b\n",
"@pytest.fixture...\n",
"b.quit()\n",
"path = tempfile.mkdtemp()\n",
"file_name = os.path.join(path, '%s.txt' % request.node.name)\n",
"f.write(request.node.name)\n",
"return file_name\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
0,
1
] | [
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"assert controller_name(CLASS_9) == 'api'\n"
] | [
"def test_it_handles_acronyms(self):...\n",
"assert controller_name(APIController) == 'api'\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assert'"
] |
[
"def FUNC_35():...\n",
"return FUNC_0(VAR_6=request.url_root, VAR_7=additional_unless)\n"
] | [
"def unless():...\n",
"return _preemptive_unless(base_url=request.url_root, additional_unless=\n additional_unless)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_6(VAR_11):...\n",
""
] | [
"def firstLinkTextFromElement(el):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_8(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = self._make_request(b'OPTIONS', b'/foo/')\n",
"self.assertEqual(VAR_6.result['code'], b'204')\n",
"self.assertNotIn('body', VAR_6.result)\n",
"self.assertTrue(VAR_6.headers.hasHeader(b'Access-Control-Allow-Origin'),\n 'has CORS Origin header')\n",
"self.assertTrue(VAR_6.headers.hasHeader(b'Access-Control-Allow-Methods'),\n 'has CORS Methods header')\n",
"self.assertTrue(VAR_6.headers.hasHeader(b'Access-Control-Allow-Headers'),\n 'has CORS Headers header')\n"
] | [
"def test_unknown_options_request(self):...\n",
"\"\"\"docstring\"\"\"\n",
"channel = self._make_request(b'OPTIONS', b'/foo/')\n",
"self.assertEqual(channel.result['code'], b'204')\n",
"self.assertNotIn('body', channel.result)\n",
"self.assertTrue(channel.headers.hasHeader(b'Access-Control-Allow-Origin'),\n 'has CORS Origin header')\n",
"self.assertTrue(channel.headers.hasHeader(b'Access-Control-Allow-Methods'),\n 'has CORS Methods header')\n",
"self.assertTrue(channel.headers.hasHeader(b'Access-Control-Allow-Headers'),\n 'has CORS Headers header')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_0(VAR_0):...\n",
"if VAR_0:\n",
"VAR_0 = '{0:02d}h:{1:02d}m'.format(VAR_0.seconds // 3600, VAR_0.seconds % \n 3600 // 60)\n",
"VAR_0 = ''\n",
"return VAR_0\n"
] | [
"def format_time_spent(time_spent):...\n",
"if time_spent:\n",
"time_spent = '{0:02d}h:{1:02d}m'.format(time_spent.seconds // 3600, \n time_spent.seconds % 3600 // 60)\n",
"time_spent = ''\n",
"return time_spent\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_11(self):...\n",
"VAR_5 = self._makeContext()\n",
"self.assertTrue(VAR_5.evaluate('x | nothing') is None)\n"
] | [
"def test_evaluate_alternative_first_missing(self):...\n",
"ec = self._makeContext()\n",
"self.assertTrue(ec.evaluate('x | nothing') is None)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def __lt__(self, VAR_18):...\n",
"\"\"\"docstring\"\"\"\n",
"return (self.param.command_index, self.param.param_index) < (VAR_18.param.\n command_index, VAR_18.param.param_index)\n"
] | [
"def __lt__(self, other):...\n",
"\"\"\"docstring\"\"\"\n",
"return (self.param.command_index, self.param.param_index) < (other.param.\n command_index, other.param.param_index)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_102(VAR_163, VAR_164=None, VAR_165=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_201 = {'int': int, 'float': float, 'long': int, 'round': round}\n",
"if '__' in VAR_163:\n",
"VAR_96('Illegal rule {0}. Cannot use \"__\"'.format(FUNC_101(VAR_163)))\n",
"if not VAR_164:\n",
"VAR_164 = {}\n",
"VAR_164['__builtins__'] = {}\n",
"VAR_164.update(VAR_201)\n",
"return eval(VAR_163, VAR_164, VAR_165)\n"
] | [
"def safe_eval(code, eval_globals=None, eval_locals=None):...\n",
"\"\"\"docstring\"\"\"\n",
"whitelisted_globals = {'int': int, 'float': float, 'long': int, 'round': round}\n",
"if '__' in code:\n",
"throw('Illegal rule {0}. Cannot use \"__\"'.format(bold(code)))\n",
"if not eval_globals:\n",
"eval_globals = {}\n",
"eval_globals['__builtins__'] = {}\n",
"eval_globals.update(whitelisted_globals)\n",
"return eval(code, eval_globals, eval_locals)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_13(self, VAR_22, VAR_23):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_32 = config.val.content.headers.referer\n",
"if VAR_32 == 'never':\n",
"VAR_22.setRawHeader('Referer'.encode('ascii'), QByteArray())\n",
"if VAR_32 == 'same-domain' and not urlutils.same_domain(VAR_22.url(), VAR_23):\n",
"VAR_22.setRawHeader('Referer'.encode('ascii'), QByteArray())\n"
] | [
"def set_referer(self, req, current_url):...\n",
"\"\"\"docstring\"\"\"\n",
"referer_header_conf = config.val.content.headers.referer\n",
"if referer_header_conf == 'never':\n",
"req.setRawHeader('Referer'.encode('ascii'), QByteArray())\n",
"if referer_header_conf == 'same-domain' and not urlutils.same_domain(req.\n",
"req.setRawHeader('Referer'.encode('ascii'), QByteArray())\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_18(self, VAR_2):...\n",
"def FUNC_30(self, VAR_8):...\n",
"VAR_2.add_url_rule('/sites/<int:id>', endpoint='site_resource.get')\n",
"assert url_for('get', VAR_8=1, _cls=SiteResource) == '/sites/1'\n",
"VAR_2.add_url_rule('/foo/<string:slug>', endpoint='some.endpoint')\n",
"assert url_for('some.endpoint', slug='hi') == '/foo/hi'\n"
] | [
"def test_it_works_with_url_for_kwargs(self, app):...\n",
"def get(self, id):...\n",
"app.add_url_rule('/sites/<int:id>', endpoint='site_resource.get')\n",
"assert url_for('get', id=1, _cls=SiteResource) == '/sites/1'\n",
"app.add_url_rule('/foo/<string:slug>', endpoint='some.endpoint')\n",
"assert url_for('some.endpoint', slug='hi') == '/foo/hi'\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"FunctionDef'",
"Expr'",
"Assert'",
"Expr'",
"Assert'"
] |
[
"@VAR_2.route('/language')...\n",
"if VAR_87.check_visibility(constants.SIDEBAR_LANGUAGE\n",
"VAR_109 = 0 if VAR_87.get_view_property('language', 'dir') == 'desc' else 1\n",
"abort(404)\n",
"VAR_107 = list()\n",
"VAR_48 = calibre_db.speaking_language(reverse_order=not order_no,\n with_count=True)\n",
"for lang in VAR_48:\n",
"VAR_128 = lang[0].name[0].upper()\n",
"return render_title_template('languages.html', VAR_48=languages, VAR_107=\n charlist, VAR_150=_(u'Languages'), VAR_9='langlist', VAR_8='language',\n VAR_10=order_no)\n",
"if VAR_128 not in VAR_107:\n",
"VAR_107.append(VAR_128)\n"
] | [
"@web.route('/language')...\n",
"if current_user.check_visibility(constants.SIDEBAR_LANGUAGE\n",
"order_no = 0 if current_user.get_view_property('language', 'dir'\n ) == 'desc' else 1\n",
"abort(404)\n",
"charlist = list()\n",
"languages = calibre_db.speaking_language(reverse_order=not order_no,\n with_count=True)\n",
"for lang in languages:\n",
"upper_lang = lang[0].name[0].upper()\n",
"return render_title_template('languages.html', languages=languages,\n charlist=charlist, title=_(u'Languages'), page='langlist', data=\n 'language', order=order_no)\n",
"if upper_lang not in charlist:\n",
"charlist.append(upper_lang)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Return'",
"Condition",
"Expr'"
] |
[
"def FUNC_22(VAR_27):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_27.is_valid:\n",
"return HttpResponseBadRequest(_(\n 'The sale associated with this invoice has already been invalidated.'))\n",
"VAR_27.is_valid = False\n",
"VAR_27.save()\n",
"VAR_74 = _('Invoice number {0} has been invalidated.').format(VAR_27.id)\n",
"return JsonResponse({'message': VAR_74})\n"
] | [
"def invalidate_invoice(obj_invoice):...\n",
"\"\"\"docstring\"\"\"\n",
"if not obj_invoice.is_valid:\n",
"return HttpResponseBadRequest(_(\n 'The sale associated with this invoice has already been invalidated.'))\n",
"obj_invoice.is_valid = False\n",
"obj_invoice.save()\n",
"message = _('Invoice number {0} has been invalidated.').format(obj_invoice.id)\n",
"return JsonResponse({'message': message})\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_1(VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"return os.path.dirname(VAR_3) == VAR_3\n"
] | [
"def is_root(directory):...\n",
"\"\"\"docstring\"\"\"\n",
"return os.path.dirname(directory) == directory\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"@override_settings(DEBUG_PROPAGATE_EXCEPTIONS=True)...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_3 = self.client.post('/password_reset/', {'email':\n 'staffmember@example.com'}, HTTP_HOST=\n 'www.example:dr.frankenstein@evil.tld')\n",
"self.assertEqual(VAR_3.status_code, 400)\n",
"self.assertEqual(len(mail.outbox), 0)\n",
"self.assertEqual(len(logger_calls), 1)\n"
] | [
"@override_settings(DEBUG_PROPAGATE_EXCEPTIONS=True)...\n",
"\"\"\"docstring\"\"\"\n",
"response = self.client.post('/password_reset/', {'email':\n 'staffmember@example.com'}, HTTP_HOST=\n 'www.example:dr.frankenstein@evil.tld')\n",
"self.assertEqual(response.status_code, 400)\n",
"self.assertEqual(len(mail.outbox), 0)\n",
"self.assertEqual(len(logger_calls), 1)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"from __future__ import unicode_literals\n",
"from django.apps import apps\n",
"from django.utils.html import format_html_join\n",
"from .permissions import permission_cabinet_view\n",
"def FUNC_0(VAR_0, VAR_1):...\n",
"VAR_4 = []\n",
"VAR_4.append('{')\n",
"VAR_4.append('\"text\": \"{}\",'.format(VAR_0.label))\n",
"VAR_4.append('\"state\": {{ \"opened\": true, \"selected\": {} }},'.format('true' if\n VAR_0 == VAR_1 else 'false'))\n",
"VAR_4.append('\"data\": {{ \"href\": \"{}\" }},'.format(VAR_0.get_absolute_url()))\n",
"VAR_5 = VAR_0.get_children().order_by('label')\n",
"if VAR_5:\n",
"VAR_4.append('\"children\" : [')\n",
"VAR_4.append('},')\n",
"for child in VAR_5:\n",
"return VAR_4\n",
"VAR_4.extend(FUNC_0(VAR_0=child, VAR_1=selected_node))\n",
"VAR_4.append(']')\n"
] | [
"from __future__ import unicode_literals\n",
"from django.apps import apps\n",
"from django.utils.html import format_html_join\n",
"from .permissions import permission_cabinet_view\n",
"def jstree_data(node, selected_node):...\n",
"result = []\n",
"result.append('{')\n",
"result.append('\"text\": \"{}\",'.format(node.label))\n",
"result.append('\"state\": {{ \"opened\": true, \"selected\": {} }},'.format(\n 'true' if node == selected_node else 'false'))\n",
"result.append('\"data\": {{ \"href\": \"{}\" }},'.format(node.get_absolute_url()))\n",
"children = node.get_children().order_by('label')\n",
"if children:\n",
"result.append('\"children\" : [')\n",
"result.append('},')\n",
"for child in children:\n",
"return result\n",
"result.extend(jstree_data(node=child, selected_node=selected_node))\n",
"result.append(']')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"For",
"Return'",
"Expr'",
"Expr'"
] |
[
"def FUNC_35(self):...\n",
"self.parser = saved_model_cli.create_parser()\n",
"VAR_9 = test.test_src_dir_path(VAR_0)\n",
"VAR_10 = self.parser.parse_args(['scan', '--dir', VAR_9, '--tag_set', 'serve'])\n",
"VAR_48 = saved_model_cli._OP_DENYLIST\n",
"saved_model_cli._OP_DENYLIST = set(['VariableV2'])\n",
"saved_model_cli.scan(VAR_10)\n",
"saved_model_cli._OP_DENYLIST = VAR_48\n",
"VAR_11 = out.getvalue().strip()\n",
"self.assertTrue(\"'VariableV2'\" in VAR_11)\n"
] | [
"def testScanCommandFoundDenylistedOp(self):...\n",
"self.parser = saved_model_cli.create_parser()\n",
"base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n",
"args = self.parser.parse_args(['scan', '--dir', base_path, '--tag_set',\n 'serve'])\n",
"op_denylist = saved_model_cli._OP_DENYLIST\n",
"saved_model_cli._OP_DENYLIST = set(['VariableV2'])\n",
"saved_model_cli.scan(args)\n",
"saved_model_cli._OP_DENYLIST = op_denylist\n",
"output = out.getvalue().strip()\n",
"self.assertTrue(\"'VariableV2'\" in output)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_1(VAR_1, VAR_2):...\n",
"return frappe.local.module_app[scrub(VAR_1)] + '.' + scrub(VAR_1\n ) + '.report.' + scrub(VAR_2) + '.' + scrub(VAR_2)\n"
] | [
"def get_report_module_dotted_path(module, report_name):...\n",
"return frappe.local.module_app[scrub(module)] + '.' + scrub(module\n ) + '.report.' + scrub(report_name) + '.' + scrub(report_name)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_21(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_55 = ['companies']\n",
"self.assertFormfield(models.Advisor, 'companies', widgets.\n FilteredSelectMultiple, VAR_55=['companies'])\n",
"VAR_16 = CLASS_27(models.Advisor, admin.site)\n",
"VAR_20 = VAR_16.formfield_for_dbfield(models.Advisor._meta.get_field(\n 'companies'), request=None)\n",
"self.assertEqual(six.text_type(VAR_20.help_text),\n ' Hold down \"Control\", or \"Command\" on a Mac, to select more than one.')\n"
] | [
"def test_m2m_widgets(self):...\n",
"\"\"\"docstring\"\"\"\n",
"filter_vertical = ['companies']\n",
"self.assertFormfield(models.Advisor, 'companies', widgets.\n FilteredSelectMultiple, filter_vertical=['companies'])\n",
"ma = AdvisorAdmin(models.Advisor, admin.site)\n",
"f = ma.formfield_for_dbfield(models.Advisor._meta.get_field('companies'),\n request=None)\n",
"self.assertEqual(six.text_type(f.help_text),\n ' Hold down \"Control\", or \"Command\" on a Mac, to select more than one.')\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_1(*, VAR_0: Optional[str], VAR_1: Optional[Path]) ->Sequence[...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_4 = FUNC_0(VAR_0=url, VAR_1=path)\n",
"if isinstance(VAR_4, GeneratorError):\n",
"return [VAR_4]\n",
"return VAR_4.build()\n"
] | [
"def create_new_client(*, url: Optional[str], path: Optional[Path]) ->Sequence[...\n",
"\"\"\"docstring\"\"\"\n",
"project = _get_project_for_url_or_path(url=url, path=path)\n",
"if isinstance(project, GeneratorError):\n",
"return [project]\n",
"return project.build()\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_30(self, VAR_8):...\n",
""
] | [
"def get(self, id):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"@FUNC_0...\n",
"if self.config.worker_app:\n",
"return ServerNoticesManager(self)\n"
] | [
"@cache_in_self...\n",
"if self.config.worker_app:\n",
"return ServerNoticesManager(self)\n"
] | [
0,
0,
0
] | [
"Condition",
"Condition",
"Return'"
] |
[
"def FUNC_1(self, VAR_1):...\n",
"from openapi_python_client.parser.properties import Property\n",
"VAR_5 = VAR_1.MagicMock()\n",
"VAR_6 = VAR_1.patch('openapi_python_client.utils.snake_case')\n",
"VAR_4 = Property(VAR_5=name, VAR_26=True, default=None)\n",
"VAR_7 = VAR_1.patch.object(VAR_4, 'get_type_string')\n",
"assert VAR_4.to_string() == f'{VAR_6(VAR_5)}: {VAR_7()}'\n",
"VAR_4.required = False\n",
"assert VAR_4.to_string() == f'{VAR_6(VAR_5)}: {VAR_7()} = None'\n",
"VAR_4.default = 'TEST'\n",
"assert VAR_4.to_string() == f'{VAR_6(VAR_5)}: {VAR_7()} = TEST'\n"
] | [
"def test_to_string(self, mocker):...\n",
"from openapi_python_client.parser.properties import Property\n",
"name = mocker.MagicMock()\n",
"snake_case = mocker.patch('openapi_python_client.utils.snake_case')\n",
"p = Property(name=name, required=True, default=None)\n",
"get_type_string = mocker.patch.object(p, 'get_type_string')\n",
"assert p.to_string() == f'{snake_case(name)}: {get_type_string()}'\n",
"p.required = False\n",
"assert p.to_string() == f'{snake_case(name)}: {get_type_string()} = None'\n",
"p.default = 'TEST'\n",
"assert p.to_string() == f'{snake_case(name)}: {get_type_string()} = TEST'\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assert'",
"Assign'",
"Assert'",
"Assign'",
"Assert'"
] |
[
"def FUNC_5(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_14 = signedjson.key.generate_signing_key('ver1')\n",
"self.expect_outgoing_key_request(self.hs.hostname, VAR_14)\n",
"VAR_12 = self.make_notary_request(self.hs.hostname, 'ed25519:ver1')\n",
"VAR_15 = VAR_12['server_keys']\n",
"self.assertEqual(len(VAR_15), 1)\n",
"VAR_16 = VAR_15[0]['signatures']\n",
"self.assertEqual(len(VAR_16), 1)\n",
"self.assertIn(self.hs.hostname, VAR_16)\n",
"VAR_17 = VAR_16[self.hs.hostname]\n",
"self.assertEqual(len(VAR_17), 2)\n",
"self.assertIn('ed25519:ver1', VAR_15[0]['verify_keys'])\n"
] | [
"def test_get_own_key(self):...\n",
"\"\"\"docstring\"\"\"\n",
"testkey = signedjson.key.generate_signing_key('ver1')\n",
"self.expect_outgoing_key_request(self.hs.hostname, testkey)\n",
"resp = self.make_notary_request(self.hs.hostname, 'ed25519:ver1')\n",
"keys = resp['server_keys']\n",
"self.assertEqual(len(keys), 1)\n",
"sigs = keys[0]['signatures']\n",
"self.assertEqual(len(sigs), 1)\n",
"self.assertIn(self.hs.hostname, sigs)\n",
"oursigs = sigs[self.hs.hostname]\n",
"self.assertEqual(len(oursigs), 2)\n",
"self.assertIn('ed25519:ver1', keys[0]['verify_keys'])\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@CLASS_4('pastebin-version')...\n",
"\"\"\"docstring\"\"\"\n",
"version.pastebin_version()\n",
"return 'text/plain', b'Paste called.'\n"
] | [
"@add_handler('pastebin-version')...\n",
"\"\"\"docstring\"\"\"\n",
"version.pastebin_version()\n",
"return 'text/plain', b'Paste called.'\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Expr'",
"Return'"
] |
[
"def FUNC_102(VAR_163, VAR_164=None, VAR_165=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_201 = {'int': int, 'float': float, 'long': int, 'round': round}\n",
"if '__' in VAR_163:\n",
"VAR_96('Illegal rule {0}. Cannot use \"__\"'.format(FUNC_101(VAR_163)))\n",
"if not VAR_164:\n",
"VAR_164 = {}\n",
"VAR_164['__builtins__'] = {}\n",
"VAR_164.update(VAR_201)\n",
"return eval(VAR_163, VAR_164, VAR_165)\n"
] | [
"def safe_eval(code, eval_globals=None, eval_locals=None):...\n",
"\"\"\"docstring\"\"\"\n",
"whitelisted_globals = {'int': int, 'float': float, 'long': int, 'round': round}\n",
"if '__' in code:\n",
"throw('Illegal rule {0}. Cannot use \"__\"'.format(bold(code)))\n",
"if not eval_globals:\n",
"eval_globals = {}\n",
"eval_globals['__builtins__'] = {}\n",
"eval_globals.update(whitelisted_globals)\n",
"return eval(code, eval_globals, eval_locals)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_10(self, VAR_10=None):...\n",
"self.register_user('room_admin', 'pass', admin=True)\n",
"VAR_8 = self.login('room_admin', 'pass')\n",
"VAR_27 = self.register_user('room_nonadmin', 'pass', admin=False)\n",
"VAR_22 = self.login('room_nonadmin', 'pass')\n",
"VAR_28 = self.helper.create_room_as(VAR_27, tok=admin_user_tok)\n",
"self.helper.join(VAR_28, VAR_27, tok=non_admin_user_tok)\n",
"VAR_29 = self.helper.upload_media(self.upload_resource, self.image_data,\n tok=non_admin_user_tok)\n",
"VAR_30 = self.helper.upload_media(self.upload_resource, self.image_data,\n tok=non_admin_user_tok)\n",
"VAR_31 = VAR_29['content_uri']\n",
"VAR_32 = VAR_30['content_uri']\n",
"self.helper.send_event(VAR_28, 'm.room.message', content={'body': 'image-1',\n 'msgtype': 'm.image', 'url': mxc_1}, txn_id='111', tok=non_admin_user_tok)\n",
"self.helper.send_event(VAR_28, 'm.room.message', content={'body': 'image-2',\n 'msgtype': 'm.image', 'url': mxc_2}, txn_id='222', tok=non_admin_user_tok)\n",
"if VAR_10:\n",
"VAR_0 = VAR_10 % urllib.parse.quote(VAR_28)\n",
"VAR_0 = '/_synapse/admin/v1/room/%s/media/quarantine' % urllib.parse.quote(\n VAR_28)\n",
"VAR_12, VAR_13 = self.make_request('POST', VAR_0, VAR_7=admin_user_tok)\n",
"self.pump(1.0)\n",
"self.assertEqual(200, int(VAR_13.code), msg=channel.result['body'])\n",
"self.assertEqual(json.loads(VAR_13.result['body'].decode('utf-8')), {\n 'num_quarantined': 2}, 'Expected 2 quarantined items')\n",
"VAR_33 = VAR_31[6:]\n",
"VAR_34 = VAR_32[6:]\n",
"self._ensure_quarantined(VAR_8, VAR_33)\n",
"self._ensure_quarantined(VAR_8, VAR_34)\n"
] | [
"def test_quarantine_all_media_in_room(self, override_url_template=None):...\n",
"self.register_user('room_admin', 'pass', admin=True)\n",
"admin_user_tok = self.login('room_admin', 'pass')\n",
"non_admin_user = self.register_user('room_nonadmin', 'pass', admin=False)\n",
"non_admin_user_tok = self.login('room_nonadmin', 'pass')\n",
"room_id = self.helper.create_room_as(non_admin_user, tok=admin_user_tok)\n",
"self.helper.join(room_id, non_admin_user, tok=non_admin_user_tok)\n",
"response_1 = self.helper.upload_media(self.upload_resource, self.image_data,\n tok=non_admin_user_tok)\n",
"response_2 = self.helper.upload_media(self.upload_resource, self.image_data,\n tok=non_admin_user_tok)\n",
"mxc_1 = response_1['content_uri']\n",
"mxc_2 = response_2['content_uri']\n",
"self.helper.send_event(room_id, 'm.room.message', content={'body':\n 'image-1', 'msgtype': 'm.image', 'url': mxc_1}, txn_id='111', tok=\n non_admin_user_tok)\n",
"self.helper.send_event(room_id, 'm.room.message', content={'body':\n 'image-2', 'msgtype': 'm.image', 'url': mxc_2}, txn_id='222', tok=\n non_admin_user_tok)\n",
"if override_url_template:\n",
"url = override_url_template % urllib.parse.quote(room_id)\n",
"url = '/_synapse/admin/v1/room/%s/media/quarantine' % urllib.parse.quote(\n room_id)\n",
"request, channel = self.make_request('POST', url, access_token=admin_user_tok)\n",
"self.pump(1.0)\n",
"self.assertEqual(200, int(channel.code), msg=channel.result['body'])\n",
"self.assertEqual(json.loads(channel.result['body'].decode('utf-8')), {\n 'num_quarantined': 2}, 'Expected 2 quarantined items')\n",
"server_and_media_id_1 = mxc_1[6:]\n",
"server_and_media_id_2 = mxc_2[6:]\n",
"self._ensure_quarantined(admin_user_tok, server_and_media_id_1)\n",
"self._ensure_quarantined(admin_user_tok, server_and_media_id_2)\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'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@ensure_csrf_cookie...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_10 = SlashSeparatedCourseKey.from_deprecated_string(VAR_10)\n",
"VAR_85 = CourseRegistrationCode.objects.filter(VAR_10=course_id).order_by(\n 'invoice_item__invoice__company_name')\n",
"VAR_88 = VAR_9.POST['download_company_name']\n",
"if VAR_88:\n",
"VAR_85 = VAR_85.filter(invoice_item__invoice__company_name=company_name)\n",
"VAR_34 = 'download'\n",
"return FUNC_34('Registration_Codes.csv', VAR_85, VAR_34)\n"
] | [
"@ensure_csrf_cookie...\n",
"\"\"\"docstring\"\"\"\n",
"course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\n",
"registration_codes = CourseRegistrationCode.objects.filter(course_id=course_id\n ).order_by('invoice_item__invoice__company_name')\n",
"company_name = request.POST['download_company_name']\n",
"if company_name:\n",
"registration_codes = registration_codes.filter(\n invoice_item__invoice__company_name=company_name)\n",
"csv_type = 'download'\n",
"return registration_codes_csv('Registration_Codes.csv', registration_codes,\n csv_type)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"@VAR_0.route('/shelf/add/<int:shelf_id>/<int:book_id>')...\n",
"VAR_12 = request.headers.get('X-Requested-With') == 'XMLHttpRequest'\n",
"VAR_0 = ub.session.query(ub.Shelf).filter(ub.Shelf.id == VAR_3).first()\n",
"if VAR_0 is None:\n",
"VAR_1.error('Invalid shelf specified: %s', VAR_3)\n",
"if not FUNC_0(VAR_0):\n",
"if not VAR_12:\n",
"if not VAR_12:\n",
"VAR_13 = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == VAR_3,\n ub.BookShelf.book_id == VAR_4).first()\n",
"flash(_(u'Invalid shelf specified'), category='error')\n",
"return 'Invalid shelf specified', 400\n",
"flash(_(u'Sorry you are not allowed to add a book to that shelf'), category\n ='error')\n",
"return 'Sorry you are not allowed to add a book to the that shelf', 403\n",
"if VAR_13:\n",
"return redirect(url_for('web.index'))\n",
"return redirect(url_for('web.index'))\n",
"VAR_1.error('Book %s is already part of %s', VAR_4, VAR_0)\n",
"VAR_14 = ub.session.query(func.max(ub.BookShelf.order)).filter(ub.BookShelf\n .shelf == VAR_3).first()\n",
"if not VAR_12:\n",
"if VAR_14[0] is None:\n",
"flash(_(u'Book is already part of the shelf: %(shelfname)s', shelfname=\n shelf.name), category='error')\n",
"return 'Book is already part of the shelf: %s' % VAR_0.name, 400\n",
"VAR_14 = 0\n",
"VAR_14 = VAR_14[0]\n",
"return redirect(url_for('web.index'))\n",
"VAR_0.books.append(ub.BookShelf(VAR_0=shelf.id, VAR_4=book_id, VAR_9=\n maxOrder + 1))\n",
"VAR_0.last_modified = datetime.utcnow()\n",
"ub.session.merge(VAR_0)\n",
"ub.session.rollback()\n",
"if not VAR_12:\n",
"ub.session.commit()\n",
"VAR_1.error('Settings DB is not Writeable')\n",
"VAR_1.debug('Book has been added to shelf: {}'.format(VAR_0.name))\n",
"return '', 204\n",
"flash(_(u'Settings DB is not Writeable'), category='error')\n",
"flash(_(u'Book has been added to shelf: %(sname)s', sname=shelf.name),\n category='success')\n",
"if 'HTTP_REFERER' in request.environ:\n",
"if 'HTTP_REFERER' in request.environ:\n",
"return redirect(request.environ['HTTP_REFERER'])\n",
"return redirect(url_for('web.index'))\n",
"return redirect(request.environ['HTTP_REFERER'])\n",
"return redirect(url_for('web.index'))\n"
] | [
"@shelf.route('/shelf/add/<int:shelf_id>/<int:book_id>')...\n",
"xhr = request.headers.get('X-Requested-With') == 'XMLHttpRequest'\n",
"shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first()\n",
"if shelf is None:\n",
"log.error('Invalid shelf specified: %s', shelf_id)\n",
"if not check_shelf_edit_permissions(shelf):\n",
"if not xhr:\n",
"if not xhr:\n",
"book_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf ==\n shelf_id, ub.BookShelf.book_id == book_id).first()\n",
"flash(_(u'Invalid shelf specified'), category='error')\n",
"return 'Invalid shelf specified', 400\n",
"flash(_(u'Sorry you are not allowed to add a book to that shelf'), category\n ='error')\n",
"return 'Sorry you are not allowed to add a book to the that shelf', 403\n",
"if book_in_shelf:\n",
"return redirect(url_for('web.index'))\n",
"return redirect(url_for('web.index'))\n",
"log.error('Book %s is already part of %s', book_id, shelf)\n",
"maxOrder = ub.session.query(func.max(ub.BookShelf.order)).filter(ub.\n BookShelf.shelf == shelf_id).first()\n",
"if not xhr:\n",
"if maxOrder[0] is None:\n",
"flash(_(u'Book is already part of the shelf: %(shelfname)s', shelfname=\n shelf.name), category='error')\n",
"return 'Book is already part of the shelf: %s' % shelf.name, 400\n",
"maxOrder = 0\n",
"maxOrder = maxOrder[0]\n",
"return redirect(url_for('web.index'))\n",
"shelf.books.append(ub.BookShelf(shelf=shelf.id, book_id=book_id, order=\n maxOrder + 1))\n",
"shelf.last_modified = datetime.utcnow()\n",
"ub.session.merge(shelf)\n",
"ub.session.rollback()\n",
"if not xhr:\n",
"ub.session.commit()\n",
"log.error('Settings DB is not Writeable')\n",
"log.debug('Book has been added to shelf: {}'.format(shelf.name))\n",
"return '', 204\n",
"flash(_(u'Settings DB is not Writeable'), category='error')\n",
"flash(_(u'Book has been added to shelf: %(sname)s', sname=shelf.name),\n category='success')\n",
"if 'HTTP_REFERER' in request.environ:\n",
"if 'HTTP_REFERER' in request.environ:\n",
"return redirect(request.environ['HTTP_REFERER'])\n",
"return redirect(url_for('web.index'))\n",
"return redirect(request.environ['HTTP_REFERER'])\n",
"return redirect(url_for('web.index'))\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
] | [
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Expr'",
"Return'",
"Expr'",
"Return'",
"Condition",
"Return'",
"Return'",
"Expr'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Return'",
"Assign'",
"Assign'",
"Return'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Return'",
"Expr'",
"Expr'",
"Condition",
"Condition",
"Return'",
"Return'",
"Return'",
"Return'"
] |
[
"def FUNC_30(VAR_27, VAR_32='\\n'):...\n",
"print(VAR_26 + VAR_27, VAR_32=end)\n"
] | [
"def in_print(s, end='\\n'):...\n",
"print(indent_str + s, end=end)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def __str__(self) ->str:...\n",
"return self.sourceName\n"
] | [
"def __str__(self) ->str:...\n",
"return self.sourceName\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_11(VAR_18, VAR_19, VAR_20=None):...\n",
"import time\n",
"VAR_30 = time.time()\n",
"if VAR_20 is None:\n",
"VAR_20 = VAR_30\n",
"if VAR_20 == 0 or VAR_30 - VAR_20 > VAR_18:\n",
"VAR_19()\n",
"return VAR_20\n",
"return VAR_30\n"
] | [
"def doEvery(s, action, lastTime=None):...\n",
"import time\n",
"newTime = time.time()\n",
"if lastTime is None:\n",
"lastTime = newTime\n",
"if lastTime == 0 or newTime - lastTime > s:\n",
"action()\n",
"return lastTime\n",
"return newTime\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Import'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Return'",
"Return'"
] |
[
"@VAR_0.simple_tag...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_42 = VAR_13.get_full_path()\n",
"VAR_43 = iri_to_uri(VAR_42)\n",
"return escape(replace_query_param(VAR_43, VAR_15, VAR_16))\n"
] | [
"@register.simple_tag...\n",
"\"\"\"docstring\"\"\"\n",
"iri = request.get_full_path()\n",
"uri = iri_to_uri(iri)\n",
"return escape(replace_query_param(uri, key, val))\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_22(self):...\n",
"self.assert_expected(self.folder.t, 'CheckI18nTranslate.html')\n"
] | [
"def testI18nTranslate(self):...\n",
"self.assert_expected(self.folder.t, 'CheckI18nTranslate.html')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_4(self):...\n",
"stripBOM(self)\n",
"if self.lineNumbers:\n",
"self.lines = hackyLineNumbers(self.lines)\n",
"self.lines = markdown.stripComments(self.lines)\n",
"self.recordDependencies(self.inputSource)\n",
"self.lines, self.mdDocument = metadata.parse(lines=self.lines)\n",
"self.md = metadata.join(self.mdBaseline, self.mdDocument, self.mdCommandLine)\n",
"self.mdDefaults = metadata.fromJson(data=config.retrieveBoilerplateFile(\n self, 'defaults', error=True), source='defaults')\n",
"self.md = metadata.join(self.mdBaseline, self.mdDefaults, self.mdDocument,\n self.mdCommandLine)\n",
"self.md.fillTextMacros(self.macros, doc=self)\n",
"VAR_22 = {k: json.dumps(v)[1:-1] for k, v in self.macros.items()}\n",
"VAR_23 = replaceMacros(config.retrieveBoilerplateFile(self,\n 'computed-metadata', error=True), VAR_29=jsonEscapedMacros)\n",
"self.mdOverridingDefaults = metadata.fromJson(data=computedMdText, source=\n 'computed-metadata')\n",
"self.md = metadata.join(self.mdBaseline, self.mdDefaults, self.\n mdOverridingDefaults, self.mdDocument, self.mdCommandLine)\n",
"self.md.computeImplicitMetadata(doc=self)\n",
"self.md.fillTextMacros(self.macros, doc=self)\n",
"self.md.validate()\n",
"extensions.load(self)\n",
"self.refs.initializeRefs(self)\n",
"self.refs.initializeBiblio()\n",
"self.lines = datablocks.transformDataBlocks(self, self.lines)\n",
"self.lines = markdown.parse(self.lines, self.md.indent, opaqueElements=self\n .md.opaqueElements, blockElements=self.md.blockElements)\n",
"self.refs.setSpecData(self.md)\n",
"self.html = ''.join(line.text for line in self.lines)\n",
"boilerplate.addHeaderFooter(self)\n",
"self.html = self.fixText(self.html)\n",
"self.document = parseDocument(self.html)\n",
"self.head = find('head', self)\n",
"self.body = find('body', self)\n",
"correctH1(self)\n",
"includes.processInclusions(self)\n",
"metadata.parseDoc(self)\n"
] | [
"def assembleDocument(self):...\n",
"stripBOM(self)\n",
"if self.lineNumbers:\n",
"self.lines = hackyLineNumbers(self.lines)\n",
"self.lines = markdown.stripComments(self.lines)\n",
"self.recordDependencies(self.inputSource)\n",
"self.lines, self.mdDocument = metadata.parse(lines=self.lines)\n",
"self.md = metadata.join(self.mdBaseline, self.mdDocument, self.mdCommandLine)\n",
"self.mdDefaults = metadata.fromJson(data=config.retrieveBoilerplateFile(\n self, 'defaults', error=True), source='defaults')\n",
"self.md = metadata.join(self.mdBaseline, self.mdDefaults, self.mdDocument,\n self.mdCommandLine)\n",
"self.md.fillTextMacros(self.macros, doc=self)\n",
"jsonEscapedMacros = {k: json.dumps(v)[1:-1] for k, v in self.macros.items()}\n",
"computedMdText = replaceMacros(config.retrieveBoilerplateFile(self,\n 'computed-metadata', error=True), macros=jsonEscapedMacros)\n",
"self.mdOverridingDefaults = metadata.fromJson(data=computedMdText, source=\n 'computed-metadata')\n",
"self.md = metadata.join(self.mdBaseline, self.mdDefaults, self.\n mdOverridingDefaults, self.mdDocument, self.mdCommandLine)\n",
"self.md.computeImplicitMetadata(doc=self)\n",
"self.md.fillTextMacros(self.macros, doc=self)\n",
"self.md.validate()\n",
"extensions.load(self)\n",
"self.refs.initializeRefs(self)\n",
"self.refs.initializeBiblio()\n",
"self.lines = datablocks.transformDataBlocks(self, self.lines)\n",
"self.lines = markdown.parse(self.lines, self.md.indent, opaqueElements=self\n .md.opaqueElements, blockElements=self.md.blockElements)\n",
"self.refs.setSpecData(self.md)\n",
"self.html = ''.join(line.text for line in self.lines)\n",
"boilerplate.addHeaderFooter(self)\n",
"self.html = self.fixText(self.html)\n",
"self.document = parseDocument(self.html)\n",
"self.head = find('head', self)\n",
"self.body = find('body', self)\n",
"correctH1(self)\n",
"includes.processInclusions(self)\n",
"metadata.parseDoc(self)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def __init__(self, VAR_3):...\n",
"super().__init__(VAR_3.toDisplayString())\n",
"self.url = VAR_3\n"
] | [
"def __init__(self, url):...\n",
"super().__init__(url.toDisplayString())\n",
"self.url = url\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'"
] |
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_19 = set(VAR_5.required or [])\n",
"required_properties: List[Property] = []\n",
"optional_properties: List[Property] = []\n",
"relative_imports: Set[str] = set()\n",
"VAR_20 = Reference.from_ref(VAR_5.title or VAR_11)\n",
"for key, value in (VAR_5.properties or {}).items():\n",
"VAR_26 = key in VAR_19\n",
"VAR_21 = CLASS_3(VAR_0=ref, required_properties=required_properties,\n optional_properties=optional_properties, relative_imports=\n relative_imports, description=data.description or '')\n",
"VAR_27 = property_from_data(VAR_11=key, VAR_26=required, VAR_5=value)\n",
"return VAR_21\n",
"if isinstance(VAR_27, ParseError):\n",
"return VAR_27\n",
"if VAR_26:\n",
"required_properties.append(VAR_27)\n",
"optional_properties.append(VAR_27)\n",
"relative_imports.update(VAR_27.get_imports(VAR_1=''))\n"
] | [
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"required_set = set(data.required or [])\n",
"required_properties: List[Property] = []\n",
"optional_properties: List[Property] = []\n",
"relative_imports: Set[str] = set()\n",
"ref = Reference.from_ref(data.title or name)\n",
"for key, value in (data.properties or {}).items():\n",
"required = key in required_set\n",
"model = Model(reference=ref, required_properties=required_properties,\n optional_properties=optional_properties, relative_imports=\n relative_imports, description=data.description or '')\n",
"p = property_from_data(name=key, required=required, data=value)\n",
"return model\n",
"if isinstance(p, ParseError):\n",
"return p\n",
"if required:\n",
"required_properties.append(p)\n",
"optional_properties.append(p)\n",
"relative_imports.update(p.get_imports(prefix=''))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"AnnAssign'",
"AnnAssign'",
"AnnAssign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Condition",
"Return'",
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |