当前位置: 首页>>代码示例>>Python>>正文


Python fnmatch.fnmatch方法代码示例

本文整理汇总了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 
开发者ID:jpush,项目名称:jbox,代码行数:23,代码来源:wsgi.py

示例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 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:25,代码来源:wsgi.py

示例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 = [] 
开发者ID:pytest-dev,项目名称:pytest,代码行数:24,代码来源:pytester.py

示例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 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:38,代码来源:shared_data.py

示例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) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:10,代码来源:pytester.py

示例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) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:12,代码来源:pytester.py

示例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") 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:12,代码来源:pytester.py

示例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) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:7,代码来源:pytester.py

示例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) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:11,代码来源:pytester.py


注:本文中的fnmatch.fnmatch.fnmatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。