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


Python pyparsing.alphas方法代码示例

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


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

示例1: getLogLineBNF

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import alphas [as 别名]
def getLogLineBNF():
    global logLineBNF
    
    if logLineBNF is None:
        integer = Word( nums )
        ipAddress = delimitedList( integer, ".", combine=True )
        
        timeZoneOffset = Word("+-",nums)
        month = Word(string.uppercase, string.lowercase, exact=3)
        serverDateTime = Group( Suppress("[") + 
                                Combine( integer + "/" + month + "/" + integer +
                                        ":" + integer + ":" + integer + ":" + integer ) +
                                timeZoneOffset + 
                                Suppress("]") )
                         
        logLineBNF = ( ipAddress.setResultsName("ipAddr") + 
                       Suppress("-") +
                       ("-" | Word( alphas+nums+"@._" )).setResultsName("auth") +
                       serverDateTime.setResultsName("timestamp") + 
                       dblQuotedString.setResultsName("cmd").setParseAction(getCmdFields) +
                       (integer | "-").setResultsName("statusCode") + 
                       (integer | "-").setResultsName("numBytesSent")  + 
                       dblQuotedString.setResultsName("referrer").setParseAction(removeQuotes) +
                       dblQuotedString.setResultsName("clientSfw").setParseAction(removeQuotes) )
    return logLineBNF 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:27,代码来源:httpServerLogParser.py

示例2: _globalParse___ssh_attributes

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import alphas [as 别名]
def _globalParse___ssh_attributes(line):
    ssh_dict = {}

    ssh_option = (Word(alphas + '-'))('option')
    ssh_value  = (restOfLine)        ('value')

    result     = (ssh_option + White() + ssh_value).parseString(line)

    if   result.option == 'logging':
        ssh_dict['logging-events']         = 'yes'
    elif result.option == 'authentication-retries':
        ssh_dict['authentication_retries'] = result.value.split()[0]
    elif result.option == 'port':
        ssh_dict['port_rotary']            = result.value.split()[0]
    elif result.option == 'maxstartups':
        ssh_dict['maxstartups']            = result.value.split()[0]
    elif result.option == 'time-out':
        ssh_dict['time-out']               = result.value.split()[0]
    elif result.option == 'version':
        ssh_dict['version']                = result.value.split()[0]

    return ssh_dict 
开发者ID:cisco-config-analysis-tool,项目名称:ccat,代码行数:24,代码来源:ssh.py

示例3: __ifaceAttributes___storm_check

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import alphas [as 别名]
def __ifaceAttributes___storm_check(storm,dct):

    parse_level  = Word(alphas)        + Suppress('level ')            + restOfLine
    parse_action = Suppress('action ') + Word(alphas)
    parse_type   = Word(alphas)        + Suppress(Optional("include")) + Word(alphas)
    try:
        value = parse_level.parseString(storm).asList()
        if 'level' in dct:
            dct['level'].append(value)
        else:
            dct['level'] = [value]
        return dct
    except ParseException:
        pass
    try:
        return util.int_dict_parse(parse_action, storm, 'action', dct)
    except ParseException:
        pass
    try:
        return util.int_dict_parse(parse_type,   storm, 'type',   dct)
    except ParseException:
        pass 
开发者ID:cisco-config-analysis-tool,项目名称:ccat,代码行数:24,代码来源:storm_control.py

示例4: grammar

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import alphas [as 别名]
def grammar():
    parenthesis = Forward()
    parenthesis <<= "(" + ZeroOrMore(CharsNotIn("()") | parenthesis) + ")"

    field_def = OneOrMore(Word(alphanums + "_\"'`:-") | parenthesis)
    field_def.setParseAction(field_act)

    tablename_def = ( Word(alphas + "`_") | QuotedString("\"") )

    field_list_def = field_def + ZeroOrMore(Suppress(",") + field_def)
    field_list_def.setParseAction(field_list_act)

    create_table_def = Literal("CREATE") + "TABLE" + tablename_def.setResultsName("tableName") + "(" + field_list_def.setResultsName("fields") + ")" + ";"
    create_table_def.setParseAction(create_table_act)

    add_fkey_def = Literal("FOREIGN") + "KEY" + "(" + Word(alphanums).setResultsName("keyName") + ")" + "REFERENCES" + Word(alphanums).setResultsName("fkTable") + "(" + Word(alphanums + "_").setResultsName("fkCol") + ")" + Optional(Literal("DEFERRABLE")) + ";"
    add_fkey_def.setParseAction(add_fkey_act)

    other_statement_def = OneOrMore(CharsNotIn(";")) + ";"
    other_statement_def.setParseAction(other_statement_act)

    comment_def = "--" + ZeroOrMore(CharsNotIn("\n"))
    comment_def.setParseAction(other_statement_act)

    return OneOrMore(comment_def | create_table_def | add_fkey_def | other_statement_def) 
开发者ID:LGE-ARC-AdvancedAI,项目名称:auptimizer,代码行数:27,代码来源:sql_graphviz.py

示例5: __call__

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import alphas [as 别名]
def __call__(self, name=None):
        """Shortcut for C{L{setResultsName}}, with C{listAllMatches=default}::
             userdata = Word(alphas).setResultsName("name") + Word(nums+"-").setResultsName("socsecno")
           could be written as::
             userdata = Word(alphas)("name") + Word(nums+"-")("socsecno")
             
           If C{name} is given with a trailing C{'*'} character, then C{listAllMatches} will be
           passed as C{True}.
           
           If C{name} is omitted, same as calling C{L{copy}}.
           """
        if name is not None:
            return self.setResultsName(name)
        else:
            return self.copy() 
