Example #1
0
 def _save_per_client_data(self):
     data = {
         'keys': self._client_keys.as_dict(),
         'generations': [g.as_dict() for g in self._generations],
     }
     blob = obnamlib.serialise_object(data)
     filename = self._get_filename()
     self._fs.overwrite_file(filename, blob)
Example #2
0
    def _save_data(self):
        blob = obnamlib.serialise_object(self._data)

        bag_store = obnamlib.BagStore()
        bag_store.set_location(self._fs, self.get_dirname())

        blob_store = obnamlib.BlobStore()
        blob_store.set_bag_store(bag_store)
        blob_store.put_well_known_blob(self._well_known_blob, blob)
Example #3
0
 def _save_per_client_data(self):
     data = {
         'whole-file-checksum': self._checksum_algorithm,
         'keys': self._client_keys.as_dict(),
         'generations': [g.as_dict() for g in self._generations],
     }
     blob = obnamlib.serialise_object(data)
     blob_store = self._get_blob_store()
     blob_store.put_well_known_blob(self._well_known_blob, blob)
Example #4
0
 def _save_per_client_data(self):
     data = {
         'whole-file-checksum': self._checksum_algorithm,
         'keys': self._client_keys.as_dict(),
         'generations': [g.as_dict() for g in self._generations],
     }
     blob = obnamlib.serialise_object(data)
     blob_store = self._get_blob_store()
     blob_store.put_well_known_blob(self._well_known_blob, blob)
Example #5
0
    def _save_data(self):
        assert self._data is not None
        blob = obnamlib.serialise_object(self._data)

        bag_store = obnamlib.BagStore()
        bag_store.set_location(self._fs, self.get_dirname())

        blob_store = obnamlib.BlobStore()
        blob_store.set_bag_store(bag_store)
        blob_store.put_well_known_blob(self._well_known_blob, blob)
Example #6
0
 def test_handles_more_complicated_object(self):
     obj = {
         'zero': 0,
         'true': True,
         'string': 'abc\0def',
         'list': ['foo'],
         'dict': {
             'one': 0,
         },
     }
     blob = obnamlib.serialise_object(obj)
     self.assertEqual(obnamlib.deserialise_object(blob), obj)
Example #7
0
 def test_handles_more_complicated_object(self):
     obj = {
         'zero': 0,
         'true': True,
         'string': 'abc\0def',
         'list': ['foo'],
         'dict': {
             'one': 0,
         },
     }
     blob = obnamlib.serialise_object(obj)
     self.assertEqual(obnamlib.deserialise_object(blob), obj)
Example #8
0
    def _save_data(self):
        root = {
            'checksum_algorithm': self._checksum_name,
            'by_chunk_id': self._by_chunk_id_tree.commit(),
            'by_checksum': self._by_checksum_tree.commit(),
            'used_by': self._used_by_tree.commit(),
        }

        blob = obnamlib.serialise_object(root)

        bag_store = obnamlib.BagStore()
        bag_store.set_location(self._fs, self.get_dirname())

        blob_store = obnamlib.BlobStore()
        blob_store.set_bag_store(bag_store)
        blob_store.put_well_known_blob(self._well_known_blob, blob)
Example #9
0
    def _save_data(self):
        root = {
            'checksum_algorithm': self._checksum_name,
            'by_chunk_id': self._by_chunk_id_tree.commit(),
            'by_checksum': self._by_checksum_tree.commit(),
            'used_by': self._used_by_tree.commit(),
        }

        blob = obnamlib.serialise_object(root)

        bag_store = obnamlib.BagStore()
        bag_store.set_location(self._fs, self.get_dirname())

        blob_store = obnamlib.BlobStore()
        blob_store.set_bag_store(bag_store)
        blob_store.put_well_known_blob(self._well_known_blob, blob)
Example #10
0
 def test_handles_dict(self):
     blob = obnamlib.serialise_object({'foo': 'bar'})
     self.assertEqual(obnamlib.deserialise_object(blob), {'foo': 'bar'})
