# Path: metageta/utilities.py
# def encode(string):
# def archivelist(f):
# def archivefileinfo(f,n):
# def archivefilename(filepath):
# def compressed_file_exists(path,testfile=True):
# def runcmd(cmd, format='s'):
# def which(name, returnfirst=True, flags=os.F_OK | os.X_OK, path=None):
# def exists(f,returnpath=False):
# def readbinary(data,offset, start, stop):
# def readascii(data,offset,start,stop):
# def ByteOrder():
# def _WinFileOwner(filepath):
# def _NixFileOwner(uid):
# def FileInfo(filepath):
# def uuid(filepath):
# def uncpath(filepath):
# def normcase(filepath):
# def normpath(filepath):
# def realpath(filepath):
# def checkExt(filepath,ext):
# def volname(path):
# def writable(filepath):
# def rglob(directory, pattern="*", regex=False, regex_flags=0, recurse=True, archive=False, excludes=[],
#           onerror=None, followlinks=False):
# def match(f, pattern="*", regex=False, regex_flags=0):
# def isrunning(pid):
# def ExceptionInfo(maxTBlevel=0):
# def FormatTraceback(trbk, maxTBlevel):
#     def __init__(self,xlsx,fields=[],update=False, sort = True):
#     def __getcol__(self,lst,val):
#     def _addsheet(self):
#     def _addheader(self, ws):
#     def _writevalue(self,row,col,value,ws=None):
#     def WriteRecord(self,data):
#     def UpdateRecord(self,data,row):
#     def save(self):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, exc_traceback):
#     def __init__(self,xlsx,returntype=dict):
#     def __getitem__(self, index):
#     def __enter__(self):
#     def __exit__(self):
#     OWNERID=(8,10) # seems to be 8 on XP, 10 on Win7
# class ExcelWriter:
# class ExcelReader:


import os,math,warnings,tempfile,re
    import gdal
    import gdalconst
    import osr
    import ogr
from metageta import utilities
    from osgeo import gdal
    from osgeo import gdalconst
    from osgeo import osr
    from osgeo import ogr

            lyr.CreateFeature(feat)
            lyr.SyncToDisk()

        except Exception, err:
            self.__error__(err)

    def UpdateRecord(self,extent,attributes,where_clause):
        '''Update record/s

            @type where_clause:  C{str}
            @param where_clause: Shapefile supported SQL where clause
            @type attributes:    C{dict}
            @param attributes:   Must match field names passed to __init__()
        '''
        try:
            geom=GeomFromExtent(extent,self._srs)
            if self._srs.IsGeographic(): #basic coordinate bounds test. Can't do for projected though
                srs=osr.SpatialReference()
                srs.ImportFromEPSG(4283)#4326)
                valid = GeomFromExtent([-180,-90,180,90], srs=srs)
                if not valid.Contains(geom):
                    #raise ValueError, 'Invalid extent coordinates'
                    warnings.warn('Invalid extent coordinates')
            lyr=self._shape.GetLayer()
            lyr.SetAttributeFilter(where_clause)
            feat=lyr.GetNextFeature()
            try:feat.SetGeometryDirectly(geom)
            except:return self.WriteRecord(extent,attributes)
            while feat:
                for a in attributes:

# Path: metageta/utilities.py
# def encode(string):
# def archivelist(f):
# def archivefileinfo(f,n):
# def archivefilename(filepath):
# def compressed_file_exists(path,testfile=True):
# def runcmd(cmd, format='s'):
# def which(name, returnfirst=True, flags=os.F_OK | os.X_OK, path=None):
# def exists(f,returnpath=False):
# def readbinary(data,offset, start, stop):
# def readascii(data,offset,start,stop):
# def ByteOrder():
# def _WinFileOwner(filepath):
# def _NixFileOwner(uid):
# def FileInfo(filepath):
# def uuid(filepath):
# def uncpath(filepath):
# def normcase(filepath):
# def normpath(filepath):
# def realpath(filepath):
# def checkExt(filepath,ext):
# def volname(path):
# def writable(filepath):
# def rglob(directory, pattern="*", regex=False, regex_flags=0, recurse=True, archive=False, excludes=[],
#           onerror=None, followlinks=False):
# def match(f, pattern="*", regex=False, regex_flags=0):
# def isrunning(pid):
# def ExceptionInfo(maxTBlevel=0):
# def FormatTraceback(trbk, maxTBlevel):
#     def __init__(self,xlsx,fields=[],update=False, sort = True):
#     def __getcol__(self,lst,val):
#     def _addsheet(self):
#     def _addheader(self, ws):
#     def _writevalue(self,row,col,value,ws=None):
#     def WriteRecord(self,data):
#     def UpdateRecord(self,data,row):
#     def save(self):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, exc_traceback):
#     def __init__(self,xlsx,returntype=dict):
#     def __getitem__(self, index):
#     def __enter__(self):
#     def __exit__(self):
#     OWNERID=(8,10) # seems to be 8 on XP, 10 on Win7
# class ExcelWriter:
# class ExcelReader:


# Path: metageta/geometry.py
import os,math,warnings,tempfile,re
    import gdal
    import gdalconst
    import osr
    import ogr
from metageta import utilities
    from osgeo import gdal
    from osgeo import gdalconst
    from osgeo import osr
    from osgeo import ogr

            lyr.CreateFeature(feat)
            lyr.SyncToDisk()

        except Exception, err:
            self.__error__(err)

    def UpdateRecord(self,extent,attributes,where_clause):
        '''Update record/s

            @type where_clause:  C{str}
            @param where_clause: Shapefile supported SQL where clause
            @type attributes:    C{dict}
            @param attributes:   Must match field names passed to __init__()
        '''
        try:
            geom=GeomFromExtent(extent,self._srs)
            if self._srs.IsGeographic(): #basic coordinate bounds test. Can't do for projected though
                srs=osr.SpatialReference()
                srs.ImportFromEPSG(4283)#4326)
                valid = GeomFromExtent([-180,-90,180,90], srs=srs)
                if not valid.Contains(geom):
                    #raise ValueError, 'Invalid extent coordinates'
                    warnings.warn('Invalid extent coordinates')
            lyr=self._shape.GetLayer()
            lyr.SetAttributeFilter(where_clause)
            feat=lyr.GetNextFeature()
            try:feat.SetGeometryDirectly(geom)
            except:return self.WriteRecord(extent,attributes)
            while feat:
                for a in attributes:

                    if a in self.fields:feat.SetField(self.fields[a], utilities.encode(attributes[a]))
