本文整理匯總了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 ")