Debian Codegraph @

stetl/filters/vsifilter.py

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