~ubuntu-branches/ubuntu/vivid/python-reportlab/vivid-proposed

« back to all changes in this revision

Viewing changes to demos/odyssey/odyssey.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-01-12 02:16:21 UTC
  • mfrom: (1.2.9) (4.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20140112021621-f4mpp5qaj1dkq2yb
Tags: 2.8~20140112-1
* New upstream snapshot.
* Build python3 packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#Copyright ReportLab Europe Ltd. 2000-2012
2
2
#see license.txt for license details
3
 
__version__=''' $Id: odyssey.py 3959 2012-09-27 14:39:39Z robin $ '''
 
3
__version__=''' $Id$ '''
4
4
___doc__=''
5
5
#odyssey.py
6
6
#
67
67
        accelStr = 'with _rl_accel'
68
68
    else:
69
69
        accelStr = 'without _rl_accel'
70
 
    print 'Benchmark of %s %s %s' % (impl, verStr, accelStr)
 
70
    print('Benchmark of %s %s %s' % (impl, verStr, accelStr))
71
71
 
72
72
    started = time.time()
73
73
    canv = canvas.Canvas('odyssey.pdf', invariant=1)
119
119
            #page
120
120
            pg = canv.getPageNumber()
121
121
            if verbose and pg % 10 == 0:
122
 
                print 'formatted page %d' % canv.getPageNumber()
 
122
                print('formatted page %d' % canv.getPageNumber())
123
123
 
124
124
    if tx:
125
125
        canv.drawText(tx)
127
127
        drawPageFrame(canv)
128
128
 
129
129
    if verbose:
130
 
        print 'about to write to disk...'
 
130
        print('about to write to disk...')
131
131
 
132
132
    canv.save()
133
133
 
136
136
    pages = canv.getPageNumber()-1
137
137
    speed =  pages / elapsed
138
138
    fileSize = os.stat('odyssey.pdf')[6] / 1024
139
 
    print '%d pages in %0.2f seconds = %0.2f pages per second, file size %d kb' % (
140
 
                pages, elapsed, speed, fileSize)
141
 
    import md5
142
 
    print 'file digest: %s' % md5.md5(open('odyssey.pdf','rb').read()).hexdigest()
 
139
    print('%d pages in %0.2f seconds = %0.2f pages per second, file size %d kb' % (
 
140
                pages, elapsed, speed, fileSize))
 
141
    import hashlib
 
142
    print('file digest: %s' % hashlib.md5(open('odyssey.pdf','rb').read()).hexdigest())
143
143
 
144
144
if __name__=='__main__':
145
145
    quiet = ('-q' in sys.argv)