class_docstr: An object to manage the profile directory and its resources.
  
  The profile directory is used by all IPython applications, to manage
  configuration, logging and security.
  
  This object knows how to find, create and manage these directories. This
  should be used by any code that wants to handle profiles.
class_docstr_tok: ["An","object","to","manage","the","profile","directory","and","its","resources",".","The","profile","directory","is","used","by","all","IPython","applications",",","to","manage","configuration",",","logging","and","security",".","This","object","knows","how","to","find",",","create","and","manage","these","directories",".","This","should","be","used","by","any","code","that","wants","to","handle","profiles","."]
docstr: ensure a directory exists at a given path
  
  This is a version of os.mkdir, with the following differences:
  
  - returns True if it created the directory, False otherwise
  - ignores EEXIST, protecting against race conditions where
    the dir may have been created in between the check and
    the creation
  - sets permissions if requested and the dir already exists
docstr_tok: ["ensure","a","directory","exists","at","a","given","path","This","is","a","version","of","os.mkdir",",","with","the","following","differences",":","-","returns","True","if","it","created","the","directory",",","False","otherwise","-","ignores","EEXIST",",","protecting","against","race","conditions","where","the","dir","may","have","been","created","in","between","the","check","and","the","creation","-","sets","permissions","if","requested","and","the","dir","already","exists"]
code: def _mkdir(self, path, mode=None):
      """ensure a directory exists at a given path
  
      This is a version of os.mkdir, with the following differences:
  
      - returns True if it created the directory, False otherwise
      - ignores EEXIST, protecting against race conditions where
        the dir may have been created in between the check and
        the creation
      - sets permissions if requested and the dir already exists
      """
      if os.path.exists(path):
          if mode and os.stat(path).st_mode != mode:
              try:
                  os.chmod(path, mode)
              except OSError:
                  self.log.warning(
                      "Could not set permissions on %s", path
                  )
          return False
      try:
          if mode:
              os.mkdir(path, mode)
          else:
              os.mkdir(path)
      except OSError as e:
          if e.errno == errno.EEXIST:
              return False
          else:
              raise
  
      return True
  
imports: import os
  import shutil
  import errno
  from pathlib import Path
  from traitlets.config.configurable import LoggingConfigurable
  from ..paths import get_ipython_package_dir
  from ..utils.path import expand_path, ensure_dir_exists
  from traitlets import Unicode, Bool, observe
label_desc: Use image node_id 2 for calling the ProfileDir obj's underlying member method code with example usage: obj._mkdir(path, mode) and returns: True, False, False