本文整理汇总了Python中gtp.pre_engine方法的典型用法代码示例。如果您正苦于以下问题:Python gtp.pre_engine方法的具体用法?Python gtp.pre_engine怎么用?Python gtp.pre_engine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtp
的用法示例。
在下文中一共展示了gtp.pre_engine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_message
# 需要导入模块: import gtp [as 别名]
# 或者: from gtp import pre_engine [as 别名]
def parse_message(message):
message = gtp.pre_engine(message).strip()
first, rest = (message.split(" ", 1) + [None])[:2]
if first.isdigit():
message_id = int(first)
if rest is not None:
command, arguments = (rest.split(" ", 1) + [None])[:2]
else:
command, arguments = None, None
else:
message_id = None
command, arguments = first, rest
command = command.replace("-", "_") # for kgs extensions.
return message_id, command, arguments
示例2: parse_message
# 需要导入模块: import gtp [as 别名]
# 或者: from gtp import pre_engine [as 别名]
def parse_message(message):
message = gtp.pre_engine(message).strip()
first, rest = (message.split(' ', 1) + [None])[:2]
if first.isdigit():
message_id = int(first)
if rest is not None:
command, arguments = (rest.split(' ', 1) + [None])[:2]
else:
command, arguments = None, None
else:
message_id = None
command, arguments = first, rest
command = command.replace('-', '_') # for kgs extensions.
return message_id, command, arguments
示例3: test_pre_engine
# 需要导入模块: import gtp [as 别名]
# 或者: from gtp import pre_engine [as 别名]
def test_pre_engine(self):
self.assertEqual(pre_engine("foo\rbar"), "foobar")
self.assertEqual(pre_engine("foo\nbar"), "foo\nbar")
self.assertEqual(pre_engine("foo\tbar"), "foo bar")
self.assertEqual(pre_engine("foo # bar"), "foo ")