Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.bio.base
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.bio.base
Commits
87811a90
Commit
87811a90
authored
9 years ago
by
Manuel Günther
Browse files
Options
Downloads
Patches
Plain Diff
Fixed py3 binary io issue (now for real)
parent
c9a0415c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/bio/base/database/utils.py
+45
-2
45 additions, 2 deletions
bob/bio/base/database/utils.py
bob/bio/base/tools/scoring.py
+1
-1
1 addition, 1 deletion
bob/bio/base/tools/scoring.py
with
46 additions
and
3 deletions
bob/bio/base/database/utils.py
+
45
−
2
View file @
87811a90
class
File
:
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
):
def
__init__
(
self
,
file_id
,
client_id
,
path
):
# The **unique** id of the file
# The **unique** id of the file
...
@@ -10,12 +30,35 @@ class File:
...
@@ -10,12 +30,35 @@ class File:
self
.
path
=
path
self
.
path
=
path
def
__lt__
(
self
,
other
):
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
# compare two File objects by comparing their IDs
return
self
.
id
<
other
.
id
return
self
.
id
<
other
.
id
class
FileSet
:
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
):
def
__init__
(
self
,
file_set_id
,
client_id
,
file_set_name
):
# The **unique** id of the file set
# The **unique** id of the file set
...
...
This diff is collapsed.
Click to expand it.
bob/bio/base/tools/scoring.py
+
1
−
1
View file @
87811a90
...
@@ -68,7 +68,7 @@ def _open_to_write(score_file, write_compressed):
...
@@ -68,7 +68,7 @@ def _open_to_write(score_file, write_compressed):
def
_write
(
f
,
data
,
write_compressed
):
def
_write
(
f
,
data
,
write_compressed
):
"""
Writes the given data to file, after converting it to the required type.
"""
"""
Writes the given data to file, after converting it to the required type.
"""
if
write_compressed
:
if
write_compressed
:
if
sys
.
version_info
[
0
]
<=
2
:
if
sys
.
version_info
[
0
]
>
2
:
data
=
str
.
encode
(
data
)
data
=
str
.
encode
(
data
)
f
.
write
(
data
)
f
.
write
(
data
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment