commit-gnue
[Top][All Lists]
Advanced

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

gnue common/src/GObjects.py common/src/GParser....


From: Jason Cater
Subject: gnue common/src/GObjects.py common/src/GParser....
Date: Wed, 01 Jan 2003 17:21:40 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    03/01/01 17:21:40

Modified files:
        common/src     : GObjects.py GParser.py 
        reports        : FAQ 
        reports/doc    : report-notes.txt 
        reports/src    : GRLayout.py GRParser.py 

Log message:
        * primary elements (section, field, summ, etc) with namespace-qualified 
attributes will output the primary element tag w/only the qualified attributes 
(e.g., <section name="foo" out:lookAtMe="1"> will output <section lookatMe="1"> 
 into the raw output stream)
        
        * Misc bug fixes

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GObjects.py.diff?tr1=1.49&tr2=1.50&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GParser.py.diff?tr1=1.57&tr2=1.58&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/FAQ.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/doc/report-notes.txt.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/src/GRLayout.py.diff?tr1=1.49&tr2=1.50&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/reports/src/GRParser.py.diff?tr1=1.29&tr2=1.30&r1=text&r2=text

Patches:
Index: gnue/common/src/GObjects.py
diff -c gnue/common/src/GObjects.py:1.49 gnue/common/src/GObjects.py:1.50
*** gnue/common/src/GObjects.py:1.49    Sun Dec 22 20:31:38 2002
--- gnue/common/src/GObjects.py Wed Jan  1 17:21:40 2003
***************
*** 49,55 ****
      self._children = []         # The objects contained by this object
      self._attributes = {}
      self._inits = []            # functions called during phaseInit stage
!     self._xmlnamespace = None
      if parent :
        parent.addChild(self)
  
--- 49,56 ----
      self._children = []         # The objects contained by this object
      self._attributes = {}
      self._inits = []            # functions called during phaseInit stage
!     self._xmlnamespace = None   # If the object is namespace-qualified, the 
namespace
!     self._xmlnamespaces = {}    # If attributes are namespace-qualified, a map
      if parent :
        parent.addChild(self)
  
***************
*** 142,148 ****
  
    def showTree(self, indent=0):
      print ' ' * indent + `self._type`,self
!     
      for child in self._children:
         child.showTree(indent + 2)
  
--- 143,149 ----
  
    def showTree(self, indent=0):
      print ' ' * indent + `self._type`,self
! 
      for child in self._children:
         child.showTree(indent + 2)
  
***************
*** 153,176 ****
    #
    def addChild(self, child):
      self._children.append(child)
- 
-   def toXML(self):
-     xml_outer = string.lower(self._type[2:])
-     r = "<" + xml_outer + ">\n  <options>\n"
-     for k in self.__dict__.keys():
-       # skip keys beginning with _
-       if k[0] == "_":
-         continue
-       val = self.__dict__[k]
-       if isinstance(val, _types.StringType):
-         str = val
-       elif isinstance(val, _types.IntType) or isinstance(val, 
_types.FloatType):
-         str = repr(val)
-       else:
-         continue
-       r += "    <" + k + ">" + str + "</" + k + ">\n"
-     r += "  </options>\n</" + xml_outer + ">\n"
-     return r
  
    #
    # dumpXML
--- 154,159 ----
Index: gnue/common/src/GParser.py
diff -c gnue/common/src/GParser.py:1.57 gnue/common/src/GParser.py:1.58
*** gnue/common/src/GParser.py:1.57     Thu Dec 26 20:00:34 2002
--- gnue/common/src/GParser.py  Wed Jan  1 17:21:40 2003
***************
*** 141,147 ****
  def addAttributesWalker(object, attributes={}):
    if isinstance(object,GRootObj):
      object.__dict__.update(attributes)
!           
  
  
  #######################################################
--- 141,147 ----
  def addAttributesWalker(object, attributes={}):
    if isinstance(object,GRootObj):
      object.__dict__.update(attributes)
! 
  
  
  #######################################################
***************
*** 264,271 ****
          if attrns:
            if not self.xmlNamespaceAttributesAsPrefixes:
              raise "Unexpected namespace on attribute"
!           prefix = attrns.split(':')[-1] + '__' + attr
!           attrs[prefix] = saxattrs[qattr]
            xmlns[prefix] = attrns
  
          else:
--- 264,271 ----
          if attrns:
            if not self.xmlNamespaceAttributesAsPrefixes:
              raise "Unexpected namespace on attribute"
