1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-05 21:07:52 +00:00

Fix check_docs.py to work with cleaned up XML.

This commit is contained in:
Brenden Matthews 2009-06-07 21:23:35 -06:00
parent 25e46ca341
commit 6ebfffe542
4 changed files with 448 additions and 453 deletions

View File

@ -8,6 +8,9 @@
* Add entropy_perc printing the available entropy as percentage
* Add read_tcp to print stuff from tcp-sockets
2009-06-07
* Conky 1.7.1 released
2009-05-31
* Fix hostname resolution for mpd_host
* Made sure that no X11 stuff is in the binary with --disable-X11

View File

@ -29,7 +29,34 @@ file_names["config_settings"] = "doc/config_settings.xml"
for fn in file_names.values():
if not os.path.exists(fn) or not os.path.isfile(fn):
print "'%s' doesn't exist, or isn't a file" % (fn)
exit(0)
exit(1)
print 'sorting/tidying docs...'
# sort the docs by variable/config setting
import string
import xml.etree.ElementTree as ET
vars_xml = ET.parse(file_names['variables'])
config_xml = ET.parse(file_names['config_settings'])
getkey = lambda x: x.findtext('term/command/option')
vars = vars_xml.getroot()
vars[:] = sorted(vars, key=getkey)
configs = config_xml.getroot()
configs[:] = sorted(configs, key=getkey)
vars_xml.write(file_names['variables'])
config_xml.write(file_names['config_settings'])
def tidy(file):
command = ['tidy', '-qim', '-xml', '-utf8', '--indent-spaces', '4']
os.system('%s %s 2>/dev/null' % (string.join(command), file))
tidy(file_names['variables'])
tidy(file_names['config_settings'])
#
# Do all the objects first
@ -54,17 +81,14 @@ file.close()
doc_objects = []
exp = re.compile("\s*<command><option>(\w*)</option></command>.*")
print "checking docs -> objs consistency (in %s)" % (file_names["text_objects"])
file = open(file_names["variables"], "r")
while file:
line = file.readline()
if len(line) == 0:
break
res = exp.match(line)
if res:
doc_objects.append(res.group(1))
if doc_objects[len(doc_objects) - 1] != "templateN" and doc_objects[len(doc_objects) - 1] not in objects:
for var in vars:
term = getkey(var)
doc_objects.append(term)
if ['templaten', 'colorn'].count(doc_objects[len(doc_objects) - 1].lower()):
# ignore these
continue
if doc_objects[len(doc_objects) - 1] not in objects:
print " '%s' is documented, but doesn't seem to be an object" % (doc_objects[len(doc_objects) - 1])
file.close()
print "done\n"
print "checking objs -> docs consistency (in %s)" % (file_names["variables"])
@ -77,7 +101,7 @@ print "done\n"
# Now we'll do config settings
#
configs = []
config_entries = []
file = open(file_names["conky"], "r")
exp1 = re.compile('\s*CONF\("(\w*)".*')
@ -96,28 +120,24 @@ while file:
conf = res.group(1)
if re.match("color\d", conf):
conf = "colorN"
if configs.count(conf) == 0:
configs.append(conf)
if config_entries.count(conf) == 0:
config_entries.append(conf)
file.close()
doc_configs = []
exp = re.compile("\s*<term><command><option>(\w*)</option></command>.*")
print "checking docs -> configs consistency (in %s)" % (file_names["conky"])
file = open(file_names["config_settings"], "r")
while file:
line = file.readline()
if len(line) == 0:
break
res = exp.match(line)
if res:
doc_configs.append(res.group(1))
if doc_configs[len(doc_configs) - 1] != "TEXT" and doc_configs[len(doc_configs) - 1] != "templateN" and doc_configs[len(doc_configs) - 1] not in configs:
for config in configs:
term = getkey(config)
doc_configs.append(term)
if ['text', 'templaten'].count(doc_configs[len(doc_configs) - 1].lower()):
# ignore these
continue
if doc_configs[len(doc_configs) - 1] not in config_entries:
print " '%s' is documented, but doesn't seem to be a config setting" % (doc_configs[len(doc_configs) - 1])
file.close()
print "done\n"
print "checking configs -> docs consistency (in %s)" % (file_names["config_settings"])
for obj in configs:
for obj in config_entries:
if obj != "text" and obj != "template" and obj not in doc_configs:
print " '%s' seems to be undocumented" % (obj)
print "done\n"
@ -128,13 +148,13 @@ print "done\n"
for i in range(0, 10):
objects.append("color" + str(i))
configs.append("color" + str(i))
config_entries.append("color" + str(i))
objects.append("template" + str(i))
configs.append("template" + str(i))
config_entries.append("template" + str(i))
# Finally, sort everything.
objects.sort()
configs.sort()
config_entries.sort()
#
# Update nano syntax stuff
@ -156,7 +176,7 @@ for line in lines:
idx = lines.index(line)
lines.pop(idx) # remove old line
line = 'color green "\<('
for obj in configs:
for obj in config_entries:
line += "%s|" % (obj)
line = line[:len(line) - 1]
line += ')\>"\n'
@ -197,7 +217,7 @@ for line in lines:
idx = lines.index(line)
lines.pop(idx) # remove old line
line = 'syn keyword ConkyrcSetting '
for obj in configs:
for obj in config_entries:
line += "%s " % (obj)
line = line[:len(line) - 1]
line += '\n'
@ -217,32 +237,4 @@ file.seek(0)
file.writelines(lines)
file.close()
print 'sorting/tidying docs...'
# sort the docs by variable/config setting
import string
import xml.etree.ElementTree as ET
vars_xml = ET.parse(file_names['variables'])
config_xml = ET.parse(file_names['config_settings'])
getkey = lambda x: x.findtext('term/command/option')
vars = vars_xml.getroot()
vars[:] = sorted(vars, key=getkey)
configs = config_xml.getroot()
configs[:] = sorted(configs, key=getkey)
vars_xml.write(file_names['variables'])
config_xml.write(file_names['config_settings'])
def tidy(file):
command = ['tidy', '-qim', '-xml', '-utf8', '--indent-spaces', '4']
os.system('%s %s 2>/dev/null' % (string.join(command), file))
tidy(file_names['variables'])
tidy(file_names['config_settings'])
print "done."

