1# http://pyrocko.org - GPLv3 

2# 

3# The Pyrocko Developers, 21st Century 

4# ---|P------/S----------~Lg---------- 

5 

6from __future__ import absolute_import, print_function 

7 

8import logging 

9 

10from ..common import SquirrelCommand 

11 

12logger = logging.getLogger('psq.cli.remove') 

13 

14headline = 'Remove entries from selection or database.' 

15 

16description = '''%s 

17 

18Allows selective removal of cached metadata from Squirrel's database. 

19 

20Currently only removal of waveform promises is supported. 

21''' % headline 

22 

23 

24class Promises(SquirrelCommand): 

25 

26 def make_subparser(self, subparsers): 

27 return subparsers.add_parser( 

28 'promises', 

29 help='Remove all waveform promises in the selection.', 

30 description='Remove all waveform promises in the selection.') 

31 

32 def setup(self, parser): 

33 parser.add_squirrel_selection_arguments() 

34 

35 def run(self, parser, args): 

36 s = args.make_squirrel() 

37 s.remove_waveform_promises(from_database='global') 

38 

39 

40def make_subparser(subparsers): 

41 return subparsers.add_parser( 

42 'remove', 

43 help=headline, 

44 subcommands=[Promises()], 

45 description=description) 

46 

47 

48def setup(parser): 

49 pass 

50 

51 

52def run(parser, args): 

53 parser.print_help()