!           prefix = attrns.split(':')[-1]
!           attrs[prefix + '__' + attr] = saxattrs[qattr]
            xmlns[prefix] = attrns
  
          else:
Index: gnue/reports/FAQ
diff -c gnue/reports/FAQ:1.2 gnue/reports/FAQ:1.3
*** gnue/reports/FAQ:1.2        Tue Apr  9 18:55:41 2002
--- gnue/reports/FAQ    Wed Jan  1 17:21:40 2003
***************
*** 1,9 ****
  
! Q: Why do you use XSLT? Isn't it slow?
  
! A: XSLT is a means to an end.  Currently, it provides the biggest bang 
!    for the buck.  Reports will have hooks so that "formatting engines" 
!    can be written that can output directly to the desired output.  
!    However, there are more pressing issues than such engines and XSLT
!    serves our needs well enough for the foreseeable future. 
  
--- 1,5 ----
  
! Q: Why is this FAQ file empty?
  
! A: Because it needs to be written!  Patches are welcome. 
  
Index: gnue/reports/doc/report-notes.txt
diff -c gnue/reports/doc/report-notes.txt:1.7 
gnue/reports/doc/report-notes.txt:1.8
*** gnue/reports/doc/report-notes.txt:1.7       Tue Dec 31 03:22:58 2002
--- gnue/reports/doc/report-notes.txt   Wed Jan  1 17:21:40 2003
***************
*** 40,46 ****
    <section positioning="below|right|marginleft|margintop|absolute|named"
           relation="<sectionname>|<formanchor>"
           mode="freeform|tabular|crosstab|(bar|pie|line)chart"
!          
           marginleft="<measurement>|auto"
           marginright="<measurement>|auto"
           margintop="<measurement>|auto"
--- 40,46 ----
    <section positioning="below|right|marginleft|margintop|absolute|named"
           relation="<sectionname>|<formanchor>"
           mode="freeform|tabular|crosstab|(bar|pie|line)chart"
! 
           marginleft="<measurement>|auto"
           marginright="<measurement>|auto"
           margintop="<measurement>|auto"
***************
*** 55,62 ****
  
           style="..."
  
!          # The following *should* typically only be defined by style=, not by 
attributes
!          # But the "styles" have to have something to "implement"
           shaderows="3"
           shadebackground="10%"
           border="<top>;<left>;<bot>;<right>;<vert>;<horiz>"
--- 55,62 ----
  
           style="..."
  
!          # The following *should* typically only be defined with style=, not 
by attributes
!          # But the "styles" must have something to "implement"
           shaderows="3"
           shadebackground="10%"
           border="<top>;<left>;<bot>;<right>;<vert>;<horiz>"
Index: gnue/reports/src/GRLayout.py
diff -c gnue/reports/src/GRLayout.py:1.49 gnue/reports/src/GRLayout.py:1.50
*** gnue/reports/src/GRLayout.py:1.49   Sun Dec 22 10:15:31 2002
--- gnue/reports/src/GRLayout.py        Wed Jan  1 17:21:40 2003
***************
*** 221,227 ****
      self._inits = [self.primaryInit]
  
    # Called if section contains data
!   def process(self, dest, mapper, isfirst, islast, firstSection, nextSection):
      return nextSection
  
    def primaryInit(self):
--- 221,244 ----
      self._inits = [self.primaryInit]
  
    # Called if section contains data
!   def process(self, dest, *args, **parms):
!     tag = self.getXmlTag()
!     attrs = ""
!     for attr in self.__dict__.keys():
!       try:    prefix, att = attr.split('__',1)
!       except: continue
!       
!       if prefix in self._xmlnamespaces.keys():
!         attrs += ' %s="%s"' % (att, saxutils.escape(self.__dict__[attr]))
! 
!     dest.write('<%s%s>' % (tag, attrs))
!     rv = self._process(dest, *args, **parms)
!     dest.write('</%s>' % tag)
!     
!     return rv
! 
!   # Called if section contains data (the non-namespace version)
!   def _process(self, dest, mapper, isfirst, islast, firstSection, 
nextSection):
      return nextSection
  
    def primaryInit(self):
***************
*** 233,238 ****
--- 250,260 ----
        except AttributeError:
          self._source = None
  
+     if not self._xmlnamespaces:
+       # Avoid any overhead if this element doesn't
+       # contain namespace-qualified attributes
+       self.process = self._process
+ 
  
  ############################################################
  #
