1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
# -*- coding: utf-8 -*-
#
# Applies a GDAL/OGR virtual file system (VSI) filter to the input source.
# See for more information: https://www.gdal.org/gdal_virtual_file_systems.html
#
# Author: Frank Steggink
#
from stetl.filter import Filter
from stetl.util import Util
from stetl.packet import FORMAT
log = Util.get_log('vsifilter')
class VsiFilter(Filter):
"""
Abstract base class for applying a GDAL/OGR virtual file system (VSI) filter.
"""
# Start attribute config meta
# End attribute config meta
# Constructor
def __init__(self, configdict, section, vsiname):
Filter.__init__(self, configdict, section, consumes=FORMAT.record, produces=FORMAT.string)
self.vsiname = vsiname
def invoke(self, packet):
if packet.data is None:
log.info("No file name given")
return packet
file_path = packet.data['file_path'].replace('\\', '/')
packet.data = '/%s/%s/%s' % (self.vsiname, file_path, packet.data['name'])
return packet
class VsiZipFilter(VsiFilter):
"""
Applies a VSIZIP filter to the input record.
consumes=FORMAT.record, produces=FORMAT.string
"""
# Start attribute config meta
# End attribute config meta
# Constructor
def __init__(self, configdict, section):
VsiFilter.__init__(self, configdict, section, 'vsizip')
|