Skip to content

Commit c51a7c4

Browse files
authored
Merge pull request #106 from minjk-bl/devops
Devops
2 parents bd9a8a9 + 26e00ba commit c51a7c4

File tree

7 files changed

+146
-53
lines changed

7 files changed

+146
-53
lines changed

css/common/subsetEditor.css

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,11 @@
242242
margin: auto;
243243
display: inherit;
244244
}
245-
.vp-ds-select-add-btn {
245+
.vp-ds-select-btn-box button {
246246
height: 24px;
247247
background: #FFFFFF;
248248
border: 0.25px solid #E4E4E4;
249-
}
250-
.vp-ds-select-del-btn {
251-
height: 24px;
252-
background: #FFFFFF;
253-
border: 0.25px solid #E4E4E4;
254-
margin-top: 5px;
249+
grid-row-gap: 5px;
255250
}
256251
.vp-ds-btn-add-condition {
257252
width: 95px;

src/api/functions/fileNaviCommand.py

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import os as _vp_os
6+
import stat as _vp_stat
67

78
def _vp_get_userprofile_path():
89
"""
@@ -64,9 +65,17 @@ def _vp_sizeof_fmt(num, suffix='B'):
6465
num /= 1024.0
6566
return '%.1f%s%s' % (num, 'Yi', suffix)
6667

67-
def _vp_search_path(path):
68+
def _vp_search_path(path, show_hidden=False):
6869
"""
6970
Search child folder and file list under the given path
71+
path: str
72+
path to search file/dir list
73+
show_hidden: bool (optional; default: False)
74+
set True for show hidden file/dir
75+
returns: list
76+
list with scanned file/dir list
77+
0 element with current and parent path information
78+
1~n elements with file/dir list under given path
7079
"""
7180
import datetime as _dt
7281
_current = _vp_os.path.abspath(path)
@@ -76,20 +85,21 @@ def _vp_search_path(path):
7685
_info = []
7786
_info.append({'current':_current,'parent':_parent})
7887
for _entry in i:
79-
_name = _entry.name
80-
_path = _entry.path # 파일 경로
81-
_stat = _entry.stat()
82-
_size = _vp_sizeof_fmt(_stat.st_size) # 파일 크기
83-
_a_time = _stat.st_atime # 최근 액세스 시간
84-
_a_dt = _dt.datetime.fromtimestamp(_a_time).strftime('%Y-%m-%d %H:%M')
85-
_m_time = _stat.st_mtime # 최근 수정 시간
86-
_m_dt = _dt.datetime.fromtimestamp(_m_time).strftime('%Y-%m-%d %H:%M')
87-
_e_type = 'other'
88-
if _entry.is_file():
89-
_e_type = 'file'
90-
elif _entry.is_dir():
91-
_e_type = 'dir'
92-
_info.append({'name':_name, 'type':_e_type, 'path':_path, 'size':_size, 'atime':str(_a_dt), 'mtime':str(_m_dt)})
88+
if show_hidden or _vp_check_hidden(_entry.path) == False:
89+
_name = _entry.name
90+
_path = _entry.path # 파일 경로
91+
_stat = _entry.stat()
92+
_size = _vp_sizeof_fmt(_stat.st_size) # 파일 크기
93+
_a_time = _stat.st_atime # 최근 액세스 시간
94+
_a_dt = _dt.datetime.fromtimestamp(_a_time).strftime('%Y-%m-%d %H:%M')
95+
_m_time = _stat.st_mtime # 최근 수정 시간
96+
_m_dt = _dt.datetime.fromtimestamp(_m_time).strftime('%Y-%m-%d %H:%M')
97+
_e_type = 'other'
98+
if _entry.is_file():
99+
_e_type = 'file'
100+
elif _entry.is_dir():
101+
_e_type = 'dir'
102+
_info.append({'name':_name, 'type':_e_type, 'path':_path, 'size':_size, 'atime':str(_a_dt), 'mtime':str(_m_dt)})
93103
return _info
94104

95105
def _vp_get_image_by_path(path):
@@ -104,10 +114,20 @@ def _vp_get_relative_path(start, path):
104114
"""
105115
Get relative path using start path and current path
106116
start: str
107-
start path
117+
start path+
108118
path: str
109119
current path
110120
returns: str
111121
current relative path
112122
"""
113-
return _vp_os.path.relpath(path, start)
123+
return _vp_os.path.relpath(path, start)
124+
125+
def _vp_check_hidden(path):
126+
"""
127+
Check if it's hidden
128+
path: str
129+
file path
130+
returns: bool
131+
True for hidden file/dir, False for others
132+
"""
133+
return bool(_vp_os.stat(path).st_file_attributes & _vp_stat.FILE_ATTRIBUTE_HIDDEN)

src/common/vpBind.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ define([
7272
this.codepreview = undefined;
7373

7474
this.howList = [
75-
{ label: 'Inner', value: 'inner' },
76-
{ label: 'Outer', value: 'outer' },
77-
{ label: 'Left', value: 'left' },
78-
{ label: 'Right', value: 'right' },
79-
{ label: 'Cross', value: 'cross' },
75+
{ label: 'Inner', value: 'inner', desc: 'Inner join' },
76+
{ label: 'Full outer', value: 'outer', desc: 'Full outer join' },
77+
{ label: 'Left outer', value: 'left', desc: 'Left outer join' },
78+
{ label: 'Right outer', value: 'right', desc: 'Right outer join' },
79+
{ label: 'Cross', value: 'cross', desc: 'Cartesian product' },
8080
]
8181
}
8282

@@ -116,13 +116,16 @@ define([
116116

117117
$(this._wrapSelector('#vp_bdHow')).val(merge.how);
118118
this._loadSelectorInput(this._wrapSelector('#vp_bdOn'), merge.on);
119-
if (on && on.length > 0) {
119+
if (merge.on && merge.on.length > 0) {
120120
$(this._wrapSelector('#vp_bdLeftOnSelect')).attr('disabled', true);
121121
$(this._wrapSelector('#vp_bdRightOnSelect')).attr('disabled', true);
122+
$(this._wrapSelector('#vp_bdLeftIndex')).attr('disabled', true);
123+
$(this._wrapSelector('#vp_bdRightIndex')).attr('disabled', true);
122124
}
123125
this._loadSelectorInput(this._wrapSelector('#vp_bdLeftOn'), merge.left.on);
124126
this._loadSelectorInput(this._wrapSelector('#vp_bdRightOn'), merge.right.on);
125-
if (merge.left.on.length > 0 || merge.right.on.length > 0) {
127+
if (merge.left.on.length > 0 || merge.right.on.length > 0
128+
|| merge.left.useIndex || merge.right.useIndex) {
126129
$(this._wrapSelector('#vp_bdOnSelect')).attr('disabled', true);
127130
}
128131

@@ -361,7 +364,7 @@ define([
361364
page.appendFormatLine('<select id="{0}">', 'vp_bdHow');
362365
var savedHow = this.state.merge.how;
363366
this.howList.forEach(how => {
364-
page.appendFormatLine('<option value="{0}"{1}>{2}</option>', how.value, savedHow==how.value?' selected':'', how.label);
367+
page.appendFormatLine('<option value="{0}"{1} title="{2}">{3}</option>', how.value, savedHow==how.value?' selected':'', how.desc, how.label);
365368
});
366369
page.appendLine('</select>');
367370
page.appendLine('</div>');
@@ -666,9 +669,13 @@ define([
666669
if (colList && colList.length > 0) {
667670
$(that._wrapSelector('#vp_bdLeftOnSelect')).attr('disabled', true);
668671
$(that._wrapSelector('#vp_bdRightOnSelect')).attr('disabled', true);
672+
$(that._wrapSelector('#vp_bdLeftIndex')).attr('disabled', true);
673+
$(that._wrapSelector('#vp_bdRightIndex')).attr('disabled', true);
669674
} else {
670675
$(that._wrapSelector('#vp_bdLeftOnSelect')).attr('disabled', false);
671676
$(that._wrapSelector('#vp_bdRightOnSelect')).attr('disabled', false);
677+
$(that._wrapSelector('#vp_bdLeftIndex')).attr('disabled', false);
678+
$(that._wrapSelector('#vp_bdRightIndex')).attr('disabled', false);
672679
}
673680
});
674681

@@ -927,7 +934,7 @@ define([
927934
//================================================================
928935
// On columns
929936
//================================================================
930-
code.appendFormat(', on=[{0}]', on.map(col => col.code));
937+
code.appendFormat(', on=[{0}]', merge.on.map(col => col.code));
931938
} else {
932939
//====================================================================
933940
// Left & Right On columns

src/common/vpCommon.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ define([
298298
iopub: {
299299
output: function(msg) {
300300
// msg.content.data['text/plain']
301-
console.log(msg);
302301
resolve(msg.content.data);
303302
}
304303
}

src/common/vpGroupby.js

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ define([
102102
]
103103

104104
this.methodList = [
105+
{ label: 'None', value: '' },
105106
{ label: 'count', value: 'count' },
106107
{ label: 'first', value: 'first' },
107108
{ label: 'last', value: 'last' },
@@ -134,13 +135,14 @@ define([
134135
_loadState(state) {
135136
var {
136137
variable, groupby, useGrouper, grouperNumber, grouperPeriod,
137-
display, method, advanced, allocateTo, resetIndex,
138+
display, method, advanced, allocateTo, toFrame, resetIndex,
138139
advPageDom, advColList, advNamingList
139140
} = state;
140141

141142
$(this._wrapSelector('#vp_gbVariable')).val(variable);
142143
$(this._wrapSelector('#vp_gbBy')).val(groupby.map(col=>col.code).join(','));
143144
$(this._wrapSelector('#vp_gbBy')).data('list', groupby);
145+
$(this._wrapSelector('#vp_gbResetIndex')).val(resetIndex?'yes':'no');
144146
if (useGrouper) {
145147
$(this._wrapSelector('#vp_gbByGrouper')).removeAttr('disabled');
146148
$(this._wrapSelector('#vp_gbByGrouper')).prop('checked', useGrouper);
@@ -157,7 +159,7 @@ define([
157159
$(this._wrapSelector('#vp_gbAdvanced')).trigger('change');
158160
}
159161
$(this._wrapSelector('#vp_gbAllocateTo')).val(allocateTo);
160-
$(this._wrapSelector('#vp_gbResetIndex')).val(resetIndex?'yes':'no');
162+
$(this._wrapSelector('#vp_gbToFrame')).val(toFrame);
161163

162164
$(this._wrapSelector('.vp-gb-adv-box')).html(advPageDom);
163165

@@ -358,6 +360,7 @@ define([
358360
page.appendLine('<div>');
359361
page.appendFormatLine('<label for="{0}" class="{1}">{2}</label>', 'vp_gbAllocateTo', 'wp80', 'Allocate to');
360362
page.appendFormatLine('<input type="text" id="{0}" placeholder="{1}"/>', 'vp_gbAllocateTo', 'New variable name');
363+
page.appendFormatLine('<label style="display:none;"><input type="checkbox" id="{0}"/><span>{1}</span></label>', 'vp_gbToFrame', 'To DataFrame');
361364
page.appendLine('</div>');
362365

363366
page.appendLine('</div>'); // end of df-box
@@ -618,6 +621,7 @@ define([
618621
$(document).off('change', this._wrapSelector('#vp_gbMethodSelect'));
619622
$(document).off('change', this._wrapSelector('#vp_gbAdvanced'));
620623
$(document).off('change', this._wrapSelector('#vp_gbAllocateTo'));
624+
$(document).off('change', this._wrapSelector('#vp_gbToFrame'));
621625
$(document).off('change', this._wrapSelector('#vp_gbResetIndex'));
622626

623627
$(document).off('click', this._wrapSelector('#vp_gbAdvAdd'));
@@ -716,6 +720,12 @@ define([
716720
$(document).on('change', this._wrapSelector('#vp_gbDisplay'), function(event) {
717721
var colList = event.dataList;
718722
that.state.display = colList;
723+
724+
if (colList && colList.length == 1) {
725+
$(that._wrapSelector('#vp_gbToFrame')).parent().show();
726+
} else {
727+
$(that._wrapSelector('#vp_gbToFrame')).parent().hide();
728+
}
719729
});
720730

721731
// display select button event
@@ -756,6 +766,11 @@ define([
756766
$(document).on('change', this._wrapSelector('#vp_gbAllocateTo'), function() {
757767
that.state.allocateTo = $(this).val();
758768
});
769+
770+
// to dataframe event
771+
$(document).on('change', this._wrapSelector('#vp_gbToFrame'), function() {
772+
that.state.toFrame = $(this).prop('checked') == true;
773+
});
759774

760775
// reset index checkbox event
761776
$(document).on('change', this._wrapSelector('#vp_gbResetIndex'), function() {
@@ -1009,9 +1024,13 @@ define([
10091024
var code = new sb.StringBuilder();
10101025
var {
10111026
variable, groupby, useGrouper, grouperNumber, grouperPeriod,
1012-
display, method, advanced, allocateTo, resetIndex
1027+
display, method, advanced, allocateTo, toFrame, resetIndex
10131028
} = this.state;
10141029

1030+
if (!variable || variable == '') {
1031+
return '';
1032+
}
1033+
10151034
// mapping colList states
10161035
groupby = groupby.map(col => col.code);
10171036
display = display.map(col => col.code);
@@ -1048,13 +1067,13 @@ define([
10481067
//====================================================================
10491068
var colStr = '';
10501069
if (display) {
1051-
if (display.length == 1) {
1052-
// for 1 column
1053-
colStr = '[' + display.join('') + ']';
1054-
} else if (display.length > 1) {
1070+
if (toFrame || display.length > 1) {
10551071
// over 2 columns
10561072
colStr = '[[' + display.join(',') + ']]';
1057-
}
1073+
} else if (display.length == 1) {
1074+
// for 1 column
1075+
colStr = '[' + display.join('') + ']';
1076+
}
10581077
}
10591078

10601079
//====================================================================
@@ -1172,21 +1191,24 @@ define([
11721191
//================================================================
11731192
// Method code generation
11741193
//================================================================
1175-
methodStr.appendFormat('{0}()', method);
1194+
if (method != '') {
1195+
methodStr.appendFormat('{0}()', method);
1196+
}
11761197
}
11771198

1178-
// when using as_index option with Grouper, use .reset_index()
1179-
if (useGrouper && resetIndex) {
1180-
methodStr.append('.reset_index()');
1199+
if (method != '') {
1200+
// when using as_index option with Grouper, use .reset_index()
1201+
if (useGrouper && resetIndex) {
1202+
methodStr.append('.reset_index()');
1203+
}
1204+
// display columns
1205+
code.appendFormat('{0}.{1}', colStr, methodStr.toString());
11811206
}
1182-
// display columns
1183-
code.appendFormat('{0}.{1}', colStr, methodStr.toString());
1184-
1207+
11851208
if (allocateTo && allocateTo != '') {
11861209
code.appendLine();
11871210
code.append(allocateTo);
11881211
}
1189-
11901212
return code.toString();
11911213
}
11921214

0 commit comments

Comments
 (0)