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


Python Group.suppress方法代码示例

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


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

示例1: simplify_name

# 需要导入模块: from pyparsing import Group [as 别名]
# 或者: from pyparsing.Group import suppress [as 别名]
    def simplify_name(self, name):
        simple = name
        year = Group(ZeroOrMore("[" + Word(nums, exact=4) +
                                "-" + Word(nums, exact=2) + "]"))

        dash = Group(ZeroOrMore(White() + "-" + White()))
        no_squared_brackets = Word(
            alphanums+alphas8bit,
            ",;.:[email protected]#°§+*{}^'?=)(/&%$£!\\|\""
        )
        bracketed = Group("[" + OneOrMore(no_squared_brackets) + "]")
        middle = ~bracketed + OneOrMore(Word(alphanums+alphas8bit+"'"))
        try:
            grammar = year.suppress() + dash.suppress() + middle
            simple = " ".join(grammar.parseString(name))
        except ParseException:
            commonlogger.error(f'Failed to simplify course name {name}',
                               exc_info=True)
        return simple.title()
开发者ID:davethecipo,项目名称:polibeepsync,代码行数:21,代码来源:common.py

示例2: delimitedList

# 需要导入模块: from pyparsing import Group [as 别名]
# 或者: from pyparsing.Group import suppress [as 别名]
string.setParseAction(lambda toks: ["'%s'" % toks[0]])

columnName = delimitedList( ident, ".",combine=True)
tableName = delimitedList( ident, ".",combine=True)
dataType = Word(alphas) + Combine(Optional(Literal("(") + (Word(nums) ^ delimitedList(string,combine=True)) + Literal(")"))) + ZeroOrMore(nnToken ^ autoincrementToken ^ (defaultToken + (string ^ nullToken)) ^ unsignedToken.suppress() )
dataType.setParseAction(convert_datatypes)

columnDescription = Group(ident + dataType)
keyDescription = Optional(primaryToken ^ uniqueToken) + keyToken + Optional(ident) + Literal("(") + delimitedList(ident + Optional(Literal("(") + Word(nums) + Literal(")"))) + Literal(")")

createTableStmt = Group(createToken + tableToken + ifneToken + ident + Literal("(")) + delimitedList(columnDescription ^ keyDescription.suppress()) + Group(Literal(")")) + Optional(autoincrementToken + Literal("=") + Word(nums)).suppress()
createTableStmt.setParseAction(rebuild_createtable)


createDataBaseStmt = Group(createToken + databaseToken + ident +  dcsToken + Word(alphanums)+ collateToken + ident)

useStmt = Group(useToken + ident)

comment = LineStart() + CharsNotIn("\n") + LineEnd()

value = Group(Literal("(") + delimitedList(Word(nums) ^ string) + Literal(")"))

insertPrefix = Group(insertToken + intoToken + ident + Literal("(") + delimitedList(ident) + Literal(")") + valuesToken)

insertStmt = insertPrefix + delimitedList(value)
insertStmt.setParseAction(rebuild_insert)

statement = ((createTableStmt ^ createDataBaseStmt.suppress() ^ useStmt.suppress() ^ insertStmt)  + Literal(";").setParseAction(lambda: [";\n"])) ^ comment.suppress() ^ White().suppress()

sql = ZeroOrMore(statement)
开发者ID:ixtel,项目名称:mysql2sqlite3,代码行数:32,代码来源:sqlparser.py


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