Fixes according to comments by @RaitoBezarius

This commit is contained in:
Shir0kamii 2015-09-14 21:38:27 +02:00
parent c33de9c0dc
commit 7aa7873b48
1 changed files with 8 additions and 5 deletions

View File

@ -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<paste_id>.*)#(?P<key>.*)')
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)