'Import data from a Shapefile
@param resource: the S3Resource
@param source: the source
@return: an S3XML ElementTree
@ToDo: Handle encodings within Shapefiles other than UTF-8'

def decode(self, resource, source, **attr):

    raise NotImplementedError
    try:
        from lxml import etree
    except ImportError:
        import sys
        print >>sys.stderr, 'ERROR:    lxml    module    needed    for    XML    handling'
        raise
    try:
        from osgeo import ogr
    except ImportError:
        import sys
        print >>sys.stderr, 'ERROR:    GDAL    module    needed    for    Shapefile    handling'
        raise
    shapefilename = source
    layername = os.path.splitext(os.path.basename(shapefilename))[0]
    ds = ogr.Open(shapefilename)
    if (ds is None):
        raise
    lyr = ds.GetLayer(0)
    root = etree.Element('shapefile', name=layername)
    OFTInteger = ogr.OFTInteger
    OFTReal = ogr.OFTReal
    OFTString = ogr.OFTString
    for feat in lyr:
        featurenode = etree.SubElement(root, 'feature')
        feat_defn = lyr.GetLayerDefn()
        GetFieldDefn = feat_defn.GetFieldDefn
        for i in range(feat_defn.GetFieldCount()):
            field_defn = GetFieldDefn(i)
            fieldnode = etree.SubElement(featurenode, field_defn.GetName())
            if (field_defn.GetType() == OFTInteger):
                fieldnode.text = str(feat.GetFieldAsInteger(i))
            elif (field_defn.GetType() == OFTReal):
                fieldnode.text = str(feat.GetFieldAsDouble(i))
            elif (field_defn.GetType() == OFTString):
                FieldString = str(feat.GetFieldAsString(i))
                fieldnode.text = FieldString.decode(encoding='UTF-8', errors='strict')
        wktnode = etree.SubElement(featurenode, 'wkt')
        geom = feat.GetGeometryRef()
        wktnode.text = geom.ExportToWkt()
    return root
