11
11
)
12
12
13
13
__all__ = ('OInfo' , 'OPackInfo' , 'ODeltaPackInfo' ,
14
- 'OStream' , 'OPackStream' , 'ODeltaPackStream' ,
15
- 'IStream' , 'InvalidOInfo' , 'InvalidOStream' )
14
+ 'OStream' , 'OPackStream' , 'ODeltaPackStream' ,
15
+ 'IStream' , 'InvalidOInfo' , 'InvalidOStream' )
16
16
17
17
#{ ODB Bases
18
18
19
+
19
20
class OInfo (tuple ):
21
+
20
22
"""Carries information about an object in an ODB, provding information
21
23
about the binary sha of the object, the type_string as well as the uncompressed size
22
24
in bytes.
@@ -62,6 +64,7 @@ def size(self):
62
64
63
65
64
66
class OPackInfo (tuple ):
67
+
65
68
"""As OInfo, but provides a type_id property to retrieve the numerical type id, and
66
69
does not include a sha.
67
70
@@ -71,7 +74,7 @@ class OPackInfo(tuple):
71
74
__slots__ = tuple ()
72
75
73
76
def __new__ (cls , packoffset , type , size ):
74
- return tuple .__new__ (cls , (packoffset ,type , size ))
77
+ return tuple .__new__ (cls , (packoffset , type , size ))
75
78
76
79
def __init__ (self , * args ):
77
80
tuple .__init__ (self )
@@ -98,6 +101,7 @@ def size(self):
98
101
99
102
100
103
class ODeltaPackInfo (OPackInfo ):
104
+
101
105
"""Adds delta specific information,
102
106
Either the 20 byte sha which points to some object in the database,
103
107
or the negative offset from the pack_offset, so that pack_offset - delta_info yields
@@ -115,6 +119,7 @@ def delta_info(self):
115
119
116
120
117
121
class OStream (OInfo ):
122
+
118
123
"""Base for object streams retrieved from the database, providing additional
119
124
information about the stream.
120
125
Generally, ODB streams are read-only as objects are immutable"""
@@ -124,7 +129,6 @@ def __new__(cls, sha, type, size, stream, *args, **kwargs):
124
129
"""Helps with the initialization of subclasses"""
125
130
return tuple .__new__ (cls , (sha , type , size , stream ))
126
131
127
-
128
132
def __init__ (self , * args , ** kwargs ):
129
133
tuple .__init__ (self )
130
134
@@ -141,6 +145,7 @@ def stream(self):
141
145
142
146
143
147
class ODeltaStream (OStream ):
148
+
144
149
"""Uses size info of its stream, delaying reads"""
145
150
146
151
def __new__ (cls , sha , type , size , stream , * args , ** kwargs ):
@@ -157,6 +162,7 @@ def size(self):
157
162
158
163
159
164
class OPackStream (OPackInfo ):
165
+
160
166
"""Next to pack object information, a stream outputting an undeltified base object
161
167
is provided"""
162
168
__slots__ = tuple ()
@@ -176,13 +182,13 @@ def stream(self):
176
182
177
183
178
184
class ODeltaPackStream (ODeltaPackInfo ):
185
+
179
186
"""Provides a stream outputting the uncompressed offset delta information"""
180
187
__slots__ = tuple ()
181
188
182
189
def __new__ (cls , packoffset , type , size , delta_info , stream ):
183
190
return tuple .__new__ (cls , (packoffset , type , size , delta_info , stream ))
184
191
185
-
186
192
#{ Stream Reader Interface
187
193
def read (self , size = - 1 ):
188
194
return self [4 ].read (size )
@@ -194,6 +200,7 @@ def stream(self):
194
200
195
201
196
202
class IStream (list ):
203
+
197
204
"""Represents an input content stream to be fed into the ODB. It is mutable to allow
198
205
the ODB to record information about the operations outcome right in this instance.
199
206
@@ -246,7 +253,6 @@ def _binsha(self):
246
253
247
254
binsha = property (_binsha , _set_binsha )
248
255
249
-
250
256
def _type (self ):
251
257
return self [1 ]
252
258
@@ -275,6 +281,7 @@ def _set_stream(self, stream):
275
281
276
282
277
283
class InvalidOInfo (tuple ):
284
+
278
285
"""Carries information about a sha identifying an object which is invalid in
279
286
the queried database. The exception attribute provides more information about
280
287
the cause of the issue"""
@@ -301,6 +308,7 @@ def error(self):
301
308
302
309
303
310
class InvalidOStream (InvalidOInfo ):
311
+
304
312
"""Carries information about an invalid ODB stream"""
305
313
__slots__ = tuple ()
306
314
0 commit comments