1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 """
16 Contains information gathered during cooking, to be used mostly if the cook
17 failed in order to resume using the same destdir
18 """
19
20 import time
21
23
25 self.__builddir = builddir
26 self.__infofile = builddir + "/conary-build-info"
27 self.__fd = None
28
30 if self.__fd:
31 self.stop()
32
34
35 self.__fd = open(self.__infofile, "r")
36 lines = self.__fd.readlines()
37 self.__fd.close()
38 for line in lines:
39 if line == '\n':
40 continue
41 (key, value) = line.split(None, 1)
42
43 keys = key.split('.')
44 if len(keys) > 1:
45 subdicts = keys[:-1]
46 key = keys[-1]
47 curdict = self
48 for subdict in subdicts:
49 if subdict not in curdict:
50 curdict[subdict] = {}
51 curdict = curdict[subdict]
52
53 value = value.replace('\\\\', '\0')
54 value = value.replace('\\n', '\n')
55 value = value.replace('\0', '\\')
56 curdict[key] = value[:-1]
57 else:
58
59 value = value.replace('\\\\', '\0')
60 value = value.replace('\\n', '\n')
61 value = value.replace('\0', '\\')
62 self[key] = value[:-1]
63
65 self.__fd = open(self.__infofile, "w")
66 tm = time.time()
67 tmstr = time.asctime()
68 self.start = "%s (%s)" % (tm, tmstr)
69
73
75 tm = time.time()
76 tmstr = time.asctime()
77 self.end = "%s (%s)" % (tm, tmstr)
78 self.__fd.close()
79 self.__fd = None
80
82
83
84
85 if not name.startswith('_BuildInfo_'):
86
87 value = str(value).replace('\\', '\\\\')
88 value = value.replace('\n', '\\n')
89 self.write('%s %s\n' % (name,value))
90 self[name] = value
91
94