|
| 1 | +import os |
| 2 | + |
| 3 | + |
| 4 | +class TaskBase(object): |
| 5 | + def __init__(self, **kwargs): |
| 6 | + print('####################################') |
| 7 | + print(self.__class__.__name__) |
| 8 | + print(kwargs) |
| 9 | + print('####################################') |
| 10 | + self.config = kwargs['config'] |
| 11 | + self.logger = kwargs['logger'] |
| 12 | + |
| 13 | + def run(self): |
| 14 | + raise NotImplementedError |
| 15 | + |
| 16 | + |
| 17 | +class TaskVector(TaskBase): |
| 18 | + def __init__(self, **kwargs): |
| 19 | + super().__init__(**kwargs) |
| 20 | + |
| 21 | + def run(self): |
| 22 | + geo_path = self.config['geo_path'] |
| 23 | + res = os.path.exists(geo_path) |
| 24 | + self.logger.info('File exist? {}'.format('yes' if res else 'no')) |
| 25 | + return res |
| 26 | + |
| 27 | + |
| 28 | +class TaskVectorTables(TaskVector): |
| 29 | + def __init__(self, **kwargs): |
| 30 | + super().__init__(**kwargs) |
| 31 | + |
| 32 | + def run(self): |
| 33 | + import fiona |
| 34 | + geo_path = self.config['geo_path'] |
| 35 | + layers = fiona.listlayers(geo_path) |
| 36 | + layers_in_config = self.config['geopackage_tables'] |
| 37 | + res = all([layer in layers_in_config for layer in layers]) |
| 38 | + self.logger.info(f'Do we have the layers? {res!r}') |
| 39 | + return res |
| 40 | + |
| 41 | +# class TaskVectorTableColumns(TaskBase): |
| 42 | +# def __init__(self, **kwargs): |
| 43 | +# super().__init__(**kwargs) |
| 44 | +# |
| 45 | +# |
| 46 | +# class TaskVectorTableColumnsUnits(TaskBase): |
| 47 | +# table = 'units' |
| 48 | +# def __init__(self, **kwargs): |
| 49 | +# super().__init__(**kwargs) |
| 50 | +# |
0 commit comments