18 ALWAYS = attimeAlways()
36 for iter, funpairs
in sorted(self.
events.iteritems()):
37 res += str(iter) +
": \n"
38 for funpair
in funpairs:
40 res += funpair[0] +
"\n"
42 res += str(funpair[1]) +
"\n"
53 self.
events[ALWAYS].remove(pairfundoc)
55 if iter
not in self.
events.keys():
57 self.
events[iter].append(pairfundoc)
61 3 entry types are possible: 1. only the functor. 2. a pair
62 (functor,doc). 3. a list of pairs (functor,doc).
64 if len(funs) == 2
and callable(funs[0])
and isinstance(funs[1], str):
68 if isinstance(fun, tuple):
71 if "functor" in fun.__dict__:
83 def run(self, iter, *args):
85 for fun, doc
in self.
events[ALWAYS]:
89 for fun, doc
in self.
events[iter]:
90 intro =
"At time " + str(iter) +
": "
94 if fun.__doc__
is not None:
95 print(intro, fun.__doc__)
97 print(intro,
"Runing ", fun)
108 This next calling pattern is a little bit strange. Use it to decorate
109 a function definition: @attime(30) def run30(): ...
118 if functer.__doc__
is None:
119 functer.__doc__ =
"No doc fun"
120 if len(functer.__doc__) > 0:
121 selfdeco.__doc__ = functer.__doc__
122 selfdeco.__doc__ += (
123 " (will be run at time " + str(selfdeco.iterRef) +
")"
125 selfdeco.fun = functer
126 selfdeco.calendarRef.registerEvents(
127 selfdeco.iterRef, functer, functer.__doc__
136 for i
in range(t + 1):
144 return s.__class__.value.__set__(s, v)
148 return mt.__class__.ref.__set__(mt, v)