lines
sequencelengths
1
444
raw_lines
sequencelengths
1
444
label
sequencelengths
1
444
type
sequencelengths
1
444
[ "def FUNC_7(self, VAR_12, VAR_10='main', VAR_13=True):...\n", "\"\"\"docstring\"\"\"\n", "VAR_14, VAR_18, VAR_24, VAR_25 = VAR_12\n", "VAR_14, VAR_18, VAR_24 = VAR_12\n", "VAR_31 = 'string' % {'database': VAR_10}\n", "VAR_25 = 0\n", "VAR_32 = {'input_phrase': VAR_14, 'phrase': VAR_18}\n", "if self.db.execute(VAR_31, VAR_32).fetchall():\n", "return\n", "VAR_33 = 'string' % {'database': VAR_10}\n", "VAR_34 = {'mlen': len(VAR_14), 'clen': len(VAR_18), 'input_phrase': VAR_14,\n 'phrase': VAR_18, 'freq': VAR_24, 'user_freq': VAR_25}\n", "self.db.execute(VAR_33, VAR_34)\n", "import traceback\n", "if VAR_13:\n", "traceback.print_exc()\n", "self.db.commit()\n" ]
[ "def add_phrase(self, aphrase, database='main', commit=True):...\n", "\"\"\"docstring\"\"\"\n", "input_phrase, phrase, freq, user_freq = aphrase\n", "input_phrase, phrase, freq = aphrase\n", "select_sqlstr = (\n \"\"\"\n SELECT * FROM %(database)s.phrases\n WHERE input_phrase = :input_phrase AND phrase = :phrase\n ;\"\"\"\n % {'database': database})\n", "user_freq = 0\n", "select_sqlargs = {'input_phrase': input_phrase, 'phrase': phrase}\n", "if self.db.execute(select_sqlstr, select_sqlargs).fetchall():\n", "return\n", "insert_sqlstr = (\n \"\"\"\n INSERT INTO %(database)s.phrases\n (mlen, clen, input_phrase, phrase, freq, user_freq)\n VALUES ( :mlen, :clen, :input_phrase, :phrase, :freq, :user_freq)\n ;\"\"\"\n % {'database': database})\n", "insert_sqlargs = {'mlen': len(input_phrase), 'clen': len(phrase),\n 'input_phrase': input_phrase, 'phrase': phrase, 'freq': freq,\n 'user_freq': user_freq}\n", "self.db.execute(insert_sqlstr, insert_sqlargs)\n", "import traceback\n", "if commit:\n", "traceback.print_exc()\n", "self.db.commit()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "Expr'", "Import'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_8(self, VAR_13):...\n", "\"\"\"docstring\"\"\"\n", "return self.Command(bin_dir_path=os.path.join(self.yarnpkg_path, 'bin'),\n VAR_14='yarnpkg', VAR_13=args or [])\n" ]
[ "def yarnpkg_command(self, args):...\n", "\"\"\"docstring\"\"\"\n", "return self.Command(bin_dir_path=os.path.join(self.yarnpkg_path, 'bin'),\n executable='yarnpkg', args=args or [])\n" ]
[ 0, 0, 2 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_1(VAR_0):...\n", "return FUNC_0(VAR_0, [])\n" ]
[ "def home(request):...\n", "return make_view(request, [])\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "\"\"\"SchoolCMS announce handlers.\n\nhandlers.\n\"\"\"\n", "from __future__ import absolute_import\n", "from __future__ import print_function\n", "from __future__ import unicode_literals\n", "from . import BaseHandler\n", "from ..db import Announce, AnnTag, TempFileList, AttachmentList, Record, GroupList\n", "import os\n", "import shutil\n", "import re\n", "from markdown import markdown\n", "from bs4 import BeautifulSoup\n", "from datetime import datetime, timedelta\n", "from sqlalchemy import desc\n", "VAR_7\n", "VAR_7 = range\n", "def FUNC_0(VAR_0, VAR_1, VAR_2=None, VAR_3=None):...\n", "if not VAR_0.isdigit():\n", "return VAR_1\n", "VAR_5 = int(VAR_0)\n", "if VAR_2 != None and VAR_5 < VAR_2:\n", "return VAR_1\n", "if VAR_3 != None and VAR_5 > VAR_3:\n", "return VAR_1\n", "return VAR_5\n" ]
[ "\"\"\"SchoolCMS announce handlers.\n\nhandlers.\n\"\"\"\n", "from __future__ import absolute_import\n", "from __future__ import print_function\n", "from __future__ import unicode_literals\n", "from . import BaseHandler\n", "from ..db import Announce, AnnTag, TempFileList, AttachmentList, Record, GroupList\n", "import os\n", "import shutil\n", "import re\n", "from markdown import markdown\n", "from bs4 import BeautifulSoup\n", "from datetime import datetime, timedelta\n", "from sqlalchemy import desc\n", "xrange\n", "xrange = range\n", "def _to_int(s, default, mi=None, mx=None):...\n", "if not s.isdigit():\n", "return default\n", "_n = int(s)\n", "if mi != None and _n < mi:\n", "return default\n", "if mx != None and _n > mx:\n", "return default\n", "return _n\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Expr'", "Assign'", "FunctionDef'", "Condition", "Return'", "Assign'", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "import logging\n", "from odoo import fields, http, _\n", "from odoo.exceptions import ValidationError, UserError\n", "VAR_0 = logging.getLogger(__name__)\n", "@http.route(['/fit_subscribe_controller/subscribe'], type='http', auth=...\n", "VAR_1 = int(VAR_1)\n", "VAR_2 = VAR_2\n", "VAR_4 = http.request.env['event.event'].sudo().browse(VAR_1)\n", "VAR_6 = 0\n", "VAR_5 = http.request.env.user.partner_id\n", "VAR_7 = int(VAR_5.id)\n", "if VAR_2:\n", "for registration in VAR_4.registration_ids:\n", "VAR_16 = http.request.env['event.registration'].sudo().search([(\n 'partner_id', '=', VAR_7), ('event_id', '=', VAR_4.id)])\n", "for VAR_5 in registration.partner_id:\n", "VAR_8 = str(http.request.httprequest.headers.environ['HTTP_REFERER'])\n", "if VAR_16:\n", "VAR_0.error('Unable to register: ' + str(e))\n", "if VAR_5.id == VAR_7:\n", "VAR_9 = str('/' + VAR_8.split('/')[-1])\n", "if VAR_4.seats_available > 0 and VAR_4.seats_availability == u'limited':\n", "if VAR_4.seats_available > 0 and VAR_4.seats_availability == u'limited':\n", "VAR_0.info('Found existing registration, set state to cancelled.')\n", "return http.request.redirect(VAR_9)\n", "VAR_0.info('Found existing registration, set state to open (confirmed)')\n", "VAR_0.info('Found existing registration, no seats available')\n", "VAR_0.info('No registration found, create new one')\n", "VAR_0.info('No seats available')\n", "registration.state = 'cancel'\n", "VAR_16.state = 'open'\n", "http.request.env['event.registration'].sudo().create({'partner_id': VAR_7,\n 'event_id': VAR_1, 'name': VAR_5.name if VAR_5.name else '', 'phone': \n VAR_5.mobile if VAR_5.mobile else '', 'email': VAR_5.email if VAR_5.\n email else ''})\n", "VAR_6 += 1\n", "VAR_6 -= 1\n", "VAR_6 -= 1\n", "self._update_counter_subscription(VAR_4, VAR_5, VAR_6)\n", "self._update_counter_subscription(VAR_4, VAR_5, VAR_6)\n", "self._update_counter_subscription(VAR_4, VAR_5, VAR_6)\n" ]
[ "import logging\n", "from odoo import fields, http, _\n", "from odoo.exceptions import ValidationError, UserError\n", "_logger = logging.getLogger(__name__)\n", "@http.route(['/fit_subscribe_controller/subscribe'], type='http', auth=...\n", "event_id = int(event_id)\n", "event_is_participating = event_is_participating\n", "event = http.request.env['event.event'].sudo().browse(event_id)\n", "subscription_update_counter = 0\n", "partner = http.request.env.user.partner_id\n", "partner_id = int(partner.id)\n", "if event_is_participating:\n", "for registration in event.registration_ids:\n", "existing_registration = http.request.env['event.registration'].sudo().search([\n ('partner_id', '=', partner_id), ('event_id', '=', event.id)])\n", "for partner in registration.partner_id:\n", "referer = str(http.request.httprequest.headers.environ['HTTP_REFERER'])\n", "if existing_registration:\n", "_logger.error('Unable to register: ' + str(e))\n", "if partner.id == partner_id:\n", "redirect = str('/' + referer.split('/')[-1])\n", "if event.seats_available > 0 and event.seats_availability == u'limited':\n", "if event.seats_available > 0 and event.seats_availability == u'limited':\n", "_logger.info('Found existing registration, set state to cancelled.')\n", "return http.request.redirect(redirect)\n", "_logger.info('Found existing registration, set state to open (confirmed)')\n", "_logger.info('Found existing registration, no seats available')\n", "_logger.info('No registration found, create new one')\n", "_logger.info('No seats available')\n", "registration.state = 'cancel'\n", "existing_registration.state = 'open'\n", "http.request.env['event.registration'].sudo().create({'partner_id':\n partner_id, 'event_id': event_id, 'name': partner.name if partner.name else\n '', 'phone': partner.mobile if partner.mobile else '', 'email': partner\n .email if partner.email else ''})\n", "subscription_update_counter += 1\n", "subscription_update_counter -= 1\n", "subscription_update_counter -= 1\n", "self._update_counter_subscription(event, partner, subscription_update_counter)\n", "self._update_counter_subscription(event, partner, subscription_update_counter)\n", "self._update_counter_subscription(event, partner, subscription_update_counter)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "ImportFrom'", "ImportFrom'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "For", "Assign'", "For", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Condition", "Condition", "Expr'", "Return'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "AugAssign'", "AugAssign'", "AugAssign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_25(VAR_8):...\n", "VAR_27 = []\n", "for VAR_45 in VAR_8:\n", "VAR_27.append({'id': VAR_45.id, 'text': VAR_45.text})\n", "return VAR_27\n" ]
[ "def _select2_list(search_results):...\n", "select2_results = []\n", "for r in search_results:\n", "select2_results.append({'id': r.id, 'text': r.text})\n", "return select2_results\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Expr'", "Return'" ]
[ "def FUNC_7(self):...\n", "return self.content\n" ]
[ "def read(self):...\n", "return self.content\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@property...\n", "return self.dag.priority(self)\n" ]
[ "@property...\n", "return self.dag.priority(self)\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "from __future__ import absolute_import\n", "from __future__ import print_function\n", "from __future__ import unicode_literals\n", "import logging\n", "import os\n", "import random\n", "import re\n", "import tempfile\n", "from cms.grading.languagemanager import filename_to_language\n", "from cmscommon.crypto import decrypt_number\n", "from cmstestsuite.web import GenericRequest, LoginRequest\n", "VAR_0 = logging.getLogger(__name__)\n", "def FUNC_0(self):...\n", "if not LoginRequest.test_success(self):\n", "return False\n", "if self.redirected_to != self.base_url:\n", "return False\n", "return True\n" ]
[ "from __future__ import absolute_import\n", "from __future__ import print_function\n", "from __future__ import unicode_literals\n", "import logging\n", "import os\n", "import random\n", "import re\n", "import tempfile\n", "from cms.grading.languagemanager import filename_to_language\n", "from cmscommon.crypto import decrypt_number\n", "from cmstestsuite.web import GenericRequest, LoginRequest\n", "logger = logging.getLogger(__name__)\n", "def test_success(self):...\n", "if not LoginRequest.test_success(self):\n", "return False\n", "if self.redirected_to != self.base_url:\n", "return False\n", "return True\n" ]
[ 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'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "FunctionDef'", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "def FUNC_15(self):...\n", "\"\"\"docstring\"\"\"\n", "self.console.info('')\n", "if not self.node_list and not self.master.connected:\n", "self._exit(\n \"\"\"No nodes were detected, or nodes do not have sos installed.\nAborting...\"\"\"\n )\n", "self.console.info('The following is a list of nodes to collect from:')\n", "if self.master.connected:\n", "self.console.info('\\t%-*s' % (self.config['hostlen'], self.config['master']))\n", "for VAR_5 in sorted(self.node_list):\n", "self.console.info('\\t%-*s' % (self.config['hostlen'], VAR_5))\n", "self.console.info('')\n", "if not self.config['case_id'] and not self.config['batch']:\n", "VAR_1 = 'Please enter the case id you are collecting reports for: '\n", "self.config['case_id'] = input(VAR_1)\n" ]
[ "def intro(self):...\n", "\"\"\"docstring\"\"\"\n", "self.console.info('')\n", "if not self.node_list and not self.master.connected:\n", "self._exit(\n \"\"\"No nodes were detected, or nodes do not have sos installed.\nAborting...\"\"\"\n )\n", "self.console.info('The following is a list of nodes to collect from:')\n", "if self.master.connected:\n", "self.console.info('\\t%-*s' % (self.config['hostlen'], self.config['master']))\n", "for node in sorted(self.node_list):\n", "self.console.info('\\t%-*s' % (self.config['hostlen'], node))\n", "self.console.info('')\n", "if not self.config['case_id'] and not self.config['batch']:\n", "msg = 'Please enter the case id you are collecting reports for: '\n", "self.config['case_id'] = input(msg)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Condition", "Expr'", "Expr'", "Condition", "Expr'", "For", "Expr'", "Expr'", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_3(VAR_3, VAR_4):...\n", "\"\"\"docstring\"\"\"\n", "VAR_7 = \"\"\"\n SELECT name\n FROM pg_settings\n WHERE name = '%s'\n \"\"\"\n", "VAR_3.execute(VAR_7 % VAR_4)\n", "return VAR_3.rowcount > 0\n" ]
[ "def option_exists(cursor, option):...\n", "\"\"\"docstring\"\"\"\n", "query = \"\"\"\n SELECT name\n FROM pg_settings\n WHERE name = '%s'\n \"\"\"\n", "cursor.execute(query % option)\n", "return cursor.rowcount > 0\n" ]
[ 0, 0, 4, 0, 4 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_6(self, VAR_3):...\n", "if VAR_3 is not None:\n", "VAR_10 = [injection_.target for injection_ in injection.objects.filter(\n result=record.id)]\n", "VAR_10 = []\n", "for VAR_21 in range(len(VAR_10)):\n", "if VAR_10[VAR_21] is None:\n", "if len(VAR_10) > 0:\n", "VAR_10[VAR_21] = '-'\n", "return ', '.join(VAR_10)\n", "return '-'\n" ]
[ "def render_targets(self, record):...\n", "if record is not None:\n", "targets = [injection_.target for injection_ in injection.objects.filter(\n result=record.id)]\n", "targets = []\n", "for index in range(len(targets)):\n", "if targets[index] is None:\n", "if len(targets) > 0:\n", "targets[index] = '-'\n", "return ', '.join(targets)\n", "return '-'\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "For", "Condition", "Condition", "Assign'", "Return'", "Return'" ]
[ "def FUNC_24(self, VAR_16):...\n", "" ]
[ "def local_path(self, volume):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "import subprocess\n", "import shlex\n", "import os\n", "import signal\n", "from helper import path_dict, path_number_of_files, pdf_stats, pdf_date_format_to_datetime\n", "import json\n", "from functools import wraps\n", "from urllib.parse import urlparse\n", "from flask import Flask, render_template, flash, redirect, url_for, session, request, logging\n", "from flask_mysqldb import MySQL\n", "from wtforms import Form, StringField, TextAreaField, PasswordField, validators\n", "from passlib.hash import sha256_crypt\n", "import time\n", "VAR_0 = Flask(__name__)\n", "VAR_0.secret_key = 'Aj\"$7PE#>3AC6W]`STXYLz*[G\\\\gQWA'\n", "VAR_0.config['MYSQL_HOST'] = 'localhost'\n", "VAR_0.config['MYSQL_USER'] = 'root'\n", "VAR_0.config['MYSQL_PASSWORD'] = 'mountain'\n", "VAR_0.config['MYSQL_DB'] = 'bar'\n", "VAR_0.config['MYSQL_CURSORCLASS'] = 'DictCursor'\n", "VAR_1 = MySQL(VAR_0)\n", "VAR_2 = 'data'\n", "VAR_3 = 10\n", "VAR_4 = 60\n", "VAR_5 = 1000\n", "def FUNC_0(VAR_6):...\n", "@wraps(VAR_6)...\n", "if 'logged_in' in VAR_10:\n", "return VAR_6(*VAR_8, **kwargs)\n", "flash('Unauthorized, Please login', 'danger')\n", "return redirect(url_for('login'))\n" ]
[ "import subprocess\n", "import shlex\n", "import os\n", "import signal\n", "from helper import path_dict, path_number_of_files, pdf_stats, pdf_date_format_to_datetime\n", "import json\n", "from functools import wraps\n", "from urllib.parse import urlparse\n", "from flask import Flask, render_template, flash, redirect, url_for, session, request, logging\n", "from flask_mysqldb import MySQL\n", "from wtforms import Form, StringField, TextAreaField, PasswordField, validators\n", "from passlib.hash import sha256_crypt\n", "import time\n", "app = Flask(__name__)\n", "app.secret_key = 'Aj\"$7PE#>3AC6W]`STXYLz*[G\\\\gQWA'\n", "app.config['MYSQL_HOST'] = 'localhost'\n", "app.config['MYSQL_USER'] = 'root'\n", "app.config['MYSQL_PASSWORD'] = 'mountain'\n", "app.config['MYSQL_DB'] = 'bar'\n", "app.config['MYSQL_CURSORCLASS'] = 'DictCursor'\n", "mysql = MySQL(app)\n", "WGET_DATA_PATH = 'data'\n", "PDF_TO_PROCESS = 10\n", "MAX_CRAWLING_DURATION = 60\n", "WAIT_AFTER_CRAWLING = 1000\n", "def is_logged_in(f):...\n", "@wraps(f)...\n", "if 'logged_in' in session:\n", "return f(*args, **kwargs)\n", "flash('Unauthorized, Please login', 'danger')\n", "return redirect(url_for('login'))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Condition", "Condition", "Return'", "Expr'", "Return'" ]
[ "@mock.patch('requests.post', FUNC_0)...\n", "\"\"\"docstring\"\"\"\n", "VAR_11 = self.test_release()\n", "VAR_15 = Release.objects.get(uuid=release3['uuid'])\n", "self.assertIn('autotest deployed ', VAR_15.summary)\n" ]
[ "@mock.patch('requests.post', mock_import_repository_task)...\n", "\"\"\"docstring\"\"\"\n", "release3 = self.test_release()\n", "release = Release.objects.get(uuid=release3['uuid'])\n", "self.assertIn('autotest deployed ', release.summary)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Expr'" ]
[ "def __init__(self, VAR_37=None, VAR_38=None, VAR_39=False):...\n", "\"\"\"docstring\"\"\"\n", "list.__init__(self)\n", "self._names = dict()\n", "if VAR_37:\n", "self.extend(map(str, VAR_37) if VAR_39 else VAR_37)\n", "if VAR_38:\n", "if isinstance(VAR_37, CLASS_2):\n", "for VAR_44, item in VAR_38.items():\n", "self.take_names(VAR_37.get_names())\n", "self.append(item)\n", "self.add_name(VAR_44)\n" ]
[ "def __init__(self, toclone=None, fromdict=None, plainstr=False):...\n", "\"\"\"docstring\"\"\"\n", "list.__init__(self)\n", "self._names = dict()\n", "if toclone:\n", "self.extend(map(str, toclone) if plainstr else toclone)\n", "if fromdict:\n", "if isinstance(toclone, Namedlist):\n", "for key, item in fromdict.items():\n", "self.take_names(toclone.get_names())\n", "self.append(item)\n", "self.add_name(key)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Condition", "Expr'", "Condition", "Condition", "For", "Expr'", "Expr'", "Expr'" ]
[ "def __exit__(self, VAR_15, VAR_16, VAR_17):...\n", "VAR_33 = self._transactions.pop()\n", "if VAR_15 is None:\n", "VAR_33.commit()\n", "VAR_33.rollback()\n" ]
[ "def __exit__(self, type, value, traceback):...\n", "transaction = self._transactions.pop()\n", "if type is None:\n", "transaction.commit()\n", "transaction.rollback()\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_4(self):...\n", "VAR_59 = defer.Deferred()\n", "self.account = IMAPAccount(self._user_id, self.soledad, VAR_59)\n", "return VAR_59\n" ]
[ "def _initialize_imap_account(self):...\n", "account_ready_cb = defer.Deferred()\n", "self.account = IMAPAccount(self._user_id, self.soledad, account_ready_cb)\n", "return account_ready_cb\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Return'" ]
[ "import logging\n", "from datetime import datetime\n", "from dateutil.relativedelta import relativedelta\n", "from odoo import fields, models\n", "VAR_0 = logging.getLogger(__name__)\n", "VAR_1 = 'res.partner'\n", "VAR_2 = ['res.partner']\n", "VAR_3 = fields.One2many(comodel_name='fit.subscription', inverse_name=\n 'subscription_partner', string='Inschrijving', store='True')\n", "VAR_4 = fields.Integer('# Inschrijvingen', compute=\n '_compute_total_scubscriptions')\n", "def FUNC_0(self):...\n", "VAR_6 = 0\n", "for subscription in self.fit_subscriptions:\n", "VAR_6 += 1\n", "self.fit_subscription_count = VAR_6\n", "def FUNC_1(self, VAR_5):...\n", "VAR_7 = False\n", "VAR_8 = str(VAR_5.event_type_id.name).lower()\n", "VAR_9 = datetime.strptime(VAR_5.date_begin, '%Y-%m-%d %H:%M:%S')\n", "if VAR_8 == 'open' and len(self.fit_subscriptions) > 0:\n", "VAR_0.info('Can subscribe for open event id: %s, name: %s', VAR_5.\n event_type_id.name, VAR_5.name)\n", "if VAR_9 < datetime.now():\n", "return True\n", "return False\n", "if VAR_9 + relativedelta(hours=-24) > datetime.now(\n", "return False\n", "for subscription in self.fit_subscriptions:\n", "if subscription._can_subscribe(VAR_5.event_type_id):\n", "return VAR_7\n", "VAR_0.info('Can subscribe for event id: %s, name: %s', VAR_5.event_type_id.\n name, VAR_5.name)\n", "VAR_7 = True\n" ]
[ "import logging\n", "from datetime import datetime\n", "from dateutil.relativedelta import relativedelta\n", "from odoo import fields, models\n", "_logger = logging.getLogger(__name__)\n", "_name = 'res.partner'\n", "_inherit = ['res.partner']\n", "fit_subscriptions = fields.One2many(comodel_name='fit.subscription',\n inverse_name='subscription_partner', string='Inschrijving', store='True')\n", "fit_subscription_count = fields.Integer('# Inschrijvingen', compute=\n '_compute_total_scubscriptions')\n", "def _compute_total_scubscriptions(self):...\n", "counter = 0\n", "for subscription in self.fit_subscriptions:\n", "counter += 1\n", "self.fit_subscription_count = counter\n", "def can_subscribe(self, event):...\n", "can_subscribe = False\n", "event_type = str(event.event_type_id.name).lower()\n", "event_start = datetime.strptime(event.date_begin, '%Y-%m-%d %H:%M:%S')\n", "if event_type == 'open' and len(self.fit_subscriptions) > 0:\n", "_logger.info('Can subscribe for open event id: %s, name: %s', event.\n event_type_id.name, event.name)\n", "if event_start < datetime.now():\n", "return True\n", "return False\n", "if event_start + relativedelta(hours=-24) > datetime.now(\n", "return False\n", "for subscription in self.fit_subscriptions:\n", "if subscription._can_subscribe(event.event_type_id):\n", "return can_subscribe\n", "_logger.info('Can subscribe for event id: %s, name: %s', event.\n event_type_id.name, event.name)\n", "can_subscribe = True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Assign'", "For", "AugAssign'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Return'", "Return'", "Condition", "Return'", "For", "Condition", "Return'", "Expr'", "Assign'" ]
[ "def FUNC_8(VAR_17):...\n", "if VAR_17 != -1:\n", "VAR_24 = CLASS_0(self.sorted_menu[VAR_17][2])\n", "VAR_25 = self.window.open_file(self.sorted_menu[VAR_17][2])\n" ]
[ "def open_the_file(index):...\n", "if index != -1:\n", "urtext_file = UrtextFile(self.sorted_menu[index][2])\n", "new_view = self.window.open_file(self.sorted_menu[index][2])\n" ]
[ 0, 0, 1, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'" ]
[ "def __enter__(self):...\n", "\"\"\"docstring\"\"\"\n", "self.start_time = time.time()\n", "return self\n" ]
[ "def __enter__(self):...\n", "\"\"\"docstring\"\"\"\n", "self.start_time = time.time()\n", "return self\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Return'" ]
[ "def FUNC_6(self, VAR_74):...\n", "if VAR_74 and (not self.domain_re.match(VAR_74) or VAR_74.endswith(\n", "VAR_101.errors.add(errors.BAD_CNAME)\n", "if VAR_74:\n", "return VAR_100(VAR_74).lower()\n", "VAR_101.errors.add(errors.BAD_CNAME)\n" ]
[ "def run(self, domain):...\n", "if domain and (not self.domain_re.match(domain) or domain.endswith(\n", "c.errors.add(errors.BAD_CNAME)\n", "if domain:\n", "return str(domain).lower()\n", "c.errors.add(errors.BAD_CNAME)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Condition", "Return'", "Expr'" ]
[ "@app.route('/api/images/<type>/<image>/ready', methods=['GET'])...\n", "if FUNC_34(VAR_11).lookup(VAR_12, file_required=False).is_ready():\n", "return {'ready': True}\n" ]
[ "@app.route('/api/images/<type>/<image>/ready', methods=['GET'])...\n", "if get_image_database(type).lookup(image, file_required=False).is_ready():\n", "return {'ready': True}\n" ]
[ 0, 0, 0 ]
[ "Condition", "Condition", "Return'" ]
[ "\"\"\"string\"\"\"\n", "from collections import defaultdict\n", "from everest.repositories.memory.querying import MemoryQuery\n", "from everest.repositories.state import EntityStateManager\n", "from itertools import islice\n", "from weakref import WeakValueDictionary\n", "__docformat__ = 'reStructuredText en'\n", "__all__ = ['EntityCache', 'EntityCacheMap']\n", "\"\"\"string\"\"\"\n", "def __init__(self, VAR_0=None, VAR_1=True):...\n", "\"\"\"docstring\"\"\"\n", "self.__allow_none_id = VAR_1\n", "if VAR_0 is None:\n", "VAR_0 = []\n", "self.__entities = VAR_0\n", "self.__id_map = WeakValueDictionary()\n", "self.__slug_map = WeakValueDictionary()\n", "def FUNC_0(self, VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "return self.__id_map.get(VAR_2)\n" ]
[ "\"\"\"\nEntity cache and cache map.\n\nThis file is part of the everest project.\nSee LICENSE.txt for licensing, CONTRIBUTORS.txt for contributor information.\n\nCreated on Feb 26, 2013.\n\"\"\"\n", "from collections import defaultdict\n", "from everest.repositories.memory.querying import MemoryQuery\n", "from everest.repositories.state import EntityStateManager\n", "from itertools import islice\n", "from weakref import WeakValueDictionary\n", "__docformat__ = 'reStructuredText en'\n", "__all__ = ['EntityCache', 'EntityCacheMap']\n", "\"\"\"\n Cache for entities.\n\n Supports add and remove operations as well as lookup by ID and\n by slug.\n \"\"\"\n", "def __init__(self, entities=None, allow_none_id=True):...\n", "\"\"\"docstring\"\"\"\n", "self.__allow_none_id = allow_none_id\n", "if entities is None:\n", "entities = []\n", "self.__entities = entities\n", "self.__id_map = WeakValueDictionary()\n", "self.__slug_map = WeakValueDictionary()\n", "def get_by_id(self, entity_id):...\n", "\"\"\"docstring\"\"\"\n", "return self.__id_map.get(entity_id)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Expr'", "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Docstring", "Return'" ]
[ "def __repr__(self):...\n", "return u'Nested({})'.format(repr(self.nested_columns))\n" ]
[ "def __repr__(self):...\n", "return u'Nested({})'.format(repr(self.nested_columns))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_3(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_5 = self.bindings['TEST_AWS_REGION']\n", "VAR_9 = self.agent.type_to_payload('deleteAmazonLoadBalancerDescription', {\n 'credentials': self.bindings['AWS_CREDENTIALS'], 'regions': [VAR_5],\n 'loadBalancerName': self.__use_lb_name})\n", "VAR_10 = aws.AwsContractBuilder(self.aws_observer)\n", "VAR_10.new_clause_builder('Load Balancer Removed').collect_resources(aws_module\n ='elb', command='describe-load-balancers', args=[\n '--load-balancer-names', self.__use_lb_name], no_resources_ok=True\n ).excludes_path_value('LoadBalancerName', self.__use_lb_name)\n", "return st.OperationContract(self.new_post_operation(title=\n 'delete_amazon_load_balancer', data=payload, path='ops'), contract=\n builder.build())\n" ]
[ "def delete_load_balancer(self):...\n", "\"\"\"docstring\"\"\"\n", "region = self.bindings['TEST_AWS_REGION']\n", "payload = self.agent.type_to_payload('deleteAmazonLoadBalancerDescription',\n {'credentials': self.bindings['AWS_CREDENTIALS'], 'regions': [region],\n 'loadBalancerName': self.__use_lb_name})\n", "builder = aws.AwsContractBuilder(self.aws_observer)\n", "builder.new_clause_builder('Load Balancer Removed').collect_resources(\n aws_module='elb', command='describe-load-balancers', args=[\n '--load-balancer-names', self.__use_lb_name], no_resources_ok=True\n ).excludes_path_value('LoadBalancerName', self.__use_lb_name)\n", "return st.OperationContract(self.new_post_operation(title=\n 'delete_amazon_load_balancer', data=payload, path='ops'), contract=\n builder.build())\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "VAR_28 = None\n", "VAR_29 = requests.post('https://api.dropbox.com/1/metadata/link', VAR_28=\n dict(link=DROPBOX_FOLDER_LINK, client_id=DROPBOX_APP_KEY, client_secret\n =DROPBOX_SECRET_KEY, path=filepath), timeout=5)\n", "if VAR_29.ok:\n", "VAR_29 = json.loads(VAR_29.content.decode())['link'].split('?')[0] + '?dl=1'\n", "VAR_28 = None\n", "VAR_29 = requests.get(VAR_29, timeout=5)\n", "VAR_28 = None\n", "return VAR_28\n", "if VAR_29.ok:\n", "VAR_28 = VAR_29.content\n" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "data = None\n", "req = requests.post('https://api.dropbox.com/1/metadata/link', data=dict(\n link=DROPBOX_FOLDER_LINK, client_id=DROPBOX_APP_KEY, client_secret=\n DROPBOX_SECRET_KEY, path=filepath), timeout=5)\n", "if req.ok:\n", "req = json.loads(req.content.decode())['link'].split('?')[0] + '?dl=1'\n", "data = None\n", "req = requests.get(req, timeout=5)\n", "data = None\n", "return data\n", "if req.ok:\n", "data = req.content\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Return'", "Condition", "Assign'" ]
[ "@integration_synonym_api...\n", "FUNC_2(VAR_2)\n", "FUNC_3(VAR_2, 'PHEEL', VAR_7='1')\n", "FUNC_5(VAR_4, VAR_5, VAR_11='FEEL', VAR_10=[{'name': '----FEEL'}, {'name':\n 'PHEEL'}])\n" ]
[ "@integration_synonym_api...\n", "clean_database(solr)\n", "seed_database_with(solr, 'PHEEL', id='1')\n", "verify_results(client, jwt, query='FEEL', expected=[{'name': '----FEEL'}, {\n 'name': 'PHEEL'}])\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_23(self):...\n", "\"\"\"docstring\"\"\"\n", "if self.local:\n", "return True\n", "self.client.close()\n", "self.log_error('Error closing SSH session: %s' % VAR_68)\n", "self.connected = False\n", "return False\n", "return True\n" ]
[ "def close_ssh_session(self):...\n", "\"\"\"docstring\"\"\"\n", "if self.local:\n", "return True\n", "self.client.close()\n", "self.log_error('Error closing SSH session: %s' % e)\n", "self.connected = False\n", "return False\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Expr'", "Expr'", "Assign'", "Return'", "Return'" ]
[ "@VAR_0.before_request...\n", "g.user = None\n", "if 'username' in VAR_19:\n", "g.user = VAR_19['username']\n" ]
[ "@app.before_request...\n", "g.user = None\n", "if 'username' in session:\n", "g.user = session['username']\n" ]
[ 0, 0, 0, 0 ]
[ "For", "Assign'", "Condition", "Assign'" ]
[ "def FUNC_11():...\n", "\"\"\"docstring\"\"\"\n", "if os.path.isfile(VAR_0):\n", "VAR_22 = yaml.load(goals_file)\n", "click.echo(\n 'There are no goals set. Set a new goal by entering \"yoda goals new\"')\n", "if len(VAR_22):\n", "VAR_22['entries'].sort(key=lambda x: x['deadline'].split('-'))\n", "click.echo(\n 'There are no goals set. Set a new goal by entering \"yoda goals new\"')\n", "click.echo('Goals')\n", "click.echo('----------------')\n", "click.echo('Status | Deadline | Name: text')\n", "click.echo('-------|-------------|---------------')\n", "VAR_30 = 0\n", "VAR_31 = 0\n", "VAR_32 = 0\n", "for entry in VAR_22['entries']:\n", "VAR_31 += 1\n", "click.echo('----------------')\n", "VAR_30 += 1 if entry['status'] == 0 else 0\n", "click.echo('')\n", "VAR_23 = entry['deadline']\n", "click.echo('Summary:')\n", "VAR_35 = entry['name']\n", "click.echo('----------------')\n", "VAR_2 = entry['text'] if entry['status'] == 0 else FUNC_0(entry['text'])\n", "if VAR_30 == 0:\n", "VAR_36 = 'O' if entry['status'] == 0 else 'X'\n", "click.echo(chalk.green(\n 'All goals have been completed! Set a new goal by entering \"yoda goals new\"'\n ))\n", "click.echo(chalk.red('Incomplete tasks: ' + str(VAR_30)))\n", "VAR_37 = datetime.datetime.strptime(VAR_23, '%Y-%m-%d')\n", "click.echo(chalk.red('Tasks with missed deadline: ' + str(VAR_32)))\n", "VAR_14 = datetime.datetime.now()\n", "click.echo(chalk.green('Completed tasks: ' + str(VAR_31 - VAR_30)))\n", "VAR_32 += 1 if VAR_37 < VAR_14 else 0\n", "click.echo(' ' + VAR_36 + ' | ' + VAR_23 + ' | #' + VAR_35 + ': ' + VAR_2)\n" ]
[ "def list_goals():...\n", "\"\"\"docstring\"\"\"\n", "if os.path.isfile(GOALS_CONFIG_FILE_PATH):\n", "contents = yaml.load(goals_file)\n", "click.echo(\n 'There are no goals set. Set a new goal by entering \"yoda goals new\"')\n", "if len(contents):\n", "contents['entries'].sort(key=lambda x: x['deadline'].split('-'))\n", "click.echo(\n 'There are no goals set. Set a new goal by entering \"yoda goals new\"')\n", "click.echo('Goals')\n", "click.echo('----------------')\n", "click.echo('Status | Deadline | Name: text')\n", "click.echo('-------|-------------|---------------')\n", "incomplete_goals = 0\n", "total_tasks = 0\n", "total_missed_deadline = 0\n", "for entry in contents['entries']:\n", "total_tasks += 1\n", "click.echo('----------------')\n", "incomplete_goals += 1 if entry['status'] == 0 else 0\n", "click.echo('')\n", "deadline = entry['deadline']\n", "click.echo('Summary:')\n", "name = entry['name']\n", "click.echo('----------------')\n", "text = entry['text'] if entry['status'] == 0 else strike(entry['text'])\n", "if incomplete_goals == 0:\n", "status = 'O' if entry['status'] == 0 else 'X'\n", "click.echo(chalk.green(\n 'All goals have been completed! Set a new goal by entering \"yoda goals new\"'\n ))\n", "click.echo(chalk.red('Incomplete tasks: ' + str(incomplete_goals)))\n", "deadline_time = datetime.datetime.strptime(deadline, '%Y-%m-%d')\n", "click.echo(chalk.red('Tasks with missed deadline: ' + str(\n total_missed_deadline)))\n", "now = datetime.datetime.now()\n", "click.echo(chalk.green('Completed tasks: ' + str(total_tasks -\n incomplete_goals)))\n", "total_missed_deadline += 1 if deadline_time < now else 0\n", "click.echo(' ' + status + ' | ' + deadline + ' | #' + name + ': ' + text)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'", "Expr'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "For", "AugAssign'", "Expr'", "AugAssign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "AugAssign'", "Expr'" ]
[ "def FUNC_6(self, VAR_41):...\n", "if VAR_41:\n", "VAR_95 = Thing._by_fullname(VAR_41, False, data=True)\n", "abort(403, 'forbidden')\n", "if isinstance(VAR_95, Message):\n", "return VAR_95\n", "VAR_52 = VAR_95.subreddit_slow\n", "if VAR_101.user_is_loggedin and VAR_52.can_comment(VAR_101.user):\n", "return VAR_95\n" ]
[ "def run(self, fullname):...\n", "if fullname:\n", "parent = Thing._by_fullname(fullname, False, data=True)\n", "abort(403, 'forbidden')\n", "if isinstance(parent, Message):\n", "return parent\n", "sr = parent.subreddit_slow\n", "if c.user_is_loggedin and sr.can_comment(c.user):\n", "return parent\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Expr'", "Condition", "Return'", "Assign'", "Condition", "Return'" ]
[ "def FUNC_20(VAR_8):...\n", "\"\"\"docstring\"\"\"\n", "VAR_8 = os.path.normpath(VAR_8)\n", "VAR_33 = re.search('{[^{]', VAR_8)\n", "VAR_34 = os.path.dirname(VAR_8[:VAR_33.start()]\n ) if VAR_33 else os.path.dirname(VAR_8)\n", "if not VAR_34:\n", "VAR_34 = '.'\n", "VAR_35 = [VAR_29.group('name') for VAR_29 in VAR_5.finditer(VAR_8)]\n", "VAR_36 = namedtuple('Wildcards', VAR_35)\n", "VAR_11 = VAR_36(*[list() for VAR_40 in VAR_35])\n", "VAR_8 = re.compile(FUNC_8(VAR_8))\n", "for dirpath, dirnames, filenames in os.walk(VAR_34):\n", "for VAR_0 in chain(filenames, dirnames):\n", "return VAR_11\n", "if dirpath != '.':\n", "VAR_0 = os.path.join(dirpath, VAR_0)\n", "VAR_29 = re.match(VAR_8, VAR_0)\n", "if VAR_29:\n", "for VAR_40, VAR_16 in VAR_29.groupdict().items():\n", "getattr(VAR_11, VAR_40).append(VAR_16)\n" ]
[ "def glob_wildcards(pattern):...\n", "\"\"\"docstring\"\"\"\n", "pattern = os.path.normpath(pattern)\n", "first_wildcard = re.search('{[^{]', pattern)\n", "dirname = os.path.dirname(pattern[:first_wildcard.start()]\n ) if first_wildcard else os.path.dirname(pattern)\n", "if not dirname:\n", "dirname = '.'\n", "names = [match.group('name') for match in _wildcard_regex.finditer(pattern)]\n", "Wildcards = namedtuple('Wildcards', names)\n", "wildcards = Wildcards(*[list() for name in names])\n", "pattern = re.compile(regex(pattern))\n", "for dirpath, dirnames, filenames in os.walk(dirname):\n", "for f in chain(filenames, dirnames):\n", "return wildcards\n", "if dirpath != '.':\n", "f = os.path.join(dirpath, f)\n", "match = re.match(pattern, f)\n", "if match:\n", "for name, value in match.groupdict().items():\n", "getattr(wildcards, name).append(value)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "For", "Return'", "Condition", "Assign'", "Assign'", "Condition", "For", "Expr'" ]
[ "def FUNC_14(self, VAR_10, VAR_11):...\n", "VAR_24 = self.common._cli_run('createhost -add %s %s' % (VAR_10, ' '.join(\n VAR_11)), None)\n" ]
[ "def _modify_3par_fibrechan_host(self, hostname, wwn):...\n", "out = self.common._cli_run('createhost -add %s %s' % (hostname, ' '.join(\n wwn)), None)\n" ]
[ 0, 2 ]
[ "FunctionDef'", "Assign'" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self._webui_url\n" ]
[ "@property...\n", "\"\"\"docstring\"\"\"\n", "return self._webui_url\n" ]
[ 0, 0, 0 ]
[ "Condition", "Docstring", "Return'" ]
[ "@mock.patch('requests.post', FUNC_0)...\n", "\"\"\"docstring\"\"\"\n", "VAR_11 = self.test_release()\n", "VAR_15 = Release.objects.get(uuid=release3['uuid'])\n", "self.assertEqual(str(VAR_15), '{}-v3'.format(VAR_11['app']))\n" ]
[ "@mock.patch('requests.post', mock_import_repository_task)...\n", "\"\"\"docstring\"\"\"\n", "release3 = self.test_release()\n", "release = Release.objects.get(uuid=release3['uuid'])\n", "self.assertEqual(str(release), '{}-v3'.format(release3['app']))\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Expr'" ]
[ "from tkinter import *\n", "from addRecipe import AddARecipe\n", "from tkinter import messagebox\n", "import datetime\n", "from mealPlan import MakeMealPlan\n", "from PIL import Image, ImageTk\n", "import sqlite3\n", "VAR_0 = 'Trebuchet MS', 24\n", "VAR_1 = 'Trebuchet MS', 12\n", "VAR_2 = []\n", "def __init__(self, VAR_3, VAR_4):...\n", "Frame.__init__(self, VAR_3)\n", "VAR_5 = Frame(self, bg='#f8f8f8')\n", "VAR_6 = Frame(self, bg='#e7e7e7')\n", "VAR_7 = Frame(self, bg='#f8f8f8')\n", "VAR_7.pack(expand=True, fill='both')\n", "Label(VAR_7, text=\"Trisha's Meal Planner\", font=LARGE_FONT, bg='#f8f8f8',\n fg='#000000').pack(fill='both', pady=20)\n", "VAR_8 = Image.open('recipe_card.jpg')\n", "VAR_9 = ImageTk.PhotoImage(VAR_8)\n", "VAR_10 = Label(VAR_7, image=render, bg='#f8f8f8')\n", "VAR_10.image = VAR_9\n", "VAR_10.pack(fill='both', pady=40)\n", "Button(VAR_7, text='Add A Recipe', highlightbackground='#f8f8f8', command=\n lambda : controller.show_frame(AddARecipe)).pack(fill=Y)\n", "Button(VAR_7, text='Make a Meal Plan', highlightbackground='#f8f8f8',\n command=lambda : controller.show_frame(MakeMealPlan)).pack(fill=Y)\n", "Button(VAR_7, text='View Recipes', highlightbackground='#f8f8f8', command=\n lambda : view_recipes()).pack(fill=Y)\n", "def FUNC_0():...\n", "VAR_7.pack_forget()\n", "VAR_5.pack(expand=True, fill='both')\n", "VAR_12 = 'meal_planner.db'\n", "VAR_20 = conn.cursor()\n", "VAR_21 = VAR_20.execute('SELECT * FROM recipe')\n", "for result in [VAR_21]:\n", "for row in result.fetchall():\n", "conn.close()\n", "VAR_24 = row[0]\n", "for i in range(len(VAR_2)):\n", "VAR_2.append(VAR_24)\n", "VAR_13 = Label(VAR_5, font=MEDIUM_FONT, bg='#f8f8f8', fg='#000000', text=\n recipeNames[i])\n", "def FUNC_1(VAR_11):...\n", "VAR_13.pack()\n", "VAR_5.pack_forget()\n", "VAR_13.bind('<Button-1>', lambda event, x=VAR_2[i]: [FUNC_1(x), VAR_5.\n pack_forget()])\n", "VAR_12 = 'meal_planner.db'\n", "VAR_6.pack(fill='both')\n", "VAR_8 = Image.open('home.jpg')\n", "VAR_9 = ImageTk.PhotoImage(VAR_8)\n", "VAR_10 = Button(VAR_6, image=render, borderwidth=0, highlightthickness=0,\n highlightbackground='#e7e7e7', command=lambda : [frame.pack(expand=True,\n fill='both'), menuFrame.pack_forget(), viewDetailsFrame.pack_forget()])\n", "VAR_10.image = VAR_9\n", "VAR_10.pack(side=LEFT)\n", "VAR_13 = Label(VAR_6, text='View Recipe', font=LARGE_FONT, bg='#e7e7e7', fg\n ='#272822')\n", "VAR_13.pack(side=LEFT, padx=300)\n", "VAR_14 = Frame(self, bg='#f8f8f8')\n", "VAR_14.pack(expand=True, fill='both')\n", "VAR_20 = conn.cursor()\n", "VAR_21 = VAR_20.execute('SELECT * FROM recipe WHERE name = ' + '\"' + VAR_11 +\n '\"')\n", "for result in [VAR_21]:\n", "for row in result.fetchall():\n", "VAR_22 = (\n \"\"\"Name: {} \n Cook time: {} \n Number of Servings: {} \n Ingredients: {} \n Directions: {}\"\"\"\n .format(VAR_24, VAR_25, VAR_26, VAR_28, VAR_29))\n", "VAR_24 = row[0]\n", "Label(VAR_14, text=string, font=MEDIUM_FONT, bg='#f8f8f8', fg='#000000').pack(\n side=LEFT)\n", "VAR_25 = row[1]\n", "conn.close()\n", "VAR_26 = row[2]\n", "Button(VAR_6, text='Delete', highlightbackground='#e7e7e7', command=lambda :\n delete_recipe(name)).pack(side=RIGHT)\n", "VAR_27 = row[3]\n", "def FUNC_2(VAR_11):...\n", "VAR_28 = row[4]\n", "VAR_12 = 'meal_planner.db'\n", "VAR_29 = row[5]\n", "VAR_15 = datetime.datetime.now()\n", "VAR_16 = datetime.date(VAR_15.year, VAR_15.month, VAR_15.day)\n", "VAR_17 = VAR_16.isocalendar()[1]\n", "VAR_18 = 'recipes_' + str(VAR_17)\n", "VAR_20 = conn.cursor()\n", "VAR_20.execute('SELECT recipe FROM ' + VAR_18 + ' WHERE recipe = ' + '\"' +\n VAR_11 + '\"')\n", "VAR_23 = VAR_20.fetchone()\n", "if VAR_23:\n", "print(VAR_23[0])\n", "FUNC_3(VAR_11)\n", "messagebox.showerror('Cannot Delete',\n \"Cannot delete recipe when it's used in the current week's menu.\")\n", "def FUNC_3(VAR_11):...\n", "VAR_19 = '\"' + VAR_11 + '\"'\n", "VAR_20 = conn.cursor()\n", "VAR_20.execute('DELETE FROM recipe WHERE name = ' + '\"' + VAR_11 + '\"')\n", "print(VAR_20.rowcount)\n", "if VAR_20.rowcount == 1:\n", "messagebox.showinfo('Success', 'Recipe Deleted.')\n", "if VAR_20.rowcount == 0:\n", "VAR_6.pack_forget()\n", "messagebox.showerror('Cannot Delete', 'Cannot delete recipe, please try again.'\n )\n", "conn.close()\n", "VAR_5.pack(expand=True, fill='both')\n" ]
[ "from tkinter import *\n", "from addRecipe import AddARecipe\n", "from tkinter import messagebox\n", "import datetime\n", "from mealPlan import MakeMealPlan\n", "from PIL import Image, ImageTk\n", "import sqlite3\n", "LARGE_FONT = 'Trebuchet MS', 24\n", "MEDIUM_FONT = 'Trebuchet MS', 12\n", "recipeNames = []\n", "def __init__(self, parent, controller):...\n", "Frame.__init__(self, parent)\n", "viewRecipeFrame = Frame(self, bg='#f8f8f8')\n", "menuFrame = Frame(self, bg='#e7e7e7')\n", "frame = Frame(self, bg='#f8f8f8')\n", "frame.pack(expand=True, fill='both')\n", "Label(frame, text=\"Trisha's Meal Planner\", font=LARGE_FONT, bg='#f8f8f8',\n fg='#000000').pack(fill='both', pady=20)\n", "load = Image.open('recipe_card.jpg')\n", "render = ImageTk.PhotoImage(load)\n", "img = Label(frame, image=render, bg='#f8f8f8')\n", "img.image = render\n", "img.pack(fill='both', pady=40)\n", "Button(frame, text='Add A Recipe', highlightbackground='#f8f8f8', command=\n lambda : controller.show_frame(AddARecipe)).pack(fill=Y)\n", "Button(frame, text='Make a Meal Plan', highlightbackground='#f8f8f8',\n command=lambda : controller.show_frame(MakeMealPlan)).pack(fill=Y)\n", "Button(frame, text='View Recipes', highlightbackground='#f8f8f8', command=\n lambda : view_recipes()).pack(fill=Y)\n", "def view_recipes():...\n", "frame.pack_forget()\n", "viewRecipeFrame.pack(expand=True, fill='both')\n", "database_file = 'meal_planner.db'\n", "cursor = conn.cursor()\n", "selection = cursor.execute('SELECT * FROM recipe')\n", "for result in [selection]:\n", "for row in result.fetchall():\n", "conn.close()\n", "name = row[0]\n", "for i in range(len(recipeNames)):\n", "recipeNames.append(name)\n", "label = Label(viewRecipeFrame, font=MEDIUM_FONT, bg='#f8f8f8', fg='#000000',\n text=recipeNames[i])\n", "def callback(recipeName):...\n", "label.pack()\n", "viewRecipeFrame.pack_forget()\n", "label.bind('<Button-1>', lambda event, x=recipeNames[i]: [callback(x),\n viewRecipeFrame.pack_forget()])\n", "database_file = 'meal_planner.db'\n", "menuFrame.pack(fill='both')\n", "load = Image.open('home.jpg')\n", "render = ImageTk.PhotoImage(load)\n", "img = Button(menuFrame, image=render, borderwidth=0, highlightthickness=0,\n highlightbackground='#e7e7e7', command=lambda : [frame.pack(expand=True,\n fill='both'), menuFrame.pack_forget(), viewDetailsFrame.pack_forget()])\n", "img.image = render\n", "img.pack(side=LEFT)\n", "label = Label(menuFrame, text='View Recipe', font=LARGE_FONT, bg='#e7e7e7',\n fg='#272822')\n", "label.pack(side=LEFT, padx=300)\n", "viewDetailsFrame = Frame(self, bg='#f8f8f8')\n", "viewDetailsFrame.pack(expand=True, fill='both')\n", "cursor = conn.cursor()\n", "selection = cursor.execute('SELECT * FROM recipe WHERE name = ' + '\"' +\n recipeName + '\"')\n", "for result in [selection]:\n", "for row in result.fetchall():\n", "string = (\n \"\"\"Name: {} \n Cook time: {} \n Number of Servings: {} \n Ingredients: {} \n Directions: {}\"\"\"\n .format(name, time, servings, ingredients, directions))\n", "name = row[0]\n", "Label(viewDetailsFrame, text=string, font=MEDIUM_FONT, bg='#f8f8f8', fg=\n '#000000').pack(side=LEFT)\n", "time = row[1]\n", "conn.close()\n", "servings = row[2]\n", "Button(menuFrame, text='Delete', highlightbackground='#e7e7e7', command=lambda\n : delete_recipe(name)).pack(side=RIGHT)\n", "favorite = row[3]\n", "def delete_recipe(recipeName):...\n", "ingredients = row[4]\n", "database_file = 'meal_planner.db'\n", "directions = row[5]\n", "now = datetime.datetime.now()\n", "dt = datetime.date(now.year, now.month, now.day)\n", "weekNumber = dt.isocalendar()[1]\n", "tableName = 'recipes_' + str(weekNumber)\n", "cursor = conn.cursor()\n", "cursor.execute('SELECT recipe FROM ' + tableName + ' WHERE recipe = ' + '\"' +\n recipeName + '\"')\n", "returnObject = cursor.fetchone()\n", "if returnObject:\n", "print(returnObject[0])\n", "actually_delete(recipeName)\n", "messagebox.showerror('Cannot Delete',\n \"Cannot delete recipe when it's used in the current week's menu.\")\n", "def actually_delete(recipeName):...\n", "queryString = '\"' + recipeName + '\"'\n", "cursor = conn.cursor()\n", "cursor.execute('DELETE FROM recipe WHERE name = ' + '\"' + recipeName + '\"')\n", "print(cursor.rowcount)\n", "if cursor.rowcount == 1:\n", "messagebox.showinfo('Success', 'Recipe Deleted.')\n", "if cursor.rowcount == 0:\n", "menuFrame.pack_forget()\n", "messagebox.showerror('Cannot Delete', 'Cannot delete recipe, please try again.'\n )\n", "conn.close()\n", "viewRecipeFrame.pack(expand=True, fill='both')\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, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 0, 4, 0, 4, 0, 4, 4, 0, 0, 0, 0, 4, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "Import'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'", "For", "For", "Expr'", "Assign'", "For", "Expr'", "Assign'", "FunctionDef'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "For", "For", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_22(self, VAR_14):...\n", "if self.is_relation_many_to_one(VAR_14):\n", "VAR_34 = self.get_relation_fk(VAR_14)\n", "return self.list_columns[VAR_14].nullable\n", "return False\n", "return VAR_34.nullable\n" ]
[ "def is_nullable(self, col_name):...\n", "if self.is_relation_many_to_one(col_name):\n", "col = self.get_relation_fk(col_name)\n", "return self.list_columns[col_name].nullable\n", "return False\n", "return col.nullable\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Return'", "Return'", "Return'" ]
[ "@app.route('/')...\n", "return render_template('home.html')\n" ]
[ "@app.route('/')...\n", "return render_template('home.html')\n" ]
[ 0, 3 ]
[ "Condition", "Return'" ]
[ "@functools.wraps(VAR_9)...\n", "VAR_19 = {'$schema': 'http://json-schema.org/draft-07/schema#',\n 'definitions': {'tag': {'type': 'object', 'required': ['namespace',\n 'predicate', 'value'], 'properties': {'namespace': {'type': 'string'},\n 'predicate': {'type': 'string'}, 'value': {'type': ['number', 'string']\n }}}, 'issue': {'type': 'object', 'required': ['title'], 'properties': {\n 'title': {'type': 'string'}, 'description': {'type': 'string'}, 'tags':\n {'type': 'array', 'default': [], 'minItems': 0, 'items': {'$ref':\n '#/definitions/tag'}}}}}}\n", "if VAR_3:\n", "VAR_19['definitions']['issue']['required'].append('id')\n", "VAR_19 = {**VAR_19, **{'type': 'object', 'properties': {'data': {'type':\n 'array', 'minItems': 1, 'items': {'$ref': '#/definitions/issue'}}}}}\n", "VAR_19['definitions']['issue']['properties']['id'] = {'type': ['integer',\n 'string']}\n", "VAR_20 = request.get_json()\n", "validate(instance=request_payload, schema=request_schema)\n", "return jsonify({'data': [], 'errors': [\n 'failed to validate payload against json schema']}), 400\n", "return VAR_9(*VAR_17, **kwargs)\n" ]
[ "@functools.wraps(func)...\n", "request_schema = {'$schema': 'http://json-schema.org/draft-07/schema#',\n 'definitions': {'tag': {'type': 'object', 'required': ['namespace',\n 'predicate', 'value'], 'properties': {'namespace': {'type': 'string'},\n 'predicate': {'type': 'string'}, 'value': {'type': ['number', 'string']\n }}}, 'issue': {'type': 'object', 'required': ['title'], 'properties': {\n 'title': {'type': 'string'}, 'description': {'type': 'string'}, 'tags':\n {'type': 'array', 'default': [], 'minItems': 0, 'items': {'$ref':\n '#/definitions/tag'}}}}}}\n", "if require_id:\n", "request_schema['definitions']['issue']['required'].append('id')\n", "request_schema = {**request_schema, **{'type': 'object', 'properties': {\n 'data': {'type': 'array', 'minItems': 1, 'items': {'$ref':\n '#/definitions/issue'}}}}}\n", "request_schema['definitions']['issue']['properties']['id'] = {'type': [\n 'integer', 'string']}\n", "request_payload = request.get_json()\n", "validate(instance=request_payload, schema=request_schema)\n", "return jsonify({'data': [], 'errors': [\n 'failed to validate payload against json schema']}), 400\n", "return func(*args, **kwargs)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 4, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Return'", "Return'" ]
[ "def __init__(self, VAR_10, VAR_11=None, VAR_12=None):...\n", "BaseResource.__init__(self, VAR_10)\n", "self._static_folder = FUNC_1()\n", "self._startup_folder = FUNC_0()\n", "self._portal = VAR_11\n", "self._disclaimer_banner = VAR_12\n", "self.putChild('startup-assets', File(self._startup_folder))\n" ]
[ "def __init__(self, services_factory, portal=None, disclaimer_banner=None):...\n", "BaseResource.__init__(self, services_factory)\n", "self._static_folder = _get_static_folder()\n", "self._startup_folder = _get_startup_folder()\n", "self._portal = portal\n", "self._disclaimer_banner = disclaimer_banner\n", "self.putChild('startup-assets', File(self._startup_folder))\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_0(self, VAR_3, VAR_4=True):...\n", "def FUNC_21(VAR_16):...\n", "return (VAR_16.input, VAR_16.dynamic_input) if VAR_4 else (VAR_16.output,\n VAR_16.dynamic_output)\n" ]
[ "def dynamic_branch(self, wildcards, input=True):...\n", "def get_io(rule):...\n", "return (rule.input, rule.dynamic_input) if input else (rule.output, rule.\n dynamic_output)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Return'" ]
[ "def FUNC_27(self):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_45(VAR_25):...\n", "if VAR_25.fieldtype == 'Table':\n", "return '{}: {}: {}'.format(_('Error'), _('Data missing in table'), _(VAR_25\n .label))\n", "if self.parentfield:\n", "return '{}: {} {} #{}: {}: {}'.format(_('Error'), VAR_54.bold(_(self.\n doctype)), _('Row'), self.idx, _('Value missing for'), _(VAR_25.label))\n", "return _('Error: Value missing for {0}: {1}').format(_(VAR_25.parent), _(\n VAR_25.label))\n" ]
[ "def _get_missing_mandatory_fields(self):...\n", "\"\"\"docstring\"\"\"\n", "def get_msg(df):...\n", "if df.fieldtype == 'Table':\n", "return '{}: {}: {}'.format(_('Error'), _('Data missing in table'), _(df.label))\n", "if self.parentfield:\n", "return '{}: {} {} #{}: {}: {}'.format(_('Error'), frappe.bold(_(self.\n doctype)), _('Row'), self.idx, _('Value missing for'), _(df.label))\n", "return _('Error: Value missing for {0}: {1}').format(_(df.parent), _(df.label))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "def FUNC_4(self):...\n", "self.layout.addWidget(self.log_area)\n" ]
[ "def setup_log_window(self):...\n", "self.layout.addWidget(self.log_area)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def __init__(self, VAR_0, VAR_1):...\n", "super(CLASS_0, self).__init__(VAR_0)\n", "self.values = VAR_1\n", "self.on_conflict = self.model_class._meta.on_conflict\n", "self.return_id = self.model_class._meta.primary_key\n" ]
[ "def __init__(self, model_class, values):...\n", "super(InsertQuery, self).__init__(model_class)\n", "self.values = values\n", "self.on_conflict = self.model_class._meta.on_conflict\n", "self.return_id = self.model_class._meta.primary_key\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'" ]
[ "import zmq\n", "import threading, multiprocessing\n", "import logging\n", "from sup.ticker import Ticker\n", "import wzrpc\n", "from wzrpc.wzhandler import WZHandler\n", "import wzauth_data\n", "\"\"\"Exception to raise when self.running is cleared\"\"\"\n", "def __init__(self):...\n", "super().__init__('Worker was interrupted at runtime')\n", "\"\"\"Exception to raise on suspend signal\"\"\"\n", "def __init__(self, VAR_0, *VAR_1, **VAR_2):...\n", "self.interval = VAR_0\n", "super().__init__(*VAR_1, **kvargs)\n", "\"\"\"Exception to raise when suspend sleep is interrupted\"\"\"\n", "def __init__(self, VAR_3, VAR_4, VAR_1=(), VAR_2={}, VAR_5=None, VAR_6=None,...\n", "super().__init__(*VAR_8, **pkvargs)\n", "self.name = VAR_5 if VAR_5 else type(self).__name__\n", "self.start_timer = VAR_6\n", "self.poll_timeout = VAR_7 if VAR_7 else 5 * 1000\n", "self.call = VAR_4, VAR_1, VAR_2\n", "self.wz_addr = VAR_3\n", "self.wz_auth_requests = []\n", "self.wz_bind_methods = []\n", "self.wz_poll_timeout = 30\n", "def __sinit__(self):...\n", "\"\"\"docstring\"\"\"\n", "self.log = logging.getLogger(self.name)\n", "self.running = threading.Event()\n", "self.sleep_ticker = Ticker()\n", "self.poller = zmq.Poller()\n", "VAR_27 = self.ctx.socket(zmq.SUB)\n", "self.poller.register(VAR_27, zmq.POLLIN)\n", "VAR_27.setsockopt(zmq.IPV6, True)\n", "VAR_27.connect(self.sig_addr)\n", "VAR_27.setsockopt(zmq.SUBSCRIBE, b'GLOBAL')\n", "VAR_27.setsockopt(zmq.SUBSCRIBE, b'WZWorker')\n", "VAR_27.setsockopt(zmq.SUBSCRIBE, bytes(self.name, 'utf-8'))\n", "self.sig_sock = VAR_27\n", "VAR_27 = self.ctx.socket(zmq.DEALER)\n", "self.poller.register(VAR_27, zmq.POLLIN)\n", "VAR_27.setsockopt(zmq.IPV6, True)\n", "self.wz_sock = VAR_27\n", "self.wz = WZHandler()\n", "def FUNC_21(VAR_10, VAR_11, VAR_12):...\n", "self.log.info('Termination signal %s recieved', repr((VAR_10, VAR_11, VAR_12)))\n", "self.term()\n", "self.wz.set_sig_handler(b'WZWorker', b'terminate', FUNC_21)\n", "def FUNC_22(VAR_10, VAR_11, VAR_12):...\n", "self.log.info('Resume signal %s recieved', repr((VAR_10, VAR_11, VAR_12)))\n", "self.wz.set_sig_handler(b'WZWorker', b'resume', FUNC_21)\n", "self.running.set()\n", "def FUNC_0(self):...\n", "self.wz_sock.connect(self.wz_addr)\n", "def FUNC_1(self, VAR_4, VAR_10, VAR_11, VAR_12, VAR_13=None, VAR_14=None):...\n", "VAR_27, VAR_28, VAR_19, VAR_29 = (self.wz_sock, self.poll, self.\n sleep_ticker, self.wz)\n", "VAR_14 = VAR_14 if VAR_14 else self.wz_poll_timeout\n", "VAR_30 = wzrpc.RequestState(VAR_4)\n", "VAR_23 = self.wz.make_req_msg(VAR_10, VAR_11, VAR_12, VAR_30.accept, VAR_13)\n", "VAR_23.insert(0, b'')\n", "VAR_27.send_multipart(VAR_23)\n", "VAR_19.tick()\n", "while self.running.is_set():\n", "VAR_28(VAR_14 * 1000)\n", "def FUNC_2(self, VAR_15):...\n", "if VAR_30.finished:\n", "VAR_27, VAR_28, VAR_19, VAR_29 = (self.wz_sock, self.poll, self.\n sleep_ticker, self.wz)\n", "if VAR_30.retry:\n", "VAR_34 = VAR_19.elapsed(False)\n", "VAR_14 = self.wz_poll_timeout\n", "VAR_23 = self.wz.make_req_msg(VAR_10, VAR_11, VAR_12, VAR_30.accept, VAR_13)\n", "return\n", "if VAR_34 >= VAR_14:\n", "VAR_31 = []\n", "VAR_23.insert(0, b'')\n", "VAR_19.tick()\n", "VAR_32 = {}\n", "VAR_27.send_multipart(VAR_23)\n", "VAR_30.accept(None, 0, 255, [VAR_34])\n", "for request in VAR_15:\n", "VAR_30.finished = False\n", "VAR_30 = wzrpc.RequestState(request[0])\n", "while self.running.is_set():\n", "VAR_30.retry = False\n", "VAR_31.append(VAR_30)\n", "VAR_35 = 0\n", "def FUNC_3(self):...\n", "VAR_23 = self.wz.make_req_msg(request[1][0], request[1][1], request[1][2],\n VAR_30.accept, request[1][3])\n", "for VAR_30 in VAR_31:\n", "for VAR_16, VAR_17 in self.wz_auth_requests:\n", "VAR_23.insert(0, b'')\n", "if VAR_30.finished:\n", "if not VAR_35:\n", "def FUNC_23(VAR_33, VAR_13, VAR_20, VAR_21, VAR_12):...\n", "def FUNC_4(self, VAR_16, VAR_17, VAR_18):...\n", "VAR_32[VAR_30] = VAR_23\n", "if not VAR_30.retry:\n", "VAR_35 = 1\n", "return\n", "VAR_19.tick()\n", "if VAR_21 == wzrpc.status.success:\n", "self.log.debug('Binding %s,%s route', VAR_16, VAR_17)\n", "VAR_27.send_multipart(VAR_23)\n", "VAR_27.send_multipart(VAR_32[VAR_30])\n", "VAR_28(VAR_14 * 1000)\n", "self.log.debug('Successfull auth for (%s, %s)', VAR_16, VAR_17)\n", "if VAR_21 == wzrpc.status.e_auth_wrong_hash:\n", "def FUNC_23(VAR_33, VAR_13, VAR_20, VAR_21, VAR_12):...\n", "VAR_30.finished = False\n", "if VAR_19.elapsed(False) >= VAR_14:\n", "self.wz_wait_reply(FUNC_23, *self.wz.make_auth_req_data(VAR_16, VAR_17,\n wzauth_data.request[VAR_16, VAR_17]))\n", "if wzrpc.status.e_timeout:\n", "if VAR_21 == wzrpc.status.success:\n", "VAR_30.retry = False\n", "for VAR_30 in VAR_31:\n", "self.log.warn('Timeout {0}, retrying'.format(VAR_12[0]))\n", "self.log.warning('Recvd unknown reply for (%s, %s) %s: %s', VAR_16, VAR_17,\n wzrpc.name_status(VAR_21), repr(VAR_12))\n", "self.wz.set_req_handler(VAR_16, VAR_17, VAR_18)\n", "if VAR_21 == wzrpc.status.e_req_denied:\n", "if not VAR_30.finished:\n", "VAR_33.retry = True\n", "self.log.debug('Succesfully binded route (%s, %s)', VAR_16, VAR_17)\n", "self.log.warn('Status {0}, reauthentificating'.format(wzrpc.name_status(\n VAR_21)))\n", "if wzrpc.status.e_timeout:\n", "VAR_30.accept(None, 0, 255, [])\n", "return self.wz_wait_reply(FUNC_23, *self.wz.make_auth_bind_route_data(\n VAR_16, VAR_17, wzauth_data.bind_route[VAR_16, VAR_17]))\n", "self.auth_requests()\n", "self.log.warn('Timeout {0}, retrying'.format(VAR_12[0]))\n", "self.log.warn('Status {0}, retrying'.format(wzrpc.name_status(VAR_21)))\n", "VAR_30.finished = True\n", "VAR_33.retry = True\n", "VAR_33.retry = True\n" ]
[ "import zmq\n", "import threading, multiprocessing\n", "import logging\n", "from sup.ticker import Ticker\n", "import wzrpc\n", "from wzrpc.wzhandler import WZHandler\n", "import wzauth_data\n", "\"\"\"Exception to raise when self.running is cleared\"\"\"\n", "def __init__(self):...\n", "super().__init__('Worker was interrupted at runtime')\n", "\"\"\"Exception to raise on suspend signal\"\"\"\n", "def __init__(self, interval, *args, **kvargs):...\n", "self.interval = interval\n", "super().__init__(*args, **kvargs)\n", "\"\"\"Exception to raise when suspend sleep is interrupted\"\"\"\n", "def __init__(self, wz_addr, fun, args=(), kvargs={}, name=None, start_timer...\n", "super().__init__(*pargs, **pkvargs)\n", "self.name = name if name else type(self).__name__\n", "self.start_timer = start_timer\n", "self.poll_timeout = poll_timeout if poll_timeout else 5 * 1000\n", "self.call = fun, args, kvargs\n", "self.wz_addr = wz_addr\n", "self.wz_auth_requests = []\n", "self.wz_bind_methods = []\n", "self.wz_poll_timeout = 30\n", "def __sinit__(self):...\n", "\"\"\"docstring\"\"\"\n", "self.log = logging.getLogger(self.name)\n", "self.running = threading.Event()\n", "self.sleep_ticker = Ticker()\n", "self.poller = zmq.Poller()\n", "s = self.ctx.socket(zmq.SUB)\n", "self.poller.register(s, zmq.POLLIN)\n", "s.setsockopt(zmq.IPV6, True)\n", "s.connect(self.sig_addr)\n", "s.setsockopt(zmq.SUBSCRIBE, b'GLOBAL')\n", "s.setsockopt(zmq.SUBSCRIBE, b'WZWorker')\n", "s.setsockopt(zmq.SUBSCRIBE, bytes(self.name, 'utf-8'))\n", "self.sig_sock = s\n", "s = self.ctx.socket(zmq.DEALER)\n", "self.poller.register(s, zmq.POLLIN)\n", "s.setsockopt(zmq.IPV6, True)\n", "self.wz_sock = s\n", "self.wz = WZHandler()\n", "def term_handler(interface, method, data):...\n", "self.log.info('Termination signal %s recieved', repr((interface, method, data))\n )\n", "self.term()\n", "self.wz.set_sig_handler(b'WZWorker', b'terminate', term_handler)\n", "def resumehandler(interface, method, data):...\n", "self.log.info('Resume signal %s recieved', repr((interface, method, data)))\n", "self.wz.set_sig_handler(b'WZWorker', b'resume', term_handler)\n", "self.running.set()\n", "def wz_connect(self):...\n", "self.wz_sock.connect(self.wz_addr)\n", "def wz_wait_reply(self, fun, interface, method, data, reqid=None, timeout=None...\n", "s, p, t, wz = self.wz_sock, self.poll, self.sleep_ticker, self.wz\n", "timeout = timeout if timeout else self.wz_poll_timeout\n", "rs = wzrpc.RequestState(fun)\n", "msg = self.wz.make_req_msg(interface, method, data, rs.accept, reqid)\n", "msg.insert(0, b'')\n", "s.send_multipart(msg)\n", "t.tick()\n", "while self.running.is_set():\n", "p(timeout * 1000)\n", "def wz_multiwait(self, requests):...\n", "if rs.finished:\n", "s, p, t, wz = self.wz_sock, self.poll, self.sleep_ticker, self.wz\n", "if rs.retry:\n", "elapsed = t.elapsed(False)\n", "timeout = self.wz_poll_timeout\n", "msg = self.wz.make_req_msg(interface, method, data, rs.accept, reqid)\n", "return\n", "if elapsed >= timeout:\n", "rslist = []\n", "msg.insert(0, b'')\n", "t.tick()\n", "msgdict = {}\n", "s.send_multipart(msg)\n", "rs.accept(None, 0, 255, [elapsed])\n", "for request in requests:\n", "rs.finished = False\n", "rs = wzrpc.RequestState(request[0])\n", "while self.running.is_set():\n", "rs.retry = False\n", "rslist.append(rs)\n", "flag = 0\n", "def auth_requests(self):...\n", "msg = self.wz.make_req_msg(request[1][0], request[1][1], request[1][2], rs.\n accept, request[1][3])\n", "for rs in rslist:\n", "for i, m in self.wz_auth_requests:\n", "msg.insert(0, b'')\n", "if rs.finished:\n", "if not flag:\n", "def accept(that, reqid, seqnum, status, data):...\n", "def bind_route(self, i, m, f):...\n", "msgdict[rs] = msg\n", "if not rs.retry:\n", "flag = 1\n", "return\n", "t.tick()\n", "if status == wzrpc.status.success:\n", "self.log.debug('Binding %s,%s route', i, m)\n", "s.send_multipart(msg)\n", "s.send_multipart(msgdict[rs])\n", "p(timeout * 1000)\n", "self.log.debug('Successfull auth for (%s, %s)', i, m)\n", "if status == wzrpc.status.e_auth_wrong_hash:\n", "def accept(that, reqid, seqnum, status, data):...\n", "rs.finished = False\n", "if t.elapsed(False) >= timeout:\n", "self.wz_wait_reply(accept, *self.wz.make_auth_req_data(i, m, wzauth_data.\n request[i, m]))\n", "if wzrpc.status.e_timeout:\n", "if status == wzrpc.status.success:\n", "rs.retry = False\n", "for rs in rslist:\n", "self.log.warn('Timeout {0}, retrying'.format(data[0]))\n", "self.log.warning('Recvd unknown reply for (%s, %s) %s: %s', i, m, wzrpc.\n name_status(status), repr(data))\n", "self.wz.set_req_handler(i, m, f)\n", "if status == wzrpc.status.e_req_denied:\n", "if not rs.finished:\n", "that.retry = True\n", "self.log.debug('Succesfully binded route (%s, %s)', i, m)\n", "self.log.warn('Status {0}, reauthentificating'.format(wzrpc.name_status(\n status)))\n", "if wzrpc.status.e_timeout:\n", "rs.accept(None, 0, 255, [])\n", "return self.wz_wait_reply(accept, *self.wz.make_auth_bind_route_data(i, m,\n wzauth_data.bind_route[i, m]))\n", "self.auth_requests()\n", "self.log.warn('Timeout {0}, retrying'.format(data[0]))\n", "self.log.warn('Status {0}, retrying'.format(wzrpc.name_status(status)))\n", "rs.finished = True\n", "that.retry = True\n", "that.retry = True\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, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 7, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "Import'", "ImportFrom'", "Import'", "ImportFrom'", "Import'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Expr'", "Expr'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "FunctionDef'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "Expr'", "Expr'", "FunctionDef'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Condition", "Expr'", "FunctionDef'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Return'", "Condition", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "For", "Assign'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "FunctionDef'", "Assign'", "For", "For", "Expr'", "Condition", "Condition", "FunctionDef'", "FunctionDef'", "Assign'", "Condition", "Assign'", "Return'", "Expr'", "Condition", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Condition", "FunctionDef'", "Assign'", "Condition", "Expr'", "Condition", "Condition", "Assign'", "For", "Expr'", "Expr'", "Expr'", "Condition", "Condition", "Assign'", "Expr'", "Expr'", "Condition", "Expr'", "Return'", "Expr'", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_4(self, VAR_16, VAR_17):...\n", "\"\"\"docstring\"\"\"\n", "VAR_53 = {}\n", "for VAR_14 in VAR_16:\n", "if not (VAR_14.code and VAR_14.code.strip()):\n", "VAR_54 = 0\n", "if not (VAR_14.type == 'normal' or VAR_14.type == 'view' and VAR_14.\n", "while True:\n", "VAR_53[VAR_14.code] = VAR_17[VAR_14.id]\n", "VAR_62 = 0\n", "for VAR_71 in VAR_16:\n", "if VAR_71.type != 'view':\n", "if VAR_62 == VAR_54:\n", "if not (VAR_71.calculation and VAR_71.calculation.strip()):\n", "VAR_54 = VAR_62\n", "return VAR_17\n", "if not VAR_71.code or VAR_71.code in VAR_53:\n", "VAR_68 = True\n", "VAR_69 = {'result': 0}\n", "VAR_70 = VAR_71.calculation % VAR_53\n", "VAR_68 = False\n", "if VAR_68:\n", "VAR_62 += 1\n", "if VAR_68:\n", "safe_eval(VAR_70, VAR_69, mode='exec', nocopy=True)\n", "VAR_68 = False\n", "VAR_17[VAR_71.id] = VAR_53[VAR_71.code] = VAR_69['result']\n", "VAR_17[VAR_71.id] = 'error'\n", "VAR_62 += 1\n" ]
[ "def compute_view_items(self, items, items_values):...\n", "\"\"\"docstring\"\"\"\n", "value_dict = {}\n", "for item in items:\n", "if not (item.code and item.code.strip()):\n", "previous_error_counter = 0\n", "if not (item.type == 'normal' or item.type == 'view' and item.calculation and\n", "while True:\n", "value_dict[item.code] = items_values[item.id]\n", "error_counter = 0\n", "for i in items:\n", "if i.type != 'view':\n", "if error_counter == previous_error_counter:\n", "if not (i.calculation and i.calculation.strip()):\n", "previous_error_counter = error_counter\n", "return items_values\n", "if not i.code or i.code in value_dict:\n", "formula_ok = True\n", "scope = {'result': 0}\n", "formula = i.calculation % value_dict\n", "formula_ok = False\n", "if formula_ok:\n", "error_counter += 1\n", "if formula_ok:\n", "safe_eval(formula, scope, mode='exec', nocopy=True)\n", "formula_ok = False\n", "items_values[i.id] = value_dict[i.code] = scope['result']\n", "items_values[i.id] = 'error'\n", "error_counter += 1\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "For", "Condition", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "For", "Condition", "Condition", "Condition", "Assign'", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "AugAssign'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "AugAssign'" ]
[ "@integration_synonym_api...\n", "FUNC_2(VAR_2)\n", "FUNC_3(VAR_2, 'GOLDSTREAM ELECTRICAL LTD')\n", "FUNC_5(VAR_4, VAR_5, VAR_11='GOLDSMITHS', VAR_10=[{'name': '----GOLDSMITHS'\n }, {'name': 'GOLDSTREAM ELECTRICAL LTD'}])\n" ]
[ "@integration_synonym_api...\n", "clean_database(solr)\n", "seed_database_with(solr, 'GOLDSTREAM ELECTRICAL LTD')\n", "verify_results(client, jwt, query='GOLDSMITHS', expected=[{'name':\n '----GOLDSMITHS'}, {'name': 'GOLDSTREAM ELECTRICAL LTD'}])\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_4(VAR_3):...\n", "if not VAR_3:\n", "return errors.BAD_USERNAME_CHARS\n", "if len(VAR_3) < 3:\n", "return errors.BAD_USERNAME_SHORT\n", "if len(VAR_3) > 20:\n", "return errors.BAD_USERNAME_LONG\n", "return errors.BAD_USERNAME_CHARS\n" ]
[ "def whyuserbad(x):...\n", "if not x:\n", "return errors.BAD_USERNAME_CHARS\n", "if len(x) < 3:\n", "return errors.BAD_USERNAME_SHORT\n", "if len(x) > 20:\n", "return errors.BAD_USERNAME_LONG\n", "return errors.BAD_USERNAME_CHARS\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "if VAR_0 is None:\n", "return True\n", "return shutil.which(VAR_0) is not None\n" ]
[ "@staticmethod...\n", "\"\"\"docstring\"\"\"\n", "if executable is None:\n", "return True\n", "return shutil.which(executable) is not None\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Return'", "Return'" ]
[ "def FUNC_7(self, VAR_14):...\n", "" ]
[ "def is_image(self, col_name):...\n", "" ]
[ 0, 0 ]
[ "FunctionDef'", "Condition" ]
[ "from __future__ import unicode_literals\n", "import frappe\n", "from frappe import _\n", "from erpnext.hr.doctype.leave_application.leave_application import get_leave_allocation_records, get_leave_balance_on, get_approved_leaves_for_period\n", "def FUNC_0(VAR_0=None):...\n", "VAR_1 = frappe.db.sql_list('select name from `tabLeave Type` order by name asc'\n )\n", "VAR_3 = FUNC_1(VAR_1)\n", "VAR_4 = FUNC_2(VAR_0, VAR_1)\n", "return VAR_3, VAR_4\n" ]
[ "from __future__ import unicode_literals\n", "import frappe\n", "from frappe import _\n", "from erpnext.hr.doctype.leave_application.leave_application import get_leave_allocation_records, get_leave_balance_on, get_approved_leaves_for_period\n", "def execute(filters=None):...\n", "leave_types = frappe.db.sql_list(\n 'select name from `tabLeave Type` order by name asc')\n", "columns = get_columns(leave_types)\n", "data = get_data(filters, leave_types)\n", "return columns, data\n" ]
[ 0, 0, 0, 4, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_0(self):...\n", "self.assertTrue(self.client.login(username='autotest', password='password'))\n" ]
[ "def setUp(self):...\n", "self.assertTrue(self.client.login(username='autotest', password='password'))\n" ]
[ 0, 5 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_23(self, VAR_6):...\n", "\"\"\"docstring\"\"\"\n", "return cryptolib.load_x509_certificate_pem_as_bare_base64(VAR_6)\n" ]
[ "def _load_x509_for_saml(self, path):...\n", "\"\"\"docstring\"\"\"\n", "return cryptolib.load_x509_certificate_pem_as_bare_base64(path)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "import json\n", "import os\n", "import stat\n", "import tempfile\n", "from django.conf import settings\n", "def FUNC_0(VAR_0, VAR_1, VAR_2):...\n", "VAR_1['AWS_ACCESS_KEY_ID'] = VAR_0.get_input('username', default='')\n", "VAR_1['AWS_SECRET_ACCESS_KEY'] = VAR_0.get_input('password', default='')\n", "if VAR_0.has_input('security_token'):\n", "VAR_1['AWS_SECURITY_TOKEN'] = VAR_0.get_input('security_token', default='')\n", "def FUNC_1(VAR_0, VAR_1, VAR_2):...\n", "VAR_3 = VAR_0.get_input('project', default='')\n", "VAR_4 = VAR_0.get_input('username', default='')\n", "VAR_1['GCE_EMAIL'] = VAR_4\n", "VAR_1['GCE_PROJECT'] = VAR_3\n", "VAR_5 = {'type': 'service_account', 'private_key': VAR_0.get_input(\n 'ssh_key_data', default=''), 'client_email': VAR_4, 'project_id': VAR_3}\n", "VAR_6, VAR_7 = tempfile.mkstemp(dir=private_data_dir)\n", "VAR_8 = os.fdopen(VAR_6, 'w')\n", "json.dump(VAR_5, VAR_8)\n", "VAR_8.close()\n", "os.chmod(VAR_7, stat.S_IRUSR | stat.S_IWUSR)\n", "VAR_1['GCE_CREDENTIALS_FILE_PATH'] = VAR_7\n", "def FUNC_2(VAR_0, VAR_1, VAR_2):...\n", "VAR_9 = VAR_0.get_input('client', default='')\n", "VAR_10 = VAR_0.get_input('tenant', default='')\n", "if len(VAR_9) and len(VAR_10):\n", "VAR_1['AZURE_CLIENT_ID'] = VAR_9\n", "VAR_1['AZURE_SUBSCRIPTION_ID'] = VAR_0.get_input('subscription', default='')\n", "VAR_1['AZURE_TENANT'] = VAR_10\n", "VAR_1['AZURE_AD_USER'] = VAR_0.get_input('username', default='')\n", "VAR_1['AZURE_SECRET'] = VAR_0.get_input('secret', default='')\n", "VAR_1['AZURE_PASSWORD'] = VAR_0.get_input('password', default='')\n", "VAR_1['AZURE_SUBSCRIPTION_ID'] = VAR_0.get_input('subscription', default='')\n", "if VAR_0.has_input('cloud_environment'):\n", "VAR_1['AZURE_CLOUD_ENVIRONMENT'] = VAR_0.get_input('cloud_environment')\n", "def FUNC_3(VAR_0, VAR_1, VAR_2):...\n", "VAR_1['VMWARE_USER'] = VAR_0.get_input('username', default='')\n", "VAR_1['VMWARE_PASSWORD'] = VAR_0.get_input('password', default='')\n", "VAR_1['VMWARE_HOST'] = VAR_0.get_input('host', default='')\n", "VAR_1['VMWARE_VALIDATE_CERTS'] = str(settings.VMWARE_VALIDATE_CERTS)\n" ]
[ "import json\n", "import os\n", "import stat\n", "import tempfile\n", "from django.conf import settings\n", "def aws(cred, env, private_data_dir):...\n", "env['AWS_ACCESS_KEY_ID'] = cred.get_input('username', default='')\n", "env['AWS_SECRET_ACCESS_KEY'] = cred.get_input('password', default='')\n", "if cred.has_input('security_token'):\n", "env['AWS_SECURITY_TOKEN'] = cred.get_input('security_token', default='')\n", "def gce(cred, env, private_data_dir):...\n", "project = cred.get_input('project', default='')\n", "username = cred.get_input('username', default='')\n", "env['GCE_EMAIL'] = username\n", "env['GCE_PROJECT'] = project\n", "json_cred = {'type': 'service_account', 'private_key': cred.get_input(\n 'ssh_key_data', default=''), 'client_email': username, 'project_id':\n project}\n", "handle, path = tempfile.mkstemp(dir=private_data_dir)\n", "f = os.fdopen(handle, 'w')\n", "json.dump(json_cred, f)\n", "f.close()\n", "os.chmod(path, stat.S_IRUSR | stat.S_IWUSR)\n", "env['GCE_CREDENTIALS_FILE_PATH'] = path\n", "def azure_rm(cred, env, private_data_dir):...\n", "client = cred.get_input('client', default='')\n", "tenant = cred.get_input('tenant', default='')\n", "if len(client) and len(tenant):\n", "env['AZURE_CLIENT_ID'] = client\n", "env['AZURE_SUBSCRIPTION_ID'] = cred.get_input('subscription', default='')\n", "env['AZURE_TENANT'] = tenant\n", "env['AZURE_AD_USER'] = cred.get_input('username', default='')\n", "env['AZURE_SECRET'] = cred.get_input('secret', default='')\n", "env['AZURE_PASSWORD'] = cred.get_input('password', default='')\n", "env['AZURE_SUBSCRIPTION_ID'] = cred.get_input('subscription', default='')\n", "if cred.has_input('cloud_environment'):\n", "env['AZURE_CLOUD_ENVIRONMENT'] = cred.get_input('cloud_environment')\n", "def vmware(cred, env, private_data_dir):...\n", "env['VMWARE_USER'] = cred.get_input('username', default='')\n", "env['VMWARE_PASSWORD'] = cred.get_input('password', default='')\n", "env['VMWARE_HOST'] = cred.get_input('host', default='')\n", "env['VMWARE_VALIDATE_CERTS'] = str(settings.VMWARE_VALIDATE_CERTS)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Import'", "Import'", "Import'", "Import'", "ImportFrom'", "FunctionDef'", "Assign'", "Assign'", "Condition", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_1(self):...\n", "return 'check the main page'\n" ]
[ "def describe(self):...\n", "return 'check the main page'\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_14(self):...\n", "self.run_test_case(self.scenario.disable_server_group())\n" ]
[ "def test_e_disable_server_group(self):...\n", "self.run_test_case(self.scenario.disable_server_group())\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def __init__(self, VAR_6, VAR_8, VAR_9, VAR_7):...\n", "\"\"\"docstring\"\"\"\n", "self.name = VAR_6\n", "self.columns = VAR_8\n", "self.type = VAR_8[0].type\n", "self.column_selects = []\n", "for VAR_29 in VAR_8:\n", "self.column_selects.append(VAR_29.select())\n", "self.filter_string = None\n", "self.filter_func = VAR_9\n", "self.display_name = VAR_7\n" ]
[ "def __init__(self, name, columns, filter_func, display_name):...\n", "\"\"\"docstring\"\"\"\n", "self.name = name\n", "self.columns = columns\n", "self.type = columns[0].type\n", "self.column_selects = []\n", "for c in columns:\n", "self.column_selects.append(c.select())\n", "self.filter_string = None\n", "self.filter_func = filter_func\n", "self.display_name = display_name\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Expr'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_21(self, VAR_9=True):...\n", "\"\"\"docstring\"\"\"\n", "self._kill_process_type(VAR_13.PROCESS_TYPE_RAYLET_MONITOR, VAR_9=check_alive)\n" ]
[ "def kill_raylet_monitor(self, check_alive=True):...\n", "\"\"\"docstring\"\"\"\n", "self._kill_process_type(ray_constants.PROCESS_TYPE_RAYLET_MONITOR,\n check_alive=check_alive)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'" ]
[ "def FUNC_4(self):...\n", "self.expected_requests([('http://localhost/swarming/api/v1/bot/handshake',\n {'data': {'attributes': 'b'}, 'headers': {'X-XSRF-Token-Request': '1'}},\n {'expiration_sec': 100, 'ignored': True, 'xsrf_token': 'token'}), (\n 'http://localhost/a', {'data': {'foo': 'bar'}, 'headers': {\n 'X-XSRF-Token': 'token'}}, 'foo', None)])\n", "VAR_0 = xsrf_client.XsrfRemote('http://localhost/',\n '/swarming/api/v1/bot/handshake')\n", "VAR_0.xsrf_request_params = {'attributes': 'b'}\n", "self.assertEqual('foo', VAR_0.url_read('/a', data={'foo': 'bar'}))\n" ]
[ "def testXsrfRemoteCustom(self):...\n", "self.expected_requests([('http://localhost/swarming/api/v1/bot/handshake',\n {'data': {'attributes': 'b'}, 'headers': {'X-XSRF-Token-Request': '1'}},\n {'expiration_sec': 100, 'ignored': True, 'xsrf_token': 'token'}), (\n 'http://localhost/a', {'data': {'foo': 'bar'}, 'headers': {\n 'X-XSRF-Token': 'token'}}, 'foo', None)])\n", "remote = xsrf_client.XsrfRemote('http://localhost/',\n '/swarming/api/v1/bot/handshake')\n", "remote.xsrf_request_params = {'attributes': 'b'}\n", "self.assertEqual('foo', remote.url_read('/a', data={'foo': 'bar'}))\n" ]
[ 0, 5, 5, 5, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_8(self, VAR_12=False):...\n", "VAR_86 = self.rules\n", "if VAR_12:\n", "VAR_86 = filterfalse(Rule.has_wildcards, VAR_86)\n", "for VAR_13 in VAR_86:\n", "logger.rule_info(VAR_10=rule.name, docstring=rule.docstring)\n" ]
[ "def list_rules(self, only_targets=False):...\n", "rules = self.rules\n", "if only_targets:\n", "rules = filterfalse(Rule.has_wildcards, rules)\n", "for rule in rules:\n", "logger.rule_info(name=rule.name, docstring=rule.docstring)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "For", "Docstring" ]
[ "@staticmethod...\n", "return ' '.join(escape_path_argument(s) for s in (sys.executable, os.path.\n join(os.path.dirname(os.path.realpath(__file__)),\n 'run_shell_command_testfiles', VAR_0)))\n" ]
[ "@staticmethod...\n", "return ' '.join(escape_path_argument(s) for s in (sys.executable, os.path.\n join(os.path.dirname(os.path.realpath(__file__)),\n 'run_shell_command_testfiles', scriptname)))\n" ]
[ 0, 2 ]
[ "Condition", "Return'" ]
[ "def FUNC_6(self):...\n", "VAR_21 = pyodbc.drivers()\n", "self.assertTrue(isinstance(VAR_21, list))\n" ]
[ "def test_drivers(self):...\n", "p = pyodbc.drivers()\n", "self.assertTrue(isinstance(p, list))\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def __exit__(self, VAR_0, VAR_1, VAR_2):...\n", "if self.conn:\n", "self.cur.close()\n", "self.conn.close()\n" ]
[ "def __exit__(self, exc_type, exc_val, exc_tb):...\n", "if self.conn:\n", "self.cur.close()\n", "self.conn.close()\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_7(self):...\n", "\"\"\"docstring\"\"\"\n", "if isinstance(self.fields, string_types):\n", "if self.fields == '*':\n", "for filter_name in ['filters', 'or_filters']:\n", "self.fields = ['*']\n", "self.fields = json.loads(self.fields)\n", "self.fields = [VAR_34.strip() for VAR_34 in self.fields.split(',')]\n", "VAR_4 = getattr(self, filter_name)\n", "if isinstance(VAR_4, string_types):\n", "VAR_4 = json.loads(VAR_4)\n", "if isinstance(VAR_4, dict):\n", "VAR_67 = VAR_4\n", "setattr(self, filter_name, VAR_4)\n", "VAR_4 = []\n", "for key, VAR_5 in iteritems(VAR_67):\n", "VAR_4.append(make_filter_tuple(self.doctype, key, VAR_5))\n" ]
[ "def parse_args(self):...\n", "\"\"\"docstring\"\"\"\n", "if isinstance(self.fields, string_types):\n", "if self.fields == '*':\n", "for filter_name in ['filters', 'or_filters']:\n", "self.fields = ['*']\n", "self.fields = json.loads(self.fields)\n", "self.fields = [f.strip() for f in self.fields.split(',')]\n", "filters = getattr(self, filter_name)\n", "if isinstance(filters, string_types):\n", "filters = json.loads(filters)\n", "if isinstance(filters, dict):\n", "fdict = filters\n", "setattr(self, filter_name, filters)\n", "filters = []\n", "for key, value in iteritems(fdict):\n", "filters.append(make_filter_tuple(self.doctype, key, value))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Condition", "For", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "For", "Expr'" ]
[ "def FUNC_29(self):...\n", "VAR_49 = re.split(self.dynamic_fill, self.file)[0]\n", "VAR_50 = os.path.dirname(VAR_49)\n", "if len(VAR_50) > 0 and not os.path.exists(VAR_50):\n", "os.makedirs(VAR_50)\n", "if e.errno != 17:\n" ]
[ "def prepare(self):...\n", "path_until_wildcard = re.split(self.dynamic_fill, self.file)[0]\n", "dir = os.path.dirname(path_until_wildcard)\n", "if len(dir) > 0 and not os.path.exists(dir):\n", "os.makedirs(dir)\n", "if e.errno != 17:\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Condition", "Expr'", "Condition" ]
[ "def FUNC_15(self):...\n", "self._omnicomp.OnFileReadyToParse(None)\n", "if not self._IsServerAlive():\n", "self._NotifyUserIfServerCrashed()\n", "VAR_5 = {}\n", "self._AddTagsFilesIfNeeded(VAR_5)\n", "self._AddSyntaxDataIfNeeded(VAR_5)\n", "self._AddExtraConfDataIfNeeded(VAR_5)\n", "self._latest_file_parse_request = EventNotification('FileReadyToParse', VAR_5)\n", "self._latest_file_parse_request.Start()\n" ]
[ "def OnFileReadyToParse(self):...\n", "self._omnicomp.OnFileReadyToParse(None)\n", "if not self._IsServerAlive():\n", "self._NotifyUserIfServerCrashed()\n", "extra_data = {}\n", "self._AddTagsFilesIfNeeded(extra_data)\n", "self._AddSyntaxDataIfNeeded(extra_data)\n", "self._AddExtraConfDataIfNeeded(extra_data)\n", "self._latest_file_parse_request = EventNotification('FileReadyToParse',\n extra_data)\n", "self._latest_file_parse_request.Start()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Condition", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "@eqlx.with_timeout...\n", "return 'no timeout'\n" ]
[ "@eqlx.with_timeout...\n", "return 'no timeout'\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "@VAR_0.assignment_tag(takes_context=True)...\n", "VAR_16 = FUNC_1(VAR_1)\n", "return VAR_16.total()['min_group_size']\n" ]
[ "@register.assignment_tag(takes_context=True)...\n", "points = _prepare_context(context)\n", "return points.total()['min_group_size']\n" ]
[ 0, 0, 0 ]
[ "Condition", "Assign'", "Return'" ]
[ "def __init__(self, VAR_9, *, VAR_10=0, VAR_11=2):...\n", "self.wires = VAR_9\n", "self.hbar = VAR_11\n", "self.eng = None\n", "self.state = None\n", "super().__init__(self.short_name, VAR_10)\n" ]
[ "def __init__(self, wires, *, shots=0, hbar=2):...\n", "self.wires = wires\n", "self.hbar = hbar\n", "self.eng = None\n", "self.state = None\n", "super().__init__(self.short_name, shots)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def __init__(self, VAR_0):...\n", "self.config = VAR_0\n", "self.db = sqlite3.connect(self.config.get_database_path(),\n check_same_thread=False)\n", "self.c = self.db.cursor()\n" ]
[ "def __init__(self, config):...\n", "self.config = config\n", "self.db = sqlite3.connect(self.config.get_database_path(),\n check_same_thread=False)\n", "self.c = self.db.cursor()\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_2(VAR_7=None, VAR_8=0, VAR_9=0):...\n", "\"\"\"docstring\"\"\"\n", "if VAR_7 is None:\n", "return True\n", "return False\n", "VAR_21 = re.match('^([^;]+)(; length=([0-9]+))?$', VAR_7, re.IGNORECASE)\n", "VAR_22 = parse_http_date(VAR_21.group(1))\n", "VAR_23 = VAR_21.group(3)\n", "if VAR_23 and int(VAR_23) != VAR_9:\n", "if int(VAR_8) > VAR_22:\n" ]
[ "def was_modified_since(header=None, mtime=0, size=0):...\n", "\"\"\"docstring\"\"\"\n", "if header is None:\n", "return True\n", "return False\n", "matches = re.match('^([^;]+)(; length=([0-9]+))?$', header, re.IGNORECASE)\n", "header_mtime = parse_http_date(matches.group(1))\n", "header_len = matches.group(3)\n", "if header_len and int(header_len) != size:\n", "if int(mtime) > header_mtime:\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Return'", "Assign'", "Assign'", "Assign'", "Condition", "Condition" ]
[ "def FUNC_5(VAR_8, VAR_9):...\n", "return dict(point=bounds, line=bounds, polygon=bounds)\n" ]
[ "def _bounds_pad_no_buf(bounds, meters_per_pixel_dim):...\n", "return dict(point=bounds, line=bounds, polygon=bounds)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def __str__(self):...\n", "return ' '.join(map(str, self))\n" ]
[ "def __str__(self):...\n", "return ' '.join(map(str, self))\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_3(self, VAR_6=None, VAR_7='', VAR_8='', VAR_9=None, VAR_10=None):...\n", "\"\"\"docstring\"\"\"\n", "VAR_5 = self.session.query(self.obj)\n", "if len(VAR_7.split('.')) >= 2:\n", "VAR_33 = ''\n", "VAR_23 = self.session.query(func.count('*')).select_from(self.obj)\n", "for join_relation in VAR_7.split('.')[:-1]:\n", "VAR_23 = self._get_base_query(VAR_5=query_count, VAR_6=filters)\n", "VAR_37 = self.get_related_model(join_relation)\n", "VAR_7 = VAR_33 + VAR_7.split('.')[-1]\n", "VAR_5 = self._get_base_query(VAR_5=query, VAR_6=filters, VAR_7=order_column,\n VAR_8=order_direction)\n", "VAR_5 = VAR_5.join(VAR_37)\n", "VAR_24 = VAR_23.scalar()\n", "VAR_33 = VAR_33 + VAR_37.__tablename__ + '.'\n", "if VAR_9:\n", "VAR_5 = VAR_5.offset(VAR_9 * VAR_10)\n", "if VAR_10:\n", "VAR_5 = VAR_5.limit(VAR_10)\n", "return VAR_24, VAR_5.all()\n" ]
[ "def query(self, filters=None, order_column='', order_direction='', page=...\n", "\"\"\"docstring\"\"\"\n", "query = self.session.query(self.obj)\n", "if len(order_column.split('.')) >= 2:\n", "tmp_order_column = ''\n", "query_count = self.session.query(func.count('*')).select_from(self.obj)\n", "for join_relation in order_column.split('.')[:-1]:\n", "query_count = self._get_base_query(query=query_count, filters=filters)\n", "model_relation = self.get_related_model(join_relation)\n", "order_column = tmp_order_column + order_column.split('.')[-1]\n", "query = self._get_base_query(query=query, filters=filters, order_column=\n order_column, order_direction=order_direction)\n", "query = query.join(model_relation)\n", "count = query_count.scalar()\n", "tmp_order_column = tmp_order_column + model_relation.__tablename__ + '.'\n", "if page:\n", "query = query.offset(page * page_size)\n", "if page_size:\n", "query = query.limit(page_size)\n", "return count, query.all()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Return'" ]
[ "@Throttle(VAR_4)...\n", "\"\"\"docstring\"\"\"\n", "import pyatmo\n", "self.station_data = pyatmo.WeatherStationData(self.auth)\n", "if self.station is not None:\n", "self.data = self.station_data.lastData(VAR_19=self.station, exclude=3600)\n", "self.data = self.station_data.lastData(exclude=3600)\n" ]
[ "@Throttle(MIN_TIME_BETWEEN_UPDATES)...\n", "\"\"\"docstring\"\"\"\n", "import pyatmo\n", "self.station_data = pyatmo.WeatherStationData(self.auth)\n", "if self.station is not None:\n", "self.data = self.station_data.lastData(station=self.station, exclude=3600)\n", "self.data = self.station_data.lastData(exclude=3600)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Import'", "Assign'", "Condition", "Assign'", "Assign'" ]
[ "def FUNC_1(self):...\n", "self.render('signup.html', VAR_6='')\n" ]
[ "def get(self):...\n", "self.render('signup.html', error='')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "from django.test import TestCase\n", "from django.utils import timezone\n", "from django.contrib.auth.models import User\n", "from django.core.exceptions import ValidationError\n", "from dashboard.tests.loader import load_model_objects\n", "from dashboard.models import ExtractedText, QANotes\n", "def FUNC_0(self):...\n", "self.objects = load_model_objects()\n", "def FUNC_1(self):...\n", "VAR_0 = ExtractedText(doc_date='Wednesday, January 21, 2014', data_document\n =self.objects.doc, extraction_script=self.objects.script)\n", "self.assertRaises(ValidationError, VAR_0.clean())\n", "VAR_0 = ExtractedText(doc_date='January 1984', data_document=self.objects.\n doc, extraction_script=self.objects.script)\n", "VAR_0.clean()\n", "self.fail('clean() raised ExceptionType unexpectedly!')\n", "VAR_0 = ExtractedText(data_document=self.objects.doc, extraction_script=\n self.objects.script)\n", "VAR_0.clean()\n", "self.fail('clean() raised ExceptionType unexpectedly!')\n", "def FUNC_2(self):...\n", "self.objects.extext.qa_edited = True\n", "VAR_1 = QANotes.objects.create(extracted_text=self.objects.extext)\n", "self.assertEqual(VAR_1.qa_notes, None)\n", "self.assertRaises(ValidationError, VAR_1.clean)\n", "def FUNC_3(self):...\n", "self.objects.extext.qa_edited = True\n", "VAR_1 = QANotes.objects.create(extracted_text=self.objects.extext)\n", "self.assertEqual(VAR_1.qa_notes, None)\n", "VAR_1.qa_notes = 'A short QA note'\n", "VAR_1.clean()\n", "VAR_3 = \"\"\"An exception of type {0} occurred. Arguments:\n{1!r}\"\"\"\n", "VAR_2 = 'A long QA note' * 200\n", "VAR_4 = VAR_3.format(type(ex).__name__, ex.args)\n", "VAR_1.qa_notes = VAR_2\n", "VAR_1.clean()\n", "VAR_3 = \"\"\"An exception of type {0} occurred. Arguments:\n{1!r}\"\"\"\n", "VAR_4 = VAR_3.format(type(ex).__name__, ex.args)\n" ]
[ "from django.test import TestCase\n", "from django.utils import timezone\n", "from django.contrib.auth.models import User\n", "from django.core.exceptions import ValidationError\n", "from dashboard.tests.loader import load_model_objects\n", "from dashboard.models import ExtractedText, QANotes\n", "def setUp(self):...\n", "self.objects = load_model_objects()\n", "def test_extracted_doc_date_validation(self):...\n", "text = ExtractedText(doc_date='Wednesday, January 21, 2014', data_document=\n self.objects.doc, extraction_script=self.objects.script)\n", "self.assertRaises(ValidationError, text.clean())\n", "text = ExtractedText(doc_date='January 1984', data_document=self.objects.\n doc, extraction_script=self.objects.script)\n", "text.clean()\n", "self.fail('clean() raised ExceptionType unexpectedly!')\n", "text = ExtractedText(data_document=self.objects.doc, extraction_script=self\n .objects.script)\n", "text.clean()\n", "self.fail('clean() raised ExceptionType unexpectedly!')\n", "def test_extracted_text_qa_notes(self):...\n", "self.objects.extext.qa_edited = True\n", "note = QANotes.objects.create(extracted_text=self.objects.extext)\n", "self.assertEqual(note.qa_notes, None)\n", "self.assertRaises(ValidationError, note.clean)\n", "def test_long_qa_notes(self):...\n", "self.objects.extext.qa_edited = True\n", "note = QANotes.objects.create(extracted_text=self.objects.extext)\n", "self.assertEqual(note.qa_notes, None)\n", "note.qa_notes = 'A short QA note'\n", "note.clean()\n", "template = \"\"\"An exception of type {0} occurred. Arguments:\n{1!r}\"\"\"\n", "long_note = 'A long QA note' * 200\n", "message = template.format(type(ex).__name__, ex.args)\n", "note.qa_notes = long_note\n", "note.clean()\n", "template = \"\"\"An exception of type {0} occurred. Arguments:\n{1!r}\"\"\"\n", "message = template.format(type(ex).__name__, ex.args)\n" ]
[ 0, 0, 0, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Assign'", "FunctionDef'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'" ]
[ "def FUNC_18(self, VAR_16, VAR_17=None, VAR_18=None, **VAR_19):...\n", "\"\"\"docstring\"\"\"\n", "VAR_38 = registration.get_mapping(self.__class__, VAR_16)\n", "VAR_18 = VAR_18 or []\n", "VAR_18.extend(VAR_38.exclude_fields)\n", "self.full_clean(VAR_18)\n", "return VAR_38(self, VAR_17).convert(**field_values)\n" ]
[ "def convert_to(self, to_resource, context=None, ignore_fields=None, **...\n", "\"\"\"docstring\"\"\"\n", "mapping = registration.get_mapping(self.__class__, to_resource)\n", "ignore_fields = ignore_fields or []\n", "ignore_fields.extend(mapping.exclude_fields)\n", "self.full_clean(ignore_fields)\n", "return mapping(self, context).convert(**field_values)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "Expr'", "Return'" ]
[ "\"\"\"string\"\"\"\n", "import sys\n", "from hp3parclient import exceptions as hpexceptions\n", "from cinder import exception\n", "from cinder.openstack.common import log as logging\n", "from cinder import utils\n", "import cinder.volume.driver\n", "from cinder.volume.drivers.san.hp import hp_3par_common as hpcommon\n", "from cinder.volume.drivers.san import san\n", "VAR_0 = 1.1\n", "VAR_1 = logging.getLogger(__name__)\n", "VAR_2 = 3260\n", "\"\"\"string\"\"\"\n", "def __init__(self, *VAR_3, **VAR_4):...\n", "super(CLASS_0, self).__init__(*VAR_3, **kwargs)\n", "self.common = None\n", "self.configuration.append_config_values(hpcommon.hp3par_opts)\n", "self.configuration.append_config_values(san.san_opts)\n", "def FUNC_0(self):...\n", "return hpcommon.HP3PARCommon(self.configuration)\n" ]
[ "\"\"\"\nVolume driver for HP 3PAR Storage array.\nThis driver requires 3.1.2 MU2 firmware on the 3PAR array.\n\nYou will need to install the python hp3parclient.\nsudo pip install hp3parclient\n\nSet the following in the cinder.conf file to enable the\n3PAR iSCSI Driver along with the required flags:\n\nvolume_driver=cinder.volume.drivers.san.hp.hp_3par_iscsi.HP3PARISCSIDriver\n\"\"\"\n", "import sys\n", "from hp3parclient import exceptions as hpexceptions\n", "from cinder import exception\n", "from cinder.openstack.common import log as logging\n", "from cinder import utils\n", "import cinder.volume.driver\n", "from cinder.volume.drivers.san.hp import hp_3par_common as hpcommon\n", "from cinder.volume.drivers.san import san\n", "VERSION = 1.1\n", "LOG = logging.getLogger(__name__)\n", "DEFAULT_ISCSI_PORT = 3260\n", "\"\"\"OpenStack iSCSI driver to enable 3PAR storage array.\n\n Version history:\n 1.0 - Initial driver\n 1.1 - QoS, extend volume, multiple iscsi ports, remove domain,\n session changes, faster clone, requires 3.1.2 MU2 firmware.\n\n \"\"\"\n", "def __init__(self, *args, **kwargs):...\n", "super(HP3PARISCSIDriver, self).__init__(*args, **kwargs)\n", "self.common = None\n", "self.configuration.append_config_values(hpcommon.hp3par_opts)\n", "self.configuration.append_config_values(san.san_opts)\n", "def _init_common(self):...\n", "return hpcommon.HP3PARCommon(self.configuration)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Expr'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Import'", "ImportFrom'", "ImportFrom'", "Assign'", "Assign'", "Assign'", "Expr'", "FunctionDef'", "Expr'", "Assign'", "Expr'", "Expr'", "FunctionDef'", "Return'" ]
[ "@wraps(VAR_7)...\n", "if VAR_12:\n", "return VAR_7(VAR_8[0], VAR_1, *VAR_8[1:], **kwargs)\n", "return VAR_7(VAR_1, *VAR_8, **kwargs)\n" ]
[ "@wraps(f)...\n", "if with_response:\n", "return f(args[0], remote, *args[1:], **kwargs)\n", "return f(remote, *args, **kwargs)\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Condition", "Return'", "Return'" ]
[ "\"\"\"\nUnit tests for the Deis api app.\n\nRun the tests with \"./manage.py test api\\\"\n\"\"\"\n", "from __future__ import unicode_literals\n", "import json\n", "import os.path\n", "from django.test import TestCase\n", "from django.conf import settings\n", "from api.models import App\n", "\"\"\"Tests creation of applications\"\"\"\n", "VAR_1 = ['tests.json']\n", "def FUNC_0(self):...\n", "self.assertTrue(self.client.login(username='autotest', password='password'))\n", "settings.SSH_PRIVATE_KEY = '<some-ssh-private-key>'\n", "def FUNC_1(self):...\n", "settings.SSH_PRIVATE_KEY = ''\n", "def FUNC_2(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_2 = '/api/apps'\n", "VAR_3 = self.client.post(VAR_2)\n", "self.assertEqual(VAR_3.status_code, 201)\n", "VAR_4 = VAR_3.data['id']\n", "self.assertIn('id', VAR_3.data)\n", "self.assertIn('url', VAR_3.data)\n", "self.assertEqual(VAR_3.data['url'], '{app_id}.deisapp.local'.format(**locals())\n )\n", "VAR_3 = self.client.get('/api/apps')\n", "self.assertEqual(VAR_3.status_code, 200)\n", "self.assertEqual(len(VAR_3.data['results']), 1)\n", "VAR_2 = '/api/apps/{app_id}'.format(**locals())\n", "VAR_3 = self.client.get(VAR_2)\n", "self.assertEqual(VAR_3.status_code, 200)\n", "VAR_5 = {'id': 'new'}\n", "VAR_3 = self.client.patch(VAR_2, json.dumps(VAR_5), content_type=\n 'application/json')\n", "self.assertEqual(VAR_3.status_code, 405)\n", "VAR_3 = self.client.delete(VAR_2)\n", "self.assertEqual(VAR_3.status_code, 204)\n", "def FUNC_3(self):...\n", "VAR_5 = {'id': 'myid'}\n", "VAR_3 = self.client.post('/api/apps', json.dumps(VAR_5), content_type=\n 'application/json')\n", "self.assertEqual(VAR_3.status_code, 201)\n", "VAR_5 = {'id': VAR_3.data['id']}\n", "VAR_3 = self.client.post('/api/apps', json.dumps(VAR_5), content_type=\n 'application/json')\n", "self.assertContains(VAR_3, 'App with this Id already exists.', status_code=400)\n", "return VAR_3\n" ]
[ "\"\"\"\nUnit tests for the Deis api app.\n\nRun the tests with \"./manage.py test api\\\"\n\"\"\"\n", "from __future__ import unicode_literals\n", "import json\n", "import os.path\n", "from django.test import TestCase\n", "from django.conf import settings\n", "from api.models import App\n", "\"\"\"Tests creation of applications\"\"\"\n", "fixtures = ['tests.json']\n", "def setUp(self):...\n", "self.assertTrue(self.client.login(username='autotest', password='password'))\n", "settings.SSH_PRIVATE_KEY = '<some-ssh-private-key>'\n", "def tearDown(self):...\n", "settings.SSH_PRIVATE_KEY = ''\n", "def test_app(self):...\n", "\"\"\"docstring\"\"\"\n", "url = '/api/apps'\n", "response = self.client.post(url)\n", "self.assertEqual(response.status_code, 201)\n", "app_id = response.data['id']\n", "self.assertIn('id', response.data)\n", "self.assertIn('url', response.data)\n", "self.assertEqual(response.data['url'], '{app_id}.deisapp.local'.format(**\n locals()))\n", "response = self.client.get('/api/apps')\n", "self.assertEqual(response.status_code, 200)\n", "self.assertEqual(len(response.data['results']), 1)\n", "url = '/api/apps/{app_id}'.format(**locals())\n", "response = self.client.get(url)\n", "self.assertEqual(response.status_code, 200)\n", "body = {'id': 'new'}\n", "response = self.client.patch(url, json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 405)\n", "response = self.client.delete(url)\n", "self.assertEqual(response.status_code, 204)\n", "def test_app_override_id(self):...\n", "body = {'id': 'myid'}\n", "response = self.client.post('/api/apps', json.dumps(body), content_type=\n 'application/json')\n", "self.assertEqual(response.status_code, 201)\n", "body = {'id': response.data['id']}\n", "response = self.client.post('/api/apps', json.dumps(body), content_type=\n 'application/json')\n", "self.assertContains(response, 'App with this Id already exists.',\n status_code=400)\n", "return response\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 5, 0, 0, 0, 5, 0, 0, 5, 0, 5, 0, 0, 0, 5, 0, 0, 0, 0, 0 ]
[ "Expr'", "ImportFrom'", "Import'", "Import'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "Expr'", "Assign'", "FunctionDef'", "Expr'", "Assign'", "FunctionDef'", "Assign'", "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "from django.utils.translation import string_concat, ugettext_lazy as _\n", "from django.utils.text import format_lazy\n", "from django.utils.functional import lazy as _lazy\n", "from lib.helpers import Enum\n", "def FUNC_6(VAR_12, *VAR_13, **VAR_14):...\n", "\"\"\"string\"\"\"\n", "return VAR_12.format(*VAR_13, **kwargs)\n", "VAR_0 = 'GET', 'HEAD', 'OPTIONS'\n", "\"\"\"\n FilterBackend interface\n \"\"\"\n", "def FUNC_0(self, VAR_2, VAR_3, VAR_4):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_1(self, VAR_4):...\n", "return []\n" ]
[ "from django.utils.translation import string_concat, ugettext_lazy as _\n", "from django.utils.text import format_lazy\n", "from django.utils.functional import lazy as _lazy\n", "from lib.helpers import Enum\n", "def _format_lazy(format_string, *args, **kwargs):...\n", "\"\"\"\nBase permission classes.\n\nThese classes use same interface than ones in django-rest-framework and\nare usable with APIViews too. We define our superclass so we don't need to\ndepend on django-rest-framework.\n\"\"\"\n", "return format_string.format(*args, **kwargs)\n", "SAFE_METHODS = 'GET', 'HEAD', 'OPTIONS'\n", "\"\"\"\n FilterBackend interface\n \"\"\"\n", "def filter_queryset(self, request, queryset, view):...\n", "\"\"\"docstring\"\"\"\n", "def get_fields(self, view):...\n", "return []\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "ImportFrom'", "ImportFrom'", "ImportFrom'", "ImportFrom'", "FunctionDef'", "Expr'", "Return'", "Assign'", "Expr'", "FunctionDef'", "Docstring", "FunctionDef'", "Return'" ]
[ "def FUNC_8(self):...\n", "VAR_3 = DatabaseQuery('DocField').execute(filters={'parent': 'DocType'},\n fields=['fieldname', 'fieldtype'], or_filters=[{'fieldtype': 'Table'},\n {'fieldtype': 'Select'}])\n", "self.assertTrue({'fieldtype': 'Table', 'fieldname': 'fields'} in VAR_3)\n", "self.assertTrue({'fieldtype': 'Select', 'fieldname': 'document_type'} in VAR_3)\n", "self.assertFalse({'fieldtype': 'Check', 'fieldname': 'issingle'} in VAR_3)\n" ]
[ "def test_or_filters(self):...\n", "data = DatabaseQuery('DocField').execute(filters={'parent': 'DocType'},\n fields=['fieldname', 'fieldtype'], or_filters=[{'fieldtype': 'Table'},\n {'fieldtype': 'Select'}])\n", "self.assertTrue({'fieldtype': 'Table', 'fieldname': 'fields'} in data)\n", "self.assertTrue({'fieldtype': 'Select', 'fieldname': 'document_type'} in data)\n", "self.assertFalse({'fieldtype': 'Check', 'fieldname': 'issingle'} in data)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_12(self, VAR_1):...\n", "\"\"\"docstring\"\"\"\n", "shellutil.run('> /var/run/utmp')\n", "shellutil.run('/usr/bin/tmsh delete auth user ' + VAR_1)\n" ]
[ "def del_account(self, username):...\n", "\"\"\"docstring\"\"\"\n", "shellutil.run('> /var/run/utmp')\n", "shellutil.run('/usr/bin/tmsh delete auth user ' + username)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Expr'" ]
[ "def FUNC_4(self):...\n", "\"\"\"docstring\"\"\"\n", "self.cursor.execute('create table t1(n int)')\n", "self.cursor.execute('insert into t1 values (?)', 1)\n", "self.cursor.execute('insert into t1 values (?)', 2)\n", "self.cursor.execute('insert into t1 values (?)', 3)\n", "for i in range(3):\n", "self.cursor.execute('select n from t1 where n < ?', 10)\n", "self.cursor.execute('select n from t1 where n < 3')\n" ]
[ "def test_multiple_bindings(self):...\n", "\"\"\"docstring\"\"\"\n", "self.cursor.execute('create table t1(n int)')\n", "self.cursor.execute('insert into t1 values (?)', 1)\n", "self.cursor.execute('insert into t1 values (?)', 2)\n", "self.cursor.execute('insert into t1 values (?)', 3)\n", "for i in range(3):\n", "self.cursor.execute('select n from t1 where n < ?', 10)\n", "self.cursor.execute('select n from t1 where n < 3')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Expr'", "Expr'", "Expr'", "For", "Expr'", "Expr'" ]
[ "@app.route('/api/server/devices/<device>/properties/<property_name>',...\n", "app.logger.debug('update property: {}/{} ({})'.format(VAR_6, VAR_7, VAR_3))\n", "VAR_18 = controller.indi_server.property(VAR_6=device, VAR_5=property_name)\n", "return {'action': 'set_property', 'device': VAR_6, 'property': VAR_7,\n 'values': VAR_3, 'result': VAR_18.set_values(VAR_3)}\n" ]
[ "@app.route('/api/server/devices/<device>/properties/<property_name>',...\n", "app.logger.debug('update property: {}/{} ({})'.format(device, property_name,\n json))\n", "indi_property = controller.indi_server.property(device=device, name=\n property_name)\n", "return {'action': 'set_property', 'device': device, 'property':\n property_name, 'values': json, 'result': indi_property.set_values(json)}\n" ]
[ 0, 0, 0, 0 ]
[ "Condition", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_4(VAR_5, VAR_7):...\n", "VAR_13 = lambda : None\n", "if VAR_7.secure_cookie_salt:\n", "set_secure_cookie_salt(VAR_7.secure_cookie_salt)\n", "set_inline_static_files_directory(VEIL_VAR_DIR / 'inline-static-files')\n", "set_external_static_files_directory(VEIL_HOME / 'static')\n", "VAR_14 = VAR_7.master_template_directory\n", "if VAR_14:\n", "register_template_loader('master', FileSystemLoader(VAR_14))\n", "VAR_15 = [create_stack_context(install_translations, VAR_13)]\n", "if VAR_7.prevents_xsrf:\n", "register_page_post_processor(set_xsrf_cookie_for_page)\n", "if VAR_7.recalculates_static_file_hash:\n", "VAR_15.append(prevent_xsrf)\n", "VAR_15.append(clear_static_file_hashes)\n", "if VAR_7.clears_template_cache:\n", "VAR_15.append(clear_template_caches)\n", "VAR_15.extend(VAR_1.get(VAR_5, []))\n", "return RoutingHTTPHandler(get_routes(VAR_5), VAR_15)\n" ]
[ "def create_website_http_handler(purpose, config):...\n", "locale_provider = lambda : None\n", "if config.secure_cookie_salt:\n", "set_secure_cookie_salt(config.secure_cookie_salt)\n", "set_inline_static_files_directory(VEIL_VAR_DIR / 'inline-static-files')\n", "set_external_static_files_directory(VEIL_HOME / 'static')\n", "master_template_directory = config.master_template_directory\n", "if master_template_directory:\n", "register_template_loader('master', FileSystemLoader(master_template_directory))\n", "website_context_managers = [create_stack_context(install_translations,\n locale_provider)]\n", "if config.prevents_xsrf:\n", "register_page_post_processor(set_xsrf_cookie_for_page)\n", "if config.recalculates_static_file_hash:\n", "website_context_managers.append(prevent_xsrf)\n", "website_context_managers.append(clear_static_file_hashes)\n", "if config.clears_template_cache:\n", "website_context_managers.append(clear_template_caches)\n", "website_context_managers.extend(additional_context_managers.get(purpose, []))\n", "return RoutingHTTPHandler(get_routes(purpose), website_context_managers)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Expr'", "Expr'", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Condition", "Expr'", "Condition", "Expr'", "Expr'", "Condition", "Expr'", "Expr'", "Return'" ]
[ "def FUNC_5():...\n", "VAR_2 = FUNC_0()\n", "print('##################################')\n", "print('# retail application #')\n", "print('##################################')\n", "VAR_1 = FUNC_4(VAR_2)\n", "print(\"\"\"\n type 'help' for query info\"\"\")\n", "print(\" enter 'quit' to exit\\n\")\n", "print('>', end='')\n", "VAR_20 = input()\n", "VAR_20.replace('\\\\s*', ' ')\n", "VAR_21 = VAR_20.split()\n", "while len(VAR_21) > 0 and VAR_21[0] != 'quit' and VAR_21[0] != 'exit':\n", "FUNC_1(VAR_21, VAR_1, VAR_2)\n", "print('>', end='')\n", "VAR_20 = input()\n", "VAR_20 = VAR_20.replace('\\\\s*', ' ')\n", "VAR_21 = VAR_20.split()\n" ]
[ "def main():...\n", "query = init()\n", "print('##################################')\n", "print('# retail application #')\n", "print('##################################')\n", "id = get_customer_id(query)\n", "print(\"\"\"\n type 'help' for query info\"\"\")\n", "print(\" enter 'quit' to exit\\n\")\n", "print('>', end='')\n", "line = input()\n", "line.replace('\\\\s*', ' ')\n", "tok = line.split()\n", "while len(tok) > 0 and tok[0] != 'quit' and tok[0] != 'exit':\n", "handle_query(tok, id, query)\n", "print('>', end='')\n", "line = input()\n", "line = line.replace('\\\\s*', ' ')\n", "tok = line.split()\n" ]
[ 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Expr'", "Assign'", "Assign'", "Assign'" ]
[ "def __init__(self):...\n", "self.content = VAR_2\n" ]
[ "def __init__(self):...\n", "self.content = content\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "def __eq__(self, VAR_35):...\n", "return self.__class__ == VAR_35.__class__ and self.nested_columns == VAR_35.nested_columns\n" ]
[ "def __eq__(self, other):...\n", "return self.__class__ == other.__class__ and self.nested_columns == other.nested_columns\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@click.group()...\n", "VAR_29 = os.path.expanduser('~/.config/neres/{}.cookies'.format(VAR_21))\n", "if not os.path.exists(os.path.dirname(VAR_29)):\n", "os.makedirs(os.path.dirname(VAR_29), 448)\n", "newrelic.initialize_cookiejar(VAR_29)\n", "if VAR_0.invoked_subcommand != 'login':\n", "if all([VAR_5, VAR_19]):\n", "VAR_0.obj = {}\n", "newrelic.login(VAR_5, VAR_19)\n", "if not newrelic.check_if_logged_in():\n", "VAR_0.obj['ACCOUNT'] = VAR_20\n", "if not VAR_20 and VAR_0.invoked_subcommand != 'list-accounts':\n", "VAR_0.obj['EMAIL'] = VAR_5\n", "VAR_20 = newrelic.get_accounts()[0]['id']\n", "VAR_0.obj['PASSWORD'] = VAR_19\n" ]
[ "@click.group()...\n", "cookiejar = os.path.expanduser('~/.config/neres/{}.cookies'.format(environment)\n )\n", "if not os.path.exists(os.path.dirname(cookiejar)):\n", "os.makedirs(os.path.dirname(cookiejar), 448)\n", "newrelic.initialize_cookiejar(cookiejar)\n", "if ctx.invoked_subcommand != 'login':\n", "if all([email, password]):\n", "ctx.obj = {}\n", "newrelic.login(email, password)\n", "if not newrelic.check_if_logged_in():\n", "ctx.obj['ACCOUNT'] = account\n", "if not account and ctx.invoked_subcommand != 'list-accounts':\n", "ctx.obj['EMAIL'] = email\n", "account = newrelic.get_accounts()[0]['id']\n", "ctx.obj['PASSWORD'] = password\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Condition", "Condition", "Assign'", "Expr'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_6(self, VAR_16):...\n", "for line in filter(lambda error: bool(error.strip()), VAR_16):\n", "self.warn(line)\n" ]
[ "def _print_errors(self, errors):...\n", "for line in filter(lambda error: bool(error.strip()), errors):\n", "self.warn(line)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "For", "Expr'" ]
[ "@tornado.web.asynchronous...\n", "VAR_6 = tornado.concurrent.Future()\n", "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", "tornado.ioloop.IOLoop.instance().add_callback(FUNC_4, VAR_2)\n", "VAR_30['file-size'] = files.format_file_size(os.path.getsize(VAR_29))\n", "VAR_7 = yield VAR_6\n", "VAR_30['owner'] = 'root'\n", "self.set_status(200, 'OK')\n", "VAR_30['date-uploaded'] = time.ctime(os.path.getctime(VAR_29))\n", "self.add_header('Cache-Control', 'max-age=0')\n", "if os.path.isdir(VAR_29):\n", "self.add_header('Connection', 'close')\n", "VAR_30['mime-type'] = 'directory/folder'\n", "VAR_30['mime-type'] = files.guess_mime_type(VAR_5)\n", "self.add_header('Content-Type', 'text/html')\n", "if VAR_30['mime-type'] == 'directory/folder':\n", "self.add_header('Content-Length', str(len(VAR_7)))\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", "self.write(VAR_7)\n", "VAR_30['uuid'] = FUNC_0(VAR_29)\n", "self.flush()\n", "VAR_17.append(VAR_30)\n", "self.finish()\n", "return self\n" ]
[ "@tornado.web.asynchronous...\n", "future = tornado.concurrent.Future()\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", "tornado.ioloop.IOLoop.instance().add_callback(get_final_html_async, target_path\n )\n", "attrib['file-size'] = files.format_file_size(os.path.getsize(actual_path))\n", "file_temp = yield future\n", "attrib['owner'] = 'root'\n", "self.set_status(200, 'OK')\n", "attrib['date-uploaded'] = time.ctime(os.path.getctime(actual_path))\n", "self.add_header('Cache-Control', 'max-age=0')\n", "if os.path.isdir(actual_path):\n", "self.add_header('Connection', 'close')\n", "attrib['mime-type'] = 'directory/folder'\n", "attrib['mime-type'] = files.guess_mime_type(file_name)\n", "self.add_header('Content-Type', 'text/html')\n", "if attrib['mime-type'] == 'directory/folder':\n", "self.add_header('Content-Length', str(len(file_temp)))\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", "self.write(file_temp)\n", "attrib['uuid'] = encode_str_to_hexed_b64(actual_path)\n", "self.flush()\n", "files_attrib_list.append(attrib)\n", "self.finish()\n", "return self\n" ]
[ 0, 0, 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, 0, 4, 0, 4, 0, 4, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "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'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Return'" ]
[ "def __init__(self, VAR_8):...\n", "self.spdx = VAR_8\n", "self.lasttok = None\n", "self.lastid = None\n", "self.lexer = lex.lex(module=self, reflags=re.UNICODE)\n", "self.parser = yacc.yacc(module=self, write_tables=False, debug=False)\n", "self.lines_checked = 0\n", "self.checked = 0\n", "self.spdx_valid = 0\n", "self.spdx_errors = 0\n", "self.curline = 0\n", "self.deepest = 0\n" ]
[ "def __init__(self, spdx):...\n", "self.spdx = spdx\n", "self.lasttok = None\n", "self.lastid = None\n", "self.lexer = lex.lex(module=self, reflags=re.UNICODE)\n", "self.parser = yacc.yacc(module=self, write_tables=False, debug=False)\n", "self.lines_checked = 0\n", "self.checked = 0\n", "self.spdx_valid = 0\n", "self.spdx_errors = 0\n", "self.curline = 0\n", "self.deepest = 0\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'" ]
[ "def FUNC_10(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_24 = False\n", "self.connect()\n", "self.close()\n", "VAR_24 = True\n", "return VAR_24\n" ]
[ "def _is_app_running(self):...\n", "\"\"\"docstring\"\"\"\n", "running = False\n", "self.connect()\n", "self.close()\n", "running = True\n", "return running\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Expr'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_11(self, VAR_7=None):...\n", "\"\"\"docstring\"\"\"\n", "VAR_18 = set()\n", "if self.benchmark and (VAR_7 is None or self.benchmark in VAR_7):\n", "if not self.benchmark.exists:\n", "for VAR_28, VAR_27 in zip(self.output, self.rule.output):\n", "VAR_18.add(self.benchmark)\n", "if VAR_7 is None or VAR_28 in VAR_7:\n", "return VAR_18\n", "if VAR_28 in self.dynamic_output:\n", "if not self.expand_dynamic(VAR_27, VAR_13=self.wildcards, VAR_14=_IOFile.\n", "if not VAR_28.exists:\n", "VAR_18.add('{} (dynamic)'.format(VAR_27))\n", "VAR_18.add(VAR_28)\n" ]
[ "def missing_output(self, requested=None):...\n", "\"\"\"docstring\"\"\"\n", "files = set()\n", "if self.benchmark and (requested is None or self.benchmark in requested):\n", "if not self.benchmark.exists:\n", "for f, f_ in zip(self.output, self.rule.output):\n", "files.add(self.benchmark)\n", "if requested is None or f in requested:\n", "return files\n", "if f in self.dynamic_output:\n", "if not self.expand_dynamic(f_, restriction=self.wildcards, omit_value=\n", "if not f.exists:\n", "files.add('{} (dynamic)'.format(f_))\n", "files.add(f)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Condition", "For", "Expr'", "Condition", "Return'", "Condition", "Condition", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_14(self, VAR_8={}):...\n", "\"\"\"docstring\"\"\"\n", "VAR_24 = self._do_search_default_automaton()\n", "if not self.crapo_state:\n", "if not VAR_24:\n", "return False\n", "if 'name' not in VAR_8:\n", "VAR_8['name'] = 'Default State for %s' % self.id\n", "VAR_8['automaton'] = VAR_24.id\n", "return self.env['crapo.state'].create(VAR_8)\n" ]
[ "def _compute_related_state(self, values={}):...\n", "\"\"\"docstring\"\"\"\n", "my_automaton = self._do_search_default_automaton()\n", "if not self.crapo_state:\n", "if not my_automaton:\n", "return False\n", "if 'name' not in values:\n", "values['name'] = 'Default State for %s' % self.id\n", "values['automaton'] = my_automaton.id\n", "return self.env['crapo.state'].create(values)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Condition", "Return'", "Condition", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_0(self):...\n", "\"\"\"docstring\"\"\"\n", "VAR_12 = self.parts\n", "VAR_13 = 0\n", "while VAR_13 < len(VAR_12):\n", "if VAR_12[VAR_13] == '.' or VAR_12[VAR_13] == '':\n", "if not VAR_12:\n", "VAR_12.pop(VAR_13)\n", "if VAR_13 < 1 or VAR_12[VAR_13] != '..' or VAR_12[VAR_13 - 1] == '..':\n", "self.trailing_slash = False\n", "return self\n", "VAR_13 += 1\n", "VAR_13 -= 1\n", "VAR_12.pop(VAR_13)\n", "VAR_12.pop(VAR_13)\n" ]
[ "def canonicalize(self):...\n", "\"\"\"docstring\"\"\"\n", "parts = self.parts\n", "i = 0\n", "while i < len(parts):\n", "if parts[i] == '.' or parts[i] == '':\n", "if not parts:\n", "parts.pop(i)\n", "if i < 1 or parts[i] != '..' or parts[i - 1] == '..':\n", "self.trailing_slash = False\n", "return self\n", "i += 1\n", "i -= 1\n", "parts.pop(i)\n", "parts.pop(i)\n" ]
[ 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Expr'", "Condition", "Assign'", "Return'", "AugAssign'", "AugAssign'", "Expr'", "Expr'" ]
[ "def FUNC_1(VAR_0, VAR_1, VAR_3=False, **VAR_2):...\n", "if VAR_3:\n", "CLASS_0.invalidate(VAR_1.user)\n", "for VAR_7 in VAR_1.assistants.all():\n", "CLASS_0.invalidate(VAR_7.user)\n" ]
[ "def invalidate_assistants(sender, instance, reverse=False, **kwargs):...\n", "if reverse:\n", "CachedTopMenu.invalidate(instance.user)\n", "for profile in instance.assistants.all():\n", "CachedTopMenu.invalidate(profile.user)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "For", "Expr'" ]