diff options
Diffstat (limited to 'parabola_repolint/fixer.py')
-rw-r--r-- | parabola_repolint/fixer.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/parabola_repolint/fixer.py b/parabola_repolint/fixer.py new file mode 100644 index 0000000..fc0eb5a --- /dev/null +++ b/parabola_repolint/fixer.py @@ -0,0 +1,37 @@ +''' +this module provides the linter issue autofixer +''' + +import os +import sh +import logging + +from parabola_repolint.config import CONFIG + + +class Fixer(): + ''' the master fixer class ''' + + def __init__(self, repo_cache): + ''' constructor ''' + self._cache = repo_cache + + def run_fixes(self, checks): + ''' run the fixes for the given issues ''' + for check in checks: + base_path = os.path.join(CONFIG.fixhooks.scriptroot, str(check)) + if not os.path.exists(base_path): + continue + + for issue in check.issues: + fixbase = check.fixhook_base(issue) + fixargs = check.fixhook_args(issue) + + path = os.path.join(base_path, fixbase + '.sh') + if not os.path.exists(path): + continue + + try: + sh.bash(path, fixbase, fixargs, _cwd=CONFIG.fixhooks.abslibre) + except sh.ErrorReturnCode: + logging.exception('%s fixhook failed for %s (%s)', check, fixbase, ', '.join(fixargs)) |