本文整理汇总了Python中MaKaC.common.indexes.IndexesHolder.getObjectsInDay方法的典型用法代码示例。如果您正苦于以下问题:Python IndexesHolder.getObjectsInDay方法的具体用法?Python IndexesHolder.getObjectsInDay怎么用?Python IndexesHolder.getObjectsInDay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.common.indexes.IndexesHolder
的用法示例。
在下文中一共展示了IndexesHolder.getObjectsInDay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cacheDay
# 需要导入模块: from MaKaC.common.indexes import IndexesHolder [as 别名]
# 或者: from MaKaC.common.indexes.IndexesHolder import getObjectsInDay [as 别名]
def cacheDay(dest, day):
"""
Cache a day, by calling wget in "mirror" mode
"""
dbi = DBMgr.getInstance()
dbi.startRequest()
index = {}
calIdx = IndexesHolder().getIndex('calendar')
objs = calIdx.getObjectsInDay(day)
for confId in objs:
if confId == '': continue
obj = ConferenceHolder().getById(confId)
url = str(urlHandlers.UHConferenceDisplay.getURL(obj))
savedDirs = re.match(r'http:\/\/(.*)', url).group(1).split('/')
print "Calling wget for %s..." % url
os.system(WGET_COMMAND % (confId, url,
os.path.join(dest, confId),
savedDirs[0]))
print "done!"
index[confId] = (os.path.join(confId,*savedDirs)+'.html', obj.getTitle())
dbi.endRequest(False)
return index
示例2: _process
# 需要导入模块: from MaKaC.common.indexes import IndexesHolder [as 别名]
# 或者: from MaKaC.common.indexes.IndexesHolder import getObjectsInDay [as 别名]
def _process( self ):
from datetime import datetime,timedelta
from MaKaC.common.indexes import IndexesHolder
self._responseUtil.content_type = 'text/xml'
XG = xmlGen.XMLGen()
XG.openTag("response")
now = startdt = enddt = datetime.now()
today = startdt.date()
startdt.replace( hour = 0, minute = 0)
enddt.replace( hour = 23, minute = 59)
calIdx = IndexesHolder().getById("calendar")
nbEvtsToday = len(calIdx.getObjectsInDay(now))
nbOngoingEvts = len(calIdx.getObjectsIn(now,now))
self._createIndicator(XG, "nbEventsToday", "total number of events for today", nbEvtsToday)
self._createIndicator(XG, "nbOngoingEvents", "total number of ongoing events", nbOngoingEvts)
XG.closeTag("response")
return XG.getXml()