***************
*** 255,261 ****
      while 1:
        if isinstance(self, GRSection) :
          self.processTrigger('On-Process')
!         
        for child in self._children:
          if child._type == "_content_":
            dest.write(child.getContent())
--- 277,283 ----
      while 1:
        if isinstance(self, GRSection) :
          self.processTrigger('On-Process')
! 
        for child in self._children:
          if child._type == "_content_":
            dest.write(child.getContent())
***************
*** 407,413 ****
  
    # Generic process() method.  Process the
    # current record and handle any children.
!   def process(self, dest, mapper, isfirst, islast, firstSection, nextSection):
      self.processTrigger('Pre-Section')
      GDebug.printMesg(10,"Repeating Section %s" % self._name)
      structuralComment(dest,"<!-- [section:%s] -->" % self._name)
--- 429,435 ----
  
    # Generic process() method.  Process the
    # current record and handle any children.
!   def _process(self, dest, mapper, isfirst, islast, firstSection, 
nextSection):
      self.processTrigger('Pre-Section')
      GDebug.printMesg(10,"Repeating Section %s" % self._name)
      structuralComment(dest,"<!-- [section:%s] -->" % self._name)
***************
*** 450,455 ****
--- 472,480 ----
    def process(self, dest, mapper, isfirst, islast, firstSection, nextSection):
      return nextSection
  
+   def _process(self, dest, mapper, isfirst, islast, firstSection, 
nextSection):
+     return nextSection
+ 
  
  
  ############################################################
***************
*** 462,468 ****
      self._section = None
      self.format = None
  
!   def process(self, dest, mapper, isfirst, islast, firstSection, nextSection):
      structuralComment(dest,"<!-- [field:%s] -->" % self.name)
      dest.write (string.replace(saxutils.escape("%s" % 
self._mymapper.getField(self.name,
                                                self.format)), '\r',''))
--- 487,493 ----
      self._section = None
      self.format = None
  
!   def _process(self, dest, mapper, isfirst, islast, firstSection, 
nextSection):
      structuralComment(dest,"<!-- [field:%s] -->" % self.name)
      dest.write (string.replace(saxutils.escape("%s" % 
self._mymapper.getField(self.name,
                                                self.format)), '\r',''))
***************
*** 473,478 ****
--- 498,537 ----
  
  ############################################################
  #
+ # <formula> tag
+ #
+ class GRFormula (GRLayoutElement):
+   def __init__(self, parent):
+     GRLayoutElement.__init__(self, parent, 'GRFormula')
+     self.section = None
+     self.format = None
+     self._inits = [self.init]
+ 
+   def _buildObject(self):
+     if self.section:
+       self._section = string.lower(self.section)
+     else:
+       self._section = None
+ 
+     return GRLayoutElement._buildObject(self)
+ 
+   def init(self):
+     code = ""
+     for f in self.getChildrenAsContent().code.split('\n'):
+       if f.strip()[:1] != '#':
+         code += f + ' '
+     self._code = code
+ 
+   def _process(self, dest, mapper, isfirst, islast, firstSection, 
nextSection):
+     structuralComment(dest,"<!-- [formula:%s] -->" % (self.section))
+ #    dest.write (self._mymapper.getSummary(self._field, self.function, 
self.format))
+     structuralComment(dest,"<!-- [/formula] -->")
+     return nextSection
+ 
+ 
+ 
+ ############################################################
+ #
  # <summ> tag
  #
  class GRSumm (GRLayoutElement):
***************
*** 491,497 ****
      self._field = string.lower(self.field)
      return GRLayoutElement._buildObject(self)
  
!   def process(self, dest, mapper, isfirst, islast, firstSection, nextSection):
      structuralComment(dest,"<!-- [summ:%s:%s:%s] -->" % (self.section, 
self._field, self.function))
      dest.write (self._mymapper.getSummary(self._field, self.function, 
self.format))
      structuralComment(dest,"<!-- [/summ] -->")
--- 550,556 ----
      self._field = string.lower(self.field)
      return GRLayoutElement._buildObject(self)
  
!   def _process(self, dest, mapper, isfirst, islast, firstSection, 
nextSection):
      structuralComment(dest,"<!-- [summ:%s:%s:%s] -->" % (self.section, 
self._field, self.function))
      dest.write (self._mymapper.getSummary(self._field, self.function, 
self.format))
      structuralComment(dest,"<!-- [/summ] -->")
