Changes between Version 1 and Version 2 of CatalogueForQIS


Ignore:
Timestamp:
Feb 28, 2012, 2:25:37 PM (12 years ago)
Author:
brushtyler
Comment:

fix retcode and use a more pythonic syntax :)

Legend:

Unmodified
Added
Removed
Modified
  • CatalogueForQIS

    v1 v2  
    3333from gdalconst import *
    3434
    35 def main( path, approx ):
    36         ds = gdal.Open( path, GA_ReadOnly )
     35def main(path, approx):
     36        ds = gdal.Open(path, GA_ReadOnly)
    3737        if ds is None:
    38                 return "Unable to open", path
     38                return 1
    3939
    4040        for i in range(ds.RasterCount):
    4141                band = ds.GetRasterBand(i+1)
    42                 band.ComputeStatistics( approx )
     42                band.ComputeStatistics(approx)
    4343
    4444        ds = None
     45        return 0
    4546
    4647if __name__ == "__main__":
     
    4849
    4950        approx = False
    50         path = ""
     51        path = None
    5152
    52         for i in range( len(sys.argv) ):
    53                 if i == 0:
    54                         continue
    55 
     53        for i in range(1, len(sys.argv)):
    5654                if sys.argv[i].lower() == "-approx":
    5755                        approx = True
     
    6058                        break
    6159
    62         if path == "":
     60        if path is None:
    6361                print "Usage:", sys.argv[0], "[-approx] <datasource>"
    6462                sys.exit(0)
    6563
    66         main( path, approx )
     64        ret = main(path, approx)
     65        sys.exit(ret)
    6766}}}
    6867