equal
deleted
inserted
replaced
30 @param path the path to the zonefile |
30 @param path the path to the zonefile |
31 @param ttl default TTL to use |
31 @param ttl default TTL to use |
32 @param comment optional comments |
32 @param comment optional comments |
33 """ |
33 """ |
34 |
34 |
35 Object.__init__(comment) |
35 Object.__init__(self, comment) |
36 conf.File.__init__(name, path) |
36 conf.File.__init__(self, name, path) |
37 |
37 |
38 # init |
38 # init |
39 self.objects = [] |
39 self.objects = [] |
40 |
40 |
41 if ttl : |
41 if ttl : |
49 self.objects.append(obj) |
49 self.objects.append(obj) |
50 |
50 |
51 # various aliases... |
51 # various aliases... |
52 add_comment = add_record = add_directive = add_obj |
52 add_comment = add_record = add_directive = add_obj |
53 |
53 |
|
54 def fmt_lines (self) : |
|
55 """ |
|
56 Just format all our objects |
|
57 """ |
|
58 |
|
59 # prefix comments |
|
60 for line in self._fmt_comments() : |
|
61 yield line |
|
62 |
|
63 # and then all objects |
|
64 for obj in self.objects : |
|
65 # ...and their lines |
|
66 for line in obj.fmt_lines() : |
|
67 yield line |
|
68 |
54 class Comment (Object) : |
69 class Comment (Object) : |
55 """ |
70 """ |
56 A comment, is, well, a comment :) |
71 A comment, is, well, a comment :) |
57 """ |
72 """ |
58 |
73 |
174 for line in self._fmt_comments() : |
189 for line in self._fmt_comments() : |
175 yield line |
190 yield line |
176 |
191 |
177 # then format the line |
192 # then format the line |
178 # XXX: TTL? |
193 # XXX: TTL? |
179 yield "%30s %4s%4s %8s %s" % (self.label if self.label is not None else '', str(self.ttl) if self.ttl else '', self.cls, self.type, self.rdata) |
194 yield "%-30s %-4s%-4s %-8s %s" % (self.label if self.label is not None else '', str(self.ttl) if self.ttl else '', self.cls, self.type, self.rdata) |
180 |
195 |
181 class SOA (ResourceRecord) : |
196 class SOA (ResourceRecord) : |
182 """ |
197 """ |
183 "Identifies the start of a zone of authority", must be the first record |
198 "Identifies the start of a zone of authority", must be the first record |
184 """ |
199 """ |