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