lines
sequencelengths 1
444
| raw_lines
sequencelengths 1
444
| label
sequencelengths 1
444
| type
sequencelengths 1
444
|
---|---|---|---|
[
"def FUNC_7(self):...\n",
"VAR_13 = FUNC_0(self.groups['path'])\n",
"if self.groups['path'] != VAR_13:\n",
"self.response.headers.set('Location', self.remote + VAR_13)\n",
"self.filename = self.local + urllib.parse.unquote(self.groups['path'])\n",
"return 307, ''\n",
"return VAR_5.respond(self)\n"
] | [
"def respond(self):...\n",
"norm_request = normpath(self.groups['path'])\n",
"if self.groups['path'] != norm_request:\n",
"self.response.headers.set('Location', self.remote + norm_request)\n",
"self.filename = self.local + urllib.parse.unquote(self.groups['path'])\n",
"return 307, ''\n",
"return handler.respond(self)\n"
] | [
0,
0,
0,
0,
1,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Return'",
"Return'"
] |
[
"@VAR_0.route('/login/<remote_app>/')...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_1 not in oauth.remote_apps:\n",
"return abort(404)\n",
"VAR_2 = url_for('.authorized', VAR_1=remote_app, next=request.args.get(\n 'next') or request.referrer or None, _external=True)\n",
"return oauth.remote_apps[VAR_1].authorize(callback=callback_url)\n"
] | [
"@blueprint.route('/login/<remote_app>/')...\n",
"\"\"\"docstring\"\"\"\n",
"if remote_app not in oauth.remote_apps:\n",
"return abort(404)\n",
"callback_url = url_for('.authorized', remote_app=remote_app, next=request.\n args.get('next') or request.referrer or None, _external=True)\n",
"return oauth.remote_apps[remote_app].authorize(callback=callback_url)\n"
] | [
0,
0,
0,
0,
5,
5
] | [
"Condition",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Return'"
] |
[
"def FUNC_3(VAR_0, VAR_4):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_0.execute(VAR_4)\n",
"VAR_0.connection.rollback()\n",
"return VAR_0.fetchall()\n",
"return None\n"
] | [
"def get_data(cur, query):...\n",
"\"\"\"docstring\"\"\"\n",
"cur.execute(query)\n",
"cur.connection.rollback()\n",
"return cur.fetchall()\n",
"return None\n"
] | [
0,
0,
4,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Expr'",
"Return'",
"Return'"
] |
[
"def FUNC_2(self, VAR_0: str):...\n",
"VAR_4 = get_json_request_body(self)\n",
"VAR_2 = VAR_4.get('submitters', None)\n",
"VAR_5 = VAR_4.get('filters', None)\n",
"VAR_3 = api.submission.get_all(VAR_0, email=get_email(self), submitters=\n subs, VAR_5=filters)\n",
"self.write(VAR_3)\n"
] | [
"def post(self, survey_id: str):...\n",
"body = get_json_request_body(self)\n",
"subs = body.get('submitters', None)\n",
"filters = body.get('filters', None)\n",
"response = api.submission.get_all(survey_id, email=get_email(self),\n submitters=subs, filters=filters)\n",
"self.write(response)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_1(self, **VAR_34):...\n",
"\"\"\"docstring\"\"\"\n",
"for arg in VAR_34:\n",
"if hasattr(self, arg):\n",
"self._check_usage()\n",
"if getattr(self, arg) is None:\n",
"setattr(self, arg, VAR_34[arg])\n"
] | [
"def update_if_absent(self, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"for arg in kwargs:\n",
"if hasattr(self, arg):\n",
"self._check_usage()\n",
"if getattr(self, arg) is None:\n",
"setattr(self, arg, kwargs[arg])\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"For",
"Condition",
"Expr'",
"Condition",
"Expr'"
] |
[
"def FUNC_0(self, VAR_4, VAR_5, VAR_6=True):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_14 = []\n",
"for VAR_43, v in VAR_5.items():\n",
"VAR_14.append(' %s=%s' % (VAR_43, v))\n",
"VAR_15 = VAR_4 + ''.join(VAR_14)\n",
"return self._run_ssh(VAR_15, VAR_6)\n"
] | [
"def _cliq_run(self, verb, cliq_args, check_exit_code=True):...\n",
"\"\"\"docstring\"\"\"\n",
"cliq_arg_strings = []\n",
"for k, v in cliq_args.items():\n",
"cliq_arg_strings.append(' %s=%s' % (k, v))\n",
"cmd = verb + ''.join(cliq_arg_strings)\n",
"return self._run_ssh(cmd, check_exit_code)\n"
] | [
0,
0,
2,
0,
2,
2,
2
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"For",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_11(self, VAR_14):...\n",
""
] | [
"def is_integer(self, col_name):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_4(VAR_4, VAR_5):...\n",
"VAR_11 = f\"\"\"\n SELECT COUNT(p.id) AS total\n FROM products AS p INNER JOIN {VAR_1} AS pt ON\n p.product_type_id=pt.id\n WHERE p.rating >= {VAR_4['rating']}\n AND pt.name = '{VAR_5}'\n \"\"\"\n",
"VAR_12 = create_connection()\n",
"VAR_12.close()\n",
"VAR_13 = VAR_12.cursor()\n",
"VAR_13.execute(VAR_11)\n",
"return int(VAR_13.fetchone()['total'])\n"
] | [
"def get_total_departments_products(filters, department):...\n",
"sql_query = f\"\"\"\n SELECT COUNT(p.id) AS total\n FROM products AS p INNER JOIN {PRODUCTS_TYPES_TABLE} AS pt ON\n p.product_type_id=pt.id\n WHERE p.rating >= {filters['rating']}\n AND pt.name = '{department}'\n \"\"\"\n",
"connection = create_connection()\n",
"connection.close()\n",
"cursor = connection.cursor()\n",
"cursor.execute(sql_query)\n",
"return int(cursor.fetchone()['total'])\n"
] | [
0,
4,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"from django import forms\n",
"VAR_0 = forms.CharField(label='', max_length=100, required=True)\n",
"VAR_0.widget.attrs['class'] = 'form-control mr-sm-2 my-2'\n",
"VAR_0.widget.attrs['placeholder'] = 'Lookup IP Address'\n"
] | [
"from django import forms\n",
"keyword = forms.CharField(label='', max_length=100, required=True)\n",
"keyword.widget.attrs['class'] = 'form-control mr-sm-2 my-2'\n",
"keyword.widget.attrs['placeholder'] = 'Lookup IP Address'\n"
] | [
0,
6,
0,
0
] | [
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_6():...\n",
"VAR_20 = db.Filesystem.get_content(VAR_4)\n",
"VAR_6.set_result(VAR_20)\n"
] | [
"def inquire_data_async():...\n",
"_tf_data = db.Filesystem.get_content(file_path)\n",
"future.set_result(_tf_data)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'"
] |
[
"def FUNC_13(self):...\n",
"self.run_test_case(self.scenario.delete_load_balancer(), max_retries=5)\n"
] | [
"def test_y_delete_load_balancer(self):...\n",
"self.run_test_case(self.scenario.delete_load_balancer(), max_retries=5)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_13(self, VAR_9, VAR_7):...\n",
"if not self.doctype:\n",
"return VAR_9\n",
"if not isinstance(VAR_9, CLASS_0):\n",
"if 'doctype' not in VAR_9:\n",
"VAR_9.parent = self.name\n",
"VAR_9['doctype'] = self.get_table_field_doctype(VAR_7)\n",
"VAR_9 = FUNC_0(VAR_9['doctype'])(VAR_9)\n",
"VAR_9.parenttype = self.doctype\n",
"if not VAR_9['doctype']:\n",
"VAR_9.init_valid_columns()\n",
"VAR_9.parentfield = VAR_7\n",
"if VAR_9.docstatus is None:\n",
"VAR_9.docstatus = 0\n",
"if not getattr(VAR_9, 'idx', None):\n",
"VAR_9.idx = len(self.get(VAR_7) or []) + 1\n",
"if not getattr(VAR_9, 'name', None):\n",
"VAR_9.__dict__['__islocal'] = 1\n",
"return VAR_9\n"
] | [
"def _init_child(self, value, key):...\n",
"if not self.doctype:\n",
"return value\n",
"if not isinstance(value, BaseDocument):\n",
"if 'doctype' not in value:\n",
"value.parent = self.name\n",
"value['doctype'] = self.get_table_field_doctype(key)\n",
"value = get_controller(value['doctype'])(value)\n",
"value.parenttype = self.doctype\n",
"if not value['doctype']:\n",
"value.init_valid_columns()\n",
"value.parentfield = key\n",
"if value.docstatus is None:\n",
"value.docstatus = 0\n",
"if not getattr(value, 'idx', None):\n",
"value.idx = len(self.get(key) or []) + 1\n",
"if not getattr(value, 'name', None):\n",
"value.__dict__['__islocal'] = 1\n",
"return value\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_4(self, VAR_9):...\n",
"self.fields.append(VAR_9)\n",
"cached_property.clear_caches(self)\n"
] | [
"def add_field(self, field):...\n",
"self.fields.append(field)\n",
"cached_property.clear_caches(self)\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'"
] |
[
"def FUNC_11(VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"return block.path_to_kname(VAR_1).startswith('dm') and FUNC_1(VAR_1\n ).startswith('CRYPT')\n"
] | [
"def identify_crypt(device):...\n",
"\"\"\"docstring\"\"\"\n",
"return block.path_to_kname(device).startswith('dm') and get_dmsetup_uuid(device\n ).startswith('CRYPT')\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def __repr__(self):...\n",
"return json_encode(self, sort_keys=True)\n"
] | [
"def __repr__(self):...\n",
"return json_encode(self, sort_keys=True)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@property...\n",
"VAR_28 = list(self.output)\n",
"if self.benchmark:\n",
"VAR_28.append(self.benchmark)\n",
"return VAR_28\n"
] | [
"@property...\n",
"products = list(self.output)\n",
"if self.benchmark:\n",
"products.append(self.benchmark)\n",
"return products\n"
] | [
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Condition",
"Expr'",
"Return'"
] |
[
"__author__ = 'Johannes Köster'\n",
"__copyright__ = 'Copyright 2015, Johannes Köster'\n",
"__email__ = '[email protected]'\n",
"__license__ = 'MIT'\n",
"import os\n",
"import sys\n",
"import base64\n",
"import json\n",
"from collections import defaultdict\n",
"from itertools import chain\n",
"from functools import partial\n",
"from operator import attrgetter\n",
"from snakemake.io import IOFile, Wildcards, Resources, _IOFile\n",
"from snakemake.utils import format, listfiles\n",
"from snakemake.exceptions import RuleException, ProtectedOutputException\n",
"from snakemake.exceptions import UnexpectedOutputException\n",
"from snakemake.logging import logger\n",
"def FUNC_0(VAR_0, VAR_1):...\n",
"return chain(*map(attrgetter(VAR_1), VAR_0))\n"
] | [
"__author__ = 'Johannes Köster'\n",
"__copyright__ = 'Copyright 2015, Johannes Köster'\n",
"__email__ = '[email protected]'\n",
"__license__ = 'MIT'\n",
"import os\n",
"import sys\n",
"import base64\n",
"import json\n",
"from collections import defaultdict\n",
"from itertools import chain\n",
"from functools import partial\n",
"from operator import attrgetter\n",
"from snakemake.io import IOFile, Wildcards, Resources, _IOFile\n",
"from snakemake.utils import format, listfiles\n",
"from snakemake.exceptions import RuleException, ProtectedOutputException\n",
"from snakemake.exceptions import UnexpectedOutputException\n",
"from snakemake.logging import logger\n",
"def jobfiles(jobs, type):...\n",
"return chain(*map(attrgetter(type), jobs))\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
7,
0,
0,
0,
0,
0,
0
] | [
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Return'"
] |
[
"def FUNC_2(self):...\n",
"self.objects.extext.qa_edited = True\n",
"VAR_1 = QANotes.objects.create(extracted_text=self.objects.extext)\n",
"self.assertEqual(VAR_1.qa_notes, None)\n",
"self.assertRaises(ValidationError, VAR_1.clean)\n"
] | [
"def test_extracted_text_qa_notes(self):...\n",
"self.objects.extext.qa_edited = True\n",
"note = QANotes.objects.create(extracted_text=self.objects.extext)\n",
"self.assertEqual(note.qa_notes, None)\n",
"self.assertRaises(ValidationError, note.clean)\n"
] | [
0,
6,
6,
6,
6
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'"
] |
[
"@hook.command(autohelp=False)...\n",
"return FUNC_1(VAR_8, 'kick', VAR_4, VAR_5, VAR_1, VAR_6, VAR_7)\n"
] | [
"@hook.command(autohelp=False)...\n",
"return process_vote(inp, 'kick', chan, mask, db, notice, conn)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_0(self, VAR_9='localhost', VAR_10='todo', VAR_11='todo', VAR_12='todo'...\n",
"\"\"\"docstring\"\"\"\n",
"self.__con = MySQLdb.connect(VAR_9, VAR_10, VAR_11, VAR_12)\n",
"return CLASS_0.CANT_CONNECT\n",
"self.__con.autocommit(True)\n",
"return CLASS_0.SUCCESS\n"
] | [
"def connect(self, hostname='localhost', username='todo', password='todo',...\n",
"\"\"\"docstring\"\"\"\n",
"self.__con = MySQLdb.connect(hostname, username, password, database)\n",
"return Database.CANT_CONNECT\n",
"self.__con.autocommit(True)\n",
"return Database.SUCCESS\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Docstring",
"Assign'",
"Return'",
"Expr'",
"Return'"
] |
[
"def __init__(self):...\n",
"self.order = list()\n"
] | [
"def __init__(self):...\n",
"self.order = list()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"def FUNC_8(VAR_24):...\n",
"return binary_to_object_id(VAR_24).redis_shard_hash() % len(self.state.\n redis_clients)\n"
] | [
"def to_shard_index(id_bin):...\n",
"return binary_to_object_id(id_bin).redis_shard_hash() % len(self.state.\n redis_clients)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"@staticmethod...\n",
"return CLASS_0._TalkToHandlerAsync(VAR_9, VAR_7, 'POST', VAR_10)\n"
] | [
"@staticmethod...\n",
"return BaseRequest._TalkToHandlerAsync(data, handler, 'POST', timeout)\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"def FUNC_0(VAR_0, VAR_1):...\n",
"VAR_12 = ''\n",
"VAR_40 = VAR_41 = None\n",
"if VAR_1.sort_field and ',' in VAR_1.sort_field:\n",
"VAR_12 = ', '.join(['`tab{0}`.`{1}` {2}'.format(VAR_0, VAR_34.split()[0].\n strip(), VAR_34.split()[1].strip()) for VAR_34 in VAR_1.sort_field.\n split(',')])\n",
"VAR_40 = VAR_1.sort_field or 'modified'\n",
"if VAR_1.is_submittable:\n",
"VAR_41 = VAR_1.sort_field and VAR_1.sort_order or 'desc'\n",
"VAR_12 = '`tab{0}`.docstatus asc, {1}'.format(VAR_0, VAR_12)\n",
"return VAR_12\n",
"VAR_12 = '`tab{0}`.`{1}` {2}'.format(VAR_0, VAR_40 or 'modified', VAR_41 or\n 'desc')\n"
] | [
"def get_order_by(doctype, meta):...\n",
"order_by = ''\n",
"sort_field = sort_order = None\n",
"if meta.sort_field and ',' in meta.sort_field:\n",
"order_by = ', '.join(['`tab{0}`.`{1}` {2}'.format(doctype, f.split()[0].\n strip(), f.split()[1].strip()) for f in meta.sort_field.split(',')])\n",
"sort_field = meta.sort_field or 'modified'\n",
"if meta.is_submittable:\n",
"sort_order = meta.sort_field and meta.sort_order or 'desc'\n",
"order_by = '`tab{0}`.docstatus asc, {1}'.format(doctype, order_by)\n",
"return order_by\n",
"order_by = '`tab{0}`.`{1}` {2}'.format(doctype, sort_field or 'modified', \n sort_order or 'desc')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'",
"Assign'"
] |
[
"from operator import itemgetter\n",
"import psycopg2\n",
"from psycopg2.extras import DictCursor\n",
"from flask import Flask\n",
"from flask import render_template\n",
"from flask import request\n",
"from gensim.models import Doc2Vec\n",
"import re\n",
"import argparse\n",
"VAR_0 = Flask(__name__)\n",
"\"\"\"Helpers\"\"\"\n",
"def FUNC_0():...\n",
"VAR_5 = conn.cursor()\n",
"VAR_6 = 'SELECT subject, count(*) FROM articles group by subject;'\n",
"VAR_5.execute(VAR_6)\n",
"VAR_7 = sorted(VAR_5.fetchall(), key=lambda tup: tup[0])\n",
"return VAR_7\n"
] | [
"from operator import itemgetter\n",
"import psycopg2\n",
"from psycopg2.extras import DictCursor\n",
"from flask import Flask\n",
"from flask import render_template\n",
"from flask import request\n",
"from gensim.models import Doc2Vec\n",
"import re\n",
"import argparse\n",
"application = Flask(__name__)\n",
"\"\"\"Helpers\"\"\"\n",
"def get_subjects():...\n",
"cur = conn.cursor()\n",
"query = 'SELECT subject, count(*) FROM articles group by subject;'\n",
"cur.execute(query)\n",
"subjects = sorted(cur.fetchall(), key=lambda tup: tup[0])\n",
"return subjects\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
4,
0,
0
] | [
"ImportFrom'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Import'",
"Assign'",
"Expr'",
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.netatmo_data.update()\n",
"VAR_13 = self.netatmo_data.data.get(self.module_name)\n",
"if VAR_13 is None:\n",
"VAR_0.warning('No data found for %s', self.module_name)\n",
"if self.type == 'temperature':\n",
"self._state = STATE_UNKNOWN\n",
"self._state = round(VAR_13['Temperature'], 1)\n",
"if self.type == 'humidity':\n",
"return\n",
"self._state = VAR_13['Humidity']\n",
"if self.type == 'rain':\n",
"self._state = VAR_13['Rain']\n",
"if self.type == 'sum_rain_1':\n",
"self._state = VAR_13['sum_rain_1']\n",
"if self.type == 'sum_rain_24':\n",
"self._state = VAR_13['sum_rain_24']\n",
"if self.type == 'noise':\n",
"self._state = VAR_13['Noise']\n",
"if self.type == 'co2':\n",
"self._state = VAR_13['CO2']\n",
"if self.type == 'pressure':\n",
"self._state = round(VAR_13['Pressure'], 1)\n",
"if self.type == 'battery_lvl':\n",
"self._state = VAR_13['battery_vp']\n",
"if self.type == 'battery_vp' and self.module_id == '6':\n",
"if VAR_13['battery_vp'] >= 5590:\n",
"if self.type == 'battery_vp' and self.module_id == '5':\n",
"self._state = 'Full'\n",
"if VAR_13['battery_vp'] >= 5180:\n",
"if VAR_13['battery_vp'] >= 5500:\n",
"if self.type == 'battery_vp' and self.module_id == '3':\n",
"self._state = 'High'\n",
"if VAR_13['battery_vp'] >= 4770:\n",
"self._state = 'Full'\n",
"if VAR_13['battery_vp'] >= 5000:\n",
"if VAR_13['battery_vp'] >= 5640:\n",
"if self.type == 'battery_vp' and self.module_id == '2':\n",
"self._state = 'Medium'\n",
"if VAR_13['battery_vp'] >= 4360:\n",
"self._state = 'High'\n",
"if VAR_13['battery_vp'] >= 4500:\n",
"self._state = 'Full'\n",
"if VAR_13['battery_vp'] >= 5280:\n",
"if VAR_13['battery_vp'] >= 5500:\n",
"if self.type == 'min_temp':\n",
"self._state = 'Low'\n",
"if VAR_13['battery_vp'] < 4360:\n",
"self._state = 'Medium'\n",
"if VAR_13['battery_vp'] >= 4000:\n",
"self._state = 'High'\n",
"if VAR_13['battery_vp'] >= 4920:\n",
"self._state = 'Full'\n",
"if VAR_13['battery_vp'] >= 5000:\n",
"self._state = VAR_13['min_temp']\n",
"if self.type == 'max_temp':\n",
"self._state = 'Very Low'\n",
"self._state = 'Low'\n",
"if VAR_13['battery_vp'] < 4000:\n",
"self._state = 'Medium'\n",
"if VAR_13['battery_vp'] >= 4560:\n",
"self._state = 'High'\n",
"if VAR_13['battery_vp'] >= 4500:\n",
"self._state = VAR_13['max_temp']\n",
"if self.type == 'windangle_value':\n",
"self._state = 'Very Low'\n",
"self._state = 'Low'\n",
"if VAR_13['battery_vp'] < 4560:\n",
"self._state = 'Medium'\n",
"if VAR_13['battery_vp'] >= 4000:\n",
"self._state = VAR_13['WindAngle']\n",
"if self.type == 'windangle':\n",
"self._state = 'Very Low'\n",
"self._state = 'Low'\n",
"if VAR_13['battery_vp'] < 4000:\n",
"if VAR_13['WindAngle'] >= 330:\n",
"if self.type == 'windstrength':\n",
"self._state = 'Very Low'\n",
"self._state = 'N (%d°)' % VAR_13['WindAngle']\n",
"if VAR_13['WindAngle'] >= 300:\n",
"self._state = VAR_13['WindStrength']\n",
"if self.type == 'gustangle_value':\n",
"self._state = 'NW (%d°)' % VAR_13['WindAngle']\n",
"if VAR_13['WindAngle'] >= 240:\n",
"self._state = VAR_13['GustAngle']\n",
"if self.type == 'gustangle':\n",
"self._state = 'W (%d°)' % VAR_13['WindAngle']\n",
"if VAR_13['WindAngle'] >= 210:\n",
"if VAR_13['GustAngle'] >= 330:\n",
"if self.type == 'guststrength':\n",
"self._state = 'SW (%d°)' % VAR_13['WindAngle']\n",
"if VAR_13['WindAngle'] >= 150:\n",
"self._state = 'N (%d°)' % VAR_13['GustAngle']\n",
"if VAR_13['GustAngle'] >= 300:\n",
"self._state = VAR_13['GustStrength']\n",
"if self.type == 'rf_status_lvl':\n",
"self._state = 'S (%d°)' % VAR_13['WindAngle']\n",
"if VAR_13['WindAngle'] >= 120:\n",
"self._state = 'NW (%d°)' % VAR_13['GustAngle']\n",
"if VAR_13['GustAngle'] >= 240:\n",
"self._state = VAR_13['rf_status']\n",
"if self.type == 'rf_status':\n",
"self._state = 'SE (%d°)' % VAR_13['WindAngle']\n",
"if VAR_13['WindAngle'] >= 60:\n",
"self._state = 'W (%d°)' % VAR_13['GustAngle']\n",
"if VAR_13['GustAngle'] >= 210:\n",
"if VAR_13['rf_status'] >= 90:\n",
"if self.type == 'wifi_status_lvl':\n",
"self._state = 'E (%d°)' % VAR_13['WindAngle']\n",
"if VAR_13['WindAngle'] >= 30:\n",
"self._state = 'SW (%d°)' % VAR_13['GustAngle']\n",
"if VAR_13['GustAngle'] >= 150:\n",
"self._state = 'Low'\n",
"if VAR_13['rf_status'] >= 76:\n",
"self._state = VAR_13['wifi_status']\n",
"if self.type == 'wifi_status':\n",
"self._state = 'NE (%d°)' % VAR_13['WindAngle']\n",
"if VAR_13['WindAngle'] >= 0:\n",
"self._state = 'S (%d°)' % VAR_13['GustAngle']\n",
"if VAR_13['GustAngle'] >= 120:\n",
"self._state = 'Medium'\n",
"if VAR_13['rf_status'] >= 60:\n",
"if VAR_13['wifi_status'] >= 86:\n",
"self._state = 'N (%d°)' % VAR_13['WindAngle']\n",
"self._state = 'SE (%d°)' % VAR_13['GustAngle']\n",
"if VAR_13['GustAngle'] >= 60:\n",
"self._state = 'High'\n",
"if VAR_13['rf_status'] <= 59:\n",
"self._state = 'Low'\n",
"if VAR_13['wifi_status'] >= 71:\n",
"self._state = 'E (%d°)' % VAR_13['GustAngle']\n",
"if VAR_13['GustAngle'] >= 30:\n",
"self._state = 'Full'\n",
"self._state = 'Medium'\n",
"if VAR_13['wifi_status'] >= 56:\n",
"self._state = 'NE (%d°)' % VAR_13['GustAngle']\n",
"if VAR_13['GustAngle'] >= 0:\n",
"self._state = 'High'\n",
"if VAR_13['wifi_status'] <= 55:\n",
"self._state = 'N (%d°)' % VAR_13['GustAngle']\n",
"self._state = 'Full'\n"
] | [
"def update(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.netatmo_data.update()\n",
"data = self.netatmo_data.data.get(self.module_name)\n",
"if data is None:\n",
"_LOGGER.warning('No data found for %s', self.module_name)\n",
"if self.type == 'temperature':\n",
"self._state = STATE_UNKNOWN\n",
"self._state = round(data['Temperature'], 1)\n",
"if self.type == 'humidity':\n",
"return\n",
"self._state = data['Humidity']\n",
"if self.type == 'rain':\n",
"self._state = data['Rain']\n",
"if self.type == 'sum_rain_1':\n",
"self._state = data['sum_rain_1']\n",
"if self.type == 'sum_rain_24':\n",
"self._state = data['sum_rain_24']\n",
"if self.type == 'noise':\n",
"self._state = data['Noise']\n",
"if self.type == 'co2':\n",
"self._state = data['CO2']\n",
"if self.type == 'pressure':\n",
"self._state = round(data['Pressure'], 1)\n",
"if self.type == 'battery_lvl':\n",
"self._state = data['battery_vp']\n",
"if self.type == 'battery_vp' and self.module_id == '6':\n",
"if data['battery_vp'] >= 5590:\n",
"if self.type == 'battery_vp' and self.module_id == '5':\n",
"self._state = 'Full'\n",
"if data['battery_vp'] >= 5180:\n",
"if data['battery_vp'] >= 5500:\n",
"if self.type == 'battery_vp' and self.module_id == '3':\n",
"self._state = 'High'\n",
"if data['battery_vp'] >= 4770:\n",
"self._state = 'Full'\n",
"if data['battery_vp'] >= 5000:\n",
"if data['battery_vp'] >= 5640:\n",
"if self.type == 'battery_vp' and self.module_id == '2':\n",
"self._state = 'Medium'\n",
"if data['battery_vp'] >= 4360:\n",
"self._state = 'High'\n",
"if data['battery_vp'] >= 4500:\n",
"self._state = 'Full'\n",
"if data['battery_vp'] >= 5280:\n",
"if data['battery_vp'] >= 5500:\n",
"if self.type == 'min_temp':\n",
"self._state = 'Low'\n",
"if data['battery_vp'] < 4360:\n",
"self._state = 'Medium'\n",
"if data['battery_vp'] >= 4000:\n",
"self._state = 'High'\n",
"if data['battery_vp'] >= 4920:\n",
"self._state = 'Full'\n",
"if data['battery_vp'] >= 5000:\n",
"self._state = data['min_temp']\n",
"if self.type == 'max_temp':\n",
"self._state = 'Very Low'\n",
"self._state = 'Low'\n",
"if data['battery_vp'] < 4000:\n",
"self._state = 'Medium'\n",
"if data['battery_vp'] >= 4560:\n",
"self._state = 'High'\n",
"if data['battery_vp'] >= 4500:\n",
"self._state = data['max_temp']\n",
"if self.type == 'windangle_value':\n",
"self._state = 'Very Low'\n",
"self._state = 'Low'\n",
"if data['battery_vp'] < 4560:\n",
"self._state = 'Medium'\n",
"if data['battery_vp'] >= 4000:\n",
"self._state = data['WindAngle']\n",
"if self.type == 'windangle':\n",
"self._state = 'Very Low'\n",
"self._state = 'Low'\n",
"if data['battery_vp'] < 4000:\n",
"if data['WindAngle'] >= 330:\n",
"if self.type == 'windstrength':\n",
"self._state = 'Very Low'\n",
"self._state = 'N (%d°)' % data['WindAngle']\n",
"if data['WindAngle'] >= 300:\n",
"self._state = data['WindStrength']\n",
"if self.type == 'gustangle_value':\n",
"self._state = 'NW (%d°)' % data['WindAngle']\n",
"if data['WindAngle'] >= 240:\n",
"self._state = data['GustAngle']\n",
"if self.type == 'gustangle':\n",
"self._state = 'W (%d°)' % data['WindAngle']\n",
"if data['WindAngle'] >= 210:\n",
"if data['GustAngle'] >= 330:\n",
"if self.type == 'guststrength':\n",
"self._state = 'SW (%d°)' % data['WindAngle']\n",
"if data['WindAngle'] >= 150:\n",
"self._state = 'N (%d°)' % data['GustAngle']\n",
"if data['GustAngle'] >= 300:\n",
"self._state = data['GustStrength']\n",
"if self.type == 'rf_status_lvl':\n",
"self._state = 'S (%d°)' % data['WindAngle']\n",
"if data['WindAngle'] >= 120:\n",
"self._state = 'NW (%d°)' % data['GustAngle']\n",
"if data['GustAngle'] >= 240:\n",
"self._state = data['rf_status']\n",
"if self.type == 'rf_status':\n",
"self._state = 'SE (%d°)' % data['WindAngle']\n",
"if data['WindAngle'] >= 60:\n",
"self._state = 'W (%d°)' % data['GustAngle']\n",
"if data['GustAngle'] >= 210:\n",
"if data['rf_status'] >= 90:\n",
"if self.type == 'wifi_status_lvl':\n",
"self._state = 'E (%d°)' % data['WindAngle']\n",
"if data['WindAngle'] >= 30:\n",
"self._state = 'SW (%d°)' % data['GustAngle']\n",
"if data['GustAngle'] >= 150:\n",
"self._state = 'Low'\n",
"if data['rf_status'] >= 76:\n",
"self._state = data['wifi_status']\n",
"if self.type == 'wifi_status':\n",
"self._state = 'NE (%d°)' % data['WindAngle']\n",
"if data['WindAngle'] >= 0:\n",
"self._state = 'S (%d°)' % data['GustAngle']\n",
"if data['GustAngle'] >= 120:\n",
"self._state = 'Medium'\n",
"if data['rf_status'] >= 60:\n",
"if data['wifi_status'] >= 86:\n",
"self._state = 'N (%d°)' % data['WindAngle']\n",
"self._state = 'SE (%d°)' % data['GustAngle']\n",
"if data['GustAngle'] >= 60:\n",
"self._state = 'High'\n",
"if data['rf_status'] <= 59:\n",
"self._state = 'Low'\n",
"if data['wifi_status'] >= 71:\n",
"self._state = 'E (%d°)' % data['GustAngle']\n",
"if data['GustAngle'] >= 30:\n",
"self._state = 'Full'\n",
"self._state = 'Medium'\n",
"if data['wifi_status'] >= 56:\n",
"self._state = 'NE (%d°)' % data['GustAngle']\n",
"if data['GustAngle'] >= 0:\n",
"self._state = 'High'\n",
"if data['wifi_status'] <= 55:\n",
"self._state = 'N (%d°)' % data['GustAngle']\n",
"self._state = 'Full'\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'"
] |
[
"def FUNC_0(self):...\n",
"VAR_5 = database.users.get_current_user()\n",
"if VAR_5:\n",
"VAR_3 = db.get(db.Key.from_path('Item', int(self.request.get('item_id'))))\n",
"self.redirect(self.request.referer)\n",
"if VAR_3.created_by_id == VAR_5.user_id(\n",
"database.logging.info('Deleting item with id %s', VAR_3.key().id())\n",
"database.db.delete(VAR_3)\n"
] | [
"def get(self):...\n",
"user = database.users.get_current_user()\n",
"if user:\n",
"item = db.get(db.Key.from_path('Item', int(self.request.get('item_id'))))\n",
"self.redirect(self.request.referer)\n",
"if item.created_by_id == user.user_id(\n",
"database.logging.info('Deleting item with id %s', item.key().id())\n",
"database.db.delete(item)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Expr'"
] |
[
"def FUNC_6(VAR_7, VAR_4):...\n",
"VAR_10 = (VAR_4['page'] - 1) * VAR_4['perPage']\n",
"VAR_11 = f\"\"\"\n SELECT u.username, r.id, r.title, r.comment, r.rating, r.timestamp\n FROM {VAR_0} p, {VAR_2} r, {VAR_3} u\n WHERE p.id={VAR_7} && r.user_id=u.id && r.product_id=p.id\n ORDER BY r.id DESC \n LIMIT {VAR_10}, {VAR_4['perPage']}\n \"\"\"\n",
"VAR_12 = create_connection()\n",
"VAR_12.close()\n",
"VAR_13 = VAR_12.cursor()\n",
"VAR_13.execute(VAR_11)\n",
"return VAR_13.fetchall()\n"
] | [
"def get_product_reviews(productId, filters):...\n",
"offset = (filters['page'] - 1) * filters['perPage']\n",
"sql_query = f\"\"\"\n SELECT u.username, r.id, r.title, r.comment, r.rating, r.timestamp\n FROM {PRODUCTS_TABLE} p, {REVIEWS_TABLE} r, {USERS_TABLE} u\n WHERE p.id={productId} && r.user_id=u.id && r.product_id=p.id\n ORDER BY r.id DESC \n LIMIT {offset}, {filters['perPage']}\n \"\"\"\n",
"connection = create_connection()\n",
"connection.close()\n",
"cursor = connection.cursor()\n",
"cursor.execute(sql_query)\n",
"return cursor.fetchall()\n"
] | [
0,
0,
4,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_9(self):...\n",
"fork(['git', '--git-dir=%s/.git' % self.directory, '--work-tree=%s' % self.\n directory, 'status'])\n"
] | [
"def status(self):...\n",
"fork(['git', '--git-dir=%s/.git' % self.directory, '--work-tree=%s' % self.\n directory, 'status'])\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_14(self, VAR_21, VAR_11):...\n",
"if VAR_0(VAR_11):\n",
"VAR_37, VAR_41 = self.process_lhs(VAR_21, VAR_11)\n",
"VAR_42, VAR_43 = self.process_rhs(VAR_21, VAR_11)\n",
"assert len(VAR_43) == 1, _('A boolean must be provided as argument')\n",
"VAR_4, *VAR_44 = VAR_43\n",
"assert isinstance(VAR_4, bool), _('Lookup argument must be a boolean')\n",
"VAR_42 = ','.join(['%s'] * len(self.empty_values))\n",
"if VAR_4:\n",
"return '%s IS NULL OR %s::text IN (%s)' % (VAR_37, VAR_37, VAR_42\n ), self.empty_values\n",
"return '%s IS NOT NULL AND %s::text NOT IN (%s)' % (VAR_37, VAR_37, VAR_42\n ), self.empty_values\n"
] | [
"def as_sql(self, compiler, connection):...\n",
"if is_postgresql(connection):\n",
"lhs, lhs_params = self.process_lhs(compiler, connection)\n",
"rhs, rhs_params = self.process_rhs(compiler, connection)\n",
"assert len(rhs_params) == 1, _('A boolean must be provided as argument')\n",
"value, *junk = rhs_params\n",
"assert isinstance(value, bool), _('Lookup argument must be a boolean')\n",
"rhs = ','.join(['%s'] * len(self.empty_values))\n",
"if value:\n",
"return '%s IS NULL OR %s::text IN (%s)' % (lhs, lhs, rhs), self.empty_values\n",
"return '%s IS NOT NULL AND %s::text NOT IN (%s)' % (lhs, lhs, rhs\n ), self.empty_values\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Assign'",
"Assert'",
"Assign'",
"Assert'",
"Assign'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_6():...\n",
"VAR_13.throw(_('Invalid Search Field'), VAR_13.DataError)\n"
] | [
"def _raise_exception():...\n",
"frappe.throw(_('Invalid Search Field'), frappe.DataError)\n"
] | [
0,
4
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_39(VAR_101):...\n",
"VAR_101.norun = True\n",
"return VAR_101\n"
] | [
"def decorate(ruleinfo):...\n",
"ruleinfo.norun = True\n",
"return ruleinfo\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Return'"
] |
[
"def FUNC_9(self):...\n",
"VAR_5 = [{'loadBalancerName': self.__lb_name, 'networkLoadBalancerName':\n self.__lb_name, 'region': 'us-central1', 'type': 'deleteLoadBalancer',\n 'regions': ['us-central1'], 'credentials': self.bindings[\n 'GCE_CREDENTIALS'], 'cloudProvider': 'gce', 'user': 'integration-tests'}]\n",
"VAR_6 = gcp.GceContractBuilder(self.gce_observer)\n",
"VAR_6.new_clause_builder('Load Balancer Created', retryable_for_secs=30\n ).list_resources('forwarding-rules').excludes_path_value('name', self.\n __lb_name)\n",
"VAR_7 = self.agent.make_json_payload_from_kwargs(VAR_5=job, description=\n 'Server Group Test - delete load balancer', application=self.TEST_APP)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'delete_load_balancer', data=payload, path=self.__path), contract=\n builder.build())\n"
] | [
"def delete_load_balancer(self):...\n",
"job = [{'loadBalancerName': self.__lb_name, 'networkLoadBalancerName': self\n .__lb_name, 'region': 'us-central1', 'type': 'deleteLoadBalancer',\n 'regions': ['us-central1'], 'credentials': self.bindings[\n 'GCE_CREDENTIALS'], 'cloudProvider': 'gce', 'user': 'integration-tests'}]\n",
"builder = gcp.GceContractBuilder(self.gce_observer)\n",
"builder.new_clause_builder('Load Balancer Created', retryable_for_secs=30\n ).list_resources('forwarding-rules').excludes_path_value('name', self.\n __lb_name)\n",
"payload = self.agent.make_json_payload_from_kwargs(job=job, description=\n 'Server Group Test - delete load balancer', application=self.TEST_APP)\n",
"return st.OperationContract(self.new_post_operation(title=\n 'delete_load_balancer', data=payload, path=self.__path), contract=\n builder.build())\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Return'"
] |
[
"from __future__ import absolute_import, division, print_function, with_statement\n",
"import os\n",
"import sys\n",
"import argparse\n",
"if __name__ == '__main__':\n",
"VAR_0 = argparse.ArgumentParser(description='See README')\n",
"VAR_0.add_argument('-c', '--count', default=3, type=int, help=\n 'with how many failure times it should be considered as an attack')\n",
"VAR_1 = VAR_0.parse_args()\n",
"VAR_2 = {}\n",
"VAR_3 = set()\n",
"for line in sys.stdin:\n",
"if 'can not parse header when' in line:\n",
"VAR_4 = line.split()[-1].split(':')[-2]\n",
"if VAR_4 not in VAR_2:\n",
"VAR_2[VAR_4] = 1\n",
"VAR_2[VAR_4] += 1\n",
"print(VAR_4)\n",
"if VAR_4 not in VAR_3 and VAR_2[VAR_4] >= VAR_1.count:\n",
"sys.stdout.flush()\n",
"VAR_3.add(VAR_4)\n",
"VAR_5 = 'iptables -A INPUT -s %s -j DROP' % VAR_4\n",
"print(VAR_5, file=sys.stderr)\n",
"sys.stderr.flush()\n",
"os.system(VAR_5)\n"
] | [
"from __future__ import absolute_import, division, print_function, with_statement\n",
"import os\n",
"import sys\n",
"import argparse\n",
"if __name__ == '__main__':\n",
"parser = argparse.ArgumentParser(description='See README')\n",
"parser.add_argument('-c', '--count', default=3, type=int, help=\n 'with how many failure times it should be considered as an attack')\n",
"config = parser.parse_args()\n",
"ips = {}\n",
"banned = set()\n",
"for line in sys.stdin:\n",
"if 'can not parse header when' in line:\n",
"ip = line.split()[-1].split(':')[-2]\n",
"if ip not in ips:\n",
"ips[ip] = 1\n",
"ips[ip] += 1\n",
"print(ip)\n",
"if ip not in banned and ips[ip] >= config.count:\n",
"sys.stdout.flush()\n",
"banned.add(ip)\n",
"cmd = 'iptables -A INPUT -s %s -j DROP' % ip\n",
"print(cmd, file=sys.stderr)\n",
"sys.stderr.flush()\n",
"os.system(cmd)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
2,
0,
0,
0,
2,
0,
0,
0,
2,
2,
0,
2
] | [
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Assign'",
"Condition",
"Assign'",
"AugAssign'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_34(VAR_11):...\n",
"VAR_22 = {'camera': camera_images_db, 'main': main_images_db}\n",
"if not VAR_11 in VAR_22:\n",
"return VAR_22[VAR_11]\n"
] | [
"def get_image_database(type):...\n",
"image_databases = {'camera': camera_images_db, 'main': main_images_db}\n",
"if not type in image_databases:\n",
"return image_databases[type]\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Condition",
"Return'"
] |
[
"@classmethod...\n",
"\"\"\"docstring\"\"\"\n",
"return kato.new_agent(VAR_14)\n"
] | [
"@classmethod...\n",
"\"\"\"docstring\"\"\"\n",
"return kato.new_agent(bindings)\n"
] | [
0,
0,
0
] | [
"Condition",
"Docstring",
"Return'"
] |
[
"def FUNC_20(self):...\n",
"self._ServerCleanup()\n"
] | [
"def OnVimLeave(self):...\n",
"self._ServerCleanup()\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_3(VAR_9='', VAR_10='GET', VAR_7='', VAR_4={}):...\n",
"VAR_19 = CLASS_2(VAR_9.split('/'))\n",
"for VAR_20, val in VAR_4.iteritems():\n",
"VAR_19.headers[VAR_20.lower()] = val\n",
"VAR_19.method = VAR_10\n",
"if isinstance(VAR_7, str):\n",
"VAR_19.content = io.BytesIO(VAR_7)\n",
"for VAR_12, val in VAR_7.items():\n",
"return VAR_19\n",
"VAR_19.addArg(VAR_12, val)\n"
] | [
"def request_mock(path='', method='GET', body='', headers={}):...\n",
"dummy = PixRequestMock(path.split('/'))\n",
"for name, val in headers.iteritems():\n",
"dummy.headers[name.lower()] = val\n",
"dummy.method = method\n",
"if isinstance(body, str):\n",
"dummy.content = io.BytesIO(body)\n",
"for key, val in body.items():\n",
"return dummy\n",
"dummy.addArg(key, val)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"For",
"Return'",
"Expr'"
] |
[
"def FUNC_4(self):...\n",
"while self.completed_path < self.MAX_CRAWLS:\n",
"if self.crawler():\n",
"self.completed_path += 1\n",
"self.invalid_path += 1\n",
"print()\n"
] | [
"def crawl(self):...\n",
"while self.completed_path < self.MAX_CRAWLS:\n",
"if self.crawler():\n",
"self.completed_path += 1\n",
"self.invalid_path += 1\n",
"print()\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Condition",
"AugAssign'",
"AugAssign'",
"Expr'"
] |
[
"@VAR_0.route('/js/<path:filename>')...\n",
"return send_from_directory('js', VAR_5)\n"
] | [
"@app.route('/js/<path:filename>')...\n",
"return send_from_directory('js', filename)\n"
] | [
0,
4
] | [
"Condition",
"Return'"
] |
[
"def FUNC_19(VAR_32, VAR_33, VAR_5=False):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_52 = {}\n",
"VAR_61 = {}\n",
"def FUNC_31(VAR_62):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_84 = 0\n",
"while VAR_62[VAR_84].isdigit():\n",
"VAR_84 += 1\n",
"if VAR_84 > 0:\n",
"return int(VAR_62[:VAR_84])\n",
"return 0\n"
] | [
"def _get_core_keywords(skw_matches, ckw_matches, spires=False):...\n",
"\"\"\"docstring\"\"\"\n",
"output = {}\n",
"category = {}\n",
"def _get_value_kw(kw):...\n",
"\"\"\"docstring\"\"\"\n",
"i = 0\n",
"while kw[i].isdigit():\n",
"i += 1\n",
"if i > 0:\n",
"return int(kw[:i])\n",
"return 0\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"AugAssign'",
"Condition",
"Return'",
"Return'"
] |
[
"from reddit_base import RedditController\n",
"from r2.lib.pages import BoringPage, ShowMeetup, NewMeetup, EditMeetup, PaneStack, CommentListing, LinkInfoPage, CommentReplyBox, NotEnoughKarmaToPost\n",
"from validator import validate, VUser, VRequired, VMeetup, VEditMeetup, VFloat, ValueOrBlank, ValidIP, VMenu, VCreateMeetup\n",
"from errors import errors\n",
"from r2.lib.jsonresponse import Json\n",
"from routes.util import url_for\n",
"from r2.models import Meetup, Link, Subreddit, CommentBuilder\n",
"from r2.models.listing import NestedListing\n",
"from r2.lib.menus import CommentSortMenu, NumCommentsMenu\n",
"from r2.lib.filters import python_websafe\n",
"from mako.template import Template\n",
"from pylons.i18n import _\n",
"from pylons import c, g, request\n",
"import json\n",
"def FUNC_0(VAR_0):...\n",
"VAR_1 = Template(filename='r2/templates/showmeetup.html', output_encoding=\n 'utf-8', encoding_errors='replace')\n",
"VAR_2 = VAR_1.get_def('meetup_info').render_unicode(VAR_0=meetup)\n",
"VAR_3 = url_for(controller='meetups', action='show', id=meetup._id36)\n",
"VAR_4 = python_websafe(VAR_0.title)\n",
"VAR_5 = u\"<h2>Discussion article for the meetup : <a href='%s'>%s</a></h2>\" % (\n VAR_3, VAR_4)\n",
"return VAR_5 + VAR_2 + VAR_5\n"
] | [
"from reddit_base import RedditController\n",
"from r2.lib.pages import BoringPage, ShowMeetup, NewMeetup, EditMeetup, PaneStack, CommentListing, LinkInfoPage, CommentReplyBox, NotEnoughKarmaToPost\n",
"from validator import validate, VUser, VRequired, VMeetup, VEditMeetup, VFloat, ValueOrBlank, ValidIP, VMenu, VCreateMeetup\n",
"from errors import errors\n",
"from r2.lib.jsonresponse import Json\n",
"from routes.util import url_for\n",
"from r2.models import Meetup, Link, Subreddit, CommentBuilder\n",
"from r2.models.listing import NestedListing\n",
"from r2.lib.menus import CommentSortMenu, NumCommentsMenu\n",
"from r2.lib.filters import python_websafe\n",
"from mako.template import Template\n",
"from pylons.i18n import _\n",
"from pylons import c, g, request\n",
"import json\n",
"def meetup_article_text(meetup):...\n",
"t = Template(filename='r2/templates/showmeetup.html', output_encoding=\n 'utf-8', encoding_errors='replace')\n",
"res = t.get_def('meetup_info').render_unicode(meetup=meetup)\n",
"url = url_for(controller='meetups', action='show', id=meetup._id36)\n",
"title = python_websafe(meetup.title)\n",
"hdr = u\"<h2>Discussion article for the meetup : <a href='%s'>%s</a></h2>\" % (\n url, title)\n",
"return hdr + res + hdr\n"
] | [
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_44(self):...\n",
"return self._names\n"
] | [
"def keys(self):...\n",
"return self._names\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_5(self):...\n",
"VAR_2 = self.prepare_args()\n",
"VAR_2.limit = self.add_limit()\n",
"if VAR_2.conditions:\n",
"VAR_2.conditions = 'where ' + VAR_2.conditions\n",
"if self.distinct:\n",
"VAR_2.fields = 'distinct ' + VAR_2.fields\n",
"VAR_7 = (\n \"\"\"select %(fields)s from %(tables)s %(conditions)s\n\t\t\t%(group_by)s %(order_by)s %(limit)s\"\"\"\n % VAR_2)\n",
"return frappe.db.sql(VAR_7, as_dict=not self.as_list, VAR_17=self.debug,\n VAR_29=self.update)\n"
] | [
"def build_and_run(self):...\n",
"args = self.prepare_args()\n",
"args.limit = self.add_limit()\n",
"if args.conditions:\n",
"args.conditions = 'where ' + args.conditions\n",
"if self.distinct:\n",
"args.fields = 'distinct ' + args.fields\n",
"query = (\n \"\"\"select %(fields)s from %(tables)s %(conditions)s\n\t\t\t%(group_by)s %(order_by)s %(limit)s\"\"\"\n % args)\n",
"return frappe.db.sql(query, as_dict=not self.as_list, debug=self.debug,\n update=self.update)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_23(VAR_38, VAR_39):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_65 = cmp(len(VAR_39[1][0]), len(VAR_38[1][0]))\n",
"if VAR_65:\n",
"return VAR_65\n",
"if VAR_38[0].isComposite() and VAR_39[0].isComposite():\n",
"VAR_85 = sum(VAR_38[1][1]) / len(VAR_38[1][1])\n",
"return cmp(len(str(VAR_39[0])), len(str(VAR_38[0])))\n",
"VAR_86 = sum(VAR_39[1][1]) / len(VAR_39[1][1])\n",
"VAR_87 = cmp(VAR_86, VAR_85)\n",
"if VAR_87:\n",
"return VAR_87\n"
] | [
"def _skw_matches_comparator(kw0, kw1):...\n",
"\"\"\"docstring\"\"\"\n",
"list_comparison = cmp(len(kw1[1][0]), len(kw0[1][0]))\n",
"if list_comparison:\n",
"return list_comparison\n",
"if kw0[0].isComposite() and kw1[0].isComposite():\n",
"component_avg0 = sum(kw0[1][1]) / len(kw0[1][1])\n",
"return cmp(len(str(kw1[0])), len(str(kw0[0])))\n",
"component_avg1 = sum(kw1[1][1]) / len(kw1[1][1])\n",
"component_comparison = cmp(component_avg1, component_avg0)\n",
"if component_comparison:\n",
"return component_comparison\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Assign'",
"Condition",
"Return'"
] |
[
"def FUNC_18(self):...\n",
"if not self._IsServerAlive():\n",
"return\n",
"SendEventNotificationAsync('InsertLeave')\n"
] | [
"def OnInsertLeave(self):...\n",
"if not self._IsServerAlive():\n",
"return\n",
"SendEventNotificationAsync('InsertLeave')\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Return'",
"Expr'"
] |
[
"def FUNC_12(self):...\n",
"VAR_4 = {url_helper.swarm_constants.COUNT_KEY: 1}\n",
"self._mox.ReplayAll()\n",
"self.assertEqual(url_helper.UrlOpen('url', VAR_4=data), None)\n",
"self._mox.VerifyAll()\n"
] | [
"def testCountKeyInData(self):...\n",
"data = {url_helper.swarm_constants.COUNT_KEY: 1}\n",
"self._mox.ReplayAll()\n",
"self.assertEqual(url_helper.UrlOpen('url', data=data), None)\n",
"self._mox.VerifyAll()\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_2(VAR_3, VAR_4, VAR_5):...\n",
""
] | [
"def check(id, attribute, clss):...\n",
""
] | [
0,
0
] | [
"FunctionDef'",
"Condition"
] |
[
"def FUNC_1(VAR_1):...\n",
"\"\"\"docstring\"\"\"\n",
"if not FUNC_0():\n",
"return VAR_1\n",
"VAR_6 = os.path.normpath(VAR_1).split(os.path.sep)\n",
"for VAR_14 in xrange(2, len(VAR_6)):\n",
"VAR_13 = os.path.sep.join(VAR_6[:VAR_14])\n",
"return os.path.normpath(os.path.sep.join(VAR_6))\n",
"if os.path.isfile(VAR_13):\n",
"VAR_15 = f.read()\n",
"assert '\\n' not in VAR_15 and VAR_15, VAR_15\n",
"VAR_6[VAR_14 - 1] = VAR_15\n"
] | [
"def resolve_symlink(path):...\n",
"\"\"\"docstring\"\"\"\n",
"if not is_windows():\n",
"return path\n",
"parts = os.path.normpath(path).split(os.path.sep)\n",
"for i in xrange(2, len(parts)):\n",
"partial = os.path.sep.join(parts[:i])\n",
"return os.path.normpath(os.path.sep.join(parts))\n",
"if os.path.isfile(partial):\n",
"link = f.read()\n",
"assert '\\n' not in link and link, link\n",
"parts[i - 1] = link\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Assign'",
"For",
"Assign'",
"Return'",
"Condition",
"Assign'",
"Assert'",
"Assign'"
] |
[
"def FUNC_18(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.upload:\n",
"return self.upload\n",
"VAR_26 = self.request.get('upload_key')\n",
"if not VAR_26:\n",
"return None\n",
"VAR_27 = storage.GcsBlobInfo.from_key(VAR_26)\n",
"if not VAR_27:\n",
"self.upload = VAR_27\n",
"return self.upload\n"
] | [
"def get_upload(self):...\n",
"\"\"\"docstring\"\"\"\n",
"if self.upload:\n",
"return self.upload\n",
"upload_key = self.request.get('upload_key')\n",
"if not upload_key:\n",
"return None\n",
"blob_info = storage.GcsBlobInfo.from_key(upload_key)\n",
"if not blob_info:\n",
"self.upload = blob_info\n",
"return self.upload\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Return'"
] |
[
"def FUNC_6(self, VAR_23):...\n",
"if VAR_23:\n",
"VAR_94 = _force_ascii(VAR_23)\n",
"if VAR_94 == VAR_23:\n",
"abort(404, 'page not found')\n",
"return Tag._by_name(VAR_94)\n"
] | [
"def run(self, name):...\n",
"if name:\n",
"cleaned = _force_ascii(name)\n",
"if cleaned == name:\n",
"abort(404, 'page not found')\n",
"return Tag._by_name(cleaned)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Assign'",
"Condition",
"Expr'",
"Return'"
] |
[
"def FUNC_9(VAR_8, VAR_11, VAR_12=False, VAR_13=False, VAR_14=None, VAR_15=False...\n",
"def FUNC_35(VAR_29):...\n",
"VAR_40 = VAR_29.group('name')\n",
"VAR_16 = VAR_11[VAR_40]\n",
"if VAR_15:\n",
"return re.sub(VAR_5, FUNC_35, VAR_8)\n",
"if VAR_13 and VAR_16 == VAR_14:\n",
"return '{{{}}}'.format(VAR_40)\n",
"if VAR_12:\n",
"return str(VAR_16)\n",
"return VAR_14\n"
] | [
"def apply_wildcards(pattern, wildcards, fill_missing=False, fail_dynamic=...\n",
"def format_match(match):...\n",
"name = match.group('name')\n",
"value = wildcards[name]\n",
"if keep_dynamic:\n",
"return re.sub(_wildcard_regex, format_match, pattern)\n",
"if fail_dynamic and value == dynamic_fill:\n",
"return '{{{}}}'.format(name)\n",
"if fill_missing:\n",
"return str(value)\n",
"return dynamic_fill\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_28(self, VAR_23):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_42 = VAR_23.split('.')[0]\n",
"if not self._plugin_exists(VAR_42):\n",
"return False\n",
"if self._check_disabled(VAR_42) and VAR_42 not in self.config['enable_plugins'\n",
"return False\n",
"if self._check_enabled(VAR_42):\n",
"return VAR_23 in self.sos_info['options']\n",
"return True\n"
] | [
"def _plugin_option_exists(self, opt):...\n",
"\"\"\"docstring\"\"\"\n",
"plug = opt.split('.')[0]\n",
"if not self._plugin_exists(plug):\n",
"return False\n",
"if self._check_disabled(plug) and plug not in self.config['enable_plugins']:\n",
"return False\n",
"if self._check_enabled(plug):\n",
"return opt in self.sos_info['options']\n",
"return True\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Return'",
"Condition",
"Return'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_14(self):...\n",
"VAR_5 = None\n",
"VAR_5 = tempfile.NamedTemporaryFile(delete=False)\n",
"if VAR_5:\n",
"VAR_5.close()\n",
"os.remove(VAR_5.name)\n",
"self._mox.StubOutWithMock(url_helper, 'UrlOpen')\n",
"VAR_12 = 'data'\n",
"url_helper.UrlOpen(mox.IgnoreArg(), method='GET').AndReturn(VAR_12)\n",
"self._mox.ReplayAll()\n",
"self.assertTrue(url_helper.DownloadFile(VAR_5.name, 'http://www.fakeurl.com'))\n",
"self.assertEqual(VAR_12, f.read())\n",
"self._mox.VerifyAll()\n"
] | [
"def testDownloadFile(self):...\n",
"local_file = None\n",
"local_file = tempfile.NamedTemporaryFile(delete=False)\n",
"if local_file:\n",
"local_file.close()\n",
"os.remove(local_file.name)\n",
"self._mox.StubOutWithMock(url_helper, 'UrlOpen')\n",
"file_data = 'data'\n",
"url_helper.UrlOpen(mox.IgnoreArg(), method='GET').AndReturn(file_data)\n",
"self._mox.ReplayAll()\n",
"self.assertTrue(url_helper.DownloadFile(local_file.name,\n 'http://www.fakeurl.com'))\n",
"self.assertEqual(file_data, f.read())\n",
"self._mox.VerifyAll()\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_10(self, *VAR_11, **VAR_12):...\n",
"for VAR_9 in VAR_11:\n",
"self._set_params_item(VAR_9)\n",
"for VAR_10, VAR_9 in VAR_12.items():\n",
"self._set_params_item(VAR_9, VAR_10=name)\n"
] | [
"def set_params(self, *params, **kwparams):...\n",
"for item in params:\n",
"self._set_params_item(item)\n",
"for name, item in kwparams.items():\n",
"self._set_params_item(item, name=name)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Expr'",
"For",
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"return 'load statement for task %s (%s)' % (self.task_id, self.url)\n"
] | [
"def describe(self):...\n",
"return 'load statement for task %s (%s)' % (self.task_id, self.url)\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_22(VAR_14, VAR_15):...\n",
"VAR_37 = VAR_14.state['sleep_streak']\n",
"self.assertEqual(VAR_14.remote, self.server)\n",
"if VAR_37 == 5:\n",
"return False\n"
] | [
"def poll_server(botobj, _):...\n",
"sleep_streak = botobj.state['sleep_streak']\n",
"self.assertEqual(botobj.remote, self.server)\n",
"if sleep_streak == 5:\n",
"return False\n"
] | [
0,
0,
5,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Condition",
"Return'"
] |
[
"def FUNC_3(VAR_10=None, VAR_4=None):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_10 = VAR_10 or []\n",
"VAR_4 = VAR_4 or []\n",
"VAR_13 = hashlib.md5(str(time.time())).hexdigest()\n",
"VAR_14 = []\n",
"for VAR_18, VAR_9 in VAR_10:\n",
"VAR_18 = FUNC_2(VAR_18)\n",
"for VAR_18, VAR_19, VAR_9 in VAR_4:\n",
"VAR_9 = FUNC_2(VAR_9)\n",
"VAR_18 = FUNC_2(VAR_18)\n",
"if len(VAR_14) > 1:\n",
"VAR_14.append('--' + VAR_13)\n",
"VAR_19 = FUNC_2(VAR_19)\n",
"VAR_14[-2] += '--'\n",
"VAR_15 = '\\r\\n'.join(VAR_14)\n",
"VAR_14.append('Content-Disposition: form-data; name=\"%s\"' % VAR_18)\n",
"VAR_9 = FUNC_2(VAR_9)\n",
"VAR_16 = 'multipart/form-data; boundary=%s' % VAR_13\n",
"VAR_14.append('')\n",
"VAR_14.append('--' + VAR_13)\n",
"return VAR_16, VAR_15\n",
"VAR_14.append(VAR_9)\n",
"VAR_14.append('Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"' %\n (VAR_18, VAR_19))\n",
"VAR_14.append('--' + VAR_13)\n",
"VAR_14.append('Content-Type: application/octet-stream')\n",
"VAR_14.append('')\n",
"VAR_14.append('')\n",
"VAR_14.append(VAR_9)\n",
"VAR_14.append('--' + VAR_13)\n",
"VAR_14.append('')\n"
] | [
"def EncodeMultipartFormData(fields=None, files=None):...\n",
"\"\"\"docstring\"\"\"\n",
"fields = fields or []\n",
"files = files or []\n",
"boundary = hashlib.md5(str(time.time())).hexdigest()\n",
"body_list = []\n",
"for key, value in fields:\n",
"key = _ConvertToAscii(key)\n",
"for key, filename, value in files:\n",
"value = _ConvertToAscii(value)\n",
"key = _ConvertToAscii(key)\n",
"if len(body_list) > 1:\n",
"body_list.append('--' + boundary)\n",
"filename = _ConvertToAscii(filename)\n",
"body_list[-2] += '--'\n",
"body = '\\r\\n'.join(body_list)\n",
"body_list.append('Content-Disposition: form-data; name=\"%s\"' % key)\n",
"value = _ConvertToAscii(value)\n",
"content_type = 'multipart/form-data; boundary=%s' % boundary\n",
"body_list.append('')\n",
"body_list.append('--' + boundary)\n",
"return content_type, body\n",
"body_list.append(value)\n",
"body_list.append('Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"' %\n (key, filename))\n",
"body_list.append('--' + boundary)\n",
"body_list.append('Content-Type: application/octet-stream')\n",
"body_list.append('')\n",
"body_list.append('')\n",
"body_list.append(value)\n",
"body_list.append('--' + boundary)\n",
"body_list.append('')\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
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"For",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"AugAssign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Return'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def __init__(self, VAR_1, VAR_7, VAR_8, VAR_9, VAR_10=None, VAR_4=None):...\n",
"GenericRequest.__init__(self, VAR_1, VAR_4)\n",
"self.url = '%stasks/%s/test' % (self.base_url, VAR_7[1])\n",
"self.task = VAR_7\n",
"self.submission_format = VAR_8\n",
"self.filenames = VAR_9\n",
"self.data = {}\n",
"if VAR_10 is None:\n",
"for filename in VAR_9:\n",
"if VAR_10 is not None:\n",
"VAR_23 = filename_to_language(filename)\n",
"self.data = {'language': VAR_10}\n",
"if VAR_23 is not None:\n",
"VAR_10 = VAR_23.name\n"
] | [
"def __init__(self, browser, task, submission_format, filenames, language=...\n",
"GenericRequest.__init__(self, browser, base_url)\n",
"self.url = '%stasks/%s/test' % (self.base_url, task[1])\n",
"self.task = task\n",
"self.submission_format = submission_format\n",
"self.filenames = filenames\n",
"self.data = {}\n",
"if language is None:\n",
"for filename in filenames:\n",
"if language is not None:\n",
"lang = filename_to_language(filename)\n",
"self.data = {'language': language}\n",
"if lang is not None:\n",
"language = lang.name\n"
] | [
0,
0,
5,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"For",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'"
] |
[
"def FUNC_4(self, VAR_10, VAR_11):...\n",
"VAR_26 = []\n",
"for VAR_1 in VAR_10:\n",
"VAR_35 = '-'\n",
"return VAR_26\n",
"VAR_28 = VAR_11(VAR_1)\n",
"if not VAR_28:\n",
"VAR_28 = VAR_28[0]\n",
"if VAR_28.access_requested:\n",
"VAR_35 = VAR_28.access_requested.strftime('%Y-%m-%d')\n",
"VAR_16 = {'user': VAR_1.name, 'email': VAR_1.email, 'affiliation': VAR_1.\n affiliation, 'country': VAR_1.country, 'newsletter': VAR_28.\n wants_newsletter, 'has_access': VAR_28.has_access, 'applyDate': VAR_35}\n",
"VAR_26.append(VAR_16)\n"
] | [
"def _build_json_response(self, query, access_for):...\n",
"json_response = []\n",
"for user in query:\n",
"applyDate = '-'\n",
"return json_response\n",
"access = access_for(user)\n",
"if not access:\n",
"access = access[0]\n",
"if access.access_requested:\n",
"applyDate = access.access_requested.strftime('%Y-%m-%d')\n",
"data = {'user': user.name, 'email': user.email, 'affiliation': user.\n affiliation, 'country': user.country, 'newsletter': access.\n wants_newsletter, 'has_access': access.has_access, 'applyDate': applyDate}\n",
"json_response.append(data)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Assign'",
"Return'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Expr'"
] |
[
"def FUNC_6(self, VAR_2, VAR_3, VAR_4, *VAR_5):...\n",
"self.write_data({'type': 'tribler_started'})\n"
] | [
"def on_tribler_started(self, subject, changetype, objectID, *args):...\n",
"self.write_data({'type': 'tribler_started'})\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_11(VAR_3):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_10 = VAR_3.user\n",
"VAR_33 = [(unicode(year), unicode(year)) for year in UserProfile.VALID_YEARS]\n",
"VAR_26 = FUNC_8(VAR_10)\n",
"VAR_1.exception('Error fetching order history from Otto.')\n",
"VAR_5 = {'auth': {}, 'duplicate_provider': None, 'nav_hidden': True,\n 'fields': {'country': {'options': list(countries)}, 'gender': {\n 'options': [(choice[0], _(choice[1])) for choice in UserProfile.\n GENDER_CHOICES]}, 'language': {'options': released_languages()},\n 'level_of_education': {'options': [(choice[0], _(choice[1])) for choice in\n UserProfile.LEVEL_OF_EDUCATION_CHOICES]}, 'password': {'url': reverse(\n 'password_reset')}, 'year_of_birth': {'options': VAR_33},\n 'preferred_language': {'options': all_languages()}, 'time_zone': {\n 'options': TIME_ZONE_CHOICES}}, 'platform_name': configuration_helpers.\n get_value('PLATFORM_NAME', settings.PLATFORM_NAME),\n 'password_reset_support_link': configuration_helpers.get_value(\n 'PASSWORD_RESET_SUPPORT_LINK', settings.PASSWORD_RESET_SUPPORT_LINK) or\n settings.SUPPORT_SITE_LINK, 'user_accounts_api_url': reverse(\n 'accounts_api', kwargs={'username': user.username}),\n 'user_preferences_api_url': reverse('preferences_api', kwargs={\n 'username': user.username}), 'disable_courseware_js': True,\n 'show_program_listing': ProgramsApiConfig.is_enabled(), 'order_history':\n VAR_26}\n",
"VAR_26 = []\n",
"if third_party_auth.is_enabled():\n",
"VAR_5['duplicate_provider'] = pipeline.get_duplicate_provider(messages.\n get_messages(VAR_3))\n",
"return VAR_5\n",
"VAR_37 = pipeline.get_provider_user_states(VAR_10)\n",
"VAR_5['auth']['providers'] = [{'id': state.provider.provider_id, 'name':\n state.provider.name, 'connected': state.has_account, 'connect_url':\n pipeline.get_login_url(state.provider.provider_id, pipeline.\n AUTH_ENTRY_ACCOUNT_SETTINGS, redirect_url=reverse('account_settings')),\n 'accepts_logins': state.provider.accepts_logins, 'disconnect_url':\n pipeline.get_disconnect_url(state.provider.provider_id, state.\n association_id)} for state in VAR_37 if state.provider.\n display_for_login or state.has_account]\n"
] | [
"def account_settings_context(request):...\n",
"\"\"\"docstring\"\"\"\n",
"user = request.user\n",
"year_of_birth_options = [(unicode(year), unicode(year)) for year in\n UserProfile.VALID_YEARS]\n",
"user_orders = get_user_orders(user)\n",
"log.exception('Error fetching order history from Otto.')\n",
"context = {'auth': {}, 'duplicate_provider': None, 'nav_hidden': True,\n 'fields': {'country': {'options': list(countries)}, 'gender': {\n 'options': [(choice[0], _(choice[1])) for choice in UserProfile.\n GENDER_CHOICES]}, 'language': {'options': released_languages()},\n 'level_of_education': {'options': [(choice[0], _(choice[1])) for choice in\n UserProfile.LEVEL_OF_EDUCATION_CHOICES]}, 'password': {'url': reverse(\n 'password_reset')}, 'year_of_birth': {'options': year_of_birth_options},\n 'preferred_language': {'options': all_languages()}, 'time_zone': {\n 'options': TIME_ZONE_CHOICES}}, 'platform_name': configuration_helpers.\n get_value('PLATFORM_NAME', settings.PLATFORM_NAME),\n 'password_reset_support_link': configuration_helpers.get_value(\n 'PASSWORD_RESET_SUPPORT_LINK', settings.PASSWORD_RESET_SUPPORT_LINK) or\n settings.SUPPORT_SITE_LINK, 'user_accounts_api_url': reverse(\n 'accounts_api', kwargs={'username': user.username}),\n 'user_preferences_api_url': reverse('preferences_api', kwargs={\n 'username': user.username}), 'disable_courseware_js': True,\n 'show_program_listing': ProgramsApiConfig.is_enabled(), 'order_history':\n user_orders}\n",
"user_orders = []\n",
"if third_party_auth.is_enabled():\n",
"context['duplicate_provider'] = pipeline.get_duplicate_provider(messages.\n get_messages(request))\n",
"return context\n",
"auth_states = pipeline.get_provider_user_states(user)\n",
"context['auth']['providers'] = [{'id': state.provider.provider_id, 'name':\n state.provider.name, 'connected': state.has_account, 'connect_url':\n pipeline.get_login_url(state.provider.provider_id, pipeline.\n AUTH_ENTRY_ACCOUNT_SETTINGS, redirect_url=reverse('account_settings')),\n 'accepts_logins': state.provider.accepts_logins, 'disconnect_url':\n pipeline.get_disconnect_url(state.provider.provider_id, state.\n association_id)} for state in auth_states if state.provider.\n display_for_login or state.has_account]\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'",
"Assign'"
] |
[
"def FUNC_14(self, VAR_11, VAR_12):...\n",
"self.common._cli_run('createhost -iscsi -add %s %s' % (VAR_11, VAR_12), None)\n"
] | [
"def _modify_3par_iscsi_host(self, hostname, iscsi_iqn):...\n",
"self.common._cli_run('createhost -iscsi -add %s %s' % (hostname, iscsi_iqn),\n None)\n"
] | [
0,
2
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_6(VAR_6, VAR_9):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_17 = VAR_6.id\n",
"VAR_18 = VAR_6.tasks\n",
"VAR_19 = set([VAR_23.id for VAR_23 in VAR_18])\n",
"for task_id, VAR_23 in VAR_9.items():\n",
"if task_id in VAR_19:\n",
"if len(VAR_19) > 0:\n",
"print(VAR_19)\n",
"VAR_23['user_id'] = VAR_17\n",
"for task_id in VAR_19:\n",
"return 'new tasks updated & created'\n",
"VAR_19.remove(task_id)\n",
"VAR_24 = Task(**task)\n",
"VAR_25 = storage.get('Task', task_id)\n",
"VAR_6.bm_update(VAR_23)\n",
"VAR_24.save()\n",
"VAR_25.delete()\n",
"print('deleted task')\n"
] | [
"def update_user_tasks(verified_user, all_tasks):...\n",
"\"\"\"docstring\"\"\"\n",
"user_id = verified_user.id\n",
"db_user_tasks = verified_user.tasks\n",
"db_user_task_ids = set([task.id for task in db_user_tasks])\n",
"for task_id, task in all_tasks.items():\n",
"if task_id in db_user_task_ids:\n",
"if len(db_user_task_ids) > 0:\n",
"print(db_user_task_ids)\n",
"task['user_id'] = user_id\n",
"for task_id in db_user_task_ids:\n",
"return 'new tasks updated & created'\n",
"db_user_task_ids.remove(task_id)\n",
"new_task = Task(**task)\n",
"task_to_delete = storage.get('Task', task_id)\n",
"verified_user.bm_update(task)\n",
"new_task.save()\n",
"task_to_delete.delete()\n",
"print('deleted task')\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
4,
4
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Condition",
"Expr'",
"Assign'",
"For",
"Return'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@staticmethod...\n",
"def FUNC_13(self, *VAR_16, **VAR_10):...\n",
"if not self.current_user or not self.current_user.admin:\n",
"return VAR_7(self, *VAR_16, **kwargs)\n"
] | [
"@staticmethod...\n",
"def wrapper(self, *args, **kwargs):...\n",
"if not self.current_user or not self.current_user.admin:\n",
"return method(self, *args, **kwargs)\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"FunctionDef'",
"Condition",
"Return'"
] |
[
"@property...\n",
"return self.type == 'CP'\n"
] | [
"@property...\n",
"return self.type == 'CP'\n"
] | [
0,
0
] | [
"Condition",
"Return'"
] |
[
"from __future__ import absolute_import, division, print_function, with_statement\n",
"import os\n",
"import sys\n",
"import argparse\n",
"if __name__ == '__main__':\n",
"VAR_0 = argparse.ArgumentParser(description='See README')\n",
"VAR_0.add_argument('-c', '--count', default=3, type=int, help=\n 'with how many failure times it should be considered as an attack')\n",
"VAR_1 = VAR_0.parse_args()\n",
"VAR_2 = {}\n",
"VAR_3 = set()\n",
"for line in sys.stdin:\n",
"if 'can not parse header when' in line:\n",
"VAR_4 = line.split()[-1].split(':')[-2]\n",
"if VAR_4 not in VAR_2:\n",
"VAR_2[VAR_4] = 1\n",
"VAR_2[VAR_4] += 1\n",
"print(VAR_4)\n",
"if VAR_4 not in VAR_3 and VAR_2[VAR_4] >= VAR_1.count:\n",
"sys.stdout.flush()\n",
"VAR_3.add(VAR_4)\n",
"VAR_5 = 'iptables -A INPUT -s %s -j DROP' % VAR_4\n",
"print(VAR_5, file=sys.stderr)\n",
"sys.stderr.flush()\n",
"os.system(VAR_5)\n"
] | [
"from __future__ import absolute_import, division, print_function, with_statement\n",
"import os\n",
"import sys\n",
"import argparse\n",
"if __name__ == '__main__':\n",
"parser = argparse.ArgumentParser(description='See README')\n",
"parser.add_argument('-c', '--count', default=3, type=int, help=\n 'with how many failure times it should be considered as an attack')\n",
"config = parser.parse_args()\n",
"ips = {}\n",
"banned = set()\n",
"for line in sys.stdin:\n",
"if 'can not parse header when' in line:\n",
"ip = line.split()[-1].split(':')[-2]\n",
"if ip not in ips:\n",
"ips[ip] = 1\n",
"ips[ip] += 1\n",
"print(ip)\n",
"if ip not in banned and ips[ip] >= config.count:\n",
"sys.stdout.flush()\n",
"banned.add(ip)\n",
"cmd = 'iptables -A INPUT -s %s -j DROP' % ip\n",
"print(cmd, file=sys.stderr)\n",
"sys.stderr.flush()\n",
"os.system(cmd)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2,
2,
0,
0,
0,
2,
0,
0,
0,
2,
2,
0,
2
] | [
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"Condition",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Condition",
"Assign'",
"Condition",
"Assign'",
"AugAssign'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"from itertools import chain\n",
"import email\n",
"import imaplib\n",
"import json\n",
"import pandas as pd\n",
"import numpy as np\n",
"import re\n",
"from urllib.parse import unquote\n",
"from db_tools import create_connection\n",
"from matcher import match\n",
"import traceback\n",
"import datetime\n",
"import os\n",
"import sys\n",
"import logging\n",
"import smtplib, ssl\n",
"VAR_0 = 465\n",
"VAR_1 = 'smtp.gmail.com'\n",
"VAR_2 = 'dilfo.hb.release'\n",
"VAR_3 = 'https://canada.constructconnect.com/dcn/certificates-and-notices/'\n",
"VAR_4 = logging.getLogger(__name__)\n",
"VAR_5 = logging.StreamHandler(sys.stdout)\n",
"VAR_5.setFormatter(logging.Formatter(\n '%(asctime)s - %(name)s - %(levelname)s - %(message)s - %(funcName)s - line %(lineno)d'\n ))\n",
"VAR_4.addHandler(VAR_5)\n",
"VAR_4.setLevel(logging.INFO)\n",
"VAR_6 = 'imap.gmail.com'\n",
"VAR_7 = 993\n",
"VAR_8 = 'dilfo.hb.release'\n",
"VAR_21 = file.read()\n",
"def FUNC_0(VAR_9):...\n",
"VAR_11 = {unquote(x.split('=')[0]): str(unquote(x.split('=')[1])).replace(\n '+', ' ') for x in VAR_9['content'].split('&')}\n",
"VAR_12 = VAR_11['job_number']\n",
"VAR_27 = pd.read_sql(f'SELECT * FROM df_dilfo WHERE job_number={VAR_12}', conn\n ).iloc[0].closed\n",
"VAR_27 = 0\n",
"VAR_13 = re.findall('<?(\\\\S+@\\\\S+\\\\.\\\\w+)>?', VAR_9['sender'])[0].lower()\n",
"VAR_11.update({'receiver_email': VAR_13})\n",
"if VAR_11['cc_email'] != '':\n",
"VAR_15 = VAR_11.pop('link_to_cert')\n",
"VAR_15 = ''\n",
"if VAR_15:\n",
"VAR_11['cc_email'] += '@dilfo.com'\n",
"VAR_15 = VAR_15.split('-notices/')[1]\n",
"VAR_15 = re.findall('[\\\\w-]*', VAR_15)[0]\n",
"VAR_11.pop('instant_scan')\n",
"VAR_22 = False\n",
"if VAR_27:\n",
"VAR_22 = True\n",
"VAR_4.info(\n f'job was already matched successfully and logged as `closed`. Sending e-mail!'\n )\n",
"if VAR_15:\n",
"VAR_30 = pd.read_sql(\n 'SELECT * FROM df_matched WHERE job_number=? AND ground_truth=1', conn,\n params=[job_number]).iloc[0]\n",
"VAR_11.update({'closed': 1})\n",
"VAR_11.update({'closed': 0})\n",
"VAR_23 = VAR_30.verifier\n",
"VAR_26 = pd.read_sql('SELECT * FROM df_matched', conn)\n",
"VAR_26 = pd.read_sql('SELECT * FROM df_dilfo', conn)\n",
"VAR_24 = VAR_30.log_date\n",
"VAR_29 = {'job_number': VAR_11['job_number'], 'dcn_key': VAR_15,\n 'ground_truth': 1, 'verifier': VAR_11['receiver_email'], 'source':\n 'input', 'log_date': str(datetime.datetime.now().date()), 'validate': 0}\n",
"VAR_26 = VAR_26.append(VAR_11, ignore_index=True)\n",
"VAR_15 = VAR_30.dcn_key\n",
"VAR_26 = VAR_26.append(VAR_29, ignore_index=True)\n",
"for dup_i in VAR_26[VAR_26.duplicated(subset=['job_number'], keep='last')\n",
"VAR_25 = f\"\"\"From: Dilfo HBR Bot\nTo: {VAR_13}\nSubject: Previously Matched: #{VAR_12}\n\nHi {VAR_13.split('.')[0].title()},\n\nIt looks like job #{VAR_12} corresponds to the following certificate:\n{VAR_3}{VAR_15}\n\nThis confirmation was provided by {VAR_23.split('.')[0].title()}{' on ' + VAR_24 if VAR_24 is not None else ''}string\"\"\"\n",
"VAR_26 = VAR_26.drop_duplicates(subset=['job_number', 'dcn_key'], keep='last')\n",
"VAR_32 = VAR_26.iloc[dup_i].job_number\n",
"VAR_26.to_sql('df_dilfo', conn, if_exists='replace', index=False)\n",
"VAR_31 = ssl.create_default_context()\n",
"VAR_4.info('password not available -> could not send e-mail')\n",
"return\n",
"VAR_26.to_sql('df_matched', conn, if_exists='replace', index=False)\n",
"VAR_33 = VAR_26.iloc[dup_i].receiver_email\n",
"if VAR_22:\n",
"VAR_16.login(VAR_2, VAR_21)\n",
"VAR_34 = VAR_26.iloc[dup_i].cc_email\n",
"VAR_35 = 'SELECT * FROM df_dilfo WHERE job_number=?'\n",
"def FUNC_1(VAR_9):...\n",
"VAR_16.sendmail(VAR_2, [VAR_13], VAR_25)\n",
"VAR_26 = VAR_26.drop(dup_i)\n",
"VAR_44 = pd.read_sql(VAR_35, conn, params=[job_number])\n",
"VAR_12 = VAR_9['subject'].split(': #')[1]\n",
"VAR_4.info(f'Successfully sent an email to {VAR_13}')\n",
"VAR_42 = '; '.join([x for x in VAR_34 + VAR_33 if x])\n",
"VAR_36 = 'SELECT * FROM df_hist ORDER BY pub_date DESC LIMIT 2000'\n",
"VAR_14 = re.findall('^[\\\\W]*([Oo\\\\d]){1}(?=[\\\\W]*)', VAR_9['content'].\n replace('#', '').replace('link', ''))[0]\n",
"VAR_43 = VAR_26[VAR_26.job_number == VAR_32].index\n",
"VAR_45 = pd.read_sql(VAR_36, conn)\n",
"VAR_14 = int(0 if VAR_14 == ('O' or 'o') else VAR_14)\n",
"VAR_26.loc[VAR_43, 'cc_email'] = VAR_26.loc[VAR_43, 'cc_email'] + '; ' + VAR_42\n",
"VAR_20 = match(VAR_44=df_dilfo, VAR_45=df_web, test=False)\n",
"VAR_15 = re.findall('\\\\w{8}-\\\\w{4}-\\\\w{4}-\\\\w{4}-\\\\w{12}', VAR_9['content'])[0]\n",
"if len(VAR_20[VAR_20.pred_match == 1]) == 0:\n",
"VAR_4.info(f'got feedback `{VAR_14}` for job #`{VAR_12}`')\n",
"VAR_25 = f\"\"\"From: Dilfo HBR Bot\nTo: {VAR_13}\nSubject: Successful Project Sign-Up: #{VAR_12}\n\nHi {VAR_13.split('.')[0].title()},\n\nYour information for project #{VAR_12}string\"\"\"\n",
"VAR_27 = pd.read_sql(f'SELECT * FROM df_dilfo WHERE job_number={VAR_12}', conn\n ).iloc[0].closed\n",
"VAR_31 = ssl.create_default_context()\n",
"VAR_4.info('password not available -> could not send e-mail')\n",
"if VAR_27:\n",
"VAR_16.login(VAR_2, VAR_21)\n",
"VAR_4.info(\n f'job was already matched successfully and logged as `closed`... skipping.'\n )\n",
"if VAR_14 == 1:\n",
"VAR_16.sendmail(VAR_2, [VAR_13], VAR_25)\n",
"return\n",
"VAR_4.info(f'got feeback that DCN key {VAR_15} was correct')\n",
"VAR_26 = pd.read_sql('SELECT * FROM df_matched', conn)\n",
"VAR_4.info(f'Successfully sent an email to {VAR_13}')\n",
"VAR_28 = 'UPDATE df_dilfo SET closed = 1 WHERE job_number = {}'\n",
"VAR_29 = {'job_number': VAR_12, 'dcn_key': VAR_15, 'ground_truth': 1 if \n VAR_14 == 1 else 0, 'multi_phase': 1 if VAR_14 == 2 else 0, 'verifier':\n VAR_9['sender'], 'source': 'feedback', 'log_date': str(datetime.\n datetime.now().date()), 'validate': 0}\n",
"conn.cursor().execute(VAR_28.format(VAR_12))\n",
"VAR_26 = VAR_26.append(VAR_29, ignore_index=True)\n",
"VAR_4.info(f'updated df_dilfo to show `closed` status for job #{VAR_12}')\n",
"VAR_26 = VAR_26.drop_duplicates(subset=['job_number', 'dcn_key'], keep='last')\n",
"VAR_26.to_sql('df_matched', conn, if_exists='replace', index=False)\n",
"VAR_4.info(\n f\"DCN key `{VAR_15}` was a {'successful match' if VAR_14 == 1 else 'mis-match'} for job #{VAR_12}\"\n )\n",
"def FUNC_2(VAR_10):...\n",
"for response_part in VAR_10:\n",
"if isinstance(response_part, tuple):\n",
"def FUNC_3():...\n",
"VAR_37 = email.message_from_string(response_part[1].decode('UTF-8'))\n",
"VAR_16 = imaplib.IMAP4_SSL(VAR_6, VAR_7)\n",
"VAR_38 = VAR_37['from']\n",
"VAR_16.login(VAR_8, VAR_21)\n",
"VAR_39 = VAR_37['subject']\n",
"VAR_16.select('INBOX')\n",
"VAR_40 = VAR_37['date']\n",
"VAR_17, VAR_10 = VAR_16.search(None, 'UNSEEN')\n",
"for part in VAR_37.walk():\n",
"VAR_18 = VAR_10[0]\n",
"if part.get_content_type() == 'text/plain':\n",
"return VAR_38, VAR_39, VAR_40, VAR_41\n",
"VAR_19 = VAR_18.split()\n",
"VAR_41 = part.get_payload(None, True).decode('UTF-8')\n",
"VAR_41 = ''\n",
"VAR_20 = []\n",
"if len(VAR_19):\n",
"for i, email_id in enumerate(VAR_19, 1):\n",
"VAR_16.logout()\n",
"VAR_17, VAR_10 = VAR_16.fetch(email_id, '(RFC822)')\n",
"return VAR_20\n",
"VAR_4.info(f'parsing new email {i} of {len(VAR_19)}')\n",
"VAR_38, VAR_39, VAR_40, VAR_41 = FUNC_2(VAR_10)\n",
"VAR_20.append({'sender': VAR_38, 'subject': VAR_39, 'date': VAR_40,\n 'content': VAR_41})\n"
] | [
"from itertools import chain\n",
"import email\n",
"import imaplib\n",
"import json\n",
"import pandas as pd\n",
"import numpy as np\n",
"import re\n",
"from urllib.parse import unquote\n",
"from db_tools import create_connection\n",
"from matcher import match\n",
"import traceback\n",
"import datetime\n",
"import os\n",
"import sys\n",
"import logging\n",
"import smtplib, ssl\n",
"port = 465\n",
"smtp_server = 'smtp.gmail.com'\n",
"sender_email = 'dilfo.hb.release'\n",
"lookup_url = (\n 'https://canada.constructconnect.com/dcn/certificates-and-notices/')\n",
"logger = logging.getLogger(__name__)\n",
"log_handler = logging.StreamHandler(sys.stdout)\n",
"log_handler.setFormatter(logging.Formatter(\n '%(asctime)s - %(name)s - %(levelname)s - %(message)s - %(funcName)s - line %(lineno)d'\n ))\n",
"logger.addHandler(log_handler)\n",
"logger.setLevel(logging.INFO)\n",
"imap_ssl_host = 'imap.gmail.com'\n",
"imap_ssl_port = 993\n",
"username = 'dilfo.hb.release'\n",
"password = file.read()\n",
"def process_as_form(email_obj):...\n",
"dict_input = {unquote(x.split('=')[0]): str(unquote(x.split('=')[1])).\n replace('+', ' ') for x in email_obj['content'].split('&')}\n",
"job_number = dict_input['job_number']\n",
"was_prev_closed = pd.read_sql(\n f'SELECT * FROM df_dilfo WHERE job_number={job_number}', conn).iloc[0\n ].closed\n",
"was_prev_closed = 0\n",
"receiver_email = re.findall('<?(\\\\S+@\\\\S+\\\\.\\\\w+)>?', email_obj['sender'])[0\n ].lower()\n",
"dict_input.update({'receiver_email': receiver_email})\n",
"if dict_input['cc_email'] != '':\n",
"dcn_key = dict_input.pop('link_to_cert')\n",
"dcn_key = ''\n",
"if dcn_key:\n",
"dict_input['cc_email'] += '@dilfo.com'\n",
"dcn_key = dcn_key.split('-notices/')[1]\n",
"dcn_key = re.findall('[\\\\w-]*', dcn_key)[0]\n",
"dict_input.pop('instant_scan')\n",
"instant_scan = False\n",
"if was_prev_closed:\n",
"instant_scan = True\n",
"logger.info(\n f'job was already matched successfully and logged as `closed`. Sending e-mail!'\n )\n",
"if dcn_key:\n",
"prev_match = pd.read_sql(\n 'SELECT * FROM df_matched WHERE job_number=? AND ground_truth=1', conn,\n params=[job_number]).iloc[0]\n",
"dict_input.update({'closed': 1})\n",
"dict_input.update({'closed': 0})\n",
"verifier = prev_match.verifier\n",
"df = pd.read_sql('SELECT * FROM df_matched', conn)\n",
"df = pd.read_sql('SELECT * FROM df_dilfo', conn)\n",
"log_date = prev_match.log_date\n",
"match_dict_input = {'job_number': dict_input['job_number'], 'dcn_key':\n dcn_key, 'ground_truth': 1, 'verifier': dict_input['receiver_email'],\n 'source': 'input', 'log_date': str(datetime.datetime.now().date()),\n 'validate': 0}\n",
"df = df.append(dict_input, ignore_index=True)\n",
"dcn_key = prev_match.dcn_key\n",
"df = df.append(match_dict_input, ignore_index=True)\n",
"for dup_i in df[df.duplicated(subset=['job_number'], keep='last')].index:\n",
"message = f\"\"\"From: Dilfo HBR Bot\nTo: {receiver_email}\nSubject: Previously Matched: #{job_number}\n\nHi {receiver_email.split('.')[0].title()},\n\nIt looks like job #{job_number} corresponds to the following certificate:\n{lookup_url}{dcn_key}\n\nThis confirmation was provided by {verifier.split('.')[0].title()}{' on ' + log_date if log_date is not None else ''}.\n\nIf any of the information above seems to be inaccurate, please reply to this e-mail for corrective action.\n\nThanks,\nDilfo HBR Bot\n\"\"\"\n",
"df = df.drop_duplicates(subset=['job_number', 'dcn_key'], keep='last')\n",
"dup_job_number = df.iloc[dup_i].job_number\n",
"df.to_sql('df_dilfo', conn, if_exists='replace', index=False)\n",
"context = ssl.create_default_context()\n",
"logger.info('password not available -> could not send e-mail')\n",
"return\n",
"df.to_sql('df_matched', conn, if_exists='replace', index=False)\n",
"dup_receiver = df.iloc[dup_i].receiver_email\n",
"if instant_scan:\n",
"server.login(sender_email, password)\n",
"dup_cc = df.iloc[dup_i].cc_email\n",
"dilfo_query = 'SELECT * FROM df_dilfo WHERE job_number=?'\n",
"def process_as_reply(email_obj):...\n",
"server.sendmail(sender_email, [receiver_email], message)\n",
"df = df.drop(dup_i)\n",
"df_dilfo = pd.read_sql(dilfo_query, conn, params=[job_number])\n",
"job_number = email_obj['subject'].split(': #')[1]\n",
"logger.info(f'Successfully sent an email to {receiver_email}')\n",
"dup_addrs = '; '.join([x for x in dup_cc + dup_receiver if x])\n",
"hist_query = 'SELECT * FROM df_hist ORDER BY pub_date DESC LIMIT 2000'\n",
"feedback = re.findall('^[\\\\W]*([Oo\\\\d]){1}(?=[\\\\W]*)', email_obj['content']\n .replace('#', '').replace('link', ''))[0]\n",
"update_i = df[df.job_number == dup_job_number].index\n",
"df_web = pd.read_sql(hist_query, conn)\n",
"feedback = int(0 if feedback == ('O' or 'o') else feedback)\n",
"df.loc[update_i, 'cc_email'] = df.loc[update_i, 'cc_email'] + '; ' + dup_addrs\n",
"results = match(df_dilfo=df_dilfo, df_web=df_web, test=False)\n",
"dcn_key = re.findall('\\\\w{8}-\\\\w{4}-\\\\w{4}-\\\\w{4}-\\\\w{12}', email_obj[\n 'content'])[0]\n",
"if len(results[results.pred_match == 1]) == 0:\n",
"logger.info(f'got feedback `{feedback}` for job #`{job_number}`')\n",
"message = f\"\"\"From: Dilfo HBR Bot\nTo: {receiver_email}\nSubject: Successful Project Sign-Up: #{job_number}\n\nHi {receiver_email.split('.')[0].title()},\n\nYour information for project #{job_number} was logged successfully but no corresponding certificates in recent history were matched to it.\n\nGoing forward, the Daily Commercial News website will be scraped on a daily basis in search of your project. You will be notified if a possible match has been detected.\n\nThanks,\nDilfo HBR Bot\n\"\"\"\n",
"was_prev_closed = pd.read_sql(\n f'SELECT * FROM df_dilfo WHERE job_number={job_number}', conn).iloc[0\n ].closed\n",
"context = ssl.create_default_context()\n",
"logger.info('password not available -> could not send e-mail')\n",
"if was_prev_closed:\n",
"server.login(sender_email, password)\n",
"logger.info(\n f'job was already matched successfully and logged as `closed`... skipping.'\n )\n",
"if feedback == 1:\n",
"server.sendmail(sender_email, [receiver_email], message)\n",
"return\n",
"logger.info(f'got feeback that DCN key {dcn_key} was correct')\n",
"df = pd.read_sql('SELECT * FROM df_matched', conn)\n",
"logger.info(f'Successfully sent an email to {receiver_email}')\n",
"update_status_query = 'UPDATE df_dilfo SET closed = 1 WHERE job_number = {}'\n",
"match_dict_input = {'job_number': job_number, 'dcn_key': dcn_key,\n 'ground_truth': 1 if feedback == 1 else 0, 'multi_phase': 1 if feedback ==\n 2 else 0, 'verifier': email_obj['sender'], 'source': 'feedback',\n 'log_date': str(datetime.datetime.now().date()), 'validate': 0}\n",
"conn.cursor().execute(update_status_query.format(job_number))\n",
"df = df.append(match_dict_input, ignore_index=True)\n",
"logger.info(f'updated df_dilfo to show `closed` status for job #{job_number}')\n",
"df = df.drop_duplicates(subset=['job_number', 'dcn_key'], keep='last')\n",
"df.to_sql('df_matched', conn, if_exists='replace', index=False)\n",
"logger.info(\n f\"DCN key `{dcn_key}` was a {'successful match' if feedback == 1 else 'mis-match'} for job #{job_number}\"\n )\n",
"def parse_email(data):...\n",
"for response_part in data:\n",
"if isinstance(response_part, tuple):\n",
"def get_job_input_data():...\n",
"msg = email.message_from_string(response_part[1].decode('UTF-8'))\n",
"server = imaplib.IMAP4_SSL(imap_ssl_host, imap_ssl_port)\n",
"sender = msg['from']\n",
"server.login(username, password)\n",
"subject = msg['subject']\n",
"server.select('INBOX')\n",
"date = msg['date']\n",
"_, data = server.search(None, 'UNSEEN')\n",
"for part in msg.walk():\n",
"mail_ids = data[0]\n",
"if part.get_content_type() == 'text/plain':\n",
"return sender, subject, date, content\n",
"id_list = mail_ids.split()\n",
"content = part.get_payload(None, True).decode('UTF-8')\n",
"content = ''\n",
"results = []\n",
"if len(id_list):\n",
"for i, email_id in enumerate(id_list, 1):\n",
"server.logout()\n",
"_, data = server.fetch(email_id, '(RFC822)')\n",
"return results\n",
"logger.info(f'parsing new email {i} of {len(id_list)}')\n",
"sender, subject, date, content = parse_email(data)\n",
"results.append({'sender': sender, 'subject': subject, 'date': date,\n 'content': content})\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,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
4,
0,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Import'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"AugAssign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Condition",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Expr'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Return'",
"Expr'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Expr'",
"Expr'",
"Condition",
"Expr'",
"Return'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Expr'",
"FunctionDef'",
"For",
"Condition",
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"For",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"For",
"Expr'",
"Assign'",
"Return'",
"Expr'",
"Assign'",
"Expr'"
] |
[
"def FUNC_1(self):...\n",
"VAR_13 = EntityCacheMap()\n",
"VAR_4 = CLASS_2(id=0)\n",
"VAR_13.add(CLASS_2, VAR_4)\n",
"self.assert_equal(VAR_13[CLASS_2].get_by_id(0), VAR_4)\n",
"self.assert_true(VAR_4 in VAR_13)\n",
"self.assert_equal(VAR_13.keys(), [CLASS_2])\n",
"VAR_13.remove(CLASS_2, VAR_4)\n",
"self.assert_false(VAR_4 in VAR_13)\n"
] | [
"def test_basics(self):...\n",
"ecm = EntityCacheMap()\n",
"ent = MyEntity(id=0)\n",
"ecm.add(MyEntity, ent)\n",
"self.assert_equal(ecm[MyEntity].get_by_id(0), ent)\n",
"self.assert_true(ent in ecm)\n",
"self.assert_equal(ecm.keys(), [MyEntity])\n",
"ecm.remove(MyEntity, ent)\n",
"self.assert_false(ent in ecm)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"@property...\n",
"\"\"\"docstring\"\"\"\n"
] | [
"@property...\n",
"\"\"\"docstring\"\"\"\n"
] | [
0,
0
] | [
"Condition",
"Docstring"
] |
[
"@utils.synchronized('3par', external=True)...\n",
"self.common.client_login()\n",
"self.common.delete_volume(VAR_6)\n",
"self.common.client_logout()\n"
] | [
"@utils.synchronized('3par', external=True)...\n",
"self.common.client_login()\n",
"self.common.delete_volume(volume)\n",
"self.common.client_logout()\n"
] | [
0,
0,
0,
0
] | [
"Condition",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_7(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.position += 1\n",
"if self.position < len(self.string):\n",
"self.char = self.string[self.position]\n",
"self.char = None\n",
"return self.char\n"
] | [
"def read(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.position += 1\n",
"if self.position < len(self.string):\n",
"self.char = self.string[self.position]\n",
"self.char = None\n",
"return self.char\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"AugAssign'",
"Condition",
"Assign'",
"Assign'",
"Return'"
] |
[
"def __iter__(self) ->Iterator[CLASS_2]:...\n",
"...\n"
] | [
"def __iter__(self) ->Iterator[IRow]:...\n",
"...\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_11(self, VAR_1, VAR_3, VAR_4=6, VAR_5=10):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_15 = \"/usr/bin/tmsh modify auth user {0} password '{1}'\".format(VAR_1,\n VAR_3)\n",
"VAR_17, VAR_20 = shellutil.run_get_output(VAR_15, log_cmd=False, VAR_8=True)\n",
"if VAR_17 != 0:\n",
"VAR_21 = self.get_userentry('admin')\n",
"if VAR_21 is None:\n",
"VAR_15 = \"/usr/bin/tmsh modify auth user 'admin' password '{0}'\".format(VAR_3)\n",
"VAR_17, VAR_20 = shellutil.run_get_output(VAR_15, log_cmd=False, VAR_8=True)\n",
"if VAR_17 != 0:\n",
"self._save_sys_config()\n",
"return VAR_17\n"
] | [
"def chpasswd(self, username, password, crypt_id=6, salt_len=10):...\n",
"\"\"\"docstring\"\"\"\n",
"cmd = \"/usr/bin/tmsh modify auth user {0} password '{1}'\".format(username,\n password)\n",
"ret, output = shellutil.run_get_output(cmd, log_cmd=False, chk_err=True)\n",
"if ret != 0:\n",
"userentry = self.get_userentry('admin')\n",
"if userentry is None:\n",
"cmd = \"/usr/bin/tmsh modify auth user 'admin' password '{0}'\".format(password)\n",
"ret, output = shellutil.run_get_output(cmd, log_cmd=False, chk_err=True)\n",
"if ret != 0:\n",
"self._save_sys_config()\n",
"return ret\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Expr'",
"Return'"
] |
[
"from google.appengine.ext import ndb\n",
"from gae_libs.handlers.base_handler import BaseHandler\n",
"from gae_libs.handlers.base_handler import Permission\n",
"def FUNC_0(VAR_0, VAR_1):...\n",
"if VAR_0 is None and VAR_1 is None:\n",
"return None, None\n",
"VAR_0 = VAR_0 if VAR_0 is not None else VAR_1\n",
"VAR_1 = VAR_1 if VAR_1 is not None else VAR_0\n",
"return min(VAR_0, VAR_1), max(VAR_0, VAR_1)\n"
] | [
"from google.appengine.ext import ndb\n",
"from gae_libs.handlers.base_handler import BaseHandler\n",
"from gae_libs.handlers.base_handler import Permission\n",
"def _GetLowerAndUpperBoundCommitPositions(lower_bound, upper_bound):...\n",
"if lower_bound is None and upper_bound is None:\n",
"return None, None\n",
"lower_bound = lower_bound if lower_bound is not None else upper_bound\n",
"upper_bound = upper_bound if upper_bound is not None else lower_bound\n",
"return min(lower_bound, upper_bound), max(lower_bound, upper_bound)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"FunctionDef'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def __init__(self, VAR_6):...\n",
"self.meta = VAR_6\n",
"self.parents = []\n",
"self.fields = []\n",
"self.virtual_fields = []\n",
"self.name = None\n",
"self.class_name = None\n",
"self.name_space = NOT_PROVIDED\n",
"self.verbose_name = None\n",
"self.verbose_name_plural = None\n",
"self.abstract = False\n",
"self.doc_group = None\n",
"self.type_field = VAR_0\n",
"self.key_field = None\n",
"self._cache = {}\n"
] | [
"def __init__(self, meta):...\n",
"self.meta = meta\n",
"self.parents = []\n",
"self.fields = []\n",
"self.virtual_fields = []\n",
"self.name = None\n",
"self.class_name = None\n",
"self.name_space = NOT_PROVIDED\n",
"self.verbose_name = None\n",
"self.verbose_name_plural = None\n",
"self.abstract = False\n",
"self.doc_group = None\n",
"self.type_field = DEFAULT_TYPE_FIELD\n",
"self.key_field = None\n",
"self._cache = {}\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_0():...\n",
"VAR_3 = datetime.now()\n",
"VAR_4 = getRedditInstance()\n",
"VAR_5 = VAR_4.subreddit('geoguessr')\n",
"VAR_0 = VAR_5.new(limit=10)\n",
"addToDatabase(VAR_0)\n",
"FUNC_1(VAR_0)\n",
"print(datetime.now() - VAR_3)\n"
] | [
"def checkNewSubmissions():...\n",
"startTime = datetime.now()\n",
"reddit = getRedditInstance()\n",
"subreddit = reddit.subreddit('geoguessr')\n",
"submissionList = subreddit.new(limit=10)\n",
"addToDatabase(submissionList)\n",
"checkForSeriesSubmissions(submissionList)\n",
"print(datetime.now() - startTime)\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_9(self, VAR_10):...\n",
"VAR_22 = _('local_path not supported')\n"
] | [
"def local_path(self, volume):...\n",
"msg = _('local_path not supported')\n"
] | [
0,
0
] | [
"FunctionDef'",
"Assign'"
] |
[
"def FUNC_6(VAR_0, VAR_3, VAR_4, VAR_5, VAR_1):...\n",
"VAR_1.execute('string'.format(VAR_0=playlist_id, VAR_3=title, VAR_4=\n thumbnail, VAR_5=position))\n"
] | [
"def create_video(playlist_id, title, thumbnail, position, db):...\n",
"db.execute(\n \"INSERT INTO video (playlist_id, title, thumbnail, position) VALUES({playlist_id}, '{title}', '{thumbnail}', {position});\"\n .format(playlist_id=playlist_id, title=title, thumbnail=thumbnail,\n position=position))\n"
] | [
0,
4
] | [
"FunctionDef'",
"Expr'"
] |
[
"def __init__(self, *VAR_4, **VAR_5):...\n",
"super(CLASS_0, self).__init__(*VAR_4, **kwargs)\n",
"self.configuration.append_config_values(VAR_1)\n",
"self._group_ip = None\n",
"self.sshpool = None\n"
] | [
"def __init__(self, *args, **kwargs):...\n",
"super(DellEQLSanISCSIDriver, self).__init__(*args, **kwargs)\n",
"self.configuration.append_config_values(eqlx_opts)\n",
"self._group_ip = None\n",
"self.sshpool = None\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Assign'",
"Assign'"
] |
[
"def FUNC_5(self, VAR_4):...\n",
"\"\"\"docstring\"\"\"\n",
"if not os.path.exists(VAR_4):\n",
"VAR_19 = os.path.dirname(VAR_4)\n",
"if not os.path.isdir(VAR_19):\n",
"try_to_create_directory(VAR_19)\n"
] | [
"def prepare_socket_file(self, socket_path):...\n",
"\"\"\"docstring\"\"\"\n",
"if not os.path.exists(socket_path):\n",
"path = os.path.dirname(socket_path)\n",
"if not os.path.isdir(path):\n",
"try_to_create_directory(path)\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Condition",
"Assign'",
"Condition",
"Expr'"
] |
[
"def FUNC_4(VAR_7, VAR_8=7):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_20 = datetime.now()\n",
"VAR_21 = VAR_7.get('startDate') or VAR_7.get('startdate')\n",
"VAR_22 = VAR_7.get('endDate') or VAR_7.get('enddate')\n",
"VAR_23 = FUNC_5(VAR_22) or VAR_20\n",
"VAR_24 = FUNC_5(VAR_21) or VAR_23 - timedelta(days=delta)\n",
"if VAR_24 > VAR_20 or VAR_24.date() >= VAR_23.date():\n",
"VAR_24 = VAR_20 - timedelta(days=7)\n",
"return VAR_24.date(), VAR_23.date()\n",
"VAR_23 = VAR_20 + timedelta(days=1)\n"
] | [
"def clean_date_params(query_dict, delta=7):...\n",
"\"\"\"docstring\"\"\"\n",
"now = datetime.now()\n",
"start_date_param = query_dict.get('startDate') or query_dict.get('startdate')\n",
"end_date_param = query_dict.get('endDate') or query_dict.get('enddate')\n",
"end_date = parse_date(end_date_param) or now\n",
"start_date = parse_date(start_date_param) or end_date - timedelta(days=delta)\n",
"if start_date > now or start_date.date() >= end_date.date():\n",
"start_date = now - timedelta(days=7)\n",
"return start_date.date(), end_date.date()\n",
"end_date = now + timedelta(days=1)\n"
] | [
0,
0,
0,
4,
4,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Return'",
"Assign'"
] |
[
"def __init__(self, VAR_10):...\n",
"super(CLASS_1, self).__init__()\n",
"self.user_id = VAR_0.select('user', 'telegram_id = ' + str(VAR_10))[0]['id']\n",
"self.path = [VAR_0.select('directory', \n \"name = '/' AND parent_directory_id = 'NULL' AND user_id = \" + str(self\n .user_id))[0]['id']]\n",
"self.last_action_message_ids = []\n"
] | [
"def __init__(self, telegram_id):...\n",
"super(Explorer, self).__init__()\n",
"self.user_id = db.select('user', 'telegram_id = ' + str(telegram_id))[0]['id']\n",
"self.path = [db.select('directory', \n \"name = '/' AND parent_directory_id = 'NULL' AND user_id = \" + str(self\n .user_id))[0]['id']]\n",
"self.last_action_message_ids = []\n"
] | [
0,
0,
4,
4,
0
] | [
"FunctionDef'",
"Expr'",
"Assign'",
"Assign'",
"Assign'"
] |
[
"def FUNC_2(VAR_3: Roamer, VAR_2: bool=None) ->object:...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_23 = VAR_3._r_item_\n",
"if VAR_2 and VAR_23 is VAR_0:\n",
"return VAR_23\n"
] | [
"def unwrap(roamer: Roamer, _raise: bool=None) ->object:...\n",
"\"\"\"docstring\"\"\"\n",
"result = roamer._r_item_\n",
"if _raise and result is MISSING:\n",
"return result\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Condition",
"Return'"
] |
[
"import odin\n",
"from odin.fields.virtual import CalculatedField\n",
"from odin.mapping.helpers import sum_fields\n",
"VAR_0 = odin.StringField()\n",
"VAR_48 = None\n",
"VAR_0 = odin.StringField()\n",
"VAR_48 = None\n",
"VAR_49 = True\n",
"VAR_48 = 'library'\n",
"VAR_50 = 'isbn'\n",
"VAR_1 = odin.StringField()\n",
"VAR_2 = odin.StringField()\n",
"VAR_3 = odin.IntegerField()\n",
"VAR_4 = odin.FloatField(default=20.4, use_default_if_not_provided=True)\n",
"VAR_5 = odin.BooleanField(is_attribute=True)\n",
"VAR_6 = odin.StringField(choices=(('sci-fi', 'Science Fiction'), ('fantasy',\n 'Fantasy'), ('biography', 'Biography'), ('others', 'Others'), (\n 'computers-and-tech', 'Computers & technology')))\n",
"VAR_7 = odin.TypedArrayField(odin.DateTimeField())\n",
"VAR_8 = odin.ArrayOf(CLASS_0, use_container=True)\n",
"VAR_9 = odin.DictAs(CLASS_1, null=True)\n",
"def __eq__(self, VAR_10):...\n",
"if VAR_10:\n",
"return vars(self) == vars(VAR_10)\n",
"return False\n"
] | [
"import odin\n",
"from odin.fields.virtual import CalculatedField\n",
"from odin.mapping.helpers import sum_fields\n",
"name = odin.StringField()\n",
"name_space = None\n",
"name = odin.StringField()\n",
"name_space = None\n",
"abstract = True\n",
"name_space = 'library'\n",
"key_field = 'isbn'\n",
"title = odin.StringField()\n",
"isbn = odin.StringField()\n",
"num_pages = odin.IntegerField()\n",
"rrp = odin.FloatField(default=20.4, use_default_if_not_provided=True)\n",
"fiction = odin.BooleanField(is_attribute=True)\n",
"genre = odin.StringField(choices=(('sci-fi', 'Science Fiction'), ('fantasy',\n 'Fantasy'), ('biography', 'Biography'), ('others', 'Others'), (\n 'computers-and-tech', 'Computers & technology')))\n",
"published = odin.TypedArrayField(odin.DateTimeField())\n",
"authors = odin.ArrayOf(Author, use_container=True)\n",
"publisher = odin.DictAs(Publisher, null=True)\n",
"def __eq__(self, other):...\n",
"if other:\n",
"return vars(self) == vars(other)\n",
"return False\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Import'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"FunctionDef'",
"Condition",
"Return'",
"Return'"
] |
[
"def FUNC_10(self):...\n",
"return self.unofficial\n"
] | [
"def is_unofficial(self):...\n",
"return self.unofficial\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_13(self, *VAR_13, **VAR_14):...\n",
"for VAR_9 in VAR_13:\n",
"self._set_log_item(VAR_9)\n",
"for VAR_10, VAR_9 in VAR_14.items():\n",
"self._set_log_item(VAR_9, VAR_10=name)\n"
] | [
"def set_log(self, *logs, **kwlogs):...\n",
"for item in logs:\n",
"self._set_log_item(item)\n",
"for name, item in kwlogs.items():\n",
"self._set_log_item(item, name=name)\n"
] | [
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"For",
"Expr'",
"For",
"Expr'"
] |
[
"def __init__(self, *VAR_10, **VAR_11):...\n",
"\"\"\"docstring\"\"\"\n",
"VAR_21 = self.cartpos = VAR_11.pop('cartpos', None)\n",
"VAR_22 = self.orderpos = VAR_11.pop('orderpos', None)\n",
"VAR_23 = VAR_21 or VAR_22\n",
"VAR_24 = VAR_23.item\n",
"VAR_25 = VAR_23.item.questions_to_ask\n",
"VAR_26 = VAR_11.pop('event')\n",
"super().__init__(*VAR_10, **kwargs)\n",
"if VAR_24.admission and VAR_26.settings.attendee_names_asked:\n",
"self.fields['attendee_name_parts'] = CLASS_1(max_length=255, required=event\n .settings.attendee_names_required, VAR_2=event.settings.name_scheme,\n VAR_32=_('Attendee name'), VAR_40=cartpos.attendee_name_parts if\n cartpos else orderpos.attendee_name_parts)\n",
"if VAR_24.admission and VAR_26.settings.attendee_emails_asked:\n",
"self.fields['attendee_email'] = forms.EmailField(required=event.settings.\n attendee_emails_required, VAR_32=_('Attendee email'), VAR_40=cartpos.\n attendee_email if cartpos else orderpos.attendee_email)\n",
"for VAR_38 in VAR_25:\n",
"VAR_35 = [VAR_30 for VAR_30 in VAR_23.answerlist if VAR_30.question_id ==\n VAR_38.id]\n",
"VAR_27 = question_form_fields.send(sender=event, position=pos)\n",
"if VAR_35:\n",
"VAR_14 = VAR_23.meta_info_data\n",
"VAR_40 = VAR_35[0]\n",
"VAR_40 = None\n",
"for r, response in sorted(VAR_27, VAR_41=lambda r: str(r[0])):\n",
"VAR_36 = pytz.timezone(VAR_26.settings.timezone)\n",
"for VAR_41, VAR_5 in response.items():\n",
"VAR_37 = rich_text(VAR_38.help_text)\n",
"self.fields[VAR_41] = VAR_5\n",
"if VAR_38.type == Question.TYPE_BOOLEAN:\n",
"VAR_5.initial = VAR_14.get('question_form_data', {}).get(VAR_41)\n",
"if VAR_38.required:\n",
"if VAR_38.type == Question.TYPE_NUMBER:\n",
"VAR_1 = forms.CheckboxInput(VAR_4={'required': 'required'})\n",
"VAR_1 = forms.CheckboxInput()\n",
"VAR_3 = forms.DecimalField(VAR_32=q.question, required=q.required, VAR_37=q\n .help_text, VAR_40=initial.answer if initial else None, min_value=\n Decimal('0.00'))\n",
"if VAR_38.type == Question.TYPE_STRING:\n",
"if VAR_40:\n",
"VAR_3.question = VAR_38\n",
"VAR_3 = forms.CharField(VAR_32=q.question, required=q.required, VAR_37=\n help_text, VAR_40=initial.answer if initial else None)\n",
"if VAR_38.type == Question.TYPE_TEXT:\n",
"VAR_42 = VAR_40.answer == 'True'\n",
"VAR_42 = False\n",
"if VAR_35:\n",
"VAR_3 = forms.CharField(VAR_32=q.question, required=q.required, VAR_37=\n help_text, VAR_1=forms.Textarea, VAR_40=initial.answer if initial else None\n )\n",
"if VAR_38.type == Question.TYPE_CHOICE:\n",
"VAR_3 = forms.BooleanField(VAR_32=q.question, required=q.required, VAR_37=\n help_text, VAR_40=initialbool, VAR_1=widget)\n",
"VAR_3.answer = VAR_35[0]\n",
"self.fields['question_%s' % VAR_38.id] = VAR_3\n",
"VAR_3 = forms.ModelChoiceField(queryset=q.options, VAR_32=q.question,\n required=q.required, VAR_37=help_text, VAR_1=forms.Select, empty_label=\n '', VAR_40=initial.options.first() if initial else None)\n",
"if VAR_38.type == Question.TYPE_CHOICE_MULTIPLE:\n",
"VAR_3 = forms.ModelMultipleChoiceField(queryset=q.options, VAR_32=q.\n question, required=q.required, VAR_37=help_text, VAR_1=forms.\n CheckboxSelectMultiple, VAR_40=initial.options.all() if initial else None)\n",
"if VAR_38.type == Question.TYPE_FILE:\n",
"VAR_3 = forms.FileField(VAR_32=q.question, required=q.required, VAR_37=\n help_text, VAR_40=initial.file if initial else None, VAR_1=\n UploadedFileWidget(position=pos, event=event, answer=initial))\n",
"if VAR_38.type == Question.TYPE_DATE:\n",
"VAR_3 = forms.DateField(VAR_32=q.question, required=q.required, VAR_37=\n help_text, VAR_40=dateutil.parser.parse(initial.answer).date() if \n initial and initial.answer else None, VAR_1=DatePickerWidget())\n",
"if VAR_38.type == Question.TYPE_TIME:\n",
"VAR_3 = forms.TimeField(VAR_32=q.question, required=q.required, VAR_37=\n help_text, VAR_40=dateutil.parser.parse(initial.answer).time() if \n initial and initial.answer else None, VAR_1=TimePickerWidget(\n time_format=get_format_without_seconds('TIME_INPUT_FORMATS')))\n",
"if VAR_38.type == Question.TYPE_DATETIME:\n",
"VAR_3 = SplitDateTimeField(VAR_32=q.question, required=q.required, VAR_37=\n help_text, VAR_40=dateutil.parser.parse(initial.answer).astimezone(tz) if\n initial and initial.answer else None, VAR_1=SplitDateTimePickerWidget(\n time_format=get_format_without_seconds('TIME_INPUT_FORMATS')))\n"
] | [
"def __init__(self, *args, **kwargs):...\n",
"\"\"\"docstring\"\"\"\n",
"cartpos = self.cartpos = kwargs.pop('cartpos', None)\n",
"orderpos = self.orderpos = kwargs.pop('orderpos', None)\n",
"pos = cartpos or orderpos\n",
"item = pos.item\n",
"questions = pos.item.questions_to_ask\n",
"event = kwargs.pop('event')\n",
"super().__init__(*args, **kwargs)\n",
"if item.admission and event.settings.attendee_names_asked:\n",
"self.fields['attendee_name_parts'] = NamePartsFormField(max_length=255,\n required=event.settings.attendee_names_required, scheme=event.settings.\n name_scheme, label=_('Attendee name'), initial=cartpos.\n attendee_name_parts if cartpos else orderpos.attendee_name_parts)\n",
"if item.admission and event.settings.attendee_emails_asked:\n",
"self.fields['attendee_email'] = forms.EmailField(required=event.settings.\n attendee_emails_required, label=_('Attendee email'), initial=cartpos.\n attendee_email if cartpos else orderpos.attendee_email)\n",
"for q in questions:\n",
"answers = [a for a in pos.answerlist if a.question_id == q.id]\n",
"responses = question_form_fields.send(sender=event, position=pos)\n",
"if answers:\n",
"data = pos.meta_info_data\n",
"initial = answers[0]\n",
"initial = None\n",
"for r, response in sorted(responses, key=lambda r: str(r[0])):\n",
"tz = pytz.timezone(event.settings.timezone)\n",
"for key, value in response.items():\n",
"help_text = rich_text(q.help_text)\n",
"self.fields[key] = value\n",
"if q.type == Question.TYPE_BOOLEAN:\n",
"value.initial = data.get('question_form_data', {}).get(key)\n",
"if q.required:\n",
"if q.type == Question.TYPE_NUMBER:\n",
"widget = forms.CheckboxInput(attrs={'required': 'required'})\n",
"widget = forms.CheckboxInput()\n",
"field = forms.DecimalField(label=q.question, required=q.required, help_text\n =q.help_text, initial=initial.answer if initial else None, min_value=\n Decimal('0.00'))\n",
"if q.type == Question.TYPE_STRING:\n",
"if initial:\n",
"field.question = q\n",
"field = forms.CharField(label=q.question, required=q.required, help_text=\n help_text, initial=initial.answer if initial else None)\n",
"if q.type == Question.TYPE_TEXT:\n",
"initialbool = initial.answer == 'True'\n",
"initialbool = False\n",
"if answers:\n",
"field = forms.CharField(label=q.question, required=q.required, help_text=\n help_text, widget=forms.Textarea, initial=initial.answer if initial else\n None)\n",
"if q.type == Question.TYPE_CHOICE:\n",
"field = forms.BooleanField(label=q.question, required=q.required, help_text\n =help_text, initial=initialbool, widget=widget)\n",
"field.answer = answers[0]\n",
"self.fields['question_%s' % q.id] = field\n",
"field = forms.ModelChoiceField(queryset=q.options, label=q.question,\n required=q.required, help_text=help_text, widget=forms.Select,\n empty_label='', initial=initial.options.first() if initial else None)\n",
"if q.type == Question.TYPE_CHOICE_MULTIPLE:\n",
"field = forms.ModelMultipleChoiceField(queryset=q.options, label=q.question,\n required=q.required, help_text=help_text, widget=forms.\n CheckboxSelectMultiple, initial=initial.options.all() if initial else None)\n",
"if q.type == Question.TYPE_FILE:\n",
"field = forms.FileField(label=q.question, required=q.required, help_text=\n help_text, initial=initial.file if initial else None, widget=\n UploadedFileWidget(position=pos, event=event, answer=initial))\n",
"if q.type == Question.TYPE_DATE:\n",
"field = forms.DateField(label=q.question, required=q.required, help_text=\n help_text, initial=dateutil.parser.parse(initial.answer).date() if \n initial and initial.answer else None, widget=DatePickerWidget())\n",
"if q.type == Question.TYPE_TIME:\n",
"field = forms.TimeField(label=q.question, required=q.required, help_text=\n help_text, initial=dateutil.parser.parse(initial.answer).time() if \n initial and initial.answer else None, widget=TimePickerWidget(\n time_format=get_format_without_seconds('TIME_INPUT_FORMATS')))\n",
"if q.type == Question.TYPE_DATETIME:\n",
"field = SplitDateTimeField(label=q.question, required=q.required, help_text\n =help_text, initial=dateutil.parser.parse(initial.answer).astimezone(tz\n ) if initial and initial.answer else None, widget=\n SplitDateTimePickerWidget(time_format=get_format_without_seconds(\n 'TIME_INPUT_FORMATS')))\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,
3,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Expr'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"For",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"For",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'",
"Condition",
"Assign'"
] |
[
"def FUNC_8(VAR_11):...\n",
"return True\n"
] | [
"def file_filter(_path):...\n",
"return True\n"
] | [
0,
0
] | [
"FunctionDef'",
"Return'"
] |
[
"def FUNC_4(VAR_4):...\n",
"\"\"\"docstring\"\"\"\n",
"return base64.b64encode(json.dumps(VAR_4, cls=JsonEncoder))\n"
] | [
"def encode_json(value):...\n",
"\"\"\"docstring\"\"\"\n",
"return base64.b64encode(json.dumps(value, cls=JsonEncoder))\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Return'"
] |
[
"def FUNC_1(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.sql_session = SQL_Session()\n"
] | [
"def prepare(self):...\n",
"\"\"\"docstring\"\"\"\n",
"self.sql_session = SQL_Session()\n"
] | [
0,
0,
0
] | [
"FunctionDef'",
"Docstring",
"Assign'"
] |
[
"def FUNC_10(self):...\n",
"self.cursor.execute('DELETE FROM log_simics_memory_diff WHERE result_id=?',\n [self.result['id']])\n",
"self.cursor.execute('DELETE FROM log_simics_register_diff WHERE result_id=?',\n [self.result['id']])\n",
"self.cursor.execute('DELETE FROM log_injection WHERE result_id=?', [self.\n result['id']])\n",
"self.cursor.execute('DELETE FROM log_event WHERE result_id=?', [self.result\n ['id']])\n",
"self.cursor.execute('DELETE FROM log_result WHERE id=?', [self.result['id']])\n"
] | [
"def delete_result(self):...\n",
"self.cursor.execute('DELETE FROM log_simics_memory_diff WHERE result_id=?',\n [self.result['id']])\n",
"self.cursor.execute('DELETE FROM log_simics_register_diff WHERE result_id=?',\n [self.result['id']])\n",
"self.cursor.execute('DELETE FROM log_injection WHERE result_id=?', [self.\n result['id']])\n",
"self.cursor.execute('DELETE FROM log_event WHERE result_id=?', [self.result\n ['id']])\n",
"self.cursor.execute('DELETE FROM log_result WHERE id=?', [self.result['id']])\n"
] | [
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
[
"def FUNC_15(self, VAR_2, VAR_3, VAR_4, *VAR_5):...\n",
"self.write_data({'type': 'market_ask_timeout', 'event': VAR_5[0]})\n"
] | [
"def on_market_ask_timeout(self, subject, changetype, objectID, *args):...\n",
"self.write_data({'type': 'market_ask_timeout', 'event': args[0]})\n"
] | [
0,
0
] | [
"FunctionDef'",
"Expr'"
] |
[
"def FUNC_1(VAR_7):...\n",
"VAR_20 = {}\n",
"for m in re.finditer('(SACSID)\\\\s+(~[0-9a-zA-Z_-]+)\\\\s+([a-z.-]+)(?:\\\\s|$)',\n",
"VAR_25, VAR_24, VAR_26 = m.groups()\n",
"VAR_21 = '(?:TRUE|FALSE)\\\\s+/\\\\s+(?:TRUE|FALSE)\\\\s+\\\\d+\\\\s+'\n",
"VAR_20[VAR_26] = VAR_25, VAR_24\n",
"VAR_22 = '([a-z.-]+)\\\\s+' + VAR_21 + '(SACSID)\\\\s+(~[0-9a-zA-Z_-]+)(?:\\\\s+|$)'\n",
"for m in re.finditer(VAR_22, VAR_7):\n",
"VAR_26, VAR_25, VAR_24 = m.groups()\n",
"if any(not d in VAR_20 for d in ['bugs.chromium.org', 'oss-fuzz.com']):\n",
"VAR_20[VAR_26] = VAR_25, VAR_24\n",
"FUNC_0('Missing domains, got: %s', ' '.join(VAR_20.keys()))\n",
"return VAR_20\n"
] | [
"def parse_cookies(text):...\n",
"cookies = {}\n",
"for m in re.finditer('(SACSID)\\\\s+(~[0-9a-zA-Z_-]+)\\\\s+([a-z.-]+)(?:\\\\s|$)',\n",
"key, value, domain = m.groups()\n",
"garbage = '(?:TRUE|FALSE)\\\\s+/\\\\s+(?:TRUE|FALSE)\\\\s+\\\\d+\\\\s+'\n",
"cookies[domain] = key, value\n",
"cj_pattern = ('([a-z.-]+)\\\\s+' + garbage +\n '(SACSID)\\\\s+(~[0-9a-zA-Z_-]+)(?:\\\\s+|$)')\n",
"for m in re.finditer(cj_pattern, text):\n",
"domain, key, value = m.groups()\n",
"if any(not d in cookies for d in ['bugs.chromium.org', 'oss-fuzz.com']):\n",
"cookies[domain] = key, value\n",
"fatal('Missing domains, got: %s', ' '.join(cookies.keys()))\n",
"return cookies\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"For",
"Assign'",
"Assign'",
"Assign'",
"Assign'",
"For",
"Assign'",
"For",
"Assign'",
"Expr'",
"Return'"
] |
[
"@auth.public...\n",
"VAR_4 = {'is_admin': auth.is_admin()}\n",
"self.response.write(template.render('templates/root.html', VAR_4=params))\n"
] | [
"@auth.public...\n",
"params = {'is_admin': auth.is_admin()}\n",
"self.response.write(template.render('templates/root.html', params=params))\n"
] | [
0,
0,
0
] | [
"Condition",
"Assign'",
"Expr'"
] |
[
"VAR_0 = 'string'\n",
"import sys, os, re\n",
"import unittest\n",
"from decimal import Decimal\n",
"from datetime import datetime, date, time\n",
"from os.path import join, getsize, dirname, abspath\n",
"from testutils import *\n",
"VAR_1 = '0123456789-abcdefghijklmnopqrstuvwxyz-'\n",
"def FUNC_0(VAR_2):...\n",
"\"\"\"docstring\"\"\"\n",
"if VAR_2 <= VAR_23(VAR_1):\n",
"return VAR_1[:VAR_2]\n",
"VAR_3 = (VAR_2 + VAR_23(VAR_1) - 1) / VAR_23(VAR_1)\n",
"VAR_4 = VAR_1 * VAR_3\n",
"return VAR_4[:VAR_2]\n"
] | [
"usage = \"\"\"usage: %prog [options] connection_string\n\nUnit tests for SQLite using the ODBC driver from http://www.ch-werner.de/sqliteodbc\n\nTo use, pass a connection string as the parameter. The tests will create and\ndrop tables t1 and t2 as necessary. On Windows, use the 32-bit driver with\n32-bit Python and the 64-bit driver with 64-bit Python (regardless of your\noperating system bitness).\n\nThese run using the version from the 'build' directory, not the version\ninstalled into the Python directories. You must run python setup.py build\nbefore running the tests.\n\nYou can also put the connection string into a setup.cfg file in the root of the project\n(the same one setup.py would use) like so:\n\n [sqlitetests]\n connection-string=Driver=SQLite3 ODBC Driver;Database=sqlite.db\n\"\"\"\n",
"import sys, os, re\n",
"import unittest\n",
"from decimal import Decimal\n",
"from datetime import datetime, date, time\n",
"from os.path import join, getsize, dirname, abspath\n",
"from testutils import *\n",
"_TESTSTR = '0123456789-abcdefghijklmnopqrstuvwxyz-'\n",
"def _generate_test_string(length):...\n",
"\"\"\"docstring\"\"\"\n",
"if length <= len(_TESTSTR):\n",
"return _TESTSTR[:length]\n",
"c = (length + len(_TESTSTR) - 1) / len(_TESTSTR)\n",
"v = _TESTSTR * c\n",
"return v[:length]\n"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Assign'",
"Import'",
"Import'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"ImportFrom'",
"Assign'",
"FunctionDef'",
"Docstring",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Return'"
] |
[
"def FUNC_5(self, VAR_8):...\n",
"VAR_16 = \"SELECT Votes FROM report WHERE Report_ID = '\" + VAR_8 + \"'\"\n",
"self.cursor.execute(VAR_16)\n",
"VAR_15 = self.cursor.fetchone()\n",
"VAR_17 = ' '.join(map(str, VAR_15))\n",
"VAR_18 = int(VAR_17)\n",
"return VAR_18\n"
] | [
"def get_vote(self, reportID):...\n",
"query1 = \"SELECT Votes FROM report WHERE Report_ID = '\" + reportID + \"'\"\n",
"self.cursor.execute(query1)\n",
"fetch = self.cursor.fetchone()\n",
"curVote = ' '.join(map(str, fetch))\n",
"intVote = int(curVote)\n",
"return intVote\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Assign'",
"Assign'",
"Assign'",
"Return'"
] |
[
"@functools.wraps(VAR_3)...\n",
"VAR_23 = VAR_5.pop('timeout', None)\n",
"VAR_24 = eventlet.spawn(VAR_3, self, *VAR_4, **kwargs)\n",
"if VAR_23 is None:\n",
"return VAR_24.wait()\n",
"VAR_36 = eventlet.spawn_after(VAR_23, VAR_24.kill)\n",
"VAR_48 = VAR_24.wait()\n",
"VAR_36.cancel()\n",
"return VAR_48\n"
] | [
"@functools.wraps(f)...\n",
"timeout = kwargs.pop('timeout', None)\n",
"gt = eventlet.spawn(f, self, *args, **kwargs)\n",
"if timeout is None:\n",
"return gt.wait()\n",
"kill_thread = eventlet.spawn_after(timeout, gt.kill)\n",
"res = gt.wait()\n",
"kill_thread.cancel()\n",
"return res\n"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
"Condition",
"Assign'",
"Assign'",
"Condition",
"Return'",
"Assign'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_9(self, VAR_11, VAR_3):...\n",
"VAR_16 = VAR_11['localattributes'].keys() if 'localattributes' in VAR_11 else [\n ]\n",
"VAR_16.extend(VAR_11['treeattributes'].keys() if 'treeattributes' in VAR_11\n else [])\n",
"return set(VAR_16)\n"
] | [
"def get_attributes(self, levelfields, doc):...\n",
"keys = levelfields['localattributes'].keys(\n ) if 'localattributes' in levelfields else []\n",
"keys.extend(levelfields['treeattributes'].keys() if 'treeattributes' in\n levelfields else [])\n",
"return set(keys)\n"
] | [
0,
0,
0,
0
] | [
"FunctionDef'",
"Assign'",
"Expr'",
"Return'"
] |
[
"def FUNC_11(VAR_18):...\n",
"if not VAR_4:\n",
"print('Restarting worker due to change in %s' % VAR_18.src_path)\n",
"log.info('modified %s' % VAR_18.src_path)\n",
"FUNC_13()\n",
"log.exception('Error while restarting worker')\n",
"FUNC_12()\n"
] | [
"def on_modified(event):...\n",
"if not is_background:\n",
"print('Restarting worker due to change in %s' % event.src_path)\n",
"log.info('modified %s' % event.src_path)\n",
"kill_children()\n",
"log.exception('Error while restarting worker')\n",
"run_children()\n"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
"FunctionDef'",
"Condition",
"Expr'",
"Expr'",
"Expr'",
"Expr'",
"Expr'"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.