Skip to content

Commit

Permalink
protocols management os-agnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
RoccoDAnt committed Oct 27, 2021
1 parent b7b952c commit e6bd8f2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions napari_zelda/napari_zelda.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def mock():
path=os.path.abspath(inspect.getfile(mock))
prot_path=os.path.dirname(os.path.dirname(path))

protocols_file=open(prot_path+'\\napari_zelda'+'\protocols_dict.json', "rb")
protocols_file=open(os.path.join(prot_path,'napari_zelda','protocols_dict.json'), "rb")

protocols_json = json.load(protocols_file)
protocols=list()
Expand All @@ -54,7 +54,7 @@ def mock():
"Plot": "results_widget",
}

protocols_description=open(prot_path+'\\napari_zelda'+'\protocols_description.txt', 'r').read()
protocols_description=open(os.path.join(prot_path,'napari_zelda','protocols_description.txt'), 'r').read()

@magicgui(labels=False,
label={'widget_type':'Label', 'value':"Threshold"},
Expand Down Expand Up @@ -477,7 +477,7 @@ def new_protocol_widget(viewer: 'napari.Viewer',
def save_protocol(self):
np_container = new_protocol_widget[3]
line=new_protocol_widget.np_name.value+'\n'
protocols_history=open(prot_path+'\\napari_zelda'+'\protocols_history.txt','a')
protocols_history=open(os.path.join(prot_path,'napari_zelda','protocols_history.txt'),'a')
protocols_history.write(line)
protocols_history.close()
#add to json
Expand All @@ -488,8 +488,7 @@ def save_protocol(self):
}
np_json_entry["steps"]=[{ "step_number": j+1, "step_name": str(np_container[j].value) } for j in range(0, (new_protocol_widget.np_steps.value))]

protocols_file=open(prot_path+'\\napari_zelda'+'\protocols_dict.json', "r+")

protocols_file=open(os.path.join(prot_path,'napari_zelda'+'protocols_dict.json'), "r+")
protocols_json = json.load(protocols_file)
protocols_json["Protocols"].append(np_json_entry)
protocols_file.seek(0)
Expand Down

0 comments on commit e6bd8f2

Please sign in to comment.