tools/docco/docpy.py
branchpy33
changeset 3881 b3e5f1288b86
parent 3794 398ea04239b5
child 4302 f3ff56a22b2e
equal deleted inserted replaced
3880:79d10ac7de19 3881:b3e5f1288b86
    32 
    32 
    33 __version__ = '0.8'
    33 __version__ = '0.8'
    34 
    34 
    35 
    35 
    36 import sys, os, re, types, getopt, copy, time
    36 import sys, os, re, types, getopt, copy, time
       
    37 from reportlab import isPy3
    37 from reportlab.pdfgen import canvas
    38 from reportlab.pdfgen import canvas
    38 from reportlab.lib import colors
    39 from reportlab.lib import colors
    39 from reportlab.lib.units import inch, cm
    40 from reportlab.lib.units import inch, cm
    40 from reportlab.lib.pagesizes import A4
    41 from reportlab.lib.pagesizes import A4
    41 from reportlab.lib import enums
    42 from reportlab.lib import enums
    70     canvas.line(2*cm, 2*cm, A4[0]-2*cm, 2*cm)
    71     canvas.line(2*cm, 2*cm, A4[0]-2*cm, 2*cm)
    71     if pageNumber > 1:
    72     if pageNumber > 1:
    72         canvas.setFont('Times-Roman', 12)
    73         canvas.setFont('Times-Roman', 12)
    73         canvas.drawString(4 * inch, cm, "%d" % pageNumber)
    74         canvas.drawString(4 * inch, cm, "%d" % pageNumber)
    74         if hasattr(canvas, 'headerLine'): # hackish
    75         if hasattr(canvas, 'headerLine'): # hackish
    75             headerline = , ' \215 '.join(canvas.headerLine) # bullet
    76             headerline = ' \215 '.join(canvas.headerLine) # bullet
    76             canvas.drawString(2*cm, A4[1]-1.75*cm, headerline)
    77             canvas.drawString(2*cm, A4[1]-1.75*cm, headerline)
    77 
    78 
    78     canvas.setFont('Times-Roman', 8)
    79     canvas.setFont('Times-Roman', 8)
    79     msg = "Generated with reportlab.lib.docpy. See http://www.reportlab.com!"
    80     msg = "Generated with reportlab.lib.docpy. See http://www.reportlab.com!"
    80     canvas.drawString(2*cm, 1.65*cm, msg)
    81     canvas.drawString(2*cm, 1.65*cm, msg)
  1182             package = eval(subname)
  1183             package = eval(subname)
  1183         path = os.path.dirname(package.__file__)
  1184         path = os.path.dirname(package.__file__)
  1184 
  1185 
  1185     cwd = os.getcwd()
  1186     cwd = os.getcwd()
  1186     builder.beginPackage(name)
  1187     builder.beginPackage(name)
  1187     os.path.walk(path, _packageWalkCallback, (builder, opts))
  1188     if isPy3:
       
  1189         for dirpath, dirnames, filenames in os.walk(path):
       
  1190             _packageWalkCallback((builder, opts), dirpath, dirnames + filenames)
       
  1191     else:
       
  1192         os.path.walk(path, _packageWalkCallback, (builder, opts))
  1188     builder.endPackage(name)
  1193     builder.endPackage(name)
  1189     os.chdir(cwd)
  1194     os.chdir(cwd)
  1190 
  1195 
  1191 
  1196 
  1192 def main():
  1197 def main():