commit-gnue
[Top][All Lists]
Advanced

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

r5340 - in trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabu


From: jcater
Subject: r5340 - in trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator: . formatters
Date: Wed, 17 Mar 2004 17:13:52 -0600 (CST)

Author: jcater
Date: 2004-03-17 17:13:51 -0600 (Wed, 17 Mar 2004)
New Revision: 5340

Modified:
   trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/Adapter.py
   
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/csv.py
   
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/html.py
   
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/pdf.py
   
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/text.py
Log:
made width optional on the tabulator's column heading

Modified: 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/Adapter.py
===================================================================
--- 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/Adapter.py   
    2004-03-17 22:48:30 UTC (rev 5339)
+++ 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/Adapter.py   
    2004-03-17 23:13:51 UTC (rev 5340)
@@ -157,8 +157,11 @@
       self.formatter.EndRow()
       
     elif name == "colhead":
-      colwidth = GTypecast.integer(self._attrs['width'])
       try:
+        colwidth = GTypecast.integer(self._attrs['width'])
+      except KeyError: 
+        colwidth = None
+      try:
         align = self._attrs['align']
       except KeyError:
         align = 'left'

Modified: 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/csv.py
===================================================================
--- 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/csv.py
        2004-03-17 22:48:30 UTC (rev 5339)
+++ 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/csv.py
        2004-03-17 23:13:51 UTC (rev 5340)
@@ -32,7 +32,7 @@
   def __init__(self, destination, stylesheet, options={}):
     self.dest = destination
     self.options = options
-    try: 
+    try:
       self.encoding = options['encoding']
     except:
       self.encoding = gConfig('textEncoding')
@@ -45,7 +45,7 @@
 
   def EndReport(self):
     pass
-    
+
   def BeginReportTitle(self):
     pass
 
@@ -54,13 +54,13 @@
 
   def BeginSection(self):
     pass
-    
+
   def EndSection(self):
     pass
 
   def BeginSectionTitle(self):
     pass
-    
+
   def EndSectionTitle(self, sectiontitle):
     pass
 
@@ -93,7 +93,7 @@
 
   def EndCol(self, col, index):
     self._row.append('"%s"' % col)
- 
 
 
 
+

Modified: 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/html.py
===================================================================
--- 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/html.py
       2004-03-17 22:48:30 UTC (rev 5339)
+++ 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/html.py
       2004-03-17 23:13:51 UTC (rev 5340)
@@ -37,7 +37,7 @@
     self._sectiontitle = u''
     self.stylesheet = stylesheet
 
-    try: 
+    try:
       self.encoding = options['encoding']
     except:
       self.encoding = gConfig('textEncoding')
@@ -56,7 +56,7 @@
 
     if css:
       css.close()
