From 9784c2e0469e7c8619cacbfb14249288763bba87 Mon Sep 17 00:00:00 2001 From: Anton Bobov Date: Wed, 23 Sep 2020 22:06:27 +0500 Subject: Updates. --- files/.task/hooks/on-add-spell-check.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'files/.task') diff --git a/files/.task/hooks/on-add-spell-check.py b/files/.task/hooks/on-add-spell-check.py index 16758f0..6ddb6de 100755 --- a/files/.task/hooks/on-add-spell-check.py +++ b/files/.task/hooks/on-add-spell-check.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 -from glob import glob -from os.path import isfile, splitext import os import re import sys +from glob import glob +from os.path import isfile, splitext try: from hunspell import HunSpell @@ -12,7 +12,6 @@ except ImportError as e: print(e) sys.exit(0) - DICT_PATH = '/usr/share/hunspell/' LANGS = ['en_US', 'ru_RU'] ENV_SKIP = 'TW_IGNORE_SPELL' @@ -41,10 +40,20 @@ def spellcheck(text): return errors + +def should_run_spellcheck(task): + if len(sys.argv) > 1: + opts = dict(arg.split(':', 1) for arg in sys.argv[1:]) + command = opts['command'] + return command in ['add', 'append', 'log', 'modify', 'prepend'] + return False + + task = Task.from_input() -errors = spellcheck(task['description']) -if len(errors) > 0: - print('Spell errors:', ', '.join(errors)) - if not ENV_SKIP in os.environ: - sys.exit(1) +if should_run_spellcheck(task): + errors = spellcheck(task['description']) + if len(errors) > 0: + print('Spell errors:', ', '.join(errors)) + if not ENV_SKIP in os.environ: + sys.exit(1) print(task.export_data()) -- cgit v1.2.3