diff options
| author | 2014-02-28 08:49:41 -0300 | |
|---|---|---|
| committer | 2014-02-28 08:49:41 -0300 | |
| commit | 0f1e24f7888ba16fe5629c57fd00f0deacb63e5e (patch) | |
| tree | 7153a3a11b766f375b1d1c0a7adc599e0a9f9c55 /dodo.py | |
| parent | 04fc43563d3d5d4218004690b5e14c19c67bdcbc (diff) | |
| parent | 2828399ba5cbb14502b023d4de1ba02f13dd5055 (diff) | |
Merge tag 'upstream/6.3.0'
Upstream version 6.3.0
Diffstat (limited to 'dodo.py')
| -rw-r--r-- | dodo.py | 88 |
1 files changed, 88 insertions, 0 deletions
@@ -0,0 +1,88 @@ + +import os +import fnmatch +import locale +import subprocess + +DOIT_CONFIG = { + 'default_tasks': ['flake8', 'test'], + 'reporter': 'executed-only', +} + + +def recursive_glob(path, pattern): + """recursively walk path directories and return files matching the pattern""" + for root, dirnames, filenames in os.walk(path): + for filename in fnmatch.filter(filenames, pattern): + yield os.path.join(root, filename) + + +def task_flake8(): + """flake8 - static check for python files""" + for fname in recursive_glob('.', '*.py'): + if fname.startswith('./cache'): + continue + yield { + 'name': fname, + 'actions': ['flake8 --ignore=E501 {0}'.format(fname)], + 'file_dep': [fname], + } + + +def task_locale(): + """set environ locale vars used in nikola tests""" + def set_nikola_test_locales(): + try: + out = subprocess.check_output(['locale', '-a']) + locales = [] + languages = set() + for line in out.splitlines(): + if line.endswith('.utf8') and '_' in line: + lang = line.split('_')[0] + if lang not in languages: + try: + locale.setlocale(locale.LC_ALL, line) + except: + continue + languages.add(lang) + locales.append((lang, line)) + if len(locales) == 2: + break + if len(locales) != 2: + return False # task failed + else: + os.environ['NIKOLA_LOCALE_DEFAULT'] = ','.join(locales[0]) + os.environ['NIKOLA_LOCALE_OTHER'] = ','.join(locales[1]) + finally: + # restore to default locale + locale.resetlocale() + + return {'actions': [set_nikola_test_locales], 'verbosity': 2} + + +def task_test(): + """run unit-tests using nose""" + return { + 'task_dep': ['locale'], + 'actions': ['nosetests'], + } + + +def task_coverage(): + """run unit-tests using nose""" + return { + 'task_dep': ['locale'], + 'actions': ['nosetests --with-coverage --cover-package=nikola --with-doctest --doctest-options=+NORMALIZE_WHITESPACE --logging-filter=-yapsy'], + 'verbosity': 2, + } + + +def task_gen_completion(): + """generate tab-completion scripts""" + cmd = 'nikola tabcompletion --shell {0} --hardcode-tasks > _nikola_{0}' + for shell in ('bash', 'zsh'): + yield { + 'name': shell, + 'actions': [cmd.format(shell)], + 'targets': ['_nikola_{0}'.format(shell)], + } |
