def _ensure_empty_directory(path):
 if path.exists():
  if (not path.isdir()):
   raise UsageError('{} is not a directory'.format(path.path))
  if path.listdir():
   raise UsageError('{} is not empty'.format(path.path))
  return
 try:
  path.makedirs()
  path.chmod(stat.S_IRWXU)
 except OSError as e:
  raise UsageError('Can not create {}. {}: {}.'.format(path.path, e.filename, e.strerror))

def _ensure_empty_directory ( path ) : if path . exists ( ) : if ( not path . isdir ( ) ) : raise UsageError ( '{} is not a directory' . format ( path . path ) ) if path . listdir ( ) : raise UsageError ( '{} is not empty' . format ( path . path ) ) return try : path . makedirs ( ) path . chmod ( stat . S_IRWXU ) except OSError as e : raise UsageError ( 'Can not create {}. {}: {}.' . format ( path . path , e . filename , e . strerror ) )
the path should not exist or it should be an empty directory .