[elbe-devel] [PATCH] Add wildcard functionality to elbe control get_files

Philipp Arras philipp.arras at linutronix.de
Fri Jun 30 11:20:15 CEST 2017


This patch allows you to view or download files in a project directory based on
a wildcard expression.

Signed-off-by: Philipp Arras <philipp.arras at linutronix.de>
---
 docs/elbe-control.txt        | 4 +++-
 elbepack/commands/control.py | 3 +++
 elbepack/soapclient.py       | 4 ++++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/docs/elbe-control.txt b/docs/elbe-control.txt
index d902bea..511acd7 100644
--- a/docs/elbe-control.txt
+++ b/docs/elbe-control.txt
@@ -110,7 +110,9 @@ Use get_files to retrieve them.
 Get list of files in the <build-dir>.
 +
 If the --output option is specified, the files are downloaded to
-the directory specified in the option.
+the directory specified in the option. If the --matches option is
+specified only files matching the wildcard expression are shown/downloaded.
+Note that you have to put the wildcard expression in quotation marks.
 
 
 'set_cdrom' <build-dir> <iso-img>::
diff --git a/elbepack/commands/control.py b/elbepack/commands/control.py
index c1e8a40..641a212 100755
--- a/elbepack/commands/control.py
+++ b/elbepack/commands/control.py
@@ -68,6 +68,9 @@ def run_command (argv):
                         dest="output", default=None,
                         help="Output files to <directory>" )
 
+    oparser.add_option( "--matches", dest="matches", default=False,
+                        help="Select files based on wildcard expression.")
+
     oparser.add_option( "--pbuilder-only", action="store_true",
                         dest="pbuilder_only", default=False,
                         help="Only list/download pbuilder Files" )
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index 4f0f63d..fe2a764 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -28,6 +28,7 @@ import socket
 import time
 import sys
 import os
+import fnmatch
 
 from datetime import datetime
 import deb822                     # package for dealing with Debian related data
@@ -411,6 +412,9 @@ class GetFilesAction(ClientAction):
             if opt.pbuilder_only and not f.name.startswith ('pbuilder'):
                 continue
 
+            if opt.matches and not fnmatch.fnmatch(f.name, opt.matches):
+                continue
+
             nfiles += 1
             try:
                 print ("%s \t(%s)" % (f.name, f.description))
-- 
2.1.4





More information about the elbe-devel mailing list