code: def _mkdir_for_config(cfg_file=cfg_file):
      
      dirname, filename = os.path.split(cfg_file)
      try:
          os.makedirs(dirname)
      except OSError as exc:
          if exc.errno == errno.EEXIST and os.path.isdir(dirname):
              pass
          else:
              raise
docs: Given a path to a filename, make sure the directory exists