code: def IsDir(v):
      
      try:
          if v:
              v = str(v)
              return os.path.isdir(v)
          else:
              raise DirInvalid("Not a directory")
      except TypeError:
          raise DirInvalid("Not a directory")
docs: Verify the directory exists.
  
      >>> IsDir()('/')
      '/'
      >>> with raises(DirInvalid, 'Not a directory'):
      ...   IsDir()(None)