-
-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathExcept.js
More file actions
78 lines (71 loc) · 2.68 KB
/
Except.js
File metadata and controls
78 lines (71 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Project Name : Visual Python
* Description : GUI-based Python code generator
* File Name : Except.js
* Author : Black Logic
* Note : Logic > except
* License : GNU GPLv3 with Visual Python special exception
* Date : 2021. 11. 18
* Change Date :
*/
//============================================================================
// [CLASS] Except
//============================================================================
define([
'vp_base/js/com/com_String',
'vp_base/js/com/component/PopupComponent',
'vp_base/js/com/component/SuggestInput'
], function(com_String, PopupComponent, SuggestInput) {
/**
* Except
*/
class Except extends PopupComponent {
_init() {
super._init();
/** Write codes executed before rendering */
this.config.dataview = false;
this.config.saveOnly = true;
this.state = {
v1: '',
v2: '',
...this.state
}
}
templateForBody() {
let { v1, v2 } = this.state;
let page = new com_String();
// suggestInput for operator
let errorList = [
'AssertionError', 'SystemError', 'TypeError', 'ModuleNotFoundError',
'BaseException', 'FileNotFoundError', 'ImportError',
'IndexError', 'MemoryError', 'LookupError', 'BufferError',
'EOFError'
];
var suggestInput = new SuggestInput();
suggestInput.setComponentID('v1');
suggestInput.addClass('vp-input vp-state w150 v1');
suggestInput.setSuggestList(function() { return errorList; });
suggestInput.setPlaceholder('Error');
suggestInput.setNormalFilter(false);
suggestInput.setValue(v1);
suggestInput.setSelectEvent(function(selectedValue) {
// trigger change
$(this.wrapSelector()).val(selectedValue);
$(this.wrapSelector()).trigger('change');
});
page.appendLine(suggestInput.toTagString());
page.appendLine('<label style="padding: 0 10px 0 10px;">as</label>');
page.appendFormatLine('<input type="text" id="v2" class="vp-input vp-state w50 v2" value="{0}"/>', v2);
return page.toString();
}
generateCode() {
let { v1, v2 } = this.state;
let asVariableStr = '';
if (v2 != '') {
asVariableStr = ' as ' + v2;
}
return `except ${v1}${asVariableStr}:`;
}
}
return Except;
});