code: def save_reg(data):
      '''
      Save the register to msgpack files
      '''
      reg_dir = _reg_dir()
      regfile = os.path.join(reg_dir, 'register')
      try:
          if not os.path.exists(reg_dir):
              os.makedirs(reg_dir)
      except OSError as exc:
          if exc.errno == errno.EEXIST:
              pass
          else:
              raise
      try:
          with salt.utils.files.fopen(regfile, 'a') as fh_:
              salt.utils.msgpack.dump(data, fh_)
      except Exception:
          log.error('Could not write to msgpack file %s', __opts__['outdir'])
          raisf save_reg(data):
      '''
      Save the register to msgpack files
      '''
      reg_dir = _reg_dir()
      regfile = os.path.join(reg_dir, 'register')
      try:
          if not os.path.exists(reg_dir):
              os.makedirs(reg_dir)
      except OSError as exc:
          if exc.errno == errno.EEXIST:
              pass
          else:
              raise
      try:
          with salt.utils.files.fopen(regfile, 'a') as fh_:
              salt.utils.msgpack.dump(data, fh_)
      except Exception:
          log.error('Could not write to msgpack file %s', __opts__['outdir'])
          raise
docs: Save the register to msgpack files