00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 import logging, os, string, sys
00022 import pyp_db
00023 import pyp_io
00024 import pyp_nrm
00025 import pyp_utils
00026 import pyp_network
00027 import networkx
00028
00029 from reportlab.lib.pagesizes import letter, A4
00030 from reportlab.lib.units import inch, cm
00031 from reportlab.pdfgen import canvas
00032
00033 global metric_to_column
00034 global byvar_to_column
00035
00036 metric_to_column = {'fa':'coi'}
00037 byvar_to_column = {'by':'birthyear',
00038 'gen':'generation'}
00039
00040 try:
00041 import adodb
00042 except ImportError:
00043 print '[ERRROR]: Unable to import adodb in pyp_db.py!'
00044 logging.error('Unable to import adodb in pyp_db.py!')
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 def meanMetricBy(pedobj,metric='fa',byvar='by', createpdf=False, conn=False):
00056 """
00057 meanMetricBy() returns a dictionary of means keyed by levels of the 'byvar' that
00058 can be used to draw graphs or prepare reports of summary statistics.
00059 """
00060
00061 conn_created = False
00062 result_dict = {}
00063 if conn == False:
00064 conn = pyp_db.connectToDatabase(pedobj)
00065 conn_created = True
00066 try:
00067 if metric not in ['fa']:
00068 logging.warning('You passed an unrecognized variable, %s, to pyp_reports/animalMetricBy() in the METRIC field. It has been changed to \'fa\' (coefficient of inbreeding).', metric)
00069 metric = 'fa'
00070 if byvar not in ['gen','sex','birthyear','by']:
00071 logging.warning('You passed an unrecognized variable, %s, to pyp_reports/animalMetricBy() in the BYVAR field. It has been changed to \'by\' (birth year).', byvar)
00072 byvar = 'by'
00073
00074 if pyp_db.doesTableExist(pedobj, conn=conn):
00075 sql = 'select %s, avg(%s) from %s group by %s' % ( byvar_to_column[byvar], \
00076 metric_to_column[metric], pedobj.kw['database_table'], byvar_to_column[byvar] )
00077 cursor = conn.Execute(sql)
00078 while not cursor.EOF:
00079 result_dict[cursor.fields[0]] = cursor.fields[1]
00080 cursor.MoveNext()
00081 cursor.Close()
00082 logging.info('pyp_reports/meanMetricBy() report completed.')
00083 else:
00084 logging.error('pyp_reports/meanMetricBy() report failed!')
00085 if conn_created:
00086 conn.Close()
00087
00088 if createpdf:
00089 try:
00090 mmbPdfTitle = '%s_mean_metric_%s_%s' % \
00091 (pedobj.kw['default_report'], metric, byvar)
00092 _mmbPdf = pdfMeanMetricBy(pedobj, result_dict, 1, mmbPdfTitle)
00093 if _mmbPdf:
00094 logging.info('pyp_reports/pdfMeanMetricBy() succeeded.')
00095 else:
00096 logging.error('pyp_reports/pdfMeanMetricBy() failed.')
00097 except:
00098 pass
00099 except:
00100 pass
00101 return result_dict
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 def pdfMeanMetricBy(pedobj, results, titlepage=0, reporttitle='', reportauthor='', reportfile=''):
00115 """
00116 pdfMeanMetricBy() returns a dictionary of means keyed by levels of the 'byvar' that
00117 can be used to draw graphs or prepare reports of summary statistics.
00118 """
00119 try:
00120 import reportlab
00121 except ImportError:
00122 logging.error('Unable to import ReportLab in pyp_reports/pdfMeanMetricBy().')
00123 return 0
00124
00125 try:
00126 if reportfile == '':
00127 _pdfOutfile = '%s_mean_metric_by.pdf' % ( pedobj.kw['default_report'] )
00128 else:
00129 _pdfOutfile = reportfile
00130 if pedobj.kw['messages'] == 'verbose':
00131 print 'Writing meanMetricBy report to %s' % ( _pdfOutfile )
00132 logging.info('Writing meanMetricBy report to %s', _pdfOutfile )
00133
00134 _pdfSettings = _pdfInitialize(pedobj)
00135 canv = canvas.Canvas(_pdfOutfile, invariant=1)
00136 canv.setPageCompression(1)
00137
00138 if titlepage:
00139 if reporttitle == '':
00140 reporttitle = 'meanMetricBy Report for Pedigree\n%s' % (pedobj.kw['pedname'])
00141 _pdfCreateTitlePage(canv, _pdfSettings, reporttitle, reportauthor)
00142 _pdfDrawPageFrame(canv, _pdfSettings)
00143
00144 canv.setFont("Times-Bold", 12)
00145 tx = canv.beginText( _pdfSettings['_pdfCalcs']['_left_margin'],
00146 _pdfSettings['_pdfCalcs']['_top_margin'] - 0.5 * _pdfSettings['_pdfCalcs']['_unit'] )
00147
00148
00149 for _k, _v in results.iteritems():
00150 if len(str(_k)) <= 14:
00151 _line = '\t%s:\t\t%s' % (_k, _v)
00152 else:
00153 _line = '\t%s:\t%s' % (_k, _v)
00154 tx.textLine(_line)
00155 if tx.getY() < _pdfSettings['_pdfCalcs']['_bottom_margin'] + \
00156 0.5 * _pdfSettings['_pdfCalcs']['_unit']:
00157 canv.drawText(tx)
00158 canv.showPage()
00159 _pdfDrawPageFrame(canv, _pdfSettings)
00160 canv.setFont('Times-Roman', 12)
00161 tx = canv.beginText( _pdfSettings['_pdfCalcs']['_left_margin'],
00162 _pdfSettings['_pdfCalcs']['_top_margin'] -
00163 0.5 * _pdfSettings['_pdfCalcs']['_unit'] )
00164 if tx:
00165 canv.drawText(tx)
00166 canv.showPage()
00167 canv.save()
00168 return 1
00169 except:
00170 return 0
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 def pdfPedigreeMetadata(pedobj, titlepage=0, reporttitle='', reportauthor='', reportfile=''):
00184 """
00185 pdfPedigreeMetadata() produces a report, in PDF format, of the metadata from
00186 the input pedigree. It is intended for use as a template for custom printed
00187 reports.
00188 """
00189 try:
00190 import reportlab
00191 except ImportError:
00192 logging.error('Unable to import ReportLab in pyp_reports/pdfPedigreeMetadata().')
00193 return 0
00194
00195 if reportfile == '':
00196 _pdfOutfile = '%s_metadata.pdf' % ( pedobj.kw['default_report'] )
00197 else:
00198 _pdfOutfile = reportfile
00199 if pedobj.kw['messages'] == 'verbose':
00200 print 'Writing metadata report to %s' % ( _pdfOutfile )
00201 logging.info('Writing metadata report to %s', _pdfOutfile )
00202
00203
00204
00205 _pdfSettings = _pdfInitialize(pedobj)
00206
00207
00208
00209
00210 canv = canvas.Canvas(_pdfOutfile, invariant=1)
00211 canv.setPageCompression(1)
00212
00213
00214 if titlepage:
00215 if reporttitle == '':
00216 reporttitle = 'Metadata for Pedigree\n%s' % (pedobj.kw['pedname'])
00217 _pdfCreateTitlePage(canv, _pdfSettings, reporttitle, reportauthor)
00218
00219
00220
00221
00222 _pdfDrawPageFrame(canv, _pdfSettings)
00223 canv.setFont("Times-Bold", 12)
00224 tx = canv.beginText( _pdfSettings['_pdfCalcs']['_left_margin'],
00225 _pdfSettings['_pdfCalcs']['_top_margin'] - 0.5 * _pdfSettings['_pdfCalcs']['_unit'] )
00226 _metadata_string = string.split(pedobj.metadata.stringme(), '\n')
00227 for _m in _metadata_string:
00228 tx.textLine(_m)
00229
00230
00231 if tx.getY() < _pdfSettings['_pdfCalcs']['_bottom_margin'] + \
00232 0.5 * _pdfSettings['_pdfCalcs']['_unit']:
00233 canv.drawText(tx)
00234 canv.showPage()
00235 _pdfDrawPageFrame(canv, _pdfSettings)
00236 canv.setFont('Times-Roman', 12)
00237 tx = canv.beginText( _pdfSettings['_pdfCalcs']['_left_margin'],
00238 _pdfSettings['_pdfCalcs']['_top_margin'] -
00239 0.5 * _pdfSettings['_pdfCalcs']['_unit'] )
00240
00241 pg = canv.getPageNumber()
00242 if pedobj.kw['messages'] == 'verbose' and pg % 10 == 0:
00243 print 'Printed page %d' % pg
00244
00245
00246
00247 if tx:
00248 canv.drawText(tx)
00249 canv.showPage()
00250
00251
00252
00253
00254
00255
00256
00257
00258 canv.save()
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270 def pdf3GenPed(animalID, pedobj, titlepage=0, reporttitle='', reportauthor='', reportfile=''):
00271 """
00272 pdf3GenPed() draws a three-generation pedigree for animal 'animalID'.
00273 """
00274
00275 try:
00276 import reportlab
00277 except ImportError:
00278 logging.error('Unable to import ReportLab in pyp_reports/pdf3GenPed().')
00279 return 0
00280
00281
00282
00283 if type(animalID) != list:
00284 animalID = [animalID]
00285
00286 if reportfile == '':
00287 _pdfOutfile = 'three_generation_pedigrees.pdf'
00288 else:
00289 _pdfOutfile = reportfile
00290 if pedobj.kw['messages'] == 'verbose':
00291 print 'Writing 3GenPed to %s' % ( _pdfOutfile )
00292 logging.info('Writing 3GenPed to %s', _pdfOutfile )
00293
00294 _pdfSettings = _pdfInitialize(pedobj)
00295
00296 canv = canvas.Canvas(_pdfOutfile, invariant=1)
00297 canv.setPageCompression(1)
00298
00299 if titlepage:
00300 if reporttitle == '':
00301 reporttitle = 'Three-generation Pedigrees'
00302 _pdfCreateTitlePage(canv, _pdfSettings, reporttitle, reportauthor)
00303 _pdfDrawPageFrame(canv, _pdfSettings)
00304
00305
00306
00307 try:
00308 for _anid in animalID:
00309
00310
00311 canv.setFont("Times-Bold", 12)
00312 tx = canv.beginText( _pdfSettings['_pdfCalcs']['_left_margin'],
00313 _pdfSettings['_pdfCalcs']['_top_margin'] - 0.5 * \
00314 _pdfSettings['_pdfCalcs']['_unit'] )
00315 _pdfDrawPageFrame(canv, _pdfSettings)
00316
00317
00318
00319
00320 if 'A' in pedobj.kw['pedformat']:
00321 _anidx = pedobj.idmap[pedobj.namemap[_anid]] - 1
00322 _anid = pedobj.backmap[pedobj.idmap[pedobj.namemap[_anid]]]
00323 else:
00324 _anidx = pedobj.idmap[_anid] - 1
00325
00326
00327
00328
00329
00330 _places = {}
00331 _places['a'] = pedobj.idmap[_anid]
00332
00333 _places['s'] = pedobj.pedigree[_places['a']-1].sireID
00334 if int(_places['s']) != pedobj.kw['missing_parent']:
00335 _places['ss'] = pedobj.pedigree[_places['s']-1].sireID
00336 _places['sd'] = pedobj.pedigree[_places['s']-1].damID
00337 else:
00338 _places['ss'] = pedobj.kw['missing_parent']
00339 _places['sd'] = pedobj.kw['missing_parent']
00340 if int(_places['ss']) != pedobj.kw['missing_parent']:
00341 _places['sss'] = pedobj.pedigree[_places['ss']-1].sireID
00342 _places['ssd'] = pedobj.pedigree[_places['ss']-1].damID
00343 else:
00344 _places['sss'] = pedobj.kw['missing_parent']
00345 _places['ssd'] = pedobj.kw['missing_parent']
00346 if int(_places['sd']) != pedobj.kw['missing_parent']:
00347 _places['sds'] = pedobj.pedigree[_places['sd']-1].sireID
00348 _places['sdd'] = pedobj.pedigree[_places['sd']-1].damID
00349 else:
00350 _places['sds'] = pedobj.kw['missing_parent']
00351 _places['sdd'] = pedobj.kw['missing_parent']
00352
00353 _places['d'] = pedobj.pedigree[_places['a']-1].damID
00354 if _places['d'] != pedobj.kw['missing_parent']:
00355 _places['ds'] = pedobj.pedigree[_places['d']-1].sireID
00356 _places['dd'] = pedobj.pedigree[_places['d']-1].damID
00357 else:
00358 _places['ds'] = pedobj.kw['missing_parent']
00359 _places['dd'] = pedobj.kw['missing_parent']
00360 if _places['ds'] != pedobj.kw['missing_parent']:
00361 _places['dss'] = pedobj.pedigree[_places['ds']-1].sireID
00362 _places['dsd'] = pedobj.pedigree[_places['ds']-1].damID
00363 else:
00364 _places['dss'] = pedobj.kw['missing_parent']
00365 _places['dsd'] = pedobj.kw['missing_parent']
00366 if _places['dd'] != pedobj.kw['missing_parent']:
00367 _places['dds'] = pedobj.pedigree[_places['dd']-1].sireID
00368 _places['ddd'] = pedobj.pedigree[_places['dd']-1].damID
00369 else:
00370 _places['dds'] = pedobj.kw['missing_parent']
00371 _places['ddd'] = pedobj.kw['missing_parent']
00372
00373
00374
00375 _sill_width = _pdfSettings['_pdfCalcs']['_frame_width'] * 0.25
00376 _16 = _pdfSettings['_pdfCalcs']['_frame_height'] / 16.
00377 _64 = _pdfSettings['_pdfCalcs']['_frame_height'] / 64.
00378 _x = _pdfSettings['_pdfCalcs']['_left_margin']
00379 _y = _pdfSettings['_pdfCalcs']['_bottom_margin']
00380
00381
00382
00383
00384 os = {}
00385 for k in _places.keys(): os[k] = {}
00386 os['a']['x'] = _x; os['a']['y'] = _y+(8*_16)
00387 os['d']['x'] = _x+_sill_width; os['d']['y'] = _y+(4*_16)
00388 os['s']['x'] = _x+_sill_width; os['s']['y'] = _y+(12*_16)
00389 os['dd']['x'] = _x+(2*_sill_width); os['dd']['y'] = _y+(2*_16)
00390 os['ds']['x'] = _x+(2*_sill_width); os['ds']['y'] = _y+(6*_16)
00391 os['sd']['x'] = _x+(2*_sill_width); os['sd']['y'] = _y+(10*_16)
00392 os['ss']['x'] = _x+(2*_sill_width); os['ss']['y'] = _y+(14*_16)
00393 os['ddd']['x'] = _x+(3*_sill_width); os['ddd']['y'] = _y+(1*_16)
00394 os['dds']['x'] = _x+(3*_sill_width); os['dds']['y'] = _y+(3*_16)
00395 os['dsd']['x'] = _x+(3*_sill_width); os['dsd']['y'] = _y+(5*_16)
00396 os['dss']['x'] = _x+(3*_sill_width); os['dss']['y'] = _y+(7*_16)
00397 os['sdd']['x'] = _x+(3*_sill_width); os['sdd']['y'] = _y+(9*_16)
00398 os['sds']['x'] = _x+(3*_sill_width); os['sds']['y'] = _y+(11*_16)
00399 os['ssd']['x'] = _x+(3*_sill_width); os['ssd']['y'] = _y+(13*_16)
00400 os['sss']['x'] = _x+(3*_sill_width); os['sss']['y'] = _y+(15*_16)
00401
00402 _line = 'Pedigree for %s (%s)' % ( pedobj.pedigree[_anidx].name, \
00403 pedobj.pedigree[_anidx].originalID )
00404 canv.setFont("Times-Bold", 12)
00405 canv.drawString( _x, _pdfSettings['_pdfCalcs']['_top_margin']-0.25*_16, _line )
00406 canv.setLineWidth(1)
00407
00408
00409
00410
00411 for k in _places.keys():
00412 canv.line( os[k]['x'], os[k]['y'], os[k]['x']+_sill_width, os[k]['y'] )
00413 if _places[k] == pedobj.kw['missing_parent']:
00414 _sill_text_1 = '(%s)' % ( 'Unknown Parent' )
00415 _sill_text_2 = ''
00416 else:
00417 _sill_text_1 = '%s' % ( pedobj.pedigree[_places[k]-1].name )
00418 _sill_text_2 = '(%s)' % ( pedobj.pedigree[_places[k]-1].originalID )
00419 canv.setFont("Times-Bold", 12)
00420 canv.drawString( os[k]['x'], os[k]['y']+2, _sill_text_1 )
00421 canv.setFont("Times-Roman", 12)
00422 canv.drawString( os[k]['x'], os[k]['y']-_64, _sill_text_2 )
00423 if k == 'a':
00424 canv.setFont("Times-Roman", 12)
00425 if pedobj.pedigree[_places[k]-1].herd == 'u':
00426 _herd = '%s' % ( pedobj.kw['missing_herd'] )
00427 else:
00428 _herd = '%s' % ( pedobj.pedigree[_places[k]-1].herd )
00429 _breed = '%s' % ( pedobj.pedigree[_places[k]-1].breed )
00430 _inbreed = '%s' % ( pedobj.pedigree[_places[k]-1].fa )
00431 _pedcomp = '%5.3f' % ( pedobj.pedigree[_places[k]-1].pedcomp )
00432 canv.drawString( _x, _y+0.25*_16, 'Pedigree completeness:' )
00433 canv.drawString( _x+_sill_width, _y+0.25*_16, _pedcomp )
00434 canv.drawString( _x, _y+0.5*_16, 'Inbreeding:' )
00435 canv.drawString( _x+_sill_width, _y+0.5*_16, _inbreed )
00436 canv.drawString( _x, _y+0.75*_16, 'Breed:' )
00437 canv.drawString( _x+_sill_width, _y+0.75*_16, _breed )
00438 canv.drawString( _x, _y+_16, 'Herd:' )
00439 canv.drawString( _x+_sill_width, _y+_16, _herd )
00440
00441
00442 canv.line( os['s']['x'],os['d']['y'],os['s']['x'],os['s']['y'] )
00443
00444 canv.line( os['ds']['x'],os['dd']['y'],os['ds']['x'],os['ds']['y'] )
00445
00446 canv.line( os['ss']['x'],os['sd']['y'],os['ss']['x'],os['ss']['y'] )
00447
00448 canv.line( os['dds']['x'],os['ddd']['y'],os['dds']['x'],os['dds']['y'] )
00449
00450 canv.line( os['dss']['x'],os['dsd']['y'],os['dss']['x'],os['dss']['y'] )
00451
00452 canv.line( os['sds']['x'],os['sdd']['y'],os['sds']['x'],os['sds']['y'] )
00453
00454 canv.line( os['sss']['x'],os['ssd']['y'],os['sss']['x'],os['sss']['y'] )
00455
00456
00457 canv.drawText(tx)
00458 canv.showPage()
00459 canv.save()
00460 return 1
00461 except:
00462 logging.error('Unable to fetch the pedigree for animal %s in pyp_reports/pdf3GenPed()!',animalID)
00463 return 0
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478 def _pdfInitialize(pedobj):
00479 """
00480 _pdfInitialize() returns a dictionary of metadata that is used for report
00481 generation.
00482 """
00483 _pdfSettings = {}
00484 _pdfSettings['_pdfTitle'] = pedobj.kw['pedname']
00485 _pdfSettings['_pdfPageinfo'] = pedobj.kw['filetag']
00486
00487 _pdfCalcs = {}
00488 if pedobj.kw['default_unit'] == 'inch':
00489 _pdfCalcs['_unit'] = inch
00490 else:
00491 _pdfCalcs['_unit'] = cm
00492 if pedobj.kw['paper_size'] == 'letter':
00493 _pdfCalcs['_page'] = letter
00494 _pdfCalcs['_top_margin'] = letter[1] - inch
00495 _pdfCalcs['_bottom_margin'] = inch
00496 _pdfCalcs['_left_margin'] = inch
00497 _pdfCalcs['_right_margin'] = letter[0] - inch
00498 _pdfCalcs['_frame_width'] = _pdfCalcs['_right_margin'] - _pdfCalcs['_left_margin']
00499 _pdfCalcs['_frame_height'] = _pdfCalcs['_top_margin'] - _pdfCalcs['_bottom_margin']
00500 _pdfCalcs['_page_width'] = letter[0]
00501 _pdfCalcs['_page_height'] = letter[1]
00502 else:
00503 _pdfCalcs['_page'] = A4
00504 _pdfCalcs['_top_margin'] = A4[1] - inch
00505 _pdfCalcs['_bottom_margin'] = inch
00506 _pdfCalcs['_left_margin'] = inch
00507 _pdfCalcs['_right_margin'] = A4[0] - inch
00508 _pdfCalcs['_frame_width'] = _pdfCalcs['_right_margin'] - _pdfCalcs['_left_margin']
00509 _pdfCalcs['_frame_height'] = _pdfCalcs['_top_margin'] - _pdfCalcs['_bottom_margin']
00510 _pdfCalcs['_page_width'] = A4[0]
00511 _pdfCalcs['_page_height'] = A4[1]
00512 _pdfSettings['_pdfCalcs'] = _pdfCalcs
00513 return _pdfSettings
00514
00515
00516
00517
00518
00519
00520
00521
00522 def _pdfDrawPageFrame(canv, _pdfSettings):
00523 """
00524 _pdfDrawPageFrame() nicely frames page contents and includes the
00525 document title in a header and the page number in a footer.
00526 """
00527
00528 canv.line(_pdfSettings['_pdfCalcs']['_left_margin'],
00529 _pdfSettings['_pdfCalcs']['_top_margin'],
00530 _pdfSettings['_pdfCalcs']['_right_margin'],
00531 _pdfSettings['_pdfCalcs']['_top_margin'])
00532 canv.setFont('Times-Italic', 12)
00533 canv.drawString(_pdfSettings['_pdfCalcs']['_left_margin'],
00534 _pdfSettings['_pdfCalcs']['_top_margin'] + 2,
00535 _pdfSettings['_pdfTitle'])
00536
00537
00538 canv.line(_pdfSettings['_pdfCalcs']['_left_margin'],
00539 _pdfSettings['_pdfCalcs']['_top_margin'],
00540 _pdfSettings['_pdfCalcs']['_right_margin'],
00541 _pdfSettings['_pdfCalcs']['_top_margin'])
00542 canv.setFont('Times-Italic', 12)
00543 canv.drawString(_pdfSettings['_pdfCalcs']['_right_margin'] - \
00544 1.85 * _pdfSettings['_pdfCalcs']['_unit'],
00545 _pdfSettings['_pdfCalcs']['_top_margin'] + 2,
00546 pyp_utils.pyp_nice_time())
00547
00548
00549 canv.line(_pdfSettings['_pdfCalcs']['_left_margin'],
00550 _pdfSettings['_pdfCalcs']['_top_margin'],
00551 _pdfSettings['_pdfCalcs']['_right_margin'],
00552 _pdfSettings['_pdfCalcs']['_top_margin'])
00553 canv.line(_pdfSettings['_pdfCalcs']['_left_margin'],
00554 _pdfSettings['_pdfCalcs']['_bottom_margin'],
00555 _pdfSettings['_pdfCalcs']['_right_margin'],
00556 _pdfSettings['_pdfCalcs']['_bottom_margin'])
00557 canv.drawCentredString(0.5 * _pdfSettings['_pdfCalcs']['_page'][0],
00558 0.5 * _pdfSettings['_pdfCalcs']['_unit'],
00559 "Page %d" % canv.getPageNumber())
00560
00561
00562
00563
00564
00565
00566
00567 def _pdfCreateTitlePage(canv, _pdfSettings, reporttitle = '', reportauthor = ''):
00568 """
00569 _pdfCreateTitlePage() adds a title page to a ReportLab canvas object.
00570 """
00571 import textwrap
00572 _pdfDrawPageFrame(canv, _pdfSettings)
00573
00574
00575
00576 _title_y = 7 * _pdfSettings['_pdfCalcs']['_unit']
00577 canv.setFont("Times-Bold", 36)
00578 if reporttitle == '':
00579 canv.drawCentredString(0.5 * _pdfSettings['_pdfCalcs']['_page'][0],
00580 7 * _pdfSettings['_pdfCalcs']['_unit'], _pdfSettings['_pdfTitle'])
00581 else:
00582
00583
00584
00585
00586 _bits = string.split(reporttitle, '\n')
00587 for _b in _bits:
00588
00589
00590 if len(_b) > 26:
00591 _b_wrapped = textwrap.wrap(_b, 26, break_long_words=True)
00592
00593 for _bw in _b_wrapped:
00594 canv.drawCentredString( 0.5 * _pdfSettings['_pdfCalcs']['_page'][0], \
00595 _title_y, _bw)
00596 _title_y = _title_y - 1 * _pdfSettings['_pdfCalcs']['_unit']
00597 else:
00598 canv.drawCentredString( 0.5 * _pdfSettings['_pdfCalcs']['_page'][0], _title_y, _b)
00599 _title_y = _title_y - 1 * _pdfSettings['_pdfCalcs']['_unit']
00600
00601
00602 if reportauthor != '':
00603 canv.setFont("Times-Bold", 18)
00604 canv.drawCentredString(0.5 * _pdfSettings['_pdfCalcs']['_page'][0],
00605 _title_y, reportauthor)
00606 canv.showPage()