103
103
import time_budget_functions
104
104
105
105
106
- __version__ = "6.2"
107
- __version_date__ = "2018-03-26 "
106
+ __version__ = "6.2.1 "
107
+ __version_date__ = "2018-03-28 "
108
108
109
109
if platform .python_version () < "3.5" :
110
110
logging .critical ("BORIS requires Python 3.5+! You are using v. {}" )
@@ -9465,11 +9465,19 @@ def export_tabular_events(self):
9465
9465
def create_behavioral_strings (self , obsId , subj , plot_parameters ):
9466
9466
"""
9467
9467
return the behavioral string for subject in obsId
9468
+
9469
+ Args:
9470
+ obsId (str): observation id
9471
+ subj (str): subject
9472
+ plot_parameters (dict): parameters
9473
+
9474
+ Returns:
9475
+ str: behavioral string for selected subject in selected observation
9468
9476
"""
9469
9477
9470
9478
s = ""
9471
9479
currentStates = []
9472
- eventsWithStatus = project_function .events_start_stop (self .pj [ETHOGRAM ], self .pj [OBSERVATIONS ][obsId ][EVENTS ])
9480
+ eventsWithStatus = project_functions .events_start_stop (self .pj [ETHOGRAM ], self .pj [OBSERVATIONS ][obsId ][EVENTS ])
9473
9481
9474
9482
for event in eventsWithStatus :
9475
9483
if event [EVENT_SUBJECT_FIELD_IDX ] == subj or (subj == NO_FOCAL_SUBJECT and event [EVENT_SUBJECT_FIELD_IDX ] == "" ):
@@ -9511,6 +9519,7 @@ def create_behavioral_strings(self, obsId, subj, plot_parameters):
9511
9519
9512
9520
return s
9513
9521
9522
+
9514
9523
def export_string_events (self ):
9515
9524
"""
9516
9525
export events from selected observations by subject as behavioral strings (plain text file)
@@ -9576,9 +9585,8 @@ def export_string_events(self):
9576
9585
outFile .write (out + "\n " )
9577
9586
9578
9587
except :
9579
- errorMsg = sys .exc_info ()[1 ]
9580
- logging .critical (errorMsg )
9581
- QMessageBox .critical (None , programName , str (errorMsg ), QMessageBox .Ok | QMessageBox .Default , QMessageBox .NoButton )
9588
+ logging .critical (sys .exc_info ()[1 ])
9589
+ QMessageBox .critical (None , programName , str (sys .exc_info ()[1 ]), QMessageBox .Ok | QMessageBox .Default , QMessageBox .NoButton )
9582
9590
9583
9591
9584
9592
def transitions_matrix (self , mode ):
@@ -9605,7 +9613,7 @@ def transitions_matrix(self, mode):
9605
9613
9606
9614
fn = QFileDialog (self ).getSaveFileName (self , "Create matrix of transitions " + mode , "" ,
9607
9615
"Transitions matrix files (*.txt *.tsv);;All files (*)" )
9608
- fileName = fn [0 ] if type (fn ) is tuple else fn
9616
+ fileName = fn [0 ] if type (fn ) is tuple else fn # PyQt4/5
9609
9617
9610
9618
else :
9611
9619
exportDir = QFileDialog (self ).getExistingDirectory (self , "Choose a directory to save the transitions matrices" ,
@@ -9614,6 +9622,7 @@ def transitions_matrix(self, mode):
9614
9622
return
9615
9623
flagMulti = True
9616
9624
9625
+ flag_overwrite_all = False
9617
9626
for subject in plot_parameters ["selected subjects" ]:
9618
9627
9619
9628
logging .debug ("subjects: {}" .format (subject ))
@@ -9643,11 +9652,13 @@ def transitions_matrix(self, mode):
9643
9652
subject = subject ,
9644
9653
mode = mode )
9645
9654
9646
- if os .path .isfile (nf ):
9647
- if dialog .MessageDialog (programName ,
9648
- "A file with same name already exists.<br><b>{}</b>" . format ( nf ),
9649
- [ "Overwrite" , CANCEL ]) == CANCEL :
9655
+ if os .path .isfile (nf ) and not flag_overwrite_all :
9656
+ answer = dialog .MessageDialog (programName , "A file with same name already exists.<br><b>{}</b>" . format ( nf ) ,
9657
+ [ "Overwrite" , "Overwrite all" , CANCEL ])
9658
+ if answer == CANCEL :
9650
9659
continue
9660
+ if answer == "Overwrite all" :
9661
+ flag_overwrite_all = True
9651
9662
9652
9663
with open (nf , "w" ) as outfile :
9653
9664
outfile .write (observed_matrix )
0 commit comments