Example #1
0
 def open_content(self, file_content, **keywords):
     if compact.PY27_ABOVE:
         import mmap
         encoding = keywords.get('encoding', 'utf-8')
         if isinstance(file_content, mmap.mmap):
             # load from mmap
             self.__multiple_sheets = keywords.get('multiple_sheets', False)
             self._file_stream = CSVMemoryMapIterator(
                 file_content, encoding)
             self._keywords = keywords
             self._native_book = self._load_from_stream()
         else:
             if compact.PY3_ABOVE:
                 if isinstance(file_content, bytes):
                     file_content = file_content.decode(encoding)
             # else python 2.7 does not care about bytes nor str
             BookReader.open_content(self, file_content, **keywords)
     else:
         BookReader.open_content(self, file_content, **keywords)
Example #2
0
    def open_content(self, file_content, **keywords):
        try:
            import mmap

            encoding = keywords.get("encoding", "utf-8")
            if isinstance(file_content, mmap.mmap):
                # load from mmap
                self.__multiple_sheets = keywords.get("multiple_sheets", False)
                self._file_stream = CSVMemoryMapIterator(
                    file_content, encoding)
                self._keywords = keywords
                self._native_book = self._load_from_stream()
            else:
                if compact.PY3_ABOVE:
                    if isinstance(file_content, bytes):
                        file_content = file_content.decode(encoding)
                # else python 2.7 does not care about bytes nor str
                BookReader.open_content(self, file_content, **keywords)
        except ImportError:
            # python 2.6 or Google app engine
            BookReader.open_content(self, file_content, **keywords)
Example #3
0
 def open_content(self, file_content, **keywords):
     if compact.PY27_ABOVE:
         import mmap
         encoding = keywords.get('encoding', 'utf-8')
         if isinstance(file_content, mmap.mmap):
             # load from mmap
             self.__multiple_sheets = keywords.get('multiple_sheets', False)
             self._file_stream = CSVMemoryMapIterator(
                 file_content, encoding)
             self._keywords = keywords
             self._native_book = self._load_from_stream()
         else:
             if compact.PY3_ABOVE:
                 if isinstance(file_content, bytes):
                     file_content = file_content.decode(encoding)
             # else python 2.7 does not care about bytes nor str
             BookReader.open_content(
                 self, file_content, **keywords)
     else:
         BookReader.open_content(
             self, file_content, **keywords)
Example #4
0
    def open_content(self, file_content, **keywords):
        try:
            import mmap

            encoding = keywords.get("encoding", "utf-8")
            if isinstance(file_content, mmap.mmap):
                # load from mmap
                self.__multiple_sheets = keywords.get("multiple_sheets", False)
                self._file_stream = CSVMemoryMapIterator(
                    file_content, encoding
                )
                self._keywords = keywords
                self._native_book = self._load_from_stream()
            else:
                if compact.PY3_ABOVE:
                    if isinstance(file_content, bytes):
                        file_content = file_content.decode(encoding)
                # else python 2.7 does not care about bytes nor str
                BookReader.open_content(self, file_content, **keywords)
        except ImportError:
            # python 2.6 or Google app engine
            BookReader.open_content(self, file_content, **keywords)