예제 #1
0
파일: core.py 프로젝트: bn0901/tablip
    def export(self, format, **kwargs):
        """
        Export :class:`Databook` object to `format`.

        :param \\*\\*kwargs: (optional) custom configuration to the format `export_book`.
        """
        fmt = registry.get_format(format)
        if not hasattr(fmt, 'export_book'):
            raise UnsupportedFormat('Format {} cannot be exported.'.format(format))

        return fmt.export_book(self, **kwargs)
예제 #2
0
파일: core.py 프로젝트: bn0901/tablip
    def load(self, in_stream, format, **kwargs):
        """
        Import `in_stream` to the :class:`Databook` object using the `format`.
        `in_stream` can be a file-like object, a string, or a bytestring.

        :param \\*\\*kwargs: (optional) custom configuration to the format `import_book`.
        """

        stream = normalize_input(in_stream)
        if not format:
            format = detect_format(stream)

        fmt = registry.get_format(format)
        if not hasattr(fmt, 'import_book'):
            raise UnsupportedFormat('Format {} cannot be loaded.'.format(format))

        fmt.import_book(self, stream, **kwargs)
        return self
예제 #3
0
파일: core.py 프로젝트: bn0901/tablip
 def _set_in_format(self, fmt_key, in_stream, **kwargs):
     in_stream = normalize_input(in_stream)
     return registry.get_format(fmt_key).import_set(self, in_stream, **kwargs)
예제 #4
0
파일: core.py 프로젝트: bn0901/tablip
 def _get_in_format(self, fmt_key, **kwargs):
     return registry.get_format(fmt_key).export_set(self, **kwargs)