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


Python Error.formatError方法代码示例

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


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

示例1: validateCommands

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import formatError [as 别名]
    def validateCommands(commands):
        for layer in commands:
            for command in layer:
                # test if the command is valid
                Tagger.getTagsForCommand(command)

                # test if size is a valid number
                if re.match(SIZE, command):
                    if(int(command[SPLIT_SIZE:]) not in range(1, 8)):
                        Error.formatError()
                # test if color is valid HEX
                elif re.match('color:[a-zA-Z0-9]+', command):
                    code = command.split(':')[-1]
                    if not re.match('[0-9a-fA-F]{6}', code):
                        Error.formatError()
开发者ID:jvitasek,项目名称:VUT-FIT-IPP-Proj3,代码行数:17,代码来源:tagger.py

示例2: getTagsForCommand

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import formatError [as 别名]
 def getTagsForCommand(command):
     if command == BOLD:
         return ('<b>', '</b>')
     elif command == ITALIC:
         return ('<i>', '</i>')
     elif command == UNDERLINE:
         return ('<u>', '</u>')
     elif command == TELETYPE:
         return ('<tt>', '</tt>')
     elif re.match(SIZE, command):
         if(int(command[SPLIT_SIZE:]) not in range(1, 8)):
             Error.formatError()
         return ('<font size=' + command[SPLIT_SIZE:] + '>', '</font>')
     elif re.match(COLOR, command):
         return ('<font color=#' + command[MAX_COLOR:] + '>', '</font>')
     # invalid command keyword
     else:
         Error.formatError()
开发者ID:jvitasek,项目名称:VUT-FIT-IPP-Proj3,代码行数:20,代码来源:tagger.py

示例3: testFormatErrorReturnValue

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import formatError [as 别名]
    def testFormatErrorReturnValue(self):
        with self.assertRaises(SystemExit) as exit_val:
            Error.formatError()

        self.assertEqual(exit_val.exception.code, 4)
开发者ID:jvitasek,项目名称:VUT-FIT-IPP-Proj3,代码行数:7,代码来源:test.py

示例4: validateExpressions

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import formatError [as 别名]
    def validateExpressions(expressions):
        for expression in expressions:
            # two dots (without the percent sign)
            if re.search('(?<!%)\.\.', expression):
                Error.formatError()

            # invalid after exclamation point
            elif re.search('![\\\|\+\)\*\.!]', expression):
                Error.formatError()

            # invalid after dot
            elif re.search('\.[\*\|\+\)]', expression):
                Error.formatError()

            # invalid after pipe
            elif re.search('\|[\*\|\+\)\.]', expression):
                Error.formatError()

            # invalid after plus
            elif re.search('\+[\*\+!]', expression):
                Error.formatError()

            # invalid after asterisk
            elif re.search('\*[\*\|\+!]', expression):
                Error.formatError()

            # invalid after left parenthesis
            elif re.search('\([\*\+\.]', expression):
                Error.formatError()

            # empty priority parentheses
            elif re.search('\((\s+)?\)', expression):
                Error.formatError()
开发者ID:jvitasek,项目名称:VUT-FIT-IPP-Proj3,代码行数:35,代码来源:tagger.py

示例5: makeRegex

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import formatError [as 别名]
    def makeRegex(expression):
        regex = ''
        p = False
        spec = False

        for i in range(0, len(expression)):
            # after % or !
            if p is True:
                p = False
                spec = False
                if expression[i] == '%':
                    regex += '%'
                elif expression[i] == 's':
                    regex += '\s'
                elif expression[i] == 'a':
                    regex += '.'
                elif expression[i] == 'd':
                    regex += '\d'
                elif expression[i] == 'l':
                    regex += '[a-z]'
                elif expression[i] == 'L':
                    regex += '[A-Z]'
                elif expression[i] == 'w':
                    regex += '[a-zA-Z]'
                elif expression[i] == 'W':
                    regex += '[a-zA-Z0-9]'
                elif expression[i] == 't':
                    regex += '\\t'
                elif expression[i] == 'n':
                    regex += '\\n'
                elif expression[i] == '.':
                    regex += '\.'
                elif expression[i] == '|':
                    regex += '\|'
                elif expression[i] == '!':
                    regex += '!'
                elif expression[i] == '*':
                    regex += '\*'
                elif expression[i] == '+':
                    regex += '\+'
                elif expression[i] == '(':
                    regex += '\('
                elif expression[i] == ')':
                    regex += '\)'
                elif expression[i] == '\\':
                    regex += '\\\\\\\\'

            # not after % or !
            else:
                # following special regex
                if expression[i] == '%' or expression[i] == '\\':
                    p = True  # after %
                    continue
                # negation
                elif expression[i] == '!':
                    p = True
                    continue
                # skipping concatenation
                elif expression[i] == '.':
                    spec = True
                    continue
                # any standalone characters
                elif expression[i] == '|':
                    spec = True
                    regex += expression[i]
                    continue
                # any character other than the above
                regex += expression[i]
                spec = False

        if p is True or spec is True:
            Error.formatError()

        return regex
开发者ID:jvitasek,项目名称:VUT-FIT-IPP-Proj3,代码行数:76,代码来源:tagger.py


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