Source code for sylib.library.plugins.export.datasource_exporters.plugin_zip_archiver

# This file is part of Sympathy for Data.
# Copyright (c) 2013, 2017, Combine Control Systems AB
#
# SYMPATHY FOR DATA COMMERCIAL LICENSE
# You should have received a link to the License with Sympathy for Data.
import os
import zipfile
from sylib.export import datasource as importdatasource


[docs] class DataArchiveZip(importdatasource.DatasourceArchiveBase): """Archiver for ZIP files. Takes all datasources in input and puts them in one ZIP file. Folder structure is discarded. """ EXPORTER_NAME = "ZIP Compressor" FILENAME_EXTENSION = "zip" @staticmethod def hide_filename(): return False def export_data(self, in_datasources, location, progress=None): if len(in_datasources): with zipfile.ZipFile(location, 'w') as f: for ds in in_datasources: path = ds.decode_path() f.write(path, os.path.basename(path)) return [location] def create_filenames(self, input_list, filename, *args): return super().create_filenames( input_list, filename, *args) def cardinality(self): return self.many_to_one