Example #11
0
 def test_handles_list(self):
     blob = obnamlib.serialise_object([1, 2, 3])
     self.assertEqual(obnamlib.deserialise_object(blob), [1, 2, 3])
Example #12
0
 def test_handles_empty_string(self):
     blob = obnamlib.serialise_object('')
     self.assertEqual(obnamlib.deserialise_object(blob), '')
Example #13
0
 def test_handles_None(self):
     blob = obnamlib.serialise_object(None)
     self.assertEqual(obnamlib.deserialise_object(blob), None)
Example #14
0
 def test_handles_a_boolean_false(self):
     blob = obnamlib.serialise_object(False)
     self.assertEqual(obnamlib.deserialise_object(blob), False)
Example #15
0
File: tree.py Project: nom3ad/obnam
 def _put_dir_obj(self, dir_obj):
     dir_obj.set_immutable()
     blob = obnamlib.serialise_object(dir_obj.as_dict())
     return self._blob_store.put_blob(blob)
Example #16
0
 def _put_dir_obj(self, dir_obj):
     dir_obj.set_immutable()
     blob = obnamlib.serialise_object(dir_obj.as_dict())
     return self._blob_store.put_blob(blob)
Example #17
0
 def test_handles_an_int(self):
     blob = obnamlib.serialise_object(42)
     self.assertEqual(obnamlib.deserialise_object(blob), 42)
Example #18
0
 def test_handles_dict(self):
     blob = obnamlib.serialise_object({'foo': 'bar'})
     self.assertEqual(obnamlib.deserialise_object(blob), {'foo': 'bar'})
Example #19
0
 def test_handles_empty_dict(self):
     blob = obnamlib.serialise_object({})
     self.assertEqual(obnamlib.deserialise_object(blob), {})
Example #20
0
 def test_handles_list(self):
     blob = obnamlib.serialise_object([1, 2, 3])
     self.assertEqual(obnamlib.deserialise_object(blob), [1, 2, 3])
Example #21
0
 def test_handles_empty_string(self):
     blob = obnamlib.serialise_object('')
     self.assertEqual(obnamlib.deserialise_object(blob), '')
Example #22
0
 def test_handles_None(self):
     blob = obnamlib.serialise_object(None)
     self.assertEqual(obnamlib.deserialise_object(blob), None)
Example #23
0
 def test_handles_empty_dict(self):
     blob = obnamlib.serialise_object({})
     self.assertEqual(obnamlib.deserialise_object(blob), {})
Example #24
0
 def test_handles_an_int(self):
     blob = obnamlib.serialise_object(42)
     self.assertEqual(obnamlib.deserialise_object(blob), 42)
Example #25
0
def serialise_bag(bag):
    obj = {
        'bag-id': bag.get_id(),
        'blobs': [bag[i] for i in range(len(bag))],
    }
    return obnamlib.serialise_object(obj)
Example #26
0
 def test_handles_a_boolean_true(self):
     blob = obnamlib.serialise_object(True)
     self.assertEqual(obnamlib.deserialise_object(blob), True)
Example #27
0
 def _save_data(self):
     assert self._data is not None
     blob = obnamlib.serialise_object(self._data)
     filename = self._get_filename()
     self._fs.overwrite_file(filename, blob)
Example #28
0
 def test_handles_a_boolean_false(self):
     blob = obnamlib.serialise_object(False)
     self.assertEqual(obnamlib.deserialise_object(blob), False)
Example #29
0
def serialise_bag(bag):
    obj = {
        'bag-id': bag.get_id(),
        'blobs': [bag[i] for i in range(len(bag))],
    }
    return obnamlib.serialise_object(obj)
Example #30
0
 def test_handles_a_boolean_true(self):
     blob = obnamlib.serialise_object(True)
     self.assertEqual(obnamlib.deserialise_object(blob), True)