From a66fb1eb5618ec55047e3511fa616d9813d6594b Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 28 May 2024 15:25:38 +0200 Subject: [PATCH 1/2] Update rm tool with usage Signed-off-by: Uilian Ries --- reference/tools/files/basic.rst | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/reference/tools/files/basic.rst b/reference/tools/files/basic.rst index fd253f02a8d5..7aee765e3e61 100644 --- a/reference/tools/files/basic.rst +++ b/reference/tools/files/basic.rst @@ -106,19 +106,26 @@ Usage: conan.tools.files.rm() ---------------------- -.. currentmodule:: conan.tools.files.files +This function removes files from the filesystem. It can be used to remove a single file or a pattern based on fnmatch. +It's indicated to use it instead of ``os.remove`` because it's cross-platform and may avoid permissions issues. -.. autofunction:: rm +.. code-block:: python + :caption: *Remove all files finished in .tmp in build_folder and recursively* + from conan.tools.files import rm -Usage: + rm(self, "*.tmp", self.build_folder, recursive=True, excludes=None) .. code-block:: python + :caption: *Remove all files from bin_folder, except for any finished by .dll* from conan.tools.files import rm - rm(self, "*.tmp", self.build_folder, recursive=True) + rm(self, "*", self.bin_folder, recursive=False, excludes="*.dll") + +.. currentmodule:: conan.tools.files.files +.. autofunction:: rm conan.tools.files.mkdir() @@ -306,7 +313,7 @@ For UNIX libraries starting with **lib**, like *libmath.a*, this tool will colle library name **math**. Regarding symlinks, this tool will keep only the "most generic" file among the resolved real file and all symlinks pointing to this real file. For example among files below, this tool will select *libmath.dylib* file and therefore only append -*math* in the returned list: +*math* in the returned list: .. code-block:: shell From c47dd4144f0e5e44c264410e4fd49db4f3d7aaa9 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 29 May 2024 12:09:36 +0200 Subject: [PATCH 2/2] Use basic rm for basic example. Co-authored-by: Carlos Zoido --- reference/tools/files/basic.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/tools/files/basic.rst b/reference/tools/files/basic.rst index 7aee765e3e61..fe00681378e1 100644 --- a/reference/tools/files/basic.rst +++ b/reference/tools/files/basic.rst @@ -114,7 +114,7 @@ It's indicated to use it instead of ``os.remove`` because it's cross-platform an from conan.tools.files import rm - rm(self, "*.tmp", self.build_folder, recursive=True, excludes=None) + rm(self, "*.tmp", self.build_folder, recursive=True) .. code-block:: python :caption: *Remove all files from bin_folder, except for any finished by .dll*