commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r8937 - trunk/gnue-common/src/definitions


From: jcater
Subject: [gnue] r8937 - trunk/gnue-common/src/definitions
Date: Thu, 26 Oct 2006 22:06:10 -0500 (CDT)

Author: jcater
Date: 2006-10-26 22:06:09 -0500 (Thu, 26 Oct 2006)
New Revision: 8937

Modified:
   trunk/gnue-common/src/definitions/GParser.py
   trunk/gnue-common/src/definitions/GParserHelpers.py
Log:
restored split between GObject and ParserObj as apparently some tools aren't 
ready for GContent to support such methods; will work-around in Designer

Modified: trunk/gnue-common/src/definitions/GParser.py
===================================================================
--- trunk/gnue-common/src/definitions/GParser.py        2006-10-27 00:59:00 UTC 
(rev 8936)
+++ trunk/gnue-common/src/definitions/GParser.py        2006-10-27 03:06:09 UTC 
(rev 8937)
@@ -172,9 +172,9 @@
   #
   #
   #object.__dict__.update(attributes)
+  if hasattr(object,'walk'):
+    object.walk (__addAttributesWalker, attributes = attributes)
 
-  object.walk (__addAttributesWalker, attributes = attributes)
-
   if initialize:
     assert gDebug (7, "Initializing the object tree starting at %s" % (object))
     object.phaseInit (dh._phaseInitCount)
@@ -210,7 +210,7 @@
 
 
 # =============================================================================
-# XML Content handler 
+# XML Content handler
 # =============================================================================
 
 class xmlHandler (xml.sax.ContentHandler):
@@ -282,13 +282,13 @@
     _singleInstanceTags. Additionally the tag-counter dictionary will
     be reset.
     """
-   
+
     for element in self.xmlElements:
       self._tagCounts [element] = 0
       try:
         if self.xmlElements [element]['Required']:
           self._requiredTags.append (element)
-          
+
       except KeyError:
         pass
 
@@ -451,7 +451,7 @@
             if 'Default' in baseAttrs [attr]:
               typecast      = baseAttrs [attr].get ('Typecast', GTypecast.text)
               lattrs [attr] = typecast (baseAttrs [attr]['Default'])
-  
+
             # Check for missing required attributes
             elif baseAttrs [attr].get ('Required', False):
               tm = u_('Error processing <%(tagname)s> tag [required attribute '
@@ -484,7 +484,7 @@
       object._xmltag           = tname
       object._xmlnamespace     = ns
       object._listedAttributes = loadedxmlattrs.keys ()
-      
+
     elif self.xmlMasqueradeNamespaceElements:
       #
       # namespace qualifier and we are masquerading
@@ -527,7 +527,7 @@
     # Save the attributes loaded from XML file (i.e., attributes that were not
     # defaulted)
     object._loadedxmlattrs = loadedxmlattrs
-    
+
     # We make the url of the xml-stream and the line number of the element
     # available to the instance (for later error handling)
     object._lineNumber = self.parser.getLineNumber ()
@@ -561,7 +561,7 @@
         handle = openResource (lattrs [attr])
         text = handle.read ().decode (textEncoding)
         handle.close ()
-        
+
         if self.xmlStack [0] != None:
           GContent (self.xmlStack [0], text)
 
@@ -577,7 +577,7 @@
     Called by the internal SAX parser whenever text (not part of a tag) is
     encountered.
     """
- 
+
     if self.xmlStack [0] != None:
       # Masqueraging namespace elements, then keep content
       xmlns = self.xmlMasqueradeNamespaceElements and \
@@ -615,19 +615,19 @@
     if not child:
       return
 
-    if hasattr(child, '_buildObject'): 
+    if hasattr(child, '_buildObject'):
         inits = child._buildObject()
         self._phaseInitCount = (inits != None and inits > self._phaseInitCount 
\
                                 and inits or self._phaseInitCount)
-        
+
     assert gDebug (7, "</%s>" % tname)
-    
+
     self.object_created(child)
 
   # ---------------------------------------------------------------------------
   # Get the root comments sequence
   # ---------------------------------------------------------------------------
-  def object_created(self, obj): 
+  def object_created(self, obj):
       pass
 
 
@@ -659,17 +659,17 @@
 
   def startCDATA (self):
     pass
-  
+
   # ---------------------------------------------------------------------------
 
   def endCDATA (self):
     pass
-      
+
   # ---------------------------------------------------------------------------
 
   def startDTD (self, name, public_id, system_id):
     pass
-          
+
   # ---------------------------------------------------------------------------
 
   def endDTD (self):
@@ -800,7 +800,7 @@
 
 
 # =============================================================================
-# Generic class for importable objects 
+# Generic class for importable objects
 # =============================================================================
 
 class GImport (GObj):

Modified: trunk/gnue-common/src/definitions/GParserHelpers.py
===================================================================
--- trunk/gnue-common/src/definitions/GParserHelpers.py 2006-10-27 00:59:00 UTC 
(rev 8936)
+++ trunk/gnue-common/src/definitions/GParserHelpers.py 2006-10-27 03:06:09 UTC 
(rev 8937)
@@ -53,7 +53,7 @@
 
   # ---------------------------------------------------------------------------
   # Constructor
-   # 
---------------------------------------------------------------------------
+  # ---------------------------------------------------------------------------
 
   def __init__ (self, parent = None, type = '_NotSet_'):
 
@@ -305,70 +305,8 @@
     return self._dumpXML_ (lookupDict, treeDump, gap, xmlnamespaces,
         textEncoding, stripPrefixes, escape)
 
-  # ---------------------------------------------------------------------------
-  # Function for traversing an object tree
-  # ---------------------------------------------------------------------------
 
-  def walk (self, function, *args, **parms):
-    """
-    Function that recursively walks down through a tree of L{ParserObj}
-    instances and applies a function to them.
-
-    @param function: the function to call for every element found in the tree
-    """
-
-    function (self, *args, **parms)
-    for child in self._children:
-      if isinstance (child, GObj):
-        child.walk (function, *args, **parms)
-
-
   # ---------------------------------------------------------------------------
-  # Get an iterator for child objects
-  # ---------------------------------------------------------------------------
-
-  def iterator (self, test = None, types = (), includeSelf = True):
-    """
-    Return a python iterator of child objects.
-
-    @param test: A function that should return true or false to
-           indicate whether a GObject should be included in the
-           iterator. This method will be passed a GObj instance.
-           e.g., test=lambda obj: obj._type in ('GFField,'GFEntry')
-    @type test: method
-
-    @param types: A list of valid child types to return.
-           E.g., types=('GFField','GFEntry')
-    @type types: list
-
-    @param includeSelf: Should the current object be included in the tests?
-    @type includeSelf: boolean
-
-    @return: An iterator of matching objects
-
-    """
-    if includeSelf:
-      objects = [self]
-    else:
-      objects = self._children
-    set = []
-
-    def _includable (object):
-      include = True
-      if test:
-        include = include and test (object)
-      if types:
-        include = include and object._type in types
-      if include:
-        set.append (object)
-
-    for child in objects:
-      child.walk (_includable)
-
-    return _GObjectIterator (set)
-
-
-  # ---------------------------------------------------------------------------
   # Find the first parent instance of a given type
   # ---------------------------------------------------------------------------
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]