diff options
author | Rob Austein <sra@hactrn.net> | 2013-05-31 23:45:18 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2013-05-31 23:45:18 +0000 |
commit | 40fd44a0ee201d80bb6b8138d3a3668e0574e20e (patch) | |
tree | 5e18367305fd22681c283abdaa80d9f5890a2d27 | |
parent | afb1ad72334ca2430589953f8e5aeeb02d678cf5 (diff) |
Gussy up wiki output to show default values. Use absent XML attribute
== Python None == commented out variable setting in generated
configuration to mean "no default value".
svn path=/trunk/; revision=5341
-rwxr-xr-x | rpkid/rpki-confgen | 28 | ||||
-rw-r--r-- | rpkid/rpki-confgen.xml | 18 |
2 files changed, 27 insertions, 19 deletions
diff --git a/rpkid/rpki-confgen b/rpkid/rpki-confgen index 0e34c48e..cf66312e 100755 --- a/rpkid/rpki-confgen +++ b/rpkid/rpki-confgen @@ -47,7 +47,9 @@ class Option(object): return len(self.name) def to_xml(self): - x = Element("option", name = self.name, value = self.value) + x = Element("option", name = self.name) + if self.value is not None: + x.set("value", self.value) for d in self.doc: SubElement(x, "doc").text = "\n" + xml8_wrapper.fill(d) + "\n" + space6 return x @@ -56,11 +58,18 @@ class Option(object): f.write("\n%s::" % self.name) for d in self.doc: f.write("\n%s\n" % item_wrapper.fill(d)) + if self.value is None: + f.write("\n%s\n" % item_wrapper.fill("No default value")) + else: + f.write("\n%s\n" % item_wrapper.fill("Default: %s" % self.value)) def to_conf(self, f, width): for d in self.doc: f.write("\n%s\n" % conf_wrapper.fill(d)) - f.write("\n%-*s = %s\n" % (width, self.name, self.value)) + if self.value is None: + f.write("\n#%-*s = ???\n" % (width - 1, self.name)) + else: + f.write("\n%-*s = %s\n" % (width, self.name, self.value)) class Section(object): @@ -204,11 +213,16 @@ for o, a in opts: ElementTree(x).write(a, pretty_print = True, encoding = "us-ascii") elif o == "--write-wiki": - with open(a, "w") as f: - for i, section in enumerate(sections): - if i: - f.write("\f\n") - section.to_wiki(f) + if "%" in a: + for section in sections: + with open(a % section.name, "w") as f: + section.to_wiki(f) + else: + with open(a, "w") as f: + for i, section in enumerate(sections): + if i: + f.write("\f\n") + section.to_wiki(f) elif o == "--write-conf": with open(a, "w") as f: diff --git a/rpkid/rpki-confgen.xml b/rpkid/rpki-confgen.xml index 456b17f1..b1e844c8 100644 --- a/rpkid/rpki-confgen.xml +++ b/rpkid/rpki-confgen.xml @@ -24,8 +24,7 @@ <section name = "myrpki"> - <option name = "handle" - value = "@HANDLE@"> + <option name = "handle"> <doc> Handle naming hosted resource-holding entity (<self/>) represented by this myrpki instance. Syntax is an identifier (ASCII letters, @@ -52,8 +51,7 @@ </doc> </option> - <option name = "rpkid_server_host" - value = "rpkid.example.org"> + <option name = "rpkid_server_host"> <doc> DNS hostname for rpkid. Must be publicly reachable to be useful. </doc> @@ -93,8 +91,7 @@ </doc> </option> - <option name = "pubd_server_host" - value = "pubd.example.org"> + <option name = "pubd_server_host"> <doc> DNS hostname for pubd, if you're running it. Must be publicly reachable to be useful. @@ -109,8 +106,7 @@ </doc> </option> - <option name = "pubd_contact_info" - value = "repo-man@rpki.example.org"> + <option name = "pubd_contact_info"> <doc> Contact information to include in offers of repository service. This only matters when we're running pubd. This should be a human @@ -260,8 +256,7 @@ </doc> </option> - <option name = "shared_sql_password" - value = "fnord"> + <option name = "shared_sql_password"> <doc> If you're comfortable with having all of the databases use the same MySQL password, set that value here. You should use a locally @@ -738,8 +733,7 @@ </doc> </option> - <option name = "secret-key" - value = ""> + <option name = "secret-key"> <doc> Site-specific secret key for Django. </doc> |