code: def assure_directory_exists(path, is_file=False):
      
      if is_file:
          path = osp.dirname(path)
      # END handle file
      if not osp.isdir(path):
          os.makedirs(path)
          return True
      return False
docs: Assure that the directory pointed to by path exists.
  
      :param is_file: If True, path is assumed to be a file and handled correctly.
          Otherwise it must be a directory
      :return: True if the directory was created, False if it already existed