[Pymoul-svn] SF.net SVN: pymoul: [279] pymoul/trunk
Status: Alpha
Brought to you by:
tiran
From: <ti...@us...> - 2007-03-25 17:55:35
|
Revision: 279 http://pymoul.svn.sourceforge.net/pymoul/?rev=279&view=rev Author: tiran Date: 2007-03-25 10:55:31 -0700 (Sun, 25 Mar 2007) Log Message: ----------- Updated pod age code Modified Paths: -------------- pymoul/trunk/Makefile.in pymoul/trunk/src/moul/time/podage.py Modified: pymoul/trunk/Makefile.in =================================================================== --- pymoul/trunk/Makefile.in 2007-03-23 17:40:11 UTC (rev 278) +++ pymoul/trunk/Makefile.in 2007-03-25 17:55:31 UTC (rev 279) @@ -103,5 +103,8 @@ serverlist: PYTHONPATH="src" $(PYTHON) src/moul/server/serverlist.py +podage: + PYTHONPATH="src" $(PYTHON) src/moul/time/podage.py + infrastructure: clean inplace ui languages xxxreport propset fixlineendings doc_html serverlist Modified: pymoul/trunk/src/moul/time/podage.py =================================================================== --- pymoul/trunk/src/moul/time/podage.py 2007-03-23 17:40:11 UTC (rev 278) +++ pymoul/trunk/src/moul/time/podage.py 2007-03-25 17:55:31 UTC (rev 279) @@ -101,7 +101,12 @@ registerPodAge = _podRegistry.register def listPodAges(): - return [name for name in _podRegistry if name] + """List pod ages sorted by offset + """ + dec = [(age.offset, name) + for name, age in _podRegistry.items() if name] + dec.sort() + return [v[1] for v in dec] class PodAgeInformation(dict): """Information about a pod age @@ -113,6 +118,7 @@ for key in ('name', 'gatenumber', 'offset'): if key not in self: raise KeyError(key) + self['offset_td'] = timedelta(seconds=self['offset']*PAHRTAHVO_SEC) def __getattribute__(self, name): if name in self: @@ -155,7 +161,7 @@ """ if startdt is None: startdt = utcnow() - base_dt = BASE_DT + self._age.offset + base_dt = BASE_DT + self._age.offset_td # calculate completed cycles since base_dt sec = td2sec(startdt - base_dt) cycles = floor(sec / PODDAY_SEC) @@ -178,7 +184,7 @@ @return: Iterator that yields (number, date) @rtype: iterator (int, datetime) """ - dt = self._base + PODDAY_TD + dt = self._base #+ PODDAY_TD n = 0 while True: yield (n, dt) @@ -187,34 +193,21 @@ # pod ages registerPodAge(PodAgeInformation( - name = 'Dereno', - gatenumber = 25, - offset = timedelta(seconds=1*PAHRTAHVO_SEC) - )) - -registerPodAge(PodAgeInformation( name = 'Negilahn', gatenumber = 18, - offset = timedelta(seconds=0) + offset = 0, # Pahrtahvotee )) registerPodAge(PodAgeInformation( - name = 'Payiferen', - gatenumber = -1, - offset = timedelta(seconds=-1) + name = 'Dereno', + gatenumber = 25, + offset = 1, # Pahrtahvo )) -registerPodAge(PodAgeInformation( - name = 'Tetsonot', - gatenumber = -1, - offset = timedelta(seconds=-1) - )) - - from moul.time.dni import DniTime from moul.time.utils import normalizeTZ -def forumTimeTable(limit=10, fmt="%Y-%m-%d %H:%M:%S %Z", tzlist=('UTC', 'CET', +def forumTimeTable(limit=5, fmt="%Y-%m-%d %H:%M:%S %Z", tzlist=('UTC', 'CET', 'US/Mountain', 'US/Pacific', 'US/Eastern', 'Australia/Sydney')): """Small utility function to create a nice list for the forum @@ -223,18 +216,20 @@ print "[spoiler=%s]" % tz for age in listPodAges(): pat = PodAgeTime(age) + print print age - print "--------------------------------------------------------------------" + print 20 * "-" for n, dt in iter(pat): if n > limit: break - dni = DniTime.fromUTC(dt) + #dni = DniTime.fromUTC(dt) ldt = normalizeTZ(tz, dt) - print "Earth: %s, D'ni: %s, %i" % (ldt.strftime(fmt), - str(dni), dni.pahrtahvo) + print ldt.strftime(fmt) + #print "Earth: %s, D'ni: %s, %i" % (ldt.strftime(fmt), + # str(dni), dni.pahrtahvo) print "[/spoiler]" -def allTzList(limit=50, fmt="%Y-%m-%d %H:%M:%S %Z"): +def allTzList(limit=50, fmt="%Y-%m-%d %H:%M %Z"): """Small utility function to create a nice list for the forum """ from pytz import common_timezones @@ -251,8 +246,9 @@ print tzname for age in listPodAges(): pat = PodAgeTime(age) + print >>fd print >>fd, age - print >>fd, "--------------------------------------------------------------------" + print >>fd, 20*"-" for n, dt in iter(pat): if n > limit: break @@ -266,5 +262,8 @@ fd.close() if __name__ == '__main__': - forumTimeTable(tzlist=('UTC',)) + #forumTimeTable(tzlist=('CET',)) + #forumTimeTable(tzlist=('UTC',)) + forumTimeTable(tzlist=('US/Pacific',)) + #forumTimeTable() #allTzList() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |