| 271 | |
| 272 | |
| 273 | class Comment(WhiteSpaceTokenList): |
| 274 | |
| 275 | token_type = 'comment' |
| 276 | |
| 277 | def __str__(self): |
| 278 | return ''.join(sum([ |
| 279 | ["("], |
| 280 | [self.quote(x) for x in self], |
| 281 | [")"], |
| 282 | ], [])) |
| 283 | |
| 284 | def quote(self, value): |
| 285 | if value.token_type == 'comment': |
| 286 | return str(value) |
| 287 | return str(value).replace('\\', '\\\\').replace( |
| 288 | '(', r'\(').replace( |
| 289 | ')', r'\)') |
| 290 | |
| 291 | @property |
| 292 | def content(self): |
| 293 | return ''.join(str(x) for x in self) |
| 294 | |
| 295 | @property |
| 296 | def comments(self): |
| 297 | return [self.content] |
| 298 | |
| 299 | class AddressList(TokenList): |
| 300 | |