@@ -25,7 +25,7 @@ class Task(utils.AutoName):
2525 Make_Video = enum .auto ()
2626 Unknown = enum .auto ()
2727task_names = [x .value for x in Task ]
28- utils .register_type (utils .CustomTypeEntry (Task ,'__enum.Task__' ,str , lambda x : getattr (Task , x .split ('.' )[1 ])))
28+ utils .register_type (utils .CustomTypeEntry (Task ,'__enum.Task__' , utils . enum_val_2_str , lambda x : getattr (Task , x .split ('.' )[1 ])))
2929
3030def get_task_name_friendly (name : str | Task ):
3131 if isinstance (name ,Task ):
@@ -85,12 +85,12 @@ class Status(utils.AutoName):
8585 Finished = enum .auto ()
8686 Errored = enum .auto ()
8787status_names = [x .value for x in Status ]
88- utils .register_type (utils .CustomTypeEntry (Status ,'__enum.Status__' ,str , lambda x : getattr (Status , x .split ('.' )[1 ])))
88+ utils .register_type (utils .CustomTypeEntry (Status ,'__enum.Status__' , utils . enum_val_2_str , lambda x : getattr (Status , x .split ('.' )[1 ])))
8989
9090
9191_status_file = 'glassesValidator.recording'
9292def _create_recording_status_file (file : pathlib .Path ):
93- task_status_dict = {str (getattr (Task ,x )): Status .Not_Started for x in Task .__members__ if x not in ['Not_Imported' , 'Make_Video' , 'Unknown' ]}
93+ task_status_dict = {utils . enum_val_2_str (getattr (Task ,x )): Status .Not_Started for x in Task .__members__ if x not in ['Not_Imported' , 'Make_Video' , 'Unknown' ]}
9494
9595 with open (file , 'w' ) as f :
9696 json .dump (task_status_dict , f , cls = utils .CustomTypeEncoder )
@@ -112,7 +112,7 @@ def get_recording_status(path: str | pathlib.Path, create_if_missing = False, sk
112112def get_last_finished_step (status : dict [str ,Status ]):
113113 last = Task .Not_Imported
114114 while (next_task := get_next_task (last )) is not None :
115- if status [str (next_task )] != Status .Finished :
115+ if status [utils . enum_val_2_str (next_task )] != Status .Finished :
116116 break
117117 last = next_task
118118
@@ -124,11 +124,11 @@ def update_recording_status(path: str | pathlib.Path, task: Task, status: Status
124124 return None
125125
126126 # set status of indicated task
127- rec_status [str (task )] = status
127+ rec_status [utils . enum_val_2_str (task )] = status
128128 # set all later tasks to not started as they would have to be rerun when an earlier tasks is rerun
129129 next_task = task
130130 while (next_task := get_next_task (next_task )) is not None :
131- rec_status [str (next_task )] = Status .Not_Started
131+ rec_status [utils . enum_val_2_str (next_task )] = Status .Not_Started
132132
133133 file = path / _status_file
134134 with open (file , 'w' ) as f :
@@ -140,7 +140,7 @@ def update_recording_status(path: str | pathlib.Path, task: Task, status: Status
140140def readMarkerIntervalsFile (fileName ) -> list [list [int ]]:
141141 analyzeFrames = []
142142 if pathlib .Path (fileName ).is_file ():
143- with open (str ( fileName ) , 'r' ) as f :
143+ with open (fileName , 'r' ) as f :
144144 reader = csv .DictReader (f , delimiter = '\t ' )
145145 for entry in reader :
146146 analyzeFrames .append ([int (float (entry ['start_frame' ])), int (float (entry ['end_frame' ]))])
0 commit comments