def delete_directory(path, conditions=None): if not all([c(path) for c in conditions]): return False try: shutil.rmtree(path) return True except Exception, ex: Log.Warn('Unable to remove directory %r - %s', path, ex, exc_info=True)
def delete_file(path, conditions=None): if not all([c(path) for c in conditions]): return False try: os.remove(path) return True except Exception, ex: Log.Warn('Unable to remove file %r - %s', path, ex, exc_info=True)
def delete_directory(path, conditions=None): if not all([c(path) for c in conditions]): return False try: shutil.rmtree(path) return True except Exception as ex: Log.Warn('Unable to remove directory %r - %s', path, ex, exc_info=True) return False
def delete_file(path, conditions=None): if not all([c(path) for c in conditions]): return False try: os.remove(path) return True except Exception as ex: Log.Warn('Unable to remove file %r - %s', path, ex, exc_info=True) return False