Пример #1
0
    def import_all(self):
        """Import content."""

        if Config.defaults:
            self._logger.debug('importing all default content')
            collection = Migrate.load(
                Config.default_content_file(Const.SNIPPET))
            collection.migrate(
                Migrate.load(Config.default_content_file(Const.SOLUTION)))
            collection.migrate(
                Migrate.load(Config.default_content_file(Const.REFERENCE)))
            self._storage.import_content(collection)
        else:
            Cause.push(
                Cause.HTTP_BAD_REQUEST,
                'import operation for content category \'all\' is supported only with default content'
            )
Пример #2
0
    def export_all(self):
        """Export content."""

        if Config.template:
            self._logger.debug('exporting: %s :template: %s', self._category, Config.get_operation_file())
            Migrate.dump_template(self._category)
        elif Config.complete:
            Migrate.dump_completion(Config.complete)
        elif Config.is_search_criteria():
            self._logger.debug('exporting: %s :based on search criteria', self._category)
            collection = self._storage.search(
                scat=Config.search_cat_kws,
                sall=Config.search_all_kws,
                stag=Config.search_tag_kws,
                sgrp=Config.search_grp_kws,
                search_filter=Config.search_filter,
                uuid=Config.operation_uuid,
                digest=Config.operation_digest,
                identity=Config.operation_identity,
                data=Config.content_data
            )
            if not collection:
                Config.validate_search_context(collection, 'export')
            else:
                filename = Config.get_operation_file(collection=collection)
                Migrate.dump(collection, filename)
        else:
            if Config.defaults:
                for category in Config.search_cat_kws:
                    collection = self._storage.export_content((category,))
                    filename = Config.default_content_file(category)
                    self._logger.debug('exporting all: %s :content to: %s', category, filename)
                    Migrate.dump(collection, filename)
            else:
                collection = self._storage.export_content(Config.search_cat_kws)
                filename = Config.get_operation_file(collection=collection)
                self._logger.debug('exporting all: %s :content to: %s', self._category, filename)
                Migrate.dump(collection, filename)