def __init__(self, file_type=None, file_stream=None,
                 renderer_library=None, **keywords):
        AbstractSource.__init__(self, **keywords)

        self._renderer = RENDERER.get_a_plugin(file_type, renderer_library)
        if file_stream:
            self._content = file_stream
        else:
            self._content = self._renderer.get_io()
        self.attributes = RENDERER.get_all_file_types()
Esempio n. 2
0
    def __init__(self,
                 file_type=None,
                 file_stream=None,
                 renderer_library=None,
                 **keywords):
        AbstractSource.__init__(self, **keywords)

        self._renderer = RENDERER.get_a_plugin(file_type, renderer_library)
        if file_stream:
            self._content = file_stream
        else:
            self._content = self._renderer.get_io()
        self.attributes = RENDERER.get_all_file_types()
Esempio n. 3
0
    def __init__(self, file_name=None, renderer_library=None, **keywords):
        AbstractSource.__init__(self, **keywords)
        self._file_name = file_name

        self.__file_type = _find_file_type_from_file_name(file_name, 'write')
        self._renderer = RENDERER.get_a_plugin(self.__file_type,
                                               renderer_library)
Esempio n. 4
0
 def can_i_handle(cls, action, file_type):
     if action == constants.WRITE_ACTION:
         status = file_type.lower() in tuple(
             RENDERER.get_all_file_types())
     else:
         status = False
     return status
Esempio n. 5
0
    def __init__(self, file_name=None, renderer_library=None, **keywords):
        AbstractSource.__init__(self, **keywords)
        self._file_name = file_name

        self.__file_type = find_file_type_from_file_name(file_name, 'write')
        self._renderer = RENDERER.get_a_plugin(
            self.__file_type, renderer_library)
Esempio n. 6
0
 def write_data(self, sheet):
     arender = RENDERER.get_a_plugin(self._db_type, self.__renderer_library)
     init_func, map_dict = _transcode_sheet_db_keywords(self._keywords)
     import_params = self.get_import_params()
     arender.render_sheet_to_stream(import_params,
                                    sheet,
                                    init=init_func,
                                    mapdict=map_dict,
                                    **self._keywords)
    def __init__(self, file_name=None, renderer_library=None, **keywords):
        AbstractSource.__init__(self, **keywords)
        self._file_name = file_name

        if "force_file_type" in keywords:
            file_type = keywords.get("force_file_type")
        else:
            file_type = find_file_type_from_file_name(file_name, "write")

        self._renderer = RENDERER.get_a_plugin(file_type, renderer_library)
Esempio n. 8
0
    def write_data(self, book):
        arender = RENDERER.get_a_plugin(self.__db_type,
                                        self.__renderer_library)
        init_funcs, map_dicts = _transcode_book_db_keywords(self._keywords)

        import_params = self.get_params()
        arender.render_book_to_stream(import_params,
                                      book,
                                      inits=init_funcs,
                                      mapdicts=map_dicts,
                                      **self._keywords)
Esempio n. 9
0
 def write_data(self, sheet):
     arender = RENDERER.get_a_plugin(self._db_type, self.__renderer_library)
     init_func, map_dict = _transcode_sheet_db_keywords(
         self._keywords)
     import_params = self.get_import_params()
     arender.render_sheet_to_stream(
         import_params,
         sheet,
         init=init_func,
         mapdict=map_dict,
         **self._keywords)
Esempio n. 10
0
    def write_data(self, book):
        arender = RENDERER.get_a_plugin(
            self.__db_type, self.__renderer_library)
        init_funcs, map_dicts = _transcode_book_db_keywords(
            self._keywords)

        import_params = self.get_params()
        arender.render_book_to_stream(
            import_params,
            book,
            inits=init_funcs,
            mapdicts=map_dicts,
            **self._keywords)
Esempio n. 11
0
def _find_file_type_from_file_name(file_name, action):
    if action == 'read':
        list_of_file_types = PARSER.get_all_file_types()
    else:
        list_of_file_types = RENDERER.get_all_file_types()
    file_types = []
    lowercase_file_name = file_name.lower()
    for a_supported_type in list_of_file_types:
        if lowercase_file_name.endswith(a_supported_type):
            file_types.append(a_supported_type)
    if len(file_types) > 1:
        file_types = sorted(file_types, key=lambda x: len(x))
        file_type = file_types[-1]
    elif len(file_types) == 1:
        file_type = file_types[0]
    else:
        file_type = lowercase_file_name.split('.')[-1]
        raise FileTypeNotSupported(
            constants.FILE_TYPE_NOT_SUPPORTED_FMT % (file_type, action))

    return file_type