+ def parseArgs(self, localdir, topath):
+ self.from_dir = argv_to_abspath(localdir)
+ self.to_dir = argv_to_unicode(topath)
+
+ synopsis = "[options] FROM ALIAS:TO"
+
+ def opt_exclude(self, pattern):
+ """Ignore files matching a glob pattern. You may give multiple
+ '--exclude' options."""
+ g = argv_to_unicode(pattern).strip()
+ if g:
+ exclude = self['exclude']
+ exclude.add(g)
+
+ def opt_exclude_from(self, filepath):
+ """Ignore file matching glob patterns listed in file, one per
+ line. The file is assumed to be in the argv encoding."""
+ abs_filepath = argv_to_abspath(filepath)
+ try:
+ exclude_file = file(abs_filepath)
+ except:
+ raise BackupConfigurationError('Error opening exclude file %s.' % quote_local_unicode_path(abs_filepath))
+ try:
+ for line in exclude_file:
+ self.opt_exclude(line)
+ finally:
+ exclude_file.close()
+
+ def opt_exclude_vcs(self):
+ """Exclude files and directories used by following version control
+ systems: CVS, RCS, SCCS, Git, SVN, Arch, Bazaar(bzr), Mercurial,
+ Darcs."""
+ for pattern in self.vcs_patterns:
+ self.opt_exclude(pattern)
+
+ def filter_listdir(self, listdir):
+ """Yields non-excluded childpaths in path."""
+ exclude = self['exclude']
+ exclude_regexps = [re.compile(fnmatch.translate(pat)) for pat in exclude]
+ for filename in listdir:
+ for regexp in exclude_regexps:
+ if regexp.match(filename):
+ break
+ else:
+ yield filename