Add append option for files from AFS
Allow to open both, .ccl and .dat For #21
This commit is contained in:
parent
67d0af292b
commit
db85eee329
@ -74,10 +74,10 @@ def create():
|
||||
ccl_path = os.path.join(PROPOSAL_PATH, new.strip())
|
||||
ccl_file_list = []
|
||||
for file in os.listdir(ccl_path):
|
||||
if file.endswith(".ccl"):
|
||||
if file.endswith((".ccl", ".dat")):
|
||||
ccl_file_list.append((os.path.join(ccl_path, file), file))
|
||||
ccl_file_select.options = ccl_file_list
|
||||
ccl_file_select.value = ccl_file_list[0][0]
|
||||
file_select.options = ccl_file_list
|
||||
file_select.value = ccl_file_list[0][0]
|
||||
|
||||
proposal_textinput = TextInput(title="Enter proposal number:", default_size=145)
|
||||
proposal_textinput.on_change("value", proposal_textinput_callback)
|
||||
@ -100,16 +100,34 @@ def create():
|
||||
scan_table_source.selected.indices = []
|
||||
scan_table_source.selected.indices = [0]
|
||||
|
||||
def ccl_file_select_callback(_attr, _old, new):
|
||||
def ccl_file_select_callback(_attr, _old, _new):
|
||||
pass
|
||||
|
||||
file_select = Select(title="Available files:")
|
||||
file_select.on_change("value", ccl_file_select_callback)
|
||||
|
||||
def file_open_button_callback():
|
||||
nonlocal det_data
|
||||
with open(new) as file:
|
||||
_, ext = os.path.splitext(new)
|
||||
with open(file_select.value) as file:
|
||||
_, ext = os.path.splitext(file_select.value)
|
||||
det_data = pyzebra.parse_1D(file, ext)
|
||||
|
||||
_init_datatable()
|
||||
|
||||
ccl_file_select = Select(title="Available .ccl files")
|
||||
ccl_file_select.on_change("value", ccl_file_select_callback)
|
||||
file_open_button = Button(label="Open", default_size=100)
|
||||
file_open_button.on_click(file_open_button_callback)
|
||||
|
||||
def file_append_button_callback():
|
||||
with open(file_select.value) as file:
|
||||
_, ext = os.path.splitext(file_select.value)
|
||||
append_data = pyzebra.parse_1D(file, ext)
|
||||
|
||||
pyzebra.unified_merge(det_data, append_data)
|
||||
|
||||
_init_datatable()
|
||||
|
||||
file_append_button = Button(label="Append", default_size=100)
|
||||
file_append_button.on_click(file_append_button_callback)
|
||||
|
||||
def upload_button_callback(_attr, _old, new):
|
||||
nonlocal det_data
|
||||
@ -119,7 +137,7 @@ def create():
|
||||
|
||||
_init_datatable()
|
||||
|
||||
upload_button = FileInput(accept=".ccl")
|
||||
upload_button = FileInput(accept=".ccl,.dat")
|
||||
upload_button.on_change("value", upload_button_callback)
|
||||
|
||||
def append_upload_button_callback(_attr, _old, new):
|
||||
@ -577,10 +595,14 @@ def create():
|
||||
),
|
||||
)
|
||||
|
||||
upload_div = Div(text="Or upload .ccl file:")
|
||||
append_upload_div = Div(text="append extra .ccl/.dat files:")
|
||||
upload_div = Div(text="or upload file:")
|
||||
append_upload_div = Div(text="append extra files:")
|
||||
tab_layout = column(
|
||||
row(proposal_textinput, ccl_file_select),
|
||||
row(
|
||||
proposal_textinput,
|
||||
file_select,
|
||||
column(Spacer(height=19), row(file_open_button, file_append_button)),
|
||||
),
|
||||
row(
|
||||
column(Spacer(height=5), upload_div),
|
||||
upload_button,
|
||||
|
Loading…
x
Reference in New Issue
Block a user