开发者ID:vulscanteam,项目名称:vulscan,代码行数:17,代码来源:pyparsing.py

示例6: _makeTags

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import alphas [as 别名]
def _makeTags(tagStr, xml):
    """Internal helper to construct opening and closing tag expressions, given a tag name"""
    if isinstance(tagStr,basestring):
        resname = tagStr
        tagStr = Keyword(tagStr, caseless=not xml)
    else:
        resname = tagStr.name

    tagAttrName = Word(alphas,alphanums+"_-:")
    if (xml):
        tagAttrValue = dblQuotedString.copy().setParseAction( removeQuotes )
        openTag = Suppress("<") + tagStr("tag") + \
                Dict(ZeroOrMore(Group( tagAttrName + Suppress("=") + tagAttrValue ))) + \
                Optional("/",default=[False]).setResultsName("empty").setParseAction(lambda s,l,t:t[0]=='/') + Suppress(">")
    else:
        printablesLessRAbrack = "".join(c for c in printables if c not in ">")
        tagAttrValue = quotedString.copy().setParseAction( removeQuotes ) | Word(printablesLessRAbrack)
        openTag = Suppress("<") + tagStr("tag") + \
                Dict(ZeroOrMore(Group( tagAttrName.setParseAction(downcaseTokens) + \
                Optional( Suppress("=") + tagAttrValue ) ))) + \
                Optional("/",default=[False]).setResultsName("empty").setParseAction(lambda s,l,t:t[0]=='/') + Suppress(">")
    closeTag = Combine(_L("</") + tagStr + ">")

    openTag = openTag.setResultsName("start"+"".join(resname.replace(":"," ").title().split())).setName("<%s>" % tagStr)
    closeTag = closeTag.setResultsName("end"+"".join(resname.replace(":"," ").title().split())).setName("</%s>" % tagStr)
    openTag.tag = resname
    closeTag.tag = resname
    return openTag, closeTag 
开发者ID:vulscanteam,项目名称:vulscan,代码行数:30,代码来源:pyparsing.py

示例7: _makeTags

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import alphas [as 别名]
def _makeTags(tagStr, xml):
    """Internal helper to construct opening and closing tag expressions, given a tag name"""
    if isinstance(tagStr,basestring):
        resname = tagStr
        tagStr = Keyword(tagStr, caseless=not xml)
    else:
        resname = tagStr.name

    tagAttrName = Word(alphas,alphanums+"_-:")
    if (xml):
        tagAttrValue = dblQuotedString.copy().setParseAction( removeQuotes )
        openTag = Suppress("<") + tagStr("tag") + \
                Dict(ZeroOrMore(Group( tagAttrName + Suppress("=") + tagAttrValue ))) + \
                Optional("/",default=[False]).setResultsName("empty").setParseAction(lambda s,l,t:t[0]=='/') + Suppress(">")
    else:
        printablesLessRAbrack = "".join(c for c in printables if c not in ">")
        tagAttrValue = quotedString.copy().setParseAction( removeQuotes ) | Word(printablesLessRAbrack)
        openTag = Suppress("<") + tagStr("tag") + \
                Dict(ZeroOrMore(Group( tagAttrName.setParseAction(downcaseTokens) + \
                Optional( Suppress("=") + tagAttrValue ) ))) + \
                Optional("/",default=[False]).setResultsName("empty").setParseAction(lambda s,l,t:t[0]=='/') + Suppress(">")
    closeTag = Combine(_L("</") + tagStr + ">")

    openTag = openTag.setResultsName("start"+"".join(resname.replace(":"," ").title().split())).setName("<%s>" % resname)
    closeTag = closeTag.setResultsName("end"+"".join(resname.replace(":"," ").title().split())).setName("</%s>" % resname)
    openTag.tag = resname
    closeTag.tag = resname
    return openTag, closeTag 
开发者ID:jpush,项目名称:jbox,代码行数:30,代码来源:pyparsing.py

示例8: _identifier_with_dots

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import alphas [as 别名]
def _identifier_with_dots(self):
        return pyparsing.Word(
            pyparsing.alphas + '_.', pyparsing.alphanums + '_.') 
开发者ID:google,项目名称:rekall,代码行数:5,代码来源:expression_parser.py

示例9: _identifier

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import alphas [as 别名]
def _identifier(self):
        proper_identifier = pyparsing.Word(
            pyparsing.alphas + '_',
            pyparsing.alphanums + '_',
        )
        return (
            (~_KEYWORD)
            + proper_identifier
        ) 
开发者ID:google,项目名称:rekall,代码行数:11,代码来源:c_parser.py

示例10: __ifaceAttributes___ip_parse

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import alphas [as 别名]
def __ifaceAttributes___ip_parse(value, dct):
    parse_mode = Word(alphas)
    parse_rate = Suppress('limit rate ') + restOfLine
    try:
        return util.int_dict_parse(parse_rate, value, 'limit', dct)
    except ParseException:
        pass
    try:
        return util.int_dict_parse(parse_mode, value, 'mode', dct)
    except ParseException:
        pass 
开发者ID:cisco-config-analysis-tool,项目名称:ccat,代码行数:13,代码来源:ip_iface.py

示例11: __call__

# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import alphas [as 别名]
def __call__(self, name):
        """Shortcut for C{L{setResultsName}}, with C{listAllMatches=default}::
             userdata = Word(alphas).setResultsName("name") + Word(nums+"-").setResultsName("socsecno")
           could be written as::
             userdata = Word(alphas)("name") + Word(nums+"-")("socsecno")
             
           If C{name} is given with a trailing C{'*'} character, then C{listAllMatches} will be
           passed as C{True}.
           """
        return self.setResultsName(name) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:12,代码来源:pyparsing.py


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