docstr: Generate TarInfo using system information
docstr_tok: ["Generate","TarInfo","using","system","information"]
code: def generate_info(
      self, name, size
  ) -> Union[tarfile.TarInfo, zipfile.ZipInfo]:
      """Generate TarInfo using system information"""
      if self.type == "tar":
          tarinfo = tarfile.TarInfo(str(name))
          if os.name == "posix":
              tarinfo.gid = os.getgid()
              tarinfo.uid = os.getuid()
          tarinfo.mtime = datetime.now().timestamp()
          tarinfo.size = size
          # Keep mode as default
          return tarinfo
      elif self.type == "zip":
          zipinfo = zipfile.ZipInfo(
              str(name), datetime.now().timetuple()[:6]
          )
          zipinfo.file_size = size
          return zipinfo
      else:
          raise ValueError(f"Not supported: type={self.type}")
  
imports: import os
  import sys
  import tarfile
  import zipfile
  from datetime import datetime
  from io import BytesIO, TextIOWrapper
  from pathlib import Path
  from typing import Dict, Iterable, Optional, Union
  import yaml
label_desc: Use image node_id 8 for calling the Archiver obj's underlying member method code with example usage: obj.generate_info(name, size) and returns: tarinfo, zipinfo