How to use substitute method in lisa

Best Python code snippet using lisa_python

SubstituteExtend.js

Source:SubstituteExtend.js Github

copy

Full Screen

1//=============================================================================2// SubstituteExtend.js3// ----------------------------------------------------------------------------4// (C)2017 Triacontane5// This software is released under the MIT License.6// http://opensource.org/licenses/mit-license.php7// ----------------------------------------------------------------------------8// Version9// 1.1.0 2018/09/09 身代わりを無効にするスキルやアイテムを直接指定できる機能を追加10// 1.0.2 2017/08/22 身代わり条件「必中以外」を無効にした場合でも必中攻撃に対する身代わりが発動しない場合がある問題を修正11// 1.0.1 2017/02/07 端末依存の記述を削除12// 1.0.0 2017/02/05 初版13// ----------------------------------------------------------------------------14// [Blog] : https://triacontane.blogspot.jp/15// [Twitter]: https://twitter.com/triacontane/16// [GitHub] : https://github.com/triacontane/17//=============================================================================18/*:19 * @plugindesc SubstituteExtendPlugin20 * @author triacontane21 *22 * @param CondDying23 * @desc デフォルトの身代わり条件である「瀕死」を有効にします。OFFにすると無効になります。(ON/OFF)24 * @default true25 * @type boolean26 *27 * @param CondNonCertainHit28 * @desc デフォルトの身代わり条件である「必中以外」を有効にします。OFFにすると無効になります。(ON/OFF)29 * @default true30 * @type boolean31 *32 * @help 以下の内容に沿って身代わりの仕様を拡張します。33 *34 * 1. デフォルトの身代わり条件である以下の二つを無効化できます。35 * ・瀕死(残HP25%以下)36 * ・スキルタイプ「必中」以外37 *38 * なお「スキルタイプ「必中」以外」の条件を外すと、防御など無関係の39 * スキルに対しても無差別に「身代わり」が発動するようになります。40 * 注意して設定してください。41 *42 * 2. 身代わりの詳細な発動条件を細かく設定できます。43 * 特徴を有するデータベースのメモ欄に、以下の通り記述してください。44 * メモ欄の「全ての条件」を満たした場合に身代わりが発動します。45 * 基本的に「特徴」の「身代わり」とセットで記述します。46 *47 * なお、特徴を有するデータベースのメモ欄とは48 * アクター、職業、武器、防具、ステート、敵キャラのいずれかのメモ欄です。49 *50 * <SE_実行者HP率:50> # 実行者のHPが50%以上のときのみ発動します。51 * <SE_SubjectHPRate:50> # 同上52 * <SE_対象者HP率:50> # 対象者のHPが50%以下のときのみ発動します。(※1)53 * <SE_TargetHPRate:50> # 同上54 * <SE_身代わり対象限定:1> # 身代わりの対象者を[1]に限定します。(※2)55 * <SE_TargetRestriction:1> # 同上56 * <SE_身代わりスイッチ:4> # スイッチ[4]がONのときのみ発動します。57 * <SE_SubstituteSwitch:4> # 同上58 * <SE_身代わり計算式:f> # 計算式[f]の結果がtrueのときのみ発動します。(※3)59 * <SE_SubstituteFormula:f> # 同上60 *61 * ※1 パラメータからデフォルトの身代わり条件である「瀕死」を62 * 無効にした場合のみ判定します。63 *64 * ※2 <SE_身代わり対象限定:n>のタグの対象者を設定したい場合、65 * 特徴を有するデータベースのメモ欄に以下の通り記述します。66 *67 * <SE_身代わり対象者:1> # <SE_身代わり対象限定:1>の対象になります。68 * <SE_SubstituteTarget:1> # 同上69 *70 * 「身代わり対象限定」で指定したパラメータと一致する場合に身代わり対象になります。71 * 例えば、メモ欄に<SE_身代わり対象限定:2>と記入した場合、同じくメモ欄に72 * <SE_身代わり対象者:2>と記入されている特徴を持つアクターに対してのみ73 * 身代わりを実行します。74 *75 * ※3 上級者向け機能です。76 * また、計算式中で不等号を使いたい場合、以下のように記述してください。77 * < → &lt;78 * > → &gt;79 *80 * 例:<SE_身代わり計算式:\v[2] &gt; 3> # 変数[2]が[3]より大きい場合、発動します。81 *82 * 計算式中では「action」で対象スキルのActionオブジェクトを参照できます。83 * うまく利用すれば身代わりが発動するスキルを細かく限定できます。84 *85 * 以下が記入例です。86 * <SE_身代わり計算式:action.isAttack()> # 通常攻撃のみ身代わり発動87 * <SE_身代わり計算式:action.isPhysical()> # 物理攻撃のみ身代わり発動88 * <SE_身代わり計算式:action.isForOne()> # 単体対象のみ身代わり発動89 *90 * 3. 身代わり発動時に、指定したIDのスキル効果を身代わり実行者に91 * 適用させることができます。92 * <SE_身代わりスキルID:5> # 身代わり発動時にスキル[5]を実行者に適用。(※1)93 * <SE_SubstituteSkillId:5> # 同上94 *95 * ※1 ダメージポップアップやアニメーション等の演出は表示されません。96 *97 * 4. 身代わりを無効にするスキルを個別指定できます。98 * スキルもしくはアイテムのメモ欄に以下の通り指定してください。99 * <SE_身代わり無効>100 * <SE_SubstituteInvalid>101 *102 * このプラグインにはプラグインコマンドはありません。103 *104 * 利用規約:105 * 作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)106 * についても制限はありません。107 * このプラグインはもうあなたのものです。108 *109 * This plugin is released under the MIT License.110 */111/*:ja112 * @plugindesc 身代わり拡張プラグイン113 * @author トリアコンタン114 *115 * @param 身代わり条件_瀕死116 * @desc デフォルトの身代わり条件である「瀕死」を有効にします。OFFにすると無効になります。(ON/OFF)117 * @default true118 * @type boolean119 *120 * @param 身代わり条件_必中以外121 * @desc デフォルトの身代わり条件である「必中以外」を有効にします。OFFにすると無効になります。(ON/OFF)122 * @default true123 * @type boolean124 *125 * @help 以下の内容に沿って身代わりの仕様を拡張します。126 *127 * 1. デフォルトの身代わり条件である以下の二つを無効化できます。128 * ・瀕死(残HP25%以下)129 * ・スキルタイプ「必中」以外130 *131 * なお「スキルタイプ「必中」以外」の条件を外すと、防御など無関係の132 * スキルに対しても無差別に「身代わり」が発動するようになります。133 * 注意して設定してください。134 *135 * 2. 身代わりの詳細な発動条件を細かく設定できます。136 * 特徴を有するデータベースのメモ欄に、以下の通り記述してください。137 * メモ欄の「全ての条件」を満たした場合に身代わりが発動します。138 * 基本的に「特徴」の「身代わり」とセットで記述します。139 *140 * なお、特徴を有するデータベースのメモ欄とは141 * アクター、職業、武器、防具、ステート、敵キャラのいずれかのメモ欄です。142 *143 * <SE_実行者HP率:50> # 実行者のHPが50%以上のときのみ発動します。144 * <SE_SubjectHPRate:50> # 同上145 * <SE_対象者HP率:50> # 対象者のHPが50%以下のときのみ発動します。(※1)146 * <SE_TargetHPRate:50> # 同上147 * <SE_身代わり対象限定:1> # 身代わりの対象者を[1]に限定します。(※2)148 * <SE_TargetRestriction:1> # 同上149 * <SE_身代わりスイッチ:4> # スイッチ[4]がONのときのみ発動します。150 * <SE_SubstituteSwitch:4> # 同上151 * <SE_身代わり計算式:f> # 計算式[f]の結果がtrueのときのみ発動します。(※3)152 * <SE_SubstituteFormula:f> # 同上153 *154 * ※1 パラメータからデフォルトの身代わり条件である「瀕死」を155 * 無効にした場合のみ判定します。156 *157 * ※2 <SE_身代わり対象限定:n>のタグの対象者を設定したい場合、158 * 特徴を有するデータベースのメモ欄に以下の通り記述します。159 *160 * <SE_身代わり対象者:1> # <SE_身代わり対象限定:1>の対象になります。161 * <SE_SubstituteTarget:1> # 同上162 *163 * 「身代わり対象限定」で指定したパラメータと一致する場合に身代わり対象になります。164 * 例えば、メモ欄に<SE_身代わり対象限定:2>と記入した場合、同じくメモ欄に165 * <SE_身代わり対象者:2>と記入されている特徴を持つアクターに対してのみ166 * 身代わりを実行します。167 *168 * ※3 上級者向け機能です。169 * また、計算式中で不等号を使いたい場合、以下のように記述してください。170 * < → &lt;171 * > → &gt;172 *173 * 例:<SE_身代わり計算式:\v[2] &gt; 3> # 変数[2]が[3]より大きい場合、発動します。174 *175 * 計算式中では「action」で対象スキルのActionオブジェクトを参照できます。176 * うまく利用すれば身代わりが発動するスキルを細かく限定できます。177 *178 * 以下が記入例です。179 * <SE_身代わり計算式:action.isAttack()> # 通常攻撃のみ身代わり発動180 * <SE_身代わり計算式:action.isPhysical()> # 物理攻撃のみ身代わり発動181 * <SE_身代わり計算式:action.isForOne()> # 単体対象のみ身代わり発動182 *183 * 3. 身代わり発動時に、指定したIDのスキル効果を身代わり実行者に184 * 適用させることができます。185 * <SE_身代わりスキルID:5> # 身代わり発動時にスキル[5]を実行者に適用。(※1)186 * <SE_SubstituteSkillId:5> # 同上187 *188 * ※1 ダメージポップアップやアニメーション等の演出は表示されません。189 *190 * 4. 身代わりを無効にするスキルを個別指定できます。191 * スキルもしくはアイテムのメモ欄に以下の通り指定してください。192 * <SE_身代わり無効>193 * <SE_SubstituteInvalid>194 *195 * このプラグインにはプラグインコマンドはありません。196 *197 * 利用規約:198 * 作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)199 * についても制限はありません。200 * このプラグインはもうあなたのものです。201 */202(function() {203 'use strict';204 var pluginName = 'SubstituteExtend';205 var metaTagPrefix = 'SE_';206 //=============================================================================207 // ローカル関数208 // プラグインパラメータやプラグインコマンドパラメータの整形やチェックをします209 //=============================================================================210 var getParamString = function(paramNames) {211 if (!Array.isArray(paramNames)) paramNames = [paramNames];212 for (var i = 0; i < paramNames.length; i++) {213 var name = PluginManager.parameters(pluginName)[paramNames[i]];214 if (name) return name;215 }216 return '';217 };218 var getParamBoolean = function(paramNames) {219 var value = getParamString(paramNames);220 return value.toUpperCase() === 'ON' || value.toUpperCase() === 'TRUE';221 };222 var getMetaValue = function(object, name) {223 var metaTagName = metaTagPrefix + name;224 return object.meta.hasOwnProperty(metaTagName) ? convertEscapeCharacters(object.meta[metaTagName]) : undefined;225 };226 var getMetaValues = function(object, names) {227 for (var i = 0, n = names.length; i < n; i++) {228 var value = getMetaValue(object, names[i]);229 if (value !== undefined) return value;230 }231 return undefined;232 };233 var convertEscapeCharacters = function(text) {234 if (text == null) {235 text = '';236 }237 if (text === true) {238 return text;239 }240 var windowLayer = SceneManager._scene._windowLayer;241 return windowLayer ? windowLayer.children[0].convertEscapeCharacters(text) : text;242 };243 var convertEscapeTags = function(text) {244 if (text == null || text === true) text = '';245 text = text.replace(/&gt;?/gi, '>');246 text = text.replace(/&lt;?/gi, '<');247 return text;248 };249 //=============================================================================250 // パラメータの取得と整形251 //=============================================================================252 var param = {};253 param.condDying = getParamBoolean(['CondDying', '身代わり条件_瀕死']);254 param.condNonCertainHit = getParamBoolean(['CondNonCertainHit', '身代わり条件_必中以外']);255 //=============================================================================256 // Game_BattlerBase257 // 身代わりを実行するかどうかの判定を拡張します。258 //=============================================================================259 var _Game_BattlerBase_isSubstitute = Game_BattlerBase.prototype.isSubstitute;260 Game_BattlerBase.prototype.isSubstitute = function() {261 return _Game_BattlerBase_isSubstitute.apply(this, arguments) && this.isSubstituteExtend();262 };263 Game_BattlerBase.prototype.isSubstituteExtend = function() {264 return this.isValidSubstituteHpRate() &&265 (param.condDying || this.isValidSubstituteTargetHpRate()) &&266 this.isValidSubstituteSwitch() &&267 this.isValidSubstituteRestriction() &&268 this.isValidSubstituteFormula() &&269 this.isValidSubstituteSkill();270 };271 Game_BattlerBase.prototype.isValidSubstituteHpRate = function() {272 var subjectHpRate = this.getSubstituteMetaInfo(['SubjectHPRate', '実行者HP率'], true);273 if (subjectHpRate) {274 return this.hpRate() >= subjectHpRate / 100;275 }276 return true;277 };278 Game_BattlerBase.prototype.isValidSubstituteTargetHpRate = function() {279 var targetHpRate = this.getSubstituteMetaInfo(['TargetHPRate', '対象者HP率'], true);280 if (targetHpRate) {281 return BattleManager.checkSubstituteTargetHpRate(targetHpRate);282 }283 return true;284 };285 Game_BattlerBase.prototype.isValidSubstituteRestriction = function() {286 var restrictionId = this.getSubstituteMetaInfo(['TargetRestriction', '身代わり対象限定'], true);287 if (restrictionId) {288 return BattleManager.checkSubstituteRestriction(restrictionId);289 }290 return true;291 };292 Game_BattlerBase.prototype.isValidSubstituteSwitch = function() {293 var switchId = this.getSubstituteMetaInfo(['SubstituteSwitch', '身代わりスイッチ'], true);294 if (switchId) {295 return $gameSwitches.value(switchId);296 }297 return true;298 };299 Game_BattlerBase.prototype.isValidSubstituteFormula = function() {300 var formula = this.getSubstituteMetaInfo(['SubstituteFormula', '身代わり計算式'], false);301 if (formula) {302 var action = BattleManager.getSubstituteAction();303 return eval(convertEscapeTags(formula));304 }305 return true;306 };307 Game_BattlerBase.prototype.isValidSubstituteSkill = function() {308 return !getMetaValues(BattleManager.getSubstituteAction().item(), ['SubstituteInvalid', '身代わり無効']);309 };310 Game_BattlerBase.prototype.isEqualSubstituteRestrictionId = function(restrictionId) {311 var restrictionTargetId = this.getSubstituteMetaInfo(['SubstituteTarget', '身代わり対象者'], true);312 return restrictionTargetId === restrictionId;313 };314 Game_BattlerBase.prototype.getSubstituteSkillId = function() {315 return this.getSubstituteMetaInfo(['SubstituteSkillId', '身代わりスキルID'], true);316 };317 Game_BattlerBase.prototype.getSubstituteMetaInfo = function(tagNames, isNumber) {318 var metaValue;319 this.traitObjects().some(function(traitObject) {320 metaValue = getMetaValues(traitObject, tagNames);321 return !!metaValue;322 });323 return (metaValue && isNumber) ? parseInt(metaValue) : metaValue;324 };325 //=============================================================================326 // BattleManager327 // 身代わり対象者の情報を保持して必要に応じて評価します。328 //=============================================================================329 var _BattleManager_applySubstitute = BattleManager.applySubstitute;330 BattleManager.applySubstitute = function(target) {331 this._substituteTarget = target;332 var substitute = _BattleManager_applySubstitute.apply(this, arguments);333 this._substituteTarget = null;334 if (substitute !== target) {335 this.applySubstituteEffect(substitute);336 }337 return substitute;338 };339 BattleManager.applySubstituteEffect = function(substitute) {340 var skillId = substitute.getSubstituteSkillId();341 if (!skillId) return;342 var action = new Game_Action(substitute);343 action.setSkill(skillId);344 action.apply(substitute);345 };346 BattleManager.checkSubstituteTargetHpRate = function(hpRate) {347 return this._substituteTarget ? this._substituteTarget.hpRate() <= hpRate / 100 : true;348 };349 BattleManager.checkSubstituteRestriction = function(restrictionId) {350 return this._substituteTarget ? this._substituteTarget.isEqualSubstituteRestrictionId(restrictionId) : true;351 };352 BattleManager.getSubstituteAction = function() {353 return this._action;354 };355 var _BattleManager_checkSubstitute = BattleManager.checkSubstitute;356 BattleManager.checkSubstitute = function(target) {357 var resultSubstitute = _BattleManager_checkSubstitute.apply(this, arguments);358 if (!resultSubstitute) {359 return this.checkSubstituteDefault(target);360 }361 return resultSubstitute;362 };363 BattleManager.checkSubstituteDefault = function(target) {364 return this.isValidSubstituteDying(target) && this.isValidSubstituteCertainHit();365 };366 BattleManager.isValidSubstituteDying = function(target) {367 return !param.condDying || target.isDying();368 };369 BattleManager.isValidSubstituteCertainHit = function() {370 return !param.condNonCertainHit || !this._action.isCertainHit();371 };...

