1# http://pyrocko.org - GPLv3 

2# 

3# The Pyrocko Developers, 21st Century 

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

5 

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

7 

8 

9def make_subparser(subparsers): 

10 return subparsers.add_parser( 

11 'scan', 

12 help=headline, 

13 description=headline + ''' 

14 

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

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

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

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

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

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

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

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

23 

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

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

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

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

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

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

30 

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

32''') 

33 

34 

35def setup(parser): 

36 parser.add_squirrel_selection_arguments() 

37 

38 

39def run(parser, args): 

40 squirrel = args.make_squirrel() 

41 print(squirrel)