[Commits] (morgen) PrintItem( ) now defaults to *not* including
descendents in the output; if
commits at osafoundation.org
commits at osafoundation.org
Wed Mar 24 13:03:43 PST 2004
Commit by: morgen
Modified files:
osaf/chandler/Chandler/repository/parcel/Util.py 1.9 1.10
Log message:
PrintItem( ) now defaults to *not* including descendents in the output; if
you want it to recurse, pass in recursive=True as the third argument:
PrintItem("//parcels", rep, recursive=True)
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/repository/parcel/Util.py.diff?r1=text&tr1=1.9&r2=text&tr2=1.10
Index: osaf/chandler/Chandler/repository/parcel/Util.py
diff -u osaf/chandler/Chandler/repository/parcel/Util.py:1.9 osaf/chandler/Chandler/repository/parcel/Util.py:1.10
--- osaf/chandler/Chandler/repository/parcel/Util.py:1.9 Tue Mar 23 21:08:37 2004
+++ osaf/chandler/Chandler/repository/parcel/Util.py Wed Mar 24 13:03:12 2004
@@ -2,20 +2,21 @@
Utility functions for displaying repository contents
"""
-__revision__ = "$Revision: 1.9 $"
-__date__ = "$Date: 2004/03/24 05:08:37 $"
+__revision__ = "$Revision: 1.10 $"
+__date__ = "$Date: 2004/03/24 21:03:12 $"
__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):
+def PrintItem(uri, rep, recursive=False, level=0):
"""
- Given a uri, display its info along with all its children recursively
-
- Example: PrintItem("//Schema", rep)
+ Given a uri, display its info; include all descendents if recursive is
+ True (default is False)
+ Example: PrintItem("//Schema", rep, recursive=True)
"""
+
for i in range(level):
print " ",
item = rep.find(uri)
@@ -111,7 +112,7 @@
print
- if item.hasChildren():
+ if recursive and item.hasChildren():
for child in item.iterChildren():
- childuri = child.itsPath
- PrintItem(childuri, rep, level+1)
+ childuri = str(child.itsPath)
+ PrintItem(childuri, rep, recursive=True, level=level+1)
More information about the Commits
mailing list