Full Screen

Full Screen

substitute-coverage.js

Source:substitute-coverage.js Github

copy

Full Screen

...31 calledFunctions: 0,32 path: "build/substitute/substitute.js",33 code: []34};35_yuitest_coverage["build/substitute/substitute.js"].code=["YUI.add('substitute', function (Y, NAME) {","","/**"," * String variable substitution and string formatting."," * If included, the substitute method is added to the YUI instance."," *"," * @module substitute"," */",""," var L = Y.Lang, DUMP = 'dump', SPACE = ' ', LBRACE = '{', RBRACE = '}',"," savedRegExp = /(~-(\\d+)-~)/g, lBraceRegExp = /\\{LBRACE\\}/g, rBraceRegExp = /\\{RBRACE\\}/g,",""," /**"," * The following methods are added to the YUI instance"," * @class YUI~substitute"," */",""," /**"," Does {placeholder} substitution on a string. The object passed as the"," second parameter provides values to replace the {placeholder}s."," {placeholder} token names must match property names of the object. For"," example",""," `var greeting = Y.substitute(\"Hello, {who}!\", { who: \"World\" });`",""," {placeholder} tokens that are undefined on the object map will be left in"," tact (leaving unsightly \"{placeholder}\"s in the output string). If your"," replacement strings *should* include curly braces, use `{LBRACE}` and"," `{RBRACE}` in your object map string value.",""," If a function is passed as a third argument, it will be called for each"," {placeholder} found. The {placeholder} name is passed as the first value"," and the value from the object map is passed as the second. If the"," {placeholder} contains a space, the first token will be used to identify"," the object map property and the remainder will be passed as a third"," argument to the function. See below for an example."," "," If the value in the object map for a given {placeholder} is an object and"," the `dump` module is loaded, the replacement value will be the string"," result of calling `Y.dump(...)` with the object as input. Include a"," numeric second token in the {placeholder} to configure the depth of the call"," to `Y.dump(...)`, e.g. \"{someObject 2}\". See the"," <a href=\"../classes/YUI.html#method_dump\">`dump`</a> method for details.",""," @method substitute"," @param {string} s The string that will be modified."," @param {object} o An object containing the replacement values."," @param {function} f An optional function that can be used to"," process each match. It receives the key,"," value, and any extra metadata included with"," the key inside of the braces."," @param {boolean} recurse if true, the replacement will be recursive,"," letting you have replacement tokens in replacement text."," The default is false."," @return {string} the substituted string.",""," @example",""," function getAttrVal(key, value, name) {"," // Return a string describing the named attribute and its value if"," // the first token is @. Otherwise, return the value from the"," // replacement object."," if (key === \"@\") {"," value += name + \" Value: \" + myObject.get(name);"," }"," return value;"," }",""," // Assuming myObject.set('foo', 'flowers'),"," // => \"Attr: foo Value: flowers\""," var attrVal = Y.substitute(\"{@ foo}\", { \"@\": \"Attr: \" }, getAttrVal);"," **/",""," substitute = function(s, o, f, recurse) {"," var i, j, k, key, v, meta, saved = [], token, dump,"," lidx = s.length;",""," for (;;) {"," i = s.lastIndexOf(LBRACE, lidx);"," if (i < 0) {"," break;"," }"," j = s.indexOf(RBRACE, i);"," if (i + 1 >= j) {"," break;"," }",""," //Extract key and meta info"," token = s.substring(i + 1, j);"," key = token;"," meta = null;"," k = key.indexOf(SPACE);"," if (k > -1) {"," meta = key.substring(k + 1);"," key = key.substring(0, k);"," }",""," // lookup the value"," v = o[key];",""," // if a substitution function was provided, execute it"," if (f) {"," v = f(key, v, meta);"," }",""," if (L.isObject(v)) {"," if (!Y.dump) {"," v = v.toString();"," } else {"," if (L.isArray(v)) {"," v = Y.dump(v, parseInt(meta, 10));"," } else {"," meta = meta || '';",""," // look for the keyword 'dump', if found force obj dump"," dump = meta.indexOf(DUMP);"," if (dump > -1) {"," meta = meta.substring(4);"," }",""," // use the toString if it is not the Object toString"," // and the 'dump' meta info was not found"," if (v.toString === Object.prototype.toString ||"," dump > -1) {"," v = Y.dump(v, parseInt(meta, 10));"," } else {"," v = v.toString();"," }"," }"," }"," } else if (L.isUndefined(v)) {"," // This {block} has no replace string. Save it for later."," v = '~-' + saved.length + '-~';"," saved.push(token);",""," // break;"," }",""," s = s.substring(0, i) + v + s.substring(j + 1);",""," if (!recurse) {"," lidx = i - 1;"," } "," }"," // restore saved {block}s and escaped braces",""," return s"," .replace(savedRegExp, function (str, p1, p2) {"," return LBRACE + saved[parseInt(p2,10)] + RBRACE;"," })"," .replace(lBraceRegExp, LBRACE)"," .replace(rBraceRegExp, RBRACE)"," ;"," };",""," Y.substitute = substitute;"," L.substitute = substitute;","","","","}, '3.7.3', {\"requires\": [\"yui-base\"], \"optional\": [\"dump\"]});"];36_yuitest_coverage["build/substitute/substitute.js"].lines = {"1":0,"10":0,"75":0,"78":0,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"99":0,"102":0,"103":0,"106":0,"107":0,"108":0,"110":0,"111":0,"113":0,"116":0,"117":0,"118":0,"123":0,"125":0,"127":0,"131":0,"133":0,"134":0,"139":0,"141":0,"142":0,"147":0,"149":0,"156":0,"157":0};37_yuitest_coverage["build/substitute/substitute.js"].functions = {"(anonymous 2):148":0,"substitute:74":0,"(anonymous 1):1":0};38_yuitest_coverage["build/substitute/substitute.js"].coveredLines = 42;39_yuitest_coverage["build/substitute/substitute.js"].coveredFunctions = 3;40_yuitest_coverline("build/substitute/substitute.js", 1);41YUI.add('substitute', function (Y, NAME) {42/**43 * String variable substitution and string formatting.44 * If included, the substitute method is added to the YUI instance.45 *46 * @module substitute47 */48 _yuitest_coverfunc("build/substitute/substitute.js", "(anonymous 1)", 1);49_yuitest_coverline("build/substitute/substitute.js", 10);50var L = Y.Lang, DUMP = 'dump', SPACE = ' ', LBRACE = '{', RBRACE = '}',51 savedRegExp = /(~-(\d+)-~)/g, lBraceRegExp = /\{LBRACE\}/g, rBraceRegExp = /\{RBRACE\}/g,52 /**53 * The following methods are added to the YUI instance54 * @class YUI~substitute55 */56 /**57 Does {placeholder} substitution on a string. The object passed as the58 second parameter provides values to replace the {placeholder}s.59 {placeholder} token names must match property names of the object. For60 example61 `var greeting = Y.substitute("Hello, {who}!", { who: "World" });`62 {placeholder} tokens that are undefined on the object map will be left in63 tact (leaving unsightly "{placeholder}"s in the output string). If your64 replacement strings *should* include curly braces, use `{LBRACE}` and65 `{RBRACE}` in your object map string value.66 If a function is passed as a third argument, it will be called for each67 {placeholder} found. The {placeholder} name is passed as the first value68 and the value from the object map is passed as the second. If the69 {placeholder} contains a space, the first token will be used to identify70 the object map property and the remainder will be passed as a third71 argument to the function. See below for an example.72 73 If the value in the object map for a given {placeholder} is an object and74 the `dump` module is loaded, the replacement value will be the string75 result of calling `Y.dump(...)` with the object as input. Include a76 numeric second token in the {placeholder} to configure the depth of the call77 to `Y.dump(...)`, e.g. "{someObject 2}". See the78 <a href="../classes/YUI.html#method_dump">`dump`</a> method for details.79 @method substitute80 @param {string} s The string that will be modified.81 @param {object} o An object containing the replacement values.82 @param {function} f An optional function that can be used to83 process each match. It receives the key,84 value, and any extra metadata included with85 the key inside of the braces.86 @param {boolean} recurse if true, the replacement will be recursive,87 letting you have replacement tokens in replacement text.88 The default is false.89 @return {string} the substituted string.90 @example91 function getAttrVal(key, value, name) {92 // Return a string describing the named attribute and its value if93 // the first token is @. Otherwise, return the value from the94 // replacement object.95 if (key === "@") {96 value += name + " Value: " + myObject.get(name);97 }98 return value;99 }100 // Assuming myObject.set('foo', 'flowers'),101 // => "Attr: foo Value: flowers"102 var attrVal = Y.substitute("{@ foo}", { "@": "Attr: " }, getAttrVal);103 **/104 substitute = function(s, o, f, recurse) {105 _yuitest_coverfunc("build/substitute/substitute.js", "substitute", 74);106_yuitest_coverline("build/substitute/substitute.js", 75);107var i, j, k, key, v, meta, saved = [], token, dump,108 lidx = s.length;109 _yuitest_coverline("build/substitute/substitute.js", 78);110for (;;) {111 _yuitest_coverline("build/substitute/substitute.js", 79);112i = s.lastIndexOf(LBRACE, lidx);113 _yuitest_coverline("build/substitute/substitute.js", 80);114if (i < 0) {115 _yuitest_coverline("build/substitute/substitute.js", 81);116break;...

Full Screen

Full Screen

table-overview-example.ts

Source:table-overview-example.ts Github

copy

Full Screen

1import {Component, OnInit, ViewChild} from '@angular/core';2import {MatPaginator, MatSort, MatTableDataSource} from '@angular/material';34export interface UserData {5 version: string;6 position: number;7 code: string;8 codeType: string;9 Description:string10}1112const users=[13 {"version":"1.0", "position": 1, "code": "0SRC0LA", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Unicondylar Synthetic Substitute- Uncemented- Open Approach"},14 {"version":"1.0", "position": 2, "code": "0SRC0LZ", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Unicondylar Synthetic Substitute- Open Approach"},15 {"version":"1.0", "position": 3, "code": "0SRC0L9", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Unicondylar Synthetic Substitute- Cemented- Open Approach"},16 {"version":"1.0", "position": 4, "code": "0SRC0JA", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Synthetic Substitute- Uncemented- Open Approach"},17 {"version":"1.0", "position": 5, "code": "0SRC0JZ", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Synthetic Substitute- Open Approach"},18 {"version":"1.0", "position": 6, "code": "0SRC0J9", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Synthetic Substitute- Cemented- Open Approach"},19 {"version":"1.0", "position": 7, "code": "0SRC0KZ", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Nonautologous Tissue Substitute- Open Approach"},20 {"version":"1.0", "position": 7, "code": "0SRC07Z", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Autologous Tissue Substitute- Open Approach"},21 {"version":"1.0", "position": 8, "code": "0SRD0LA", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Unicondylar Synthetic Substitute- Uncemented- Open Approach"},22 {"version":"1.0", "position": 9, "code": "0SRD0LZ", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Unicondylar Synthetic Substitute- Open Approach"},23 {"version":"1.0", "position": 10, "code": "0SRD0L9", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Unicondylar Synthetic Substitute- Cemented- Open Approach"},24 {"version":"1.0", "position": 11, "code": "0SRD0JA", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Synthetic Substitute- Uncemented- Open Approach"},25 {"version":"1.0", "position": 12, "code": "0SRD0JZ", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Synthetic Substitute- Open Approach"},26 {"version":"1.0", "position": 13, "code": "0SRD0J9", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Synthetic Substitute- Cemented- Open Approach"},27 {"version":"1.0", "position": 14, "code": "0SRD0KZ", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Nonautologous Tissue Substitute- Open Approach"},28 {"version":"1.0", "position": 15, "code": "0SRD07Z", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Autologous Tissue Substitute- Open Approach"},29 {"version":"1.0", "position": 16, "code": "0SRT0J9", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint, Femoral Surface with Synthetic Substitute, Cemented, Open Approach"},30 {"version":"1.0", "position": 17, "code": "0SRT0JA", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint, Femoral Surface with Synthetic Substitute, Uncemented, Open Approach"},31 {"version":"1.0", "position": 18, "code": "0SRU0J9", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint, Femoral Surface with Synthetic Substitute, Cemented, Open Approach"},32 {"version":"1.0", "position": 19, "code": "0SRU0JA", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint, Femoral Surface with Synthetic Substitute, Uncemented, Open Approach"},33 {"version":"1.0", "position": 20, "code": "0SRV0J9", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint, Tibial Surface with Synthetic Substitute, Cemented, Open Approach"},34 {"version":"1.0", "position": 21, "code": "0SRV0JA", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint, Tibial Surface with Synthetic Substitute, Uncemented, Open Approach"},35 {"version":"1.0", "position": 22, "code": "0SRW0J9", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint, Tibial Surface with Synthetic Substitute, Cemented, Open Approach"},36 {"version":"1.0", "position": 23, "code": "0SRW0JA", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint, Tibial Surface with Synthetic Substitute, Uncemented, Open Approach"},37 {"version":"1.0", "position": 24, "code": "27447", "codeType": "CPT", "Description": "Total knee replacement"},38 {"version":"1.0", "position": 24, "code": "81.54", "codeType": "ICD9-Procedure", "Description": "Total knee replacement"}39 ,40 {"version":"2.0", "position": 1, "code": "0SRC0LAv2", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Unicondylar Synthetic Substitute- Uncemented- Open Approach"},41 {"version":"2.0", "position": 2, "code": "0SRC0LZ", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Unicondylar Synthetic Substitute- Open Approach"},42 {"version":"2.0", "position": 3, "code": "0SRC0L9", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Unicondylar Synthetic Substitute- Cemented- Open Approach"},43 {"version":"2.0", "position": 4, "code": "0SRC0JA", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Synthetic Substitute- Uncemented- Open Approach"},44 {"version":"2.0", "position": 5, "code": "0SRC0JZ", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Synthetic Substitute- Open Approach"},45 {"version":"2.0", "position": 6, "code": "0SRC0J9", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Synthetic Substitute- Cemented- Open Approach"},46 {"version":"2.0", "position": 7, "code": "0SRC0KZ", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Nonautologous Tissue Substitute- Open Approach"},47 {"version":"2.0", "position": 7, "code": "0SRC07Z", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint with Autologous Tissue Substitute- Open Approach"},48 {"version":"2.0", "position": 8, "code": "0SRD0LA", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Unicondylar Synthetic Substitute- Uncemented- Open Approach"},49 {"version":"2.0", "position": 9, "code": "0SRD0LZ", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Unicondylar Synthetic Substitute- Open Approach"},50 {"version":"2.0", "position": 10, "code": "0SRD0L9", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Unicondylar Synthetic Substitute- Cemented- Open Approach"},51 {"version":"2.0", "position": 11, "code": "0SRD0JA", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Synthetic Substitute- Uncemented- Open Approach"},52 {"version":"2.0", "position": 12, "code": "0SRD0JZ", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Synthetic Substitute- Open Approach"},53 {"version":"2.0", "position": 13, "code": "0SRD0J9", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Synthetic Substitute- Cemented- Open Approach"},54 {"version":"2.0", "position": 14, "code": "0SRD0KZ", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Nonautologous Tissue Substitute- Open Approach"},55 {"version":"2.0", "position": 15, "code": "0SRD07Z", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint with Autologous Tissue Substitute- Open Approach"},56 {"version":"2.0", "position": 16, "code": "0SRT0J9", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint, Femoral Surface with Synthetic Substitute, Cemented, Open Approach"},57 {"version":"2.0", "position": 17, "code": "0SRT0JA", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint, Femoral Surface with Synthetic Substitute, Uncemented, Open Approach"},58 {"version":"2.0", "position": 18, "code": "0SRU0J9", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint, Femoral Surface with Synthetic Substitute, Cemented, Open Approach"},59 {"version":"2.0", "position": 19, "code": "0SRU0JA", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint, Femoral Surface with Synthetic Substitute, Uncemented, Open Approach"},60 {"version":"2.0", "position": 20, "code": "0SRV0J9", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint, Tibial Surface with Synthetic Substitute, Cemented, Open Approach"},61 {"version":"2.0", "position": 21, "code": "0SRV0JA", "codeType": "ICD10-PCS", "Description": "Replacement of Right Knee Joint, Tibial Surface with Synthetic Substitute, Uncemented, Open Approach"},62 {"version":"2.0", "position": 22, "code": "0SRW0J9", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint, Tibial Surface with Synthetic Substitute, Cemented, Open Approach"},63 {"version":"2.0", "position": 23, "code": "0SRW0JA", "codeType": "ICD10-PCS", "Description": "Replacement of Left Knee Joint, Tibial Surface with Synthetic Substitute, Uncemented, Open Approach"},64 {"version":"2.0", "position": 24, "code": "27447", "codeType": "CPT", "Description": "Total knee replacement"},65 {"version":"2.0", "position": 24, "code": "81.54", "codeType": "ICD9-Procedure", "Description": "Total knee replacement"}]6667/**68 * @title Data table with sorting, pagination, and filtering.69 */70@Component({71 selector: 'table-overview-example',72 styleUrls: ['table-overview-example.css'],73 templateUrl: 'table-overview-example.html',74})75export class TableOverviewExample implements OnInit {76 versions=["1.0","2.0"]77 displayedColumns: string[] = ['position', 'code', 'codeType', 'Description'];78 columnsToDisplay: string[] = this.displayedColumns.slice();7980 dataSource: MatTableDataSource<UserData>;8182 @ViewChild(MatPaginator) paginator: MatPaginator;83 @ViewChild(MatSort) sort: MatSort;8485 constructor() {86 // Create 100 users87 8889 // Assign the data to the data source for the table to render90 this.dataSource = new MatTableDataSource(users);91 }9293 ngOnInit() {94 this.dataSource.paginator = this.paginator;95 this.dataSource.sort = this.sort;96 }9798 applyFilter(filterValue: string) {99 console.log(filterValue);100 this.dataSource.filter = filterValue.trim().toLowerCase();101102 if (this.dataSource.paginator) {103 this.dataSource.paginator.firstPage();104 }105 }106}107108109110111/** Copyright 2018 Google Inc. All Rights Reserved.112 Use of this source code is governed by an MIT-style license that ...

Full Screen

Full Screen

test_pep292.py

Source:test_pep292.py Github

copy

Full Screen

...16 return obj17class TestTemplate(unittest.TestCase):18 def test_regular_templates(self):19 s = Template('$who likes to eat a bag of $what worth $$100')20 self.assertEqual(s.substitute(dict(who='tim', what='ham')),21 'tim likes to eat a bag of ham worth $100')22 self.assertRaises(KeyError, s.substitute, dict(who='tim'))23 def test_regular_templates_with_braces(self):24 s = Template('$who likes ${what} for ${meal}')25 d = dict(who='tim', what='ham', meal='dinner')26 self.assertEqual(s.substitute(d), 'tim likes ham for dinner')27 self.assertRaises(KeyError, s.substitute,28 dict(who='tim', what='ham'))29 def test_escapes(self):30 eq = self.assertEqual31 s = Template('$who likes to eat a bag of $$what worth $$100')32 eq(s.substitute(dict(who='tim', what='ham')),33 'tim likes to eat a bag of $what worth $100')34 s = Template('$who likes $$')35 eq(s.substitute(dict(who='tim', what='ham')), 'tim likes $')36 def test_percents(self):37 eq = self.assertEqual38 s = Template('%(foo)s $foo ${foo}')39 d = dict(foo='baz')40 eq(s.substitute(d), '%(foo)s baz baz')41 eq(s.safe_substitute(d), '%(foo)s baz baz')42 def test_stringification(self):43 eq = self.assertEqual44 s = Template('tim has eaten $count bags of ham today')45 d = dict(count=7)46 eq(s.substitute(d), 'tim has eaten 7 bags of ham today')47 eq(s.safe_substitute(d), 'tim has eaten 7 bags of ham today')48 s = Template('tim has eaten ${count} bags of ham today')49 eq(s.substitute(d), 'tim has eaten 7 bags of ham today')50 def test_tupleargs(self):51 eq = self.assertEqual52 s = Template('$who ate ${meal}')53 d = dict(who=('tim', 'fred'), meal=('ham', 'kung pao'))54 eq(s.substitute(d), "('tim', 'fred') ate ('ham', 'kung pao')")55 eq(s.safe_substitute(d), "('tim', 'fred') ate ('ham', 'kung pao')")56 def test_SafeTemplate(self):57 eq = self.assertEqual58 s = Template('$who likes ${what} for ${meal}')59 eq(s.safe_substitute(dict(who='tim')), 'tim likes ${what} for ${meal}')60 eq(s.safe_substitute(dict(what='ham')), '$who likes ham for ${meal}')61 eq(s.safe_substitute(dict(what='ham', meal='dinner')),62 '$who likes ham for dinner')63 eq(s.safe_substitute(dict(who='tim', what='ham')),64 'tim likes ham for ${meal}')65 eq(s.safe_substitute(dict(who='tim', what='ham', meal='dinner')),66 'tim likes ham for dinner')67 def test_invalid_placeholders(self):68 raises = self.assertRaises69 s = Template('$who likes $')70 raises(ValueError, s.substitute, dict(who='tim'))71 s = Template('$who likes ${what)')72 raises(ValueError, s.substitute, dict(who='tim'))73 s = Template('$who likes $100')74 raises(ValueError, s.substitute, dict(who='tim'))75 def test_idpattern_override(self):76 class PathPattern(Template):77 idpattern = r'[_a-z][._a-z0-9]*'78 m = Mapping()79 m.bag = Bag()80 m.bag.foo = Bag()81 m.bag.foo.who = 'tim'82 m.bag.what = 'ham'83 s = PathPattern('$bag.foo.who likes to eat a bag of $bag.what')84 self.assertEqual(s.substitute(m), 'tim likes to eat a bag of ham')85 def test_pattern_override(self):86 class MyPattern(Template):87 pattern = r"""88 (?P<escaped>@{2}) |89 @(?P<named>[_a-z][._a-z0-9]*) |90 @{(?P<braced>[_a-z][._a-z0-9]*)} |91 (?P<invalid>@)92 """93 m = Mapping()94 m.bag = Bag()95 m.bag.foo = Bag()96 m.bag.foo.who = 'tim'97 m.bag.what = 'ham'98 s = MyPattern('@bag.foo.who likes to eat a bag of @bag.what')99 self.assertEqual(s.substitute(m), 'tim likes to eat a bag of ham')100 class BadPattern(Template):101 pattern = r"""102 (?P<badname>.*) |103 (?P<escaped>@{2}) |104 @(?P<named>[_a-z][._a-z0-9]*) |105 @{(?P<braced>[_a-z][._a-z0-9]*)} |106 (?P<invalid>@) |107 """108 s = BadPattern('@bag.foo.who likes to eat a bag of @bag.what')109 self.assertRaises(ValueError, s.substitute, {})110 self.assertRaises(ValueError, s.safe_substitute, {})111 def test_unicode_values(self):112 s = Template('$who likes $what')113 d = dict(who=u't\xffm', what=u'f\xfe\fed')114 self.assertEqual(s.substitute(d), u't\xffm likes f\xfe\x0ced')115 def test_keyword_arguments(self):116 eq = self.assertEqual117 s = Template('$who likes $what')118 eq(s.substitute(who='tim', what='ham'), 'tim likes ham')119 eq(s.substitute(dict(who='tim'), what='ham'), 'tim likes ham')120 eq(s.substitute(dict(who='fred', what='kung pao'),121 who='tim', what='ham'),122 'tim likes ham')123 s = Template('the mapping is $mapping')124 eq(s.substitute(dict(foo='none'), mapping='bozo'),125 'the mapping is bozo')126 eq(s.substitute(dict(mapping='one'), mapping='two'),127 'the mapping is two')128 def test_keyword_arguments_safe(self):129 eq = self.assertEqual130 raises = self.assertRaises131 s = Template('$who likes $what')132 eq(s.safe_substitute(who='tim', what='ham'), 'tim likes ham')133 eq(s.safe_substitute(dict(who='tim'), what='ham'), 'tim likes ham')134 eq(s.safe_substitute(dict(who='fred', what='kung pao'),135 who='tim', what='ham'),136 'tim likes ham')137 s = Template('the mapping is $mapping')138 eq(s.safe_substitute(dict(foo='none'), mapping='bozo'),139 'the mapping is bozo')140 eq(s.safe_substitute(dict(mapping='one'), mapping='two'),141 'the mapping is two')142 d = dict(mapping='one')143 raises(TypeError, s.substitute, d, {})144 raises(TypeError, s.safe_substitute, d, {})145 def test_delimiter_override(self):146 eq = self.assertEqual147 raises = self.assertRaises148 class AmpersandTemplate(Template):149 delimiter = '&'150 s = AmpersandTemplate('this &gift is for &{who} &&')151 eq(s.substitute(gift='bud', who='you'), 'this bud is for you &')152 raises(KeyError, s.substitute)153 eq(s.safe_substitute(gift='bud', who='you'), 'this bud is for you &')154 eq(s.safe_substitute(), 'this &gift is for &{who} &')155 s = AmpersandTemplate('this &gift is for &{who} &')156 raises(ValueError, s.substitute, dict(gift='bud', who='you'))157 eq(s.safe_substitute(), 'this &gift is for &{who} &')158 class PieDelims(Template):159 delimiter = '@'160 s = PieDelims('@who likes to eat a bag of @{what} worth $100')161 self.assertEqual(s.substitute(dict(who='tim', what='ham')),162 'tim likes to eat a bag of ham worth $100')163def test_main():164 from test import test_support165 test_classes = [TestTemplate,]166 test_support.run_unittest(*test_classes)167if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful