lines
listlengths 1
444
| raw_lines
listlengths 1
444
| label
listlengths 1
444
| type
listlengths 1
444
|
|---|---|---|---|
[
"def FUNC_39(self, VAR_16, VAR_25=None, VAR_26=True):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_47 = self.meta.get_field(VAR_16)\n",
"if VAR_47 and VAR_47.get('__print_hide'):\n",
"return True\n",
"VAR_48 = 0\n",
"if self.get(VAR_16) == 0 and not self.meta.istable:\n",
"VAR_48 = (VAR_25 and VAR_25.print_hide_if_no_value or VAR_47 and VAR_47.\n print_hide_if_no_value)\n",
"if not VAR_48:\n",
"if VAR_25 and VAR_25.print_hide is not None:\n",
"return VAR_48\n",
"VAR_48 = VAR_25.print_hide\n",
"if VAR_47:\n",
"VAR_48 = VAR_47.print_hide\n"
] |
[
"def is_print_hide(self, fieldname, df=None, for_print=True):...\n",
"\"\"\"docstring\"\"\"\n",
"meta_df = self.meta.get_field(fieldname)\n",
"if meta_df and meta_df.get('__print_hide'):\n",
"return True\n",
"print_hide = 0\n",
"if self.get(fieldname) == 0 and not self.meta.istable:\n",
"print_hide = (df and df.print_hide_if_no_value or meta_df and meta_df.\n print_hide_if_no_value)\n",
"if not print_hide:\n",
"if df and df.print_hide is not None:\n",
"return print_hide\n",
"print_hide = df.print_hide\n",
"if meta_df:\n",
"print_hide = meta_df.print_hide\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'"
] |
[
"def FUNC_20(self, VAR_14):...\n",
""
] |
[
"def is_relation_one_to_one(self, col_name):...\n",
""
] |
[
0,
0
] |
[
"FunctionDef'",
"Condition"
] |
[
"def FUNC_6(self):...\n",
"VAR_5 = [{'cloudProvider': 'gce', 'asgName': self.__server_group_name,\n 'serverGroupName': self.__server_group_name, 'region': self.TEST_REGION,\n 'zone': self.TEST_ZONE, 'type': 'disableServerGroup', 'regions': [self.\n TEST_REGION], 'zones': [self.TEST_ZONE], 'credentials': self.bindings[\n 'GCE_CREDENTIALS'], 'user': 'integration-tests'}]\n",
"VAR_6 = gcp.GceContractBuilder(self.gce_observer)\n",
"VAR_6.new_clause_builder('Server Group Disabled', retryable_for_secs=90\n ).list_resources('managed-instance-groups').contains_path_value(\n 'baseInstanceName', self.__server_group_name).excludes_pred_list([jc.\n PathContainsPredicate('baseInstanceName', self.__server_group_name), jc\n .PathContainsPredicate('targetPools', 'https')])\n",
"VAR_7 = self.agent.make_json_payload_from_kwargs(VAR_5=job, description=\n 'Server Group Test - disable server group', application=self.TEST_APP)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'disable_server_group', data=payload, path=self.__path), contract=\n builder.build())\n"
] |
[
"def disable_server_group(self):...\n",
"job = [{'cloudProvider': 'gce', 'asgName': self.__server_group_name,\n 'serverGroupName': self.__server_group_name, 'region': self.TEST_REGION,\n 'zone': self.TEST_ZONE, 'type': 'disableServerGroup', 'regions': [self.\n TEST_REGION], 'zones': [self.TEST_ZONE], 'credentials': self.bindings[\n 'GCE_CREDENTIALS'], 'user': 'integration-tests'}]\n",
"builder = gcp.GceContractBuilder(self.gce_observer)\n",
"builder.new_clause_builder('Server Group Disabled', retryable_for_secs=90\n ).list_resources('managed-instance-groups').contains_path_value(\n 'baseInstanceName', self.__server_group_name).excludes_pred_list([jc.\n PathContainsPredicate('baseInstanceName', self.__server_group_name), jc\n .PathContainsPredicate('targetPools', 'https')])\n",
"payload = self.agent.make_json_payload_from_kwargs(job=job, description=\n 'Server Group Test - disable server group', application=self.TEST_APP)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'disable_server_group', data=payload, path=self.__path), contract=\n builder.build())\n"
] |
[
0,
0,
0,
1,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_1(self, VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"self.connection = sqlite3.connect(self.db_path)\n",
"self.cursor = self.connection.cursor()\n",
"if self.connection:\n",
"VAR_34 = codecs.open(VAR_1[0], encoding='utf-8', mode='r')\n",
"VAR_33 = VAR_34.read()\n",
"self.cursor.executescript(VAR_33)\n",
"print('db created and contents imported from %s' % VAR_1[0])\n"
] |
[
"def import_database(self, sqlfile):...\n",
"\"\"\"docstring\"\"\"\n",
"self.connection = sqlite3.connect(self.db_path)\n",
"self.cursor = self.connection.cursor()\n",
"if self.connection:\n",
"f = codecs.open(sqlfile[0], encoding='utf-8', mode='r')\n",
"sql = f.read()\n",
"self.cursor.executescript(sql)\n",
"print('db created and contents imported from %s' % sqlfile[0])\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_6(self):...\n",
"VAR_8 = 'test_foo.py'\n",
"VAR_7 = BokChoyTestSuite('', test_spec=spec, default_store='draft')\n",
"VAR_1 = 'tests/{}'.format(VAR_8)\n",
"self.assertEqual(VAR_7.cmd, self._expected_command(VAR_1=name, VAR_2='draft'))\n"
] |
[
"def test_spec_with_draft_default_store(self):...\n",
"spec = 'test_foo.py'\n",
"suite = BokChoyTestSuite('', test_spec=spec, default_store='draft')\n",
"name = 'tests/{}'.format(spec)\n",
"self.assertEqual(suite.cmd, self._expected_command(name=name, store='draft'))\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"import os\n",
"from flask import Flask, render_template, request, send_from_directory, redirect, url_for, flash, abort, Response\n",
"from flask_login import LoginManager, login_required, login_user, logout_user\n",
"from flask_mysqldb import MySQL\n",
"from forms import registerForm, loginForm\n",
"from passlib.hash import sha256_crypt\n",
"from urllib.parse import urlparse, urljoin\n",
"from werkzeug.utils import secure_filename\n",
"VAR_0 = Flask(__name__, static_url_path='/static')\n",
"VAR_1 = 'C:/Users/s164376/Documents/WebTechTeam/Markis/uploads'\n",
"VAR_2 = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])\n",
"VAR_0.config['MYSQL_HOST'] = 'cs-students.nl'\n",
"VAR_0.config['MYSQL_USER'] = 'markis'\n",
"VAR_0.config['MYSQL_PASSWORD'] = 'dlSvw7noOQbiExlU'\n",
"VAR_0.config['MYSQL_DB'] = 'markis'\n",
"VAR_0.config['MYSQL_CURSORCLASS'] = 'DictCursor'\n",
"VAR_0.config['UPLOAD_FOLDER'] = VAR_1\n",
"VAR_0.secret_key = (\n 'kjdnkjfn89dbndh7cg76chb7hjhsbGHmmDDEaQc4By9VH5667HkmFxdxAjhb5Eub')\n",
"VAR_3 = MySQL(VAR_0)\n",
"VAR_4 = LoginManager()\n",
"VAR_4.init_app(VAR_0)\n",
"VAR_4.login_view = 'login'\n",
"VAR_4.login_message = 'You need to be logged in to view this page!'\n",
"@VAR_0.route('/')...\n",
"VAR_8 = VAR_3.connection\n",
"VAR_9 = VAR_8.cursor()\n",
"VAR_9.execute(\n 'SELECT subject_id, subject_name FROM subjects WHERE 1 ORDER BY subject_id ASC'\n )\n",
"VAR_10 = VAR_9.fetchall()\n",
"return render_template('home.html', subjects=rv)\n"
] |
[
"import os\n",
"from flask import Flask, render_template, request, send_from_directory, redirect, url_for, flash, abort, Response\n",
"from flask_login import LoginManager, login_required, login_user, logout_user\n",
"from flask_mysqldb import MySQL\n",
"from forms import registerForm, loginForm\n",
"from passlib.hash import sha256_crypt\n",
"from urllib.parse import urlparse, urljoin\n",
"from werkzeug.utils import secure_filename\n",
"app = Flask(__name__, static_url_path='/static')\n",
"UPLOAD_FOLDER = 'C:/Users/s164376/Documents/WebTechTeam/Markis/uploads'\n",
"ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])\n",
"app.config['MYSQL_HOST'] = 'cs-students.nl'\n",
"app.config['MYSQL_USER'] = 'markis'\n",
"app.config['MYSQL_PASSWORD'] = 'dlSvw7noOQbiExlU'\n",
"app.config['MYSQL_DB'] = 'markis'\n",
"app.config['MYSQL_CURSORCLASS'] = 'DictCursor'\n",
"app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER\n",
"app.secret_key = (\n 'kjdnkjfn89dbndh7cg76chb7hjhsbGHmmDDEaQc4By9VH5667HkmFxdxAjhb5Eub')\n",
"mysql = MySQL(app)\n",
"login_manager = LoginManager()\n",
"login_manager.init_app(app)\n",
"login_manager.login_view = 'login'\n",
"login_manager.login_message = 'You need to be logged in to view this page!'\n",
"@app.route('/')...\n",
"conn = mysql.connection\n",
"cur = conn.cursor()\n",
"cur.execute(\n 'SELECT subject_id, subject_name FROM subjects WHERE 1 ORDER BY subject_id ASC'\n )\n",
"rv = cur.fetchall()\n",
"return render_template('home.html', subjects=rv)\n"
] |
[
0,
0,
0,
4,
0,
0,
0,
0,
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
4,
0,
0,
0,
0,
0,
4,
4,
4,
4,
4
] |
[
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_18(self):...\n",
"return FUNC_18.dumps(self.properties())\n"
] |
[
"def json(self):...\n",
"return json.dumps(self.properties())\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_0(VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"if not FUNC_4('pdftotext'):\n",
"VAR_0.warning(\n 'GNU file was not found on the system. Switching to a weak file extension test.'\n )\n",
"VAR_9 = os.popen('file ' + re.escape(VAR_2)).read()\n",
"if VAR_2.lower().endswith('.pdf'):\n",
"VAR_19 = VAR_9.split(':')[1]\n",
"VAR_0.error('string')\n",
"VAR_10 = VAR_19.find('PDF') > -1\n",
"return True\n",
"return False\n",
"return VAR_10\n"
] |
[
"def is_pdf(document):...\n",
"\"\"\"docstring\"\"\"\n",
"if not executable_exists('pdftotext'):\n",
"log.warning(\n 'GNU file was not found on the system. Switching to a weak file extension test.'\n )\n",
"file_output = os.popen('file ' + re.escape(document)).read()\n",
"if document.lower().endswith('.pdf'):\n",
"filetype = file_output.split(':')[1]\n",
"log.error(\n \"Your version of the 'file' utility seems to be unsupported. Please report this to cds.support@cern.ch.\"\n )\n",
"pdf = filetype.find('PDF') > -1\n",
"return True\n",
"return False\n",
"return pdf\n"
] |
[
0,
0,
0,
0,
0,
0,
7,
7,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Return'",
"Return'",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"VAR_3 = Walker()\n",
"VAR_4 = 3\n",
"VAR_5 = 0\n",
"VAR_3.walk(VAR_2, VAR_4, VAR_5, 'east')\n"
] |
[
"def test_walker(self):...\n",
"walkman = Walker()\n",
"row = 3\n",
"col = 0\n",
"walkman.walk(board, row, col, 'east')\n"
] |
[
0,
1,
1,
0,
1
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_22(self):...\n",
"return bool(self._latest_file_parse_request and self.\n _latest_file_parse_request.Done())\n"
] |
[
"def DiagnosticsForCurrentFileReady(self):...\n",
"return bool(self._latest_file_parse_request and self.\n _latest_file_parse_request.Done())\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"self.login()\n",
"while True:\n",
"VAR_30 = random.choice(self.tasks)\n",
"self.do_step(SubmitRandomRequest(self.browser, VAR_30, VAR_10=self.base_url,\n VAR_11=self.submissions_path))\n"
] |
[
"def act(self):...\n",
"self.login()\n",
"while True:\n",
"task = random.choice(self.tasks)\n",
"self.do_step(SubmitRandomRequest(self.browser, task, base_url=self.base_url,\n submissions_path=self.submissions_path))\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Condition",
"Assign'",
"Expr'"
] |
[
"def FUNC_4(VAR_18, VAR_17, VAR_19):...\n",
"\"\"\"docstring\"\"\"\n",
"return keyworder.get_composite_keywords(VAR_18, VAR_17, VAR_19) or {}\n"
] |
[
"def extract_composite_keywords(ckw_db, fulltext, skw_spans):...\n",
"\"\"\"docstring\"\"\"\n",
"return keyworder.get_composite_keywords(ckw_db, fulltext, skw_spans) or {}\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_0(self, VAR_45):...\n",
"\"\"\"docstring\"\"\"\n",
"self.variable_manager.extra_vars = {'job_id': VAR_45}\n",
"self.pbex.run()\n",
"return self.pbex._tqm._stats\n"
] |
[
"def run(self, job_id):...\n",
"\"\"\"docstring\"\"\"\n",
"self.variable_manager.extra_vars = {'job_id': job_id}\n",
"self.pbex.run()\n",
"return self.pbex._tqm._stats\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'",
"Return'"
] |
[
"from __future__ import absolute_import\n",
"from binascii import hexlify\n",
"from datetime import datetime\n",
"from pony import orm\n",
"from pony.orm import db_session, desc, raw_sql, select\n",
"from Tribler.Core.Category.FamilyFilter import default_xxx_filter\n",
"from Tribler.Core.Modules.MetadataStore.OrmBindings.channel_node import LEGACY_ENTRY, TODELETE\n",
"from Tribler.Core.Modules.MetadataStore.serialization import REGULAR_TORRENT, TorrentMetadataPayload\n",
"from Tribler.Core.Utilities.tracker_utils import get_uniformed_tracker_url\n",
"from Tribler.pyipv8.ipv8.database import database_blob\n",
"def FUNC_0(VAR_0):...\n",
"VAR_1 = REGULAR_TORRENT\n",
"VAR_2 = orm.Required(database_blob)\n",
"VAR_3 = orm.Optional(int, VAR_3=64, default=0)\n",
"VAR_4 = orm.Optional(datetime, default=datetime.utcnow)\n",
"VAR_5 = orm.Optional(str, default='')\n",
"VAR_6 = orm.Optional(str, default='')\n",
"VAR_7 = orm.Optional(str, default='')\n",
"orm.composite_key(VAR_0.ChannelNode.public_key, VAR_2)\n",
"VAR_8 = orm.Optional(float, default=0)\n",
"VAR_9 = orm.Optional('TorrentState', reverse='metadata')\n",
"VAR_10 = TorrentMetadataPayload\n",
"def __init__(self, *VAR_11, **VAR_12):...\n",
"if 'health' not in VAR_12 and 'infohash' in VAR_12:\n",
"VAR_12['health'] = VAR_0.TorrentState.get(VAR_2=kwargs['infohash']\n ) or VAR_0.TorrentState(VAR_2=kwargs['infohash'])\n",
"if 'xxx' not in VAR_12:\n",
"VAR_12['xxx'] = default_xxx_filter.isXXXTorrentMetadataDict(VAR_12)\n",
"super(CLASS_0, self).__init__(*VAR_11, **kwargs)\n",
"if 'tracker_info' in VAR_12:\n",
"self.add_tracker(VAR_12['tracker_info'])\n",
"def FUNC_1(self, VAR_13):...\n",
"VAR_31 = get_uniformed_tracker_url(VAR_13)\n",
"if VAR_31:\n",
"VAR_39 = VAR_0.TrackerState.get(url=sanitized_url) or VAR_0.TrackerState(url\n =sanitized_url)\n",
"def FUNC_2(self):...\n",
"self.health.trackers.add(VAR_39)\n",
"self.add_tracker(self.tracker_info)\n",
"def FUNC_3(self):...\n",
"return 'magnet:?xt=urn:btih:%s&dn=%s' % (str(self.infohash).encode('hex'),\n self.title) + ('&tr=%s' % self.tracker_info if self.tracker_info else '')\n"
] |
[
"from __future__ import absolute_import\n",
"from binascii import hexlify\n",
"from datetime import datetime\n",
"from pony import orm\n",
"from pony.orm import db_session, desc, raw_sql, select\n",
"from Tribler.Core.Category.FamilyFilter import default_xxx_filter\n",
"from Tribler.Core.Modules.MetadataStore.OrmBindings.channel_node import LEGACY_ENTRY, TODELETE\n",
"from Tribler.Core.Modules.MetadataStore.serialization import REGULAR_TORRENT, TorrentMetadataPayload\n",
"from Tribler.Core.Utilities.tracker_utils import get_uniformed_tracker_url\n",
"from Tribler.pyipv8.ipv8.database import database_blob\n",
"def define_binding(db):...\n",
"_discriminator_ = REGULAR_TORRENT\n",
"infohash = orm.Required(database_blob)\n",
"size = orm.Optional(int, size=64, default=0)\n",
"torrent_date = orm.Optional(datetime, default=datetime.utcnow)\n",
"title = orm.Optional(str, default='')\n",
"tags = orm.Optional(str, default='')\n",
"tracker_info = orm.Optional(str, default='')\n",
"orm.composite_key(db.ChannelNode.public_key, infohash)\n",
"xxx = orm.Optional(float, default=0)\n",
"health = orm.Optional('TorrentState', reverse='metadata')\n",
"_payload_class = TorrentMetadataPayload\n",
"def __init__(self, *args, **kwargs):...\n",
"if 'health' not in kwargs and 'infohash' in kwargs:\n",
"kwargs['health'] = db.TorrentState.get(infohash=kwargs['infohash']\n ) or db.TorrentState(infohash=kwargs['infohash'])\n",
"if 'xxx' not in kwargs:\n",
"kwargs['xxx'] = default_xxx_filter.isXXXTorrentMetadataDict(kwargs)\n",
"super(TorrentMetadata, self).__init__(*args, **kwargs)\n",
"if 'tracker_info' in kwargs:\n",
"self.add_tracker(kwargs['tracker_info'])\n",
"def add_tracker(self, tracker_url):...\n",
"sanitized_url = get_uniformed_tracker_url(tracker_url)\n",
"if sanitized_url:\n",
"tracker = db.TrackerState.get(url=sanitized_url) or db.TrackerState(url=\n sanitized_url)\n",
"def before_update(self):...\n",
"self.health.trackers.add(tracker)\n",
"self.add_tracker(self.tracker_info)\n",
"def get_magnet(self):...\n",
"return 'magnet:?xt=urn:btih:%s&dn=%s' % (str(self.infohash).encode('hex'),\n self.title) + ('&tr=%s' % self.tracker_info if self.tracker_info else '')\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"FunctionDef'",
"Expr'",
"Expr'",
"FunctionDef'",
"Return'"
] |
[
"@db.transact...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_14 = self.check_auth(VAR_9)\n",
"VAR_22 = db.get_root()['oms_root']\n",
"VAR_23, VAR_13 = traverse_path(VAR_22, VAR_9.path[1:])\n",
"if not VAR_23 and VAR_13:\n",
"VAR_23 = [VAR_22]\n",
"VAR_12 = VAR_23[-1]\n",
"VAR_24 = self.get_interaction(VAR_9, VAR_14)\n",
"VAR_9.interaction = VAR_24\n",
"if self.use_security_proxy:\n",
"VAR_12 = proxy_factory(VAR_12, VAR_24)\n",
"VAR_25 = self.find_view(VAR_12, VAR_13)\n",
"VAR_26 = VAR_25.rw_transaction(VAR_9)\n",
"if VAR_24:\n",
"def FUNC_13(VAR_25, VAR_27):...\n",
"VAR_25 = proxy_factory(VAR_25, VAR_24)\n",
"return getattr(VAR_25, VAR_27, None)\n",
"from opennode.oms.endpoint.httprest.auth import IHttpRestAuthenticationUtility\n",
"for VAR_27 in ('render_' + VAR_9.method, 'render'):\n",
"if VAR_14 or not getUtility(IHttpRestAuthenticationUtility\n",
"VAR_30 = FUNC_13(VAR_25, VAR_27)\n",
"if VAR_30:\n",
"VAR_32 = VAR_30(VAR_9)\n",
"if VAR_26:\n",
"return VAR_32\n",
"return db.RollbackValue(VAR_32)\n"
] |
[
"@db.transact...\n",
"\"\"\"docstring\"\"\"\n",
"token = self.check_auth(request)\n",
"oms_root = db.get_root()['oms_root']\n",
"objs, unresolved_path = traverse_path(oms_root, request.path[1:])\n",
"if not objs and unresolved_path:\n",
"objs = [oms_root]\n",
"obj = objs[-1]\n",
"interaction = self.get_interaction(request, token)\n",
"request.interaction = interaction\n",
"if self.use_security_proxy:\n",
"obj = proxy_factory(obj, interaction)\n",
"view = self.find_view(obj, unresolved_path)\n",
"needs_rw_transaction = view.rw_transaction(request)\n",
"if interaction:\n",
"def get_renderer(view, method):...\n",
"view = proxy_factory(view, interaction)\n",
"return getattr(view, method, None)\n",
"from opennode.oms.endpoint.httprest.auth import IHttpRestAuthenticationUtility\n",
"for method in ('render_' + request.method, 'render'):\n",
"if token or not getUtility(IHttpRestAuthenticationUtility\n",
"renderer = get_renderer(view, method)\n",
"if renderer:\n",
"res = renderer(request)\n",
"if needs_rw_transaction:\n",
"return res\n",
"return db.RollbackValue(res)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"FunctionDef'",
"Assign'",
"Return'",
"ImportFrom'",
"For",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_34(self):...\n",
""
] |
[
"def get(self):...\n",
""
] |
[
0,
0
] |
[
"FunctionDef'",
"Condition"
] |
[
"def FUNC_0(self):...\n",
"self.mail_service = mock()\n",
"self.services_factory = mock()\n",
"self.services_factory.mode = UserAgentMode(is_single_user=True)\n",
"self.services = mock()\n",
"self.services.mail_service = self.mail_service\n",
"self.services_factory._services_by_user = {'someuserid': self.mail_service}\n",
"when(self.services_factory).services(ANY()).thenReturn(self.services)\n",
"self.mail_service.account_email = self.MAIL_ADDRESS\n",
"VAR_1 = RootResource(self.services_factory)\n",
"VAR_1._html_template = (\n '<html><head><title>$account_email</title></head></html>')\n",
"VAR_1._mode = VAR_1\n",
"self.web = DummySite(VAR_1)\n"
] |
[
"def setUp(self):...\n",
"self.mail_service = mock()\n",
"self.services_factory = mock()\n",
"self.services_factory.mode = UserAgentMode(is_single_user=True)\n",
"self.services = mock()\n",
"self.services.mail_service = self.mail_service\n",
"self.services_factory._services_by_user = {'someuserid': self.mail_service}\n",
"when(self.services_factory).services(ANY()).thenReturn(self.services)\n",
"self.mail_service.account_email = self.MAIL_ADDRESS\n",
"root_resource = RootResource(self.services_factory)\n",
"root_resource._html_template = (\n '<html><head><title>$account_email</title></head></html>')\n",
"root_resource._mode = root_resource\n",
"self.web = DummySite(root_resource)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_2(VAR_14, VAR_15=None, VAR_16=None, VAR_17='width=\\\\textwidth'):...\n",
"if not VAR_16:\n",
"VAR_16 = VAR_15[0][0]\n",
"if VAR_14[0]:\n",
"if VAR_14[1]:\n",
"if VAR_14[1]:\n",
"return self.markers[0] % (VAR_14[0][0], VAR_14[0][1], VAR_14[1][0], VAR_14[\n 1][1], VAR_16)\n",
"return self.markers[1] % (VAR_14[0][0], VAR_14[0][1], VAR_16)\n",
"return self.markers[2] % (VAR_14[1][0], VAR_14[1][1], VAR_16)\n",
"return self.markers[3] % (VAR_17, VAR_16)\n"
] |
[
"def singleImage(dims, files=None, file=None, implicitDims='width=\\\\textwidth'):...\n",
"if not file:\n",
"file = files[0][0]\n",
"if dims[0]:\n",
"if dims[1]:\n",
"if dims[1]:\n",
"return self.markers[0] % (dims[0][0], dims[0][1], dims[1][0], dims[1][1], file)\n",
"return self.markers[1] % (dims[0][0], dims[0][1], file)\n",
"return self.markers[2] % (dims[1][0], dims[1][1], file)\n",
"return self.markers[3] % (implicitDims, file)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Return'",
"Return'",
"Return'",
"Return'"
] |
[
"def FUNC_2(self, VAR_39, VAR_40):...\n",
"assert len(VAR_39) > 0, 'Invalid data type'\n",
"assert isinstance(VAR_40, dict), 'Invalid parameter data format'\n",
"if VAR_39.upper() == 'FIELD':\n",
"VAR_85 = self.field_mapping[VAR_40['field']]\n",
"if VAR_39.upper() == 'INTEGER':\n",
"return '`{table}`.`{field}`'.format(VAR_77=field_data[self.TABLE_NAME],\n VAR_52=field_data[self.FIELD_NAME])\n",
"return int(VAR_40['value'])\n",
"if VAR_39.upper() == 'STRING':\n",
"return VAR_40['value']\n"
] |
[
"def _process_parameter(self, data_type, parameter_data):...\n",
"assert len(data_type) > 0, 'Invalid data type'\n",
"assert isinstance(parameter_data, dict), 'Invalid parameter data format'\n",
"if data_type.upper() == 'FIELD':\n",
"field_data = self.field_mapping[parameter_data['field']]\n",
"if data_type.upper() == 'INTEGER':\n",
"return '`{table}`.`{field}`'.format(table=field_data[self.TABLE_NAME],\n field=field_data[self.FIELD_NAME])\n",
"return int(parameter_data['value'])\n",
"if data_type.upper() == 'STRING':\n",
"return parameter_data['value']\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
4
] |
[
"FunctionDef'",
"Assert'",
"Assert'",
"Condition",
"Assign'",
"Condition",
"Return'",
"Return'",
"Condition",
"Return'"
] |
[
"def FUNC_0(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.eng:\n",
"self.eng.reset()\n",
"self.eng, VAR_13 = sf.Engine(self.wires, VAR_12=self.hbar)\n",
"self.reset()\n",
"for operation in self._queue:\n",
"if operation.name not in VAR_0:\n",
"self.state = self.eng.run('fock', cutoff_dim=self.cutoff)\n",
"VAR_17 = [(x.val if isinstance(x, Variable) else x) for x in operation.params]\n",
"VAR_14 = self._observe.wires\n",
"VAR_18 = VAR_0[operation.name](*VAR_17)\n",
"if self._observe.name == 'Fock':\n",
"if isinstance(operation.wires, int):\n",
"VAR_15 = self.state.mean_photon(VAR_14)\n",
"if self._observe.name == 'X':\n",
"VAR_18 | VAR_13[operation.wires]\n",
"VAR_18 | [VAR_13[i] for i in operation.wires]\n",
"VAR_16 = 0\n",
"VAR_15, VAR_16 = self.state.quad_expectation(VAR_14, 0)\n",
"if self._observe.name == 'P':\n",
"if self.shots != 0:\n",
"VAR_15, VAR_16 = self.state.quad_expectation(VAR_14, np.pi / 2)\n",
"if self._observe.name == 'Homodyne':\n",
"VAR_15 = np.random.normal(VAR_15, np.sqrt(VAR_16 / self.shots))\n",
"self._out = VAR_15\n",
"VAR_15, VAR_16 = self.state.quad_expectation(VAR_14, *self.observe.params)\n"
] |
[
"def execute(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.eng:\n",
"self.eng.reset()\n",
"self.eng, q = sf.Engine(self.wires, hbar=self.hbar)\n",
"self.reset()\n",
"for operation in self._queue:\n",
"if operation.name not in operator_map:\n",
"self.state = self.eng.run('fock', cutoff_dim=self.cutoff)\n",
"p = [(x.val if isinstance(x, Variable) else x) for x in operation.params]\n",
"reg = self._observe.wires\n",
"op = operator_map[operation.name](*p)\n",
"if self._observe.name == 'Fock':\n",
"if isinstance(operation.wires, int):\n",
"ex = self.state.mean_photon(reg)\n",
"if self._observe.name == 'X':\n",
"op | q[operation.wires]\n",
"op | [q[i] for i in operation.wires]\n",
"var = 0\n",
"ex, var = self.state.quad_expectation(reg, 0)\n",
"if self._observe.name == 'P':\n",
"if self.shots != 0:\n",
"ex, var = self.state.quad_expectation(reg, np.pi / 2)\n",
"if self._observe.name == 'Homodyne':\n",
"ex = np.random.normal(ex, np.sqrt(var / self.shots))\n",
"self._out = ex\n",
"ex, var = self.state.quad_expectation(reg, *self.observe.params)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"For",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_19(self, VAR_6, VAR_14):...\n",
"self.common.extend_volume(VAR_6, VAR_14)\n"
] |
[
"def extend_volume(self, volume, new_size):...\n",
"self.common.extend_volume(volume, new_size)\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return len(self.edges)\n"
] |
[
"def ecount(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return len(self.edges)\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"import json\n",
"from django.contrib.postgres import forms, lookups\n",
"from django.contrib.postgres.fields.array import ArrayField\n",
"from django.core import exceptions\n",
"from django.db.models import Field, TextField, Transform\n",
"from django.utils.translation import gettext_lazy as _\n",
"from .mixins import CheckFieldDefaultMixin\n",
"__all__ = ['HStoreField']\n",
"VAR_0 = False\n",
"VAR_1 = _('Map of strings to strings/nulls')\n",
"VAR_2 = {'not_a_string': _('The value of “%(key)s” is not a string or null.')}\n",
"VAR_3 = 'dict', '{}'\n",
"def FUNC_0(self, VAR_4):...\n",
"return 'hstore'\n"
] |
[
"import json\n",
"from django.contrib.postgres import forms, lookups\n",
"from django.contrib.postgres.fields.array import ArrayField\n",
"from django.core import exceptions\n",
"from django.db.models import Field, TextField, Transform\n",
"from django.utils.translation import gettext_lazy as _\n",
"from .mixins import CheckFieldDefaultMixin\n",
"__all__ = ['HStoreField']\n",
"empty_strings_allowed = False\n",
"description = _('Map of strings to strings/nulls')\n",
"default_error_messages = {'not_a_string': _(\n 'The value of “%(key)s” is not a string or null.')}\n",
"_default_hint = 'dict', '{}'\n",
"def db_type(self, connection):...\n",
"return 'hstore'\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_5(self):...\n",
"if not self._server_popen:\n",
"return -1\n",
"return self._server_popen.pid\n"
] |
[
"def ServerPid(self):...\n",
"if not self._server_popen:\n",
"return -1\n",
"return self._server_popen.pid\n"
] |
[
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"import hashlib\n",
"from webapp.web import BaseHandler\n",
"from model import dbapi\n",
"def FUNC_0(self):...\n",
"if self.check_xsrf_cookie() == False:\n",
"VAR_0 = 'xsrf invalid'\n",
"def FUNC_1(self, VAR_0=''):...\n",
"self.get(VAR_0)\n",
"VAR_1 = self.xsrf_from_html()\n",
"VAR_2 = {'error_info': VAR_0, 'xsrf_token': VAR_1}\n",
"VAR_3 = self.wrap_html('templates/register.html', VAR_2)\n",
"return self.write(VAR_3)\n"
] |
[
"import hashlib\n",
"from webapp.web import BaseHandler\n",
"from model import dbapi\n",
"def check_xsrf(self):...\n",
"if self.check_xsrf_cookie() == False:\n",
"error = 'xsrf invalid'\n",
"def get(self, error=''):...\n",
"self.get(error)\n",
"xsrf_token = self.xsrf_from_html()\n",
"params = {'error_info': error, 'xsrf_token': xsrf_token}\n",
"body = self.wrap_html('templates/register.html', params)\n",
"return self.write(body)\n"
] |
[
0,
0,
0,
0,
0,
5,
0,
5,
0,
0,
0,
0
] |
[
"Import'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Condition",
"Assign'",
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_4(VAR_6, VAR_7=3):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = list(VAR_6)\n",
"VAR_26 = lambda : [VAR_0 for VAR_0 in VAR_6 if not os.path.exists(VAR_0)]\n",
"VAR_27 = VAR_26()\n",
"if VAR_27:\n",
"logger.info('Waiting at most {} seconds for missing files.'.format(VAR_7))\n",
"for _ in range(VAR_7):\n",
"if not VAR_26():\n",
"return\n",
"VAR_23.sleep(1)\n"
] |
[
"def wait_for_files(files, latency_wait=3):...\n",
"\"\"\"docstring\"\"\"\n",
"files = list(files)\n",
"get_missing = lambda : [f for f in files if not os.path.exists(f)]\n",
"missing = get_missing()\n",
"if missing:\n",
"logger.info('Waiting at most {} seconds for missing files.'.format(\n latency_wait))\n",
"for _ in range(latency_wait):\n",
"if not get_missing():\n",
"return\n",
"time.sleep(1)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"For",
"Condition",
"Return'",
"Expr'"
] |
[
"def FUNC_6(self):...\n",
"\"\"\"docstring\"\"\"\n",
"FUNC_0()\n"
] |
[
"def test_connect_to_database(self):...\n",
"\"\"\"docstring\"\"\"\n",
"connect()\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Expr'"
] |
[
"def FUNC_0(self):...\n",
"VAR_8 = []\n",
"for VAR_5 in self.groups:\n",
"VAR_8.append(VAR_5.serialize())\n",
"return dict(VAR_2=self.name, vars=self.vars.copy(), address=self.address,\n uuid=self._uuid, VAR_8=groups, implicit=self.implicit)\n"
] |
[
"def serialize(self):...\n",
"groups = []\n",
"for group in self.groups:\n",
"groups.append(group.serialize())\n",
"return dict(name=self.name, vars=self.vars.copy(), address=self.address,\n uuid=self._uuid, groups=groups, implicit=self.implicit)\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"For",
"Expr'",
"Return'"
] |
[
"def FUNC_21(VAR_27, VAR_28, VAR_29, VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_49 = len(VAR_27)\n",
"if VAR_49 <= ray_constants.PICKLE_OBJECT_WARNING_SIZE:\n",
"return\n",
"VAR_50 = 'string'.format(VAR_29, VAR_28, VAR_49)\n",
"FUNC_2(VAR_2, ray_constants.PICKLING_LARGE_OBJECT_PUSH_ERROR, VAR_50, VAR_5\n =worker.task_driver_id)\n"
] |
[
"def check_oversized_pickle(pickled, name, obj_type, worker):...\n",
"\"\"\"docstring\"\"\"\n",
"length = len(pickled)\n",
"if length <= ray_constants.PICKLE_OBJECT_WARNING_SIZE:\n",
"return\n",
"warning_message = (\n 'Warning: The {} {} has size {} when pickled. It will be stored in Redis, which could cause memory issues. This may mean that its definition uses a large array or other object.'\n .format(obj_type, name, length))\n",
"push_error_to_driver(worker, ray_constants.PICKLING_LARGE_OBJECT_PUSH_ERROR,\n warning_message, driver_id=worker.task_driver_id)\n"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Expr'"
] |
[
"def FUNC_0(self, VAR_2, VAR_3, VAR_4, VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_6 = []\n",
"VAR_7 = self.pool.get('ir.model.data')\n",
"VAR_8 = self.pool.get('res.users').browse(VAR_2, VAR_3, VAR_3).company_id.id\n",
"VAR_9 = self.pool.get('account.bank.statement')\n",
"VAR_10 = self.pool.get('ir.sequence')\n",
"VAR_11 = self.pool.get('account.journal')\n",
"VAR_2.execute(\n 'select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id'\n % VAR_3)\n",
"VAR_12 = map(lambda x1: x1[0], VAR_2.fetchall())\n",
"VAR_2.execute('string' % ','.join(map(lambda x: \"'\" + str(x) + \"'\", VAR_12)))\n",
"VAR_13 = map(lambda x1: x1[0], VAR_2.fetchall())\n",
"for journal in VAR_11.browse(VAR_2, VAR_3, VAR_13):\n",
"VAR_4 = VAR_9.search(VAR_2, VAR_3, [('state', '!=', 'confirm'), ('user_id',\n '=', VAR_3), ('journal_id', '=', journal.id)])\n",
"VAR_14 = self.pool.get('ir.model.data')\n",
"if len(VAR_4):\n",
"VAR_15 = VAR_14._get_id(VAR_2, VAR_3, 'account', 'view_bank_statement_tree')\n",
"VAR_17 = ''\n",
"VAR_16 = VAR_14._get_id(VAR_2, VAR_3, 'account', 'view_bank_statement_form2')\n",
"if journal.sequence_id:\n",
"if VAR_15:\n",
"VAR_17 = VAR_10.get_id(VAR_2, VAR_3, journal.sequence_id.id)\n",
"VAR_17 = VAR_10.get(VAR_2, VAR_3, 'account.bank.statement')\n",
"VAR_15 = VAR_14.browse(VAR_2, VAR_3, VAR_15, VAR_5=context).res_id\n",
"if VAR_16:\n",
"VAR_18 = VAR_9.create(VAR_2, VAR_3, {'journal_id': journal.id, 'company_id':\n VAR_8, 'user_id': VAR_3, 'state': 'open', 'name': VAR_17,\n 'starting_details_ids': VAR_9._get_cash_close_box_lines(VAR_2, VAR_3, [])})\n",
"VAR_16 = VAR_14.browse(VAR_2, VAR_3, VAR_16, VAR_5=context).res_id\n",
"return {'domain': \"[('state','=','open')]\", 'name': 'Open Statement',\n 'view_type': 'form', 'view_mode': 'tree,form', 'res_model':\n 'account.bank.statement', 'views': [(VAR_15, 'tree'), (VAR_16, 'form')],\n 'type': 'ir.actions.act_window'}\n",
"VAR_9.button_open(VAR_2, VAR_3, [VAR_18], VAR_5)\n"
] |
[
"def open_statement(self, cr, uid, ids, context):...\n",
"\"\"\"docstring\"\"\"\n",
"list_statement = []\n",
"mod_obj = self.pool.get('ir.model.data')\n",
"company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id\n",
"statement_obj = self.pool.get('account.bank.statement')\n",
"sequence_obj = self.pool.get('ir.sequence')\n",
"journal_obj = self.pool.get('account.journal')\n",
"cr.execute(\n 'select DISTINCT journal_id from pos_journal_users where user_id=%d order by journal_id'\n % uid)\n",
"j_ids = map(lambda x1: x1[0], cr.fetchall())\n",
"cr.execute(\n \"\"\" select id from account_journal\n where auto_cash='True' and type='cash'\n and id in (%s)\"\"\"\n % ','.join(map(lambda x: \"'\" + str(x) + \"'\", j_ids)))\n",
"journal_ids = map(lambda x1: x1[0], cr.fetchall())\n",
"for journal in journal_obj.browse(cr, uid, journal_ids):\n",
"ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id',\n '=', uid), ('journal_id', '=', journal.id)])\n",
"data_obj = self.pool.get('ir.model.data')\n",
"if len(ids):\n",
"id2 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')\n",
"number = ''\n",
"id3 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')\n",
"if journal.sequence_id:\n",
"if id2:\n",
"number = sequence_obj.get_id(cr, uid, journal.sequence_id.id)\n",
"number = sequence_obj.get(cr, uid, 'account.bank.statement')\n",
"id2 = data_obj.browse(cr, uid, id2, context=context).res_id\n",
"if id3:\n",
"statement_id = statement_obj.create(cr, uid, {'journal_id': journal.id,\n 'company_id': company_id, 'user_id': uid, 'state': 'open', 'name':\n number, 'starting_details_ids': statement_obj._get_cash_close_box_lines\n (cr, uid, [])})\n",
"id3 = data_obj.browse(cr, uid, id3, context=context).res_id\n",
"return {'domain': \"[('state','=','open')]\", 'name': 'Open Statement',\n 'view_type': 'form', 'view_mode': 'tree,form', 'res_model':\n 'account.bank.statement', 'views': [(id2, 'tree'), (id3, 'form')],\n 'type': 'ir.actions.act_window'}\n",
"statement_obj.button_open(cr, uid, [statement_id], context)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Expr'"
] |
[
"def FUNC_5(self):...\n",
"VAR_14 = self.new_mocked_client(client.RESTClient, url_prefix='api/v1/')\n",
"VAR_17 = VAR_14.new_client_for('switch/ports')\n",
"VAR_17.get('11a2b')\n",
"FUNC_1('get', VAR_17, 'https://1.2.3.4/api/v1/switch/ports/11a2b')\n"
] |
[
"def test_client_for(self):...\n",
"api = self.new_mocked_client(client.RESTClient, url_prefix='api/v1/')\n",
"sub_api = api.new_client_for('switch/ports')\n",
"sub_api.get('11a2b')\n",
"assert_call('get', sub_api, 'https://1.2.3.4/api/v1/switch/ports/11a2b')\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@classmethod...\n",
"\"\"\"docstring\"\"\"\n",
"return VAR_14(VAR_4=home, VAR_5=None)\n"
] |
[
"@classmethod...\n",
"\"\"\"docstring\"\"\"\n",
"return cls(home_path=home, bin_path=None)\n"
] |
[
0,
0,
0
] |
[
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_3(self, VAR_18):...\n",
"if self.command in VAR_18:\n",
"VAR_18[self.command](*self.args)\n",
"VAR_45 = os.fork()\n",
"if VAR_45 == 0:\n",
"os.execv(self.full_command, self.args)\n",
"self.pid = VAR_45\n"
] |
[
"def execute(self, builtins):...\n",
"if self.command in builtins:\n",
"builtins[self.command](*self.args)\n",
"pid = os.fork()\n",
"if pid == 0:\n",
"os.execv(self.full_command, self.args)\n",
"self.pid = pid\n"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Assign'"
] |
[
"def FUNC_4(self, VAR_3):...\n",
"VAR_4 = cStringIO.StringIO()\n",
"self.parser.dump(VAR_4)\n",
"VAR_5 = VAR_4.getvalue()\n",
"VAR_4.close()\n",
"self.assertEqual(VAR_5, VAR_3.lstrip())\n"
] |
[
"def representation_is(self, content):...\n",
"target = cStringIO.StringIO()\n",
"self.parser.dump(target)\n",
"repr_ = target.getvalue()\n",
"target.close()\n",
"self.assertEqual(repr_, content.lstrip())\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"def FUNC_5(self, VAR_21):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_24 = self.getfile(VAR_21, VAR_23=False)\n",
"if VAR_24 is not False:\n",
"return True\n"
] |
[
"def lexists(self, path):...\n",
"\"\"\"docstring\"\"\"\n",
"f = self.getfile(path, follow_symlinks=False)\n",
"if f is not False:\n",
"return True\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_16(self):...\n",
"return False\n"
] |
[
"def do_existing_paths(self):...\n",
"return False\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_17(self, VAR_34):...\n",
"\"\"\"docstring\"\"\"\n",
"if not VAR_34:\n",
"return True\n",
"if self.tempfiles[VAR_34] is not None:\n",
"VAR_70 = hashlib.sha256(FUNC_14(self.tempfiles[VAR_34], 'rb').read()\n ).hexdigest()\n",
"return os.close(VAR_34)\n",
"VAR_71 = self.cfg.get('honeypot', 'download_path') + '/' + VAR_70\n",
"if os.path.exists(VAR_71):\n",
"os.remove(self.tempfiles[VAR_34])\n",
"os.rename(self.tempfiles[VAR_34], VAR_71)\n",
"self.update_realfile(self.getfile(self.filenames[VAR_34]), VAR_71)\n",
"log.msg(format='SFTP Uploaded file \"%(filename)s\" to %(outfile)s', eventid=\n 'cowrie.session.file_upload', VAR_32=os.path.basename(self.filenames[fd\n ]), VAR_59=shasumfile, VAR_70=shasum)\n"
] |
[
"def close(self, fd):...\n",
"\"\"\"docstring\"\"\"\n",
"if not fd:\n",
"return True\n",
"if self.tempfiles[fd] is not None:\n",
"shasum = hashlib.sha256(open(self.tempfiles[fd], 'rb').read()).hexdigest()\n",
"return os.close(fd)\n",
"shasumfile = self.cfg.get('honeypot', 'download_path') + '/' + shasum\n",
"if os.path.exists(shasumfile):\n",
"os.remove(self.tempfiles[fd])\n",
"os.rename(self.tempfiles[fd], shasumfile)\n",
"self.update_realfile(self.getfile(self.filenames[fd]), shasumfile)\n",
"log.msg(format='SFTP Uploaded file \"%(filename)s\" to %(outfile)s', eventid=\n 'cowrie.session.file_upload', filename=os.path.basename(self.filenames[\n fd]), outfile=shasumfile, shasum=shasum)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"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"
] |
[
"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,
5,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_5(VAR_3, VAR_4, VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"if not FUNC_6(VAR_3, VAR_4, VAR_5):\n",
"VAR_7 = \"ALTER SYSTEM SET %s TO '%s'\"\n",
"return False\n",
"VAR_3.execute(VAR_7 % (VAR_4, VAR_5))\n",
"return True\n"
] |
[
"def option_set(cursor, option, value):...\n",
"\"\"\"docstring\"\"\"\n",
"if not option_matches(cursor, option, value):\n",
"query = \"ALTER SYSTEM SET %s TO '%s'\"\n",
"return False\n",
"cursor.execute(query % (option, value))\n",
"return True\n"
] |
[
0,
0,
4,
0,
0,
4,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Return'",
"Expr'",
"Return'"
] |
[
"def FUNC_7(VAR_9, VAR_10):...\n",
"\"\"\"docstring\"\"\"\n",
"assert VAR_9 in ['tags_key', 'tags_value']\n",
"VAR_7, VAR_39 = VAR_9.split('_', 1)\n",
"VAR_40 = state.get_config('nested_tags_only', 1)\n",
"if VAR_40:\n",
"VAR_63 = '{}.key'.format(VAR_7)\n",
"VAR_65 = PROMOTED_COLS[VAR_7]\n",
"VAR_64 = '{}.value'.format(VAR_7)\n",
"VAR_66 = COLUMN_TAG_MAP[VAR_7]\n",
"VAR_41 = FUNC_9(VAR_10) & set(['tags_key', 'tags_value'])\n",
"VAR_63 = u'arrayConcat([{}], {}.key)'.format(u', '.join(u\"'{}'\".format(\n VAR_66.get(p, p)) for p in VAR_65), VAR_7)\n",
"if len(VAR_41) == 2:\n",
"VAR_64 = u'arrayConcat([{}], {}.value)'.format(', '.join(FUNC_1(p) for p in\n VAR_65), VAR_7)\n",
"VAR_13 = u'arrayJoin(arrayMap((x,y) -> [x,y], {}, {}))'.format(VAR_63, VAR_64)\n",
"return 'arrayJoin({})'.format(VAR_63 if VAR_39 == 'key' else VAR_64)\n",
"VAR_13 = FUNC_5(VAR_13, 'all_tags', VAR_10)\n",
"return u'({})[{}]'.format(VAR_13, 1 if VAR_39 == 'key' else 2)\n"
] |
[
"def tags_expr(column_name, body):...\n",
"\"\"\"docstring\"\"\"\n",
"assert column_name in ['tags_key', 'tags_value']\n",
"col, k_or_v = column_name.split('_', 1)\n",
"nested_tags_only = state.get_config('nested_tags_only', 1)\n",
"if nested_tags_only:\n",
"key_list = '{}.key'.format(col)\n",
"promoted = PROMOTED_COLS[col]\n",
"val_list = '{}.value'.format(col)\n",
"col_map = COLUMN_TAG_MAP[col]\n",
"cols_used = all_referenced_columns(body) & set(['tags_key', 'tags_value'])\n",
"key_list = u'arrayConcat([{}], {}.key)'.format(u', '.join(u\"'{}'\".format(\n col_map.get(p, p)) for p in promoted), col)\n",
"if len(cols_used) == 2:\n",
"val_list = u'arrayConcat([{}], {}.value)'.format(', '.join(string_col(p) for\n p in promoted), col)\n",
"expr = u'arrayJoin(arrayMap((x,y) -> [x,y], {}, {}))'.format(key_list, val_list\n )\n",
"return 'arrayJoin({})'.format(key_list if k_or_v == 'key' else val_list)\n",
"expr = alias_expr(expr, 'all_tags', body)\n",
"return u'({})[{}]'.format(expr, 1 if k_or_v == 'key' else 2)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assert'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Assign'",
"Return'"
] |
[
"def __init__(self, VAR_1, VAR_3=None):...\n",
"FUNC_0(self)\n",
"self.list_columns = dict()\n",
"self.list_properties = dict()\n",
"self.session = VAR_3\n",
"for VAR_36 in sa.orm.class_mapper(VAR_1).iterate_properties:\n",
"if type(VAR_36) != SynonymProperty:\n",
"for VAR_14 in VAR_1.__mapper__.columns.keys():\n",
"self.list_properties[VAR_36.key] = VAR_36\n",
"if VAR_14 in self.list_properties:\n",
"super(CLASS_0, self).__init__(VAR_1)\n",
"self.list_columns[VAR_14] = VAR_1.__mapper__.columns[VAR_14]\n"
] |
[
"def __init__(self, obj, session=None):...\n",
"_include_filters(self)\n",
"self.list_columns = dict()\n",
"self.list_properties = dict()\n",
"self.session = session\n",
"for prop in sa.orm.class_mapper(obj).iterate_properties:\n",
"if type(prop) != SynonymProperty:\n",
"for col_name in obj.__mapper__.columns.keys():\n",
"self.list_properties[prop.key] = prop\n",
"if col_name in self.list_properties:\n",
"super(SQLAInterface, self).__init__(obj)\n",
"self.list_columns[col_name] = obj.__mapper__.columns[col_name]\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"For",
"Assign'",
"Condition",
"Expr'",
"Assign'"
] |
[
"def FUNC_27(VAR_50):...\n",
"if re.compile('^(select|delete|update|drop|create)\\\\s').match(VAR_50):\n",
"FUNC_26()\n",
"if re.compile('\\\\s*[a-zA-z]*\\\\s*( from | group by | order by | where | join )'\n",
"FUNC_26()\n"
] |
[
"def _is_query(field):...\n",
"if re.compile('^(select|delete|update|drop|create)\\\\s').match(field):\n",
"_raise_exception()\n",
"if re.compile('\\\\s*[a-zA-z]*\\\\s*( from | group by | order by | where | join )'\n",
"_raise_exception()\n"
] |
[
0,
0,
0,
4,
0
] |
[
"FunctionDef'",
"Condition",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_0(self):...\n",
"if not GenericRequest.test_success(self):\n",
"return False\n",
"self.get_submission_info()\n",
"return False\n",
"return True\n"
] |
[
"def test_success(self):...\n",
"if not GenericRequest.test_success(self):\n",
"return False\n",
"self.get_submission_info()\n",
"return False\n",
"return True\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Return'",
"Expr'",
"Return'",
"Return'"
] |
[
"def __init__(self, VAR_32):...\n",
"super(CLASS_1, self).__init__()\n",
"self.signal = VAR_32\n"
] |
[
"def __init__(self, sig):...\n",
"super(MustExit, self).__init__()\n",
"self.signal = sig\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Assign'"
] |
[
"def FUNC_0(self, VAR_4, VAR_5):...\n",
"\"\"\"docstring\"\"\"\n",
"assert not VAR_4.endswith('/')\n",
"assert not VAR_5.endswith('/')\n",
"if '/' in VAR_5:\n",
"VAR_34, VAR_5 = VAR_5.split('/', 1)\n",
"if VAR_5 in self.nodes:\n",
"if VAR_34 in self.nodes:\n",
"return self.nodes[VAR_5]\n",
"VAR_20 = '{}/{}'.format(self.vpath, VAR_5).lstrip('/')\n",
"return self.nodes[VAR_34].add(VAR_4, VAR_5)\n",
"VAR_21 = CLASS_0('{}/{}'.format(self.realpath, VAR_34), '{}/{}'.format(self\n .vpath, VAR_34).lstrip('/'), self.uread, self.uwrite)\n",
"VAR_21 = CLASS_0(VAR_4, VAR_20)\n",
"self.nodes[VAR_34] = VAR_21\n",
"self.nodes[VAR_5] = VAR_21\n",
"return VAR_21.add(VAR_4, VAR_5)\n",
"return VAR_21\n"
] |
[
"def add(self, src, dst):...\n",
"\"\"\"docstring\"\"\"\n",
"assert not src.endswith('/')\n",
"assert not dst.endswith('/')\n",
"if '/' in dst:\n",
"name, dst = dst.split('/', 1)\n",
"if dst in self.nodes:\n",
"if name in self.nodes:\n",
"return self.nodes[dst]\n",
"vp = '{}/{}'.format(self.vpath, dst).lstrip('/')\n",
"return self.nodes[name].add(src, dst)\n",
"vn = VFS('{}/{}'.format(self.realpath, name), '{}/{}'.format(self.vpath,\n name).lstrip('/'), self.uread, self.uwrite)\n",
"vn = VFS(src, vp)\n",
"self.nodes[name] = vn\n",
"self.nodes[dst] = vn\n",
"return vn.add(src, dst)\n",
"return vn\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assert'",
"Assert'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Return'",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'",
"Return'"
] |
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"if 'network' in VAR_5 and 'domains' in VAR_5['network']:\n",
"VAR_20 = dict((i['domain'], i['ip']) for i in VAR_5['network']['domains'])\n",
"VAR_20 = dict()\n",
"VAR_21 = dict((i['ip'], i['domain']) for i in VAR_5['network']['domains'])\n",
"VAR_21 = dict()\n",
"for i in VAR_5['network']['dns']:\n",
"return {'domainlookups': VAR_20, 'iplookups': VAR_21}\n",
"for VAR_29 in i['answers']:\n",
"VAR_21[VAR_29['data']] = i['request']\n"
] |
[
"@staticmethod...\n",
"\"\"\"docstring\"\"\"\n",
"if 'network' in report and 'domains' in report['network']:\n",
"domainlookups = dict((i['domain'], i['ip']) for i in report['network'][\n 'domains'])\n",
"domainlookups = dict()\n",
"iplookups = dict((i['ip'], i['domain']) for i in report['network']['domains'])\n",
"iplookups = dict()\n",
"for i in report['network']['dns']:\n",
"return {'domainlookups': domainlookups, 'iplookups': iplookups}\n",
"for a in i['answers']:\n",
"iplookups[a['data']] = i['request']\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Return'",
"For",
"Assign'"
] |
[
"def FUNC_2(self):...\n",
"VAR_6 = 'SELECT MAX(bno) FROM bookings'\n",
"self.cursor.execute(VAR_6)\n",
"VAR_8 = self.cursor.fetchone()\n",
"return int(VAR_8[0]) + 1\n"
] |
[
"def generate_bno(self):...\n",
"query = 'SELECT MAX(bno) FROM bookings'\n",
"self.cursor.execute(query)\n",
"max_bno = self.cursor.fetchone()\n",
"return int(max_bno[0]) + 1\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_32(self, VAR_15):...\n",
"for file_col in self.get_file_column_list():\n",
"if self.is_file(file_col):\n",
"for file_col in self.get_image_column_list():\n",
"if getattr(VAR_15, file_col):\n",
"if self.is_image(file_col):\n",
"VAR_28 = FileManager()\n",
"if getattr(VAR_15, file_col):\n",
"VAR_28.delete_file(getattr(VAR_15, file_col))\n",
"VAR_29 = ImageManager()\n",
"VAR_29.delete_file(getattr(VAR_15, file_col))\n"
] |
[
"def _delete_files(self, item):...\n",
"for file_col in self.get_file_column_list():\n",
"if self.is_file(file_col):\n",
"for file_col in self.get_image_column_list():\n",
"if getattr(item, file_col):\n",
"if self.is_image(file_col):\n",
"fm = FileManager()\n",
"if getattr(item, file_col):\n",
"fm.delete_file(getattr(item, file_col))\n",
"im = ImageManager()\n",
"im.delete_file(getattr(item, file_col))\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"For",
"Condition",
"For",
"Condition",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_4(self):...\n",
"if self._user_notified_about_crash or self._IsServerAlive():\n",
"return\n",
"self._user_notified_about_crash = True\n",
"if self._server_stderr:\n",
"VAR_27 = ''.join(server_stderr_file.readlines()[:-VAR_1])\n",
"vimsupport.PostVimMessage(VAR_3)\n",
"vimsupport.PostMultiLineNotice(VAR_2 + VAR_27)\n"
] |
[
"def _NotifyUserIfServerCrashed(self):...\n",
"if self._user_notified_about_crash or self._IsServerAlive():\n",
"return\n",
"self._user_notified_about_crash = True\n",
"if self._server_stderr:\n",
"error_output = ''.join(server_stderr_file.readlines()[:-\n NUM_YCMD_STDERR_LINES_ON_CRASH])\n",
"vimsupport.PostVimMessage(SERVER_CRASH_MESSAGE_SAME_STDERR)\n",
"vimsupport.PostMultiLineNotice(SERVER_CRASH_MESSAGE_STDERR_FILE + error_output)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Expr'"
] |
[
"async def FUNC_15(VAR_3):...\n",
"VAR_19 = await VAR_1(VAR_3, VAR_4)\n",
"return VAR_19\n"
] |
[
"async def ret(request):...\n",
"out = await func(request, base)\n",
"return out\n"
] |
[
0,
0,
0
] |
[
"AsyncFunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return True\n"
] |
[
"def do_traverse(self):...\n",
"\"\"\"docstring\"\"\"\n",
"return True\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def __init__(self, VAR_0=None, VAR_1=None, VAR_2=None, VAR_3=None, VAR_4=None):...\n",
"self.name = VAR_1\n",
"self.password = VAR_2\n",
"self.email = VAR_3\n",
"self.country = VAR_4\n",
"self.conn = VAR_0\n"
] |
[
"def __init__(self, conn=None, name=None, password=None, email=None, country...\n",
"self.name = name\n",
"self.password = password\n",
"self.email = email\n",
"self.country = country\n",
"self.conn = conn\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_8(self, VAR_2):...\n",
"VAR_8 = []\n",
"VAR_10 = False\n",
"for i, ch in enumerate(VAR_2):\n",
"if ch in ['\"', \"'\"]:\n",
"return VAR_8\n",
"VAR_10 = not VAR_10\n",
"if ch == ';' and not VAR_10:\n",
"VAR_8.append(i)\n",
"if ch == '#' and not VAR_10:\n"
] |
[
"def _find_breakpoints(self, line):...\n",
"breakpoints = []\n",
"in_quote = False\n",
"for i, ch in enumerate(line):\n",
"if ch in ['\"', \"'\"]:\n",
"return breakpoints\n",
"in_quote = not in_quote\n",
"if ch == ';' and not in_quote:\n",
"breakpoints.append(i)\n",
"if ch == '#' and not in_quote:\n"
] |
[
0,
2,
2,
2,
2,
2,
2,
2,
2,
2
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"For",
"Condition",
"Return'",
"Assign'",
"Condition",
"Expr'",
"Condition"
] |
[
"def FUNC_11(VAR_7, VAR_6):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_19 = VAR_7.hook\n",
"VAR_20 = list(set(itertools.chain(*VAR_19.tljh_extra_apt_packages())))\n",
"if VAR_20:\n",
"VAR_1.info('Installing {} apt packages collected from plugins: {}'.format(\n len(VAR_20), ' '.join(VAR_20)))\n",
"VAR_21 = list(set(itertools.chain(*VAR_19.tljh_extra_user_conda_packages())))\n",
"apt.install_packages(VAR_20)\n",
"if VAR_21:\n",
"VAR_1.info('Installing {} conda packages collected from plugins: {}'.format\n (len(VAR_21), ' '.join(VAR_21)))\n",
"VAR_22 = list(set(itertools.chain(*VAR_19.tljh_extra_user_pip_packages())))\n",
"conda.ensure_conda_packages(USER_ENV_PREFIX, VAR_21)\n",
"if VAR_22:\n",
"VAR_1.info('Installing {} pip packages collected from plugins: {}'.format(\n len(VAR_22), ' '.join(VAR_22)))\n",
"conda.ensure_pip_packages(USER_ENV_PREFIX, VAR_22)\n"
] |
[
"def run_plugin_actions(plugin_manager, plugins):...\n",
"\"\"\"docstring\"\"\"\n",
"hook = plugin_manager.hook\n",
"apt_packages = list(set(itertools.chain(*hook.tljh_extra_apt_packages())))\n",
"if apt_packages:\n",
"logger.info('Installing {} apt packages collected from plugins: {}'.format(\n len(apt_packages), ' '.join(apt_packages)))\n",
"conda_packages = list(set(itertools.chain(*hook.\n tljh_extra_user_conda_packages())))\n",
"apt.install_packages(apt_packages)\n",
"if conda_packages:\n",
"logger.info('Installing {} conda packages collected from plugins: {}'.\n format(len(conda_packages), ' '.join(conda_packages)))\n",
"pip_packages = list(set(itertools.chain(*hook.tljh_extra_user_pip_packages())))\n",
"conda.ensure_conda_packages(USER_ENV_PREFIX, conda_packages)\n",
"if pip_packages:\n",
"logger.info('Installing {} pip packages collected from plugins: {}'.format(\n len(pip_packages), ' '.join(pip_packages)))\n",
"conda.ensure_pip_packages(USER_ENV_PREFIX, pip_packages)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_8(VAR_10):...\n",
"VAR_0 = []\n",
"VAR_28 = 0\n",
"VAR_11 = set()\n",
"for VAR_29 in VAR_5.finditer(VAR_10):\n",
"VAR_0.append(re.escape(VAR_10[VAR_28:VAR_29.start()]))\n",
"VAR_0.append(re.escape(VAR_10[VAR_28:]))\n",
"VAR_51 = VAR_29.group('name')\n",
"VAR_0.append('$')\n",
"if VAR_51 in VAR_11:\n",
"return ''.join(VAR_0)\n",
"if VAR_29.group('constraint'):\n",
"VAR_11.add(VAR_51)\n",
"VAR_0.append('(?P={})'.format(VAR_51))\n",
"VAR_0.append('(?P<{}>{})'.format(VAR_51, VAR_29.group('constraint') if\n VAR_29.group('constraint') else '.+'))\n",
"VAR_28 = VAR_29.end()\n"
] |
[
"def regex(filepattern):...\n",
"f = []\n",
"last = 0\n",
"wildcards = set()\n",
"for match in _wildcard_regex.finditer(filepattern):\n",
"f.append(re.escape(filepattern[last:match.start()]))\n",
"f.append(re.escape(filepattern[last:]))\n",
"wildcard = match.group('name')\n",
"f.append('$')\n",
"if wildcard in wildcards:\n",
"return ''.join(f)\n",
"if match.group('constraint'):\n",
"wildcards.add(wildcard)\n",
"f.append('(?P={})'.format(wildcard))\n",
"f.append('(?P<{}>{})'.format(wildcard, match.group('constraint') if match.\n group('constraint') else '.+'))\n",
"last = match.end()\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Condition",
"Return'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Assign'"
] |
[
"def FUNC_2(self):...\n",
"print('TOTAL: %5d' % self.total, file=sys.stderr)\n",
"print('SUCCESS: %5d' % self.success, file=sys.stderr)\n",
"print('FAIL: %5d' % self.failure, file=sys.stderr)\n",
"print('ERROR: %5d' % self.error, file=sys.stderr)\n",
"print('UNDECIDED: %5d' % self.undecided, file=sys.stderr)\n",
"print('Total time: %7.3f' % self.total_time, file=sys.stderr)\n",
"print('Average time: %7.3f' % (self.total_time / self.total), file=sys.stderr)\n",
"print('Max time: %7.3f' % self.max_time, file=sys.stderr)\n"
] |
[
"def print_stats(self):...\n",
"print('TOTAL: %5d' % self.total, file=sys.stderr)\n",
"print('SUCCESS: %5d' % self.success, file=sys.stderr)\n",
"print('FAIL: %5d' % self.failure, file=sys.stderr)\n",
"print('ERROR: %5d' % self.error, file=sys.stderr)\n",
"print('UNDECIDED: %5d' % self.undecided, file=sys.stderr)\n",
"print('Total time: %7.3f' % self.total_time, file=sys.stderr)\n",
"print('Average time: %7.3f' % (self.total_time / self.total), file=sys.stderr)\n",
"print('Max time: %7.3f' % self.max_time, file=sys.stderr)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"import time\n",
"import sys\n",
"import citest.gcp_testing as gcp\n",
"import citest.json_contract as jc\n",
"import citest.service_testing as st\n",
"import spinnaker_testing as sk\n",
"import spinnaker_testing.gate as gate\n",
"@classmethod...\n",
"\"\"\"docstring\"\"\"\n",
"return gate.new_agent(VAR_1)\n"
] |
[
"import time\n",
"import sys\n",
"import citest.gcp_testing as gcp\n",
"import citest.json_contract as jc\n",
"import citest.service_testing as st\n",
"import spinnaker_testing as sk\n",
"import spinnaker_testing.gate as gate\n",
"@classmethod...\n",
"\"\"\"docstring\"\"\"\n",
"return gate.new_agent(bindings)\n"
] |
[
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] |
[
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_25(VAR_10):...\n",
"self.events_requests.remove(VAR_9)\n"
] |
[
"def on_request_finished(_):...\n",
"self.events_requests.remove(request)\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Expr'"
] |
[
"@utils.synchronized('3par', external=True)...\n",
"self.common.client_login()\n",
"VAR_16 = self.common.get_volume_stats(VAR_4)\n",
"VAR_16['storage_protocol'] = 'FC'\n",
"VAR_17 = self.configuration.safe_get('volume_backend_name')\n",
"VAR_16['volume_backend_name'] = VAR_17 or self.__class__.__name__\n",
"self.common.client_logout()\n",
"return VAR_16\n"
] |
[
"@utils.synchronized('3par', external=True)...\n",
"self.common.client_login()\n",
"stats = self.common.get_volume_stats(refresh)\n",
"stats['storage_protocol'] = 'FC'\n",
"backend_name = self.configuration.safe_get('volume_backend_name')\n",
"stats['volume_backend_name'] = backend_name or self.__class__.__name__\n",
"self.common.client_logout()\n",
"return stats\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_7(VAR_7, VAR_12):...\n",
"VAR_9 = FUNC_6(VAR_7, 'Main')\n",
"VAR_9.cmd('send-keys', VAR_12, 'Enter')\n"
] |
[
"def send_main_session_command(session, cmd):...\n",
"window = find_window(session, 'Main')\n",
"window.cmd('send-keys', cmd, 'Enter')\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_15(self, VAR_10, VAR_19, VAR_20, VAR_21, VAR_16=None):...\n",
"if not VAR_16:\n",
"VAR_16 = self.path[-1:][0]\n",
"return VAR_0.insert('file', {'name': VAR_19, 'mime': VAR_20, 'size': VAR_21,\n 'telegram_id': VAR_10, 'directory_id': VAR_16, 'user_id': self.user_id})\n"
] |
[
"def new_file(self, telegram_id, name, mime, size, directory_id=None):...\n",
"if not directory_id:\n",
"directory_id = self.path[-1:][0]\n",
"return db.insert('file', {'name': name, 'mime': mime, 'size': size,\n 'telegram_id': telegram_id, 'directory_id': directory_id, 'user_id':\n self.user_id})\n"
] |
[
0,
0,
0,
4
] |
[
"FunctionDef'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_0(self, VAR_0='crimemap'):...\n",
"return pymysql.connect(host='localhost', user=dbconfig.db_user, passwd=\n dbconfig.db_password, db=database)\n"
] |
[
"def connect(self, database='crimemap'):...\n",
"return pymysql.connect(host='localhost', user=dbconfig.db_user, passwd=\n dbconfig.db_password, db=database)\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_11(VAR_12):...\n",
"return {'id': VAR_12.id, 'size': VAR_12.members.count(), 'collaborators':\n VAR_12.collaborator_names(VAR_7)}\n"
] |
[
"def group_entry(group):...\n",
"return {'id': group.id, 'size': group.members.count(), 'collaborators':\n group.collaborator_names(profile)}\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_0(VAR_0):...\n",
"\"\"\"docstring\"\"\"\n",
"@functools.wraps(VAR_0)...\n",
"if not self.request.headers.get('X-XSRF-Token-Request'):\n",
"return VAR_0(self, *VAR_5, **kwargs)\n"
] |
[
"def require_xsrf_token_request(f):...\n",
"\"\"\"docstring\"\"\"\n",
"@functools.wraps(f)...\n",
"if not self.request.headers.get('X-XSRF-Token-Request'):\n",
"return f(self, *args, **kwargs)\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Condition",
"Return'"
] |
[
"def __ne__(self, VAR_1):...\n",
"return not self.__eq__(VAR_1)\n"
] |
[
"def __ne__(self, other):...\n",
"return not self.__eq__(other)\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_9(VAR_12):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_30 = []\n",
"VAR_31 = []\n",
"VAR_32 = CommerceConfiguration.current()\n",
"VAR_33 = {'username': VAR_12.username}\n",
"VAR_34 = VAR_32.is_cache_enabled\n",
"VAR_35 = VAR_32.CACHE_KEY + '.' + str(VAR_12.id) if VAR_34 else None\n",
"VAR_36 = ecommerce_api_client(VAR_12)\n",
"VAR_37 = get_edx_api_data(VAR_32, 'orders', VAR_36=api, querystring=\n user_query, VAR_35=cache_key)\n",
"for order in VAR_37:\n",
"if order['status'].lower() == 'complete':\n",
"return VAR_31\n",
"VAR_47 = datetime.strptime(order['date_placed'], '%Y-%m-%dT%H:%M:%SZ')\n",
"VAR_48 = {'number': order['number'], 'price': order['total_excl_tax'],\n 'order_date': strftime_localized(VAR_47, 'SHORT_DATE'), 'receipt_url':\n EcommerceService().get_receipt_page_url(order['number']), 'lines':\n order['lines']}\n",
"VAR_31.append(VAR_48)\n"
] |
[
"def get_user_orders(user):...\n",
"\"\"\"docstring\"\"\"\n",
"no_data = []\n",
"user_orders = []\n",
"commerce_configuration = CommerceConfiguration.current()\n",
"user_query = {'username': user.username}\n",
"use_cache = commerce_configuration.is_cache_enabled\n",
"cache_key = commerce_configuration.CACHE_KEY + '.' + str(user.id\n ) if use_cache else None\n",
"api = ecommerce_api_client(user)\n",
"commerce_user_orders = get_edx_api_data(commerce_configuration, 'orders',\n api=api, querystring=user_query, cache_key=cache_key)\n",
"for order in commerce_user_orders:\n",
"if order['status'].lower() == 'complete':\n",
"return user_orders\n",
"date_placed = datetime.strptime(order['date_placed'], '%Y-%m-%dT%H:%M:%SZ')\n",
"order_data = {'number': order['number'], 'price': order['total_excl_tax'],\n 'order_date': strftime_localized(date_placed, 'SHORT_DATE'),\n 'receipt_url': EcommerceService().get_receipt_page_url(order['number']),\n 'lines': order['lines']}\n",
"user_orders.append(order_data)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"@route('GET', '/-test/veil-test.js', VAR_1=website)...\n",
"get_current_http_response().set_header('Content-Type',\n 'text/javascript; charset=utf-8')\n",
"return (as_path(__file__).dirname() / 'veil-test.js').text()\n"
] |
[
"@route('GET', '/-test/veil-test.js', website=website)...\n",
"get_current_http_response().set_header('Content-Type',\n 'text/javascript; charset=utf-8')\n",
"return (as_path(__file__).dirname() / 'veil-test.js').text()\n"
] |
[
0,
0,
0
] |
[
"Condition",
"Expr'",
"Return'"
] |
[
"def __init__(self):...\n",
"tk.Tk.__init__(self)\n",
"self.title('Raspi-Telxon')\n",
"self.titleFont = font.Font(family='Helvetica', size=24)\n",
"self.itemFont = font.Font(family='Helvetica', size=18)\n",
"VAR_7 = tk.Frame(self)\n",
"VAR_7.pack(side='top', fill='both', expand=True)\n",
"VAR_7.grid_rowconfigure(0, weight=1)\n",
"VAR_7.grid_columnconfigure(0, weight=1)\n",
"self.frames = {}\n",
"self.result = ''\n",
"self.container = VAR_7\n",
"for VAR_1 in (CLASS_1, VAR_9):\n",
"VAR_2 = VAR_1(VAR_7, self)\n",
"self.show_frame(CLASS_1)\n",
"self.frames[VAR_1] = VAR_2\n",
"VAR_2.grid(row=0, column=0, sticky='nsew')\n"
] |
[
"def __init__(self):...\n",
"tk.Tk.__init__(self)\n",
"self.title('Raspi-Telxon')\n",
"self.titleFont = font.Font(family='Helvetica', size=24)\n",
"self.itemFont = font.Font(family='Helvetica', size=18)\n",
"container = tk.Frame(self)\n",
"container.pack(side='top', fill='both', expand=True)\n",
"container.grid_rowconfigure(0, weight=1)\n",
"container.grid_columnconfigure(0, weight=1)\n",
"self.frames = {}\n",
"self.result = ''\n",
"self.container = container\n",
"for F in (StartPage, SearchPage):\n",
"frame = F(container, self)\n",
"self.show_frame(StartPage)\n",
"self.frames[F] = frame\n",
"frame.grid(row=0, column=0, sticky='nsew')\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_7():...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_11 = 'string'\n",
"VAR_16 = frappe.db.sql(VAR_11, as_dict=True)\n",
"for r in VAR_16:\n",
"if r.live_ebay_id == '':\n",
"FUNC_5(r.item_code, '')\n",
"if r.item_code:\n",
"FUNC_5(r.sku, r.live_ebay_id)\n",
"msgprint('The ebay item cannot be found on ERPNEXT so unable to record ebay id'\n , r.live_ebay_id)\n"
] |
[
"def sync_ebay_ids():...\n",
"\"\"\"docstring\"\"\"\n",
"sql = \"\"\"\n select * from (\n SELECT t1.sku, t2.item_code, ifnull(t1.ebay_id, '') as live_ebay_id,\n ifnull(t2.ebay_id, '') as dead_ebay_id FROM `zEbayListings` t1\n LEFT JOIN `tabItem` t2 ON t1.sku = t2.item_code\n UNION\n SELECT t1.sku, t2.item_code, ifnull(t1.ebay_id, '') as live_ebay_id,\n ifnull(t2.ebay_id, '') as dead_ebay_id FROM `zEbayListings` t1\n RIGHT JOIN `tabItem` t2 ON t1.sku = t2.item_code\n ) as t\n where t.live_ebay_id <> t.dead_ebay_id\n \"\"\"\n",
"records = frappe.db.sql(sql, as_dict=True)\n",
"for r in records:\n",
"if r.live_ebay_id == '':\n",
"set_item_ebay_id(r.item_code, '')\n",
"if r.item_code:\n",
"set_item_ebay_id(r.sku, r.live_ebay_id)\n",
"msgprint('The ebay item cannot be found on ERPNEXT so unable to record ebay id'\n , r.live_ebay_id)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
4
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"For",
"Condition",
"Expr'",
"Condition",
"Expr'",
"Expr'"
] |
[
"@VAR_2.route('/upload_file', methods=['POST', 'GET'])...\n",
"if request.method == 'POST':\n",
"VAR_6 = request.files['image_upload']\n",
"VAR_6.save('/home/pr0phet/MyProjects/Web/static/' + VAR_6.filename)\n",
"VAR_4 = (\n \"INSERT INTO imageTable(img_path, img_name)\\t\\t\\t\\tVALUES('%s', '%s')\" %\n ('/static/' + VAR_6.filename, VAR_6.filename))\n",
"VAR_1.execute(VAR_4)\n",
"VAR_0.commit()\n",
"return redirect(url_for('index'))\n"
] |
[
"@app.route('/upload_file', methods=['POST', 'GET'])...\n",
"if request.method == 'POST':\n",
"f = request.files['image_upload']\n",
"f.save('/home/pr0phet/MyProjects/Web/static/' + f.filename)\n",
"query = (\n \"INSERT INTO imageTable(img_path, img_name)\\t\\t\\t\\tVALUES('%s', '%s')\" %\n ('/static/' + f.filename, f.filename))\n",
"cursor.execute(query)\n",
"db.commit()\n",
"return redirect(url_for('index'))\n"
] |
[
0,
0,
4,
4,
4,
0,
0,
4
] |
[
"Condition",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Return'"
] |
[
"import json\n",
"import multiprocessing\n",
"from leap.mail.adaptors.soledad import SoledadMailAdaptor\n",
"from leap.srp_session import SRPSession\n",
"from mockito import mock\n",
"import os\n",
"import shutil\n",
"import time\n",
"import uuid\n",
"import random\n",
"from leap.mail.imap.account import IMAPAccount\n",
"from leap.soledad.client import Soledad\n",
"from mock import Mock\n",
"from twisted.internet import reactor, defer\n",
"from twisted.internet.defer import succeed\n",
"from twisted.web.resource import getChildForRequest\n",
"from zope.interface import implementer\n",
"from twisted.cred import checkers, credentials\n",
"from pixelated.adapter.mailstore.leap_attachment_store import LeapAttachmentStore\n",
"from pixelated.adapter.services.feedback_service import FeedbackService\n",
"from pixelated.application import ServicesFactory, UserAgentMode, SingleUserServicesFactory, set_up_protected_resources\n",
"from pixelated.bitmask_libraries.config import LeapConfig\n",
"from pixelated.bitmask_libraries.session import LeapSession\n",
"from pixelated.config.services import Services\n",
"from pixelated.config.site import PixelatedSite\n",
"from pixelated.adapter.mailstore import LeapMailStore\n",
"from pixelated.adapter.mailstore.searchable_mailstore import SearchableMailStore\n",
"from pixelated.adapter.search import SearchEngine\n",
"from pixelated.adapter.services.draft_service import DraftService\n",
"from pixelated.adapter.services.mail_service import MailService\n",
"from pixelated.resources.root_resource import RootResource\n",
"from test.support.integration.model import MailBuilder\n",
"from test.support.test_helper import request_mock\n",
"from test.support.integration.model import ResponseMail\n",
"from tempdir import TempDir\n",
"VAR_2 = (\n 'Þ3?\\x87ÿÙÓ\\x14ð§>\\x1f%C{\\x16.\\\\®\\x8c\\x13§û\\x04Ô]+\\x8d_íÑ\\x8d\\x0bI\\x8a\\x0e¤tm«¿´¥\\x99\\x00dÕw\\x9f\\x18¼\\x1dÔ_WÒ¶èH\\x83\\x1bØ\\x9d\\xad'\n )\n",
"def __init__(self, VAR_3, VAR_4):...\n",
"self._user_id = VAR_3\n",
"self._leap_home = VAR_4\n",
"self._uuid = str(VAR_1.uuid4())\n",
"self._mail_address = '%s@pixelated.org' % VAR_3\n",
"self._soledad = None\n",
"self._services = None\n",
"@defer.inlineCallbacks...\n",
"VAR_37 = os.path.join(self._leap_home, self._uuid)\n",
"self.soledad = yield FUNC_0(VAR_0=soledad_test_folder, VAR_1=self._uuid)\n",
"self.search_engine = SearchEngine(self.INDEX_KEY, user_home=soledad_test_folder\n )\n",
"self.keymanager = mock()\n",
"self.mail_sender = self._create_mail_sender()\n",
"self.mail_store = SearchableMailStore(LeapMailStore(self.soledad), self.\n search_engine)\n",
"self.attachment_store = LeapAttachmentStore(self.soledad)\n",
"yield self._initialize_imap_account()\n",
"self.draft_service = DraftService(self.mail_store)\n",
"self.leap_session = mock()\n",
"self.feedback_service = FeedbackService(self.leap_session)\n",
"self.mail_service = self._create_mail_service(self.mail_sender, self.\n mail_store, self.search_engine, self.attachment_store)\n",
"VAR_58 = yield self.mail_service.all_mails()\n",
"if len(VAR_58) > 0:\n",
"self.search_engine.index_mails(VAR_58)\n",
"@property...\n",
"if self._services is None:\n",
"VAR_79 = mock(Services)\n",
"return self._services\n",
"VAR_79.keymanager = self.keymanager\n",
"VAR_79.mail_service = self.mail_service\n",
"VAR_79.draft_service = self.draft_service\n",
"VAR_79.search_engine = self.search_engine\n",
"VAR_79.feedback_service = self.feedback_service\n",
"VAR_79._leap_session = self.leap_session\n",
"self._services = VAR_79\n",
"self.leap_session.close = lambda : 'mocked'\n"
] |
[
"import json\n",
"import multiprocessing\n",
"from leap.mail.adaptors.soledad import SoledadMailAdaptor\n",
"from leap.srp_session import SRPSession\n",
"from mockito import mock\n",
"import os\n",
"import shutil\n",
"import time\n",
"import uuid\n",
"import random\n",
"from leap.mail.imap.account import IMAPAccount\n",
"from leap.soledad.client import Soledad\n",
"from mock import Mock\n",
"from twisted.internet import reactor, defer\n",
"from twisted.internet.defer import succeed\n",
"from twisted.web.resource import getChildForRequest\n",
"from zope.interface import implementer\n",
"from twisted.cred import checkers, credentials\n",
"from pixelated.adapter.mailstore.leap_attachment_store import LeapAttachmentStore\n",
"from pixelated.adapter.services.feedback_service import FeedbackService\n",
"from pixelated.application import ServicesFactory, UserAgentMode, SingleUserServicesFactory, set_up_protected_resources\n",
"from pixelated.bitmask_libraries.config import LeapConfig\n",
"from pixelated.bitmask_libraries.session import LeapSession\n",
"from pixelated.config.services import Services\n",
"from pixelated.config.site import PixelatedSite\n",
"from pixelated.adapter.mailstore import LeapMailStore\n",
"from pixelated.adapter.mailstore.searchable_mailstore import SearchableMailStore\n",
"from pixelated.adapter.search import SearchEngine\n",
"from pixelated.adapter.services.draft_service import DraftService\n",
"from pixelated.adapter.services.mail_service import MailService\n",
"from pixelated.resources.root_resource import RootResource\n",
"from test.support.integration.model import MailBuilder\n",
"from test.support.test_helper import request_mock\n",
"from test.support.integration.model import ResponseMail\n",
"from tempdir import TempDir\n",
"INDEX_KEY = (\n 'Þ3?\\x87ÿÙÓ\\x14ð§>\\x1f%C{\\x16.\\\\®\\x8c\\x13§û\\x04Ô]+\\x8d_íÑ\\x8d\\x0bI\\x8a\\x0e¤tm«¿´¥\\x99\\x00dÕw\\x9f\\x18¼\\x1dÔ_WÒ¶èH\\x83\\x1bØ\\x9d\\xad'\n )\n",
"def __init__(self, user_id, leap_home):...\n",
"self._user_id = user_id\n",
"self._leap_home = leap_home\n",
"self._uuid = str(uuid.uuid4())\n",
"self._mail_address = '%s@pixelated.org' % user_id\n",
"self._soledad = None\n",
"self._services = None\n",
"@defer.inlineCallbacks...\n",
"soledad_test_folder = os.path.join(self._leap_home, self._uuid)\n",
"self.soledad = yield initialize_soledad(tempdir=soledad_test_folder, uuid=\n self._uuid)\n",
"self.search_engine = SearchEngine(self.INDEX_KEY, user_home=soledad_test_folder\n )\n",
"self.keymanager = mock()\n",
"self.mail_sender = self._create_mail_sender()\n",
"self.mail_store = SearchableMailStore(LeapMailStore(self.soledad), self.\n search_engine)\n",
"self.attachment_store = LeapAttachmentStore(self.soledad)\n",
"yield self._initialize_imap_account()\n",
"self.draft_service = DraftService(self.mail_store)\n",
"self.leap_session = mock()\n",
"self.feedback_service = FeedbackService(self.leap_session)\n",
"self.mail_service = self._create_mail_service(self.mail_sender, self.\n mail_store, self.search_engine, self.attachment_store)\n",
"mails = yield self.mail_service.all_mails()\n",
"if len(mails) > 0:\n",
"self.search_engine.index_mails(mails)\n",
"@property...\n",
"if self._services is None:\n",
"services = mock(Services)\n",
"return self._services\n",
"services.keymanager = self.keymanager\n",
"services.mail_service = self.mail_service\n",
"services.draft_service = self.draft_service\n",
"services.search_engine = self.search_engine\n",
"services.feedback_service = self.feedback_service\n",
"services._leap_session = self.leap_session\n",
"self._services = services\n",
"self.leap_session.close = lambda : 'mocked'\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_28(VAR_21):...\n",
"if not VAR_25(VAR_21):\n",
"return VAR_21, False\n",
"VAR_36.release()\n",
"return VAR_21, True\n"
] |
[
"def handler(msg):...\n",
"if not match(msg):\n",
"return msg, False\n",
"lock.release()\n",
"return msg, True\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Return'",
"Expr'",
"Return'"
] |
[
"def FUNC_5(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = '/api/apps'\n",
"VAR_5 = {'id': 'autotest'}\n",
"VAR_3 = self.client.post(VAR_2, json.dumps(VAR_5), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_3.status_code, 201)\n",
"VAR_4 = VAR_3.data['id']\n",
"VAR_6 = os.path.join(settings.DEIS_LOG_DIR, VAR_4 + '.log')\n",
"VAR_2 = '/api/apps/{app_id}/logs'.format(**locals())\n",
"VAR_3 = self.client.get(VAR_2)\n",
"self.assertIn('autotest created initial release', VAR_3.data)\n",
"self.assertEqual(VAR_3.status_code, 200)\n",
"os.remove(VAR_6)\n"
] |
[
"def test_app_release_notes_in_logs(self):...\n",
"\"\"\"docstring\"\"\"\n",
"url = '/api/apps'\n",
"body = {'id': 'autotest'}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 201)\n",
"app_id = response.data['id']\n",
"path = os.path.join(settings.DEIS_LOG_DIR, app_id + '.log')\n",
"url = '/api/apps/{app_id}/logs'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertIn('autotest created initial release', response.data)\n",
"self.assertEqual(response.status_code, 200)\n",
"os.remove(path)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._unit_of_measurement\n"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n",
"return self._unit_of_measurement\n"
] |
[
0,
0,
0
] |
[
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_5(self, VAR_3):...\n",
"if self.data:\n",
"if VAR_3 != self.data[len(self.data) - 1]:\n",
"self.data.append(VAR_3)\n",
"self.data.append(VAR_3)\n",
"if len(self.data) > self.size:\n",
"self.data.pop(0)\n"
] |
[
"def push(self, item):...\n",
"if self.data:\n",
"if item != self.data[len(self.data) - 1]:\n",
"self.data.append(item)\n",
"self.data.append(item)\n",
"if len(self.data) > self.size:\n",
"self.data.pop(0)\n"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Condition",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_8(self):...\n",
"VAR_57 = FUNC_0(self.request, self.ctype)\n",
"if not VAR_57:\n",
"return FUNC_6(\"You don't have enough permission to update TestCases.\")\n",
"VAR_68 = self.get_update_action()\n",
"if VAR_68 is not None:\n",
"return FUNC_6('Not know what to update.')\n",
"VAR_104 = VAR_68()\n",
"return FUNC_6(VAR_94(err))\n",
"if VAR_104 is None:\n",
"self._sendmail()\n",
"VAR_104 = FUNC_7()\n",
"return VAR_104\n"
] |
[
"def update(self):...\n",
"has_perms = check_permission(self.request, self.ctype)\n",
"if not has_perms:\n",
"return say_no(\"You don't have enough permission to update TestCases.\")\n",
"action = self.get_update_action()\n",
"if action is not None:\n",
"return say_no('Not know what to update.')\n",
"resp = action()\n",
"return say_no(str(err))\n",
"if resp is None:\n",
"self._sendmail()\n",
"resp = say_yes()\n",
"return resp\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Return'",
"Condition",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_11(self):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_2 = {'SEVERITY': {'LOW': 5}, 'CONFIDENCE': {'MEDIUM': 5}}\n",
"self.check_example('exec-as-root.py', VAR_2)\n"
] |
[
"def test_exec_as_root(self):...\n",
"\"\"\"docstring\"\"\"\n",
"expect = {'SEVERITY': {'LOW': 5}, 'CONFIDENCE': {'MEDIUM': 5}}\n",
"self.check_example('exec-as-root.py', expect)\n"
] |
[
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Expr'"
] |
[
"def FUNC_32(VAR_1, VAR_32):...\n",
"VAR_1.__self__.__delitem__(VAR_32)\n"
] |
[
"def memoize_delete(obj, item):...\n",
"obj.__self__.__delitem__(item)\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_6(self):...\n",
"VAR_4 = 'autotest-errors'\n",
"VAR_2 = '/api/apps'\n",
"VAR_5 = {'id': 'camelCase'}\n",
"VAR_3 = self.client.post(VAR_2, json.dumps(VAR_5), content_type=\n 'application/json')\n",
"self.assertContains(VAR_3, 'App IDs can only contain [a-z0-9-]',\n status_code=400)\n",
"VAR_2 = '/api/apps'\n",
"VAR_5 = {'id': 'deis'}\n",
"VAR_3 = self.client.post(VAR_2, json.dumps(VAR_5), content_type=\n 'application/json')\n",
"self.assertContains(VAR_3, \"App IDs cannot be 'deis'\", status_code=400)\n",
"VAR_5 = {'id': VAR_4}\n",
"VAR_3 = self.client.post(VAR_2, json.dumps(VAR_5), content_type=\n 'application/json')\n",
"self.assertEqual(VAR_3.status_code, 201)\n",
"VAR_4 = VAR_3.data['id']\n",
"VAR_2 = '/api/apps/{app_id}'.format(**locals())\n",
"VAR_3 = self.client.delete(VAR_2)\n",
"self.assertEquals(VAR_3.status_code, 204)\n",
"for endpoint in ('containers', 'config', 'releases', 'builds'):\n",
"VAR_2 = '/api/apps/{app_id}/{endpoint}'.format(**locals())\n",
"VAR_3 = self.client.get(VAR_2)\n",
"self.assertEquals(VAR_3.status_code, 404)\n"
] |
[
"def test_app_errors(self):...\n",
"app_id = 'autotest-errors'\n",
"url = '/api/apps'\n",
"body = {'id': 'camelCase'}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertContains(response, 'App IDs can only contain [a-z0-9-]',\n status_code=400)\n",
"url = '/api/apps'\n",
"body = {'id': 'deis'}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertContains(response, \"App IDs cannot be 'deis'\", status_code=400)\n",
"body = {'id': app_id}\n",
"response = self.client.post(url, json.dumps(body), content_type=\n 'application/json')\n",
"self.assertEqual(response.status_code, 201)\n",
"app_id = response.data['id']\n",
"url = '/api/apps/{app_id}'.format(**locals())\n",
"response = self.client.delete(url)\n",
"self.assertEquals(response.status_code, 204)\n",
"for endpoint in ('containers', 'config', 'releases', 'builds'):\n",
"url = '/api/apps/{app_id}/{endpoint}'.format(**locals())\n",
"response = self.client.get(url)\n",
"self.assertEquals(response.status_code, 404)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"For",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_0(self, VAR_1, VAR_2, VAR_3, VAR_4=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_4 is None:\n",
"VAR_4 = {}\n",
"VAR_17 = self.pool.get('product.product').browse(VAR_1, VAR_2, VAR_3, VAR_4\n =context)\n",
"VAR_18 = (VAR_17.property_stock_account_input and VAR_17.\n property_stock_account_input.id or False)\n",
"if not VAR_18:\n",
"VAR_18 = (VAR_17.categ_id.property_stock_account_input_categ and VAR_17.\n categ_id.property_stock_account_input_categ.id or False)\n",
"VAR_19 = (VAR_17.property_stock_account_output and VAR_17.\n property_stock_account_output.id or False)\n",
"if not VAR_19:\n",
"VAR_19 = (VAR_17.categ_id.property_stock_account_output_categ and VAR_17.\n categ_id.property_stock_account_output_categ.id or False)\n",
"VAR_20 = (VAR_17.categ_id.property_stock_journal and VAR_17.categ_id.\n property_stock_journal.id or False)\n",
"VAR_21 = (VAR_17.categ_id.property_stock_variation and VAR_17.categ_id.\n property_stock_variation.id or False)\n",
"return {'stock_account_input': VAR_18, 'stock_account_output': VAR_19,\n 'stock_journal': VAR_20, 'property_stock_variation': VAR_21}\n"
] |
[
"def get_product_accounts(self, cr, uid, product_id, context=None):...\n",
"\"\"\"docstring\"\"\"\n",
"if context is None:\n",
"context = {}\n",
"product_obj = self.pool.get('product.product').browse(cr, uid, product_id,\n context=context)\n",
"stock_input_acc = (product_obj.property_stock_account_input and product_obj\n .property_stock_account_input.id or False)\n",
"if not stock_input_acc:\n",
"stock_input_acc = (product_obj.categ_id.property_stock_account_input_categ and\n product_obj.categ_id.property_stock_account_input_categ.id or False)\n",
"stock_output_acc = (product_obj.property_stock_account_output and\n product_obj.property_stock_account_output.id or False)\n",
"if not stock_output_acc:\n",
"stock_output_acc = (product_obj.categ_id.\n property_stock_account_output_categ and product_obj.categ_id.\n property_stock_account_output_categ.id or False)\n",
"journal_id = (product_obj.categ_id.property_stock_journal and product_obj.\n categ_id.property_stock_journal.id or False)\n",
"account_variation = (product_obj.categ_id.property_stock_variation and\n product_obj.categ_id.property_stock_variation.id or False)\n",
"return {'stock_account_input': stock_input_acc, 'stock_account_output':\n stock_output_acc, 'stock_journal': journal_id,\n 'property_stock_variation': account_variation}\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"from __future__ import unicode_literals\n",
"import frappe\n",
"from frappe.utils import getdate, add_days, today, cint\n",
"from frappe import _\n",
"def FUNC_0(VAR_0=None):...\n",
"VAR_1 = FUNC_1()\n",
"VAR_2 = FUNC_2(VAR_0)\n",
"return VAR_1, VAR_2\n"
] |
[
"from __future__ import unicode_literals\n",
"import frappe\n",
"from frappe.utils import getdate, add_days, today, cint\n",
"from frappe import _\n",
"def execute(filters=None):...\n",
"columns = get_columns()\n",
"data = get_data(filters)\n",
"return columns, data\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"ImportFrom'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_3(VAR_3):...\n",
"VAR_3 = VAR_3.replace(\"'\", ''')\n",
"VAR_3 = VAR_3.replace('\"', '"')\n",
"return VAR_3\n"
] |
[
"def quote_escape(string):...\n",
"string = string.replace(\"'\", ''')\n",
"string = string.replace('\"', '"')\n",
"return string\n"
] |
[
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Return'"
] |
[
"import time\n",
"import math\n",
"from flask import request\n",
"from pyMetricServer import app\n",
"from pyMetricServer.system.database import database, getMetric\n",
"from werkzeug.exceptions import abort\n",
"from pyMetricServer.system.decorators import crossdomain\n",
"from flask.json import jsonify\n",
"@app.route('/metric/api/v1.0/metric/get')...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_0 = getMetric(request.args.get('fromtime', None), request.args.get(\n 'totime', None), request.args.get('origin', None), request.args.get(\n 'key', None), request.args.get('count', None), (request.args.get(\n 'order', 'Time'), bool(request.args.get('desc', True))))\n",
"return jsonify({'results': VAR_0, 'resultcount': len(VAR_0)})\n"
] |
[
"import time\n",
"import math\n",
"from flask import request\n",
"from pyMetricServer import app\n",
"from pyMetricServer.system.database import database, getMetric\n",
"from werkzeug.exceptions import abort\n",
"from pyMetricServer.system.decorators import crossdomain\n",
"from flask.json import jsonify\n",
"@app.route('/metric/api/v1.0/metric/get')...\n",
"\"\"\"docstring\"\"\"\n",
"res = getMetric(request.args.get('fromtime', None), request.args.get(\n 'totime', None), request.args.get('origin', None), request.args.get(\n 'key', None), request.args.get('count', None), (request.args.get(\n 'order', 'Time'), bool(request.args.get('desc', True))))\n",
"return jsonify({'results': res, 'resultcount': len(res)})\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Condition",
"Docstring",
"Assign'",
"Return'"
] |
[
"@rest_utils.ajax(data_required=True)...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_25 = VAR_1.DATA['updated']\n",
"if VAR_1.DATA.get('removed'):\n",
"for VAR_6 in VAR_1.DATA.get('removed'):\n",
"api.nova.aggregate_set_metadata(VAR_1, VAR_7, VAR_25)\n",
"VAR_25[VAR_6] = None\n"
] |
[
"@rest_utils.ajax(data_required=True)...\n",
"\"\"\"docstring\"\"\"\n",
"updated = request.DATA['updated']\n",
"if request.DATA.get('removed'):\n",
"for name in request.DATA.get('removed'):\n",
"api.nova.aggregate_set_metadata(request, aggregate_id, updated)\n",
"updated[name] = None\n"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
"Condition",
"Docstring",
"Assign'",
"Condition",
"For",
"Expr'",
"Assign'"
] |
[
"def FUNC_5(self, VAR_5):...\n",
"return True\n"
] |
[
"def verify_location(self, location):...\n",
"return True\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_5(self, VAR_15, VAR_16=None, VAR_17=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_20 = {'description': VAR_15}\n",
"if not VAR_16:\n",
"VAR_16 = self.default_tag\n",
"if VAR_17:\n",
"VAR_23 = CLASS_0.__format_date(VAR_17)\n",
"VAR_19 = self.__con.cursor()\n",
"if VAR_23 == CLASS_0.INVALID_DATE:\n",
"if VAR_19.execute(\"SELECT tagid FROM tags WHERE name='%s'\" % VAR_16):\n",
"return VAR_23\n",
"VAR_20['due_date'] = VAR_23\n",
"VAR_20['tagid'] = str(VAR_19.fetchone()[0])\n",
"self.add_tag(VAR_16)\n",
"VAR_19.execute(\"INSERT INTO tasks(%s) VALUES('%s')\" % (','.join(VAR_20.keys\n ()), \"','\".join(VAR_20.values())))\n",
"return CLASS_0.DUPLICATE\n",
"VAR_20['tagid'] = str(self.__con.insert_id())\n",
"return CLASS_0.SUCCESS\n"
] |
[
"def create_task(self, description, tag=None, due_date=None):...\n",
"\"\"\"docstring\"\"\"\n",
"cols = {'description': description}\n",
"if not tag:\n",
"tag = self.default_tag\n",
"if due_date:\n",
"valid_date = Database.__format_date(due_date)\n",
"cur = self.__con.cursor()\n",
"if valid_date == Database.INVALID_DATE:\n",
"if cur.execute(\"SELECT tagid FROM tags WHERE name='%s'\" % tag):\n",
"return valid_date\n",
"cols['due_date'] = valid_date\n",
"cols['tagid'] = str(cur.fetchone()[0])\n",
"self.add_tag(tag)\n",
"cur.execute(\"INSERT INTO tasks(%s) VALUES('%s')\" % (','.join(cols.keys()),\n \"','\".join(cols.values())))\n",
"return Database.DUPLICATE\n",
"cols['tagid'] = str(self.__con.insert_id())\n",
"return Database.SUCCESS\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
0,
0,
0,
0,
2,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Return'",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"return '{0}'.format(self.name)\n"
] |
[
"def select(self):...\n",
"return '{0}'.format(self.name)\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def __init__(self, VAR_23):...\n",
"super(CLASS_2, self).__init__()\n",
"self.has_a_single_h1 = VAR_23\n"
] |
[
"def __init__(self, has_a_single_h1):...\n",
"super(_AdjustTOC, self).__init__()\n",
"self.has_a_single_h1 = has_a_single_h1\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"Expr'",
"Assign'"
] |
[
"def FUNC_3(self, VAR_6):...\n",
"self.common = self._init_common()\n",
"self._check_flags()\n",
"self.iscsi_ips = {}\n",
"VAR_21 = {}\n",
"if len(self.configuration.hp3par_iscsi_ips) > 0:\n",
"for VAR_42 in self.configuration.hp3par_iscsi_ips:\n",
"if self.configuration.iscsi_ip_address not in VAR_21:\n",
"VAR_38 = VAR_42.split(':')\n",
"VAR_38 = self.configuration.iscsi_ip_address\n",
"VAR_22 = self.common.get_ports()['iSCSI']\n",
"if len(VAR_38) == 1:\n",
"VAR_39 = self.configuration.iscsi_port\n",
"for VAR_38, iscsi_info in VAR_22.iteritems():\n",
"VAR_21[VAR_42] = {'ip_port': VAR_2}\n",
"if len(VAR_38) == 2:\n",
"VAR_21[VAR_38] = {'ip_port': VAR_39}\n",
"if VAR_38 in VAR_21:\n",
"if self.configuration.iscsi_ip_address in VAR_21:\n",
"VAR_21[VAR_38[0]] = {'ip_port': VAR_38[1]}\n",
"VAR_40 = _(\"Invalid IP address format '%s'\") % VAR_42\n",
"VAR_39 = VAR_21[VAR_38]['ip_port']\n",
"if len(VAR_21) > 0:\n",
"VAR_1.warn(VAR_40)\n",
"self.iscsi_ips[VAR_38] = {'ip_port': VAR_39, 'nsp': iscsi_info['nsp'],\n 'iqn': iscsi_info['iqn']}\n",
"VAR_40 = _('string') % ', '.join(VAR_21)\n",
"if not len(self.iscsi_ips) > 0:\n",
"VAR_1.warn(VAR_40)\n",
"VAR_40 = _('At least one valid iSCSI IP address must be set.')\n",
"self.common.do_setup(VAR_6)\n"
] |
[
"def do_setup(self, context):...\n",
"self.common = self._init_common()\n",
"self._check_flags()\n",
"self.iscsi_ips = {}\n",
"temp_iscsi_ip = {}\n",
"if len(self.configuration.hp3par_iscsi_ips) > 0:\n",
"for ip_addr in self.configuration.hp3par_iscsi_ips:\n",
"if self.configuration.iscsi_ip_address not in temp_iscsi_ip:\n",
"ip = ip_addr.split(':')\n",
"ip = self.configuration.iscsi_ip_address\n",
"iscsi_ports = self.common.get_ports()['iSCSI']\n",
"if len(ip) == 1:\n",
"ip_port = self.configuration.iscsi_port\n",
"for ip, iscsi_info in iscsi_ports.iteritems():\n",
"temp_iscsi_ip[ip_addr] = {'ip_port': DEFAULT_ISCSI_PORT}\n",
"if len(ip) == 2:\n",
"temp_iscsi_ip[ip] = {'ip_port': ip_port}\n",
"if ip in temp_iscsi_ip:\n",
"if self.configuration.iscsi_ip_address in temp_iscsi_ip:\n",
"temp_iscsi_ip[ip[0]] = {'ip_port': ip[1]}\n",
"msg = _(\"Invalid IP address format '%s'\") % ip_addr\n",
"ip_port = temp_iscsi_ip[ip]['ip_port']\n",
"if len(temp_iscsi_ip) > 0:\n",
"LOG.warn(msg)\n",
"self.iscsi_ips[ip] = {'ip_port': ip_port, 'nsp': iscsi_info['nsp'], 'iqn':\n iscsi_info['iqn']}\n",
"msg = _(\n \"Found invalid iSCSI IP address(s) in configuration option(s) hp3par_iscsi_ips or iscsi_ip_address '%s.'\"\n ) % ', '.join(temp_iscsi_ip)\n",
"if not len(self.iscsi_ips) > 0:\n",
"LOG.warn(msg)\n",
"msg = _('At least one valid iSCSI IP address must be set.')\n",
"self.common.do_setup(context)\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
] |
[
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"For",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"For",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_17(self):...\n",
""
] |
[
"def builds(self):...\n",
""
] |
[
0,
0
] |
[
"FunctionDef'",
"Condition"
] |
[
"def FUNC_4(VAR_4):...\n",
"VAR_7 = Message('Welcome to Game Change!', recipients=[user.email])\n",
"VAR_7.body = render_template('emails/signup.txt', email_key=\n urlsafe_b64encode(str(hash(user.id))), VAR_8=user.first_name,\n email_address=user.email)\n",
"VAR_7.html = render_template('emails/signup.html', email_key=\n urlsafe_b64encode(str(hash(user.id))), VAR_8=user.first_name,\n email_address=user.email)\n",
"if not VAR_0.debug:\n",
"VAR_2.send(VAR_7)\n",
"VAR_0.logger.debug(\"\"\"E-mail to %s not sent, debug mode. \n %s\"\"\", VAR_4.\n email, VAR_7.body)\n"
] |
[
"def send_email_to_user(user):...\n",
"msg = Message('Welcome to Game Change!', recipients=[user.email])\n",
"msg.body = render_template('emails/signup.txt', email_key=urlsafe_b64encode\n (str(hash(user.id))), first_name=user.first_name, email_address=user.email)\n",
"msg.html = render_template('emails/signup.html', email_key=\n urlsafe_b64encode(str(hash(user.id))), first_name=user.first_name,\n email_address=user.email)\n",
"if not app.debug:\n",
"mail.send(msg)\n",
"app.logger.debug(\"\"\"E-mail to %s not sent, debug mode. \n %s\"\"\", user.email,\n msg.body)\n"
] |
[
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def __len__(self):...\n",
""
] |
[
"def __len__(self):...\n",
""
] |
[
0,
0
] |
[
"FunctionDef'",
"Condition"
] |
[
"def FUNC_5(self, VAR_11='', VAR_6=None):...\n",
"VAR_5 = self.session.query(self.obj)\n",
"VAR_5 = self._get_base_query(VAR_5=query, VAR_6=filters)\n",
"VAR_25 = VAR_5.all()\n",
"VAR_26 = GroupByDateMonth(VAR_11, 'Group by Month')\n",
"return VAR_26.apply(VAR_25)\n"
] |
[
"def query_month_group(self, group_by='', filters=None):...\n",
"query = self.session.query(self.obj)\n",
"query = self._get_base_query(query=query, filters=filters)\n",
"query_result = query.all()\n",
"group = GroupByDateMonth(group_by, 'Group by Month')\n",
"return group.apply(query_result)\n"
] |
[
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_22(self, VAR_21, VAR_40):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_57 = self.getfile(VAR_21)\n",
"if VAR_57 == False:\n",
"VAR_57[VAR_6] = FUNC_30.S_IFMT(VAR_57[VAR_6]) | VAR_40\n"
] |
[
"def chmod(self, path, perm):...\n",
"\"\"\"docstring\"\"\"\n",
"p = self.getfile(path)\n",
"if p == False:\n",
"p[A_MODE] = stat.S_IFMT(p[A_MODE]) | perm\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Assign'"
] |
[
"def FUNC_16(VAR_3, VAR_8, VAR_9='DUMMY_INVALID_TOKEN'):...\n",
"VAR_0, VAR_10 = FUNC_0()\n",
"VAR_23 = FUNC_8(VAR_10, VAR_9, VAR_3)\n",
"if not VAR_23 and FUNC_13(VAR_10, VAR_3):\n",
"FUNC_6(VAR_9, VAR_8)\n",
"VAR_24 = list(filter(lambda x: x, VAR_8.split(',')))\n",
"if len(VAR_24) > 1:\n",
"if not FUNC_15(VAR_3):\n",
"for opt in VAR_24:\n",
"FUNC_14(VAR_10, VAR_3, opt)\n",
"FUNC_1(VAR_0)\n"
] |
[
"def vote(poll_name, options_string, token_used='DUMMY_INVALID_TOKEN'):...\n",
"conn, c = connectDB()\n",
"token_valid = checkTokenValid(c, token_used, poll_name)\n",
"if not token_valid and checkTokenNeeded(c, poll_name):\n",
"markTokenUsedExternal(token_used, options_string)\n",
"options = list(filter(lambda x: x, options_string.split(',')))\n",
"if len(options) > 1:\n",
"if not isMultiChoice(poll_name):\n",
"for opt in options:\n",
"incrementOption(c, poll_name, opt)\n",
"closeDB(conn)\n"
] |
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Condition",
"For",
"Expr'",
"Expr'"
] |
[
"import sqlite3 as sql\n",
"def __init__(self, *VAR_0, **VAR_1):...\n",
"self.dbStr = '../Databases/Product.db'\n",
"self.table_name = 'products'\n",
"self.id_column = 'id'\n",
"self.column_2 = 'upc'\n",
"self.column_3 = 'name'\n",
"self.column_4 = 'image'\n",
"self.some_upc = ''\n",
"self.result = ''\n",
"def FUNC_0(self):...\n",
"VAR_2 = sql.connect(self.dbStr)\n",
"VAR_3 = VAR_2.cursor()\n",
"VAR_3.execute('SELECT * FROM {tn} WHERE {upc}={my_upc}'.format(tn=self.\n table_name, cn=self.column_2, upc=self.column_2, my_upc=self.some_upc))\n",
"VAR_4 = VAR_3.fetchone()\n",
"return VAR_4\n"
] |
[
"import sqlite3 as sql\n",
"def __init__(self, *args, **kwargs):...\n",
"self.dbStr = '../Databases/Product.db'\n",
"self.table_name = 'products'\n",
"self.id_column = 'id'\n",
"self.column_2 = 'upc'\n",
"self.column_3 = 'name'\n",
"self.column_4 = 'image'\n",
"self.some_upc = ''\n",
"self.result = ''\n",
"def fetch_product(self):...\n",
"conn = sql.connect(self.dbStr)\n",
"c = conn.cursor()\n",
"c.execute('SELECT * FROM {tn} WHERE {upc}={my_upc}'.format(tn=self.\n table_name, cn=self.column_2, upc=self.column_2, my_upc=self.some_upc))\n",
"result = c.fetchone()\n",
"return result\n"
] |
[
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
0,
0
] |
[
"Import'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_27(VAR_18):...\n",
"return VAR_18[0]\n"
] |
[
"def get_key(item):...\n",
"return item[0]\n"
] |
[
0,
0
] |
[
"FunctionDef'",
"Return'"
] |
[
"def FUNC_3(self):...\n",
"for VAR_5 in self.groups:\n",
"self.add_group(VAR_5)\n"
] |
[
"def populate_ancestors(self):...\n",
"for group in self.groups:\n",
"self.add_group(group)\n"
] |
[
0,
0,
0
] |
[
"FunctionDef'",
"For",
"Expr'"
] |
[
"def FUNC_19(self, VAR_21):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_58 = self.getfile(VAR_21)\n",
"if VAR_58 != False:\n",
"self.mkdir(VAR_21, 0, 0, 4096, 16877)\n"
] |
[
"def mkdir2(self, path):...\n",
"\"\"\"docstring\"\"\"\n",
"dir = self.getfile(path)\n",
"if dir != False:\n",
"self.mkdir(path, 0, 0, 4096, 16877)\n"
] |
[
0,
0,
0,
0,
0
] |
[
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Expr'"
] |
[
"@VAR_2.route('/temp')...\n",
"return render_template('libraries/temp/index.html')\n"
] |
[
"@endpoints.route('/temp')...\n",
"return render_template('libraries/temp/index.html')\n"
] |
[
0,
0
] |
[
"Condition",
"Return'"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.