This file is indexed.

/usr/share/qgis/grass/scripts/r.external.all.py is in qgis-plugin-grass-common 2.0.1-2build2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-

"""
***************************************************************************
    r.external.all.py
    ---------------------
    Date                 : July 2009
    Copyright            : (C) 2009 by Lorenzo Masini
    Email                : rugginoso at develer dot com
***************************************************************************
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
***************************************************************************
"""

__author__ = 'Lorenzo Masini'
__date__ = 'July 2009'
__copyright__ = '(C) 2009, Lorenzo Masini'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'


############################################################################
#
# MODULE:       qgis.r.external.all.py
# AUTHOR(S):    Lorenzo Masini
#
# PURPOSE:      Link all GDAL supported raster files into a directory
#		to binary raster map layers.
# COPYRIGHT:    (C) 2009 by Lorenzo Masini
#
#               This program is free software under the GNU General Public
#               License (>=v2). Read the file COPYING that comes with GRASS
#               for details.
#
#############################################################################

#%Module
#% description: Link all GDAL supported raster files into a directory to binary raster map layers.
#% keywords: raster, import
#%End

#%option
#% key: input
#% type: string
#% gisprompt: input
#% key_desc : name
#% description: Directory containing raster files
#% required : yes
#%end

#%option
#% key: band
#% type: integer
#% description: Band to select
#% answer: 1
#% required : no
#%end

#%flag
#% key: o
#% description: Override projection (use location's projection)
#%end

#%flag
#% key: e
#% description: Extend location extents based on new dataset
#%end

#%flag
#% key: r
#% description: Recursively scan subdirectories

import sys
import os
try:
    from grass.script import core as grass
except ImportError:
    import grass
except:
    raise Exception ("Cannot find 'grass' Python module. Python is supported by GRASS from version >= 6.4" )


def import_directory_of_rasters(directory, recursive):
    for dir, dirnames, filenames in os.walk(directory):
	for filename in filenames:
		if grass.run_command('r.external', flags=flags_string, input=os.path.join(dir, filename), band=options['band'], output=filename[:-4], title=filename[:-4]) != 0:
			grass.warning('Cannot import file' + filename)
	if not recursive:
		break
	for dirname in dirnames:
		import_directory_of_rasters(dirname, recursive)

def main():
    input = options['input']
    recursive = flags['r']

    import_directory_of_rasters(input, recursive)

if __name__ == "__main__":
    options, flags = grass.parser()
    flags_string = "".join([k for k in flags.keys() if flags[k] and k != 'r'])
    main()