本文整理汇总了Python中fnmatch.fnmatch.fnmatch方法的典型用法代码示例。如果您正苦于以下问题:Python fnmatch.fnmatch方法的具体用法?Python fnmatch.fnmatch怎么用?Python fnmatch.fnmatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fnmatch.fnmatch
的用法示例。
在下文中一共展示了fnmatch.fnmatch方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from fnmatch import fnmatch [as 别名]
# 或者: from fnmatch.fnmatch import fnmatch [as 别名]
def __init__(self, app, exports, disallow=None, cache=True,
cache_timeout=60 * 60 * 12, fallback_mimetype='text/plain'):
self.app = app
self.exports = {}
self.cache = cache
self.cache_timeout = cache_timeout
for key, value in iteritems(exports):
if isinstance(value, tuple):
loader = self.get_package_loader(*value)
elif isinstance(value, string_types):
if os.path.isfile(value):
loader = self.get_file_loader(value)
else:
loader = self.get_directory_loader(value)
else:
raise TypeError('unknown def %r' % value)
self.exports[key] = loader
if disallow is not None:
from fnmatch import fnmatch
self.is_allowed = lambda x: not fnmatch(x, disallow)
self.fallback_mimetype = fallback_mimetype
示例2: __init__
# 需要导入模块: from fnmatch import fnmatch [as 别名]
# 或者: from fnmatch.fnmatch import fnmatch [as 别名]
def __init__(self, app, exports, disallow=None, cache=True,
cache_timeout=60 * 60 * 12, fallback_mimetype='text/plain'):
self.app = app
self.exports = []
self.cache = cache
self.cache_timeout = cache_timeout
if hasattr(exports, 'items'):
exports = iteritems(exports)
for key, value in exports:
if isinstance(value, tuple):
loader = self.get_package_loader(*value)
elif isinstance(value, string_types):
if os.path.isfile(value):
loader = self.get_file_loader(value)
else:
loader = self.get_directory_loader(value)
else:
raise TypeError('unknown def %r' % value)
self.exports.append((key, loader))
if disallow is not None:
from fnmatch import fnmatch
self.is_allowed = lambda x: not fnmatch(x, disallow)
self.fallback_mimetype = fallback_mimetype
示例3: _no_match_line
# 需要导入模块: from fnmatch import fnmatch [as 别名]
# 或者: from fnmatch.fnmatch import fnmatch [as 别名]
def _no_match_line(
self, pat: str, match_func: Callable[[str, str], bool], match_nickname: str
) -> None:
"""Ensure captured lines does not have a the given pattern, using ``fnmatch.fnmatch``
:param str pat: the pattern to match lines
"""
__tracebackhide__ = True
nomatch_printed = False
wnick = len(match_nickname) + 1
for line in self.lines:
if match_func(line, pat):
msg = "{}: {!r}".format(match_nickname, pat)
self._log(msg)
self._log("{:>{width}}".format("with:", width=wnick), repr(line))
self._fail(msg)
else:
if not nomatch_printed:
self._log("{:>{width}}".format("nomatch:", width=wnick), repr(pat))
nomatch_printed = True
self._log("{:>{width}}".format("and:", width=wnick), repr(line))
self._log_output = []
示例4: __init__
# 需要导入模块: from fnmatch import fnmatch [as 别名]
# 或者: from fnmatch.fnmatch import fnmatch [as 别名]
def __init__(
self,
app,
exports,
disallow=None,
cache=True,
cache_timeout=60 * 60 * 12,
fallback_mimetype="text/plain",
):
self.app = app
self.exports = []
self.cache = cache
self.cache_timeout = cache_timeout
if hasattr(exports, "items"):
exports = exports.items()
for key, value in exports:
if isinstance(value, tuple):
loader = self.get_package_loader(*value)
elif isinstance(value, string_types):
if os.path.isfile(value):
loader = self.get_file_loader(value)
else:
loader = self.get_directory_loader(value)
else:
raise TypeError("unknown def %r" % value)
self.exports.append((key, loader))
if disallow is not None:
from fnmatch import fnmatch
self.is_allowed = lambda x: not fnmatch(x, disallow)
self.fallback_mimetype = fallback_mimetype
示例5: fnmatch_lines_random
# 需要导入模块: from fnmatch import fnmatch [as 别名]
# 或者: from fnmatch.fnmatch import fnmatch [as 别名]
def fnmatch_lines_random(self, lines2):
"""Check lines exist in the output using in any order.
Lines are checked using ``fnmatch.fnmatch``. The argument is a list of
lines which have to occur in the output, in any order.
"""
self._match_lines_random(lines2, fnmatch)
示例6: get_lines_after
# 需要导入模块: from fnmatch import fnmatch [as 别名]
# 或者: from fnmatch.fnmatch import fnmatch [as 别名]
def get_lines_after(self, fnline):
"""Return all lines following the given line in the text.
The given line can contain glob wildcards.
"""
for i, line in enumerate(self.lines):
if fnline == line or fnmatch(line, fnline):
return self.lines[i + 1 :]
raise ValueError("line %r not found in output" % fnline)
示例7: fnmatch_lines
# 需要导入模块: from fnmatch import fnmatch [as 别名]
# 或者: from fnmatch.fnmatch import fnmatch [as 别名]
def fnmatch_lines(self, lines2):
"""Search captured text for matching lines using ``fnmatch.fnmatch``.
The argument is a list of lines which have to match and can use glob
wildcards. If they do not match a pytest.fail() is called. The
matches and non-matches are also printed on stdout.
"""
__tracebackhide__ = True
self._match_lines(lines2, fnmatch, "fnmatch")
示例8: fnmatch_lines_random
# 需要导入模块: from fnmatch import fnmatch [as 别名]
# 或者: from fnmatch.fnmatch import fnmatch [as 别名]
def fnmatch_lines_random(self, lines2: Sequence[str]) -> None:
"""Check lines exist in the output in any order (using :func:`python:fnmatch.fnmatch`).
"""
__tracebackhide__ = True
self._match_lines_random(lines2, fnmatch)
示例9: get_lines_after
# 需要导入模块: from fnmatch import fnmatch [as 别名]
# 或者: from fnmatch.fnmatch import fnmatch [as 别名]
def get_lines_after(self, fnline: str) -> Sequence[str]:
"""Return all lines following the given line in the text.
The given line can contain glob wildcards.
"""
for i, line in enumerate(self.lines):
if fnline == line or fnmatch(line, fnline):
return self.lines[i + 1 :]
raise ValueError("line %r not found in output" % fnline)