lines
sequencelengths
1
444
raw_lines
sequencelengths
1
444
label
sequencelengths
1
444
type
sequencelengths
1
444
[ "@VAR_0.route('normalize_column', methods=['POST'])...\n", "VAR_1 = get_dataset_with_id(request.args.get('dataset_id'))\n", "VAR_2 = request.form['column']\n", "normalize_attribute(VAR_1.working_copy, VAR_2)\n", "flash('An unexpected error occured while normalizing the column', 'danger')\n", "flash('Column normalized successfully.', 'success')\n", "create_action('Normalized {0}'.format(VAR_2), VAR_1.id, current_user.id)\n", "return redirect(request.referrer)\n" ]
[ "@_transform.route('normalize_column', methods=['POST'])...\n", "dataset = get_dataset_with_id(request.args.get('dataset_id'))\n", "col = request.form['column']\n", "normalize_attribute(dataset.working_copy, col)\n", "flash('An unexpected error occured while normalizing the column', 'danger')\n", "flash('Column normalized successfully.', 'success')\n", "create_action('Normalized {0}'.format(col), dataset.id, current_user.id)\n", "return redirect(request.referrer)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "def __init__(self, VAR_20, VAR_21, *VAR_19, **VAR_5):...\n", "super().__init__(*VAR_19, **kwargs)\n", "self.start = VAR_20\n", "self.end = VAR_21\n" ]
[ "def __init__(self, start, end, *args, **kwargs):...\n", "super().__init__(*args, **kwargs)\n", "self.start = start\n", "self.end = end\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'" ]
[ "def FUNC_5(self):...\n", "self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters={'name': ['like', 'J%']}))\n" ]
[ "def test_filters_3(self):...\n", "self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters={'name': ['like', 'J%']}))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_6(self, VAR_7=None, VAR_3=None, VAR_4=None, VAR_8=None):...\n", "if VAR_7:\n", "if isinstance(VAR_7, dict):\n", "return self.__dict__\n", "return FUNC_1(self.get_all_children(), VAR_7, VAR_4=limit)\n", "if VAR_3:\n", "if isinstance(VAR_3, dict):\n", "VAR_9 = self.__dict__.get(VAR_7, VAR_8)\n", "VAR_9 = FUNC_1(self.__dict__.get(VAR_7, []), VAR_3, VAR_4=limit)\n", "VAR_8 = VAR_3\n", "if VAR_9 is None and VAR_7 not in self.ignore_in_getter and VAR_7 in (VAR_6\n", "VAR_3 = None\n", "self.set(VAR_7, [])\n", "return VAR_9\n", "VAR_9 = self.__dict__.get(VAR_7, VAR_8)\n", "VAR_9 = self.__dict__.get(VAR_7)\n" ]
[ "def get(self, key=None, filters=None, limit=None, default=None):...\n", "if key:\n", "if isinstance(key, dict):\n", "return self.__dict__\n", "return _filter(self.get_all_children(), key, limit=limit)\n", "if filters:\n", "if isinstance(filters, dict):\n", "value = self.__dict__.get(key, default)\n", "value = _filter(self.__dict__.get(key, []), filters, limit=limit)\n", "default = filters\n", "if value is None and key not in self.ignore_in_getter and key in (d.\n", "filters = None\n", "self.set(key, [])\n", "return value\n", "value = self.__dict__.get(key, default)\n", "value = self.__dict__.get(key)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Return'", "Return'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Return'", "Assign'", "Assign'" ]
[ "def FUNC_0():...\n", "return {'queue': {'name': None, 'type': 'sqs', 'timeout-seconds': 20},\n 'store': {'type': 's3', 'name': None, 'path': 'osm',\n 'reduced-redundancy': False, 'date-prefix': '', 'delete-retry-interval':\n 60}, 'aws': {'credentials': {'aws_access_key_id': None,\n 'aws_secret_access_key': None}}, 'tiles': {'seed': {'all': {\n 'zoom-start': None, 'zoom-until': None}, 'metro-extract': {'url': None,\n 'zoom-start': None, 'zoom-until': None, 'cities': None}, 'top-tiles': {\n 'url': None, 'zoom-start': None, 'zoom-until': None}, 'custom': {\n 'zoom-start': None, 'zoom-until': None, 'bboxes': []},\n 'should-add-to-tiles-of-interest': True, 'n-threads': 50, 'unique': \n True}, 'intersect': {'expired-location': None, 'parent-zoom-until':\n None}, 'max-zoom-with-changes': 16}, 'toi-store': {'type': None},\n 'toi-prune': {'tile-traffic-log-path': '/tmp/tile-traffic.log'},\n 'process': {'n-simultaneous-query-sets': 0, 'n-simultaneous-s3-storage':\n 0, 'log-queue-sizes': True, 'log-queue-sizes-interval-seconds': 10,\n 'query-config': None, 'template-path': None, 'reload-templates': False,\n 'formats': ['json'], 'buffer': {}, 'yaml': {'type': None, 'parse': {\n 'path': ''}, 'callable': {'dotted-name': ''}}}, 'logging': {'config':\n None}, 'redis': {'host': 'localhost', 'port': 6379, 'db': 0,\n 'cache-set-key': 'tilequeue.tiles-of-interest', 'type': 'redis_client'},\n 'postgresql': {'host': 'localhost', 'port': 5432, 'dbnames': ('osm',),\n 'user': 'osm', 'password': None}, 'metatile': {'size': None,\n 'start-zoom': 0}, 'queue_buffer_size': {'sql': None, 'proc': None, 's3':\n None}}\n" ]
[ "def default_yml_config():...\n", "return {'queue': {'name': None, 'type': 'sqs', 'timeout-seconds': 20},\n 'store': {'type': 's3', 'name': None, 'path': 'osm',\n 'reduced-redundancy': False, 'date-prefix': '', 'delete-retry-interval':\n 60}, 'aws': {'credentials': {'aws_access_key_id': None,\n 'aws_secret_access_key': None}}, 'tiles': {'seed': {'all': {\n 'zoom-start': None, 'zoom-until': None}, 'metro-extract': {'url': None,\n 'zoom-start': None, 'zoom-until': None, 'cities': None}, 'top-tiles': {\n 'url': None, 'zoom-start': None, 'zoom-until': None}, 'custom': {\n 'zoom-start': None, 'zoom-until': None, 'bboxes': []},\n 'should-add-to-tiles-of-interest': True, 'n-threads': 50, 'unique': \n True}, 'intersect': {'expired-location': None, 'parent-zoom-until':\n None}, 'max-zoom-with-changes': 16}, 'toi-store': {'type': None},\n 'toi-prune': {'tile-traffic-log-path': '/tmp/tile-traffic.log'},\n 'process': {'n-simultaneous-query-sets': 0, 'n-simultaneous-s3-storage':\n 0, 'log-queue-sizes': True, 'log-queue-sizes-interval-seconds': 10,\n 'query-config': None, 'template-path': None, 'reload-templates': False,\n 'formats': ['json'], 'buffer': {}, 'yaml': {'type': None, 'parse': {\n 'path': ''}, 'callable': {'dotted-name': ''}}}, 'logging': {'config':\n None}, 'redis': {'host': 'localhost', 'port': 6379, 'db': 0,\n 'cache-set-key': 'tilequeue.tiles-of-interest', 'type': 'redis_client'},\n 'postgresql': {'host': 'localhost', 'port': 5432, 'dbnames': ('osm',),\n 'user': 'osm', 'password': None}, 'metatile': {'size': None,\n 'start-zoom': 0}, 'queue_buffer_size': {'sql': None, 'proc': None, 's3':\n None}}\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_0(self, VAR_0, VAR_1):...\n", "VAR_2, VAR_3 = self.fillParams([('attr', None, True), ('doc', None, True)])\n", "VAR_4 = self.db.execute(\n \"\"\"\n\t\t\tselect attr from attributes where attr='%s'\n\t\t\t\"\"\" % VAR_2)\n", "if not VAR_4:\n", "self.db.execute(\"\"\"\n\t\t\tdelete from attributes_doc where attr='%s'\n\t\t\t\"\"\" %\n VAR_2)\n", "if VAR_3:\n", "self.db.execute(\n \"\"\"\n\t\t\t\tinsert into attributes_doc\n\t\t\t\t(attr, doc)\n\t\t\t\tvalues ('%s', '%s')\n\t\t\t\t\"\"\"\n % (VAR_2, VAR_3))\n" ]
[ "def run(self, params, args):...\n", "attr, doc = self.fillParams([('attr', None, True), ('doc', None, True)])\n", "rows = self.db.execute(\n \"\"\"\n\t\t\tselect attr from attributes where attr='%s'\n\t\t\t\"\"\" % attr)\n", "if not rows:\n", "self.db.execute(\"\"\"\n\t\t\tdelete from attributes_doc where attr='%s'\n\t\t\t\"\"\" % attr\n )\n", "if doc:\n", "self.db.execute(\n \"\"\"\n\t\t\t\tinsert into attributes_doc\n\t\t\t\t(attr, doc)\n\t\t\t\tvalues ('%s', '%s')\n\t\t\t\t\"\"\"\n % (attr, doc))\n" ]
[ 0, 0, 2, 0, 2, 0, 2 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Expr'" ]
[ "@VAR_4.cli.command('initdb')...\n", "\"\"\"docstring\"\"\"\n", "FUNC_3()\n", "print('Initialized the database.')\n" ]
[ "@app.cli.command('initdb')...\n", "\"\"\"docstring\"\"\"\n", "init_db()\n", "print('Initialized the database.')\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Expr'", "Expr'" ]
[ "def FUNC_1(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_18 = ['hp3par_api_url', 'hp3par_username', 'hp3par_password', 'san_ip',\n 'san_login', 'san_password']\n", "self.common.check_flags(self.configuration, VAR_18)\n" ]
[ "def _check_flags(self):...\n", "\"\"\"docstring\"\"\"\n", "required_flags = ['hp3par_api_url', 'hp3par_username', 'hp3par_password',\n 'san_ip', 'san_login', 'san_password']\n", "self.common.check_flags(self.configuration, required_flags)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'" ]
[ "def FUNC_2(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_1 = self.client.get('/api/apps', HTTP_X_DEIS_VERSION='1234.5678')\n", "self.assertEqual(VAR_1.status_code, 405)\n" ]
[ "def test_x_deis_version_header_bad(self):...\n", "\"\"\"docstring\"\"\"\n", "response = self.client.get('/api/apps', HTTP_X_DEIS_VERSION='1234.5678')\n", "self.assertEqual(response.status_code, 405)\n" ]
[ 0, 0, 5, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'" ]
[ "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'" ]
[ "def FUNC_0():...\n", "def FUNC_1():...\n", "return FUNC_1\n" ]
[ "def a():...\n", "def b():...\n", "return b\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Return'" ]
[ "def FUNC_2(self):...\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_7 = Container.objects.create(owner=User.objects.get(username='autotest'\n ), app=App.objects.get(id=app_id), release=App.objects.get(id=app_id).\n release_set.latest(), type='web', VAR_9=1)\n", "self.assertEqual(VAR_7.state, 'initialized')\n", "self.assertRaises(TransitionNotAllowed, lambda : VAR_7.start())\n", "VAR_7.create()\n", "self.assertEqual(VAR_7.state, 'created')\n", "VAR_7.start()\n", "self.assertEqual(VAR_7.state, 'up')\n", "VAR_7.destroy()\n", "self.assertEqual(VAR_7.state, 'destroyed')\n" ]
[ "def test_container_state_good(self):...\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", "c = Container.objects.create(owner=User.objects.get(username='autotest'),\n app=App.objects.get(id=app_id), release=App.objects.get(id=app_id).\n release_set.latest(), type='web', num=1)\n", "self.assertEqual(c.state, 'initialized')\n", "self.assertRaises(TransitionNotAllowed, lambda : c.start())\n", "c.create()\n", "self.assertEqual(c.state, 'created')\n", "c.start()\n", "self.assertEqual(c.state, 'up')\n", "c.destroy()\n", "self.assertEqual(c.state, 'destroyed')\n" ]
[ 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_0(self):...\n", "return self.config['runtime.static_dir']\n" ]
[ "def get_base_path(self):...\n", "return self.config['runtime.static_dir']\n" ]
[ 0, 1 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_12(self):...\n", "self.run_test_case(self.scenario.delete_server_group(), max_retries=5)\n" ]
[ "def test_x_delete_server_group(self):...\n", "self.run_test_case(self.scenario.delete_server_group(), max_retries=5)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_3(self, VAR_1, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "self.cursor.execute('DELETE FROM {0} WHERE {1}'.format(VAR_1, VAR_3))\n", "print('Erro: {}'.format(error))\n", "self.__connection.commit()\n", "return self.cursor\n" ]
[ "def delete_where(self, table, where):...\n", "\"\"\"docstring\"\"\"\n", "self.cursor.execute('DELETE FROM {0} WHERE {1}'.format(table, where))\n", "print('Erro: {}'.format(error))\n", "self.__connection.commit()\n", "return self.cursor\n" ]
[ 0, 0, 4, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_1(VAR_2):...\n", "return HttpResponsePermanentRedirect(reverse('home'))\n" ]
[ "def redirect_to_home(request):...\n", "return HttpResponsePermanentRedirect(reverse('home'))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_18(self, VAR_18, VAR_23):...\n", "\"\"\"docstring\"\"\"\n", "if type(VAR_18) == str:\n", "VAR_18 = self.locate(VAR_18)\n", "if VAR_18.parent:\n", "if not VAR_18:\n", "VAR_18.file_name = VAR_23\n", "if VAR_18.is_dir:\n", "return False\n", "VAR_18.parent.sub_names_idx[VAR_18.file_name] = VAR_18\n", "self._update_in_db(VAR_18)\n", "self._update_in_db(VAR_18.parent)\n", "return True\n" ]
[ "def rename(self, item, file_name):...\n", "\"\"\"docstring\"\"\"\n", "if type(item) == str:\n", "item = self.locate(item)\n", "if item.parent:\n", "if not item:\n", "item.file_name = file_name\n", "if item.is_dir:\n", "return False\n", "item.parent.sub_names_idx[item.file_name] = item\n", "self._update_in_db(item)\n", "self._update_in_db(item.parent)\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Condition", "Return'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def __init__(self, *VAR_5, **VAR_6):...\n", "self.campaign = VAR_6['campaign']\n", "super(CLASS_2, self).__init__(*VAR_5, **kwargs)\n", "self.queryset = VAR_6['queryset']\n", "VAR_28 = self.simics_register_diff_choices('checkpoint_number')\n", "self.filters['checkpoint_number'].extra.update(VAR_4=checkpoint_number_choices)\n", "self.filters['checkpoint_number'].widget.attrs['size'] = min(len(VAR_28), 10)\n", "VAR_30 = self.simics_register_diff_choices('register')\n", "self.filters['register'].extra.update(VAR_4=register_choices)\n", "self.filters['register'].widget.attrs['size'] = min(len(VAR_30), 10)\n" ]
[ "def __init__(self, *args, **kwargs):...\n", "self.campaign = kwargs['campaign']\n", "super(simics_register_diff_filter, self).__init__(*args, **kwargs)\n", "self.queryset = kwargs['queryset']\n", "checkpoint_number_choices = self.simics_register_diff_choices(\n 'checkpoint_number')\n", "self.filters['checkpoint_number'].extra.update(choices=\n checkpoint_number_choices)\n", "self.filters['checkpoint_number'].widget.attrs['size'] = min(len(\n checkpoint_number_choices), 10)\n", "register_choices = self.simics_register_diff_choices('register')\n", "self.filters['register'].extra.update(choices=register_choices)\n", "self.filters['register'].widget.attrs['size'] = min(len(register_choices), 10)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'" ]
[ "@defer.inlineCallbacks...\n", "\"\"\"docstring\"\"\"\n", "VAR_13, VAR_8, VAR_14 = yield completion.complete(self, self.lineBuffer,\n self.lineBufferIndex)\n", "if len(VAR_14) == 1:\n", "VAR_17 = '' if VAR_8 else ' '\n", "if len(VAR_14) > 1:\n", "if self.lineBuffer[self.lineBufferIndex - len(VAR_13) - 1] == '\"':\n", "VAR_19 = os.path.commonprefix(VAR_14)\n", "VAR_17 = '\" '\n", "if VAR_14[0].endswith('='):\n", "VAR_18 = VAR_19[len(VAR_13):]\n", "VAR_17 = ''\n", "VAR_18 = VAR_14[0][len(VAR_13):] + VAR_17\n", "self.insert_text(VAR_18)\n", "self.insert_text(VAR_18)\n", "if not VAR_18:\n", "self.terminal.nextLine()\n", "self.terminal.write(columnize(VAR_14))\n", "self.drawInputLine()\n", "if len(VAR_8):\n", "self.terminal.cursorBackward(len(VAR_8))\n" ]
[ "@defer.inlineCallbacks...\n", "\"\"\"docstring\"\"\"\n", "partial, rest, completions = yield completion.complete(self, self.\n lineBuffer, self.lineBufferIndex)\n", "if len(completions) == 1:\n", "space = '' if rest else ' '\n", "if len(completions) > 1:\n", "if self.lineBuffer[self.lineBufferIndex - len(partial) - 1] == '\"':\n", "common_prefix = os.path.commonprefix(completions)\n", "space = '\" '\n", "if completions[0].endswith('='):\n", "patch = common_prefix[len(partial):]\n", "space = ''\n", "patch = completions[0][len(partial):] + space\n", "self.insert_text(patch)\n", "self.insert_text(patch)\n", "if not patch:\n", "self.terminal.nextLine()\n", "self.terminal.write(columnize(completions))\n", "self.drawInputLine()\n", "if len(rest):\n", "self.terminal.cursorBackward(len(rest))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Condition", "Expr'", "Expr'", "Expr'", "Condition", "Expr'" ]
[ "def FUNC_3(self):...\n", "self.assertIn('USER', os.environ)\n", "self.assertNotIn('USER', os.environ)\n" ]
[ "def test_hermetic_environment(self):...\n", "self.assertIn('USER', os.environ)\n", "self.assertNotIn('USER', os.environ)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'" ]
[ "def FUNC_17(self, VAR_14):...\n", "" ]
[ "def is_relation(self, col_name):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "@django.utils.decorators.classonlymethod...\n", "\"\"\"docstring\"\"\"\n", "for key in VAR_12:\n", "if key in VAR_11.http_method_names:\n", "def FUNC_8(VAR_2, *VAR_3, **VAR_4):...\n", "if not hasattr(VAR_11, key):\n", "self = VAR_11(**initkwargs)\n", "if hasattr(self, 'get') and not hasattr(self, 'head'):\n", "self.head = self.get\n", "self.request = VAR_2\n", "self.args = VAR_3\n", "self.kwargs = VAR_4\n", "self.setup(VAR_2, *VAR_3, **kwargs)\n", "return self.dispatch(VAR_2, *VAR_3, **kwargs)\n" ]
[ "@django.utils.decorators.classonlymethod...\n", "\"\"\"docstring\"\"\"\n", "for key in initkwargs:\n", "if key in cls.http_method_names:\n", "def view(request, *args, **kwargs):...\n", "if not hasattr(cls, key):\n", "self = cls(**initkwargs)\n", "if hasattr(self, 'get') and not hasattr(self, 'head'):\n", "self.head = self.get\n", "self.request = request\n", "self.args = args\n", "self.kwargs = kwargs\n", "self.setup(request, *args, **kwargs)\n", "return self.dispatch(request, *args, **kwargs)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "For", "Condition", "FunctionDef'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "@retries(5, delay=0.5, backoff=1.5)...\n", "if VAR_11 == 'POST':\n", "return requests.post(FUNC_2(VAR_7), VAR_9=ToUtf8Json(data), headers=_HEADERS)\n", "if VAR_11 == 'GET':\n", "return requests.get(FUNC_2(VAR_7), headers=_HEADERS)\n" ]
[ "@retries(5, delay=0.5, backoff=1.5)...\n", "if method == 'POST':\n", "return requests.post(_BuildUri(handler), data=ToUtf8Json(data), headers=\n _HEADERS)\n", "if method == 'GET':\n", "return requests.get(_BuildUri(handler), headers=_HEADERS)\n" ]
[ 0, 0, 7, 0, 0 ]
[ "Condition", "Condition", "Return'", "Condition", "Return'" ]
[ "@utils.synchronized('3par', external=True)...\n", "self.common.client_login()\n", "self.common.delete_volume(VAR_6)\n", "self.common.client_logout()\n" ]
[ "@utils.synchronized('3par', external=True)...\n", "self.common.client_login()\n", "self.common.delete_volume(volume)\n", "self.common.client_logout()\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_3(self):...\n", "VAR_8 = 'test_foo.py'\n", "VAR_7 = BokChoyTestSuite('', test_spec=spec)\n", "VAR_1 = 'tests/{}'.format(VAR_8)\n", "self.assertEqual(VAR_7.cmd, self._expected_command(VAR_1=name))\n" ]
[ "def test_suite_spec(self):...\n", "spec = 'test_foo.py'\n", "suite = BokChoyTestSuite('', test_spec=spec)\n", "name = 'tests/{}'.format(spec)\n", "self.assertEqual(suite.cmd, self._expected_command(name=name))\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_20(self):...\n", "if self.context.products.is_required_data('zinc_analysis'):\n", "self.context.products.safe_create_data('zinc_analysis', dict)\n", "if self.context.products.is_required_data('zinc_args'):\n", "self.context.products.safe_create_data('zinc_args', lambda : defaultdict(list))\n" ]
[ "def create_empty_extra_products(self):...\n", "if self.context.products.is_required_data('zinc_analysis'):\n", "self.context.products.safe_create_data('zinc_analysis', dict)\n", "if self.context.products.is_required_data('zinc_args'):\n", "self.context.products.safe_create_data('zinc_args', lambda : defaultdict(list))\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Condition", "Expr'" ]
[ "def FUNC_5(self):...\n", "VAR_10 = None\n", "VAR_26, VAR_8 = read_config(self.source)\n", "if VAR_26 is None:\n", "VAR_12 = YamlConfig(VAR_26, VAR_7=self.skip_checks)\n", "if VAR_12.host and self._is_newer(VAR_8, VAR_12.host_name):\n", "VAR_10 = self.create_filename(VAR_12.host_name)\n", "if VAR_10:\n", "VAR_11 = CLASS_1(VAR_12, VAR_8)\n", "VAR_3.info(\"Icinga config file '%s' created.\" % VAR_10)\n", "return VAR_10\n", "self.write_output(VAR_10, VAR_11)\n" ]
[ "def generate(self):...\n", "file_name = None\n", "raw_yaml_config, header_source = read_config(self.source)\n", "if raw_yaml_config is None:\n", "yaml_config = YamlConfig(raw_yaml_config, skip_checks=self.skip_checks)\n", "if yaml_config.host and self._is_newer(header_source, yaml_config.host_name):\n", "file_name = self.create_filename(yaml_config.host_name)\n", "if file_name:\n", "yaml_icinga = YamlToIcinga(yaml_config, header_source)\n", "LOG.info(\"Icinga config file '%s' created.\" % file_name)\n", "return file_name\n", "self.write_output(file_name, yaml_icinga)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Expr'", "Return'", "Expr'" ]
[ "def FUNC_0(self):...\n", "\"\"\"docstring\"\"\"\n", "log.debug(\n 'Establishing SSH tunnel to the server where the database is located...')\n", "sshtunnel.SSH_TIMEOUT = 5.0\n", "sshtunnel.TUNNEL_TIMEOUT = 5.0\n", "self.tunnel = sshtunnel.SSHTunnelForwarder(ssh_address_or_host=config.\n SERVER_ADDRESS, ssh_username=config.SSH_USER, ssh_password=config.\n SSH_PASSWD, ssh_port=22, remote_bind_address=('127.0.0.1', 3306))\n", "self.tunnel.start()\n", "self.tunnel_opened = True\n", "log.debug('SSH tunnel has been established.')\n" ]
[ "def _open_ssh_tunnel(self):...\n", "\"\"\"docstring\"\"\"\n", "log.debug(\n 'Establishing SSH tunnel to the server where the database is located...')\n", "sshtunnel.SSH_TIMEOUT = 5.0\n", "sshtunnel.TUNNEL_TIMEOUT = 5.0\n", "self.tunnel = sshtunnel.SSHTunnelForwarder(ssh_address_or_host=config.\n SERVER_ADDRESS, ssh_username=config.SSH_USER, ssh_password=config.\n SSH_PASSWD, ssh_port=22, remote_bind_address=('127.0.0.1', 3306))\n", "self.tunnel.start()\n", "self.tunnel_opened = True\n", "log.debug('SSH tunnel has been established.')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_11(VAR_10):...\n", "if VAR_10 and VAR_10 >= 16070400:\n", "return True\n", "return False\n" ]
[ "def validate_hsts_max_age(max_age):...\n", "if max_age and max_age >= 16070400:\n", "return True\n", "return False\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_2(self):...\n", "VAR_22 = []\n", "for VAR_6 in Ganesha.get_ganesha_clusters():\n", "VAR_22.extend([VAR_26.to_dict() for VAR_26 in GaneshaConf.instance(VAR_6).\n list_exports()])\n", "return VAR_22\n" ]
[ "def list(self):...\n", "result = []\n", "for cluster_id in Ganesha.get_ganesha_clusters():\n", "result.extend([export.to_dict() for export in GaneshaConf.instance(\n cluster_id).list_exports()])\n", "return result\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Expr'", "Return'" ]
[ "def __contains__(self, VAR_0):...\n", "for node in self.nodes:\n", "if node['node_object'] == VAR_0:\n", "return False\n", "return True\n" ]
[ "def __contains__(self, obj):...\n", "for node in self.nodes:\n", "if node['node_object'] == obj:\n", "return False\n", "return True\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Condition", "Return'", "Return'" ]
[ "def FUNC_0(self, *VAR_3, **VAR_4):...\n", "VAR_7 = super().get_context_data(*VAR_3, **kwargs)\n", "if self.request.GET.get('back', None) is not None:\n", "VAR_7['back_link'] = self.request.GET['back']\n", "return VAR_7\n" ]
[ "def get_context_data(self, *args, **kwargs):...\n", "data = super().get_context_data(*args, **kwargs)\n", "if self.request.GET.get('back', None) is not None:\n", "data['back_link'] = self.request.GET['back']\n", "return data\n" ]
[ 0, 0, 3, 3, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Return'" ]
[ "def FUNC_7(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_1 = self.bindings\n", "VAR_7 = VAR_1['TEST_APP_COMPONENT_NAME']\n", "VAR_15 = '{app}-{stack}-v000'.format(app=self.TEST_APP, stack=bindings[\n 'TEST_STACK'])\n", "VAR_8 = VAR_1['TEST_AWS_REGION']\n", "VAR_9 = [VAR_8 + 'a', VAR_8 + 'b']\n", "VAR_12 = self.agent.make_json_payload_from_kwargs(job=[{'type':\n 'createServerGroup', 'cloudProvider': 'aws', 'application': self.\n TEST_APP, 'credentials': bindings['AWS_CREDENTIALS'], 'strategy': '',\n 'capacity': {'min': 2, 'max': 2, 'desired': 2},\n 'targetHealthyDeployPercentage': 100, 'loadBalancers': [\n load_balancer_name], 'cooldown': 8, 'healthCheckType': 'EC2',\n 'healthCheckGracePeriod': 40, 'instanceMonitoring': False,\n 'ebsOptimized': False, 'iamRole': bindings['AWS_IAM_ROLE'],\n 'terminationPolicies': ['Default'], 'availabilityZones': {region:\n avail_zones}, 'keyPair': bindings['AWS_CREDENTIALS'] + '-keypair',\n 'suspendedProcesses': [], 'subnetType': 'internal (defaultvpc)',\n 'securityGroups': [bindings['TEST_AWS_SECURITY_GROUP_ID']],\n 'virtualizationType': 'paravirtual', 'stack': bindings['TEST_STACK'],\n 'freeFormDetails': '', 'amiName': bindings['TEST_AWS_AMI'],\n 'instanceType': 'm1.small', 'useSourceCapacity': False, 'account':\n bindings['AWS_CREDENTIALS'], 'user': '[anonymous]'}], description=\n 'Create Server Group in ' + group_name, application=self.TEST_APP)\n", "VAR_13 = aws.AwsContractBuilder(self.aws_observer)\n", "VAR_13.new_clause_builder('Auto Server Group Added', retryable_for_secs=30\n ).collect_resources('autoscaling', 'describe-auto-scaling-groups', args\n =['--auto-scaling-group-names', group_name]).contains_path_value(\n 'AutoScalingGroups', {'MaxSize': 2})\n", "return st.OperationContract(self.new_post_operation(title=\n 'create_server_group', data=payload, path='tasks'), VAR_6=builder.build())\n" ]
[ "def create_server_group(self):...\n", "\"\"\"docstring\"\"\"\n", "bindings = self.bindings\n", "load_balancer_name = bindings['TEST_APP_COMPONENT_NAME']\n", "group_name = '{app}-{stack}-v000'.format(app=self.TEST_APP, stack=bindings[\n 'TEST_STACK'])\n", "region = bindings['TEST_AWS_REGION']\n", "avail_zones = [region + 'a', region + 'b']\n", "payload = self.agent.make_json_payload_from_kwargs(job=[{'type':\n 'createServerGroup', 'cloudProvider': 'aws', 'application': self.\n TEST_APP, 'credentials': bindings['AWS_CREDENTIALS'], 'strategy': '',\n 'capacity': {'min': 2, 'max': 2, 'desired': 2},\n 'targetHealthyDeployPercentage': 100, 'loadBalancers': [\n load_balancer_name], 'cooldown': 8, 'healthCheckType': 'EC2',\n 'healthCheckGracePeriod': 40, 'instanceMonitoring': False,\n 'ebsOptimized': False, 'iamRole': bindings['AWS_IAM_ROLE'],\n 'terminationPolicies': ['Default'], 'availabilityZones': {region:\n avail_zones}, 'keyPair': bindings['AWS_CREDENTIALS'] + '-keypair',\n 'suspendedProcesses': [], 'subnetType': 'internal (defaultvpc)',\n 'securityGroups': [bindings['TEST_AWS_SECURITY_GROUP_ID']],\n 'virtualizationType': 'paravirtual', 'stack': bindings['TEST_STACK'],\n 'freeFormDetails': '', 'amiName': bindings['TEST_AWS_AMI'],\n 'instanceType': 'm1.small', 'useSourceCapacity': False, 'account':\n bindings['AWS_CREDENTIALS'], 'user': '[anonymous]'}], description=\n 'Create Server Group in ' + group_name, application=self.TEST_APP)\n", "builder = aws.AwsContractBuilder(self.aws_observer)\n", "builder.new_clause_builder('Auto Server Group Added', retryable_for_secs=30\n ).collect_resources('autoscaling', 'describe-auto-scaling-groups', args\n =['--auto-scaling-group-names', group_name]).contains_path_value(\n 'AutoScalingGroups', {'MaxSize': 2})\n", "return st.OperationContract(self.new_post_operation(title=\n 'create_server_group', data=payload, path='tasks'), contract=builder.\n build())\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_0(VAR_0, VAR_1):...\n", "VAR_15 = '%s.change_%s' % tuple(VAR_1.split('.'))\n", "if VAR_0.user.has_perm(VAR_15):\n", "return True\n", "return False\n" ]
[ "def check_permission(request, ctype):...\n", "perm = '%s.change_%s' % tuple(ctype.split('.'))\n", "if request.user.has_perm(perm):\n", "return True\n", "return False\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_23(self):...\n", "if self.limit_page_length:\n", "return 'limit %s, %s' % (self.limit_start, self.limit_page_length)\n", "return ''\n" ]
[ "def add_limit(self):...\n", "if self.limit_page_length:\n", "return 'limit %s, %s' % (self.limit_start, self.limit_page_length)\n", "return ''\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_1(self):...\n", "VAR_5 = self._dbArgs.copy()\n", "self.augmentDatabaseArgs(VAR_5)\n", "return self.dbapiModule().connect(**kwargs)\n" ]
[ "def newConnection(self):...\n", "kwargs = self._dbArgs.copy()\n", "self.augmentDatabaseArgs(kwargs)\n", "return self.dbapiModule().connect(**kwargs)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_3(self):...\n", "VAR_2 = self.connect()\n", "VAR_3 = 'DELETE FROM crimes;'\n", "VAR_2.close()\n", "cursor.execute(VAR_3)\n", "VAR_2.commit()\n" ]
[ "def clear_all(self):...\n", "connection = self.connect()\n", "query = 'DELETE FROM crimes;'\n", "connection.close()\n", "cursor.execute(query)\n", "connection.commit()\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "@property...\n", "def FUNC_34(VAR_25):...\n", "VAR_24 = os.environ.get(VAR_25)\n", "return self.Location.from_home(VAR_24) if VAR_24 else None\n" ]
[ "@property...\n", "def env_home(home_env_var):...\n", "home = os.environ.get(home_env_var)\n", "return self.Location.from_home(home) if home else None\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_6():...\n", "VAR_13.throw(_('Invalid Search Field'), VAR_13.DataError)\n" ]
[ "def _raise_exception():...\n", "frappe.throw(_('Invalid Search Field'), frappe.DataError)\n" ]
[ 0, 4 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_2(self, VAR_6):...\n", "VAR_6 = u\"'{0}'\".format(VAR_6)\n", "return VAR_6\n" ]
[ "def insert_format(self, value):...\n", "value = u\"'{0}'\".format(value)\n", "return value\n" ]
[ 0, 4, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "import pymysql.cursors\n", "def __init__(self, VAR_0):...\n", "VAR_3 = pymysql.connect(host='localhost', user='root', password='', VAR_0=\n db, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor,\n autocommit=True)\n", "self.connection = VAR_3\n", "def FUNC_1(self, VAR_1, VAR_2=None):...\n", "VAR_1 = cursor.mogrify(VAR_1, VAR_2)\n", "print('Something went wrong', e)\n", "self.connection.close()\n", "def FUNC_0(VAR_0):...\n", "print('Running Query:', VAR_1)\n", "return False\n", "return CLASS_0(VAR_0)\n", "VAR_4 = cursor.execute(VAR_1, VAR_2)\n", "if VAR_1.lower().find('insert') >= 0:\n", "self.connection.commit()\n", "if VAR_1.lower().find('select') >= 0:\n", "return cursor.lastrowid\n", "VAR_5 = cursor.fetchall()\n", "self.connection.commit()\n", "return VAR_5\n" ]
[ "import pymysql.cursors\n", "def __init__(self, db):...\n", "connection = pymysql.connect(host='localhost', user='root', password='', db\n =db, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor,\n autocommit=True)\n", "self.connection = connection\n", "def query_db(self, query, data=None):...\n", "query = cursor.mogrify(query, data)\n", "print('Something went wrong', e)\n", "self.connection.close()\n", "def connectToMySQL(db):...\n", "print('Running Query:', query)\n", "return False\n", "return MySQLConnection(db)\n", "executable = cursor.execute(query, data)\n", "if query.lower().find('insert') >= 0:\n", "self.connection.commit()\n", "if query.lower().find('select') >= 0:\n", "return cursor.lastrowid\n", "result = cursor.fetchall()\n", "self.connection.commit()\n", "return result\n" ]
[ 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "FunctionDef'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "Return'", "Return'", "Assign'", "Condition", "Expr'", "Condition", "Return'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_6(self, VAR_10):...\n", "\"\"\"docstring\"\"\"\n", "return VAR_10 in self._rules\n" ]
[ "def is_rule(self, name):...\n", "\"\"\"docstring\"\"\"\n", "return name in self._rules\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "\"\"\"\nUnit tests for the Deis api app.\n\nRun the tests with \"./manage.py test api\\\"\n\"\"\"\n", "from __future__ import unicode_literals\n", "import json\n", "import mock\n", "import requests\n", "from django.test import TransactionTestCase\n", "from api.models import Build\n", "def FUNC_0(*VAR_0, **VAR_1):...\n", "VAR_2 = requests.Response()\n", "VAR_2.status_code = 200\n", "VAR_2._content_consumed = True\n", "return VAR_2\n" ]
[ "\"\"\"\nUnit tests for the Deis api app.\n\nRun the tests with \"./manage.py test api\\\"\n\"\"\"\n", "from __future__ import unicode_literals\n", "import json\n", "import mock\n", "import requests\n", "from django.test import TransactionTestCase\n", "from api.models import Build\n", "def mock_import_repository_task(*args, **kwargs):...\n", "resp = requests.Response()\n", "resp.status_code = 200\n", "resp._content_consumed = True\n", "return resp\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "ImportFrom'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_22(self, VAR_11):...\n", "\"\"\"docstring\"\"\"\n", "VAR_35 = self.common._cli_run('showvlun -a -host %s' % VAR_11, None)\n", "if VAR_35:\n", "VAR_35 = VAR_35[1:]\n", "for line in VAR_35:\n", "VAR_30 = line.split(',')\n", "if VAR_30 and len(VAR_30) > 4:\n", "return VAR_30[4]\n" ]
[ "def _get_active_nsp(self, hostname):...\n", "\"\"\"docstring\"\"\"\n", "result = self.common._cli_run('showvlun -a -host %s' % hostname, None)\n", "if result:\n", "result = result[1:]\n", "for line in result:\n", "info = line.split(',')\n", "if info and len(info) > 4:\n", "return info[4]\n" ]
[ 0, 0, 2, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "For", "Assign'", "Condition", "Return'" ]
[ "def FUNC_36(self, VAR_14):...\n", "return self.__class__(self.get_related_model(VAR_14), self.session)\n" ]
[ "def get_related_interface(self, col_name):...\n", "return self.__class__(self.get_related_model(col_name), self.session)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_16(self, **VAR_17):...\n", "\"\"\"docstring\"\"\"\n", "self.set_defaults(**kwargs)\n", "for VAR_42, VAR_3 in VAR_17.items():\n", "self.overridable[VAR_42] = VAR_3\n" ]
[ "def set_params(self, **kwargs):...\n", "\"\"\"docstring\"\"\"\n", "self.set_defaults(**kwargs)\n", "for k, v in kwargs.items():\n", "self.overridable[k] = v\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "For", "Assign'" ]
[ "def FUNC_11():...\n", "VAR_16 = FUNC_7('models.json')\n", "return [(VAR_34['model_system_name'], VAR_34['model_name_user'] + ':' +\n VAR_34['author']) for VAR_34 in VAR_16]\n" ]
[ "def get_models_choices():...\n", "models = load_json('models.json')\n", "return [(model['model_system_name'], model['model_name_user'] + ':' + model\n ['author']) for model in models]\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "@api.public...\n", "FUNC_31(self, 'POST')\n" ]
[ "@api.public...\n", "record(self, 'POST')\n" ]
[ 0, 0 ]
[ "Condition", "Expr'" ]
[ "def FUNC_8(self):...\n", "run_shell_command('super-cool-command', weird_parameter2='abc')\n", "run_shell_command('super-cool-command', universal_newlines=False)\n" ]
[ "def test_run_shell_command_kwargs_delegation(self):...\n", "run_shell_command('super-cool-command', weird_parameter2='abc')\n", "run_shell_command('super-cool-command', universal_newlines=False)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'" ]
[ "\"\"\"Internal bot API handlers.\"\"\"\n", "import base64\n", "import json\n", "import logging\n", "import textwrap\n", "import webob\n", "import webapp2\n", "from google.appengine.api import app_identity\n", "from google.appengine.api import datastore_errors\n", "from google.appengine.datastore import datastore_query\n", "from google.appengine import runtime\n", "from google.appengine.ext import ndb\n", "from components import auth\n", "from components import ereporter2\n", "from components import utils\n", "from server import acl\n", "from server import bot_code\n", "from server import bot_management\n", "from server import stats\n", "from server import task_pack\n", "from server import task_request\n", "from server import task_result\n", "from server import task_scheduler\n", "from server import task_to_run\n", "def FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_2 = frozenset(VAR_2)\n", "VAR_6 = VAR_2 - VAR_0\n", "VAR_7 = VAR_1 - VAR_2\n", "if VAR_6 or VAR_7:\n", "VAR_22 = ' missing: %s' % sorted(VAR_7) if VAR_7 else ''\n", "def FUNC_1(VAR_0, VAR_2, VAR_3):...\n", "VAR_23 = ' superfluous: %s' % sorted(VAR_6) if VAR_6 else ''\n", "\"\"\"docstring\"\"\"\n", "return 'Unexpected %s%s%s; did you make a typo?' % (VAR_3, VAR_22, VAR_23)\n", "return FUNC_0(VAR_0, VAR_0, VAR_2, VAR_3)\n" ]
[ "\"\"\"Internal bot API handlers.\"\"\"\n", "import base64\n", "import json\n", "import logging\n", "import textwrap\n", "import webob\n", "import webapp2\n", "from google.appengine.api import app_identity\n", "from google.appengine.api import datastore_errors\n", "from google.appengine.datastore import datastore_query\n", "from google.appengine import runtime\n", "from google.appengine.ext import ndb\n", "from components import auth\n", "from components import ereporter2\n", "from components import utils\n", "from server import acl\n", "from server import bot_code\n", "from server import bot_management\n", "from server import stats\n", "from server import task_pack\n", "from server import task_request\n", "from server import task_result\n", "from server import task_scheduler\n", "from server import task_to_run\n", "def has_unexpected_subset_keys(expected_keys, minimum_keys, actual_keys, name):...\n", "\"\"\"docstring\"\"\"\n", "actual_keys = frozenset(actual_keys)\n", "superfluous = actual_keys - expected_keys\n", "missing = minimum_keys - actual_keys\n", "if superfluous or missing:\n", "msg_missing = ' missing: %s' % sorted(missing) if missing else ''\n", "def has_unexpected_keys(expected_keys, actual_keys, name):...\n", "msg_superfluous = ' superfluous: %s' % sorted(superfluous\n ) if superfluous else ''\n", "\"\"\"docstring\"\"\"\n", "return 'Unexpected %s%s%s; did you make a typo?' % (name, msg_missing,\n msg_superfluous)\n", "return has_unexpected_subset_keys(expected_keys, expected_keys, actual_keys,\n name)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "FunctionDef'", "Assign'", "Docstring", "Return'", "Return'" ]
[ "def FUNC_2(self, VAR_5, VAR_6):...\n", "\"\"\"docstring\"\"\"\n", "VAR_7 = 'ALTER TABLE ' + VAR_2 + ' ADD COLUMN ' + str(VAR_5) + ' ' + VAR_0(\n VAR_6)\n", "self._run_command(VAR_7)\n", "print('Column ' + str(VAR_5) + ' already exists!')\n" ]
[ "def _addColumn(self, column, init_data):...\n", "\"\"\"docstring\"\"\"\n", "command = 'ALTER TABLE ' + TABLE_NAME + ' ADD COLUMN ' + str(column\n ) + ' ' + getSQLiteType(init_data)\n", "self._run_command(command)\n", "print('Column ' + str(column) + ' already exists!')\n" ]
[ 0, 0, 4, 4, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_5():...\n", "" ]
[ "def genSSCI():...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_8(VAR_25, VAR_24):...\n", "for VAR_27 in VAR_24:\n", "if VAR_27['submittable'] and VAR_27['confirm_the_level'] and VAR_27['passed']:\n", "if 'unconfirmed' in VAR_25:\n", "FUNC_8(VAR_27, VAR_27.get('children', []))\n", "for child in VAR_25.get('children', []):\n", "if 'unconfirmed' in child:\n" ]
[ "def r_check(parent, children):...\n", "for entry in children:\n", "if entry['submittable'] and entry['confirm_the_level'] and entry['passed']:\n", "if 'unconfirmed' in parent:\n", "r_check(entry, entry.get('children', []))\n", "for child in parent.get('children', []):\n", "if 'unconfirmed' in child:\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Condition", "Condition", "Expr'", "For", "Condition" ]
[ "def FUNC_37(VAR_47, VAR_56):...\n", "return os.path.relpath(VAR_47, VAR_56).startswith(os.pardir)\n" ]
[ "def is_outside(path, putative_parent):...\n", "return os.path.relpath(path, putative_parent).startswith(os.pardir)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@property...\n", "return [CLASS_3(self, obj) for obj in self.object_list]\n" ]
[ "@property...\n", "return [SmartListItem(self, obj) for obj in self.object_list]\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_18(self, VAR_14):...\n", "" ]
[ "def is_relation_many_to_one(self, col_name):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_1(VAR_1):...\n", "VAR_3 = [_('Employee') + ':Link/Employee:150', _('Employee Name') + '::200',\n _('Department') + '::150']\n", "for leave_type in VAR_1:\n", "VAR_3.append(_(leave_type) + ' ' + _('Opening') + ':Float:160')\n", "return VAR_3\n", "VAR_3.append(_(leave_type) + ' ' + _('Taken') + ':Float:160')\n", "VAR_3.append(_(leave_type) + ' ' + _('Balance') + ':Float:160')\n" ]
[ "def get_columns(leave_types):...\n", "columns = [_('Employee') + ':Link/Employee:150', _('Employee Name') +\n '::200', _('Department') + '::150']\n", "for leave_type in leave_types:\n", "columns.append(_(leave_type) + ' ' + _('Opening') + ':Float:160')\n", "return columns\n", "columns.append(_(leave_type) + ' ' + _('Taken') + ':Float:160')\n", "columns.append(_(leave_type) + ' ' + _('Balance') + ':Float:160')\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Expr'", "Return'", "Expr'", "Expr'" ]
[ "@VAR_0.route('/login', methods=['GET', 'POST'])...\n", "if request.method == 'POST':\n", "VAR_42 = request.form['username']\n", "return render_template('login.html')\n", "VAR_52 = request.form['password']\n", "VAR_28 = VAR_1.connection.cursor()\n", "VAR_29 = VAR_28.execute('SELECT * FROM Users WHERE username = %s', [VAR_42])\n", "if VAR_29 > 0:\n", "VAR_54 = VAR_28.fetchone()\n", "VAR_55 = 'Username not found'\n", "VAR_44 = VAR_54['password']\n", "return render_template('login.html', VAR_55=error)\n", "if sha256_crypt.verify(VAR_52, VAR_44):\n", "VAR_10['logged_in'] = True\n", "VAR_55 = 'Invalid login'\n", "VAR_10['username'] = VAR_42\n", "return render_template('login.html', VAR_55=error)\n", "flash('You are now logged in', 'success')\n", "return redirect(url_for('index'))\n" ]
[ "@app.route('/login', methods=['GET', 'POST'])...\n", "if request.method == 'POST':\n", "username = request.form['username']\n", "return render_template('login.html')\n", "password_candidate = request.form['password']\n", "cur = mysql.connection.cursor()\n", "result = cur.execute('SELECT * FROM Users WHERE username = %s', [username])\n", "if result > 0:\n", "data = cur.fetchone()\n", "error = 'Username not found'\n", "password = data['password']\n", "return render_template('login.html', error=error)\n", "if sha256_crypt.verify(password_candidate, password):\n", "session['logged_in'] = True\n", "error = 'Invalid login'\n", "session['username'] = username\n", "return render_template('login.html', error=error)\n", "flash('You are now logged in', 'success')\n", "return redirect(url_for('index'))\n" ]
[ 0, 0, 4, 0, 0, 0, 4, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Assign'", "Return'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Return'", "Expr'", "Return'" ]
[ "def FUNC_4(VAR_12):...\n", "VAR_19 = os.path.join(os.getcwd(), VAR_5.registry.settings[VAR_12])\n", "if not os.path.isdir(VAR_19):\n", "VAR_0.error(f'Unable to add_static_view {VAR_12}:{VAR_19}')\n", "return VAR_19\n" ]
[ "def settings_path(key):...\n", "path = os.path.join(os.getcwd(), config.registry.settings[key])\n", "if not os.path.isdir(path):\n", "log.error(f'Unable to add_static_view {key}:{path}')\n", "return path\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Expr'", "Return'" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "if VAR_4 in [TaskStatus.READY, TaskStatus.LOCKED_FOR_VALIDATION, TaskStatus\n", "return\n", "VAR_6 = ProjectService.get_project_by_id(VAR_1)\n", "VAR_7 = UserService.get_user_by_id(VAR_2)\n", "CLASS_0._update_tasks_stats(VAR_6, VAR_7, VAR_3, VAR_4, VAR_5)\n", "UserService.upsert_mapped_projects(VAR_2, VAR_1)\n", "VAR_6.last_updated = timestamp()\n", "return VAR_6, VAR_7\n" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "if new_state in [TaskStatus.READY, TaskStatus.LOCKED_FOR_VALIDATION,\n", "return\n", "project = ProjectService.get_project_by_id(project_id)\n", "user = UserService.get_user_by_id(user_id)\n", "StatsService._update_tasks_stats(project, user, last_state, new_state, action)\n", "UserService.upsert_mapped_projects(user_id, project_id)\n", "project.last_updated = timestamp()\n", "return project, user\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Return'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_0(self, VAR_9):...\n", "self.formUrl = VAR_9\n", "VAR_18 = urlparse(self.formUrl)\n", "self.schema = VAR_18.scheme\n", "self.host = VAR_18.netloc\n", "self.httpRequests = 0\n", "VAR_34 = self.session.get(self.formUrl, headers={'Accept-Encoding': None})\n", "self.logger.critical('%s : Host unreachable (%s)', getHost(VAR_9), e)\n", "VAR_21 = FUNC_7(VAR_34.text)\n", "self.httpRequests += 1\n", "exit()\n", "if len(VAR_21) == 0:\n", "if self.logger.verbosity > 1:\n", "self.logger.critical('No HTML form found here')\n", "if len(VAR_21) > 1:\n", "printSimpleResponseObject(VAR_34)\n", "if self.logger.verbosity > 2:\n", "exit()\n", "self.logger.critical(\n '%s forms found containing file upload inputs, no way to choose which one to test.'\n , len(VAR_21))\n", "if len(VAR_21[0][1]) > 1:\n", "print('\\x1b[36m' + VAR_34.text + '\\x1b[m')\n", "if VAR_34.status_code < 200 or VAR_34.status_code > 300:\n", "exit()\n", "self.logger.critical(\n '%s file inputs found inside the same form, no way to choose which one to test.'\n , len(VAR_21[0]))\n", "self.inputName = VAR_21[0][1][0]['name']\n", "self.logger.critical('Server responded with following status : %s - %s',\n VAR_34.status_code, VAR_34.reason)\n", "exit()\n", "self.logger.debug('Found the following file upload input : %s', self.inputName)\n", "exit()\n", "VAR_22 = VAR_21[0][0]\n", "self.action = VAR_22['action']\n", "self.action = ''\n", "self.uploadUrl = urljoin(self.formUrl, self.action)\n", "self.logger.debug('Using following URL for file upload : %s', self.uploadUrl)\n", "if not self.uploadsFolder and not self.trueRegex:\n", "self.logger.warning(\n 'No uploads folder nor true regex defined, code execution detection will not be possible.'\n )\n", "if not self.uploadsFolder and self.trueRegex:\n", "print(\n 'No uploads path provided, code detection can still be done using true regex capturing group.'\n )\n", "VAR_40 = input(\n 'Do you want to use the True Regex for code execution detection ? [Y/n] ')\n", "if VAR_40.lower().startswith('y') or VAR_40 == '':\n", "VAR_43 = input('Preffix capturing group of the true regex with : ')\n", "self.logger.warning(\n 'Code execution detection will not be possible as there is no path nor regex pattern configured.'\n )\n", "VAR_44 = input('Suffix capturing group of the true regex with : ')\n", "self.codeExecUrlPattern = VAR_43 + '$captGroup$' + VAR_44\n" ]
[ "def setup(self, initUrl):...\n", "self.formUrl = initUrl\n", "url = urlparse(self.formUrl)\n", "self.schema = url.scheme\n", "self.host = url.netloc\n", "self.httpRequests = 0\n", "initGet = self.session.get(self.formUrl, headers={'Accept-Encoding': None})\n", "self.logger.critical('%s : Host unreachable (%s)', getHost(initUrl), e)\n", "detectedForms = detectForms(initGet.text)\n", "self.httpRequests += 1\n", "exit()\n", "if len(detectedForms) == 0:\n", "if self.logger.verbosity > 1:\n", "self.logger.critical('No HTML form found here')\n", "if len(detectedForms) > 1:\n", "printSimpleResponseObject(initGet)\n", "if self.logger.verbosity > 2:\n", "exit()\n", "self.logger.critical(\n '%s forms found containing file upload inputs, no way to choose which one to test.'\n , len(detectedForms))\n", "if len(detectedForms[0][1]) > 1:\n", "print('\\x1b[36m' + initGet.text + '\\x1b[m')\n", "if initGet.status_code < 200 or initGet.status_code > 300:\n", "exit()\n", "self.logger.critical(\n '%s file inputs found inside the same form, no way to choose which one to test.'\n , len(detectedForms[0]))\n", "self.inputName = detectedForms[0][1][0]['name']\n", "self.logger.critical('Server responded with following status : %s - %s',\n initGet.status_code, initGet.reason)\n", "exit()\n", "self.logger.debug('Found the following file upload input : %s', self.inputName)\n", "exit()\n", "formDestination = detectedForms[0][0]\n", "self.action = formDestination['action']\n", "self.action = ''\n", "self.uploadUrl = urljoin(self.formUrl, self.action)\n", "self.logger.debug('Using following URL for file upload : %s', self.uploadUrl)\n", "if not self.uploadsFolder and not self.trueRegex:\n", "self.logger.warning(\n 'No uploads folder nor true regex defined, code execution detection will not be possible.'\n )\n", "if not self.uploadsFolder and self.trueRegex:\n", "print(\n 'No uploads path provided, code detection can still be done using true regex capturing group.'\n )\n", "cont = input(\n 'Do you want to use the True Regex for code execution detection ? [Y/n] ')\n", "if cont.lower().startswith('y') or cont == '':\n", "preffixPattern = input('Preffix capturing group of the true regex with : ')\n", "self.logger.warning(\n 'Code execution detection will not be possible as there is no path nor regex pattern configured.'\n )\n", "suffixPattern = input('Suffix capturing group of the true regex with : ')\n", "self.codeExecUrlPattern = preffixPattern + '$captGroup$' + suffixPattern\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "AugAssign'", "Expr'", "Condition", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Assign'" ]
[ "" ]
[ "" ]
[ 0 ]
[ "Condition" ]
[ "def FUNC_4(self, VAR_5='test', VAR_6=None):...\n", "\"\"\"docstring\"\"\"\n", "from invenio.modules.oauthclient.client import oauth\n", "oauth.remote_apps[VAR_5].handle_oauth2_response = MagicMock(return_value=\n data or {'access_token': 'test_access_token', 'scope': '', 'token_type':\n 'bearer'})\n" ]
[ "def mock_response(self, app='test', data=None):...\n", "\"\"\"docstring\"\"\"\n", "from invenio.modules.oauthclient.client import oauth\n", "oauth.remote_apps[app].handle_oauth2_response = MagicMock(return_value=data or\n {'access_token': 'test_access_token', 'scope': '', 'token_type': 'bearer'})\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "ImportFrom'", "Assign'" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "self.csv.size\n", "VAR_29 = False\n", "return VAR_29\n", "VAR_29 = self.csv.url\n", "VAR_29 = False\n" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "self.csv.size\n", "csv_url = False\n", "return csv_url\n", "csv_url = self.csv.url\n", "csv_url = False\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Expr'", "Assign'", "Return'", "Assign'", "Assign'" ]
[ "from datetime import datetime\n", "import io\n", "from twisted.web.test.test_web import DummyRequest\n", "from pixelated.adapter.model.mail import InputMail\n", "VAR_0 = ['\\\\Seen', '\\\\Answered', '\\\\Flagged', '\\\\Deleted', '\\\\Draft',\n '\\\\Recent', 'List']\n", "VAR_1 = {'date': str(datetime.now())}\n", "def FUNC_0():...\n", "return {'header': {'to': ['[email protected]', '[email protected]'],\n 'cc': ['[email protected]', '[email protected]'], 'bcc': [\n '[email protected]', '[email protected]'], 'subject': 'Subject'},\n 'body': 'Body', 'ident': '', 'tags': []}\n" ]
[ "from datetime import datetime\n", "import io\n", "from twisted.web.test.test_web import DummyRequest\n", "from pixelated.adapter.model.mail import InputMail\n", "LEAP_FLAGS = ['\\\\Seen', '\\\\Answered', '\\\\Flagged', '\\\\Deleted', '\\\\Draft',\n '\\\\Recent', 'List']\n", "DEFAULT_HEADERS = {'date': str(datetime.now())}\n", "def mail_dict():...\n", "return {'header': {'to': ['[email protected]', '[email protected]'],\n 'cc': ['[email protected]', '[email protected]'], 'bcc': [\n '[email protected]', '[email protected]'], 'subject': 'Subject'},\n 'body': 'Body', 'ident': '', 'tags': []}\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "FunctionDef'", "Return'" ]
[ "def FUNC_11(self, VAR_5, VAR_8):...\n", "VAR_14 = 'string' % (VAR_5, VAR_8)\n", "VAR_11 = sql.queryDB(self.conn, VAR_14)\n", "return VAR_11\n" ]
[ "def getUsersByName(self, userid, username):...\n", "sqlText = (\n \"select userid,name,country,(select Count(*) from friends where users.userid=friends.friendid and friends.userid=%d) as follow from users where users.name='%s';\"\n % (userid, username))\n", "result = sql.queryDB(self.conn, sqlText)\n", "return result\n" ]
[ 0, 4, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "@click.command(help='Delete a monitor')...\n", "if not VAR_14:\n", "VAR_14 = click.prompt('string'.format(VAR_12=monitor), prompt_suffix='> ')\n", "if VAR_14.strip() != VAR_12:\n", "print('abort')\n", "newrelic.delete_monitor(VAR_0.obj['ACCOUNT'], VAR_12)\n", "sys.exit(1)\n", "print(click.style(u'OK', fg='green', bold=True))\n" ]
[ "@click.command(help='Delete a monitor')...\n", "if not confirm:\n", "confirm = click.prompt(\n \"\"\"\n ! WARNING: Destructive Action\n ! This command will destroy the monitor: {monitor}\n ! To proceed, type \"{monitor}\" or\n re-run this command with --confirm={monitor}\n\n\"\"\"\n .format(monitor=monitor), prompt_suffix='> ')\n", "if confirm.strip() != monitor:\n", "print('abort')\n", "newrelic.delete_monitor(ctx.obj['ACCOUNT'], monitor)\n", "sys.exit(1)\n", "print(click.style(u'OK', fg='green', bold=True))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n" ]
[ 0, 0 ]
[ "Condition", "Docstring" ]
[ "def FUNC_13(self):...\n", "VAR_11 = {}\n", "for VAR_12 in self.parent_groups:\n", "VAR_11[VAR_12.name] = VAR_12\n", "return VAR_11\n", "VAR_11.update(VAR_12._get_ancestors())\n" ]
[ "def _get_ancestors(self):...\n", "results = {}\n", "for g in self.parent_groups:\n", "results[g.name] = g\n", "return results\n", "results.update(g._get_ancestors())\n" ]
[ 0, 1, 0, 1, 1, 1 ]
[ "FunctionDef'", "Assign'", "For", "Assign'", "Return'", "Expr'" ]
[ "def FUNC_40(VAR_87):...\n", "return filterfalse(self.is_rule, VAR_87)\n" ]
[ "def files(items):...\n", "return filterfalse(self.is_rule, items)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "\"\"\"string\"\"\"\n", "import random\n", "import hashlib\n", "from urlparse import urlparse\n", "from decorator import decorator\n", "from pylons import session, request, config\n", "from pylons.controllers.util import abort\n", "from pylons.i18n import _\n", "def FUNC_0(VAR_0=['POST', 'GET', 'PUT', 'DELETE']):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_5(VAR_1, *VAR_2, **VAR_3):...\n", "def FUNC_6():...\n", "if not request.method in VAR_0:\n", "return True\n", "if not request.environ.get('AUTH_TYPE') == 'cookie':\n", "return True\n", "if config.get('skip_authentication'):\n", "return True\n", "if request.environ.get('HTTP_REFERER'):\n", "VAR_7 = urlparse(request.environ.get('HTTP_REFERER'))\n", "if request.method == 'GET' and FUNC_4():\n", "VAR_8 = VAR_7.hostname\n", "return True\n", "return False\n", "if VAR_7.port:\n", "VAR_8 += ':' + str(VAR_7.port)\n", "if VAR_8.endswith(request.environ['adhocracy.domain']):\n", "if request.method != 'GET':\n", "return True\n" ]
[ "\"\"\"\nXSRF is Cross-Site Request Forgery, where an attacker has a user follow a link that triggers an \naction on a site which the user did not intentionally want to perform (i.e. vote in \na certain way). To prevent this, some actions are only possible if authorized via HTTP or if a\nmodtoken - a shared SHA1 hash - is included. \n\"\"\"\n", "import random\n", "import hashlib\n", "from urlparse import urlparse\n", "from decorator import decorator\n", "from pylons import session, request, config\n", "from pylons.controllers.util import abort\n", "from pylons.i18n import _\n", "def RequireInternalRequest(methods=['POST', 'GET', 'PUT', 'DELETE']):...\n", "\"\"\"docstring\"\"\"\n", "def _decorate(f, *a, **kw):...\n", "def check():...\n", "if not request.method in methods:\n", "return True\n", "if not request.environ.get('AUTH_TYPE') == 'cookie':\n", "return True\n", "if config.get('skip_authentication'):\n", "return True\n", "if request.environ.get('HTTP_REFERER'):\n", "ref_url = urlparse(request.environ.get('HTTP_REFERER'))\n", "if request.method == 'GET' and has_token():\n", "ref_host = ref_url.hostname\n", "return True\n", "return False\n", "if ref_url.port:\n", "ref_host += ':' + str(ref_url.port)\n", "if ref_host.endswith(request.environ['adhocracy.domain']):\n", "if request.method != 'GET':\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 5, 0 ]
[ "Expr'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Docstring", "FunctionDef'", "FunctionDef'", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Return'", "Return'", "Condition", "AugAssign'", "Condition", "Condition", "Return'" ]
[ "from __future__ import unicode_literals\n", "import json\n", "from django.test import TestCase\n", "def FUNC_0(self):...\n", "VAR_1, VAR_2 = 'firstuser', 'password'\n", "VAR_3 = '[email protected]'\n", "VAR_4 = {'username': VAR_1, 'password': VAR_2, 'email': VAR_3}\n", "VAR_5 = '/api/auth/register'\n", "VAR_6 = self.client.post(VAR_5, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "self.assertTrue(VAR_6.data['is_superuser'])\n", "VAR_1, VAR_2 = 'seconduser', 'password'\n", "VAR_3 = '[email protected]'\n", "VAR_4 = {'username': VAR_1, 'password': VAR_2, 'email': VAR_3}\n", "VAR_5 = '/api/auth/register'\n", "VAR_6 = self.client.post(VAR_5, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "self.assertFalse(VAR_6.data['is_superuser'])\n", "def FUNC_1(self):...\n", "VAR_4 = {'username': 'firstuser', 'password': 'password', 'email':\n '[email protected]'}\n", "VAR_5 = '/api/auth/register'\n", "VAR_6 = self.client.post(VAR_5, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "self.assertTrue(VAR_6.data['is_superuser'])\n", "self.assertTrue(self.client.login(VAR_1='firstuser', VAR_2='password'))\n", "VAR_6 = self.client.get('/api/admin/perms', content_type='application/json')\n", "self.assertEqual(VAR_6.status_code, 200)\n", "self.assertEqual(len(VAR_6.data['results']), 1)\n", "self.assertEqual(VAR_6.data['results'][0]['username'], 'firstuser')\n", "self.assertTrue(VAR_6.data['results'][0]['is_superuser'])\n", "VAR_4 = {'username': 'seconduser', 'password': 'password', 'email':\n '[email protected]'}\n", "VAR_5 = '/api/auth/register'\n", "VAR_6 = self.client.post(VAR_5, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "self.assertFalse(VAR_6.data['is_superuser'])\n", "self.assertTrue(self.client.login(VAR_1='seconduser', VAR_2='password'))\n", "VAR_6 = self.client.get('/api/admin/perms', content_type='application/json')\n", "self.assertEqual(VAR_6.status_code, 403)\n", "self.assertIn('You do not have permission', VAR_6.data['detail'])\n", "def FUNC_2(self):...\n", "VAR_4 = {'username': 'first', 'password': 'password', 'email':\n '[email protected]'}\n", "VAR_5 = '/api/auth/register'\n", "VAR_6 = self.client.post(VAR_5, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "self.assertTrue(VAR_6.data['is_superuser'])\n", "VAR_4 = {'username': 'second', 'password': 'password', 'email':\n '[email protected]'}\n", "VAR_5 = '/api/auth/register'\n", "VAR_6 = self.client.post(VAR_5, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "self.assertFalse(VAR_6.data['is_superuser'])\n", "self.assertTrue(self.client.login(VAR_1='first', VAR_2='password'))\n", "VAR_5 = '/api/admin/perms'\n", "VAR_7 = {'username': 'second'}\n", "VAR_6 = self.client.post(VAR_5, json.dumps(VAR_7), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "VAR_6 = self.client.get(VAR_5)\n", "self.assertEqual(VAR_6.status_code, 200)\n", "self.assertEqual(len(VAR_6.data['results']), 2)\n", "self.assertIn('second', str(VAR_6.data['results']))\n", "def FUNC_3(self):...\n", "VAR_4 = {'username': 'first', 'password': 'password', 'email':\n '[email protected]'}\n", "VAR_5 = '/api/auth/register'\n", "VAR_6 = self.client.post(VAR_5, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "self.assertTrue(VAR_6.data['is_superuser'])\n", "VAR_4 = {'username': 'second', 'password': 'password', 'email':\n '[email protected]'}\n", "VAR_5 = '/api/auth/register'\n", "VAR_6 = self.client.post(VAR_5, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "self.assertFalse(VAR_6.data['is_superuser'])\n", "self.assertTrue(self.client.login(VAR_1='first', VAR_2='password'))\n", "VAR_5 = '/api/admin/perms'\n", "VAR_7 = {'username': 'second'}\n", "VAR_6 = self.client.post(VAR_5, json.dumps(VAR_7), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "VAR_6 = self.client.delete(VAR_5 + '/second')\n", "self.assertEqual(VAR_6.status_code, 204)\n", "VAR_6 = self.client.get(VAR_5)\n", "self.assertEqual(VAR_6.status_code, 200)\n", "self.assertEqual(len(VAR_6.data['results']), 1)\n", "self.assertNotIn('two', str(VAR_6.data['results']))\n", "VAR_0 = ['test_sharing.json']\n", "def FUNC_4(self):...\n", "self.assertTrue(self.client.login(VAR_1='autotest-1', VAR_2='password'))\n", "def FUNC_2(self):...\n", "VAR_6 = self.client.get('/api/apps')\n", "self.assertEqual(VAR_6.status_code, 200)\n", "self.assertEqual(len(VAR_6.data['results']), 2)\n", "VAR_8 = VAR_6.data['results'][0]['id']\n", "self.assertTrue(self.client.login(VAR_1='autotest-2', VAR_2='password'))\n", "VAR_6 = self.client.get('/api/apps')\n", "self.assertEqual(len(VAR_6.data['results']), 1)\n", "for model in ['builds', 'config', 'containers', 'limits', 'releases']:\n", "VAR_6 = self.client.get('/api/apps/{}/{}/'.format(VAR_8, model))\n", "self.assertTrue(self.client.login(VAR_1='autotest-1', VAR_2='password'))\n", "self.assertEqual(VAR_6.data['detail'], 'Not found')\n", "VAR_5 = '/api/apps/{}/perms'.format(VAR_8)\n", "VAR_7 = {'username': 'autotest-2'}\n", "VAR_6 = self.client.post(VAR_5, json.dumps(VAR_7), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "self.assertTrue(self.client.login(VAR_1='autotest-2', VAR_2='password'))\n", "VAR_6 = self.client.get('/api/apps')\n", "self.assertEqual(VAR_6.status_code, 200)\n", "self.assertEqual(len(VAR_6.data['results']), 2)\n", "for model in ['builds', 'containers', 'releases']:\n", "VAR_6 = self.client.get('/api/apps/{}/{}/'.format(VAR_8, model))\n", "def FUNC_5(self):...\n", "self.assertEqual(len(VAR_6.data['results']), 0)\n", "VAR_6 = self.client.get('/api/apps')\n", "VAR_8 = VAR_6.data['results'][0]['id']\n", "self.assertTrue(self.client.login(VAR_1='autotest-2', VAR_2='password'))\n", "VAR_5 = '/api/apps/{}/perms'.format(VAR_8)\n", "VAR_7 = {'username': 'autotest-2'}\n", "VAR_6 = self.client.post(VAR_5, json.dumps(VAR_7), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 403)\n", "def FUNC_3(self):...\n", "self.assertTrue(self.client.login(VAR_1='autotest-1', VAR_2='password'))\n", "VAR_6 = self.client.get('/api/apps')\n", "VAR_8 = VAR_6.data['results'][0]['id']\n", "VAR_5 = '/api/apps/{}/perms'.format(VAR_8)\n", "VAR_7 = {'username': 'autotest-2'}\n", "VAR_6 = self.client.post(VAR_5, json.dumps(VAR_7), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "self.assertTrue(self.client.login(VAR_1='autotest-2', VAR_2='password'))\n", "VAR_6 = self.client.get('/api/apps')\n", "self.assertEqual(VAR_6.status_code, 200)\n", "self.assertEqual(len(VAR_6.data['results']), 2)\n", "VAR_5 = '/api/apps/{}/perms/{}'.format(VAR_8, 'autotest-2')\n", "VAR_6 = self.client.delete(VAR_5, content_type='application/json')\n", "self.assertEqual(VAR_6.status_code, 403)\n", "self.assertIsNone(VAR_6.data)\n", "self.assertTrue(self.client.login(VAR_1='autotest-1', VAR_2='password'))\n", "VAR_6 = self.client.delete(VAR_5, content_type='application/json')\n", "self.assertEqual(VAR_6.status_code, 204)\n", "self.assertIsNone(VAR_6.data)\n", "self.assertTrue(self.client.login(VAR_1='autotest-2', VAR_2='password'))\n", "VAR_6 = self.client.get('/api/apps')\n", "self.assertEqual(len(VAR_6.data['results']), 1)\n", "self.assertTrue(self.client.login(VAR_1='autotest-1', VAR_2='password'))\n", "VAR_6 = self.client.delete(VAR_5, content_type='application/json')\n", "self.assertEqual(VAR_6.status_code, 404)\n", "def FUNC_1(self):...\n", "VAR_6 = self.client.get('/api/apps')\n", "self.assertEqual(VAR_6.status_code, 200)\n", "self.assertEqual(len(VAR_6.data['results']), 2)\n", "VAR_8 = VAR_6.data['results'][0]['id']\n", "VAR_5 = '/api/apps/{}/perms'.format(VAR_8)\n", "VAR_7 = {'username': 'autotest-2'}\n", "VAR_6 = self.client.post(VAR_5, json.dumps(VAR_7), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "VAR_6 = self.client.get('/api/apps/{}/perms'.format(VAR_8), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.data, {'users': ['autotest-2']})\n", "def FUNC_6(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = self.client.get('/api/apps')\n", "self.assertEqual(VAR_6.status_code, 200)\n", "self.assertEqual(len(VAR_6.data['results']), 2)\n", "def FUNC_7(self):...\n", "VAR_6 = self.client.get('/api/apps')\n", "VAR_8 = VAR_6.data['results'][0]['id']\n", "self.assertTrue(self.client.login(VAR_1='autotest-2', VAR_2='password'))\n", "VAR_6 = self.client.get('/api/apps/{}/perms'.format(VAR_8), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 403)\n" ]
[ "from __future__ import unicode_literals\n", "import json\n", "from django.test import TestCase\n", "def test_first_signup(self):...\n", "username, password = 'firstuser', 'password'\n", "email = '[email protected]'\n", "submit = {'username': username, 'password': password, 'email': email}\n", "url = '/api/auth/register'\n", "response = self.client.post(url, json.dumps(submit), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "self.assertTrue(response.data['is_superuser'])\n", "username, password = 'seconduser', 'password'\n", "email = '[email protected]'\n", "submit = {'username': username, 'password': password, 'email': email}\n", "url = '/api/auth/register'\n", "response = self.client.post(url, json.dumps(submit), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "self.assertFalse(response.data['is_superuser'])\n", "def test_list(self):...\n", "submit = {'username': 'firstuser', 'password': 'password', 'email':\n '[email protected]'}\n", "url = '/api/auth/register'\n", "response = self.client.post(url, json.dumps(submit), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "self.assertTrue(response.data['is_superuser'])\n", "self.assertTrue(self.client.login(username='firstuser', password='password'))\n", "response = self.client.get('/api/admin/perms', content_type='application/json')\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 1)\n", "self.assertEqual(response.data['results'][0]['username'], 'firstuser')\n", "self.assertTrue(response.data['results'][0]['is_superuser'])\n", "submit = {'username': 'seconduser', 'password': 'password', 'email':\n '[email protected]'}\n", "url = '/api/auth/register'\n", "response = self.client.post(url, json.dumps(submit), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "self.assertFalse(response.data['is_superuser'])\n", "self.assertTrue(self.client.login(username='seconduser', password='password'))\n", "response = self.client.get('/api/admin/perms', content_type='application/json')\n", "self.assertEqual(response.status_code, 403)\n", "self.assertIn('You do not have permission', response.data['detail'])\n", "def test_create(self):...\n", "submit = {'username': 'first', 'password': 'password', 'email':\n '[email protected]'}\n", "url = '/api/auth/register'\n", "response = self.client.post(url, json.dumps(submit), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "self.assertTrue(response.data['is_superuser'])\n", "submit = {'username': 'second', 'password': 'password', 'email':\n '[email protected]'}\n", "url = '/api/auth/register'\n", "response = self.client.post(url, json.dumps(submit), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "self.assertFalse(response.data['is_superuser'])\n", "self.assertTrue(self.client.login(username='first', password='password'))\n", "url = '/api/admin/perms'\n", "body = {'username': 'second'}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 2)\n", "self.assertIn('second', str(response.data['results']))\n", "def test_delete(self):...\n", "submit = {'username': 'first', 'password': 'password', 'email':\n '[email protected]'}\n", "url = '/api/auth/register'\n", "response = self.client.post(url, json.dumps(submit), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "self.assertTrue(response.data['is_superuser'])\n", "submit = {'username': 'second', 'password': 'password', 'email':\n '[email protected]'}\n", "url = '/api/auth/register'\n", "response = self.client.post(url, json.dumps(submit), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "self.assertFalse(response.data['is_superuser'])\n", "self.assertTrue(self.client.login(username='first', password='password'))\n", "url = '/api/admin/perms'\n", "body = {'username': 'second'}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "response = self.client.delete(url + '/second')\n", "self.assertEqual(response.status_code, 204)\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 1)\n", "self.assertNotIn('two', str(response.data['results']))\n", "fixtures = ['test_sharing.json']\n", "def setUp(self):...\n", "self.assertTrue(self.client.login(username='autotest-1', password='password'))\n", "def test_create(self):...\n", "response = self.client.get('/api/apps')\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 2)\n", "app_id = response.data['results'][0]['id']\n", "self.assertTrue(self.client.login(username='autotest-2', password='password'))\n", "response = self.client.get('/api/apps')\n", "self.assertEqual(len(response.data['results']), 1)\n", "for model in ['builds', 'config', 'containers', 'limits', 'releases']:\n", "response = self.client.get('/api/apps/{}/{}/'.format(app_id, model))\n", "self.assertTrue(self.client.login(username='autotest-1', password='password'))\n", "self.assertEqual(response.data['detail'], 'Not found')\n", "url = '/api/apps/{}/perms'.format(app_id)\n", "body = {'username': 'autotest-2'}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "self.assertTrue(self.client.login(username='autotest-2', password='password'))\n", "response = self.client.get('/api/apps')\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 2)\n", "for model in ['builds', 'containers', 'releases']:\n", "response = self.client.get('/api/apps/{}/{}/'.format(app_id, model))\n", "def test_create_errors(self):...\n", "self.assertEqual(len(response.data['results']), 0)\n", "response = self.client.get('/api/apps')\n", "app_id = response.data['results'][0]['id']\n", "self.assertTrue(self.client.login(username='autotest-2', password='password'))\n", "url = '/api/apps/{}/perms'.format(app_id)\n", "body = {'username': 'autotest-2'}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 403)\n", "def test_delete(self):...\n", "self.assertTrue(self.client.login(username='autotest-1', password='password'))\n", "response = self.client.get('/api/apps')\n", "app_id = response.data['results'][0]['id']\n", "url = '/api/apps/{}/perms'.format(app_id)\n", "body = {'username': 'autotest-2'}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "self.assertTrue(self.client.login(username='autotest-2', password='password'))\n", "response = self.client.get('/api/apps')\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 2)\n", "url = '/api/apps/{}/perms/{}'.format(app_id, 'autotest-2')\n", "response = self.client.delete(url, content_type='application/json')\n", "self.assertEqual(response.status_code, 403)\n", "self.assertIsNone(response.data)\n", "self.assertTrue(self.client.login(username='autotest-1', password='password'))\n", "response = self.client.delete(url, content_type='application/json')\n", "self.assertEqual(response.status_code, 204)\n", "self.assertIsNone(response.data)\n", "self.assertTrue(self.client.login(username='autotest-2', password='password'))\n", "response = self.client.get('/api/apps')\n", "self.assertEqual(len(response.data['results']), 1)\n", "self.assertTrue(self.client.login(username='autotest-1', password='password'))\n", "response = self.client.delete(url, content_type='application/json')\n", "self.assertEqual(response.status_code, 404)\n", "def test_list(self):...\n", "response = self.client.get('/api/apps')\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 2)\n", "app_id = response.data['results'][0]['id']\n", "url = '/api/apps/{}/perms'.format(app_id)\n", "body = {'username': 'autotest-2'}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "response = self.client.get('/api/apps/{}/perms'.format(app_id),\n content_type='application/json')\n", "self.assertEqual(response.data, {'users': ['autotest-2']})\n", "def test_admin_can_list(self):...\n", "\"\"\"docstring\"\"\"\n", "response = self.client.get('/api/apps')\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 2)\n", "def test_list_errors(self):...\n", "response = self.client.get('/api/apps')\n", "app_id = response.data['results'][0]['id']\n", "self.assertTrue(self.client.login(username='autotest-2', password='password'))\n", "response = self.client.get('/api/apps/{}/perms'.format(app_id),\n content_type='application/json')\n", "self.assertEqual(response.status_code, 403)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 5, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5, 0, 5, 0, 0, 0, 5, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Import'", "ImportFrom'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "FunctionDef'", "Expr'", "FunctionDef'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "For", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "For", "Assign'", "FunctionDef'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "FunctionDef'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "FunctionDef'", "Docstring", "Assign'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_12(VAR_4):...\n", "VAR_0, VAR_10 = FUNC_0()\n", "VAR_18 = \"SELECT name from {} where token='{}'\".format(CFG(\n 'tokens_table_name'), VAR_4)\n", "VAR_20 = FUNC_3(VAR_10, VAR_18)\n", "if not VAR_20:\n", "VAR_18 = \"SELECT poll_name from {} where adm_token='{}'\".format(CFG(\n 'admintoken_table_name'), VAR_4)\n", "FUNC_1(VAR_0)\n", "VAR_20 = FUNC_3(VAR_10, VAR_18)\n", "return VAR_20\n" ]
[ "def pollNameFromToken(token):...\n", "conn, c = connectDB()\n", "req = \"SELECT name from {} where token='{}'\".format(CFG('tokens_table_name'\n ), token)\n", "answer = queryOne(c, req)\n", "if not answer:\n", "req = \"SELECT poll_name from {} where adm_token='{}'\".format(CFG(\n 'admintoken_table_name'), token)\n", "closeDB(conn)\n", "answer = queryOne(c, req)\n", "return answer\n" ]
[ 0, 0, 4, 0, 0, 4, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_0(VAR_0, VAR_1):...\n", "res: GroupReservation = GroupReservation.objects.get(id=rid)\n" ]
[ "def update_reservation_articles(postdict, rid):...\n", "res: GroupReservation = GroupReservation.objects.get(id=rid)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "AnnAssign'" ]
[ "@functools.wraps(VAR_0)...\n", "if not self.request.headers.get('X-XSRF-Token-Request'):\n", "return VAR_0(self, *VAR_5, **kwargs)\n" ]
[ "@functools.wraps(f)...\n", "if not self.request.headers.get('X-XSRF-Token-Request'):\n", "return f(self, *args, **kwargs)\n" ]
[ 0, 0, 0 ]
[ "Condition", "Condition", "Return'" ]
[ "def FUNC_2(VAR_6, VAR_7):...\n", "if os.getenv('VEIL_REMOTE_BROWSER'):\n", "VAR_7 = 'remote'\n", "get_executing_test().browser_type = VAR_7\n", "VAR_10 = get_executing_test()\n", "VAR_10.addCleanup(FUNC_7)\n", "if 'spynner' == VAR_7:\n", "FUNC_3(VAR_6)\n", "if 'chrome' == VAR_7:\n", "FUNC_4(VAR_6)\n", "if 'remote' == VAR_7:\n", "VAR_9 = 'http://{}:4444/wd/hub'.format(os.getenv('VEIL_REMOTE_BROWSER'))\n", "FUNC_5(VAR_6, VAR_9)\n" ]
[ "def start_browser(url, browser_type):...\n", "if os.getenv('VEIL_REMOTE_BROWSER'):\n", "browser_type = 'remote'\n", "get_executing_test().browser_type = browser_type\n", "test = get_executing_test()\n", "test.addCleanup(stop_browser)\n", "if 'spynner' == browser_type:\n", "start_spynner_browser(url)\n", "if 'chrome' == browser_type:\n", "start_chrome_browser(url)\n", "if 'remote' == browser_type:\n", "command_executor = 'http://{}:4444/wd/hub'.format(os.getenv(\n 'VEIL_REMOTE_BROWSER'))\n", "start_remote_browser(url, command_executor)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Assign'", "Expr'" ]
[ "def FUNC_29(self):...\n", "VAR_49 = re.split(self.dynamic_fill, self.file)[0]\n", "VAR_50 = os.path.dirname(VAR_49)\n", "if len(VAR_50) > 0 and not os.path.exists(VAR_50):\n", "os.makedirs(VAR_50)\n", "if e.errno != 17:\n" ]
[ "def prepare(self):...\n", "path_until_wildcard = re.split(self.dynamic_fill, self.file)[0]\n", "dir = os.path.dirname(path_until_wildcard)\n", "if len(dir) > 0 and not os.path.exists(dir):\n", "os.makedirs(dir)\n", "if e.errno != 17:\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Expr'", "Condition" ]
[ "def FUNC_2(self):...\n", "CLASS_3.ScenarioMaker().given_a_deep_link_domain('pachatary://app'\n ).given_a_dynamic_link('').when_call_profile_redirect('a_b.c'\n ).then_response_should_be_a_redirect_to('pachatary://app/profiles/a_b.c')\n" ]
[ "def test_when_there_is_no_dynamic_link_returns_deep_link(self):...\n", "RedirectProfileTestCase.ScenarioMaker().given_a_deep_link_domain(\n 'pachatary://app').given_a_dynamic_link('').when_call_profile_redirect(\n 'a_b.c').then_response_should_be_a_redirect_to(\n 'pachatary://app/profiles/a_b.c')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_0(self, VAR_4, VAR_5, VAR_6=True):...\n", "\"\"\"docstring\"\"\"\n", "VAR_14 = []\n", "for VAR_43, v in VAR_5.items():\n", "VAR_14.append(' %s=%s' % (VAR_43, v))\n", "VAR_15 = VAR_4 + ''.join(VAR_14)\n", "return self._run_ssh(VAR_15, VAR_6)\n" ]
[ "def _cliq_run(self, verb, cliq_args, check_exit_code=True):...\n", "\"\"\"docstring\"\"\"\n", "cliq_arg_strings = []\n", "for k, v in cliq_args.items():\n", "cliq_arg_strings.append(' %s=%s' % (k, v))\n", "cmd = verb + ''.join(cliq_arg_strings)\n", "return self._run_ssh(cmd, check_exit_code)\n" ]
[ 0, 0, 2, 0, 2, 2, 2 ]
[ "FunctionDef'", "Docstring", "Assign'", "For", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_0(VAR_0: bool):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = threading.current_thread()\n", "if isinstance(VAR_6, threads.CauldronThread):\n", "VAR_6.is_executing = VAR_0\n" ]
[ "def set_executing(on: bool):...\n", "\"\"\"docstring\"\"\"\n", "my_thread = threading.current_thread()\n", "if isinstance(my_thread, threads.CauldronThread):\n", "my_thread.is_executing = on\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'" ]
[ "def FUNC_39(VAR_101):...\n", "VAR_101.resources = VAR_76, VAR_52\n", "return VAR_101\n" ]
[ "def decorate(ruleinfo):...\n", "ruleinfo.resources = args, resources\n", "return ruleinfo\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_6(self):...\n", "VAR_1 = '/api/apps'\n", "VAR_2 = self.client.post(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 201)\n", "VAR_3 = VAR_2.data['id']\n", "VAR_1 = '/api/apps/{app_id}/builds'.format(**locals())\n", "VAR_4 = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 201)\n", "VAR_1 = '/api/apps/{app_id}/releases'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 2)\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 1)\n", "VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_4 = {'web': 20}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 204)\n", "chaos.CREATE_ERROR_RATE = 0.5\n", "chaos.START_ERROR_RATE = 0.5\n", "VAR_1 = '/api/apps/{app_id}/config'.format(**locals())\n", "VAR_4 = {'values': json.dumps({'NEW_URL1': 'http://localhost:8080/'})}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "self.assertEqual(VAR_2.status_code, 503)\n", "VAR_1 = '/api/apps/{app_id}/releases'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 2)\n", "VAR_1 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "self.assertEqual(len(VAR_2.data['results']), 20)\n", "VAR_5 = set([c['state'] for c in VAR_2.data['results']])\n", "self.assertEqual(VAR_5, set(['up']))\n" ]
[ "def test_config_chaos(self):...\n", "url = '/api/apps'\n", "response = self.client.post(url)\n", "self.assertEqual(response.status_code, 201)\n", "app_id = response.data['id']\n", "url = '/api/apps/{app_id}/builds'.format(**locals())\n", "body = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\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(len(response.data['results']), 2)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 1)\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'web': 20}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\n", "chaos.CREATE_ERROR_RATE = 0.5\n", "chaos.START_ERROR_RATE = 0.5\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, 503)\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(len(response.data['results']), 2)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 20)\n", "states = set([c['state'] for c in response.data['results']])\n", "self.assertEqual(states, set(['up']))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_8(self):...\n", "VAR_9 = fingerprint(VAR_0)\n", "self.assertEquals(VAR_9, '54:6d:da:1f:91:b5:2b:6f:a2:83:90:c4:f9:73:76:f5')\n" ]
[ "def test_rsa_key_fingerprint(self):...\n", "fp = fingerprint(RSA_PUBKEY)\n", "self.assertEquals(fp, '54:6d:da:1f:91:b5:2b:6f:a2:83:90:c4:f9:73:76:f5')\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_23(VAR_33, VAR_13, VAR_20, VAR_21, VAR_12):...\n", "if VAR_21 == wzrpc.status.success:\n", "self.log.debug('Auth records on router were cleared')\n", "self.log.warn('Status %s, passing', wzrpc.name_status(VAR_21))\n" ]
[ "def accept(that, reqid, seqnum, status, data):...\n", "if status == wzrpc.status.success:\n", "self.log.debug('Auth records on router were cleared')\n", "self.log.warn('Status %s, passing', wzrpc.name_status(status))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_4(VAR_6, VAR_7=3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = list(VAR_6)\n", "VAR_26 = lambda : [VAR_0 for VAR_0 in VAR_6 if not os.path.exists(VAR_0)]\n", "VAR_27 = VAR_26()\n", "if VAR_27:\n", "logger.info('Waiting at most {} seconds for missing files.'.format(VAR_7))\n", "for _ in range(VAR_7):\n", "if not VAR_26():\n", "return\n", "VAR_23.sleep(1)\n" ]
[ "def wait_for_files(files, latency_wait=3):...\n", "\"\"\"docstring\"\"\"\n", "files = list(files)\n", "get_missing = lambda : [f for f in files if not os.path.exists(f)]\n", "missing = get_missing()\n", "if missing:\n", "logger.info('Waiting at most {} seconds for missing files.'.format(\n latency_wait))\n", "for _ in range(latency_wait):\n", "if not get_missing():\n", "return\n", "time.sleep(1)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "For", "Condition", "Return'", "Expr'" ]
[ "def __init__(self, VAR_10, VAR_11):...\n", "unittest.TestCase.__init__(self, VAR_10)\n", "self.connection_string = VAR_11\n" ]
[ "def __init__(self, method_name, connection_string):...\n", "unittest.TestCase.__init__(self, method_name)\n", "self.connection_string = connection_string\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'" ]
[ "def __delitem__(self, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = self.url_to_path(VAR_3)\n", "os.remove(VAR_6)\n", "os.removedirs(os.path.dirname(VAR_6))\n" ]
[ "def __delitem__(self, url):...\n", "\"\"\"docstring\"\"\"\n", "path = self.url_to_path(url)\n", "os.remove(path)\n", "os.removedirs(os.path.dirname(path))\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Expr'" ]
[ "@wait_for(timeout=10.0)...\n", "@defer.inlineCallbacks...\n", "VAR_9 = yield VAR_2.client.mail_store.all_mails()\n", "for mail in VAR_9:\n", "yield VAR_2.client.mail_store.delete_mail(mail.ident)\n", "return FUNC_8()\n" ]
[ "@wait_for(timeout=10.0)...\n", "@defer.inlineCallbacks...\n", "mails = yield context.client.mail_store.all_mails()\n", "for mail in mails:\n", "yield context.client.mail_store.delete_mail(mail.ident)\n", "return _delete_all_mails()\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "For", "Condition", "Assign'", "For", "Expr'", "Return'" ]
[ "def FUNC_0(VAR_0):...\n", "\"\"\"docstring\"\"\"\n", "VAR_0 = str(VAR_0)\n", "pathlib.Path(VAR_0).mkdir(parents=True, exist_ok=True)\n" ]
[ "def create_directory_tree(path):...\n", "\"\"\"docstring\"\"\"\n", "path = str(path)\n", "pathlib.Path(path).mkdir(parents=True, exist_ok=True)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'" ]
[ "def __init__(self, VAR_7, VAR_57, VAR_58=True, **VAR_16):...\n", "self.nav = VAR_57\n", "self.remember = VAR_58\n", "VAR_7 = VAR_57.get_param, VAR_7\n", "CLASS_0.__init__(self, VAR_7, **kw)\n" ]
[ "def __init__(self, param, menu_cls, remember=True, **kw):...\n", "self.nav = menu_cls\n", "self.remember = remember\n", "param = menu_cls.get_param, param\n", "Validator.__init__(self, param, **kw)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def __init__(self, VAR_45, VAR_46, VAR_47, VAR_48, VAR_49, VAR_50, VAR_51,...\n", "self.st_mode = VAR_45\n", "self.st_ino = VAR_46\n", "self.st_dev = VAR_47\n", "self.st_nlink = VAR_48\n", "self.st_uid = VAR_49\n", "self.st_gid = VAR_50\n", "self.st_size = VAR_51\n", "self.st_atime = VAR_52\n", "self.st_mtime = VAR_53\n", "self.st_ctime = VAR_54\n" ]
[ "def __init__(self, st_mode, st_ino, st_dev, st_nlink, st_uid, st_gid,...\n", "self.st_mode = st_mode\n", "self.st_ino = st_ino\n", "self.st_dev = st_dev\n", "self.st_nlink = st_nlink\n", "self.st_uid = st_uid\n", "self.st_gid = st_gid\n", "self.st_size = st_size\n", "self.st_atime = st_atime\n", "self.st_mtime = st_mtime\n", "self.st_ctime = st_ctime\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_5(self):...\n", "VAR_1 = 'http://my.url.com'\n", "VAR_2 = 'True'\n", "url_helper.urllib2.urlopen(VAR_1, mox.IgnoreArg(), timeout=mox.IgnoreArg()\n ).AndReturn(StringIO.StringIO(VAR_2))\n", "self._mox.ReplayAll()\n", "self.assertEqual(url_helper.UrlOpen(VAR_1, method='POST'), VAR_2)\n", "self._mox.VerifyAll()\n" ]
[ "def testUrlOpenPOSTSuccess(self):...\n", "url = 'http://my.url.com'\n", "response = 'True'\n", "url_helper.urllib2.urlopen(url, mox.IgnoreArg(), timeout=mox.IgnoreArg()\n ).AndReturn(StringIO.StringIO(response))\n", "self._mox.ReplayAll()\n", "self.assertEqual(url_helper.UrlOpen(url, method='POST'), response)\n", "self._mox.VerifyAll()\n" ]
[ 0, 0, 0, 5, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_0(self):...\n", "return self._doc['rules'].keys()\n" ]
[ "def get_rule_names(self):...\n", "return self._doc['rules'].keys()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_4(VAR_3, VAR_7):...\n", "VAR_8 = VAR_3.cursor()\n", "VAR_10 = VAR_8.execute(VAR_7)\n", "VAR_3.commit()\n", "print('update data successfull')\n", "return VAR_10\n" ]
[ "def updateDB(conn, sql_update):...\n", "cur = conn.cursor()\n", "result = cur.execute(sql_update)\n", "conn.commit()\n", "print('update data successfull')\n", "return result\n" ]
[ 0, 0, 4, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_0(self, VAR_0='crimemap'):...\n", "return pymysql.connect(host='localhost', user=dbconfig.db_user, passwd=\n dbconfig.db_password, db=database)\n" ]
[ "def connect(self, database='crimemap'):...\n", "return pymysql.connect(host='localhost', user=dbconfig.db_user, passwd=\n dbconfig.db_password, db=database)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_3(VAR_0, VAR_1):...\n", "VAR_9 = get_object_or_404(Hunt, id=pk)\n", "if VAR_9.enable == True:\n", "VAR_9.setDisable()\n", "VAR_9.setEnable()\n", "VAR_9.stop()\n", "VAR_9.start()\n", "return redirect('twitter_hunter:index')\n" ]
[ "def hunt_switch_enable(request, pk):...\n", "hunt = get_object_or_404(Hunt, id=pk)\n", "if hunt.enable == True:\n", "hunt.setDisable()\n", "hunt.setEnable()\n", "hunt.stop()\n", "hunt.start()\n", "return redirect('twitter_hunter:index')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_9(self):...\n", "\"\"\"docstring\"\"\"\n", "self.check_image_exists()\n", "if not self.security_groups:\n", "self.security_groups[self.tenant_id] = self.verify(25, self.\n _create_security_group, 1, 'Security group can not be created.',\n 'security group creation', self.compute_client)\n", "VAR_5 = rand_name('ost1_test-server-smoke-file_inj-')\n", "VAR_6 = [self.security_groups[self.tenant_id].name]\n", "VAR_10 = {'/home/cirros/server.txt': self._load_file('server.txt')}\n", "VAR_7 = self.verify(300, self._create_server, 2,\n 'Creating instance using the new security group has failed.',\n 'instance creation', self.compute_client, VAR_5, VAR_6, VAR_10=data_file)\n", "VAR_8 = self.verify(20, self._create_floating_ip, 3,\n 'Floating IP can not be created.', 'floating IP creation')\n", "self.verify(20, self._assign_floating_ip_to_instance, 3,\n 'Floating IP can not be assigned.', 'floating IP assignment', self.\n compute_client, VAR_7, VAR_8)\n", "self.floating_ips.append(VAR_8)\n", "VAR_9 = VAR_8.ip\n", "self.verify(600, self._run_command_from_vm, 4,\n 'Can not find injected file on instance.',\n 'check if injected file exists', VAR_9, 30, (9, 60),\n '[ -f /home/cirros/server.txt ] && echo \"True\" || echo \"False\"')\n", "self.verify(20, self.compute_client.servers.remove_floating_ip, 5,\n 'Floating IP cannot be removed.', 'removing floating IP', VAR_7, VAR_8)\n", "self.verify(20, self.compute_client.floating_ips.delete, 5,\n 'Floating IP cannot be deleted.', 'floating IP deletion', VAR_8)\n", "if self.floating_ips:\n", "self.floating_ips.remove(VAR_8)\n", "self.verify(30, self._delete_server, 6, 'Server can not be deleted. ',\n 'server deletion', VAR_7)\n" ]
[ "def test_009_create_server_with_file(self):...\n", "\"\"\"docstring\"\"\"\n", "self.check_image_exists()\n", "if not self.security_groups:\n", "self.security_groups[self.tenant_id] = self.verify(25, self.\n _create_security_group, 1, 'Security group can not be created.',\n 'security group creation', self.compute_client)\n", "name = rand_name('ost1_test-server-smoke-file_inj-')\n", "security_groups = [self.security_groups[self.tenant_id].name]\n", "data_file = {'/home/cirros/server.txt': self._load_file('server.txt')}\n", "server = self.verify(300, self._create_server, 2,\n 'Creating instance using the new security group has failed.',\n 'instance creation', self.compute_client, name, security_groups,\n data_file=data_file)\n", "floating_ip = self.verify(20, self._create_floating_ip, 3,\n 'Floating IP can not be created.', 'floating IP creation')\n", "self.verify(20, self._assign_floating_ip_to_instance, 3,\n 'Floating IP can not be assigned.', 'floating IP assignment', self.\n compute_client, server, floating_ip)\n", "self.floating_ips.append(floating_ip)\n", "ip_address = floating_ip.ip\n", "self.verify(600, self._run_command_from_vm, 4,\n 'Can not find injected file on instance.',\n 'check if injected file exists', ip_address, 30, (9, 60),\n '[ -f /home/cirros/server.txt ] && echo \"True\" || echo \"False\"')\n", "self.verify(20, self.compute_client.servers.remove_floating_ip, 5,\n 'Floating IP cannot be removed.', 'removing floating IP', server,\n floating_ip)\n", "self.verify(20, self.compute_client.floating_ips.delete, 5,\n 'Floating IP cannot be deleted.', 'floating IP deletion', floating_ip)\n", "if self.floating_ips:\n", "self.floating_ips.remove(floating_ip)\n", "self.verify(30, self._delete_server, 6, 'Server can not be deleted. ',\n 'server deletion', server)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_6(self, VAR_10):...\n", "return '%s%s' % (self.configuration.iscsi_target_prefix, VAR_10['name'])\n" ]
[ "def _build_iscsi_target_name(self, volume):...\n", "return '%s%s' % (self.configuration.iscsi_target_prefix, volume['name'])\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_25(self, VAR_73):...\n", "def FUNC_39(VAR_101):...\n", "VAR_101.message = VAR_73\n", "return VAR_101\n" ]
[ "def message(self, message):...\n", "def decorate(ruleinfo):...\n", "ruleinfo.message = message\n", "return ruleinfo\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_15(VAR_16):...\n", "\"\"\"docstring\"\"\"\n", "if FUNC_12(VAR_16, 'temp'):\n", "return VAR_19(VAR_16, 'protected')\n" ]
[ "def protected(value):...\n", "\"\"\"docstring\"\"\"\n", "if is_flagged(value, 'temp'):\n", "return flag(value, 'protected')\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'" ]