本文整理汇总了Python中nell.utilities.TimeAgent.dt2tlst方法的典型用法代码示例。如果您正苦于以下问题:Python TimeAgent.dt2tlst方法的具体用法?Python TimeAgent.dt2tlst怎么用?Python TimeAgent.dt2tlst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nell.utilities.TimeAgent
的用法示例。
在下文中一共展示了TimeAgent.dt2tlst方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: jsondict
# 需要导入模块: from nell.utilities import TimeAgent [as 别名]
# 或者: from nell.utilities.TimeAgent import dt2tlst [as 别名]
def jsondict(self, tz):
start = self.period.start if tz == 'UTC' else TimeAgent.utc2est(self.period.start)
end = self.period.end() if tz == 'UTC' else TimeAgent.utc2est(self.period.end())
w = self.period.window
# stakeholder want's 'T' or '' for this
sponsored = self.period.session.project.is_sponsored()
sponsored = '' if not sponsored else 'T'
js = {"id" : self.period.id
, "session" : SessionHttpAdapter(self.period.session).jsondict()
, "session_name" : self.period.session.name
, "handle" : self.period.toHandle()
, "stype" : self.period.session.session_type.type[0].swapcase()
, "end_date" : d2str(end)
, "end_time" : t2str(end)
, "date" : d2str(start)
, "time" : t2str(start)
, "lst" : str(TimeAgent.dt2tlst(self.period.start))
, "duration" : self.period.duration
, "sscore" : self.period.score # scheduling score
, "cscore" : -1.0 # current score
, "forecast" : dt2str(self.period.forecast)
, "backup" : self.period.backup
, "moc_ack" : self.period.moc_ack if self.period.moc_ack is not None else False
, "state" : self.period.state.abbreviation if self.period.state is not None else ""
, "windowed" : True if w is not None else False
, "wdefault" : self.period.is_windowed_default() \
if w is not None else None
, "wstart" : d2str(w.start_date()) if w is not None else None
, "wend" : d2str(w.last_date()) if w is not None else None
, "sponsored" : sponsored
, "sponsor" : self.period.session.project.sponsor_text()
, "receivers" : self.period.get_rcvrs_json()
}
# include the accounting but keep the dict flat
if self.period.accounting is not None:
accounting_js = self.period.accounting.jsondict()
# make sure the final jsondict has only one 'id'
accounting_id = accounting_js.pop('id')
accounting_js.update({'accounting_id' : accounting_id})
js.update(accounting_js)
return js