def mkdir_with_parents(dir_name):
 pathmembers = dir_name.split(os.sep)
 tmp_stack = []
 while (pathmembers and (not os.path.isdir(deunicodise(os.sep.join(pathmembers))))):
  tmp_stack.append(pathmembers.pop())
 while tmp_stack:
  pathmembers.append(tmp_stack.pop())
  cur_dir = os.sep.join(pathmembers)
  try:
   debug(('mkdir(%s)' % cur_dir))
   os.mkdir(deunicodise(cur_dir))
  except (OSError, IOError) as e:
   debug(("Can not make directory '%s' (Reason: %s)" % (cur_dir, e.strerror)))
   return False
  except Exception as e:
   debug(("Can not make directory '%s' (Reason: %s)" % (cur_dir, e)))
   return False
 return True

def mkdir_with_parents ( dir_name ) : pathmembers = dir_name . split ( os . sep ) tmp_stack = [ ] while ( pathmembers and ( not os . path . isdir ( deunicodise ( os . sep . join ( pathmembers ) ) ) ) ) : tmp_stack . append ( pathmembers . pop ( ) ) while tmp_stack : pathmembers . append ( tmp_stack . pop ( ) ) cur_dir = os . sep . join ( pathmembers ) try : debug ( ( 'mkdir(%s)' % cur_dir ) ) os . mkdir ( deunicodise ( cur_dir ) ) except ( OSError , IOError ) as e : debug ( ( "Can not make directory '%s' (Reason: %s)" % ( cur_dir , e . strerror ) ) ) return False except Exception as e : debug ( ( "Can not make directory '%s' (Reason: %s)" % ( cur_dir , e ) ) ) return False return True
mkdir_with_parents create directory dir_name with all parent directories returns true on success .