diff --git a/ChangeLog b/ChangeLog index 8b8a462f..68be0477 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-04 Ozan Çağlayan + * pisi/actionsapi/shelltools.py (unlink): Support glob patterns in + unlink(). + 2009-12-21 Gökçen Eraslan * pisi/actionsapi/cmaketools.py: Change CMake build type to RelWithDebInfo to get faster KDE packages. diff --git a/pisi/actionsapi/shelltools.py b/pisi/actionsapi/shelltools.py index a2f76d5a..04911434 100644 --- a/pisi/actionsapi/shelltools.py +++ b/pisi/actionsapi/shelltools.py @@ -90,17 +90,21 @@ def sym(source, destination): except OSError: ctx.ui.error(_('ActionsAPI [sym]: Permission denied: %s to %s') % (source, destination)) -def unlink(filePath): +def unlink(pattern): '''remove the file path''' - if isFile(filePath) or isLink(filePath): - try: - os.unlink(filePath) - except OSError: - ctx.ui.error(_('ActionsAPI [unlink]: Permission denied: %s.') % (filePath)) - elif isDirectory(filePath): - pass - else: - ctx.ui.error(_('ActionsAPI [unlink]: File %s doesn\'t exists.') % (filePath)) + filePathGlob = glob.glob(pattern) + if len(filePathGlob) == 0: + raise FileError(_("No file matched pattern \"%s\". Remove operation failed.") % pattern) + for filePath in filePathGlob: + if isFile(filePath) or isLink(filePath): + try: + os.unlink(filePath) + except OSError: + ctx.ui.error(_('ActionsAPI [unlink]: Permission denied: %s.') % (filePath)) + elif isDirectory(filePath): + pass + else: + ctx.ui.error(_('ActionsAPI [unlink]: File %s doesn\'t exists.') % (filePath)) def unlinkDir(sourceDirectory): '''delete an entire directory tree'''