Allow serialization of Sectors class

This commit is contained in:
Anders Ingemann 2015-01-03 12:44:32 +01:00
parent b537f2d987
commit f43e2480a5
2 changed files with 11 additions and 0 deletions

View file

@ -149,3 +149,13 @@ class Sectors(object):
raise UnitError('Cannot take modulus of sectors with different sector sizes')
self.bytes %= other.bytes
return self
def __getstate__(self):
return {'__class__': self.__module__ + '.' + self.__class__.__name__,
'sector_size': self.sector_size,
'bytes': self.bytes,
}
def __setstate__(self, state):
self.sector_size = state['sector_size']
self.bytes = state['bytes']

View file

@ -21,6 +21,7 @@ supported_classes = ['bootstrapvz.base.manifest.Manifest',
'bootstrapvz.base.fs.partitions.single.SinglePartition',
'bootstrapvz.base.fs.partitions.unformatted.UnformattedPartition',
'bootstrapvz.common.bytes.Bytes',
'bootstrapvz.common.sectors.Sectors',
]
supported_exceptions = ['bootstrapvz.common.exceptions.ManifestError',