lines
sequencelengths 1
444
| raw_lines
sequencelengths 1
444
| label
sequencelengths 1
444
| type
sequencelengths 1
444
|
---|---|---|---|
[
"def FUNC_28(self, VAR_23):...\n",
"return self.mtime > VAR_23\n"
] | [
"def is_newer(self, time):...\n",
"return self.mtime > time\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_36(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = {'SEVERITY': {'MEDIUM': 12}, 'CONFIDENCE': {'LOW': 7, 'MEDIUM': 5}}\n",
"self.check_example('sql_statements.py', VAR_2)\n"
] | [
"def test_sql_statements(self):...\n",
"\"\"\"docstring\"\"\"\n",
"expect = {'SEVERITY': {'MEDIUM': 12}, 'CONFIDENCE': {'LOW': 7, 'MEDIUM': 5}}\n",
"self.check_example('sql_statements.py', expect)\n"
] | [
0,
0,
4,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_2(VAR_9):...\n",
"VAR_34 = VAR_9.cmd('list-panes', '-F #{pane_pid}')\n",
"return [int(p) for p in VAR_34.stdout]\n"
] | [
"def get_window_pid(window):...\n",
"r = window.cmd('list-panes', '-F #{pane_pid}')\n",
"return [int(p) for p in r.stdout]\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"return 'submit user test %s for task %s (ID %d) %s' % (repr(self.filenames),\n self.task[1], self.task[0], self.url)\n"
] | [
"def describe(self):...\n",
"return 'submit user test %s for task %s (ID %d) %s' % (repr(self.filenames),\n self.task[1], self.task[0], self.url)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_12(self):...\n",
"VAR_26 = os.path.join(self.path, 'manifest.json')\n",
"if not os.path.exists(VAR_26):\n",
"return\n",
"FUNC_1('MANIFEST')\n",
"\"\"\"\n Check if there is no comma syntax issue\n \"\"\"\n",
"VAR_26 = json.loads(data_file.read())\n",
"FUNC_4(\n \"[YEP-2.1] Syntax (comma) or encoding issue with manifest.json. Can't check file.\"\n )\n",
"VAR_27 = ('name', 'id', 'packaging_format', 'description', 'url', 'version',\n 'license', 'maintainer', 'requirements', 'multi_instance', 'services',\n 'arguments')\n",
"for field in VAR_27:\n",
"if field not in VAR_26:\n",
"\"\"\"\n Check values in keys\n \"\"\"\n",
"FUNC_3('[YEP-2.1] \"' + field + '\" field is missing')\n",
"if 'packaging_format' not in VAR_26:\n",
"FUNC_4('[YEP-2.1] \"packaging_format\" key is missing')\n",
"if not isinstance(VAR_26['packaging_format'], int):\n",
"if 'id' in VAR_26:\n",
"FUNC_4('[YEP-2.1] \"packaging_format\": value isn\\'t an integer type')\n",
"if VAR_26['packaging_format'] != 1:\n",
"if not re.match('^[a-z1-9]((_|-)?[a-z1-9])+$', VAR_26['id']):\n",
"if 'name' in VAR_26:\n",
"FUNC_4('[YEP-2.1] \"packaging_format\" field: current format value is \\'1\\'')\n",
"FUNC_4(\n \"[YEP-1.1] 'id' field '%s' should respect this regex '^[a-z1-9]((_|-)?[a-z1-9])+$'\"\n )\n",
"if len(VAR_26['name']) > 22:\n",
"if 'id' in VAR_26:\n",
"FUNC_3('string')\n",
"VAR_33 = 'https://raw.githubusercontent.com/YunoHost/apps/master/official.json'\n",
"def FUNC_19(VAR_16):...\n",
"VAR_34 = json.loads(FUNC_5(VAR_33)['content'])\n",
"VAR_37 = os.path.join(VAR_16, 'README.md')\n",
"VAR_35 = (\n 'https://raw.githubusercontent.com/YunoHost/apps/master/community.json')\n",
"if os.path.isfile(VAR_37):\n",
"VAR_36 = json.loads(FUNC_5(VAR_35)['content'])\n",
"return 'LICENSE' in open(VAR_37).read()\n",
"return False\n",
"if VAR_26['id'] not in VAR_34 and VAR_26['id'] not in VAR_36:\n",
"FUNC_3(\n '[YEP-1.2] This app is not registered in official or community applications'\n )\n"
] | [
"def check_manifest(self):...\n",
"manifest = os.path.join(self.path, 'manifest.json')\n",
"if not os.path.exists(manifest):\n",
"return\n",
"print_header('MANIFEST')\n",
"\"\"\"\n Check if there is no comma syntax issue\n \"\"\"\n",
"manifest = json.loads(data_file.read())\n",
"print_error(\n \"[YEP-2.1] Syntax (comma) or encoding issue with manifest.json. Can't check file.\"\n )\n",
"fields = ('name', 'id', 'packaging_format', 'description', 'url', 'version',\n 'license', 'maintainer', 'requirements', 'multi_instance', 'services',\n 'arguments')\n",
"for field in fields:\n",
"if field not in manifest:\n",
"\"\"\"\n Check values in keys\n \"\"\"\n",
"print_warning('[YEP-2.1] \"' + field + '\" field is missing')\n",
"if 'packaging_format' not in manifest:\n",
"print_error('[YEP-2.1] \"packaging_format\" key is missing')\n",
"if not isinstance(manifest['packaging_format'], int):\n",
"if 'id' in manifest:\n",
"print_error('[YEP-2.1] \"packaging_format\": value isn\\'t an integer type')\n",
"if manifest['packaging_format'] != 1:\n",
"if not re.match('^[a-z1-9]((_|-)?[a-z1-9])+$', manifest['id']):\n",
"if 'name' in manifest:\n",
"print_error('[YEP-2.1] \"packaging_format\" field: current format value is \\'1\\''\n )\n",
"print_error(\n \"[YEP-1.1] 'id' field '%s' should respect this regex '^[a-z1-9]((_|-)?[a-z1-9])+$'\"\n )\n",
"if len(manifest['name']) > 22:\n",
"if 'id' in manifest:\n",
"print_warning(\n \"[YEP-1.1] The 'name' field shouldn't be too long to be able to be with one line in the app list. The most current bigger name is actually compound of 22 characters.\"\n )\n",
"official_list_url = (\n 'https://raw.githubusercontent.com/YunoHost/apps/master/official.json')\n",
"def license_mentionned_in_readme(path):...\n",
"official_list = json.loads(urlopen(official_list_url)['content'])\n",
"readme_path = os.path.join(path, 'README.md')\n",
"community_list_url = (\n 'https://raw.githubusercontent.com/YunoHost/apps/master/community.json')\n",
"if os.path.isfile(readme_path):\n",
"community_list = json.loads(urlopen(community_list_url)['content'])\n",
"return 'LICENSE' in open(readme_path).read()\n",
"return False\n",
"if manifest['id'] not in official_list and manifest['id'\n",
"print_warning(\n '[YEP-1.2] This app is not registered in official or community applications'\n )\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"For",
"Condition",
"Expr'",
"Expr'",
"For",
"Expr'",
"For",
"Condition",
"Expr'",
"For",
"Condition",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Condition",
"Expr'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Return'",
"Condition",
"Expr'"
] |
[
"def FUNC_11(self, VAR_19):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.test_name is None:\n",
"self.initFile('line')\n",
"if not self.reached_corner[0]:\n",
"self.reached_corner[0] = self.navloc.goToPosition(0, 0)\n",
"if self.navloc.goToPosition(VAR_19, 0):\n",
"if self.reached_corner[0]:\n",
"self.reached_corner[0] = False\n",
"self.logArrival('home', 0, 0)\n",
"self.logArrival('endpoint', VAR_19, 0)\n"
] | [
"def testLine(self, length):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.test_name is None:\n",
"self.initFile('line')\n",
"if not self.reached_corner[0]:\n",
"self.reached_corner[0] = self.navloc.goToPosition(0, 0)\n",
"if self.navloc.goToPosition(length, 0):\n",
"if self.reached_corner[0]:\n",
"self.reached_corner[0] = False\n",
"self.logArrival('home', 0, 0)\n",
"self.logArrival('endpoint', length, 0)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_6(self, VAR_64):...\n",
"VAR_90 = VAR_64.split(',')\n",
"return Thing._by_fullname(VAR_90, data=True, return_dict=False)\n"
] | [
"def run(self, id_str):...\n",
"tids = id_str.split(',')\n",
"return Thing._by_fullname(tids, data=True, return_dict=False)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_0(VAR_0):...\n",
"if VAR_0.method == 'POST':\n",
"VAR_2 = VAR_0.POST.get('answer', '').lower()\n",
"return render(VAR_0, 'exercises/first_exercise.html')\n",
"VAR_3 = 0\n",
"if 'hello' in VAR_2:\n",
"VAR_3 += 1\n",
"if 'a+' in VAR_2:\n",
"VAR_3 += 1\n",
"return render(VAR_0, 'exercises/first_result.html', {'points': VAR_3,\n 'max_points': 2})\n"
] | [
"def first(request):...\n",
"if request.method == 'POST':\n",
"submission = request.POST.get('answer', '').lower()\n",
"return render(request, 'exercises/first_exercise.html')\n",
"points = 0\n",
"if 'hello' in submission:\n",
"points += 1\n",
"if 'a+' in submission:\n",
"points += 1\n",
"return render(request, 'exercises/first_result.html', {'points': points,\n 'max_points': 2})\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Condition",
"AugAssign'",
"Condition",
"AugAssign'",
"Return'"
] |
[
"import logging\n",
"import os\n",
"from xml.sax import SAXParseException\n",
"from twisted.cred import credentials\n",
"from twisted.internet import defer\n",
"from twisted.web import util\n",
"from twisted.web.error import FlattenerError\n",
"from twisted.web.http import UNAUTHORIZED, OK\n",
"from twisted.web.resource import IResource, NoResource\n",
"from twisted.web.server import NOT_DONE_YET\n",
"from twisted.web.static import File\n",
"from twisted.web.template import Element, XMLFile, renderElement, renderer\n",
"from twisted.python.filepath import FilePath\n",
"from pixelated.adapter.welcome_mail import add_welcome_mail\n",
"from pixelated.resources import BaseResource, UnAuthorizedResource, IPixelatedSession\n",
"VAR_0 = logging.getLogger(__name__)\n",
"def FUNC_0():...\n",
"VAR_1 = os.path.dirname(os.path.abspath(__file__))\n",
"return os.path.join(VAR_1, '..', 'assets')\n"
] | [
"import logging\n",
"import os\n",
"from xml.sax import SAXParseException\n",
"from twisted.cred import credentials\n",
"from twisted.internet import defer\n",
"from twisted.web import util\n",
"from twisted.web.error import FlattenerError\n",
"from twisted.web.http import UNAUTHORIZED, OK\n",
"from twisted.web.resource import IResource, NoResource\n",
"from twisted.web.server import NOT_DONE_YET\n",
"from twisted.web.static import File\n",
"from twisted.web.template import Element, XMLFile, renderElement, renderer\n",
"from twisted.python.filepath import FilePath\n",
"from pixelated.adapter.welcome_mail import add_welcome_mail\n",
"from pixelated.resources import BaseResource, UnAuthorizedResource, IPixelatedSession\n",
"log = logging.getLogger(__name__)\n",
"def _get_startup_folder():...\n",
"path = os.path.dirname(os.path.abspath(__file__))\n",
"return os.path.join(path, '..', 'assets')\n"
] | [
0,
0,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self, VAR_38):...\n",
"if not VAR_38:\n",
"if self.emp_error is not None:\n",
"if len(VAR_38) > self.length:\n",
"VAR_101.errors.add(self.emp_error)\n",
"VAR_101.errors.add(self.len_error)\n",
"return VAR_38\n"
] | [
"def run(self, title):...\n",
"if not title:\n",
"if self.emp_error is not None:\n",
"if len(title) > self.length:\n",
"c.errors.add(self.emp_error)\n",
"c.errors.add(self.len_error)\n",
"return title\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"Condition",
"Expr'",
"Expr'",
"Return'"
] |
[
"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 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"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"ImportFrom'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_0(self, VAR_11):...\n",
""
] | [
"def add_tag_by_name(self, tagname):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_4(VAR_30):...\n",
"VAR_39 = 'meal_planner.db'\n",
"VAR_50 = 'ingredients_' + str(VAR_13)\n",
"conn.execute('CREATE TABLE IF NOT EXISTS ' + VAR_50 + ' (ingredients text)')\n",
"conn.execute('INSERT INTO ' + VAR_50 + ' VALUES (?);', (VAR_30,))\n"
] | [
"def save_ingredients(ingredients):...\n",
"database_file = 'meal_planner.db'\n",
"tableName = 'ingredients_' + str(weekNumber)\n",
"conn.execute('CREATE TABLE IF NOT EXISTS ' + tableName + ' (ingredients text)')\n",
"conn.execute('INSERT INTO ' + tableName + ' VALUES (?);', (ingredients,))\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_11(self):...\n",
"self.client.login(username=self.tester.username, password='password')\n",
"VAR_1 = self.client.post(self.update_url, {'content_type':\n 'testruns.testcaserun', 'object_pk': self.case_run_1.pk, 'field':\n 'case_run_status', 'value': str(TestCaseRunStatus.objects.get(name=\n 'PAUSED').pk), 'value_type': 'int'})\n",
"self.assertJSONEqual(str(VAR_1.content, encoding=settings.DEFAULT_CHARSET),\n {'rc': 0, 'response': 'ok'})\n",
"self.assertEqual('PAUSED', TestCaseRun.objects.get(pk=self.case_run_1.pk).\n case_run_status.name)\n"
] | [
"def test_change_case_run_status(self):...\n",
"self.client.login(username=self.tester.username, password='password')\n",
"response = self.client.post(self.update_url, {'content_type':\n 'testruns.testcaserun', 'object_pk': self.case_run_1.pk, 'field':\n 'case_run_status', 'value': str(TestCaseRunStatus.objects.get(name=\n 'PAUSED').pk), 'value_type': 'int'})\n",
"self.assertJSONEqual(str(response.content, encoding=settings.\n DEFAULT_CHARSET), {'rc': 0, 'response': 'ok'})\n",
"self.assertEqual('PAUSED', TestCaseRun.objects.get(pk=self.case_run_1.pk).\n case_run_status.name)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_6(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_3:\n",
"VAR_14 = utils.FolderSearch.getFilepathsInclSubfolders(PIC_FOLDER,\n allowed_extensions=['txt', 'png', 'jpg', 'jpeg'])\n",
"VAR_35 = utils.DropboxFolderSearch.getFilepathsInclSubfoldersDropboxPublic(\n DROPBOX_FOLDER_LINK, DROPBOX_APP_KEY, DROPBOX_SECRET_KEY,\n unixify_mod_time=True)\n",
"VAR_35 = list(zip(VAR_14, [utils.FileUtils.getModificationTimeUnix(f) for f in\n VAR_14]))\n",
"VAR_14 = [i[0] for i in VAR_35]\n",
"for i in VAR_35:\n",
"self.fileToDB(i[0], i[1])\n",
"self.checkFilesForDeletion(VAR_14)\n",
"VAR_27 = time()\n",
"self.update_filelist_thread_queue.put((VAR_27,))\n"
] | [
"def updateFileList(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if not FROM_DROPBOX:\n",
"files = utils.FolderSearch.getFilepathsInclSubfolders(PIC_FOLDER,\n allowed_extensions=['txt', 'png', 'jpg', 'jpeg'])\n",
"files_and_mods = (utils.DropboxFolderSearch.\n getFilepathsInclSubfoldersDropboxPublic(DROPBOX_FOLDER_LINK,\n DROPBOX_APP_KEY, DROPBOX_SECRET_KEY, unixify_mod_time=True))\n",
"files_and_mods = list(zip(files, [utils.FileUtils.getModificationTimeUnix(f\n ) for f in files]))\n",
"files = [i[0] for i in files_and_mods]\n",
"for i in files_and_mods:\n",
"self.fileToDB(i[0], i[1])\n",
"self.checkFilesForDeletion(files)\n",
"last_filelist_update_time = time()\n",
"self.update_filelist_thread_queue.put((last_filelist_update_time,))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_1(VAR_4, VAR_5):...\n",
"VAR_10 = (VAR_4['page'] - 1) * VAR_4['perPage']\n",
"VAR_11 = f\"\"\"string{VAR_0} AS p INNER JOIN {VAR_1} AS pt ON\n p.product_type_id=pt.id\n WHERE p.rating >= {VAR_4['rating']}\n AND pt.name = '{VAR_5}'\n ORDER BY p.id LIMIT {VAR_10}, {VAR_4['perPage']}\n \"\"\"\n",
"VAR_12 = create_connection()\n",
"VAR_12.close()\n",
"VAR_13 = VAR_12.cursor()\n",
"VAR_13.execute(VAR_11)\n",
"return VAR_13.fetchall()\n"
] | [
"def get_department_products(filters, department):...\n",
"offset = (filters['page'] - 1) * filters['perPage']\n",
"sql_query = f\"\"\"\n SELECT p.id, p.ean, p.name, p.description, pt.name AS type, p.company, p.price, p.rating, p.weight, p.quantity, p.image_url\n FROM {PRODUCTS_TABLE} AS p INNER JOIN {PRODUCTS_TYPES_TABLE} AS pt ON\n p.product_type_id=pt.id\n WHERE p.rating >= {filters['rating']}\n AND pt.name = '{department}'\n ORDER BY p.id LIMIT {offset}, {filters['perPage']}\n \"\"\"\n",
"connection = create_connection()\n",
"connection.close()\n",
"cursor = connection.cursor()\n",
"cursor.execute(sql_query)\n",
"return cursor.fetchall()\n"
] | [
0,
0,
4,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"import logging\n",
"import pandas as pd\n",
"from webapp import db, app\n",
"from webapp.utils import generate_matched_table_name, table_exists\n",
"from collections import OrderedDict\n",
"from webapp.logger import logger\n",
"import numpy as np\n",
"def FUNC_0(VAR_0, VAR_1, VAR_2, VAR_3):...\n",
"VAR_20 = VAR_0[VAR_0.matched_id.isin(VAR_2)]\n",
"VAR_21, VAR_7 = VAR_1(VAR_0)\n",
"VAR_22, VAR_23 = VAR_1(VAR_20, VAR_7)\n",
"VAR_6 = []\n",
"logger.info(VAR_3)\n",
"logger.info(VAR_22)\n",
"logger.info(len(VAR_0.matched_id.unique()))\n",
"for bin_index in range(len(VAR_21)):\n",
"return [VAR_6, list(VAR_21.index)]\n",
"VAR_52 = {'x': VAR_3, 'y': int(VAR_21.iloc[bin_index]) / len(VAR_0.\n matched_id.unique()) * 100}\n",
"VAR_52 = {'x': VAR_3, 'y': 0}\n",
"VAR_53 = {'x': 'Jail & Homeless', 'y': int(VAR_22.iloc[bin_index]) / len(\n VAR_20.matched_id.unique()) * 100}\n",
"VAR_53 = {'x': 'Jail & Homeless', 'y': 0}\n",
"VAR_6.append((VAR_52, VAR_53))\n"
] | [
"import logging\n",
"import pandas as pd\n",
"from webapp import db, app\n",
"from webapp.utils import generate_matched_table_name, table_exists\n",
"from collections import OrderedDict\n",
"from webapp.logger import logger\n",
"import numpy as np\n",
"def get_histogram_bar_chart_data(data, distribution_function, shared_ids,...\n",
"intersection_data = data[data.matched_id.isin(shared_ids)]\n",
"distribution, groups = distribution_function(data)\n",
"distribution_intersection, _ = distribution_function(intersection_data, groups)\n",
"bins = []\n",
"logger.info(data_name)\n",
"logger.info(distribution_intersection)\n",
"logger.info(len(data.matched_id.unique()))\n",
"for bin_index in range(len(distribution)):\n",
"return [bins, list(distribution.index)]\n",
"of_status = {'x': data_name, 'y': int(distribution.iloc[bin_index]) / len(\n data.matched_id.unique()) * 100}\n",
"of_status = {'x': data_name, 'y': 0}\n",
"all_status = {'x': 'Jail & Homeless', 'y': int(distribution_intersection.\n iloc[bin_index]) / len(intersection_data.matched_id.unique()) * 100}\n",
"all_status = {'x': 'Jail & Homeless', 'y': 0}\n",
"bins.append((of_status, all_status))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"For",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_5(self, VAR_1, VAR_2, VAR_8=None, VAR_9='form', VAR_4=None, VAR_14...\n",
"VAR_29 = super(CLASS_0, self).fields_view_get(VAR_1, VAR_2, VAR_8, VAR_9,\n VAR_4, VAR_14=toolbar, VAR_15=submenu)\n",
"if VAR_4 is None:\n",
"VAR_4 = {}\n",
"if 'location' in VAR_4 and VAR_4['location']:\n",
"VAR_51 = self.pool.get('stock.location').browse(VAR_1, VAR_2, VAR_4['location']\n )\n",
"return VAR_29\n",
"VAR_52 = VAR_29.get('fields', {})\n",
"if VAR_52:\n",
"if VAR_51.usage == 'supplier':\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'internal':\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Receptions')\n",
"if VAR_52.get('qty_available'):\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'customer':\n",
"VAR_29['fields']['qty_available']['string'] = _('Received Qty')\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Stock')\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'inventory':\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Deliveries')\n",
"if VAR_52.get('qty_available'):\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'procurement':\n",
"VAR_29['fields']['qty_available']['string'] = _('Delivered Qty')\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future P&L')\n",
"if VAR_52.get('qty_available'):\n",
"if VAR_52.get('virtual_available'):\n",
"if VAR_51.usage == 'production':\n",
"VAR_29['fields']['qty_available']['string'] = _('P&L Qty')\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Qty')\n",
"if VAR_52.get('qty_available'):\n",
"if VAR_52.get('virtual_available'):\n",
"VAR_29['fields']['qty_available']['string'] = _('Unplanned Qty')\n",
"VAR_29['fields']['virtual_available']['string'] = _('Future Productions')\n",
"if VAR_52.get('qty_available'):\n",
"VAR_29['fields']['qty_available']['string'] = _('Produced Qty')\n"
] | [
"def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=...\n",
"res = super(product_product, self).fields_view_get(cr, uid, view_id,\n view_type, context, toolbar=toolbar, submenu=submenu)\n",
"if context is None:\n",
"context = {}\n",
"if 'location' in context and context['location']:\n",
"location_info = self.pool.get('stock.location').browse(cr, uid, context[\n 'location'])\n",
"return res\n",
"fields = res.get('fields', {})\n",
"if fields:\n",
"if location_info.usage == 'supplier':\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'internal':\n",
"res['fields']['virtual_available']['string'] = _('Future Receptions')\n",
"if fields.get('qty_available'):\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'customer':\n",
"res['fields']['qty_available']['string'] = _('Received Qty')\n",
"res['fields']['virtual_available']['string'] = _('Future Stock')\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'inventory':\n",
"res['fields']['virtual_available']['string'] = _('Future Deliveries')\n",
"if fields.get('qty_available'):\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'procurement':\n",
"res['fields']['qty_available']['string'] = _('Delivered Qty')\n",
"res['fields']['virtual_available']['string'] = _('Future P&L')\n",
"if fields.get('qty_available'):\n",
"if fields.get('virtual_available'):\n",
"if location_info.usage == 'production':\n",
"res['fields']['qty_available']['string'] = _('P&L Qty')\n",
"res['fields']['virtual_available']['string'] = _('Future Qty')\n",
"if fields.get('qty_available'):\n",
"if fields.get('virtual_available'):\n",
"res['fields']['qty_available']['string'] = _('Unplanned Qty')\n",
"res['fields']['virtual_available']['string'] = _('Future Productions')\n",
"if fields.get('qty_available'):\n",
"res['fields']['qty_available']['string'] = _('Produced Qty')\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
] | [
"For",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'"
] |
[
"from __future__ import print_function\n",
"import os\n",
"import sys\n",
"import etcd\n",
"from custodia.store.interface import CSStore, CSStoreError, CSStoreExists\n",
"def FUNC_0(VAR_0):...\n",
"print(VAR_0, file=sys.stderr)\n",
"def __init__(self, VAR_1):...\n",
"self.server = VAR_1.get('etcd_server', '127.0.0.1')\n",
"self.port = int(VAR_1.get('etcd_port', 4001))\n",
"self.namespace = VAR_1.get('namespace', '/custodia')\n",
"self.etcd = etcd.Client(self.server, self.port)\n",
"FUNC_0('Error creating namespace %s: [%r]' % (self.namespace, repr(err)))\n",
"def FUNC_1(self, VAR_2):...\n",
"self.etcd.write(self.namespace, None, dir=True)\n",
"VAR_7 = self.etcd.get(os.path.join(self.namespace, VAR_2))\n",
"FUNC_0('Error fetching key %s: [%r]' % (VAR_2, repr(err)))\n",
"return VAR_7.value\n"
] | [
"from __future__ import print_function\n",
"import os\n",
"import sys\n",
"import etcd\n",
"from custodia.store.interface import CSStore, CSStoreError, CSStoreExists\n",
"def log_error(error):...\n",
"print(error, file=sys.stderr)\n",
"def __init__(self, config):...\n",
"self.server = config.get('etcd_server', '127.0.0.1')\n",
"self.port = int(config.get('etcd_port', 4001))\n",
"self.namespace = config.get('namespace', '/custodia')\n",
"self.etcd = etcd.Client(self.server, self.port)\n",
"log_error('Error creating namespace %s: [%r]' % (self.namespace, repr(err)))\n",
"def get(self, key):...\n",
"self.etcd.write(self.namespace, None, dir=True)\n",
"result = self.etcd.get(os.path.join(self.namespace, key))\n",
"log_error('Error fetching key %s: [%r]' % (key, repr(err)))\n",
"return result.value\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0
] | [
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_7(self):...\n",
"VAR_24 = time()\n",
"for i in range(self.options.iterations):\n",
"if self.db.campaign['aux']:\n",
"VAR_25 = time()\n",
"VAR_41 = Thread(VAR_18=self.aux.command, args=('./' + self.db.campaign[\n 'aux_command'],))\n",
"VAR_34 = Thread(VAR_18=self.dut.command, args=('./' + self.db.campaign[\n 'command'],))\n",
"self.db.campaign['exec_time'] = (VAR_25 - VAR_24) / self.options.iterations\n",
"VAR_41.start()\n",
"VAR_34.start()\n",
"db.log_event('Information', 'Debugger', 'Timed application', campaign=True)\n",
"if self.db.campaign['aux']:\n",
"VAR_41.join()\n",
"if self.db.campaign['kill_dut']:\n",
"self.dut.serial.write('\\x03')\n",
"VAR_34.join()\n"
] | [
"def time_application(self):...\n",
"start = time()\n",
"for i in range(self.options.iterations):\n",
"if self.db.campaign['aux']:\n",
"end = time()\n",
"aux_process = Thread(target=self.aux.command, args=('./' + self.db.campaign\n ['aux_command'],))\n",
"dut_process = Thread(target=self.dut.command, args=('./' + self.db.campaign\n ['command'],))\n",
"self.db.campaign['exec_time'] = (end - start) / self.options.iterations\n",
"aux_process.start()\n",
"dut_process.start()\n",
"db.log_event('Information', 'Debugger', 'Timed application', campaign=True)\n",
"if self.db.campaign['aux']:\n",
"aux_process.join()\n",
"if self.db.campaign['kill_dut']:\n",
"self.dut.serial.write('\\x03')\n",
"dut_process.join()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_16(**VAR_19):...\n",
"VAR_35 = FUNC_8('users/add', VAR_16=kwargs)\n",
"VAR_46 = re.search('/user/([0-9]+)$', VAR_35.url)\n",
"if VAR_46:\n",
"VAR_10 = int(VAR_46.group(1))\n",
"VAR_19['user_id'] = VAR_10\n",
"VAR_3[VAR_10] = VAR_19\n",
"VAR_35 = FUNC_8('contest/' + VAR_19['contest_id'] + '/users/add', VAR_16=kwargs\n )\n",
"VAR_46 = re.search('<input type=\"radio\" name=\"user_id\" value=\"' + VAR_68(\n VAR_10) + '\"/>', VAR_35.text)\n",
"if VAR_46:\n",
"return VAR_10\n"
] | [
"def add_user(**kwargs):...\n",
"r = admin_req('users/add', args=kwargs)\n",
"g = re.search('/user/([0-9]+)$', r.url)\n",
"if g:\n",
"user_id = int(g.group(1))\n",
"kwargs['user_id'] = user_id\n",
"created_users[user_id] = kwargs\n",
"r = admin_req('contest/' + kwargs['contest_id'] + '/users/add', args=kwargs)\n",
"g = re.search('<input type=\"radio\" name=\"user_id\" value=\"' + str(user_id) +\n '\"/>', r.text)\n",
"if g:\n",
"return user_id\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_0(self):...\n",
""
] | [
"def run_check(self):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_5(self, VAR_9):...\n",
"self.virtual_fields.append(VAR_9)\n",
"cached_property.clear_caches(self)\n"
] | [
"def add_virtual_field(self, field):...\n",
"self.virtual_fields.append(field)\n",
"cached_property.clear_caches(self)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'"
] |
[
"@staticmethod...\n",
"VAR_17 = ['sup', 'i', 'span']\n",
"return getattr(VAR_5, 'name', None) == 'a' and getattr(VAR_5.parent, 'name',\n None) not in VAR_17 and not VAR_5.has_attr('style')\n"
] | [
"@staticmethod...\n",
"tags = ['sup', 'i', 'span']\n",
"return getattr(element, 'name', None) == 'a' and getattr(element.parent,\n 'name', None) not in tags and not element.has_attr('style')\n"
] | [
0,
0,
0
] | [
"Condition",
"Assign'",
"Return'"
] |
[
"@rest_utils.ajax()...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_18 = VAR_1.DATA.get('length', 100)\n",
"VAR_19 = api.nova.server_console_output(VAR_1, VAR_3, tail_length=log_length)\n",
"return {'lines': [x for x in VAR_19.split('\\n')]}\n"
] | [
"@rest_utils.ajax()...\n",
"\"\"\"docstring\"\"\"\n",
"log_length = request.DATA.get('length', 100)\n",
"console_lines = api.nova.server_console_output(request, server_id,\n tail_length=log_length)\n",
"return {'lines': [x for x in console_lines.split('\\n')]}\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Return'"
] |
[
"def __getstate__(self):...\n",
"return self.serialize()\n"
] | [
"def __getstate__(self):...\n",
"return self.serialize()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_0(self):...\n",
"for VAR_7 in self.G.edges():\n",
"self.calcLKVM(VAR_7)\n"
] | [
"def calcAllLKVM(self):...\n",
"for edge in self.G.edges():\n",
"self.calcLKVM(edge)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"For",
"Expr'"
] |
[
"def FUNC_1(self, VAR_0):...\n",
"self.__init__(VAR_4=False)\n",
"self.name = VAR_0.get('name')\n",
"self.vars = VAR_0.get('vars', dict())\n",
"self.address = VAR_0.get('address', '')\n",
"self._uuid = VAR_0.get('uuid', None)\n",
"self.implicit = VAR_0.get('implicit', False)\n",
"VAR_8 = VAR_0.get('groups', [])\n",
"for group_data in VAR_8:\n",
"VAR_10 = Group()\n",
"VAR_10.deserialize(group_data)\n",
"self.groups.append(VAR_10)\n"
] | [
"def deserialize(self, data):...\n",
"self.__init__(gen_uuid=False)\n",
"self.name = data.get('name')\n",
"self.vars = data.get('vars', dict())\n",
"self.address = data.get('address', '')\n",
"self._uuid = data.get('uuid', None)\n",
"self.implicit = data.get('implicit', False)\n",
"groups = data.get('groups', [])\n",
"for group_data in groups:\n",
"g = Group()\n",
"g.deserialize(group_data)\n",
"self.groups.append(g)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@commands.command()...\n",
"\"\"\"docstring\"\"\"\n",
"await self.simple_embed('string')\n"
] | [
"@commands.command()...\n",
"\"\"\"docstring\"\"\"\n",
"await self.simple_embed(\n \"\"\"If you have boot9strap and Luma3DS installed after following Plailect's guide, run Luma Updater to make sure it is on the latest Luma3DS normal version and then you can proceed to update your 3DS through system settings. \nNTR CFW works on the latest version.\n; Use this version of BootNTR: \n<https://github.com/Nanquitas/BootNTR/releases>\nNote: if there is a homebrew application that is no longer working, it may exist as a CIA that you can download under the TitleDB option in FBI.\n\n If you still have arm9loaderhax you can update to boot9strap following [this guide](https://3ds.guide/updating-to-boot9strap)\"\"\"\n )\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Expr'"
] |
[
"def FUNC_4(VAR_7, VAR_8, VAR_9, VAR_10):...\n",
"if VAR_7.does_intersect_rule(VAR_4(VAR_8['bookmarks'], VAR_8['attributes'],\n",
"VAR_25 = [VAR_9]\n",
"return\n",
"for VAR_24, VAR_11 in VAR_8['levels']:\n",
"VAR_27 = VAR_11['bookmarks'] if 'bookmarks' in VAR_11 else []\n",
"VAR_28 = VAR_11['treeattributes'] if 'treeattributes' in VAR_11 else {}\n",
"VAR_29 = VAR_11['localattributes'] if 'localattributes' in VAR_11 else {}\n",
"VAR_30 = VAR_11['key'] if 'key' in VAR_11 else None\n",
"VAR_31 = VAR_11['collection'] if 'collection' in VAR_11 else None\n",
"VAR_32 = VAR_11['user'] if 'user' in VAR_11 else None\n",
"VAR_33 = VAR_11['group'] if 'group' in VAR_11 else None\n",
"VAR_34 = VAR_11['permissions'] if 'permissions' in VAR_11 else None\n",
"VAR_13 = VAR_6(VAR_27, VAR_28, VAR_29, VAR_30, VAR_31, VAR_32, VAR_33, VAR_34)\n",
"VAR_35 = VAR_0[VAR_24].get_directories(VAR_13, VAR_11, VAR_7, VAR_25, VAR_10)\n",
"if not VAR_35:\n",
"VAR_36 = []\n",
"for ictx, dirname in VAR_35:\n",
"VAR_42 = ictx.attributes.copy()\n",
"VAR_25 = VAR_36\n",
"if 'treeattributes' in VAR_11:\n",
"VAR_42.update(VAR_28)\n",
"VAR_43 = VAR_42.copy()\n",
"if 'localattributes' in VAR_11:\n",
"VAR_43.update(VAR_29)\n",
"VAR_21 = ictx.parameters.copy()\n",
"VAR_44 = ictx.collections.copy()\n",
"if VAR_30:\n",
"VAR_50 = os.path.basename(dirname)\n",
"VAR_45 = attrexpr.eval_attribute_expr(VAR_32, VAR_43, VAR_21\n ) if VAR_32 else ictx.user\n",
"VAR_21[VAR_30] = VAR_50\n",
"VAR_46 = attrexpr.eval_attribute_expr(VAR_33, VAR_43, VAR_21\n ) if VAR_33 else ictx.group\n",
"if VAR_31:\n",
"VAR_47 = ugoexpr.eval_ugo_expr(VAR_34) if VAR_34 else ictx.permissions\n",
"VAR_44[VAR_30] = VAR_31\n",
"VAR_48 = VAR_5(VAR_43, VAR_21, dirname, VAR_44, VAR_45, VAR_46, VAR_47)\n",
"VAR_49 = VAR_7.does_intersect_path(VAR_48)\n",
"if VAR_49:\n",
"VAR_7.test(VAR_48, VAR_13)\n",
"VAR_48 = VAR_5(VAR_42, VAR_21, dirname, VAR_44, VAR_45, VAR_46, VAR_47)\n",
"VAR_36.append(VAR_48)\n"
] | [
"def _traverse(searcher, rule, ctx, client):...\n",
"if searcher.does_intersect_rule(RuleTraversalContext(rule['bookmarks'],\n",
"pathlist = [ctx]\n",
"return\n",
"for leveltype, levelfields in rule['levels']:\n",
"levelbookmarks = levelfields['bookmarks'] if 'bookmarks' in levelfields else []\n",
"leveltreeattr = levelfields['treeattributes'\n ] if 'treeattributes' in levelfields else {}\n",
"levellocalattr = levelfields['localattributes'\n ] if 'localattributes' in levelfields else {}\n",
"levelparameter = levelfields['key'] if 'key' in levelfields else None\n",
"levelcollection = levelfields['collection'\n ] if 'collection' in levelfields else None\n",
"leveluser = levelfields['user'] if 'user' in levelfields else None\n",
"levelgroup = levelfields['group'] if 'group' in levelfields else None\n",
"levelpermissions = levelfields['permissions'\n ] if 'permissions' in levelfields else None\n",
"levelctx = LevelTraversalContext(levelbookmarks, leveltreeattr,\n levellocalattr, levelparameter, levelcollection, leveluser, levelgroup,\n levelpermissions)\n",
"ruletuples = FnLevel[leveltype].get_directories(levelctx, levelfields,\n searcher, pathlist, client)\n",
"if not ruletuples:\n",
"passedlist = []\n",
"for ictx, dirname in ruletuples:\n",
"treeattr = ictx.attributes.copy()\n",
"pathlist = passedlist\n",
"if 'treeattributes' in levelfields:\n",
"treeattr.update(leveltreeattr)\n",
"localattr = treeattr.copy()\n",
"if 'localattributes' in levelfields:\n",
"localattr.update(levellocalattr)\n",
"parameters = ictx.parameters.copy()\n",
"collections = ictx.collections.copy()\n",
"if levelparameter:\n",
"basename = os.path.basename(dirname)\n",
"user = attrexpr.eval_attribute_expr(leveluser, localattr, parameters\n ) if leveluser else ictx.user\n",
"parameters[levelparameter] = basename\n",
"group = attrexpr.eval_attribute_expr(levelgroup, localattr, parameters\n ) if levelgroup else ictx.group\n",
"if levelcollection:\n",
"permissions = ugoexpr.eval_ugo_expr(levelpermissions\n ) if levelpermissions else ictx.permissions\n",
"collections[levelparameter] = levelcollection\n",
"newctx = PathTraversalContext(localattr, parameters, dirname, collections,\n user, group, permissions)\n",
"test = searcher.does_intersect_path(newctx)\n",
"if test:\n",
"searcher.test(newctx, levelctx)\n",
"newctx = PathTraversalContext(treeattr, parameters, dirname, collections,\n user, group, permissions)\n",
"passedlist.append(newctx)\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,
1,
0,
0,
0,
1,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Return'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"For",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def __init__(self):...\n",
"self.updated_input = set()\n",
"self.updated_input_run = set()\n",
"self.missing_output = set()\n",
"self.incomplete_output = set()\n",
"self.forced = False\n",
"self.noio = False\n",
"self.nooutput = False\n",
"self.derived = True\n"
] | [
"def __init__(self):...\n",
"self.updated_input = set()\n",
"self.updated_input_run = set()\n",
"self.missing_output = set()\n",
"self.incomplete_output = set()\n",
"self.forced = False\n",
"self.noio = False\n",
"self.nooutput = False\n",
"self.derived = True\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_3():...\n",
"VAR_9 = FUNC_0()\n",
"VAR_10 = VAR_9.cursor()\n",
"VAR_10.execute(VAR_8)\n",
"VAR_9.commit()\n",
"VAR_2.info('successfully created also table for the first time')\n"
] | [
"def create_also_table():...\n",
"db = db_connect()\n",
"cursor = db.cursor()\n",
"cursor.execute(ALSO_TABLE)\n",
"db.commit()\n",
"logger.info('successfully created also table for the first time')\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self.config.get(self.section, 'userdb_mongo_database')\n"
] | [
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self.config.get(self.section, 'userdb_mongo_database')\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_0(self):...\n",
"\"\"\"docstring\"\"\"\n",
"\"\"\"string\"\"\"\n",
"VAR_15 = int(request.args.get('page'))\n",
"VAR_16 = db_interac.get_messages(VAR_15)\n",
"return VAR_16, 200\n"
] | [
"def get(self):...\n",
"\"\"\"docstring\"\"\"\n",
"\"\"\"\n # Check the request comes from appropriate location.\n if not utils.validate_ip(request.remote_addr)\n return {}, 403\n \"\"\"\n",
"page = int(request.args.get('page'))\n",
"response = db_interac.get_messages(page)\n",
"return response, 200\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Return'"
] |
[
"\"\"\"string\"\"\"\n",
"from urllib import quote, unquote\n",
"from urllib.parse import quote, unquote\n",
"from circuits.six import text_type\n",
"from circuits import handler, BaseComponent, Event\n",
"from circuits.web.utils import parse_qs\n",
"from circuits.web.events import response\n",
"from circuits.web.errors import httperror\n",
"from circuits.web.processors import process\n",
"from circuits.web.controllers import BaseController\n",
"VAR_0 = 'web'\n",
"def __init__(self, **VAR_1):...\n",
"super(CLASS_0, self).__init__(**kwargs)\n",
"self.paths = dict()\n",
"def FUNC_0(self, VAR_2, VAR_3):...\n",
"def FUNC_7(VAR_11):...\n",
"return '/%s' % '/'.join(VAR_11)\n"
] | [
"\"\"\"Dispatcher\n\nThis module implements a basic URL to Channel dispatcher.\nThis is the default dispatcher used by circuits.web\n\"\"\"\n",
"from urllib import quote, unquote\n",
"from urllib.parse import quote, unquote\n",
"from circuits.six import text_type\n",
"from circuits import handler, BaseComponent, Event\n",
"from circuits.web.utils import parse_qs\n",
"from circuits.web.events import response\n",
"from circuits.web.errors import httperror\n",
"from circuits.web.processors import process\n",
"from circuits.web.controllers import BaseController\n",
"channel = 'web'\n",
"def __init__(self, **kwargs):...\n",
"super(Dispatcher, self).__init__(**kwargs)\n",
"self.paths = dict()\n",
"def resolve_path(self, paths, parts):...\n",
"def rebuild_path(url_parts):...\n",
"return '/%s' % '/'.join(url_parts)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Expr'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"FunctionDef'",
"Expr'",
"Assign'",
"FunctionDef'",
"FunctionDef'",
"Return'"
] |
[
"from django.db import models\n",
"from .common_info import CommonInfo\n",
"from django.core.exceptions import ValidationError\n",
"from .weight_fraction_type import WeightFractionType\n",
"from .extracted_chemical import ExtractedChemical\n",
"from .script import Script\n",
"def FUNC_0(VAR_0):...\n",
"if VAR_0 < 0 or VAR_0 > 1:\n",
"VAR_1 = models.DecimalField(max_digits=16, decimal_places=15, null=True,\n blank=True, validators=[validate_wf_analysis])\n",
"VAR_2 = models.DecimalField(max_digits=16, decimal_places=15, null=True,\n blank=True, validators=[validate_wf_analysis])\n",
"VAR_3 = models.DecimalField(max_digits=16, decimal_places=15, null=True,\n blank=True, validators=[validate_wf_analysis])\n",
"VAR_4 = models.ForeignKey(to=Script, on_delete=models.CASCADE, null=True,\n blank=True)\n",
"VAR_5 = models.OneToOneField(related_name='ingredient', parent_link=True,\n on_delete=models.CASCADE, to='dashboard.RawChem')\n",
"def __str__(self):...\n",
"return str(self.id)\n"
] | [
"from django.db import models\n",
"from .common_info import CommonInfo\n",
"from django.core.exceptions import ValidationError\n",
"from .weight_fraction_type import WeightFractionType\n",
"from .extracted_chemical import ExtractedChemical\n",
"from .script import Script\n",
"def validate_wf_analysis(value):...\n",
"if value < 0 or value > 1:\n",
"lower_wf_analysis = models.DecimalField(max_digits=16, decimal_places=15,\n null=True, blank=True, validators=[validate_wf_analysis])\n",
"central_wf_analysis = models.DecimalField(max_digits=16, decimal_places=15,\n null=True, blank=True, validators=[validate_wf_analysis])\n",
"upper_wf_analysis = models.DecimalField(max_digits=16, decimal_places=15,\n null=True, blank=True, validators=[validate_wf_analysis])\n",
"script = models.ForeignKey(to=Script, on_delete=models.CASCADE, null=True,\n blank=True)\n",
"rawchem_ptr = models.OneToOneField(related_name='ingredient', parent_link=\n True, on_delete=models.CASCADE, to='dashboard.RawChem')\n",
"def __str__(self):...\n",
"return str(self.id)\n"
] | [
0,
0,
0,
6,
6,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def __init__(self, *VAR_2, **VAR_3):...\n",
"super(CLASS_1, self).__init__(*VAR_2, **kwargs)\n",
"self.OIDC_OP_AUTH_ENDPOINT = import_from_settings(\n 'OIDC_OP_AUTHORIZATION_ENDPOINT')\n",
"self.OIDC_RP_CLIENT_ID = import_from_settings('OIDC_RP_CLIENT_ID')\n"
] | [
"def __init__(self, *args, **kwargs):...\n",
"super(OIDCAuthenticationRequestView, self).__init__(*args, **kwargs)\n",
"self.OIDC_OP_AUTH_ENDPOINT = import_from_settings(\n 'OIDC_OP_AUTHORIZATION_ENDPOINT')\n",
"self.OIDC_RP_CLIENT_ID = import_from_settings('OIDC_RP_CLIENT_ID')\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'"
] |
[
"def FUNC_0(self):...\n",
"self.db_conn.commit()\n"
] | [
"def commit(self):...\n",
"self.db_conn.commit()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_6(self, VAR_44=None):...\n",
"if not VAR_101.user_is_loggedin:\n",
"if VAR_44 is not None and not valid_password(VAR_101.user, VAR_44):\n",
"VAR_101.errors.add(errors.WRONG_PASSWORD)\n"
] | [
"def run(self, password=None):...\n",
"if not c.user_is_loggedin:\n",
"if password is not None and not valid_password(c.user, password):\n",
"c.errors.add(errors.WRONG_PASSWORD)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"Expr'"
] |
[
"@functools.wraps(VAR_0)...\n",
"\"\"\"docstring\"\"\"\n",
"if hasattr(VAR_9, 'interaction'):\n",
"VAR_28 = map(lambda pp: pp.principal.id, VAR_9.interaction.participations)\n",
"VAR_28 = []\n",
"if hasattr(self, 'logFile'):\n",
"VAR_29 = '%s %s - %s \"%s\" %d %s \"%s\" \"%s\"\\n' % (VAR_9.getClientIP(), VAR_28,\n self._logDateTime, '%s %s %s' % (self._escape(VAR_9.method), self.\n _escape(VAR_9.uri), self._escape(VAR_9.clientproto)), VAR_9.code, VAR_9\n .sentLength or '-', self._escape(VAR_9.getHeader('referer') or '-'),\n self._escape(VAR_9.getHeader('user-agent') or '-'))\n",
"self.logFile.write(VAR_29)\n"
] | [
"@functools.wraps(f)...\n",
"\"\"\"docstring\"\"\"\n",
"if hasattr(request, 'interaction'):\n",
"principals = map(lambda pp: pp.principal.id, request.interaction.participations\n )\n",
"principals = []\n",
"if hasattr(self, 'logFile'):\n",
"line = '%s %s - %s \"%s\" %d %s \"%s\" \"%s\"\\n' % (request.getClientIP(),\n principals, self._logDateTime, '%s %s %s' % (self._escape(request.\n method), self._escape(request.uri), self._escape(request.clientproto)),\n request.code, request.sentLength or '-', self._escape(request.getHeader\n ('referer') or '-'), self._escape(request.getHeader('user-agent') or '-'))\n",
"self.logFile.write(line)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_17 = [VAR_28.mtime for VAR_28 in self.expanded_output if VAR_28.exists]\n",
"if self.benchmark and self.benchmark.exists:\n",
"VAR_17.append(self.benchmark.mtime)\n",
"if VAR_17:\n",
"return min(VAR_17)\n",
"return None\n"
] | [
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"existing = [f.mtime for f in self.expanded_output if f.exists]\n",
"if self.benchmark and self.benchmark.exists:\n",
"existing.append(self.benchmark.mtime)\n",
"if existing:\n",
"return min(existing)\n",
"return None\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Return'",
"Return'"
] |
[
"from django.db import models\n",
"from dashboard.models import CommonInfo\n",
"from .raw_chem import RawChem\n",
"VAR_0 = models.CharField('Raw CAS', max_length=100, null=True, blank=True)\n",
"VAR_1 = models.CharField('Raw chemical name', max_length=500, null=True,\n blank=True)\n",
"VAR_2 = models.BooleanField(default=False)\n",
"@classmethod...\n",
"return ['raw_cas', 'raw_chem_name']\n"
] | [
"from django.db import models\n",
"from dashboard.models import CommonInfo\n",
"from .raw_chem import RawChem\n",
"raw_cas_old = models.CharField('Raw CAS', max_length=100, null=True, blank=True\n )\n",
"raw_chem_name_old = models.CharField('Raw chemical name', max_length=500,\n null=True, blank=True)\n",
"qa_flag = models.BooleanField(default=False)\n",
"@classmethod...\n",
"return ['raw_cas', 'raw_chem_name']\n"
] | [
0,
6,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Return'"
] |
[
"from libtmux import Server\n",
"from yaml import load, dump\n",
"from setupParser import Loader\n",
"from DepTree import Node, dep_resolve, CircularReferenceException\n",
"import logging\n",
"import os\n",
"import socket\n",
"import argparse\n",
"from psutil import Process\n",
"from subprocess import call\n",
"from graphviz import Digraph\n",
"from enum import Enum\n",
"from time import sleep\n",
"import sys\n",
"from PyQt4 import QtGui\n",
"import hyperGUI\n",
"VAR_0 = '%(asctime)s: %(name)s [%(levelname)s]:\\t%(message)s'\n",
"logging.basicConfig(level=logging.WARNING, format=FORMAT, datefmt='%I:%M:%S')\n",
"VAR_1 = '/tmp/Hyperion/slave/components'\n",
"VAR_2 = '/tmp/Hyperion/components'\n",
"VAR_3 = '/tmp/Hyperion/log'\n",
"VAR_4 = os.path.dirname(__file__)\n",
"VAR_5 = '%s/scripts/start_named_clone_session.sh' % VAR_4\n",
"VAR_19 = 0\n",
"VAR_20 = 1\n",
"VAR_21 = 2\n",
"VAR_22 = 3\n",
"VAR_23 = 4\n",
"def __init__(self, VAR_24=None):...\n",
"self.logger = logging.getLogger(__name__)\n",
"self.logger.setLevel(logging.DEBUG)\n",
"self.configfile = VAR_24\n",
"self.nodes = {}\n",
"self.server = []\n",
"self.host_list = []\n",
"if VAR_24:\n",
"self.load_config(VAR_24)\n",
"self.config = None\n",
"self.session_name = self.config['name']\n",
"def FUNC_13(self, VAR_25='default.yaml'):...\n",
"dump(self.config, outfile, default_flow_style=False)\n",
"self.config = load(data_file, Loader)\n",
"self.logger.debug('Loading config was successful')\n",
"def FUNC_14(self):...\n",
"self.server = Server()\n",
"if not self.config:\n",
"if self.server.has_session(self.session_name):\n",
"self.logger.error(' Config not loaded yet!')\n",
"for group in self.config['groups']:\n",
"self.session = self.server.find_where({'session_name': self.session_name})\n",
"self.logger.info('starting new session by name \"%s\" on server' % self.\n session_name)\n",
"def FUNC_15(self, VAR_26):...\n",
"for VAR_6 in group['components']:\n",
"self.host_list = list(set(self.host_list))\n",
"self.logger.info('found running session by name \"%s\" on server' % self.\n session_name)\n",
"self.session = self.server.new_session(VAR_30=self.session_name, VAR_15='Main')\n",
"for group in self.config['groups']:\n",
"self.logger.debug(\"Checking component '%s' in group '%s' on host '%s'\" % (\n VAR_6['name'], group['name'], VAR_6['host']))\n",
"self.set_dependencies(True)\n",
"for VAR_6 in group['components']:\n",
"VAR_47 = Node({'name': 'master_node'})\n",
"if VAR_6['host'] != 'localhost' and not self.run_on_localhost(VAR_6):\n",
"self.nodes[VAR_6['name']] = Node(VAR_6)\n",
"for VAR_11 in self.nodes:\n",
"self.copy_component_to_remote(VAR_6, VAR_6['name'], VAR_6['host'])\n",
"VAR_49 = self.nodes.get(VAR_11)\n",
"self.nodes['master_node'] = VAR_47\n",
"VAR_47.addEdge(VAR_49)\n",
"VAR_49 = self.nodes.get('master_node')\n",
"self.logger.error(\n 'Detected circular dependency reference between %s and %s!' % (ex.node1,\n ex.node2))\n",
"def FUNC_16(self, VAR_27, VAR_6, VAR_28):...\n",
"if 'depends' in VAR_49.component:\n",
"VAR_50 = []\n",
"if VAR_26:\n",
"self.host_list.append(VAR_28)\n",
"for dep in VAR_49.component['depends']:\n",
"VAR_51 = []\n",
"exit(1)\n",
"self.logger.debug('Saving component to tmp')\n",
"if dep in self.nodes:\n",
"dep_resolve(VAR_49, VAR_50, VAR_51)\n",
"VAR_48 = '%s/%s.yaml' % (VAR_2, VAR_6)\n",
"VAR_49.addEdge(self.nodes[dep])\n",
"self.logger.error(\"Unmet dependency: '%s' for component '%s'!\" % (dep,\n VAR_49.comp_name))\n",
"VAR_59 = ''\n",
"FUNC_10(VAR_48)\n",
"if VAR_26:\n",
"for VAR_49 in VAR_50:\n",
"dump(VAR_27, outfile, default_flow_style=False)\n",
"exit(1)\n",
"if VAR_49 is not VAR_47:\n",
"self.logger.debug('Dependency tree for start all: %s' % VAR_59)\n",
"self.logger.debug('Copying component \"%s\" to remote host \"%s\"' % (VAR_6,\n VAR_28))\n",
"VAR_59 = '%s -> %s' % (VAR_59, VAR_49.comp_name)\n",
"VAR_12 = \"ssh %s 'mkdir -p %s' & scp %s %s:%s/%s.yaml\" % (VAR_28, VAR_1,\n VAR_48, VAR_28, VAR_1, VAR_6)\n",
"self.logger.debug(VAR_12)\n",
"FUNC_7(self.session, VAR_12)\n",
"def FUNC_17(self, VAR_6):...\n",
"if VAR_6['host'] != 'localhost' and not self.run_on_localhost(VAR_6):\n",
"self.logger.debug(\"Stopping remote component '%s' on host '%s'\" % (VAR_6[\n 'name'], VAR_6['host']))\n",
"VAR_9 = FUNC_6(self.session, VAR_6['name'])\n",
"self.stop_remote_component(VAR_6['name'], VAR_6['host'])\n",
"if VAR_9:\n",
"def FUNC_18(self, VAR_14, VAR_28):...\n",
"self.logger.debug(\"window '%s' found running\" % VAR_6['name'])\n",
"VAR_12 = \"ssh %s 'hyperion --config %s/%s.yaml slave --kill'\" % (VAR_28,\n VAR_1, VAR_14)\n",
"self.logger.info('Shutting down window...')\n",
"self.logger.debug('Run cmd:\\n%s' % VAR_12)\n",
"FUNC_4(VAR_9)\n",
"FUNC_7(self.session, VAR_12)\n",
"self.logger.info('... done!')\n",
"def FUNC_19(self, VAR_6):...\n",
"VAR_49 = self.nodes.get(VAR_6['name'])\n",
"VAR_50 = []\n",
"VAR_51 = []\n",
"dep_resolve(VAR_49, VAR_50, VAR_51)\n",
"for VAR_49 in VAR_50:\n",
"self.logger.debug(\"node name '%s' vs. comp name '%s'\" % (VAR_49.comp_name,\n VAR_6['name']))\n",
"self.logger.debug(\"All dependencies satisfied, starting '%s'\" % VAR_6['name'])\n",
"if VAR_49.comp_name != VAR_6['name']:\n",
"VAR_52 = self.check_component(VAR_49.component)\n",
"self.logger.debug('Checking and starting %s' % VAR_49.comp_name)\n",
"if VAR_52 is CLASS_0.STARTED_BY_HAND or VAR_52 is CLASS_0.RUNNING:\n",
"VAR_52 = self.check_component(VAR_49.component)\n",
"self.logger.debug('Component %s is already running. Skipping start' % VAR_6\n ['name'])\n",
"self.start_component_without_deps(VAR_6)\n",
"if VAR_52 is CLASS_0.STOPPED_BUT_SUCCESSFUL or VAR_52 is CLASS_0.STARTED_BY_HAND or VAR_52 is CLASS_0.RUNNING:\n",
"return True\n",
"self.logger.debug(\n 'Component %s is already running, skipping to next in line' % VAR_6['name']\n )\n",
"self.logger.debug(\"Start component '%s' as dependency of '%s'\" % (VAR_49.\n comp_name, VAR_6['name']))\n",
"self.start_component_without_deps(VAR_49.component)\n",
"VAR_62 = 0\n",
"while True:\n",
"self.logger.debug('Checking %s resulted in checkstate %s' % (VAR_49.\n comp_name, VAR_52))\n",
"VAR_52 = self.check_component(VAR_49.component)\n",
"if VAR_52 is not CLASS_0.RUNNING or VAR_52 is not CLASS_0.STOPPED_BUT_SUCCESSFUL:\n",
"if VAR_62 > 100:\n",
"return False\n",
"VAR_62 = VAR_62 + 1\n",
"sleep(0.5)\n"
] | [
"from libtmux import Server\n",
"from yaml import load, dump\n",
"from setupParser import Loader\n",
"from DepTree import Node, dep_resolve, CircularReferenceException\n",
"import logging\n",
"import os\n",
"import socket\n",
"import argparse\n",
"from psutil import Process\n",
"from subprocess import call\n",
"from graphviz import Digraph\n",
"from enum import Enum\n",
"from time import sleep\n",
"import sys\n",
"from PyQt4 import QtGui\n",
"import hyperGUI\n",
"FORMAT = '%(asctime)s: %(name)s [%(levelname)s]:\\t%(message)s'\n",
"logging.basicConfig(level=logging.WARNING, format=FORMAT, datefmt='%I:%M:%S')\n",
"TMP_SLAVE_DIR = '/tmp/Hyperion/slave/components'\n",
"TMP_COMP_DIR = '/tmp/Hyperion/components'\n",
"TMP_LOG_PATH = '/tmp/Hyperion/log'\n",
"BASE_DIR = os.path.dirname(__file__)\n",
"SCRIPT_CLONE_PATH = '%s/scripts/start_named_clone_session.sh' % BASE_DIR\n",
"RUNNING = 0\n",
"STOPPED = 1\n",
"STOPPED_BUT_SUCCESSFUL = 2\n",
"STARTED_BY_HAND = 3\n",
"DEP_FAILED = 4\n",
"def __init__(self, configfile=None):...\n",
"self.logger = logging.getLogger(__name__)\n",
"self.logger.setLevel(logging.DEBUG)\n",
"self.configfile = configfile\n",
"self.nodes = {}\n",
"self.server = []\n",
"self.host_list = []\n",
"if configfile:\n",
"self.load_config(configfile)\n",
"self.config = None\n",
"self.session_name = self.config['name']\n",
"def load_config(self, filename='default.yaml'):...\n",
"dump(self.config, outfile, default_flow_style=False)\n",
"self.config = load(data_file, Loader)\n",
"self.logger.debug('Loading config was successful')\n",
"def init(self):...\n",
"self.server = Server()\n",
"if not self.config:\n",
"if self.server.has_session(self.session_name):\n",
"self.logger.error(' Config not loaded yet!')\n",
"for group in self.config['groups']:\n",
"self.session = self.server.find_where({'session_name': self.session_name})\n",
"self.logger.info('starting new session by name \"%s\" on server' % self.\n session_name)\n",
"def set_dependencies(self, exit_on_fail):...\n",
"for comp in group['components']:\n",
"self.host_list = list(set(self.host_list))\n",
"self.logger.info('found running session by name \"%s\" on server' % self.\n session_name)\n",
"self.session = self.server.new_session(session_name=self.session_name,\n window_name='Main')\n",
"for group in self.config['groups']:\n",
"self.logger.debug(\"Checking component '%s' in group '%s' on host '%s'\" % (\n comp['name'], group['name'], comp['host']))\n",
"self.set_dependencies(True)\n",
"for comp in group['components']:\n",
"master_node = Node({'name': 'master_node'})\n",
"if comp['host'] != 'localhost' and not self.run_on_localhost(comp):\n",
"self.nodes[comp['name']] = Node(comp)\n",
"for name in self.nodes:\n",
"self.copy_component_to_remote(comp, comp['name'], comp['host'])\n",
"node = self.nodes.get(name)\n",
"self.nodes['master_node'] = master_node\n",
"master_node.addEdge(node)\n",
"node = self.nodes.get('master_node')\n",
"self.logger.error(\n 'Detected circular dependency reference between %s and %s!' % (ex.node1,\n ex.node2))\n",
"def copy_component_to_remote(self, infile, comp, host):...\n",
"if 'depends' in node.component:\n",
"res = []\n",
"if exit_on_fail:\n",
"self.host_list.append(host)\n",
"for dep in node.component['depends']:\n",
"unres = []\n",
"exit(1)\n",
"self.logger.debug('Saving component to tmp')\n",
"if dep in self.nodes:\n",
"dep_resolve(node, res, unres)\n",
"tmp_comp_path = '%s/%s.yaml' % (TMP_COMP_DIR, comp)\n",
"node.addEdge(self.nodes[dep])\n",
"self.logger.error(\"Unmet dependency: '%s' for component '%s'!\" % (dep, node\n .comp_name))\n",
"dep_string = ''\n",
"ensure_dir(tmp_comp_path)\n",
"if exit_on_fail:\n",
"for node in res:\n",
"dump(infile, outfile, default_flow_style=False)\n",
"exit(1)\n",
"if node is not master_node:\n",
"self.logger.debug('Dependency tree for start all: %s' % dep_string)\n",
"self.logger.debug('Copying component \"%s\" to remote host \"%s\"' % (comp, host))\n",
"dep_string = '%s -> %s' % (dep_string, node.comp_name)\n",
"cmd = \"ssh %s 'mkdir -p %s' & scp %s %s:%s/%s.yaml\" % (host, TMP_SLAVE_DIR,\n tmp_comp_path, host, TMP_SLAVE_DIR, comp)\n",
"self.logger.debug(cmd)\n",
"send_main_session_command(self.session, cmd)\n",
"def stop_component(self, comp):...\n",
"if comp['host'] != 'localhost' and not self.run_on_localhost(comp):\n",
"self.logger.debug(\"Stopping remote component '%s' on host '%s'\" % (comp[\n 'name'], comp['host']))\n",
"window = find_window(self.session, comp['name'])\n",
"self.stop_remote_component(comp['name'], comp['host'])\n",
"if window:\n",
"def stop_remote_component(self, comp_name, host):...\n",
"self.logger.debug(\"window '%s' found running\" % comp['name'])\n",
"cmd = \"ssh %s 'hyperion --config %s/%s.yaml slave --kill'\" % (host,\n TMP_SLAVE_DIR, comp_name)\n",
"self.logger.info('Shutting down window...')\n",
"self.logger.debug('Run cmd:\\n%s' % cmd)\n",
"kill_window(window)\n",
"send_main_session_command(self.session, cmd)\n",
"self.logger.info('... done!')\n",
"def start_component(self, comp):...\n",
"node = self.nodes.get(comp['name'])\n",
"res = []\n",
"unres = []\n",
"dep_resolve(node, res, unres)\n",
"for node in res:\n",
"self.logger.debug(\"node name '%s' vs. comp name '%s'\" % (node.comp_name,\n comp['name']))\n",
"self.logger.debug(\"All dependencies satisfied, starting '%s'\" % comp['name'])\n",
"if node.comp_name != comp['name']:\n",
"state = self.check_component(node.component)\n",
"self.logger.debug('Checking and starting %s' % node.comp_name)\n",
"if state is CheckState.STARTED_BY_HAND or state is CheckState.RUNNING:\n",
"state = self.check_component(node.component)\n",
"self.logger.debug('Component %s is already running. Skipping start' % comp[\n 'name'])\n",
"self.start_component_without_deps(comp)\n",
"if state is CheckState.STOPPED_BUT_SUCCESSFUL or state is CheckState.STARTED_BY_HAND or state is CheckState.RUNNING:\n",
"return True\n",
"self.logger.debug(\n 'Component %s is already running, skipping to next in line' % comp['name'])\n",
"self.logger.debug(\"Start component '%s' as dependency of '%s'\" % (node.\n comp_name, comp['name']))\n",
"self.start_component_without_deps(node.component)\n",
"tries = 0\n",
"while True:\n",
"self.logger.debug('Checking %s resulted in checkstate %s' % (node.comp_name,\n state))\n",
"state = self.check_component(node.component)\n",
"if state is not CheckState.RUNNING or state is not CheckState.STOPPED_BUT_SUCCESSFUL:\n",
"if tries > 100:\n",
"return False\n",
"tries = tries + 1\n",
"sleep(0.5)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"ImportFrom'",
"Import'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"FunctionDef'",
"Assign'",
"Condition",
"Condition",
"Expr'",
"For",
"Assign'",
"Expr'",
"FunctionDef'",
"For",
"Assign'",
"Expr'",
"Assign'",
"For",
"Expr'",
"Expr'",
"For",
"Assign'",
"Condition",
"Assign'",
"For",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"For",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"For",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"FunctionDef'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"For",
"Expr'",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Return'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Condition",
"Return'",
"Assign'",
"Expr'"
] |
[
"def __init__(self, VAR_25=None, VAR_40=None, VAR_41=None, VAR_42=None,...\n",
"VAR_54 = config.NsxLibConfig(VAR_40=username or NSX_USER, VAR_41=password or\n NSX_PASSWORD, VAR_42=retries or NSX_HTTP_RETRIES, VAR_43=insecure if \n insecure is not None else NSX_INSECURE, VAR_44=ca_file or NSX_CERT,\n VAR_32=concurrent_connections or NSX_CONCURENT_CONN, VAR_45=\n http_timeout or NSX_HTTP_TIMEOUT, VAR_46=http_read_timeout or\n NSX_HTTP_READ_TIMEOUT, VAR_47=conn_idle_timeout or NSX_CONN_IDLE_TIME,\n http_provider=NsxClientTestCase.MockHTTPProvider(session_response=\n session_response), VAR_48=nsx_api_managers or [NSX_MANAGER],\n plugin_scope=PLUGIN_SCOPE, plugin_tag=PLUGIN_TAG, plugin_ver=PLUGIN_VER)\n",
"super(CLASS_2.MockNSXClusteredAPI, self).__init__(VAR_54)\n",
"self._record = mock.Mock()\n"
] | [
"def __init__(self, session_response=None, username=None, password=None,...\n",
"nsxlib_config = config.NsxLibConfig(username=username or NSX_USER, password\n =password or NSX_PASSWORD, retries=retries or NSX_HTTP_RETRIES,\n insecure=insecure if insecure is not None else NSX_INSECURE, ca_file=\n ca_file or NSX_CERT, concurrent_connections=concurrent_connections or\n NSX_CONCURENT_CONN, http_timeout=http_timeout or NSX_HTTP_TIMEOUT,\n http_read_timeout=http_read_timeout or NSX_HTTP_READ_TIMEOUT,\n conn_idle_timeout=conn_idle_timeout or NSX_CONN_IDLE_TIME,\n http_provider=NsxClientTestCase.MockHTTPProvider(session_response=\n session_response), nsx_api_managers=nsx_api_managers or [NSX_MANAGER],\n plugin_scope=PLUGIN_SCOPE, plugin_tag=PLUGIN_TAG, plugin_ver=PLUGIN_VER)\n",
"super(NsxClientTestCase.MockNSXClusteredAPI, self).__init__(nsxlib_config)\n",
"self._record = mock.Mock()\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Expr'",
"Assign'"
] |
[
"@staticmethod...\n",
"return CLASS_0._TalkToHandlerAsync(VAR_9, VAR_7, 'POST', VAR_10)\n"
] | [
"@staticmethod...\n",
"return BaseRequest._TalkToHandlerAsync(data, handler, 'POST', timeout)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"\"\"\"docstring\"\"\"\n",
"while True:\n",
"VAR_48 = self.readline()\n",
"sys.exit(0)\n",
"self.execute(VAR_48)\n"
] | [
"def run(self):...\n",
"\"\"\"docstring\"\"\"\n",
"while True:\n",
"line = self.readline()\n",
"sys.exit(0)\n",
"self.execute(line)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_15 = ['hp3par_api_url', 'hp3par_username', 'hp3par_password', 'san_ip',\n 'san_login', 'san_password']\n",
"self.common.check_flags(self.configuration, VAR_15)\n"
] | [
"def _check_flags(self):...\n",
"\"\"\"docstring\"\"\"\n",
"required_flags = ['hp3par_api_url', 'hp3par_username', 'hp3par_password',\n 'san_ip', 'san_login', 'san_password']\n",
"self.common.check_flags(self.configuration, required_flags)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_0(VAR_0, VAR_1, VAR_2):...\n",
"VAR_1['AWS_ACCESS_KEY_ID'] = VAR_0.get_input('username', default='')\n",
"VAR_1['AWS_SECRET_ACCESS_KEY'] = VAR_0.get_input('password', default='')\n",
"if VAR_0.has_input('security_token'):\n",
"VAR_1['AWS_SECURITY_TOKEN'] = VAR_0.get_input('security_token', default='')\n"
] | [
"def aws(cred, env, private_data_dir):...\n",
"env['AWS_ACCESS_KEY_ID'] = cred.get_input('username', default='')\n",
"env['AWS_SECRET_ACCESS_KEY'] = cred.get_input('password', default='')\n",
"if cred.has_input('security_token'):\n",
"env['AWS_SECURITY_TOKEN'] = cred.get_input('security_token', default='')\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Assign'"
] |
[
"def FUNC_1(self):...\n",
"VAR_4 = self.get_option('cluster') or '%'\n",
"VAR_5 = self.get_option('datacenter') or '%'\n",
"self.dbcmd = '/usr/share/ovirt-engine/dbscripts/engine-psql.sh -c \"'\n",
"self.dbcmd += 'string' % (VAR_4, VAR_5)\n",
"self.log_debug('Query command for ovirt DB set to: %s' % self.dbcmd)\n"
] | [
"def format_db_cmd(self):...\n",
"cluster = self.get_option('cluster') or '%'\n",
"datacenter = self.get_option('datacenter') or '%'\n",
"self.dbcmd = '/usr/share/ovirt-engine/dbscripts/engine-psql.sh -c \"'\n",
"self.dbcmd += (\n 'select host_name from vds_static where cluster_id in (select cluster_id from cluster where name like \\'%s\\' and storage_pool_id in (select id from storage_pool where name like \\'%s\\'))\"'\n % (cluster, datacenter))\n",
"self.log_debug('Query command for ovirt DB set to: %s' % self.dbcmd)\n"
] | [
0,
2,
2,
2,
2,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"AugAssign'",
"Expr'"
] |
[
"def FUNC_1():...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_5 = {}\n",
"for arg in request.args:\n",
"VAR_8 = re.findall('page_(.*)', arg)\n",
"return VAR_5\n",
"if VAR_8:\n",
"VAR_5[VAR_8[0]] = int(request.args.get(arg))\n"
] | [
"def get_page_args():...\n",
"\"\"\"docstring\"\"\"\n",
"pages = {}\n",
"for arg in request.args:\n",
"re_match = re.findall('page_(.*)', arg)\n",
"return pages\n",
"if re_match:\n",
"pages[re_match[0]] = int(request.args.get(arg))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"For",
"Assign'",
"Return'",
"Condition",
"Assign'"
] |
[
"def FUNC_7(self, VAR_13, VAR_11, VAR_7, VAR_14, VAR_10):...\n",
"VAR_18 = VAR_11['rules']\n",
"for VAR_37, VAR_9 in itertools.product(VAR_18, VAR_14):\n",
"VAR_8 = VAR_10.get_rule(VAR_37)\n",
"return None\n",
"FUNC_4(VAR_7, VAR_8, VAR_9, VAR_10)\n"
] | [
"def get_directories(self, levelctx, levelfields, searcher, ctxlist, client):...\n",
"rulenames = levelfields['rules']\n",
"for rulename, ctx in itertools.product(rulenames, ctxlist):\n",
"rule = client.get_rule(rulename)\n",
"return None\n",
"_traverse(searcher, rule, ctx, client)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Assign'",
"Return'",
"Expr'"
] |
[
"\"\"\"string\"\"\"\n",
"from Tkinter import *\n",
"from SeleniumDriver import *\n",
"import pyperclip\n",
"VAR_0 = None\n",
"VAR_1 = None\n",
"VAR_2 = None\n",
"VAR_3 = None\n",
"VAR_4 = None\n",
"def __init__(self, VAR_5, VAR_6):...\n",
"self.master = VAR_5\n",
"VAR_5.title('Jira Automation')\n",
"self.firefox = VAR_6\n",
"self.colorWhiteText = '#FFF'\n",
"self.colorGreyBackground = '#708090'\n",
"VAR_12 = Label(VAR_5, text=' ')\n",
"VAR_12.grid(column=0, row=0)\n",
"self.login_button = Button(VAR_5, text='JIRA Login', command=self.\n setCredentials)\n",
"self.login_button.grid(sticky='E', column=3, row=0)\n",
"self.summary_static_text = Label(VAR_5, text='Input Sync Summary:')\n",
"self.summary_static_text.grid(columnspan=4, sticky='W', row=1)\n",
"self.summary_field = Entry(VAR_9, width=61)\n",
"self.summary_field.configure(background=self.colorGreyBackground,\n foreground=self.colorWhiteText)\n",
"self.summary_field.grid(columnspan=4, column=0, row=2, sticky='W')\n",
"VAR_13 = Label(VAR_5, text=' ')\n",
"VAR_13.grid(column=0, row=3)\n",
"self.clarify_static_text = Label(VAR_5, text='Input Case Number:')\n",
"self.clarify_static_text.grid(columnspan=4, sticky='W', row=4)\n",
"self.clarify_field = Entry(VAR_9, width=61)\n",
"self.clarify_field.configure(background=self.colorGreyBackground,\n foreground=self.colorWhiteText)\n",
"self.clarify_field.grid(column=0, row=5, columnspan=4, sticky='W')\n",
"VAR_14 = Label(VAR_5, text=' ')\n",
"VAR_14.grid(column=0, row=6)\n",
"self.detailed_static_text = Label(VAR_5, text='Input Detailed Information')\n",
"self.detailed_static_text.grid(columnspan=4, sticky='W', row=7)\n",
"self.detailed_field = Text(VAR_9, height=35, width=79)\n",
"self.detailed_field.configure(background=self.colorGreyBackground,\n foreground=self.colorWhiteText)\n",
"self.detailed_field.grid(columnspan=4, row=8, column=0, sticky='W')\n",
"self.run_split_button = Button(VAR_5, text='Create JIRA', command=self.\n createCase)\n",
"self.run_split_button.grid(row=10, column=1, sticky='W')\n",
"self.close_button = Button(VAR_5, text='Close', command=master.quit)\n",
"self.close_button.grid(row=10, column=2, sticky='E')\n",
"def FUNC_0(self):...\n",
"self.win = Toplevel()\n",
"self.win.title = 'Input JIRA Login'\n",
"self.username_static_text = Label(self.win, text='Username:')\n",
"self.username_static_text.grid(column=0, row=0, sticky='E')\n",
"self.username_field = Entry(self.win)\n",
"self.username_field.configure(background=self.colorGreyBackground,\n foreground=self.colorWhiteText)\n",
"self.username_field.grid(column=1, row=0, sticky='W')\n",
"self.password_static_text = Label(self.win, text='Password:')\n",
"self.password_static_text.grid(column=0, row=1, sticky='E')\n",
"self.password_field = Entry(self.win, show='*')\n",
"self.password_field.configure(background=self.colorGreyBackground,\n foreground=self.colorWhiteText)\n",
"self.password_field.grid(column=1, row=1, sticky='W')\n",
"self.submit_button = Button(self.win, text='Save Credentials', command=self\n .setLoginInfo)\n",
"self.submit_button.grid(column=1, row=2, columnspan=2)\n",
"def FUNC_1(self):...\n",
"self.password = self.password_field.get()\n",
"self.username = self.username_field.get()\n",
"self.destroy_window(self.win)\n",
"def FUNC_2(self, VAR_7):...\n",
"self.error_window = Toplevel()\n",
"self.error_window.title = 'ERROR - PLEASE READ'\n",
"VAR_15 = Message(self.error_window, text=error_message, width=500)\n",
"VAR_15.grid(row=0, column=0, columnspan=3)\n",
"VAR_16 = Button(self.error_window, text='Ok', command=lambda : self.\n error_window.destroy())\n",
"VAR_16.grid(row=1, column=1)\n",
"def FUNC_3(self, VAR_8):...\n",
"VAR_8.destroy()\n",
"def FUNC_4(self):...\n",
"if self.password == None or self.username == None or self.password == ' ' or self.username == ' ':\n",
"self.errorNotification('Please login to JIRA first')\n",
"self.firefox.loadPage('https://devops.partech.com/jira/login.jsp', 'JIRA')\n",
"if __name__ == '__main__':\n",
"self.firefox.login(self.username, self.password)\n",
"VAR_9 = Tk()\n",
"self.firefox.createNewTicket()\n",
"VAR_10 = SeleniumDriver()\n",
"self.firefox.inputDataToCase(self.summary_field.get(), self.detailed_field.\n get('1.0', END))\n",
"VAR_11 = CLASS_0(VAR_9, VAR_10)\n",
"VAR_9.mainloop()\n"
] | [
"\"\"\"\nAuthor; Garrett Breeden\nVersion: 1.0\n 1. Integrated SeleniumDriver into GUI \n - Data should now pass from GUI -> Selenium\n 2. Updated input field classes\n 3. Small GUI Tweaks\n\nVersion: 1.2\n 1. Corrected issue with data being passed to Selenium from GUI\n\n\nTO ONLY BE USED BY L2 AND L3 @ PARTECH\n\"\"\"\n",
"from Tkinter import *\n",
"from SeleniumDriver import *\n",
"import pyperclip\n",
"username = None\n",
"password = None\n",
"summary = None\n",
"clarify = None\n",
"details = None\n",
"def __init__(self, master, selenium):...\n",
"self.master = master\n",
"master.title('Jira Automation')\n",
"self.firefox = selenium\n",
"self.colorWhiteText = '#FFF'\n",
"self.colorGreyBackground = '#708090'\n",
"empty_spacer_1 = Label(master, text=' ')\n",
"empty_spacer_1.grid(column=0, row=0)\n",
"self.login_button = Button(master, text='JIRA Login', command=self.\n setCredentials)\n",
"self.login_button.grid(sticky='E', column=3, row=0)\n",
"self.summary_static_text = Label(master, text='Input Sync Summary:')\n",
"self.summary_static_text.grid(columnspan=4, sticky='W', row=1)\n",
"self.summary_field = Entry(root, width=61)\n",
"self.summary_field.configure(background=self.colorGreyBackground,\n foreground=self.colorWhiteText)\n",
"self.summary_field.grid(columnspan=4, column=0, row=2, sticky='W')\n",
"empty_spacer_2 = Label(master, text=' ')\n",
"empty_spacer_2.grid(column=0, row=3)\n",
"self.clarify_static_text = Label(master, text='Input Case Number:')\n",
"self.clarify_static_text.grid(columnspan=4, sticky='W', row=4)\n",
"self.clarify_field = Entry(root, width=61)\n",
"self.clarify_field.configure(background=self.colorGreyBackground,\n foreground=self.colorWhiteText)\n",
"self.clarify_field.grid(column=0, row=5, columnspan=4, sticky='W')\n",
"empty_spacer_3 = Label(master, text=' ')\n",
"empty_spacer_3.grid(column=0, row=6)\n",
"self.detailed_static_text = Label(master, text='Input Detailed Information')\n",
"self.detailed_static_text.grid(columnspan=4, sticky='W', row=7)\n",
"self.detailed_field = Text(root, height=35, width=79)\n",
"self.detailed_field.configure(background=self.colorGreyBackground,\n foreground=self.colorWhiteText)\n",
"self.detailed_field.grid(columnspan=4, row=8, column=0, sticky='W')\n",
"self.run_split_button = Button(master, text='Create JIRA', command=self.\n createCase)\n",
"self.run_split_button.grid(row=10, column=1, sticky='W')\n",
"self.close_button = Button(master, text='Close', command=master.quit)\n",
"self.close_button.grid(row=10, column=2, sticky='E')\n",
"def setCredentials(self):...\n",
"self.win = Toplevel()\n",
"self.win.title = 'Input JIRA Login'\n",
"self.username_static_text = Label(self.win, text='Username:')\n",
"self.username_static_text.grid(column=0, row=0, sticky='E')\n",
"self.username_field = Entry(self.win)\n",
"self.username_field.configure(background=self.colorGreyBackground,\n foreground=self.colorWhiteText)\n",
"self.username_field.grid(column=1, row=0, sticky='W')\n",
"self.password_static_text = Label(self.win, text='Password:')\n",
"self.password_static_text.grid(column=0, row=1, sticky='E')\n",
"self.password_field = Entry(self.win, show='*')\n",
"self.password_field.configure(background=self.colorGreyBackground,\n foreground=self.colorWhiteText)\n",
"self.password_field.grid(column=1, row=1, sticky='W')\n",
"self.submit_button = Button(self.win, text='Save Credentials', command=self\n .setLoginInfo)\n",
"self.submit_button.grid(column=1, row=2, columnspan=2)\n",
"def setLoginInfo(self):...\n",
"self.password = self.password_field.get()\n",
"self.username = self.username_field.get()\n",
"self.destroy_window(self.win)\n",
"def errorNotification(self, error_message):...\n",
"self.error_window = Toplevel()\n",
"self.error_window.title = 'ERROR - PLEASE READ'\n",
"error_message_text = Message(self.error_window, text=error_message, width=500)\n",
"error_message_text.grid(row=0, column=0, columnspan=3)\n",
"close_button_error = Button(self.error_window, text='Ok', command=lambda :\n self.error_window.destroy())\n",
"close_button_error.grid(row=1, column=1)\n",
"def destroy_window(self, window):...\n",
"window.destroy()\n",
"def createCase(self):...\n",
"if self.password == None or self.username == None or self.password == ' ' or self.username == ' ':\n",
"self.errorNotification('Please login to JIRA first')\n",
"self.firefox.loadPage('https://devops.partech.com/jira/login.jsp', 'JIRA')\n",
"if __name__ == '__main__':\n",
"self.firefox.login(self.username, self.password)\n",
"root = Tk()\n",
"self.firefox.createNewTicket()\n",
"_selenium = SeleniumDriver()\n",
"self.firefox.inputDataToCase(self.summary_field.get(), self.detailed_field.\n get('1.0', END))\n",
"main_GUI = JiraGeneratorWindow(root, _selenium)\n",
"root.mainloop()\n"
] | [
0,
5,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Expr'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_1(self, VAR_10, VAR_11, VAR_12):...\n",
"fd.write(VAR_12)\n",
"fd.flush()\n",
"fd.seek(0)\n",
"VAR_35 = os.path.basename(fd.name)\n",
"if self.shouldLog:\n",
"self.logger.debug('Sending file %s with mime type : %s', VAR_35, VAR_11)\n",
"VAR_30 = self.session.post(self.uploadUrl, files={self.inputName: (filename,\n fd, mime)}, data=self.postData)\n",
"self.httpRequests += 1\n",
"if self.shouldLog:\n",
"if self.logger.verbosity > 1:\n",
"return VAR_30, VAR_35\n",
"printSimpleResponseObject(VAR_30)\n",
"if self.logger.verbosity > 2:\n",
"print('\\x1b[36m' + VAR_30.text + '\\x1b[m')\n"
] | [
"def uploadFile(self, suffix, mime, payload):...\n",
"fd.write(payload)\n",
"fd.flush()\n",
"fd.seek(0)\n",
"filename = os.path.basename(fd.name)\n",
"if self.shouldLog:\n",
"self.logger.debug('Sending file %s with mime type : %s', filename, mime)\n",
"fu = self.session.post(self.uploadUrl, files={self.inputName: (filename, fd,\n mime)}, data=self.postData)\n",
"self.httpRequests += 1\n",
"if self.shouldLog:\n",
"if self.logger.verbosity > 1:\n",
"return fu, filename\n",
"printSimpleResponseObject(fu)\n",
"if self.logger.verbosity > 2:\n",
"print('\\x1b[36m' + fu.text + '\\x1b[m')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
7,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"AugAssign'",
"Condition",
"Condition",
"Return'",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_20(self, VAR_19, VAR_20):...\n",
"\"\"\"docstring\"\"\"\n",
"for clause in reversed(self.order):\n",
"VAR_40 = VAR_20.has_wildcards() - VAR_19.has_wildcards()\n",
"VAR_51 = clause.index(VAR_19.name)\n",
"if VAR_40 != 0:\n",
"VAR_52 = clause.index(VAR_20.name)\n",
"return VAR_40\n",
"return 0\n",
"VAR_39 = VAR_52 - VAR_51\n",
"if VAR_39 < 0:\n",
"VAR_39 = -1\n",
"if VAR_39 > 0:\n",
"return VAR_39\n",
"VAR_39 = 1\n"
] | [
"def compare(self, rule1, rule2):...\n",
"\"\"\"docstring\"\"\"\n",
"for clause in reversed(self.order):\n",
"wildcard_cmp = rule2.has_wildcards() - rule1.has_wildcards()\n",
"i = clause.index(rule1.name)\n",
"if wildcard_cmp != 0:\n",
"j = clause.index(rule2.name)\n",
"return wildcard_cmp\n",
"return 0\n",
"comp = j - i\n",
"if comp < 0:\n",
"comp = -1\n",
"if comp > 0:\n",
"return comp\n",
"comp = 1\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"For",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Assign'"
] |
[
"def FUNC_19(self, VAR_6, VAR_14):...\n",
"self.common.extend_volume(VAR_6, VAR_14)\n"
] | [
"def extend_volume(self, volume, new_size):...\n",
"self.common.extend_volume(volume, new_size)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_3(VAR_21, VAR_22, VAR_23=BaseInlineFormSet, VAR_24=forms.ModelForm,...\n",
"VAR_32 = VAR_22.detail_fields()\n",
"if VAR_4:\n",
"VAR_32 = [in_field for in_field in VAR_32 if not in_field in VAR_4]\n",
"return forms.inlineformset_factory(VAR_21=parent_model, VAR_22=model,\n VAR_27=formset_fields, VAR_23=formset, VAR_24=form, VAR_2=extra, VAR_3=\n can_delete)\n"
] | [
"def make_formset(parent_model, model, formset=BaseInlineFormSet, form=forms...\n",
"formset_fields = model.detail_fields()\n",
"if exclude:\n",
"formset_fields = [in_field for in_field in formset_fields if not in_field in\n exclude]\n",
"return forms.inlineformset_factory(parent_model=parent_model, model=model,\n fields=formset_fields, formset=formset, form=form, extra=extra,\n can_delete=can_delete)\n"
] | [
0,
0,
0,
0,
0
] | [
"For",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"def __call__(self, VAR_20):...\n",
"return set(filter(lambda VAR_53: str(VAR_53.value).startswith(str(self.\n prefix)), VAR_20))\n"
] | [
"def __call__(self, urls):...\n",
"return set(filter(lambda u: str(u.value).startswith(str(self.prefix)), urls))\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_2(self, VAR_1, VAR_7, VAR_8, VAR_9, VAR_4=None):...\n",
"if VAR_4 is None:\n",
"VAR_4 = {}\n",
"VAR_29 = super(CLASS_0, self).view_header_get(VAR_1, VAR_7, VAR_8, VAR_9, VAR_4\n )\n",
"if VAR_29:\n",
"return VAR_29\n",
"if VAR_4.get('active_id', False) and VAR_4.get('active_model'\n",
"return _('Products: ') + self.pool.get('stock.location').browse(VAR_1,\n VAR_7, VAR_4['active_id'], VAR_4).name\n",
"return VAR_29\n"
] | [
"def view_header_get(self, cr, user, view_id, view_type, context=None):...\n",
"if context is None:\n",
"context = {}\n",
"res = super(product_product, self).view_header_get(cr, user, view_id,\n view_type, context)\n",
"if res:\n",
"return res\n",
"if context.get('active_id', False) and context.get('active_model'\n",
"return _('Products: ') + self.pool.get('stock.location').browse(cr, user,\n context['active_id'], context).name\n",
"return res\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"self.render('report.html')\n"
] | [
"def get(self):...\n",
"self.render('report.html')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_58():...\n",
"VAR_36.execute('rollback')\n"
] | [
"def test():...\n",
"cnxn.execute('rollback')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@integration_synonym_api...\n",
"FUNC_2(VAR_2)\n",
"FUNC_3(VAR_2, 'AILEEN ENTERPRISES', VAR_7='1')\n",
"FUNC_5(VAR_4, VAR_5, VAR_11='ALAN HARGREAVES CORPORATION', VAR_10=[{'name':\n '----ALAN HARGREAVES'}, {'name': '----ALAN'}])\n"
] | [
"@integration_synonym_api...\n",
"clean_database(solr)\n",
"seed_database_with(solr, 'AILEEN ENTERPRISES', id='1')\n",
"verify_results(client, jwt, query='ALAN HARGREAVES CORPORATION', expected=[\n {'name': '----ALAN HARGREAVES'}, {'name': '----ALAN'}])\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_0(VAR_6):...\n",
"@wraps(VAR_6)...\n",
"if 'logged_in' in VAR_10:\n",
"return VAR_6(*VAR_8, **kwargs)\n",
"flash('Unauthorized, Please login', 'danger')\n",
"return redirect(url_for('login'))\n"
] | [
"def is_logged_in(f):...\n",
"@wraps(f)...\n",
"if 'logged_in' in session:\n",
"return f(*args, **kwargs)\n",
"flash('Unauthorized, Please login', 'danger')\n",
"return redirect(url_for('login'))\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"Return'",
"Expr'",
"Return'"
] |
[
"import socket\n",
"import threading\n",
"import tornado\n",
"import tornado.concurrent\n",
"import tornado.httputil\n",
"import tornado.httpserver\n",
"import tornado.gen\n",
"import tornado.ioloop\n",
"import tornado.process\n",
"import tornado.web\n",
"from bzs import const\n",
"from bzs import db\n",
"from bzs import files\n",
"from bzs import module_error404\n",
"from bzs import module_files\n",
"from bzs import module_home\n",
"from bzs import module_index\n",
"from bzs import module_static\n",
"VAR_0 = 80\n",
"def FUNC_0():...\n",
"VAR_1 = tornado.web.Application([('^/$', module_index.MainframeHandler), (\n '/static/.*', module_static.StaticHandler), ('^/home', module_home.\n HomeHandler), ('^/files/?()$', module_files.FilesListHandler), (\n '^/files/list/(.*)', module_files.FilesListHandler), (\n '^/files/download/(.*)/(.*)/?$', module_files.FilesDownloadHandler), (\n '^/files/upload/(.*)/(.*)$', module_files.FilesUploadHandler), (\n '^/files/operation/?', module_files.FilesOperationHandler), ('.*',\n module_error404.Error404Handler)], xsrf_cookies=False)\n",
"VAR_2 = tornado.netutil.bind_sockets(const.get_const('server-port'), family\n =socket.AF_INET)\n",
"if const.get_const('server-threads') > 1:\n",
"if hasattr(os, 'fork'):\n",
"VAR_3 = tornado.httpserver.HTTPServer(VAR_1, xheaders=True)\n",
"tornado.process.fork_processes(const.get_const('server-threads') - 1)\n",
"VAR_3.add_sockets(VAR_2)\n",
"tornado.ioloop.IOLoop.instance().start()\n",
"return\n"
] | [
"import socket\n",
"import threading\n",
"import tornado\n",
"import tornado.concurrent\n",
"import tornado.httputil\n",
"import tornado.httpserver\n",
"import tornado.gen\n",
"import tornado.ioloop\n",
"import tornado.process\n",
"import tornado.web\n",
"from bzs import const\n",
"from bzs import db\n",
"from bzs import files\n",
"from bzs import module_error404\n",
"from bzs import module_files\n",
"from bzs import module_home\n",
"from bzs import module_index\n",
"from bzs import module_static\n",
"WEB_PORT = 80\n",
"def main():...\n",
"web_app = tornado.web.Application([('^/$', module_index.MainframeHandler),\n ('/static/.*', module_static.StaticHandler), ('^/home', module_home.\n HomeHandler), ('^/files/?()$', module_files.FilesListHandler), (\n '^/files/list/(.*)', module_files.FilesListHandler), (\n '^/files/download/(.*)/(.*)/?$', module_files.FilesDownloadHandler), (\n '^/files/upload/(.*)/(.*)$', module_files.FilesUploadHandler), (\n '^/files/operation/?', module_files.FilesOperationHandler), ('.*',\n module_error404.Error404Handler)], xsrf_cookies=False)\n",
"web_sockets = tornado.netutil.bind_sockets(const.get_const('server-port'),\n family=socket.AF_INET)\n",
"if const.get_const('server-threads') > 1:\n",
"if hasattr(os, 'fork'):\n",
"web_server = tornado.httpserver.HTTPServer(web_app, xheaders=True)\n",
"tornado.process.fork_processes(const.get_const('server-threads') - 1)\n",
"web_server.add_sockets(web_sockets)\n",
"tornado.ioloop.IOLoop.instance().start()\n",
"return\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"For",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"import random\n",
"from flask import url_for, redirect, render_template, request\n",
"from . import bp as app\n",
"@app.route('/')...\n",
"return render_template('home.html')\n"
] | [
"import random\n",
"from flask import url_for, redirect, render_template, request\n",
"from . import bp as app\n",
"@app.route('/')...\n",
"return render_template('home.html')\n"
] | [
0,
0,
0,
0,
3
] | [
"Import'",
"ImportFrom'",
"ImportFrom'",
"Condition",
"Return'"
] |
[
"def FUNC_12(self, VAR_13, VAR_12):...\n",
"self.send_rep(VAR_13, 0, wzrpc.status.error, VAR_12)\n"
] | [
"def send_error_rep(self, reqid, data):...\n",
"self.send_rep(reqid, 0, wzrpc.status.error, data)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_7(self, VAR_9, VAR_11=None):...\n",
"get_and_check_project(VAR_9, VAR_11)\n",
"VAR_25 = self.queryset.filter(VAR_1=project_pk)\n",
"VAR_25 = filters.OrderingFilter().filter_queryset(self.request, VAR_25, self)\n",
"VAR_26 = CLASS_1(VAR_25, many=True)\n",
"return Response(VAR_26.data)\n"
] | [
"def list(self, request, project_pk=None):...\n",
"get_and_check_project(request, project_pk)\n",
"tasks = self.queryset.filter(project=project_pk)\n",
"tasks = filters.OrderingFilter().filter_queryset(self.request, tasks, self)\n",
"serializer = TaskSerializer(tasks, many=True)\n",
"return Response(serializer.data)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self, VAR_33):...\n",
"VAR_78 = []\n",
"for v in self.splitter.split(VAR_33):\n",
"VAR_21 = self.id_re.match(v)\n",
"return VAR_78\n",
"if VAR_21:\n",
"VAR_108 = CLASS_5(None, False).run(VAR_21.group(1))\n",
"if VAR_108:\n",
"VAR_78.append(VAR_108)\n"
] | [
"def run(self, val):...\n",
"res = []\n",
"for v in self.splitter.split(val):\n",
"link_id = self.id_re.match(v)\n",
"return res\n",
"if link_id:\n",
"l = VLink(None, False).run(link_id.group(1))\n",
"if l:\n",
"res.append(l)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Condition",
"Expr'"
] |
[
"@property...\n",
"return self.type == 'CO'\n"
] | [
"@property...\n",
"return self.type == 'CO'\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_3(VAR_4):...\n",
"VAR_41 = list(set(itertools.chain.from_iterable(VAR_4.values())))\n",
"VAR_42 = {obj.id: obj for obj in education_group_year.search(id=flat_root_ids)}\n",
"return {obj_id: sorted([VAR_42[VAR_60] for VAR_60 in parents], VAR_57=lambda\n obj: obj.acronym) for obj_id, parents in VAR_4.items()}\n"
] | [
"def _convert_parent_ids_to_instances(root_ids_by_object_id):...\n",
"flat_root_ids = list(set(itertools.chain.from_iterable(\n root_ids_by_object_id.values())))\n",
"map_instance_by_id = {obj.id: obj for obj in education_group_year.search(id\n =flat_root_ids)}\n",
"return {obj_id: sorted([map_instance_by_id[parent_id] for parent_id in\n parents], key=lambda obj: obj.acronym) for obj_id, parents in\n root_ids_by_object_id.items()}\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"return \"\"\"Task: %s (ID %d)\nFile: %s\n\"\"\" % (self.task[1], self.task[0], repr\n (self.filenames)) + GenericRequest.specific_info(self)\n"
] | [
"def specific_info(self):...\n",
"return \"\"\"Task: %s (ID %d)\nFile: %s\n\"\"\" % (self.task[1], self.task[0], repr\n (self.filenames)) + GenericRequest.specific_info(self)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"async def FUNC_8(VAR_6):...\n",
"VAR_10 = {'Authorization': f'Bearer {VAR_1}'}\n",
"VAR_8 = await VAR_6.get('/results', VAR_10=headers)\n",
"VAR_9 = await VAR_8.json()\n",
"assert VAR_8.status == 200\n"
] | [
"async def test_positive_get_all_results(test_cli):...\n",
"headers = {'Authorization': f'Bearer {access_token}'}\n",
"resp = await test_cli.get('/results', headers=headers)\n",
"resp_json = await resp.json()\n",
"assert resp.status == 200\n"
] | [
0,
0,
0,
0,
0
] | [
"AsyncFunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assert'"
] |
[
"@VAR_2.route('/update_comment/<pic_name>', methods=['POST', 'GET'])...\n",
"if request.method == 'POST':\n",
"VAR_4 = (\n \"UPDATE commentsTable\\t\\t\\t\\t\\tSET comment = '%s'\\t\\t\\t\\t\\tWHERE comment_id = '%s' \"\n % (request.form['new_comment'], request.form['edit_value']))\n",
"return redirect(url_for('view_comment', VAR_3=pic_name))\n",
"VAR_1.execute(VAR_4)\n",
"VAR_0.commit()\n"
] | [
"@app.route('/update_comment/<pic_name>', methods=['POST', 'GET'])...\n",
"if request.method == 'POST':\n",
"query = (\n \"UPDATE commentsTable\\t\\t\\t\\t\\tSET comment = '%s'\\t\\t\\t\\t\\tWHERE comment_id = '%s' \"\n % (request.form['new_comment'], request.form['edit_value']))\n",
"return redirect(url_for('view_comment', pic_name=pic_name))\n",
"cursor.execute(query)\n",
"db.commit()\n"
] | [
0,
0,
4,
4,
0,
0
] | [
"Condition",
"Condition",
"Assign'",
"Return'",
"Expr'",
"Expr'"
] |
[
"def FUNC_17(self, VAR_24):...\n",
""
] | [
"def process_wz_msg(self, frames):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_18(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_47 = self.auth_method\n",
"if not VAR_47:\n",
"for VAR_47 in self.get_auth_methods(config.ensure_configured()):\n",
"if VAR_47 not in VAR_4:\n",
"if VAR_47 in VAR_4:\n",
"return VAR_4[VAR_47]\n"
] | [
"def _get_users_api(self):...\n",
"\"\"\"docstring\"\"\"\n",
"method = self.auth_method\n",
"if not method:\n",
"for method in self.get_auth_methods(config.ensure_configured()):\n",
"if method not in _METHOD_TO_USERS_API:\n",
"if method in _METHOD_TO_USERS_API:\n",
"return _METHOD_TO_USERS_API[method]\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"For",
"Condition",
"Condition",
"Return'"
] |
[
"def FUNC_26(VAR_30, *VAR_12, **VAR_17):...\n",
"if not GLSetting.memory_copy.anomaly_checks:\n",
"return VAR_20(VAR_30, *VAR_12, **kw)\n",
"if GLSetting.anomalies_counter[VAR_1] > alarm_level[VAR_1]:\n",
"if VAR_1 == 'new_submission':\n",
"return VAR_20(VAR_30, *VAR_12, **kw)\n",
"log.debug('Blocked a New Submission (%d > %d)' % (GLSetting.\n anomalies_counter[VAR_1], alarm_level[VAR_1]))\n",
"if VAR_1 == 'finalized_submission':\n",
"log.debug('Blocked a Finalized Submission (%d > %d)' % (GLSetting.\n anomalies_counter[VAR_1], alarm_level[VAR_1]))\n",
"if VAR_1 == 'anon_requests':\n",
"log.debug('Blocked an Anon Request (%d > %d)' % (GLSetting.\n anomalies_counter[VAR_1], alarm_level[VAR_1]))\n",
"if VAR_1 == 'file_uploaded':\n",
"log.debug('Blocked a File upload (%d > %d)' % (GLSetting.anomalies_counter[\n VAR_1], alarm_level[VAR_1]))\n",
"log.debug('Blocked an Unknown event (=%s) !? [BUG!] (%d > %d)' % (VAR_1,\n GLSetting.anomalies_counter[VAR_1], alarm_level[VAR_1]))\n"
] | [
"def call_handler(cls, *args, **kw):...\n",
"if not GLSetting.memory_copy.anomaly_checks:\n",
"return method_handler(cls, *args, **kw)\n",
"if GLSetting.anomalies_counter[element] > alarm_level[element]:\n",
"if element == 'new_submission':\n",
"return method_handler(cls, *args, **kw)\n",
"log.debug('Blocked a New Submission (%d > %d)' % (GLSetting.\n anomalies_counter[element], alarm_level[element]))\n",
"if element == 'finalized_submission':\n",
"log.debug('Blocked a Finalized Submission (%d > %d)' % (GLSetting.\n anomalies_counter[element], alarm_level[element]))\n",
"if element == 'anon_requests':\n",
"log.debug('Blocked an Anon Request (%d > %d)' % (GLSetting.\n anomalies_counter[element], alarm_level[element]))\n",
"if element == 'file_uploaded':\n",
"log.debug('Blocked a File upload (%d > %d)' % (GLSetting.anomalies_counter[\n element], alarm_level[element]))\n",
"log.debug('Blocked an Unknown event (=%s) !? [BUG!] (%d > %d)' % (element,\n GLSetting.anomalies_counter[element], alarm_level[element]))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Condition",
"Condition",
"Return'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_22(self):...\n",
"self.assertRaises(NotImplementedError, self.driver.local_path, '')\n"
] | [
"def test_local_path(self):...\n",
"self.assertRaises(NotImplementedError, self.driver.local_path, '')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@api.public...\n",
"FUNC_31(self, 'DELETE')\n"
] | [
"@api.public...\n",
"record(self, 'DELETE')\n"
] | [
0,
0
] | [
"Condition",
"Expr'"
] |
[
"def FUNC_0(VAR_0):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_83.included_stack:\n",
"return None\n",
"return os.path.join(os.path.dirname(VAR_83.included_stack[-1]), VAR_0)\n"
] | [
"def srcdir(path):...\n",
"\"\"\"docstring\"\"\"\n",
"if not workflow.included_stack:\n",
"return None\n",
"return os.path.join(os.path.dirname(workflow.included_stack[-1]), path)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Return'"
] |
[
"import time\n",
"import mox\n",
"import paramiko\n",
"from cinder import context\n",
"from cinder import exception\n",
"from cinder.openstack.common import log as logging\n",
"from cinder.openstack.common import processutils\n",
"from cinder import test\n",
"from cinder.volume import configuration as conf\n",
"from cinder.volume.drivers import eqlx\n",
"VAR_0 = logging.getLogger(__name__)\n",
"def FUNC_0(self):...\n",
"super(CLASS_0, self).setUp()\n",
"self.configuration = mox.MockObject(conf.Configuration)\n",
"self.configuration.append_config_values(mox.IgnoreArg())\n",
"self.configuration.san_is_local = False\n",
"self.configuration.san_ip = '10.0.0.1'\n",
"self.configuration.san_login = 'foo'\n",
"self.configuration.san_password = 'bar'\n",
"self.configuration.san_ssh_port = 16022\n",
"self.configuration.san_thin_provision = True\n",
"self.configuration.eqlx_pool = 'non-default'\n",
"self.configuration.eqlx_use_chap = True\n",
"self.configuration.eqlx_group_name = 'group-0'\n",
"self.configuration.eqlx_cli_timeout = 30\n",
"self.configuration.eqlx_cli_max_retries = 5\n",
"self.configuration.eqlx_chap_login = 'admin'\n",
"self.configuration.eqlx_chap_password = 'password'\n",
"self.configuration.volume_name_template = 'volume_%s'\n",
"self._context = context.get_admin_context()\n",
"self.driver = eqlx.DellEQLSanISCSIDriver(configuration=self.configuration)\n",
"self.volume_name = 'fakevolume'\n",
"self.volid = 'fakeid'\n",
"self.connector = {'ip': '10.0.0.2', 'initiator':\n 'iqn.1993-08.org.debian:01:222', 'host': 'fakehost'}\n",
"self.fake_iqn = 'iqn.2003-10.com.equallogic:group01:25366:fakev'\n",
"self.driver._group_ip = '10.0.1.6'\n",
"self.properties = {'target_discoverd': True, 'target_portal': '%s:3260' %\n self.driver._group_ip, 'target_iqn': self.fake_iqn, 'volume_id': 1}\n",
"self._model_update = {'provider_location': '%s:3260,1 %s 0' % (self.driver.\n _group_ip, self.fake_iqn), 'provider_auth': 'CHAP %s %s' % (self.\n configuration.eqlx_chap_login, self.configuration.eqlx_chap_password)}\n",
"def FUNC_1(self, VAR_1):...\n",
"return self.properties\n"
] | [
"import time\n",
"import mox\n",
"import paramiko\n",
"from cinder import context\n",
"from cinder import exception\n",
"from cinder.openstack.common import log as logging\n",
"from cinder.openstack.common import processutils\n",
"from cinder import test\n",
"from cinder.volume import configuration as conf\n",
"from cinder.volume.drivers import eqlx\n",
"LOG = logging.getLogger(__name__)\n",
"def setUp(self):...\n",
"super(DellEQLSanISCSIDriverTestCase, self).setUp()\n",
"self.configuration = mox.MockObject(conf.Configuration)\n",
"self.configuration.append_config_values(mox.IgnoreArg())\n",
"self.configuration.san_is_local = False\n",
"self.configuration.san_ip = '10.0.0.1'\n",
"self.configuration.san_login = 'foo'\n",
"self.configuration.san_password = 'bar'\n",
"self.configuration.san_ssh_port = 16022\n",
"self.configuration.san_thin_provision = True\n",
"self.configuration.eqlx_pool = 'non-default'\n",
"self.configuration.eqlx_use_chap = True\n",
"self.configuration.eqlx_group_name = 'group-0'\n",
"self.configuration.eqlx_cli_timeout = 30\n",
"self.configuration.eqlx_cli_max_retries = 5\n",
"self.configuration.eqlx_chap_login = 'admin'\n",
"self.configuration.eqlx_chap_password = 'password'\n",
"self.configuration.volume_name_template = 'volume_%s'\n",
"self._context = context.get_admin_context()\n",
"self.driver = eqlx.DellEQLSanISCSIDriver(configuration=self.configuration)\n",
"self.volume_name = 'fakevolume'\n",
"self.volid = 'fakeid'\n",
"self.connector = {'ip': '10.0.0.2', 'initiator':\n 'iqn.1993-08.org.debian:01:222', 'host': 'fakehost'}\n",
"self.fake_iqn = 'iqn.2003-10.com.equallogic:group01:25366:fakev'\n",
"self.driver._group_ip = '10.0.1.6'\n",
"self.properties = {'target_discoverd': True, 'target_portal': '%s:3260' %\n self.driver._group_ip, 'target_iqn': self.fake_iqn, 'volume_id': 1}\n",
"self._model_update = {'provider_location': '%s:3260,1 %s 0' % (self.driver.\n _group_ip, self.fake_iqn), 'provider_auth': 'CHAP %s %s' % (self.\n configuration.eqlx_chap_login, self.configuration.eqlx_chap_password)}\n",
"def _fake_get_iscsi_properties(self, volume):...\n",
"return self.properties\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
] | [
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_2(VAR_0, VAR_1):...\n",
"VAR_5 = frappe.session.user\n",
"VAR_6 = get_leave_allocation_records(VAR_0.to_date)\n",
"VAR_7 = get_leave_allocation_records(VAR_0.from_date)\n",
"VAR_8 = frappe.get_all('Employee', VAR_0={'status': 'Active', 'company':\n filters.company}, fields=['name', 'employee_name', 'department', 'user_id']\n )\n",
"VAR_4 = []\n",
"for employee in VAR_8:\n",
"VAR_12 = FUNC_3(employee.department)\n",
"return VAR_4\n",
"if len(VAR_12) and VAR_5 in VAR_12 or VAR_5 in ['Administrator', employee.\n",
"VAR_13 = [employee.name, employee.employee_name, employee.department]\n",
"for leave_type in VAR_1:\n",
"VAR_14 = get_approved_leaves_for_period(employee.name, leave_type, VAR_0.\n from_date, VAR_0.to_date)\n",
"VAR_4.append(VAR_13)\n",
"VAR_15 = get_leave_balance_on(employee.name, leave_type, VAR_0.from_date,\n VAR_7.get(employee.name, frappe._dict()))\n",
"VAR_16 = get_leave_balance_on(employee.name, leave_type, VAR_0.to_date,\n VAR_6.get(employee.name, frappe._dict()))\n",
"VAR_13 += [VAR_15, VAR_14, VAR_16]\n"
] | [
"def get_data(filters, leave_types):...\n",
"user = frappe.session.user\n",
"allocation_records_based_on_to_date = get_leave_allocation_records(filters.\n to_date)\n",
"allocation_records_based_on_from_date = get_leave_allocation_records(filters\n .from_date)\n",
"active_employees = frappe.get_all('Employee', filters={'status': 'Active',\n 'company': filters.company}, fields=['name', 'employee_name',\n 'department', 'user_id'])\n",
"data = []\n",
"for employee in active_employees:\n",
"leave_approvers = get_approvers(employee.department)\n",
"return data\n",
"if len(leave_approvers) and user in leave_approvers or user in ['Administrator'\n",
"row = [employee.name, employee.employee_name, employee.department]\n",
"for leave_type in leave_types:\n",
"leaves_taken = get_approved_leaves_for_period(employee.name, leave_type,\n filters.from_date, filters.to_date)\n",
"data.append(row)\n",
"opening = get_leave_balance_on(employee.name, leave_type, filters.from_date,\n allocation_records_based_on_from_date.get(employee.name, frappe._dict()))\n",
"closing = get_leave_balance_on(employee.name, leave_type, filters.to_date,\n allocation_records_based_on_to_date.get(employee.name, frappe._dict()))\n",
"row += [opening, leaves_taken, closing]\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Return'",
"Condition",
"Assign'",
"For",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"AugAssign'"
] |
[
"def FUNC_5(self, VAR_8):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_14 = hmac.new(b'd1b964811afb40118a12068ff74a12f4', digestmod=hashlib.sha1)\n",
"VAR_15 = self.login_data['grant_type']\n",
"VAR_16 = self.login_data['client_id']\n",
"VAR_17 = self.login_data['source']\n",
"VAR_14.update(bytes(VAR_15 + VAR_16 + VAR_17 + VAR_8, 'utf-8'))\n",
"return VAR_14.hexdigest()\n"
] | [
"def _get_signature(self, timestamp):...\n",
"\"\"\"docstring\"\"\"\n",
"ha = hmac.new(b'd1b964811afb40118a12068ff74a12f4', digestmod=hashlib.sha1)\n",
"grant_type = self.login_data['grant_type']\n",
"client_id = self.login_data['client_id']\n",
"source = self.login_data['source']\n",
"ha.update(bytes(grant_type + client_id + source + timestamp, 'utf-8'))\n",
"return ha.hexdigest()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_1(self, VAR_6, VAR_7, VAR_5):...\n",
"VAR_14 = []\n",
"VAR_14.append('string'.format(VAR_6))\n",
"VAR_14.append('string'.format(VAR_6, VAR_5, VAR_7))\n",
"for query in VAR_14:\n",
"self.cur.execute(query)\n",
"self.conn.commit()\n"
] | [
"def update_roster(self, username, role, server_id):...\n",
"sql = []\n",
"sql.append(\n \"\"\"INSERT INTO users (username)\n VALUES ('{0}')\n ON DUPLICATE KEY UPDATE username = '{0}';\n \"\"\"\n .format(username))\n",
"sql.append(\n \"\"\"INSERT INTO roles (username, server_id, role)\n VALUES ('{0}', '{1}', '{2}')\n ON DUPLICATE KEY UPDATE role = '{2}';\n \"\"\"\n .format(username, server_id, role))\n",
"for query in sql:\n",
"self.cur.execute(query)\n",
"self.conn.commit()\n"
] | [
0,
4,
4,
4,
4,
4,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"For",
"Expr'",
"Expr'"
] |
[
"def FUNC_24(VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_40 = [VAR_5['name']]\n",
"VAR_27 = VAR_5['holders']\n",
"for holder_no, holder in enumerate(VAR_27):\n",
"VAR_43 = VAR_33[min(len(VAR_27) - (holder_no + 1), 1)]\n",
"return VAR_40\n",
"VAR_44 = FUNC_24(holder)\n",
"for line_no, line in enumerate(VAR_44):\n",
"VAR_40.append(VAR_43[min(line_no, 1)] + line)\n"
] | [
"def format_tree(tree):...\n",
"\"\"\"docstring\"\"\"\n",
"result = [tree['name']]\n",
"holders = tree['holders']\n",
"for holder_no, holder in enumerate(holders):\n",
"spacer_style = spacers[min(len(holders) - (holder_no + 1), 1)]\n",
"return result\n",
"subtree_lines = format_tree(holder)\n",
"for line_no, line in enumerate(subtree_lines):\n",
"result.append(spacer_style[min(line_no, 1)] + line)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"For",
"Assign'",
"Return'",
"Assign'",
"For",
"Expr'"
] |
[
"@api.multi...\n",
"return self.write({'state': 'active'})\n"
] | [
"@api.multi...\n",
"return self.write({'state': 'active'})\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_9(self, VAR_10, VAR_6, VAR_11, VAR_12, VAR_13, VAR_14):...\n",
"if VAR_12:\n",
"VAR_36 = db.log_event('Information', 'Debugger', 'Command', VAR_10, success\n =False)\n",
"VAR_6 = [bytes(output, encoding='utf-8') for output in VAR_6]\n",
"VAR_27 = ''\n",
"if VAR_11 is None:\n",
"VAR_11 = VAR_10\n",
"VAR_28 = self.telnet.read_very_eager().decode('utf-8', 'replace')\n",
"if self.db.result:\n",
"self.db.result['debugger_output'] += VAR_28\n",
"self.db.campaign['debugger_output'] += VAR_28\n",
"if self.options.debug:\n",
"print(colored(VAR_28, 'yellow'))\n",
"if VAR_10:\n",
"self.telnet.write(bytes(VAR_10 + VAR_13, encoding='utf-8'))\n",
"for i in range(len(VAR_6)):\n",
"if VAR_14:\n",
"VAR_29, VAR_30, VAR_28 = self.telnet.expect(VAR_6, timeout=self.timeout)\n",
"VAR_29, VAR_30, VAR_28 = self.telnet.expect(self.prompts, timeout=self.timeout)\n",
"VAR_29, VAR_30, VAR_28 = self.telnet.expect([bytes(VAR_10, encoding='utf-8'\n )], timeout=self.timeout)\n",
"VAR_28 = VAR_10 + '\\n'\n",
"VAR_28 = VAR_28.decode('utf-8', 'replace')\n",
"VAR_28 = VAR_28.decode('utf-8', 'replace')\n",
"VAR_28 = VAR_28.decode('utf-8', 'replace')\n",
"if self.db.result:\n",
"if self.db.result:\n",
"if self.db.result:\n",
"self.db.result['debugger_output'] += VAR_28\n",
"self.db.campaign['debugger_output'] += VAR_28\n",
"self.db.result['debugger_output'] += VAR_28\n",
"self.db.campaign['debugger_output'] += VAR_28\n",
"self.db.result['debugger_output'] += VAR_28\n",
"self.db.campaign['debugger_output'] += VAR_28\n",
"if self.options.debug:\n",
"VAR_27 += VAR_28\n",
"VAR_27 += VAR_28\n",
"print(colored(VAR_28, 'yellow'))\n",
"if VAR_14 and VAR_29 < 0:\n",
"if self.options.debug:\n",
"if self.options.debug:\n",
"print(colored(VAR_28, 'yellow'), VAR_25='')\n",
"if VAR_29 < 0:\n",
"print(colored(VAR_28, 'yellow'))\n",
"if self.db.result:\n",
"db.update('result')\n",
"db.update('campaign')\n",
"if VAR_29 < 0:\n",
"for message in self.error_messages:\n",
"if message in VAR_27:\n",
"if VAR_12:\n",
"db.log_event_success(VAR_36)\n",
"return VAR_27\n"
] | [
"def command(self, command, expected_output, error_message, log_event,...\n",
"if log_event:\n",
"event = db.log_event('Information', 'Debugger', 'Command', command, success\n =False)\n",
"expected_output = [bytes(output, encoding='utf-8') for output in\n expected_output]\n",
"return_buffer = ''\n",
"if error_message is None:\n",
"error_message = command\n",
"buff = self.telnet.read_very_eager().decode('utf-8', 'replace')\n",
"if self.db.result:\n",
"self.db.result['debugger_output'] += buff\n",
"self.db.campaign['debugger_output'] += buff\n",
"if self.options.debug:\n",
"print(colored(buff, 'yellow'))\n",
"if command:\n",
"self.telnet.write(bytes(command + line_ending, encoding='utf-8'))\n",
"for i in range(len(expected_output)):\n",
"if echo:\n",
"index, match, buff = self.telnet.expect(expected_output, timeout=self.timeout)\n",
"index, match, buff = self.telnet.expect(self.prompts, timeout=self.timeout)\n",
"index, match, buff = self.telnet.expect([bytes(command, encoding='utf-8')],\n timeout=self.timeout)\n",
"buff = command + '\\n'\n",
"buff = buff.decode('utf-8', 'replace')\n",
"buff = buff.decode('utf-8', 'replace')\n",
"buff = buff.decode('utf-8', 'replace')\n",
"if self.db.result:\n",
"if self.db.result:\n",
"if self.db.result:\n",
"self.db.result['debugger_output'] += buff\n",
"self.db.campaign['debugger_output'] += buff\n",
"self.db.result['debugger_output'] += buff\n",
"self.db.campaign['debugger_output'] += buff\n",
"self.db.result['debugger_output'] += buff\n",
"self.db.campaign['debugger_output'] += buff\n",
"if self.options.debug:\n",
"return_buffer += buff\n",
"return_buffer += buff\n",
"print(colored(buff, 'yellow'))\n",
"if echo and index < 0:\n",
"if self.options.debug:\n",
"if self.options.debug:\n",
"print(colored(buff, 'yellow'), end='')\n",
"if index < 0:\n",
"print(colored(buff, 'yellow'))\n",
"if self.db.result:\n",
"db.update('result')\n",
"db.update('campaign')\n",
"if index < 0:\n",
"for message in self.error_messages:\n",
"if message in return_buffer:\n",
"if log_event:\n",
"db.log_event_success(event)\n",
"return return_buffer\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"AugAssign'",
"AugAssign'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"For",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"AugAssign'",
"AugAssign'",
"AugAssign'",
"AugAssign'",
"AugAssign'",
"AugAssign'",
"Condition",
"AugAssign'",
"AugAssign'",
"Expr'",
"Condition",
"Condition",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Condition",
"For",
"Condition",
"Condition",
"Expr'",
"Return'"
] |
[
"def FUNC_0(VAR_0):...\n",
"VAR_6 = (\"\"\"INSERT INTO dialogs (name, created_at)\nVALUES ('%s', NOW())\"\"\" %\n VAR_0)\n",
"return {'status': 1}\n"
] | [
"def db_addDialog(nameDialog):...\n",
"sql = (\"\"\"INSERT INTO dialogs (name, created_at)\nVALUES ('%s', NOW())\"\"\" %\n nameDialog)\n",
"return {'status': 1}\n"
] | [
0,
4,
4
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"@rest_utils.ajax(data_required=True)...\n",
"VAR_30 = VAR_1.DATA.get('flavor_access', [])\n",
"VAR_27 = not VAR_30\n",
"VAR_33 = api.nova.flavor_get_extras(VAR_1, VAR_5, raw=True)\n",
"api.nova.flavor_delete(VAR_1, VAR_5)\n",
"VAR_31 = api.nova.flavor_create(VAR_1, VAR_6=request.DATA['name'], memory=\n request.DATA['ram'], vcpu=request.DATA['vcpus'], disk=request.DATA[\n 'disk'], ephemeral=request.DATA['OS-FLV-EXT-DATA:ephemeral'], swap=\n request.DATA['swap'], flavorid=flavor_id, VAR_27=is_public)\n",
"for project in VAR_30:\n",
"api.nova.add_tenant_to_flavor(VAR_1, VAR_31.id, project.get('id'))\n",
"if VAR_33:\n",
"api.nova.flavor_extra_set(VAR_1, VAR_31.id, VAR_33)\n"
] | [
"@rest_utils.ajax(data_required=True)...\n",
"flavor_access = request.DATA.get('flavor_access', [])\n",
"is_public = not flavor_access\n",
"extras_dict = api.nova.flavor_get_extras(request, flavor_id, raw=True)\n",
"api.nova.flavor_delete(request, flavor_id)\n",
"flavor = api.nova.flavor_create(request, name=request.DATA['name'], memory=\n request.DATA['ram'], vcpu=request.DATA['vcpus'], disk=request.DATA[\n 'disk'], ephemeral=request.DATA['OS-FLV-EXT-DATA:ephemeral'], swap=\n request.DATA['swap'], flavorid=flavor_id, is_public=is_public)\n",
"for project in flavor_access:\n",
"api.nova.add_tenant_to_flavor(request, flavor.id, project.get('id'))\n",
"if extras_dict:\n",
"api.nova.flavor_extra_set(request, flavor.id, extras_dict)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"For",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_12(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_50 = frappe.db.get_table_columns(self.doctype)\n",
"VAR_51 = []\n",
"for fld in self.fields:\n",
"for VAR_34 in optional_fields:\n",
"for fld in VAR_51:\n",
"if VAR_34 in fld and not VAR_34 in VAR_50:\n",
"VAR_51 = []\n",
"VAR_51.append(fld)\n",
"for VAR_67 in self.filters:\n",
"if isinstance(VAR_67, string_types):\n",
"for VAR_67 in VAR_51:\n",
"VAR_67 = [VAR_67]\n",
"for element in VAR_67:\n",
"if isinstance(self.filters, dict):\n",
"if element in optional_fields and element not in VAR_50:\n",
"self.filters.remove(VAR_67)\n",
"VAR_51.append(VAR_67)\n"
] | [
"def set_optional_columns(self):...\n",
"\"\"\"docstring\"\"\"\n",
"columns = frappe.db.get_table_columns(self.doctype)\n",
"to_remove = []\n",
"for fld in self.fields:\n",
"for f in optional_fields:\n",
"for fld in to_remove:\n",
"if f in fld and not f in columns:\n",
"to_remove = []\n",
"to_remove.append(fld)\n",
"for each in self.filters:\n",
"if isinstance(each, string_types):\n",
"for each in to_remove:\n",
"each = [each]\n",
"for element in each:\n",
"if isinstance(self.filters, dict):\n",
"if element in optional_fields and element not in columns:\n",
"self.filters.remove(each)\n",
"to_remove.append(each)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"For",
"For",
"For",
"Condition",
"Assign'",
"Expr'",
"For",
"Condition",
"For",
"Assign'",
"For",
"Condition",
"Condition",
"Expr'",
"Expr'"
] |
[
"def __init__(self, VAR_6, VAR_7=None):...\n",
"super().__init__(VAR_6, VAR_7)\n",
"self.type = 'ip'\n"
] | [
"def __init__(self, name, display_name=None):...\n",
"super().__init__(name, display_name)\n",
"self.type = 'ip'\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'"
] |
[
"def FUNC_19(VAR_16):...\n",
"VAR_37 = os.path.join(VAR_16, 'README.md')\n",
"if os.path.isfile(VAR_37):\n",
"return 'LICENSE' in open(VAR_37).read()\n",
"return False\n"
] | [
"def license_mentionned_in_readme(path):...\n",
"readme_path = os.path.join(path, 'README.md')\n",
"if os.path.isfile(readme_path):\n",
"return 'LICENSE' in open(readme_path).read()\n",
"return False\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_1():...\n",
"VAR_3 = {'foo': 'bar'}\n",
"VAR_1 = json.dumps(VAR_3)\n",
"VAR_2 = load_source(VAR_1)\n",
"assert VAR_2 == VAR_3\n"
] | [
"def test_json_string():...\n",
"native = {'foo': 'bar'}\n",
"source = json.dumps(native)\n",
"result = load_source(source)\n",
"assert result == native\n"
] | [
0,
7,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assert'"
] |
[
"\"\"\"\nsabnzbd.database - Database Support\n\"\"\"\n",
"import sqlite3\n",
"import os\n",
"import pysqlite2.dbapi2 as sqlite3\n",
"import time\n",
"import zlib\n",
"import logging\n",
"import sys\n",
"import threading\n",
"import sabnzbd\n",
"import sabnzbd.cfg\n",
"from sabnzbd.constants import DB_HISTORY_NAME, STAGES\n",
"from sabnzbd.encoding import unicoder\n",
"from sabnzbd.bpsmeter import this_week, this_month\n",
"from sabnzbd.decorators import synchronized\n",
"from sabnzbd.misc import get_all_passwords, int_conv\n",
"VAR_0 = threading.RLock()\n",
"def FUNC_0(VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_1:\n",
"VAR_1 = ''\n",
"VAR_1 = VAR_1.replace('*', '%').replace(' ', '%')\n",
"if VAR_1 and VAR_1.startswith('^'):\n",
"VAR_1 = VAR_1.replace('^', '')\n",
"if VAR_1 and VAR_1.endswith('$'):\n",
"VAR_1 += '%'\n",
"VAR_1 = VAR_1.replace('$', '')\n",
"VAR_1 = '%' + VAR_1 + '%'\n",
"return VAR_1\n",
"VAR_1 = '%' + VAR_1\n"
] | [
"\"\"\"\nsabnzbd.database - Database Support\n\"\"\"\n",
"import sqlite3\n",
"import os\n",
"import pysqlite2.dbapi2 as sqlite3\n",
"import time\n",
"import zlib\n",
"import logging\n",
"import sys\n",
"import threading\n",
"import sabnzbd\n",
"import sabnzbd.cfg\n",
"from sabnzbd.constants import DB_HISTORY_NAME, STAGES\n",
"from sabnzbd.encoding import unicoder\n",
"from sabnzbd.bpsmeter import this_week, this_month\n",
"from sabnzbd.decorators import synchronized\n",
"from sabnzbd.misc import get_all_passwords, int_conv\n",
"DB_LOCK = threading.RLock()\n",
"def convert_search(search):...\n",
"\"\"\"docstring\"\"\"\n",
"if not search:\n",
"search = ''\n",
"search = search.replace('*', '%').replace(' ', '%')\n",
"if search and search.startswith('^'):\n",
"search = search.replace('^', '')\n",
"if search and search.endswith('$'):\n",
"search += '%'\n",
"search = search.replace('$', '')\n",
"search = '%' + search + '%'\n",
"return search\n",
"search = '%' + search\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
] | [
"Expr'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"AugAssign'",
"Assign'",
"Assign'",
"Return'",
"Assign'"
] |
[
"@transaction.atomic...\n",
"VAR_6 = RegisterStudentForm(VAR_0.POST)\n",
"if not VAR_6.is_valid():\n",
"return FUNC_0(VAR_0, VAR_4=form)\n",
"VAR_9 = Course.objects.get(course_number=request.POST['course_number'])\n",
"VAR_10 = Student.objects.get(andrew_id=request.POST['andrew_id'])\n",
"VAR_9.students.add(VAR_10)\n",
"VAR_9.save()\n",
"return FUNC_0(VAR_0, VAR_1=['Added %s to %s' % (student, course)])\n"
] | [
"@transaction.atomic...\n",
"form = RegisterStudentForm(request.POST)\n",
"if not form.is_valid():\n",
"return make_view(request, register_student_form=form)\n",
"course = Course.objects.get(course_number=request.POST['course_number'])\n",
"student = Student.objects.get(andrew_id=request.POST['andrew_id'])\n",
"course.students.add(student)\n",
"course.save()\n",
"return make_view(request, messages=['Added %s to %s' % (student, course)])\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"@integration_synonym_api...\n",
"FUNC_2(VAR_2)\n",
"FUNC_3(VAR_2, 'FEDS', VAR_7='1')\n",
"FUNC_5(VAR_4, VAR_5, VAR_11='FADS', VAR_10=[{'name': '----FADS'}])\n"
] | [
"@integration_synonym_api...\n",
"clean_database(solr)\n",
"seed_database_with(solr, 'FEDS', id='1')\n",
"verify_results(client, jwt, query='FADS', expected=[{'name': '----FADS'}])\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_2():...\n",
"super(CLASS_6, self).__init__(slideParser.parse(VAR_10, slideLexer))\n"
] | [
"def innerFunc():...\n",
"super(Emph, self).__init__(slideParser.parse(txt, slideLexer))\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_28(self, VAR_2, VAR_3, VAR_4, VAR_32, VAR_7={}):...\n",
"if 'hours' in VAR_32 and not VAR_32['hours']:\n",
"VAR_32['hours'] = 0.0\n",
"if 'hours' in VAR_32:\n",
"for work in self.browse(VAR_2, VAR_3, VAR_4, VAR_7):\n",
"return super(CLASS_3, self).write(VAR_2, VAR_3, VAR_4, VAR_32, VAR_7)\n",
"VAR_2.execute(\n 'update project_task set remaining_hours=remaining_hours - %s + (%s) where id=%s'\n , (VAR_32.get('hours', 0.0), work.hours, work.task_id.id))\n"
] | [
"def write(self, cr, uid, ids, vals, context={}):...\n",
"if 'hours' in vals and not vals['hours']:\n",
"vals['hours'] = 0.0\n",
"if 'hours' in vals:\n",
"for work in self.browse(cr, uid, ids, context):\n",
"return super(project_work, self).write(cr, uid, ids, vals, context)\n",
"cr.execute(\n 'update project_task set remaining_hours=remaining_hours - %s + (%s) where id=%s'\n , (vals.get('hours', 0.0), work.hours, work.task_id.id))\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"For",
"Return'",
"Expr'"
] |
[
"def FUNC_25(self, VAR_21):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_57 = self.getfile(VAR_21, VAR_23=False)\n",
"if VAR_57 == False:\n",
"if not VAR_57[VAR_6] & FUNC_30.S_IFLNK:\n",
"return VAR_57[VAR_9]\n"
] | [
"def readlink(self, path):...\n",
"\"\"\"docstring\"\"\"\n",
"p = self.getfile(path, follow_symlinks=False)\n",
"if p == False:\n",
"if not p[A_MODE] & stat.S_IFLNK:\n",
"return p[A_TARGET]\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Condition",
"Return'"
] |
[
"def FUNC_0(self, VAR_1):...\n",
"VAR_5 = ('select comment from comments order by date desc where userid=%d' %\n VAR_1)\n",
"VAR_6 = sql.queryDB(self.conn, VAR_5)\n",
"return VAR_6\n"
] | [
"def getCommentsByUser(self, userid):...\n",
"sqlText = (\n 'select comment from comments order by date desc where userid=%d' % userid)\n",
"result = sql.queryDB(self.conn, sqlText)\n",
"return result\n"
] | [
0,
4,
4,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"import sublime\n",
"import sublime_plugin\n",
"import os\n",
"import re\n",
"import datetime\n",
"import Urtext.urtext as Urtext\n",
"import pprint\n",
"import sys\n",
"sys.path.append(os.path.join(os.path.dirname(__file__)))\n",
"from anytree import Node, RenderTree\n",
"import anytree\n",
"import logging\n",
"def FUNC_0():...\n",
"VAR_3 = sublime.load_settings('urtext-default.sublime-settings')\n",
"VAR_4 = VAR_3.get('meta_separator')\n",
"return VAR_4\n"
] | [
"import sublime\n",
"import sublime_plugin\n",
"import os\n",
"import re\n",
"import datetime\n",
"import Urtext.urtext as Urtext\n",
"import pprint\n",
"import sys\n",
"sys.path.append(os.path.join(os.path.dirname(__file__)))\n",
"from anytree import Node, RenderTree\n",
"import anytree\n",
"import logging\n",
"def meta_separator():...\n",
"settings = sublime.load_settings('urtext-default.sublime-settings')\n",
"meta_separator = settings.get('meta_separator')\n",
"return meta_separator\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Expr'",
"ImportFrom'",
"Import'",
"Import'",
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_7(self, VAR_2, VAR_3, VAR_4, *VAR_5):...\n",
"self.write_data({'type': 'channel_discovered', 'event': VAR_5[0]})\n"
] | [
"def on_channel_discovered(self, subject, changetype, objectID, *args):...\n",
"self.write_data({'type': 'channel_discovered', 'event': args[0]})\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.