Skip to content

Commit fcc0c7e

Browse files
Provide Parse Status in returned dictionary
Small patch contributed by Gregg Morris <[email protected]> to provide parse status in the returned dict from _parse method. ``` Hi Chris-- For my purposes it's very helpful to know why a call to (in my case) parser.from_buffer() returns an empty dictionary. The status code returned by the tika server is a fine solution to that. The status code from the server is passed to the _parse() function, so I added "status" to the "parsed" dictionary and put the code there, regardless of anything else returned in that dictionary. This may certainly fall into the category of "nobody else cares", but in case you think it's worthwhile, here's the patch: diff --git a/tika/parser.py b/tika/parser.py index 2cc2e07..84b4c88 100644 --- a/tika/parser.py +++ b/tika/parser.py @@ -42,7 +42,8 @@ def _parse(jsonOutput): parsed={} if not jsonOutput: return parsed - elif jsonOutput[1] == None or jsonOutput[1] == "": + parsed["status"] = jsonOutput[0] + if jsonOutput[1] == None or jsonOutput[1] == "": return parsed realJson = json.loads(jsonOutput[1]) Thanks for your tika efforts! Gregg ```
1 parent 23966e8 commit fcc0c7e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tika/parser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ def _parse(jsonOutput):
6969
parsed={}
7070
if not jsonOutput:
7171
return parsed
72-
elif jsonOutput[1] == None or jsonOutput[1] == "":
72+
73+
parsed["status"] = jsonOutput[0]
74+
if jsonOutput[1] == None or jsonOutput[1] == "":
7375
return parsed
7476
realJson = json.loads(jsonOutput[1])
7577

0 commit comments

Comments
 (0)