parameters: ()
return_statement: return ret
docstring: Return 0 in case of success, 1 for failure.
docstring_summary: Return 0 in case of success, 1 for failure.
docstring_tokens: Return 0 in case of success 1 for failure .
function: def main():
      """Return 0 in case of success, 1 for failure."""
  
      i = 1
      filename = None
      quiet = False
      full_check = None
      while i < len(sys.argv):
          if sys.argv[i] == '-q':
              quiet = True
          elif sys.argv[i] == '--full-check=yes':
              full_check = True
          elif sys.argv[i] == '--full-check=no':
              full_check = False
          elif sys.argv[i] == '--full-check=auto':
              full_check = None
          elif sys.argv[i][0] == '-':
              return Usage()
          elif filename is None:
              filename = sys.argv[i]
          else:
              return Usage()
  
          i += 1
  
      if filename is None:
          return Usage()
  
      if full_check is None:
          full_check = filename.startswith('/vsimem/') or os.path.exists(filename)
  
      try:
          ret = 0
          warnings, errors, details = validate(filename, full_check=full_check)
          if warnings:
              if not quiet:
                  print('The following warnings were found:')
                  for warning in warnings:
                      print(' - ' + warning)
                  print('')
          if errors:
              if not quiet:
                  print('%s is NOT a valid cloud optimized GeoTIFF.' % filename)
                  print('The following errors were found:')
                  for error in errors:
                      print(' - ' + error)
                  print('')
              ret = 1
          else:
              if not quiet:
                  print('%s is a valid cloud optimized GeoTIFF' % filename)
  
          if not quiet and not warnings and not errors:
              headers_size = min(details['data_offsets'][k] for k in details['data_offsets'])
              if headers_size == 0:
                  headers_size = gdal.VSIStatL(filename).size
              print('\nThe size of all IFD headers is %d bytes' % headers_size)
      except ValidateCloudOptimizedGeoTIFFException as e:
          if not quiet:
              print('%s is NOT a valid cloud optimized GeoTIFF : %s' %
                    (filename, str(e)))
          ret = 1
  
      return ret
function_tokens: def main ( ) : i = 1 filename = None quiet = False full_check = None while i < len ( sys . argv ) : if sys . argv [ i ] == '-q' : quiet = True elif sys . argv [ i ] == '--full-check=yes' : full_check = True elif sys . argv [ i ] == '--full-check=no' : full_check = False elif sys . argv [ i ] == '--full-check=auto' : full_check = None elif sys . argv [ i ] [ 0 ] == '-' : return Usage ( ) elif filename is None : filename = sys . argv [ i ] else : return Usage ( ) i += 1 if filename is None : return Usage ( ) if full_check is None : full_check = filename . startswith ( '/vsimem/' ) or os . path . exists ( filename ) try : ret = 0 warnings , errors , details = validate ( filename , full_check = full_check ) if warnings : if not quiet : print ( 'The following warnings were found:' ) for warning in warnings : print ( ' - ' + warning ) print ( '' ) if errors : if not quiet : print ( '%s is NOT a valid cloud optimized GeoTIFF.' % filename ) print ( 'The following errors were found:' ) for error in errors : print ( ' - ' + error ) print ( '' ) ret = 1 else : if not quiet : print ( '%s is a valid cloud optimized GeoTIFF' % filename ) if not quiet and not warnings and not errors : headers_size = min ( details [ 'data_offsets' ] [ k ] for k in details [ 'data_offsets' ] ) if headers_size == 0 : headers_size = gdal . VSIStatL ( filename ) . size print ( '\nThe size of all IFD headers is %d bytes' % headers_size ) except ValidateCloudOptimizedGeoTIFFException as e : if not quiet : print ( '%s is NOT a valid cloud optimized GeoTIFF : %s' % ( filename , str ( e ) ) ) ret = 1 return ret