ソースを参照

Repository,remote: Rename argument of get to 'id'.

Martin Hostettler 8 年 前
コミット
1edff44b3d
2 ファイル変更13 行追加13 行削除
  1. 9 9
      src/borg/remote.py
  2. 4 4
      src/borg/repository.py

+ 9 - 9
src/borg/remote.py

@@ -88,7 +88,7 @@ compatMap = {
     '__len__': (),
     'list': ('limit', 'marker', ),
     'put': ('id', 'data', ),
-    'get': ('id_', ),
+    'get': ('id', ),
     'delete': ('id', ),
     'save_key': ('keydata', ),
     'load_key': (),
@@ -690,12 +690,12 @@ This problem will go away as soon as the server has been upgraded to 1.0.7+.
                     if calls:
                         if is_preloaded:
                             assert cmd == 'get', "is_preload is only supported for 'get'"
-                            if calls[0]['id_'] in self.chunkid_to_msgids:
-                                waiting_for.append(pop_preload_msgid(calls.pop(0)['id_']))
+                            if calls[0]['id'] in self.chunkid_to_msgids:
+                                waiting_for.append(pop_preload_msgid(calls.pop(0)['id']))
                         else:
                             args = calls.pop(0)
-                            if cmd == 'get' and args['id_'] in self.chunkid_to_msgids:
-                                waiting_for.append(pop_preload_msgid(args['id_']))
+                            if cmd == 'get' and args['id'] in self.chunkid_to_msgids:
+                                waiting_for.append(pop_preload_msgid(args['id']))
                             else:
                                 self.msgid += 1
                                 waiting_for.append(self.msgid)
@@ -705,7 +705,7 @@ This problem will go away as soon as the server has been upgraded to 1.0.7+.
                                     self.to_send = msgpack.packb((1, self.msgid, cmd, self.named_to_positional(cmd, args)))
                     if not self.to_send and self.preload_ids:
                         chunk_id = self.preload_ids.pop(0)
-                        args = {'id_': chunk_id}
+                        args = {'id': chunk_id}
                         self.msgid += 1
                         self.chunkid_to_msgids.setdefault(chunk_id, []).append(self.msgid)
                         if self.dictFormat:
@@ -756,12 +756,12 @@ This problem will go away as soon as the server has been upgraded to 1.0.7+.
     def scan(self, limit=None, marker=None):
         """actual remoting is done via self.call in the @api decorator"""
 
-    def get(self, id_):
-        for resp in self.get_many([id_]):
+    def get(self, id):
+        for resp in self.get_many([id]):
             return resp
 
     def get_many(self, ids, is_preloaded=False):
-        for resp in self.call_many('get', [{'id_': id_} for id_ in ids], is_preloaded=is_preloaded):
+        for resp in self.call_many('get', [{'id': id} for id in ids], is_preloaded=is_preloaded):
             yield resp
 
     @api(since=parse_version('1.0.0'))

+ 4 - 4
src/borg/repository.py

@@ -825,14 +825,14 @@ class Repository:
                         return result
         return result
 
-    def get(self, id_):
+    def get(self, id):
         if not self.index:
             self.index = self.open_index(self.get_transaction_id())
         try:
-            segment, offset = self.index[id_]
-            return self.io.read(segment, offset, id_)
+            segment, offset = self.index[id]
+            return self.io.read(segment, offset, id)
         except KeyError:
-            raise self.ObjectNotFound(id_, self.path) from None
+            raise self.ObjectNotFound(id, self.path) from None
 
     def get_many(self, ids, is_preloaded=False):
         for id_ in ids: