Skip to content

Commit 5fe31b3

Browse files
committed
minor improvements
1 parent 3b842d7 commit 5fe31b3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tika/tika.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def make_content_disposition_header(fn):
140140
from subprocess import STDOUT
141141
from os import walk
142142
import logging
143-
import _io
143+
import io
144144

145145
log_path = os.getenv('TIKA_LOG_PATH', tempfile.gettempdir())
146146
log_file = os.path.join(log_path, 'tika.log')
@@ -326,7 +326,7 @@ def parse1(option, urlOrPath, serverEndpoint=ServerEndpoint, verbose=Verbose, ti
326326
service = services.get(option, services['all'])
327327
if service == '/tika': responseMimeType = 'text/plain'
328328
headers.update({'Accept': responseMimeType, 'Content-Disposition': make_content_disposition_header(path.encode('utf-8') if type(path) is unicode_string else path)})
329-
with urlOrPath if type(urlOrPath) is _io.BufferedReader else open(path, 'rb') as f:
329+
with urlOrPath if isinstance(urlOrPath, io.BufferedIOBase) else open(path, 'rb') as f:
330330
status, response = callServer('put', serverEndpoint, service, f,
331331
headers, verbose, tikaServerJar, config_path=config_path,
332332
rawResponse=rawResponse, requestOptions=requestOptions)
@@ -699,8 +699,8 @@ def getRemoteFile(urlOrPath, destPath):
699699
:param destPath: path to store the resource, usually a path on file system
700700
:return: tuple having (path, 'local'/'remote'/'binary')
701701
'''
702-
#update to handle binary stream input
703-
if type(urlOrPath) is _io.BufferedReader:
702+
# handle binary stream input
703+
if isinstance(urlOrPath, io.BufferedIOBase):
704704
return (urlOrPath.name, 'binary')
705705

706706
urlp = urlparse(urlOrPath)

0 commit comments

Comments
 (0)