Show
Ignore:
Timestamp:
10/06/08 00:22:07 (16 years ago)
Author:
jerome
Message:

Removed spaces at EOL.

Location:
pkpgcounter/trunk/tests
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • pkpgcounter/trunk/tests/gstests.py

    r564 r3436  
    11#! /usr/bin/env python 
    2 # -*- coding: UTF-8 -*- 
     2# -*- coding: utf-8 -*- 
    33# 
    44# pkpgcounter : a generic Page Description Language parser 
     
    99# the Free Software Foundation, either version 3 of the License, or 
    1010# (at your option) any later version. 
    11 #  
     11# 
    1212# This program is distributed in the hope that it will be useful, 
    1313# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1414# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1515# GNU General Public License for more details. 
    16 #  
     16# 
    1717# You should have received a copy of the GNU General Public License 
    1818# along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     
    4343        self.md5sum = self.computeChecksum() 
    4444        self.mastersize = None 
    45          
    46     def __del__(self) :     
     45 
     46    def __del__(self) : 
    4747        """Remove temporary file, if any.""" 
    4848        if self.tmp is not None : 
    4949            self.tmp.close() 
    50              
    51     def computeChecksum(self) :     
     50 
     51    def computeChecksum(self) : 
    5252        """Computes an MD5 checksum for the input file's content.""" 
    5353        checksum = md5.new() 
     
    6060            infile = sys.stdin 
    6161            istemp = True 
    62         else :     
     62        else : 
    6363            infile = open(self.inputfile, "rb") 
    64              
     64 
    6565        while True : 
    6666            data = infile.read(MEGABYTE) 
    6767            if not data : 
    6868                break 
    69             if istemp :     
     69            if istemp : 
    7070                self.tmp.write(data) 
    7171            checksum.update(data) 
    72              
    73         if istemp :     
    74             self.tmp.flush()     
     72 
     73        if istemp : 
     74            self.tmp.flush() 
    7575        else : 
    7676            infile.close() 
    77              
    78         return checksum.hexdigest()     
    79          
     77 
     78        return checksum.hexdigest() 
     79 
    8080    def getAvailableDevices(self) : 
    8181        """Returns a list of available GhostScript devices. 
    82          
     82 
    8383           The list is returned without any x11, bbox, nor ijs related device. 
    8484        """ 
     
    9393                                           and (not dev == "/nullpage") \ 
    9494                                           and (not dev == "/bbox") ] 
    95                 devices.sort()                            
     95                devices.sort() 
    9696                return devices 
    9797        return [] 
    98              
     98 
    9999    def getAvailableIJSPrintClasses(self) : 
    100100        """Returns a list of available IJS Print Classes. 
    101          
     101 
    102102           Currently the list is a static one and doesn't contain all the available print classes. 
    103103        """ 
    104         return [ "DJ3600", "DJ3320", "DJ9xx", "DJGenericVIP", "LJColor",  
     104        return [ "DJ3600", "DJ3320", "DJ9xx", "DJGenericVIP", "LJColor", 
    105105                 "DJ850", "DJ890", "DJ9xxVIP", "DJ8xx", "DJ540", "DJ660", 
    106106                 "DJ6xx", "DJ350", "DJ6xxPhoto", "DJ630", "DJ8x5", "DJ4100", 
     
    108108                 "Postscript", "LJJetReady", "LJMono", "LJFastRaster", 
    109109                 "LJZjsMono", ] 
    110              
     110 
    111111    def batchGeneration(self, infilename, devices, root, command) : 
    112112        """Loops over a set of devices calling a particular command.""" 
     
    121121            if os.path.exists(outfilename) and os.stat(outfilename).st_size : 
    122122                sys.stdout.write("Skipping %(outfilename)s : already exists.\n" % locals()) 
    123             else :     
     123            else : 
    124124                sys.stdout.write("Generating %(outfilename)s " % locals()) 
    125125                sys.stdout.flush() 
    126126                os.system(cmd) 
    127127                sys.stdout.write("\n") 
    128                  
     128 
    129129            if not os.path.exists(outfilename) : 
    130130                sys.stderr.write("ERROR : During the generation of %(outfilename)s\n" % locals()) 
    131             elif not os.stat(outfilename).st_size :     
     131            elif not os.stat(outfilename).st_size : 
    132132                sys.stderr.write("ERROR : Unsupported driver, impossible to generate %(outfilename)s\n" % locals()) 
    133133                os.remove(outfilename) 
    134             else :     
     134            else : 
    135135                self.results[outfilename] = { "command" : cmd, 
    136136                                              "device" : "%s" % (devprefix + device), 
     
    138138                                              "details" : None, 
    139139                                            } 
    140                  
     140 
    141141    def genTestSuite(self) : 
    142142        """Generate the testsuite.""" 
    143143        root = "testsuite.%s" % self.md5sum 
    144         self.batchGeneration(self.inputfile, self.getAvailableDevices(),  
    145                                         root,  
     144        self.batchGeneration(self.inputfile, self.getAvailableDevices(), 
     145                                        root, 
    146146                                        'gs -dQUIET -dBATCH -dNOPAUSE -dPARANOIDSAFER -sOutputFile="%(outfilename)s" -sDEVICE="%(device)s" "%(infilename)s"') 
    147                                      
    148         self.batchGeneration(self.inputfile, self.getAvailableIJSPrintClasses(),  
    149                                         "%(root)s.hpijs" % locals(),  
     147 
     148        self.batchGeneration(self.inputfile, self.getAvailableIJSPrintClasses(), 
     149                                        "%(root)s.hpijs" % locals(), 
    150150                                        'gs -dBATCH -dQUIET -dPARANOIDSAFER -dNOPAUSE -sDEVICE=ijs -sIjsServer=hpijs -dIjsUseOutputFD -sDeviceManufacturer="HEWLETT-PACKARD" -sDeviceModel="%(device)s" -sOutputFile="%(outfilename)s" "%(infilename)s"') 
    151                  
    152     def runPipe(self, cmd) :             
     151 
     152    def runPipe(self, cmd) : 
    153153        """Runs a command in a pipe, returns the command's output as a string.""" 
    154154        answerfd = os.popen(cmd, "r") 
    155155        try : 
    156156            return answerfd.read().strip() 
    157         finally :         
     157        finally : 
    158158            answerfd.close() 
    159          
    160     def computeSize(self, filename) :     
     159 
     160    def computeSize(self, filename) : 
    161161        """Computes the size in pages of a file in the testsuite.""" 
    162162        answer = self.runPipe('pkpgcounter "%(filename)s" 2>/dev/null' % locals()) 
    163163        try : 
    164164            return int(answer) 
    165         except (ValueError, TypeError) :     
     165        except (ValueError, TypeError) : 
    166166            return 0 
    167          
     167 
    168168    def runTests(self) : 
    169169        """Launches the page counting tests against the testsuite.""" 
     
    172172        if not mastersize : 
    173173            raise RuntimeError, "Unable to compute the size of the testsuite's master file %(masterfilename)s" % locals() 
    174         else :     
     174        else : 
    175175            sys.stdout.write("Master file's contains %(mastersize)i pages.\n" % locals()) 
    176176        testsuite = glob.glob("testsuite.*") 
     
    181181            if len(parts) > 3 : 
    182182                devname = ".".join(parts[2:]) 
    183             else :     
     183            else : 
    184184                devname = parts[-1] 
    185             result = self.results.setdefault(testfname, { "command" : "See above",  
    186                                                           "device" : devname,  
    187                                                           "result" : None,  
     185            result = self.results.setdefault(testfname, { "command" : "See above", 
     186                                                          "device" : devname, 
     187                                                          "result" : None, 
    188188                                                          "details" : None }) 
    189189            sys.stdout.write("Testing %(testfname)s ... " % locals()) 
     
    194194                    result["result"] = "UNSUPPORTED" 
    195195                    result["details"] = "Unsupported file format" 
    196                 else :     
     196                else : 
    197197                    result["result"] = "FAILED" 
    198198                    result["details"] = "Found %(size)i pages instead of %(mastersize)i\n" % locals() 
    199             else :     
     199            else : 
    200200                result["result"] = "SUPPORTED" 
    201201                result["details"] = None 
    202             sys.stdout.write("%s\n" % result["result"])     
     202            sys.stdout.write("%s\n" % result["result"]) 
    203203        self.supportedpct = 100.0 * len([True for r in self.results.values() if r["result"] == "SUPPORTED"]) / nbtests 
    204204        self.failedpct = 100.0 * len([True for r in self.results.values() if r["result"] == "FAILED"]) / nbtests 
    205205        self.unsupportedpct = 100.0 * len([True for r in self.results.values() if r["result"] == "UNSUPPORTED"]) / nbtests 
    206          
     206 
    207207    def genHTMLReport(self, filename) : 
    208208        """Generates an HTML report.""" 
     
    232232        for key in keys : 
    233233            value = self.results[key] 
    234             linecount += 1     
    235             if not (linecount % 2) :     
     234            linecount += 1 
     235            if not (linecount % 2) : 
    236236                linecolor = "#DEDEDE" 
    237             else :     
     237            else : 
    238238                linecolor = "#FFFFFF" 
    239             out.write('<tr bgcolor="%s">\n' % linecolor)     
     239            out.write('<tr bgcolor="%s">\n' % linecolor) 
    240240            if value["result"] == "SUPPORTED" : 
    241241                color = "#00FF00" 
    242             elif value["result"] == "UNSUPPORTED" :     
     242            elif value["result"] == "UNSUPPORTED" : 
    243243                color = "#FF0000" 
    244             else :     
     244            else : 
    245245                color = "orange" 
    246246            out.write('<td bgcolor="%s"><strong>%s</strong></td>\n' % (color, value["device"])) 
     
    250250        out.write("</table></body></html>\n") 
    251251        out.close() 
    252          
    253 def main() :         
     252 
     253def main() : 
    254254    """Main function.""" 
    255255    try : 
     
    259259            sys.stderr.write("usage : %s [inputfile.ps]\n" % sys.argv[0]) 
    260260            sys.exit(-1) 
    261         else :     
     261        else : 
    262262            testsuite = TestSuite(sys.argv[1]) 
    263263            testsuite.genTestSuite() 
    264264            testsuite.runTests() 
    265265            testsuite.genHTMLReport("%s.html" % testsuite.md5sum) 
    266     except KeyboardInterrupt :         
     266    except KeyboardInterrupt : 
    267267        sys.stderr.write("Interrupted at user's request !\n") 
    268          
     268 
    269269if __name__ == "__main__" : 
    270270    sys.exit(main()) 
    271          
     271 
  • pkpgcounter/trunk/tests/README

    r463 r3436  
    1919==================================================================== 
    2020 
    21 This directory contains a gzipped PostScript file, master.ps.gz,  
    22 obtained by printing to a file a part of the SlashDot.org website  
    23 from the Galeon web browser on July 2nd 2004.  
     21This directory contains a gzipped PostScript file, master.ps.gz, 
     22obtained by printing to a file a part of the SlashDot.org website 
     23from the Galeon web browser on July 2nd 2004. 
    2424 
    25 When uncompressed, this 16 pages file can be used to test the  
    26 accuracy of the generic Page Description Language analyzer included  
    27 in pkpgcounter for different conversion outputs of gs.  
     25When uncompressed, this 16 pages file can be used to test the 
     26accuracy of the generic Page Description Language analyzer included 
     27in pkpgcounter for different conversion outputs of gs. 
    2828 
    2929To see if it works, simply launch : 
    3030 
    3131        $ ./runtests.sh 
    32          
    33 It should report 16 pages for each document. If it doesn't then  
    34 there's a bug in the generic Page Description Language analyzer.  
     32 
     33It should report 16 pages for each document. If it doesn't then 
     34there's a bug in the generic Page Description Language analyzer. 
    3535Please report this to : alet@librelogiciel.com 
    3636 
    3737This script will also launch the test for the computation of 
    38 ink coverage. Look at the file colors.pdf to see what the  
     38ink coverage. Look at the file colors.pdf to see what the 
    3939results should look like. 
  • pkpgcounter/trunk/tests/runcolors.py

    r564 r3436  
    11#! /usr/bin/env python 
    2 # -*- coding: UTF-8 -*- 
     2# -*- coding: utf-8 -*- 
    33# 
    44# pkpgcounter : a generic Page Description Language parser 
     
    99# the Free Software Foundation, either version 3 of the License, or 
    1010# (at your option) any later version. 
    11 #  
     11# 
    1212# This program is distributed in the hope that it will be useful, 
    1313# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1414# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1515# GNU General Public License for more details. 
    16 #  
     16# 
    1717# You should have received a copy of the GNU General Public License 
    1818# along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     
    5252        pkpgcounter --colorspace $cspace colors.pdf ; 
    5353        echo ; 
    54     done     
     54    done 
    5555 
    5656Please report any problem to : alet@librelogiciel.com 
     
    115115    from reportlab.lib.units import cm 
    116116    from reportlab.pdfgen import canvas 
    117 except ImportError :     
     117except ImportError : 
    118118    sys.stderr.write("Please download and install ReportLab\n\tfrom http://www.reportlab.org\n") 
    119119    sys.exit(-1) 
     
    124124    xbase = 2*cm 
    125125    ybase = height - 2*cm 
    126      
     126 
    127127    # First we output the explanations on the first page. 
    128128    canv.setFont("Courier", 14) 
     
    131131        ybase -= 18 
    132132    canv.showPage() 
    133      
     133 
    134134    # Then we output each page 
    135135    for color in (colors.Color(1, 0, 0),        # Red 
    136136                  colors.Color(0, 1, 0),        # Green 
    137137                  colors.Color(0, 0, 1)) :      # Blue 
    138         canv.setStrokeColorRGB(*color.rgb())           
    139         canv.setFillColorRGB(*color.rgb())           
     138        canv.setStrokeColorRGB(*color.rgb()) 
     139        canv.setFillColorRGB(*color.rgb()) 
    140140        canv.rect(0, 0, width, height, fill=1) 
    141141        canv.showPage() 
    142          
     142 
    143143    for color in (colors.CMYKColor(1, 0, 0, 0), # Cyan 
    144144                  colors.CMYKColor(0, 1, 0, 0), # Magenta 
     
    146146                  colors.CMYKColor(0, 0, 0, 1), # Black 
    147147                  colors.CMYKColor(0, 0, 0, 0)) : # White 
    148         canv.setStrokeColorCMYK(*color.cmyk())           
    149         canv.setFillColorCMYK(*color.cmyk())           
     148        canv.setStrokeColorCMYK(*color.cmyk()) 
     149        canv.setFillColorCMYK(*color.cmyk()) 
    150150        canv.rect(0, 0, width, height, fill=1) 
    151151        canv.showPage() 
    152          
     152 
    153153    # Finally outputs the expected results. 
    154154    canv.setFont("Helvetica-Bold", 16) 
     
    160160        ybase -= 14 
    161161    canv.showPage() 
    162          
    163     canv.save()         
     162 
     163    canv.save() 
  • pkpgcounter/trunk/tests/runtest.sh

    r564 r3436  
    88# the Free Software Foundation, either version 3 of the License, or 
    99# (at your option) any later version. 
    10 #  
     10# 
    1111# This program is distributed in the hope that it will be useful, 
    1212# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1313# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414# GNU General Public License for more details. 
    15 #  
     15# 
    1616# You should have received a copy of the GNU General Public License 
    1717# along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     
    1919echo "Analyzing colors..." 
    2020if ! [ -f "colors.pdf" ]  ; then 
    21    python ./runcolors.py ;  
     21   python ./runcolors.py ; 
    2222fi ; 
    23 echo  
     23echo 
    2424 
    2525for cspace in BW RGB CMY CMYK GC ; do 
     
    2727    pkpgcounter --colorspace $cspace colors.pdf ; 
    2828    echo ; 
    29 done     
     29done 
    3030 
    3131echo "Generating testsuite..."