本文整理汇总了Python中pyparsing.Literal.ignore方法的典型用法代码示例。如果您正苦于以下问题:Python Literal.ignore方法的具体用法?Python Literal.ignore怎么用?Python Literal.ignore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyparsing.Literal
的用法示例。
在下文中一共展示了Literal.ignore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_log_formats
# 需要导入模块: from pyparsing import Literal [as 别名]
# 或者: from pyparsing.Literal import ignore [as 别名]
def get_log_formats(config):
"""
Parse config for log_format directives
:return: iterator over ('format name', 'format string') tuple of found directives
"""
# log_format name [params]
log_format = Literal('log_format') + parameter + Group(OneOrMore(parameter)) + semicolon
log_format.ignore(pythonStyleComment)
for directive in log_format.searchString(config).asList():
name = directive[1]
format_string = ''.join(directive[2])
yield name, format_string
示例2: get_access_logs
# 需要导入模块: from pyparsing import Literal [as 别名]
# 或者: from pyparsing.Literal import ignore [as 别名]
def get_access_logs(config):
"""
Parse config for access_log directives
:return: iterator over ('path', 'format name') tuple of found directives
"""
access_log = Literal("access_log") + ZeroOrMore(parameter) + semicolon
access_log.ignore(pythonStyleComment)
for directive in access_log.searchString(config).asList():
path = directive[1]
if path == 'off' or path.startswith('syslog:'):
# nothing to process here
continue
format_name = 'combined'
if len(directive) > 2 and '=' not in directive[2]:
format_name = directive[2]
yield path, format_name