Esempio n. 1
0
File: day.py Progetto: M-o-a-T/moat
	def _range(self,start,end):
		#
		#txt = self.descr.split()
		def j(x):
			for y in x:
				for z in y:
					if z:
						yield z
		txt=list(j(TimeSplit.findall(self.descr)))
		start = make_naive(start,get_current_timezone())
		end = make_naive(end,get_current_timezone())
		while start < end:
			a = time_until(txt, invert=False, now=start)
			b = time_until(txt, invert=True, now=a)
			if b is None:
				b = time_until(txt, invert=True, now=a)
			yield (make_aware(a,get_current_timezone()), b-a)
			start=b
Esempio n. 2
0
    def _range(self, start, end):
        #
        #txt = self.descr.split()
        def j(x):
            for y in x:
                for z in y:
                    if z:
                        yield z

        txt = list(j(TimeSplit.findall(self.descr)))
        start = make_naive(start, get_current_timezone())
        end = make_naive(end, get_current_timezone())
        while start < end:
            a = time_until(txt, invert=False, now=start)
            b = time_until(txt, invert=True, now=a)
            if b is None:
                b = time_until(txt, invert=True, now=a)
            yield (make_aware(a, get_current_timezone()), b - a)
            start = b
Esempio n. 3
0
	def _schedule(self):
		"""Sleep until the next time this monitor should run"""
		s = self.stopped_at or now()
		if self.delay_for:
			if isinstance(self.delay_for,tuple):
				s = time_delta(self.delay_for, now=s)
			else:
				s += dt.timedelta(0,self.delay_for)
		if self.delay_until:
			if self.stopped_at:
				s = time_until(self.delay_until, now=s, invert=True)
			s = time_until(self.delay_until, now=s)
		if not self.delay_for and not self.delay_until:
			if isinstance(self.delay,tuple):
				s = time_delta(self.delay, now=s)
			else:
				s += dt.timedelta(0,self.delay)

		self.started_at = s
		with log_wait("monitor","sleep",*self.name):
			sleepUntil(False,s)
Esempio n. 4
0
def chk(iso,a,invert=False):
	if a == "":
		a = ()
	else:
		a = a.split(" ")
	res = time_until(a,now=now,invert=invert)
	if res is None:
		if iso == "-": return
	res -= datetime.timedelta(0,0,res.microsecond)
	res = str(res)
	if iso == res: return

	global err
	global lnp
	if lnp is None or lnp != now:
		lnp = now
		print("@",now,"::")
	err += 1
	print("?",iso,"≠",res,"@",a)
Esempio n. 5
0
def chk(iso, a, invert=False):
    if a == "":
        a = ()
    else:
        a = a.split(" ")
    res = time_until(a, now=now, invert=invert)
    if res is None:
        if iso == "-": return
    res -= datetime.timedelta(0, 0, res.microsecond)
    res = str(res)
    if iso == res: return

    global err
    global lnp
    if lnp is None or lnp != now:
        lnp = now
        print("@", now, "::")
    err += 1
    print("?", iso, "≠", res, "@", a)
Esempio n. 6
0
		def delta():
			return time_until(event, now=now(self.parent.force))
Esempio n. 7
0
		def delta():
			s = time_until(event, invert=True, now=now(self.parent.force))
			return time_until(event, now=s)