Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
amaiya committed Oct 1, 2022
1 parent 6d0e4e4 commit 8d5e39e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ Most recent releases are shown at the top. Each release shows:
- **Changed**: Additional parameters, changes to inputs or outputs, etc
- **Fixed**: Bug fixes that don't change documented behaviour

## 0.31.10 (2022-10-01)

### new:
- N/A

### changed
- N/A

### fixed:
- Adjusted tika imports due to issue with `/tmp/tika.log` in multi-user scenario


## 0.31.9 (2022-09-24)

### new:
Expand Down
23 changes: 13 additions & 10 deletions ktrain/text/textextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
from ..imports import *
from . import textutils as TU

try:
from tika import parser

TIKA_INSTALLED = True
except ImportError:
TIKA_INSTALLED = False

try:
import textract
Expand All @@ -27,10 +21,17 @@ class TextExtractor:
"""

def __init__(self, use_tika=True):
if use_tika and not TIKA_INSTALLED:
raise ValueError(
"If use_tika=True, then TextExtractor requires tika: pip install tika"
)
if use_tika:
try:
from tika import parser
except ImportError as e:
raise ValueError(
"If use_tika=True, then TextExtractor requires tika: pip install tika"
)
except PermissionError as e:
raise PermissionError(
f"There may already be a /tmp/tika.log file from another user - please delete it or change permissions: {e}"
)
if not use_tika and not TEXTRACT_INSTALLED:
raise ValueError(
"If use_tika=False, then TextExtractor requires textract: pip install textract"
Expand Down Expand Up @@ -89,6 +90,8 @@ def extract(

def _extract(self, filename):
if self.use_tika:
from tika import parser

if JAVA_INSTALLED:
parsed = parser.from_file(filename)
text = parsed["content"]
Expand Down
2 changes: 1 addition & 1 deletion ktrain/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__all__ = ["__version__"]
__version__ = "0.31.9"
__version__ = "0.31.10"

0 comments on commit 8d5e39e

Please sign in to comment.