-    
+
     self.writeout('<html>\n')
     self.writeout('  <head>\n')
     self.writeout('    <meta http-equiv="Content-Type" content="text/html; 
charset=%s"/>\n' % self.encoding)
@@ -67,7 +67,7 @@
   def EndReport(self):
     self.writeout('  </body>\n')
     self.writeout('</html>')
-    
+
   def BeginReportTitle(self):
     pass
 
@@ -77,13 +77,13 @@
 
   def BeginSection(self):
     pass
-    
+
   def EndSection(self):
     pass
 
   def BeginSectionTitle(self):
     pass
-    
+
   def EndSectionTitle(self, sectiontitle):
     self._sectiontitle = sectiontitle
     self.writeout('  <h2>%s</h2>\n' % self._sectiontitle)

Modified: 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/pdf.py
===================================================================
--- 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/pdf.py
        2004-03-17 22:48:30 UTC (rev 5339)
+++ 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/pdf.py
        2004-03-17 23:13:51 UTC (rev 5340)
@@ -37,7 +37,7 @@
 except ImportError:
   raise "Unable to load reportlab. You can get reportlab from"+\
         " www.reportlab.org. If you have debian just do a apt-get install "+\
-       " python-reportlab."
+        " python-reportlab."
 
 from reportlab.platypus.doctemplate import PageTemplate, BaseDocTemplate
 from reportlab.platypus import Table, Paragraph
@@ -55,7 +55,7 @@
   ttf_supported = 1
 except ImportError:
   ttf_supported = 0
-  
+
 PAGE_WIDTH = defaultPageSize[0]
 PAGE_HEIGHT = defaultPageSize[1]
 
@@ -89,10 +89,10 @@
 
     #self.font = 'Arial'
     #self.boldfont = 'Arial'
-    
+
     #self.font = 'ArialUnicodeMS'
     #self.boldfont = 'ArialUnicodeMS'
-    
+
     #self.font = 'SimSun'
 
     #self.font = 'ZenKai-Medium'
@@ -104,7 +104,7 @@
   def loadFont(self,name):
     if not ttf_supported:
       return
-    
+
     if font_to_filename.has_key(name):
       try:
         pdfmetrics.registerFont(TTFont(name, self.fontdir + \
@@ -113,7 +113,7 @@
       except Exception,msg:
         print _("Error occured loading font %s (%s).") % (name,msg)
         sys.exit(0)
-    
+
     # TODO: do we need more mappings?
     #addMapping('Arial', 0, 1, 'ArialI')
     #addMapping('Arial', 1, 0, 'ArialB')
@@ -122,13 +122,13 @@
   # Used to paint non-flowing (i.e standard) parts of pages
   def myPages(self, canvas, doc):
     canvas.saveState()
-    
+
     # first frame for title and sectiontitle
     f1 = Frame(self._doc.leftMargin-cm, 
self._doc.bottomMargin+self._doc.height-0.4*cm,
-                    self._doc.width+2*cm, 2.5*cm, 
-                    leftPadding=0, bottomPadding=0, rightPadding=0, 
topPadding=0, 
+                    self._doc.width+2*cm, 2.5*cm,
+                    leftPadding=0, bottomPadding=0, rightPadding=0, 
topPadding=0,
                     id='title', showBoundary=0)
-    
+
     titlestyle = getSampleStyleSheet()["Title"]
     titlestyle.fontName=self.font
     p1 = Paragraph(self._reporttitle, titlestyle)
@@ -141,8 +141,8 @@
 
     # second frame for table heading
     f2 = Frame(self._doc.leftMargin, 
self._doc.bottomMargin+self._doc.height-cm,
-                    self._doc.width, 0.65*cm, 
-                    leftPadding=0, bottomPadding=0, rightPadding=0, 
topPadding=0, 
+                    self._doc.width, 0.65*cm,
+                    leftPadding=0, bottomPadding=0, rightPadding=0, 
topPadding=0,
                     id='head', showBoundary=0)
 
     # white on black for table heading
@@ -150,7 +150,7 @@
     Style.append(('BACKGROUND', (0,0), (-1,-1), colors.black))
     Style.append(('TEXTCOLOR', (0,0), (-1,-1), colors.white))
     Style.append(('FONTNAME', (0,0), (-1,-1), self.font))
-    
+
     t = Table([self._tableHead], colWidths=self._colwidth, style=Style)
     f2.addFromList([t], canvas)
 
@@ -167,34 +167,34 @@
   def EndReport(self):
     # third frame for table body
     frame = Frame(self._doc.leftMargin, self._doc.bottomMargin,
-                         self._doc.width, self._doc.height-cm, 
-                         leftPadding=0, bottomPadding=0, rightPadding=0, 
topPadding=0, 
+                         self._doc.width, self._doc.height-cm,
+                         leftPadding=0, bottomPadding=0, rightPadding=0, 
topPadding=0,
                          id='body', showBoundary=0)
     pt = PageTemplate(id='All', frames=frame, onPage=self.myPages, 
pagesize=self._doc.pagesize)
     self._doc.addPageTemplates(pt)
     self._doc.build(self._body)
-    
-    
+
+
   def BeginReportTitle(self):
     pass
-    
-    
+
+
   def EndReportTitle(self, reporttitle):
     self._reporttitle = reporttitle.encode('utf-8')
 
 
   def BeginSection(self):
     pass
-  
-  
+
+
   def EndSection(self):
     pass
 
 
   def BeginSectionTitle(self):
     pass
-    
-    
+
+
   def EndSectionTitle(self, sectiontitle):
     self._sectiontitle = sectiontitle.encode('utf-8')
 
@@ -220,11 +220,11 @@
       self._tableStyle.append(('ALIGN', (i, 0), (i, 0), 
self._tableAlign[i].upper()))
       self._tableStyle.append(('FONTNAME', (0,0), (-1,-1), self.font))
       self._colwidth[i] = (self._doc.width/self._headwidth)*self._colwidth[i]
-      
+
     self._oddStyle = [elem for elem in self._tableStyle]
     self._oddStyle.append(('BACKGROUND', (0,0), (-1,-1), colors.lightgrey))
     self._oddStyle.append(('TEXTCOLOR', (0,0), (-1,-1), colors.black))
-    
+
     self._subtotalStyle = [elem for elem in self._tableStyle]
     self._subtotalStyle.append(('LINEABOVE', (0,0), (-1,-1), 0.25, 
colors.black))
     self._subtotalStyle.append(('FONTNAME', (0,0), (-1,-1), self.boldfont))
@@ -234,6 +234,11 @@
 
 
   def EndColHead(self, colhead, width, alignment=None):
+
+    # TODO: temporary... should be calculated
+    if not width:
+      width = 15
+
     self._tableHead.append(colhead.encode('utf-8'))
     self._tableAlign.append(alignment)
     self._colwidth.append(width)
@@ -256,15 +261,15 @@
     t = Table([self._row], colWidths=self._colwidth, style=self._rowStyle)
     self._body.append(t)
     self._odd = not self._odd
-    
 
+
   def BeginCol(self):
     pass
 
 
   def EndCol(self, col, index):
     self._row.append(col.encode('utf-8'))
- 
 
 
 
+

Modified: 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/text.py
===================================================================
--- 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/text.py
       2004-03-17 22:48:30 UTC (rev 5339)
+++ 
trunk/gnue-reports/src/adapters/filters/SimpleTabulation/tabulator/formatters/text.py
       2004-03-17 23:13:51 UTC (rev 5340)
@@ -35,8 +35,8 @@
 
     self._reporttitle = u''
     self._sectiontitle = u''
-    
-    try: 
+
+    try:
       self.encoding = options['encoding']
     except:
       self.encoding = gConfig('textEncoding')
@@ -106,6 +106,11 @@
 
 
   def EndColHead(self, colhead, width, alignment=None):
+
+    # TODO: temporary... should be calculated
+    if not width:
+      width = 15
+
     if alignment == 'center':
       ch = colhead.strip().center(width)
     elif alignment == 'right':
@@ -126,9 +131,9 @@
   def EndRow(self):
     if self._rowtype == 'subtotal':
       self.writeout('%s\n' % ('-'*self._headwidth))
-      
+
     self.writeout('%s\n' % ''.join(self._row))
-    
+
     if self._rowtype == 'subtotal':
       self.writeout('\n')
 





reply via email to

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