本文整理汇总了Python中parser.parse方法的典型用法代码示例。如果您正苦于以下问题:Python parser.parse方法的具体用法?Python parser.parse怎么用?Python parser.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parser
的用法示例。
在下文中一共展示了parser.parse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: command
# 需要导入模块: import parser [as 别名]
# 或者: from parser import parse [as 别名]
def command(command_data, session, db, add_to_updates_queue=True):
"""
Main command parsing function
:param command_data:
:param session:
:param db:
:param add_to_updates_queue:
:return: response object
"""
global processed_commands
global error_num
global success_num
processed_commands+=1
# Call the parser
command_data.update({"db": db})
parse_data = parser.parse(command_data, session)
command_id = command_data['id']
parse_data.update({"command_id": command_data['id']})
log.info(":{0}:Finished parsing".format(command_id))
response = plugin_handler.subscriptions().process_event(parse_data, db)
log.info("Got response {0} with type {1}".format(response, type(response)))
if response["type"] == "success":
success_num+=1
else:
error_num+=1
log.debug("Got response {0} from plugin handler".format(response))
log.info("{0}:Setting update for command with response {1}".format(
command_id, response
))
session_id = session['id']
#Add the response to the update queue
global sessions
if add_to_updates_queue:
sessions[session_id]["updates"].put({"command_id": command_id, "response": response})
if session_id in commands.keys():
commands[session_id].append([command_data["command"], response["text"]])
else:
commands.update({session_id:
[[command_data["command"], response["text"]]]})
return response
示例2: __init__
# 需要导入模块: import parser [as 别名]
# 或者: from parser import parse [as 别名]
def __init__(self, content=None, base_path=None, base_uri=None, strict=False):
if content is not None:
self.data = parse(content, strict)
else:
self.data = {}
self._base_uri = base_uri
if self._base_uri:
if not self._base_uri.endswith('/'):
self._base_uri += '/'
self._initialize_attributes()
self.base_path = base_path