lines
listlengths
1
444
raw_lines
listlengths
1
444
label
listlengths
1
444
type
listlengths
1
444
[ "def FUNC_9(self, VAR_12, VAR_13):...\n", "if VAR_12:\n", "VAR_35 = {'active_model': self._name, 'active_id': self.id, 'active_ids':\n self.ids}\n", "if VAR_13:\n", "VAR_12.with_delay().run_async(VAR_35)\n", "VAR_12.with_context(VAR_35).run()\n" ]
[ "def exec_action(self, action, async_action):...\n", "if action:\n", "context = {'active_model': self._name, 'active_id': self.id, 'active_ids':\n self.ids}\n", "if async_action:\n", "action.with_delay().run_async(context)\n", "action.with_context(context).run()\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_2(self, VAR_8):...\n", "\"\"\"docstring\"\"\"\n", "VAR_5 = {}\n", "VAR_5['clusterName'] = VAR_8\n", "VAR_5['searchDepth'] = '1'\n", "VAR_5['verbose'] = '0'\n", "VAR_18 = self._cliq_run_xml('getClusterInfo', VAR_5)\n", "return VAR_18\n" ]
[ "def _cliq_get_cluster_info(self, cluster_name):...\n", "\"\"\"docstring\"\"\"\n", "cliq_args = {}\n", "cliq_args['clusterName'] = cluster_name\n", "cliq_args['searchDepth'] = '1'\n", "cliq_args['verbose'] = '0'\n", "result_xml = self._cliq_run_xml('getClusterInfo', cliq_args)\n", "return result_xml\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "import os, sys, platform\n", "from os.path import join, dirname, abspath, basename\n", "import unittest\n", "def FUNC_0():...\n", "\"\"\"docstring\"\"\"\n", "import imp\n", "VAR_5 = [VAR_13[0] for VAR_13 in imp.get_suffixes() if VAR_13[-1] == imp.\n C_EXTENSION]\n", "VAR_6 = [('pyodbc%s' % ext) for ext in VAR_5]\n", "VAR_7 = '-%s.%s' % (sys.version_info[0], sys.version_info[1])\n", "VAR_8 = join(dirname(dirname(abspath(__file__))), 'build')\n", "for root, dirs, files in os.walk(VAR_8):\n", "for d in dirs[:]:\n", "print(\n 'Did not find the pyodbc library in the build directory. Will use an installed version.'\n )\n", "if not d.endswith(VAR_7):\n", "for VAR_2 in VAR_6:\n", "def FUNC_1(VAR_0):...\n", "dirs.remove(d)\n", "if VAR_2 in files:\n", "import pyodbc\n", "sys.path.insert(0, root)\n", "print('python: %s' % sys.version)\n", "return\n", "print('pyodbc: %s %s' % (pyodbc.version, os.path.abspath(pyodbc.__file__)))\n", "print('odbc: %s' % VAR_0.getinfo(pyodbc.SQL_ODBC_VER))\n", "print('driver: %s %s' % (VAR_0.getinfo(pyodbc.SQL_DRIVER_NAME), VAR_0.\n getinfo(pyodbc.SQL_DRIVER_VER)))\n", "print(' supports ODBC version %s' % VAR_0.getinfo(pyodbc.\n SQL_DRIVER_ODBC_VER))\n", "print('os: %s' % platform.system())\n", "print('unicode: Py_Unicode=%s SQLWCHAR=%s' % (pyodbc.UNICODE_SIZE, pyodbc.\n SQLWCHAR_SIZE))\n", "VAR_9 = VAR_0.cursor()\n", "for typename in ['VARCHAR', 'WVARCHAR', 'BINARY']:\n", "VAR_13 = getattr(pyodbc, 'SQL_' + typename)\n", "if platform.system() == 'Windows':\n", "VAR_9.getTypeInfo(VAR_13)\n", "print(' %s' % ' '.join([s for s in platform.win32_ver() if s]))\n", "def FUNC_2(VAR_1, VAR_2, *VAR_3):...\n", "VAR_14 = VAR_9.fetchone()\n", "\"\"\"docstring\"\"\"\n", "print('Max %s = %s' % (typename, VAR_14 and VAR_14[2] or '(not supported)'))\n", "if VAR_2:\n", "if not VAR_2.startswith('test_'):\n", "VAR_15 = [method for method in dir(VAR_1) if method.startswith('test_')]\n", "VAR_2 = 'test_%s' % VAR_2\n", "VAR_15 = [VAR_2]\n", "return unittest.TestSuite([VAR_1(VAR_2, *VAR_3) for VAR_2 in VAR_15])\n" ]
[ "import os, sys, platform\n", "from os.path import join, dirname, abspath, basename\n", "import unittest\n", "def add_to_path():...\n", "\"\"\"docstring\"\"\"\n", "import imp\n", "library_exts = [t[0] for t in imp.get_suffixes() if t[-1] == imp.C_EXTENSION]\n", "library_names = [('pyodbc%s' % ext) for ext in library_exts]\n", "dir_suffix = '-%s.%s' % (sys.version_info[0], sys.version_info[1])\n", "build = join(dirname(dirname(abspath(__file__))), 'build')\n", "for root, dirs, files in os.walk(build):\n", "for d in dirs[:]:\n", "print(\n 'Did not find the pyodbc library in the build directory. Will use an installed version.'\n )\n", "if not d.endswith(dir_suffix):\n", "for name in library_names:\n", "def print_library_info(cnxn):...\n", "dirs.remove(d)\n", "if name in files:\n", "import pyodbc\n", "sys.path.insert(0, root)\n", "print('python: %s' % sys.version)\n", "return\n", "print('pyodbc: %s %s' % (pyodbc.version, os.path.abspath(pyodbc.__file__)))\n", "print('odbc: %s' % cnxn.getinfo(pyodbc.SQL_ODBC_VER))\n", "print('driver: %s %s' % (cnxn.getinfo(pyodbc.SQL_DRIVER_NAME), cnxn.\n getinfo(pyodbc.SQL_DRIVER_VER)))\n", "print(' supports ODBC version %s' % cnxn.getinfo(pyodbc.\n SQL_DRIVER_ODBC_VER))\n", "print('os: %s' % platform.system())\n", "print('unicode: Py_Unicode=%s SQLWCHAR=%s' % (pyodbc.UNICODE_SIZE, pyodbc.\n SQLWCHAR_SIZE))\n", "cursor = cnxn.cursor()\n", "for typename in ['VARCHAR', 'WVARCHAR', 'BINARY']:\n", "t = getattr(pyodbc, 'SQL_' + typename)\n", "if platform.system() == 'Windows':\n", "cursor.getTypeInfo(t)\n", "print(' %s' % ' '.join([s for s in platform.win32_ver() if s]))\n", "def load_tests(testclass, name, *args):...\n", "row = cursor.fetchone()\n", "\"\"\"docstring\"\"\"\n", "print('Max %s = %s' % (typename, row and row[2] or '(not supported)'))\n", "if name:\n", "if not name.startswith('test_'):\n", "names = [method for method in dir(testclass) if method.startswith('test_')]\n", "name = 'test_%s' % name\n", "names = [name]\n", "return unittest.TestSuite([testclass(name, *args) for name in names])\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 ]
[ "Import'", "ImportFrom'", "Import'", "FunctionDef'", "Docstring", "Import'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "For", "Expr'", "Condition", "For", "FunctionDef'", "Expr'", "Condition", "Import'", "Expr'", "Expr'", "Return'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "For", "Assign'", "For", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Docstring", "Expr'", "Condition", "Condition", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_1(self, VAR_5):...\n", "VAR_16 = super().get_transform(VAR_5)\n", "if VAR_16:\n", "return VAR_16\n", "return CLASS_2(VAR_5)\n" ]
[ "def get_transform(self, name):...\n", "transform = super().get_transform(name)\n", "if transform:\n", "return transform\n", "return KeyTransformFactory(name)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_1(self):...\n", "VAR_0 = ExtractedText(doc_date='Wednesday, January 21, 2014', data_document\n =self.objects.doc, extraction_script=self.objects.script)\n", "self.assertRaises(ValidationError, VAR_0.clean())\n", "VAR_0 = ExtractedText(doc_date='January 1984', data_document=self.objects.\n doc, extraction_script=self.objects.script)\n", "VAR_0.clean()\n", "self.fail('clean() raised ExceptionType unexpectedly!')\n", "VAR_0 = ExtractedText(data_document=self.objects.doc, extraction_script=\n self.objects.script)\n", "VAR_0.clean()\n", "self.fail('clean() raised ExceptionType unexpectedly!')\n" ]
[ "def test_extracted_doc_date_validation(self):...\n", "text = ExtractedText(doc_date='Wednesday, January 21, 2014', data_document=\n self.objects.doc, extraction_script=self.objects.script)\n", "self.assertRaises(ValidationError, text.clean())\n", "text = ExtractedText(doc_date='January 1984', data_document=self.objects.\n doc, extraction_script=self.objects.script)\n", "text.clean()\n", "self.fail('clean() raised ExceptionType unexpectedly!')\n", "text = ExtractedText(data_document=self.objects.doc, extraction_script=self\n .objects.script)\n", "text.clean()\n", "self.fail('clean() raised ExceptionType unexpectedly!')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'" ]
[ "@utils.synchronized('3par', external=True)...\n", "self.common.client_login()\n", "self.common.delete_snapshot(VAR_8)\n", "self.common.client_logout()\n" ]
[ "@utils.synchronized('3par', external=True)...\n", "self.common.client_login()\n", "self.common.delete_snapshot(snapshot)\n", "self.common.client_logout()\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_2(self):...\n", "\"\"\"docstring\"\"\"\n", "while True:\n", "self.update_log_filenames()\n", "self.check_log_files_and_push_updates()\n", "time.sleep(1)\n" ]
[ "def run(self):...\n", "\"\"\"docstring\"\"\"\n", "while True:\n", "self.update_log_filenames()\n", "self.check_log_files_and_push_updates()\n", "time.sleep(1)\n" ]
[ 0, 0, 6, 0, 6, 6 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_1(VAR_2):...\n", "VAR_5 = socket.socket()\n", "return VAR_5.connect_ex(('127.0.0.1', VAR_2)) == 0\n", "VAR_5.close()\n" ]
[ "def test_port(port):...\n", "s = socket.socket()\n", "return s.connect_ex(('127.0.0.1', port)) == 0\n", "s.close()\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'", "Expr'" ]
[ "@handled_function...\n", "" ]
[ "@handled_function...\n", "" ]
[ 0, 0 ]
[ "Condition", "Condition" ]
[ "def FUNC_1():...\n", "from pyramid import session\n", "def FUNC_4(VAR_5, VAR_6='csrf_token', VAR_7=VAR_1, VAR_8=True):...\n", "VAR_10 = VAR_5.params.get(VAR_6, VAR_5.headers.get(VAR_7))\n", "if VAR_10 != VAR_5.session.get_csrf_token():\n", "if VAR_8:\n", "return True\n", "return False\n" ]
[ "def monkeypatch_pyramid_csrf_check():...\n", "from pyramid import session\n", "def check_csrf_token(request, token='csrf_token', header=HEADER_NAME,...\n", "supplied_token = request.params.get(token, request.headers.get(header))\n", "if supplied_token != request.session.get_csrf_token():\n", "if raises:\n", "return True\n", "return False\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "FunctionDef'", "Assign'", "Condition", "Condition", "Return'", "Return'" ]
[ "def FUNC_3(self, VAR_3):...\n", "VAR_6 = \"SELECT COUNT(email) FROM members WHERE email = '{email}'\".format(email\n =member)\n", "self.cursor.execute(VAR_6)\n", "VAR_9 = self.cursor.fetchone()\n", "if int(VAR_9[0]) > 0:\n", "return True\n", "return False\n" ]
[ "def verify_email(self, member):...\n", "query = \"SELECT COUNT(email) FROM members WHERE email = '{email}'\".format(email\n =member)\n", "self.cursor.execute(query)\n", "result = self.cursor.fetchone()\n", "if int(result[0]) > 0:\n", "return True\n", "return False\n" ]
[ 0, 4, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Assign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_11(self, VAR_12, VAR_13=None):...\n", "VAR_41 = VAR_12.GET.get('end', None)\n", "if VAR_41:\n", "return self.streaming_response(f'wins_current_fy_{now().isoformat()}.csv')\n", "self.end_date = models.DateField().to_python(VAR_41)\n", "self.end_date = None\n" ]
[ "def get(self, request, format=None):...\n", "end_str = request.GET.get('end', None)\n", "if end_str:\n", "return self.streaming_response(f'wins_current_fy_{now().isoformat()}.csv')\n", "self.end_date = models.DateField().to_python(end_str)\n", "self.end_date = None\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Return'", "Assign'", "Assign'" ]
[ "def FUNC_9(VAR_4):...\n", "return [{'id': tag_id, 'name': MEASURE_TAGS[tag_id]['name']} for tag_id in\n VAR_4]\n" ]
[ "def _hydrate_tags(tag_ids):...\n", "return [{'id': tag_id, 'name': MEASURE_TAGS[tag_id]['name']} for tag_id in\n tag_ids]\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "from __future__ import unicode_literals, print_function, division\n", "import logging\n", "import threading\n", "import time\n", "import traceback\n", "import lxml.html\n", "import os.path\n", "import spynner\n", "import selenium.webdriver\n", "import os\n", "from veil.utility.path import *\n", "from veil.development.test import *\n", "from veil.profile.web import *\n", "from veil.frontend.web.static_file import *\n", "VAR_0 = logging.getLogger(__name__)\n", "def FUNC_0(VAR_1, VAR_2, VAR_3, VAR_4=60, VAR_5='spynner'):...\n", "@route('POST', '/-test/stop', VAR_1=website)...\n", "FUNC_7()\n", "@route('POST', '/-test/fail', VAR_1=website)...\n", "VAR_16 = get_http_argument('message')\n", "VAR_0.error(VAR_16)\n", "get_executing_test().error = VAR_16\n", "@route('POST', '/-test/log', VAR_1=website)...\n", "VAR_0.info(get_http_argument('message'))\n", "@route('GET', '/-test/veil-test.js', VAR_1=website)...\n", "get_current_http_response().set_header('Content-Type',\n 'text/javascript; charset=utf-8')\n", "return (as_path(__file__).dirname() / 'veil-test.js').text()\n" ]
[ "from __future__ import unicode_literals, print_function, division\n", "import logging\n", "import threading\n", "import time\n", "import traceback\n", "import lxml.html\n", "import os.path\n", "import spynner\n", "import selenium.webdriver\n", "import os\n", "from veil.utility.path import *\n", "from veil.development.test import *\n", "from veil.profile.web import *\n", "from veil.frontend.web.static_file import *\n", "LOGGER = logging.getLogger(__name__)\n", "def start_website_and_browser(website, path, page_interactions, timeout=60,...\n", "@route('POST', '/-test/stop', website=website)...\n", "stop_browser()\n", "@route('POST', '/-test/fail', website=website)...\n", "message = get_http_argument('message')\n", "LOGGER.error(message)\n", "get_executing_test().error = message\n", "@route('POST', '/-test/log', website=website)...\n", "LOGGER.info(get_http_argument('message'))\n", "@route('GET', '/-test/veil-test.js', website=website)...\n", "get_current_http_response().set_header('Content-Type',\n 'text/javascript; charset=utf-8')\n", "return (as_path(__file__).dirname() / 'veil-test.js').text()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "FunctionDef'", "Condition", "Expr'", "Condition", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_36(self):...\n", "self.compilation_ko(\n \"\"\"\nif address :is \"From\" \"tim@example.com\" \"tutu\" {\n discard;\n}\n\"\"\")\n" ]
[ "def test_extra_arg(self):...\n", "self.compilation_ko(\n \"\"\"\nif address :is \"From\" \"tim@example.com\" \"tutu\" {\n discard;\n}\n\"\"\")\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "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 __getitem__(self, VAR_44):...\n", "" ]
[ "def __getitem__(self, key):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_0(VAR_1, VAR_2=True):...\n", "if exists(join(VAR_1, '.svn')):\n", "VAR_24 = CLASS_3\n", "if exists(join(VAR_1, '.git')):\n", "return VAR_24.url_from_directory(VAR_1, VAR_2)\n", "VAR_24 = CLASS_2\n" ]
[ "def url_from_directory(directory, include_commit=True):...\n", "if exists(join(directory, '.svn')):\n", "cls = SvnSubproject\n", "if exists(join(directory, '.git')):\n", "return cls.url_from_directory(directory, include_commit)\n", "cls = GitSubproject\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Condition", "Return'", "Assign'" ]
[ "def FUNC_15(self, VAR_15, VAR_16):...\n", "\"\"\"docstring\"\"\"\n", "VAR_14 = 500\n", "self.handle_exception_exception()\n", "VAR_13 = {'message': VAR_15.message, 'email': helpers.get_user_email(),\n 'traceDump': traceback.format_exc(), 'status': VAR_14, 'type': VAR_15.\n __class__.__name__}\n", "if isinstance(VAR_15, helpers.EarlyExitException):\n", "VAR_14 = VAR_15.status\n", "VAR_13['params'] = self.request.params.dict_of_lists()\n", "VAR_13 = VAR_15.to_dict()\n", "if VAR_14 >= 400 and VAR_14 <= 499:\n", "logging.info(json.dumps(VAR_13, cls=JsonEncoder))\n", "logging.exception(VAR_15)\n", "if helpers.should_render_json(self.request.headers.get('accept', ''), self.\n", "self.render_json(VAR_13, VAR_14)\n", "if VAR_14 == 403 or VAR_14 == 401:\n", "self.render_forbidden(VAR_15.message)\n", "self.render('error.html', VAR_13, VAR_14)\n" ]
[ "def handle_exception(self, exception, _):...\n", "\"\"\"docstring\"\"\"\n", "status = 500\n", "self.handle_exception_exception()\n", "values = {'message': exception.message, 'email': helpers.get_user_email(),\n 'traceDump': traceback.format_exc(), 'status': status, 'type':\n exception.__class__.__name__}\n", "if isinstance(exception, helpers.EarlyExitException):\n", "status = exception.status\n", "values['params'] = self.request.params.dict_of_lists()\n", "values = exception.to_dict()\n", "if status >= 400 and status <= 499:\n", "logging.info(json.dumps(values, cls=JsonEncoder))\n", "logging.exception(exception)\n", "if helpers.should_render_json(self.request.headers.get('accept', ''), self.\n", "self.render_json(values, status)\n", "if status == 403 or status == 401:\n", "self.render_forbidden(exception.message)\n", "self.render('error.html', values, status)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_14(self, VAR_7):...\n", "return VAR_7 in self._job_status\n" ]
[ "def _job_id_exists(self, job_id):...\n", "return job_id in self._job_status\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "from google.appengine.ext import db\n", "import logging\n", "VAR_0 = ['user', 'editor', 'superuser']\n", "VAR_9 = db.DateTimeProperty(auto_now_add=True)\n", "VAR_10 = db.StringProperty(required=True)\n", "VAR_2 = db.StringProperty()\n", "VAR_3 = db.StringProperty()\n", "VAR_1 = db.StringProperty()\n", "VAR_11 = db.StringListProperty()\n", "VAR_12 = db.StringListProperty()\n", "def FUNC_0(VAR_1):...\n", "return CLASS_0.all().filter('token =', VAR_1).get()\n" ]
[ "from google.appengine.ext import db\n", "import logging\n", "ROLES = ['user', 'editor', 'superuser']\n", "timestamp = db.DateTimeProperty(auto_now_add=True)\n", "description = db.StringProperty(required=True)\n", "email = db.StringProperty()\n", "user_id = db.StringProperty()\n", "token = db.StringProperty()\n", "user_roles = db.StringListProperty()\n", "requested_roles = db.StringListProperty()\n", "def check_token(token):...\n", "return Authorization.all().filter('token =', token).get()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Import'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Return'" ]
[ "import re\n", "import typing\n", "from urllib.parse import urlparse\n", "from django import forms\n", "from django.core.exceptions import ValidationError\n", "from django.forms import ModelForm\n", "from lib.forms import ModelFormWithSubmit\n", "from projects.project_models import Project\n", "from .source_models import FileSource, GithubSource, Source\n", "VAR_0 = [('text/dar', 'Dar'), ('text/dockerfile', 'Dockerfile'), (\n 'text/ipynb', 'Jupyter Notebook'), ('text/rmarkdown', 'RMarkdown')]\n", "def FUNC_0(VAR_1: Project, VAR_2: str, VAR_3: typing.Optional[int]=None...\n", "\"\"\"docstring\"\"\"\n", "VAR_4 = FileSource.objects.filter(VAR_1=project, VAR_2=path)\n", "if VAR_3:\n", "VAR_4 = VAR_4.exclude(pk=existing_source_pk)\n", "if len(VAR_4):\n", "VAR_5 = forms.ChoiceField(choices=FILE_TYPES)\n", "VAR_2 = forms.RegexField(regex='^[^/][A-Za-z\\\\-/\\\\.]+[^/]$', widget=forms.\n TextInput, error_messages={'invalid':\n 'The path must not contain spaces, or start or end with a /'})\n", "VAR_7 = FileSource\n", "VAR_8 = 'path',\n", "VAR_9 = {'type': forms.Select(), 'path': forms.TextInput()}\n", "def FUNC_1(self):...\n", "FUNC_0(self.initial['project'], self.cleaned_data['path'])\n", "return super().clean()\n" ]
[ "import re\n", "import typing\n", "from urllib.parse import urlparse\n", "from django import forms\n", "from django.core.exceptions import ValidationError\n", "from django.forms import ModelForm\n", "from lib.forms import ModelFormWithSubmit\n", "from projects.project_models import Project\n", "from .source_models import FileSource, GithubSource, Source\n", "FILE_TYPES = [('text/dar', 'Dar'), ('text/dockerfile', 'Dockerfile'), (\n 'text/ipynb', 'Jupyter Notebook'), ('text/rmarkdown', 'RMarkdown')]\n", "def validate_unique_project_path(project: Project, path: str,...\n", "\"\"\"docstring\"\"\"\n", "existing_sources = FileSource.objects.filter(project=project, path=path)\n", "if existing_source_pk:\n", "existing_sources = existing_sources.exclude(pk=existing_source_pk)\n", "if len(existing_sources):\n", "type = forms.ChoiceField(choices=FILE_TYPES)\n", "path = forms.RegexField(regex='^[^/][A-Za-z\\\\-/\\\\.]+[^/]$', widget=forms.\n TextInput, error_messages={'invalid':\n 'The path must not contain spaces, or start or end with a /'})\n", "model = FileSource\n", "fields = 'path',\n", "widgets = {'type': forms.Select(), 'path': forms.TextInput()}\n", "def clean(self):...\n", "validate_unique_project_path(self.initial['project'], self.cleaned_data['path']\n )\n", "return super().clean()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1 ]
[ "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Condition", "Docstring", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Expr'", "Return'" ]
[ "def FUNC_41(self):...\n", "\"\"\"docstring\"\"\"\n", "tournament.reportMatch(p1=2, p2='%')\n" ]
[ "def test_p2_contains_symbol(self):...\n", "\"\"\"docstring\"\"\"\n", "tournament.reportMatch(p1=2, p2='%')\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'" ]
[ "def FUNC_8(self, VAR_26):...\n", "\"\"\"docstring\"\"\"\n", "VAR_21 = self.resolve_path(VAR_26, os.path.dirname(VAR_26))\n", "if not VAR_21 or not self.exists(VAR_21):\n", "VAR_24 = self.getfile(VAR_21)\n", "if VAR_24[VAR_2] == VAR_12:\n", "if VAR_24[VAR_2] == VAR_13 and VAR_24[VAR_10]:\n", "return FUNC_14(VAR_24[VAR_10], 'rb').read()\n", "if VAR_24[VAR_2] == VAR_13 and VAR_24[VAR_5] == 0:\n", "return ''\n" ]
[ "def file_contents(self, target):...\n", "\"\"\"docstring\"\"\"\n", "path = self.resolve_path(target, os.path.dirname(target))\n", "if not path or not self.exists(path):\n", "f = self.getfile(path)\n", "if f[A_TYPE] == T_DIR:\n", "if f[A_TYPE] == T_FILE and f[A_REALFILE]:\n", "return open(f[A_REALFILE], 'rb').read()\n", "if f[A_TYPE] == T_FILE and f[A_SIZE] == 0:\n", "return ''\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Return'", "Condition", "Return'" ]
[ "def FUNC_21(self, VAR_20, VAR_21, VAR_22):...\n", "VAR_6 = VAR_21.get_headerbar()\n", "self.set_titlebar(VAR_6)\n" ]
[ "def on_tab_switch(self, notebook, tab, pagenum):...\n", "headerbar = tab.get_headerbar()\n", "self.set_titlebar(headerbar)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "@api_view(['GET'])...\n", "return FUNC_7(VAR_0, 'ccg')\n" ]
[ "@api_view(['GET'])...\n", "return _measure_by_org(request, 'ccg')\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def __init__(self, VAR_1, VAR_7, VAR_11, VAR_4=None):...\n", "GenericRequest.__init__(self, VAR_1, VAR_4)\n", "self.url = '%stasks/%s/submissions/%s/token' % (self.base_url, VAR_7[1], VAR_11\n )\n", "self.task = VAR_7\n", "self.submission_num = VAR_11\n", "self.data = {}\n" ]
[ "def __init__(self, browser, task, submission_num, base_url=None):...\n", "GenericRequest.__init__(self, browser, base_url)\n", "self.url = '%stasks/%s/submissions/%s/token' % (self.base_url, task[1],\n submission_num)\n", "self.task = task\n", "self.submission_num = submission_num\n", "self.data = {}\n" ]
[ 0, 0, 5, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_7(self):...\n", "return self.content\n" ]
[ "def read(self):...\n", "return self.content\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_9(self):...\n", "\"\"\"docstring\"\"\"\n", "self.tables = ['`tab' + self.doctype + '`']\n", "if self.fields:\n", "for VAR_34 in self.fields:\n", "if not ('tab' in VAR_34 and '.' in VAR_34\n", "VAR_32 = VAR_34.split('.')[0]\n", "if VAR_32.lower().startswith('group_concat('):\n", "VAR_32 = VAR_32[13:]\n", "if VAR_32.lower().startswith('ifnull('):\n", "VAR_32 = VAR_32[7:]\n", "if not VAR_32[0] == '`':\n", "VAR_32 = '`' + VAR_32 + '`'\n", "if not VAR_32 in self.tables:\n", "self.append_table(VAR_32)\n" ]
[ "def extract_tables(self):...\n", "\"\"\"docstring\"\"\"\n", "self.tables = ['`tab' + self.doctype + '`']\n", "if self.fields:\n", "for f in self.fields:\n", "if not ('tab' in f and '.' in f) or 'locate(' in f or 'count(' in f:\n", "table_name = f.split('.')[0]\n", "if table_name.lower().startswith('group_concat('):\n", "table_name = table_name[13:]\n", "if table_name.lower().startswith('ifnull('):\n", "table_name = table_name[7:]\n", "if not table_name[0] == '`':\n", "table_name = '`' + table_name + '`'\n", "if not table_name in self.tables:\n", "self.append_table(table_name)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "For", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Condition", "Expr'" ]
[ "def FUNC_0():...\n", "return psycopg2.connect(database='tournament', user='postgres')\n" ]
[ "def connect():...\n", "return psycopg2.connect(database='tournament', user='postgres')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "import sqlite3\n", "import os\n", "from server.settings import BASE_DIR\n", "VAR_0 = os.path.join(BASE_DIR, 'db.sqlite3')\n", "def FUNC_0(VAR_1):...\n", "VAR_3 = sqlite3.connect(VAR_0)\n", "VAR_1 = 'select * from django_migrations;'\n", "VAR_4 = VAR_3.cursor()\n", "VAR_4.execute(VAR_1)\n", "VAR_5 = VAR_4.fetchall()\n", "return VAR_5\n" ]
[ "import sqlite3\n", "import os\n", "from server.settings import BASE_DIR\n", "DB_FILE = os.path.join(BASE_DIR, 'db.sqlite3')\n", "def sqlite_executor(sql):...\n", "conn = sqlite3.connect(DB_FILE)\n", "sql = 'select * from django_migrations;'\n", "cursor = conn.cursor()\n", "cursor.execute(sql)\n", "res = cursor.fetchall()\n", "return res\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "ImportFrom'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_7(self, VAR_24, VAR_25):...\n", "VAR_39 = self.metadata('queries', VAR_20=database_name, VAR_22=False) or {}\n", "VAR_41 = VAR_39.get(VAR_25)\n", "if VAR_41:\n", "if not isinstance(VAR_41, dict):\n", "VAR_41 = {'sql': VAR_41}\n", "VAR_41['name'] = VAR_25\n", "return VAR_41\n" ]
[ "def get_canned_query(self, database_name, query_name):...\n", "queries = self.metadata('queries', database=database_name, fallback=False) or {\n }\n", "query = queries.get(query_name)\n", "if query:\n", "if not isinstance(query, dict):\n", "query = {'sql': query}\n", "query['name'] = query_name\n", "return query\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_2(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': 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, 204)\n", "chaos.CREATE_ERROR_RATE = 0.5\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, 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", "self.assertEqual(len(VAR_2.data['results']), 20)\n", "VAR_5 = set([c['state'] for c in VAR_2.data['results']])\n", "self.assertEqual(VAR_5, set(['error', 'created']))\n" ]
[ "def test_create_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': 0}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 204)\n", "chaos.CREATE_ERROR_RATE = 0.5\n", "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, 503)\n", "url = '/api/apps/{app_id}/containers'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 20)\n", "states = set([c['state'] for c in response.data['results']])\n", "self.assertEqual(states, set(['error', 'created']))\n" ]
[ 0, 0, 5, 0, 0, 0, 0, 5, 0, 0, 5, 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'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_10(self):...\n", "\"\"\"docstring\"\"\"\n", "if self.r_handler.current_user is not None:\n", "self._check_xsrf_cookie()\n", "VAR_15 = self.r_handler.request.headers.get('Token', None)\n", "return True\n", "VAR_16 = self.r_handler.request.headers.get('Email', None)\n", "if VAR_15 is not None and VAR_16 is not None:\n", "return False\n", "VAR_39 = self.session.query(SurveyCreator.token, SurveyCreator.token_expiration\n ).join(Email).filter(Email.address == VAR_16).one()\n", "return False\n", "if VAR_39.token_expiration.timetuple() < localtime():\n", "return False\n", "VAR_34 = VAR_39.token is not None\n", "return VAR_34 and bcrypt_sha256.verify(VAR_15, VAR_39.token)\n" ]
[ "def is_authenticated(self):...\n", "\"\"\"docstring\"\"\"\n", "if self.r_handler.current_user is not None:\n", "self._check_xsrf_cookie()\n", "token = self.r_handler.request.headers.get('Token', None)\n", "return True\n", "email = self.r_handler.request.headers.get('Email', None)\n", "if token is not None and email is not None:\n", "return False\n", "user = self.session.query(SurveyCreator.token, SurveyCreator.token_expiration\n ).join(Email).filter(Email.address == email).one()\n", "return False\n", "if user.token_expiration.timetuple() < localtime():\n", "return False\n", "token_exists = user.token is not None\n", "return token_exists and bcrypt_sha256.verify(token, user.token)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'", "Assign'", "Return'", "Assign'", "Condition", "Return'", "Assign'", "Return'", "Condition", "Return'", "Assign'", "Return'" ]
[ "def __init__(self, VAR_61=False, VAR_62=False, VAR_63='rate_', *VAR_15, **...\n", "self.rate_user = VAR_61\n", "self.rate_ip = VAR_62\n", "self.prefix = VAR_63\n", "CLASS_0.__init__(self, *VAR_15, **kw)\n" ]
[ "def __init__(self, rate_user=False, rate_ip=False, prefix='rate_', *a, **kw):...\n", "self.rate_user = rate_user\n", "self.rate_ip = rate_ip\n", "self.prefix = prefix\n", "Validator.__init__(self, *a, **kw)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "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'" ]
[ "def FUNC_7(self):...\n", "return self.content\n" ]
[ "def read(self):...\n", "return self.content\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_2(self, VAR_0):...\n", "" ]
[ "def delete(self, user_id):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_1(self):...\n", "return DataDocument.objects.filter(extractedtext__extraction_script=self.pk\n ).count()\n" ]
[ "def get_datadocument_count(self):...\n", "return DataDocument.objects.filter(extractedtext__extraction_script=self.pk\n ).count()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_11(self, VAR_12='Not Authorized', VAR_13=None):...\n", "return VAR_12, 401, {'Content-Type': 'text/plain'}\n" ]
[ "def oidc_error(self, message='Not Authorized', code=None):...\n", "return message, 401, {'Content-Type': 'text/plain'}\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_3(self, VAR_3):...\n", "VAR_20 = VAR_3.value.upper()\n", "if VAR_3.type == 'ID':\n", "if not VAR_20 in self.spdx.licenses:\n", "if VAR_3.type == 'EXC':\n", "self.lastid = VAR_20\n", "if VAR_20 not in self.spdx.exceptions:\n", "if VAR_3.type != 'WITH':\n", "if self.lastid not in self.spdx.exceptions[VAR_20]:\n", "self.lastid = None\n", "self.lastid = None\n" ]
[ "def validate(self, tok):...\n", "id = tok.value.upper()\n", "if tok.type == 'ID':\n", "if not id in self.spdx.licenses:\n", "if tok.type == 'EXC':\n", "self.lastid = id\n", "if id not in self.spdx.exceptions:\n", "if tok.type != 'WITH':\n", "if self.lastid not in self.spdx.exceptions[id]:\n", "self.lastid = None\n", "self.lastid = None\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Assign'" ]
[ "@login_required...\n", "\"\"\"docstring\"\"\"\n", "return render_to_response('student_account/finish_auth.html', {\n 'disable_courseware_js': True, 'disable_footer': True})\n" ]
[ "@login_required...\n", "\"\"\"docstring\"\"\"\n", "return render_to_response('student_account/finish_auth.html', {\n 'disable_courseware_js': True, 'disable_footer': True})\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def FUNC_1(VAR_4):...\n", "VAR_14 = VAR_4.request\n", "VAR_15 = get_localizer(VAR_14)\n", "def FUNC_6(*VAR_16, **VAR_17):...\n", "return VAR_15.translate(VAR_1(*VAR_16, **kwargs))\n" ]
[ "def add_localizer_to_request(event):...\n", "request = event.request\n", "localizer = get_localizer(request)\n", "def auto_translate(*args, **kwargs):...\n", "return localizer.translate(translation_string_factory(*args, **kwargs))\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "FunctionDef'", "Return'" ]
[ "def FUNC_10(self, VAR_24):...\n", "return isinstance(VAR_24, requests_exceptions.ConnectionError)\n" ]
[ "def is_connection_exception(self, exception):...\n", "return isinstance(exception, requests_exceptions.ConnectionError)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self._get_version(self.java)\n" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self._get_version(self.java)\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "def FUNC_9(self):...\n", "self.run_test_case(self.scenario.create_app())\n" ]
[ "def test_a_create_app(self):...\n", "self.run_test_case(self.scenario.create_app())\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_12(VAR_2, VAR_10):...\n", "VAR_2.cursor.execute('string', (VAR_10,))\n", "VAR_27 = VAR_2.cursor.fetchone()\n", "if not VAR_27:\n", "return VAR_0(*VAR_27)\n" ]
[ "def get_from_id(db, submission_id):...\n", "db.cursor.execute(\n \"\"\"SELECT id, sheet_id, student_id, time, files_path, deleted FROM submission\n WHERE id = ?\"\"\"\n , (submission_id,))\n", "row = db.cursor.fetchone()\n", "if not row:\n", "return Submission(*row)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_1(self):...\n", "db.session.commit()\n" ]
[ "def save(self):...\n", "db.session.commit()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_17(VAR_16):...\n", "return VAR_19(VAR_16, 'touch')\n" ]
[ "def touch(value):...\n", "return flag(value, 'touch')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_10(self):...\n", "self._tab_after(' ls comp')\n", "eq_(self.terminal.method_calls, [('write', ('utes ',), {})])\n" ]
[ "def test_command_arg_spaces_before_command(self):...\n", "self._tab_after(' ls comp')\n", "eq_(self.terminal.method_calls, [('write', ('utes ',), {})])\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'" ]
[ "def FUNC_6(VAR_8):...\n", "\"\"\"docstring\"\"\"\n", "VAR_19 = {}\n", "for VAR_22 in VAR_8.keys():\n", "VAR_21 = VAR_8[VAR_22]\n", "return VAR_19\n", "if type(VAR_21) == UnicodeType:\n", "VAR_19[VAR_22] = VAR_21.encode('utf-8')\n", "if type(VAR_21) == IntType:\n", "VAR_19[VAR_22] = VAR_21\n", "VAR_19[VAR_22] = str(VAR_21)\n" ]
[ "def row2dict(row):...\n", "\"\"\"docstring\"\"\"\n", "d = {}\n", "for column_name in row.keys():\n", "v = row[column_name]\n", "return d\n", "if type(v) == UnicodeType:\n", "d[column_name] = v.encode('utf-8')\n", "if type(v) == IntType:\n", "d[column_name] = v\n", "d[column_name] = str(v)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "For", "Assign'", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_41(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_32 = list()\n", "for VAR_14 in self.get_columns_list():\n", "if not self.is_pk(VAR_14) and not self.is_fk(VAR_14):\n", "return VAR_32\n", "VAR_32.append(VAR_14)\n" ]
[ "def get_user_columns_list(self):...\n", "\"\"\"docstring\"\"\"\n", "ret_lst = list()\n", "for col_name in self.get_columns_list():\n", "if not self.is_pk(col_name) and not self.is_fk(col_name):\n", "return ret_lst\n", "ret_lst.append(col_name)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "For", "Condition", "Return'", "Expr'" ]
[ "def FUNC_0(self, VAR_2):...\n", "self.start_exporting()\n", "self.conn.execute(\n \"INSERT INTO webpages(title, content, url) VALUES ('%s', '%s', '%s')\" %\n (VAR_2['title'], VAR_2['content'], VAR_2['url']))\n", "self.conn.commit()\n", "self.finish_exporting()\n" ]
[ "def export_item(self, item):...\n", "self.start_exporting()\n", "self.conn.execute(\n \"INSERT INTO webpages(title, content, url) VALUES ('%s', '%s', '%s')\" %\n (item['title'], item['content'], item['url']))\n", "self.conn.commit()\n", "self.finish_exporting()\n" ]
[ 0, 0, 4, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_9(VAR_11):...\n", "return ray.ObjectID(VAR_11)\n" ]
[ "def binary_to_object_id(binary_object_id):...\n", "return ray.ObjectID(binary_object_id)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_10(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': -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, 400)\n", "VAR_4 = '/api/apps/{app_id}/scale'.format(**locals())\n", "VAR_8 = {'web': 'one'}\n", "VAR_5 = self.client.post(VAR_4, json.dumps(VAR_8), content_type=\n 'application/json')\n", "self.assertEqual(VAR_5.status_code, 400)\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, 400)\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" ]
[ "def test_container_scale_errors(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': -1}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 400)\n", "url = '/api/apps/{app_id}/scale'.format(**locals())\n", "body = {'web': 'one'}\n", "response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 400)\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, 400)\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" ]
[ 0, 0, 0, 0, 0, 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'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_5(VAR_6, VAR_4):...\n", "print('auth_check_password', VAR_6.password_hash, VAR_4)\n", "return check_password_hash(VAR_6.password_hash, VAR_4)\n" ]
[ "def auth_check_password(user, password):...\n", "print('auth_check_password', user.password_hash, password)\n", "return check_password_hash(user.password_hash, password)\n" ]
[ 0, 6, 0 ]
[ "FunctionDef'", "Expr'", "Return'" ]
[ "def FUNC_18(VAR_29):...\n", "VAR_30 = [b'WipeManager']\n", "VAR_30.extend(wzrpc.make_sig_msg(b'WipeManager', b'passthrough', VAR_29))\n", "VAR_3.send_multipart(VAR_30)\n" ]
[ "def send_passthrough(frames):...\n", "msg = [b'WipeManager']\n", "msg.extend(wzrpc.make_sig_msg(b'WipeManager', b'passthrough', frames))\n", "sig_sock.send_multipart(msg)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_3(self, VAR_2, VAR_7, VAR_8):...\n", "VAR_1 = self.current_user\n", "if VAR_7 == 'consent':\n", "VAR_33 = db.DatasetVersion.select().where(db.DatasetVersion.version == VAR_8\n ).get()\n", "db.UserConsentLog.create(VAR_1=user, VAR_0=dv)\n" ]
[ "def post(self, dataset, event, target):...\n", "user = self.current_user\n", "if event == 'consent':\n", "dv = db.DatasetVersion.select().where(db.DatasetVersion.version == target).get(\n )\n", "db.UserConsentLog.create(user=user, dataset_version=dv)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Expr'" ]
[ "def FUNC_6(self):...\n", "self.login()\n", "while True:\n", "VAR_29 = random.random()\n", "VAR_30 = random.choice(self.tasks)\n", "if VAR_29 < 0.1 and self.submissions_path is not None:\n", "self.do_step(SubmitRandomRequest(self.browser, VAR_30, VAR_10=self.base_url,\n VAR_11=self.submissions_path))\n", "if VAR_29 < 0.6 and VAR_30[2] != []:\n", "self.do_step(TaskStatementRequest(self.browser, VAR_30[1], random.choice(\n VAR_30[2]), VAR_10=self.base_url))\n", "self.do_step(TaskRequest(self.browser, VAR_30[1], VAR_10=self.base_url))\n" ]
[ "def act(self):...\n", "self.login()\n", "while True:\n", "choice = random.random()\n", "task = random.choice(self.tasks)\n", "if choice < 0.1 and self.submissions_path is not None:\n", "self.do_step(SubmitRandomRequest(self.browser, task, base_url=self.base_url,\n submissions_path=self.submissions_path))\n", "if choice < 0.6 and task[2] != []:\n", "self.do_step(TaskStatementRequest(self.browser, task[1], random.choice(task\n [2]), base_url=self.base_url))\n", "self.do_step(TaskRequest(self.browser, task[1], base_url=self.base_url))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_2():...\n", "" ]
[ "def main():...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "def FUNC_4(VAR_2, VAR_3=None, VAR_4=None, VAR_5=0, VAR_6=20, VAR_7=None):...\n", "VAR_11 = []\n", "if VAR_4:\n", "if VAR_4.blogger:\n", "if VAR_3:\n", "VAR_11.append('t1.blogger=\"%s\"' % frappe.db.escape(VAR_4.blogger))\n", "if VAR_4.blog_category:\n", "VAR_11.append('(t1.content like \"%{0}%\" or t1.title like \"%{0}%\")'.format(\n frappe.db.escape(VAR_3)))\n", "if VAR_11:\n", "VAR_11.append('t1.blog_category=\"%s\"' % frappe.db.escape(VAR_4.blog_category))\n", "frappe.local.no_cache = 1\n", "VAR_12 = 'string' % {'start': VAR_5, 'page_len': VAR_6, 'condition': \n ' and ' + ' and '.join(VAR_11) if VAR_11 else ''}\n", "VAR_13 = frappe.db.sql(VAR_12, as_dict=1)\n", "for post in VAR_13:\n", "post.cover_image = find_first_image(post.content)\n", "return VAR_13\n", "post.published = global_date_format(post.creation)\n", "post.content = strip_html_tags(post.content[:340])\n", "if not post.comments:\n", "post.comment_text = _('No comments yet')\n", "if post.comments == 1:\n", "post.avatar = post.avatar or ''\n", "post.comment_text = _('1 comment')\n", "post.comment_text = _('{0} comments').format(str(post.comments))\n", "post.category = frappe.db.get_value('Blog Category', post.blog_category, [\n 'route', 'title'], as_dict=True)\n", "if post.avatar and (not 'http:' in post.avatar and not 'https:' in post.avatar\n", "post.avatar = '/' + post.avatar\n" ]
[ "def get_blog_list(doctype, txt=None, filters=None, limit_start=0,...\n", "conditions = []\n", "if filters:\n", "if filters.blogger:\n", "if txt:\n", "conditions.append('t1.blogger=\"%s\"' % frappe.db.escape(filters.blogger))\n", "if filters.blog_category:\n", "conditions.append('(t1.content like \"%{0}%\" or t1.title like \"%{0}%\")'.\n format(frappe.db.escape(txt)))\n", "if conditions:\n", "conditions.append('t1.blog_category=\"%s\"' % frappe.db.escape(filters.\n blog_category))\n", "frappe.local.no_cache = 1\n", "query = (\n \"\"\"\t\tselect\n\t\t\tt1.title, t1.name, t1.blog_category, t1.route, t1.published_on,\n\t\t\t\tt1.published_on as creation,\n\t\t\t\tt1.content as content,\n\t\t\t\tifnull(t1.blog_intro, t1.content) as intro,\n\t\t\t\tt2.full_name, t2.avatar, t1.blogger,\n\t\t\t\t(select count(name) from `tabCommunication`\n\t\t\t\t\twhere\n\t\t\t\t\t\tcommunication_type='Comment'\n\t\t\t\t\t\tand comment_type='Comment'\n\t\t\t\t\t\tand reference_doctype='Blog Post'\n\t\t\t\t\t\tand reference_name=t1.name) as comments\n\t\tfrom `tabBlog Post` t1, `tabBlogger` t2\n\t\twhere ifnull(t1.published,0)=1\n\t\tand t1.blogger = t2.name\n\t\t%(condition)s\n\t\torder by published_on desc, name asc\n\t\tlimit %(start)s, %(page_len)s\"\"\"\n % {'start': limit_start, 'page_len': limit_page_length, 'condition': \n ' and ' + ' and '.join(conditions) if conditions else ''})\n", "posts = frappe.db.sql(query, as_dict=1)\n", "for post in posts:\n", "post.cover_image = find_first_image(post.content)\n", "return posts\n", "post.published = global_date_format(post.creation)\n", "post.content = strip_html_tags(post.content[:340])\n", "if not post.comments:\n", "post.comment_text = _('No comments yet')\n", "if post.comments == 1:\n", "post.avatar = post.avatar or ''\n", "post.comment_text = _('1 comment')\n", "post.comment_text = _('{0} comments').format(str(post.comments))\n", "post.category = frappe.db.get_value('Blog Category', post.blog_category, [\n 'route', 'title'], as_dict=True)\n", "if post.avatar and (not 'http:' in post.avatar and not 'https:' in post.avatar\n", "post.avatar = '/' + post.avatar\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Condition", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Return'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'" ]
[ "def FUNC_15(self, VAR_7, VAR_10):...\n", "\"\"\"docstring\"\"\"\n", "VAR_25 = None\n", "VAR_11 = self.common._safe_hostname(VAR_10['host'])\n", "VAR_33 = self.common.get_cpg(VAR_7, allowSnap=True)\n", "VAR_13 = self.common.get_domain(VAR_33)\n", "VAR_25 = self.common._get_3par_host(VAR_11)\n", "VAR_14 = self.common.get_persona_type(VAR_7)\n", "return VAR_25\n", "if not VAR_25['iSCSIPaths']:\n", "VAR_11 = self._create_3par_iscsi_host(VAR_11, VAR_10['initiator'], VAR_13,\n VAR_14)\n", "self._modify_3par_iscsi_host(VAR_11, VAR_10['initiator'])\n", "VAR_25 = self.common._get_3par_host(VAR_11)\n", "VAR_25 = self.common._get_3par_host(VAR_11)\n" ]
[ "def _create_host(self, volume, connector):...\n", "\"\"\"docstring\"\"\"\n", "host = None\n", "hostname = self.common._safe_hostname(connector['host'])\n", "cpg = self.common.get_cpg(volume, allowSnap=True)\n", "domain = self.common.get_domain(cpg)\n", "host = self.common._get_3par_host(hostname)\n", "persona_id = self.common.get_persona_type(volume)\n", "return host\n", "if not host['iSCSIPaths']:\n", "hostname = self._create_3par_iscsi_host(hostname, connector['initiator'],\n domain, persona_id)\n", "self._modify_3par_iscsi_host(hostname, connector['initiator'])\n", "host = self.common._get_3par_host(hostname)\n", "host = self.common._get_3par_host(hostname)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Condition", "Assign'", "Expr'", "Assign'", "Assign'" ]
[ "def FUNC_2(self, VAR_1):...\n", "VAR_2 = self.connect()\n", "VAR_3 = \"INSERT INTO crimes (description) VALUES('{}');\".format(VAR_1)\n", "VAR_2.close()\n", "cursor.execute(VAR_3)\n", "VAR_2.commit()\n" ]
[ "def add_input(self, data):...\n", "connection = self.connect()\n", "query = \"INSERT INTO crimes (description) VALUES('{}');\".format(data)\n", "connection.close()\n", "cursor.execute(query)\n", "connection.commit()\n" ]
[ 0, 0, 4, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def __init__(self):...\n", "self.xsrf_token = None\n", "self.session = requests.Session()\n" ]
[ "def __init__(self):...\n", "self.xsrf_token = None\n", "self.session = requests.Session()\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'" ]
[ "def FUNC_5(self):...\n", "VAR_13 = {'puc': ['2']}\n", "VAR_14 = self.client.post('/get_data/', VAR_13=data)\n", "for hnp in [b'ball bearings', b'motorcycle', b'vitamin a&amp;d', b'dish soap']:\n", "self.assertIn(hnp, VAR_14.content)\n" ]
[ "def test_habits_and_practices_cards(self):...\n", "data = {'puc': ['2']}\n", "response = self.client.post('/get_data/', data=data)\n", "for hnp in [b'ball bearings', b'motorcycle', b'vitamin a&amp;d', b'dish soap']:\n", "self.assertIn(hnp, response.content)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "For", "Expr'" ]
[ "@app.route('/api/images/<type>/<image>/wait_until_ready', methods=['GET'])...\n", "FUNC_34(VAR_11).lookup(VAR_12, file_required=False).wait_until_ready()\n", "return {'ready': True}\n" ]
[ "@app.route('/api/images/<type>/<image>/wait_until_ready', methods=['GET'])...\n", "get_image_database(type).lookup(image, file_required=False).wait_until_ready()\n", "return {'ready': True}\n" ]
[ 0, 0, 0 ]
[ "Condition", "Expr'", "Return'" ]
[ "def FUNC_5(self, *VAR_4, **VAR_5):...\n", "VAR_11 = self.REQUEST\n", "VAR_16 = VAR_11.RESPONSE\n", "VAR_17 = VAR_11.SESSION\n", "self._zmi_page_request()\n", "VAR_16.setHeader('Expires', DateTime(VAR_11['ZMI_TIME'] - 10000).toZone(\n 'GMT+1').rfc822())\n", "VAR_16.setHeader('Cache-Control', 'no-cache')\n", "VAR_16.setHeader('Pragma', 'no-cache')\n", "VAR_16.setHeader('Content-Type', 'text/html;charset=%s' % VAR_11['ZMS_CHARSET']\n )\n", "if not VAR_11.get('preview'):\n", "VAR_11.set('preview', 'preview')\n", "VAR_18 = self.getLanguages(VAR_11)\n", "if VAR_11.get('lang') not in VAR_18:\n", "VAR_11.set('lang', VAR_18[0])\n", "if VAR_11.get('manage_lang') not in self.getLocale().get_manage_langs():\n", "VAR_11.set('manage_lang', self.get_manage_lang())\n", "if not VAR_11.get('manage_tabs_message'):\n", "VAR_11.set('manage_tabs_message', self.getConfProperty(\n 'ZMS.manage_tabs_message', ''))\n", "if VAR_11.form.has_key('zmi-manage-system'):\n", "VAR_11.SESSION.set('zmi-manage-system', int(VAR_11.get('zmi-manage-system')))\n", "VAR_19 = self.getPhysicalPath()\n", "VAR_20 = VAR_11['URL0'][len(VAR_11['BASE0']):].split('/')\n", "VAR_21 = VAR_20[:-1]\n", "if len(filter(lambda x: x.find('.') > 0 or x.startswith('manage_'), VAR_21)\n", "for VAR_25 in range(len(VAR_21)):\n", "if VAR_21[:-(VAR_25 + 1)] != VAR_19[:-(VAR_25 + 1)]:\n", "VAR_23 = VAR_21 + [VAR_20[-1]]\n", "VAR_21[:-(VAR_25 + 1)] = VAR_19[:-(VAR_25 + 1)]\n", "if VAR_20 != VAR_23:\n", "VAR_11.RESPONSE.redirect('/'.join(VAR_23))\n" ]
[ "def zmi_page_request(self, *args, **kwargs):...\n", "request = self.REQUEST\n", "RESPONSE = request.RESPONSE\n", "SESSION = request.SESSION\n", "self._zmi_page_request()\n", "RESPONSE.setHeader('Expires', DateTime(request['ZMI_TIME'] - 10000).toZone(\n 'GMT+1').rfc822())\n", "RESPONSE.setHeader('Cache-Control', 'no-cache')\n", "RESPONSE.setHeader('Pragma', 'no-cache')\n", "RESPONSE.setHeader('Content-Type', 'text/html;charset=%s' % request[\n 'ZMS_CHARSET'])\n", "if not request.get('preview'):\n", "request.set('preview', 'preview')\n", "langs = self.getLanguages(request)\n", "if request.get('lang') not in langs:\n", "request.set('lang', langs[0])\n", "if request.get('manage_lang') not in self.getLocale().get_manage_langs():\n", "request.set('manage_lang', self.get_manage_lang())\n", "if not request.get('manage_tabs_message'):\n", "request.set('manage_tabs_message', self.getConfProperty(\n 'ZMS.manage_tabs_message', ''))\n", "if request.form.has_key('zmi-manage-system'):\n", "request.SESSION.set('zmi-manage-system', int(request.get('zmi-manage-system')))\n", "physical_path = self.getPhysicalPath()\n", "path_to_handle = request['URL0'][len(request['BASE0']):].split('/')\n", "path = path_to_handle[:-1]\n", "if len(filter(lambda x: x.find('.') > 0 or x.startswith('manage_'), path)\n", "for i in range(len(path)):\n", "if path[:-(i + 1)] != physical_path[:-(i + 1)]:\n", "new_path = path + [path_to_handle[-1]]\n", "path[:-(i + 1)] = physical_path[:-(i + 1)]\n", "if path_to_handle != new_path:\n", "request.RESPONSE.redirect('/'.join(new_path))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "For", "Expr'", "Assign'", "Assign'", "Assign'", "Condition", "For", "Condition", "Assign'", "Assign'", "Condition", "Expr'" ]
[ "def FUNC_4(VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_20 = enterprise_customer_for_request(VAR_3)\n", "if not VAR_20:\n", "return {}\n", "VAR_21 = configuration_helpers.get_value('PLATFORM_NAME', settings.\n PLATFORM_NAME)\n", "if VAR_20.branding_configuration.logo:\n", "VAR_34 = VAR_20.branding_configuration.logo.url\n", "VAR_34 = ''\n", "if getattr(VAR_20.branding_configuration, 'welcome_message', None):\n", "VAR_35 = VAR_20.branding_configuration.welcome_message\n", "VAR_35 = configuration_helpers.get_value(\n 'ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE', settings.\n ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE)\n", "VAR_22 = VAR_35.format(start_bold=u'<b>', end_bold=u'</b>', enterprise_name\n =enterprise_customer.name, VAR_21=platform_name)\n", "VAR_23 = configuration_helpers.get_value('ENTERPRISE_PLATFORM_WELCOME_TEMPLATE'\n , settings.ENTERPRISE_PLATFORM_WELCOME_TEMPLATE)\n", "VAR_24 = VAR_23.format(VAR_21=platform_name)\n", "VAR_5 = {'enterprise_name': VAR_20.name, 'enterprise_logo_url': VAR_34,\n 'enterprise_branded_welcome_string': VAR_22, 'platform_welcome_string':\n VAR_24}\n", "return VAR_5\n" ]
[ "def enterprise_sidebar_context(request):...\n", "\"\"\"docstring\"\"\"\n", "enterprise_customer = enterprise_customer_for_request(request)\n", "if not enterprise_customer:\n", "return {}\n", "platform_name = configuration_helpers.get_value('PLATFORM_NAME', settings.\n PLATFORM_NAME)\n", "if enterprise_customer.branding_configuration.logo:\n", "enterprise_logo_url = enterprise_customer.branding_configuration.logo.url\n", "enterprise_logo_url = ''\n", "if getattr(enterprise_customer.branding_configuration, 'welcome_message', None\n", "branded_welcome_template = (enterprise_customer.branding_configuration.\n welcome_message)\n", "branded_welcome_template = configuration_helpers.get_value(\n 'ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE', settings.\n ENTERPRISE_SPECIFIC_BRANDED_WELCOME_TEMPLATE)\n", "branded_welcome_string = branded_welcome_template.format(start_bold=u'<b>',\n end_bold=u'</b>', enterprise_name=enterprise_customer.name,\n platform_name=platform_name)\n", "platform_welcome_template = configuration_helpers.get_value(\n 'ENTERPRISE_PLATFORM_WELCOME_TEMPLATE', settings.\n ENTERPRISE_PLATFORM_WELCOME_TEMPLATE)\n", "platform_welcome_string = platform_welcome_template.format(platform_name=\n platform_name)\n", "context = {'enterprise_name': enterprise_customer.name,\n 'enterprise_logo_url': enterprise_logo_url,\n 'enterprise_branded_welcome_string': branded_welcome_string,\n 'platform_welcome_string': platform_welcome_string}\n", "return context\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Return'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_23(self):...\n", "return self._email\n" ]
[ "def email(self):...\n", "return self._email\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@commands.command(pass_context=True, name='7zip')...\n", "\"\"\"docstring\"\"\"\n", "VAR_7 = discord.Embed(VAR_2='Download 7zip', VAR_3=discord.Color(255))\n", "VAR_7.set_thumbnail(url='http://i.imgur.com/cX1fuf6.png')\n", "VAR_7.url = 'http://www.7-zip.org/download.html'\n", "VAR_7.description = (\n 'To be able to extract .7z files you need 7zip installed, get it here.')\n", "await self.bot.say('', VAR_7=embed)\n" ]
[ "@commands.command(pass_context=True, name='7zip')...\n", "\"\"\"docstring\"\"\"\n", "embed = discord.Embed(title='Download 7zip', color=discord.Color(255))\n", "embed.set_thumbnail(url='http://i.imgur.com/cX1fuf6.png')\n", "embed.url = 'http://www.7-zip.org/download.html'\n", "embed.description = (\n 'To be able to extract .7z files you need 7zip installed, get it here.')\n", "await self.bot.say('', embed=embed)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "@classmethod...\n", "" ]
[ "@classmethod...\n", "" ]
[ 0, 0 ]
[ "Condition", "Condition" ]
[ "def FUNC_21(VAR_11=5):...\n", "return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in\n range(VAR_11))\n" ]
[ "def genSingleToken(length=5):...\n", "return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in\n range(length))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_17(self, VAR_13):...\n", "VAR_5 = self.found_tags[VAR_13]\n", "VAR_24 = self.view.window().new_file()\n", "VAR_24.run_command('insert_snippet', {'contents': \n \"\"\"\nFiles found for tag: %s\n\n\"\"\" % VAR_5})\n", "for file in self.tagged_files[VAR_5]:\n", "VAR_42 = file.get_tag('title')[0] + ' -> ' + file.filename + '\\n'\n", "VAR_24.run_command('insert_snippet', {'contents': VAR_42})\n" ]
[ "def list_files(self, selected_tag):...\n", "tag = self.found_tags[selected_tag]\n", "new_view = self.view.window().new_file()\n", "new_view.run_command('insert_snippet', {'contents': \n \"\"\"\nFiles found for tag: %s\n\n\"\"\" % tag})\n", "for file in self.tagged_files[tag]:\n", "listing = file.get_tag('title')[0] + ' -> ' + file.filename + '\\n'\n", "new_view.run_command('insert_snippet', {'contents': listing})\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "For", "Assign'", "Expr'" ]
[ "def __init__(self, VAR_2={}, VAR_3=False, VAR_4='campaign-data/db.sqlite3'):...\n", "if not exists(VAR_4):\n", "self.campaign = VAR_2\n", "self.result = {}\n", "self.file = VAR_4\n", "self.lock = Lock()\n", "if VAR_3:\n", "db.__create_result()\n" ]
[ "def __init__(self, campaign={}, create_result=False, database_file=...\n", "if not exists(database_file):\n", "self.campaign = campaign\n", "self.result = {}\n", "self.file = database_file\n", "self.lock = Lock()\n", "if create_result:\n", "db.__create_result()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'" ]
[ "from __future__ import absolute_import\n", "from mock import MagicMock, patch\n", "from six.moves.urllib_parse import quote_plus\n", "from flask import url_for, session\n", "from invenio.testsuite import make_test_suite, run_test_suite\n", "from invenio.ext.sqlalchemy import db\n", "from .helpers import OAuth2ClientTestCase\n", "def FUNC_0(self):...\n", "VAR_8 = lambda x: dict(request_token_params={'scope': ''}, base_url=\n 'https://foo.bar/', request_token_url=None, access_token_url=\n 'https://foo.bar/oauth/access_token', authorize_url=\n 'https://foo.bar/oauth/authorize', consumer_key=x, consumer_secret=\n 'testsecret')\n", "self.app.config['OAUTHCLIENT_REMOTE_APPS'] = dict(test=dict(\n authorized_handler=self.handler, params=params('testid'), title=\n 'MyLinkedTestAccount'), test_invalid=dict(authorized_handler=self.\n handler_invalid, params=params('test_invalidid'), title='Test Invalid'),\n full=dict(params=params('fullid'), title='Full'))\n", "self.handled_resp = None\n", "self.handled_remote = None\n", "self.handled_args = None\n", "self.handled_kwargs = None\n", "from invenio.modules.oauthclient.models import RemoteToken, RemoteAccount\n", "RemoteToken.query.delete()\n", "RemoteAccount.query.delete()\n", "db.session.commit()\n", "def FUNC_1(self):...\n", "self.handled_resp = None\n", "self.handled_remote = None\n", "self.handled_args = None\n", "self.handled_kwargs = None\n", "from invenio.modules.oauthclient.models import RemoteToken, RemoteAccount\n", "RemoteToken.query.delete()\n", "RemoteAccount.query.delete()\n", "db.session.commit()\n", "def FUNC_2(self, VAR_1, VAR_2, *VAR_3, **VAR_4):...\n", "self.handled_resp = VAR_1\n", "self.handled_remote = VAR_2\n", "self.handled_args = VAR_3\n", "self.handled_kwargs = VAR_4\n", "return 'TEST'\n" ]
[ "from __future__ import absolute_import\n", "from mock import MagicMock, patch\n", "from six.moves.urllib_parse import quote_plus\n", "from flask import url_for, session\n", "from invenio.testsuite import make_test_suite, run_test_suite\n", "from invenio.ext.sqlalchemy import db\n", "from .helpers import OAuth2ClientTestCase\n", "def setUp(self):...\n", "params = lambda x: dict(request_token_params={'scope': ''}, base_url=\n 'https://foo.bar/', request_token_url=None, access_token_url=\n 'https://foo.bar/oauth/access_token', authorize_url=\n 'https://foo.bar/oauth/authorize', consumer_key=x, consumer_secret=\n 'testsecret')\n", "self.app.config['OAUTHCLIENT_REMOTE_APPS'] = dict(test=dict(\n authorized_handler=self.handler, params=params('testid'), title=\n 'MyLinkedTestAccount'), test_invalid=dict(authorized_handler=self.\n handler_invalid, params=params('test_invalidid'), title='Test Invalid'),\n full=dict(params=params('fullid'), title='Full'))\n", "self.handled_resp = None\n", "self.handled_remote = None\n", "self.handled_args = None\n", "self.handled_kwargs = None\n", "from invenio.modules.oauthclient.models import RemoteToken, RemoteAccount\n", "RemoteToken.query.delete()\n", "RemoteAccount.query.delete()\n", "db.session.commit()\n", "def tearDown(self):...\n", "self.handled_resp = None\n", "self.handled_remote = None\n", "self.handled_args = None\n", "self.handled_kwargs = None\n", "from invenio.modules.oauthclient.models import RemoteToken, RemoteAccount\n", "RemoteToken.query.delete()\n", "RemoteAccount.query.delete()\n", "db.session.commit()\n", "def handler(self, resp, remote, *args, **kwargs):...\n", "self.handled_resp = resp\n", "self.handled_remote = remote\n", "self.handled_args = args\n", "self.handled_kwargs = kwargs\n", "return 'TEST'\n" ]
[ 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 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "ImportFrom'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "ImportFrom'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_26(self):...\n", "return self.user_id\n" ]
[ "def get_id(self):...\n", "return self.user_id\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_5(VAR_12):...\n", "\"\"\"docstring\"\"\"\n", "if isinstance(VAR_12, str):\n", "return unicoder(VAR_12)\n", "if isinstance(VAR_12, list):\n", "VAR_82 = []\n", "if isinstance(VAR_12, dict):\n", "for VAR_58 in VAR_12:\n", "VAR_82 = {}\n", "return VAR_12\n", "VAR_82.append(FUNC_5(VAR_58))\n", "return VAR_82\n", "for VAR_85 in VAR_12:\n", "VAR_82[VAR_85] = FUNC_5(VAR_12[VAR_85])\n", "return VAR_82\n" ]
[ "def decode_factory(text):...\n", "\"\"\"docstring\"\"\"\n", "if isinstance(text, str):\n", "return unicoder(text)\n", "if isinstance(text, list):\n", "new_text = []\n", "if isinstance(text, dict):\n", "for t in text:\n", "new_text = {}\n", "return text\n", "new_text.append(decode_factory(t))\n", "return new_text\n", "for key in text:\n", "new_text[key] = decode_factory(text[key])\n", "return new_text\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "Assign'", "Condition", "For", "Assign'", "Return'", "Expr'", "Return'", "For", "Assign'", "Return'" ]
[ "def FUNC_5(self):...\n", "\"\"\"docstring\"\"\"\n", "if not self.run_local:\n", "if not (self.configuration.san_password or self.configuration.san_private_key):\n", "if not self.configuration.san_ip:\n" ]
[ "def check_for_setup_error(self):...\n", "\"\"\"docstring\"\"\"\n", "if not self.run_local:\n", "if not (self.configuration.san_password or self.configuration.san_private_key):\n", "if not self.configuration.san_ip:\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Condition", "Condition" ]
[ "@staticmethod...\n", "return mongo.db.analysis.find_one({'info.id': int(VAR_1)}, sort=[('_id',\n pymongo.DESCENDING)])\n" ]
[ "@staticmethod...\n", "return mongo.db.analysis.find_one({'info.id': int(task_id)}, sort=[('_id',\n pymongo.DESCENDING)])\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_3(self, VAR_4, VAR_5):...\n", "VAR_9 = 'string'.format(VAR_4, VAR_5)\n", "VAR_7 = self.__conn.cursor()\n", "VAR_7.execute(VAR_9)\n", "VAR_10 = VAR_7.fetchone()\n", "if VAR_10:\n", "return Client(VAR_10[0], VAR_10[1], VAR_10[2], VAR_10[3])\n", "return False\n" ]
[ "def login(self, username, password):...\n", "select_query = (\n \"\"\"\n SELECT client_id, username, balance, message\n FROM Clients\n WHERE username = '{}' AND password = '{}'\n LIMIT 1\n \"\"\"\n .format(username, password))\n", "cursor = self.__conn.cursor()\n", "cursor.execute(select_query)\n", "user = cursor.fetchone()\n", "if user:\n", "return Client(user[0], user[1], user[2], user[3])\n", "return False\n" ]
[ 0, 4, 0, 4, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_27(VAR_21):...\n", "if VAR_21.type != 'response':\n", "return False\n", "VAR_33['msg'] = VAR_21\n", "return VAR_21.request_seq == VAR_13\n" ]
[ "def match(msg):...\n", "if msg.type != 'response':\n", "return False\n", "result['msg'] = msg\n", "return msg.request_seq == seq\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "Return'" ]
[ "def FUNC_14(self, VAR_22=4567, VAR_23='127.0.0.1'):...\n", "reactor.listenTCP(VAR_22, PixelatedSite(self.resource), interface=host)\n" ]
[ "def listenTCP(self, port=4567, host='127.0.0.1'):...\n", "reactor.listenTCP(port, PixelatedSite(self.resource), interface=host)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_2(VAR_14, VAR_15=None, VAR_16=None, VAR_17='width=\\\\textwidth'):...\n", "if not VAR_16:\n", "VAR_16 = VAR_15[0][0]\n", "if VAR_14[0]:\n", "if VAR_14[1]:\n", "if VAR_14[1]:\n", "return self.markers[0] % (VAR_14[0][0], VAR_14[0][1], VAR_14[1][0], VAR_14[\n 1][1], VAR_16)\n", "return self.markers[1] % (VAR_14[0][0], VAR_14[0][1], VAR_16)\n", "return self.markers[2] % (VAR_14[1][0], VAR_14[1][1], VAR_16)\n", "return self.markers[3] % (VAR_17, VAR_16)\n" ]
[ "def singleImage(dims, files=None, file=None, implicitDims='width=\\\\textwidth'):...\n", "if not file:\n", "file = files[0][0]\n", "if dims[0]:\n", "if dims[1]:\n", "if dims[1]:\n", "return self.markers[0] % (dims[0][0], dims[0][1], dims[1][0], dims[1][1], file)\n", "return self.markers[1] % (dims[0][0], dims[0][1], file)\n", "return self.markers[2] % (dims[1][0], dims[1][1], file)\n", "return self.markers[3] % (implicitDims, file)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Condition", "Condition", "Condition", "Return'", "Return'", "Return'", "Return'" ]
[ "def FUNC_0(VAR_2, VAR_3):...\n", "\"\"\"docstring\"\"\"\n", "VAR_5 = dict(external_id=resp.get('orcid'), external_method='orcid')\n", "return VAR_5\n" ]
[ "def account_info(remote, resp):...\n", "\"\"\"docstring\"\"\"\n", "account_info = dict(external_id=resp.get('orcid'), external_method='orcid')\n", "return account_info\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_13(self, VAR_8):...\n", "logging.info('Rebooting bot: %s', VAR_8)\n", "VAR_36 = {'cmd': 'restart', 'message': VAR_8}\n", "self.send_response(VAR_36)\n" ]
[ "def _cmd_restart(self, message):...\n", "logging.info('Rebooting bot: %s', message)\n", "out = {'cmd': 'restart', 'message': message}\n", "self.send_response(out)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Expr'" ]
[ "def __init__(self, VAR_32, *, VAR_33=0):...\n", "self.wires = VAR_32\n", "self.eng = None\n", "self._state = None\n", "super().__init__(self.short_name, VAR_33)\n" ]
[ "def __init__(self, wires, *, shots=0):...\n", "self.wires = wires\n", "self.eng = None\n", "self._state = None\n", "super().__init__(self.short_name, shots)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "@utils.synchronized('3par', external=True)...\n", "" ]
[ "@utils.synchronized('3par', external=True)...\n", "" ]
[ 0, 0 ]
[ "Condition", "Condition" ]
[ "def __init__(self, VAR_1, VAR_4=None):...\n", "\"\"\"docstring\"\"\"\n", "super(CLASS_0, self).__init__(VAR_1, VAR_4)\n", "VAR_1 = self.bindings\n", "VAR_1['TEST_APP_COMPONENT_NAME'] = '{app}-{stack}-{detail}'.format(app=\n bindings['TEST_APP'], stack=bindings['TEST_STACK'], detail=bindings[\n 'TEST_COMPONENT_DETAIL'])\n", "self.TEST_APP = VAR_1['TEST_APP']\n" ]
[ "def __init__(self, bindings, agent=None):...\n", "\"\"\"docstring\"\"\"\n", "super(AwsSmokeTestScenario, self).__init__(bindings, agent)\n", "bindings = self.bindings\n", "bindings['TEST_APP_COMPONENT_NAME'] = '{app}-{stack}-{detail}'.format(app=\n bindings['TEST_APP'], stack=bindings['TEST_STACK'], detail=bindings[\n 'TEST_COMPONENT_DETAIL'])\n", "self.TEST_APP = bindings['TEST_APP']\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Assign'" ]
[ "import collections\n", "import os\n", "import pytest\n", "import tempfile\n", "import unittest\n", "import reframe as rfm\n", "import reframe.core.runtime as rt\n", "import reframe.frontend.dependency as dependency\n", "import reframe.frontend.executors as executors\n", "import reframe.frontend.executors.policies as policies\n", "import reframe.utility.os_ext as os_ext\n", "from reframe.core.exceptions import DependencyError, JobNotStartedError\n", "from reframe.frontend.loader import RegressionCheckLoader\n", "import unittests.fixtures as fixtures\n", "from unittests.resources.checks.hellocheck import HelloTest\n", "from unittests.resources.checks.frontend_checks import BadSetupCheck, BadSetupCheckEarly, KeyboardInterruptCheck, RetriesCheck, SleepCheck, SleepCheckPollFail, SleepCheckPollFailLate, SystemExitCheck\n", "def FUNC_0(self):...\n", "self.loader = RegressionCheckLoader(['unittests/resources/checks'],\n ignore_conflicts=True)\n", "self.runner = executors.Runner(policies.SerialExecutionPolicy())\n", "self.checks = self.loader.load_all()\n", "rt.runtime().resources.prefix = tempfile.mkdtemp(dir='unittests')\n", "rt.runtime()._current_run = 0\n", "def FUNC_1(self):...\n", "os_ext.rmtree(rt.runtime().resources.prefix)\n", "def FUNC_2(self, VAR_0, *VAR_1, **VAR_2):...\n", "VAR_14 = executors.generate_testcases(VAR_0, *VAR_1, **kwargs)\n", "self.runner.runall(VAR_14)\n", "def FUNC_3(self, VAR_3):...\n", "VAR_15 = self.runner.stats\n", "return len([VAR_33 for VAR_33 in VAR_15.failures() if VAR_33.failed_stage ==\n VAR_3])\n" ]
[ "import collections\n", "import os\n", "import pytest\n", "import tempfile\n", "import unittest\n", "import reframe as rfm\n", "import reframe.core.runtime as rt\n", "import reframe.frontend.dependency as dependency\n", "import reframe.frontend.executors as executors\n", "import reframe.frontend.executors.policies as policies\n", "import reframe.utility.os_ext as os_ext\n", "from reframe.core.exceptions import DependencyError, JobNotStartedError\n", "from reframe.frontend.loader import RegressionCheckLoader\n", "import unittests.fixtures as fixtures\n", "from unittests.resources.checks.hellocheck import HelloTest\n", "from unittests.resources.checks.frontend_checks import BadSetupCheck, BadSetupCheckEarly, KeyboardInterruptCheck, RetriesCheck, SleepCheck, SleepCheckPollFail, SleepCheckPollFailLate, SystemExitCheck\n", "def setUp(self):...\n", "self.loader = RegressionCheckLoader(['unittests/resources/checks'],\n ignore_conflicts=True)\n", "self.runner = executors.Runner(policies.SerialExecutionPolicy())\n", "self.checks = self.loader.load_all()\n", "rt.runtime().resources.prefix = tempfile.mkdtemp(dir='unittests')\n", "rt.runtime()._current_run = 0\n", "def tearDown(self):...\n", "os_ext.rmtree(rt.runtime().resources.prefix)\n", "def runall(self, checks, *args, **kwargs):...\n", "cases = executors.generate_testcases(checks, *args, **kwargs)\n", "self.runner.runall(cases)\n", "def _num_failures_stage(self, stage):...\n", "stats = self.runner.stats\n", "return len([t for t in stats.failures() if t.failed_stage == stage])\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 ]
[ "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Expr'", "FunctionDef'", "Assign'", "Expr'", "FunctionDef'", "Assign'", "Return'" ]
[ "from __future__ import absolute_import, print_function\n", "import contextlib\n", "import json\n", "import socket\n", "import sys\n", "import time\n", "import threading\n", "import warnings\n", "from ptvsd._util import new_hidden_thread, Closeable, ClosedError\n", "from .message import raw_read_all as read_messages, raw_write_one as write_message\n", "from .socket import Connection, create_server, create_client, close, recv_as_read, send_as_write, timeout as socket_timeout\n", "from .threading import get_locked_and_waiter\n", "from .vsc import parse_message\n", "VAR_0 = False\n", "VAR_1 = 5.0\n", "@classmethod...\n", "def FUNC_25(VAR_3, VAR_6):...\n", "VAR_7 = FUNC_0()\n", "for VAR_41 in range(int(VAR_6 * 10)):\n", "return VAR_7\n", "VAR_7.connect(VAR_3)\n", "if VAR_2.VERBOSE:\n", "print('+', end='')\n", "time.sleep(0.1)\n", "sys.stdout.flush()\n" ]
[ "from __future__ import absolute_import, print_function\n", "import contextlib\n", "import json\n", "import socket\n", "import sys\n", "import time\n", "import threading\n", "import warnings\n", "from ptvsd._util import new_hidden_thread, Closeable, ClosedError\n", "from .message import raw_read_all as read_messages, raw_write_one as write_message\n", "from .socket import Connection, create_server, create_client, close, recv_as_read, send_as_write, timeout as socket_timeout\n", "from .threading import get_locked_and_waiter\n", "from .vsc import parse_message\n", "VERBOSE = False\n", "TIMEOUT = 5.0\n", "@classmethod...\n", "def connect(addr, timeout):...\n", "sock = create_client()\n", "for _ in range(int(timeout * 10)):\n", "return sock\n", "sock.connect(addr)\n", "if cls.VERBOSE:\n", "print('+', end='')\n", "time.sleep(0.1)\n", "sys.stdout.flush()\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 ]
[ "ImportFrom'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Condition", "FunctionDef'", "Assign'", "For", "Return'", "Expr'", "Condition", "Expr'", "Expr'", "Expr'" ]
[ "\"\"\"API endpoints dealing with submissions.\"\"\"\n", "from tornado.escape import json_encode, to_unicode\n", "import tornado.web\n", "import api.submission\n", "from db.survey import IncorrectQuestionIdError\n", "from pages.util.base import APIHandler, get_email, get_json_request_body, catch_bare_integrity_error, validation_message, BaseHandler\n", "\"\"\"The endpoint for getting all submissions to a survey.\"\"\"\n", "def FUNC_0(self):...\n", "if 'submitter' in self.request.arguments:\n", "return list(map(to_unicode, self.request.arguments['submitter']))\n", "def FUNC_1(self, VAR_0: str):...\n", "VAR_2 = self._get_subs()\n", "VAR_3 = api.submission.get_all(VAR_0, email=get_email(self), submitters=subs)\n", "self.write(VAR_3)\n", "def FUNC_2(self, VAR_0: str):...\n", "VAR_4 = get_json_request_body(self)\n", "VAR_2 = VAR_4.get('submitters', None)\n", "VAR_5 = VAR_4.get('filters', None)\n", "VAR_3 = api.submission.get_all(VAR_0, email=get_email(self), submitters=\n subs, VAR_5=filters)\n", "self.write(VAR_3)\n", "\"\"\"The endpoint for getting a single submission.\"\"\"\n", "def FUNC_1(self, VAR_1: str):...\n", "VAR_3 = api.submission.get_one(VAR_1, email=get_email(self))\n", "self.write(VAR_3)\n", "\"\"\"The endpoint for submitting to a survey. You don't need to log in.\"\"\"\n", "@catch_bare_integrity_error...\n", "VAR_6 = get_json_request_body(self)\n", "if VAR_6.get('survey_id', None) != VAR_0:\n", "VAR_7 = validation_message('submission', 'survey_id', 'invalid')\n", "self.write(api.submission.submit(VAR_6))\n", "VAR_7 = validation_message('submission', str(e), 'missing_field')\n", "self.set_status(201)\n", "VAR_7 = validation_message('submission', 'question_id', 'invalid')\n" ]
[ "\"\"\"API endpoints dealing with submissions.\"\"\"\n", "from tornado.escape import json_encode, to_unicode\n", "import tornado.web\n", "import api.submission\n", "from db.survey import IncorrectQuestionIdError\n", "from pages.util.base import APIHandler, get_email, get_json_request_body, catch_bare_integrity_error, validation_message, BaseHandler\n", "\"\"\"The endpoint for getting all submissions to a survey.\"\"\"\n", "def _get_subs(self):...\n", "if 'submitter' in self.request.arguments:\n", "return list(map(to_unicode, self.request.arguments['submitter']))\n", "def get(self, survey_id: str):...\n", "subs = self._get_subs()\n", "response = api.submission.get_all(survey_id, email=get_email(self),\n submitters=subs)\n", "self.write(response)\n", "def post(self, survey_id: str):...\n", "body = get_json_request_body(self)\n", "subs = body.get('submitters', None)\n", "filters = body.get('filters', None)\n", "response = api.submission.get_all(survey_id, email=get_email(self),\n submitters=subs, filters=filters)\n", "self.write(response)\n", "\"\"\"The endpoint for getting a single submission.\"\"\"\n", "def get(self, submission_id: str):...\n", "response = api.submission.get_one(submission_id, email=get_email(self))\n", "self.write(response)\n", "\"\"\"The endpoint for submitting to a survey. You don't need to log in.\"\"\"\n", "@catch_bare_integrity_error...\n", "data = get_json_request_body(self)\n", "if data.get('survey_id', None) != survey_id:\n", "reason = validation_message('submission', 'survey_id', 'invalid')\n", "self.write(api.submission.submit(data))\n", "reason = validation_message('submission', str(e), 'missing_field')\n", "self.set_status(201)\n", "reason = validation_message('submission', 'question_id', 'invalid')\n" ]
[ 0, 5, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "ImportFrom'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "Expr'", "FunctionDef'", "Condition", "Return'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Expr'", "Expr'", "Condition", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'" ]
[ "def FUNC_4(self, *VAR_4, **VAR_6):...\n", "\"\"\"docstring\"\"\"\n", "for VAR_9 in VAR_4:\n", "self._set_inoutput_item(VAR_9)\n", "for VAR_10, VAR_9 in VAR_6.items():\n", "self._set_inoutput_item(VAR_9, VAR_10=name)\n" ]
[ "def set_input(self, *input, **kwinput):...\n", "\"\"\"docstring\"\"\"\n", "for item in input:\n", "self._set_inoutput_item(item)\n", "for name, item in kwinput.items():\n", "self._set_inoutput_item(item, name=name)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "For", "Expr'", "For", "Expr'" ]
[ "def __str__(self):...\n", "return self.get_name()\n" ]
[ "def __str__(self):...\n", "return self.get_name()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_1(VAR_1):...\n", "return FUNC_0(VAR_1[0])\n" ]
[ "def fix_sort_list(list):...\n", "return fix_sort(list[0])\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_8(self, VAR_9, VAR_7=False, VAR_10=None):...\n", "\"\"\"docstring\"\"\"\n", "VAR_29 = self.output if VAR_7 else self.input\n", "if isinstance(VAR_9, str):\n", "if isinstance(VAR_9, _IOFile):\n", "if callable(VAR_9):\n", "self.dependencies[VAR_9] = VAR_9.rule\n", "VAR_44 = IOFile(VAR_9, VAR_16=self)\n", "if VAR_7:\n", "VAR_48 = len(VAR_29)\n", "if is_flagged(VAR_9, 'temp'):\n", "VAR_29.append(VAR_9)\n", "for VAR_51 in VAR_9:\n", "if not VAR_7:\n", "if is_flagged(VAR_9, 'protected'):\n", "if VAR_10:\n", "self._set_inoutput_item(VAR_51, VAR_7=output)\n", "if VAR_10:\n", "self.temp_output.add(VAR_44)\n", "if not VAR_7:\n", "if is_flagged(VAR_9, 'touch'):\n", "VAR_29.add_name(VAR_10)\n", "VAR_29.set_name(VAR_10, VAR_48, end=len(inoutput))\n", "self.protected_output.add(VAR_44)\n", "if not VAR_7:\n", "if is_flagged(VAR_9, 'dynamic'):\n", "self.touch_output.add(VAR_44)\n", "if VAR_7:\n", "if is_flagged(VAR_9, 'subworkflow'):\n", "self.dynamic_output.add(VAR_44)\n", "self.dynamic_input.add(VAR_44)\n", "if VAR_7:\n", "VAR_29.append(VAR_44)\n", "self.subworkflow_input[VAR_44] = VAR_9.flags['subworkflow']\n", "if VAR_10:\n", "VAR_29.add_name(VAR_10)\n" ]
[ "def _set_inoutput_item(self, item, output=False, name=None):...\n", "\"\"\"docstring\"\"\"\n", "inoutput = self.output if output else self.input\n", "if isinstance(item, str):\n", "if isinstance(item, _IOFile):\n", "if callable(item):\n", "self.dependencies[item] = item.rule\n", "_item = IOFile(item, rule=self)\n", "if output:\n", "start = len(inoutput)\n", "if is_flagged(item, 'temp'):\n", "inoutput.append(item)\n", "for i in item:\n", "if not output:\n", "if is_flagged(item, 'protected'):\n", "if name:\n", "self._set_inoutput_item(i, output=output)\n", "if name:\n", "self.temp_output.add(_item)\n", "if not output:\n", "if is_flagged(item, 'touch'):\n", "inoutput.add_name(name)\n", "inoutput.set_name(name, start, end=len(inoutput))\n", "self.protected_output.add(_item)\n", "if not output:\n", "if is_flagged(item, 'dynamic'):\n", "self.touch_output.add(_item)\n", "if output:\n", "if is_flagged(item, 'subworkflow'):\n", "self.dynamic_output.add(_item)\n", "self.dynamic_input.add(_item)\n", "if output:\n", "inoutput.append(_item)\n", "self.subworkflow_input[_item] = item.flags['subworkflow']\n", "if name:\n", "inoutput.add_name(name)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "For", "Condition", "Condition", "Condition", "Expr'", "Condition", "Expr'", "Condition", "Condition", "Expr'", "Expr'", "Expr'", "Condition", "Condition", "Expr'", "Condition", "Condition", "Expr'", "Expr'", "Condition", "Expr'", "Assign'", "Condition", "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'" ]
[ "def FUNC_7(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_14, VAR_15 = new_log_monitor_log_file()\n", "VAR_16 = ray.services.start_log_monitor(self.redis_address, self.\n _node_ip_address, VAR_14=stdout_file, VAR_15=stderr_file,\n redis_password=self._ray_params.redis_password)\n", "assert VAR_13.PROCESS_TYPE_LOG_MONITOR not in self.all_processes\n", "self.all_processes[VAR_13.PROCESS_TYPE_LOG_MONITOR] = [VAR_16]\n" ]
[ "def start_log_monitor(self):...\n", "\"\"\"docstring\"\"\"\n", "stdout_file, stderr_file = new_log_monitor_log_file()\n", "process_info = ray.services.start_log_monitor(self.redis_address, self.\n _node_ip_address, stdout_file=stdout_file, stderr_file=stderr_file,\n redis_password=self._ray_params.redis_password)\n", "assert ray_constants.PROCESS_TYPE_LOG_MONITOR not in self.all_processes\n", "self.all_processes[ray_constants.PROCESS_TYPE_LOG_MONITOR] = [process_info]\n" ]
[ 0, 0, 0, 6, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assert'", "Assign'" ]
[ "def FUNC_13(self, VAR_13):...\n", "if VAR_13:\n", "self._update_backend_status()\n", "return self.device_stats\n" ]
[ "def get_volume_stats(self, refresh):...\n", "if refresh:\n", "self._update_backend_status()\n", "return self.device_stats\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_27(self, VAR_15):...\n", "" ]
[ "def add(self, item):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "from __future__ import absolute_import\n", "from __future__ import division\n", "from __future__ import print_function\n", "import argparse\n", "import logging\n", "import os\n", "import redis\n", "import time\n", "import ray.ray_constants as ray_constants\n", "from ray.services import get_ip_address\n", "from ray.services import get_port\n", "import ray.utils\n", "VAR_0 = logging.getLogger(__name__)\n", "\"\"\"string\"\"\"\n", "def __init__(self, VAR_1, VAR_2, VAR_3, VAR_4=None):...\n", "\"\"\"docstring\"\"\"\n", "self.node_ip_address = VAR_3\n", "self.redis_client = redis.StrictRedis(host=redis_ip_address, port=\n redis_port, password=redis_password)\n", "self.log_files = {}\n", "self.log_file_handles = {}\n", "self.files_to_ignore = set()\n", "def FUNC_0(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_8 = len(self.log_files)\n", "VAR_9 = self.redis_client.lrange('LOG_FILENAMES:{}'.format(self.\n node_ip_address), VAR_8, -1)\n", "for VAR_10 in VAR_9:\n", "VAR_0.info('Beginning to track file {}'.format(VAR_10))\n", "def FUNC_1(self):...\n", "assert VAR_10 not in self.log_files\n", "\"\"\"docstring\"\"\"\n", "self.log_files[VAR_10] = []\n", "for VAR_10 in self.log_files:\n", "if VAR_10 in self.log_file_handles:\n", "def FUNC_2(self):...\n", "VAR_11 = []\n", "if VAR_10 in self.files_to_ignore:\n", "\"\"\"docstring\"\"\"\n", "while True:\n", "self.log_file_handles[VAR_10] = open(VAR_10, 'r')\n", "if e.errno == os.errno.EMFILE:\n", "while True:\n", "VAR_12 = self.log_file_handles[VAR_10].tell()\n", "VAR_0.warning('Warning: Ignoring {} because there are too many open files.'\n .format(VAR_10))\n", "if e.errno == os.errno.ENOENT:\n", "self.update_log_filenames()\n", "VAR_13 = self.log_file_handles[VAR_10].readline()\n", "self.files_to_ignore.add(VAR_10)\n", "VAR_0.warning('Warning: The file {} was not found.'.format(VAR_10))\n", "self.check_log_files_and_push_updates()\n", "if VAR_13 != '':\n", "time.sleep(1)\n", "VAR_11.append(VAR_13)\n", "self.log_file_handles[VAR_10].seek(VAR_12)\n", "if len(VAR_11) > 0:\n", "self.log_files[VAR_10] += VAR_11\n", "VAR_14 = 'LOGFILE:{}:{}'.format(self.node_ip_address, ray.utils.decode(VAR_10))\n", "self.redis_client.rpush(VAR_14, *VAR_11)\n" ]
[ "from __future__ import absolute_import\n", "from __future__ import division\n", "from __future__ import print_function\n", "import argparse\n", "import logging\n", "import os\n", "import redis\n", "import time\n", "import ray.ray_constants as ray_constants\n", "from ray.services import get_ip_address\n", "from ray.services import get_port\n", "import ray.utils\n", "logger = logging.getLogger(__name__)\n", "\"\"\"A monitor process for monitoring Ray log files.\n\n Attributes:\n node_ip_address: The IP address of the node that the log monitor\n process is running on. This will be used to determine which log\n files to track.\n redis_client: A client used to communicate with the Redis server.\n log_files: A dictionary mapping the name of a log file to a list of\n strings representing its contents.\n log_file_handles: A dictionary mapping the name of a log file to a file\n handle for that file.\n \"\"\"\n", "def __init__(self, redis_ip_address, redis_port, node_ip_address,...\n", "\"\"\"docstring\"\"\"\n", "self.node_ip_address = node_ip_address\n", "self.redis_client = redis.StrictRedis(host=redis_ip_address, port=\n redis_port, password=redis_password)\n", "self.log_files = {}\n", "self.log_file_handles = {}\n", "self.files_to_ignore = set()\n", "def update_log_filenames(self):...\n", "\"\"\"docstring\"\"\"\n", "num_current_log_files = len(self.log_files)\n", "new_log_filenames = self.redis_client.lrange('LOG_FILENAMES:{}'.format(self\n .node_ip_address), num_current_log_files, -1)\n", "for log_filename in new_log_filenames:\n", "logger.info('Beginning to track file {}'.format(log_filename))\n", "def check_log_files_and_push_updates(self):...\n", "assert log_filename not in self.log_files\n", "\"\"\"docstring\"\"\"\n", "self.log_files[log_filename] = []\n", "for log_filename in self.log_files:\n", "if log_filename in self.log_file_handles:\n", "def run(self):...\n", "new_lines = []\n", "if log_filename in self.files_to_ignore:\n", "\"\"\"docstring\"\"\"\n", "while True:\n", "self.log_file_handles[log_filename] = open(log_filename, 'r')\n", "if e.errno == os.errno.EMFILE:\n", "while True:\n", "current_position = self.log_file_handles[log_filename].tell()\n", "logger.warning('Warning: Ignoring {} because there are too many open files.'\n .format(log_filename))\n", "if e.errno == os.errno.ENOENT:\n", "self.update_log_filenames()\n", "next_line = self.log_file_handles[log_filename].readline()\n", "self.files_to_ignore.add(log_filename)\n", "logger.warning('Warning: The file {} was not found.'.format(log_filename))\n", "self.check_log_files_and_push_updates()\n", "if next_line != '':\n", "time.sleep(1)\n", "new_lines.append(next_line)\n", "self.log_file_handles[log_filename].seek(current_position)\n", "if len(new_lines) > 0:\n", "self.log_files[log_filename] += new_lines\n", "redis_key = 'LOGFILE:{}:{}'.format(self.node_ip_address, ray.utils.decode(\n log_filename))\n", "self.redis_client.rpush(redis_key, *new_lines)\n" ]
[ 0, 0, 0, 0, 0, 0, 6, 6, 0, 6, 6, 0, 0, 6, 0, 0, 6, 6, 6, 6, 6, 0, 0, 6, 6, 6, 0, 0, 6, 0, 6, 6, 6, 0, 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Import'", "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "Import'", "Assign'", "Expr'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "For", "Expr'", "FunctionDef'", "Assert'", "Docstring", "Assign'", "For", "Condition", "FunctionDef'", "Assign'", "Condition", "Docstring", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Expr'", "Condition", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Condition", "Expr'", "Expr'", "Expr'", "Condition", "AugAssign'", "Assign'", "Expr'" ]