Commit 87811a90 authored by Manuel Günther's avatar Manuel Günther
Browse files

Fixed py3 binary io issue (now for real)

parent c9a0415c
class File:
"""This class defines the minimum interface of a file that needs to be exported"""
"""This class defines the minimum interface of a database file that needs to be exported.
Each file has a path, an id and an associated client (aka. identity, person, user).
Usually, this file is part of a database, which has a common directory for all files.
The path of this file is usually *relative* to that common directory, and it is usually stored *without* filename extension.
The file id can be anything hashable, but needs to be unique all over the database.
The client id can be anything hashable, but needs to be identical for different files of the same client, and different between clients.
**Parameters:**
file_id : str or int
A unique ID that identifies the file.
This ID might be identical to the ``path``, though integral IDs perform faster.
client_id : str or int
A unique ID that identifies the client (user) to which this file belongs.
This ID might be the name of the person, though integral IDs perform faster.
path : str
The file path of the file, which is relative to the common database directory, and without filename extension.
"""
def __init__(self, file_id, client_id, path):
# The **unique** id of the file
......@@ -10,12 +30,35 @@ class File:
self.path = path
def __lt__(self, other):
"""Defines an order between files by using the order of the file ids."""
# compare two File objects by comparing their IDs
return self.id < other.id
class FileSet:
"""This class defines the minimum interface of a file set that needs to be exported"""
"""This class defines the minimum interface of a set of database files that needs to be exported.
Use this class, whenever the database provides several files that belong to the same probe.
Each file set has an id, an associated client (aka. identity, person, user), and a list of associated files.
Usually, these files are part of a database, which has a common directory for all files.
The paths of this file set are usually *relative* to that common directory, and they are usually stored *without* filename extension.
The file id can be anything hashable, but needs to be unique all over the database.
The client id can be anything hashable, but needs to be identical for different files of the same client, and different between clients.
**Parameters:**
file_id : str or int
A unique ID that identifies the file.
This ID might be identical to the ``path``, though integral IDs perform faster.
client_id : str or int
A unique ID that identifies the client (user) to which this file belongs.
This ID might be the name of the person, though integral IDs perform faster.
path : str
The file path of the file, which is relative to the common database directory, and without filename extension.
"""
def __init__(self, file_set_id, client_id, file_set_name):
# The **unique** id of the file set
......
......@@ -68,7 +68,7 @@ def _open_to_write(score_file, write_compressed):
def _write(f, data, write_compressed):
"""Writes the given data to file, after converting it to the required type."""
if write_compressed:
if sys.version_info[0] <= 2:
if sys.version_info[0] > 2:
data = str.encode(data)
f.write(data)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment