diff options
author | Adrien Sohier | 2015-12-01 19:14:40 +0100 |
---|---|---|
committer | Adrien Sohier | 2015-12-01 19:14:40 +0100 |
commit | 420fcb58c970419003737862178fac52f3fb3098 (patch) | |
tree | f07e2584baf773feac1ce449dba09e65d3240dec | |
parent | 90ebc1a88410fe3534f18fca0614564d12327514 (diff) | |
download | aur-trash-py.tar.gz |
Added 'empty' operation
-rw-r--r-- | .SRCINFO | 2 | ||||
-rw-r--r-- | PKGBUILD | 2 | ||||
-rwxr-xr-x | Trash.py | 12 |
3 files changed, 12 insertions, 4 deletions
@@ -1,6 +1,6 @@ pkgbase = trash-py pkgdesc = A cli trash in python 3 - pkgver = 1.0 + pkgver = 1.1 pkgrel = 1 url = http://www.art-software.fr arch = any @@ -1,7 +1,7 @@ # Maintainer: Adrien Sohier <adrien.sohier@art-software.fr> pkgname=trash-py -pkgver=1.0 +pkgver=1.1 pkgrel=1 pkgdesc='A cli trash in python 3' arch=('any') @@ -1,6 +1,5 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# vim: foldlevel=0 from math import log from os import environ, listdir, mkdir, stat, unlink @@ -91,6 +90,11 @@ def restoreItems(ids): unlink(pathDir+"/{itemId}".format(itemId=item)) print(_("Restored [{itemId}] {itemPath}").format(itemId=item, itemPath=path)) +def emptyTrash(): + call(['rm', '-r', dataDir]) + call(['rm', '-r', pathDir]) + _checkTrashDir_ + def orderIds(): notFound = 0 for num, item in enumerate([int(i) for i in listdir(pathDir)]): @@ -113,7 +117,7 @@ def orderIds(): def showHelp(): print(basename(argv[0])+" [put <path [path [...]]> | list | drop <id [id [...]]> | restore <id [id [...]]> | gc]") - print(_("\n- put:\t\tPut items to trash\n- list:\t\tList trashed items with their id\n- drop:\t\tDrop items from the trash\n- restore:\tRestore items from the trash to their original path\n- gc:\t\tReorder items")) + print(_("\n- put:\t\tPut items to trash\n- list:\t\tList trashed items with their id\n- drop:\t\tDrop items from the trash\n- empty:\tEmpty the trash.\n- restore:\tRestore items from the trash to their original path\n- gc:\t\tReorder items")) ##### Useful stuff ##### def _checkTrashDir_(): @@ -145,6 +149,10 @@ if __name__ == "__main__": while len(args) > 0: arg = args[0] args = args[1:] + + if arg == "empty": + emptyTrash() + break if arg == "put": putToTrash(args) |