def deserialize(cls, postproc): return cls( validation.validate_relative_path('"file"', postproc['file']), re.compile(validation.validate_string('"pattern"', postproc['pattern'])), validation.validate_string('"replacement"', postproc['replacement']), validation.validate_nonnegative_int('"count"', postproc.get('count', 0)), )
def deserialize(cls, file): name = validation.validate_relative_path('"name"', file['name']) with validation.deserialization_context('In file "{}"'.format(name)): size = validation.validate_nonnegative_int('"size"', file['size']) with validation.deserialization_context('"checksum"'): checksum = cache.Checksum.deserialize(file['checksum']) with validation.deserialization_context('"source"'): source = file_source.FileSource.deserialize(file['source']) return cls(name, size, checksum, source)