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 

8headline = 'Scan and index files and directories.' 

9 

10 

11def make_subparser(subparsers): 

12 return subparsers.add_parser( 

13 'scan', 

14 help=headline, 

15 description=headline + ''' 

16 

17Read and cache meta-data of all files in formats understood by Squirrel under 

18selected paths. Subdirectories are recursively traversed and file formats are 

19auto-detected unless a specific format is forced with the ``--format`` option. 

20Modification times of files already known to Squirrel are checked by default 

21and re-indexed as needed. To speed up scanning, these checks can be disabled 

22with the ``--optimistic`` option. With this option, only new files are indexed 

23during scanning and modifications are handled "last minute" (i.e. just before 

24the actual data (e.g. waveform samples) are requested by the application). 

25 

26Usually, the contents of files given to Squirrel are made available within the 

27application through a runtime selection which is discarded again when the 

28application quits. Getting the cached meta-data into the runtime selection can 

29be a bottleneck for application startup with large datasets. To speed up 

30startup of Squirrel-based applications, persistent selections created with the 

31``--persistent`` option can be used. 

32 

33After scanning, information about the current data selection is printed. 

34''') 

35 

36 

37def setup(parser): 

38 parser.add_squirrel_selection_arguments() 

39 

40 

41def run(parser, args): 

42 squirrel = args.make_squirrel() 

43 print(squirrel)