nodes: 0, module; 1, function_definition; 2, function_name:zip_currentdir; 3, parameters; 4, type; 5, block; 6, identifier:self; 7, None; 8, expression_statement; 9, with_statement; 10, delete_statement; 11, comment:"""Pack the current working directory in a `zip` file.
  
          |FileManager| subclasses allow for manual packing and automatic
          unpacking of working directories.  The only supported format is `zip`.
          To avoid possible inconsistencies, origin directories and zip
          files are removed after packing or unpacking, respectively.
  
          As an example scenario, we prepare a |FileManager| object with
          the current working directory `folder` containing the files
          `test1.txt` and `text2.txt`:
  
          >>> from hydpy.core.filetools import FileManager
          >>> filemanager = FileManager()
          >>> filemanager.BASEDIR = 'basename'
          >>> filemanager.projectdir = 'projectname'
          >>> import os
          >>> from hydpy import repr_, TestIO
          >>> TestIO.clear()
          >>> basepath = 'projectname/basename'
          >>> with TestIO():
          ...     os.makedirs(basepath)
          ...     filemanager.currentdir = 'folder'
          ...     open(f'{basepath}/folder/file1.txt', 'w').close()
          ...     open(f'{basepath}/folder/file2.txt', 'w').close()
          ...     filemanager.filenames
          ['file1.txt', 'file2.txt']
  
          The directories existing under the base path are identical
          with the ones returned by property |FileManager.availabledirs|:
  
          >>> with TestIO():
          ...     sorted(os.listdir(basepath))
          ...     filemanager.availabledirs    # doctest: +ELLIPSIS
          ['folder']
          Folder2Path(folder=.../projectname/basename/folder)
  
          After packing the current working directory manually, it is
          still counted as a available directory:
  
          >>> with TestIO():
          ...     filemanager.zip_currentdir()
          ...     sorted(os.listdir(basepath))
          ...     filemanager.availabledirs    # doctest: +ELLIPSIS
          ['folder.zip']
          Folder2Path(folder=.../projectname/basename/folder.zip)
  
          Instead of the complete directory, only the contained files
          are packed:
  
          >>> from zipfile import ZipFile
          >>> with TestIO():
          ...     with ZipFile('projectname/basename/folder.zip', 'r') as zp:
          ...         sorted(zp.namelist())
          ['file1.txt', 'file2.txt']
  
          The zip file is unpacked again, as soon as `folder` becomes
          the current working directory:
  
          >>> with TestIO():
          ...     filemanager.currentdir = 'folder'
          ...     sorted(os.listdir(basepath))
          ...     filemanager.availabledirs
          ...     filemanager.filenames    # doctest: +ELLIPSIS
          ['folder']
          Folder2Path(folder=.../projectname/basename/folder)
          ['file1.txt', 'file2.txt']
          """; 12, with_clause; 13, block; 14, attribute; 15, with_item; 16, for_statement; 17, identifier:self; 18, identifier:currentdir; 19, as_pattern; 20, pattern_list; 21, call; 22, block; 23, call; 24, as_pattern_target; 25, identifier:filepath; 26, identifier:filename; 27, identifier:zip; 28, argument_list; 29, expression_statement; 30, attribute; 31, argument_list; 32, identifier:zipfile_; 33, attribute; 34, attribute; 35, call; 36, identifier:zipfile; 37, identifier:ZipFile; 38, string; 39, string; 40, identifier:self; 41, identifier:filepaths; 42, identifier:self; 43, identifier:filenames; 44, attribute; 45, argument_list; 46, interpolation; 47, string_content:.zip; 48, string_content:w; 49, identifier:zipfile_; 50, identifier:write; 51, keyword_argument; 52, keyword_argument; 53, attribute; 54, identifier:filename; 55, identifier:filepath; 56, identifier:arcname; 57, identifier:filename; 58, identifier:self; 59, identifier:currentpath
code: def zip_currentdir(self) -> None:
          """Pack the current working directory in a `zip` file.
  
          |FileManager| subclasses allow for manual packing and automatic
          unpacking of working directories.  The only supported format is `zip`.
          To avoid possible inconsistencies, origin directories and zip
          files are removed after packing or unpacking, respectively.
  
          As an example scenario, we prepare a |FileManager| object with
          the current working directory `folder` containing the files
          `test1.txt` and `text2.txt`:
  
          >>> from hydpy.core.filetools import FileManager
          >>> filemanager = FileManager()
          >>> filemanager.BASEDIR = 'basename'
          >>> filemanager.projectdir = 'projectname'
          >>> import os
          >>> from hydpy import repr_, TestIO
          >>> TestIO.clear()
          >>> basepath = 'projectname/basename'
          >>> with TestIO():
          ...     os.makedirs(basepath)
          ...     filemanager.currentdir = 'folder'
          ...     open(f'{basepath}/folder/file1.txt', 'w').close()
          ...     open(f'{basepath}/folder/file2.txt', 'w').close()
          ...     filemanager.filenames
          ['file1.txt', 'file2.txt']
  
          The directories existing under the base path are identical
          with the ones returned by property |FileManager.availabledirs|:
  
          >>> with TestIO():
          ...     sorted(os.listdir(basepath))
          ...     filemanager.availabledirs    # doctest: +ELLIPSIS
          ['folder']
          Folder2Path(folder=.../projectname/basename/folder)
  
          After packing the current working directory manually, it is
          still counted as a available directory:
  
          >>> with TestIO():
          ...     filemanager.zip_currentdir()
          ...     sorted(os.listdir(basepath))
          ...     filemanager.availabledirs    # doctest: +ELLIPSIS
          ['folder.zip']
          Folder2Path(folder=.../projectname/basename/folder.zip)
  
          Instead of the complete directory, only the contained files
          are packed:
  
          >>> from zipfile import ZipFile
          >>> with TestIO():
          ...     with ZipFile('projectname/basename/folder.zip', 'r') as zp:
          ...         sorted(zp.namelist())
          ['file1.txt', 'file2.txt']
  
          The zip file is unpacked again, as soon as `folder` becomes
          the current working directory:
  
          >>> with TestIO():
          ...     filemanager.currentdir = 'folder'
          ...     sorted(os.listdir(basepath))
          ...     filemanager.availabledirs
          ...     filemanager.filenames    # doctest: +ELLIPSIS
          ['folder']
          Folder2Path(folder=.../projectname/basename/folder)
          ['file1.txt', 'file2.txt']
          """
          with zipfile.ZipFile(f'{self.currentpath}.zip', 'w') as zipfile_:
              for filepath, filename in zip(self.filepaths, self.filenames):
                  zipfile_.write(filename=filepath, arcname=filename)
          del self.currentdir