Skip to content

Commit ecaabec

Browse files
authored
Merge pull request #106 from mdevolde/master
Minor bug in the detection of non-existent versions
2 parents 2fbc1a1 + 7220912 commit ecaabec

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ into where the ``language_tool_python`` package resides.
270270

271271
### LanguageTool Version
272272

273-
As of April 2020, `language_tool_python` was forked from `language-check` and no longer supports LanguageTool versions lower than 4.0.
273+
LanguageTool versions under 6.0 are no longer downloadable from the LanguageTool website. If you need to use an older version, you can download it from the [LanguageTool GitHub tags page](https://github.com/languagetool-org/languagetool/tags) and build it yourself.
274274

275275
### Acknowledgements
276276

language_tool_python/download_lt.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from .utils import (
1414
find_existing_language_tool_downloads,
1515
get_language_tool_download_path,
16+
PathError,
1617
LTP_JAR_DIR_PATH_ENV_VAR
1718
)
1819

@@ -125,13 +126,13 @@ def http_get(url: str, out_file: IO[bytes], proxies: Optional[Dict[str, str]] =
125126
:type out_file: IO[bytes]
126127
:param proxies: Optional dictionary of proxies to use for the request.
127128
:type proxies: Optional[Dict[str, str]]
128-
:raises Exception: If the file could not be found at the given URL (HTTP 403).
129+
:raises PathError: If the file could not be found at the given URL (HTTP 404).
129130
"""
130131
req = requests.get(url, stream=True, proxies=proxies)
131132
content_length = req.headers.get('Content-Length')
132133
total = int(content_length) if content_length is not None else None
133-
if req.status_code == 403: # Not found on AWS
134-
raise Exception(f'Could not find at URL {url}.')
134+
if req.status_code == 404:
135+
raise PathError(f'Could not find at URL {url}. The given version may not exist or is no longer available.')
135136
version = re.search(r'(\d+\.\d+)', url).group(1)
136137
progress = tqdm.tqdm(unit="B", unit_scale=True, total=total,
137138
desc=f'Downloading LanguageTool {version}')

language_tool_python/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class PathError(LanguageToolError):
6565
"""
6666
Exception raised for errors in the file path used in LanguageTool.
6767
This error is raised when there is an issue with the file path provided
68-
to LanguageTool, such as the LanguageTool JAR file not being found.
68+
to LanguageTool, such as the LanguageTool JAR file not being found,
69+
or a download path not being a valid available file path.
6970
"""
7071
pass
7172

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "language_tool_python"
3-
version = "2.9.0"
3+
version = "2.9.1"
44
requires-python = ">=3.9"
55
description = "Checks grammar using LanguageTool."
66
readme = { file = "README.md", content-type = "text/markdown" }

0 commit comments

Comments
 (0)