diff options
author | Lars Wirzenius <liw@liw.fi> | 2015-08-28 19:34:27 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-08-28 19:34:27 +0300 |
commit | 2d5d67229226caf9998c333b0e139e8275785460 (patch) | |
tree | 03a2dfbf074b36de8fdb7b0af8552e052a06fbfd /obnamlib/plugins/exclude_pathnames_plugin.py | |
parent | 88779962676b5d81c2b57b2fb12aff88467e1bfc (diff) | |
download | obnam-2d5d67229226caf9998c333b0e139e8275785460.tar.gz |
Put back progress.error call
Diffstat (limited to 'obnamlib/plugins/exclude_pathnames_plugin.py')
-rw-r--r-- | obnamlib/plugins/exclude_pathnames_plugin.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/obnamlib/plugins/exclude_pathnames_plugin.py b/obnamlib/plugins/exclude_pathnames_plugin.py index eeeaa27f..a72e2d59 100644 --- a/obnamlib/plugins/exclude_pathnames_plugin.py +++ b/obnamlib/plugins/exclude_pathnames_plugin.py @@ -54,10 +54,16 @@ class ExcludePathnamesPlugin(obnamlib.ObnamPlugin): def config_loaded(self): self.app.hooks.add_callback('backup-exclude', self.exclude) self.pathname_excluder = obnamlib.PathnameExcluder() - self.compile_exclusion_patterns() - self.compile_inclusion_patterns() + self.patterns_have_been_compiled = False + + def exclude(self, pathname=None, stat_result=None, exclude=None, + progress=None, **kwargs): + + if not self.patterns_have_been_compiled: + self.compile_exclusion_patterns(progress) + self.compile_inclusion_patterns(progress) + self.patterns_have_been_compiled = True - def exclude(self, pathname=None, stat_result=None, exclude=None, **kwargs): is_excluded, regexp = self.pathname_excluder.exclude(pathname) if is_excluded: logging.debug('Exclude (pattern): %s', pathname) @@ -65,7 +71,7 @@ class ExcludePathnamesPlugin(obnamlib.ObnamPlugin): elif regexp is not None: logging.debug('Include due to regexp: %s', pathname) - def compile_exclusion_patterns(self): + def compile_exclusion_patterns(self, progress): regexps = self.read_patterns_from_files( self.app.settings['exclude-from']) @@ -78,15 +84,17 @@ class ExcludePathnamesPlugin(obnamlib.ObnamPlugin): regexps.append(log) logging.debug('Compiling exclusion patterns') - self.compile_regexps(regexps, self.pathname_excluder.exclude_regexp) + self.compile_regexps( + regexps, self.pathname_excluder.exclude_regexp, progress) - def compile_inclusion_patterns(self): + def compile_inclusion_patterns(self, progress): logging.debug('Compiling inclusion patterns') self.compile_regexps( self.app.settings['include'], - self.pathname_excluder.allow_regexp) + self.pathname_excluder.allow_regexp, + progress) - def compile_regexps(self, regexps, compiler): + def compile_regexps(self, regexps, compiler, progress): for regexp in regexps: if not regexp: logging.debug('Ignoring empty pattern') @@ -98,6 +106,7 @@ class ExcludePathnamesPlugin(obnamlib.ObnamPlugin): msg = ('error compiling regular expression "%s": %s' % (regexp, e)) logging.error(msg) + progress.error(msg) def read_patterns_from_files(self, filenames): patterns = [] |