more 2to3ing
authorandy
Mon, 08 Feb 2010 22:28:42 +0000
changeset 3327 512eb20b0c3d
parent 3326 ce725978d11c
child 3328 4d7f836cd947
more 2to3ing
docs/source/index.rst
docs/source/lib.rst
src/reportlab/__init__.py
src/reportlab/lib/utils.py
src/reportlab/pdfbase/pdfdoc.py
src/reportlab/platypus/tableofcontents.py
--- a/docs/source/index.rst	Mon Feb 08 18:17:33 2010 +0000
+++ b/docs/source/index.rst	Mon Feb 08 22:28:42 2010 +0000
@@ -3,18 +3,33 @@
    You can adapt this file completely to your liking, but it should at least
    contain the root `toctree` directive.
 
-Welcome to the Reportlab PDF Library documentation!
-=====================================
+===================================
+ReportLab PDF Toolkit documentation
+===================================
+
+.. rubric:: API references and more for the ReportLab PDF Toolkit
+
 
 Contents:
 
 .. toctree::
    :maxdepth: 2
 
+   Library reference <lib.rst>
+    
+
 Actually, that's an exaggeration.  We're just playing with Sphinx at the moment.
 Pay no attention to the Sphinx docs until this page says something more
 constructive!
 
+We're planning to use Sphinx for the automated API references.  We have
+always been able to make our own documents in PDF, without using other
+peoples' libraries,. and don't want to back away from this. So, the main
+User Guide will remain in PDF format for now.  However, programmers need
+API refs online, and we want to learn Sphinx (and use rst2pdf) in due
+course.
+
+ :ref:`API reference <api>` |
 
 Indices and tables
 ==================
@@ -23,3 +38,5 @@
 * :ref:`modindex`
 * :ref:`search`
 
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/source/lib.rst	Mon Feb 08 22:28:42 2010 +0000
@@ -0,0 +1,43 @@
+
+
+===================================
+ReportLab Library Reference
+===================================
+
+.. rubric:: API main index
+
+This page should shows what we consider to be the PUBLIC API.
+We will document modules, classes and functions which we think
+programmers need to use to generate PDFs.  If it's internal,
+we should leave it out  (or find a way to mark it as private..)
+
+
+
+reportlab.lib.geomutils
+-----------------------
+
+.. automodule:: reportlab.lib.geomutils
+   :members:
+
+reportlab.lib.colors
+--------------------
+
+.. automodule:: reportlab.lib.colors
+   :members:
+   
+
+reportlab.graphics.shapes
+-------------------------
+
+.. automodule:: reportlab.graphics.shapes
+   :members:
+   
+reportlab.pdfgen.canvas
+-------------------------
+
+.. automodule:: reportlab.pdfgen.canvas
+   :members:
+
+   
+
+blah
--- a/src/reportlab/__init__.py	Mon Feb 08 18:17:33 2010 +0000
+++ b/src/reportlab/__init__.py	Mon Feb 08 22:28:42 2010 +0000
@@ -7,15 +7,18 @@
 
 import sys
 
-if sys.version_info[0:2] < (2, 3):
-    warning = """The trunk of reportlab requires Python 2.3 or higher.
-    Any older applications should either use released versions beginning
-    with 1.x (e.g. 1.21), or snapshots or checkouts from our 'version1'
-    branch.
+if sys.version_info[0:2] < (2, 4):
+    warning = """The trunk of reportlab requires Python 2.4 or higher.
+
+    Python 2.3 users may still use ReportLab 2.4 or any other bugfixes
+    derived from it.  Python 2.2 and below need to use released versions 
+    beginning     with 1.x (e.g. 1.21), or snapshots or checkouts from 
+    our 'version1' branch.
     """
-    raise ImportError("reportlab needs Python 2.3 or higher", warning)
+    raise ImportError("reportlab needs Python 2.4 or higher", warning)
 
 def getStory(context):
+    "This is a helper for our old autogenerated documentation system"
     if context.target == 'UserGuide':
         # parse some local file
         import os
--- a/src/reportlab/lib/utils.py	Mon Feb 08 18:17:33 2010 +0000
+++ b/src/reportlab/lib/utils.py	Mon Feb 08 22:28:42 2010 +0000
@@ -434,8 +434,8 @@
         if 'b' not in mode and os.linesep!='\n': s = s.replace(os.linesep,'\n')
         return getStringIO(s)
 
-import urllib
-def open_for_read(name,mode='b', urlopen=urllib.urlopen):
+import urllib2
+def open_for_read(name,mode='b', urlopen=urllib2.urlopen):
     '''attempt to open a file or URL for reading'''
     if hasattr(name,'read'): return name
     try:
@@ -445,7 +445,7 @@
             return getStringIO(urlopen(name).read())
         except:
             raise IOError('Cannot open resource "%s"' % name)
-del urllib
+del urllib2
 
 def open_and_read(name,mode='b'):
     return open_for_read(name,mode).read()
--- a/src/reportlab/pdfbase/pdfdoc.py	Mon Feb 08 18:17:33 2010 +0000
+++ b/src/reportlab/pdfbase/pdfdoc.py	Mon Feb 08 22:28:42 2010 +0000
@@ -1537,7 +1537,7 @@
         counts = []
         for e in tree:
             counts.append(count(e, closedict))
-        return reduce(add, counts)
+        return sum(counts)  #used to be: return reduce(add, counts)
     return 1
 
 class PDFInfo:
--- a/src/reportlab/platypus/tableofcontents.py	Mon Feb 08 18:17:33 2010 +0000
+++ b/src/reportlab/platypus/tableofcontents.py	Mon Feb 08 22:28:42 2010 +0000
@@ -412,7 +412,10 @@
 
     def _build(self,availWidth,availHeight):
         _tempEntries = self._getlastEntries()
-        _tempEntries.sort(lambda a,b: cmp([x.upper() for x in a[0]], [x.upper() for x in b[0]]))
+        def getkey(seq):
+            return [x.upper() for x in seq[0]]
+        _tempEntries.sort(key=getkey)
+        #was: _tempEntries.sort(lambda a,b: cmp([x.upper() for x in a[0]], [x.upper() for x in b[0]]))
         leveloffset = self.headers and 1 or 0
 
         def drawIndexEntryEnd(canvas, kind, label):