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.
参数: - 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.
返回类型: 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
namematchespattern, ignoring case differences.参数: - pattern (str) – A wildcard pattern. e.g.
"*.py" - name (str) – A filename
返回类型: 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
Trueifpatternsis an empty list.参数: - patterns (list) – A list of wildcard pattern. e.g.
["*.py", "*.pyc"] - name (str) – A filename.
返回类型: bool
- patterns (list) – A list of wildcard pattern. e.g.
-
fs.wildcard.match(pattern, name)¶ Test whether
namematchespattern.参数: - pattern (str) – A wildcard pattern. e.g.
"*.py" - name (str) – A filename
返回类型: 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
Trueifpatternsis an empty list.参数: - patterns (list) – A list of wildcard pattern. e.g.
["*.py", "*.pyc"] - name (str) – A filename.
返回类型: bool
- patterns (list) – A list of wildcard pattern. e.g.