lines
sequencelengths 1
444
| raw_lines
sequencelengths 1
444
| label
sequencelengths 1
444
| type
sequencelengths 1
444
|
---|---|---|---|
[
"def FUNC_17(self):...\n",
"self._test_strtype('blob', None, 100)\n"
] | [
"def test_null_blob(self):...\n",
"self._test_strtype('blob', None, 100)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_2():...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = {}\n",
"for arg in request.args:\n",
"VAR_8 = re.findall('psize_(.*)', arg)\n",
"return VAR_6\n",
"if VAR_8:\n",
"VAR_6[VAR_8[0]] = int(request.args.get(arg))\n"
] | [
"def get_page_size_args():...\n",
"\"\"\"docstring\"\"\"\n",
"page_sizes = {}\n",
"for arg in request.args:\n",
"re_match = re.findall('psize_(.*)', arg)\n",
"return page_sizes\n",
"if re_match:\n",
"page_sizes[re_match[0]] = int(request.args.get(arg))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"For",
"Assign'",
"Return'",
"Condition",
"Assign'"
] |
[
"def FUNC_6(self):...\n",
"if self.status_code not in [200, 302]:\n",
"return False\n",
"if self.status_code == 200 and self.res_data is None:\n",
"return False\n",
"if self.status_code == 200 and len(self.res_data) < CLASS_1.MINIMUM_LENGTH:\n",
"return False\n",
"return True\n"
] | [
"def test_success(self):...\n",
"if self.status_code not in [200, 302]:\n",
"return False\n",
"if self.status_code == 200 and self.res_data is None:\n",
"return False\n",
"if self.status_code == 200 and len(self.res_data\n",
"return False\n",
"return True\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_33(self):...\n",
"self.compilation_ko(\n \"\"\"\nif anyof (header :is \"Sender\" {\n fileinto \"trash\";\n}\n\"\"\")\n"
] | [
"def test_nonclosed_tests_list2(self):...\n",
"self.compilation_ko(\n \"\"\"\nif anyof (header :is \"Sender\" {\n fileinto \"trash\";\n}\n\"\"\")\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@staticmethod...\n",
"VAR_27 = []\n",
"VAR_28 = 'camera_name', 'lens_name', 'country_en'\n",
"VAR_29 = VAR_8.camera, VAR_8.lens, VAR_8.country['en-US']\n",
"for feature_name, VAR_5 in zip(VAR_28, VAR_29):\n",
"if not VAR_5:\n",
"return VAR_27\n",
"VAR_27.append(0)\n",
"VAR_10 = FUNC_8(VAR_5, feature_name)\n",
"VAR_27.append(VAR_10)\n"
] | [
"@staticmethod...\n",
"same_feature = []\n",
"feature_types = 'camera_name', 'lens_name', 'country_en'\n",
"features = image_data.camera, image_data.lens, image_data.country['en-US']\n",
"for feature_name, feature in zip(feature_types, features):\n",
"if not feature:\n",
"return same_feature\n",
"same_feature.append(0)\n",
"answer = get_number_users_by_feature(feature, feature_name)\n",
"same_feature.append(answer)\n"
] | [
0,
0,
0,
4,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Return'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"@login_required()...\n",
"VAR_5 = {}\n",
"VAR_6, VAR_7 = FUNC_5(**kwargs)\n",
"VAR_5['concept'] = VAR_6\n",
"VAR_4 = VAR_6.transaction\n",
"if VAR_4.closed:\n",
"return redirect('message', message=gettext('Transaction Closed'))\n",
"VAR_5['transaction'] = VAR_4\n",
"if VAR_0.method == 'POST':\n",
"VAR_26 = VAR_7(VAR_0.POST, instance=concept)\n",
"VAR_26 = VAR_7(instance=concept)\n",
"if VAR_26.is_valid():\n",
"VAR_5['form'] = VAR_26\n",
"VAR_26.save()\n",
"VAR_5['form'] = VAR_26\n",
"return render(VAR_0, 'transactions/concept_edit.html', VAR_5)\n",
"return redirect('transaction_edit', VAR_20=transaction.code)\n",
"return render(VAR_0, 'transactions/concept_edit.html', VAR_5)\n"
] | [
"@login_required()...\n",
"extra_context = {}\n",
"concept, concept_form = get_concept_and_form_from_kwargs(**kwargs)\n",
"extra_context['concept'] = concept\n",
"transaction = concept.transaction\n",
"if transaction.closed:\n",
"return redirect('message', message=gettext('Transaction Closed'))\n",
"extra_context['transaction'] = transaction\n",
"if request.method == 'POST':\n",
"form = concept_form(request.POST, instance=concept)\n",
"form = concept_form(instance=concept)\n",
"if form.is_valid():\n",
"extra_context['form'] = form\n",
"form.save()\n",
"extra_context['form'] = form\n",
"return render(request, 'transactions/concept_edit.html', extra_context)\n",
"return redirect('transaction_edit', transaction_code=transaction.code)\n",
"return render(request, 'transactions/concept_edit.html', extra_context)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Return'",
"Return'",
"Return'"
] |
[
"def FUNC_25(self):...\n",
"if not self._IsServerAlive():\n",
"return\n",
"VAR_23 = BaseRequest.PostDataToHandler(BuildRequestData(),\n 'detailed_diagnostic')\n",
"vimsupport.PostVimMessage(str(e))\n",
"if 'message' in VAR_23:\n",
"vimsupport.EchoText(VAR_23['message'])\n"
] | [
"def ShowDetailedDiagnostic(self):...\n",
"if not self._IsServerAlive():\n",
"return\n",
"debug_info = BaseRequest.PostDataToHandler(BuildRequestData(),\n 'detailed_diagnostic')\n",
"vimsupport.PostVimMessage(str(e))\n",
"if 'message' in debug_info:\n",
"vimsupport.EchoText(debug_info['message'])\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Condition",
"Expr'"
] |
[
"@app.route('/dds')...\n",
"return redirect('https://soundcloud.com/doobiedecibelsystem')\n"
] | [
"@app.route('/dds')...\n",
"return redirect('https://soundcloud.com/doobiedecibelsystem')\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_14(self):...\n",
"\"\"\"docstring\"\"\"\n",
"for unit in (self.metadata('custom_units') or []):\n",
"ureg.define(unit)\n"
] | [
"def register_custom_units(self):...\n",
"\"\"\"docstring\"\"\"\n",
"for unit in (self.metadata('custom_units') or []):\n",
"ureg.define(unit)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"For",
"Expr'"
] |
[
"def FUNC_22(VAR_30, VAR_3):...\n",
"if not isinstance(VAR_30, _IOFile):\n",
"return IOFile(VAR_30, VAR_16=self)\n",
"return VAR_30.apply_wildcards(VAR_3, fill_missing=f in self.dynamic_input,\n fail_dynamic=self.dynamic_output)\n"
] | [
"def concretize_iofile(f, wildcards):...\n",
"if not isinstance(f, _IOFile):\n",
"return IOFile(f, rule=self)\n",
"return f.apply_wildcards(wildcards, fill_missing=f in self.dynamic_input,\n fail_dynamic=self.dynamic_output)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_1(VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"verbout(GR, 'Receiving headers...\\n')\n",
"verbout(color.GREY, ' ' + color.UNDERLINE + 'HEADERS' + color.END + color.\n GREY + ':' + '\\n')\n",
"for key, val in VAR_2.items():\n",
"verbout(' ', color.CYAN + key + ': ' + color.ORANGE + val)\n",
"verbout('', '')\n"
] | [
"def pheaders(tup):...\n",
"\"\"\"docstring\"\"\"\n",
"verbout(GR, 'Receiving headers...\\n')\n",
"verbout(color.GREY, ' ' + color.UNDERLINE + 'HEADERS' + color.END + color.\n GREY + ':' + '\\n')\n",
"for key, val in tup.items():\n",
"verbout(' ', color.CYAN + key + ': ' + color.ORANGE + val)\n",
"verbout('', '')\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Expr'",
"For",
"Expr'",
"Expr'"
] |
[
"def FUNC_11(self, VAR_38):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_71 = ''\n",
"if VAR_38:\n",
"VAR_55 = VAR_38.keys()[0]\n",
"return VAR_71\n",
"VAR_90 = getattr(self, self.WHERE_CONDITION_MAPPING.get(VAR_55))\n",
"VAR_71 = VAR_90(VAR_38[VAR_55])\n"
] | [
"def _generate_sql_condition(self, data):...\n",
"\"\"\"docstring\"\"\"\n",
"result = ''\n",
"if data:\n",
"condition = data.keys()[0]\n",
"return result\n",
"function = getattr(self, self.WHERE_CONDITION_MAPPING.get(condition))\n",
"result = function(data[condition])\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Assign'"
] |
[
"def FUNC_10(self):...\n",
"self.client.login(username=self.tester.username, password='password')\n",
"VAR_4 = {'content_type': 'testplans.testplan', 'object_pk': self.plan.pk,\n 'field': 'is_active', 'value': 'False', 'value_type': 'bool'}\n",
"VAR_1 = self.client.post(self.update_url, VAR_4)\n",
"self.assertJSONEqual(str(VAR_1.content, encoding=settings.DEFAULT_CHARSET),\n {'rc': 0, 'response': 'ok'})\n",
"VAR_5 = TestPlan.objects.get(pk=self.plan.pk)\n",
"self.assertFalse(VAR_5.is_active)\n"
] | [
"def test_update_plan_is_active(self):...\n",
"self.client.login(username=self.tester.username, password='password')\n",
"post_data = {'content_type': 'testplans.testplan', 'object_pk': self.plan.\n pk, 'field': 'is_active', 'value': 'False', 'value_type': 'bool'}\n",
"response = self.client.post(self.update_url, post_data)\n",
"self.assertJSONEqual(str(response.content, encoding=settings.\n DEFAULT_CHARSET), {'rc': 0, 'response': 'ok'})\n",
"plan = TestPlan.objects.get(pk=self.plan.pk)\n",
"self.assertFalse(plan.is_active)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_0(self):...\n",
"super(CLASS_2, self).setUp()\n",
"self.view = UserUpdateView()\n",
"VAR_2 = self.factory.get('/fake-url')\n",
"VAR_2.user = self.user\n",
"self.view.request = VAR_2\n"
] | [
"def setUp(self):...\n",
"super(TestUserUpdateView, self).setUp()\n",
"self.view = UserUpdateView()\n",
"request = self.factory.get('/fake-url')\n",
"request.user = self.user\n",
"self.view.request = request\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_1():...\n",
""
] | [
"def connect():...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_4(self, VAR_1, VAR_2, VAR_5, VAR_10=None, VAR_11=False, VAR_4=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_10:\n",
"VAR_10 = []\n",
"if VAR_4 is None:\n",
"VAR_4 = {}\n",
"VAR_29 = {}\n",
"for VAR_48 in VAR_5:\n",
"VAR_29[VAR_48] = {}.fromkeys(VAR_10, 0.0)\n",
"for VAR_55 in VAR_10:\n",
"VAR_49 = VAR_4.copy()\n",
"return VAR_29\n",
"if VAR_55 == 'qty_available':\n",
"VAR_49.update({'states': ('done',), 'what': ('in', 'out')})\n",
"if VAR_55 == 'virtual_available':\n",
"VAR_49.update({'states': ('confirmed', 'waiting', 'assigned', 'done'),\n 'what': ('in', 'out')})\n",
"if VAR_55 == 'incoming_qty':\n",
"VAR_49.update({'states': ('confirmed', 'waiting', 'assigned'), 'what': ('in',)}\n )\n",
"if VAR_55 == 'outgoing_qty':\n",
"VAR_49.update({'states': ('confirmed', 'waiting', 'assigned'), 'what': (\n 'out',)})\n",
"VAR_50 = self.get_product_available(VAR_1, VAR_2, VAR_5, VAR_4=c)\n",
"for VAR_48 in VAR_5:\n",
"VAR_29[VAR_48][VAR_55] = VAR_50.get(VAR_48, 0.0)\n"
] | [
"def _product_available(self, cr, uid, ids, field_names=None, arg=False,...\n",
"\"\"\"docstring\"\"\"\n",
"if not field_names:\n",
"field_names = []\n",
"if context is None:\n",
"context = {}\n",
"res = {}\n",
"for id in ids:\n",
"res[id] = {}.fromkeys(field_names, 0.0)\n",
"for f in field_names:\n",
"c = context.copy()\n",
"return res\n",
"if f == 'qty_available':\n",
"c.update({'states': ('done',), 'what': ('in', 'out')})\n",
"if f == 'virtual_available':\n",
"c.update({'states': ('confirmed', 'waiting', 'assigned', 'done'), 'what': (\n 'in', 'out')})\n",
"if f == 'incoming_qty':\n",
"c.update({'states': ('confirmed', 'waiting', 'assigned'), 'what': ('in',)})\n",
"if f == 'outgoing_qty':\n",
"c.update({'states': ('confirmed', 'waiting', 'assigned'), 'what': ('out',)})\n",
"stock = self.get_product_available(cr, uid, ids, context=c)\n",
"for id in ids:\n",
"res[id][f] = stock.get(id, 0.0)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"For",
"Assign'",
"For",
"Assign'",
"Return'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"For",
"Assign'"
] |
[
"def FUNC_0(self):...\n",
"if not LoginRequest.test_success(self):\n",
"return False\n",
"if self.redirected_to != self.base_url:\n",
"return False\n",
"return True\n"
] | [
"def test_success(self):...\n",
"if not LoginRequest.test_success(self):\n",
"return False\n",
"if self.redirected_to != self.base_url:\n",
"return False\n",
"return True\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def __init__(self, VAR_15, VAR_16, VAR_17):...\n",
"\"\"\"docstring\"\"\"\n",
"self._name = 'Netatmo {} {}'.format(VAR_16, VAR_5[VAR_17][0])\n",
"self.netatmo_data = VAR_15\n",
"self.module_name = VAR_16\n",
"self.type = VAR_17\n",
"self._state = None\n",
"self._device_class = VAR_5[self.type][3]\n",
"self._icon = VAR_5[self.type][2]\n",
"self._unit_of_measurement = VAR_5[self.type][1]\n",
"VAR_20 = self.netatmo_data.station_data.moduleByName(module=module_name)['_id']\n",
"self.module_id = VAR_20[1]\n"
] | [
"def __init__(self, netatmo_data, module_name, sensor_type):...\n",
"\"\"\"docstring\"\"\"\n",
"self._name = 'Netatmo {} {}'.format(module_name, SENSOR_TYPES[sensor_type][0])\n",
"self.netatmo_data = netatmo_data\n",
"self.module_name = module_name\n",
"self.type = sensor_type\n",
"self._state = None\n",
"self._device_class = SENSOR_TYPES[self.type][3]\n",
"self._icon = SENSOR_TYPES[self.type][2]\n",
"self._unit_of_measurement = SENSOR_TYPES[self.type][1]\n",
"module_id = self.netatmo_data.station_data.moduleByName(module=module_name)[\n '_id']\n",
"self.module_id = module_id[1]\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def __str__(self):...\n",
"return str(self.raw_chem_name) if self.raw_chem_name else ''\n"
] | [
"def __str__(self):...\n",
"return str(self.raw_chem_name) if self.raw_chem_name else ''\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@classmethod...\n",
"VAR_31 = lambda _request: None\n",
"return [VAR_31, VAR_31]\n"
] | [
"@classmethod...\n",
"non_applicable = lambda _request: None\n",
"return [non_applicable, non_applicable]\n"
] | [
0,
0,
0
] | [
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_2(VAR_0):...\n",
"\"\"\"docstring\"\"\"\n"
] | [
"def rw_transaction(request):...\n",
"\"\"\"docstring\"\"\"\n"
] | [
0,
0
] | [
"FunctionDef'",
"Docstring"
] |
[
"def FUNC_3(self, VAR_6):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_6:\n",
"return []\n",
"VAR_14 = 'string'\n",
"self.cursor.execute(VAR_14, [tuple(VAR_6)])\n",
"return self.cursor.fetchall()\n"
] | [
"def get_cve_cwe_map(self, ids):...\n",
"\"\"\"docstring\"\"\"\n",
"if not ids:\n",
"return []\n",
"query = (\n 'SELECT cve_id, cwe.name, cwe.link FROM cve_cwe map JOIN cwe ON map.cwe_id = cwe.id WHERE map.cve_id IN %s'\n )\n",
"self.cursor.execute(query, [tuple(ids)])\n",
"return self.cursor.fetchall()\n"
] | [
0,
0,
0,
0,
4,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Expr'",
"Return'"
] |
[
"import praw\n",
"import re\n",
"from datetime import datetime\n",
"import operator\n",
"import sqlite3\n",
"def FUNC_0(VAR_0):...\n",
"VAR_4 = datetime.fromtimestamp(VAR_0.created)\n",
"return VAR_4.strftime('%Y-%m-%d %H:%M:%S')\n"
] | [
"import praw\n",
"import re\n",
"from datetime import datetime\n",
"import operator\n",
"import sqlite3\n",
"def getDate(submission):...\n",
"time = datetime.fromtimestamp(submission.created)\n",
"return time.strftime('%Y-%m-%d %H:%M:%S')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"ImportFrom'",
"Import'",
"Import'",
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def __init__(self):...\n",
"VAR_0 = []\n",
"VAR_6 = os.path.join(settings.config_dir, 'commands.json')\n",
"if os.path.isfile(VAR_6):\n",
"VAR_0.extend(json.load(json_commands_file))\n",
"self.commands = [CLASS_0(c, VAR_2=True) for c in VAR_0]\n"
] | [
"def __init__(self):...\n",
"commands = []\n",
"ro_commands_file = os.path.join(settings.config_dir, 'commands.json')\n",
"if os.path.isfile(ro_commands_file):\n",
"commands.extend(json.load(json_commands_file))\n",
"self.commands = [Command(c, readonly=True) for c in commands]\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'"
] |
[
"def FUNC_31(VAR_1, VAR_16):...\n",
"VAR_30 = VAR_1.xsrf_token_data == {'some': 'data'}\n",
"VAR_12.append((VAR_16, VAR_30))\n"
] | [
"def record(request_handler, method):...\n",
"is_valid = request_handler.xsrf_token_data == {'some': 'data'}\n",
"calls.append((method, is_valid))\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_2(VAR_9):...\n",
"\"\"\"docstring\"\"\"\n",
"if isinstance(VAR_9, str):\n",
"return VAR_9\n",
"if isinstance(VAR_9, unicode):\n",
"return VAR_9.encode('utf-8')\n",
"return str(VAR_9)\n"
] | [
"def _ConvertToAscii(value):...\n",
"\"\"\"docstring\"\"\"\n",
"if isinstance(value, str):\n",
"return value\n",
"if isinstance(value, unicode):\n",
"return value.encode('utf-8')\n",
"return str(value)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_7(self):...\n",
"VAR_18 = 'URL: %s\\n' % unicode(self.url)\n",
"if self.response is not None:\n",
"VAR_18 += \"\"\"\nREQUEST HEADERS\n\"\"\"\n",
"VAR_18 += \"\"\"\nNO REQUEST INFORMATION AVAILABLE\n\"\"\"\n",
"for key, value in self.response.request.headers.iteritems():\n",
"if self.res_data is not None:\n",
"VAR_18 += '%s: %s\\n' % (key, value)\n",
"VAR_18 += \"\"\"\nREQUEST DATA\n%s\n\"\"\" % self.response.request.body\n",
"VAR_19 = self.response.headers.items()\n",
"VAR_18 += \"\"\"\nNO RESPONSE INFORMATION AVAILABLE\n\"\"\"\n",
"VAR_18 += \"\"\"\nRESPONSE HEADERS\n%s\"\"\" % ''.join([('%s: %s\\n' % (header[0],\n header[1])) for header in VAR_19])\n",
"return VAR_18\n",
"VAR_18 += \"\"\"\nRESPONSE DATA\n%s\n\"\"\" % self.res_data\n"
] | [
"def specific_info(self):...\n",
"res = 'URL: %s\\n' % unicode(self.url)\n",
"if self.response is not None:\n",
"res += \"\"\"\nREQUEST HEADERS\n\"\"\"\n",
"res += \"\"\"\nNO REQUEST INFORMATION AVAILABLE\n\"\"\"\n",
"for key, value in self.response.request.headers.iteritems():\n",
"if self.res_data is not None:\n",
"res += '%s: %s\\n' % (key, value)\n",
"res += \"\"\"\nREQUEST DATA\n%s\n\"\"\" % self.response.request.body\n",
"headers = self.response.headers.items()\n",
"res += \"\"\"\nNO RESPONSE INFORMATION AVAILABLE\n\"\"\"\n",
"res += \"\"\"\nRESPONSE HEADERS\n%s\"\"\" % ''.join([('%s: %s\\n' % (header[0],\n header[1])) for header in headers])\n",
"return res\n",
"res += \"\"\"\nRESPONSE DATA\n%s\n\"\"\" % self.res_data\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"AugAssign'",
"AugAssign'",
"For",
"Condition",
"AugAssign'",
"AugAssign'",
"Assign'",
"AugAssign'",
"AugAssign'",
"Return'",
"AugAssign'"
] |
[
"def FUNC_2(self):...\n",
"self._check_key(VAR_0)\n"
] | [
"def test_rsa_key(self):...\n",
"self._check_key(RSA_PUBKEY)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_0(VAR_2, VAR_3, VAR_4=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_4 = dict(VAR_4 or {})\n",
"VAR_4['Content-Length'] = len(VAR_2)\n",
"def __init__(self):...\n",
"self.content = VAR_2\n",
"def FUNC_6(self, VAR_7):...\n",
"VAR_8 = self.content\n",
"while VAR_8:\n",
"yield VAR_8[:VAR_7]\n",
"def FUNC_7(self):...\n",
"VAR_8 = VAR_8[VAR_7:]\n",
"return self.content\n"
] | [
"def make_fake_response(content, url, headers=None):...\n",
"\"\"\"docstring\"\"\"\n",
"headers = dict(headers or {})\n",
"headers['Content-Length'] = len(content)\n",
"def __init__(self):...\n",
"self.content = content\n",
"def iter_content(self, chunk_size):...\n",
"c = self.content\n",
"while c:\n",
"yield c[:chunk_size]\n",
"def read(self):...\n",
"c = c[chunk_size:]\n",
"return self.content\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"FunctionDef'",
"Assign'",
"Condition",
"Expr'",
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_8(VAR_10):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_25 = []\n",
"VAR_26 = []\n",
"VAR_27 = CommerceConfiguration.current()\n",
"VAR_28 = {'username': VAR_10.username}\n",
"VAR_29 = VAR_27.is_cache_enabled\n",
"VAR_30 = VAR_27.CACHE_KEY + '.' + str(VAR_10.id) if VAR_29 else None\n",
"VAR_31 = ecommerce_api_client(VAR_10)\n",
"VAR_32 = get_edx_api_data(VAR_27, 'orders', VAR_31=api, querystring=\n user_query, VAR_30=cache_key)\n",
"for order in VAR_32:\n",
"if order['status'].lower() == 'complete':\n",
"return VAR_26\n",
"VAR_42 = datetime.strptime(order['date_placed'], '%Y-%m-%dT%H:%M:%SZ')\n",
"VAR_43 = {'number': order['number'], 'price': order['total_excl_tax'],\n 'order_date': strftime_localized(VAR_42, 'SHORT_DATE'), 'receipt_url':\n EcommerceService().get_receipt_page_url(order['number']), 'lines':\n order['lines']}\n",
"VAR_26.append(VAR_43)\n"
] | [
"def get_user_orders(user):...\n",
"\"\"\"docstring\"\"\"\n",
"no_data = []\n",
"user_orders = []\n",
"commerce_configuration = CommerceConfiguration.current()\n",
"user_query = {'username': user.username}\n",
"use_cache = commerce_configuration.is_cache_enabled\n",
"cache_key = commerce_configuration.CACHE_KEY + '.' + str(user.id\n ) if use_cache else None\n",
"api = ecommerce_api_client(user)\n",
"commerce_user_orders = get_edx_api_data(commerce_configuration, 'orders',\n api=api, querystring=user_query, cache_key=cache_key)\n",
"for order in commerce_user_orders:\n",
"if order['status'].lower() == 'complete':\n",
"return user_orders\n",
"date_placed = datetime.strptime(order['date_placed'], '%Y-%m-%dT%H:%M:%SZ')\n",
"order_data = {'number': order['number'], 'price': order['total_excl_tax'],\n 'order_date': strftime_localized(date_placed, 'SHORT_DATE'),\n 'receipt_url': EcommerceService().get_receipt_page_url(order['number']),\n 'lines': order['lines']}\n",
"user_orders.append(order_data)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_9(self, VAR_9, VAR_10):...\n",
"if self._IsServerAlive():\n",
"return FUNC_9(VAR_9, VAR_10)\n"
] | [
"def SendCommandRequest(self, arguments, completer):...\n",
"if self._IsServerAlive():\n",
"return SendCommandRequest(arguments, completer)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'"
] |
[
"def FUNC_8(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = self.charset\n",
"if self._path is not None:\n",
"return url_escape(self._path, b\"^A-Za-z0-9\\\\-._~!$&\\\\'()*+,;=%:@/\")\n",
"if self._parts:\n",
"VAR_12 = self._parts\n",
"VAR_7 = b''\n",
"if VAR_2:\n",
"if self._leading_slash:\n",
"VAR_12 = map(lambda p: p.encode(VAR_2), VAR_12)\n",
"VAR_7 = b'/'.join(map(lambda p: url_escape(p,\n b\"^A-Za-z0-9\\\\-._~!$&\\\\'()*+,;=:@\"), VAR_12))\n",
"VAR_7 = b'/' + VAR_7\n",
"if self._trailing_slash:\n",
"VAR_7 = VAR_7 + b'/'\n",
"return VAR_7\n"
] | [
"def to_bytes(self):...\n",
"\"\"\"docstring\"\"\"\n",
"charset = self.charset\n",
"if self._path is not None:\n",
"return url_escape(self._path, b\"^A-Za-z0-9\\\\-._~!$&\\\\'()*+,;=%:@/\")\n",
"if self._parts:\n",
"parts = self._parts\n",
"path = b''\n",
"if charset:\n",
"if self._leading_slash:\n",
"parts = map(lambda p: p.encode(charset), parts)\n",
"path = b'/'.join(map(lambda p: url_escape(p,\n b\"^A-Za-z0-9\\\\-._~!$&\\\\'()*+,;=:@\"), parts))\n",
"path = b'/' + path\n",
"if self._trailing_slash:\n",
"path = path + b'/'\n",
"return path\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_24(VAR_19, VAR_20, VAR_21=None):...\n",
"VAR_28 = None\n",
"if VAR_21:\n",
"VAR_28 = jsonutils.dumps({'httpStatus': 'dummy', 'error_code': VAR_21,\n 'module_name': 'dummy', 'error_message': 'bad'})\n",
"VAR_29 = mocks.MockRequestsResponse(VAR_20, VAR_28)\n",
"VAR_30 = self.new_mocked_client(client.RESTClient, mock_validate=False,\n session_response=response)\n",
"VAR_31 = getattr(VAR_30, 'url_%s' % VAR_19)\n",
"VAR_31('', None)\n"
] | [
"def _verb_response_code(http_verb, status_code, error_code=None):...\n",
"content = None\n",
"if error_code:\n",
"content = jsonutils.dumps({'httpStatus': 'dummy', 'error_code': error_code,\n 'module_name': 'dummy', 'error_message': 'bad'})\n",
"response = mocks.MockRequestsResponse(status_code, content)\n",
"client_api = self.new_mocked_client(client.RESTClient, mock_validate=False,\n session_response=response)\n",
"client_call = getattr(client_api, 'url_%s' % http_verb)\n",
"client_call('', None)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_6(self, VAR_19, VAR_17=None, VAR_18=None):...\n",
"for ending in ['/', '/index.html']:\n",
"if VAR_19.endswith(ending):\n",
"VAR_0.debug('Redirecting %s', self)\n",
"VAR_19 = VAR_19[1:]\n",
"VAR_27 = re.sub(ending + '$', '.html', VAR_19)\n",
"return self.get_full_path(VAR_16=to, VAR_17=language, VAR_18=version_slug)\n"
] | [
"def redirect_sphinx_html(self, path, language=None, version_slug=None):...\n",
"for ending in ['/', '/index.html']:\n",
"if path.endswith(ending):\n",
"log.debug('Redirecting %s', self)\n",
"path = path[1:]\n",
"to = re.sub(ending + '$', '.html', path)\n",
"return self.get_full_path(filename=to, language=language, version_slug=\n version_slug)\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_3(VAR_0):...\n",
"import pdb\n",
"pdb.set_trace()\n"
] | [
"def SetUpAppendRedirect(cmd):...\n",
"import pdb\n",
"pdb.set_trace()\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Import'",
"Expr'"
] |
[
"@auth.route('/oauthorize')...\n",
"VAR_1 = twitter.authorized_response()\n",
"if not VAR_1:\n",
"flash(u'You denied the request to sign in.')\n",
"VAR_2 = VAR_1['user_id']\n",
"return redirect(url_for('gallery.show_posts'))\n",
"VAR_3 = User.query.filter_by(VAR_2=user_id).first()\n",
"if VAR_3:\n",
"login_user(VAR_3)\n",
"VAR_6['user_id'] = VAR_2\n",
"VAR_5 = request.args.get('next')\n",
"VAR_6['token'] = VAR_1['oauth_token']\n",
"flash('You were signed in as %s' % VAR_3.username)\n",
"VAR_6['secret'] = VAR_1['oauth_token_secret']\n",
"return redirect(url_for('auth.test'))\n",
"return redirect(url_for('auth.signup'))\n"
] | [
"@auth.route('/oauthorize')...\n",
"resp = twitter.authorized_response()\n",
"if not resp:\n",
"flash(u'You denied the request to sign in.')\n",
"user_id = resp['user_id']\n",
"return redirect(url_for('gallery.show_posts'))\n",
"user = User.query.filter_by(user_id=user_id).first()\n",
"if user:\n",
"login_user(user)\n",
"session['user_id'] = user_id\n",
"next = request.args.get('next')\n",
"session['token'] = resp['oauth_token']\n",
"flash('You were signed in as %s' % user.username)\n",
"session['secret'] = resp['oauth_token_secret']\n",
"return redirect(url_for('auth.test'))\n",
"return redirect(url_for('auth.signup'))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
6,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'",
"Return'"
] |
[
"def FUNC_6(self, VAR_7):...\n",
"VAR_76 = CLASS_6.run(self, VAR_7)\n",
"if VAR_76 and not (VAR_101.user_is_loggedin and VAR_76.can_edit(VAR_101.\n",
"abort(403, 'forbidden')\n",
"return VAR_76\n"
] | [
"def run(self, param):...\n",
"meetup = VMeetup.run(self, param)\n",
"if meetup and not (c.user_is_loggedin and meetup.can_edit(c.user, c.\n",
"abort(403, 'forbidden')\n",
"return meetup\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Expr'",
"Return'"
] |
[
"def FUNC_4(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = self\n",
"@classmethod...\n",
"VAR_31 = lambda _request: None\n",
"return [VAR_31, VAR_31]\n"
] | [
"def test_anonymous(self):...\n",
"\"\"\"docstring\"\"\"\n",
"test = self\n",
"@classmethod...\n",
"non_applicable = lambda _request: None\n",
"return [non_applicable, non_applicable]\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"@utils.synchronized('3par', external=True)...\n",
"self.common.client_login()\n",
"VAR_16 = self.common.get_volume_stats(VAR_4)\n",
"VAR_16['storage_protocol'] = 'FC'\n",
"VAR_17 = self.configuration.safe_get('volume_backend_name')\n",
"VAR_16['volume_backend_name'] = VAR_17 or self.__class__.__name__\n",
"self.common.client_logout()\n",
"return VAR_16\n"
] | [
"@utils.synchronized('3par', external=True)...\n",
"self.common.client_login()\n",
"stats = self.common.get_volume_stats(refresh)\n",
"stats['storage_protocol'] = 'FC'\n",
"backend_name = self.configuration.safe_get('volume_backend_name')\n",
"stats['volume_backend_name'] = backend_name or self.__class__.__name__\n",
"self.common.client_logout()\n",
"return stats\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_3(VAR_5: HttpRequest, VAR_6: str='/admin/users'):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_10 = VAR_6\n",
"if VAR_5.GET.get('redirect'):\n",
"VAR_10 = VAR_5.GET['redirect']\n",
"if not VAR_5.user.is_authenticated:\n",
"return HttpResponseForbidden()\n",
"VAR_11 = Profile.objects.get(authuser=request.user)\n",
"if VAR_11.rights < 2:\n",
"return HttpResponseForbidden()\n",
"if VAR_5.GET.get('user_id'):\n",
"return HttpResponseBadRequest(str(e))\n",
"return redirect(VAR_10)\n",
"VAR_12 = int(VAR_5.GET['user_id'])\n",
"VAR_18 = str(VAR_5.POST['username'])\n",
"VAR_13 = str(VAR_5.POST['display_name'])\n",
"VAR_13 = str(VAR_5.POST['display_name'])\n",
"VAR_14 = int(VAR_5.POST['dect'])\n",
"VAR_14 = int(VAR_5.POST['dect'])\n",
"VAR_15 = str(VAR_5.POST['notes'])\n",
"VAR_15 = str(VAR_5.POST['notes'])\n",
"VAR_2 = str(VAR_5.POST['password'])\n",
"VAR_2 = str(VAR_5.POST['password'])\n",
"VAR_3 = str(VAR_5.POST['confirm_password'])\n",
"VAR_3 = str(VAR_5.POST['confirm_password'])\n",
"VAR_16 = str(VAR_5.POST['email'])\n",
"VAR_16 = str(VAR_5.POST['email'])\n",
"VAR_17 = int(VAR_5.POST['rights'])\n",
"VAR_17 = int(VAR_5.POST['rights'])\n",
"user: Profile = Profile.objects.get(pk=pid)\n",
"if not FUNC_1(VAR_2, VAR_3):\n",
"user.displayName = VAR_13\n",
"FUNC_2('password mismatch')\n",
"auth_user: User = User.objects.create_user(VAR_18=username, email=mail,\n password=pw1)\n",
"user.dect = VAR_14\n",
"auth_user.save()\n",
"user.notes = VAR_15\n",
"user: Profile = Profile()\n",
"user.rights = VAR_17\n",
"user.rights = VAR_17\n",
"user.number_of_allowed_reservations = int(VAR_5.POST['allowed_reservations'])\n",
"user.number_of_allowed_reservations = int(VAR_5.POST['allowed_reservations'])\n",
"if VAR_5.POST.get('active'):\n",
"user.displayName = VAR_13\n",
"user.active = magic.parse_bool(VAR_5.POST['active'])\n",
"au: User = user.authuser\n",
"user.authuser = auth_user\n",
"if FUNC_1(VAR_2, VAR_3):\n",
"user.dect = VAR_14\n",
"logging.log(logging.INFO, 'Set password for user: ' + user.displayName)\n",
"logging.log(logging.INFO, 'Failed to set password for: ' + user.displayName)\n",
"user.notes = VAR_15\n",
"au.set_password(VAR_2)\n",
"au.email = VAR_16\n",
"user.active = True\n",
"au.save()\n",
"user.save()\n",
"user.save()\n"
] | [
"def action_save_user(request: HttpRequest, default_forward_url: str=...\n",
"\"\"\"docstring\"\"\"\n",
"forward_url = default_forward_url\n",
"if request.GET.get('redirect'):\n",
"forward_url = request.GET['redirect']\n",
"if not request.user.is_authenticated:\n",
"return HttpResponseForbidden()\n",
"profile = Profile.objects.get(authuser=request.user)\n",
"if profile.rights < 2:\n",
"return HttpResponseForbidden()\n",
"if request.GET.get('user_id'):\n",
"return HttpResponseBadRequest(str(e))\n",
"return redirect(forward_url)\n",
"pid = int(request.GET['user_id'])\n",
"username = str(request.POST['username'])\n",
"displayname = str(request.POST['display_name'])\n",
"displayname = str(request.POST['display_name'])\n",
"dect = int(request.POST['dect'])\n",
"dect = int(request.POST['dect'])\n",
"notes = str(request.POST['notes'])\n",
"notes = str(request.POST['notes'])\n",
"pw1 = str(request.POST['password'])\n",
"pw1 = str(request.POST['password'])\n",
"pw2 = str(request.POST['confirm_password'])\n",
"pw2 = str(request.POST['confirm_password'])\n",
"mail = str(request.POST['email'])\n",
"mail = str(request.POST['email'])\n",
"rights = int(request.POST['rights'])\n",
"rights = int(request.POST['rights'])\n",
"user: Profile = Profile.objects.get(pk=pid)\n",
"if not check_password_conformity(pw1, pw2):\n",
"user.displayName = displayname\n",
"recreate_form('password mismatch')\n",
"auth_user: User = User.objects.create_user(username=username, email=mail,\n password=pw1)\n",
"user.dect = dect\n",
"auth_user.save()\n",
"user.notes = notes\n",
"user: Profile = Profile()\n",
"user.rights = rights\n",
"user.rights = rights\n",
"user.number_of_allowed_reservations = int(request.POST['allowed_reservations'])\n",
"user.number_of_allowed_reservations = int(request.POST['allowed_reservations'])\n",
"if request.POST.get('active'):\n",
"user.displayName = displayname\n",
"user.active = magic.parse_bool(request.POST['active'])\n",
"au: User = user.authuser\n",
"user.authuser = auth_user\n",
"if check_password_conformity(pw1, pw2):\n",
"user.dect = dect\n",
"logging.log(logging.INFO, 'Set password for user: ' + user.displayName)\n",
"logging.log(logging.INFO, 'Failed to set password for: ' + user.displayName)\n",
"user.notes = notes\n",
"au.set_password(pw1)\n",
"au.email = mail\n",
"user.active = True\n",
"au.save()\n",
"user.save()\n",
"user.save()\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,
3,
0,
3,
0,
0,
3,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
3,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"AnnAssign'",
"Condition",
"Assign'",
"Expr'",
"AnnAssign'",
"Assign'",
"Expr'",
"Assign'",
"AnnAssign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"AnnAssign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_35(VAR_29, VAR_30, VAR_1, VAR_31):...\n",
"VAR_40 = FUNC_0(VAR_1, VAR_29)\n",
"VAR_41 = FUNC_0(VAR_1, VAR_30)\n",
"if VAR_40 is None:\n",
"return VAR_41\n",
"if VAR_41 is None:\n",
"return VAR_40\n",
"return VAR_31(VAR_40, VAR_41)\n"
] | [
"def _get_stricter_version(a, b, name, stricter):...\n",
"version_a = _parse_java_version(name, a)\n",
"version_b = _parse_java_version(name, b)\n",
"if version_a is None:\n",
"return version_b\n",
"if version_b is None:\n",
"return version_a\n",
"return stricter(version_a, version_b)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"\"\"\"\nCreated on 1 Feb 2018\n\n@author: Teodor Gherasim Nistor\n\"\"\"\n",
"from ply import lex\n",
"from beamr.lexers.generic import t_error\n",
"from beamr.lexers.document import t_COMMENT\n",
"import beamr\n",
"VAR_0 = ('COMMENT', 'ESCAPE', 'STRETCH1', 'STRETCH2', 'EMPH', 'CITATION',\n 'FOOTNOTE', 'URL', 'LISTITEM', 'COLUMN', 'IMGENV', 'PLUSENV', 'TABENV',\n 'VERBATIM', 'MACRO', 'BOX', 'ANTIESCAPE', 'TEXT')\n",
"def FUNC_0(VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_1.value = beamr.interpreters.Escape(VAR_1.value)\n",
"return VAR_1\n"
] | [
"\"\"\"\nCreated on 1 Feb 2018\n\n@author: Teodor Gherasim Nistor\n\"\"\"\n",
"from ply import lex\n",
"from beamr.lexers.generic import t_error\n",
"from beamr.lexers.document import t_COMMENT\n",
"import beamr\n",
"tokens = ('COMMENT', 'ESCAPE', 'STRETCH1', 'STRETCH2', 'EMPH', 'CITATION',\n 'FOOTNOTE', 'URL', 'LISTITEM', 'COLUMN', 'IMGENV', 'PLUSENV', 'TABENV',\n 'VERBATIM', 'MACRO', 'BOX', 'ANTIESCAPE', 'TEXT')\n",
"def t_ESCAPE(t):...\n",
"\"\"\"docstring\"\"\"\n",
"t.value = beamr.interpreters.Escape(t.value)\n",
"return t\n"
] | [
0,
0,
0,
2,
0,
2,
0,
0,
0,
0
] | [
"Expr'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Assign'",
"FunctionDef'",
"Docstring",
"Assign'",
"Return'"
] |
[
"def FUNC_2(VAR_87):...\n",
"return map(self._rules.__getitem__, filter(self.is_rule, VAR_87))\n"
] | [
"def rules(items):...\n",
"return map(self._rules.__getitem__, filter(self.is_rule, items))\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_8(self, VAR_10):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_5 = {}\n",
"VAR_5['volumeName'] = VAR_10['name']\n",
"VAR_5['prompt'] = 'false'\n",
"VAR_27 = self._cliq_get_volume_info(VAR_10['name'])\n",
"VAR_0.error('Volume did not exist. It will not be deleted')\n",
"self._cliq_run_xml('deleteVolume', VAR_5)\n",
"return\n"
] | [
"def delete_volume(self, volume):...\n",
"\"\"\"docstring\"\"\"\n",
"cliq_args = {}\n",
"cliq_args['volumeName'] = volume['name']\n",
"cliq_args['prompt'] = 'false'\n",
"volume_info = self._cliq_get_volume_info(volume['name'])\n",
"LOG.error('Volume did not exist. It will not be deleted')\n",
"self._cliq_run_xml('deleteVolume', cliq_args)\n",
"return\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_3(self, VAR_6=None, VAR_7='', VAR_8='', VAR_9=None, VAR_10=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_5 = self.session.query(self.obj)\n",
"if len(VAR_7.split('.')) >= 2:\n",
"VAR_33 = ''\n",
"VAR_23 = self.session.query(func.count('*')).select_from(self.obj)\n",
"for join_relation in VAR_7.split('.')[:-1]:\n",
"VAR_23 = self._get_base_query(VAR_5=query_count, VAR_6=filters)\n",
"VAR_37 = self.get_related_model(join_relation)\n",
"VAR_7 = VAR_33 + VAR_7.split('.')[-1]\n",
"VAR_5 = self._get_base_query(VAR_5=query, VAR_6=filters, VAR_7=order_column,\n VAR_8=order_direction)\n",
"VAR_5 = VAR_5.join(VAR_37)\n",
"VAR_24 = VAR_23.scalar()\n",
"VAR_33 = VAR_33 + VAR_37.__tablename__ + '.'\n",
"if VAR_9:\n",
"VAR_5 = VAR_5.offset(VAR_9 * VAR_10)\n",
"if VAR_10:\n",
"VAR_5 = VAR_5.limit(VAR_10)\n",
"return VAR_24, VAR_5.all()\n"
] | [
"def query(self, filters=None, order_column='', order_direction='', page=...\n",
"\"\"\"docstring\"\"\"\n",
"query = self.session.query(self.obj)\n",
"if len(order_column.split('.')) >= 2:\n",
"tmp_order_column = ''\n",
"query_count = self.session.query(func.count('*')).select_from(self.obj)\n",
"for join_relation in order_column.split('.')[:-1]:\n",
"query_count = self._get_base_query(query=query_count, filters=filters)\n",
"model_relation = self.get_related_model(join_relation)\n",
"order_column = tmp_order_column + order_column.split('.')[-1]\n",
"query = self._get_base_query(query=query, filters=filters, order_column=\n order_column, order_direction=order_direction)\n",
"query = query.join(model_relation)\n",
"count = query_count.scalar()\n",
"tmp_order_column = tmp_order_column + model_relation.__tablename__ + '.'\n",
"if page:\n",
"query = query.offset(page * page_size)\n",
"if page_size:\n",
"query = query.limit(page_size)\n",
"return count, query.all()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_11(VAR_1, *VAR_8, **VAR_9):...\n",
"\"\"\"docstring\"\"\"\n",
"if current_user.is_authenticated():\n",
"return redirect('/')\n",
"VAR_21 = FUNC_5(VAR_1)\n",
"if not VAR_21:\n",
"return redirect('/')\n",
"if not VAR_16.get(VAR_17(VAR_1.name) + '_autoregister', False):\n",
"return redirect(url_for('.login', VAR_0=remote.name))\n",
"VAR_22 = EmailSignUpForm(request.form)\n",
"if VAR_22.validate_on_submit():\n",
"VAR_27 = VAR_16.get(VAR_17(VAR_1.name) + '_account_info')\n",
"return render_template('oauthclient/signup.html', VAR_22=form, VAR_1=remote,\n app_title=cfg['OAUTHCLIENT_REMOTE_APPS'][remote.name].get('title', ''),\n app_description=cfg['OAUTHCLIENT_REMOTE_APPS'][remote.name].get(\n 'description', ''), app_icon=cfg['OAUTHCLIENT_REMOTE_APPS'][remote.name\n ].get('icon', None))\n",
"VAR_11 = oauth_register(VAR_27, VAR_22.data)\n",
"if VAR_11 is None:\n",
"VAR_16.pop(VAR_17(VAR_1.name) + '_autoregister', None)\n",
"if not oauth_authenticate(VAR_1.consumer_key, VAR_11, require_existing_link\n",
"return current_app.login_manager.unauthorized()\n",
"VAR_5 = FUNC_4(VAR_1, VAR_21[0], VAR_6=oauth_token[1])\n",
"VAR_19 = signup_handlers[VAR_1.name]\n",
"if VAR_5 is None:\n",
"if not VAR_5.remote_account.extra_data:\n",
"VAR_19['setup'](VAR_5)\n",
"VAR_16.pop(VAR_17(VAR_1.name) + '_account_info', None)\n",
"if request.args.get('next', None):\n",
"return redirect(request.args.get('next'))\n",
"return redirect('/')\n"
] | [
"def signup_handler(remote, *args, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"if current_user.is_authenticated():\n",
"return redirect('/')\n",
"oauth_token = token_getter(remote)\n",
"if not oauth_token:\n",
"return redirect('/')\n",
"if not session.get(token_session_key(remote.name) + '_autoregister', False):\n",
"return redirect(url_for('.login', remote_app=remote.name))\n",
"form = EmailSignUpForm(request.form)\n",
"if form.validate_on_submit():\n",
"account_info = session.get(token_session_key(remote.name) + '_account_info')\n",
"return render_template('oauthclient/signup.html', form=form, remote=remote,\n app_title=cfg['OAUTHCLIENT_REMOTE_APPS'][remote.name].get('title', ''),\n app_description=cfg['OAUTHCLIENT_REMOTE_APPS'][remote.name].get(\n 'description', ''), app_icon=cfg['OAUTHCLIENT_REMOTE_APPS'][remote.name\n ].get('icon', None))\n",
"user = oauth_register(account_info, form.data)\n",
"if user is None:\n",
"session.pop(token_session_key(remote.name) + '_autoregister', None)\n",
"if not oauth_authenticate(remote.consumer_key, user, require_existing_link=\n",
"return current_app.login_manager.unauthorized()\n",
"token = token_setter(remote, oauth_token[0], secret=oauth_token[1])\n",
"handlers = signup_handlers[remote.name]\n",
"if token is None:\n",
"if not token.remote_account.extra_data:\n",
"handlers['setup'](token)\n",
"session.pop(token_session_key(remote.name) + '_account_info', None)\n",
"if request.args.get('next', None):\n",
"return redirect(request.args.get('next'))\n",
"return redirect('/')\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'",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_5(self):...\n",
"\"\"\"docstring\"\"\"\n",
"model.bootstrap_ip_whitelist('bots', ['192.168.1.100/32'])\n",
"@api.public...\n",
"self.response.write(api.get_current_identity().to_bytes())\n",
"VAR_7 = self.make_test_app('/request', CLASS_7)\n",
"def FUNC_26(VAR_8):...\n",
"api.reset_local_state()\n",
"return VAR_7.get('/request', extra_environ={'REMOTE_ADDR': ip}).body\n"
] | [
"def test_ip_whitelist_bot(self):...\n",
"\"\"\"docstring\"\"\"\n",
"model.bootstrap_ip_whitelist('bots', ['192.168.1.100/32'])\n",
"@api.public...\n",
"self.response.write(api.get_current_identity().to_bytes())\n",
"app = self.make_test_app('/request', Handler)\n",
"def call(ip):...\n",
"api.reset_local_state()\n",
"return app.get('/request', extra_environ={'REMOTE_ADDR': ip}).body\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"FunctionDef'",
"Expr'",
"Return'"
] |
[
"@VAR_0.route('/authorized/<remote_app>/')...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_1 not in handlers:\n",
"return abort(404)\n",
"return handlers[VAR_1]()\n"
] | [
"@blueprint.route('/authorized/<remote_app>/')...\n",
"\"\"\"docstring\"\"\"\n",
"if remote_app not in handlers:\n",
"return abort(404)\n",
"return handlers[remote_app]()\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_6():...\n",
"VAR_12 = FUNC_0()\n",
"VAR_13 = VAR_12.cursor()\n",
"VAR_14 = []\n",
"VAR_15 = 'string'\n",
"VAR_13.execute(VAR_15)\n",
"VAR_16 = VAR_13.fetchall()\n",
"for VAR_21 in VAR_16:\n",
"VAR_21 = list(VAR_21)\n",
"VAR_14.sort(key=lambda row: row[0])\n",
"VAR_21[1] = float(VAR_21[1]) / 100\n",
"VAR_17 = []\n",
"VAR_21 = [(VAR_21[i].capitalize() if type(VAR_21[i]) == str and i != 3 else\n VAR_21[i]) for i in range(len(VAR_21))]\n",
"for VAR_21 in VAR_14:\n",
"VAR_14.append(VAR_21)\n",
"VAR_17.append({'date': VAR_21[0], 'amount': VAR_21[1], 'category': VAR_21[2\n ], 'description': VAR_21[3], 'person': VAR_21[4], 'id': VAR_21[5]})\n",
"VAR_12.commit()\n",
"VAR_12.close()\n",
"return VAR_17\n"
] | [
"def display_all_data():...\n",
"conn = check_heroku_db()\n",
"cur = conn.cursor()\n",
"out = []\n",
"query = \"\"\"\n SELECT txn_date, amount, cat_name, description, person_name, ledger.id\n FROM ledger\n JOIN persons\n ON ledger.person_id=persons.id\n JOIN categories\n ON ledger.category_id=categories.id\n \"\"\"\n",
"cur.execute(query)\n",
"results = cur.fetchall()\n",
"for row in results:\n",
"row = list(row)\n",
"out.sort(key=lambda row: row[0])\n",
"row[1] = float(row[1]) / 100\n",
"out_dicts = []\n",
"row = [(row[i].capitalize() if type(row[i]) == str and i != 3 else row[i]) for\n i in range(len(row))]\n",
"for row in out:\n",
"out.append(row)\n",
"out_dicts.append({'date': row[0], 'amount': row[1], 'category': row[2],\n 'description': row[3], 'person': row[4], 'id': row[5]})\n",
"conn.commit()\n",
"conn.close()\n",
"return out_dicts\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"For",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"VAR_6 = BeautifulSoup(self.res_data, 'html.parser')\n",
"VAR_7 = {}\n",
"VAR_8 = VAR_6.find_all(id='submission_status')[0]\n",
"VAR_7['status'] = VAR_8.text.strip()\n",
"VAR_9 = VAR_6.find_all(id='compilation')\n",
"if VAR_9:\n",
"VAR_12 = VAR_9[0]\n",
"VAR_7['compile_output'] = None\n",
"VAR_7['compile_output'] = '\\n'.join([pre.text.strip() for pre in VAR_12.\n findAll('pre')])\n",
"VAR_10 = []\n",
"VAR_9 = VAR_6.find_all(id=re.compile('^eval_outcome_'))\n",
"VAR_11 = VAR_6.find_all(id=re.compile('^eval_text_'))\n",
"for outcome_tag, text_tag in zip(VAR_9, VAR_11):\n",
"VAR_10.append({'outcome': outcome_tag.text.strip(), 'text': text_tag.text.\n strip()})\n",
"VAR_7['evaluations'] = VAR_10\n",
"return VAR_7\n"
] | [
"def get_submission_info(self):...\n",
"soup = BeautifulSoup(self.res_data, 'html.parser')\n",
"info = {}\n",
"tag = soup.find_all(id='submission_status')[0]\n",
"info['status'] = tag.text.strip()\n",
"tags = soup.find_all(id='compilation')\n",
"if tags:\n",
"content = tags[0]\n",
"info['compile_output'] = None\n",
"info['compile_output'] = '\\n'.join([pre.text.strip() for pre in content.\n findAll('pre')])\n",
"evaluations = []\n",
"tags = soup.find_all(id=re.compile('^eval_outcome_'))\n",
"text_tags = soup.find_all(id=re.compile('^eval_text_'))\n",
"for outcome_tag, text_tag in zip(tags, text_tags):\n",
"evaluations.append({'outcome': outcome_tag.text.strip(), 'text': text_tag.\n text.strip()})\n",
"info['evaluations'] = evaluations\n",
"return info\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"VAR_1 = 'http://my.url.com'\n",
"VAR_2 = 'True'\n",
"url_helper.urllib2.urlopen(mox.IsA(urllib2.Request), timeout=mox.IgnoreArg()\n ).AndReturn(StringIO.StringIO(VAR_2))\n",
"self._mox.ReplayAll()\n",
"self.assertEqual(url_helper.UrlOpen(VAR_1, method='POSTFORM'), VAR_2)\n",
"self._mox.VerifyAll()\n"
] | [
"def testUrlOpenPOSTFORMSuccess(self):...\n",
"url = 'http://my.url.com'\n",
"response = 'True'\n",
"url_helper.urllib2.urlopen(mox.IsA(urllib2.Request), timeout=mox.IgnoreArg()\n ).AndReturn(StringIO.StringIO(response))\n",
"self._mox.ReplayAll()\n",
"self.assertEqual(url_helper.UrlOpen(url, method='POSTFORM'), response)\n",
"self._mox.VerifyAll()\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_31(VAR_62):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_84 = 0\n",
"while VAR_62[VAR_84].isdigit():\n",
"VAR_84 += 1\n",
"if VAR_84 > 0:\n",
"return int(VAR_62[:VAR_84])\n",
"return 0\n"
] | [
"def _get_value_kw(kw):...\n",
"\"\"\"docstring\"\"\"\n",
"i = 0\n",
"while kw[i].isdigit():\n",
"i += 1\n",
"if i > 0:\n",
"return int(kw[:i])\n",
"return 0\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"AugAssign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"if is_banned_IP(VAR_102.ip):\n",
"VAR_101.errors.add(errors.BANNED_IP)\n",
"return VAR_102.ip\n"
] | [
"def run(self):...\n",
"if is_banned_IP(request.ip):\n",
"c.errors.add(errors.BANNED_IP)\n",
"return request.ip\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Return'"
] |
[
"def __init__(self, VAR_0, VAR_1, VAR_2, VAR_3):...\n",
"self.cmd = VAR_0\n",
"self.stdout = VAR_1\n",
"self.stderr = VAR_2\n",
"self.ret_code = VAR_3\n"
] | [
"def __init__(self, cmd, stdout, stderr, ret_code):...\n",
"self.cmd = cmd\n",
"self.stdout = stdout\n",
"self.stderr = stderr\n",
"self.ret_code = ret_code\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_14(self, VAR_64):...\n",
"self._onerror = VAR_64\n"
] | [
"def onerror(self, func):...\n",
"self._onerror = func\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"@login_required()...\n",
"VAR_3 = DataGroup.objects.all()\n",
"VAR_4 = {}\n",
"VAR_4['object_list'] = VAR_3\n",
"return render(VAR_0, VAR_1, VAR_4)\n"
] | [
"@login_required()...\n",
"datagroup = DataGroup.objects.all()\n",
"data = {}\n",
"data['object_list'] = datagroup\n",
"return render(request, template_name, data)\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_19(self, VAR_14):...\n",
""
] | [
"def is_relation_many_to_many(self, col_name):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_14(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = {'SEVERITY': {'MEDIUM': 3}, 'CONFIDENCE': {'HIGH': 3}}\n",
"self.check_example('httplib_https.py', VAR_2)\n"
] | [
"def test_httplib_https(self):...\n",
"\"\"\"docstring\"\"\"\n",
"expect = {'SEVERITY': {'MEDIUM': 3}, 'CONFIDENCE': {'HIGH': 3}}\n",
"self.check_example('httplib_https.py', expect)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_16(self):...\n",
"self.assertEqual(self.driver._get_space_in_gb('123.0GB'), 123.0)\n",
"self.assertEqual(self.driver._get_space_in_gb('123.0TB'), 123.0 * 1024)\n",
"self.assertEqual(self.driver._get_space_in_gb('1024.0MB'), 1.0)\n"
] | [
"def test_get_space_in_gb(self):...\n",
"self.assertEqual(self.driver._get_space_in_gb('123.0GB'), 123.0)\n",
"self.assertEqual(self.driver._get_space_in_gb('123.0TB'), 123.0 * 1024)\n",
"self.assertEqual(self.driver._get_space_in_gb('1024.0MB'), 1.0)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"import json as json_module\n",
"import logging\n",
"import sys\n",
"from citest.service_testing import HttpContractBuilder\n",
"from citest.service_testing import NoOpOperation\n",
"import citest.gcp_testing as gcp\n",
"import citest.json_contract as jc\n",
"import citest.service_testing as st\n",
"import spinnaker_testing as sk\n",
"import spinnaker_testing.kato as kato\n",
"VAR_0 = []\n",
"VAR_1 = []\n",
"VAR_2 = ''\n",
"VAR_3 = ''\n",
"VAR_4 = ''\n",
"VAR_5 = ''\n",
"VAR_6 = ''\n",
"VAR_7 = ''\n",
"VAR_8 = ''\n",
"VAR_9 = ''\n",
"VAR_10 = ''\n",
"VAR_11 = ''\n",
"VAR_12 = ''\n",
"@classmethod...\n",
"\"\"\"docstring\"\"\"\n",
"return kato.new_agent(VAR_14)\n"
] | [
"import json as json_module\n",
"import logging\n",
"import sys\n",
"from citest.service_testing import HttpContractBuilder\n",
"from citest.service_testing import NoOpOperation\n",
"import citest.gcp_testing as gcp\n",
"import citest.json_contract as jc\n",
"import citest.service_testing as st\n",
"import spinnaker_testing as sk\n",
"import spinnaker_testing.kato as kato\n",
"use_instance_names = []\n",
"use_instance_zones = []\n",
"__use_lb_name = ''\n",
"__use_lb_tp_name = ''\n",
"__use_lb_hc_name = ''\n",
"__use_lb_target = ''\n",
"__use_http_lb_name = ''\n",
"__use_http_lb_proxy_name = ''\n",
"__use_http_lb_hc_name = ''\n",
"__use_http_lb_bs_name = ''\n",
"__use_http_lb_fr_name = ''\n",
"__use_http_lb_map_name = ''\n",
"__use_http_lb_http_proxy_name = ''\n",
"@classmethod...\n",
"\"\"\"docstring\"\"\"\n",
"return kato.new_agent(bindings)\n"
] | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_5(self):...\n",
"if not self.route:\n",
"return frappe.db.get_value('Blog Category', self.blog_category, 'route'\n ) + '/' + self.scrub(self.title)\n"
] | [
"def make_route(self):...\n",
"if not self.route:\n",
"return frappe.db.get_value('Blog Category', self.blog_category, 'route'\n ) + '/' + self.scrub(self.title)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'"
] |
[
"def FUNC_0(self, VAR_1, VAR_2, VAR_3, VAR_4=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_4 is None:\n",
"VAR_4 = {}\n",
"VAR_17 = self.pool.get('product.product').browse(VAR_1, VAR_2, VAR_3, VAR_4\n =context)\n",
"VAR_18 = (VAR_17.property_stock_account_input and VAR_17.\n property_stock_account_input.id or False)\n",
"if not VAR_18:\n",
"VAR_18 = (VAR_17.categ_id.property_stock_account_input_categ and VAR_17.\n categ_id.property_stock_account_input_categ.id or False)\n",
"VAR_19 = (VAR_17.property_stock_account_output and VAR_17.\n property_stock_account_output.id or False)\n",
"if not VAR_19:\n",
"VAR_19 = (VAR_17.categ_id.property_stock_account_output_categ and VAR_17.\n categ_id.property_stock_account_output_categ.id or False)\n",
"VAR_20 = (VAR_17.categ_id.property_stock_journal and VAR_17.categ_id.\n property_stock_journal.id or False)\n",
"VAR_21 = (VAR_17.categ_id.property_stock_variation and VAR_17.categ_id.\n property_stock_variation.id or False)\n",
"return {'stock_account_input': VAR_18, 'stock_account_output': VAR_19,\n 'stock_journal': VAR_20, 'property_stock_variation': VAR_21}\n"
] | [
"def get_product_accounts(self, cr, uid, product_id, context=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if context is None:\n",
"context = {}\n",
"product_obj = self.pool.get('product.product').browse(cr, uid, product_id,\n context=context)\n",
"stock_input_acc = (product_obj.property_stock_account_input and product_obj\n .property_stock_account_input.id or False)\n",
"if not stock_input_acc:\n",
"stock_input_acc = (product_obj.categ_id.property_stock_account_input_categ and\n product_obj.categ_id.property_stock_account_input_categ.id or False)\n",
"stock_output_acc = (product_obj.property_stock_account_output and\n product_obj.property_stock_account_output.id or False)\n",
"if not stock_output_acc:\n",
"stock_output_acc = (product_obj.categ_id.\n property_stock_account_output_categ and product_obj.categ_id.\n property_stock_account_output_categ.id or False)\n",
"journal_id = (product_obj.categ_id.property_stock_journal and product_obj.\n categ_id.property_stock_journal.id or False)\n",
"account_variation = (product_obj.categ_id.property_stock_variation and\n product_obj.categ_id.property_stock_variation.id or False)\n",
"return {'stock_account_input': stock_input_acc, 'stock_account_output':\n stock_output_acc, 'stock_journal': journal_id,\n 'property_stock_variation': account_variation}\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@app.route('/updatedb/politicians')...\n",
"return insert_politicians_in_db()\n"
] | [
"@app.route('/updatedb/politicians')...\n",
"return insert_politicians_in_db()\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_21(self):...\n",
"@eqlx.with_timeout...\n",
"return 'no timeout'\n"
] | [
"def test_with_timeout(self):...\n",
"@eqlx.with_timeout...\n",
"return 'no timeout'\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'"
] |
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"return User.filter_users(VAR_4, VAR_13, VAR_14)\n"
] | [
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"return User.filter_users(username, project_id, page)\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_0(self, *VAR_5, **VAR_4):...\n",
"if self.run_local:\n",
"return utils.execute(*VAR_5, **kwargs)\n",
"VAR_7 = VAR_4.pop('check_exit_code', None)\n",
"VAR_6 = ' '.join(VAR_5)\n",
"return self._run_ssh(VAR_6, VAR_7)\n"
] | [
"def san_execute(self, *cmd, **kwargs):...\n",
"if self.run_local:\n",
"return utils.execute(*cmd, **kwargs)\n",
"check_exit_code = kwargs.pop('check_exit_code', None)\n",
"command = ' '.join(cmd)\n",
"return self._run_ssh(command, check_exit_code)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def __exit__(self, VAR_7, VAR_8, VAR_9):...\n",
"\"\"\"docstring\"\"\"\n",
"for VAR_12, VAR_8 in self.extra_data.items():\n",
"if not isinstance(VAR_12, str) or not isinstance(VAR_8, str):\n",
"if VAR_7 is not None:\n",
"VAR_5 = json.dumps({'type': str(VAR_7), 'value': str(VAR_8), 'traceback':\n str(traceback.format_exc())})\n",
"VAR_5 = json.dumps(self.extra_data)\n",
"VAR_10 = {'event_type': self.event_type, 'start_time': self.start_time,\n 'end_time': time.time(), 'extra_data': VAR_5}\n",
"self.profiler.add_event(VAR_10)\n"
] | [
"def __exit__(self, type, value, tb):...\n",
"\"\"\"docstring\"\"\"\n",
"for key, value in self.extra_data.items():\n",
"if not isinstance(key, str) or not isinstance(value, str):\n",
"if type is not None:\n",
"extra_data = json.dumps({'type': str(type), 'value': str(value),\n 'traceback': str(traceback.format_exc())})\n",
"extra_data = json.dumps(self.extra_data)\n",
"event = {'event_type': self.event_type, 'start_time': self.start_time,\n 'end_time': time.time(), 'extra_data': extra_data}\n",
"self.profiler.add_event(event)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"For",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_13(self):...\n",
"self.driver._eql_execute = self.mox.CreateMock(self.driver._eql_execute)\n",
"VAR_9 = '10.1.2.3'\n",
"for feature in ('confirmation', 'paging', 'events', 'formatoutput'):\n",
"self.driver._eql_execute('cli-settings', feature, 'off')\n",
"self.driver._eql_execute('grpparams', 'show').AndReturn([\n 'Group-Ipaddress: %s' % VAR_9])\n",
"self.mox.ReplayAll()\n",
"self.driver.do_setup(self._context)\n",
"self.assertEqual(VAR_9, self.driver._group_ip)\n"
] | [
"def test_do_setup(self):...\n",
"self.driver._eql_execute = self.mox.CreateMock(self.driver._eql_execute)\n",
"fake_group_ip = '10.1.2.3'\n",
"for feature in ('confirmation', 'paging', 'events', 'formatoutput'):\n",
"self.driver._eql_execute('cli-settings', feature, 'off')\n",
"self.driver._eql_execute('grpparams', 'show').AndReturn([\n 'Group-Ipaddress: %s' % fake_group_ip])\n",
"self.mox.ReplayAll()\n",
"self.driver.do_setup(self._context)\n",
"self.assertEqual(fake_group_ip, self.driver._group_ip)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"For",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_32(self):...\n",
"VAR_33 = VAR_5.search(self.file)\n",
"if VAR_33:\n",
"return self.file[:VAR_33.start()]\n",
"return self.file\n"
] | [
"def constant_prefix(self):...\n",
"first_wildcard = _wildcard_regex.search(self.file)\n",
"if first_wildcard:\n",
"return self.file[:first_wildcard.start()]\n",
"return self.file\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"@app.route('/search', methods=['POST', 'GET'])...\n",
"VAR_5 = request.args.get('q').lower()\n",
"VAR_7 = Politician.all()\n",
"VAR_7.filter('name =', VAR_5)\n",
"VAR_2 = None\n",
"for p in VAR_7:\n",
"VAR_2 = p\n",
"if VAR_2 != None:\n",
"VAR_2.search_count = VAR_2.search_count + 1\n",
"return render_template('politician_notfound.html', VAR_6=query)\n",
"VAR_2.put()\n",
"return render_template('politician.html', VAR_6=query, VAR_2=politician)\n"
] | [
"@app.route('/search', methods=['POST', 'GET'])...\n",
"query = request.args.get('q').lower()\n",
"politicians = Politician.all()\n",
"politicians.filter('name =', query)\n",
"politician = None\n",
"for p in politicians:\n",
"politician = p\n",
"if politician != None:\n",
"politician.search_count = politician.search_count + 1\n",
"return render_template('politician_notfound.html', q=query)\n",
"politician.put()\n",
"return render_template('politician.html', q=query, politician=politician)\n"
] | [
0,
6,
0,
0,
0,
0,
0,
0,
0,
0,
0,
6
] | [
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"For",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Expr'",
"Return'"
] |
[
"def FUNC_10(self, VAR_15, VAR_16):...\n",
"VAR_36 = {'cmd': 'sleep', 'duration': task_scheduler.exponential_backoff(\n VAR_15), 'quarantined': VAR_16}\n",
"self.send_response(VAR_36)\n"
] | [
"def _cmd_sleep(self, sleep_streak, quarantined):...\n",
"out = {'cmd': 'sleep', 'duration': task_scheduler.exponential_backoff(\n sleep_streak), 'quarantined': quarantined}\n",
"self.send_response(out)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"@property...\n",
"return self._subworkflows.values()\n"
] | [
"@property...\n",
"return self._subworkflows.values()\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_17(self):...\n",
"self.run_test_case(self.scenario.destroy_server_group('v001'))\n"
] | [
"def test_h_destroy_server_group_v001(self):...\n",
"self.run_test_case(self.scenario.destroy_server_group('v001'))\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_3(self, VAR_6):...\n",
"self.common = self._init_common()\n",
"self._check_flags()\n",
"self.iscsi_ips = {}\n",
"VAR_21 = {}\n",
"if len(self.configuration.hp3par_iscsi_ips) > 0:\n",
"for VAR_42 in self.configuration.hp3par_iscsi_ips:\n",
"if self.configuration.iscsi_ip_address not in VAR_21:\n",
"VAR_38 = VAR_42.split(':')\n",
"VAR_38 = self.configuration.iscsi_ip_address\n",
"VAR_22 = self.common.get_ports()['iSCSI']\n",
"if len(VAR_38) == 1:\n",
"VAR_39 = self.configuration.iscsi_port\n",
"for VAR_38, iscsi_info in VAR_22.iteritems():\n",
"VAR_21[VAR_42] = {'ip_port': VAR_2}\n",
"if len(VAR_38) == 2:\n",
"VAR_21[VAR_38] = {'ip_port': VAR_39}\n",
"if VAR_38 in VAR_21:\n",
"if self.configuration.iscsi_ip_address in VAR_21:\n",
"VAR_21[VAR_38[0]] = {'ip_port': VAR_38[1]}\n",
"VAR_40 = _(\"Invalid IP address format '%s'\") % VAR_42\n",
"VAR_39 = VAR_21[VAR_38]['ip_port']\n",
"if len(VAR_21) > 0:\n",
"VAR_1.warn(VAR_40)\n",
"self.iscsi_ips[VAR_38] = {'ip_port': VAR_39, 'nsp': iscsi_info['nsp'],\n 'iqn': iscsi_info['iqn']}\n",
"VAR_40 = _('string') % ', '.join(VAR_21)\n",
"if not len(self.iscsi_ips) > 0:\n",
"VAR_1.warn(VAR_40)\n",
"VAR_40 = _('At least one valid iSCSI IP address must be set.')\n",
"self.common.do_setup(VAR_6)\n"
] | [
"def do_setup(self, context):...\n",
"self.common = self._init_common()\n",
"self._check_flags()\n",
"self.iscsi_ips = {}\n",
"temp_iscsi_ip = {}\n",
"if len(self.configuration.hp3par_iscsi_ips) > 0:\n",
"for ip_addr in self.configuration.hp3par_iscsi_ips:\n",
"if self.configuration.iscsi_ip_address not in temp_iscsi_ip:\n",
"ip = ip_addr.split(':')\n",
"ip = self.configuration.iscsi_ip_address\n",
"iscsi_ports = self.common.get_ports()['iSCSI']\n",
"if len(ip) == 1:\n",
"ip_port = self.configuration.iscsi_port\n",
"for ip, iscsi_info in iscsi_ports.iteritems():\n",
"temp_iscsi_ip[ip_addr] = {'ip_port': DEFAULT_ISCSI_PORT}\n",
"if len(ip) == 2:\n",
"temp_iscsi_ip[ip] = {'ip_port': ip_port}\n",
"if ip in temp_iscsi_ip:\n",
"if self.configuration.iscsi_ip_address in temp_iscsi_ip:\n",
"temp_iscsi_ip[ip[0]] = {'ip_port': ip[1]}\n",
"msg = _(\"Invalid IP address format '%s'\") % ip_addr\n",
"ip_port = temp_iscsi_ip[ip]['ip_port']\n",
"if len(temp_iscsi_ip) > 0:\n",
"LOG.warn(msg)\n",
"self.iscsi_ips[ip] = {'ip_port': ip_port, 'nsp': iscsi_info['nsp'], 'iqn':\n iscsi_info['iqn']}\n",
"msg = _(\n \"Found invalid iSCSI IP address(s) in configuration option(s) hp3par_iscsi_ips or iscsi_ip_address '%s.'\"\n ) % ', '.join(temp_iscsi_ip)\n",
"if not len(self.iscsi_ips) > 0:\n",
"LOG.warn(msg)\n",
"msg = _('At least one valid iSCSI IP address must be set.')\n",
"self.common.do_setup(context)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"For",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"For",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_9(VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_16 = os.path.join(VAR_2, 'bin', 'tljh-config')\n",
"VAR_17 = '/usr/bin/tljh-config'\n",
"if os.path.exists(VAR_17):\n",
"if os.path.realpath(VAR_17) != VAR_16:\n",
"os.symlink(VAR_16, VAR_17)\n",
"return\n"
] | [
"def ensure_symlinks(prefix):...\n",
"\"\"\"docstring\"\"\"\n",
"tljh_config_src = os.path.join(prefix, 'bin', 'tljh-config')\n",
"tljh_config_dest = '/usr/bin/tljh-config'\n",
"if os.path.exists(tljh_config_dest):\n",
"if os.path.realpath(tljh_config_dest) != tljh_config_src:\n",
"os.symlink(tljh_config_src, tljh_config_dest)\n",
"return\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"Return'"
] |
[
"def __init__(self):...\n",
"self.content = VAR_2\n"
] | [
"def __init__(self):...\n",
"self.content = content\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._server\n"
] | [
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._server\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_4(VAR_6, VAR_7, **VAR_8):...\n",
"\"\"\"docstring\"\"\"\n",
"assert VAR_0.name != VAR_6.name, 'Refusing to route reply back to the same network, as this would cause a recursive loop'\n",
"log.debug('(%s) networks.remote: re-routing reply %r from network %s',\n VAR_0.name, VAR_7, VAR_6.name)\n",
"if 'source' in VAR_8:\n",
"VAR_0.reply(VAR_7, VAR_1=irc.pseudoclient.uid, **kwargs)\n"
] | [
"def _remote_reply(placeholder_self, text, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"assert irc.name != placeholder_self.name, 'Refusing to route reply back to the same network, as this would cause a recursive loop'\n",
"log.debug('(%s) networks.remote: re-routing reply %r from network %s', irc.\n name, text, placeholder_self.name)\n",
"if 'source' in kwargs:\n",
"irc.reply(text, source=irc.pseudoclient.uid, **kwargs)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assert'",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_4(VAR_9):...\n",
"VAR_9.cmd('send-keys', '', 'C-c')\n",
"VAR_9.kill_window()\n"
] | [
"def kill_window(window):...\n",
"window.cmd('send-keys', '', 'C-c')\n",
"window.kill_window()\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'"
] |
[
"@mock.patch('requests.post', FUNC_0)...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_4 = '/api/apps'\n",
"VAR_5 = self.client.post(VAR_4)\n",
"self.assertEqual(VAR_5.status_code, 201)\n",
"VAR_6 = VAR_5.data['id']\n",
"VAR_14 = {'username': 'autotest', 'app': VAR_6}\n",
"VAR_4 = '/api/hooks/builds'.format(**locals())\n",
"VAR_7 = {'receive_user': 'autotest', 'receive_repo': VAR_6, 'image':\n '{app_id}:v2'.format(**locals())}\n",
"self.assertIsNone(self.client.logout())\n",
"VAR_5 = self.client.post(VAR_4, json.dumps(VAR_7), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_5.status_code, 403)\n",
"VAR_5 = self.client.post(VAR_4, json.dumps(VAR_7), content_type=\n 'application/json', HTTP_X_DEIS_BUILDER_AUTH=settings.BUILDER_KEY)\n",
"self.assertEqual(VAR_5.status_code, 200)\n",
"self.assertIn('release', VAR_5.data)\n",
"self.assertIn('version', VAR_5.data['release'])\n",
"self.assertIn('domains', VAR_5.data)\n"
] | [
"@mock.patch('requests.post', mock_import_repository_task)...\n",
"\"\"\"docstring\"\"\"\n",
"url = '/api/apps'\n",
"response = self.client.post(url)\n",
"self.assertEqual(response.status_code, 201)\n",
"app_id = response.data['id']\n",
"build = {'username': 'autotest', 'app': app_id}\n",
"url = '/api/hooks/builds'.format(**locals())\n",
"body = {'receive_user': 'autotest', 'receive_repo': app_id, 'image':\n '{app_id}:v2'.format(**locals())}\n",
"self.assertIsNone(self.client.logout())\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 403)\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json', HTTP_X_DEIS_BUILDER_AUTH=settings.BUILDER_KEY)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertIn('release', response.data)\n",
"self.assertIn('version', response.data['release'])\n",
"self.assertIn('domains', response.data)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@mock.patch('requests.post', FUNC_0)...\n",
"\"\"\"docstring\"\"\"\n",
"self.client.login(username='autotest2', password='password')\n",
"VAR_4 = '/api/apps'\n",
"VAR_5 = self.client.post(VAR_4)\n",
"self.assertEqual(VAR_5.status_code, 201)\n",
"VAR_6 = VAR_5.data['id']\n",
"self.client.login(username='autotest', password='password')\n",
"VAR_4 = '/api/apps/{app_id}/config'.format(**locals())\n",
"VAR_7 = {'values': json.dumps({'NEW_URL1': 'http://localhost:8080/'})}\n",
"VAR_5 = self.client.post(VAR_4, json.dumps(VAR_7), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_5.status_code, 201)\n",
"self.assertIn('NEW_URL1', VAR_5.data['values'])\n",
"VAR_4 = '/api/apps/{app_id}/releases'.format(**locals())\n",
"VAR_5 = self.client.get(VAR_4)\n",
"self.assertEqual(VAR_5.status_code, 200)\n",
"self.assertEqual(VAR_5.data['count'], 2)\n"
] | [
"@mock.patch('requests.post', mock_import_repository_task)...\n",
"\"\"\"docstring\"\"\"\n",
"self.client.login(username='autotest2', password='password')\n",
"url = '/api/apps'\n",
"response = self.client.post(url)\n",
"self.assertEqual(response.status_code, 201)\n",
"app_id = response.data['id']\n",
"self.client.login(username='autotest', password='password')\n",
"url = '/api/apps/{app_id}/config'.format(**locals())\n",
"body = {'values': json.dumps({'NEW_URL1': 'http://localhost:8080/'})}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 201)\n",
"self.assertIn('NEW_URL1', response.data['values'])\n",
"url = '/api/apps/{app_id}/releases'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(response.data['count'], 2)\n"
] | [
0,
0,
5,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_10(self):...\n",
"VAR_18 = self._session\n",
"if VAR_18 is None:\n",
"return\n",
"self._session = None\n",
"VAR_18.close()\n"
] | [
"def _detach(self):...\n",
"session = self._session\n",
"if session is None:\n",
"return\n",
"self._session = None\n",
"session.close()\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Expr'"
] |
[
"from pylons import c, request, g\n",
"from pylons.i18n import _\n",
"from pylons.controllers.util import abort\n",
"from r2.lib import utils, captcha\n",
"from r2.lib.filters import unkeep_space, websafe, _force_utf8, _force_ascii\n",
"from r2.lib.db.operators import asc, desc\n",
"from r2.config import cache\n",
"from r2.lib.template_helpers import add_sr\n",
"from r2.lib.jsonresponse import json_respond\n",
"from r2.models import *\n",
"from r2.controllers.errors import errors, UserRequiredException\n",
"from copy import copy\n",
"from datetime import datetime, timedelta\n",
"import re\n",
"VAR_6 = None\n",
"def __init__(self, VAR_7=None, VAR_8=None, VAR_9=True, VAR_10=True, VAR_11=True...\n",
"if VAR_7:\n",
"self.param = VAR_7\n",
"self.param = self.default_param\n",
"self.default = VAR_8\n",
"self.post, self.get, self.url = VAR_9, VAR_10, VAR_11\n",
"def __call__(self, VAR_11):...\n",
"VAR_15 = []\n",
"if self.param:\n",
"for p in utils.tup(self.param):\n",
"return self.run(*VAR_15)\n",
"if self.post and VAR_102.post.get(p):\n",
"VAR_33 = VAR_102.post[p]\n",
"if self.get and VAR_102.get.get(p):\n",
"VAR_15.append(VAR_33)\n",
"VAR_33 = VAR_102.get[p]\n",
"if self.url and VAR_11.get(p):\n",
"VAR_33 = VAR_11[p]\n",
"VAR_33 = self.default\n"
] | [
"from pylons import c, request, g\n",
"from pylons.i18n import _\n",
"from pylons.controllers.util import abort\n",
"from r2.lib import utils, captcha\n",
"from r2.lib.filters import unkeep_space, websafe, _force_utf8, _force_ascii\n",
"from r2.lib.db.operators import asc, desc\n",
"from r2.config import cache\n",
"from r2.lib.template_helpers import add_sr\n",
"from r2.lib.jsonresponse import json_respond\n",
"from r2.models import *\n",
"from r2.controllers.errors import errors, UserRequiredException\n",
"from copy import copy\n",
"from datetime import datetime, timedelta\n",
"import re\n",
"default_param = None\n",
"def __init__(self, param=None, default=None, post=True, get=True, url=True):...\n",
"if param:\n",
"self.param = param\n",
"self.param = self.default_param\n",
"self.default = default\n",
"self.post, self.get, self.url = post, get, url\n",
"def __call__(self, url):...\n",
"a = []\n",
"if self.param:\n",
"for p in utils.tup(self.param):\n",
"return self.run(*a)\n",
"if self.post and request.post.get(p):\n",
"val = request.post[p]\n",
"if self.get and request.get.get(p):\n",
"a.append(val)\n",
"val = request.get[p]\n",
"if self.url and url.get(p):\n",
"val = url[p]\n",
"val = self.default\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
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Condition",
"For",
"Return'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Assign'"
] |
[
"def FUNC_10(self):...\n",
"VAR_1 = self.objects.dg.pk\n",
"VAR_2 = self.client.get(f'/datagroup/{VAR_1}/')\n",
"self.assertContains(VAR_2, '<a href=\"/datasource/', msg_prefix=\n 'Should be able to get back to DataSource from here.')\n"
] | [
"def test_detail_datasource_link(self):...\n",
"pk = self.objects.dg.pk\n",
"response = self.client.get(f'/datagroup/{pk}/')\n",
"self.assertContains(response, '<a href=\"/datasource/', msg_prefix=\n 'Should be able to get back to DataSource from here.')\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"@VAR_0.route('/load_bounding_box_mailles/<limit>', methods=['GET'])...\n",
"VAR_8 = getConnexion()\n",
"VAR_9 = 'SELECT ST_TRANSFORM(ST_MakeEnvelope(' + VAR_4 + ', 4326),32620);'\n",
"VAR_8.cur.execute(VAR_9)\n",
"VAR_12 = VAR_8.cur.fetchone()\n",
"VAR_9 = 'string' + VAR_4 + \"\"\", 4326),32620)) ) AS f)\n AS fc; \"\"\"\n",
"VAR_8.cur.execute(VAR_9)\n",
"VAR_11 = VAR_8.cur.fetchone()\n",
"VAR_8.closeAll()\n",
"return Response(flask.json.dumps(VAR_11), mimetype='application/json')\n"
] | [
"@addObs.route('/load_bounding_box_mailles/<limit>', methods=['GET'])...\n",
"db = getConnexion()\n",
"sql = 'SELECT ST_TRANSFORM(ST_MakeEnvelope(' + limit + ', 4326),32620);'\n",
"db.cur.execute(sql)\n",
"bounding = db.cur.fetchone()\n",
"sql = \"\"\" SELECT row_to_json(fc)\n FROM ( SELECT \n 'FeatureCollection' AS type, \n array_to_json(array_agg(f)) AS features\n FROM(\n SELECT 'Feature' AS type,\n ST_ASGeoJSON(ST_TRANSFORM(m.geom,4326))::json As geometry,\n row_to_json((SELECT l FROM(SELECT id_maille) AS l)) AS properties\n FROM layers.maille_1_2 AS m WHERE m.taille_maille='1' AND ST_Within(m.geom,ST_TRANSFORM(ST_MakeEnvelope(\"\"\" + limit + \"\"\", 4326),32620)) ) AS f)\n AS fc; \"\"\"\n",
"db.cur.execute(sql)\n",
"res = db.cur.fetchone()\n",
"db.closeAll()\n",
"return Response(flask.json.dumps(res), mimetype='application/json')\n"
] | [
0,
0,
4,
0,
4,
4,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_13(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_7, VAR_12 = self.make_xsrf_handling_app()\n",
"VAR_17 = VAR_7.get('/request').body\n",
"VAR_7.post('/request', {'xsrf_token': VAR_17})\n",
"self.assertEqual([('POST', True)], VAR_12)\n"
] | [
"def test_xsrf_token_post_param(self):...\n",
"\"\"\"docstring\"\"\"\n",
"app, calls = self.make_xsrf_handling_app()\n",
"token = app.get('/request').body\n",
"app.post('/request', {'xsrf_token': token})\n",
"self.assertEqual([('POST', True)], calls)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_0(VAR_3=None, VAR_4=None, VAR_5=True):...\n",
"VAR_14, VAR_15 = vimsupport.CurrentLineAndColumn()\n",
"VAR_16 = vimsupport.GetCurrentBufferFilepath()\n",
"VAR_17 = {'filetypes': vimsupport.CurrentFiletypes(), 'line_num': VAR_14,\n 'column_num': VAR_15, 'start_column': VAR_3, 'line_value': vim.current.\n line, 'filepath': VAR_16}\n",
"if VAR_5:\n",
"VAR_17['file_data'] = vimsupport.GetUnsavedAndCurrentBufferData()\n",
"if VAR_4:\n",
"VAR_17['query'] = VAR_4\n",
"return VAR_17\n"
] | [
"def BuildRequestData(start_column=None, query=None, include_buffer_data=True):...\n",
"line, column = vimsupport.CurrentLineAndColumn()\n",
"filepath = vimsupport.GetCurrentBufferFilepath()\n",
"request_data = {'filetypes': vimsupport.CurrentFiletypes(), 'line_num':\n line, 'column_num': column, 'start_column': start_column, 'line_value':\n vim.current.line, 'filepath': filepath}\n",
"if include_buffer_data:\n",
"request_data['file_data'] = vimsupport.GetUnsavedAndCurrentBufferData()\n",
"if query:\n",
"request_data['query'] = query\n",
"return request_data\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self, *VAR_4, **VAR_5):...\n",
"return self._run_ssh(VAR_4, VAR_14=self.configuration.eqlx_cli_max_retries)\n"
] | [
"def _eql_execute(self, *args, **kwargs):...\n",
"return self._run_ssh(args, attempts=self.configuration.eqlx_cli_max_retries)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_44(self):...\n",
"return [i.name for i in self.obj.__mapper__.columns if isinstance(i.type,\n FileColumn)]\n"
] | [
"def get_file_column_list(self):...\n",
"return [i.name for i in self.obj.__mapper__.columns if isinstance(i.type,\n FileColumn)]\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_5(self, VAR_13, VAR_11, VAR_12, VAR_14='tests'):...\n",
"\"\"\"docstring\"\"\"\n",
"self._logger.csv(VAR_13 + '_waypoints', ['X_target', 'Y_target', 'X_map',\n 'Y_map', 'X_ekf', 'Y_ekf'], [VAR_11, VAR_12, self.map_pos.x, self.\n map_pos.y, self.p.x, self.p.y], VAR_14=folder)\n"
] | [
"def csvLogArrival(self, test_name, x, y, folder='tests'):...\n",
"\"\"\"docstring\"\"\"\n",
"self._logger.csv(test_name + '_waypoints', ['X_target', 'Y_target', 'X_map',\n 'Y_map', 'X_ekf', 'Y_ekf'], [x, y, self.map_pos.x, self.map_pos.y, self\n .p.x, self.p.y], folder=folder)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._unit_of_measurement\n"
] | [
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._unit_of_measurement\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_15(self, VAR_24='/tmp/app_test_client.log', VAR_22=4567, VAR_23=...\n",
"def FUNC_41():...\n",
"self.listenTCP(VAR_22, VAR_23)\n",
"reactor.run()\n",
"VAR_67 = multiprocessing.Process(target=_start)\n",
"VAR_67.start()\n",
"time.sleep(1)\n",
"return lambda : VAR_67.terminate()\n"
] | [
"def run_on_a_thread(self, logfile='/tmp/app_test_client.log', port=4567,...\n",
"def _start():...\n",
"self.listenTCP(port, host)\n",
"reactor.run()\n",
"process = multiprocessing.Process(target=_start)\n",
"process.start()\n",
"time.sleep(1)\n",
"return lambda : process.terminate()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"FunctionDef'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_37(self, VAR_29):...\n",
"VAR_12.append('authorization_error')\n",
"super(CLASS_7, self).authorization_error(VAR_29)\n"
] | [
"def authorization_error(self, err):...\n",
"calls.append('authorization_error')\n",
"super(Handler, self).authorization_error(err)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'"
] |
[
"def FUNC_7(self, VAR_21, VAR_22, VAR_23=None):...\n",
"import migrate.changeset\n",
"VAR_38 = datetime.now().strftime('_%Y%m%d%H%M%S').encode('utf-8')\n",
"self.metadata\n",
"VAR_39 = 'tmp_'.encode('utf-8')\n",
"VAR_40 = sqlalchemy.Table(VAR_21, self.metadata, autoload=True,\n autoload_with=self._engine)\n",
"VAR_41 = 'tmp_' + hashlib.sha256(VAR_39 + VAR_21.encode('utf-8') + VAR_38\n ).hexdigest()[0:56]\n",
"VAR_42 = sqlalchemy.Table(VAR_41, self.metadata, autoload=False)\n",
"for VAR_51 in VAR_40.columns:\n",
"VAR_42.append_column(VAR_51.copy())\n",
"VAR_42.create()\n",
"VAR_43 = {}\n",
"for index in VAR_40.indexes:\n",
"VAR_48 = hashlib.sha256(VAR_39 + index.name.encode('utf-8') + VAR_38\n ).hexdigest()[0:60]\n",
"self.insert(VAR_42.name, VAR_22, VAR_23=batch_size)\n",
"VAR_43[VAR_48] = index.name\n",
"self.execute(\n \"BEGIN; SET LOCAL statement_timeout = '1min'; ANALYZE %s; COMMIT;\" % VAR_21\n )\n",
"VAR_26 = []\n",
"VAR_50 = sqlalchemy.Table(VAR_21 + '_b', self.metadata)\n",
"for VAR_51 in index.columns:\n",
"VAR_50.drop(bind=self._connection, checkfirst=True)\n",
"VAR_26.append(next(x for x in VAR_42.columns if x.name == VAR_51.name))\n",
"VAR_49 = sqlalchemy.Index(VAR_48, *VAR_26)\n",
"VAR_40.rename(VAR_48=source.name + '_b', connection=self._connection)\n",
"VAR_49.unique = index.unique\n",
"VAR_42.rename(VAR_48=table, connection=self._connection)\n",
"VAR_49.table = VAR_42\n",
"for index in VAR_40.indexes:\n",
"VAR_49.create(bind=self._connection)\n",
"index.rename(index.name[0:-2] + '_b', connection=self._connection)\n",
"for index in VAR_42.indexes:\n",
"index.rename(VAR_43[index.name], connection=self._connection)\n",
"for VAR_11 in VAR_10:\n",
"VAR_11(VAR_42, VAR_40)\n"
] | [
"def replace(self, table, dataframe, batch_size=None):...\n",
"import migrate.changeset\n",
"suffix = datetime.now().strftime('_%Y%m%d%H%M%S').encode('utf-8')\n",
"self.metadata\n",
"temp = 'tmp_'.encode('utf-8')\n",
"source = sqlalchemy.Table(table, self.metadata, autoload=True,\n autoload_with=self._engine)\n",
"destination_name = 'tmp_' + hashlib.sha256(temp + table.encode('utf-8') +\n suffix).hexdigest()[0:56]\n",
"destination = sqlalchemy.Table(destination_name, self.metadata, autoload=False)\n",
"for column in source.columns:\n",
"destination.append_column(column.copy())\n",
"destination.create()\n",
"original_names = {}\n",
"for index in source.indexes:\n",
"name = hashlib.sha256(temp + index.name.encode('utf-8') + suffix).hexdigest()[\n 0:60]\n",
"self.insert(destination.name, dataframe, batch_size=batch_size)\n",
"original_names[name] = index.name\n",
"self.execute(\n \"BEGIN; SET LOCAL statement_timeout = '1min'; ANALYZE %s; COMMIT;\" % table)\n",
"columns = []\n",
"backup = sqlalchemy.Table(table + '_b', self.metadata)\n",
"for column in index.columns:\n",
"backup.drop(bind=self._connection, checkfirst=True)\n",
"columns.append(next(x for x in destination.columns if x.name == column.name))\n",
"new = sqlalchemy.Index(name, *columns)\n",
"source.rename(name=source.name + '_b', connection=self._connection)\n",
"new.unique = index.unique\n",
"destination.rename(name=table, connection=self._connection)\n",
"new.table = destination\n",
"for index in source.indexes:\n",
"new.create(bind=self._connection)\n",
"index.rename(index.name[0:-2] + '_b', connection=self._connection)\n",
"for index in destination.indexes:\n",
"index.rename(original_names[index.name], connection=self._connection)\n",
"for func in _after_replace_callbacks:\n",
"func(destination, source)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Import'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Expr'",
"Expr'",
"Assign'",
"For",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"For",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"For",
"Expr'",
"Expr'",
"For",
"Expr'",
"For",
"Expr'"
] |
[
"def FUNC_2(self, VAR_2, VAR_4):...\n",
"VAR_16 = VAR_4.get_access_mode()\n",
"if VAR_16 == VAR_1.ANONYMOUS:\n",
"return True\n",
"if not VAR_2.user.is_authenticated():\n",
"return False\n",
"if VAR_16 >= VAR_1.SUPERUSER:\n",
"return VAR_2.user.is_superuser\n",
"if VAR_16 >= VAR_1.TEACHER:\n",
"if not VAR_4.is_teacher:\n",
"if VAR_16 >= VAR_1.ASSISTANT:\n",
"self.error_msg(_('Only course teachers shall pass.'))\n",
"return True\n",
"if not VAR_4.is_course_staff:\n",
"if VAR_16 == VAR_1.ENROLLED:\n",
"return False\n",
"self.error_msg(_('Only course staff shall pass.'))\n",
"if not VAR_4.is_course_staff and not VAR_4.is_student:\n",
"return False\n",
"self.error_msg(_('Only enrolled students shall pass.'))\n",
"return False\n"
] | [
"def has_permission(self, request, view):...\n",
"access_mode = view.get_access_mode()\n",
"if access_mode == ACCESS.ANONYMOUS:\n",
"return True\n",
"if not request.user.is_authenticated():\n",
"return False\n",
"if access_mode >= ACCESS.SUPERUSER:\n",
"return request.user.is_superuser\n",
"if access_mode >= ACCESS.TEACHER:\n",
"if not view.is_teacher:\n",
"if access_mode >= ACCESS.ASSISTANT:\n",
"self.error_msg(_('Only course teachers shall pass.'))\n",
"return True\n",
"if not view.is_course_staff:\n",
"if access_mode == ACCESS.ENROLLED:\n",
"return False\n",
"self.error_msg(_('Only course staff shall pass.'))\n",
"if not view.is_course_staff and not view.is_student:\n",
"return False\n",
"self.error_msg(_('Only enrolled students shall pass.'))\n",
"return False\n"
] | [
0,
0,
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Condition",
"Condition",
"Expr'",
"Return'",
"Condition",
"Condition",
"Return'",
"Expr'",
"Condition",
"Return'",
"Expr'",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"super(CLASS_0, self).setUp()\n",
"self.mock(net, 'url_open', self._url_open)\n",
"self.mock(net, 'url_read_json', self._url_read_json)\n",
"self.mock(net, 'sleep_before_retry', lambda *VAR_10: None)\n",
"self._lock = threading.Lock()\n",
"self._requests = []\n"
] | [
"def setUp(self):...\n",
"super(TestCase, self).setUp()\n",
"self.mock(net, 'url_open', self._url_open)\n",
"self.mock(net, 'url_read_json', self._url_read_json)\n",
"self.mock(net, 'sleep_before_retry', lambda *_: None)\n",
"self._lock = threading.Lock()\n",
"self._requests = []\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'"
] |
[
"def FUNC_11(self):...\n",
"VAR_13 = self.cnxn.getinfo(pyodbc.SQL_CONCAT_NULL_BEHAVIOR)\n",
"self.assertTrue(isinstance(VAR_13, int))\n"
] | [
"def test_getinfo_smallint(self):...\n",
"value = self.cnxn.getinfo(pyodbc.SQL_CONCAT_NULL_BEHAVIOR)\n",
"self.assertTrue(isinstance(value, int))\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"async def FUNC_7(VAR_12: int, VAR_13: int):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_15 = -1\n",
"await cursor.execute(\n 'INSERT INTO item (player_uid, item_id) values (%d, %d)' %\n (VAR_12, VAR_13))\n",
"FUNC_10(ex)\n",
"await conn.commit()\n",
"VAR_15 = conn.insert_id()\n",
"return False, -1\n",
"return True, VAR_15\n"
] | [
"async def create_item(player_uid: int, item_id: int):...\n",
"\"\"\"docstring\"\"\"\n",
"uid = -1\n",
"await cursor.execute(\n 'INSERT INTO item (player_uid, item_id) values (%d, %d)' %\n (player_uid, item_id))\n",
"_error_report(ex)\n",
"await conn.commit()\n",
"uid = conn.insert_id()\n",
"return False, -1\n",
"return True, uid\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"AsyncFunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Return'",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = {'SEVERITY': {'HIGH': 13}, 'CONFIDENCE': {'HIGH': 13}}\n",
"self.check_example('ciphers.py', VAR_2)\n"
] | [
"def test_ciphers(self):...\n",
"\"\"\"docstring\"\"\"\n",
"expect = {'SEVERITY': {'HIGH': 13}, 'CONFIDENCE': {'HIGH': 13}}\n",
"self.check_example('ciphers.py', expect)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"import asyncio\n",
"import click\n",
"import collections\n",
"import hashlib\n",
"import os\n",
"import sys\n",
"import threading\n",
"import traceback\n",
"import urllib.parse\n",
"from concurrent import futures\n",
"from pathlib import Path\n",
"from markupsafe import Markup\n",
"from jinja2 import ChoiceLoader, Environment, FileSystemLoader, PrefixLoader\n",
"from sanic import Sanic, response\n",
"from sanic.exceptions import InvalidUsage, NotFound\n",
"from .views.base import DatasetteError, ureg\n",
"from .views.database import DatabaseDownload, DatabaseView\n",
"from .views.index import IndexView\n",
"from .views.special import JsonDataView\n",
"from .views.table import RowView, TableView\n",
"from .utils import InterruptedError, Results, escape_css_string, escape_sqlite, get_plugins, module_from_path, sqlite3, sqlite_timelimit, to_css_class\n",
"from .inspect import inspect_hash, inspect_views, inspect_tables\n",
"from .plugins import pm, DEFAULT_PLUGINS\n",
"from .version import __version__\n",
"VAR_0 = Path(__file__).parent.parent\n",
"VAR_1 = threading.local()\n",
"VAR_2 = object()\n",
"VAR_3 = collections.namedtuple('ConfigOption', ('name', 'default', 'help'))\n",
"VAR_4 = VAR_3('default_page_size', 100,\n \"\"\"\n Default page size for the table view\n \"\"\".strip()), VAR_3(\n 'max_returned_rows', 1000,\n \"\"\"\n Maximum rows that can be returned from a table or custom query\n \"\"\"\n .strip()), VAR_3('num_sql_threads', 3,\n \"\"\"\n Number of threads in the thread pool for executing SQLite queries\n \"\"\"\n .strip()), VAR_3('sql_time_limit_ms', 1000,\n \"\"\"\n Time limit for a SQL query in milliseconds\n \"\"\".strip()\n ), VAR_3('default_facet_size', 30,\n \"\"\"\n Number of values to return for requested facets\n \"\"\".strip()\n ), VAR_3('facet_time_limit_ms', 200,\n \"\"\"\n Time limit for calculating a requested facet\n \"\"\".strip()\n ), VAR_3('facet_suggest_time_limit_ms', 50,\n \"\"\"\n Time limit for calculating a suggested facet\n \"\"\".strip()\n ), VAR_3('allow_facet', True,\n \"\"\"\n Allow users to specify columns to facet using ?_facet= parameter\n \"\"\"\n .strip()), VAR_3('allow_download', True,\n \"\"\"\n Allow users to download the original SQLite database files\n \"\"\"\n .strip()), VAR_3('suggest_facets', True,\n \"\"\"\n Calculate and display suggested facets\n \"\"\".strip()), VAR_3(\n 'allow_sql', True,\n \"\"\"\n Allow arbitrary SQL queries via ?sql= parameter\n \"\"\".strip()\n ), VAR_3('default_cache_ttl', 365 * 24 * 60 * 60,\n \"\"\"\n Default HTTP cache TTL (used in Cache-Control: max-age= header)\n \"\"\"\n .strip()), VAR_3('cache_size_kb', 0,\n \"\"\"\n SQLite cache size in KB (0 == use SQLite default)\n \"\"\".\n strip()), VAR_3('allow_csv_stream', True,\n \"\"\"\n Allow .csv?_stream=1 to download all rows (ignoring max_returned_rows)\n \"\"\"\n .strip()), VAR_3('max_csv_mb', 100,\n \"\"\"\n Maximum size allowed for CSV export in MB - set 0 to disable this limit\n \"\"\"\n .strip()), VAR_3('truncate_cells_html', 2048,\n \"\"\"\n Truncate cells longer than this in HTML table view - set 0 to disable\n \"\"\"\n .strip()), VAR_3('force_https_urls', False,\n \"\"\"\n Force URLs in API output to always use https:// protocol\n \"\"\"\n .strip())\n",
"VAR_5 = {option.name: option.default for option in VAR_4}\n",
"async def FUNC_0(VAR_6):...\n",
"return response.text('')\n"
] | [
"import asyncio\n",
"import click\n",
"import collections\n",
"import hashlib\n",
"import os\n",
"import sys\n",
"import threading\n",
"import traceback\n",
"import urllib.parse\n",
"from concurrent import futures\n",
"from pathlib import Path\n",
"from markupsafe import Markup\n",
"from jinja2 import ChoiceLoader, Environment, FileSystemLoader, PrefixLoader\n",
"from sanic import Sanic, response\n",
"from sanic.exceptions import InvalidUsage, NotFound\n",
"from .views.base import DatasetteError, ureg\n",
"from .views.database import DatabaseDownload, DatabaseView\n",
"from .views.index import IndexView\n",
"from .views.special import JsonDataView\n",
"from .views.table import RowView, TableView\n",
"from .utils import InterruptedError, Results, escape_css_string, escape_sqlite, get_plugins, module_from_path, sqlite3, sqlite_timelimit, to_css_class\n",
"from .inspect import inspect_hash, inspect_views, inspect_tables\n",
"from .plugins import pm, DEFAULT_PLUGINS\n",
"from .version import __version__\n",
"app_root = Path(__file__).parent.parent\n",
"connections = threading.local()\n",
"MEMORY = object()\n",
"ConfigOption = collections.namedtuple('ConfigOption', ('name', 'default',\n 'help'))\n",
"CONFIG_OPTIONS = ConfigOption('default_page_size', 100,\n \"\"\"\n Default page size for the table view\n \"\"\".strip()\n ), ConfigOption('max_returned_rows', 1000,\n \"\"\"\n Maximum rows that can be returned from a table or custom query\n \"\"\"\n .strip()), ConfigOption('num_sql_threads', 3,\n \"\"\"\n Number of threads in the thread pool for executing SQLite queries\n \"\"\"\n .strip()), ConfigOption('sql_time_limit_ms', 1000,\n \"\"\"\n Time limit for a SQL query in milliseconds\n \"\"\".strip()\n ), ConfigOption('default_facet_size', 30,\n \"\"\"\n Number of values to return for requested facets\n \"\"\".strip()\n ), ConfigOption('facet_time_limit_ms', 200,\n \"\"\"\n Time limit for calculating a requested facet\n \"\"\".strip()\n ), ConfigOption('facet_suggest_time_limit_ms', 50,\n \"\"\"\n Time limit for calculating a suggested facet\n \"\"\".strip()\n ), ConfigOption('allow_facet', True,\n \"\"\"\n Allow users to specify columns to facet using ?_facet= parameter\n \"\"\"\n .strip()), ConfigOption('allow_download', True,\n \"\"\"\n Allow users to download the original SQLite database files\n \"\"\"\n .strip()), ConfigOption('suggest_facets', True,\n \"\"\"\n Calculate and display suggested facets\n \"\"\".strip()\n ), ConfigOption('allow_sql', True,\n \"\"\"\n Allow arbitrary SQL queries via ?sql= parameter\n \"\"\".strip()\n ), ConfigOption('default_cache_ttl', 365 * 24 * 60 * 60,\n \"\"\"\n Default HTTP cache TTL (used in Cache-Control: max-age= header)\n \"\"\"\n .strip()), ConfigOption('cache_size_kb', 0,\n \"\"\"\n SQLite cache size in KB (0 == use SQLite default)\n \"\"\".\n strip()), ConfigOption('allow_csv_stream', True,\n \"\"\"\n Allow .csv?_stream=1 to download all rows (ignoring max_returned_rows)\n \"\"\"\n .strip()), ConfigOption('max_csv_mb', 100,\n \"\"\"\n Maximum size allowed for CSV export in MB - set 0 to disable this limit\n \"\"\"\n .strip()), ConfigOption('truncate_cells_html', 2048,\n \"\"\"\n Truncate cells longer than this in HTML table view - set 0 to disable\n \"\"\"\n .strip()), ConfigOption('force_https_urls', False,\n \"\"\"\n Force URLs in API output to always use https:// protocol\n \"\"\"\n .strip())\n",
"DEFAULT_CONFIG = {option.name: option.default for option in CONFIG_OPTIONS}\n",
"async def favicon(request):...\n",
"return response.text('')\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,
6,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"AsyncFunctionDef'",
"Return'"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.