Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite06224b

Browse files
author
minjk-bl
committed
Add ignoreWarning util function
1 parent4fe6bd0 commite06224b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

‎visualpython/js/com/com_util.js‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,31 @@ define([
245245
returnlabel;
246246
}
247247

248+
/**
249+
* Pack the code with ignoring the warnings
250+
*@param {*} code
251+
*/
252+
varignoreWarning=function(code){
253+
varconvertedCode=newcom_String();
254+
convertedCode.appendLine('import warnings');
255+
convertedCode.appendLine('from IPython.display import display');
256+
convertedCode.appendLine('with warnings.catch_warnings():');
257+
convertedCode.appendLine(" warnings.simplefilter('ignore')");
258+
letcodeLines=code.split('\n');
259+
codeLines.forEach((line,idx)=>{
260+
if(idx>0){
261+
convertedCode.appendLine();
262+
}
263+
if(codeLines.length==idx+1){
264+
// last line
265+
convertedCode.appendFormat(" display({0})",line);
266+
}else{
267+
convertedCode.appendFormat(" {0}",line);
268+
}
269+
});
270+
returnconvertedCode.toString();
271+
}
272+
248273
//============================================================================
249274
// Cross-browser RegEx Split
250275
//============================================================================
@@ -377,6 +402,7 @@ define([
377402
setIsAPIListRunCode:setIsAPIListRunCode,
378403
getIsAPIListRunCode:getIsAPIListRunCode,
379404
safeString:safeString,
405+
ignoreWarning:ignoreWarning,
380406

381407
regex_split:regex_split
382408
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp