Support glob patterns in shelltools.unlink()

This commit is contained in:
Ozan Çağlayan
2010-01-04 08:00:20 +00:00
parent 4a533ca0bd
commit 528ba418cc
2 changed files with 18 additions and 10 deletions
+4
View File
@@ -1,3 +1,7 @@
2010-01-04 Ozan Çağlayan <ozan@pardus.org.tr>
* pisi/actionsapi/shelltools.py (unlink): Support glob patterns in
unlink().
2009-12-21 Gökçen Eraslan <gokcen@pardus.org.tr>
* pisi/actionsapi/cmaketools.py: Change CMake build type to
RelWithDebInfo to get faster KDE packages.
+14 -10
View File
@@ -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'''