docs: def archive(source, archive, path_in_arc=None, remove_source=False,
              compression=zipfile.ZIP_DEFLATED, compresslevel=-1):
      """Archives a MRIO database as zip file
  
      This function is a wrapper around zipfile.write,
      to ease the writing of an archive and removing the source data.
  
      Note
      ----
      In contrast to zipfile.write, this function raises an
      error if the data (path + filename) are identical in the zip archive.
      Background: the zip standard allows that files with the same name and path
      are stored side by side in a zip file. This becomes an issue when unpacking
      this files as they overwrite each other upon extraction.
  
      Parameters
      ----------
  
      source: str or pathlib.Path or list of these
          Location of the mrio data (folder).
          If not all data should be archived, pass a list of
          all files which should be included in the archive (absolute path)
  
      archive: str or pathlib.Path
          Full path with filename for the archive.
  
      path_in_arc: string, optional
          Path within the archive zip file where data should be stored.
          'path_in_arc' must be given without leading dot and slash.
          Thus to point to the data in the root of the compressed file pass '',
          for data in e.g. the folder 'mrio_v1' pass 'mrio_v1/'.
          If None (default) data will be stored in the root of the archive.
  
      remove_source: boolean, optional
          If True, deletes the source file from the disk (all files
          specified in 'source' or the specified directory, depending if a
          list of files or directory was passed). If False, leaves the
          original files on disk. Also removes all empty directories
          in source including source.
  
      compression: ZIP compression method, optional
          This is passed to zipfile.write. By default it is set to ZIP_DEFLATED.
          NB: This is different from the zipfile default (ZIP_STORED) which would
          not give any compression. See
          https://docs.python.org/3/library/zipfile.html#zipfile-objects for
          further information. Depending on the value given here additional
          modules might be necessary (e.g. zlib for ZIP_DEFLATED). Futher
          information on this can also be found in the zipfile python docs.
  
      compresslevel: int, optional
          This is passed to zipfile.write and specifies the compression level.
          Acceptable values depend on the method specified at the parameter
          'compression'.  By default, it is set to -1 which gives a compromise
          between speed and size for the ZIP_DEFLATED compression (this is
          internally interpreted as 6 as described here:
          https://docs.python.org/3/library/zlib.html#zlib.compressobj )
          NB: This is only used if python version >= 3.7
  
      Raises
      ------
      FileExistsError: In case a file to be archived already present in the
      archive.
  
      """
      archive = Path(archive)
  
      if type(source) is not list:
          source_root = str(source)
          source_files = [f for f in Path(source).glob('**/*') if f.is_file()]
      else:
          source_root = os.path.commonpath([str(f) for f in source])
          source_files = [Path(f) for f in source]
  
      path_in_arc = '' if not path_in_arc else path_in_arc
  
      arc_file_names = {
          str(f): os.path.join(path_in_arc, str(f.relative_to(source_root)))
          for f in source_files}
  
      if archive.exists():
          with zipfile.ZipFile(file=str(archive), mode='r') as zf:
              already_present = zf.namelist()
          duplicates = {ff: zf for ff, zf in arc_file_names.items()
                        if zf in already_present}
  
          if duplicates:
              raise FileExistsError(
                  'These files already exists in {arc} for '
                  'path_in_arc "{pa}":\n  {filelist}'.format(
                      pa=path_in_arc, arc=archive,
                      filelist='\n  '.join(duplicates.values())))
  
      if sys.version_info.major == 3 and sys.version_info.minor >= 7:
          zip_open_para = dict(file=str(archive), mode='a',
                               compression=compression,
                               compresslevel=compresslevel)
      else:
          zip_open_para = dict(file=str(archive), mode='a',
                               compression=compression)
  
      with zipfile.ZipFile(**zip_open_para) as zz:
          for fullpath, zippath in arc_file_names.items():
              zz.write(str(fullpath), str(zippath))
  
      if remove_source:
          for f in source_files:
              os.remove(str(f))
  
          for root, dirs, files in os.walk(source_root, topdown=False):
              for name in dirs:
                  dir_path = os.path.join(root, name)
                  if not os.listdir(dir_path):
                      os.rmdir(os.path.join(root, name))
          try:
              os.rmdir(source_root)
          except OSError:
              pass