Skip to content

Commit 6aef1c6

Browse files
committed
fix: powwibly wrong version displayed in dl progress bar, added picky mode in LT requests
1 parent d88e994 commit 6aef1c6

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

language_tool_python/__main__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def parse_args():
3838
parser.add_argument('--enabled-only', action='store_true',
3939
help='disable all rules except those specified in '
4040
'--enable')
41+
parser.add_argument('-p', '--picky', action='store_true',
42+
help='If set, additional rules will be activated.')
4143
parser.add_argument(
4244
'--version', action='version',
4345
version='%(prog)s {}'.format(__version__),
@@ -124,6 +126,9 @@ def main():
124126
lang_tool.enabled_rules.update(args.enable)
125127
lang_tool.enabled_rules_only = args.enabled_only
126128

129+
if args.picky:
130+
lang_tool.picky = True
131+
127132
try:
128133
if args.apply:
129134
print(lang_tool.correct(text))

language_tool_python/download_lt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ def http_get(url, out_file, proxies=None):
114114
total = int(content_length) if content_length is not None else None
115115
if req.status_code == 403: # Not found on AWS
116116
raise Exception('Could not find at URL {}.'.format(url))
117+
version = re.search(r'(\d+\.\d+)', url).group(1)
117118
progress = tqdm.tqdm(unit="B", unit_scale=True, total=total,
118-
desc=f'Downloading LanguageTool {LTP_DOWNLOAD_VERSION}')
119+
desc=f'Downloading LanguageTool {version}')
119120
for chunk in req.iter_content(chunk_size=1024):
120121
if chunk: # filter out keep-alive new chunks
121122
progress.update(len(chunk))

language_tool_python/server.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def __init__(
8787
self.enabled_categories = set()
8888
self.enabled_rules_only = False
8989
self.preferred_variants = set()
90+
self.picky = False
9091

9192
def __enter__(self):
9293
return self
@@ -161,6 +162,8 @@ def _create_params(self, text: str) -> Dict[str, str]:
161162
params['enabledCategories'] = ','.join(self.enabled_categories)
162163
if self.preferred_variants:
163164
params['preferredVariants'] = ','.join(self.preferred_variants)
165+
if self.picky:
166+
params['level'] = 'picky'
164167
return params
165168

166169
def correct(self, text: str) -> str:

0 commit comments

Comments
 (0)