From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id F17EB1382C5 for ; Sat, 20 Feb 2021 21:27:54 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3E813E088B; Sat, 20 Feb 2021 21:27:54 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2808CE088B for ; Sat, 20 Feb 2021 21:27:54 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2C9E233BE99 for ; Sat, 20 Feb 2021 21:27:53 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 78EE44EF for ; Sat, 20 Feb 2021 21:27:50 +0000 (UTC) From: "Matt Turner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Turner" Message-ID: <1613856449.4fd2ac23250ab2ac1f6a506ee433f466a4f9e026.mattst88@gentoo> Subject: [gentoo-commits] proj/catalyst:master commit in: catalyst/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/fileops.py X-VCS-Directories: catalyst/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: 4fd2ac23250ab2ac1f6a506ee433f466a4f9e026 X-VCS-Branch: master Date: Sat, 20 Feb 2021 21:27:50 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 4e8df394-a808-4125-9887-f2de7fabaa9f X-Archives-Hash: 8ab5d39b650a759267d76b11c94624c2 Message-ID: <20210220212750.-Rqld2luYEtNTPyJNWP2P6R6EBRLwjRfBMjIFhjtJAI@z> commit: 4fd2ac23250ab2ac1f6a506ee433f466a4f9e026 Author: Felix Bier rohde-schwarz com> AuthorDate: Sat Feb 13 23:18:17 2021 +0000 Commit: Matt Turner gentoo org> CommitDate: Sat Feb 20 21:27:29 2021 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4fd2ac23 Enable recursive globbing for clear_path This commit enables recursive globbing in clear_path, allowing the usage of '**' to match an arbitrary number of sub-directories. Before this commit, clear_path used only non-recursive globbing. This allowed to use '*' to expand names within one directory, e.g. '/a/*/c' can expand to '/a/b/c', but not '/a/b/b/c'. With this commit, '/a/**/c' can be used to expand to '/a/b/c', '/a/b/b/c', '/a/b/b/b/c' etc. This is motivated by wanting to recursively delete all occurences of a filename with the 'stage4/rm' entry of a spec file. The '/rm' entries are processed with 'clear_path' in the existing code. Additionally, 'glob.glob' is replaced with 'glob.iglob', which returns the same files as 'glob.glob', but as an iterator instead of as a list (so it no longer necessary to hold all matches in memory at once). Recursive globbing has been added in Python 3.5. References: https://docs.python.org/3/library/glob.html#glob.glob https://docs.python.org/3/library/glob.html#glob.iglob Signed-off-by: Felix Bier rohde-schwarz.com> Signed-off-by: Matt Turner gentoo.org> catalyst/fileops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst/fileops.py b/catalyst/fileops.py index 5c6f5cd8..59525420 100644 --- a/catalyst/fileops.py +++ b/catalyst/fileops.py @@ -99,7 +99,7 @@ def clear_dir(target, mode=0o755, remove=False, def clear_path(target_path): """Nuke |target_path| regardless of it being a dir, file or glob.""" - targets = glob.glob(target_path) + targets = glob.iglob(target_path, recursive=True) for path in targets: clear_dir(path, remove=True)