***************
*** 513,519 ****
      GRLayoutElement.__init__(self, parent=None)
      GRStubParam.__init__(self, parent)
  
!   def process(self, dest, mapper, isfirst, islast, firstSection, nextSection):
      structuralComment(dest,"<!-- [param:%s] -->" % self.name)
      dest.write (self.getFormattedValue())
      structuralComment(dest,"<!-- [/param:%s] -->" % self.name)
--- 572,578 ----
      GRLayoutElement.__init__(self, parent=None)
      GRStubParam.__init__(self, parent)
  
!   def _process(self, dest, mapper, isfirst, islast, firstSection, 
nextSection):
      structuralComment(dest,"<!-- [param:%s] -->" % self.name)
      dest.write (self.getFormattedValue())
      structuralComment(dest,"<!-- [/param:%s] -->" % self.name)
***************
*** 531,537 ****
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRFirstRow')
  
!   def process(self, dest, mapper, isfirst, islast, firstSection, nextSection):
      if isfirst:
        nextSection = self.processChildren(dest, mapper, isfirst, islast, 
firstSection, nextSection)
      return nextSection
--- 590,596 ----
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRFirstRow')
  
!   def _process(self, dest, mapper, isfirst, islast, firstSection, 
nextSection):
      if isfirst:
        nextSection = self.processChildren(dest, mapper, isfirst, islast, 
firstSection, nextSection)
      return nextSection
***************
*** 542,548 ****
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRNotFirstRow')
  
!   def process(self, dest, mapper, isfirst, islast, firstSection, nextSection):
      if not isfirst:
        nextSection = self.processChildren(dest, mapper, isfirst, islast, 
firstSection, nextSection)
      return nextSection
--- 601,607 ----
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRNotFirstRow')
  
!   def _process(self, dest, mapper, isfirst, islast, firstSection, 
nextSection):
      if not isfirst:
        nextSection = self.processChildren(dest, mapper, isfirst, islast, 
firstSection, nextSection)
      return nextSection
***************
*** 552,558 ****
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRLastRow')
  
!   def process(self, dest, mapper, isfirst, islast, firstSection, nextSection):
      if islast:
        nextSection = self.processChildren(dest, mapper, isfirst, islast, 
firstSection, nextSection)
      return nextSection
--- 611,617 ----
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRLastRow')
  
!   def _process(self, dest, mapper, isfirst, islast, firstSection, 
nextSection):
      if islast:
        nextSection = self.processChildren(dest, mapper, isfirst, islast, 
firstSection, nextSection)
      return nextSection
***************
*** 562,568 ****
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRNotLastRow')
  
!   def process(self, dest, mapper, isfirst, islast, firstSection, nextSection):
      if not islast:
        nextSection = self.processChildren(dest, mapper, isfirst, islast, 
firstSection, nextSection)
      return nextSection
--- 621,627 ----
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRNotLastRow')
  
!   def _process(self, dest, mapper, isfirst, islast, firstSection, 
nextSection):
      if not islast:
        nextSection = self.processChildren(dest, mapper, isfirst, islast, 
firstSection, nextSection)
      return nextSection
***************
*** 578,584 ****
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRPassThru')
  
!   def process(self, dest, mapper, isfirst, islast, firstSection, nextSection):
      dest.write('<%s' % self._xmltag)
      for attr in self._loadedxmlattrs.keys():
        dest.write(' %s="%s"' % (attr, 
saxutils.escape(str(self._loadedxmlattrs[attr]))))
--- 637,643 ----
    def __init__(self, parent):
      ContainerElement.__init__(self, parent, 'GRPassThru')
  
!   def _process(self, dest, mapper, isfirst, islast, firstSection, 
nextSection):
      dest.write('<%s' % self._xmltag)
      for attr in self._loadedxmlattrs.keys():
        dest.write(' %s="%s"' % (attr, 
saxutils.escape(str(self._loadedxmlattrs[attr]))))
Index: gnue/reports/src/GRParser.py
diff -c gnue/reports/src/GRParser.py:1.29 gnue/reports/src/GRParser.py:1.30
*** gnue/reports/src/GRParser.py:1.29   Mon Nov  4 16:13:19 2002
--- gnue/reports/src/GRParser.py        Wed Jan  1 17:21:40 2003
***************
*** 296,298 ****
--- 296,301 ----
      #
      self.xmlMasqueradeNamespaceElements = GRLayout.GRPassThru
  
+     #
+     self.xmlNamespaceAttributesAsPrefixes = 1
+ 



reply via email to

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