fs.wildcard¶
Match wildcard filenames.
-
fs.wildcard.
get_matcher
(patterns, case_sensitive)¶ Get a callable that checks a list of names matches the given wildcard patterns.
Parameters: - patterns (list) – A list of wildcard pattern. e.g.
["*.py", "*.pyc"]
- case_sensitive (bool) – If True, then the callable will be case sensitive, otherwise it will be case insensitive.
Return type: callable
Here’s an example:
>>> import wildcard >>> is_python = wildcard.get_macher(['*.py']) >>> is_python('__init__.py') >>> True >>> is_python('foo.txt') >>> False
- patterns (list) – A list of wildcard pattern. e.g.
-
fs.wildcard.
imatch
(pattern, name)¶ Test whether
name
matchespattern
, ignoring case differences.Parameters: - pattern (str) – A wildcard pattern. e.g.
"*.py"
- name (str) – A filename
Return type: bool
- pattern (str) – A wildcard pattern. e.g.
-
fs.wildcard.
imatch_any
(patterns, name)¶ Test if a name matches at least one of a list of patterns, ignoring case differences. Will return
True
ifpatterns
is an empty list.Parameters: - patterns (list) – A list of wildcard pattern. e.g.
["*.py", "*.pyc"]
- name (str) – A filename.
Return type: bool
- patterns (list) – A list of wildcard pattern. e.g.
-
fs.wildcard.
match
(pattern, name)¶ Test whether
name
matchespattern
.Parameters: - pattern (str) – A wildcard pattern. e.g.
"*.py"
- name (str) – A filename
Return type: bool
- pattern (str) – A wildcard pattern. e.g.
-
fs.wildcard.
match_any
(patterns, name)¶ Test if a name matches at least one of a list of patterns. Will return
True
ifpatterns
is an empty list.Parameters: - patterns (list) – A list of wildcard pattern. e.g.
["*.py", "*.pyc"]
- name (str) – A filename.
Return type: bool
- patterns (list) – A list of wildcard pattern. e.g.