Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.bio.base
Commits
87811a90
Commit
87811a90
authored
Jun 25, 2015
by
Manuel Günther
Browse files
Fixed py3 binary io issue (now for real)
parent
c9a0415c
Changes
2
Hide whitespace changes
Inline
Side-by-side
bob/bio/base/database/utils.py
View file @
87811a90
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
...
...
bob/bio/base/tools/scoring.py
View file @
87811a90
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment