本文整理匯總了Python中graphserver.ext.gtfs.gtfsdb.GTFSDatabase.service_periods方法的典型用法代碼示例。如果您正苦於以下問題:Python GTFSDatabase.service_periods方法的具體用法?Python GTFSDatabase.service_periods怎麽用?Python GTFSDatabase.service_periods使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類graphserver.ext.gtfs.gtfsdb.GTFSDatabase
的用法示例。
在下文中一共展示了GTFSDatabase.service_periods方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: open
# 需要導入模塊: from graphserver.ext.gtfs.gtfsdb import GTFSDatabase [as 別名]
# 或者: from graphserver.ext.gtfs.gtfsdb.GTFSDatabase import service_periods [as 別名]
#!/usr/bin/python
import sys, struct
from struct import Struct
# requires graphserver to be installed
from graphserver.ext.gtfs.gtfsdb import GTFSDatabase
from datetime import timedelta, date
gtfsdb_file = sys.argv[1]
try:
with open(gtfsdb_file) as f:
db = GTFSDatabase(gtfsdb_file)
except IOError as e:
print "gtfsdb file %s cannot be opened" % gtfsdb_file
exit(1)
# display number of active services to spot the usable period for this feed
dfrom, dto = db.date_range()
d = dfrom
while d <= dto:
active_sids = db.service_periods(d)
print d, len(active_sids)
d += timedelta(days=1)