duplicity.globmatch module

exception duplicity.globmatch.FilePrefixError[source]

Bases: GlobbingError

Signals that a specified file doesn’t start with correct prefix

exception duplicity.globmatch.GlobbingError[source]

Bases: Exception

Something has gone wrong when parsing a glob string

duplicity.globmatch._glob_get_prefix_regexs(glob_str)[source]

Return list of regexps equivalent to prefixes of glob_str

duplicity.globmatch.glob_to_regex(pat)[source]

Returned regular expression equivalent to shell glob pat

Currently only the ?, , [], and * expressions are supported. Ranges like [a-z] are currently unsupported. There is no way to quote these special characters.

This function taken with minor modifications from efnmatch.py by Donovan Baarda.

duplicity.globmatch.select_fn_from_glob(glob_str, include, ignore_case=False)[source]

Return a function test_fn(path) which tests whether path matches glob, as per the Unix shell rules, taking as arguments a path, a glob string and include (0 indicating that the glob string is an exclude glob and 1 indicating that it is an include glob, returning:

0 - if the file should be excluded 1 - if the file should be included 2 - if the folder should be scanned for any included/excluded files None - if the selection function has nothing to say about the file

The basic idea is to turn glob_str into a regular expression, and just use the normal regular expression. There is a complication because the selection function should return ‘2’ (scan) for directories which may contain a file which matches the glob_str. So we break up the glob string into parts, and any file which matches an initial sequence of glob parts gets scanned.

Thanks to Donovan Baarda who provided some code which did some things similar to this.

Note: including a folder implicitly includes everything within it.