Skip to content
Snippets Groups Projects
Commit 68e92000 authored by Manuel Günther's avatar Manuel Günther
Browse files

Fixed File and FileSet classes and according tests.

parent 72a64a04
No related branches found
No related tags found
No related merge requests found
import os
class File:
"""This class defines the minimum interface of a database file that needs to be exported.
......@@ -34,6 +36,31 @@ class File:
# compare two File objects by comparing their IDs
return self.id < other.id
def make_path(self, directory = None, extension = None):
"""make_path(directory = None, extension = None) -> path
Generates the full path using the given directory and filename extension.
**Parameters:**
directory : str or ``None``
The directory to prepend.
If ``None``, no directory will be preprended.
extension : str or ``None``
The filename extension to append.
If ``None``, no file name extension will be appended.
**Returns:**
path : str
The full path including directory and extension.
"""
if directory is None: directory = '.'
if extension is None: extension = ''
return os.path.join(directory, self.path + extension)
class FileSet:
"""This class defines the minimum interface of a set of database files that needs to be exported.
......@@ -62,6 +89,7 @@ class FileSet:
assert all(f.client_id == self.client_id for f in files)
# The list of files contained in this set
self.files = files
self.path = "+".join(f.path for f in files)
def __lt__(self, other):
"""Defines an order between file sets by using the order of the file set ids."""
......
This diff is collapsed.
This diff is collapsed.
......@@ -41,8 +41,8 @@ class FileSetDatabase (DatabaseBobZT):
def t_model_ids(self, group = 'dev'):
return self.model_ids(group)
def t_enroll_files(self, model_id, group = 'dev'):
return self.enroll_files(model_id, group)
def t_enroll_files(self, t_model_id, group = 'dev'):
return self.enroll_files(t_model_id, group)
def z_probe_files(self, group = 'dev'):
return self.probe_files(None, group)
......
......@@ -188,7 +188,7 @@ def test_verify_fileset():
test_dir = tempfile.mkdtemp(prefix='bobtest_')
# define dummy parameters
parameters = [
'-d', os.path.join(dummy_dir, 'database.py'),
'-d', os.path.join(dummy_dir, 'fileset.py'),
'-p', 'dummy',
'-e', 'bob.bio.base.test.dummy.extractor.DummyExtractor()',
'-a', 'dummy',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment