"""Iterates through a directory reporting 3DBM and GSM Files. This script is meant to be executed from the command line. ------------ Dependencies ------------ :: Python: 2.2.[3-*] MineSight 3D: 4.[00-*].* MineSight Grail: 4.[00-*].* ----------------- License Agreement ----------------- The Original Code is rptpcftype.py. The Initial Developer of the Original Code is Leica Geosystems. Portions created by Leica Geosystems are Copyright (C) 2014 year. Leica Geosystems. All Rights Reserved. """ import fnmatch import os import sys from grail.data import pcf def _walk(arg, dirname, fnames): # Only consider files that pass this filter. Note that files like # rpt110.rpt will pass, but they will have trouble loading later. filter = "*10.*" dats = fnmatch.filter(fnames, filter) for d in dats: path = os.path.join(dirname, d) try: # If the file was not a PCF file, then we will get a # pcf.PCFError, that we catch and ignore. p = pcf.Pcf(path) print path, if p.isgsm(): print "is GSM!" else: print "is 3DBM!" except pcf.PcfError: # Not that important, just keep iterating through the files. pass if __name__=="__main__": # See if there is an argument to this program. If not then default to # the current working directory. try: startDir = sys.argv[1] except IndexError: # Oh well, you didn't supply an argument. We will default to the # current working directory. startDir = os.getcwd() print "walking through ", startDir os.path.walk(startDir, _walk, None)