當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。