lines
sequencelengths
1
444
raw_lines
sequencelengths
1
444
label
sequencelengths
1
444
type
sequencelengths
1
444
[ "def FUNC_0(VAR_2, VAR_3):...\n", "VAR_4 = {requests.codes.NOT_FOUND: {'202': exceptions.\n BackendResourceNotFound, 'default': exceptions.ResourceNotFound},\n requests.codes.PRECONDITION_FAILED: exceptions.StaleRevision, requests.\n codes.INTERNAL_SERVER_ERROR: {'99': exceptions.ClientCertificateNotTrusted}\n }\n", "if VAR_2 in VAR_4:\n", "if isinstance(VAR_4[VAR_2], dict):\n", "return exceptions.ManagerError\n", "if VAR_3 and str(VAR_3) in VAR_4[VAR_2]:\n", "return VAR_4[VAR_2]\n", "return VAR_4[VAR_2][str(VAR_3)]\n", "if 'default' in VAR_4[VAR_2]:\n", "return VAR_4[VAR_2]['default']\n" ]
[ "def http_error_to_exception(status_code, error_code):...\n", "errors = {requests.codes.NOT_FOUND: {'202': exceptions.\n BackendResourceNotFound, 'default': exceptions.ResourceNotFound},\n requests.codes.PRECONDITION_FAILED: exceptions.StaleRevision, requests.\n codes.INTERNAL_SERVER_ERROR: {'99': exceptions.ClientCertificateNotTrusted}\n }\n", "if status_code in errors:\n", "if isinstance(errors[status_code], dict):\n", "return exceptions.ManagerError\n", "if error_code and str(error_code) in errors[status_code]:\n", "return errors[status_code]\n", "return errors[status_code][str(error_code)]\n", "if 'default' in errors[status_code]:\n", "return errors[status_code]['default']\n" ]
[ 0, 5, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Condition", "Return'", "Condition", "Return'", "Return'", "Condition", "Return'" ]
[ "@staticmethod...\n", "def FUNC_13(VAR_9, VAR_7, VAR_11, VAR_10):...\n", "if VAR_11 == 'POST':\n", "return CLASS_0.session.post(FUNC_2(VAR_7), VAR_9=ToUtf8Json(data), headers=\n _HEADERS, VAR_10=timeout)\n", "if VAR_11 == 'GET':\n", "return CLASS_0.session.get(FUNC_2(VAR_7), headers=_HEADERS, VAR_10=timeout)\n", "@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", "if not FUNC_3():\n", "return VAR_1.submit(FUNC_14, VAR_9, VAR_7, VAR_11)\n", "return FUNC_13(VAR_9, VAR_7, VAR_11, VAR_10)\n" ]
[ "@staticmethod...\n", "def SendRequest(data, handler, method, timeout):...\n", "if method == 'POST':\n", "return BaseRequest.session.post(_BuildUri(handler), data=ToUtf8Json(data),\n headers=_HEADERS, timeout=timeout)\n", "if method == 'GET':\n", "return BaseRequest.session.get(_BuildUri(handler), headers=_HEADERS,\n timeout=timeout)\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", "if not _CheckServerIsHealthyWithCache():\n", "return _EXECUTOR.submit(DelayedSendRequest, data, handler, method)\n", "return SendRequest(data, handler, method, timeout)\n" ]
[ 0, 0, 0, 7, 0, 7, 0, 0, 7, 0, 0, 0, 0, 0 ]
[ "Condition", "FunctionDef'", "Condition", "Return'", "Condition", "Return'", "Condition", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "def FUNC_5(self, VAR_3):...\n", "if self.data:\n", "if VAR_3 != self.data[len(self.data) - 1]:\n", "self.data.append(VAR_3)\n", "self.data.append(VAR_3)\n", "if len(self.data) > self.size:\n", "self.data.pop(0)\n" ]
[ "def push(self, item):...\n", "if self.data:\n", "if item != self.data[len(self.data) - 1]:\n", "self.data.append(item)\n", "self.data.append(item)\n", "if len(self.data) > self.size:\n", "self.data.pop(0)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Expr'", "Expr'", "Condition", "Expr'" ]
[ "def FUNC_6(self, VAR_11):...\n", "if VAR_11 and is_banned_domain(VAR_11):\n", "VAR_101.errors.add(errors.BANNED_DOMAIN)\n" ]
[ "def run(self, url):...\n", "if url and is_banned_domain(url):\n", "c.errors.add(errors.BANNED_DOMAIN)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'" ]
[ "def FUNC_0(self):...\n", "\"\"\"docstring\"\"\"\n", "return database_utilities.execute_query('select * from admins')\n" ]
[ "def get(self):...\n", "\"\"\"docstring\"\"\"\n", "return database_utilities.execute_query('select * from admins')\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_4(self):...\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_4 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "self.assertEqual(len(VAR_5.data['results']), 0)\n", "VAR_4 = '/api/apps/{app_id}/builds'.format(**locals())\n", "VAR_8 = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "VAR_5 = self.client.post(VAR_4, json.dumps(VAR_8), content_type=\n 'application/json')\n", "self.assertEqual(VAR_5.status_code, 201)\n", "VAR_4 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_8 = {'web': 4, 'worker': 2}\n", "VAR_5 = self.client.post(VAR_4, json.dumps(VAR_8), content_type=\n 'application/json')\n", "self.assertEqual(VAR_5.status_code, 204)\n", "VAR_4 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "self.assertEqual(len(VAR_5.data['results']), 6)\n", "VAR_4 = '/api/apps/{app_id}'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "VAR_4 = '/api/apps/{app_id}/containers/web'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "self.assertEqual(len(VAR_5.data['results']), 4)\n", "VAR_9 = VAR_5.data['results'][0]['num']\n", "VAR_4 = '/api/apps/{app_id}/containers/web/{num}'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "self.assertEqual(VAR_5.data['num'], VAR_9)\n", "VAR_4 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_8 = {'web': 2, 'worker': 1}\n", "VAR_5 = self.client.post(VAR_4, json.dumps(VAR_8), content_type=\n 'application/json')\n", "self.assertEqual(VAR_5.status_code, 204)\n", "VAR_4 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "self.assertEqual(len(VAR_5.data['results']), 3)\n", "self.assertEqual(max(VAR_7['num'] for VAR_7 in VAR_5.data['results']), 2)\n", "VAR_4 = '/api/apps/{app_id}'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "VAR_4 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_8 = {'web': 0, 'worker': 0}\n", "VAR_5 = self.client.post(VAR_4, json.dumps(VAR_8), content_type=\n 'application/json')\n", "self.assertEqual(VAR_5.status_code, 204)\n", "VAR_4 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "self.assertEqual(len(VAR_5.data['results']), 0)\n", "VAR_4 = '/api/apps/{app_id}'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n" ]
[ "def test_container_api_heroku(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}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 0)\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}/scale'.format(**locals())\n", "body = {'web': 4, 'worker': 2}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\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']), 6)\n", "url = '/api/apps/{app_id}'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "url = '/api/apps/{app_id}/containers/web'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 4)\n", "num = response.data['results'][0]['num']\n", "url = '/api/apps/{app_id}/containers/web/{num}'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(response.data['num'], num)\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'web': 2, 'worker': 1}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\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']), 3)\n", "self.assertEqual(max(c['num'] for c in response.data['results']), 2)\n", "url = '/api/apps/{app_id}'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'web': 0, 'worker': 0}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\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']), 0)\n", "url = '/api/apps/{app_id}'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n" ]
[ 0, 0, 0, 0, 0, 0, 5, 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, 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'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "import os\n", "from columnize import columnize\n", "from twisted.internet import defer\n", "from opennode.oms.endpoint.ssh import cmd, completion, cmdline\n", "from opennode.oms.endpoint.ssh.terminal import InteractiveTerminal\n", "from opennode.oms.endpoint.ssh.tokenizer import CommandLineTokenizer, CommandLineSyntaxError\n", "from opennode.oms.zodb import db\n", "\"\"\"string\"\"\"\n", "def __init__(self):...\n", "super(CLASS_0, self).__init__()\n", "self.path = ['']\n", "@defer.inlineCallbacks...\n", "self.obj_path = yield db.transact(lambda : [db.ref(db.get_root()['oms_root'])]\n )()\n", "FUNC_10()\n", "self.tokenizer = CommandLineTokenizer()\n", "def FUNC_0(self, VAR_0):...\n", "VAR_0 = VAR_0.strip()\n", "VAR_16, VAR_10 = self.parse_line(VAR_0)\n", "self.terminal.write('Syntax error: %s\\n' % e.message)\n", "VAR_4 = defer.maybeDeferred(VAR_16, *VAR_10)\n", "self.print_prompt()\n", "@VAR_4...\n", "return\n", "self.print_prompt()\n", "@VAR_4...\n", "if not VAR_6.check(cmdline.ArgumentParsingError):\n", "VAR_6.raiseException()\n", "self.print_prompt()\n", "VAR_5 = defer.Deferred()\n", "VAR_4.addBoth(VAR_5.callback)\n", "return VAR_5\n" ]
[ "import os\n", "from columnize import columnize\n", "from twisted.internet import defer\n", "from opennode.oms.endpoint.ssh import cmd, completion, cmdline\n", "from opennode.oms.endpoint.ssh.terminal import InteractiveTerminal\n", "from opennode.oms.endpoint.ssh.tokenizer import CommandLineTokenizer, CommandLineSyntaxError\n", "from opennode.oms.zodb import db\n", "\"\"\"The OMS virtual console over SSH.\n\n Accepts lines of input and writes them back to its connection. If\n a line consisting solely of \"quit\" is received, the connection\n is dropped.\n\n \"\"\"\n", "def __init__(self):...\n", "super(OmsSshProtocol, self).__init__()\n", "self.path = ['']\n", "@defer.inlineCallbacks...\n", "self.obj_path = yield db.transact(lambda : [db.ref(db.get_root()['oms_root'])]\n )()\n", "_get_obj_path()\n", "self.tokenizer = CommandLineTokenizer()\n", "def lineReceived(self, line):...\n", "line = line.strip()\n", "command, cmd_args = self.parse_line(line)\n", "self.terminal.write('Syntax error: %s\\n' % e.message)\n", "deferred = defer.maybeDeferred(command, *cmd_args)\n", "self.print_prompt()\n", "@deferred...\n", "return\n", "self.print_prompt()\n", "@deferred...\n", "if not f.check(cmdline.ArgumentParsingError):\n", "f.raiseException()\n", "self.print_prompt()\n", "ret = defer.Deferred()\n", "deferred.addBoth(ret.callback)\n", "return ret\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Expr'", "FunctionDef'", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Condition", "Return'", "Expr'", "Condition", "Condition", "Expr'", "Expr'", "Assign'", "Expr'", "Return'" ]
[ "\"\"\"string\"\"\"\n", "from lxml import etree\n", "from cinder import exception\n", "from cinder.openstack.common import log as logging\n", "from cinder.volume.drivers.san.san import SanISCSIDriver\n", "VAR_0 = logging.getLogger(__name__)\n", "\"\"\"string\"\"\"\n", "VAR_1 = {}\n", "def __init__(self, *VAR_2, **VAR_3):...\n", "super(CLASS_0, self).__init__(*VAR_2, **kwargs)\n", "self.cluster_vip = None\n", "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" ]
[ "\"\"\"\nHP Lefthand SAN ISCSI Driver.\n\nThe driver communicates to the backend aka Cliq via SSH to perform all the\noperations on the SAN.\n\"\"\"\n", "from lxml import etree\n", "from cinder import exception\n", "from cinder.openstack.common import log as logging\n", "from cinder.volume.drivers.san.san import SanISCSIDriver\n", "LOG = logging.getLogger(__name__)\n", "\"\"\"Executes commands relating to HP/Lefthand SAN ISCSI volumes.\n\n We use the CLIQ interface, over SSH.\n\n Rough overview of CLIQ commands used:\n\n :createVolume: (creates the volume)\n\n :getVolumeInfo: (to discover the IQN etc)\n\n :getClusterInfo: (to discover the iSCSI target IP address)\n\n :assignVolumeChap: (exports it with CHAP security)\n\n The 'trick' here is that the HP SAN enforces security by default, so\n normally a volume mount would need both to configure the SAN in the volume\n layer and do the mount on the compute layer. Multi-layer operations are\n not catered for at the moment in the cinder architecture, so instead we\n share the volume using CHAP at volume creation time. Then the mount need\n only use those CHAP credentials, so can take place exclusively in the\n compute layer.\n \"\"\"\n", "device_stats = {}\n", "def __init__(self, *args, **kwargs):...\n", "super(HpSanISCSIDriver, self).__init__(*args, **kwargs)\n", "self.cluster_vip = None\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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, 2 ]
[ "Expr'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Expr'", "Assign'", "FunctionDef'", "Expr'", "Assign'", "FunctionDef'", "Docstring", "Assign'", "For", "Expr'", "Assign'", "Return'" ]
[ "def __init__(self, VAR_0=None, *VAR_2, **VAR_3):...\n", "super(CLASS_0, self).__init__(*VAR_2, **kwargs)\n" ]
[ "def __init__(self, name=None, *args, **kwargs):...\n", "super(PrimaryKeyField, self).__init__(*args, **kwargs)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_10(self, VAR_14):...\n", "" ]
[ "def is_text(self, col_name):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_1(VAR_0, VAR_3, VAR_1, VAR_2):...\n", "VAR_4 = VAR_0.cursor()\n", "VAR_5 = 'ALTER TABLE Presets DROP COLUMN id;'\n", "VAR_4.execute(VAR_5)\n", "VAR_5 = (\n 'ALTER TABLE Presets ADD COLUMN id INT AUTO_INCREMENT PRIMARY KEY NOT NULL FIRST;'\n )\n", "VAR_4.execute(VAR_5)\n", "if VAR_1 != 'NA':\n", "VAR_5 = \"UPDATE Presets SET querval='\" + VAR_1 + \"' WHERE id=\" + str(VAR_3\n ) + ';'\n", "if VAR_2 != 'NA':\n", "VAR_4.execute(VAR_5)\n", "VAR_5 = \"UPDATE Presets SET description='\" + VAR_2 + \"' WHERE id=\" + str(VAR_3\n ) + ';'\n", "VAR_5 = 'ALTER TABLE Presets DROP COLUMN id;'\n", "VAR_4.execute(VAR_5)\n", "VAR_4.execute(VAR_5)\n", "VAR_5 = (\n 'ALTER TABLE Presets ADD COLUMN id INT AUTO_INCREMENT PRIMARY KEY NOT NULL FIRST;'\n )\n", "VAR_4.execute(VAR_5)\n" ]
[ "def edit_preset(conn, key, queryin, descriptin):...\n", "cursor = conn.cursor()\n", "quer = 'ALTER TABLE Presets DROP COLUMN id;'\n", "cursor.execute(quer)\n", "quer = (\n 'ALTER TABLE Presets ADD COLUMN id INT AUTO_INCREMENT PRIMARY KEY NOT NULL FIRST;'\n )\n", "cursor.execute(quer)\n", "if queryin != 'NA':\n", "quer = \"UPDATE Presets SET querval='\" + queryin + \"' WHERE id=\" + str(key\n ) + ';'\n", "if descriptin != 'NA':\n", "cursor.execute(quer)\n", "quer = \"UPDATE Presets SET description='\" + descriptin + \"' WHERE id=\" + str(\n key) + ';'\n", "quer = 'ALTER TABLE Presets DROP COLUMN id;'\n", "cursor.execute(quer)\n", "cursor.execute(quer)\n", "quer = (\n 'ALTER TABLE Presets ADD COLUMN id INT AUTO_INCREMENT PRIMARY KEY NOT NULL FIRST;'\n )\n", "cursor.execute(quer)\n" ]
[ 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_9(self, VAR_9, VAR_12, VAR_8):...\n", "if VAR_9 is None:\n", "return VAR_9\n", "return [self.base_field.from_db_value(item, VAR_12, VAR_8) for item in VAR_9]\n" ]
[ "def _from_db_value(self, value, expression, connection):...\n", "if value is None:\n", "return value\n", "return [self.base_field.from_db_value(item, expression, connection) for\n item in value]\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "from datetime import timedelta\n", "from django.contrib.auth.models import User\n", "from django.core.urlresolvers import reverse\n", "from django.test import TestCase\n", "from django.test.client import Client\n", "from django.utils import timezone\n", "from course.models import Course, CourseInstance, CourseHook, CourseModule, LearningObjectCategory, StudentGroup\n", "from exercise.models import BaseExercise, Submission\n", "from exercise.exercise_models import LearningObject\n", "def FUNC_0(self):...\n", "self.client = Client()\n", "self.user = User(username='testUser')\n", "self.user.set_password('testPassword')\n", "self.user.save()\n", "self.grader = User(username='grader', is_staff=True)\n", "self.grader.set_password('graderPassword')\n", "self.grader.save()\n", "self.superuser = User(username='staff', is_staff=False, is_superuser=True)\n", "self.superuser.set_password('staffPassword')\n", "self.superuser.save()\n", "self.course = Course.objects.create(name='test course', code='123456',\n VAR_5='Course-Url')\n", "self.today = timezone.now()\n", "self.tomorrow = self.today + timedelta(days=1)\n", "self.two_days_from_now = self.tomorrow + timedelta(days=1)\n", "self.yesterday = self.today - timedelta(days=1)\n", "self.past_course_instance = CourseInstance.objects.create(instance_name=\n 'Fall 2011 day 0', starting_time=self.yesterday, ending_time=self.today,\n course=self.course, VAR_5='T-00.1000_d0')\n", "self.current_course_instance = CourseInstance.objects.create(instance_name=\n 'Fall 2011 day 1', starting_time=self.today, ending_time=self.tomorrow,\n course=self.course, VAR_5='T-00.1000_d1')\n", "self.future_course_instance = CourseInstance.objects.create(instance_name=\n 'Fall 2011 day 2', starting_time=self.tomorrow, ending_time=self.\n two_days_from_now, course=self.course, VAR_5='T-00.1000_d2')\n", "self.hidden_course_instance = CourseInstance.objects.create(instance_name=\n 'Secret super course', starting_time=self.tomorrow, ending_time=self.\n two_days_from_now, course=self.course, VAR_5='T-00.1000_hidden',\n visible_to_students=False)\n", "self.course_module = CourseModule.objects.create(name='test module', VAR_5=\n 'test-module', points_to_pass=10, course_instance=self.\n current_course_instance, opening_time=self.today, closing_time=self.\n tomorrow)\n", "self.course_module_with_late_submissions_allowed = CourseModule.objects.create(\n name='test module', VAR_5='test-module-late', points_to_pass=50,\n course_instance=self.current_course_instance, opening_time=self.today,\n closing_time=self.tomorrow, late_submissions_allowed=True,\n late_submission_deadline=self.two_days_from_now,\n late_submission_penalty=0.2)\n", "self.learning_object_category = LearningObjectCategory.objects.create(name=\n 'test category', course_instance=self.current_course_instance,\n points_to_pass=5)\n", "self.learning_object = LearningObject.objects.create(name=\n 'test learning object', course_module=self.course_module, category=self\n .learning_object_category, VAR_5='l1')\n", "self.broken_learning_object = LearningObject.objects.create(name=\n 'test learning object', course_module=self.\n course_module_with_late_submissions_allowed, category=self.\n learning_object_category, VAR_5='l2')\n", "self.base_exercise = BaseExercise.objects.create(name='test exercise',\n course_module=self.course_module, category=self.\n learning_object_category, service_url='http://localhost/', VAR_5='b1')\n", "self.submission = Submission.objects.create(exercise=self.base_exercise,\n grader=self.grader.userprofile)\n", "self.submission.submitters.add(self.user.userprofile)\n", "self.course_hook = CourseHook.objects.create(hook_url='test_hook_url',\n course_instance=self.current_course_instance)\n", "def FUNC_1(self):...\n", "self.assertFalse(self.past_course_instance.is_open())\n", "self.assertTrue(self.current_course_instance.is_open())\n", "self.assertFalse(self.future_course_instance.is_open())\n", "def FUNC_2(self):...\n", "self.assertEqual('/Course-Url/T-00.1000_d1/', self.current_course_instance.\n get_absolute_url())\n", "self.assertEqual('/Course-Url/T-00.1000_hidden/', self.\n hidden_course_instance.get_absolute_url())\n", "def FUNC_3(self):...\n", "self.assertFalse(self.course.is_teacher(self.user))\n", "self.assertFalse(self.current_course_instance.is_assistant(self.user))\n", "self.assertFalse(self.current_course_instance.is_teacher(self.user))\n", "self.assertFalse(self.current_course_instance.is_course_staff(self.user))\n", "self.assertEquals(0, len(self.current_course_instance.\n get_course_staff_profiles()))\n", "self.current_course_instance.assistants.add(self.user.userprofile)\n", "self.assertFalse(self.course.is_teacher(self.user))\n", "self.assertTrue(self.current_course_instance.is_assistant(self.user))\n", "self.assertFalse(self.current_course_instance.is_teacher(self.user))\n", "self.assertTrue(self.current_course_instance.is_course_staff(self.user))\n", "self.assertEquals(1, len(self.current_course_instance.\n get_course_staff_profiles()))\n", "self.course.teachers.add(self.user.userprofile)\n", "self.assertTrue(self.course.is_teacher(self.user))\n", "self.assertTrue(self.current_course_instance.is_assistant(self.user))\n", "self.assertTrue(self.current_course_instance.is_teacher(self.user))\n", "self.assertTrue(self.current_course_instance.is_course_staff(self.user))\n", "self.assertEquals(1, len(self.current_course_instance.\n get_course_staff_profiles()))\n", "self.assertEquals('testUser', self.current_course_instance.\n get_course_staff_profiles()[0].shortname)\n", "self.current_course_instance.assistants.clear()\n", "self.assertTrue(self.course.is_teacher(self.user))\n", "self.assertFalse(self.current_course_instance.is_assistant(self.user))\n", "self.assertTrue(self.current_course_instance.is_teacher(self.user))\n", "self.assertTrue(self.current_course_instance.is_course_staff(self.user))\n", "self.assertEquals(1, len(self.current_course_instance.\n get_course_staff_profiles()))\n", "self.course.teachers.clear()\n", "self.assertFalse(self.course.is_teacher(self.user))\n", "self.assertFalse(self.current_course_instance.is_assistant(self.user))\n", "self.assertFalse(self.current_course_instance.is_teacher(self.user))\n", "self.assertFalse(self.current_course_instance.is_course_staff(self.user))\n", "self.assertEquals(0, len(self.current_course_instance.\n get_course_staff_profiles()))\n", "def FUNC_4(self):...\n", "VAR_0 = self.current_course_instance.get_submitted_profiles()\n", "self.assertEquals(1, len(VAR_0))\n", "self.assertEquals('testUser', VAR_0[0].shortname)\n", "VAR_1 = Submission.objects.create(exercise=self.base_exercise, grader=self.\n grader.userprofile)\n", "VAR_1.submitters.add(self.user.userprofile)\n", "VAR_0 = self.current_course_instance.get_submitted_profiles()\n", "self.assertEquals(1, len(VAR_0))\n", "self.assertEquals('testUser', VAR_0[0].shortname)\n", "VAR_2 = Submission.objects.create(exercise=self.base_exercise, grader=self.\n user.userprofile)\n", "VAR_2.submitters.add(self.grader.userprofile)\n", "VAR_0 = self.current_course_instance.get_submitted_profiles()\n", "self.assertEquals(2, len(VAR_0))\n", "self.assertEquals('testUser', VAR_0[0].shortname)\n", "self.assertEquals('grader', VAR_0[1].shortname)\n", "def FUNC_5(self):...\n", "self.assertTrue(self.current_course_instance.is_visible_to())\n", "self.assertFalse(self.hidden_course_instance.is_visible_to())\n", "self.assertTrue(self.current_course_instance.is_visible_to(self.user))\n", "self.assertFalse(self.hidden_course_instance.is_visible_to(self.user))\n", "self.assertTrue(self.current_course_instance.is_visible_to(self.superuser))\n", "self.assertTrue(self.hidden_course_instance.is_visible_to(self.superuser))\n", "def FUNC_6(self):...\n", "VAR_3 = CourseInstance.objects.get_visible()\n", "self.assertEqual(3, len(VAR_3))\n", "self.assertTrue(self.current_course_instance in VAR_3)\n", "self.assertTrue(self.future_course_instance in VAR_3)\n", "VAR_3 = CourseInstance.objects.get_visible(self.user)\n", "self.assertEqual(3, len(VAR_3))\n", "self.assertTrue(self.current_course_instance in VAR_3)\n", "self.assertTrue(self.future_course_instance in VAR_3)\n", "VAR_3 = CourseInstance.objects.get_visible(self.superuser)\n", "self.assertEqual(4, len(VAR_3))\n", "self.assertTrue(self.current_course_instance in VAR_3)\n", "self.assertTrue(self.future_course_instance in VAR_3)\n", "self.assertTrue(self.hidden_course_instance in VAR_3)\n", "def FUNC_7(self):...\n", "self.assertEquals('123456 test course: Fall 2011 day 1', str(self.\n current_course_instance))\n", "self.assertEquals('123456 test course: Secret super course', str(self.\n hidden_course_instance))\n", "def FUNC_8(self):...\n", "self.assertEquals('123456 test course: Fall 2011 day 1 -> test_hook_url',\n str(self.course_hook))\n", "def FUNC_9(self):...\n", "self.assertEquals(0, self.course_module.get_late_submission_point_worth())\n", "self.assertEquals(80, self.course_module_with_late_submissions_allowed.\n get_late_submission_point_worth())\n", "def FUNC_10(self):...\n", "self.assertFalse(self.course_module.is_open(self.yesterday))\n", "self.assertTrue(self.course_module.is_open(self.today))\n", "self.assertTrue(self.course_module.is_open())\n", "self.assertTrue(self.course_module.is_open(self.tomorrow))\n", "self.assertFalse(self.course_module.is_open(self.two_days_from_now))\n", "def FUNC_11(self):...\n", "self.assertFalse(self.course_module.is_after_open(self.yesterday))\n", "self.assertTrue(self.course_module.is_after_open(self.today))\n", "self.assertTrue(self.course_module.is_after_open())\n", "self.assertTrue(self.course_module.is_after_open(self.tomorrow))\n", "self.assertTrue(self.course_module.is_after_open(self.two_days_from_now))\n", "def FUNC_12(self):...\n", "VAR_4 = self.client.get('/no_course/test', follow=True)\n", "self.assertEqual(VAR_4.status_code, 404)\n", "VAR_4 = self.client.get(self.current_course_instance.get_absolute_url(),\n follow=True)\n", "self.assertTrue(VAR_4.redirect_chain)\n", "self.assertEqual(VAR_4.status_code, 200)\n", "self.assertTemplateUsed(VAR_4, 'userprofile/login.html')\n", "self.client.login(username='testUser', password='testPassword')\n", "VAR_4 = self.client.get('/no_course/test', follow=True)\n", "self.assertEqual(VAR_4.status_code, 404)\n", "VAR_4 = self.client.get(self.current_course_instance.get_absolute_url(),\n follow=True)\n", "self.assertEqual(VAR_4.status_code, 200)\n", "self.assertEqual(VAR_4.context['course'], self.course)\n", "self.assertEqual(VAR_4.context['instance'], self.current_course_instance)\n", "self.assertFalse(VAR_4.context['is_assistant'])\n", "self.assertFalse(VAR_4.context['is_teacher'])\n", "VAR_4 = self.client.get(self.hidden_course_instance.get_absolute_url(),\n follow=True)\n", "self.assertEqual(VAR_4.status_code, 403)\n", "def FUNC_13(self):...\n", "VAR_5 = self.current_course_instance.get_edit_url()\n", "VAR_4 = self.client.get(VAR_5)\n", "self.assertEqual(VAR_4.status_code, 302)\n", "self.client.login(username='testUser', password='testPassword')\n", "VAR_4 = self.client.get(VAR_5)\n", "self.assertEqual(VAR_4.status_code, 403)\n", "self.current_course_instance.assistants.add(self.grader.userprofile)\n", "self.client.login(username='grader', password='graderPassword')\n", "VAR_4 = self.client.get(VAR_5)\n", "self.assertEqual(VAR_4.status_code, 403)\n", "VAR_4 = self.client.get(self.current_course_instance.get_absolute_url(),\n follow=True)\n", "self.assertEqual(VAR_4.status_code, 200)\n", "self.assertTrue(VAR_4.context['is_assistant'])\n", "self.assertFalse(VAR_4.context['is_teacher'])\n", "self.current_course_instance.assistants.clear()\n", "self.course.teachers.add(self.grader.userprofile)\n", "VAR_4 = self.client.get(VAR_5)\n", "self.assertEqual(VAR_4.status_code, 200)\n", "VAR_4 = self.client.get(self.current_course_instance.get_absolute_url(),\n follow=True)\n", "self.assertEqual(VAR_4.status_code, 200)\n", "self.assertFalse(VAR_4.context['is_assistant'])\n", "self.assertTrue(VAR_4.context['is_teacher'])\n", "self.client.logout()\n", "VAR_4 = self.client.get(VAR_5)\n", "self.assertEqual(VAR_4.status_code, 302)\n", "self.client.login(username='staff', password='staffPassword')\n", "VAR_4 = self.client.get(VAR_5)\n", "self.assertEqual(VAR_4.status_code, 200)\n", "self.assertFalse(VAR_4.context['is_assistant'])\n", "self.assertTrue(VAR_4.context['is_teacher'])\n", "def FUNC_14(self):...\n", "VAR_6 = StudentGroup(course_instance=self.current_course_instance)\n", "VAR_6.save()\n", "VAR_6.members.add(self.user.userprofile, self.grader.userprofile)\n", "self.assertEqual(StudentGroup.get_exact(self.current_course_instance, [self\n .user.userprofile, self.grader.userprofile]), VAR_6)\n", "self.assertEqual(StudentGroup.get_exact(self.current_course_instance, [self\n .user.userprofile, self.superuser.userprofile]), None)\n" ]
[ "from datetime import timedelta\n", "from django.contrib.auth.models import User\n", "from django.core.urlresolvers import reverse\n", "from django.test import TestCase\n", "from django.test.client import Client\n", "from django.utils import timezone\n", "from course.models import Course, CourseInstance, CourseHook, CourseModule, LearningObjectCategory, StudentGroup\n", "from exercise.models import BaseExercise, Submission\n", "from exercise.exercise_models import LearningObject\n", "def setUp(self):...\n", "self.client = Client()\n", "self.user = User(username='testUser')\n", "self.user.set_password('testPassword')\n", "self.user.save()\n", "self.grader = User(username='grader', is_staff=True)\n", "self.grader.set_password('graderPassword')\n", "self.grader.save()\n", "self.superuser = User(username='staff', is_staff=False, is_superuser=True)\n", "self.superuser.set_password('staffPassword')\n", "self.superuser.save()\n", "self.course = Course.objects.create(name='test course', code='123456', url=\n 'Course-Url')\n", "self.today = timezone.now()\n", "self.tomorrow = self.today + timedelta(days=1)\n", "self.two_days_from_now = self.tomorrow + timedelta(days=1)\n", "self.yesterday = self.today - timedelta(days=1)\n", "self.past_course_instance = CourseInstance.objects.create(instance_name=\n 'Fall 2011 day 0', starting_time=self.yesterday, ending_time=self.today,\n course=self.course, url='T-00.1000_d0')\n", "self.current_course_instance = CourseInstance.objects.create(instance_name=\n 'Fall 2011 day 1', starting_time=self.today, ending_time=self.tomorrow,\n course=self.course, url='T-00.1000_d1')\n", "self.future_course_instance = CourseInstance.objects.create(instance_name=\n 'Fall 2011 day 2', starting_time=self.tomorrow, ending_time=self.\n two_days_from_now, course=self.course, url='T-00.1000_d2')\n", "self.hidden_course_instance = CourseInstance.objects.create(instance_name=\n 'Secret super course', starting_time=self.tomorrow, ending_time=self.\n two_days_from_now, course=self.course, url='T-00.1000_hidden',\n visible_to_students=False)\n", "self.course_module = CourseModule.objects.create(name='test module', url=\n 'test-module', points_to_pass=10, course_instance=self.\n current_course_instance, opening_time=self.today, closing_time=self.\n tomorrow)\n", "self.course_module_with_late_submissions_allowed = CourseModule.objects.create(\n name='test module', url='test-module-late', points_to_pass=50,\n course_instance=self.current_course_instance, opening_time=self.today,\n closing_time=self.tomorrow, late_submissions_allowed=True,\n late_submission_deadline=self.two_days_from_now,\n late_submission_penalty=0.2)\n", "self.learning_object_category = LearningObjectCategory.objects.create(name=\n 'test category', course_instance=self.current_course_instance,\n points_to_pass=5)\n", "self.learning_object = LearningObject.objects.create(name=\n 'test learning object', course_module=self.course_module, category=self\n .learning_object_category, url='l1')\n", "self.broken_learning_object = LearningObject.objects.create(name=\n 'test learning object', course_module=self.\n course_module_with_late_submissions_allowed, category=self.\n learning_object_category, url='l2')\n", "self.base_exercise = BaseExercise.objects.create(name='test exercise',\n course_module=self.course_module, category=self.\n learning_object_category, service_url='http://localhost/', url='b1')\n", "self.submission = Submission.objects.create(exercise=self.base_exercise,\n grader=self.grader.userprofile)\n", "self.submission.submitters.add(self.user.userprofile)\n", "self.course_hook = CourseHook.objects.create(hook_url='test_hook_url',\n course_instance=self.current_course_instance)\n", "def test_course_instance_open(self):...\n", "self.assertFalse(self.past_course_instance.is_open())\n", "self.assertTrue(self.current_course_instance.is_open())\n", "self.assertFalse(self.future_course_instance.is_open())\n", "def test_course_url(self):...\n", "self.assertEqual('/Course-Url/T-00.1000_d1/', self.current_course_instance.\n get_absolute_url())\n", "self.assertEqual('/Course-Url/T-00.1000_hidden/', self.\n hidden_course_instance.get_absolute_url())\n", "def test_course_staff(self):...\n", "self.assertFalse(self.course.is_teacher(self.user))\n", "self.assertFalse(self.current_course_instance.is_assistant(self.user))\n", "self.assertFalse(self.current_course_instance.is_teacher(self.user))\n", "self.assertFalse(self.current_course_instance.is_course_staff(self.user))\n", "self.assertEquals(0, len(self.current_course_instance.\n get_course_staff_profiles()))\n", "self.current_course_instance.assistants.add(self.user.userprofile)\n", "self.assertFalse(self.course.is_teacher(self.user))\n", "self.assertTrue(self.current_course_instance.is_assistant(self.user))\n", "self.assertFalse(self.current_course_instance.is_teacher(self.user))\n", "self.assertTrue(self.current_course_instance.is_course_staff(self.user))\n", "self.assertEquals(1, len(self.current_course_instance.\n get_course_staff_profiles()))\n", "self.course.teachers.add(self.user.userprofile)\n", "self.assertTrue(self.course.is_teacher(self.user))\n", "self.assertTrue(self.current_course_instance.is_assistant(self.user))\n", "self.assertTrue(self.current_course_instance.is_teacher(self.user))\n", "self.assertTrue(self.current_course_instance.is_course_staff(self.user))\n", "self.assertEquals(1, len(self.current_course_instance.\n get_course_staff_profiles()))\n", "self.assertEquals('testUser', self.current_course_instance.\n get_course_staff_profiles()[0].shortname)\n", "self.current_course_instance.assistants.clear()\n", "self.assertTrue(self.course.is_teacher(self.user))\n", "self.assertFalse(self.current_course_instance.is_assistant(self.user))\n", "self.assertTrue(self.current_course_instance.is_teacher(self.user))\n", "self.assertTrue(self.current_course_instance.is_course_staff(self.user))\n", "self.assertEquals(1, len(self.current_course_instance.\n get_course_staff_profiles()))\n", "self.course.teachers.clear()\n", "self.assertFalse(self.course.is_teacher(self.user))\n", "self.assertFalse(self.current_course_instance.is_assistant(self.user))\n", "self.assertFalse(self.current_course_instance.is_teacher(self.user))\n", "self.assertFalse(self.current_course_instance.is_course_staff(self.user))\n", "self.assertEquals(0, len(self.current_course_instance.\n get_course_staff_profiles()))\n", "def test_course_instance_submitters(self):...\n", "students = self.current_course_instance.get_submitted_profiles()\n", "self.assertEquals(1, len(students))\n", "self.assertEquals('testUser', students[0].shortname)\n", "submission2 = Submission.objects.create(exercise=self.base_exercise, grader\n =self.grader.userprofile)\n", "submission2.submitters.add(self.user.userprofile)\n", "students = self.current_course_instance.get_submitted_profiles()\n", "self.assertEquals(1, len(students))\n", "self.assertEquals('testUser', students[0].shortname)\n", "submission3 = Submission.objects.create(exercise=self.base_exercise, grader\n =self.user.userprofile)\n", "submission3.submitters.add(self.grader.userprofile)\n", "students = self.current_course_instance.get_submitted_profiles()\n", "self.assertEquals(2, len(students))\n", "self.assertEquals('testUser', students[0].shortname)\n", "self.assertEquals('grader', students[1].shortname)\n", "def test_course_instance_visibility(self):...\n", "self.assertTrue(self.current_course_instance.is_visible_to())\n", "self.assertFalse(self.hidden_course_instance.is_visible_to())\n", "self.assertTrue(self.current_course_instance.is_visible_to(self.user))\n", "self.assertFalse(self.hidden_course_instance.is_visible_to(self.user))\n", "self.assertTrue(self.current_course_instance.is_visible_to(self.superuser))\n", "self.assertTrue(self.hidden_course_instance.is_visible_to(self.superuser))\n", "def test_course_instance_get_visible(self):...\n", "open_course_instances = CourseInstance.objects.get_visible()\n", "self.assertEqual(3, len(open_course_instances))\n", "self.assertTrue(self.current_course_instance in open_course_instances)\n", "self.assertTrue(self.future_course_instance in open_course_instances)\n", "open_course_instances = CourseInstance.objects.get_visible(self.user)\n", "self.assertEqual(3, len(open_course_instances))\n", "self.assertTrue(self.current_course_instance in open_course_instances)\n", "self.assertTrue(self.future_course_instance in open_course_instances)\n", "open_course_instances = CourseInstance.objects.get_visible(self.superuser)\n", "self.assertEqual(4, len(open_course_instances))\n", "self.assertTrue(self.current_course_instance in open_course_instances)\n", "self.assertTrue(self.future_course_instance in open_course_instances)\n", "self.assertTrue(self.hidden_course_instance in open_course_instances)\n", "def test_course_instance_unicode_string(self):...\n", "self.assertEquals('123456 test course: Fall 2011 day 1', str(self.\n current_course_instance))\n", "self.assertEquals('123456 test course: Secret super course', str(self.\n hidden_course_instance))\n", "def test_course_hook_unicode_string(self):...\n", "self.assertEquals('123456 test course: Fall 2011 day 1 -> test_hook_url',\n str(self.course_hook))\n", "def test_course_module_late_submission_point_worth(self):...\n", "self.assertEquals(0, self.course_module.get_late_submission_point_worth())\n", "self.assertEquals(80, self.course_module_with_late_submissions_allowed.\n get_late_submission_point_worth())\n", "def test_course_module_open(self):...\n", "self.assertFalse(self.course_module.is_open(self.yesterday))\n", "self.assertTrue(self.course_module.is_open(self.today))\n", "self.assertTrue(self.course_module.is_open())\n", "self.assertTrue(self.course_module.is_open(self.tomorrow))\n", "self.assertFalse(self.course_module.is_open(self.two_days_from_now))\n", "def test_course_module_after_open(self):...\n", "self.assertFalse(self.course_module.is_after_open(self.yesterday))\n", "self.assertTrue(self.course_module.is_after_open(self.today))\n", "self.assertTrue(self.course_module.is_after_open())\n", "self.assertTrue(self.course_module.is_after_open(self.tomorrow))\n", "self.assertTrue(self.course_module.is_after_open(self.two_days_from_now))\n", "def test_course_views(self):...\n", "response = self.client.get('/no_course/test', follow=True)\n", "self.assertEqual(response.status_code, 404)\n", "response = self.client.get(self.current_course_instance.get_absolute_url(),\n follow=True)\n", "self.assertTrue(response.redirect_chain)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertTemplateUsed(response, 'userprofile/login.html')\n", "self.client.login(username='testUser', password='testPassword')\n", "response = self.client.get('/no_course/test', follow=True)\n", "self.assertEqual(response.status_code, 404)\n", "response = self.client.get(self.current_course_instance.get_absolute_url(),\n follow=True)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(response.context['course'], self.course)\n", "self.assertEqual(response.context['instance'], self.current_course_instance)\n", "self.assertFalse(response.context['is_assistant'])\n", "self.assertFalse(response.context['is_teacher'])\n", "response = self.client.get(self.hidden_course_instance.get_absolute_url(),\n follow=True)\n", "self.assertEqual(response.status_code, 403)\n", "def test_course_teacher_views(self):...\n", "url = self.current_course_instance.get_edit_url()\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 302)\n", "self.client.login(username='testUser', password='testPassword')\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 403)\n", "self.current_course_instance.assistants.add(self.grader.userprofile)\n", "self.client.login(username='grader', password='graderPassword')\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 403)\n", "response = self.client.get(self.current_course_instance.get_absolute_url(),\n follow=True)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertTrue(response.context['is_assistant'])\n", "self.assertFalse(response.context['is_teacher'])\n", "self.current_course_instance.assistants.clear()\n", "self.course.teachers.add(self.grader.userprofile)\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "response = self.client.get(self.current_course_instance.get_absolute_url(),\n follow=True)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertFalse(response.context['is_assistant'])\n", "self.assertTrue(response.context['is_teacher'])\n", "self.client.logout()\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 302)\n", "self.client.login(username='staff', password='staffPassword')\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertFalse(response.context['is_assistant'])\n", "self.assertTrue(response.context['is_teacher'])\n", "def test_groups(self):...\n", "group = StudentGroup(course_instance=self.current_course_instance)\n", "group.save()\n", "group.members.add(self.user.userprofile, self.grader.userprofile)\n", "self.assertEqual(StudentGroup.get_exact(self.current_course_instance, [self\n .user.userprofile, self.grader.userprofile]), group)\n", "self.assertEqual(StudentGroup.get_exact(self.current_course_instance, [self\n .user.userprofile, self.superuser.userprofile]), None)\n" ]
[ 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "FunctionDef'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_0(self, VAR_4, VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = 'string'.format(VAR_5=' '.join(start_urls), VAR_4=report_dir)\n", "return VAR_6\n" ]
[ "def _expected_command(self, report_dir, start_urls):...\n", "\"\"\"docstring\"\"\"\n", "expected_statement = (\n 'pa11ycrawler run {start_urls} --pa11ycrawler-allowed-domains=localhost --pa11ycrawler-reports-dir={report_dir} --pa11ycrawler-deny-url-matcher=logout --pa11y-reporter=\"1.0-json\" --depth-limit=6 '\n .format(start_urls=' '.join(start_urls), report_dir=report_dir))\n", "return expected_statement\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_9(VAR_7):...\n", "if VAR_1:\n", "print('about to get bracket for url {}'.format(VAR_7))\n", "VAR_6, VAR_45 = FUNC_5(VAR_7)\n", "VAR_46 = BeautifulSoup(VAR_6, 'html.parser')\n", "VAR_47 = VAR_46.find_all('script')\n", "VAR_14 = None\n", "for VAR_93 in VAR_47:\n", "if 'matches_by_round' in str(VAR_93):\n", "if VAR_1:\n", "VAR_34 = str(VAR_93).index('matches_by_round')\n", "print('got bracket: \\n', VAR_14)\n", "return VAR_14\n", "VAR_93 = str(VAR_93)[VAR_34:]\n", "VAR_14 = VAR_93\n" ]
[ "def get_bracket(url):...\n", "if debug:\n", "print('about to get bracket for url {}'.format(url))\n", "data, status = hit_url(url)\n", "soup = BeautifulSoup(data, 'html.parser')\n", "script = soup.find_all('script')\n", "bracket = None\n", "for s in script:\n", "if 'matches_by_round' in str(s):\n", "if debug:\n", "index = str(s).index('matches_by_round')\n", "print('got bracket: \\n', bracket)\n", "return bracket\n", "s = str(s)[index:]\n", "bracket = s\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Condition", "Condition", "Assign'", "Expr'", "Return'", "Assign'", "Assign'" ]
[ "@VAR_0.route('/')...\n", "VAR_1 = get_db(VAR_0, g)\n", "return render_template('index.html')\n" ]
[ "@app.route('/')...\n", "con = get_db(app, g)\n", "return render_template('index.html')\n" ]
[ 0, 4, 0 ]
[ "Condition", "Assign'", "Return'" ]
[ "def FUNC_3(self, VAR_2, VAR_4, VAR_5):...\n", "return False\n" ]
[ "def has_object_permission(self, request, view, obj):...\n", "return False\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_10(self, VAR_13):...\n", "return VAR_13.name in self._localrules or VAR_13.norun\n" ]
[ "def is_local(self, rule):...\n", "return rule.name in self._localrules or rule.norun\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_12(self):...\n", "\"\"\"docstring\"\"\"\n", "self._state = None\n", "self._out = None\n" ]
[ "def reset(self):...\n", "\"\"\"docstring\"\"\"\n", "self._state = None\n", "self._out = None\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'" ]
[ "def FUNC_15(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_21 = [VAR_28 for VAR_28 in self.expanded_output if VAR_28.exists]\n", "if VAR_21:\n", "logger.info(\n \"\"\"Removing output files of failed job {} since they might be corrupted:\n{}\"\"\"\n .format(self, ', '.join(VAR_21)))\n", "for VAR_28 in VAR_21:\n", "VAR_28.remove()\n" ]
[ "def cleanup(self):...\n", "\"\"\"docstring\"\"\"\n", "to_remove = [f for f in self.expanded_output if f.exists]\n", "if to_remove:\n", "logger.info(\n \"\"\"Removing output files of failed job {} since they might be corrupted:\n{}\"\"\"\n .format(self, ', '.join(to_remove)))\n", "for f in to_remove:\n", "f.remove()\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Expr'", "For", "Expr'" ]
[ "def FUNC_2(VAR_3):...\n", "return CLASS_0.all().filter('user_id =', VAR_3).get()\n" ]
[ "def check_user_id(user_id):...\n", "return Authorization.all().filter('user_id =', user_id).get()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_4(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}/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", "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", "chaos.DESTROY_ERROR_RATE = 0.5\n", "VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_4 = {'web': 0}\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}/containers'.format(**locals())\n", "VAR_2 = self.client.get(VAR_1)\n", "self.assertEqual(VAR_2.status_code, 200)\n", "VAR_5 = set([c['state'] for c in VAR_2.data['results']])\n", "self.assertEqual(VAR_5, set(['error']))\n", "VAR_6 = 20\n", "for _ in range(100):\n", "VAR_1 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_4 = {'web': 0}\n", "VAR_2 = self.client.post(VAR_1, json.dumps(VAR_4), content_type=\n 'application/json')\n", "if VAR_2.status_code == 204:\n", "self.assertEquals(VAR_2.status_code, 503)\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", "VAR_6 = len(VAR_2.data['results'])\n" ]
[ "def test_destroy_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}/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", "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", "chaos.DESTROY_ERROR_RATE = 0.5\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'web': 0}\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}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "states = set([c['state'] for c in response.data['results']])\n", "self.assertEqual(states, set(['error']))\n", "containers = 20\n", "for _ in range(100):\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'web': 0}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "if response.status_code == 204:\n", "self.assertEquals(response.status_code, 503)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "containers = len(response.data['results'])\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 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "For", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_0():...\n", "VAR_1 = {'foo': 'bar'}\n", "VAR_2 = load_source(VAR_1)\n", "assert VAR_2 == VAR_1\n" ]
[ "def test_native_mapping_is_passthrough():...\n", "source = {'foo': 'bar'}\n", "result = load_source(source)\n", "assert result == source\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assert'" ]
[ "def FUNC_6(*VAR_12):...\n", "\"\"\"docstring\"\"\"\n", "VAR_23 = np.asarray(VAR_12[0])\n", "if VAR_23.shape[0] != VAR_23.shape[1]:\n", "if not np.allclose(VAR_23 @ VAR_23.conj().T, np.identity(VAR_23.shape[0]),\n", "return VAR_23\n" ]
[ "def unitary(*args):...\n", "\"\"\"docstring\"\"\"\n", "U = np.asarray(args[0])\n", "if U.shape[0] != U.shape[1]:\n", "if not np.allclose(U @ U.conj().T, np.identity(U.shape[0]), atol=tolerance):\n", "return U\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Condition", "Return'" ]
[ "@pytest.fixture...\n", "while VAR_0 is None:\n", "VAR_12 = random.randint(1, 10000)\n", "return VAR_3.run_until_complete(VAR_5(VAR_4))\n", "VAR_0 = f'amichay.oren+{VAR_12}@gmail.com'\n", "if User.username_exists(VAR_0):\n", "VAR_0 = None\n" ]
[ "@pytest.fixture...\n", "while username is None:\n", "i = random.randint(1, 10000)\n", "return loop.run_until_complete(sanic_client(app))\n", "username = f'amichay.oren+{i}@gmail.com'\n", "if User.username_exists(username):\n", "username = None\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Assign'", "Return'", "Assign'", "Condition", "Assign'" ]
[ "@session_manager...\n", "\"\"\"docstring\"\"\"\n", "from invenio.modules.accounts.models import User, UserEXT\n", "from invenio.ext.sqlalchemy import db\n", "from ..handlers import token_session_key\n", "from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound\n", "import json\n", "import requests\n", "VAR_6 = session.get(token_session_key(VAR_2.name) + '_account_info').get(\n 'external_id')\n", "VAR_7 = {'orcid': VAR_6}\n", "VAR_4.remote_account.extra_data = VAR_7\n", "VAR_8 = User.query.join(UserEXT).filter_by(id=orcid, method='orcid').one()\n", "current_app.logger.exception('No user entry in userEXT.')\n", "if VAR_8 and not any([VAR_8.given_names, VAR_8.family_name]):\n", "VAR_9 = 'http://orcid.org/{0}/orcid-bio'.format(VAR_6)\n", "VAR_10 = {'Accept': 'application/orcid+json'}\n", "VAR_11 = requests.get(VAR_9, VAR_10=headers)\n", "VAR_12 = VAR_11.status_code\n", "if VAR_12 == requests.codes.ok:\n", "VAR_13 = json.loads(VAR_11.content)\n", "current_app.logger.exception('Not valid JSON response from ' +\n 'ORCID:\\n {0}'.format(repr(VAR_13)))\n", "VAR_14 = VAR_13['orcid-profile']['orcid-bio']['personal-details']\n", "current_app.logger.exception('Unexpected return format ' +\n 'from ORCID:\\n {0}'.format(repr(VAR_13)))\n", "db.session.add(VAR_8)\n", "return\n", "VAR_8.given_names = VAR_14['given-names']['value']\n", "return\n", "current_user.reload()\n", "VAR_8.family_name = VAR_14['family-name']['value']\n" ]
[ "@session_manager...\n", "\"\"\"docstring\"\"\"\n", "from invenio.modules.accounts.models import User, UserEXT\n", "from invenio.ext.sqlalchemy import db\n", "from ..handlers import token_session_key\n", "from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound\n", "import json\n", "import requests\n", "orcid = session.get(token_session_key(remote.name) + '_account_info').get(\n 'external_id')\n", "extra_data = {'orcid': orcid}\n", "token.remote_account.extra_data = extra_data\n", "user = User.query.join(UserEXT).filter_by(id=orcid, method='orcid').one()\n", "current_app.logger.exception('No user entry in userEXT.')\n", "if user and not any([user.given_names, user.family_name]):\n", "request_url = 'http://orcid.org/{0}/orcid-bio'.format(orcid)\n", "headers = {'Accept': 'application/orcid+json'}\n", "response = requests.get(request_url, headers=headers)\n", "code = response.status_code\n", "if code == requests.codes.ok:\n", "orcid_bio = json.loads(response.content)\n", "current_app.logger.exception('Not valid JSON response from ' +\n 'ORCID:\\n {0}'.format(repr(orcid_bio)))\n", "name = orcid_bio['orcid-profile']['orcid-bio']['personal-details']\n", "current_app.logger.exception('Unexpected return format ' +\n 'from ORCID:\\n {0}'.format(repr(orcid_bio)))\n", "db.session.add(user)\n", "return\n", "user.given_names = name['given-names']['value']\n", "return\n", "current_user.reload()\n", "user.family_name = name['family-name']['value']\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Import'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Return'", "Assign'", "Return'", "Expr'", "Assign'" ]
[ "def __init__(self, VAR_2=None):...\n", "self.total = 0\n", "self.success = 0\n", "self.failure = 0\n", "self.error = 0\n", "self.undecided = 0\n", "self.total_time = 0.0\n", "self.max_time = 0.0\n", "self.log_dir = VAR_2\n", "if self.log_dir is not None:\n", "os.makedirs(self.log_dir)\n" ]
[ "def __init__(self, log_dir=None):...\n", "self.total = 0\n", "self.success = 0\n", "self.failure = 0\n", "self.error = 0\n", "self.undecided = 0\n", "self.total_time = 0.0\n", "self.max_time = 0.0\n", "self.log_dir = log_dir\n", "if self.log_dir is not None:\n", "os.makedirs(self.log_dir)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'" ]
[ "def FUNC_25(self, VAR_14):...\n", "" ]
[ "def is_fk(self, col_name):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_3():...\n", "print('grocery== list')\n", "VAR_43 = Frame(self)\n", "VAR_43.rowconfigure(0, weight=1)\n", "VAR_43.columnconfigure(0, weight=1)\n", "VAR_43.rowconfigure(1, weight=3)\n", "VAR_43.columnconfigure(1, weight=3)\n", "VAR_43.pack()\n", "VAR_15.pack_forget()\n", "VAR_9.pack_forget()\n", "VAR_8.configure(text='Grocery List')\n", "VAR_44 = 0\n", "VAR_39 = 'meal_planner.db'\n", "VAR_45 = []\n", "VAR_48 = conn.cursor()\n", "VAR_50 = 'ingredients_' + str(VAR_13)\n", "VAR_49 = VAR_48.execute('SELECT * FROM ' + VAR_50)\n", "for result in [VAR_49]:\n", "for VAR_32 in result.fetchall():\n", "VAR_46 = 0\n", "print(VAR_32)\n", "for item in VAR_45:\n", "for ingredient in VAR_32:\n", "print(item)\n", "VAR_42 = Button(VAR_4, text='Return to Menu', highlightbackground='#e7e7e7',\n command=lambda : [groceryListFrame.pack_forget(), menu.pack(),\n returnButton.pack_forget(), label.configure(text='Meal Planer'),\n groceryButton.pack(side=RIGHT)])\n", "print(ingredient)\n", "VAR_44 = VAR_44 + 1\n", "VAR_42.pack(side=RIGHT)\n", "VAR_45.append(str(ingredient).split())\n", "Label(VAR_43, text=ingredient, font=MEDIUM_FONT, justify=LEFT).grid(VAR_32=\n i, VAR_33=0, sticky='w')\n" ]
[ "def view_grocery_list():...\n", "print('grocery== list')\n", "groceryListFrame = Frame(self)\n", "groceryListFrame.rowconfigure(0, weight=1)\n", "groceryListFrame.columnconfigure(0, weight=1)\n", "groceryListFrame.rowconfigure(1, weight=3)\n", "groceryListFrame.columnconfigure(1, weight=3)\n", "groceryListFrame.pack()\n", "menu.pack_forget()\n", "groceryButton.pack_forget()\n", "label.configure(text='Grocery List')\n", "i = 0\n", "database_file = 'meal_planner.db'\n", "item_array = []\n", "cursor = conn.cursor()\n", "tableName = 'ingredients_' + str(weekNumber)\n", "selection = cursor.execute('SELECT * FROM ' + tableName)\n", "for result in [selection]:\n", "for row in result.fetchall():\n", "j = 0\n", "print(row)\n", "for item in item_array:\n", "for ingredient in row:\n", "print(item)\n", "returnButton = Button(menuFrame, text='Return to Menu', highlightbackground\n ='#e7e7e7', command=lambda : [groceryListFrame.pack_forget(), menu.pack\n (), returnButton.pack_forget(), label.configure(text='Meal Planer'),\n groceryButton.pack(side=RIGHT)])\n", "print(ingredient)\n", "i = i + 1\n", "returnButton.pack(side=RIGHT)\n", "item_array.append(str(ingredient).split())\n", "Label(groceryListFrame, text=ingredient, font=MEDIUM_FONT, justify=LEFT).grid(\n row=i, column=0, sticky='w')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "For", "Assign'", "Expr'", "For", "For", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_1(VAR_1):...\n", "for VAR_5 in VAR_1.traverse():\n", "if VAR_5.path.startswith('LICENSES'):\n", "if VAR_5.path.find('license-rules.rst') >= 0:\n", "if not os.path.isfile(VAR_5.path):\n", "VAR_22.parse_lines(VAR_15, VAR_19.maxlines, VAR_5.path)\n" ]
[ "def scan_git_tree(tree):...\n", "for el in tree.traverse():\n", "if el.path.startswith('LICENSES'):\n", "if el.path.find('license-rules.rst') >= 0:\n", "if not os.path.isfile(el.path):\n", "parser.parse_lines(fd, args.maxlines, el.path)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Condition", "Condition", "Condition", "Expr'" ]
[ "def FUNC_3(self, VAR_2):...\n", "VAR_6 = os.path.join(self.namespace, VAR_2)\n", "self.etcd.write(VAR_6, None, dir=True, prevExist=False)\n", "FUNC_0('Error storing key %s: [%r]' % (VAR_2, repr(err)))\n" ]
[ "def span(self, key):...\n", "path = os.path.join(self.namespace, key)\n", "self.etcd.write(path, None, dir=True, prevExist=False)\n", "log_error('Error storing key %s: [%r]' % (key, repr(err)))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'" ]
[ "def __init__(self, *VAR_1, **VAR_2):...\n", "super().__init__(*VAR_1, **kwargs)\n", "self.setup_logging()\n", "self.setup_window()\n", "self.setup_menus()\n", "self.setup_action_listeners()\n", "self.setup_log_window()\n", "self.setup_matisse()\n", "self.setup_widgets()\n", "self.aboutToQuit.connect(self.clean_up)\n", "VAR_5 = QWidget()\n", "VAR_5.setLayout(self.layout)\n", "self.window.setCentralWidget(VAR_5)\n", "self.window.show()\n" ]
[ "def __init__(self, *args, **kwargs):...\n", "super().__init__(*args, **kwargs)\n", "self.setup_logging()\n", "self.setup_window()\n", "self.setup_menus()\n", "self.setup_action_listeners()\n", "self.setup_log_window()\n", "self.setup_matisse()\n", "self.setup_widgets()\n", "self.aboutToQuit.connect(self.clean_up)\n", "container = QWidget()\n", "container.setLayout(self.layout)\n", "self.window.setCentralWidget(container)\n", "self.window.show()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def __new__(VAR_22, VAR_3):...\n", "VAR_48 = str.__new__(VAR_22, VAR_3)\n", "VAR_48._is_function = type(VAR_3).__name__ == 'function'\n", "VAR_48._file = VAR_3\n", "VAR_48.rule = None\n", "VAR_48._regex = None\n", "return VAR_48\n" ]
[ "def __new__(cls, file):...\n", "obj = str.__new__(cls, file)\n", "obj._is_function = type(file).__name__ == 'function'\n", "obj._file = file\n", "obj.rule = None\n", "obj._regex = None\n", "return obj\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "@staticmethod...\n", "VAR_31 = openid.get_current_user(VAR_3)\n", "return CLASS_4(VAR_31.sub, VAR_31.email, VAR_31.picture) if VAR_31 else None\n" ]
[ "@staticmethod...\n", "user = openid.get_current_user(request)\n", "return CurrentUser(user.sub, user.email, user.picture) if user else None\n" ]
[ 0, 0, 0 ]
[ "Condition", "Assign'", "Return'" ]
[ "@FUNC_7...\n", "\"\"\"docstring\"\"\"\n", "FUNC_1(VAR_1, VAR_2)\n", "return redirect('/')\n" ]
[ "@oauth_error_handler...\n", "\"\"\"docstring\"\"\"\n", "response_token_setter(remote, resp)\n", "return redirect('/')\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Expr'", "Return'" ]
[ "def FUNC_0(self, VAR_3):...\n", "VAR_5 = '%s timestamp' % str(VAR_3)\n", "return VAR_5\n" ]
[ "def create_field(self, name):...\n", "field_string = '%s timestamp' % str(name)\n", "return field_string\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self.obj.__name__\n" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self.obj.__name__\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def FUNC_0(VAR_0, VAR_1, VAR_2=None, VAR_3=False):...\n", "\"\"\"docstring\"\"\"\n", "VAR_1 = posixpath.normpath(unquote(VAR_1))\n", "VAR_1 = VAR_1.lstrip('/')\n", "VAR_10 = ''\n", "for VAR_18 in VAR_1.split('/'):\n", "if not VAR_18:\n", "if VAR_10 and VAR_1 != VAR_10:\n", "VAR_17, VAR_18 = os.path.splitdrive(VAR_18)\n", "return HttpResponseRedirect(VAR_10)\n", "VAR_6 = os.path.join(VAR_2, VAR_10)\n", "VAR_19, VAR_18 = os.path.split(VAR_18)\n", "if os.path.isdir(VAR_6):\n", "if VAR_18 in (os.curdir, os.pardir):\n", "if VAR_3:\n", "if not os.path.exists(VAR_6):\n", "VAR_10 = os.path.join(VAR_10, VAR_18).replace('\\\\', '/')\n", "return FUNC_1(VAR_10, VAR_6)\n", "VAR_11 = os.stat(VAR_6)\n", "if not FUNC_2(VAR_0.META.get('HTTP_IF_MODIFIED_SINCE'), VAR_11.st_mtime,\n", "return HttpResponseNotModified()\n", "VAR_12, VAR_13 = mimetypes.guess_type(VAR_6)\n", "VAR_12 = VAR_12 or 'application/octet-stream'\n", "VAR_14 = FileResponse(open(VAR_6, 'rb'), VAR_12=content_type)\n", "VAR_14['Last-Modified'] = http_date(VAR_11.st_mtime)\n", "if stat.S_ISREG(VAR_11.st_mode):\n", "VAR_14['Content-Length'] = VAR_11.st_size\n", "if VAR_13:\n", "VAR_14['Content-Encoding'] = VAR_13\n", "return VAR_14\n" ]
[ "def serve(request, path, document_root=None, show_indexes=False):...\n", "\"\"\"docstring\"\"\"\n", "path = posixpath.normpath(unquote(path))\n", "path = path.lstrip('/')\n", "newpath = ''\n", "for part in path.split('/'):\n", "if not part:\n", "if newpath and path != newpath:\n", "drive, part = os.path.splitdrive(part)\n", "return HttpResponseRedirect(newpath)\n", "fullpath = os.path.join(document_root, newpath)\n", "head, part = os.path.split(part)\n", "if os.path.isdir(fullpath):\n", "if part in (os.curdir, os.pardir):\n", "if show_indexes:\n", "if not os.path.exists(fullpath):\n", "newpath = os.path.join(newpath, part).replace('\\\\', '/')\n", "return directory_index(newpath, fullpath)\n", "statobj = os.stat(fullpath)\n", "if not was_modified_since(request.META.get('HTTP_IF_MODIFIED_SINCE'),\n", "return HttpResponseNotModified()\n", "content_type, encoding = mimetypes.guess_type(fullpath)\n", "content_type = content_type or 'application/octet-stream'\n", "response = FileResponse(open(fullpath, 'rb'), content_type=content_type)\n", "response['Last-Modified'] = http_date(statobj.st_mtime)\n", "if stat.S_ISREG(statobj.st_mode):\n", "response['Content-Length'] = statobj.st_size\n", "if encoding:\n", "response['Content-Encoding'] = encoding\n", "return response\n" ]
[ 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0, 6, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "For", "Condition", "Condition", "Assign'", "Return'", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Condition", "Assign'", "Return'", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Return'" ]
[ "def FUNC_21(self):...\n", "VAR_14 = self.new_mocked_client(client.NSX3Client)\n", "VAR_14.create('ports', {'resource-name': 'port1'})\n", "FUNC_2('post', VAR_14, 'https://1.2.3.4/api/v1/ports', VAR_8=jsonutils.\n dumps({'resource-name': 'port1'}))\n" ]
[ "def test_create_resource(self):...\n", "api = self.new_mocked_client(client.NSX3Client)\n", "api.create('ports', {'resource-name': 'port1'})\n", "assert_json_call('post', api, 'https://1.2.3.4/api/v1/ports', data=\n jsonutils.dumps({'resource-name': 'port1'}))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'" ]
[ "from __future__ import unicode_literals\n", "import frappe, unittest\n", "from frappe.model.db_query import DatabaseQuery\n", "from frappe.desk.reportview import get_filters_cond\n", "def FUNC_1(self):...\n", "self.assertTrue({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n limit_page_length=None))\n", "def FUNC_2(self):...\n", "self.assertTrue({'name': 'DocType', 'issingle': 0} in DatabaseQuery(\n 'DocType').execute(fields=['name', 'issingle'], limit_page_length=None))\n", "def FUNC_3(self):...\n", "self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters=[['DocType', 'name', 'like', 'J%']]))\n", "def FUNC_4(self):...\n", "self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters=[{'name': ['like', 'J%']}]))\n", "def FUNC_5(self):...\n", "self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters={'name': ['like', 'J%']}))\n", "def FUNC_6(self):...\n", "self.assertTrue({'name': 'DocField'} in DatabaseQuery('DocType').execute(\n filters={'name': 'DocField'}))\n", "def FUNC_7(self):...\n", "self.assertFalse(DatabaseQuery('DocType').execute(filters={'name': ['in',\n None]}))\n", "self.assertTrue({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters={'name': ['not in', None]}))\n", "for result in [{'name': 'DocType'}, {'name': 'DocField'}]:\n", "self.assertTrue(result in DatabaseQuery('DocType').execute(filters={'name':\n ['in', 'DocType,DocField']}))\n", "for result in [{'name': 'DocType'}, {'name': 'DocField'}]:\n", "self.assertFalse(result in DatabaseQuery('DocType').execute(filters={'name':\n ['not in', 'DocType,DocField']}))\n", "def FUNC_8(self):...\n", "VAR_3 = DatabaseQuery('DocField').execute(filters={'parent': 'DocType'},\n fields=['fieldname', 'fieldtype'], or_filters=[{'fieldtype': 'Table'},\n {'fieldtype': 'Select'}])\n", "self.assertTrue({'fieldtype': 'Table', 'fieldname': 'fields'} in VAR_3)\n", "self.assertTrue({'fieldtype': 'Select', 'fieldname': 'document_type'} in VAR_3)\n", "self.assertFalse({'fieldtype': 'Check', 'fieldname': 'issingle'} in VAR_3)\n", "def FUNC_9(self):...\n", "\"\"\"docstring\"\"\"\n", "frappe.db.sql('delete from tabEvent')\n", "VAR_4 = FUNC_0()\n", "VAR_5 = FUNC_0(VAR_1='2016-07-05 23:59:59')\n", "VAR_6 = FUNC_0(VAR_1='2016-07-06 00:00:00')\n", "VAR_7 = FUNC_0(VAR_1='2016-07-07 23:59:59')\n", "VAR_8 = FUNC_0(VAR_1='2016-07-08 00:00:01')\n", "VAR_3 = DatabaseQuery('Event').execute(filters={'starts_on': ['between',\n None]}, fields=['name'])\n", "self.assertTrue({'name': VAR_5.name} not in VAR_3)\n", "VAR_3 = DatabaseQuery('Event').execute(filters={'starts_on': ['between', [\n '2016-07-06', '2016-07-07']]}, fields=['name'])\n", "self.assertTrue({'name': VAR_6.name} in VAR_3)\n", "self.assertTrue({'name': VAR_7.name} in VAR_3)\n", "self.assertTrue({'name': VAR_5.name} not in VAR_3)\n", "self.assertTrue({'name': VAR_8.name} not in VAR_3)\n", "VAR_3 = DatabaseQuery('Event').execute(filters={'starts_on': ['between', [\n '2016-07-07']]}, fields=['name'])\n", "self.assertTrue({'name': VAR_7.name} in VAR_3)\n", "self.assertTrue({'name': VAR_8.name} in VAR_3)\n", "self.assertTrue({'name': VAR_4.name} in VAR_3)\n", "self.assertTrue({'name': VAR_5.name} not in VAR_3)\n", "self.assertTrue({'name': VAR_6.name} not in VAR_3)\n", "def FUNC_10(self):...\n", "frappe.set_user('[email protected]')\n", "self.assertRaises(frappe.PermissionError, get_filters_cond, 'DocType', dict\n (istable=1), [])\n", "self.assertTrue(get_filters_cond('DocType', dict(istable=1), [],\n ignore_permissions=True))\n", "frappe.set_user('Administrator')\n", "def FUNC_11(self):...\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name', 'issingle, version()'], limit_start=0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name',\n 'issingle, IF(issingle=1, (select name from tabUser), count(name))'],\n limit_start=0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name', 'issingle, (select count(*) from tabSessions)'],\n limit_start=0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name',\n \"issingle, SELECT LOCATE('', `tabUser`.`user`) AS user;\"], limit_start=\n 0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name',\n 'issingle, IF(issingle=1, (SELECT name from tabUser), count(*))'],\n limit_start=0, limit_page_length=1)\n", "VAR_3 = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n 'count(name)'], limit_start=0, limit_page_length=1)\n", "self.assertTrue('count(name)' in VAR_3[0])\n", "VAR_3 = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n \"locate('', name) as _relevance\"], limit_start=0, limit_page_length=1)\n", "self.assertTrue('_relevance' in VAR_3[0])\n", "VAR_3 = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n 'date(creation) as creation'], limit_start=0, limit_page_length=1)\n", "self.assertTrue('creation' in VAR_3[0])\n", "VAR_3 = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n 'datediff(modified, creation) as date_diff'], limit_start=0,\n limit_page_length=1)\n", "self.assertTrue('date_diff' in VAR_3[0])\n", "def FUNC_0(VAR_0='_Test Event', VAR_1=None):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.utils import get_datetime\n", "VAR_2 = frappe.get_doc({'doctype': 'Event', 'subject': VAR_0, 'event_type':\n 'Public', 'starts_on': get_datetime(VAR_1)}).insert(ignore_permissions=True\n )\n", "return VAR_2\n" ]
[ "from __future__ import unicode_literals\n", "import frappe, unittest\n", "from frappe.model.db_query import DatabaseQuery\n", "from frappe.desk.reportview import get_filters_cond\n", "def test_basic(self):...\n", "self.assertTrue({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n limit_page_length=None))\n", "def test_fields(self):...\n", "self.assertTrue({'name': 'DocType', 'issingle': 0} in DatabaseQuery(\n 'DocType').execute(fields=['name', 'issingle'], limit_page_length=None))\n", "def test_filters_1(self):...\n", "self.assertFalse({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters=[['DocType', 'name', 'like', 'J%']]))\n", "def test_filters_2(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", "def test_filters_4(self):...\n", "self.assertTrue({'name': 'DocField'} in DatabaseQuery('DocType').execute(\n filters={'name': 'DocField'}))\n", "def test_in_not_in_filters(self):...\n", "self.assertFalse(DatabaseQuery('DocType').execute(filters={'name': ['in',\n None]}))\n", "self.assertTrue({'name': 'DocType'} in DatabaseQuery('DocType').execute(\n filters={'name': ['not in', None]}))\n", "for result in [{'name': 'DocType'}, {'name': 'DocField'}]:\n", "self.assertTrue(result in DatabaseQuery('DocType').execute(filters={'name':\n ['in', 'DocType,DocField']}))\n", "for result in [{'name': 'DocType'}, {'name': 'DocField'}]:\n", "self.assertFalse(result in DatabaseQuery('DocType').execute(filters={'name':\n ['not in', 'DocType,DocField']}))\n", "def test_or_filters(self):...\n", "data = DatabaseQuery('DocField').execute(filters={'parent': 'DocType'},\n fields=['fieldname', 'fieldtype'], or_filters=[{'fieldtype': 'Table'},\n {'fieldtype': 'Select'}])\n", "self.assertTrue({'fieldtype': 'Table', 'fieldname': 'fields'} in data)\n", "self.assertTrue({'fieldtype': 'Select', 'fieldname': 'document_type'} in data)\n", "self.assertFalse({'fieldtype': 'Check', 'fieldname': 'issingle'} in data)\n", "def test_between_filters(self):...\n", "\"\"\"docstring\"\"\"\n", "frappe.db.sql('delete from tabEvent')\n", "todays_event = create_event()\n", "event1 = create_event(starts_on='2016-07-05 23:59:59')\n", "event2 = create_event(starts_on='2016-07-06 00:00:00')\n", "event3 = create_event(starts_on='2016-07-07 23:59:59')\n", "event4 = create_event(starts_on='2016-07-08 00:00:01')\n", "data = DatabaseQuery('Event').execute(filters={'starts_on': ['between',\n None]}, fields=['name'])\n", "self.assertTrue({'name': event1.name} not in data)\n", "data = DatabaseQuery('Event').execute(filters={'starts_on': ['between', [\n '2016-07-06', '2016-07-07']]}, fields=['name'])\n", "self.assertTrue({'name': event2.name} in data)\n", "self.assertTrue({'name': event3.name} in data)\n", "self.assertTrue({'name': event1.name} not in data)\n", "self.assertTrue({'name': event4.name} not in data)\n", "data = DatabaseQuery('Event').execute(filters={'starts_on': ['between', [\n '2016-07-07']]}, fields=['name'])\n", "self.assertTrue({'name': event3.name} in data)\n", "self.assertTrue({'name': event4.name} in data)\n", "self.assertTrue({'name': todays_event.name} in data)\n", "self.assertTrue({'name': event1.name} not in data)\n", "self.assertTrue({'name': event2.name} not in data)\n", "def test_ignore_permissions_for_get_filters_cond(self):...\n", "frappe.set_user('[email protected]')\n", "self.assertRaises(frappe.PermissionError, get_filters_cond, 'DocType', dict\n (istable=1), [])\n", "self.assertTrue(get_filters_cond('DocType', dict(istable=1), [],\n ignore_permissions=True))\n", "frappe.set_user('Administrator')\n", "def test_query_fields_sanitizer(self):...\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name', 'issingle, version()'], limit_start=0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name',\n 'issingle, IF(issingle=1, (select name from tabUser), count(name))'],\n limit_start=0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name', 'issingle, (select count(*) from tabSessions)'],\n limit_start=0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name',\n \"issingle, SELECT LOCATE('', `tabUser`.`user`) AS user;\"], limit_start=\n 0, limit_page_length=1)\n", "self.assertRaises(frappe.DataError, DatabaseQuery('DocType').execute,\n fields=['name',\n 'issingle, IF(issingle=1, (SELECT name from tabUser), count(*))'],\n limit_start=0, limit_page_length=1)\n", "data = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n 'count(name)'], limit_start=0, limit_page_length=1)\n", "self.assertTrue('count(name)' in data[0])\n", "data = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n \"locate('', name) as _relevance\"], limit_start=0, limit_page_length=1)\n", "self.assertTrue('_relevance' in data[0])\n", "data = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n 'date(creation) as creation'], limit_start=0, limit_page_length=1)\n", "self.assertTrue('creation' in data[0])\n", "data = DatabaseQuery('DocType').execute(fields=['name', 'issingle',\n 'datediff(modified, creation) as date_diff'], limit_start=0,\n limit_page_length=1)\n", "self.assertTrue('date_diff' in data[0])\n", "def create_event(subject='_Test Event', starts_on=None):...\n", "\"\"\"docstring\"\"\"\n", "from frappe.utils import get_datetime\n", "event = frappe.get_doc({'doctype': 'Event', 'subject': subject,\n 'event_type': 'Public', 'starts_on': get_datetime(starts_on)}).insert(\n ignore_permissions=True)\n", "return event\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 ]
[ "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "For", "Expr'", "For", "Expr'", "FunctionDef'", "Assign'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "FunctionDef'", "Docstring", "ImportFrom'", "Assign'", "Return'" ]
[ "@VAR_5.setter...\n", "self._benchmark = IOFile(VAR_5, VAR_16=self)\n" ]
[ "@benchmark.setter...\n", "self._benchmark = IOFile(benchmark, rule=self)\n" ]
[ 0, 0 ]
[ "Condition", "Assign'" ]
[ "def FUNC_12(self, VAR_5):...\n", "VAR_20 = VAR_5.args['username'][0]\n", "VAR_21 = VAR_5.args['password'][0]\n", "return credentials.UsernamePassword(VAR_20, VAR_21)\n" ]
[ "def _get_creds_from(self, request):...\n", "username = request.args['username'][0]\n", "password = request.args['password'][0]\n", "return credentials.UsernamePassword(username, password)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_13(VAR_6, VAR_5):...\n", "print('in makeStrings')\n", "print(VAR_5)\n", "if VAR_5 == []:\n", "return 'true'\n", "VAR_11 = '('\n", "for i in range(0, len(VAR_5) - 1):\n", "VAR_11 += ' ' + VAR_6 + \" = '\" + VAR_5[i] + \"' or \"\n", "VAR_11 += ' ' + VAR_6 + \" = '\" + VAR_5[len(VAR_5) - 1] + \"' ) \"\n", "print('result is ' + VAR_11)\n", "return VAR_11\n" ]
[ "def makeStrings(columnname, list):...\n", "print('in makeStrings')\n", "print(list)\n", "if list == []:\n", "return 'true'\n", "result = '('\n", "for i in range(0, len(list) - 1):\n", "result += ' ' + columnname + \" = '\" + list[i] + \"' or \"\n", "result += ' ' + columnname + \" = '\" + list[len(list) - 1] + \"' ) \"\n", "print('result is ' + result)\n", "return result\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Condition", "Return'", "Assign'", "For", "AugAssign'", "AugAssign'", "Expr'", "Return'" ]
[ "def FUNC_1(self):...\n", "VAR_2 = self.connect()\n", "VAR_3 = 'SELECT description FROM crimes;'\n", "VAR_2.close()\n", "cursor.execute(VAR_3)\n", "return cursor.fetchall()\n" ]
[ "def get_all_inputs(self):...\n", "connection = self.connect()\n", "query = 'SELECT description FROM crimes;'\n", "connection.close()\n", "cursor.execute(query)\n", "return cursor.fetchall()\n" ]
[ 0, 0, 0, 0, 4, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_19(self):...\n", "VAR_21, VAR_22 = shellutil.run_get_output(\"sysctl hw.ncpu |awk '{print $2}'\")\n", "if VAR_21:\n", "return int(VAR_22)\n" ]
[ "def get_processor_cores(self):...\n", "ret, output = shellutil.run_get_output(\"sysctl hw.ncpu |awk '{print $2}'\")\n", "if ret:\n", "return int(output)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_17(self, VAR_19, VAR_18, VAR_20):...\n", "if VAR_18.collection:\n", "VAR_30 = self._ds.get_collection(VAR_18.collection)\n", "return 'X',\n", "return VAR_30[0],\n" ]
[ "def get_parameters(self, key, levelctx, pathctxlist):...\n", "if levelctx.collection:\n", "coll = self._ds.get_collection(levelctx.collection)\n", "return 'X',\n", "return coll[0],\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Return'", "Return'" ]
[ "def FUNC_2(self):...\n", "VAR_7 = BokChoyTestSuite('')\n", "VAR_1 = 'tests'\n", "self.assertEqual(VAR_7.cmd, self._expected_command(VAR_1=name))\n" ]
[ "def test_default(self):...\n", "suite = BokChoyTestSuite('')\n", "name = 'tests'\n", "self.assertEqual(suite.cmd, self._expected_command(name=name))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'" ]
[ "@functools.wraps(VAR_7)...\n", "assert isinstance(self, webapp2.RequestHandler)\n", "assert self.request.method == 'GET'\n", "if model.is_replica():\n", "VAR_40 = model.get_replication_state().primary_url\n", "return VAR_7(self, *VAR_9, **kwargs)\n", "VAR_41 = 'http://' if utils.is_local_dev_server() else 'https://'\n", "assert VAR_40 and VAR_40.startswith(VAR_41), VAR_40\n", "assert self.request.path_qs.startswith('/'), self.request.path_qs\n", "self.redirect(VAR_40.rstrip('/') + self.request.path_qs, abort=True)\n" ]
[ "@functools.wraps(method)...\n", "assert isinstance(self, webapp2.RequestHandler)\n", "assert self.request.method == 'GET'\n", "if model.is_replica():\n", "primary_url = model.get_replication_state().primary_url\n", "return method(self, *args, **kwargs)\n", "protocol = 'http://' if utils.is_local_dev_server() else 'https://'\n", "assert primary_url and primary_url.startswith(protocol), primary_url\n", "assert self.request.path_qs.startswith('/'), self.request.path_qs\n", "self.redirect(primary_url.rstrip('/') + self.request.path_qs, abort=True)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assert'", "Assert'", "Condition", "Assign'", "Return'", "Assign'", "Assert'", "Assert'", "Expr'" ]
[ "def FUNC_6(self, VAR_2, VAR_3):...\n", "logging.debug('API: Getting remote host %s path %s contents' % (VAR_2, VAR_3))\n", "VAR_5 = list()\n", "logging.debug('Checking path %s' % VAR_3)\n", "if not self.remote_exists(VAR_2, VAR_3):\n", "while not self.remote_exists(VAR_2, VAR_3):\n", "for line in self.remote_iterdir(VAR_2, VAR_3):\n", "logging.debug('Path does not exist, working up the tree...')\n", "logging.debug(line)\n", "return VAR_5\n", "logging.debug(VAR_3.as_posix())\n", "if len(line) > 0 and line != './' and line != '../':\n", "VAR_3 = VAR_3.parent\n", "if line[-1] == '/':\n", "VAR_5.append({'type': 'dir', 'name': line[:-1]})\n", "if line[-1] == '@':\n", "VAR_5.append({'type': 'link', 'name': line[:-1]})\n", "if line[-1] == '*':\n", "VAR_5.append({'type': 'file', 'name': line[:-1]})\n", "if line[-1] not in ['#']:\n", "VAR_5.append({'type': 'file', 'name': line})\n" ]
[ "def remote_listing(self, host, path):...\n", "logging.debug('API: Getting remote host %s path %s contents' % (host, path))\n", "contents = list()\n", "logging.debug('Checking path %s' % path)\n", "if not self.remote_exists(host, path):\n", "while not self.remote_exists(host, path):\n", "for line in self.remote_iterdir(host, path):\n", "logging.debug('Path does not exist, working up the tree...')\n", "logging.debug(line)\n", "return contents\n", "logging.debug(path.as_posix())\n", "if len(line) > 0 and line != './' and line != '../':\n", "path = path.parent\n", "if line[-1] == '/':\n", "contents.append({'type': 'dir', 'name': line[:-1]})\n", "if line[-1] == '@':\n", "contents.append({'type': 'link', 'name': line[:-1]})\n", "if line[-1] == '*':\n", "contents.append({'type': 'file', 'name': line[:-1]})\n", "if line[-1] not in ['#']:\n", "contents.append({'type': 'file', 'name': line})\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Expr'", "Condition", "Condition", "For", "Expr'", "Expr'", "Return'", "Expr'", "Condition", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'" ]
[ "@classmethod...\n", "\"\"\"docstring\"\"\"\n", "return VAR_18._check_executable_command(VAR_0=cls.executable, VAR_19=cls.\n prerequisite_command, VAR_20=cls.prerequisite_fail_msg)\n" ]
[ "@classmethod...\n", "\"\"\"docstring\"\"\"\n", "return cls._check_executable_command(executable=cls.executable, command=cls\n .prerequisite_command, fail_msg=cls.prerequisite_fail_msg)\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "@property...\n", "return self.extracted_text.data_document\n" ]
[ "@property...\n", "return self.extracted_text.data_document\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_1(self):...\n", "VAR_2 = self.connects()\n", "VAR_4 = 'SELECT description FROM crimes;'\n", "VAR_2.close()\n", "cursor.execute(VAR_4)\n", "return cursor.fetchall()\n" ]
[ "def get_all_inputs(self):...\n", "connection = self.connects()\n", "query = 'SELECT description FROM crimes;'\n", "connection.close()\n", "cursor.execute(query)\n", "return cursor.fetchall()\n" ]
[ 0, 0, 0, 0, 4, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_15(self, VAR_20=None, VAR_18=None, **VAR_3):...\n", "VAR_34 = VAR_3.pop('cache', False)\n", "VAR_20 = self.__prepare(VAR_20, VAR_18)\n", "VAR_22 = self._dataframe(VAR_20, VAR_3, VAR_34=cache)\n", "VAR_37 = StringIO()\n", "VAR_22.info(buf=buffer, memory_usage='deep')\n", "VAR_0.info(VAR_37.getvalue())\n", "VAR_0.info(VAR_22.head())\n", "return VAR_22\n" ]
[ "def dataframe(self, sql=None, filename=None, **kwargs):...\n", "cache = kwargs.pop('cache', False)\n", "sql = self.__prepare(sql, filename)\n", "dataframe = self._dataframe(sql, kwargs, cache=cache)\n", "buffer = StringIO()\n", "dataframe.info(buf=buffer, memory_usage='deep')\n", "logger.info(buffer.getvalue())\n", "logger.info(dataframe.head())\n", "return dataframe\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_13(self):...\n", "for filename in ['cert_db.sqlite3', 'rf_model.pkl', 'rf_features.pkl']:\n", "os.rename('temp_' + filename, filename)\n", "os.remove(filename)\n" ]
[ "def tearDown(self):...\n", "for filename in ['cert_db.sqlite3', 'rf_model.pkl', 'rf_features.pkl']:\n", "os.rename('temp_' + filename, filename)\n", "os.remove(filename)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Expr'", "Expr'" ]
[ "@wraps(VAR_5)...\n", "VAR_26 = json.dumps(VAR_5(*VAR_18, **kwargs) or {'error':\n 'No data found for your request'}, default=serialize_to_json)\n", "VAR_63 = [('Content-Type', 'application/json'), ('Content-Length', str(len(\n VAR_26)))]\n", "return Response(VAR_26, status=200, VAR_63=headers)\n" ]
[ "@wraps(func)...\n", "result = json.dumps(func(*args, **kwargs) or {'error':\n 'No data found for your request'}, default=serialize_to_json)\n", "headers = [('Content-Type', 'application/json'), ('Content-Length', str(len\n (result)))]\n", "return Response(result, status=200, headers=headers)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_1(VAR_4, VAR_5, VAR_6):...\n", "VAR_11 = VAR_1.emails\n", "VAR_12 = {'gmail': VAR_5, 'facebook': VAR_6}\n", "VAR_11.insert(VAR_12)\n", "return HttpResponse('Gmail is: ' + VAR_5 + '. Facebook is: ' + VAR_6)\n" ]
[ "def addUser(request, gmail, fb):...\n", "emails = db.emails\n", "new_email = {'gmail': gmail, 'facebook': fb}\n", "emails.insert(new_email)\n", "return HttpResponse('Gmail is: ' + gmail + '. Facebook is: ' + fb)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_1(self):...\n", "self.assertEqual((0, 0), analyze_regression_range.\n _GetLowerAndUpperBoundCommitPositions(0, 0))\n", "self.assertEqual((0, 0), analyze_regression_range.\n _GetLowerAndUpperBoundCommitPositions(None, 0))\n", "self.assertEqual((0, 0), analyze_regression_range.\n _GetLowerAndUpperBoundCommitPositions(0, None))\n", "self.assertEqual((None, None), analyze_regression_range.\n _GetLowerAndUpperBoundCommitPositions(None, None))\n", "self.assertEqual((1, 2), analyze_regression_range.\n _GetLowerAndUpperBoundCommitPositions(1, 2))\n", "self.assertEqual((1, 2), analyze_regression_range.\n _GetLowerAndUpperBoundCommitPositions(2, 1))\n" ]
[ "def testGetLowerAndUpperBoundCopmmitPositions(self):...\n", "self.assertEqual((0, 0), analyze_regression_range.\n _GetLowerAndUpperBoundCommitPositions(0, 0))\n", "self.assertEqual((0, 0), analyze_regression_range.\n _GetLowerAndUpperBoundCommitPositions(None, 0))\n", "self.assertEqual((0, 0), analyze_regression_range.\n _GetLowerAndUpperBoundCommitPositions(0, None))\n", "self.assertEqual((None, None), analyze_regression_range.\n _GetLowerAndUpperBoundCommitPositions(None, None))\n", "self.assertEqual((1, 2), analyze_regression_range.\n _GetLowerAndUpperBoundCommitPositions(1, 2))\n", "self.assertEqual((1, 2), analyze_regression_range.\n _GetLowerAndUpperBoundCommitPositions(2, 1))\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "@app.route('/api/server/disconnect', methods=['PUT'])...\n", "controller.indi_server.disconnect()\n", "VAR_17 = not timeout(5)(lambda : not controller.indi_server.is_connected())()\n", "return notify('indi_server', 'indi_server_disconnect', controller.\n indi_server.to_map(), VAR_17)\n" ]
[ "@app.route('/api/server/disconnect', methods=['PUT'])...\n", "controller.indi_server.disconnect()\n", "is_error = not timeout(5)(lambda : not controller.indi_server.is_connected())()\n", "return notify('indi_server', 'indi_server_disconnect', controller.\n indi_server.to_map(), is_error)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_1(self):...\n", "settings.SCHEDULER_MODULE = 'mock'\n", "settings.SSH_PRIVATE_KEY = ''\n" ]
[ "def tearDown(self):...\n", "settings.SCHEDULER_MODULE = 'mock'\n", "settings.SSH_PRIVATE_KEY = ''\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'" ]
[ "def FUNC_0():...\n", "if len(sys.argv) > 1:\n", "VAR_0 = int(sys.argv[1])\n", "if sys.version_info.major < 3:\n", "print('This script only runs in python3')\n", "VAR_1 = './data'\n", "return\n", "if not os.path.isdir(VAR_1):\n", "os.makedirs(VAR_1)\n", "VAR_2 = os.path.join(VAR_1, '{}_{}'.format(resolution_width, resolution_height)\n )\n", "if not os.path.isdir(VAR_1):\n", "if not os.path.isdir(VAR_2):\n", "print(\"Failed to create data path '{}'\".format(VAR_1))\n", "os.makedirs(VAR_2)\n", "VAR_3 = sqlite3.connect('./data/data.db')\n", "return\n", "if not os.path.isdir(VAR_2):\n", "VAR_4 = VAR_3.cursor()\n", "print(\"Failed to create image path '{}'\".format(VAR_2))\n", "VAR_4.execute(\n \"\"\"\n select name from sqlite_master\n where type='table' and name='wallpapers'\n \"\"\"\n )\n", "return\n", "if VAR_4.fetchone() == None:\n", "VAR_4.execute('string')\n", "VAR_5 = 0\n", "while VAR_5 <= VAR_0:\n", "VAR_6 = (\n 'https://www.bing.com/HPImageArchive.aspx?format=js&idx={}&n=1&mkt=en-US'\n .format(VAR_5))\n", "VAR_3.commit()\n", "print(\"Getting iamge list from '{}'\".format(VAR_6))\n", "VAR_4.close()\n", "VAR_7 = requests.get(VAR_6)\n", "VAR_3.close()\n", "if VAR_7.status_code != requests.codes.ok:\n", "print(\"Failed to get url '{}'\".format(VAR_6))\n", "VAR_8 = VAR_7.json()\n", "VAR_9 = VAR_8['images'][0]['startdate']\n", "VAR_10 = VAR_8['images'][0]['urlbase']\n", "VAR_11 = VAR_8['images'][0]['url']\n", "VAR_12 = VAR_8['images'][0]['copyright']\n", "VAR_4.execute(\n \"\"\"\n select * from wallpapers\n where image_date='{}'\n \"\"\"\n .format(VAR_9))\n", "if VAR_4.fetchone() == None:\n", "VAR_4.execute('string'.format(VAR_9, VAR_10, VAR_12))\n", "VAR_13 = os.path.join(VAR_2, '{}.jpg'.format(VAR_9))\n", "print('## Inserted image {} to database ##'.format(VAR_9))\n", "if not os.path.isfile(VAR_13):\n", "VAR_14 = 'https://www.bing.com{}_{}x{}.jpg'.format(VAR_10, resolution_width,\n resolution_height)\n", "VAR_5 += 1\n", "print(\"## Downloading image from '{}'\".format(VAR_14))\n", "VAR_15 = requests.get(VAR_14)\n", "if VAR_15.status_code != requests.codes.ok:\n", "print(\"Failed to get url '{}'\".format(VAR_14))\n", "VAR_16 = Image.open(BytesIO(VAR_15.content))\n", "VAR_16.save(VAR_13)\n", "print('## Downloaded image {} ##'.format(VAR_13))\n" ]
[ "def main():...\n", "if len(sys.argv) > 1:\n", "NUM_IMAGES_TO_GET = int(sys.argv[1])\n", "if sys.version_info.major < 3:\n", "print('This script only runs in python3')\n", "data_dir = './data'\n", "return\n", "if not os.path.isdir(data_dir):\n", "os.makedirs(data_dir)\n", "image_dir = os.path.join(data_dir, '{}_{}'.format(resolution_width,\n resolution_height))\n", "if not os.path.isdir(data_dir):\n", "if not os.path.isdir(image_dir):\n", "print(\"Failed to create data path '{}'\".format(data_dir))\n", "os.makedirs(image_dir)\n", "conn = sqlite3.connect('./data/data.db')\n", "return\n", "if not os.path.isdir(image_dir):\n", "c = conn.cursor()\n", "print(\"Failed to create image path '{}'\".format(image_dir))\n", "c.execute(\n \"\"\"\n select name from sqlite_master\n where type='table' and name='wallpapers'\n \"\"\"\n )\n", "return\n", "if c.fetchone() == None:\n", "c.execute(\n \"\"\"\n create table wallpapers (\n id integer primary key autoincrement not null,\n image_date text not null,\n url_base text not null,\n copyright text not null)\n \"\"\"\n )\n", "idx = 0\n", "while idx <= NUM_IMAGES_TO_GET:\n", "list_url = (\n 'https://www.bing.com/HPImageArchive.aspx?format=js&idx={}&n=1&mkt=en-US'\n .format(idx))\n", "conn.commit()\n", "print(\"Getting iamge list from '{}'\".format(list_url))\n", "c.close()\n", "r = requests.get(list_url)\n", "conn.close()\n", "if r.status_code != requests.codes.ok:\n", "print(\"Failed to get url '{}'\".format(list_url))\n", "j = r.json()\n", "image_date = j['images'][0]['startdate']\n", "url_base = j['images'][0]['urlbase']\n", "url = j['images'][0]['url']\n", "copyright = j['images'][0]['copyright']\n", "c.execute(\n \"\"\"\n select * from wallpapers\n where image_date='{}'\n \"\"\"\n .format(image_date))\n", "if c.fetchone() == None:\n", "c.execute(\n \"\"\"\n insert into wallpapers (image_date, url_base, copyright)\n values ('{}', '{}', '{}')\n \"\"\"\n .format(image_date, url_base, copyright))\n", "image_path = os.path.join(image_dir, '{}.jpg'.format(image_date))\n", "print('## Inserted image {} to database ##'.format(image_date))\n", "if not os.path.isfile(image_path):\n", "image_url = 'https://www.bing.com{}_{}x{}.jpg'.format(url_base,\n resolution_width, resolution_height)\n", "idx += 1\n", "print(\"## Downloading image from '{}'\".format(image_url))\n", "r_image = requests.get(image_url)\n", "if r_image.status_code != requests.codes.ok:\n", "print(\"Failed to get url '{}'\".format(image_url))\n", "image = Image.open(BytesIO(r_image.content))\n", "image.save(image_path)\n", "print('## Downloaded image {} ##'.format(image_path))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Return'", "Condition", "Expr'", "Assign'", "Condition", "Condition", "Expr'", "Expr'", "Assign'", "Return'", "Condition", "Assign'", "Expr'", "Expr'", "Return'", "Condition", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Condition", "Expr'", "Assign'", "Expr'", "Condition", "Assign'", "AugAssign'", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_7(self, VAR_5, **VAR_6):...\n", "self.render('app.html', VAR_2={})\n" ]
[ "def write_error(self, error, **kargs):...\n", "self.render('app.html', page_json={})\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "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" ]
[ "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 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_5(self, VAR_5, VAR_4, VAR_7):...\n", "\"\"\"docstring\"\"\"\n", "VAR_3 = '/camefrom/'\n", "VAR_25 = c.get(VAR_5)\n", "VAR_10 = VAR_25.headers['Set-Cookie']\n", "VAR_16 = VAR_32._session.token\n", "VAR_28 = auth_response(VAR_16, VAR_4)\n", "VAR_23 = OutstandingQueriesCache(VAR_32)\n", "VAR_23.set(VAR_16, VAR_3)\n", "VAR_25 = self.app.dispatch_request()\n", "self.assertEquals(VAR_25.status_code, 302)\n", "self.assertEquals(VAR_25.location, VAR_3)\n", "VAR_7()\n" ]
[ "def acs(self, url, eppn, check_fn):...\n", "\"\"\"docstring\"\"\"\n", "came_from = '/camefrom/'\n", "resp = c.get(url)\n", "cookie = resp.headers['Set-Cookie']\n", "token = session._session.token\n", "authr = auth_response(token, eppn)\n", "oq_cache = OutstandingQueriesCache(session)\n", "oq_cache.set(token, came_from)\n", "resp = self.app.dispatch_request()\n", "self.assertEquals(resp.status_code, 302)\n", "self.assertEquals(resp.location, came_from)\n", "check_fn()\n" ]
[ 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "async def FUNC_1(self, VAR_2: str) ->None:...\n", "VAR_7 = await as_future(session.query(database.Paste).filter(database.Paste\n .paste_id == VAR_2).first)\n", "if not VAR_7:\n", "self.set_status(404)\n", "self.set_header('Content-Type', 'text/plain; charset=utf-8')\n", "self.render('404.html', pagetitle='404')\n", "self.write(VAR_7.raw)\n", "return\n" ]
[ "async def get(self, paste_id: str) ->None:...\n", "paste = await as_future(session.query(database.Paste).filter(database.Paste\n .paste_id == paste_id).first)\n", "if not paste:\n", "self.set_status(404)\n", "self.set_header('Content-Type', 'text/plain; charset=utf-8')\n", "self.render('404.html', pagetitle='404')\n", "self.write(paste.raw)\n", "return\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "AsyncFunctionDef'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_23(self, VAR_12=False):...\n", "if self.DiagnosticsForCurrentFileReady():\n", "VAR_22 = self._latest_file_parse_request.Response()\n", "return []\n", "self._latest_file_parse_request = None\n", "if VAR_12:\n", "return vimsupport.ConvertDiagnosticsToQfList(VAR_22)\n", "return VAR_22\n" ]
[ "def GetDiagnosticsFromStoredRequest(self, qflist_format=False):...\n", "if self.DiagnosticsForCurrentFileReady():\n", "diagnostics = self._latest_file_parse_request.Response()\n", "return []\n", "self._latest_file_parse_request = None\n", "if qflist_format:\n", "return vimsupport.ConvertDiagnosticsToQfList(diagnostics)\n", "return diagnostics\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Return'", "Assign'", "Condition", "Return'", "Return'" ]
[ "def __str__(self):...\n", "return self.txt\n" ]
[ "def __str__(self):...\n", "return self.txt\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_3():...\n", "def FUNC_12():...\n", "VAR_18 = requests.get(FUNC_2('healthy'))\n", "VAR_18.raise_for_status()\n", "return VAR_18.json()\n" ]
[ "def _CheckServerIsHealthyWithCache():...\n", "def _ServerIsHealthy():...\n", "response = requests.get(_BuildUri('healthy'))\n", "response.raise_for_status()\n", "return response.json()\n" ]
[ 0, 0, 7, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_1(self, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_4 = '/api/keys'\n", "VAR_5 = {'id': '[email protected]', 'public': VAR_3}\n", "VAR_6 = self.client.post(VAR_4, json.dumps(VAR_5), content_type=\n 'application/json')\n", "self.assertEqual(VAR_6.status_code, 201)\n", "VAR_7 = VAR_6.data['id']\n", "VAR_6 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_6.status_code, 200)\n", "self.assertEqual(len(VAR_6.data['results']), 1)\n", "VAR_4 = '/api/keys/{key_id}'.format(**locals())\n", "VAR_6 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_6.status_code, 200)\n", "self.assertEqual(VAR_5['id'], VAR_6.data['id'])\n", "self.assertEqual(VAR_5['public'], VAR_6.data['public'])\n", "VAR_6 = self.client.delete(VAR_4)\n", "self.assertEqual(VAR_6.status_code, 204)\n" ]
[ "def _check_key(self, pubkey):...\n", "\"\"\"docstring\"\"\"\n", "url = '/api/keys'\n", "body = {'id': '[email protected]', 'public': pubkey}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "key_id = response.data['id']\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 1)\n", "url = '/api/keys/{key_id}'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(body['id'], response.data['id'])\n", "self.assertEqual(body['public'], response.data['public'])\n", "response = self.client.delete(url)\n", "self.assertEqual(response.status_code, 204)\n" ]
[ 0, 0, 0, 0, 5, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 5, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_8(self, VAR_12=False):...\n", "VAR_86 = self.rules\n", "if VAR_12:\n", "VAR_86 = filterfalse(Rule.has_wildcards, VAR_86)\n", "for VAR_13 in VAR_86:\n", "logger.rule_info(VAR_10=rule.name, docstring=rule.docstring)\n" ]
[ "def list_rules(self, only_targets=False):...\n", "rules = self.rules\n", "if only_targets:\n", "rules = filterfalse(Rule.has_wildcards, rules)\n", "for rule in rules:\n", "logger.rule_info(name=rule.name, docstring=rule.docstring)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "For", "Docstring" ]
[ "@property...\n", "if self._hosts is None:\n", "self._hosts = set(self.hosts)\n", "return self._hosts\n" ]
[ "@property...\n", "if self._hosts is None:\n", "self._hosts = set(self.hosts)\n", "return self._hosts\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Condition", "Assign'", "Return'" ]
[ "def FUNC_5(VAR_3, VAR_10, VAR_2):...\n", "if '%(key)s' in VAR_3:\n", "VAR_3 = VAR_3.replace('%(key)s', VAR_10)\n", "if '%s' in VAR_3:\n", "VAR_3 = VAR_3.replace('%s', (VAR_2 or '') + '%')\n", "return VAR_3\n" ]
[ "def scrub_custom_query(query, key, txt):...\n", "if '%(key)s' in query:\n", "query = query.replace('%(key)s', key)\n", "if '%s' in query:\n", "query = query.replace('%s', (txt or '') + '%')\n", "return query\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Condition", "Assign'", "Return'" ]
[ "def FUNC_6(self, VAR_3):...\n", "if VAR_3.name not in self.host_names:\n", "self.hosts.append(VAR_3)\n", "self._hosts.add(VAR_3.name)\n", "VAR_3.add_group(self)\n", "self.clear_hosts_cache()\n" ]
[ "def add_host(self, host):...\n", "if host.name not in self.host_names:\n", "self.hosts.append(host)\n", "self._hosts.add(host.name)\n", "host.add_group(self)\n", "self.clear_hosts_cache()\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def __call__(self, VAR_11):...\n", "VAR_15 = []\n", "if self.param:\n", "for p in utils.tup(self.param):\n", "return self.run(*VAR_15)\n", "if self.post and VAR_102.post.get(p):\n", "VAR_33 = VAR_102.post[p]\n", "if self.get and VAR_102.get.get(p):\n", "VAR_15.append(VAR_33)\n", "VAR_33 = VAR_102.get[p]\n", "if self.url and VAR_11.get(p):\n", "VAR_33 = VAR_11[p]\n", "VAR_33 = self.default\n" ]
[ "def __call__(self, url):...\n", "a = []\n", "if self.param:\n", "for p in utils.tup(self.param):\n", "return self.run(*a)\n", "if self.post and request.post.get(p):\n", "val = request.post[p]\n", "if self.get and request.get.get(p):\n", "a.append(val)\n", "val = request.get[p]\n", "if self.url and url.get(p):\n", "val = url[p]\n", "val = self.default\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "For", "Return'", "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_7(VAR_6, VAR_5=None):...\n", "VAR_46 = VAR_5.keys() if VAR_5 else []\n", "VAR_47 = list(FUNC_0(VAR_6=academic_year).filter(parent__isnull=False).\n filter(Q(child_leaf__isnull=False) | Q(child_branch__isnull=False)).\n select_related('education_group_year__education_group_type').values(\n 'parent', 'child_branch', 'child_leaf', *VAR_46))\n", "VAR_48 = {}\n", "for group_element_year in VAR_47:\n", "VAR_57 = FUNC_8(VAR_7=group_element_year['child_branch'], VAR_8=\n group_element_year['child_leaf'])\n", "return VAR_48\n", "VAR_48.setdefault(VAR_57, []).append(group_element_year)\n" ]
[ "def _build_parent_list_by_education_group_year_id(academic_year, filters=None):...\n", "columns_needed_for_filters = filters.keys() if filters else []\n", "group_elements = list(search(academic_year=academic_year).filter(\n parent__isnull=False).filter(Q(child_leaf__isnull=False) | Q(\n child_branch__isnull=False)).select_related(\n 'education_group_year__education_group_type').values('parent',\n 'child_branch', 'child_leaf', *columns_needed_for_filters))\n", "result = {}\n", "for group_element_year in group_elements:\n", "key = _build_child_key(child_branch=group_element_year['child_branch'],\n child_leaf=group_element_year['child_leaf'])\n", "return result\n", "result.setdefault(key, []).append(group_element_year)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Return'", "Expr'" ]
[ "@VAR_0.route('/logout')...\n", "VAR_19.pop('username', None)\n", "return redirect(url_for('index'))\n" ]
[ "@app.route('/logout')...\n", "session.pop('username', None)\n", "return redirect(url_for('index'))\n" ]
[ 0, 0, 0 ]
[ "Condition", "Expr'", "Return'" ]
[ "def FUNC_0():...\n", "\"\"\"docstring\"\"\"\n", "VAR_3 = {'TEST_STACK': str(CLASS_0.DEFAULT_TEST_ID), 'TEST_APP': \n 'gcpsmoketest' + CLASS_0.DEFAULT_TEST_ID}\n", "return st.ScenarioTestRunner.main(CLASS_0, default_binding_overrides=\n defaults, test_case_list=[GoogleSmokeTest])\n" ]
[ "def main():...\n", "\"\"\"docstring\"\"\"\n", "defaults = {'TEST_STACK': str(GoogleSmokeTestScenario.DEFAULT_TEST_ID),\n 'TEST_APP': 'gcpsmoketest' + GoogleSmokeTestScenario.DEFAULT_TEST_ID}\n", "return st.ScenarioTestRunner.main(GoogleSmokeTestScenario,\n default_binding_overrides=defaults, test_case_list=[GoogleSmokeTest])\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_13(self, VAR_2):...\n", "return redirect(self._passphrase_next_url(VAR_2))\n" ]
[ "def _redirect_from_passphrase(self, request):...\n", "return redirect(self._passphrase_next_url(request))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_8(self, VAR_15):...\n", "VAR_32 = 1.0\n", "VAR_33 = 'GB'\n", "if VAR_15.endswith('MB'):\n", "VAR_32 = 1.0 / 1024\n", "if VAR_15.endswith('TB'):\n", "VAR_33 = 'MB'\n", "VAR_32 = 1.0 * 1024\n", "return VAR_32 * float(VAR_15.partition(VAR_33)[0])\n", "VAR_33 = 'TB'\n" ]
[ "def _get_space_in_gb(self, val):...\n", "scale = 1.0\n", "part = 'GB'\n", "if val.endswith('MB'):\n", "scale = 1.0 / 1024\n", "if val.endswith('TB'):\n", "part = 'MB'\n", "scale = 1.0 * 1024\n", "return scale * float(val.partition(part)[0])\n", "part = 'TB'\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Return'", "Assign'" ]
[ "from osv import fields, osv\n", "from tools.translate import _\n", "VAR_0 = 'product.product'\n", "def FUNC_0(self, VAR_1, VAR_2, VAR_3, VAR_4=None):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_4 is None:\n", "VAR_4 = {}\n", "VAR_17 = self.pool.get('product.product').browse(VAR_1, VAR_2, VAR_3, VAR_4\n =context)\n", "VAR_18 = (VAR_17.property_stock_account_input and VAR_17.\n property_stock_account_input.id or False)\n", "if not VAR_18:\n", "VAR_18 = (VAR_17.categ_id.property_stock_account_input_categ and VAR_17.\n categ_id.property_stock_account_input_categ.id or False)\n", "VAR_19 = (VAR_17.property_stock_account_output and VAR_17.\n property_stock_account_output.id or False)\n", "if not VAR_19:\n", "VAR_19 = (VAR_17.categ_id.property_stock_account_output_categ and VAR_17.\n categ_id.property_stock_account_output_categ.id or False)\n", "VAR_20 = (VAR_17.categ_id.property_stock_journal and VAR_17.categ_id.\n property_stock_journal.id or False)\n", "VAR_21 = (VAR_17.categ_id.property_stock_variation and VAR_17.categ_id.\n property_stock_variation.id or False)\n", "return {'stock_account_input': VAR_18, 'stock_account_output': VAR_19,\n 'stock_journal': VAR_20, 'property_stock_variation': VAR_21}\n" ]
[ "from osv import fields, osv\n", "from tools.translate import _\n", "_inherit = 'product.product'\n", "def get_product_accounts(self, cr, uid, product_id, context=None):...\n", "\"\"\"docstring\"\"\"\n", "if context is None:\n", "context = {}\n", "product_obj = self.pool.get('product.product').browse(cr, uid, product_id,\n context=context)\n", "stock_input_acc = (product_obj.property_stock_account_input and product_obj\n .property_stock_account_input.id or False)\n", "if not stock_input_acc:\n", "stock_input_acc = (product_obj.categ_id.property_stock_account_input_categ and\n product_obj.categ_id.property_stock_account_input_categ.id or False)\n", "stock_output_acc = (product_obj.property_stock_account_output and\n product_obj.property_stock_account_output.id or False)\n", "if not stock_output_acc:\n", "stock_output_acc = (product_obj.categ_id.\n property_stock_account_output_categ and product_obj.categ_id.\n property_stock_account_output_categ.id or False)\n", "journal_id = (product_obj.categ_id.property_stock_journal and product_obj.\n categ_id.property_stock_journal.id or False)\n", "account_variation = (product_obj.categ_id.property_stock_variation and\n product_obj.categ_id.property_stock_variation.id or False)\n", "return {'stock_account_input': stock_input_acc, 'stock_account_output':\n stock_output_acc, 'stock_journal': journal_id,\n 'property_stock_variation': account_variation}\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "Assign'", "FunctionDef'", "Docstring", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_5(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_16 = self.describe()\n", "self.start_time = time.time()\n", "self.response = self.browser.do_request(self.url, self.data, self.files)\n", "self.exception_data = traceback.format_exc()\n", "self.outcome = None\n", "self.stop_time = time.time()\n", "self.response.raise_for_status()\n", "self.outcome = CLASS_1.OUTCOME_ERROR\n", "VAR_17 = None\n", "self.duration = self.stop_time - self.start_time\n", "self.status_code = self.response.status_code\n", "VAR_17 = self.test_success()\n", "self.exception_data = traceback.format_exc()\n", "if self.outcome is None:\n", "self.res_data = self.response.text\n", "self.outcome = CLASS_1.OUTCOME_ERROR\n", "if VAR_17 is None:\n", "print(\"\"\"Request '%s' terminated with an exception: %s\n%s\"\"\" % (VAR_16,\n repr(exc), self.exception_data), file=sys.stderr)\n", "if len(self.response.history) > 0:\n", "if VAR_0:\n", "if VAR_17:\n", "self.redirected_to = self.response.url\n", "print(\"Could not determine status for request '%s'\" % VAR_16, file=sys.stderr)\n", "self.outcome = CLASS_1.OUTCOME_UNDECIDED\n", "if VAR_0:\n", "if not VAR_17:\n", "print(\"Request '%s' successfully completed in %.3fs\" % (VAR_16, self.\n duration), file=sys.stderr)\n", "self.outcome = CLASS_1.OUTCOME_SUCCESS\n", "if VAR_0:\n", "print(\"Request '%s' failed\" % VAR_16, file=sys.stderr)\n", "self.outcome = CLASS_1.OUTCOME_FAILURE\n", "if self.exception_data is not None:\n", "print(self.exception_data, file=sys.stderr)\n" ]
[ "def _execute(self):...\n", "\"\"\"docstring\"\"\"\n", "description = self.describe()\n", "self.start_time = time.time()\n", "self.response = self.browser.do_request(self.url, self.data, self.files)\n", "self.exception_data = traceback.format_exc()\n", "self.outcome = None\n", "self.stop_time = time.time()\n", "self.response.raise_for_status()\n", "self.outcome = GenericRequest.OUTCOME_ERROR\n", "success = None\n", "self.duration = self.stop_time - self.start_time\n", "self.status_code = self.response.status_code\n", "success = self.test_success()\n", "self.exception_data = traceback.format_exc()\n", "if self.outcome is None:\n", "self.res_data = self.response.text\n", "self.outcome = GenericRequest.OUTCOME_ERROR\n", "if success is None:\n", "print(\"\"\"Request '%s' terminated with an exception: %s\n%s\"\"\" % (description,\n repr(exc), self.exception_data), file=sys.stderr)\n", "if len(self.response.history) > 0:\n", "if debug:\n", "if success:\n", "self.redirected_to = self.response.url\n", "print(\"Could not determine status for request '%s'\" % description, file=sys\n .stderr)\n", "self.outcome = GenericRequest.OUTCOME_UNDECIDED\n", "if debug:\n", "if not success:\n", "print(\"Request '%s' successfully completed in %.3fs\" % (description, self.\n duration), file=sys.stderr)\n", "self.outcome = GenericRequest.OUTCOME_SUCCESS\n", "if debug:\n", "print(\"Request '%s' failed\" % description, file=sys.stderr)\n", "self.outcome = GenericRequest.OUTCOME_FAILURE\n", "if self.exception_data is not None:\n", "print(self.exception_data, file=sys.stderr)\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 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Condition", "Condition", "Assign'", "Expr'", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Expr'" ]
[ "def FUNC_2(VAR_87):...\n", "return map(self._rules.__getitem__, filter(self.is_rule, VAR_87))\n" ]
[ "def rules(items):...\n", "return map(self._rules.__getitem__, filter(self.is_rule, items))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@utils.synchronized('3par', external=True)...\n", "self.common.client_login()\n", "VAR_18 = self.common.create_volume(VAR_6)\n", "self.common.client_logout()\n", "return {'metadata': VAR_18}\n" ]
[ "@utils.synchronized('3par', external=True)...\n", "self.common.client_login()\n", "metadata = self.common.create_volume(volume)\n", "self.common.client_logout()\n", "return {'metadata': metadata}\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_6(self, VAR_11, VAR_52=None):...\n", "if VAR_52 is None and not isinstance(VAR_101.site, FakeSubreddit):\n", "VAR_52 = VAR_101.site\n", "if VAR_52:\n", "if not VAR_11:\n", "VAR_52 = None\n", "VAR_52 = Subreddit._by_name(VAR_52)\n", "VAR_101.errors.add(errors.SUBREDDIT_NOEXIST)\n", "return self.error(errors.NO_URL)\n", "VAR_11 = utils.sanitize_url(VAR_11)\n", "VAR_52 = None\n", "if VAR_11 == 'self':\n", "return VAR_11\n", "if VAR_11:\n", "VAR_108 = Link._by_url(VAR_11, VAR_52)\n", "return VAR_11\n", "return self.error(errors.BAD_URL)\n", "self.error(errors.ALREADY_SUB)\n", "return utils.tup(VAR_108)\n" ]
[ "def run(self, url, sr=None):...\n", "if sr is None and not isinstance(c.site, FakeSubreddit):\n", "sr = c.site\n", "if sr:\n", "if not url:\n", "sr = None\n", "sr = Subreddit._by_name(sr)\n", "c.errors.add(errors.SUBREDDIT_NOEXIST)\n", "return self.error(errors.NO_URL)\n", "url = utils.sanitize_url(url)\n", "sr = None\n", "if url == 'self':\n", "return url\n", "if url:\n", "l = Link._by_url(url, sr)\n", "return url\n", "return self.error(errors.BAD_URL)\n", "self.error(errors.ALREADY_SUB)\n", "return utils.tup(l)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Expr'", "Return'", "Assign'", "Assign'", "Condition", "Return'", "Condition", "Assign'", "Return'", "Return'", "Expr'", "Return'" ]
[ "@classmethod...\n", "\"\"\"docstring\"\"\"\n", "if VAR_21.USE_OPENID:\n", "VAR_52 = FUNC_3\n", "VAR_52 = FUNC_2\n", "return FUNC_4, VAR_52, FUNC_5\n" ]
[ "@classmethod...\n", "\"\"\"docstring\"\"\"\n", "if conf.USE_OPENID:\n", "cookie_auth = openid_cookie_authentication\n", "cookie_auth = gae_cookie_authentication\n", "return oauth_authentication, cookie_auth, service_to_service_authentication\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_6(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_11 = []\n", "for user in self.company.employees:\n", "VAR_12 = 'view.%s' % self.type_, 'view.file', 'add.file', 'edit.file'\n", "return VAR_11\n", "if self.status in ('draft', 'invalid'):\n", "VAR_12 += ('edit.%s' % self.type_, 'wait.%s' % self.type_, 'delete.%s' %\n self.type_, 'draft.%s' % self.type_)\n", "if self.status in ('wait',):\n", "VAR_12 += 'draft.%s' % self.type_,\n", "VAR_11.append((Allow, user.login, VAR_12))\n" ]
[ "def _get_user_status_acl(self):...\n", "\"\"\"docstring\"\"\"\n", "acl = []\n", "for user in self.company.employees:\n", "perms = 'view.%s' % self.type_, 'view.file', 'add.file', 'edit.file'\n", "return acl\n", "if self.status in ('draft', 'invalid'):\n", "perms += ('edit.%s' % self.type_, 'wait.%s' % self.type_, 'delete.%s' %\n self.type_, 'draft.%s' % self.type_)\n", "if self.status in ('wait',):\n", "perms += 'draft.%s' % self.type_,\n", "acl.append((Allow, user.login, perms))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "For", "Assign'", "Return'", "Condition", "AugAssign'", "Condition", "AugAssign'", "Expr'" ]
[ "def FUNC_58(self):...\n", "VAR_2 = {'SEVERITY': {}, 'CONFIDENCE': {}}\n", "self.check_example('nosec.py', VAR_2)\n" ]
[ "def test_nosec(self):...\n", "expect = {'SEVERITY': {}, 'CONFIDENCE': {}}\n", "self.check_example('nosec.py', expect)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_1(self):...\n", "return 'check user_test %s' % self.user_test_id\n" ]
[ "def describe(self):...\n", "return 'check user_test %s' % self.user_test_id\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_9(self):...\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_4 = '/api/apps/{app_id}/builds'.format(**locals())\n", "VAR_8 = {'image': 'autotest/example', 'sha': 'a' * 40, 'procfile': json.\n dumps({'web': 'node server.js', 'worker': 'node worker.js'})}\n", "VAR_5 = self.client.post(VAR_4, json.dumps(VAR_8), content_type=\n 'application/json')\n", "self.assertEqual(VAR_5.status_code, 201)\n", "VAR_4 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_8 = {'web': 1}\n", "VAR_5 = self.client.post(VAR_4, json.dumps(VAR_8), content_type=\n 'application/json')\n", "self.assertEqual(VAR_5.status_code, 204)\n", "VAR_4 = '/api/apps/{app_id}/containers'.format(**locals())\n", "VAR_5 = self.client.get(VAR_4)\n", "self.assertEqual(VAR_5.status_code, 200)\n", "self.assertEqual(len(VAR_5.data['results']), 1)\n", "VAR_10 = VAR_5.data['results'][0]['uuid']\n", "VAR_11 = Container.objects.get(VAR_10=uuid)\n", "self.assertNotIn('{c_type}', VAR_11._command)\n" ]
[ "def test_container_command_format(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}/scale'.format(**locals())\n", "body = {'web': 1}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\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", "uuid = response.data['results'][0]['uuid']\n", "container = Container.objects.get(uuid=uuid)\n", "self.assertNotIn('{c_type}', container._command)\n" ]
[ 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'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_3(self, VAR_6):...\n", "\"\"\"docstring\"\"\"\n", "VAR_7 = logging.getLogger(__name__)\n", "VAR_7.debug('Added subscriber')\n", "self.subscribed_queues.append(VAR_6)\n" ]
[ "def add_subscriber(self, queue):...\n", "\"\"\"docstring\"\"\"\n", "logger = logging.getLogger(__name__)\n", "logger.debug('Added subscriber')\n", "self.subscribed_queues.append(queue)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Expr'" ]
[ "@staticmethod...\n", "return CLASS_0._TalkToHandlerAsync(VAR_9, VAR_7, 'POST', VAR_10)\n" ]
[ "@staticmethod...\n", "return BaseRequest._TalkToHandlerAsync(data, handler, 'POST', timeout)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "@auth.require(acl.is_bot)...\n", "self.response.headers['Content-Type'] = 'text/x-python'\n", "self.response.headers['Content-Disposition'\n ] = 'attachment; filename=\"swarming_bot_bootstrap.py\"'\n", "self.response.out.write(bot_code.get_bootstrap(self.request.host_url).content)\n" ]
[ "@auth.require(acl.is_bot)...\n", "self.response.headers['Content-Type'] = 'text/x-python'\n", "self.response.headers['Content-Disposition'\n ] = 'attachment; filename=\"swarming_bot_bootstrap.py\"'\n", "self.response.out.write(bot_code.get_bootstrap(self.request.host_url).content)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_8(self):...\n", "VAR_12 = traversal.TraversalPath.parse('level2s[b].level3s[4]')\n", "self.assertRaises(IndexError, VAR_12.get_value, VAR_0)\n", "VAR_12 = traversal.TraversalPath.parse('level2s[b].level3s_sd[1]')\n", "self.assertRaises(KeyError, VAR_12.get_value, VAR_0)\n" ]
[ "def test_invalid_path(self):...\n", "path = traversal.TraversalPath.parse('level2s[b].level3s[4]')\n", "self.assertRaises(IndexError, path.get_value, TEST_STRUCTURE)\n", "path = traversal.TraversalPath.parse('level2s[b].level3s_sd[1]')\n", "self.assertRaises(KeyError, path.get_value, TEST_STRUCTURE)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_0(VAR_6):...\n", "\"\"\"docstring\"\"\"\n", "FUNC_5(VAR_6)\n", "VAR_8 = FUNC_6(VAR_6)\n", "VAR_15 = FUNC_7(request.data, VAR_8)\n", "if re.search('[^a-zA-Z0-9]', VAR_15['key']):\n", "VAR_16 = FUNC_9({'key': VAR_22}, VAR_0, VAR_8)\n", "VAR_22 = open('keys/%s/%s.key' % (VAR_6, VAR_15['key']), 'r').read()\n", "return VAR_16\n" ]
[ "def getKey(client):...\n", "\"\"\"docstring\"\"\"\n", "validateClient(client)\n", "client_pub_key = loadClientRSAKey(client)\n", "token_data = decodeRequestToken(request.data, client_pub_key)\n", "if re.search('[^a-zA-Z0-9]', token_data['key']):\n", "keytoken = packJWT({'key': requested_key}, SERVER_JWT_PRIVATE_KEY,\n client_pub_key)\n", "requested_key = open('keys/%s/%s.key' % (client, token_data['key']), 'r').read(\n )\n", "return keytoken\n" ]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_12(self, VAR_9, VAR_10=None, VAR_13=None, VAR_14=None, **VAR_7):...\n", "if self.closed:\n", "if self._adapter is not None:\n", "assert self._session is None\n", "VAR_1 = 'localhost', self._addr.port\n", "self._run_server_ex = None\n", "def FUNC_15():...\n", "self._session = self.SESSION.create_server(VAR_1, **kwargs)\n", "self._run_server_ex = traceback.format_exc()\n", "VAR_19 = new_hidden_thread(target=run, name='test.client')\n", "VAR_19.start()\n", "def FUNC_16():...\n", "VAR_19.join(timeout=self._connecttimeout)\n", "if VAR_19.is_alive():\n", "warnings.warn('timed out waiting for connection')\n", "if self._session is None:\n", "VAR_22 = 'unable to connect after {} secs'.format(self._connecttimeout)\n", "self._launch(VAR_9, VAR_10=script, VAR_11=wait, VAR_12=False, VAR_13=env,\n VAR_14=cwd)\n", "if self._run_server_ex is None:\n", "return self._adapter, self._session\n", "VAR_22 = VAR_22 + os.linesep + self._run_server_ex\n" ]
[ "def host_local_debugger(self, argv, script=None, env=None, cwd=None, **kwargs):...\n", "if self.closed:\n", "if self._adapter is not None:\n", "assert self._session is None\n", "addr = 'localhost', self._addr.port\n", "self._run_server_ex = None\n", "def run():...\n", "self._session = self.SESSION.create_server(addr, **kwargs)\n", "self._run_server_ex = traceback.format_exc()\n", "t = new_hidden_thread(target=run, name='test.client')\n", "t.start()\n", "def wait():...\n", "t.join(timeout=self._connecttimeout)\n", "if t.is_alive():\n", "warnings.warn('timed out waiting for connection')\n", "if self._session is None:\n", "message = 'unable to connect after {} secs'.format(self._connecttimeout)\n", "self._launch(argv, script=script, wait_for_connect=wait, detachable=False,\n env=env, cwd=cwd)\n", "if self._run_server_ex is None:\n", "return self._adapter, self._session\n", "message = message + os.linesep + self._run_server_ex\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Condition", "Assert'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "FunctionDef'", "Expr'", "Condition", "Expr'", "Condition", "Assign'", "Expr'", "Condition", "Return'", "Assign'" ]
[ "@api.multi...\n", "\"\"\"docstring\"\"\"\n", "for VAR_12 in self:\n", "VAR_31 = self.closest_invoice_line(VAR_12, datetime.today().strftime(\n '%Y-%m-%d'))\n", "VAR_32 = 0\n", "if VAR_31 and VAR_31.price_unit:\n", "VAR_32 = VAR_31.price_unit\n", "VAR_12.system_cost = VAR_32\n", "VAR_32 *= 1 - VAR_31.discount / 100\n", "VAR_0.info('Setting invoice cost $ %d - %s' % (VAR_32, VAR_12.default_code))\n", "VAR_32 *= 1 + VAR_31.invoice_discount\n", "if VAR_31.invoice_id.partner_id.ref == 'BULONFER':\n", "VAR_32 *= 1 - 0.05\n" ]
[ "@api.multi...\n", "\"\"\"docstring\"\"\"\n", "for prod in self:\n", "invoice_line = self.closest_invoice_line(prod, datetime.today().strftime(\n '%Y-%m-%d'))\n", "invoice_price = 0\n", "if invoice_line and invoice_line.price_unit:\n", "invoice_price = invoice_line.price_unit\n", "prod.system_cost = invoice_price\n", "invoice_price *= 1 - invoice_line.discount / 100\n", "_logger.info('Setting invoice cost $ %d - %s' % (invoice_price, prod.\n default_code))\n", "invoice_price *= 1 + invoice_line.invoice_discount\n", "if invoice_line.invoice_id.partner_id.ref == 'BULONFER':\n", "invoice_price *= 1 - 0.05\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "For", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "AugAssign'", "Expr'", "AugAssign'", "Condition", "AugAssign'" ]
[ "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_9(self, VAR_14):...\n", "" ]
[ "def is_string(self, col_name):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_39(VAR_101):...\n", "VAR_101.input = VAR_69, VAR_70\n", "return VAR_101\n" ]
[ "def decorate(ruleinfo):...\n", "ruleinfo.input = paths, kwpaths\n", "return ruleinfo\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "@VAR_0.route('/table_detection')...\n", "return render_template('table_detection.html', wait=WAIT_AFTER_CRAWLING)\n" ]
[ "@app.route('/table_detection')...\n", "return render_template('table_detection.html', wait=WAIT_AFTER_CRAWLING)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_7(self, VAR_21, VAR_23=True):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_21 == '/':\n", "return self.fs\n", "VAR_55 = VAR_21.strip('/').split('/')\n", "VAR_22 = ''\n", "VAR_57 = self.fs\n", "for VAR_66 in VAR_55:\n", "if VAR_66 not in [x[VAR_1] for x in VAR_57[VAR_8]]:\n", "return VAR_57\n", "return False\n", "for x in VAR_57[VAR_8]:\n", "if x[VAR_1] == VAR_66:\n", "VAR_22 = '/'.join((VAR_22, VAR_66))\n", "if VAR_66 == VAR_55[-1] and VAR_23 == False:\n", "VAR_57 = x\n", "if x[VAR_2] == VAR_11:\n", "if x[VAR_9][0] == '/':\n", "VAR_57 = x\n", "VAR_57 = self.getfile(x[VAR_9], VAR_23=follow_symlinks)\n", "VAR_57 = self.getfile('/'.join((VAR_22, x[VAR_9])), VAR_23=follow_symlinks)\n", "if VAR_57 == False:\n", "return False\n" ]
[ "def getfile(self, path, follow_symlinks=True):...\n", "\"\"\"docstring\"\"\"\n", "if path == '/':\n", "return self.fs\n", "pieces = path.strip('/').split('/')\n", "cwd = ''\n", "p = self.fs\n", "for piece in pieces:\n", "if piece not in [x[A_NAME] for x in p[A_CONTENTS]]:\n", "return p\n", "return False\n", "for x in p[A_CONTENTS]:\n", "if x[A_NAME] == piece:\n", "cwd = '/'.join((cwd, piece))\n", "if piece == pieces[-1] and follow_symlinks == False:\n", "p = x\n", "if x[A_TYPE] == T_LINK:\n", "if x[A_TARGET][0] == '/':\n", "p = x\n", "p = self.getfile(x[A_TARGET], follow_symlinks=follow_symlinks)\n", "p = self.getfile('/'.join((cwd, x[A_TARGET])), follow_symlinks=follow_symlinks)\n", "if p == False:\n", "return False\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Assign'", "Assign'", "Assign'", "For", "For", "Return'", "Return'", "For", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Return'" ]