本文整理汇总了Python中pyparsing.White方法的典型用法代码示例。如果您正苦于以下问题:Python pyparsing.White方法的具体用法?Python pyparsing.White怎么用?Python pyparsing.White使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyparsing
的用法示例。
在下文中一共展示了pyparsing.White方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _globalParse___ssh_attributes
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import White [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
示例2: get_attributes
# 需要导入模块: import pyparsing [as 别名]
# 或者: from pyparsing import White [as 别名]
def get_attributes(config):
options_list = []
option = White(exact=1) + Suppress(Optional(White())) + restOfLine
next_line = config.readline()
try:
option_parse = option.parseString(next_line)
while option_parse[0] == ' ':
options_list.append(option_parse[-1])
next_line = config.readline()
option_parse = option.parseString(next_line)
except:
pass
return options_list, next_line