code: def add_directory(self, directory: PathLike, *, load_wdl: bool = True, load_dtz: bool = True) -> int:
          
          num = 0
          directory = os.path.abspath(directory)
  
          for filename in os.listdir(directory):
              path = os.path.join(directory, filename)
              tablename, ext = os.path.splitext(filename)
  
              if is_table_name(tablename) and os.path.isfile(path):
                  if load_wdl:
                      if ext == self.variant.tbw_suffix:
                          num += self._open_table(self.wdl, WdlTable, path)
                      elif "P" not in tablename and ext == self.variant.pawnless_tbw_suffix:
                          num += self._open_table(self.wdl, WdlTable, path)
  
                  if load_dtz:
                      if ext == self.variant.tbz_suffix:
                          num += self._open_table(self.dtz, DtzTable, path)
                      elif "P" not in tablename and ext == self.variant.pawnless_tbz_suffix:
                          num += self._open_table(self.dtz, DtzTable, path)
  
          return num
docs: Adds tables from a directory.
  
          By default all available tables with the correct file names
          (e.g. WDL files like ``KQvKN.rtbw`` and DTZ files like ``KRBvK.rtbz``)
          are added.
  
          The relevant files are lazily opened when the tablebase is actually
          probed.
  
          Returns the number of table files that were found.