File tree 2 files changed +43
-0
lines changed
2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 48
48
entry_points = {
49
49
'console_scripts' : [
50
50
'zerobin = zerobin.routes:main' ,
51
+ 'remove_paste = zerobin.remove_paste:main' ,
51
52
]
52
53
}
53
54
Original file line number Diff line number Diff line change
1
+ from zerobin .paste import Paste
2
+ from clize import run
3
+ import re
4
+
5
+ paste_url = re .compile ('/paste/(?P<paste_id>.*)#(?P<key>.*)' )
6
+
7
+ def unpack_paste (paste ):
8
+ """Take either the ID or the URL of a paste, and return its ID"""
9
+
10
+ try_url = paste_url .search (paste )
11
+
12
+ if try_url :
13
+ return try_url .group ('paste_id' )
14
+ return paste
15
+
16
+
17
+ def remove_paste (* paste_list , quiet :'q' = False ):
18
+ """
19
+ Remove pastes, given its ID or its URL
20
+
21
+ paste_list: Liste of paste, given by ID or URL
22
+
23
+ quiet: Don't print anything
24
+ """
25
+
26
+ for paste_uuid in map (unpack_paste , paste_list ):
27
+ try :
28
+ Paste .load (paste_uuid ).delete ()
29
+
30
+ except ValueError :
31
+ if not quiet :
32
+ print ('Paste {} doesn\' t exist' .format (paste_uuid ))
33
+
34
+ else :
35
+ if not quiet :
36
+ print ('Paste {} is removed' .format (paste_uuid ))
37
+
38
+ def main ():
39
+ run (remove_paste )
40
+
41
+ if __name__ == "__main__" :
42
+ main ()
You can’t perform that action at this time.
0 commit comments