[Libreoffice-commits] .: src/globals.py src/ole.py src/xlsstream.py xls-dump.py

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Apr 11 20:37:45 PDT 2011


 src/globals.py   |    2 ++
 src/ole.py       |   40 ++++++++++++++++++++--------------------
 src/xlsstream.py |   13 +++++++------
 xls-dump.py      |    4 ++--
 4 files changed, 31 insertions(+), 28 deletions(-)

New commits:
commit c7cd449cad9afc4b1d91cfa41b108265422988a8
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Mon Apr 11 23:35:54 2011 -0400

    Standardize the column width and make it a bit wider.

diff --git a/src/globals.py b/src/globals.py
index 3ccfe14..8f757e5 100644
--- a/src/globals.py
+++ b/src/globals.py
@@ -27,6 +27,8 @@
 
 import sys, struct, math, zipfile, xmlpp, StringIO
 
+OutputWidth = 76
+
 class ByteConvertError(Exception): pass
 
 class ByteStreamError(Exception): pass
diff --git a/src/ole.py b/src/ole.py
index edc5d7b..150b1cc 100644
--- a/src/ole.py
+++ b/src/ole.py
@@ -115,16 +115,16 @@ class Header(object):
                 output("%2.2X "%ord(b))
             output("\n")
 
-        def printSep (c='-', w=68, prefix=''):
+        def printSep (c, w, prefix=''):
             print(prefix + c*w)
 
-        printSep('=', 68)
+        printSep('=', globals.OutputWidth)
         print("Compound Document Header")
-        printSep('-', 68)
+        printSep('-', globals.OutputWidth)
 
         if self.params.debug:
             globals.dumpBytes(self.bytes[0:512])
-            printSep('-', 68)
+            printSep('-', globals.OutputWidth)
 
         # document ID and unique ID
         output("Document ID: ")
@@ -306,9 +306,9 @@ all the sectors pointed by the sector IDs in order of occurrence.
 
     def output (self):
         print('')
-        print("="*68)
+        print("="*globals.OutputWidth)
         print("Master Sector Allocation Table (MSAT)")
-        print("-"*68)
+        print("-"*globals.OutputWidth)
 
         for id in self.secIDs:
             print("sector ID: %5d   (pos: %7d)"%(id, 512+id*self.sectorSize))
@@ -411,15 +411,15 @@ class SAT(object):
 
     def output (self):
         print('')
-        print("="*68)
+        print("="*globals.OutputWidth)
         print("Sector Allocation Table (SAT)")
-        print("-"*68)
+        print("-"*globals.OutputWidth)
         if self.params.debug:
             self.outputRawBytes()
-            print("-"*68)
+            print("-"*globals.OutputWidth)
             for i in xrange(0, len(self.array)):
                 print("%5d: %5d"%(i, self.array[i]))
-            print("-"*68)
+            print("-"*globals.OutputWidth)
 
         self.outputArrayStats()
 
@@ -449,12 +449,12 @@ sectors are contained in the SAT as a sector ID chain.
 
     def output (self):
         print('')
-        print("="*68)
+        print("="*globals.OutputWidth)
         print("Short Sector Allocation Table (SSAT)")
-        print("-"*68)
+        print("-"*globals.OutputWidth)
         if self.params.debug:
             self.outputRawBytes()
-            print("-"*68)
+            print("-"*globals.OutputWidth)
             for i in xrange(0, len(self.array)):
                 item = self.array[i]
                 output("%3d : %3d\n"%(i, item))
@@ -577,20 +577,20 @@ entire file stream.
 
     def output (self, debug=False):
         print('')
-        print("="*68)
+        print("="*globals.OutputWidth)
         print("Directory")
 
         if debug:
-            print("-"*68)
+            print("-"*globals.OutputWidth)
             print("sector(s) used:")
             for secID in self.sectorIDs:
                 print("  sector %d"%secID)
 
             print("")
             for secID in self.sectorIDs:
