Skip to content

Commit ca2a692

Browse files
committed
Fix for #375 #382 Adds an option for raw response returning in parser.py
1 parent b6f1374 commit ca2a692

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tika/parser.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import os
2121
import json
2222

23-
def from_file(filename, serverEndpoint=ServerEndpoint, service='all', xmlContent=False, headers=None, config_path=None, requestOptions={}):
23+
def from_file(filename, serverEndpoint=ServerEndpoint, service='all', xmlContent=False, headers=None, config_path=None, requestOptions={}, raw_response=False):
2424
'''
2525
Parses a file for metadata and content
2626
:param filename: path to file which needs to be parsed or binary file using open(path,'rb')
@@ -41,10 +41,13 @@ def from_file(filename, serverEndpoint=ServerEndpoint, service='all', xmlContent
4141
else:
4242
output = parse1(service, filename, serverEndpoint, services={'meta': '/meta', 'text': '/tika', 'all': '/rmeta/xml'},
4343
headers=headers, config_path=config_path, requestOptions=requestOptions)
44-
return _parse(output, service)
44+
if raw_response:
45+
return output
46+
else:
47+
return _parse(output, service)
4548

4649

47-
def from_buffer(string, serverEndpoint=ServerEndpoint, xmlContent=False, headers=None, config_path=None, requestOptions={}):
50+
def from_buffer(string, serverEndpoint=ServerEndpoint, xmlContent=False, headers=None, config_path=None, requestOptions={}, raw_response=False):
4851
'''
4952
Parses the content from buffer
5053
:param string: Buffer value
@@ -63,7 +66,10 @@ def from_buffer(string, serverEndpoint=ServerEndpoint, xmlContent=False, headers
6366
else:
6467
status, response = callServer('put', serverEndpoint, '/rmeta/xml', string, headers, False, config_path=config_path, requestOptions=requestOptions)
6568

66-
return _parse((status,response))
69+
if raw_response:
70+
return (status, response)
71+
else:
72+
return _parse((status,response))
6773

6874
def _parse(output, service='all'):
6975
'''

0 commit comments

Comments
 (0)