several fixes and improvements for handling old relacs files #4

Merged
csachgau merged 10 commits from relacs into master 2020-08-14 15:04:42 +00:00
Showing only changes of commit 31bb53fe31 - Show all commits

View File

@ -312,11 +312,12 @@ class Dataset:
return len(Datasets()) return len(Datasets())
@staticmethod @staticmethod
def find(min_duration=None, experimenter=None, quality=None, min_date=None, max_date=None, test=False): def find(dataset_id=None, min_duration=None, experimenter=None, quality=None, min_date=None, max_date=None, test=False):
"""Find dataset entries in the database. You may restrict the search by providing the following arguments. All restrictions are connected """Find dataset entries in the database. You may restrict the search by providing the following arguments. All restrictions are connected
with a logical AND. with a logical AND.
Args: Args:
dataset_id (str, optional): the id of the given Dataset, if unique, all other restrictions will be ignored. Defaults to None
min_duration (float, optional): minimum duration of the recording session, if not given, any length datasets will be returned. Defaults to None. min_duration (float, optional): minimum duration of the recording session, if not given, any length datasets will be returned. Defaults to None.
experimenter (str, optional): the name of the one who did the recording. The name does not need to be the full name. Defaults to None. experimenter (str, optional): the name of the one who did the recording. The name does not need to be the full name. Defaults to None.
quality (str, optional): the quality assigned to the dataset during recording (e.g. good, fair, poor). Defaults to None. quality (str, optional): the quality assigned to the dataset during recording (e.g. good, fair, poor). Defaults to None.
@ -328,6 +329,10 @@ class Dataset:
int: Count of matching results int: Count of matching results
""" """
dataset_list = Datasets() dataset_list = Datasets()
if dataset_id:
dataset_list = dataset_list & "dataset_id like '%{0:s}%'".format(dataset_id)
if len(dataset_list) == 1:
return [Dataset(tuple=dataset_list.fetch(as_dict=True)[0])], 1
if min_duration: if min_duration:
dataset_list = dataset_list & "duration > %.2f" % min_duration dataset_list = dataset_list & "duration > %.2f" % min_duration
if experimenter: if experimenter: