docs: def __save_shadow_copy(self):
          """
          Saves a copy of the stored routine source with pure SQL (if shadow directory is set).
          """
          if not self.shadow_directory:
              return
  
          destination_filename = os.path.join(self.shadow_directory, self._routine_name) + '.sql'
  
          if os.path.realpath(destination_filename) == os.path.realpath(self._source_filename):
              raise LoaderException("Shadow copy will override routine source '{}'".format(self._source_filename))
  
          # Remove the (read only) shadow file if it exists.
          if os.path.exists(destination_filename):
              os.remove(destination_filename)
  
          # Write the shadow file.
          with open(destination_filename, 'wt', encoding=self._routine_file_encoding) as handle:
              handle.write(self._routine_source_code)
  
          # Make the file read only.
          mode = os.stat(self._source_filename)[stat.ST_MODE]
          os.chmod(destination_filename, mode & ~stat.S_IWUSR & ~stat.S_IWGRP & ~stat.S_IWOTH)