b2sdk._internal.scan.policies
- class b2sdk._internal.scan.policies.RegexSet(regex_iterable)[source]
Bases:
object
Hold a (possibly empty) set of regular expressions and know how to check whether a string matches any of them.
- b2sdk._internal.scan.policies.convert_dir_regex_to_dir_prefix_regex(dir_regex)[source]
The patterns used to match directory names (and file names) are allowed to match a prefix of the name. This ‘feature’ was unintentional, but is being retained for compatibility.
This means that a regex that matches a directory name can’t be used directly to match against a file name and test whether the file should be excluded because it matches the directory.
The pattern ‘photos’ will match directory names ‘photos’ and ‘photos2’, and should exclude files ‘photos/kitten.jpg’, and ‘photos2/puppy.jpg’. It should not exclude ‘photos.txt’, because there is no directory name that matches.
On the other hand, the pattern ‘photos$’ should match ‘photos/kitten.jpg’, but not ‘photos2/puppy.jpg’, nor ‘photos.txt’
If the original regex is valid, there are only two cases to consider: either the regex ends in ‘$’ or does not.
- class b2sdk._internal.scan.policies.IntegerRange(begin, end)[source]
Bases:
object
Hold a range of two integers. If the range value is None, it indicates that the value should be treated as -Inf (for begin) or +Inf (for end).
- class b2sdk._internal.scan.policies.ScanPoliciesManager(exclude_dir_regexes=(), exclude_file_regexes=(), include_file_regexes=(), exclude_all_symlinks=False, exclude_modified_before=None, exclude_modified_after=None, exclude_uploaded_before=None, exclude_uploaded_after=None)[source]
Bases:
object
Policy object used when scanning folders, used to decide which files to include in the list of files.
Code that scans through files should at least use should_exclude_file() to decide whether each file should be included; it will check include/exclude patterns for file names, as well as patterns for excluding directories.
Code that scans may optionally use should_exclude_directory() to test whether it can skip a directory completely and not bother listing the files and sub-directories in it.
- Parameters:
exclude_all_symlinks (
bool
) –
- __init__(exclude_dir_regexes=(), exclude_file_regexes=(), include_file_regexes=(), exclude_all_symlinks=False, exclude_modified_before=None, exclude_modified_after=None, exclude_uploaded_before=None, exclude_uploaded_after=None)[source]
- Parameters:
exclude_dir_regexes (
Iterable
[str
|Pattern
]) – regexes to exclude directoriesexclude_file_regexes (
Iterable
[str
|Pattern
]) – regexes to exclude filesinclude_file_regexes (
Iterable
[str
|Pattern
]) – regexes to include filesexclude_all_symlinks (
bool
) – if True, exclude all symlinksexclude_modified_before (
Optional
[int
]) – optionally exclude file versions (both local and b2) modified before (in millis)exclude_modified_after (
Optional
[int
]) – optionally exclude file versions (both local and b2) modified after (in millis)exclude_uploaded_before (
Optional
[int
]) – optionally exclude b2 file versions uploaded before (in millis)exclude_uploaded_after (
Optional
[int
]) – optionally exclude b2 file versions uploaded after (in millis)
The regex matching priority for a given path is: 1) the path is always excluded if it’s dir matches exclude_dir_regexes, if not then 2) the path is always included if it matches include_file_regexes, if not then 3) the path is excluded if it matches exclude_file_regexes, if not then 4) the path is included
- should_exclude_local_path(local_path)[source]
Whether a local path should be excluded from the scan or not.
This method assumes that the directory holding the path_ has already been checked for exclusion.
- Parameters:
local_path (
LocalPath
) –
- should_exclude_b2_file_version(file_version, relative_path)[source]
Whether a b2 file version should be excluded from the scan or not.
This method assumes that the directory holding the path_ has already been checked for exclusion.
- Parameters:
file_version (
FileVersion
) –relative_path (
str
) –