You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.5 KiB
76 lines
2.5 KiB
11 years ago
|
from xml.sax.saxutils import escape
|
||
12 years ago
|
|
||
11 years ago
|
class DokuWikiTablesOutput():
|
||
|
def __init__(self, groups):
|
||
|
result = "====== Parameter Reference ======\nThis list is auto-generated every few minutes and contains the most recent parameter names and default values.\n\n"
|
||
12 years ago
|
for group in groups:
|
||
|
result += "==== %s ====\n\n" % group.GetName()
|
||
11 years ago
|
result += "|< 100% 20% 20% 10% 10% 10% 30%>|\n"
|
||
11 years ago
|
result += "^ Name ^ Description ^ Min ^ Max ^ Default ^ Comment ^\n"
|
||
12 years ago
|
for param in group.GetParams():
|
||
|
code = param.GetFieldValue("code")
|
||
|
name = param.GetFieldValue("short_desc")
|
||
|
min_val = param.GetFieldValue("min")
|
||
11 years ago
|
max_val = param.GetFieldValue("max")
|
||
|
def_val = param.GetFieldValue("default")
|
||
|
long_desc = param.GetFieldValue("long_desc")
|
||
|
|
||
|
name = name.replace("\n", " ")
|
||
|
result += "| %s | %s |" % (code, name)
|
||
|
|
||
12 years ago
|
if min_val is not None:
|
||
11 years ago
|
result += " %s |" % min_val
|
||
11 years ago
|
else:
|
||
11 years ago
|
result += " |"
|
||
|
|
||
12 years ago
|
if max_val is not None:
|
||
11 years ago
|
result += " %s |" % max_val
|
||
11 years ago
|
else:
|
||
11 years ago
|
result += " |"
|
||
|
|
||
12 years ago
|
if def_val is not None:
|
||
11 years ago
|
result += " %s |" % def_val
|
||
11 years ago
|
else:
|
||
11 years ago
|
result += " |"
|
||
|
|
||
11 years ago
|
if long_desc is not None:
|
||
11 years ago
|
long_desc = long_desc.replace("\n", " ")
|
||
|
result += " %s |" % long_desc
|
||
11 years ago
|
else:
|
||
11 years ago
|
result += " |"
|
||
|
|
||
|
result += "\n"
|
||
11 years ago
|
result += "\n"
|
||
11 years ago
|
self.output = result;
|
||
|
|
||
|
def Save(self, filename):
|
||
|
with open(filename, 'w') as f:
|
||
|
f.write(self.output)
|
||
|
|
||
|
def SaveRpc(self, filename):
|
||
|
with open(filename, 'w') as f:
|
||
|
f.write("""<?xml version='1.0'?>
|
||
|
<methodCall>
|
||
|
<methodName>wiki.putPage</methodName>
|
||
|
<params>
|
||
|
<param>
|
||
|
<value>
|
||
|
<string>:firmware:parameters</string>
|
||
|
</value>
|
||
|
</param>
|
||
|
<param>
|
||
|
<value>
|
||
|
<string>""")
|
||
|
f.write(escape(self.output))
|
||
|
f.write("""</string>
|
||
|
</value>
|
||
|
</param>
|
||
|
<param>
|
||
|
<value>
|
||
|
<name>sum</name>
|
||
|
<string>Updated parameters automagically from code.</string>
|
||
|
</value>
|
||
|
</param>
|
||
|
</params>
|
||
|
</methodCall>""")
|