[Commits] (morgen) Modified the PrintItem method to use Andi's new
item.iterAttributes()
commits at osafoundation.org
commits at osafoundation.org
Mon Mar 22 10:53:38 PST 2004
Commit by: morgen
Modified files:
osaf/chandler/Chandler/repository/parcel/Util.py 1.6 1.7
Log message:
Modified the PrintItem method to use Andi's new item.iterAttributes()
Removed the utility method GetAttributes() which is obsoleted by iterAttributes
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/parcel/Util.py.diff?r1=text&tr1=1.6&r2=text&tr2=1.7
Index: osaf/chandler/Chandler/repository/parcel/Util.py
diff -u osaf/chandler/Chandler/repository/parcel/Util.py:1.6 osaf/chandler/Chandler/repository/parcel/Util.py:1.7
--- osaf/chandler/Chandler/repository/parcel/Util.py:1.6 Sun Mar 21 11:38:41 2004
+++ osaf/chandler/Chandler/repository/parcel/Util.py Mon Mar 22 10:53:07 2004
@@ -2,15 +2,15 @@
Utility functions for displaying repository contents
"""
-__revision__ = "$Revision: 1.6 $"
-__date__ = "$Date: 2004/03/21 19:38:41 $"
+__revision__ = "$Revision: 1.7 $"
+__date__ = "$Date: 2004/03/22 18:53:07 $"
__copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
import repository
def PrintItem(uri, rep, level=0):
- """
+ """
Given a uri, display its info along with all its children recursively
Example: PrintItem("//Schema", rep)
@@ -19,29 +19,44 @@
for i in range(level):
print " ",
item = rep.find(uri)
- print uri
-
- for i in range(level+2):
- print " ",
+ print "%s (Kind: %s)" % (uri, item.kind.getItemPath() )
- print "attributes:"
- for (attr,source) in GetAttributes(item):
- for k in range(level+4):
+ # For Kinds, display their attributes (except for the internal ones
+ # like notFoundAttributes:
+ if "//Schema/Core/Kind" == str(item.kind.getItemPath()):
+ for i in range(level+2):
print " ",
- if source is item:
- print attr.getItemPath()
- else:
- print attr.getItemPath(), "(from %s)" % source.getItemPath()
+ print "attributes:"
+
+ displayedAttrs = { }
+ for (name,attr) in item.kind.iterAttributes():
+ if name == "attributes" or \
+ name == "notFoundAttributes" or \
+ name == "inheritedAttributes":
+ continue
+ displayedAttrs[name] = attr
+
+ keys = displayedAttrs.keys()
+ keys.sort()
+ for key in keys:
+ for k in range(level+4):
+ print " ",
+ print "%s %s" % ( key, displayedAttrs[key].getItemPath() )
+ displayedAttrs = { }
for (name, value) in item.iterAttributeValues():
+ displayedAttrs[name] = value
+ keys = displayedAttrs.keys()
+ keys.sort()
+ for name in keys:
+ value = displayedAttrs[name]
t = type(value)
- if name == "attributes":
- pass
-
-
- elif name == "notFoundAttributes" or name == "inheritedAttributes":
+ if name == "attributes" or \
+ name == "notFoundAttributes" or \
+ name == "inheritedAttributes" or \
+ name == "kind":
pass
elif t == list \
@@ -92,18 +107,3 @@
childuri = child.getItemPath()
PrintItem(childuri, rep, level+1)
-def GetAttributes(kind):
- """ Build the list of attributes this kind has, including inherited
- """
- try:
- for attr in kind.attributes:
- yield (attr, kind)
- except AttributeError, e:
- pass
-
- try:
- for superKind in kind.superKinds:
- for tuple in GetAttributes(superKind):
- yield tuple
- except AttributeError, e:
- pass
More information about the Commits
mailing list