1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 """
21 IDO specific features
22 * find layer_real_source_path from sysdef file.
23 * time manipulation for robot releasing.
24 """
25 import re
26 import datetime
27
28 MATCH_ENTITY = re.compile(r".*ENTITY\s+layer_real_source_path\s+\"(.+)\"\s*>?.*")
29
31 """ Search for layer_real_source_path entity inside the sysdef file. """
32 input = open(sysdef, 'r')
33 for line in input.readlines():
34 result = MATCH_ENTITY.match(line)
35 if result != None:
36 input.close()
37 return result.groups()[0]
38 input.close()
39 return None
40
41
43 """ This function returns a datetime object representing the monday from closest
44 even week.
45 """
46 week = int(now.strftime("%W"))
47 day = int(now.strftime("%w")) - 1
48 monday = now - datetime.timedelta(days=day + week.__mod__(2) * 7)
49 monday = monday.replace(hour = 0, minute = 0, second = 0, microsecond = 0)
50 return monday
51
53 """ Get the absolute date from the day and time. """
54 time = datetime.datetime.strptime(time, "%H:%M")
55 delta = datetime.timedelta(days = day-1, hours = time.hour, minutes= time.minute)
56 return get_first_day_of_cycle(now) + delta
57
58
59 -def is_in_interval(day1, time1, day2, time2, now = datetime.datetime.now()):
60 """ Return True is get_absolute_date(day1, time1) < now < get_absolute_date(day2, time2). """
61 delta1 = get_absolute_date(day1, time1, now)
62 delta2 = get_absolute_date(day2, time2, now)
63 if now <= delta1:
64 return False
65 if delta2 <= now:
66 return False
67 return True
68