code: def ensure_dir(d):
      
      if not os.path.exists(d):
          try:
              os.makedirs(d)
          except OSError as oe:
              # should not happen with os.makedirs
              # ENOENT: No such file or directory
              if os.errno == errno.ENOENT:
                  msg = twdd("""One or more directories in the path ({}) do not exist. If
                             you are specifying a new directory for output, please ensure
                             all other directories in the path currently exist.""")
                  return msg.format(d)
              else:
                  msg = twdd("""An error occurred trying to create the output directory
                             ({}) with message: {}""")
                  return msg.format(d, oe.strerror)
docs: Check to make sure the supplied directory path does not exist, if so, create it. The
      method catches OSError exceptions and returns a descriptive message instead of
      re-raising the error.
  
      :type d: str
      :param d: It is the full path to a directory.
  
      :return: Does not return anything, but creates a directory path if it doesn't exist
               already.