本文整理汇总了Python中pyon.public.IonObject.event方法的典型用法代码示例。如果您正苦于以下问题:Python IonObject.event方法的具体用法?Python IonObject.event怎么用?Python IonObject.event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.public.IonObject
的用法示例。
在下文中一共展示了IonObject.event方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_event_computed_attributes
# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import event [as 别名]
def get_event_computed_attributes(event, include_event=False, include_special=False, include_formatted=False):
"""
@param event any Event to compute attributes for
@retval an EventComputedAttributes object for given event
"""
evt_computed = IonObject(OT.EventComputedAttributes)
evt_computed.event_id = event._id
evt_computed.ts_computed = get_ion_ts()
evt_computed.event = event if include_event else None
try:
summary = get_event_summary(event)
evt_computed.event_summary = summary
if include_special:
spc_attrs = ["%s:%s" % (k, str(getattr(event, k))[:50]) for k in sorted(event.__dict__.keys()) if k not in ['_id', '_rev', 'type_', 'origin', 'origin_type', 'ts_created', 'base_types']]
evt_computed.special_attributes = ", ".join(spc_attrs)
if include_formatted:
evt_computed.event_attributes_formatted = pprint.pformat(event.__dict__)
except Exception as ex:
log.exception("Error computing EventComputedAttributes for event %s: %s", event, ex)
return evt_computed