@@ -106,7 +106,7 @@ def open_workbook(self, *args, **kwargs):
106106 if isinstance (self ._open_workbook , type (None )):
107107 self .load_engine ()
108108 # just in case the user passes an already opened workbook of io_class
109- if isinstance (args [0 ], self .io_class ):
109+ if len ( args ) > 0 and isinstance (args [0 ], self .io_class ):
110110 return args [0 ]
111111 return self ._open_workbook (* args , ** kwargs )
112112
@@ -122,14 +122,21 @@ def is_ext(self, path):
122122 else :
123123 return False
124124
125- def is_type (self , io ):
125+ def is_type (self , io ):#, engine=None):
126126 """Verify if the io type is supported by the reader. If the reader is
127127 not installed, return False.
128128 """
129129 if isinstance (io , type (None )):
130130 return False
131131 elif isinstance (io , self .io_class ):
132132 return True
133+ # elif self.engine == engine:
134+ # return True
135+ # elif isinstance(io, compat.string_types):
136+ # if self.is_ext(io):
137+ # return True
138+ # else:
139+ # return False
133140 else :
134141 return False
135142
@@ -164,6 +171,24 @@ def _load_engine(self):
164171 self ._open_workbook = xlrd .open_workbook
165172 self .io_class = xlrd .Book
166173
174+ # def open_workbook(self, *args, **kwargs):
175+ # """Explicitely load the engine again (and trigger an ImportError in the
176+ # process) if _open_workbook is set to None.
177+ # """
178+ # # try to load the engine again and raise import error if required
179+ # if isinstance(self._open_workbook, type(None)):
180+ # self.load_engine()
181+ # io = args[0]
182+ # # just in case the user passes an already opened workbook of io_class
183+ # if isinstance(io, self.io_class):
184+ # return io
185+ # # N.B. xlrd.Book has a read attribute too
186+ # elif hasattr(io, "read"):
187+ # data = io.read()
188+ # return self._open_workbook(file_contents=data)
189+ #
190+ # return self._open_workbook(*args, **kwargs)
191+
167192
168193class EZODFFile (BaseFile ):
169194 """File reader class for ODF spreadsheets (depends on ezodf)
0 commit comments