-                print("-"*68)
+                print("-"*globals.OutputWidth)
                 print("  Raw Hex Dump (sector %d)"%secID)
-                print("-"*68)
+                print("-"*globals.OutputWidth)
                 pos = globals.getSectorPos(secID, self.sectorSize)
                 globals.dumpBytes(self.bytes[pos:pos+self.sectorSize], 128)
 
@@ -598,7 +598,7 @@ entire file stream.
             self.__outputEntry(entry, debug)
 
     def __outputEntry (self, entry, debug):
-        print("-"*68)
+        print("-"*globals.OutputWidth)
         if len(entry.Name) > 0:
             name = entry.Name
             if ord(name[0]) <= 5:
@@ -608,9 +608,9 @@ entire file stream.
             print("name: [empty]   (name buffer size: %d bytes)"%entry.CharBufferSize)
 
         if self.params.debug:
-            print("-"*68)
+            print("-"*globals.OutputWidth)
             globals.dumpBytes(entry.bytes)
-            print("-"*68)
+            print("-"*globals.OutputWidth)
 
         output("type: ")
         if entry.Type == Directory.Type.Empty:
diff --git a/src/xlsstream.py b/src/xlsstream.py
index 394077e..d923bd9 100644
--- a/src/xlsstream.py
+++ b/src/xlsstream.py
@@ -334,14 +334,14 @@ class XLStream(object):
         self.params = params
         self.strmData = strmData
 
-    def __printSep (self, c='-', w=68, prefix=''):
+    def __printSep (self, c, w, prefix=''):
         print(prefix + c*w)
 
     def printStreamInfo (self):
-        self.__printSep('=', 68)
+        self.__printSep('=', globals.OutputWidth)
         print("Excel File Format Dumper by Kohei Yoshida")
         print("  total stream size: %d bytes"%self.size)
-        self.__printSep('=', 68)
+        self.__printSep('=', globals.OutputWidth)
         print('')
 
     def printHeader (self):
@@ -434,7 +434,7 @@ class XLDirStream(object):
             self.pos += 1
         return bytes
 
-    def __printSep (self, c='-', w=68, prefix=''):
+    def __printSep (self, c, w, prefix=''):
         print(prefix + c*w)
 
     def __readRecordBytes (self):
@@ -492,7 +492,8 @@ class XLDirStream(object):
         handler = None 
         
         print("")
-        self.__printSep('=', 61, "%4.4Xh: "%header)
+        headerStr = "%4.4Xh: "%header
+        self.__printSep('=', globals.OutputWidth-len(headerStr), headerStr)
         if recData.has_key(header):
             print("%4.4Xh: %s - %s (%4.4Xh)"%
                   (header, recData[header][0], recData[header][1], header))
@@ -511,7 +512,7 @@ class XLDirStream(object):
         else:
             print("%4.4Xh:   size = %d"%(header, size))
 
-        self.__printSep('-', 61, "%4.4Xh: "%header)
+        self.__printSep('-', globals.OutputWidth-len(headerStr), headerStr)
         for i in xrange(0, size):
             if (i+1) % 16 == 1:
                 output("%4.4Xh: "%header)
diff --git a/xls-dump.py b/xls-dump.py
index 357bd97..ca3e8c0 100755
--- a/xls-dump.py
+++ b/xls-dump.py
@@ -59,12 +59,12 @@ class XLDumper(object):
         dirname = direntry.Name
         dirname = globals.encodeName(dirname)
         print("")
-        print("="*68)
+        print("="*globals.OutputWidth)
         if direntry.isStorage():
             print("%s (storage)"%dirname)
         else:
             print("%s (stream, size: %d bytes)"%(dirname, byteLen))
-        print("-"*68)
+        print("-"*globals.OutputWidth)
 
     def __parseFile (self):
         file = open(self.filepath, 'rb')


More information about the Libreoffice-commits mailing list