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


Python sre_compile.error方法代码示例

本文整理汇总了Python中sre_compile.error方法的典型用法代码示例。如果您正苦于以下问题:Python sre_compile.error方法的具体用法?Python sre_compile.error怎么用?Python sre_compile.error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sre_compile的用法示例。


在下文中一共展示了sre_compile.error方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _compile

# 需要导入模块: import sre_compile [as 别名]
# 或者: from sre_compile import error [as 别名]
def _compile(*key):
    # internal: compile pattern
    pattern, flags = key
    bypass_cache = flags & DEBUG
    if not bypass_cache:
        cachekey = (type(key[0]),) + key
        try:
            p, loc = _cache[cachekey]
            if loc is None or loc == _locale.setlocale(_locale.LC_CTYPE):
                return p
        except KeyError:
            pass
    if isinstance(pattern, _pattern_type):
        if flags:
            raise ValueError('Cannot process flags argument with a compiled pattern')
        return pattern
    if not sre_compile.isstring(pattern):
        raise TypeError, "first argument must be string or compiled pattern"
    try:
        p = sre_compile.compile(pattern, flags)
    except error, v:
        raise error, v # invalid expression 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:re.py

示例2: _compile

# 需要导入模块: import sre_compile [as 别名]
# 或者: from sre_compile import error [as 别名]
def _compile(*key):
    # internal: compile pattern
    cachekey = (type(key[0]),) + key
    p = _cache.get(cachekey)
    if p is not None:
        return p
    pattern, flags = key
    if isinstance(pattern, _pattern_type):
        if flags:
            raise ValueError('Cannot process flags argument with a compiled pattern')
        return pattern
    if not sre_compile.isstring(pattern):
        raise TypeError, "first argument must be string or compiled pattern"
    try:
        p = sre_compile.compile(pattern, flags)
    except error, v:
        raise error, v # invalid expression 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:19,代码来源:re.py

示例3: match_log

# 需要导入模块: import sre_compile [as 别名]
# 或者: from sre_compile import error [as 别名]
def match_log(self, line):
        """
        Matches lines from compare log with the target serial output. Compare log lines are matched in seq using index
        self.compare_log_idx. Lines can be strings to be matched as is or regular expressions.

        :param line:
        :return:
        """
        if self.compare_log_idx < len(self.compare_log):
            regex = self.compare_log[self.compare_log_idx]
            # Either the line is matched as is or it is checked as a regular expression.
            try:
                if regex in line or re.search(regex, line):
                    self.compare_log_idx += 1
            except error:
                # May not be a regular expression
                return False
        return self.compare_log_idx == len(self.compare_log) 
开发者ID:ARMmbed,项目名称:mbed-os-tools,代码行数:20,代码来源:host_test_default.py

示例4: _compile_repl

# 需要导入模块: import sre_compile [as 别名]
# 或者: from sre_compile import error [as 别名]
def _compile_repl(*key):
    # internal: compile replacement pattern
    p = _cache_repl.get(key)
    if p is not None:
        return p
    repl, pattern = key
    try:
        p = sre_parse.parse_template(repl, pattern)
    except error, v:
        raise error, v # invalid expression 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:re.py

示例5: _compile

# 需要导入模块: import sre_compile [as 别名]
# 或者: from sre_compile import error [as 别名]
def _compile(*key):
    # internal: compile pattern
    cachekey = (type(key[0]),) + key
    p = _cache.get(cachekey)
    if p is not None:
        return p
    pattern, flags = key
    if isinstance(pattern, _pattern_type):
        return pattern
    if not sre_compile.isstring(pattern):
        raise TypeError, "first argument must be string or compiled pattern"
    try:
        p = sre_compile.compile(pattern, flags)
    except error, v:
        raise error, v # invalid expression 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:17,代码来源:re.py


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