summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJan Safranek <jsafrane@redhat.com>2012-11-01 16:26:09 +0100
committerJan Safranek <jsafrane@redhat.com>2012-11-01 16:26:09 +0100
commit0bd973c335dd56a198c05cc2fe2f37c99ac1d961 (patch)
tree58d10be2f6a796685a6760dd20089054011d020f /tools
parent972244be7679e03edf0dfd148e4d11efa3f5caff (diff)
downloadopenlmi-providers-0bd973c335dd56a198c05cc2fe2f37c99ac1d961.tar.gz
openlmi-providers-0bd973c335dd56a198c05cc2fe2f37c99ac1d961.tar.xz
openlmi-providers-0bd973c335dd56a198c05cc2fe2f37c99ac1d961.zip
Added -s and -A parameters
Diffstat (limited to 'tools')
-rwxr-xr-xtools/class2dot.py48
-rwxr-xr-xtools/class2html.py6
2 files changed, 46 insertions, 8 deletions
diff --git a/tools/class2dot.py b/tools/class2dot.py
index 43f8db3..b37d048 100755
--- a/tools/class2dot.py
+++ b/tools/class2dot.py
@@ -95,7 +95,19 @@ class DotExporter(object):
if q.name == "ValueMap":
print >>self.file, "<tr><td class=\"qualifiers\"><b>ValueMap</b></td> <td class=\"qualifiers\"><table><tr><td class=\"qualifiers\">%s</td></tr></table></td></tr>" % ("</td></tr><tr><td class=\"qualifiers\">".join(q.value))
- def print_class(self, c, display_local = True):
+ def compare_properties(self, p1, p2):
+ """
+ Compare two properties. Only Name and Description are checked.
+ """
+ if p1.name != p2.name:
+ return False
+ d1 = p1.qualifiers.get("Description", None)
+ d2 = p2.qualifiers.get("Description", None)
+ if d1.value != d2.value:
+ return False
+ return True
+
+ def print_class(self, c, display_local = True, box_only = False):
"""
Print one class, inc. header.
"""
@@ -107,17 +119,24 @@ class DotExporter(object):
# draw arrow to parent
print >>self.file, "\"%s\"->\"%s\"" % (c.classname, c.superclass)
+ if box_only:
+ return
+
local_props = []
for name in sorted(c.properties.keys()):
if parent and parent.properties.has_key(name):
- pass
+ if not self.compare_properties(c.properties[name], parent.properties[name]):
+ # the property was overridden
+ local_props.append(c.properties[name])
else:
local_props.append(c.properties[name])
local_methods = []
for name in sorted(c.methods.keys()):
if parent and parent.methods.has_key(name):
- pass
+ if not self.compare_properties(c.methods[name], parent.methods[name]):
+ # the property was overridden
+ local_methods.append(c.methods[name])
else:
local_methods.append(c.methods[name])
@@ -140,9 +159,9 @@ class DotExporter(object):
def add_class(self, classname):
self.classes.add(classname)
- def export(self):
+ def export(self, shrink, noassoc = False):
"""
- Print all classes and their parent.
+ Print all classes and their parents.
"""
print >>self.file, """
digraph "classes_No_Name" {
@@ -153,7 +172,16 @@ edge [arrowhead="empty" fontsize=10 fontname="sans-serif"]
"""
while self.classes:
c = self.classes.pop()
- self.print_class(self.load_class(c))
+
+ cl = self.load_class(c)
+ if noassoc and cl.qualifiers.get("Association", False):
+ continue
+
+ if shrink and shrink.match(c):
+
+ self.print_class(cl, box_only = True)
+ else:
+ self.print_class(cl)
print >>self.file, "}"
@@ -168,14 +196,20 @@ subclass.
parser = optparse.OptionParser(usage="usage: %prog [options] classname [classname ...]", description=description)
parser.add_option('-u', '--url', action='store', dest='addr', default='https://localhost:5989', help='URL of CIM server, default: https://localhost:5989')
parser.add_option('-U', '--user', action='store', dest='user', default=None, help='CIM user name')
+parser.add_option('-s', '--shrink', action='store', dest='shrink', default=None, help='Regular expression pattern of CIM classes, which will be drawn only as boxes, without properties.')
+parser.add_option('-A', '--no-associations', action='store_true', dest='noassoc', default=False, help='Skip association classes.')
parser.add_option('-P', '--password', action='store', dest='password', default=None, help='CIM password')
(options, args) = parser.parse_args()
sys.stdout.softspace=0
+shrink = None
+if options.shrink:
+ shrink = re.compile(options.shrink)
+
cliconn = pywbem.WBEMConnection(options.addr, (options.user, options.password))
exporter = DotExporter(cliconn)
for c in args:
exporter.add_class(c)
-exporter.export()
+exporter.export(shrink = shrink, noassoc = options.noassoc)
diff --git a/tools/class2html.py b/tools/class2html.py
index 2b1f547..24a0366 100755
--- a/tools/class2html.py
+++ b/tools/class2html.py
@@ -122,7 +122,8 @@ class HtmlExporter(object):
if p.qualifiers.has_key("Out"):
direction.add("OUT")
if p.qualifiers.has_key("In"):
- direction.add("IN")
+ if p.qualifiers["In"].value:
+ direction.add("IN")
if not direction:
direction.add("IN")
direction = "/".join(sorted(direction))
@@ -205,6 +206,9 @@ class HtmlExporter(object):
for name in sorted(c.methods.keys()):
if parent and parent.methods.has_key(name):
inherited_methods.append(c.methods[name])
+ if not self.compare_properties(c.methods[name], parent.methods[name]):
+ # the property was overridden
+ local_methods.append(c.methods[name])
else:
local_methods.append(c.methods[name])