From 7aa7873b4838eff286442000651549ce41294958 Mon Sep 17 00:00:00 2001 From: Shir0kamii Date: Mon, 14 Sep 2015 21:38:27 +0200 Subject: [PATCH] Fixes according to comments by @RaitoBezarius --- zerobin/remove_paste.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/zerobin/remove_paste.py b/zerobin/remove_paste.py index 489f18b..8f60b21 100644 --- a/zerobin/remove_paste.py +++ b/zerobin/remove_paste.py @@ -2,6 +2,9 @@ from zerobin.paste import Paste from clize import run import re +# The regex parse the url and separate the paste's id from the decription key +# After the '/paste/' part, there is several caracters, identified as +# the uuid of the paste. Followed by a '#', the decryption key of the paste. paste_url = re.compile('/paste/(?P.*)#(?P.*)') def unpack_paste(paste): @@ -14,11 +17,11 @@ def unpack_paste(paste): return paste -def remove_paste(*paste_list, quiet:'q'=False): +def remove_paste(*pastes, quiet:'q'=False): """ Remove pastes, given its ID or its URL - paste_list: Liste of paste, given by ID or URL + pastes: List of pastes, given by ID or URL quiet: Don't print anything """ @@ -26,14 +29,14 @@ def remove_paste(*paste_list, quiet:'q'=False): for paste_uuid in map(unpack_paste, paste_list): try: Paste.load(paste_uuid).delete() + + if not quiet: + print('Paste {} is removed'.format(paste_uuid)) except ValueError: if not quiet: print('Paste {} doesn\'t exist'.format(paste_uuid)) - else: - if not quiet: - print('Paste {} is removed'.format(paste_uuid)) def main(): run(remove_paste)