mirror of
https://github.com/Tygs/0bin.git
synced 2023-08-10 21:13:00 +03:00
Fixes according to comments by @RaitoBezarius
This commit is contained in:
parent
c33de9c0dc
commit
7aa7873b48
@ -2,6 +2,9 @@ from zerobin.paste import Paste
|
|||||||
from clize import run
|
from clize import run
|
||||||
import re
|
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>.*)')
|
paste_url = re.compile('/paste/(?P<paste_id>.*)#(?P<key>.*)')
|
||||||
|
|
||||||
def unpack_paste(paste):
|
def unpack_paste(paste):
|
||||||
@ -14,11 +17,11 @@ def unpack_paste(paste):
|
|||||||
return 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
|
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
|
quiet: Don't print anything
|
||||||
"""
|
"""
|
||||||
@ -27,13 +30,13 @@ def remove_paste(*paste_list, quiet:'q'=False):
|
|||||||
try:
|
try:
|
||||||
Paste.load(paste_uuid).delete()
|
Paste.load(paste_uuid).delete()
|
||||||
|
|
||||||
|
if not quiet:
|
||||||
|
print('Paste {} is removed'.format(paste_uuid))
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
if not quiet:
|
if not quiet:
|
||||||
print('Paste {} doesn\'t exist'.format(paste_uuid))
|
print('Paste {} doesn\'t exist'.format(paste_uuid))
|
||||||
|
|
||||||
else:
|
|
||||||
if not quiet:
|
|
||||||
print('Paste {} is removed'.format(paste_uuid))
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
run(remove_paste)
|
run(remove_paste)
|
||||||
|
Loading…
Reference in New Issue
Block a user