Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master, master-1, and master-0

Add some docstrings.

Changeset 1f82f503323a

Parent f99649c01b7b

by Jelmer Vernooij

Changes to one file · Browse files at 1f82f503323a Showing diff from parent f99649c01b7b Diff from another changeset...

 
38
39
40
 
41
42
 
 
 
 
43
44
 
45
46
47
 
65
66
67
68
69
70
 
 
 
71
72
73
74
 
 
 
 
 
75
76
77
 
183
184
185
 
 
 
 
186
187
188
 
191
192
193
 
194
195
 
 
 
 
196
197
198
 
199
200
201
 
202
203
204
205
 
206
207
208
209
210
211
 
212
213
214
 
38
39
40
41
42
43
44
45
46
47
48
 
49
50
51
52
 
70
71
72
 
 
 
73
74
75
76
77
 
 
78
79
80
81
82
83
84
85
 
191
192
193
194
195
196
197
198
199
200
 
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
@@ -38,10 +38,15 @@
 PACKDIR = 'pack'    class ObjectStore(object): + """Object store."""     def __init__(self, path): + """Open an object store. + + :param path: Path of the object store. + """   self.path = path - self._packs = None + self._pack_cache = None   self.pack_dir = os.path.join(self.path, PACKDIR)     def determine_wants_all(self, refs): @@ -65,13 +70,16 @@
  @property   def packs(self):   """List with pack objects.""" - if self._packs is None: - self._packs = list(load_packs(self.pack_dir)) - return self._packs + if self._pack_cache is None: + self._pack_cache = list(load_packs(self.pack_dir)) + return self._pack_cache     def _add_known_pack(self, path): - if self._packs is not None: - self._packs.append(Pack(path)) + """Add a newly appeared pack to the cache by path. + + """ + if self._pack_cache is not None: + self._pack_cache.append(Pack(path))     def _get_shafile_path(self, sha):   dir = sha[:2] @@ -183,6 +191,10 @@
  return f, commit     def add_objects(self, objects): + """Add a set of objects to this object store. + + :param objects: Iterable over a list of objects. + """   if len(objects) == 0:   return   f, commit = self.add_pack() @@ -191,24 +203,33 @@
     class ObjectImporter(object): + """Interface for importing objects."""     def __init__(self, count): + """Create a new ObjectImporter. + + :param count: Number of objects that's going to be imported. + """   self.count = count     def add_object(self, object): + """Add an object."""   raise NotImplementedError(self.add_object)     def finish(self, object): + """Finish the imoprt and write objects to disk."""   raise NotImplementedError(self.finish)      class ObjectIterator(object): + """Interface for iterating over objects."""     def iterobjects(self):   raise NotImplementedError(self.iterobjects)      class ObjectStoreIterator(ObjectIterator): + """ObjectIterator that works on top of an ObjectStore."""     def __init__(self, store, sha_iter):   self.store = store