本文整理匯總了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)