lines
sequencelengths
1
383
raw_lines
sequencelengths
1
383
label
sequencelengths
1
383
type
sequencelengths
1
383
[ "def FUNC_4(VAR_4):...\n", "if hasattr(VAR_4, '__iter__'):\n", "return True\n", "return isinstance(VAR_4, basestring)\n" ]
[ "def is_iterable(thing):...\n", "if hasattr(thing, '__iter__'):\n", "return True\n", "return isinstance(thing, basestring)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Return'" ]
[ "def FUNC_119(VAR_174):...\n", "for df in VAR_174.meta.get('fields', {'no_copy': 1}):\n", "if hasattr(VAR_174, df.fieldname):\n", "VAR_174.set(df.fieldname, None)\n" ]
[ "def remove_no_copy_fields(d):...\n", "for df in d.meta.get('fields', {'no_copy': 1}):\n", "if hasattr(d, df.fieldname):\n", "d.set(df.fieldname, None)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Condition", "Expr'" ]
[ "@VAR_0.route('/past/<unique_id>/<measure_type>/<measurement_id>/<past_seconds>'...\n", "\"\"\"docstring\"\"\"\n", "if not str_is_float(VAR_15):\n", "return '', 204\n", "if VAR_12 == 'tag':\n", "VAR_76 = []\n", "if VAR_12 in ['input', 'math', 'function', 'output', 'pid']:\n", "VAR_77 = NoteTags.query.filter(NoteTags.unique_id == VAR_9).first()\n", "VAR_47 = InfluxDBClient(INFLUXDB_HOST, INFLUXDB_PORT, INFLUXDB_USER,\n INFLUXDB_PASSWORD, INFLUXDB_DATABASE)\n", "VAR_78 = Notes.query.filter(Notes.date_time >= datetime.datetime.utcnow() -\n datetime.timedelta(seconds=int(past_seconds))).all()\n", "if VAR_12 in ['input', 'math', 'function', 'output', 'pid']:\n", "for each_note in VAR_78:\n", "VAR_83 = DeviceMeasurements.query.filter(DeviceMeasurements.unique_id == VAR_13\n ).first()\n", "VAR_83 = None\n", "if VAR_77.unique_id in each_note.tags.split(','):\n", "if VAR_76:\n", "if not VAR_83:\n", "VAR_76.append([each_note.date_time.strftime('%Y-%m-%dT%H:%M:%S.000000000Z'),\n each_note.name, each_note.note])\n", "return jsonify(VAR_76)\n", "return '', 204\n", "return 'Could not find measurement'\n", "if VAR_83:\n", "VAR_80 = Conversion.query.filter(Conversion.unique_id == VAR_83.conversion_id\n ).first()\n", "VAR_80 = None\n", "VAR_22, VAR_21, VAR_29 = return_measurement_info(VAR_83, VAR_80)\n", "if hasattr(VAR_83, 'measurement_type'\n", "VAR_107 = PID.query.filter(PID.unique_id == VAR_83.device_id).first()\n", "VAR_61 = query_string(VAR_21, VAR_9, VAR_83=measurement, VAR_22=channel,\n past_sec=past_seconds)\n", "VAR_1.debug(\"URL for 'past_data' raised and error: {err}\".format(err=e))\n", "if VAR_107 and ',' in VAR_107.measurement:\n", "if VAR_61 == 1:\n", "return '', 204\n", "VAR_110 = VAR_107.measurement.split(',')[1]\n", "return '', 204\n", "VAR_62 = VAR_47.query(VAR_61).raw\n", "VAR_111 = DeviceMeasurements.query.filter(DeviceMeasurements.unique_id ==\n VAR_110).first()\n", "if 'series' in VAR_62 and VAR_62['series']:\n", "if VAR_111:\n", "return jsonify(VAR_62['series'][0]['values'])\n", "return '', 204\n", "VAR_80 = Conversion.query.filter(Conversion.unique_id == VAR_111.conversion_id\n ).first()\n", "VAR_37, VAR_21, VAR_29 = return_measurement_info(VAR_111, VAR_80)\n" ]
[ "@blueprint.route(...\n", "\"\"\"docstring\"\"\"\n", "if not str_is_float(past_seconds):\n", "return '', 204\n", "if measure_type == 'tag':\n", "notes_list = []\n", "if measure_type in ['input', 'math', 'function', 'output', 'pid']:\n", "tag = NoteTags.query.filter(NoteTags.unique_id == unique_id).first()\n", "dbcon = InfluxDBClient(INFLUXDB_HOST, INFLUXDB_PORT, INFLUXDB_USER,\n INFLUXDB_PASSWORD, INFLUXDB_DATABASE)\n", "notes = Notes.query.filter(Notes.date_time >= datetime.datetime.utcnow() -\n datetime.timedelta(seconds=int(past_seconds))).all()\n", "if measure_type in ['input', 'math', 'function', 'output', 'pid']:\n", "for each_note in notes:\n", "measure = DeviceMeasurements.query.filter(DeviceMeasurements.unique_id ==\n measurement_id).first()\n", "measure = None\n", "if tag.unique_id in each_note.tags.split(','):\n", "if notes_list:\n", "if not measure:\n", "notes_list.append([each_note.date_time.strftime(\n '%Y-%m-%dT%H:%M:%S.000000000Z'), each_note.name, each_note.note])\n", "return jsonify(notes_list)\n", "return '', 204\n", "return 'Could not find measurement'\n", "if measure:\n", "conversion = Conversion.query.filter(Conversion.unique_id == measure.\n conversion_id).first()\n", "conversion = None\n", "channel, unit, measurement = return_measurement_info(measure, conversion)\n", "if hasattr(measure, 'measurement_type'\n", "setpoint_pid = PID.query.filter(PID.unique_id == measure.device_id).first()\n", "query_str = query_string(unit, unique_id, measure=measurement, channel=\n channel, past_sec=past_seconds)\n", "logger.debug(\"URL for 'past_data' raised and error: {err}\".format(err=e))\n", "if setpoint_pid and ',' in setpoint_pid.measurement:\n", "if query_str == 1:\n", "return '', 204\n", "pid_measurement = setpoint_pid.measurement.split(',')[1]\n", "return '', 204\n", "raw_data = dbcon.query(query_str).raw\n", "setpoint_measurement = DeviceMeasurements.query.filter(DeviceMeasurements.\n unique_id == pid_measurement).first()\n", "if 'series' in raw_data and raw_data['series']:\n", "if setpoint_measurement:\n", "return jsonify(raw_data['series'][0]['values'])\n", "return '', 204\n", "conversion = Conversion.query.filter(Conversion.unique_id ==\n setpoint_measurement.conversion_id).first()\n", "_, unit, measurement = return_measurement_info(setpoint_measurement, conversion\n )\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Return'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "For", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Expr'", "Return'", "Return'", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Condition", "Condition", "Return'", "Assign'", "Return'", "Assign'", "Assign'", "Condition", "Condition", "Return'", "Return'", "Assign'", "Assign'" ]
[ "def FUNC_8(self):...\n", "self.room_members = [VAR_0, VAR_1]\n", "self.assertEquals(self.event_source.get_current_key(), 0)\n", "self.get_success(self.handler.started_typing(target_user=U_APPLE, requester\n =create_requester(U_APPLE), VAR_16=ROOM_ID, timeout=10000))\n", "self.on_new_event.assert_has_calls([call('typing_key', 1, rooms=[ROOM_ID])])\n", "self.on_new_event.reset_mock()\n", "self.assertEquals(self.event_source.get_current_key(), 1)\n", "VAR_18 = self.get_success(self.event_source.get_new_events(room_ids=[\n ROOM_ID], from_key=0))\n", "self.assertEquals(VAR_18[0], [{'type': 'm.typing', 'room_id': VAR_3,\n 'content': {'user_ids': [VAR_0.to_string()]}}])\n", "self.reactor.pump([16])\n", "self.on_new_event.assert_has_calls([call('typing_key', 2, rooms=[ROOM_ID])])\n", "self.assertEquals(self.event_source.get_current_key(), 2)\n", "VAR_18 = self.get_success(self.event_source.get_new_events(room_ids=[\n ROOM_ID], from_key=1))\n", "self.assertEquals(VAR_18[0], [{'type': 'm.typing', 'room_id': VAR_3,\n 'content': {'user_ids': []}}])\n", "self.get_success(self.handler.started_typing(target_user=U_APPLE, requester\n =create_requester(U_APPLE), VAR_16=ROOM_ID, timeout=10000))\n", "self.on_new_event.assert_has_calls([call('typing_key', 3, rooms=[ROOM_ID])])\n", "self.on_new_event.reset_mock()\n", "self.assertEquals(self.event_source.get_current_key(), 3)\n", "VAR_18 = self.get_success(self.event_source.get_new_events(room_ids=[\n ROOM_ID], from_key=0))\n", "self.assertEquals(VAR_18[0], [{'type': 'm.typing', 'room_id': VAR_3,\n 'content': {'user_ids': [VAR_0.to_string()]}}])\n" ]
[ "def test_typing_timeout(self):...\n", "self.room_members = [U_APPLE, U_BANANA]\n", "self.assertEquals(self.event_source.get_current_key(), 0)\n", "self.get_success(self.handler.started_typing(target_user=U_APPLE, requester\n =create_requester(U_APPLE), room_id=ROOM_ID, timeout=10000))\n", "self.on_new_event.assert_has_calls([call('typing_key', 1, rooms=[ROOM_ID])])\n", "self.on_new_event.reset_mock()\n", "self.assertEquals(self.event_source.get_current_key(), 1)\n", "events = self.get_success(self.event_source.get_new_events(room_ids=[\n ROOM_ID], from_key=0))\n", "self.assertEquals(events[0], [{'type': 'm.typing', 'room_id': ROOM_ID,\n 'content': {'user_ids': [U_APPLE.to_string()]}}])\n", "self.reactor.pump([16])\n", "self.on_new_event.assert_has_calls([call('typing_key', 2, rooms=[ROOM_ID])])\n", "self.assertEquals(self.event_source.get_current_key(), 2)\n", "events = self.get_success(self.event_source.get_new_events(room_ids=[\n ROOM_ID], from_key=1))\n", "self.assertEquals(events[0], [{'type': 'm.typing', 'room_id': ROOM_ID,\n 'content': {'user_ids': []}}])\n", "self.get_success(self.handler.started_typing(target_user=U_APPLE, requester\n =create_requester(U_APPLE), room_id=ROOM_ID, timeout=10000))\n", "self.on_new_event.assert_has_calls([call('typing_key', 3, rooms=[ROOM_ID])])\n", "self.on_new_event.reset_mock()\n", "self.assertEquals(self.event_source.get_current_key(), 3)\n", "events = self.get_success(self.event_source.get_new_events(room_ids=[\n ROOM_ID], from_key=0))\n", "self.assertEquals(events[0], [{'type': 'm.typing', 'room_id': ROOM_ID,\n 'content': {'user_ids': [U_APPLE.to_string()]}}])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_44(self):...\n", "\"\"\"docstring\"\"\"\n", "for modulename in self.server_extensions:\n", "VAR_11 = importlib.import_module(modulename)\n", "if self.reraise_server_extension_failures:\n", "VAR_106 = getattr(VAR_11, 'load_jupyter_server_extension', None)\n", "self.log.warn('Error loading server extension %s', modulename, exc_info=True)\n", "if VAR_106 is not None:\n", "VAR_106(self)\n" ]
[ "def init_server_extensions(self):...\n", "\"\"\"docstring\"\"\"\n", "for modulename in self.server_extensions:\n", "mod = importlib.import_module(modulename)\n", "if self.reraise_server_extension_failures:\n", "func = getattr(mod, 'load_jupyter_server_extension', None)\n", "self.log.warn('Error loading server extension %s', modulename, exc_info=True)\n", "if func is not None:\n", "func(self)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "For", "Assign'", "Condition", "Assign'", "Expr'", "Condition", "Expr'" ]
[ "def FUNC_1(VAR_11, VAR_12=''):...\n", "\"\"\"docstring\"\"\"\n", "return force_text(urllib_parse.quote_plus(force_str(VAR_11), force_str(VAR_12))\n )\n" ]
[ "def urlquote_plus(url, safe=''):...\n", "\"\"\"docstring\"\"\"\n", "return force_text(urllib_parse.quote_plus(force_str(url), force_str(safe)))\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def __init__(self, *VAR_13, **VAR_14):...\n", "super(CLASS_2, self).__init__(*VAR_13, **kwargs)\n", "if not check_path_owner(self.directory):\n", "VAR_1.warning('string', self.directory)\n", "self.directory = None\n" ]
[ "def __init__(self, *args, **kwargs):...\n", "super(SafeFileCache, self).__init__(*args, **kwargs)\n", "if not check_path_owner(self.directory):\n", "logger.warning(\n \"The directory '%s' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.\"\n , self.directory)\n", "self.directory = None\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Condition", "Expr'", "Assign'" ]
[ "def FUNC_9(VAR_26: Optional[Dict[Text, Any]]) ->Text:...\n", "if not VAR_26:\n", "return ''\n", "VAR_58 = copy.deepcopy(VAR_26)\n", "for key in ['pipeline', 'policies']:\n", "if VAR_58.get(key):\n", "return rasa.shared.utils.io.deep_container_fingerprint(VAR_58)\n", "for p in VAR_58[key]:\n", "if 'epochs' in p:\n" ]
[ "def _get_fingerprint_of_config_without_epochs(config: Optional[Dict[Text, Any]]...\n", "if not config:\n", "return ''\n", "copied_config = copy.deepcopy(config)\n", "for key in ['pipeline', 'policies']:\n", "if copied_config.get(key):\n", "return rasa.shared.utils.io.deep_container_fingerprint(copied_config)\n", "for p in copied_config[key]:\n", "if 'epochs' in p:\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Assign'", "For", "Condition", "Return'", "For", "Condition" ]
[ "def FUNC_74(VAR_129, VAR_42):...\n", "if hasattr(VAR_129, 'fnargs'):\n", "VAR_210 = VAR_129.fnargs\n", "VAR_210, VAR_220, VAR_221, VAR_222 = inspect.getargspec(VAR_129)\n", "VAR_210 = inspect.getfullargspec(VAR_129).args\n", "VAR_194 = {}\n", "VAR_220 = inspect.getfullargspec(VAR_129).varargs\n", "for VAR_223 in VAR_42:\n", "VAR_221 = inspect.getfullargspec(VAR_129).varkw\n", "if VAR_223 in VAR_210 or VAR_221:\n", "VAR_194.pop('ignore_permissions', None)\n", "VAR_222 = inspect.getfullargspec(VAR_129).defaults\n", "VAR_194[VAR_223] = VAR_42.get(VAR_223)\n", "VAR_194.pop('flags', None)\n", "return VAR_194\n" ]
[ "def get_newargs(fn, kwargs):...\n", "if hasattr(fn, 'fnargs'):\n", "fnargs = fn.fnargs\n", "fnargs, varargs, varkw, defaults = inspect.getargspec(fn)\n", "fnargs = inspect.getfullargspec(fn).args\n", "newargs = {}\n", "varargs = inspect.getfullargspec(fn).varargs\n", "for a in kwargs:\n", "varkw = inspect.getfullargspec(fn).varkw\n", "if a in fnargs or varkw:\n", "newargs.pop('ignore_permissions', None)\n", "defaults = inspect.getfullargspec(fn).defaults\n", "newargs[a] = kwargs.get(a)\n", "newargs.pop('flags', None)\n", "return newargs\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_70(VAR_15, VAR_145):...\n", "VAR_107 = FUNC_12(VAR_145, 'inverted', VAR_15.getSizeC())\n", "VAR_50, VAR_51, VAR_52 = FUNC_2(VAR_145['c'])\n", "VAR_15.setActiveChannels(VAR_50, VAR_51, VAR_52, VAR_107)\n", "if VAR_145['m'] == 'g':\n", "VAR_15.setGreyscaleRenderingModel()\n", "VAR_15.setColorRenderingModel()\n", "if 'z' in VAR_145:\n", "VAR_15._re.setDefaultZ(VAR_178(VAR_145['z']) - 1)\n", "if 't' in VAR_145:\n", "VAR_15._re.setDefaultT(VAR_178(VAR_145['t']) - 1)\n", "VAR_15.saveDefaults()\n" ]
[ "def applyRenderingSettings(image, rdef):...\n", "invert_flags = _get_maps_enabled(rdef, 'inverted', image.getSizeC())\n", "channels, windows, colors = _split_channel_info(rdef['c'])\n", "image.setActiveChannels(channels, windows, colors, invert_flags)\n", "if rdef['m'] == 'g':\n", "image.setGreyscaleRenderingModel()\n", "image.setColorRenderingModel()\n", "if 'z' in rdef:\n", "image._re.setDefaultZ(long(rdef['z']) - 1)\n", "if 't' in rdef:\n", "image._re.setDefaultT(long(rdef['t']) - 1)\n", "image.saveDefaults()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Expr'", "Condition", "Expr'", "Expr'", "Condition", "Expr'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_31(VAR_31):...\n", "VAR_63 = \"'\" * isinstance(VAR_31, str)\n", "return VAR_63 + str(VAR_31) + VAR_63\n" ]
[ "def _maybe_add_quotes(value):...\n", "is_quotes = \"'\" * isinstance(value, str)\n", "return is_quotes + str(value) + is_quotes\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_19(VAR_9, VAR_10, VAR_11):...\n", "if VAR_87.role_admin():\n", "VAR_11 = int(VAR_11)\n", "VAR_11 = VAR_87.id\n", "if VAR_87.check_visibility(constants.SIDEBAR_DOWNLOAD):\n", "if VAR_87.show_detail_random():\n", "abort(404)\n", "VAR_68 = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()\n ).order_by(func.random()).limit(config.config_random_books)\n", "VAR_68 = false()\n", "VAR_63, VAR_64, VAR_65 = calibre_db.fill_indexpage(VAR_9, 0, db.Books, ub.\n Downloads.user_id == VAR_11, VAR_10, ub.Downloads, db.Books.id == ub.\n Downloads.book_id)\n", "for VAR_95 in VAR_63:\n", "if not calibre_db.session.query(db.Books).filter(calibre_db.common_filters()\n", "VAR_104 = ub.session.query(ub.User).filter(ub.User.id == VAR_11).first()\n", "ub.delete_download(VAR_95.id)\n", "return render_title_template('index.html', VAR_68=random, VAR_63=entries,\n VAR_65=pagination, id=user_id, VAR_149=_(\n u'Downloaded books by %(user)s', user=user.name), VAR_9='download')\n" ]
[ "def render_downloaded_books(page, order, user_id):...\n", "if current_user.role_admin():\n", "user_id = int(user_id)\n", "user_id = current_user.id\n", "if current_user.check_visibility(constants.SIDEBAR_DOWNLOAD):\n", "if current_user.show_detail_random():\n", "abort(404)\n", "random = calibre_db.session.query(db.Books).filter(calibre_db.common_filters()\n ).order_by(func.random()).limit(config.config_random_books)\n", "random = false()\n", "entries, __, pagination = calibre_db.fill_indexpage(page, 0, db.Books, ub.\n Downloads.user_id == user_id, order, ub.Downloads, db.Books.id == ub.\n Downloads.book_id)\n", "for book in entries:\n", "if not calibre_db.session.query(db.Books).filter(calibre_db.common_filters()\n", "user = ub.session.query(ub.User).filter(ub.User.id == user_id).first()\n", "ub.delete_download(book.id)\n", "return render_title_template('index.html', random=random, entries=entries,\n pagination=pagination, id=user_id, title=_(\n u'Downloaded books by %(user)s', user=user.name), page='download')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "For", "Condition", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_43(self, VAR_21, VAR_22, VAR_20):...\n", "if not self.view_settings.get(VAR_21):\n", "self.view_settings[VAR_21] = dict()\n", "self.view_settings[VAR_21][VAR_22] = VAR_20\n", "flag_modified(self, 'view_settings')\n", "VAR_1.commit()\n", "VAR_1.rollback()\n" ]
[ "def set_view_property(self, page, prop, value):...\n", "if not self.view_settings.get(page):\n", "self.view_settings[page] = dict()\n", "self.view_settings[page][prop] = value\n", "flag_modified(self, 'view_settings')\n", "session.commit()\n", "session.rollback()\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_6(self):...\n", "if not self.json:\n", "print('Currently running servers:')\n", "for serverinfo in FUNC_2(self.runtime_dir):\n", "if self.json:\n", "print(VAR_27.dumps(serverinfo))\n", "print(serverinfo['url'], '::', serverinfo['notebook_dir'])\n" ]
[ "def start(self):...\n", "if not self.json:\n", "print('Currently running servers:')\n", "for serverinfo in list_running_servers(self.runtime_dir):\n", "if self.json:\n", "print(json.dumps(serverinfo))\n", "print(serverinfo['url'], '::', serverinfo['notebook_dir'])\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "For", "Condition", "Expr'", "Expr'" ]
[ "@VAR_2.route('/ajax/editrestriction/<int:res_type>', defaults={'user_id': 0...\n", "VAR_10 = request.form.to_dict()\n", "if VAR_10['id'].startswith('a'):\n", "if VAR_8 == 0:\n", "if VAR_10['id'].startswith('d'):\n", "VAR_69 = config.list_allowed_tags()\n", "if VAR_8 == 1:\n", "if VAR_8 == 0:\n", "return ''\n", "VAR_69[VAR_119(VAR_10['id'][1:])] = VAR_10['Element']\n", "VAR_69 = config.list_allowed_column_values()\n", "if VAR_8 == 2:\n", "VAR_69 = config.list_denied_tags()\n", "if VAR_8 == 1:\n", "config.config_allowed_tags = ','.join(VAR_69)\n", "VAR_69[VAR_119(VAR_10['id'][1:])] = VAR_10['Element']\n", "if isinstance(VAR_9, VAR_119):\n", "if VAR_8 == 3:\n", "VAR_69[VAR_119(VAR_10['id'][1:])] = VAR_10['Element']\n", "VAR_69 = config.list_denied_column_values()\n", "if VAR_8 == 2:\n", "config.save()\n", "config.config_allowed_column_value = ','.join(VAR_69)\n", "VAR_120 = ub.session.query(ub.User).filter(ub.User.id == VAR_119(VAR_9)).first(\n )\n", "VAR_120 = VAR_62\n", "if isinstance(VAR_9, VAR_119):\n", "config.config_denied_tags = ','.join(VAR_69)\n", "VAR_69[VAR_119(VAR_10['id'][1:])] = VAR_10['Element']\n", "if isinstance(VAR_9, VAR_119):\n", "if VAR_8 == 3:\n", "config.save()\n", "VAR_69 = VAR_120.list_allowed_tags()\n", "VAR_120 = ub.session.query(ub.User).filter(ub.User.id == VAR_119(VAR_9)).first(\n )\n", "VAR_120 = VAR_62\n", "config.save()\n", "config.config_denied_column_value = ','.join(VAR_69)\n", "VAR_120 = ub.session.query(ub.User).filter(ub.User.id == VAR_119(VAR_9)).first(\n )\n", "VAR_120 = VAR_62\n", "if isinstance(VAR_9, VAR_119):\n", "VAR_69[VAR_119(VAR_10['id'][1:])] = VAR_10['Element']\n", "VAR_69 = VAR_120.list_allowed_column_values()\n", "config.save()\n", "VAR_69 = VAR_120.list_denied_tags()\n", "VAR_120 = ub.session.query(ub.User).filter(ub.User.id == VAR_119(VAR_9)).first(\n )\n", "VAR_120 = VAR_62\n", "VAR_120.allowed_tags = ','.join(VAR_69)\n", "VAR_69[VAR_119(VAR_10['id'][1:])] = VAR_10['Element']\n", "VAR_69[VAR_119(VAR_10['id'][1:])] = VAR_10['Element']\n", "VAR_69 = VAR_120.list_denied_column_values()\n", "ub.session_commit('Changed allowed tags of user {} to {}'.format(VAR_120.\n name, VAR_120.allowed_tags))\n", "VAR_120.allowed_column_value = ','.join(VAR_69)\n", "VAR_120.denied_tags = ','.join(VAR_69)\n", "VAR_69[VAR_119(VAR_10['id'][1:])] = VAR_10['Element']\n", "ub.session_commit('Changed allowed columns of user {} to {}'.format(VAR_120\n .name, VAR_120.allowed_column_value))\n", "ub.session_commit('Changed denied tags of user {} to {}'.format(VAR_120.\n name, VAR_120.denied_tags))\n", "VAR_120.denied_column_value = ','.join(VAR_69)\n", "ub.session_commit('Changed denied columns of user {} to {}'.format(VAR_120.\n name, VAR_120.denied_column_value))\n" ]
[ "@admi.route('/ajax/editrestriction/<int:res_type>', defaults={'user_id': 0},...\n", "element = request.form.to_dict()\n", "if element['id'].startswith('a'):\n", "if res_type == 0:\n", "if element['id'].startswith('d'):\n", "elementlist = config.list_allowed_tags()\n", "if res_type == 1:\n", "if res_type == 0:\n", "return ''\n", "elementlist[int(element['id'][1:])] = element['Element']\n", "elementlist = config.list_allowed_column_values()\n", "if res_type == 2:\n", "elementlist = config.list_denied_tags()\n", "if res_type == 1:\n", "config.config_allowed_tags = ','.join(elementlist)\n", "elementlist[int(element['id'][1:])] = element['Element']\n", "if isinstance(user_id, int):\n", "if res_type == 3:\n", "elementlist[int(element['id'][1:])] = element['Element']\n", "elementlist = config.list_denied_column_values()\n", "if res_type == 2:\n", "config.save()\n", "config.config_allowed_column_value = ','.join(elementlist)\n", "usr = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()\n", "usr = current_user\n", "if isinstance(user_id, int):\n", "config.config_denied_tags = ','.join(elementlist)\n", "elementlist[int(element['id'][1:])] = element['Element']\n", "if isinstance(user_id, int):\n", "if res_type == 3:\n", "config.save()\n", "elementlist = usr.list_allowed_tags()\n", "usr = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()\n", "usr = current_user\n", "config.save()\n", "config.config_denied_column_value = ','.join(elementlist)\n", "usr = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()\n", "usr = current_user\n", "if isinstance(user_id, int):\n", "elementlist[int(element['id'][1:])] = element['Element']\n", "elementlist = usr.list_allowed_column_values()\n", "config.save()\n", "elementlist = usr.list_denied_tags()\n", "usr = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first()\n", "usr = current_user\n", "usr.allowed_tags = ','.join(elementlist)\n", "elementlist[int(element['id'][1:])] = element['Element']\n", "elementlist[int(element['id'][1:])] = element['Element']\n", "elementlist = usr.list_denied_column_values()\n", "ub.session_commit('Changed allowed tags of user {} to {}'.format(usr.name,\n usr.allowed_tags))\n", "usr.allowed_column_value = ','.join(elementlist)\n", "usr.denied_tags = ','.join(elementlist)\n", "elementlist[int(element['id'][1:])] = element['Element']\n", "ub.session_commit('Changed allowed columns of user {} to {}'.format(usr.\n name, usr.allowed_column_value))\n", "ub.session_commit('Changed denied tags of user {} to {}'.format(usr.name,\n usr.denied_tags))\n", "usr.denied_column_value = ','.join(elementlist)\n", "ub.session_commit('Changed denied columns of user {} to {}'.format(usr.name,\n usr.denied_column_value))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Condition", "Condition", "Assign'", "Condition", "Condition", "Return'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_55(VAR_21, VAR_33, VAR_34):...\n", "VAR_21 = VAR_21.outerjoin(ub.BookShelf, db.Books.id == ub.BookShelf.book_id\n ).filter(or_(ub.BookShelf.shelf == None, ub.BookShelf.shelf.notin_(VAR_34))\n )\n", "if len(VAR_33) > 0:\n", "VAR_21 = VAR_21.filter(ub.BookShelf.shelf.in_(VAR_33))\n", "return VAR_21\n" ]
[ "def adv_search_shelf(q, include_shelf_inputs, exclude_shelf_inputs):...\n", "q = q.outerjoin(ub.BookShelf, db.Books.id == ub.BookShelf.book_id).filter(or_\n (ub.BookShelf.shelf == None, ub.BookShelf.shelf.notin_(\n exclude_shelf_inputs)))\n", "if len(include_shelf_inputs) > 0:\n", "q = q.filter(ub.BookShelf.shelf.in_(include_shelf_inputs))\n", "return q\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Return'" ]
[ "def FUNC_10(self):...\n", "VAR_21 = 'input1=/path/file.txt[ab3];input2=file2'\n", "VAR_22 = 'input3=np.zeros([2,2]);input4=[4,5]'\n", "VAR_23 = saved_model_cli.preprocess_inputs_arg_string(VAR_21)\n", "VAR_24 = saved_model_cli.preprocess_input_exprs_arg_string(VAR_22, safe=False)\n", "self.assertTrue(VAR_23['input1'] == ('/path/file.txt', 'ab3'))\n", "self.assertTrue(VAR_23['input2'] == ('file2', None))\n", "print(VAR_24['input3'])\n", "self.assertAllClose(VAR_24['input3'], np.zeros([2, 2]))\n", "self.assertAllClose(VAR_24['input4'], [4, 5])\n", "self.assertTrue(len(VAR_23) == 2)\n", "self.assertTrue(len(VAR_24) == 2)\n" ]
[ "def testInputPreProcessFormats(self):...\n", "input_str = 'input1=/path/file.txt[ab3];input2=file2'\n", "input_expr_str = 'input3=np.zeros([2,2]);input4=[4,5]'\n", "input_dict = saved_model_cli.preprocess_inputs_arg_string(input_str)\n", "input_expr_dict = saved_model_cli.preprocess_input_exprs_arg_string(\n input_expr_str, safe=False)\n", "self.assertTrue(input_dict['input1'] == ('/path/file.txt', 'ab3'))\n", "self.assertTrue(input_dict['input2'] == ('file2', None))\n", "print(input_expr_dict['input3'])\n", "self.assertAllClose(input_expr_dict['input3'], np.zeros([2, 2]))\n", "self.assertAllClose(input_expr_dict['input4'], [4, 5])\n", "self.assertTrue(len(input_dict) == 2)\n", "self.assertTrue(len(input_expr_dict) == 2)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_41(self):...\n", "VAR_29 = models.Individual._meta.get_field('parent').rel\n", "VAR_27 = widgets.AdminRadioSelect()\n", "VAR_27 = widgets.RelatedFieldWidgetWrapper(VAR_27, VAR_29, widget_admin_site)\n", "self.assertFalse(VAR_27.can_add_related)\n" ]
[ "def test_no_can_add_related(self):...\n", "rel = models.Individual._meta.get_field('parent').rel\n", "w = widgets.AdminRadioSelect()\n", "w = widgets.RelatedFieldWidgetWrapper(w, rel, widget_admin_site)\n", "self.assertFalse(w.can_add_related)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_40(VAR_48):...\n", "return VAR_48\n" ]
[ "def fake_wrapper_session(sess):...\n", "return sess\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_6(self, VAR_12):...\n", "\"\"\"docstring\"\"\"\n", "VAR_12.setattr(filescheme.jinja.utils, 'resource_filename', lambda name:\n '/test path/foo.svg')\n", "VAR_19 = filescheme.dirbrowser_html(os.getcwd()).decode('utf-8')\n", "VAR_20 = bs4.BeautifulSoup(VAR_19, 'html.parser')\n", "print(VAR_20.prettify())\n", "VAR_24 = VAR_20.html.head.style.string\n", "assert \"background-image: url('file:///test%20path/foo.svg');\" in VAR_24\n" ]
[ "def test_icons(self, monkeypatch):...\n", "\"\"\"docstring\"\"\"\n", "monkeypatch.setattr(filescheme.jinja.utils, 'resource_filename', lambda\n name: '/test path/foo.svg')\n", "html = filescheme.dirbrowser_html(os.getcwd()).decode('utf-8')\n", "soup = bs4.BeautifulSoup(html, 'html.parser')\n", "print(soup.prettify())\n", "css = soup.html.head.style.string\n", "assert \"background-image: url('file:///test%20path/foo.svg');\" in css\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assert'" ]
[ "def FUNC_64(VAR_122=False, VAR_123=False):...\n", "\"\"\"docstring\"\"\"\n", "if getattr(VAR_19, 'in_install_db', True):\n", "return []\n", "if not VAR_12:\n", "FUNC_5()\n", "if not VAR_1.all_apps:\n", "VAR_1.all_apps = FUNC_10().get_value('all_apps', FUNC_63)\n", "VAR_190 = json.loads(VAR_12.get_global('installed_apps') or '[]')\n", "if VAR_122:\n", "VAR_190 = [VAR_219 for VAR_219 in VAR_1.all_apps if VAR_219 in VAR_190]\n", "if VAR_123:\n", "if 'frappe' in VAR_190:\n", "return VAR_190\n", "VAR_190.remove('frappe')\n", "VAR_190.append('frappe')\n" ]
[ "def get_installed_apps(sort=False, frappe_last=False):...\n", "\"\"\"docstring\"\"\"\n", "if getattr(flags, 'in_install_db', True):\n", "return []\n", "if not db:\n", "connect()\n", "if not local.all_apps:\n", "local.all_apps = cache().get_value('all_apps', get_all_apps)\n", "installed = json.loads(db.get_global('installed_apps') or '[]')\n", "if sort:\n", "installed = [app for app in local.all_apps if app in installed]\n", "if frappe_last:\n", "if 'frappe' in installed:\n", "return installed\n", "installed.remove('frappe')\n", "installed.append('frappe')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "Expr'", "Condition", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Return'", "Expr'", "Expr'" ]
[ "@VAR_2.route('/send/<int:book_id>/<book_format>/<int:convert>')...\n", "if not config.get_mail_server_configured():\n", "flash(_(u'Please configure the SMTP mail settings first...'), category='error')\n", "if VAR_87.kindle_mail:\n", "if 'HTTP_REFERER' in request.environ:\n", "VAR_136 = send_mail(VAR_5, VAR_6, VAR_43, VAR_87.kindle_mail, config.\n config_calibre_dir, VAR_87.name)\n", "flash(_(\n u'Please update your profile with a valid Send to Kindle E-mail Address.'\n ), category='error')\n", "return redirect(request.environ['HTTP_REFERER'])\n", "return redirect(url_for('web.index'))\n", "if VAR_136 is None:\n", "flash(_(u'Book successfully queued for sending to %(kindlemail)s',\n kindlemail=current_user.kindle_mail), category='success')\n", "flash(_(u'Oops! There was an error sending this book: %(res)s', res=result),\n category='error')\n", "ub.update_download(VAR_5, int(VAR_87.id))\n" ]
[ "@web.route('/send/<int:book_id>/<book_format>/<int:convert>')...\n", "if not config.get_mail_server_configured():\n", "flash(_(u'Please configure the SMTP mail settings first...'), category='error')\n", "if current_user.kindle_mail:\n", "if 'HTTP_REFERER' in request.environ:\n", "result = send_mail(book_id, book_format, convert, current_user.kindle_mail,\n config.config_calibre_dir, current_user.name)\n", "flash(_(\n u'Please update your profile with a valid Send to Kindle E-mail Address.'\n ), category='error')\n", "return redirect(request.environ['HTTP_REFERER'])\n", "return redirect(url_for('web.index'))\n", "if result is None:\n", "flash(_(u'Book successfully queued for sending to %(kindlemail)s',\n kindlemail=current_user.kindle_mail), category='success')\n", "flash(_(u'Oops! There was an error sending this book: %(res)s', res=result),\n category='error')\n", "ub.update_download(book_id, int(current_user.id))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "For", "Condition", "Expr'", "Condition", "Condition", "Assign'", "Expr'", "Return'", "Return'", "Condition", "Expr'", "Expr'", "Expr'" ]
[ "def __init__(self, **VAR_20):...\n", "self.options = VAR_20\n" ]
[ "def __init__(self, **kwargs):...\n", "self.options = kwargs\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "def __init__(self, *, VAR_3: GeneratorData) ->None:...\n", "self.openapi: GeneratorData = VAR_3\n", "self.env: Environment = Environment(loader=PackageLoader(__package__),\n trim_blocks=True, lstrip_blocks=True)\n", "self.project_name: str = (self.project_name_override or\n f\"{VAR_3.title.replace(' ', '-').lower()}-client\")\n", "self.project_dir: Path = Path.cwd() / self.project_name\n", "self.package_name: str = (self.package_name_override or self.project_name.\n replace('-', '_'))\n", "self.package_dir: Path = self.project_dir / self.package_name\n", "self.package_description: str = (\n f'A client library for accessing {self.openapi.title}')\n", "self.version: str = VAR_3.version\n", "self.env.filters.update(self.TEMPLATE_FILTERS)\n" ]
[ "def __init__(self, *, openapi: GeneratorData) ->None:...\n", "self.openapi: GeneratorData = openapi\n", "self.env: Environment = Environment(loader=PackageLoader(__package__),\n trim_blocks=True, lstrip_blocks=True)\n", "self.project_name: str = (self.project_name_override or\n f\"{openapi.title.replace(' ', '-').lower()}-client\")\n", "self.project_dir: Path = Path.cwd() / self.project_name\n", "self.package_name: str = (self.package_name_override or self.project_name.\n replace('-', '_'))\n", "self.package_dir: Path = self.project_dir / self.package_name\n", "self.package_description: str = (\n f'A client library for accessing {self.openapi.title}')\n", "self.version: str = openapi.version\n", "self.env.filters.update(self.TEMPLATE_FILTERS)\n" ]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "AnnAssign'", "Expr'" ]
[ "def FUNC_24(VAR_45=None):...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_1.session:\n", "return ['Guest']\n", "import frappe.permissions\n", "return frappe.permissions.get_roles(VAR_45 or VAR_1.session.user)\n" ]
[ "def get_roles(username=None):...\n", "\"\"\"docstring\"\"\"\n", "if not local.session:\n", "return ['Guest']\n", "import frappe.permissions\n", "return frappe.permissions.get_roles(username or local.session.user)\n" ]
[ 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Import'", "Return'" ]
[ "def FUNC_55(VAR_21, VAR_33, VAR_34):...\n", "VAR_21 = VAR_21.outerjoin(ub.BookShelf, db.Books.id == ub.BookShelf.book_id\n ).filter(or_(ub.BookShelf.shelf == None, ub.BookShelf.shelf.notin_(VAR_34))\n )\n", "if len(VAR_33) > 0:\n", "VAR_21 = VAR_21.filter(ub.BookShelf.shelf.in_(VAR_33))\n", "return VAR_21\n" ]
[ "def adv_search_shelf(q, include_shelf_inputs, exclude_shelf_inputs):...\n", "q = q.outerjoin(ub.BookShelf, db.Books.id == ub.BookShelf.book_id).filter(or_\n (ub.BookShelf.shelf == None, ub.BookShelf.shelf.notin_(\n exclude_shelf_inputs)))\n", "if len(include_shelf_inputs) > 0:\n", "q = q.filter(ub.BookShelf.shelf.in_(include_shelf_inputs))\n", "return q\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Return'" ]
[ "def FUNC_22(self):...\n", "VAR_27 = np.array([[1], [2]])\n", "VAR_28 = np.array(range(5))\n", "VAR_32 = os.path.join(test.get_temp_dir(), 'input.npz')\n", "np.savez(VAR_32, VAR_54=x0, VAR_55=x1)\n", "VAR_21 = 'x=' + VAR_32 + '[c]'\n", "saved_model_cli.load_inputs_from_input_arg_string(VAR_21, '', '')\n" ]
[ "def testInputParserErrorWrongName(self):...\n", "x0 = np.array([[1], [2]])\n", "x1 = np.array(range(5))\n", "input_path = os.path.join(test.get_temp_dir(), 'input.npz')\n", "np.savez(input_path, a=x0, b=x1)\n", "input_str = 'x=' + input_path + '[c]'\n", "saved_model_cli.load_inputs_from_input_arg_string(input_str, '', '')\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_4(self, VAR_5, VAR_6):...\n", "\"\"\"docstring\"\"\"\n", "VAR_0 = '/groups/%s/profile' % (VAR_5,)\n", "VAR_12, VAR_13 = self.make_request('GET', VAR_0.encode('ascii'), VAR_7=self\n .admin_user_tok)\n", "self.assertEqual(VAR_6, int(VAR_13.result['code']), msg=channel.result['body'])\n" ]
[ "def _check_group(self, group_id, expect_code):...\n", "\"\"\"docstring\"\"\"\n", "url = '/groups/%s/profile' % (group_id,)\n", "request, channel = self.make_request('GET', url.encode('ascii'),\n access_token=self.admin_user_tok)\n", "self.assertEqual(expect_code, int(channel.result['code']), msg=channel.\n result['body'])\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'" ]
[ "def FUNC_68(self, VAR_42: int=5) ->str:...\n", "return jwt.encode({'public_id': self.public_id, 'exp': datetime.datetime.\n utcnow() + datetime.timedelta(days=expires_in_days)}, VAR_0.config[\n 'SECRET_KEY'], algorithm='HS256')\n" ]
[ "def generate_auth_token(self, expires_in_days: int=5) ->str:...\n", "return jwt.encode({'public_id': self.public_id, 'exp': datetime.datetime.\n utcnow() + datetime.timedelta(days=expires_in_days)}, gui.config[\n 'SECRET_KEY'], algorithm='HS256')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def __init__(self, *VAR_6, **VAR_7):...\n", "super().__init__(*VAR_6, **kwargs)\n", "self.helper = FormHelper(self)\n", "self.helper.form_tag = False\n", "self.helper.layout = Layout(SearchField('q'), InlineRadios('format'))\n" ]
[ "def __init__(self, *args, **kwargs):...\n", "super().__init__(*args, **kwargs)\n", "self.helper = FormHelper(self)\n", "self.helper.form_tag = False\n", "self.helper.layout = Layout(SearchField('q'), InlineRadios('format'))\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Assign'", "Assign'", "Assign'" ]
[ "def __init__(self, VAR_4):...\n", "self.server_name = VAR_4.hostname\n", "self.client = VAR_4.get_http_client()\n" ]
[ "def __init__(self, hs):...\n", "self.server_name = hs.hostname\n", "self.client = hs.get_http_client()\n" ]
[ 0, 0, 4 ]
[ "FunctionDef'", "Assign'", "Assign'" ]
[ "@moderator_required...\n", "VAR_6 = get_object_or_404(Topic, VAR_1=pk)\n", "if is_post(VAR_0):\n", "VAR_7 = Topic.objects.filter(VAR_1=pk).exclude(**{field_name: to_value}\n ).update(**{field_name: to_value, 'reindex_at': timezone.now()})\n", "return render(VAR_0=request, template_name='spirit/topic/moderate.html',\n context={'topic': topic})\n", "if VAR_7 and VAR_4 is not None:\n", "Comment.create_moderation_action(user=request.user, VAR_6=topic, VAR_4=action)\n", "if VAR_5 is not None:\n", "messages.info(VAR_0, VAR_5)\n", "return redirect(VAR_0.POST.get('next', VAR_6.get_absolute_url()))\n" ]
[ "@moderator_required...\n", "topic = get_object_or_404(Topic, pk=pk)\n", "if is_post(request):\n", "count = Topic.objects.filter(pk=pk).exclude(**{field_name: to_value}).update(**\n {field_name: to_value, 'reindex_at': timezone.now()})\n", "return render(request=request, template_name='spirit/topic/moderate.html',\n context={'topic': topic})\n", "if count and action is not None:\n", "Comment.create_moderation_action(user=request.user, topic=topic, action=action)\n", "if message is not None:\n", "messages.info(request, message)\n", "return redirect(request.POST.get('next', topic.get_absolute_url()))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 ]
[ "Condition", "Assign'", "Condition", "Assign'", "Return'", "Condition", "Expr'", "Condition", "Expr'", "Return'" ]
[ "def FUNC_75(self):...\n", "\"\"\"docstring\"\"\"\n", "file_lock.delete_lock(self.get_signature())\n" ]
[ "def unlock(self):...\n", "\"\"\"docstring\"\"\"\n", "file_lock.delete_lock(self.get_signature())\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Expr'" ]
[ "@csrf_exempt...\n", "from ee.clickhouse.sql.events import TRUNCATE_EVENTS_TABLE_SQL\n", "from posthog.client import sync_execute\n", "sync_execute(TRUNCATE_EVENTS_TABLE_SQL())\n", "return HttpResponse()\n" ]
[ "@csrf_exempt...\n", "from ee.clickhouse.sql.events import TRUNCATE_EVENTS_TABLE_SQL\n", "from posthog.client import sync_execute\n", "sync_execute(TRUNCATE_EVENTS_TABLE_SQL())\n", "return HttpResponse()\n" ]
[ 0, 0, 0, 0, 0 ]
[ "Condition", "ImportFrom'", "ImportFrom'", "Expr'", "Return'" ]
[ "def FUNC_8(self):...\n", "return [d.as_dict(no_default_fields=True) for d in self.columns]\n" ]
[ "def get_columns(self):...\n", "return [d.as_dict(no_default_fields=True) for d in self.columns]\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_0(*, VAR_0: Client, VAR_1: List[AnEnum], VAR_2: Union[date, datetime]...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = '{}/tests/'.format(VAR_0.base_url)\n", "VAR_12: Dict[str, Any] = VAR_0.get_headers()\n", "VAR_7 = []\n", "for an_enum_value_item_data in VAR_1:\n", "VAR_10 = an_enum_value_item_data.value\n", "if isinstance(VAR_2, date):\n", "VAR_7.append(VAR_10)\n", "VAR_11 = VAR_2.isoformat()\n", "VAR_11 = VAR_2.isoformat()\n", "params: Dict[str, Any] = {'an_enum_value': VAR_7, 'some_date': VAR_11}\n", "VAR_8 = httpx.get(VAR_6=url, VAR_12=headers, params=params)\n", "if VAR_8.status_code == 200:\n", "return [AModel.from_dict(item) for item in cast(List[Dict[str, Any]], VAR_8\n .json())]\n", "if VAR_8.status_code == 422:\n", "return HTTPValidationError.from_dict(cast(Dict[str, Any], VAR_8.json()))\n" ]
[ "def get_user_list(*, client: Client, an_enum_value: List[AnEnum], some_date:...\n", "\"\"\"docstring\"\"\"\n", "url = '{}/tests/'.format(client.base_url)\n", "headers: Dict[str, Any] = client.get_headers()\n", "json_an_enum_value = []\n", "for an_enum_value_item_data in an_enum_value:\n", "an_enum_value_item = an_enum_value_item_data.value\n", "if isinstance(some_date, date):\n", "json_an_enum_value.append(an_enum_value_item)\n", "json_some_date = some_date.isoformat()\n", "json_some_date = some_date.isoformat()\n", "params: Dict[str, Any] = {'an_enum_value': json_an_enum_value, 'some_date':\n json_some_date}\n", "response = httpx.get(url=url, headers=headers, params=params)\n", "if response.status_code == 200:\n", "return [AModel.from_dict(item) for item in cast(List[Dict[str, Any]],\n response.json())]\n", "if response.status_code == 422:\n", "return HTTPValidationError.from_dict(cast(Dict[str, Any], response.json()))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Assign'", "AnnAssign'", "Assign'", "For", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "AnnAssign'", "Assign'", "Condition", "Return'", "Condition", "Return'" ]
[ "def FUNC_12(self, VAR_12):...\n", "if not self.isAuthorized():\n", "VAR_11 = [VAR_69 for VAR_69 in json.loads(unquote(VAR_12))]\n", "VAR_61 = self.download_check_files(VAR_11)\n", "if VAR_61 == 'ok':\n", "FUNC_0()\n", "return VAR_61\n", "VAR_82 = 'application/x-zip-compressed'\n", "VAR_53.response.headers['Content-Type'] = VAR_82\n", "VAR_83 = 'attachment; filename=\"music.zip\"'\n", "VAR_53.response.headers['Content-Disposition'] = VAR_83\n", "VAR_84 = cherry.config['media.basedir']\n", "VAR_98 = [os.path.join(VAR_84, f) for f in VAR_11]\n", "return zipstream.ZipStream(VAR_98)\n" ]
[ "def download(self, value):...\n", "if not self.isAuthorized():\n", "filelist = [filepath for filepath in json.loads(unquote(value))]\n", "dlstatus = self.download_check_files(filelist)\n", "if dlstatus == 'ok':\n", "_save_and_release_session()\n", "return dlstatus\n", "zipmime = 'application/x-zip-compressed'\n", "cherrypy.response.headers['Content-Type'] = zipmime\n", "zipname = 'attachment; filename=\"music.zip\"'\n", "cherrypy.response.headers['Content-Disposition'] = zipname\n", "basedir = cherry.config['media.basedir']\n", "fullpath_filelist = [os.path.join(basedir, f) for f in filelist]\n", "return zipstream.ZipStream(fullpath_filelist)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Return'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_31(VAR_31):...\n", "VAR_63 = \"'\" * isinstance(VAR_31, str)\n", "return VAR_63 + str(VAR_31) + VAR_63\n" ]
[ "def _maybe_add_quotes(value):...\n", "is_quotes = \"'\" * isinstance(value, str)\n", "return is_quotes + str(value) + is_quotes\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Return'" ]
[ "def FUNC_11(VAR_14: Union[Text, Path]) ->Any:...\n", "\"\"\"docstring\"\"\"\n", "import jsonpickle.ext.numpy as jsonpickle_numpy\n", "import jsonpickle\n", "jsonpickle_numpy.register_handlers()\n", "VAR_22 = rasa.shared.utils.io.read_file(VAR_14)\n", "return jsonpickle.loads(VAR_22)\n" ]
[ "def json_unpickle(file_name: Union[Text, Path]) ->Any:...\n", "\"\"\"docstring\"\"\"\n", "import jsonpickle.ext.numpy as jsonpickle_numpy\n", "import jsonpickle\n", "jsonpickle_numpy.register_handlers()\n", "file_content = rasa.shared.utils.io.read_file(file_name)\n", "return jsonpickle.loads(file_content)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Import'", "Import'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_17(self, VAR_2):...\n", "def FUNC_29(self):...\n", "VAR_2.add_url_rule('/about-us', endpoint='site_controller.about_us')\n", "assert url_for('about_us', _cls=SiteController) == '/about-us'\n" ]
[ "def test_it_works_with_controller_method_names(self, app):...\n", "def about_us(self):...\n", "app.add_url_rule('/about-us', endpoint='site_controller.about_us')\n", "assert url_for('about_us', _cls=SiteController) == '/about-us'\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Expr'", "Assert'" ]
[ "def FUNC_17(self):...\n", "VAR_22, VAR_23 = self.make_request('POST', '/createRoom', b'{\"custom\":\"stuff\"}'\n )\n", "self.assertEquals(200, VAR_23.code)\n", "self.assertTrue('room_id' in VAR_23.json_body)\n" ]
[ "def test_post_room_custom_key(self):...\n", "request, channel = self.make_request('POST', '/createRoom',\n b'{\"custom\":\"stuff\"}')\n", "self.assertEquals(200, channel.code)\n", "self.assertTrue('room_id' in channel.json_body)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'" ]
[ "@log_function...\n", "\"\"\"docstring\"\"\"\n", "VAR_0.debug('backfill dest=%s, room_id=%s, event_tuples=%r, limit=%s',\n VAR_5, VAR_6, VAR_9, str(VAR_10))\n", "if not VAR_9:\n", "return\n", "VAR_2 = FUNC_1('/backfill/%s', VAR_6)\n", "VAR_3 = {'v': VAR_9, 'limit': [str(VAR_10)]}\n", "return self.client.get_json(VAR_5, VAR_2=path, VAR_3=args,\n try_trailing_slash_on_400=True)\n" ]
[ "@log_function...\n", "\"\"\"docstring\"\"\"\n", "logger.debug('backfill dest=%s, room_id=%s, event_tuples=%r, limit=%s',\n destination, room_id, event_tuples, str(limit))\n", "if not event_tuples:\n", "return\n", "path = _create_v1_path('/backfill/%s', room_id)\n", "args = {'v': event_tuples, 'limit': [str(limit)]}\n", "return self.client.get_json(destination, path=path, args=args,\n try_trailing_slash_on_400=True)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Expr'", "Condition", "Return'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_2(self, *VAR_12):...\n", "self.transitiveDependencies.update(VAR_12)\n" ]
[ "def recordDependencies(self, *inputSources):...\n", "self.transitiveDependencies.update(inputSources)\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Expr'" ]
[ "def FUNC_3(self):...\n", "VAR_26 = b'{\"topic\":\"My Topic Name\"}'\n", "VAR_27 = '/rooms/%s/state/m.room.topic' % self.created_rmid\n", "VAR_22, VAR_23 = self.make_request('PUT', '/rooms/%s/state/m.room.topic' %\n self.uncreated_rmid, VAR_26)\n", "self.assertEquals(403, VAR_23.code, msg=channel.result['body'])\n", "VAR_22, VAR_23 = self.make_request('GET', '/rooms/%s/state/m.room.topic' %\n self.uncreated_rmid)\n", "self.assertEquals(403, VAR_23.code, msg=channel.result['body'])\n", "VAR_22, VAR_23 = self.make_request('PUT', VAR_27, VAR_26)\n", "self.assertEquals(403, VAR_23.code, msg=channel.result['body'])\n", "VAR_22, VAR_23 = self.make_request('GET', VAR_27)\n", "self.assertEquals(403, VAR_23.code, msg=channel.result['body'])\n", "self.helper.invite(VAR_7=self.created_rmid, src=self.rmcreator_id, targ=\n self.user_id)\n", "VAR_22, VAR_23 = self.make_request('PUT', VAR_27, VAR_26)\n", "self.assertEquals(403, VAR_23.code, msg=channel.result['body'])\n", "VAR_22, VAR_23 = self.make_request('GET', VAR_27)\n", "self.assertEquals(403, VAR_23.code, msg=channel.result['body'])\n", "self.helper.join(VAR_7=self.created_rmid, user=self.user_id)\n", "self.helper.auth_user_id = self.rmcreator_id\n", "VAR_22, VAR_23 = self.make_request('PUT', VAR_27, VAR_26)\n", "self.assertEquals(200, VAR_23.code, msg=channel.result['body'])\n", "self.helper.auth_user_id = self.user_id\n", "VAR_22, VAR_23 = self.make_request('GET', VAR_27)\n", "self.assertEquals(200, VAR_23.code, msg=channel.result['body'])\n", "self.assert_dict(json.loads(VAR_26.decode('utf8')), VAR_23.json_body)\n", "self.helper.leave(VAR_7=self.created_rmid, user=self.user_id)\n", "VAR_22, VAR_23 = self.make_request('PUT', VAR_27, VAR_26)\n", "self.assertEquals(403, VAR_23.code, msg=channel.result['body'])\n", "VAR_22, VAR_23 = self.make_request('GET', VAR_27)\n", "self.assertEquals(200, VAR_23.code, msg=channel.result['body'])\n", "VAR_22, VAR_23 = self.make_request('GET', '/rooms/%s/state/m.room.topic' %\n self.created_public_rmid)\n", "self.assertEquals(403, VAR_23.code, msg=channel.result['body'])\n", "VAR_22, VAR_23 = self.make_request('PUT', '/rooms/%s/state/m.room.topic' %\n self.created_public_rmid, VAR_26)\n", "self.assertEquals(403, VAR_23.code, msg=channel.result['body'])\n" ]
[ "def test_topic_perms(self):...\n", "topic_content = b'{\"topic\":\"My Topic Name\"}'\n", "topic_path = '/rooms/%s/state/m.room.topic' % self.created_rmid\n", "request, channel = self.make_request('PUT', '/rooms/%s/state/m.room.topic' %\n self.uncreated_rmid, topic_content)\n", "self.assertEquals(403, channel.code, msg=channel.result['body'])\n", "request, channel = self.make_request('GET', '/rooms/%s/state/m.room.topic' %\n self.uncreated_rmid)\n", "self.assertEquals(403, channel.code, msg=channel.result['body'])\n", "request, channel = self.make_request('PUT', topic_path, topic_content)\n", "self.assertEquals(403, channel.code, msg=channel.result['body'])\n", "request, channel = self.make_request('GET', topic_path)\n", "self.assertEquals(403, channel.code, msg=channel.result['body'])\n", "self.helper.invite(room=self.created_rmid, src=self.rmcreator_id, targ=self\n .user_id)\n", "request, channel = self.make_request('PUT', topic_path, topic_content)\n", "self.assertEquals(403, channel.code, msg=channel.result['body'])\n", "request, channel = self.make_request('GET', topic_path)\n", "self.assertEquals(403, channel.code, msg=channel.result['body'])\n", "self.helper.join(room=self.created_rmid, user=self.user_id)\n", "self.helper.auth_user_id = self.rmcreator_id\n", "request, channel = self.make_request('PUT', topic_path, topic_content)\n", "self.assertEquals(200, channel.code, msg=channel.result['body'])\n", "self.helper.auth_user_id = self.user_id\n", "request, channel = self.make_request('GET', topic_path)\n", "self.assertEquals(200, channel.code, msg=channel.result['body'])\n", "self.assert_dict(json.loads(topic_content.decode('utf8')), channel.json_body)\n", "self.helper.leave(room=self.created_rmid, user=self.user_id)\n", "request, channel = self.make_request('PUT', topic_path, topic_content)\n", "self.assertEquals(403, channel.code, msg=channel.result['body'])\n", "request, channel = self.make_request('GET', topic_path)\n", "self.assertEquals(200, channel.code, msg=channel.result['body'])\n", "request, channel = self.make_request('GET', '/rooms/%s/state/m.room.topic' %\n self.created_public_rmid)\n", "self.assertEquals(403, channel.code, msg=channel.result['body'])\n", "request, channel = self.make_request('PUT', '/rooms/%s/state/m.room.topic' %\n self.created_public_rmid, topic_content)\n", "self.assertEquals(403, channel.code, msg=channel.result['body'])\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 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "@pytest.mark.linux...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_4.config.webengine:\n", "pytest.skip()\n", "VAR_26 = VAR_2 / 'downloads'\n", "VAR_26.ensure(dir=True)\n", "(VAR_2 / 'user-dirs.dirs').write('XDG_DOWNLOAD_DIR={}'.format(VAR_26))\n", "VAR_16 = {'XDG_CONFIG_HOME': str(VAR_2)}\n", "VAR_11 = ['--temp-basedir'] + FUNC_0(VAR_4.config)\n", "VAR_6.start(VAR_11, VAR_16=env)\n", "VAR_6.set_setting('downloads.location.prompt', 'false')\n", "VAR_6.set_setting('downloads.location.directory', str(VAR_26))\n", "VAR_6.open_path('data/downloads/download.bin', wait=False)\n", "VAR_6.wait_for(category='downloads', message='Download * finished')\n", "VAR_6.open_path('data/downloads/download.bin', wait=False)\n", "VAR_6.wait_for(message='Entering mode KeyMode.yesno *')\n", "VAR_6.send_cmd(':prompt-accept yes')\n", "VAR_6.wait_for(category='downloads', message='Download * finished')\n", "VAR_27 = VAR_26.listdir()\n", "assert len(VAR_27) == 1\n", "assert VAR_27[0].basename == 'download.bin'\n" ]
[ "@pytest.mark.linux...\n", "\"\"\"docstring\"\"\"\n", "if not request.config.webengine:\n", "pytest.skip()\n", "download_dir = tmpdir / 'downloads'\n", "download_dir.ensure(dir=True)\n", "(tmpdir / 'user-dirs.dirs').write('XDG_DOWNLOAD_DIR={}'.format(download_dir))\n", "env = {'XDG_CONFIG_HOME': str(tmpdir)}\n", "args = ['--temp-basedir'] + _base_args(request.config)\n", "quteproc_new.start(args, env=env)\n", "quteproc_new.set_setting('downloads.location.prompt', 'false')\n", "quteproc_new.set_setting('downloads.location.directory', str(download_dir))\n", "quteproc_new.open_path('data/downloads/download.bin', wait=False)\n", "quteproc_new.wait_for(category='downloads', message='Download * finished')\n", "quteproc_new.open_path('data/downloads/download.bin', wait=False)\n", "quteproc_new.wait_for(message='Entering mode KeyMode.yesno *')\n", "quteproc_new.send_cmd(':prompt-accept yes')\n", "quteproc_new.wait_for(category='downloads', message='Download * finished')\n", "files = download_dir.listdir()\n", "assert len(files) == 1\n", "assert files[0].basename == 'download.bin'\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Docstring", "Condition", "Expr'", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'", "Assign'", "Assert'", "Assert'" ]
[ "def FUNC_36(self, VAR_31, VAR_32, VAR_6=''):...\n", "VAR_75 = VAR_6 == ''\n", "if VAR_75:\n", "VAR_6 = VAR_53.session['username']\n", "if VAR_75 or VAR_53.session['admin']:\n", "VAR_107 = self.userdb.auth(VAR_6, VAR_31)\n", "return self.userdb.changePassword(VAR_6, VAR_32)\n", "VAR_108 = userdb.User.nobody() != VAR_107\n", "if not VAR_108:\n" ]
[ "def api_userchangepassword(self, oldpassword, newpassword, username=''):...\n", "isself = username == ''\n", "if isself:\n", "username = cherrypy.session['username']\n", "if isself or cherrypy.session['admin']:\n", "authed_user = self.userdb.auth(username, oldpassword)\n", "return self.userdb.changePassword(username, newpassword)\n", "is_authenticated = userdb.User.nobody() != authed_user\n", "if not is_authenticated:\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Return'", "Assign'", "Condition" ]
[ "def FUNC_13(VAR_15, VAR_16, VAR_18):...\n", "VAR_19 = {}\n", "if current_user.role_delete_books():\n", "VAR_17 = calibre_db.get_book(VAR_15)\n", "return FUNC_12(VAR_16, VAR_18, VAR_19, VAR_15)\n", "if VAR_17:\n", "VAR_2.error('Book with id \"%s\" could not be deleted: not found', VAR_15)\n", "VAR_68, VAR_49 = helper.delete_book(VAR_17, config.config_calibre_dir,\n VAR_16=book_format.upper())\n", "VAR_2.debug_or_exception(ex)\n", "if not VAR_68:\n", "calibre_db.session.rollback()\n", "if VAR_18:\n", "if VAR_49:\n", "if VAR_18:\n", "return json.dumps([{'location': url_for('editbook.edit_book', VAR_15=\n book_id), 'type': 'danger', 'format': '', 'message': VAR_49}])\n", "flash(VAR_49, category='error')\n", "if VAR_18:\n", "if not VAR_16:\n", "return json.dumps([{'location': url_for('editbook.edit_book', VAR_15=\n book_id), 'type': 'danger', 'format': '', 'message': ex}])\n", "flash(str(ex), category='error')\n", "return redirect(url_for('editbook.edit_book', VAR_15=book_id))\n", "VAR_19 = {'location': url_for('editbook.edit_book', VAR_15=book_id), 'type':\n 'warning', 'format': '', 'message': VAR_49}\n", "flash(VAR_49, category='warning')\n", "FUNC_11(VAR_15, VAR_17)\n", "calibre_db.session.query(db.Data).filter(db.Data.book == VAR_17.id).filter(\n db.Data.format == VAR_16).delete()\n", "return redirect(url_for('editbook.edit_book', VAR_15=book_id))\n", "calibre_db.session.commit()\n" ]
[ "def delete_book(book_id, book_format, jsonResponse):...\n", "warning = {}\n", "if current_user.role_delete_books():\n", "book = calibre_db.get_book(book_id)\n", "return render_delete_book_result(book_format, jsonResponse, warning, book_id)\n", "if book:\n", "log.error('Book with id \"%s\" could not be deleted: not found', book_id)\n", "result, error = helper.delete_book(book, config.config_calibre_dir,\n book_format=book_format.upper())\n", "log.debug_or_exception(ex)\n", "if not result:\n", "calibre_db.session.rollback()\n", "if jsonResponse:\n", "if error:\n", "if jsonResponse:\n", "return json.dumps([{'location': url_for('editbook.edit_book', book_id=\n book_id), 'type': 'danger', 'format': '', 'message': error}])\n", "flash(error, category='error')\n", "if jsonResponse:\n", "if not book_format:\n", "return json.dumps([{'location': url_for('editbook.edit_book', book_id=\n book_id), 'type': 'danger', 'format': '', 'message': ex}])\n", "flash(str(ex), category='error')\n", "return redirect(url_for('editbook.edit_book', book_id=book_id))\n", "warning = {'location': url_for('editbook.edit_book', book_id=book_id),\n 'type': 'warning', 'format': '', 'message': error}\n", "flash(error, category='warning')\n", "delete_whole_book(book_id, book)\n", "calibre_db.session.query(db.Data).filter(db.Data.book == book.id).filter(db\n .Data.format == book_format).delete()\n", "return redirect(url_for('editbook.edit_book', book_id=book_id))\n", "calibre_db.session.commit()\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Return'", "Condition", "Expr'", "Assign'", "Expr'", "Condition", "Expr'", "Condition", "Condition", "Condition", "Return'", "Expr'", "Condition", "Condition", "Return'", "Expr'", "Return'", "Assign'", "Expr'", "Expr'", "Expr'", "Return'", "Expr'" ]
[ "def FUNC_119(VAR_174):...\n", "for df in VAR_174.meta.get('fields', {'no_copy': 1}):\n", "if hasattr(VAR_174, df.fieldname):\n", "VAR_174.set(df.fieldname, None)\n" ]
[ "def remove_no_copy_fields(d):...\n", "for df in d.meta.get('fields', {'no_copy': 1}):\n", "if hasattr(d, df.fieldname):\n", "d.set(df.fieldname, None)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "For", "Condition", "Expr'" ]
[ "def FUNC_117(VAR_10):...\n", "def FUNC_168(*VAR_9, **VAR_13):...\n", "VAR_27 = None\n", "VAR_27 = VAR_10(*VAR_9, **b)\n", "thread.start_new_thread(VAR_26, (VAR_27,))\n", "return FUNC_168\n", "return VAR_27\n" ]
[ "def _completion(f):...\n", "def __completion(*a, **b):...\n", "d = None\n", "d = f(*a, **b)\n", "thread.start_new_thread(callback, (d,))\n", "return __completion\n", "return d\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "FunctionDef'", "Assign'", "Assign'", "Expr'", "Return'", "Return'" ]
[ "def FUNC_23(VAR_21):...\n", "\"\"\"docstring\"\"\"\n", "VAR_47 = 'string'\n", "VAR_48 = VAR_21.add_parser('show', description=show_msg, formatter_class=\n argparse.RawTextHelpFormatter)\n", "VAR_48.add_argument('--dir', type=str, required=True, help=\n 'directory containing the SavedModel to inspect')\n", "VAR_48.add_argument('--all', action='store_true', help=\n 'if set, will output all information in given SavedModel')\n", "VAR_48.add_argument('--tag_set', type=str, default=None, help=\n \"tag-set of graph in SavedModel to show, separated by ','\")\n", "VAR_48.add_argument('--signature_def', type=str, default=None, metavar=\n 'SIGNATURE_DEF_KEY', help=\n 'key of SignatureDef to display input(s) and output(s) for')\n", "VAR_48.set_defaults(func=show)\n" ]
[ "def add_show_subparser(subparsers):...\n", "\"\"\"docstring\"\"\"\n", "show_msg = \"\"\"Usage examples:\nTo show all tag-sets in a SavedModel:\n$saved_model_cli show --dir /tmp/saved_model\n\nTo show all available SignatureDef keys in a MetaGraphDef specified by its tag-set:\n$saved_model_cli show --dir /tmp/saved_model --tag_set serve\n\nFor a MetaGraphDef with multiple tags in the tag-set, all tags must be passed in, separated by ';':\n$saved_model_cli show --dir /tmp/saved_model --tag_set serve,gpu\n\nTo show all inputs and outputs TensorInfo for a specific SignatureDef specified by the SignatureDef key in a MetaGraph.\n$saved_model_cli show --dir /tmp/saved_model --tag_set serve --signature_def serving_default\n\nTo show all available information in the SavedModel:\n$saved_model_cli show --dir /tmp/saved_model --all\"\"\"\n", "parser_show = subparsers.add_parser('show', description=show_msg,\n formatter_class=argparse.RawTextHelpFormatter)\n", "parser_show.add_argument('--dir', type=str, required=True, help=\n 'directory containing the SavedModel to inspect')\n", "parser_show.add_argument('--all', action='store_true', help=\n 'if set, will output all information in given SavedModel')\n", "parser_show.add_argument('--tag_set', type=str, default=None, help=\n \"tag-set of graph in SavedModel to show, separated by ','\")\n", "parser_show.add_argument('--signature_def', type=str, default=None, metavar\n ='SIGNATURE_DEF_KEY', help=\n 'key of SignatureDef to display input(s) and output(s) for')\n", "parser_show.set_defaults(func=show)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_117():...\n", "return VAR_12.sql_list('select name from tabDocType where istable=1')\n" ]
[ "def get_tables():...\n", "return db.sql_list('select name from tabDocType where istable=1')\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@override_settings(LOGIN_URL='/login/')...\n", "self.assertLoginURLEquals('/login/?next=/login_required/')\n" ]
[ "@override_settings(LOGIN_URL='/login/')...\n", "self.assertLoginURLEquals('/login/?next=/login_required/')\n" ]
[ 0, 0 ]
[ "Condition", "Expr'" ]
[ "def FUNC_73(self, VAR_144, VAR_145=True, VAR_90=None):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_153(VAR_114):...\n", "def FUNC_118(*VAR_9, **VAR_13):...\n", "VAR_431, VAR_432, VAR_141 = self.basic()\n", "VAR_141 = VAR_141 or self.user\n", "VAR_433 = VAR_145\n", "if callable(VAR_433):\n", "VAR_433 = VAR_433()\n", "if VAR_433:\n", "if not VAR_141:\n", "if callable(VAR_144):\n", "if VAR_263.request.ajax:\n", "VAR_453 = VAR_144()\n", "VAR_453 = VAR_144\n", "if VAR_90 is not None:\n", "if not VAR_453:\n", "if callable(VAR_90):\n", "if self.settings.allow_basic_login_only or VAR_432 or VAR_263.request.is_restful:\n", "VAR_263.session.flash = self.messages.access_denied\n", "return VAR_114(*VAR_9, **b)\n", "return VAR_90()\n", "redirect(VAR_90)\n", "VAR_112 = self.here()\n", "return FUNC_3(self.settings.on_failed_authorization)\n", "VAR_263.session.flash = VAR_263.response.flash\n", "return FUNC_3(self.settings.on_failed_authentication, self.settings.\n login_url + '?_next=' + urllib_quote(VAR_112))\n" ]
[ "def requires(self, condition, requires_login=True, otherwise=None):...\n", "\"\"\"docstring\"\"\"\n", "def decorator(action):...\n", "def f(*a, **b):...\n", "basic_allowed, basic_accepted, user = self.basic()\n", "user = user or self.user\n", "login_required = requires_login\n", "if callable(login_required):\n", "login_required = login_required()\n", "if login_required:\n", "if not user:\n", "if callable(condition):\n", "if current.request.ajax:\n", "flag = condition()\n", "flag = condition\n", "if otherwise is not None:\n", "if not flag:\n", "if callable(otherwise):\n", "if self.settings.allow_basic_login_only or basic_accepted or current.request.is_restful:\n", "current.session.flash = self.messages.access_denied\n", "return action(*a, **b)\n", "return otherwise()\n", "redirect(otherwise)\n", "next = self.here()\n", "return call_or_redirect(self.settings.on_failed_authorization)\n", "current.session.flash = current.response.flash\n", "return call_or_redirect(self.settings.on_failed_authentication, self.\n settings.login_url + '?_next=' + urllib_quote(next))\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "FunctionDef'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Condition", "Condition", "Condition", "Condition", "Assign'", "Return'", "Return'", "Expr'", "Assign'", "Return'", "Assign'", "Return'" ]
[ "def FUNC_13(self):...\n", "\"\"\"docstring\"\"\"\n", "return FILTERS.get_search_name(self.cleaned_data.get('q', ''))\n" ]
[ "def get_name(self):...\n", "\"\"\"docstring\"\"\"\n", "return FILTERS.get_search_name(self.cleaned_data.get('q', ''))\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Return'" ]
[ "def FUNC_23(self, VAR_12, VAR_6):...\n", "VAR_29 = VAR_12.get('filters') or []\n", "if VAR_6:\n", "for key, value in iteritems(VAR_6):\n", "return VAR_29\n", "VAR_39, VAR_40 = '=', value\n", "if isinstance(value, (list, tuple)):\n", "VAR_39, VAR_40 = value\n", "VAR_29.append([key, VAR_39, VAR_40])\n" ]
[ "def get_standard_report_filters(self, params, filters):...\n", "_filters = params.get('filters') or []\n", "if filters:\n", "for key, value in iteritems(filters):\n", "return _filters\n", "condition, _value = '=', value\n", "if isinstance(value, (list, tuple)):\n", "condition, _value = value\n", "_filters.append([key, condition, _value])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "For", "Return'", "Assign'", "Condition", "Assign'", "Expr'" ]
[ "def FUNC_25(self):...\n", "VAR_21 = self.client.get('%s/admin_widgets/car/' % self.admin_root)\n", "self.assertContains(VAR_21, '%s/auth/user/add/' % self.admin_root)\n" ]
[ "def test_changelist_foreignkey(self):...\n", "response = self.client.get('%s/admin_widgets/car/' % self.admin_root)\n", "self.assertContains(response, '%s/auth/user/add/' % self.admin_root)\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'" ]
[ "def FUNC_1(self, VAR_2, VAR_3, VAR_10, VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "VAR_22 = CLASS_0(VAR_2, VAR_3, VAR_10, VAR_5)\n", "VAR_23 = VAR_22,\n", "return make_deferred_yieldable(self._verify_objects(VAR_23)[0])\n" ]
[ "def verify_json_for_server(self, server_name, json_object, validity_time,...\n", "\"\"\"docstring\"\"\"\n", "req = VerifyJsonRequest(server_name, json_object, validity_time, request_name)\n", "requests = req,\n", "return make_deferred_yieldable(self._verify_objects(requests)[0])\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Return'" ]
[ "async def FUNC_9(self, VAR_17, VAR_18, VAR_19):...\n", "\"\"\"docstring\"\"\"\n", "VAR_32 = VAR_18['valid_until_ts']\n", "VAR_33 = {}\n", "for VAR_43, key_data in VAR_18['verify_keys'].items():\n", "if is_signing_algorithm_supported(VAR_43):\n", "VAR_2 = VAR_18['server_name']\n", "VAR_56 = key_data['key']\n", "VAR_34 = False\n", "VAR_57 = decode_base64(VAR_56)\n", "for VAR_43 in VAR_18['signatures'].get(VAR_2, {}):\n", "VAR_44 = decode_verify_key_bytes(VAR_43, VAR_57)\n", "VAR_49 = VAR_33.get(VAR_43)\n", "if not VAR_34:\n", "VAR_33[VAR_43] = FetchKeyResult(VAR_44=verify_key, valid_until_ts=\n ts_valid_until_ms)\n", "if not VAR_49:\n", "for VAR_43, key_data in VAR_18['old_verify_keys'].items():\n", "verify_signed_json(VAR_18, VAR_2, VAR_49.verify_key)\n", "if is_signing_algorithm_supported(VAR_43):\n", "VAR_35 = encode_canonical_json(VAR_18)\n", "VAR_34 = True\n", "VAR_56 = key_data['key']\n", "await make_deferred_yieldable(defer.gatherResults([run_in_background(self.\n store.store_server_keys_json, VAR_2=server_name, VAR_43=key_id, VAR_17=\n from_server, ts_now_ms=time_added_ms, ts_expires_ms=ts_valid_until_ms,\n VAR_35=key_json_bytes) for VAR_43 in VAR_33], consumeErrors=True).\n addErrback(unwrapFirstError))\n", "VAR_57 = decode_base64(VAR_56)\n", "return VAR_33\n", "VAR_44 = decode_verify_key_bytes(VAR_43, VAR_57)\n", "VAR_33[VAR_43] = FetchKeyResult(VAR_44=verify_key, valid_until_ts=key_data[\n 'expired_ts'])\n" ]
[ "async def process_v2_response(self, from_server, response_json, time_added_ms):...\n", "\"\"\"docstring\"\"\"\n", "ts_valid_until_ms = response_json['valid_until_ts']\n", "verify_keys = {}\n", "for key_id, key_data in response_json['verify_keys'].items():\n", "if is_signing_algorithm_supported(key_id):\n", "server_name = response_json['server_name']\n", "key_base64 = key_data['key']\n", "verified = False\n", "key_bytes = decode_base64(key_base64)\n", "for key_id in response_json['signatures'].get(server_name, {}):\n", "verify_key = decode_verify_key_bytes(key_id, key_bytes)\n", "key = verify_keys.get(key_id)\n", "if not verified:\n", "verify_keys[key_id] = FetchKeyResult(verify_key=verify_key, valid_until_ts=\n ts_valid_until_ms)\n", "if not key:\n", "for key_id, key_data in response_json['old_verify_keys'].items():\n", "verify_signed_json(response_json, server_name, key.verify_key)\n", "if is_signing_algorithm_supported(key_id):\n", "key_json_bytes = encode_canonical_json(response_json)\n", "verified = True\n", "key_base64 = key_data['key']\n", "await make_deferred_yieldable(defer.gatherResults([run_in_background(self.\n store.store_server_keys_json, server_name=server_name, key_id=key_id,\n from_server=from_server, ts_now_ms=time_added_ms, ts_expires_ms=\n ts_valid_until_ms, key_json_bytes=key_json_bytes) for key_id in\n verify_keys], consumeErrors=True).addErrback(unwrapFirstError))\n", "key_bytes = decode_base64(key_base64)\n", "return verify_keys\n", "verify_key = decode_verify_key_bytes(key_id, key_bytes)\n", "verify_keys[key_id] = FetchKeyResult(verify_key=verify_key, valid_until_ts=\n key_data['expired_ts'])\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 ]
[ "AsyncFunctionDef'", "Docstring", "Assign'", "Assign'", "For", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "For", "Assign'", "Assign'", "Condition", "Assign'", "Condition", "For", "Expr'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Return'", "Assign'", "Assign'" ]
[ "def FUNC_13(self, VAR_0):...\n", "VAR_13 = VAR_0.patch('httpx.get')\n", "VAR_15 = VAR_0.patch('yaml.safe_load')\n", "from openapi_python_client import _get_document\n", "VAR_7 = VAR_0.MagicMock()\n", "VAR_2(VAR_6=None, VAR_7=path)\n", "VAR_13.assert_not_called()\n", "VAR_7.read_bytes.assert_called_once()\n", "VAR_15.assert_called_once_with(VAR_7.read_bytes())\n" ]
[ "def test__get_document_path_no_url(self, mocker):...\n", "get = mocker.patch('httpx.get')\n", "loads = mocker.patch('yaml.safe_load')\n", "from openapi_python_client import _get_document\n", "path = mocker.MagicMock()\n", "_get_document(url=None, path=path)\n", "get.assert_not_called()\n", "path.read_bytes.assert_called_once()\n", "loads.assert_called_once_with(path.read_bytes())\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "ImportFrom'", "Assign'", "Expr'", "Expr'", "Expr'", "Expr'" ]
[ "def FUNC_31(self):...\n", "if VAR_53.session['admin'] and cherry.config['general.update_notification']:\n", "FUNC_0()\n", "return {'type': 'wisdom', 'data': self.model.motd()}\n", "VAR_104 = self.model.check_for_updates()\n", "if VAR_104:\n", "VAR_115 = VAR_104[0]['version']\n", "VAR_116 = []\n", "VAR_117 = []\n", "for version in VAR_104:\n", "for update in version['features']:\n", "VAR_118 = {'type': 'update', 'data': {}}\n", "if update.startswith('FEATURE:'):\n", "VAR_118['data']['version'] = VAR_115\n", "VAR_116.append(update[len('FEATURE:'):])\n", "if update.startswith('FIX:'):\n", "VAR_118['data']['features'] = VAR_116\n", "VAR_117.append(update[len('FIX:'):])\n", "if update.startswith('FIXED:'):\n", "VAR_118['data']['fixes'] = VAR_117\n", "VAR_117.append(update[len('FIXED:'):])\n", "return VAR_118\n" ]
[ "def api_getmotd(self):...\n", "if cherrypy.session['admin'] and cherry.config['general.update_notification']:\n", "_save_and_release_session()\n", "return {'type': 'wisdom', 'data': self.model.motd()}\n", "new_versions = self.model.check_for_updates()\n", "if new_versions:\n", "newest_version = new_versions[0]['version']\n", "features = []\n", "fixes = []\n", "for version in new_versions:\n", "for update in version['features']:\n", "retdata = {'type': 'update', 'data': {}}\n", "if update.startswith('FEATURE:'):\n", "retdata['data']['version'] = newest_version\n", "features.append(update[len('FEATURE:'):])\n", "if update.startswith('FIX:'):\n", "retdata['data']['features'] = features\n", "fixes.append(update[len('FIX:'):])\n", "if update.startswith('FIXED:'):\n", "retdata['data']['fixes'] = fixes\n", "fixes.append(update[len('FIXED:'):])\n", "return retdata\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Expr'", "Return'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "For", "For", "Assign'", "Condition", "Assign'", "Expr'", "Condition", "Assign'", "Expr'", "Condition", "Assign'", "Expr'", "Return'" ]
[ "def FUNC_45(self, VAR_112=VAR_3, VAR_134=VAR_3, VAR_135=VAR_3, VAR_136=...\n", "VAR_56 = VAR_263.request\n", "VAR_244 = VAR_263.response\n", "VAR_139 = VAR_263.session\n", "VAR_101, VAR_153 = self.db, self.table_cas()\n", "VAR_139._cas_service = VAR_56.vars.service or VAR_139._cas_service\n", "if VAR_56.env.http_host not in self.settings.cas_domains or not VAR_139._cas_service:\n", "def FUNC_157(VAR_262=False):...\n", "VAR_266 = VAR_153(VAR_364=session._cas_service, VAR_143=self.user.id)\n", "if VAR_266:\n", "VAR_264 = VAR_266.ticket\n", "VAR_264 = 'ST-' + web2py_uuid()\n", "VAR_364 = VAR_139._cas_service\n", "VAR_153.insert(VAR_364=session._cas_service, VAR_143=self.user.id, VAR_264=\n ticket, created_on=request.now, VAR_265=interactivelogin)\n", "VAR_365 = '&' if '?' in VAR_364 else '?'\n", "if 'warn' in VAR_56.vars and not VAR_262:\n", "VAR_244.headers['refresh'\n ] = '5;URL=%s' % VAR_364 + VAR_365 + 'ticket=' + VAR_264\n", "redirect(VAR_364 + VAR_365 + 'ticket=' + VAR_264)\n", "return A('Continue to %s' % VAR_364, _href=service + query_sep + 'ticket=' +\n ticket)\n", "if self.is_logged_in() and 'renew' not in VAR_56.vars:\n", "return FUNC_157()\n", "if not self.is_logged_in() and 'gateway' in VAR_56.vars:\n", "redirect(VAR_139._cas_service)\n", "def FUNC_158(VAR_7, VAR_135=VAR_135):...\n", "if VAR_135 is not VAR_3:\n", "VAR_135(VAR_7)\n", "return FUNC_157(VAR_262=True)\n" ]
[ "def cas_login(self, next=DEFAULT, onvalidation=DEFAULT, onaccept=DEFAULT,...\n", "request = current.request\n", "response = current.response\n", "session = current.session\n", "db, table = self.db, self.table_cas()\n", "session._cas_service = request.vars.service or session._cas_service\n", "if request.env.http_host not in self.settings.cas_domains or not session._cas_service:\n", "def allow_access(interactivelogin=False):...\n", "row = table(service=session._cas_service, user_id=self.user.id)\n", "if row:\n", "ticket = row.ticket\n", "ticket = 'ST-' + web2py_uuid()\n", "service = session._cas_service\n", "table.insert(service=session._cas_service, user_id=self.user.id, ticket=\n ticket, created_on=request.now, renew=interactivelogin)\n", "query_sep = '&' if '?' in service else '?'\n", "if 'warn' in request.vars and not interactivelogin:\n", "response.headers['refresh'\n ] = '5;URL=%s' % service + query_sep + 'ticket=' + ticket\n", "redirect(service + query_sep + 'ticket=' + ticket)\n", "return A('Continue to %s' % service, _href=service + query_sep + 'ticket=' +\n ticket)\n", "if self.is_logged_in() and 'renew' not in request.vars:\n", "return allow_access()\n", "if not self.is_logged_in() and 'gateway' in request.vars:\n", "redirect(session._cas_service)\n", "def cas_onaccept(form, onaccept=onaccept):...\n", "if onaccept is not DEFAULT:\n", "onaccept(form)\n", "return allow_access(interactivelogin=True)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "FunctionDef'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Return'", "Condition", "Return'", "Condition", "Expr'", "FunctionDef'", "Condition", "Expr'", "Return'" ]
[ "@transaction.non_atomic_requests...\n", "\"\"\"docstring\"\"\"\n", "VAR_38 = CourseKey.from_string(VAR_10)\n", "VAR_65 = get_course_by_id(VAR_38)\n", "VAR_78 = instructor_analytics.basic.AVAILABLE_FEATURES\n", "VAR_68 = list(microsite.get_value('student_profile_download_fields', []))\n", "if not VAR_68:\n", "VAR_68 = ['id', 'username', 'name', 'email', 'language', 'location',\n 'year_of_birth', 'gender', 'level_of_education', 'mailing_address', 'goals'\n ]\n", "VAR_76 = {'id': _('User ID'), 'username': _('Username'), 'name': _('Name'),\n 'email': _('Email'), 'language': _('Language'), 'location': _(\n 'Location'), 'year_of_birth': _('Birth Year'), 'gender': _('Gender'),\n 'level_of_education': _('Level of Education'), 'mailing_address': _(\n 'Mailing Address'), 'goals': _('Goals')}\n", "if is_course_cohorted(VAR_65.id):\n", "VAR_68.append('cohort')\n", "if VAR_65.teams_enabled:\n", "VAR_76['cohort'] = _('Cohort')\n", "VAR_68.append('team')\n", "VAR_68.append('city')\n", "VAR_76['team'] = _('Team')\n", "VAR_76['city'] = _('City')\n", "VAR_68.append('country')\n", "VAR_76['country'] = _('Country')\n", "if not VAR_26:\n", "VAR_175 = instructor_analytics.basic.enrolled_students_features(VAR_38, VAR_68)\n", "instructor_task.api.submit_calculate_students_features_csv(VAR_9, VAR_38,\n VAR_68)\n", "VAR_196 = _('string')\n", "VAR_63 = {'course_id': unicode(VAR_38), 'students': VAR_175,\n 'students_count': len(VAR_175), 'queried_features': VAR_68,\n 'feature_names': VAR_76, 'available_features': VAR_78}\n", "VAR_172 = _('string')\n", "return JsonResponse({'status': VAR_196})\n", "return JsonResponse(VAR_63)\n", "return JsonResponse({'status': VAR_172})\n" ]
[ "@transaction.non_atomic_requests...\n", "\"\"\"docstring\"\"\"\n", "course_key = CourseKey.from_string(course_id)\n", "course = get_course_by_id(course_key)\n", "available_features = instructor_analytics.basic.AVAILABLE_FEATURES\n", "query_features = list(microsite.get_value('student_profile_download_fields',\n []))\n", "if not query_features:\n", "query_features = ['id', 'username', 'name', 'email', 'language', 'location',\n 'year_of_birth', 'gender', 'level_of_education', 'mailing_address', 'goals'\n ]\n", "query_features_names = {'id': _('User ID'), 'username': _('Username'),\n 'name': _('Name'), 'email': _('Email'), 'language': _('Language'),\n 'location': _('Location'), 'year_of_birth': _('Birth Year'), 'gender':\n _('Gender'), 'level_of_education': _('Level of Education'),\n 'mailing_address': _('Mailing Address'), 'goals': _('Goals')}\n", "if is_course_cohorted(course.id):\n", "query_features.append('cohort')\n", "if course.teams_enabled:\n", "query_features_names['cohort'] = _('Cohort')\n", "query_features.append('team')\n", "query_features.append('city')\n", "query_features_names['team'] = _('Team')\n", "query_features_names['city'] = _('City')\n", "query_features.append('country')\n", "query_features_names['country'] = _('Country')\n", "if not csv:\n", "student_data = instructor_analytics.basic.enrolled_students_features(course_key\n , query_features)\n", "instructor_task.api.submit_calculate_students_features_csv(request,\n course_key, query_features)\n", "already_running_status = _(\n 'This enrollment report is currently being created. To view the status of the report, see Pending Tasks below. You will be able to download the report when it is complete.'\n )\n", "response_payload = {'course_id': unicode(course_key), 'students':\n student_data, 'students_count': len(student_data), 'queried_features':\n query_features, 'feature_names': query_features_names,\n 'available_features': available_features}\n", "success_status = _(\n 'The enrolled learner profile report is being created. To view the status of the report, see Pending Tasks below.'\n )\n", "return JsonResponse({'status': already_running_status})\n", "return JsonResponse(response_payload)\n", "return JsonResponse({'status': success_status})\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 ]
[ "Condition", "Docstring", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Condition", "Expr'", "Condition", "Assign'", "Expr'", "Expr'", "Assign'", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Expr'", "Assign'", "Assign'", "Assign'", "Return'", "Return'", "Return'" ]
[ "def FUNC_4(VAR_9):...\n", "VAR_17 = list()\n", "for element in VAR_9:\n", "VAR_17.append(element.id)\n", "VAR_4[VAR_18.id] = VAR_17\n" ]
[ "def store_ids(result):...\n", "ids = list()\n", "for element in result:\n", "ids.append(element.id)\n", "searched_ids[current_user.id] = ids\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Expr'", "Assign'" ]
[ "def FUNC_11(self):...\n", "if not self.json:\n", "self.json = '{}'\n" ]
[ "def update_report_json(self):...\n", "if not self.json:\n", "self.json = '{}'\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'" ]
[ "def FUNC_34(self):...\n", "self.parser = saved_model_cli.create_parser()\n", "VAR_9 = test.test_src_dir_path(VAR_0)\n", "VAR_10 = self.parser.parse_args(['scan', '--dir', VAR_9])\n", "saved_model_cli.scan(VAR_10)\n", "VAR_11 = out.getvalue().strip()\n", "self.assertTrue('does not contain denylisted ops' in VAR_11)\n" ]
[ "def testScanCommand(self):...\n", "self.parser = saved_model_cli.create_parser()\n", "base_path = test.test_src_dir_path(SAVED_MODEL_PATH)\n", "args = self.parser.parse_args(['scan', '--dir', base_path])\n", "saved_model_cli.scan(args)\n", "output = out.getvalue().strip()\n", "self.assertTrue('does not contain denylisted ops' in output)\n" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Expr'" ]
[ "def FUNC_4(VAR_4):...\n", "from helpdesk.settings import DEFAULT_USER_SETTINGS\n", "return DEFAULT_USER_SETTINGS[VAR_4]\n" ]
[ "def get_default_setting(setting):...\n", "from helpdesk.settings import DEFAULT_USER_SETTINGS\n", "return DEFAULT_USER_SETTINGS[setting]\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "Return'" ]
[ "def FUNC_1(self, VAR_4):...\n", "\"\"\"docstring\"\"\"\n", "if not VAR_4 in self._exempt:\n", "self._exempt.append(VAR_4)\n" ]
[ "def exempt(self, view_func):...\n", "\"\"\"docstring\"\"\"\n", "if not view_func in self._exempt:\n", "self._exempt.append(view_func)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'" ]
[ "def FUNC_2(self):...\n", "VAR_3 = [{'boom': {}}, {'account_data': 'Hello World'}, {'event_fields': [\n '\\\\\\\\foo']}, {'room': {'timeline': {'limit': 0}, 'state': {'not_bars':\n ['*']}}}, {'event_format': 'other'}, {'room': {'not_rooms': [\n '#foo:pik-test']}}, {'presence': {'senders': ['@bar;pik.test.com']}}]\n", "for VAR_14 in VAR_3:\n", "self.filtering.check_valid_filter(VAR_14)\n", "self.assertIsInstance(check_filter_error.exception, SynapseError)\n" ]
[ "def test_errors_on_invalid_filters(self):...\n", "invalid_filters = [{'boom': {}}, {'account_data': 'Hello World'}, {\n 'event_fields': ['\\\\\\\\foo']}, {'room': {'timeline': {'limit': 0},\n 'state': {'not_bars': ['*']}}}, {'event_format': 'other'}, {'room': {\n 'not_rooms': ['#foo:pik-test']}}, {'presence': {'senders': [\n '@bar;pik.test.com']}}]\n", "for filter in invalid_filters:\n", "self.filtering.check_valid_filter(filter)\n", "self.assertIsInstance(check_filter_error.exception, SynapseError)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "For", "Expr'", "Expr'" ]
[ "def FUNC_0(VAR_2):...\n", "\"\"\"docstring\"\"\"\n", "VAR_6 = [e.upper() for e in VAR_2.name().split('-')]\n", "if VAR_2.usedBits() < 128:\n", "return False\n", "if VAR_2.keyExchangeMethod() == 'DH' and utils.is_windows:\n", "return False\n", "if VAR_2.encryptionMethod().upper().startswith('RC4'):\n", "return False\n", "if VAR_2.encryptionMethod().upper().startswith('DES'):\n", "return False\n", "if 'MD5' in VAR_6:\n", "return False\n", "if VAR_2.authenticationMethod() in ['aNULL', 'NULL']:\n", "return False\n", "if VAR_2.encryptionMethod() in ['eNULL', 'NULL']:\n", "return False\n", "if 'EXP' in VAR_6 or 'EXPORT' in VAR_6:\n", "return False\n", "if 'ADH' in VAR_6:\n", "return False\n", "return True\n" ]
[ "def _is_secure_cipher(cipher):...\n", "\"\"\"docstring\"\"\"\n", "tokens = [e.upper() for e in cipher.name().split('-')]\n", "if cipher.usedBits() < 128:\n", "return False\n", "if cipher.keyExchangeMethod() == 'DH' and utils.is_windows:\n", "return False\n", "if cipher.encryptionMethod().upper().startswith('RC4'):\n", "return False\n", "if cipher.encryptionMethod().upper().startswith('DES'):\n", "return False\n", "if 'MD5' in tokens:\n", "return False\n", "if cipher.authenticationMethod() in ['aNULL', 'NULL']:\n", "return False\n", "if cipher.encryptionMethod() in ['eNULL', 'NULL']:\n", "return False\n", "if 'EXP' in tokens or 'EXPORT' in tokens:\n", "return False\n", "if 'ADH' in tokens:\n", "return False\n", "return True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Condition", "Return'", "Return'" ]
[ "def FUNC_37(self):...\n", "from zope.interface.verify import verifyClass\n", "from zope.tal.interfaces import ITALExpressionEngine\n", "verifyClass(ITALExpressionEngine, self._getTargetClass())\n" ]
[ "def test_class_conforms_to_ITALExpressionEngine(self):...\n", "from zope.interface.verify import verifyClass\n", "from zope.tal.interfaces import ITALExpressionEngine\n", "verifyClass(ITALExpressionEngine, self._getTargetClass())\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "ImportFrom'", "Expr'" ]
[ "@VAR_2.route('/download/<int:book_id>/<book_format>', defaults={'anyname':...\n", "VAR_96 = 'kobo' if 'Kobo' in request.headers.get('User-Agent') else ''\n", "return get_download_link(VAR_5, VAR_6, VAR_96)\n" ]
[ "@web.route('/download/<int:book_id>/<book_format>', defaults={'anyname':...\n", "client = 'kobo' if 'Kobo' in request.headers.get('User-Agent') else ''\n", "return get_download_link(book_id, book_format, client)\n" ]
[ 0, 0, 0 ]
[ "For", "Assign'", "Return'" ]
[ "def FUNC_5(self):...\n", "from django.contrib.admin.views.main import TO_FIELD_VAR\n", "VAR_12 = self.base_url_parameters()\n", "VAR_12.update({TO_FIELD_VAR: self.rel.get_related_field().name})\n", "return VAR_12\n" ]
[ "def url_parameters(self):...\n", "from django.contrib.admin.views.main import TO_FIELD_VAR\n", "params = self.base_url_parameters()\n", "params.update({TO_FIELD_VAR: self.rel.get_related_field().name})\n", "return params\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "ImportFrom'", "Assign'", "Expr'", "Return'" ]
[ "async def FUNC_5(self):...\n", "if hasattr(self, 'resolved_ref'):\n", "return self.resolved_ref\n", "VAR_28 = '{api_base_path}/repos/{user}/{repo}/commits/{ref}'.format(VAR_25=\n self.api_base_path.format(hostname=self.hostname), user=self.user, repo\n =self.repo, ref=self.unresolved_ref)\n", "self.log.debug('Fetching %s', VAR_28)\n", "VAR_48 = self.cache.get(VAR_28)\n", "if VAR_48:\n", "VAR_29 = VAR_48['etag']\n", "VAR_24 = self.cache_404.get(VAR_28)\n", "self.log.debug('Cache hit for %s: %s', VAR_28, VAR_29)\n", "if VAR_24:\n", "VAR_41 = await self.github_api_request(VAR_28, VAR_29=etag)\n", "self.log.debug('Cache hit for 404 on %s', VAR_28)\n", "VAR_29 = None\n", "if VAR_41 is None:\n", "return None\n", "self.log.debug('Caching 404 on %s', VAR_28)\n", "if VAR_41.code == 304:\n", "self.cache_404.set(VAR_28, True)\n", "self.log.info('Using cached ref for %s: %s', VAR_28, VAR_48['sha'])\n", "if VAR_48:\n", "return None\n", "self.resolved_ref = VAR_48['sha']\n", "self.log.debug('Cache outdated for %s', VAR_28)\n", "VAR_45 = json.loads(VAR_41.body.decode('utf-8'))\n", "self.cache.move_to_end(VAR_28)\n", "if 'sha' not in VAR_45:\n", "return self.resolved_ref\n", "self.log.warning('No sha for %s in %s', VAR_28, VAR_45)\n", "self.resolved_ref = VAR_45['sha']\n", "self.resolved_ref = None\n", "self.cache.set(VAR_28, {'etag': VAR_41.headers.get('ETag'), 'sha': self.\n resolved_ref})\n", "return None\n", "return self.resolved_ref\n" ]
[ "async def get_resolved_ref(self):...\n", "if hasattr(self, 'resolved_ref'):\n", "return self.resolved_ref\n", "api_url = '{api_base_path}/repos/{user}/{repo}/commits/{ref}'.format(\n api_base_path=self.api_base_path.format(hostname=self.hostname), user=\n self.user, repo=self.repo, ref=self.unresolved_ref)\n", "self.log.debug('Fetching %s', api_url)\n", "cached = self.cache.get(api_url)\n", "if cached:\n", "etag = cached['etag']\n", "cache_404 = self.cache_404.get(api_url)\n", "self.log.debug('Cache hit for %s: %s', api_url, etag)\n", "if cache_404:\n", "resp = await self.github_api_request(api_url, etag=etag)\n", "self.log.debug('Cache hit for 404 on %s', api_url)\n", "etag = None\n", "if resp is None:\n", "return None\n", "self.log.debug('Caching 404 on %s', api_url)\n", "if resp.code == 304:\n", "self.cache_404.set(api_url, True)\n", "self.log.info('Using cached ref for %s: %s', api_url, cached['sha'])\n", "if cached:\n", "return None\n", "self.resolved_ref = cached['sha']\n", "self.log.debug('Cache outdated for %s', api_url)\n", "ref_info = json.loads(resp.body.decode('utf-8'))\n", "self.cache.move_to_end(api_url)\n", "if 'sha' not in ref_info:\n", "return self.resolved_ref\n", "self.log.warning('No sha for %s in %s', api_url, ref_info)\n", "self.resolved_ref = ref_info['sha']\n", "self.resolved_ref = None\n", "self.cache.set(api_url, {'etag': resp.headers.get('ETag'), 'sha': self.\n resolved_ref})\n", "return None\n", "return self.resolved_ref\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 ]
[ "AsyncFunctionDef'", "Condition", "Return'", "Assign'", "Expr'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Condition", "Assign'", "Expr'", "Assign'", "Condition", "Return'", "Expr'", "Condition", "Expr'", "Expr'", "Condition", "Return'", "Assign'", "Expr'", "Assign'", "Expr'", "Condition", "Return'", "Expr'", "Assign'", "Assign'", "Expr'", "Return'", "Return'" ]
[ "@VAR_25.whitelist(allow_guest=True)...\n", "return 'pong'\n" ]
[ "@frappe.whitelist(allow_guest=True)...\n", "return 'pong'\n" ]
[ 0, 0 ]
[ "Condition", "Return'" ]
[ "def FUNC_88(self, VAR_156, VAR_166=False):...\n", "if VAR_156 in '_cloud':\n", "return self.cloud()\n", "if VAR_156 in '_search':\n", "return self.search()\n", "VAR_212 = self.auth.db.wiki_page(VAR_156=slug)\n", "if VAR_212 and not self.can_read(VAR_212):\n", "return self.not_authorized(VAR_212)\n", "if VAR_263.request.extension == 'html':\n", "if not VAR_212:\n", "if VAR_263.request.extension == 'load':\n", "VAR_12 = URL(VAR_11=('_create', slug))\n", "VAR_303 = VAR_212.html if not VAR_166 else self.get_renderer()(VAR_212)\n", "return self.fix_hostname(VAR_212.html) if VAR_212 else ''\n", "if not VAR_212:\n", "return dict(VAR_229=A('Create page \"%s\"' % slug, _href=url, _class='btn'))\n", "VAR_229 = XML(self.fix_hostname(VAR_303))\n", "return dict(VAR_441=page.title, VAR_156=page.slug, VAR_212=page, VAR_229=\n page.body, VAR_211=page.tags, created_on=page.created_on, modified_on=\n page.modified_on)\n", "return dict(VAR_441=page.title, VAR_156=page.slug, VAR_212=page, VAR_229=\n content, VAR_211=page.tags, created_on=page.created_on, modified_on=\n page.modified_on)\n" ]
[ "def read(self, slug, force_render=False):...\n", "if slug in '_cloud':\n", "return self.cloud()\n", "if slug in '_search':\n", "return self.search()\n", "page = self.auth.db.wiki_page(slug=slug)\n", "if page and not self.can_read(page):\n", "return self.not_authorized(page)\n", "if current.request.extension == 'html':\n", "if not page:\n", "if current.request.extension == 'load':\n", "url = URL(args=('_create', slug))\n", "html = page.html if not force_render else self.get_renderer()(page)\n", "return self.fix_hostname(page.html) if page else ''\n", "if not page:\n", "return dict(content=A('Create page \"%s\"' % slug, _href=url, _class='btn'))\n", "content = XML(self.fix_hostname(html))\n", "return dict(title=page.title, slug=page.slug, page=page, content=page.body,\n tags=page.tags, created_on=page.created_on, modified_on=page.modified_on)\n", "return dict(title=page.title, slug=page.slug, page=page, content=content,\n tags=page.tags, created_on=page.created_on, modified_on=page.modified_on)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Return'", "Condition", "Return'", "Assign'", "Condition", "Return'", "Condition", "Condition", "Condition", "Assign'", "Assign'", "Return'", "Condition", "Return'", "Assign'", "Return'", "Return'" ]
[ "def FUNC_13():...\n", "VAR_3 = FUNC_5()\n", "if len(request.args) == 2:\n", "VAR_120 = 'web2py.plugin.%s.w2p' % request.args[1]\n", "if VAR_5:\n", "VAR_5 = plugin_pack(VAR_3, request.args[1], request)\n", "VAR_43.headers['Content-Type'] = 'application/w2p'\n", "session.flash = T('internal error')\n", "VAR_119 = 'attachment; filename=%s' % VAR_120\n", "redirect(URL('plugin', VAR_98=request.args))\n", "VAR_43.headers['Content-Disposition'] = VAR_119\n", "return FUNC_3(VAR_5, 'rb')\n" ]
[ "def pack_plugin():...\n", "app = get_app()\n", "if len(request.args) == 2:\n", "fname = 'web2py.plugin.%s.w2p' % request.args[1]\n", "if filename:\n", "filename = plugin_pack(app, request.args[1], request)\n", "response.headers['Content-Type'] = 'application/w2p'\n", "session.flash = T('internal error')\n", "disposition = 'attachment; filename=%s' % fname\n", "redirect(URL('plugin', args=request.args))\n", "response.headers['Content-Disposition'] = disposition\n", "return safe_read(filename, 'rb')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Condition", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'", "Return'" ]
[ "def FUNC_13(self, VAR_31: Dict[str, Any], VAR_30: EventBase) ->None:...\n", "\"\"\"docstring\"\"\"\n", "if 'url' in VAR_30.content:\n", "VAR_31['image_url'] = VAR_30.content['url']\n" ]
[ "def add_image_message_vars(self, messagevars: Dict[str, Any], event: EventBase...\n", "\"\"\"docstring\"\"\"\n", "if 'url' in event.content:\n", "messagevars['image_url'] = event.content['url']\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Assign'" ]
[ "def FUNC_4(VAR_23, VAR_24=None, VAR_25=False):...\n", "\"\"\"docstring\"\"\"\n", "if getattr(VAR_1, 'initialised', None):\n", "return\n", "if not VAR_24:\n", "VAR_24 = '.'\n", "VAR_1.error_log = []\n", "VAR_1.message_log = []\n", "VAR_1.debug_log = []\n", "VAR_1.realtime_log = []\n", "VAR_1.flags = CLASS_0({'currently_saving': [], 'redirect_location': '',\n 'in_install_db': False, 'in_install_app': False, 'in_import': False,\n 'in_test': False, 'mute_messages': False, 'ignore_links': False,\n 'mute_emails': False, 'has_dataurl': False, 'new_site': VAR_25})\n", "VAR_1.rollback_observers = []\n", "VAR_1.before_commit = []\n", "VAR_1.test_objects = {}\n", "VAR_1.site = VAR_23\n", "VAR_1.sites_path = VAR_24\n", "VAR_1.site_path = os.path.join(VAR_24, VAR_23)\n", "VAR_1.all_apps = None\n", "VAR_1.request_ip = None\n", "VAR_1.response = CLASS_0({'docs': []})\n", "VAR_1.task_id = None\n", "VAR_1.conf = CLASS_0(FUNC_7())\n", "VAR_1.lang = VAR_1.conf.lang or 'en'\n", "VAR_1.lang_full_dict = None\n", "VAR_1.module_app = None\n", "VAR_1.app_modules = None\n", "VAR_1.system_settings = CLASS_0()\n", "VAR_1.user = None\n", "VAR_1.user_perms = None\n", "VAR_1.session = None\n", "VAR_1.role_permissions = {}\n", "VAR_1.valid_columns = {}\n", "VAR_1.new_doc_templates = {}\n", "VAR_1.link_count = {}\n", "VAR_1.jenv = None\n", "VAR_1.jloader = None\n", "VAR_1.cache = {}\n", "VAR_1.document_cache = {}\n", "VAR_1.meta_cache = {}\n", "VAR_1.form_dict = CLASS_0()\n", "VAR_1.session = CLASS_0()\n", "VAR_1.dev_server = os.environ.get('DEV_SERVER', False)\n", "FUNC_68()\n", "VAR_1.initialised = True\n" ]
[ "def init(site, sites_path=None, new_site=False):...\n", "\"\"\"docstring\"\"\"\n", "if getattr(local, 'initialised', None):\n", "return\n", "if not sites_path:\n", "sites_path = '.'\n", "local.error_log = []\n", "local.message_log = []\n", "local.debug_log = []\n", "local.realtime_log = []\n", "local.flags = _dict({'currently_saving': [], 'redirect_location': '',\n 'in_install_db': False, 'in_install_app': False, 'in_import': False,\n 'in_test': False, 'mute_messages': False, 'ignore_links': False,\n 'mute_emails': False, 'has_dataurl': False, 'new_site': new_site})\n", "local.rollback_observers = []\n", "local.before_commit = []\n", "local.test_objects = {}\n", "local.site = site\n", "local.sites_path = sites_path\n", "local.site_path = os.path.join(sites_path, site)\n", "local.all_apps = None\n", "local.request_ip = None\n", "local.response = _dict({'docs': []})\n", "local.task_id = None\n", "local.conf = _dict(get_site_config())\n", "local.lang = local.conf.lang or 'en'\n", "local.lang_full_dict = None\n", "local.module_app = None\n", "local.app_modules = None\n", "local.system_settings = _dict()\n", "local.user = None\n", "local.user_perms = None\n", "local.session = None\n", "local.role_permissions = {}\n", "local.valid_columns = {}\n", "local.new_doc_templates = {}\n", "local.link_count = {}\n", "local.jenv = None\n", "local.jloader = None\n", "local.cache = {}\n", "local.document_cache = {}\n", "local.meta_cache = {}\n", "local.form_dict = _dict()\n", "local.session = _dict()\n", "local.dev_server = os.environ.get('DEV_SERVER', False)\n", "setup_module_map()\n", "local.initialised = True\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assign'" ]
[ "def __call__(VAR_20, VAR_21):...\n", "\"\"\"docstring\"\"\"\n", "def FUNC_19(VAR_2, *VAR_23, **VAR_24):...\n", "VAR_3 = VAR_2.GET.get('url')\n", "if VAR_3 is None or len(VAR_3) == 0:\n", "VAR_3 = VAR_2.get_full_path()\n", "VAR_9 = False\n", "VAR_14 = VAR_24.get('conn', None)\n", "VAR_16 = None\n", "VAR_19 = VAR_24.get('server_id', None)\n", "if VAR_14 is None:\n", "VAR_9 = VAR_20.doConnectionCleanup\n", "VAR_36 = None\n", "VAR_0.debug('Connection not provided, attempting to get one.')\n", "VAR_36 = VAR_21(VAR_2, *VAR_23, **kwargs)\n", "VAR_39 = isinstance(VAR_36, CLASS_0)\n", "return VAR_36\n", "VAR_14 = VAR_20.get_connection(VAR_19, VAR_2)\n", "VAR_0.error('Error retrieving connection.', exc_info=True)\n", "if VAR_14 is None:\n", "if VAR_9 and VAR_39:\n", "VAR_16 = str(x)\n", "return VAR_20.on_not_logged_in(VAR_2, VAR_3, VAR_16)\n", "VAR_20.on_logged_in(VAR_2, VAR_14)\n", "VAR_9 = not VAR_39\n", "VAR_20.verify_is_admin(VAR_14)\n", "VAR_0.debug('Doing connection cleanup? %s' % VAR_9)\n", "VAR_20.verify_is_group_owner(VAR_14, VAR_24.get('gid'))\n", "if VAR_9:\n", "VAR_0.warn('Failed to clean up connection', exc_info=True)\n", "VAR_20.load_server_settings(VAR_14, VAR_2)\n", "if VAR_14 is not None and VAR_14.c is not None:\n", "VAR_15 = VAR_24.get('share_id')\n", "VAR_14.close(hard=False)\n", "VAR_17 = VAR_20.prepare_share_connection(VAR_2, VAR_14, VAR_15)\n", "if VAR_17 is not None:\n", "VAR_20.on_share_connection_prepared(VAR_2, VAR_17)\n", "VAR_24['conn'] = VAR_14\n", "VAR_24['conn'] = VAR_17\n", "VAR_24['url'] = VAR_3\n" ]
[ "def __call__(ctx, f):...\n", "\"\"\"docstring\"\"\"\n", "def wrapped(request, *args, **kwargs):...\n", "url = request.GET.get('url')\n", "if url is None or len(url) == 0:\n", "url = request.get_full_path()\n", "doConnectionCleanup = False\n", "conn = kwargs.get('conn', None)\n", "error = None\n", "server_id = kwargs.get('server_id', None)\n", "if conn is None:\n", "doConnectionCleanup = ctx.doConnectionCleanup\n", "retval = None\n", "logger.debug('Connection not provided, attempting to get one.')\n", "retval = f(request, *args, **kwargs)\n", "delayConnectionCleanup = isinstance(retval, ConnCleaningHttpResponse)\n", "return retval\n", "conn = ctx.get_connection(server_id, request)\n", "logger.error('Error retrieving connection.', exc_info=True)\n", "if conn is None:\n", "if doConnectionCleanup and delayConnectionCleanup:\n", "error = str(x)\n", "return ctx.on_not_logged_in(request, url, error)\n", "ctx.on_logged_in(request, conn)\n", "doConnectionCleanup = not delayConnectionCleanup\n", "ctx.verify_is_admin(conn)\n", "logger.debug('Doing connection cleanup? %s' % doConnectionCleanup)\n", "ctx.verify_is_group_owner(conn, kwargs.get('gid'))\n", "if doConnectionCleanup:\n", "logger.warn('Failed to clean up connection', exc_info=True)\n", "ctx.load_server_settings(conn, request)\n", "if conn is not None and conn.c is not None:\n", "share_id = kwargs.get('share_id')\n", "conn.close(hard=False)\n", "conn_share = ctx.prepare_share_connection(request, conn, share_id)\n", "if conn_share is not None:\n", "ctx.on_share_connection_prepared(request, conn_share)\n", "kwargs['conn'] = conn\n", "kwargs['conn'] = conn_share\n", "kwargs['url'] = url\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 ]
[ "FunctionDef'", "Docstring", "FunctionDef'", "Assign'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "Assign'", "Expr'", "Assign'", "Assign'", "Return'", "Assign'", "Expr'", "Condition", "Condition", "Assign'", "Return'", "Expr'", "Assign'", "Expr'", "Expr'", "Expr'", "Condition", "Expr'", "Expr'", "Condition", "Assign'", "Expr'", "Assign'", "Condition", "Expr'", "Assign'", "Assign'", "Assign'" ]
[ "@VAR_2.route('/language')...\n", "if VAR_87.check_visibility(constants.SIDEBAR_LANGUAGE):\n", "VAR_107 = list()\n", "abort(404)\n", "if VAR_87.filter_language() == u'all':\n", "VAR_48 = calibre_db.speaking_language()\n", "VAR_48 = calibre_db.session.query(db.Languages).filter(db.Languages.\n lang_code == VAR_87.filter_language()).all()\n", "VAR_110 = calibre_db.session.query(db.books_languages_link, func.count(\n 'books_languages_link.book').label('bookcount')).group_by(text(\n 'books_languages_link.lang_code')).all()\n", "VAR_48[0].name = isoLanguages.get_language_name(get_locale(), VAR_48[0].\n name.lang_code)\n", "return render_title_template('languages.html', VAR_48=languages, VAR_110=\n lang_counter, VAR_107=charlist, VAR_149=_(u'Languages'), VAR_9=\n 'langlist', VAR_8='language')\n" ]
[ "@web.route('/language')...\n", "if current_user.check_visibility(constants.SIDEBAR_LANGUAGE):\n", "charlist = list()\n", "abort(404)\n", "if current_user.filter_language() == u'all':\n", "languages = calibre_db.speaking_language()\n", "languages = calibre_db.session.query(db.Languages).filter(db.Languages.\n lang_code == current_user.filter_language()).all()\n", "lang_counter = calibre_db.session.query(db.books_languages_link, func.count\n ('books_languages_link.book').label('bookcount')).group_by(text(\n 'books_languages_link.lang_code')).all()\n", "languages[0].name = isoLanguages.get_language_name(get_locale(), languages[\n 0].name.lang_code)\n", "return render_title_template('languages.html', languages=languages,\n lang_counter=lang_counter, charlist=charlist, title=_(u'Languages'),\n page='langlist', data='language')\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Condition", "Assign'", "Expr'", "Condition", "Assign'", "Assign'", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_63(self, VAR_64):...\n", "\"\"\"docstring\"\"\"\n", "if self.options.get('escape'):\n", "return VAR_19(VAR_64)\n", "return VAR_64\n" ]
[ "def inline_html(self, html):...\n", "\"\"\"docstring\"\"\"\n", "if self.options.get('escape'):\n", "return escape(html)\n", "return html\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Return'", "Return'" ]
[ "def FUNC_11(VAR_3):...\n", "import datetime\n", "VAR_20 = os.path.join(apath(VAR_3, VAR_122=request), 'progress.log')\n", "VAR_32 = re.compile('\\\\[(.*?)\\\\][^\\\\:]+\\\\:\\\\s+(\\\\-?\\\\d+)')\n", "if not os.path.exists(VAR_20):\n", "return []\n", "VAR_35 = VAR_32.findall(open(VAR_20, 'r').read())\n", "VAR_36, VAR_37 = [], 0\n", "for VAR_156 in VAR_35:\n", "if not VAR_156:\n", "return VAR_36\n", "VAR_118 = -(request.now - datetime.datetime.strptime(VAR_156[0],\n '%Y-%m-%d %H:%M:%S')).days\n", "VAR_37 += int(VAR_156[1])\n", "VAR_36.append([VAR_118, VAR_37])\n" ]
[ "def report_progress(app):...\n", "import datetime\n", "progress_file = os.path.join(apath(app, r=request), 'progress.log')\n", "regex = re.compile('\\\\[(.*?)\\\\][^\\\\:]+\\\\:\\\\s+(\\\\-?\\\\d+)')\n", "if not os.path.exists(progress_file):\n", "return []\n", "matches = regex.findall(open(progress_file, 'r').read())\n", "events, counter = [], 0\n", "for m in matches:\n", "if not m:\n", "return events\n", "days = -(request.now - datetime.datetime.strptime(m[0], '%Y-%m-%d %H:%M:%S')\n ).days\n", "counter += int(m[1])\n", "events.append([days, counter])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Import'", "Assign'", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "For", "Condition", "Return'", "Assign'", "AugAssign'", "Expr'" ]
[ "def FUNC_3():...\n", "return VAR_6\n" ]
[ "def getEngine():...\n", "return _engine\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "@VAR_2.route('/', defaults={'page': 1})...\n", "VAR_20 = (request.args.get('sort') or 'stored').lower()\n", "return FUNC_15('newest', VAR_20, 1, VAR_9)\n" ]
[ "@web.route('/', defaults={'page': 1})...\n", "sort_param = (request.args.get('sort') or 'stored').lower()\n", "return render_books_list('newest', sort_param, 1, page)\n" ]
[ 0, 0, 0 ]
[ "Condition", "Assign'", "Return'" ]
[ "def FUNC_6(self, VAR_14):...\n", "VAR_87 = self.output(FUNC_4(VAR_14))\n", "VAR_88 = self.block.def_footnotes\n", "self.block.def_links = {}\n", "self.block.def_footnotes = {}\n", "self.inline.links = {}\n", "self.inline.footnotes = {}\n", "if not self.footnotes:\n", "return VAR_87\n", "VAR_61 = filter(lambda o: VAR_88.get(o['key']), self.footnotes)\n", "self.footnotes = sorted(VAR_61, VAR_13=lambda o: keys.get(o['key']),\n reverse=True)\n", "VAR_67 = self.renderer.placeholder()\n", "while self.footnotes:\n", "VAR_103 = self.footnotes.pop()\n", "VAR_87 += self.renderer.footnotes(VAR_67)\n", "VAR_67 += self.renderer.footnote_item(VAR_103['key'], VAR_103['text'])\n", "return VAR_87\n" ]
[ "def parse(self, text):...\n", "out = self.output(preprocessing(text))\n", "keys = self.block.def_footnotes\n", "self.block.def_links = {}\n", "self.block.def_footnotes = {}\n", "self.inline.links = {}\n", "self.inline.footnotes = {}\n", "if not self.footnotes:\n", "return out\n", "footnotes = filter(lambda o: keys.get(o['key']), self.footnotes)\n", "self.footnotes = sorted(footnotes, key=lambda o: keys.get(o['key']),\n reverse=True)\n", "body = self.renderer.placeholder()\n", "while self.footnotes:\n", "note = self.footnotes.pop()\n", "out += self.renderer.footnotes(body)\n", "body += self.renderer.footnote_item(note['key'], note['text'])\n", "return out\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Condition", "Return'", "Assign'", "Assign'", "Assign'", "Condition", "Assign'", "AugAssign'", "AugAssign'", "Return'" ]
[ "def FUNC_1(self):...\n", "VAR_12, VAR_13 = self.make_request('GET', self.url, shorthand=False)\n", "self.assertEqual(200, int(VAR_13.result['code']), msg=channel.result['body'])\n", "self.assertEqual({'server_version', 'python_version'}, set(VAR_13.json_body\n .keys()))\n" ]
[ "def test_version_string(self):...\n", "request, channel = self.make_request('GET', self.url, shorthand=False)\n", "self.assertEqual(200, int(channel.result['code']), msg=channel.result['body'])\n", "self.assertEqual({'server_version', 'python_version'}, set(channel.\n json_body.keys()))\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "Expr'" ]
[ "def FUNC_0(self, VAR_1):...\n", "VAR_17 = VAR_1.MagicMock(class_name='MyTestEnum')\n", "VAR_1.patch(f'{VAR_0}.Reference.from_ref', return_value=fake_reference)\n", "from openapi_python_client.parser import properties\n", "VAR_22 = properties.EnumProperty(VAR_5='test', VAR_26=True, default=None,\n VAR_21={}, title='a_title')\n", "assert VAR_22.get_type_string() == 'MyTestEnum'\n", "VAR_22.required = False\n", "assert VAR_22.get_type_string() == 'Optional[MyTestEnum]'\n", "properties._existing_enums = {}\n" ]
[ "def test_get_type_string(self, mocker):...\n", "fake_reference = mocker.MagicMock(class_name='MyTestEnum')\n", "mocker.patch(f'{MODULE_NAME}.Reference.from_ref', return_value=fake_reference)\n", "from openapi_python_client.parser import properties\n", "enum_property = properties.EnumProperty(name='test', required=True, default\n =None, values={}, title='a_title')\n", "assert enum_property.get_type_string() == 'MyTestEnum'\n", "enum_property.required = False\n", "assert enum_property.get_type_string() == 'Optional[MyTestEnum]'\n", "properties._existing_enums = {}\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Expr'", "ImportFrom'", "Assign'", "Assert'", "Assign'", "Assert'", "Assign'" ]
[ "def FUNC_2(VAR_3, VAR_4):...\n", "if VAR_3['aggregate_function'] == 'count':\n", "VAR_31 = 'count(*) as _aggregate_column'\n", "VAR_31 = '{0}(`tab{1}`.{2}) as _aggregate_column'.format(VAR_3.\n aggregate_function, VAR_4, VAR_3.aggregate_on)\n", "return VAR_31\n" ]
[ "def get_group_by_field(args, doctype):...\n", "if args['aggregate_function'] == 'count':\n", "group_by_field = 'count(*) as _aggregate_column'\n", "group_by_field = '{0}(`tab{1}`.{2}) as _aggregate_column'.format(args.\n aggregate_function, doctype, args.aggregate_on)\n", "return group_by_field\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Return'" ]
[ "def FUNC_37(VAR_37, VAR_42):...\n", "if VAR_37.cover:\n", "VAR_98 = VAR_37.cover\n", "VAR_98 = os.path.join(constants.STATIC_DIR, 'generic_cover.jpg')\n", "VAR_76 = os.path.join(config.config_calibre_dir, VAR_42.path, 'cover.jpg')\n", "copyfile(VAR_98, VAR_76)\n", "VAR_1.error('Failed to move cover file %s: %s', VAR_76, e)\n", "if VAR_37.cover:\n", "flash(_(u'Failed to Move Cover File %(file)s: %(error)s', file=\n new_coverpath, VAR_51=e), category='error')\n", "os.unlink(VAR_37.cover)\n" ]
[ "def move_coverfile(meta, db_book):...\n", "if meta.cover:\n", "coverfile = meta.cover\n", "coverfile = os.path.join(constants.STATIC_DIR, 'generic_cover.jpg')\n", "new_coverpath = os.path.join(config.config_calibre_dir, db_book.path,\n 'cover.jpg')\n", "copyfile(coverfile, new_coverpath)\n", "log.error('Failed to move cover file %s: %s', new_coverpath, e)\n", "if meta.cover:\n", "flash(_(u'Failed to Move Cover File %(file)s: %(error)s', file=\n new_coverpath, error=e), category='error')\n", "os.unlink(meta.cover)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Condition", "Assign'", "Assign'", "Assign'", "Expr'", "Expr'", "Condition", "Expr'", "Expr'" ]
[ "def FUNC_0(self):...\n", "self.reactor = ThreadedMemoryReactorClock()\n" ]
[ "def setUp(self):...\n", "self.reactor = ThreadedMemoryReactorClock()\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Assign'" ]
[ "def FUNC_44(VAR_16):...\n", "VAR_83 = False\n", "VAR_83 |= FUNC_38(VAR_16, 'config_log_level')\n", "VAR_83 |= FUNC_41(VAR_16, 'config_logfile')\n", "if not logger.is_valid_logfile(config.config_logfile):\n", "return VAR_83, FUNC_50(_(\n 'Logfile Location is not Valid, Please Enter Correct Path'))\n", "VAR_83 |= FUNC_40(VAR_16, 'config_access_log')\n", "VAR_83 |= FUNC_41(VAR_16, 'config_access_logfile')\n", "if not logger.is_valid_logfile(config.config_access_logfile):\n", "return VAR_83, FUNC_50(_(\n 'Access Logfile Location is not Valid, Please Enter Correct Path'))\n", "return VAR_83, None\n" ]
[ "def _configuration_logfile_helper(to_save):...\n", "reboot_required = False\n", "reboot_required |= _config_int(to_save, 'config_log_level')\n", "reboot_required |= _config_string(to_save, 'config_logfile')\n", "if not logger.is_valid_logfile(config.config_logfile):\n", "return reboot_required, _configuration_result(_(\n 'Logfile Location is not Valid, Please Enter Correct Path'))\n", "reboot_required |= _config_checkbox_int(to_save, 'config_access_log')\n", "reboot_required |= _config_string(to_save, 'config_access_logfile')\n", "if not logger.is_valid_logfile(config.config_access_logfile):\n", "return reboot_required, _configuration_result(_(\n 'Access Logfile Location is not Valid, Please Enter Correct Path'))\n", "return reboot_required, None\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "AugAssign'", "AugAssign'", "Condition", "Return'", "AugAssign'", "AugAssign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_2(VAR_0):...\n", "VAR_0.DEBUG = True\n", "VAR_6 = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' parent=view\"\n )\n", "VAR_7 = unicorn(None, VAR_6)\n", "VAR_10 = CLASS_0(component_name='test', component_id='asdf')\n", "VAR_8 = {'view': VAR_10}\n", "VAR_7.render(VAR_8)\n", "assert VAR_7.parent\n", "assert VAR_7.component_id == 'asdf:tests.templatetags.test_unicorn_render.FakeComponentKwargs'\n" ]
[ "def test_unicorn_render_parent(settings):...\n", "settings.DEBUG = True\n", "token = Token(TokenType.TEXT,\n \"unicorn 'tests.templatetags.test_unicorn_render.FakeComponentKwargs' parent=view\"\n )\n", "unicorn_node = unicorn(None, token)\n", "view = FakeComponentParent(component_name='test', component_id='asdf')\n", "context = {'view': view}\n", "unicorn_node.render(context)\n", "assert unicorn_node.parent\n", "assert unicorn_node.component_id == 'asdf:tests.templatetags.test_unicorn_render.FakeComponentKwargs'\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Assign'", "Assign'", "Assign'", "Assign'", "Assign'", "Expr'", "Assert'", "Assert'" ]
[ "def FUNC_9():...\n", "\"\"\"docstring\"\"\"\n", "if VAR_12:\n", "VAR_12.close()\n", "release_local(VAR_1)\n" ]
[ "def destroy():...\n", "\"\"\"docstring\"\"\"\n", "if db:\n", "db.close()\n", "release_local(local)\n" ]
[ 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Condition", "Expr'", "Expr'" ]
[ "@wraps(VAR_3)...\n", "VAR_12 = FUNC_2()\n", "if VAR_12 is not None:\n", "VAR_16 = ub.session.query(ub.User).join(ub.RemoteAuthToken).filter(ub.\n RemoteAuthToken.auth_token == VAR_12).filter(ub.RemoteAuthToken.\n token_type == 1).first()\n", "if VAR_16 is not None:\n", "login_user(VAR_16)\n", "VAR_0.debug('Received Kobo request without a recognizable auth token.')\n", "return VAR_3(*VAR_9, **kwargs)\n", "return abort(401)\n" ]
[ "@wraps(f)...\n", "auth_token = get_auth_token()\n", "if auth_token is not None:\n", "user = ub.session.query(ub.User).join(ub.RemoteAuthToken).filter(ub.\n RemoteAuthToken.auth_token == auth_token).filter(ub.RemoteAuthToken.\n token_type == 1).first()\n", "if user is not None:\n", "login_user(user)\n", "log.debug('Received Kobo request without a recognizable auth token.')\n", "return f(*args, **kwargs)\n", "return abort(401)\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "Condition", "Assign'", "Condition", "Assign'", "Condition", "Expr'", "Expr'", "Return'", "Return'" ]
[ "def FUNC_2(self) ->str:...\n", "\"\"\"docstring\"\"\"\n", "VAR_9 = [p.get_type_string() for p in self.inner_properties]\n", "VAR_10 = ', '.join(VAR_9)\n", "if self.required:\n", "return f'Union[{VAR_10}]'\n", "return f'Optional[Union[{VAR_10}]]'\n" ]
[ "def get_type_string(self) ->str:...\n", "\"\"\"docstring\"\"\"\n", "inner_types = [p.get_type_string() for p in self.inner_properties]\n", "inner_prop_string = ', '.join(inner_types)\n", "if self.required:\n", "return f'Union[{inner_prop_string}]'\n", "return f'Optional[Union[{inner_prop_string}]]'\n" ]
[ 0, 0, 0, 0, 5, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Assign'", "Condition", "Return'", "Return'" ]
[ "def FUNC_16(self, VAR_6, VAR_7=None):...\n", "self.request_profile(VAR_6, VAR_7=access_token)\n", "self.request_profile(VAR_6, VAR_8='/displayname', VAR_7=access_token)\n", "self.request_profile(VAR_6, VAR_8='/avatar_url', VAR_7=access_token)\n" ]
[ "def try_fetch_profile(self, expected_code, access_token=None):...\n", "self.request_profile(expected_code, access_token=access_token)\n", "self.request_profile(expected_code, url_suffix='/displayname', access_token\n =access_token)\n", "self.request_profile(expected_code, url_suffix='/avatar_url', access_token=\n access_token)\n" ]
[ 0, 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'", "Expr'" ]
[ "from openapi_python_client import utils\n", "def FUNC_0():...\n", "assert utils.snake_case('HTTP') == 'http'\n", "assert utils.snake_case('HTTP RESPONSE') == 'http_response'\n", "def FUNC_1():...\n", "assert utils.snake_case('HTTPResponse') == 'http_response'\n", "assert utils.snake_case('APIClientHTTPResponse') == 'api_client_http_response'\n", "assert utils.snake_case('OAuthClientHTTPResponse'\n ) == 'o_auth_client_http_response'\n", "def FUNC_2():...\n", "assert utils.snake_case('HttpResponsePascalCase'\n ) == 'http_response_pascal_case'\n", "def FUNC_3():...\n", "assert utils.snake_case('httpResponseLowerCamel'\n ) == 'http_response_lower_camel'\n", "def FUNC_4():...\n", "assert utils.spinal_case('keep_alive') == 'keep-alive'\n" ]
[ "from openapi_python_client import utils\n", "def test_snake_case_uppercase_str():...\n", "assert utils.snake_case('HTTP') == 'http'\n", "assert utils.snake_case('HTTP RESPONSE') == 'http_response'\n", "def test_snake_case_from_pascal_with_acronyms():...\n", "assert utils.snake_case('HTTPResponse') == 'http_response'\n", "assert utils.snake_case('APIClientHTTPResponse') == 'api_client_http_response'\n", "assert utils.snake_case('OAuthClientHTTPResponse'\n ) == 'o_auth_client_http_response'\n", "def test_snake_case_from_pascal():...\n", "assert utils.snake_case('HttpResponsePascalCase'\n ) == 'http_response_pascal_case'\n", "def test_snake_case_from_camel():...\n", "assert utils.snake_case('httpResponseLowerCamel'\n ) == 'http_response_lower_camel'\n", "def test_spinal_case():...\n", "assert utils.spinal_case('keep_alive') == 'keep-alive'\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
[ "ImportFrom'", "FunctionDef'", "Assert'", "Assert'", "FunctionDef'", "Assert'", "Assert'", "Assert'", "FunctionDef'", "Assert'", "FunctionDef'", "Assert'", "FunctionDef'", "Assert'" ]
[ "def FUNC_52():...\n", "self.http_server.stop()\n", "self.io_loop.stop()\n" ]
[ "def _stop():...\n", "self.http_server.stop()\n", "self.io_loop.stop()\n" ]
[ 0, 0, 0 ]
[ "FunctionDef'", "Expr'", "Expr'" ]
[ "def FUNC_3(self, VAR_5, VAR_8):...\n", "return [self._translate_uuid_to_id(VAR_5, img) for img in VAR_8]\n" ]
[ "def _translate_uuids_to_ids(self, context, images):...\n", "return [self._translate_uuid_to_id(context, img) for img in images]\n" ]
[ 0, 0 ]
[ "FunctionDef'", "Return'" ]
[ "def FUNC_16(self, VAR_5):...\n", "\"\"\"docstring\"\"\"\n", "VAR_39 = VAR_1(VAR_12, VAR_5, 'js', 'main.min.js')\n", "if not self.should_run(VAR_5, VAR_39):\n", "log.info('%s up to date' % VAR_39)\n", "log.info('Rebuilding %s' % VAR_39)\n", "return\n", "FUNC_7(['node', 'tools/build-main.js', VAR_5])\n" ]
[ "def build_main(self, name):...\n", "\"\"\"docstring\"\"\"\n", "target = pjoin(static, name, 'js', 'main.min.js')\n", "if not self.should_run(name, target):\n", "log.info('%s up to date' % target)\n", "log.info('Rebuilding %s' % target)\n", "return\n", "run(['node', 'tools/build-main.js', name])\n" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ "FunctionDef'", "Docstring", "Assign'", "Condition", "Expr'", "Expr'", "Return'", "Expr'" ]