This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
forked from thomasvs/morituri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
result.py
176 lines (135 loc) · 4.72 KB
/
result.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# -*- Mode: Python; test-case-name: morituri.test.test_result_result -*-
# vi:si:et:sw=4:sts=4:ts=4
# Morituri - for those about to RIP
# Copyright (C) 2009 Thomas Vander Stichele
# This file is part of morituri.
#
# morituri is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# morituri is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with morituri. If not, see <http://www.gnu.org/licenses/>.
import pkg_resources
import time
class TrackResult:
"""
@type filename: unicode
@ivar testcrc: 4-byte CRC for the test read
@type testcrc: int
@ivar copycrc: 4-byte CRC for the copy read
@type copycrc: int
@var accurip: whether this track's AR CRC was found in the
database, and thus whether the track is considered
accurately ripped.
If false, it can be ripped wrong, not exist in
the database, ...
@type accurip: bool
@var ARCRC: our calculated 4 byte AccurateRip CRC for this
track.
@type ARCRC: int
@var ARDBCRC: the 4-byte AccurateRip CRC this
track did or should have matched in the database.
If None, the track is not in the database.
@type ARDBCRC: int
@var ARDBConfidence: confidence for the matched AccurateRip CRC for
this track in the database.
If None, the track is not in the database.
@var ARDBMaxConfidence: maximum confidence in the AccurateRip database for
this track; can still be 0.
If None, the track is not in the database.
"""
number = None
filename = None
pregap = 0 # in frames
peak = 0.0
quality = 0.0
testspeed = 0.0
copyspeed = 0.0
testduration = 0.0
copyduration = 0.0
testcrc = None
copycrc = None
accurip = False # whether it's in the database
ARCRC = None
ARDBCRC = None
ARDBConfidence = None
ARDBMaxConfidence = None
classVersion = 3
class RipResult:
"""
I hold information about the result for rips.
I can be used to write log files.
@ivar offset: sample read offset
@ivar table: the full index table
@type table: L{morituri.image.table.Table}
@ivar vendor: vendor of the CD drive
@ivar model: model of the CD drive
@ivar release: release of the CD drive
@ivar cdrdaoVersion: version of cdrdao used for the rip
@ivar cdparanoiaVersion: version of cdparanoia used for the rip
"""
offset = 0
table = None
artist = None
title = None
vendor = None
model = None
release = None
cdrdaoVersion = None
cdparanoiaVersion = None
cdparanoiaDefeatsCache = None
gstreamerVersion = None
pyGIVersion = None
encoderVersion = None
profileName = None
profilePipeline = None
classVersion = 3
def __init__(self):
self.tracks = []
def getTrackResult(self, number):
"""
@param number: the track number (0 for HTOA)
@type number: int
@rtype: L{TrackResult}
"""
for t in self.tracks:
if t.number == number:
return t
return None
class Logger(object):
"""
I log the result of a rip.
"""
def log(self, ripResult, epoch=time.time()):
"""
Create a log from the given ripresult.
@param epoch: when the log file gets generated
@type epoch: float
@type ripResult: L{RipResult}
@rtype: str
"""
raise NotImplementedError
# A setuptools-like entry point
class EntryPoint(object):
name = 'morituri'
def load(self):
from morituri.result import logger
return logger.MorituriLogger
def getLoggers():
"""
Get all logger plugins with entry point 'morituri.logger'.
@rtype: dict of C{str} -> C{Logger}
"""
d = {}
pluggables = list(pkg_resources.iter_entry_points("morituri.logger"))
for entrypoint in [EntryPoint(), ] + pluggables:
plugin_class = entrypoint.load()
d[entrypoint.name] = plugin_class
return d