Skip to content

Commit 35ef23b

Browse files
committed
Support new standalone JAR filename (LanguageTool 2.1).
1 parent 01b4c43 commit 35ef23b

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

‎language_tool/__init__.py‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
__all__ = ["LanguageTool", "Error", "get_languages", "correct", "get_version",
4949
"get_directory", "set_directory"]
5050

51+
JAR_NAMES = [
52+
"languagetool-standalone-*.jar", # 2.1
53+
"LanguageTool.jar",
54+
"LanguageTool.uno.jar"
55+
]
5156
FAILSAFE_LANGUAGE = "en"
5257

5358
# http://mail.python.org/pipermail/python-dev/2011-July/112551.html
@@ -553,14 +558,19 @@ def get_jar_info():
553558
java_path = which("java")
554559
if not java_path:
555560
raise JavaError("can’t find Java")
556-
jar_names = ["LanguageTool.jar", "LanguageTool.uno.jar"]
557-
for jar_name in jar_names:
558-
jar_path = os.path.join(get_directory(), jar_name)
559-
if os.path.isfile(jar_path):
561+
dir_name = get_directory()
562+
jar_path = None
563+
for jar_name in JAR_NAMES:
564+
for jar_path in glob.glob(os.path.join(dir_name, jar_name)):
565+
if os.path.isfile(jar_path):
566+
break
567+
else:
568+
jar_path = None
569+
if jar_path:
560570
break
561571
else:
562-
raise PathError("can’t find {!r} in {!r}"
563-
.format(jar_names[0], get_directory()))
572+
raise PathError("can’t find languagetool-standalone in {!r}"
573+
.format(dir_name))
564574
cache["jar_info"] = java_path, jar_path
565575
return java_path, jar_path
566576

0 commit comments

Comments
 (0)