def ensure_directory_exists(dirname, context=None):
 real_dirname = dirname
 if context:
  real_dirname = realpath_with_context(dirname, context)
 if (not os.path.exists(real_dirname)):
  mas_iterations = 2
  if sys.platform.startswith('win'):
   mas_iterations = 10
  ensure_makedirs(real_dirname, mas_iterations)
 assert os.path.exists(real_dirname), ('ENSURE dir exists: %s' % dirname)
 assert os.path.isdir(real_dirname), ('ENSURE isa dir: %s' % dirname)

def ensure_directory_exists ( dirname , context = None ) : real_dirname = dirname if context : real_dirname = realpath_with_context ( dirname , context ) if ( not os . path . exists ( real_dirname ) ) : mas_iterations = 2 if sys . platform . startswith ( 'win' ) : mas_iterations = 10 ensure_makedirs ( real_dirname , mas_iterations ) assert os . path . exists ( real_dirname ) , ( 'ENSURE dir exists: %s' % dirname ) assert os . path . isdir ( real_dirname ) , ( 'ENSURE isa dir: %s' % dirname )
creates the given directory if it does not already exist .