          logger.verbose("Destination format set to '%s'", dst_fmt)
  
          self.serializer = self.get_serializer("", dst_fmt)
          filename = os.path.splitext(self.file)[0]
          self.file = "{}.{}".format(filename, self.serializer.ext)
          logger.debug("Destination file: '%s'", self.file)
  
      def save(self):
          """ Backup copy of old alignments and save new alignments """
          self.backup()
 
</s> remove         try:
            logger.info("Writing alignments to: '%s'", self.file)
            with open(self.file, self.serializer.woptions) as align:
                align.write(self.serializer.marshal(self.data))
            logger.debug("Saved alignments")
        except IOError as err:
            logger.error("'%s' not written: %s", self.file, err.strerror)
 </s> add         logger.info("Writing alignments to: '%s'", self.file)
        self.serializer.save(self.file, self.data)
        logger.debug("Saved alignments") </s> remove         try:
            logger.info("Reading alignments from: '%s'", self.file)
            with open(self.file, self.serializer.roptions) as align:
                data = self.serializer.unmarshal(align.read())
        except IOError as err:
            logger.error("'%s' not read: %s", self.file, err.strerror)
            exit(1)
 </s> add         logger.info("Reading alignments from: '%s'", self.file)
        data = self.serializer.load(self.file) </s> remove                                                    self.serializer.ext))
            logger.debug("File extension set from serializer: '%s'", self.serializer.ext)
 </s> add                                                    self.serializer.file_extension))
            logger.debug("File extension set from serializer: '%s'",
                         self.serializer.file_extension) </s> remove         self.serializer = Serializer.get_serializer("json")
        filename = "{}_state.{}".format(model_name, self.serializer.ext)
 </s> add         self.serializer = get_serializer("json")
        filename = "{}_state.{}".format(model_name, self.serializer.file_extension) </s> remove             retval = Serializer.get_serializer(serializer)
        logger.verbose("Using '%s' serializer for alignments", retval.ext)
 </s> add             retval = get_serializer(serializer)
        logger.verbose("Using '%s' serializer for alignments", retval.file_extension)
        self.file = "{}.{}".format(filename, self.serializer.file_extension)
          logger.verbose("Destination format set to '%s'", dst_fmt)
  
          self.serializer = self.get_serializer("", dst_fmt)
          filename = os.path.splitext(self.file)[0]
        self.file = "{}.{}".format(filename, self.serializer.file_extension)
          logger.debug("Destination file: '%s'", self.file)
  
      def save(self):
          """ Backup copy of old alignments and save new alignments """
          self.backup()
keep keep keep keep replace keep keep keep keep keep
 Standardize serialization (#903)

* Standardize serialization

- Linting
- Standardize serializer use throughout code
- Extend serializer to load and save files
- Always load and save in utf-8
- Create documentation 
tools/lib_alignments/media.py