def remove(ctx, relpath): lektor_cli_ctx = Context() lektor_cli_ctx.load_plugins() env = lektor_cli_ctx.get_env() path = os.path.join(OUTPUT_DIR, relpath) with CliReporter(env, verbosity=0), reporter.build('prune', None): if os.path.exists(path): reporter.report_pruned_artifact(relpath) if os.path.isdir(path): shutil.rmtree(path) else: os.remove(path)
def prune(self, all=False): """This cleans up data left in the build folder that does not correspond to known artifacts. """ with reporter.build(all and 'clean' or 'prune', self): with self.new_build_state() as build_state: for aft in build_state.iter_unreferenced_artifacts(all=all): reporter.report_pruned_artifact(aft) filename = build_state.get_destination_filename(aft) prune_file_and_folder(filename, self.destination_path) build_state.remove_artifact(aft) if all: build_state.vacuum()
def prune(self, all=False): """This cleans up data left in the build folder that does not correspond to known artifacts. """ with reporter.build(all and "clean" or "prune", self): with self.new_build_state() as build_state: for aft in build_state.iter_unreferenced_artifacts(all=all): reporter.report_pruned_artifact(aft) filename = build_state.get_destination_filename(aft) prune_file_and_folder(filename, self.destination_path) build_state.remove_artifact(aft) if all: build_state.vacuum()
def prune(self, all=False): """This cleans up data left in the build folder that does not correspond to known artifacts. """ with reporter.build(all and "clean" or "prune", self): self.env.plugin_controller.emit("before_prune", builder=self, all=all) with self.new_build_state() as build_state: for aft in build_state.iter_unreferenced_artifacts(all=all): reporter.report_pruned_artifact(aft) filename = build_state.get_destination_filename(aft) prune_file_and_folder(filename, self.destination_path) build_state.remove_artifact(aft) build_state.prune_source_infos() if all: build_state.vacuum() self.env.plugin_controller.emit("after_prune", builder=self, all=all)
def prune(self, all=False): """This cleans up data left in the build folder that does not correspond to known artifacts. """ path_cache = PathCache(self.env) with reporter.build(all and "clean" or "prune", self): self.env.plugin_controller.emit("before-prune", builder=self, all=all) with self.new_build_state(path_cache=path_cache) as build_state: for aft in build_state.iter_unreferenced_artifacts(all=all): reporter.report_pruned_artifact(aft) filename = build_state.get_destination_filename(aft) prune_file_and_folder(filename, self.destination_path) build_state.remove_artifact(aft) build_state.prune_source_infos() if all: build_state.vacuum() self.env.plugin_controller.emit("after-prune", builder=self, all=all)