-
Notifications
You must be signed in to change notification settings - Fork 21
/
formatter.py
43 lines (36 loc) · 1.06 KB
/
formatter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from textwrap import dedent
class Formatter(object):
"""
Abstract class to define the interface for formatters.
"""
def __init__(self):
"""
Initialize formatter, maybe generate a preamble for the config
"""
self.config = []
self.add_comment(dedent(
"""
This file is automatically generated.
"""
))
def add_comment(self, comment):
"""
Add a comment to the config. Default is prefixed with #
"""
self.config.append("# " + "\n# ".join(comment.split("\n")))
def add_data(self, asn, name, template, peer):
"""
Add config directives so that every domain in domains is forwarded to
every server in servers.
"""
raise NotImplementedError()
def add_section(self, name):
"""
Add new Section Header to SmokePing
"""
raise NotImplementedError()
def finalize(self):
"""
Finalize configuration and return it
"""
return "\n".join(self.config)