From a8864fba9fd21f412cd0e2c6e072deeb204049bb Mon Sep 17 00:00:00 2001 From: Zhiguang Li Date: Fri, 15 Mar 2013 10:32:10 +0800 Subject: Add regex support for subcommand forall Filter the project list based on regex or wildcard matching of strings, then we can handle subset of all projects. Change-Id: Ib6c23aec79e7d981f7b6a5eb0ae93c44effec467 Signed-off-by: Zhiguang Li --- command.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'command.py') diff --git a/command.py b/command.py index 959805a2..66a9e74d 100644 --- a/command.py +++ b/command.py @@ -186,6 +186,17 @@ class Command(object): result.sort(key=_getpath) return result + def FindProjects(self, args): + result = [] + for project in self.GetProjects(''): + for arg in args: + pattern = re.compile(r'%s' % arg, re.IGNORECASE) + if pattern.search(project.name) or pattern.search(project.relpath): + result.append(project) + break + result.sort(key=lambda project: project.relpath) + return result + # pylint: disable=W0223 # Pylint warns that the `InteractiveCommand` and `PagedCommand` classes do not # override method `Execute` which is abstract in `Command`. Since that method -- cgit v1.2.3-54-g00ecf