lines
sequencelengths 1
444
| raw_lines
sequencelengths 1
444
| label
sequencelengths 1
444
| type
sequencelengths 1
444
|
---|---|---|---|
[
"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'"
] |
[
"def FUNC_5(VAR_6):...\n",
"\"\"\"docstring\"\"\"\n",
"if 'CF-Cache-Status' in VAR_6.headers or 'CF-RAY' in VAR_6.headers:\n",
"return False\n",
"return True\n"
] | [
"def validate_not_using_cdn(page):...\n",
"\"\"\"docstring\"\"\"\n",
"if 'CF-Cache-Status' in page.headers or 'CF-RAY' in page.headers:\n",
"return False\n",
"return True\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_35(self):...\n",
"\"\"\"docstring\"\"\"\n",
"pyodbc.lowercase = True\n",
"self.cursor = self.cnxn.cursor()\n",
"self.cursor.execute('create table t1(Abc int, dEf int)')\n",
"self.cursor.execute('select * from t1')\n",
"VAR_27 = [VAR_31[0] for VAR_31 in self.cursor.description]\n",
"VAR_27.sort()\n",
"self.assertEqual(VAR_27, ['abc', 'def'])\n",
"pyodbc.lowercase = False\n"
] | [
"def test_lower_case(self):...\n",
"\"\"\"docstring\"\"\"\n",
"pyodbc.lowercase = True\n",
"self.cursor = self.cnxn.cursor()\n",
"self.cursor.execute('create table t1(Abc int, dEf int)')\n",
"self.cursor.execute('select * from t1')\n",
"names = [t[0] for t in self.cursor.description]\n",
"names.sort()\n",
"self.assertEqual(names, ['abc', 'def'])\n",
"pyodbc.lowercase = False\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Assign'"
] |
[
"def FUNC_26(self):...\n",
"return 'management/get_tag.html', TestPlan.objects.get(pk=self.object_pk)\n"
] | [
"def plan(self):...\n",
"return 'management/get_tag.html', TestPlan.objects.get(pk=self.object_pk)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_8(VAR_9):...\n",
"\"\"\"docstring\"\"\"\n",
"def FUNC_9(*VAR_13, **VAR_14):...\n",
"VAR_15 = 'memory alloced: %s kb' % str(gc.mem_alloc() / 1024)\n",
"VAR_16 = 'memory free: %s kb' % str(gc.mem_free() / 1024)\n",
"gc.collect()\n",
"VAR_17 = 'after collect: %s kb available' % str(gc.mem_free() / 1024)\n",
"print(FUNC_3(VAR_15, VAR_2='red'))\n",
"print(FUNC_3(VAR_16, VAR_2='green'))\n",
"print(FUNC_3(VAR_17, VAR_2='blue'))\n",
"VAR_9(*VAR_13, **kwargs)\n",
"VAR_18 = 'after %s excuted: %s kb available' % (VAR_9.__name__, str(gc.\n mem_free() / 1024))\n",
"print(FUNC_3(VAR_18, VAR_2='red'))\n",
"return FUNC_9\n"
] | [
"def mem_analyze(func):...\n",
"\"\"\"docstring\"\"\"\n",
"def wrapper(*args, **kwargs):...\n",
"memory_alloc = 'memory alloced: %s kb' % str(gc.mem_alloc() / 1024)\n",
"memory_free = 'memory free: %s kb' % str(gc.mem_free() / 1024)\n",
"gc.collect()\n",
"memory_after_collect = 'after collect: %s kb available' % str(gc.mem_free() /\n 1024)\n",
"print(rainbow(memory_alloc, color='red'))\n",
"print(rainbow(memory_free, color='green'))\n",
"print(rainbow(memory_after_collect, color='blue'))\n",
"func(*args, **kwargs)\n",
"memory_after_func_excute = 'after %s excuted: %s kb available' % (func.\n __name__, str(gc.mem_free() / 1024))\n",
"print(rainbow(memory_after_func_excute, color='red'))\n",
"return wrapper\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_8(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.assertTrue(self.client.login(username='autotest2', password='password'))\n",
"VAR_4 = 'autotest'\n",
"VAR_2 = '/api/apps'\n",
"VAR_5 = {'id': VAR_4}\n",
"VAR_3 = self.client.post(VAR_2, json.dumps(VAR_5), content_type=\n 'application/json')\n",
"self.assertTrue(self.client.login(username='autotest', password='password'))\n",
"VAR_2 = '/api/apps/{}'.format(VAR_4)\n",
"VAR_3 = self.client.get(VAR_2)\n",
"self.assertEqual(VAR_3.status_code, 200)\n",
"VAR_2 = '/api/apps/{app_id}/logs'.format(**locals())\n",
"VAR_3 = self.client.get(VAR_2)\n",
"self.assertEqual(VAR_3.status_code, 200)\n",
"self.assertIn('autotest2 created initial release', VAR_3.data)\n",
"VAR_2 = '/api/apps/{app_id}/run'.format(**locals())\n",
"VAR_5 = {'command': 'ls -al'}\n",
"VAR_3 = self.client.post(VAR_2, json.dumps(VAR_5), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_3.status_code, 200)\n",
"self.assertEqual(VAR_3.data[0], 0)\n",
"VAR_2 = '/api/apps/{}'.format(VAR_4)\n",
"VAR_3 = self.client.delete(VAR_2)\n",
"self.assertEqual(VAR_3.status_code, 204)\n"
] | [
"def test_admin_can_manage_other_apps(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.assertTrue(self.client.login(username='autotest2', password='password'))\n",
"app_id = 'autotest'\n",
"url = '/api/apps'\n",
"body = {'id': app_id}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertTrue(self.client.login(username='autotest', password='password'))\n",
"url = '/api/apps/{}'.format(app_id)\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"url = '/api/apps/{app_id}/logs'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertIn('autotest2 created initial release', response.data)\n",
"url = '/api/apps/{app_id}/run'.format(**locals())\n",
"body = {'command': 'ls -al'}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 200)\n",
"self.assertEqual(response.data[0], 0)\n",
"url = '/api/apps/{}'.format(app_id)\n",
"response = self.client.delete(url)\n",
"self.assertEqual(response.status_code, 204)\n"
] | [
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_15(self):...\n",
""
] | [
"def testDownloadFileDownloadError(self):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_2(self):...\n",
"self.result.update({'campaign_id': self.campaign['id'], 'aux_output': '',\n 'data_diff': None, 'debugger_output': '', 'detected_errors': None,\n 'dut_output': '', 'num_injections': None, 'outcome_category':\n 'Incomplete', 'outcome': 'Incomplete', 'timestamp': None})\n",
"self.insert('result')\n"
] | [
"def __create_result(self):...\n",
"self.result.update({'campaign_id': self.campaign['id'], 'aux_output': '',\n 'data_diff': None, 'debugger_output': '', 'detected_errors': None,\n 'dut_output': '', 'num_injections': None, 'outcome_category':\n 'Incomplete', 'outcome': 'Incomplete', 'timestamp': None})\n",
"self.insert('result')\n"
] | [
0,
2,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'"
] |
[
"@VAR_0.route('/level-1/login', methods=['POST'])...\n",
"VAR_19 = CLASS_1.query.get(request.form['account'])\n",
"if VAR_19:\n",
"if request.form['password'] == VAR_19.pwd:\n",
"return redirect(VAR_4 + 'level-1/index')\n",
"if int(current_user.level1_progress) <= 1 and str(request.form['account']\n",
"current_user.level1_progress = 2\n",
"return redirect(VAR_4 + 'level-1/inbox?account=' + VAR_19.account)\n",
"VAR_2.session.commit()\n"
] | [
"@app.route('/level-1/login', methods=['POST'])...\n",
"user = BMailUser.query.get(request.form['account'])\n",
"if user:\n",
"if request.form['password'] == user.pwd:\n",
"return redirect(url_prefix + 'level-1/index')\n",
"if int(current_user.level1_progress) <= 1 and str(request.form['account']\n",
"current_user.level1_progress = 2\n",
"return redirect(url_prefix + 'level-1/inbox?account=' + user.account)\n",
"db.session.commit()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"For",
"Return'",
"For",
"Assign'",
"Return'",
"Expr'"
] |
[
"def FUNC_0(self, VAR_1, VAR_2, VAR_3, VAR_4=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_4 is None:\n",
"VAR_4 = {}\n",
"VAR_17 = self.pool.get('product.product').browse(VAR_1, VAR_2, VAR_3, VAR_4\n =context)\n",
"VAR_18 = (VAR_17.property_stock_account_input and VAR_17.\n property_stock_account_input.id or False)\n",
"if not VAR_18:\n",
"VAR_18 = (VAR_17.categ_id.property_stock_account_input_categ and VAR_17.\n categ_id.property_stock_account_input_categ.id or False)\n",
"VAR_19 = (VAR_17.property_stock_account_output and VAR_17.\n property_stock_account_output.id or False)\n",
"if not VAR_19:\n",
"VAR_19 = (VAR_17.categ_id.property_stock_account_output_categ and VAR_17.\n categ_id.property_stock_account_output_categ.id or False)\n",
"VAR_20 = (VAR_17.categ_id.property_stock_journal and VAR_17.categ_id.\n property_stock_journal.id or False)\n",
"VAR_21 = (VAR_17.categ_id.property_stock_variation and VAR_17.categ_id.\n property_stock_variation.id or False)\n",
"return {'stock_account_input': VAR_18, 'stock_account_output': VAR_19,\n 'stock_journal': VAR_20, 'property_stock_variation': VAR_21}\n"
] | [
"def get_product_accounts(self, cr, uid, product_id, context=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if context is None:\n",
"context = {}\n",
"product_obj = self.pool.get('product.product').browse(cr, uid, product_id,\n context=context)\n",
"stock_input_acc = (product_obj.property_stock_account_input and product_obj\n .property_stock_account_input.id or False)\n",
"if not stock_input_acc:\n",
"stock_input_acc = (product_obj.categ_id.property_stock_account_input_categ and\n product_obj.categ_id.property_stock_account_input_categ.id or False)\n",
"stock_output_acc = (product_obj.property_stock_account_output and\n product_obj.property_stock_account_output.id or False)\n",
"if not stock_output_acc:\n",
"stock_output_acc = (product_obj.categ_id.\n property_stock_account_output_categ and product_obj.categ_id.\n property_stock_account_output_categ.id or False)\n",
"journal_id = (product_obj.categ_id.property_stock_journal and product_obj.\n categ_id.property_stock_journal.id or False)\n",
"account_variation = (product_obj.categ_id.property_stock_variation and\n product_obj.categ_id.property_stock_variation.id or False)\n",
"return {'stock_account_input': stock_input_acc, 'stock_account_output':\n stock_output_acc, 'stock_journal': journal_id,\n 'property_stock_variation': account_variation}\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@property...\n",
"return self._result_getter()\n"
] | [
"@property...\n",
"return self._result_getter()\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_8(self, VAR_4, VAR_5):...\n",
"if VAR_4 == 'ansible_group_priority':\n",
"self.set_priority(int(VAR_5))\n",
"self.vars[VAR_4] = VAR_5\n"
] | [
"def set_variable(self, key, value):...\n",
"if key == 'ansible_group_priority':\n",
"self.set_priority(int(value))\n",
"self.vars[key] = value\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Assign'"
] |
[
"def FUNC_4(self, VAR_4):...\n",
"if is_sqlite(VAR_4):\n",
"VAR_7 = self._sqlite_engine_cache.get_or_set(VAR_4, lambda : self.\n _create_sqlite_engine(VAR_4))\n",
"VAR_7 = create_engine(VAR_4)\n",
"return VAR_7\n"
] | [
"def _get_engine(self, connection_url):...\n",
"if is_sqlite(connection_url):\n",
"engine = self._sqlite_engine_cache.get_or_set(connection_url, lambda : self\n ._create_sqlite_engine(connection_url))\n",
"engine = create_engine(connection_url)\n",
"return engine\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"from django.conf import settings\n",
"from django.contrib import messages\n",
"from django.core.exceptions import MultipleObjectsReturned, PermissionDenied\n",
"from django.http.response import Http404, HttpResponse\n",
"from django.shortcuts import get_object_or_404\n",
"from django.utils.decorators import method_decorator\n",
"from django.utils.translation import ugettext_lazy as _\n",
"from django.views.decorators.clickjacking import xframe_options_exempt\n",
"from django.views.decorators.csrf import csrf_exempt\n",
"from django.views.static import serve\n",
"from authorization.permissions import ACCESS\n",
"from course.models import CourseModule\n",
"from course.viewbase import CourseInstanceBaseView, EnrollableViewMixin\n",
"from lib.remote_page import RemotePageNotFound, request_for_response\n",
"from lib.viewbase import BaseRedirectMixin, BaseView\n",
"from .models import LearningObject, LearningObjectDisplay\n",
"from .protocol.exercise_page import ExercisePage\n",
"from .submission_models import SubmittedFile, Submission\n",
"from .viewbase import ExerciseBaseView, SubmissionBaseView, SubmissionMixin, ExerciseModelBaseView, ExerciseTemplateBaseView\n",
"from .exercisecollection_models import ExerciseCollection\n",
"from .exercise_summary import UserExerciseSummary\n",
"from django.urls import reverse\n",
"VAR_0 = 'exercise/toc.html'\n",
"VAR_0 = 'exercise/results.html'\n",
"VAR_1 = 'exercise/_exercise_info.html'\n",
"def FUNC_0(self):...\n",
"super().get_common_objects()\n",
"self.get_summary_submissions()\n",
"VAR_0 = 'exercise/exercise.html'\n",
"VAR_1 = 'exercise/exercise_plain.html'\n",
"VAR_2 = 'exercise'\n",
"VAR_3 = ACCESS.STUDENT\n",
"@method_decorator(csrf_exempt)...\n",
"return super().dispatch(VAR_4, *VAR_5, **kwargs)\n"
] | [
"from django.conf import settings\n",
"from django.contrib import messages\n",
"from django.core.exceptions import MultipleObjectsReturned, PermissionDenied\n",
"from django.http.response import Http404, HttpResponse\n",
"from django.shortcuts import get_object_or_404\n",
"from django.utils.decorators import method_decorator\n",
"from django.utils.translation import ugettext_lazy as _\n",
"from django.views.decorators.clickjacking import xframe_options_exempt\n",
"from django.views.decorators.csrf import csrf_exempt\n",
"from django.views.static import serve\n",
"from authorization.permissions import ACCESS\n",
"from course.models import CourseModule\n",
"from course.viewbase import CourseInstanceBaseView, EnrollableViewMixin\n",
"from lib.remote_page import RemotePageNotFound, request_for_response\n",
"from lib.viewbase import BaseRedirectMixin, BaseView\n",
"from .models import LearningObject, LearningObjectDisplay\n",
"from .protocol.exercise_page import ExercisePage\n",
"from .submission_models import SubmittedFile, Submission\n",
"from .viewbase import ExerciseBaseView, SubmissionBaseView, SubmissionMixin, ExerciseModelBaseView, ExerciseTemplateBaseView\n",
"from .exercisecollection_models import ExerciseCollection\n",
"from .exercise_summary import UserExerciseSummary\n",
"from django.urls import reverse\n",
"template_name = 'exercise/toc.html'\n",
"template_name = 'exercise/results.html'\n",
"ajax_template_name = 'exercise/_exercise_info.html'\n",
"def get_common_objects(self):...\n",
"super().get_common_objects()\n",
"self.get_summary_submissions()\n",
"template_name = 'exercise/exercise.html'\n",
"ajax_template_name = 'exercise/exercise_plain.html'\n",
"post_url_name = 'exercise'\n",
"access_mode = ACCESS.STUDENT\n",
"@method_decorator(csrf_exempt)...\n",
"return super().dispatch(request, *args, **kwargs)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"self.clear_cookie('user')\n"
] | [
"def delete_session_cookie(self):...\n",
"self.clear_cookie('user')\n"
] | [
0,
0
] | [
"FunctionDef'",
"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_5(self):...\n",
"VAR_15 = []\n",
"for VAR_6 in self.actors.keys():\n",
"VAR_15 = VAR_15 + self.actors[VAR_6].draw()\n",
"return VAR_15\n"
] | [
"def draw(self):...\n",
"drawings = []\n",
"for ID in self.actors.keys():\n",
"drawings = drawings + self.actors[ID].draw()\n",
"return drawings\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Assign'",
"Return'"
] |
[
"from __future__ import absolute_import, division\n",
"from abc import abstractmethod\n",
"from PyQt5.QtCore import QAbstractTableModel, QModelIndex, Qt, pyqtSignal\n",
"from TriblerGUI.defs import ACTION_BUTTONS\n",
"from TriblerGUI.utilities import format_size, pretty_date\n",
"\"\"\"string\"\"\"\n",
"VAR_0 = pyqtSignal(str, bool)\n",
"def __init__(self, VAR_1=None):...\n",
"super(CLASS_0, self).__init__(VAR_1)\n",
"self.data_items = []\n",
"self.item_load_batch = 50\n",
"self.total_items = 0\n",
"self.infohashes = {}\n",
"@abstractmethod...\n",
"@abstractmethod...\n",
"def FUNC_2(self):...\n",
"self.beginResetModel()\n",
"self.data_items = []\n",
"self.endResetModel()\n",
"def FUNC_3(self, VAR_5, VAR_6):...\n",
"self.reset()\n",
"self.on_sort.emit(self.columns[VAR_5], bool(VAR_6))\n",
"def FUNC_4(self, VAR_7):...\n",
"if not VAR_7:\n",
"return\n",
"VAR_21 = self.rowCount()\n",
"VAR_22 = self.rowCount() + len(VAR_7)\n",
"self.beginInsertRows(QModelIndex(), VAR_21, VAR_22 - 1)\n",
"self.data_items.extend(VAR_7)\n",
"self.endInsertRows()\n",
"VAR_8 = []\n",
"VAR_9 = {}\n",
"VAR_10 = {}\n",
"VAR_11 = {}\n",
"def __init__(self, VAR_12=False):...\n",
"CLASS_0.__init__(self, VAR_1=None)\n",
"self.data_items = []\n",
"self.column_position = {name: i for i, name in enumerate(self.columns)}\n",
"self.edit_enabled = False\n",
"self.hide_xxx = VAR_12\n",
"def FUNC_5(self, VAR_13, VAR_14, VAR_15=None):...\n",
"if VAR_14 == Qt.Horizontal and VAR_15 == Qt.DisplayRole:\n",
"return self.column_headers[VAR_13]\n",
"def FUNC_0(self, VAR_2, VAR_3, **VAR_4):...\n",
"def FUNC_1(self):...\n",
"def FUNC_6(self, VAR_1=QModelIndex()):...\n",
"return len(self.data_items)\n"
] | [
"from __future__ import absolute_import, division\n",
"from abc import abstractmethod\n",
"from PyQt5.QtCore import QAbstractTableModel, QModelIndex, Qt, pyqtSignal\n",
"from TriblerGUI.defs import ACTION_BUTTONS\n",
"from TriblerGUI.utilities import format_size, pretty_date\n",
"\"\"\"\n The base model for the tables in the Tribler GUI.\n It is specifically designed to fetch data from a remote data source, i.e. over a RESTful API.\n \"\"\"\n",
"on_sort = pyqtSignal(str, bool)\n",
"def __init__(self, parent=None):...\n",
"super(RemoteTableModel, self).__init__(parent)\n",
"self.data_items = []\n",
"self.item_load_batch = 50\n",
"self.total_items = 0\n",
"self.infohashes = {}\n",
"@abstractmethod...\n",
"@abstractmethod...\n",
"def reset(self):...\n",
"self.beginResetModel()\n",
"self.data_items = []\n",
"self.endResetModel()\n",
"def sort(self, column, order):...\n",
"self.reset()\n",
"self.on_sort.emit(self.columns[column], bool(order))\n",
"def add_items(self, new_data_items):...\n",
"if not new_data_items:\n",
"return\n",
"old_end = self.rowCount()\n",
"new_end = self.rowCount() + len(new_data_items)\n",
"self.beginInsertRows(QModelIndex(), old_end, new_end - 1)\n",
"self.data_items.extend(new_data_items)\n",
"self.endInsertRows()\n",
"column_headers = []\n",
"column_width = {}\n",
"column_flags = {}\n",
"column_display_filters = {}\n",
"def __init__(self, hide_xxx=False):...\n",
"RemoteTableModel.__init__(self, parent=None)\n",
"self.data_items = []\n",
"self.column_position = {name: i for i, name in enumerate(self.columns)}\n",
"self.edit_enabled = False\n",
"self.hide_xxx = hide_xxx\n",
"def headerData(self, num, orientation, role=None):...\n",
"if orientation == Qt.Horizontal and role == Qt.DisplayRole:\n",
"return self.column_headers[num]\n",
"def _get_remote_data(self, start, end, **kwargs):...\n",
"def _set_remote_data(self):...\n",
"def rowCount(self, parent=QModelIndex()):...\n",
"return len(self.data_items)\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
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Expr'",
"Assign'",
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"FunctionDef'",
"Expr'",
"Assign'",
"Expr'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Condition",
"Return'",
"FunctionDef'",
"FunctionDef'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_0(VAR_1: ISpy, VAR_2: str) ->str:...\n",
"return f\"SELECT {', '.join(FUNC_1(VAR_1))} FROM {VAR_2}\"\n"
] | [
"def construct_select_statement(spy: ISpy, from_: str) ->str:...\n",
"return f\"SELECT {', '.join(construct_selects(spy))} FROM {from_}\"\n"
] | [
0,
4
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_1(self, VAR_6, VAR_7):...\n",
"VAR_1 = None\n",
"VAR_9 = []\n",
"VAR_10 = []\n",
"VAR_11 = []\n",
"if len(VAR_7) == 0:\n",
"VAR_1 = 'global'\n",
"if len(VAR_7) == 1:\n",
"if not VAR_1:\n",
"VAR_9 = self.getOSNames(VAR_7)\n",
"VAR_9 = []\n",
"VAR_10 = self.getApplianceNames(VAR_7)\n",
"VAR_10 = []\n",
"VAR_11 = self.getHostnames(VAR_7)\n",
"VAR_11 = []\n",
"if VAR_7[0] in VAR_9:\n",
"if not VAR_1:\n",
"VAR_1 = 'os'\n",
"if VAR_7[0] in VAR_10:\n",
"if VAR_1 == 'global':\n",
"VAR_1 = 'appliance'\n",
"if VAR_7[0] in VAR_11:\n",
"VAR_0 = 'global'\n",
"VAR_0 = VAR_7[0]\n",
"VAR_1 = 'host'\n",
"VAR_3, VAR_4, VAR_5, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16 = self.fillParams([\n ('adapter', None), ('enclosure', None), ('slot', None), ('hotspare',\n None), ('raidlevel', None), ('arrayid', None, True), ('options', ''), (\n 'force', 'n')])\n",
"if not VAR_12 and not VAR_5:\n",
"if VAR_14 != 'global' and not VAR_13:\n",
"if VAR_3:\n",
"VAR_3 = -1\n",
"VAR_3 = int(VAR_3)\n",
"if VAR_3 < 0:\n",
"if VAR_4:\n",
"VAR_4 = -1\n",
"VAR_4 = int(VAR_4)\n",
"if VAR_4 < 0:\n",
"VAR_17 = []\n",
"if VAR_5:\n",
"for VAR_21 in VAR_5.split(','):\n",
"VAR_18 = []\n",
"if VAR_21 == '*':\n",
"if VAR_12:\n",
"VAR_21 = -1\n",
"VAR_21 = int(VAR_21)\n",
"if VAR_21 < 0:\n",
"for VAR_22 in VAR_12.split(','):\n",
"if VAR_14 in ['global', '*']:\n",
"VAR_17.append(VAR_21)\n",
"if VAR_21 in VAR_17:\n",
"VAR_22 = int(VAR_22)\n",
"if VAR_22 < 0:\n",
"if VAR_14 == 'global' and len(VAR_18) == 0:\n",
"VAR_14 = int(VAR_14)\n",
"if VAR_14 < 1:\n",
"if VAR_22 in VAR_18:\n",
"VAR_2 = None\n",
"VAR_18.append(VAR_22)\n",
"if VAR_1 == 'global':\n",
"VAR_2 = -1\n",
"if VAR_1 == 'appliance':\n",
"VAR_16 = self.str2bool(VAR_16)\n",
"self.db.execute(\"\"\"select id from appliances where\n\t\t\t\tname = '%s' \"\"\" % VAR_0)\n",
"if VAR_1 == 'host':\n",
"for VAR_5 in VAR_17:\n",
"VAR_2, = self.db.fetchone()\n",
"self.db.execute(\"\"\"select id from nodes where\n\t\t\t\tname = '%s' \"\"\" % VAR_0)\n",
"if not VAR_16:\n",
"for VAR_12 in VAR_18:\n",
"VAR_2, = self.db.fetchone()\n",
"self.checkIt(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5)\n",
"if not VAR_16:\n",
"if VAR_14 == 'global':\n",
"self.checkIt(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_12)\n",
"VAR_14 = -1\n",
"if VAR_14 == '*':\n",
"for VAR_5 in VAR_17:\n",
"VAR_14 = -2\n",
"self.db.execute('string' % (VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_13,\n VAR_14, VAR_15))\n",
"for VAR_12 in VAR_18:\n",
"VAR_13 = -1\n",
"if VAR_14 == 'global':\n",
"VAR_14 = -1\n",
"self.db.execute('string' % (VAR_1, VAR_2, VAR_3, VAR_4, VAR_12, VAR_13,\n VAR_14, VAR_15))\n"
] | [
"def run(self, params, args):...\n",
"scope = None\n",
"oses = []\n",
"appliances = []\n",
"hosts = []\n",
"if len(args) == 0:\n",
"scope = 'global'\n",
"if len(args) == 1:\n",
"if not scope:\n",
"oses = self.getOSNames(args)\n",
"oses = []\n",
"appliances = self.getApplianceNames(args)\n",
"appliances = []\n",
"hosts = self.getHostnames(args)\n",
"hosts = []\n",
"if args[0] in oses:\n",
"if not scope:\n",
"scope = 'os'\n",
"if args[0] in appliances:\n",
"if scope == 'global':\n",
"scope = 'appliance'\n",
"if args[0] in hosts:\n",
"name = 'global'\n",
"name = args[0]\n",
"scope = 'host'\n",
"adapter, enclosure, slot, hotspare, raidlevel, arrayid, options, force = (self\n .fillParams([('adapter', None), ('enclosure', None), ('slot', None), (\n 'hotspare', None), ('raidlevel', None), ('arrayid', None, True), (\n 'options', ''), ('force', 'n')]))\n",
"if not hotspare and not slot:\n",
"if arrayid != 'global' and not raidlevel:\n",
"if adapter:\n",
"adapter = -1\n",
"adapter = int(adapter)\n",
"if adapter < 0:\n",
"if enclosure:\n",
"enclosure = -1\n",
"enclosure = int(enclosure)\n",
"if enclosure < 0:\n",
"slots = []\n",
"if slot:\n",
"for s in slot.split(','):\n",
"hotspares = []\n",
"if s == '*':\n",
"if hotspare:\n",
"s = -1\n",
"s = int(s)\n",
"if s < 0:\n",
"for h in hotspare.split(','):\n",
"if arrayid in ['global', '*']:\n",
"slots.append(s)\n",
"if s in slots:\n",
"h = int(h)\n",
"if h < 0:\n",
"if arrayid == 'global' and len(hotspares) == 0:\n",
"arrayid = int(arrayid)\n",
"if arrayid < 1:\n",
"if h in hotspares:\n",
"tableid = None\n",
"hotspares.append(h)\n",
"if scope == 'global':\n",
"tableid = -1\n",
"if scope == 'appliance':\n",
"force = self.str2bool(force)\n",
"self.db.execute(\"\"\"select id from appliances where\n\t\t\t\tname = '%s' \"\"\" % name)\n",
"if scope == 'host':\n",
"for slot in slots:\n",
"tableid, = self.db.fetchone()\n",
"self.db.execute(\"\"\"select id from nodes where\n\t\t\t\tname = '%s' \"\"\" % name)\n",
"if not force:\n",
"for hotspare in hotspares:\n",
"tableid, = self.db.fetchone()\n",
"self.checkIt(name, scope, tableid, adapter, enclosure, slot)\n",
"if not force:\n",
"if arrayid == 'global':\n",
"self.checkIt(name, scope, tableid, adapter, enclosure, hotspare)\n",
"arrayid = -1\n",
"if arrayid == '*':\n",
"for slot in slots:\n",
"arrayid = -2\n",
"self.db.execute(\n \"\"\"insert into storage_controller\n\t\t\t\t(scope, tableid, adapter, enclosure, slot,\n\t\t\t\traidlevel, arrayid, options) values ('%s', %s, %s, %s,\n\t\t\t\t%s, %s, %s, '%s') \"\"\"\n % (scope, tableid, adapter, enclosure, slot, raidlevel, arrayid, options))\n",
"for hotspare in hotspares:\n",
"raidlevel = -1\n",
"if arrayid == 'global':\n",
"arrayid = -1\n",
"self.db.execute(\n \"\"\"insert into storage_controller\n\t\t\t\t(scope, tableid, adapter, enclosure, slot,\n\t\t\t\traidlevel, arrayid, options) values ('%s', %s, %s, %s,\n\t\t\t\t%s, %s, %s, '%s') \"\"\"\n % (scope, tableid, adapter, enclosure, hotspare, raidlevel, arrayid,\n options))\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,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"For",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"For",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"For",
"Assign'",
"Expr'",
"Condition",
"For",
"Assign'",
"Expr'",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Condition",
"For",
"Assign'",
"Expr'",
"For",
"Assign'",
"Condition",
"Assign'",
"Expr'"
] |
[
"def FUNC_8(self, VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_10 = []\n",
"for VAR_5 in self.tid_num_to_tag_nums(self.tid_to_tid_num(VAR_3)):\n",
"VAR_10.append(self.tag_num_to_tag(VAR_5))\n",
"return VAR_10\n"
] | [
"def get_tags(self, tid):...\n",
"\"\"\"docstring\"\"\"\n",
"tags = []\n",
"for tag_num in self.tid_num_to_tag_nums(self.tid_to_tid_num(tid)):\n",
"tags.append(self.tag_num_to_tag(tag_num))\n",
"return tags\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"For",
"Expr'",
"Return'"
] |
[
"def FUNC_0(self, VAR_6):...\n",
"if not self.logined:\n",
"self._capdata = 0, 0\n",
"self.log.warning('Caprate limit reached, calling dologin() for now')\n",
"return\n",
"self.dologin()\n"
] | [
"def on_caprate_limit(self, rate):...\n",
"if not self.logined:\n",
"self._capdata = 0, 0\n",
"self.log.warning('Caprate limit reached, calling dologin() for now')\n",
"return\n",
"self.dologin()\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Expr'",
"Return'",
"Expr'"
] |
[
"def FUNC_31(VAR_1, VAR_16):...\n",
"VAR_30 = VAR_1.xsrf_token_data == {'some': 'data'}\n",
"VAR_12.append((VAR_16, VAR_30))\n"
] | [
"def record(request_handler, method):...\n",
"is_valid = request_handler.xsrf_token_data == {'some': 'data'}\n",
"calls.append((method, is_valid))\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_4(self, VAR_9, VAR_10):...\n",
"\"\"\"docstring\"\"\"\n"
] | [
"def remove_export(self, context, volume):...\n",
"\"\"\"docstring\"\"\"\n"
] | [
0,
0
] | [
"FunctionDef'",
"Docstring"
] |
[
"def FUNC_5(self, VAR_7, VAR_9):...\n",
"\"\"\"docstring\"\"\"\n",
"return self.tool_classpath_from_products(VAR_9, self._key_for_tool_version(\n VAR_7, self.version), scope=self.options_scope)\n"
] | [
"def _tool_classpath(self, tool, products):...\n",
"\"\"\"docstring\"\"\"\n",
"return self.tool_classpath_from_products(products, self.\n _key_for_tool_version(tool, self.version), scope=self.options_scope)\n"
] | [
0,
0,
7
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_7(self):...\n",
"self.driver._eql_execute = self.mox.CreateMock(self.driver._eql_execute)\n",
"VAR_3 = {'name': 'fakesnap', 'volume_name': 'fakevolume_name'}\n",
"VAR_1 = {'name': self.volume_name}\n",
"self.driver._eql_execute('volume', 'select', VAR_3['volume_name'],\n 'snapshot', 'select', VAR_3['name'], 'clone', VAR_1['name']).AndReturn([\n 'iSCSI target name is %s.' % self.fake_iqn])\n",
"self.mox.ReplayAll()\n",
"VAR_2 = self.driver.create_volume_from_snapshot(VAR_1, VAR_3)\n",
"self.assertEqual(VAR_2, self._model_update)\n"
] | [
"def test_create_volume_from_snapshot(self):...\n",
"self.driver._eql_execute = self.mox.CreateMock(self.driver._eql_execute)\n",
"snapshot = {'name': 'fakesnap', 'volume_name': 'fakevolume_name'}\n",
"volume = {'name': self.volume_name}\n",
"self.driver._eql_execute('volume', 'select', snapshot['volume_name'],\n 'snapshot', 'select', snapshot['name'], 'clone', volume['name']).AndReturn(\n ['iSCSI target name is %s.' % self.fake_iqn])\n",
"self.mox.ReplayAll()\n",
"model_update = self.driver.create_volume_from_snapshot(volume, snapshot)\n",
"self.assertEqual(model_update, self._model_update)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def __init__(self, VAR_22):...\n",
"VAR_71, VAR_72, VAR_73 = VAR_22.year, VAR_22.month, VAR_22.day\n",
"self.yold = VAR_71 + 1166\n",
"self.hour = VAR_22.hour\n",
"self.minute = VAR_22.minute\n",
"self.second = VAR_22.second\n",
"if (VAR_72, VAR_73) == (2, 29):\n",
"self.weekdayname = self.ST_TIBS_DAY\n",
"VAR_102 = int(VAR_22.strftime('%j'))\n",
"if calendar.isleap(VAR_71):\n",
"if VAR_102 > 60:\n",
"VAR_29 = int((VAR_102 - 1) / 73)\n",
"VAR_102 -= 1\n",
"self.season = VAR_29 + 1\n",
"self.seasonname = self.SEASONS[VAR_29]\n",
"self.day = (VAR_102 - 1) % 73 + 1\n",
"self.weekday = (VAR_102 - 1) % 5 + 1\n",
"if self.day == 5 or self.day == 50:\n",
"VAR_107 = 1 if self.day == 50 else 0\n",
"self.weekdayname = self.WEEKDAYS[self.weekday - 1]\n",
"VAR_108 = VAR_29 * 2 + VAR_107\n",
"self.weekdayname = self.HOLIDAYS[VAR_108]\n"
] | [
"def __init__(self, dt):...\n",
"y, m, d = dt.year, dt.month, dt.day\n",
"self.yold = y + 1166\n",
"self.hour = dt.hour\n",
"self.minute = dt.minute\n",
"self.second = dt.second\n",
"if (m, d) == (2, 29):\n",
"self.weekdayname = self.ST_TIBS_DAY\n",
"day_of_year = int(dt.strftime('%j'))\n",
"if calendar.isleap(y):\n",
"if day_of_year > 60:\n",
"season = int((day_of_year - 1) / 73)\n",
"day_of_year -= 1\n",
"self.season = season + 1\n",
"self.seasonname = self.SEASONS[season]\n",
"self.day = (day_of_year - 1) % 73 + 1\n",
"self.weekday = (day_of_year - 1) % 5 + 1\n",
"if self.day == 5 or self.day == 50:\n",
"offs = 1 if self.day == 50 else 0\n",
"self.weekdayname = self.WEEKDAYS[self.weekday - 1]\n",
"holidayidx = season * 2 + offs\n",
"self.weekdayname = self.HOLIDAYS[holidayidx]\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"AugAssign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_5(self, VAR_2):...\n",
""
] | [
"def cut(self, key):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_0():...\n",
"VAR_1 = Context().list_devices(ID_VENDOR_ID='0403', ID_MODEL_ID='6014')\n",
"VAR_2 = []\n",
"for debugger in VAR_1:\n",
"if 'DEVLINKS' not in debugger:\n",
"return VAR_2\n",
"VAR_2.append(debugger['ID_SERIAL_SHORT'])\n"
] | [
"def find_ftdi_serials():...\n",
"debuggers = Context().list_devices(ID_VENDOR_ID='0403', ID_MODEL_ID='6014')\n",
"serials = []\n",
"for debugger in debuggers:\n",
"if 'DEVLINKS' not in debugger:\n",
"return serials\n",
"serials.append(debugger['ID_SERIAL_SHORT'])\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"For",
"Condition",
"Return'",
"Expr'"
] |
[
"def FUNC_11(self):...\n",
"VAR_4 = 'hubba-bubba'\n",
"def FUNC_29():...\n",
"VAR_4 = 'hubba-bubba'\n",
"self.assertEquals(VAR_32['eduPersonPrincipalName'], VAR_4)\n",
"self.acs('/login', VAR_4, FUNC_29)\n"
] | [
"def test_login_assertion_consumer_service(self):...\n",
"eppn = 'hubba-bubba'\n",
"def _check():...\n",
"eppn = 'hubba-bubba'\n",
"self.assertEquals(session['eduPersonPrincipalName'], eppn)\n",
"self.acs('/login', eppn, _check)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"import mimetypes\n",
"import os\n",
"from django.contrib.gis.db.models import GeometryField\n",
"from django.contrib.gis.db.models.functions import Envelope\n",
"from django.core.exceptions import ObjectDoesNotExist\n",
"from django.db.models.functions import Cast\n",
"from django.http import HttpResponse\n",
"from wsgiref.util import FileWrapper\n",
"from rest_framework import status, serializers, viewsets, filters, exceptions, permissions, parsers\n",
"from rest_framework.response import Response\n",
"from rest_framework.decorators import detail_route\n",
"from rest_framework.views import APIView\n",
"from .common import get_and_check_project, get_tile_json\n",
"from app import models, scheduler, pending_actions\n",
"from nodeodm.models import ProcessingNode\n",
"def FUNC_0(self, VAR_0):...\n",
"return VAR_0.id\n"
] | [
"import mimetypes\n",
"import os\n",
"from django.contrib.gis.db.models import GeometryField\n",
"from django.contrib.gis.db.models.functions import Envelope\n",
"from django.core.exceptions import ObjectDoesNotExist\n",
"from django.db.models.functions import Cast\n",
"from django.http import HttpResponse\n",
"from wsgiref.util import FileWrapper\n",
"from rest_framework import status, serializers, viewsets, filters, exceptions, permissions, parsers\n",
"from rest_framework.response import Response\n",
"from rest_framework.decorators import detail_route\n",
"from rest_framework.views import APIView\n",
"from .common import get_and_check_project, get_tile_json\n",
"from app import models, scheduler, pending_actions\n",
"from nodeodm.models import ProcessingNode\n",
"def to_representation(self, obj):...\n",
"return obj.id\n"
] | [
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Return'"
] |
[
"@classmethod...\n",
"super(CLASS_0, VAR_6).register_options(VAR_8)\n"
] | [
"@classmethod...\n",
"super(JavacCompile, cls).register_options(register)\n"
] | [
0,
0
] | [
"Condition",
"Expr'"
] |
[
"def FUNC_1(self, VAR_2, VAR_3, VAR_4, *VAR_5):...\n",
"self.write_data({'type': 'upgrader_started'})\n"
] | [
"def on_upgrader_started(self, subject, changetype, objectID, *args):...\n",
"self.write_data({'type': 'upgrader_started'})\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@VAR_2.route('/data/slaves/')...\n",
"VAR_24, VAR_23 = FUNC_4(request.args)\n",
"VAR_30 = (VAR_23 - VAR_24).days\n",
"if VAR_30 <= 8:\n",
"VAR_66 = 5\n",
"VAR_66 = int(round(VAR_30 * 0.4))\n",
"VAR_31 = 'Only slaves with more than %d jobs are displayed.' % VAR_66\n",
"VAR_28 = FUNC_0()\n",
"VAR_32 = VAR_28.cursor()\n",
"VAR_32.execute('string'.format(VAR_24, VAR_23))\n",
"VAR_33 = VAR_32.fetchall()\n",
"VAR_32.close()\n",
"VAR_28.close()\n",
"if not VAR_33:\n",
"return\n",
"VAR_14 = {}\n",
"VAR_34 = 'fail retry infra success total'.split()\n",
"VAR_35 = {VAR_26: (0) for VAR_26 in VAR_34}\n",
"VAR_35['jobs_since_last_success'] = 0\n",
"VAR_6 = []\n",
"for VAR_87, VAR_26, VAR_52 in VAR_33:\n",
"VAR_14.setdefault(VAR_87, VAR_35.copy())\n",
"VAR_36 = [VAR_67 for VAR_67 in VAR_14 if VAR_14[VAR_67]['total'] > VAR_66]\n",
"VAR_14[VAR_87]['jobs_since_last_success'] += 1\n",
"for VAR_67 in VAR_36:\n",
"if VAR_26 == 'testfailed':\n",
"VAR_64 = VAR_14[VAR_67]\n",
"VAR_27 = {}\n",
"VAR_14[VAR_87]['fail'] += 1\n",
"if VAR_26 == 'retry':\n",
"VAR_49 = FUNC_6(VAR_64['success'], VAR_64['retry'], VAR_64['total'])\n",
"VAR_37 = sorted(VAR_14.keys())\n",
"VAR_14[VAR_87]['total'] += 1\n",
"VAR_14[VAR_87]['retry'] += 1\n",
"if VAR_26 == 'success':\n",
"VAR_14[VAR_67]['sfr'] = VAR_49\n",
"for VAR_38, slave_group in groupby(VAR_37, lambda x: x.rsplit('-', 1)[0]):\n",
"VAR_6.append(VAR_52)\n",
"VAR_14[VAR_87]['success'] += 1\n",
"if VAR_26 == 'busted' or VAR_26 == 'exception':\n",
"VAR_37 = list(slave_group)\n",
"for VAR_67 in VAR_14.keys():\n",
"VAR_14[VAR_87]['jobs_since_last_success'] = 0\n",
"VAR_14[VAR_87]['infra'] += 1\n",
"if not any(VAR_67 in VAR_37 for VAR_67 in VAR_36):\n",
"if VAR_67 not in VAR_36:\n",
"return {'slaves': VAR_14, 'platforms': VAR_27, 'dates': FUNC_3(VAR_6),\n 'disclaimer': VAR_31}\n",
"VAR_27[VAR_38] = {}\n",
"VAR_64 = {}\n",
"for VAR_83 in ['success', 'retry', 'total']:\n",
"VAR_82 = reduce(lambda x, y: x + y, [VAR_14[VAR_67][VAR_83] for VAR_67 in\n VAR_37])\n",
"VAR_49 = FUNC_6(VAR_64['success'], VAR_64['retry'], VAR_64['total'])\n",
"VAR_64[VAR_83] = VAR_82\n",
"VAR_27[VAR_38].update(VAR_49)\n"
] | [
"@app.route('/data/slaves/')...\n",
"start_date, end_date = clean_date_params(request.args)\n",
"days_to_show = (end_date - start_date).days\n",
"if days_to_show <= 8:\n",
"jobs = 5\n",
"jobs = int(round(days_to_show * 0.4))\n",
"info = 'Only slaves with more than %d jobs are displayed.' % jobs\n",
"db = create_db_connnection()\n",
"cursor = db.cursor()\n",
"cursor.execute(\n \"\"\"select slave, result, date from testjobs\n where result in\n (\"retry\", \"testfailed\", \"success\", \"busted\", \"exception\")\n and date between \"{0}\" and \"{1}\"\n order by date;\"\"\"\n .format(start_date, end_date))\n",
"query_results = cursor.fetchall()\n",
"cursor.close()\n",
"db.close()\n",
"if not query_results:\n",
"return\n",
"data = {}\n",
"labels = 'fail retry infra success total'.split()\n",
"summary = {result: (0) for result in labels}\n",
"summary['jobs_since_last_success'] = 0\n",
"dates = []\n",
"for name, result, date in query_results:\n",
"data.setdefault(name, summary.copy())\n",
"slave_list = [slave for slave in data if data[slave]['total'] > jobs]\n",
"data[name]['jobs_since_last_success'] += 1\n",
"for slave in slave_list:\n",
"if result == 'testfailed':\n",
"results = data[slave]\n",
"platforms = {}\n",
"data[name]['fail'] += 1\n",
"if result == 'retry':\n",
"fail_rates = calculate_fail_rate(results['success'], results['retry'],\n results['total'])\n",
"slaves = sorted(data.keys())\n",
"data[name]['total'] += 1\n",
"data[name]['retry'] += 1\n",
"if result == 'success':\n",
"data[slave]['sfr'] = fail_rates\n",
"for platform, slave_group in groupby(slaves, lambda x: x.rsplit('-', 1)[0]):\n",
"dates.append(date)\n",
"data[name]['success'] += 1\n",
"if result == 'busted' or result == 'exception':\n",
"slaves = list(slave_group)\n",
"for slave in data.keys():\n",
"data[name]['jobs_since_last_success'] = 0\n",
"data[name]['infra'] += 1\n",
"if not any(slave in slaves for slave in slave_list):\n",
"if slave not in slave_list:\n",
"return {'slaves': data, 'platforms': platforms, 'dates': get_date_range(\n dates), 'disclaimer': info}\n",
"platforms[platform] = {}\n",
"results = {}\n",
"for label in ['success', 'retry', 'total']:\n",
"r = reduce(lambda x, y: x + y, [data[slave][label] for slave in slaves])\n",
"fail_rates = calculate_fail_rate(results['success'], results['retry'],\n results['total'])\n",
"results[label] = r\n",
"platforms[platform].update(fail_rates)\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
] | [
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Expr'",
"Assign'",
"AugAssign'",
"For",
"Condition",
"Assign'",
"Assign'",
"AugAssign'",
"Condition",
"Assign'",
"Assign'",
"AugAssign'",
"AugAssign'",
"Condition",
"Assign'",
"For",
"Expr'",
"AugAssign'",
"Condition",
"Assign'",
"For",
"Assign'",
"AugAssign'",
"For",
"Condition",
"Return'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_6(VAR_1, VAR_5=''):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_18 = VAR_17(VAR_1.name)\n",
"return VAR_16.pop(VAR_18, None)\n"
] | [
"def token_delete(remote, token=''):...\n",
"\"\"\"docstring\"\"\"\n",
"session_key = token_session_key(remote.name)\n",
"return session.pop(session_key, None)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Return'"
] |
[
"@session_manager...\n",
"\"\"\"docstring\"\"\"\n",
"from invenio.modules.accounts.models import User, UserEXT\n",
"from invenio.ext.sqlalchemy import db\n",
"from ..handlers import token_session_key\n",
"from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound\n",
"import json\n",
"import requests\n",
"VAR_6 = session.get(token_session_key(VAR_2.name) + '_account_info').get(\n 'external_id')\n",
"VAR_7 = {'orcid': VAR_6}\n",
"VAR_4.remote_account.extra_data = VAR_7\n",
"VAR_8 = User.query.join(UserEXT).filter_by(id=orcid, method='orcid').one()\n",
"current_app.logger.exception('No user entry in userEXT.')\n",
"if VAR_8 and not any([VAR_8.given_names, VAR_8.family_name]):\n",
"VAR_9 = 'http://orcid.org/{0}/orcid-bio'.format(VAR_6)\n",
"VAR_10 = {'Accept': 'application/orcid+json'}\n",
"VAR_11 = requests.get(VAR_9, VAR_10=headers)\n",
"VAR_12 = VAR_11.status_code\n",
"if VAR_12 == requests.codes.ok:\n",
"VAR_13 = json.loads(VAR_11.content)\n",
"current_app.logger.exception('Not valid JSON response from ' +\n 'ORCID:\\n {0}'.format(repr(VAR_13)))\n",
"VAR_14 = VAR_13['orcid-profile']['orcid-bio']['personal-details']\n",
"current_app.logger.exception('Unexpected return format ' +\n 'from ORCID:\\n {0}'.format(repr(VAR_13)))\n",
"db.session.add(VAR_8)\n",
"return\n",
"VAR_8.given_names = VAR_14['given-names']['value']\n",
"return\n",
"current_user.reload()\n",
"VAR_8.family_name = VAR_14['family-name']['value']\n"
] | [
"@session_manager...\n",
"\"\"\"docstring\"\"\"\n",
"from invenio.modules.accounts.models import User, UserEXT\n",
"from invenio.ext.sqlalchemy import db\n",
"from ..handlers import token_session_key\n",
"from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound\n",
"import json\n",
"import requests\n",
"orcid = session.get(token_session_key(remote.name) + '_account_info').get(\n 'external_id')\n",
"extra_data = {'orcid': orcid}\n",
"token.remote_account.extra_data = extra_data\n",
"user = User.query.join(UserEXT).filter_by(id=orcid, method='orcid').one()\n",
"current_app.logger.exception('No user entry in userEXT.')\n",
"if user and not any([user.given_names, user.family_name]):\n",
"request_url = 'http://orcid.org/{0}/orcid-bio'.format(orcid)\n",
"headers = {'Accept': 'application/orcid+json'}\n",
"response = requests.get(request_url, headers=headers)\n",
"code = response.status_code\n",
"if code == requests.codes.ok:\n",
"orcid_bio = json.loads(response.content)\n",
"current_app.logger.exception('Not valid JSON response from ' +\n 'ORCID:\\n {0}'.format(repr(orcid_bio)))\n",
"name = orcid_bio['orcid-profile']['orcid-bio']['personal-details']\n",
"current_app.logger.exception('Unexpected return format ' +\n 'from ORCID:\\n {0}'.format(repr(orcid_bio)))\n",
"db.session.add(user)\n",
"return\n",
"user.given_names = name['given-names']['value']\n",
"return\n",
"current_user.reload()\n",
"user.family_name = name['family-name']['value']\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Import'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Return'",
"Assign'",
"Return'",
"Expr'",
"Assign'"
] |
[
"def __init__(self, VAR_3, VAR_4, VAR_5=None, VAR_6=None):...\n",
"self.rule = VAR_3\n",
"self.dag = VAR_4\n",
"self.targetfile = VAR_5\n",
"self.wildcards_dict = self.rule.get_wildcards(VAR_5)\n",
"self.wildcards = Wildcards(fromdict=self.wildcards_dict)\n",
"self._format_wildcards = self.wildcards if VAR_6 is None else Wildcards(\n fromdict=format_wildcards)\n",
"(self.input, self.output, self.params, self.log, self.benchmark, self.\n ruleio, self.dependencies) = VAR_3.expand_wildcards(self.wildcards_dict)\n",
"self.resources_dict = {name: min(self.rule.workflow.global_resources.get(\n name, res), res) for name, res in VAR_3.resources.items()}\n",
"self.threads = self.resources_dict['_cores']\n",
"self.resources = Resources(fromdict=self.resources_dict)\n",
"self._inputsize = None\n",
"self.dynamic_output, self.dynamic_input = set(), set()\n",
"self.temp_output, self.protected_output = set(), set()\n",
"self.touch_output = set()\n",
"self.subworkflow_input = dict()\n",
"for VAR_28 in self.output:\n",
"VAR_27 = self.ruleio[VAR_28]\n",
"for VAR_28 in self.input:\n",
"if VAR_27 in self.rule.dynamic_output:\n",
"VAR_27 = self.ruleio[VAR_28]\n",
"self._hash = self.rule.__hash__()\n",
"self.dynamic_output.add(VAR_28)\n",
"if VAR_27 in self.rule.temp_output:\n",
"if VAR_27 in self.rule.dynamic_input:\n",
"if True or not self.dynamic_output:\n",
"self.temp_output.add(VAR_28)\n",
"if VAR_27 in self.rule.protected_output:\n",
"self.dynamic_input.add(VAR_28)\n",
"if VAR_27 in self.rule.subworkflow_input:\n",
"for o in self.output:\n",
"self.protected_output.add(VAR_28)\n",
"if VAR_27 in self.rule.touch_output:\n",
"self.subworkflow_input[VAR_28] = self.rule.subworkflow_input[VAR_27]\n",
"self._hash ^= o.__hash__()\n",
"self.touch_output.add(VAR_28)\n"
] | [
"def __init__(self, rule, dag, targetfile=None, format_wildcards=None):...\n",
"self.rule = rule\n",
"self.dag = dag\n",
"self.targetfile = targetfile\n",
"self.wildcards_dict = self.rule.get_wildcards(targetfile)\n",
"self.wildcards = Wildcards(fromdict=self.wildcards_dict)\n",
"self._format_wildcards = (self.wildcards if format_wildcards is None else\n Wildcards(fromdict=format_wildcards))\n",
"(self.input, self.output, self.params, self.log, self.benchmark, self.\n ruleio, self.dependencies) = rule.expand_wildcards(self.wildcards_dict)\n",
"self.resources_dict = {name: min(self.rule.workflow.global_resources.get(\n name, res), res) for name, res in rule.resources.items()}\n",
"self.threads = self.resources_dict['_cores']\n",
"self.resources = Resources(fromdict=self.resources_dict)\n",
"self._inputsize = None\n",
"self.dynamic_output, self.dynamic_input = set(), set()\n",
"self.temp_output, self.protected_output = set(), set()\n",
"self.touch_output = set()\n",
"self.subworkflow_input = dict()\n",
"for f in self.output:\n",
"f_ = self.ruleio[f]\n",
"for f in self.input:\n",
"if f_ in self.rule.dynamic_output:\n",
"f_ = self.ruleio[f]\n",
"self._hash = self.rule.__hash__()\n",
"self.dynamic_output.add(f)\n",
"if f_ in self.rule.temp_output:\n",
"if f_ in self.rule.dynamic_input:\n",
"if True or not self.dynamic_output:\n",
"self.temp_output.add(f)\n",
"if f_ in self.rule.protected_output:\n",
"self.dynamic_input.add(f)\n",
"if f_ in self.rule.subworkflow_input:\n",
"for o in self.output:\n",
"self.protected_output.add(f)\n",
"if f_ in self.rule.touch_output:\n",
"self.subworkflow_input[f] = self.rule.subworkflow_input[f_]\n",
"self._hash ^= o.__hash__()\n",
"self.touch_output.add(f)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"For",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Condition",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"For",
"Expr'",
"Condition",
"Assign'",
"AugAssign'",
"Expr'"
] |
[
"def FUNC_2(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_4, VAR_5, VAR_4 = parse_magnetlink(\n 'magnet:?xt=urn:btih:apctqfwnowubxzoidazgaj2ba6fs6juc')\n",
"self.assertEqual(VAR_5, \"\\x03Å8\\x16Íu¨\\x1båÈ\\x182`'A\\x07\\x8b/&\\x82\")\n"
] | [
"def test_parse_magnetlink_lowercase(self):...\n",
"\"\"\"docstring\"\"\"\n",
"_, hashed, _ = parse_magnetlink(\n 'magnet:?xt=urn:btih:apctqfwnowubxzoidazgaj2ba6fs6juc')\n",
"self.assertEqual(hashed, \"\\x03Å8\\x16Íu¨\\x1båÈ\\x182`'A\\x07\\x8b/&\\x82\")\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_0():...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_8 = (\n b'\\n-----BEGIN PGP PUBLIC KEY BLOCK-----\\nVersion: GnuPG v1\\nComment: GPGTools - https://gpgtools.org\\n\\n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\\n=CLGF\\n-----END PGP PUBLIC KEY BLOCK-----\\n '\n .strip())\n",
"apt.trust_gpg_key(VAR_8)\n",
"apt.add_source('nodesource', 'https://deb.nodesource.com/node_10.x', 'main')\n",
"apt.install_packages(['nodejs'])\n"
] | [
"def ensure_node():...\n",
"\"\"\"docstring\"\"\"\n",
"key = (\n b'\\n-----BEGIN PGP PUBLIC KEY BLOCK-----\\nVersion: GnuPG v1\\nComment: GPGTools - https://gpgtools.org\\n\\n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\\n=CLGF\\n-----END PGP PUBLIC KEY BLOCK-----\\n '\n .strip())\n",
"apt.trust_gpg_key(key)\n",
"apt.add_source('nodesource', 'https://deb.nodesource.com/node_10.x', 'main')\n",
"apt.install_packages(['nodejs'])\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def __init__(self, *VAR_6, **VAR_7):...\n",
"super(CLASS_2, self).__init__(*VAR_6, **kwargs)\n",
"self.fields['script_selection'].widget.attrs.update({'style':\n 'height:2.75rem; !important'})\n",
"self.fields['clean_comp_data_file'].widget.attrs.update({'accept': '.csv'})\n",
"self.collapsed = True\n"
] | [
"def __init__(self, *args, **kwargs):...\n",
"super(CleanCompDataForm, self).__init__(*args, **kwargs)\n",
"self.fields['script_selection'].widget.attrs.update({'style':\n 'height:2.75rem; !important'})\n",
"self.fields['clean_comp_data_file'].widget.attrs.update({'accept': '.csv'})\n",
"self.collapsed = True\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Expr'",
"Assign'"
] |
[
"def FUNC_5(self):...\n",
"VAR_8 = 'test_foo.py:FooTest.test_bar'\n",
"VAR_7 = BokChoyTestSuite('', test_spec=spec)\n",
"VAR_1 = 'tests/{}'.format(VAR_8)\n",
"self.assertEqual(VAR_7.cmd, self._expected_command(VAR_1=name))\n"
] | [
"def test_testcase_spec(self):...\n",
"spec = 'test_foo.py:FooTest.test_bar'\n",
"suite = BokChoyTestSuite('', test_spec=spec)\n",
"name = 'tests/{}'.format(spec)\n",
"self.assertEqual(suite.cmd, self._expected_command(name=name))\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_2(VAR_1, VAR_2, VAR_3, VAR_4=False):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_16 = f'SELECT * FROM {VAR_2};'\n",
"if VAR_4:\n",
"print(VAR_16)\n",
"VAR_17 = VAR_1.cursor()\n",
"VAR_17.execute(VAR_16)\n",
"VAR_18 = list(next(zip(*VAR_17.description)))\n",
"for col in VAR_3:\n",
"if col not in VAR_18:\n",
"VAR_17.close()\n",
"VAR_17.close()\n",
"VAR_1.close()\n"
] | [
"def db_check(conn, table, columns, debug=False):...\n",
"\"\"\"docstring\"\"\"\n",
"sql = f'SELECT * FROM {table};'\n",
"if debug:\n",
"print(sql)\n",
"cursor = conn.cursor()\n",
"cursor.execute(sql)\n",
"db_columns = list(next(zip(*cursor.description)))\n",
"for col in columns:\n",
"if col not in db_columns:\n",
"cursor.close()\n",
"cursor.close()\n",
"conn.close()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"For",
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_22(VAR_14, VAR_15):...\n",
"VAR_37 = VAR_14.state['sleep_streak']\n",
"self.assertEqual(VAR_14.remote, self.server)\n",
"if VAR_37 == 5:\n",
"return False\n"
] | [
"def poll_server(botobj, _):...\n",
"sleep_streak = botobj.state['sleep_streak']\n",
"self.assertEqual(botobj.remote, self.server)\n",
"if sleep_streak == 5:\n",
"return False\n"
] | [
0,
0,
5,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Condition",
"Return'"
] |
[
"@utils.synchronized('3par', external=True)...\n",
""
] | [
"@utils.synchronized('3par', external=True)...\n",
""
] | [
0,
0
] | [
"Condition",
"Condition"
] |
[
"def FUNC_0(self, VAR_0='crimemap'):...\n",
"return pymysql.connect(host='localhost', user=dbconfig.db_user, passwd=\n dbconfig.db_password, db=database)\n"
] | [
"def connect(self, database='crimemap'):...\n",
"return pymysql.connect(host='localhost', user=dbconfig.db_user, passwd=\n dbconfig.db_password, db=database)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_15(self, VAR_33, VAR_34, VAR_35, VAR_36=nsx_client.JSONRESTClient....\n",
"VAR_55 = VAR_34._conn\n",
"if VAR_38:\n",
"VAR_38 = jsonutils.dumps(VAR_38, sort_keys=True)\n",
"VAR_55.assert_called_once(VAR_33, **{'url': url, 'verify': NSX_CERT, 'body':\n data, 'headers': headers, 'cert': None, 'timeout': timeout})\n"
] | [
"def assert_json_call(self, method, client, url, headers=nsx_client....\n",
"cluster = client._conn\n",
"if data:\n",
"data = jsonutils.dumps(data, sort_keys=True)\n",
"cluster.assert_called_once(method, **{'url': url, 'verify': NSX_CERT,\n 'body': data, 'headers': headers, 'cert': None, 'timeout': timeout})\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Assign'",
"Expr'"
] |
[
"@VAR_0.filter...\n",
"return News.AUDIENCE[VAR_6]\n"
] | [
"@register.filter...\n",
"return News.AUDIENCE[audience]\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_6(self, VAR_11):...\n",
"VAR_33 = CLASS_43.run(self, VAR_11)\n",
"if VAR_33 is None:\n",
"return ''\n",
"return VAR_33\n"
] | [
"def run(self, url):...\n",
"val = VSanitizedUrl.run(self, url)\n",
"if val is None:\n",
"return ''\n",
"return val\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_6(VAR_13):...\n",
"return os.path.isfile(VAR_13) and os.access(VAR_13, os.X_OK)\n"
] | [
"def is_executable(path):...\n",
"return os.path.isfile(path) and os.access(path, os.X_OK)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"\"\"\"docstring\"\"\"\n",
"while True:\n",
"self.update_log_filenames()\n",
"self.check_log_files_and_push_updates()\n",
"time.sleep(1)\n"
] | [
"def run(self):...\n",
"\"\"\"docstring\"\"\"\n",
"while True:\n",
"self.update_log_filenames()\n",
"self.check_log_files_and_push_updates()\n",
"time.sleep(1)\n"
] | [
0,
0,
6,
0,
6,
6
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_26(*VAR_29, **VAR_30):...\n",
""
] | [
"def raiseOSError(*_a, **_k):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def __init__(self, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5=False):...\n",
"self.campaign_data = VAR_1\n",
"self.result_data = VAR_2\n",
"self.options = VAR_3\n",
"self.aux = VAR_5\n",
"self.uboot_command = (self.options.dut_uboot if not self.aux else self.\n options.aux_uboot)\n",
"VAR_17 = VAR_3.dut_serial_port if not VAR_5 else VAR_3.aux_serial_port\n",
"VAR_18 = VAR_3.dut_baud_rate if not VAR_5 else VAR_3.aux_baud_rate\n",
"self.serial = Serial(port=None, baudrate=baud_rate, timeout=options.timeout,\n rtscts=True)\n",
"if self.campaign_data['use_simics']:\n",
"self.serial._dsrdtr = True\n",
"self.serial.port = VAR_17\n",
"self.serial.open()\n",
"self.serial.reset_input_buffer()\n",
"self.prompt = VAR_3.dut_prompt if not VAR_5 else VAR_3.aux_prompt\n",
"self.prompt += ' '\n",
"self.rsakey = VAR_4\n"
] | [
"def __init__(self, campaign_data, result_data, options, rsakey, aux=False):...\n",
"self.campaign_data = campaign_data\n",
"self.result_data = result_data\n",
"self.options = options\n",
"self.aux = aux\n",
"self.uboot_command = (self.options.dut_uboot if not self.aux else self.\n options.aux_uboot)\n",
"serial_port = options.dut_serial_port if not aux else options.aux_serial_port\n",
"baud_rate = options.dut_baud_rate if not aux else options.aux_baud_rate\n",
"self.serial = Serial(port=None, baudrate=baud_rate, timeout=options.timeout,\n rtscts=True)\n",
"if self.campaign_data['use_simics']:\n",
"self.serial._dsrdtr = True\n",
"self.serial.port = serial_port\n",
"self.serial.open()\n",
"self.serial.reset_input_buffer()\n",
"self.prompt = options.dut_prompt if not aux else options.aux_prompt\n",
"self.prompt += ' '\n",
"self.rsakey = rsakey\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"AugAssign'",
"Assign'"
] |
[
"\"\"\"Volume driver for Dell EqualLogic Storage.\"\"\"\n",
"import functools\n",
"import random\n",
"import eventlet\n",
"from eventlet import greenthread\n",
"import greenlet\n",
"from oslo.config import cfg\n",
"from cinder import exception\n",
"from cinder.openstack.common import excutils\n",
"from cinder.openstack.common import log as logging\n",
"from cinder.openstack.common import processutils\n",
"from cinder import utils\n",
"from cinder.volume.drivers.san import SanISCSIDriver\n",
"VAR_0 = logging.getLogger(__name__)\n",
"VAR_1 = [cfg.StrOpt('eqlx_group_name', default='group-0', help=\n 'Group name to use for creating volumes'), cfg.IntOpt(\n 'eqlx_cli_timeout', default=30, help=\n 'Timeout for the Group Manager cli command execution'), cfg.IntOpt(\n 'eqlx_cli_max_retries', default=5, help=\n 'Maximum retry count for reconnection'), cfg.BoolOpt('eqlx_use_chap',\n default=False, help='Use CHAP authentication for targets?'), cfg.StrOpt\n ('eqlx_chap_login', default='admin', help='Existing CHAP account name'),\n cfg.StrOpt('eqlx_chap_password', default='password', help=\n 'Password for specified CHAP account name', secret=True), cfg.StrOpt(\n 'eqlx_pool', default='default', help=\n 'Pool in which volumes will be created')]\n",
"VAR_2 = cfg.CONF\n",
"VAR_2.register_opts(VAR_1)\n",
"def FUNC_0(VAR_3):...\n",
"@functools.wraps(VAR_3)...\n",
"VAR_23 = VAR_5.pop('timeout', None)\n",
"VAR_24 = eventlet.spawn(VAR_3, self, *VAR_4, **kwargs)\n",
"if VAR_23 is None:\n",
"return VAR_24.wait()\n",
"VAR_36 = eventlet.spawn_after(VAR_23, VAR_24.kill)\n",
"VAR_48 = VAR_24.wait()\n",
"VAR_36.cancel()\n",
"return FUNC_1\n",
"return VAR_48\n"
] | [
"\"\"\"Volume driver for Dell EqualLogic Storage.\"\"\"\n",
"import functools\n",
"import random\n",
"import eventlet\n",
"from eventlet import greenthread\n",
"import greenlet\n",
"from oslo.config import cfg\n",
"from cinder import exception\n",
"from cinder.openstack.common import excutils\n",
"from cinder.openstack.common import log as logging\n",
"from cinder.openstack.common import processutils\n",
"from cinder import utils\n",
"from cinder.volume.drivers.san import SanISCSIDriver\n",
"LOG = logging.getLogger(__name__)\n",
"eqlx_opts = [cfg.StrOpt('eqlx_group_name', default='group-0', help=\n 'Group name to use for creating volumes'), cfg.IntOpt(\n 'eqlx_cli_timeout', default=30, help=\n 'Timeout for the Group Manager cli command execution'), cfg.IntOpt(\n 'eqlx_cli_max_retries', default=5, help=\n 'Maximum retry count for reconnection'), cfg.BoolOpt('eqlx_use_chap',\n default=False, help='Use CHAP authentication for targets?'), cfg.StrOpt\n ('eqlx_chap_login', default='admin', help='Existing CHAP account name'),\n cfg.StrOpt('eqlx_chap_password', default='password', help=\n 'Password for specified CHAP account name', secret=True), cfg.StrOpt(\n 'eqlx_pool', default='default', help=\n 'Pool in which volumes will be created')]\n",
"CONF = cfg.CONF\n",
"CONF.register_opts(eqlx_opts)\n",
"def with_timeout(f):...\n",
"@functools.wraps(f)...\n",
"timeout = kwargs.pop('timeout', None)\n",
"gt = eventlet.spawn(f, self, *args, **kwargs)\n",
"if timeout is None:\n",
"return gt.wait()\n",
"kill_thread = eventlet.spawn_after(timeout, gt.kill)\n",
"res = gt.wait()\n",
"kill_thread.cancel()\n",
"return __inner\n",
"return res\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
] | [
"Expr'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Return'",
"Return'"
] |
[
"def FUNC_2(self, VAR_3, VAR_4=None, VAR_5=0):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.conn or not self.conn.open:\n",
"self.connect()\n",
"VAR_7 = self.conn.cursor()\n",
"if e.args[0] in [2006, 2013]:\n",
"return VAR_7\n",
"VAR_7.execute(VAR_3, VAR_4)\n",
"log.info(e)\n",
"log.error(e)\n",
"self.connect()\n",
"log.error(e)\n",
"if VAR_5 > 3:\n",
"log.error(e)\n",
"VAR_5 += 1\n",
"log.warning('Ran out of limit of trials...')\n",
"log.warning(e)\n",
"log.info('Trying execute the query again...')\n",
"return self.execute_query(VAR_3, VAR_4, VAR_5)\n"
] | [
"def execute_query(self, query, parameters=None, trials=0):...\n",
"\"\"\"docstring\"\"\"\n",
"if not self.conn or not self.conn.open:\n",
"self.connect()\n",
"cursor = self.conn.cursor()\n",
"if e.args[0] in [2006, 2013]:\n",
"return cursor\n",
"cursor.execute(query, parameters)\n",
"log.info(e)\n",
"log.error(e)\n",
"self.connect()\n",
"log.error(e)\n",
"if trials > 3:\n",
"log.error(e)\n",
"trials += 1\n",
"log.warning('Ran out of limit of trials...')\n",
"log.warning(e)\n",
"log.info('Trying execute the query again...')\n",
"return self.execute_query(query, parameters, trials)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Return'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"AugAssign'",
"Expr'",
"Expr'",
"Expr'",
"Return'"
] |
[
"import pymysql\n",
"import dbconfig\n",
"def FUNC_0(self, VAR_0='crimemap'):...\n",
"return pymysql.connect(host='localhost', user=dbconfig.db_user, passwd=\n dbconfig.db_password, db=database)\n"
] | [
"import pymysql\n",
"import dbconfig\n",
"def connect(self, database='crimemap'):...\n",
"return pymysql.connect(host='localhost', user=dbconfig.db_user, passwd=\n dbconfig.db_password, db=database)\n"
] | [
0,
0,
0,
0
] | [
"Import'",
"Import'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_12(self):...\n",
"VAR_8 = VAR_3.connection\n",
"VAR_9 = VAR_8.cursor()\n",
"VAR_9.execute('SELECT id FROM users WHERE username=\"%s\" ' % self.username)\n",
"VAR_10 = VAR_9.fetchall()\n",
"return str(VAR_10[0]['id'])\n"
] | [
"def get_id(self):...\n",
"conn = mysql.connection\n",
"cur = conn.cursor()\n",
"cur.execute('SELECT id FROM users WHERE username=\"%s\" ' % self.username)\n",
"rv = cur.fetchall()\n",
"return str(rv[0]['id'])\n"
] | [
0,
0,
0,
4,
0,
4
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_0(self, VAR_0='crimemap'):...\n",
"return pymysql.connect(host='localhost', user=dbconfig.db_user, passwd=\n dbconfig.db_password, db=database)\n"
] | [
"def connect(self, database='crimemap'):...\n",
"return pymysql.connect(host='localhost', user=dbconfig.db_user, passwd=\n dbconfig.db_password, db=database)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_5(self, VAR_5):...\n",
"if VAR_5 in self.groups:\n",
"self.groups.remove(VAR_5)\n",
"for oldg in VAR_5.get_ancestors():\n",
"if oldg.name != 'all':\n",
"for childg in self.groups:\n",
"if oldg in childg.get_ancestors():\n"
] | [
"def remove_group(self, group):...\n",
"if group in self.groups:\n",
"self.groups.remove(group)\n",
"for oldg in group.get_ancestors():\n",
"if oldg.name != 'all':\n",
"for childg in self.groups:\n",
"if oldg in childg.get_ancestors():\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"For",
"Condition",
"For",
"Condition"
] |
[
"from __future__ import absolute_import\n",
"from __future__ import division\n",
"from __future__ import print_function\n",
"import atexit\n",
"import json\n",
"import os\n",
"import logging\n",
"import signal\n",
"import threading\n",
"import time\n",
"import ray\n",
"import ray.ray_constants as ray_constants\n",
"from ray.tempfile_services import get_logs_dir_path, get_object_store_socket_name, get_raylet_socket_name, new_log_monitor_log_file, new_monitor_log_file, new_raylet_monitor_log_file, new_plasma_store_log_file, new_raylet_log_file, new_webui_log_file, set_temp_root, try_to_create_directory\n",
"VAR_0 = logging.getLogger(__name__)\n",
"\"\"\"string\"\"\"\n",
"def __init__(self, VAR_1, VAR_2=False, VAR_3=True):...\n",
"\"\"\"docstring\"\"\"\n",
"self.all_processes = {}\n",
"VAR_1.update_if_absent(node_ip_address=ray.services.get_node_ip_address(),\n include_log_monitor=True, resources={}, include_webui=False,\n worker_path=os.path.join(os.path.dirname(os.path.abspath(__file__)),\n 'workers/default_worker.py'))\n",
"if VAR_2:\n",
"VAR_1.update_if_absent(num_redis_shards=1, include_webui=True)\n",
"VAR_18 = ray.services.create_redis_client(VAR_1.redis_address, VAR_1.\n redis_password)\n",
"self._ray_params = VAR_1\n",
"VAR_1.include_java = ray.services.include_java_from_redis(VAR_18)\n",
"self._config = json.loads(VAR_1._internal_config\n ) if VAR_1._internal_config else None\n",
"self._node_ip_address = VAR_1.node_ip_address\n",
"self._redis_address = VAR_1.redis_address\n",
"self._plasma_store_socket_name = None\n",
"self._raylet_socket_name = None\n",
"self._webui_url = None\n",
"self.start_ray_processes()\n",
"if VAR_3:\n",
"atexit.register(lambda : self.kill_all_processes(VAR_9=False, VAR_8=True))\n",
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._node_ip_address\n"
] | [
"from __future__ import absolute_import\n",
"from __future__ import division\n",
"from __future__ import print_function\n",
"import atexit\n",
"import json\n",
"import os\n",
"import logging\n",
"import signal\n",
"import threading\n",
"import time\n",
"import ray\n",
"import ray.ray_constants as ray_constants\n",
"from ray.tempfile_services import get_logs_dir_path, get_object_store_socket_name, get_raylet_socket_name, new_log_monitor_log_file, new_monitor_log_file, new_raylet_monitor_log_file, new_plasma_store_log_file, new_raylet_log_file, new_webui_log_file, set_temp_root, try_to_create_directory\n",
"logger = logging.getLogger(__name__)\n",
"\"\"\"An encapsulation of the Ray processes on a single node.\n\n This class is responsible for starting Ray processes and killing them.\n\n Attributes:\n all_processes (dict): A mapping from process type (str) to a list of\n ProcessInfo objects. All lists have length one except for the Redis\n server list, which has multiple.\n \"\"\"\n",
"def __init__(self, ray_params, head=False, shutdown_at_exit=True):...\n",
"\"\"\"docstring\"\"\"\n",
"self.all_processes = {}\n",
"ray_params.update_if_absent(node_ip_address=ray.services.\n get_node_ip_address(), include_log_monitor=True, resources={},\n include_webui=False, worker_path=os.path.join(os.path.dirname(os.path.\n abspath(__file__)), 'workers/default_worker.py'))\n",
"if head:\n",
"ray_params.update_if_absent(num_redis_shards=1, include_webui=True)\n",
"redis_client = ray.services.create_redis_client(ray_params.redis_address,\n ray_params.redis_password)\n",
"self._ray_params = ray_params\n",
"ray_params.include_java = ray.services.include_java_from_redis(redis_client)\n",
"self._config = json.loads(ray_params._internal_config\n ) if ray_params._internal_config else None\n",
"self._node_ip_address = ray_params.node_ip_address\n",
"self._redis_address = ray_params.redis_address\n",
"self._plasma_store_socket_name = None\n",
"self._raylet_socket_name = None\n",
"self._webui_url = None\n",
"self.start_ray_processes()\n",
"if shutdown_at_exit:\n",
"atexit.register(lambda : self.kill_all_processes(check_alive=False,\n allow_graceful=True))\n",
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._node_ip_address\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
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"Assign'",
"Expr'",
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Docstring",
"Return'"
] |
[
"def __init__(self, *VAR_3, **VAR_4):...\n",
"super(CLASS_1, self).__init__(*VAR_3, **kwargs)\n"
] | [
"def __init__(self, *args, **kwargs):...\n",
"super(SanISCSIDriver, self).__init__(*args, **kwargs)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_10(self):...\n",
"self.run_test_case(self.scenario.create_load_balancer())\n"
] | [
"def test_a_create_load_balancer(self):...\n",
"self.run_test_case(self.scenario.create_load_balancer())\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_5():...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_7 = FUNC_4('news')\n",
"if VAR_7 is not None:\n",
"VAR_0 = VAR_7.cursor()\n",
"if FUNC_0(VAR_0, 'DESC', 3):\n",
"print('Successful creating top articles report.')\n",
"print('Error creating top articles report.')\n",
"if FUNC_1(VAR_0, 'DESC'):\n",
"print('Successful creating top authors report.')\n",
"print('Error creating top authors report.')\n",
"if FUNC_2(VAR_0, 1):\n",
"print('Successful creating daily error percentage report.')\n",
"print('Error creating daily error percentage report.')\n",
"VAR_7.close()\n"
] | [
"def main():...\n",
"\"\"\"docstring\"\"\"\n",
"conn = setup_connection('news')\n",
"if conn is not None:\n",
"cur = conn.cursor()\n",
"if get_top_articles(cur, 'DESC', 3):\n",
"print('Successful creating top articles report.')\n",
"print('Error creating top articles report.')\n",
"if get_top_authors(cur, 'DESC'):\n",
"print('Successful creating top authors report.')\n",
"print('Error creating top authors report.')\n",
"if get_error_days(cur, 1):\n",
"print('Successful creating daily error percentage report.')\n",
"print('Error creating daily error percentage report.')\n",
"conn.close()\n"
] | [
0,
0,
0,
0,
0,
4,
0,
0,
4,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_11(self, VAR_15, VAR_16, VAR_17):...\n",
"self.checked += 1\n",
"self.curline = 0\n",
"for VAR_25 in VAR_15:\n",
"if pe.tok:\n",
"VAR_25 = VAR_25.decode(locale.getpreferredencoding(False), errors='ignore')\n",
"VAR_27 = VAR_25.find(VAR_14) + pe.tok.lexpos\n",
"sys.stdout.write('%s: %d:0 %s\\n' % (VAR_17, self.curline, VAR_27, pe.txt))\n",
"self.curline += 1\n",
"VAR_3 = pe.tok.value\n",
"self.spdx_errors += 1\n",
"if self.curline > VAR_16:\n",
"sys.stdout.write('%s: %d:%d %s: %s\\n' % (VAR_17, self.curline, VAR_27, pe.\n txt, VAR_3))\n",
"self.lines_checked += 1\n",
"if VAR_25.find('SPDX-License-Identifier:') < 0:\n",
"VAR_14 = VAR_25.split(':')[1].strip()\n",
"if VAR_25.strip().endswith('*/'):\n",
"VAR_14 = VAR_14.rstrip('*/').strip()\n",
"if VAR_25.startswith('LIST \"'):\n",
"VAR_14 = VAR_14.rstrip('\"').strip()\n",
"self.parse(VAR_14)\n",
"self.spdx_valid += 1\n"
] | [
"def parse_lines(self, fd, maxlines, fname):...\n",
"self.checked += 1\n",
"self.curline = 0\n",
"for line in fd:\n",
"if pe.tok:\n",
"line = line.decode(locale.getpreferredencoding(False), errors='ignore')\n",
"col = line.find(expr) + pe.tok.lexpos\n",
"sys.stdout.write('%s: %d:0 %s\\n' % (fname, self.curline, col, pe.txt))\n",
"self.curline += 1\n",
"tok = pe.tok.value\n",
"self.spdx_errors += 1\n",
"if self.curline > maxlines:\n",
"sys.stdout.write('%s: %d:%d %s: %s\\n' % (fname, self.curline, col, pe.txt, tok)\n )\n",
"self.lines_checked += 1\n",
"if line.find('SPDX-License-Identifier:') < 0:\n",
"expr = line.split(':')[1].strip()\n",
"if line.strip().endswith('*/'):\n",
"expr = expr.rstrip('*/').strip()\n",
"if line.startswith('LIST \"'):\n",
"expr = expr.rstrip('\"').strip()\n",
"self.parse(expr)\n",
"self.spdx_valid += 1\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"AugAssign'",
"Assign'",
"For",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"AugAssign'",
"Assign'",
"AugAssign'",
"Condition",
"Expr'",
"AugAssign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"AugAssign'"
] |
[
"def FUNC_20(self):...\n",
"self._ServerCleanup()\n"
] | [
"def OnVimLeave(self):...\n",
"self._ServerCleanup()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@staticmethod...\n",
"VAR_5 = CLASS_0._get_report(VAR_1)\n",
"if not VAR_5:\n",
"VAR_9 = {'analysis': VAR_5}\n",
"VAR_13 = CLASS_0._get_dnsinfo(VAR_5)\n",
"VAR_9.update(VAR_13)\n",
"return VAR_9\n"
] | [
"@staticmethod...\n",
"report = AnalysisController._get_report(task_id)\n",
"if not report:\n",
"data = {'analysis': report}\n",
"dnsinfo = AnalysisController._get_dnsinfo(report)\n",
"data.update(dnsinfo)\n",
"return data\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"self.uut.output_regex = 'string'\n",
"self.uut.severity_map = {'I': RESULT_SEVERITY.INFO}\n",
"VAR_1 = list(self.uut.process_output(['info_msg|1.0|2.3|I: Info message\\n'],\n 'a/file.py', ['original_file_lines_placeholder']))\n",
"self.assertEqual(len(VAR_1), 1)\n",
"self.assertEqual(VAR_1[0].affected_code[0].start.line, 1)\n",
"self.assertEqual(VAR_1[0].affected_code[0].start.column, 0)\n",
"self.assertEqual(VAR_1[0].affected_code[0].end.line, 2)\n",
"self.assertEqual(VAR_1[0].affected_code[0].end.column, 3)\n",
"self.assertEqual(VAR_1[0].severity, RESULT_SEVERITY.INFO)\n",
"self.assertEqual(VAR_1[0].origin, 'Lint (info_msg)')\n"
] | [
"def test_custom_regex(self):...\n",
"self.uut.output_regex = (\n '(?P<origin>\\\\w+)\\\\|(?P<line>\\\\d+)\\\\.(?P<column>\\\\d+)\\\\|(?P<end_line>\\\\d+)\\\\.(?P<end_column>\\\\d+)\\\\|(?P<severity>\\\\w+): (?P<message>.*)'\n )\n",
"self.uut.severity_map = {'I': RESULT_SEVERITY.INFO}\n",
"out = list(self.uut.process_output(['info_msg|1.0|2.3|I: Info message\\n'],\n 'a/file.py', ['original_file_lines_placeholder']))\n",
"self.assertEqual(len(out), 1)\n",
"self.assertEqual(out[0].affected_code[0].start.line, 1)\n",
"self.assertEqual(out[0].affected_code[0].start.column, 0)\n",
"self.assertEqual(out[0].affected_code[0].end.line, 2)\n",
"self.assertEqual(out[0].affected_code[0].end.column, 3)\n",
"self.assertEqual(out[0].severity, RESULT_SEVERITY.INFO)\n",
"self.assertEqual(out[0].origin, 'Lint (info_msg)')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def __db_connect__(self):...\n",
"self.db = sqlite3.connect(self.db_name)\n",
"self.db.row_factory = sqlite3.Row\n",
"self.cursor = self.db.cursor()\n"
] | [
"def __db_connect__(self):...\n",
"self.db = sqlite3.connect(self.db_name)\n",
"self.db.row_factory = sqlite3.Row\n",
"self.cursor = self.db.cursor()\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_16(self):...\n",
"VAR_7 = Pa11yCrawler('')\n",
"VAR_7.get_test_course()\n",
"self._mock_sh.assert_has_calls([call(\n 'wget {targz} -O {dir}demo_course.tar.gz'.format(targz=suite.\n tar_gz_file, dir=suite.imports_dir)), call(\n 'tar zxf {dir}demo_course.tar.gz -C {dir}'.format(dir=suite.imports_dir))])\n"
] | [
"def test_get_test_course(self):...\n",
"suite = Pa11yCrawler('')\n",
"suite.get_test_course()\n",
"self._mock_sh.assert_has_calls([call(\n 'wget {targz} -O {dir}demo_course.tar.gz'.format(targz=suite.\n tar_gz_file, dir=suite.imports_dir)), call(\n 'tar zxf {dir}demo_course.tar.gz -C {dir}'.format(dir=suite.imports_dir))])\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@api_view(['GET'])...\n",
"VAR_7 = utils.param_to_list(VAR_0.query_params.get('measure', None))\n",
"VAR_8 = utils.param_to_list(VAR_0.query_params.get('tags', None))\n",
"VAR_9 = MeasureGlobal.objects.select_related('measure')\n",
"if VAR_7:\n",
"VAR_9 = VAR_9.filter(measure_id__in=measures)\n",
"if VAR_8:\n",
"VAR_9 = VAR_9.filter(measure__tags__overlap=tags)\n",
"VAR_9 = VAR_9.order_by('measure_id', 'month')\n",
"VAR_10 = {}\n",
"for mg in VAR_9:\n",
"VAR_25 = mg.measure_id\n",
"VAR_11 = {'measures': [VAR_10[k] for k in VAR_10]}\n",
"VAR_26 = {'date': mg.month, 'numerator': mg.numerator, 'denominator': mg.\n denominator, 'calc_value': mg.calc_value, 'percentiles': mg.percentiles,\n 'cost_savings': mg.cost_savings}\n",
"return Response(VAR_11)\n",
"if VAR_25 in VAR_10:\n",
"VAR_10[VAR_25]['data'].append(VAR_26)\n",
"VAR_13 = mg.measure\n",
"if VAR_13.tags_focus:\n",
"VAR_39 = ','.join(VAR_13.tags_focus)\n",
"VAR_39 = ''\n",
"VAR_10[VAR_25] = {'id': VAR_25, 'name': VAR_13.name, 'title': VAR_13.title,\n 'description': VAR_13.description, 'why_it_matters': VAR_13.\n why_it_matters, 'numerator_short': VAR_13.numerator_short,\n 'denominator_short': VAR_13.denominator_short, 'url': VAR_13.url,\n 'is_cost_based': VAR_13.is_cost_based, 'is_percentage': VAR_13.\n is_percentage, 'low_is_good': VAR_13.low_is_good, 'tags_focus': VAR_39,\n 'numerator_is_list_of_bnf_codes': VAR_13.numerator_is_list_of_bnf_codes,\n 'tags': FUNC_9(VAR_13.tags), 'data': [VAR_26]}\n"
] | [
"@api_view(['GET'])...\n",
"measures = utils.param_to_list(request.query_params.get('measure', None))\n",
"tags = utils.param_to_list(request.query_params.get('tags', None))\n",
"qs = MeasureGlobal.objects.select_related('measure')\n",
"if measures:\n",
"qs = qs.filter(measure_id__in=measures)\n",
"if tags:\n",
"qs = qs.filter(measure__tags__overlap=tags)\n",
"qs = qs.order_by('measure_id', 'month')\n",
"rolled = {}\n",
"for mg in qs:\n",
"id = mg.measure_id\n",
"d = {'measures': [rolled[k] for k in rolled]}\n",
"d_copy = {'date': mg.month, 'numerator': mg.numerator, 'denominator': mg.\n denominator, 'calc_value': mg.calc_value, 'percentiles': mg.percentiles,\n 'cost_savings': mg.cost_savings}\n",
"return Response(d)\n",
"if id in rolled:\n",
"rolled[id]['data'].append(d_copy)\n",
"measure = mg.measure\n",
"if measure.tags_focus:\n",
"tags_focus = ','.join(measure.tags_focus)\n",
"tags_focus = ''\n",
"rolled[id] = {'id': id, 'name': measure.name, 'title': measure.title,\n 'description': measure.description, 'why_it_matters': measure.\n why_it_matters, 'numerator_short': measure.numerator_short,\n 'denominator_short': measure.denominator_short, 'url': measure.url,\n 'is_cost_based': measure.is_cost_based, 'is_percentage': measure.\n is_percentage, 'low_is_good': measure.low_is_good, 'tags_focus':\n tags_focus, 'numerator_is_list_of_bnf_codes': measure.\n numerator_is_list_of_bnf_codes, 'tags': _hydrate_tags(measure.tags),\n 'data': [d_copy]}\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_11(self):...\n",
"VAR_21 = ['vim', VAR_2]\n",
"if not self.writeable:\n",
"VAR_21.insert(1, '-R')\n",
"subprocess.call(VAR_21)\n",
"return None\n"
] | [
"def open_temp_file(self):...\n",
"params = ['vim', TEMP_FILE]\n",
"if not self.writeable:\n",
"params.insert(1, '-R')\n",
"subprocess.call(params)\n",
"return None\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"super(CLASS_0, self).setUp()\n",
"self.mock(net, 'url_open', self._url_open)\n",
"self.mock(net, 'url_read_json', self._url_read_json)\n",
"self.mock(net, 'sleep_before_retry', lambda *VAR_10: None)\n",
"self._lock = threading.Lock()\n",
"self._requests = []\n"
] | [
"def setUp(self):...\n",
"super(TestCase, self).setUp()\n",
"self.mock(net, 'url_open', self._url_open)\n",
"self.mock(net, 'url_read_json', self._url_read_json)\n",
"self.mock(net, 'sleep_before_retry', lambda *_: None)\n",
"self._lock = threading.Lock()\n",
"self._requests = []\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'"
] |
[
"@utils.synchronized('3par', external=True)...\n",
"\"\"\"docstring\"\"\"\n",
"self.common.client_login()\n",
"VAR_25 = self._create_host(VAR_7, VAR_10)\n",
"VAR_26 = self.common.create_vlun(VAR_7, VAR_25)\n",
"self.common.client_logout()\n",
"VAR_27 = self._get_iscsi_ip(VAR_25['name'])\n",
"VAR_28 = self.iscsi_ips[VAR_27]['ip_port']\n",
"VAR_29 = self.iscsi_ips[VAR_27]['iqn']\n",
"VAR_30 = {'driver_volume_type': 'iscsi', 'data': {'target_portal': '%s:%s' %\n (VAR_27, VAR_28), 'target_iqn': VAR_29, 'target_lun': VAR_26['lun'],\n 'target_discovered': True}}\n",
"return VAR_30\n"
] | [
"@utils.synchronized('3par', external=True)...\n",
"\"\"\"docstring\"\"\"\n",
"self.common.client_login()\n",
"host = self._create_host(volume, connector)\n",
"vlun = self.common.create_vlun(volume, host)\n",
"self.common.client_logout()\n",
"iscsi_ip = self._get_iscsi_ip(host['name'])\n",
"iscsi_ip_port = self.iscsi_ips[iscsi_ip]['ip_port']\n",
"iscsi_target_iqn = self.iscsi_ips[iscsi_ip]['iqn']\n",
"info = {'driver_volume_type': 'iscsi', 'data': {'target_portal': '%s:%s' %\n (iscsi_ip, iscsi_ip_port), 'target_iqn': iscsi_target_iqn, 'target_lun':\n vlun['lun'], 'target_discovered': True}}\n",
"return info\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_14(VAR_10):...\n",
"\"\"\"docstring\"\"\"\n",
"return \"<input type='hidden' name='csrf' id='csrf' value='{}'>\".format(FUNC_13\n (VAR_10))\n"
] | [
"def csrf_tag(csrf):...\n",
"\"\"\"docstring\"\"\"\n",
"return \"<input type='hidden' name='csrf' id='csrf' value='{}'>\".format(\n csrf_hash(csrf))\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"@VAR_0.route('/peti/')...\n",
"VAR_9 = ''\n",
"VAR_2.execute('select * from PETITION_DATA_TB')\n",
"VAR_11 = VAR_2.fetchall()\n",
"VAR_9 += 'string'\n",
"for i in range(len(VAR_11)):\n",
"VAR_9 += (\n '<tr><th scope=\"row\">{}</th><td><a href=\"/peti/a/{}\">{}</a></td></tr>'.\n format(VAR_11[i][0], VAR_11[i][0], VAR_11[i][1]))\n",
"VAR_9 += '</tbody></table>'\n",
"VAR_9 += 'string'\n",
"return render_template('index.html', OFORM_APPNAME=LocalSettings.\n OFORM_APPNAME, OFORM_CONTENT=BODY_CONTENT)\n"
] | [
"@app.route('/peti/')...\n",
"BODY_CONTENT = ''\n",
"curs.execute('select * from PETITION_DATA_TB')\n",
"result = curs.fetchall()\n",
"BODY_CONTENT += (\n '<h1>새로운 청원들</h1><table class=\"table table-hover\"><thead><tr><th scope=\"col\">N</th><th scope=\"col\">Column heading</th></tr></thead><tbody>'\n )\n",
"for i in range(len(result)):\n",
"BODY_CONTENT += (\n '<tr><th scope=\"row\">{}</th><td><a href=\"/peti/a/{}\">{}</a></td></tr>'.\n format(result[i][0], result[i][0], result[i][1]))\n",
"BODY_CONTENT += '</tbody></table>'\n",
"BODY_CONTENT += (\n '<button onclick=\"window.location.href=\\'write\\'\" class=\"btn btn-primary\" value=\"publish\">청원 등록</button>'\n )\n",
"return render_template('index.html', OFORM_APPNAME=LocalSettings.\n OFORM_APPNAME, OFORM_CONTENT=BODY_CONTENT)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Expr'",
"Assign'",
"AugAssign'",
"For",
"AugAssign'",
"AugAssign'",
"AugAssign'",
"Return'"
] |
[
"def FUNC_56(self):...\n",
"self._test_strtype('blob', VAR_13, VAR_23(VAR_13))\n"
] | [
"def t(self):...\n",
"self._test_strtype('blob', value, len(value))\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_0(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.write(api.survey.get_all(get_email(self)))\n"
] | [
"def get(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.write(api.survey.get_all(get_email(self)))\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'"
] |
[
"@api.require(lambda : True)...\n",
""
] | [
"@api.require(lambda : True)...\n",
""
] | [
0,
0
] | [
"Condition",
"Condition"
] |
[
"def FUNC_13(self):...\n",
"self.run_test_case(self.scenario.delete_server_group(), max_retries=5)\n"
] | [
"def test_x_delete_server_group(self):...\n",
"self.run_test_case(self.scenario.delete_server_group(), max_retries=5)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_0(VAR_9):...\n",
"VAR_11 = {unquote(x.split('=')[0]): str(unquote(x.split('=')[1])).replace(\n '+', ' ') for x in VAR_9['content'].split('&')}\n",
"VAR_12 = VAR_11['job_number']\n",
"VAR_27 = pd.read_sql(f'SELECT * FROM df_dilfo WHERE job_number={VAR_12}', conn\n ).iloc[0].closed\n",
"VAR_27 = 0\n",
"VAR_13 = re.findall('<?(\\\\S+@\\\\S+\\\\.\\\\w+)>?', VAR_9['sender'])[0].lower()\n",
"VAR_11.update({'receiver_email': VAR_13})\n",
"if VAR_11['cc_email'] != '':\n",
"VAR_15 = VAR_11.pop('link_to_cert')\n",
"VAR_15 = ''\n",
"if VAR_15:\n",
"VAR_11['cc_email'] += '@dilfo.com'\n",
"VAR_15 = VAR_15.split('-notices/')[1]\n",
"VAR_15 = re.findall('[\\\\w-]*', VAR_15)[0]\n",
"VAR_11.pop('instant_scan')\n",
"VAR_22 = False\n",
"if VAR_27:\n",
"VAR_22 = True\n",
"VAR_4.info(\n f'job was already matched successfully and logged as `closed`. Sending e-mail!'\n )\n",
"if VAR_15:\n",
"VAR_30 = pd.read_sql(\n 'SELECT * FROM df_matched WHERE job_number=? AND ground_truth=1', conn,\n params=[job_number]).iloc[0]\n",
"VAR_11.update({'closed': 1})\n",
"VAR_11.update({'closed': 0})\n",
"VAR_23 = VAR_30.verifier\n",
"VAR_26 = pd.read_sql('SELECT * FROM df_matched', conn)\n",
"VAR_26 = pd.read_sql('SELECT * FROM df_dilfo', conn)\n",
"VAR_24 = VAR_30.log_date\n",
"VAR_29 = {'job_number': VAR_11['job_number'], 'dcn_key': VAR_15,\n 'ground_truth': 1, 'verifier': VAR_11['receiver_email'], 'source':\n 'input', 'log_date': str(datetime.datetime.now().date()), 'validate': 0}\n",
"VAR_26 = VAR_26.append(VAR_11, ignore_index=True)\n",
"VAR_15 = VAR_30.dcn_key\n",
"VAR_26 = VAR_26.append(VAR_29, ignore_index=True)\n",
"for dup_i in VAR_26[VAR_26.duplicated(subset=['job_number'], keep='last')\n",
"VAR_25 = f\"\"\"From: Dilfo HBR Bot\nTo: {VAR_13}\nSubject: Previously Matched: #{VAR_12}\n\nHi {VAR_13.split('.')[0].title()},\n\nIt looks like job #{VAR_12} corresponds to the following certificate:\n{VAR_3}{VAR_15}\n\nThis confirmation was provided by {VAR_23.split('.')[0].title()}{' on ' + VAR_24 if VAR_24 is not None else ''}string\"\"\"\n",
"VAR_26 = VAR_26.drop_duplicates(subset=['job_number', 'dcn_key'], keep='last')\n",
"VAR_32 = VAR_26.iloc[dup_i].job_number\n",
"VAR_26.to_sql('df_dilfo', conn, if_exists='replace', index=False)\n",
"VAR_31 = ssl.create_default_context()\n",
"VAR_4.info('password not available -> could not send e-mail')\n",
"return\n",
"VAR_26.to_sql('df_matched', conn, if_exists='replace', index=False)\n",
"VAR_33 = VAR_26.iloc[dup_i].receiver_email\n",
"if VAR_22:\n",
"VAR_16.login(VAR_2, VAR_21)\n",
"VAR_34 = VAR_26.iloc[dup_i].cc_email\n",
"VAR_35 = 'SELECT * FROM df_dilfo WHERE job_number=?'\n",
"VAR_16.sendmail(VAR_2, [VAR_13], VAR_25)\n",
"VAR_26 = VAR_26.drop(dup_i)\n",
"VAR_44 = pd.read_sql(VAR_35, conn, params=[job_number])\n",
"VAR_4.info(f'Successfully sent an email to {VAR_13}')\n",
"VAR_42 = '; '.join([x for x in VAR_34 + VAR_33 if x])\n",
"VAR_36 = 'SELECT * FROM df_hist ORDER BY pub_date DESC LIMIT 2000'\n",
"VAR_43 = VAR_26[VAR_26.job_number == VAR_32].index\n",
"VAR_45 = pd.read_sql(VAR_36, conn)\n",
"VAR_26.loc[VAR_43, 'cc_email'] = VAR_26.loc[VAR_43, 'cc_email'] + '; ' + VAR_42\n",
"VAR_20 = match(VAR_44=df_dilfo, VAR_45=df_web, test=False)\n",
"if len(VAR_20[VAR_20.pred_match == 1]) == 0:\n",
"VAR_25 = f\"\"\"From: Dilfo HBR Bot\nTo: {VAR_13}\nSubject: Successful Project Sign-Up: #{VAR_12}\n\nHi {VAR_13.split('.')[0].title()},\n\nYour information for project #{VAR_12}string\"\"\"\n",
"VAR_31 = ssl.create_default_context()\n",
"VAR_4.info('password not available -> could not send e-mail')\n",
"VAR_16.login(VAR_2, VAR_21)\n",
"VAR_16.sendmail(VAR_2, [VAR_13], VAR_25)\n",
"VAR_4.info(f'Successfully sent an email to {VAR_13}')\n"
] | [
"def process_as_form(email_obj):...\n",
"dict_input = {unquote(x.split('=')[0]): str(unquote(x.split('=')[1])).\n replace('+', ' ') for x in email_obj['content'].split('&')}\n",
"job_number = dict_input['job_number']\n",
"was_prev_closed = pd.read_sql(\n f'SELECT * FROM df_dilfo WHERE job_number={job_number}', conn).iloc[0\n ].closed\n",
"was_prev_closed = 0\n",
"receiver_email = re.findall('<?(\\\\S+@\\\\S+\\\\.\\\\w+)>?', email_obj['sender'])[0\n ].lower()\n",
"dict_input.update({'receiver_email': receiver_email})\n",
"if dict_input['cc_email'] != '':\n",
"dcn_key = dict_input.pop('link_to_cert')\n",
"dcn_key = ''\n",
"if dcn_key:\n",
"dict_input['cc_email'] += '@dilfo.com'\n",
"dcn_key = dcn_key.split('-notices/')[1]\n",
"dcn_key = re.findall('[\\\\w-]*', dcn_key)[0]\n",
"dict_input.pop('instant_scan')\n",
"instant_scan = False\n",
"if was_prev_closed:\n",
"instant_scan = True\n",
"logger.info(\n f'job was already matched successfully and logged as `closed`. Sending e-mail!'\n )\n",
"if dcn_key:\n",
"prev_match = pd.read_sql(\n 'SELECT * FROM df_matched WHERE job_number=? AND ground_truth=1', conn,\n params=[job_number]).iloc[0]\n",
"dict_input.update({'closed': 1})\n",
"dict_input.update({'closed': 0})\n",
"verifier = prev_match.verifier\n",
"df = pd.read_sql('SELECT * FROM df_matched', conn)\n",
"df = pd.read_sql('SELECT * FROM df_dilfo', conn)\n",
"log_date = prev_match.log_date\n",
"match_dict_input = {'job_number': dict_input['job_number'], 'dcn_key':\n dcn_key, 'ground_truth': 1, 'verifier': dict_input['receiver_email'],\n 'source': 'input', 'log_date': str(datetime.datetime.now().date()),\n 'validate': 0}\n",
"df = df.append(dict_input, ignore_index=True)\n",
"dcn_key = prev_match.dcn_key\n",
"df = df.append(match_dict_input, ignore_index=True)\n",
"for dup_i in df[df.duplicated(subset=['job_number'], keep='last')].index:\n",
"message = f\"\"\"From: Dilfo HBR Bot\nTo: {receiver_email}\nSubject: Previously Matched: #{job_number}\n\nHi {receiver_email.split('.')[0].title()},\n\nIt looks like job #{job_number} corresponds to the following certificate:\n{lookup_url}{dcn_key}\n\nThis confirmation was provided by {verifier.split('.')[0].title()}{' on ' + log_date if log_date is not None else ''}.\n\nIf any of the information above seems to be inaccurate, please reply to this e-mail for corrective action.\n\nThanks,\nDilfo HBR Bot\n\"\"\"\n",
"df = df.drop_duplicates(subset=['job_number', 'dcn_key'], keep='last')\n",
"dup_job_number = df.iloc[dup_i].job_number\n",
"df.to_sql('df_dilfo', conn, if_exists='replace', index=False)\n",
"context = ssl.create_default_context()\n",
"logger.info('password not available -> could not send e-mail')\n",
"return\n",
"df.to_sql('df_matched', conn, if_exists='replace', index=False)\n",
"dup_receiver = df.iloc[dup_i].receiver_email\n",
"if instant_scan:\n",
"server.login(sender_email, password)\n",
"dup_cc = df.iloc[dup_i].cc_email\n",
"dilfo_query = 'SELECT * FROM df_dilfo WHERE job_number=?'\n",
"server.sendmail(sender_email, [receiver_email], message)\n",
"df = df.drop(dup_i)\n",
"df_dilfo = pd.read_sql(dilfo_query, conn, params=[job_number])\n",
"logger.info(f'Successfully sent an email to {receiver_email}')\n",
"dup_addrs = '; '.join([x for x in dup_cc + dup_receiver if x])\n",
"hist_query = 'SELECT * FROM df_hist ORDER BY pub_date DESC LIMIT 2000'\n",
"update_i = df[df.job_number == dup_job_number].index\n",
"df_web = pd.read_sql(hist_query, conn)\n",
"df.loc[update_i, 'cc_email'] = df.loc[update_i, 'cc_email'] + '; ' + dup_addrs\n",
"results = match(df_dilfo=df_dilfo, df_web=df_web, test=False)\n",
"if len(results[results.pred_match == 1]) == 0:\n",
"message = f\"\"\"From: Dilfo HBR Bot\nTo: {receiver_email}\nSubject: Successful Project Sign-Up: #{job_number}\n\nHi {receiver_email.split('.')[0].title()},\n\nYour information for project #{job_number} was logged successfully but no corresponding certificates in recent history were matched to it.\n\nGoing forward, the Daily Commercial News website will be scraped on a daily basis in search of your project. You will be notified if a possible match has been detected.\n\nThanks,\nDilfo HBR Bot\n\"\"\"\n",
"context = ssl.create_default_context()\n",
"logger.info('password not available -> could not send e-mail')\n",
"server.login(sender_email, password)\n",
"server.sendmail(sender_email, [receiver_email], message)\n",
"logger.info(f'Successfully sent an email to {receiver_email}')\n"
] | [
0,
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"AugAssign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Return'",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_35(self):...\n",
"self.cursor.execute('create table t1(i int)')\n",
"self.cursor.execute('insert into t1 values (1)')\n",
"VAR_4 = self.cursor.execute('delete from t1')\n",
"self.assertEqual(VAR_4, self.cursor)\n"
] | [
"def test_retcursor_delete(self):...\n",
"self.cursor.execute('create table t1(i int)')\n",
"self.cursor.execute('insert into t1 values (1)')\n",
"v = self.cursor.execute('delete from t1')\n",
"self.assertEqual(v, self.cursor)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_3(self, VAR_10, VAR_11):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_17 = {}\n",
"if not int(VAR_11['simulated-human-interaction']):\n",
"VAR_17['human'] = int(VAR_11['simulated-human-interaction'])\n",
"return emit_options(VAR_17)\n"
] | [
"def translate_options(self, info, options):...\n",
"\"\"\"docstring\"\"\"\n",
"ret = {}\n",
"if not int(options['simulated-human-interaction']):\n",
"ret['human'] = int(options['simulated-human-interaction'])\n",
"return emit_options(ret)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"\"\"\"\nUnit tests for the Deis api app.\n\nRun the tests with \"./manage.py test api\\\"\n\"\"\"\n",
"from __future__ import unicode_literals\n",
"from django.test import TestCase\n",
"from deis import __version__\n",
"\"\"\"Tests middleware.py's business logic\"\"\"\n",
"VAR_0 = ['tests.json']\n",
"def FUNC_0(self):...\n",
"self.assertTrue(self.client.login(username='autotest', password='password'))\n",
"def FUNC_1(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_1 = self.client.get('/api/apps', HTTP_X_DEIS_VERSION=__version__.rsplit\n ('.', 1)[0])\n",
"self.assertEqual(VAR_1.status_code, 200)\n",
"def FUNC_2(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_1 = self.client.get('/api/apps', HTTP_X_DEIS_VERSION='1234.5678')\n",
"self.assertEqual(VAR_1.status_code, 405)\n",
"def FUNC_3(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_1 = self.client.get('/api/apps')\n",
"self.assertEqual(VAR_1.status_code, 200)\n"
] | [
"\"\"\"\nUnit tests for the Deis api app.\n\nRun the tests with \"./manage.py test api\\\"\n\"\"\"\n",
"from __future__ import unicode_literals\n",
"from django.test import TestCase\n",
"from deis import __version__\n",
"\"\"\"Tests middleware.py's business logic\"\"\"\n",
"fixtures = ['tests.json']\n",
"def setUp(self):...\n",
"self.assertTrue(self.client.login(username='autotest', password='password'))\n",
"def test_x_deis_version_header_good(self):...\n",
"\"\"\"docstring\"\"\"\n",
"response = self.client.get('/api/apps', HTTP_X_DEIS_VERSION=__version__.\n rsplit('.', 1)[0])\n",
"self.assertEqual(response.status_code, 200)\n",
"def test_x_deis_version_header_bad(self):...\n",
"\"\"\"docstring\"\"\"\n",
"response = self.client.get('/api/apps', HTTP_X_DEIS_VERSION='1234.5678')\n",
"self.assertEqual(response.status_code, 405)\n",
"def test_x_deis_version_header_not_present(self):...\n",
"\"\"\"docstring\"\"\"\n",
"response = self.client.get('/api/apps')\n",
"self.assertEqual(response.status_code, 200)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
5,
0,
0,
5,
0,
0,
0,
5,
0,
0,
0,
5,
0
] | [
"Expr'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Expr'",
"Assign'",
"FunctionDef'",
"Expr'",
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_3(VAR_4, VAR_5, *VAR_6):...\n",
"VAR_14 = 'could not resolve dependency: %s' % VAR_4\n",
"VAR_20 = VAR_5[VAR_6]\n",
"if not VAR_20:\n",
"return VAR_20\n"
] | [
"def resolve_dep(target, from_map, *args):...\n",
"errmsg = 'could not resolve dependency: %s' % target\n",
"ret = from_map[args]\n",
"if not ret:\n",
"return ret\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_19(self):...\n",
"self._diag_interface.OnCursorMoved()\n"
] | [
"def OnCursorMoved(self):...\n",
"self._diag_interface.OnCursorMoved()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"@api.model...\n",
"\"\"\"docstring\"\"\"\n",
"return list(VAR_0)\n"
] | [
"@api.model...\n",
"\"\"\"docstring\"\"\"\n",
"return list(ADDRESS_FIELDS)\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_4(VAR_2):...\n",
"VAR_7 = files.get_static_data('./static/files.html')\n",
"VAR_2 = FUNC_1(VAR_2)\n",
"VAR_2 = '/'\n",
"if not VAR_2:\n",
"VAR_2 = '/'\n",
"VAR_14 = VAR_2.split('/')\n",
"VAR_15 = list()\n",
"while '' in VAR_14:\n",
"VAR_14.remove('')\n",
"VAR_14 = [''] + VAR_14\n",
"VAR_16 = ''\n",
"for VAR_33 in range(0, len(VAR_14)):\n",
"VAR_14[VAR_33] += '/'\n",
"VAR_17 = list()\n",
"VAR_16 += VAR_14[VAR_33]\n",
"for VAR_5 in os.listdir(VAR_2):\n",
"VAR_15.append(dict(folder_name=files_hierarchy[i], href_path=\n '/files/list/%s' % encode_str_to_hexed_b64(files_hierarchy_cwd),\n disabled=i == len(files_hierarchy) - 1))\n",
"VAR_18 = FUNC_0(VAR_16)\n",
"VAR_29 = VAR_2 + VAR_5\n",
"VAR_19 = users.get_user_by_cookie(self.get_cookie('user_active_login',\n default=''))\n",
"VAR_30 = dict()\n",
"VAR_7 = preproc.preprocess_webpage(VAR_7, VAR_19, VAR_17=files_attrib_list,\n VAR_15=files_hierarchy_list, VAR_18=cwd_uuid)\n",
"VAR_30['file-name'] = VAR_5\n",
"VAR_6.set_result(VAR_7)\n",
"VAR_30['allow-edit'] = True\n",
"VAR_30['file-size'] = files.format_file_size(os.path.getsize(VAR_29))\n",
"VAR_30['owner'] = 'root'\n",
"VAR_30['date-uploaded'] = time.ctime(os.path.getctime(VAR_29))\n",
"if os.path.isdir(VAR_29):\n",
"VAR_30['mime-type'] = 'directory/folder'\n",
"VAR_30['mime-type'] = files.guess_mime_type(VAR_5)\n",
"if VAR_30['mime-type'] == 'directory/folder':\n",
"VAR_30['target-link'] = '/files/list/%s' % FUNC_0(VAR_29 + '/')\n",
"VAR_30['target-link'] = '/files/download/%s/%s' % (FUNC_0(VAR_29), VAR_5)\n",
"VAR_30['uuid'] = FUNC_0(VAR_29)\n",
"VAR_17.append(VAR_30)\n"
] | [
"def get_final_html_async(target_path):...\n",
"file_temp = files.get_static_data('./static/files.html')\n",
"target_path = decode_hexed_b64_to_str(target_path)\n",
"target_path = '/'\n",
"if not target_path:\n",
"target_path = '/'\n",
"files_hierarchy = target_path.split('/')\n",
"files_hierarchy_list = list()\n",
"while '' in files_hierarchy:\n",
"files_hierarchy.remove('')\n",
"files_hierarchy = [''] + files_hierarchy\n",
"files_hierarchy_cwd = ''\n",
"for i in range(0, len(files_hierarchy)):\n",
"files_hierarchy[i] += '/'\n",
"files_attrib_list = list()\n",
"files_hierarchy_cwd += files_hierarchy[i]\n",
"for file_name in os.listdir(target_path):\n",
"files_hierarchy_list.append(dict(folder_name=files_hierarchy[i], href_path=\n '/files/list/%s' % encode_str_to_hexed_b64(files_hierarchy_cwd),\n disabled=i == len(files_hierarchy) - 1))\n",
"cwd_uuid = encode_str_to_hexed_b64(files_hierarchy_cwd)\n",
"actual_path = target_path + file_name\n",
"working_user = users.get_user_by_cookie(self.get_cookie('user_active_login',\n default=''))\n",
"attrib = dict()\n",
"file_temp = preproc.preprocess_webpage(file_temp, working_user,\n files_attrib_list=files_attrib_list, files_hierarchy_list=\n files_hierarchy_list, cwd_uuid=cwd_uuid)\n",
"attrib['file-name'] = file_name\n",
"future.set_result(file_temp)\n",
"attrib['allow-edit'] = True\n",
"attrib['file-size'] = files.format_file_size(os.path.getsize(actual_path))\n",
"attrib['owner'] = 'root'\n",
"attrib['date-uploaded'] = time.ctime(os.path.getctime(actual_path))\n",
"if os.path.isdir(actual_path):\n",
"attrib['mime-type'] = 'directory/folder'\n",
"attrib['mime-type'] = files.guess_mime_type(file_name)\n",
"if attrib['mime-type'] == 'directory/folder':\n",
"attrib['target-link'] = '/files/list/%s' % encode_str_to_hexed_b64(\n actual_path + '/')\n",
"attrib['target-link'] = '/files/download/%s/%s' % (encode_str_to_hexed_b64(\n actual_path), file_name)\n",
"attrib['uuid'] = encode_str_to_hexed_b64(actual_path)\n",
"files_attrib_list.append(attrib)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
4,
4,
4,
4,
4,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"For",
"AugAssign'",
"Assign'",
"AugAssign'",
"For",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_29(VAR_13):...\n",
""
] | [
"def failing(request):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_5(VAR_6):...\n",
"if re.search('[^a-zA-Z0-9]', VAR_6):\n",
"if not os.path.isdir('keys/' + VAR_6):\n"
] | [
"def validateClient(client):...\n",
"if re.search('[^a-zA-Z0-9]', client):\n",
"if not os.path.isdir('keys/' + client):\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition"
] |
[
"@login_required()...\n",
"VAR_12 = DataSourceForm(VAR_0.POST or None)\n",
"if VAR_12.is_valid():\n",
"VAR_12.save()\n",
"return render(VAR_0, VAR_1, {'form': VAR_12})\n",
"return redirect('data_source_list')\n"
] | [
"@login_required()...\n",
"form = DataSourceForm(request.POST or None)\n",
"if form.is_valid():\n",
"form.save()\n",
"return render(request, template_name, {'form': form})\n",
"return redirect('data_source_list')\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Expr'",
"Return'",
"Return'"
] |
[
"import os\n",
"import re\n",
"import shutil\n",
"from subprocess import check_call, CalledProcessError, DEVNULL\n",
"import tempfile\n",
"from coalib.bears.Bear import Bear\n",
"from coalib.misc.Decorators import enforce_signature\n",
"from coalib.misc.Shell import escape_path_argument, run_shell_command\n",
"from coalib.results.Diff import Diff\n",
"from coalib.results.Result import Result\n",
"from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY\n",
"\"\"\"string\"\"\"\n",
"VAR_0 = None\n",
"VAR_1 = None\n",
"VAR_2 = 'Unknown failure.'\n",
"VAR_3 = ''\n",
"VAR_4 = re.compile(\n '(?P<line>\\\\d+)\\\\.(?P<column>\\\\d+)\\\\|(?P<severity>\\\\d+): (?P<message>.*)')\n",
"VAR_5 = 'No result message was set'\n",
"VAR_6 = RESULT_SEVERITY.NORMAL\n",
"VAR_7 = False\n",
"VAR_8 = False\n",
"VAR_9 = False\n",
"VAR_10 = None\n",
"def FUNC_0(self, VAR_11=None, VAR_12=None):...\n",
"\"\"\"docstring\"\"\"\n",
"assert self.use_stdin and VAR_12 is not None or not self.use_stdin and VAR_11 is not None\n",
"VAR_21 = self.generate_config_file()\n",
"self.command = self._create_command(VAR_11=filename, VAR_21=config_file)\n",
"VAR_22 = ''.join(VAR_12) if self.use_stdin else None\n",
"VAR_23, VAR_24 = run_shell_command(self.command, stdin=stdin_input)\n",
"self.stdout_output = tuple(VAR_23.splitlines(keepends=True))\n",
"self.stderr_output = tuple(VAR_24.splitlines(keepends=True))\n",
"VAR_25 = self.stderr_output if self.use_stderr else self.stdout_output\n",
"VAR_26 = self.process_output(VAR_25, VAR_11, VAR_12)\n",
"if not self.use_stderr:\n",
"self._print_errors(self.stderr_output)\n",
"if VAR_21:\n",
"os.remove(VAR_21)\n",
"return VAR_26\n"
] | [
"import os\n",
"import re\n",
"import shutil\n",
"from subprocess import check_call, CalledProcessError, DEVNULL\n",
"import tempfile\n",
"from coalib.bears.Bear import Bear\n",
"from coalib.misc.Decorators import enforce_signature\n",
"from coalib.misc.Shell import escape_path_argument, run_shell_command\n",
"from coalib.results.Diff import Diff\n",
"from coalib.results.Result import Result\n",
"from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY\n",
"\"\"\"\n Deals with the creation of linting bears.\n\n For the tutorial see:\n http://coala.readthedocs.org/en/latest/Users/Tutorials/Linter_Bears.html\n\n :param executable: The executable to run the linter.\n :param prerequisite_command: The command to run as a prerequisite\n and is of type ``list``.\n :param prerequisites_fail_msg: The message to be displayed if the\n prerequisite fails.\n :param arguments: The arguments to supply to the linter,\n such that the file name to be analyzed\n can be appended to the end. Note that\n we use ``.format()`` on the arguments -\n so, ``{abc}`` needs to be given as\n ``{{abc}}``. Currently, the following\n will be replaced:\n\n - ``{filename}`` - The filename passed\n to ``lint()``\n - ``{config_file}`` - The config file\n created using ``config_file()``\n\n :param output_regex: The regex which will match the output of the linter\n to get results. This is not used if\n ``gives_corrected`` is set. This regex should give\n out the following variables:\n\n - line - The line where the issue starts.\n - column - The column where the issue starts.\n - end_line - The line where the issue ends.\n - end_column - The column where the issue ends.\n - severity - The severity of the issue.\n - message - The message of the result.\n - origin - The origin of the issue.\n\n :param diff_severity: The severity to use for all results if\n ``gives_corrected`` is set.\n :param diff_message: The message to use for all results if\n ``gives_corrected`` is set.\n :param use_stderr: Uses stderr as the output stream is it's True.\n :param use_stdin: Sends file as stdin instead of giving the file name.\n :param gives_corrected: True if the executable gives the corrected file\n or just the issues.\n :param severity_map: A dict where the keys are the possible severity\n values the Linter gives out and the values are the\n severity of the coala Result to set it to. If it is\n not a dict, it is ignored.\n \"\"\"\n",
"executable = None\n",
"prerequisite_command = None\n",
"prerequisite_fail_msg = 'Unknown failure.'\n",
"arguments = ''\n",
"output_regex = re.compile(\n '(?P<line>\\\\d+)\\\\.(?P<column>\\\\d+)\\\\|(?P<severity>\\\\d+): (?P<message>.*)')\n",
"diff_message = 'No result message was set'\n",
"diff_severity = RESULT_SEVERITY.NORMAL\n",
"use_stderr = False\n",
"use_stdin = False\n",
"gives_corrected = False\n",
"severity_map = None\n",
"def lint(self, filename=None, file=None):...\n",
"\"\"\"docstring\"\"\"\n",
"assert self.use_stdin and file is not None or not self.use_stdin and filename is not None\n",
"config_file = self.generate_config_file()\n",
"self.command = self._create_command(filename=filename, config_file=config_file)\n",
"stdin_input = ''.join(file) if self.use_stdin else None\n",
"stdout_output, stderr_output = run_shell_command(self.command, stdin=\n stdin_input)\n",
"self.stdout_output = tuple(stdout_output.splitlines(keepends=True))\n",
"self.stderr_output = tuple(stderr_output.splitlines(keepends=True))\n",
"results_output = self.stderr_output if self.use_stderr else self.stdout_output\n",
"results = self.process_output(results_output, filename, file)\n",
"if not self.use_stderr:\n",
"self._print_errors(self.stderr_output)\n",
"if config_file:\n",
"os.remove(config_file)\n",
"return results\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Docstring",
"Assert'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Return'"
] |
[
"def FUNC_7(VAR_8):...\n",
"VAR_11 = VAR_8.split('/')\n",
"if len(VAR_11) == 3:\n",
"VAR_15 = int(VAR_11[0])\n",
"if len(VAR_11) == 1:\n",
"VAR_2 = VAR_11[1]\n",
"VAR_15 = 1\n",
"return VAR_15, VAR_2, VAR_8\n",
"VAR_8 = VAR_11[2]\n",
"VAR_8 = VAR_11[0]\n",
"VAR_2 = 'service'\n"
] | [
"def _parse_username(username):...\n",
"username_arr = username.split('/')\n",
"if len(username_arr) == 3:\n",
"version = int(username_arr[0])\n",
"if len(username_arr) == 1:\n",
"user_type = username_arr[1]\n",
"version = 1\n",
"return version, user_type, username\n",
"username = username_arr[2]\n",
"username = username_arr[0]\n",
"user_type = 'service'\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_6():...\n",
"if not request.method in VAR_0:\n",
"return True\n",
"if not request.environ.get('AUTH_TYPE') == 'cookie':\n",
"return True\n",
"if config.get('skip_authentication'):\n",
"return True\n",
"if request.environ.get('HTTP_REFERER'):\n",
"VAR_7 = urlparse(request.environ.get('HTTP_REFERER'))\n",
"if request.method == 'GET' and FUNC_4():\n",
"VAR_8 = VAR_7.hostname\n",
"return True\n",
"return False\n",
"if VAR_7.port:\n",
"VAR_8 += ':' + str(VAR_7.port)\n",
"if VAR_8.endswith(request.environ['adhocracy.domain']):\n",
"if request.method != 'GET':\n",
"return True\n"
] | [
"def check():...\n",
"if not request.method in methods:\n",
"return True\n",
"if not request.environ.get('AUTH_TYPE') == 'cookie':\n",
"return True\n",
"if config.get('skip_authentication'):\n",
"return True\n",
"if request.environ.get('HTTP_REFERER'):\n",
"ref_url = urlparse(request.environ.get('HTTP_REFERER'))\n",
"if request.method == 'GET' and has_token():\n",
"ref_host = ref_url.hostname\n",
"return True\n",
"return False\n",
"if ref_url.port:\n",
"ref_host += ':' + str(ref_url.port)\n",
"if ref_host.endswith(request.environ['adhocracy.domain']):\n",
"if request.method != 'GET':\n",
"return True\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
5,
0,
0,
0,
0,
0,
0,
5,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Return'",
"Condition",
"AugAssign'",
"Condition",
"Condition",
"Return'"
] |
[
"def FUNC_0(VAR_0):...\n",
"\"\"\"docstring\"\"\"\n",
"if '<' in VAR_0:\n",
"FUNC_1(VAR_0)\n",
"if '>' in VAR_0:\n",
"FUNC_2(VAR_0)\n",
"if '>>' in VAR_0:\n",
"FUNC_3(VAR_0)\n"
] | [
"def IO_redirection(cmd):...\n",
"\"\"\"docstring\"\"\"\n",
"if '<' in cmd:\n",
"SetUpInputRedirect(cmd)\n",
"if '>' in cmd:\n",
"SetUpOutputRedirect(cmd)\n",
"if '>>' in cmd:\n",
"SetUpAppendRedirect(cmd)\n"
] | [
0,
0,
0,
6,
0,
6,
0,
6
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_15(self, VAR_65):...\n",
"if self.overwrite_workdir is None:\n",
"if not os.path.exists(VAR_65):\n",
"os.makedirs(VAR_65)\n",
"self._workdir = VAR_65\n",
"os.chdir(VAR_65)\n"
] | [
"def workdir(self, workdir):...\n",
"if self.overwrite_workdir is None:\n",
"if not os.path.exists(workdir):\n",
"os.makedirs(workdir)\n",
"self._workdir = workdir\n",
"os.chdir(workdir)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_9(self):...\n",
"VAR_1 = self.objects.dg.pk\n",
"VAR_2 = self.client.get(f'/datagroup/{VAR_1}/').content.decode('utf8')\n",
"self.assertIn('<th>Product</th>', VAR_2,\n 'Data Group should have Product column.')\n",
"VAR_9 = GroupType.objects.create(title='Functional use')\n",
"self.objects.dg.group_type = VAR_9\n",
"self.objects.dg.save()\n",
"VAR_2 = self.client.get(f'/datagroup/{VAR_1}/').content.decode('utf8')\n",
"self.assertNotIn('<th>Product</th>', VAR_2,\n 'Data Group should have Product column.')\n"
] | [
"def test_detail_table_headers(self):...\n",
"pk = self.objects.dg.pk\n",
"response = self.client.get(f'/datagroup/{pk}/').content.decode('utf8')\n",
"self.assertIn('<th>Product</th>', response,\n 'Data Group should have Product column.')\n",
"fu = GroupType.objects.create(title='Functional use')\n",
"self.objects.dg.group_type = fu\n",
"self.objects.dg.save()\n",
"response = self.client.get(f'/datagroup/{pk}/').content.decode('utf8')\n",
"self.assertNotIn('<th>Product</th>', response,\n 'Data Group should have Product column.')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_36(VAR_11):...\n",
"for VAR_51, VAR_58 in VAR_11.items():\n",
"if isinstance(VAR_58, str) or not isinstance(VAR_58, Iterable):\n",
"VAR_58 = [VAR_58]\n",
"yield [(VAR_51, VAR_16) for VAR_16 in VAR_58]\n"
] | [
"def flatten(wildcards):...\n",
"for wildcard, values in wildcards.items():\n",
"if isinstance(values, str) or not isinstance(values, Iterable):\n",
"values = [values]\n",
"yield [(wildcard, value) for value in values]\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Condition",
"Assign'",
"Expr'"
] |
[
"import logging\n",
"import traceback\n",
"from django.conf import settings\n",
"from django.core.mail import send_mail\n",
"from django.core.urlresolvers import reverse\n",
"VAR_0 = logging.getLogger('lib.email_messages')\n",
"def FUNC_0(VAR_1, VAR_2, VAR_3, VAR_4=True):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_5 = VAR_2.course_instance\n",
"if VAR_5.technical_error_emails:\n",
"VAR_9 = VAR_5.technical_error_emails.split(',')\n",
"VAR_9 = (p.user.email for p in VAR_5.course.teachers.all() if p.user.email)\n",
"VAR_6 = '-'\n",
"if VAR_4:\n",
"VAR_6 = traceback.format_exc()\n",
"VAR_7 = settings.EXERCISE_ERROR_SUBJECT.format(course=instance.course.code,\n VAR_2=str(exercise))\n",
"VAR_8 = settings.EXERCISE_ERROR_DESCRIPTION.format(VAR_3=message,\n exercise_url=request.build_absolute_uri(exercise.get_absolute_url()),\n course_edit_url=request.build_absolute_uri(instance.get_url(\n 'course-details')), VAR_6=error_trace, request_fields=repr(request))\n",
"if VAR_9:\n",
"send_mail(VAR_7, VAR_8, settings.SERVER_EMAIL, VAR_9, True)\n",
"VAR_0.exception('Failed to send error emails.')\n"
] | [
"import logging\n",
"import traceback\n",
"from django.conf import settings\n",
"from django.core.mail import send_mail\n",
"from django.core.urlresolvers import reverse\n",
"logger = logging.getLogger('lib.email_messages')\n",
"def email_course_error(request, exercise, message, exception=True):...\n",
"\"\"\"docstring\"\"\"\n",
"instance = exercise.course_instance\n",
"if instance.technical_error_emails:\n",
"recipients = instance.technical_error_emails.split(',')\n",
"recipients = (p.user.email for p in instance.course.teachers.all() if p.\n user.email)\n",
"error_trace = '-'\n",
"if exception:\n",
"error_trace = traceback.format_exc()\n",
"subject = settings.EXERCISE_ERROR_SUBJECT.format(course=instance.course.\n code, exercise=str(exercise))\n",
"body = settings.EXERCISE_ERROR_DESCRIPTION.format(message=message,\n exercise_url=request.build_absolute_uri(exercise.get_absolute_url()),\n course_edit_url=request.build_absolute_uri(instance.get_url(\n 'course-details')), error_trace=error_trace, request_fields=repr(request))\n",
"if recipients:\n",
"send_mail(subject, body, settings.SERVER_EMAIL, recipients, True)\n",
"logger.exception('Failed to send error emails.')\n"
] | [
0,
0,
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_0(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return len(self.nodes)\n"
] | [
"def vcount(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return len(self.nodes)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_5(VAR_4, *VAR_5, **VAR_6):...\n",
""
] | [
"def dummy_handler(remote, *args, **kargs):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_0(VAR_3):...\n",
"@functools.wraps(VAR_3)...\n",
"VAR_23 = VAR_5.pop('timeout', None)\n",
"VAR_24 = eventlet.spawn(VAR_3, self, *VAR_4, **kwargs)\n",
"if VAR_23 is None:\n",
"return VAR_24.wait()\n",
"VAR_36 = eventlet.spawn_after(VAR_23, VAR_24.kill)\n",
"VAR_48 = VAR_24.wait()\n",
"VAR_36.cancel()\n",
"return FUNC_1\n",
"return VAR_48\n"
] | [
"def with_timeout(f):...\n",
"@functools.wraps(f)...\n",
"timeout = kwargs.pop('timeout', None)\n",
"gt = eventlet.spawn(f, self, *args, **kwargs)\n",
"if timeout is None:\n",
"return gt.wait()\n",
"kill_thread = eventlet.spawn_after(timeout, gt.kill)\n",
"res = gt.wait()\n",
"kill_thread.cancel()\n",
"return __inner\n",
"return res\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Return'",
"Return'"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.