View File

@ -689,9 +689,9 @@
<command>
<option>diskiograph</option>
</command>
<option>(device) ("normal"|"log") (height),(width) (gradient
colour 1) (gradient colour 2) (scale) (-t)
</option>
<option>(device) ("normal"|"log") (height),(width)
(gradient colour 1) (gradient colour 2) (scale)
(-t)</option>
</term>
<listitem>Disk IO graph, colours defined in hex, minus the
#. If scale is non-zero, it becomes the scale for the
@ -707,9 +707,9 @@
<command>
<option>diskiograph_read</option>
</command>
<option>(device) ("normal"|"log") (height),(width) (gradient
colour 1) (gradient colour 2) (scale) (-t)
</option>
<option>(device) ("normal"|"log") (height),(width)
(gradient colour 1) (gradient colour 2) (scale)
(-t)</option>
</term>
<listitem>Disk IO graph for reads, colours defined in hex,
minus the #. If scale is non-zero, it becomes the scale for
@ -726,9 +726,9 @@
<command>
<option>diskiograph_write</option>
</command>
<option>(device) ("normal"|"log") (height),(width) (gradient
colour 1) (gradient colour 2) (scale) (-t)
</option>
<option>(device) ("normal"|"log") (height),(width)
(gradient colour 1) (gradient colour 2) (scale)
(-t)</option>
</term>
<listitem>Disk IO graph for writes, colours defined in hex,
minus the #. If scale is non-zero, it becomes the scale for
@ -765,9 +765,9 @@
<command>
<option>downspeedgraph</option>
</command>
<option>(netdev) ("normal"|"log") (height),(width) (gradient
colour 1) (gradient colour 2) (scale) (-t)
</option>
<option>(netdev) ("normal"|"log") (height),(width)
(gradient colour 1) (gradient colour 2) (scale)
(-t)</option>
</term>
<listitem>Download speed graph, colours defined in hex,
minus the #. If scale is non-zero, it becomes the scale for
@ -1777,17 +1777,17 @@
<command>
<option>lua_graph</option>
</command>
<option>
function_name (function parameters)
("normal"|"log") (height),(width) (gradient colour 1) (gradient colour 2) (scale) (-t)
</option>
<option>function_name (function parameters)
("normal"|"log") (height),(width) (gradient colour 1)
(gradient colour 2) (scale) (-t)</option>
</term>
<listitem>Executes a Lua function with given parameters and
draws a graph. Expects result value to be any number, and by default will scale to show the full range. See also 'lua_load' on how to load
scripts. Takes the switch '-t' to use a temperature
gradient, which makes the gradient values change depending
on the amplitude of a particular graph value (try it and
see).
draws a graph. Expects result value to be any number, and
by default will scale to show the full range. See also
'lua_load' on how to load scripts. Takes the switch '-t' to
use a temperature gradient, which makes the gradient values
change depending on the amplitude of a particular graph
value (try it and see).
<para /></listitem>
</varlistentry>
<varlistentry>
@ -3061,9 +3061,9 @@
<command>
<option>upspeedgraph</option>
</command>
<option>(netdev) ("normal"|"log") (height),(width) (gradient
colour 1) (gradient colour 2) (scale) (-t)
</option>
<option>(netdev) ("normal"|"log") (height),(width)
(gradient colour 1) (gradient colour 2) (scale)
(-t)</option>
</term>
<listitem>Upload speed graph, colours defined in hex, minus
the #. If scale is non-zero, it becomes the scale for the