File: 0003-Update-documentation-build-to-work-with-python3.patch

package info (click to toggle)
pydispatcher 2.0.5-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 444 kB
  • sloc: python: 1,079; makefile: 10
file content (231 lines) | stat: -rw-r--r-- 10,760 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
From: Neil Muller <drnlmuller+debian@gmail.com>
Date: Fri, 27 Dec 2019 11:52:26 +0200
Subject: Update documentation build to work with python3

We update the builddocs command and pydoc2 modules to work with python3
---
 docs/pydoc/builddocs.py |  2 +-
 docs/pydoc/pydoc2.py    | 58 +++++++++++++++++++++++--------------------------
 2 files changed, 28 insertions(+), 32 deletions(-)

diff --git a/docs/pydoc/builddocs.py b/docs/pydoc/builddocs.py
index 004118d..1880b17 100755
--- a/docs/pydoc/builddocs.py
+++ b/docs/pydoc/builddocs.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 """Script to automatically generate OpenGLContext documentation"""
 import pydoc2
 
diff --git a/docs/pydoc/pydoc2.py b/docs/pydoc/pydoc2.py
index 7b28bac..f5bfcaa 100644
--- a/docs/pydoc/pydoc2.py
+++ b/docs/pydoc/pydoc2.py
@@ -1,21 +1,19 @@
 """Pydoc sub-class for generating documentation for entire packages"""
 import pydoc, inspect, os, string
-import sys, imp, os, stat, re, types, inspect
-from repr import Repr
-from string import expandtabs, find, join, lower, split, strip, rfind, rstrip
+import sys
 
 
 class DefaultFormatter(pydoc.HTMLDoc):
     def docmodule(self, object, name=None, mod=None, packageContext = None, *ignored):
         """Produce HTML documentation for a module object."""
         name = object.__name__ # ignore the passed-in name
-        parts = split(name, '.')
+        parts = name.split('.')
         links = []
         for i in range(len(parts)-1):
             links.append(
                 '<a href="%s.html"><font color="#ffffff">%s</font></a>' %
-                (join(parts[:i+1], '.'), parts[i]))
-        linkedname = join(links + parts[-1:], '.')
+                ('.'.join(parts[:i+1]), parts[i]))
+        linkedname = '.'.join(links + parts[-1:])
         head = '<big><big><strong>%s</strong></big></big>' % linkedname
         try:
             path = inspect.getabsfile(object)
@@ -35,7 +33,7 @@ class DefaultFormatter(pydoc.HTMLDoc):
         if hasattr(object, '__date__'):
             info.append(self.escape(str(object.__date__)))
         if info:
-            head = head + ' (%s)' % join(info, ', ')
+            head = head + ' (%s)' % ', '.join(info)
         result = self.heading(
             head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
 
@@ -52,7 +50,7 @@ class DefaultFormatter(pydoc.HTMLDoc):
                 module = sys.modules.get(modname)
                 if modname != name and module and hasattr(module, key):
                     if getattr(module, key) is base:
-                        if not cdict.has_key(key):
+                        if key not in cdict:
                             cdict[key] = cdict[base] = modname + '.html#' + key
         funcs, fdict = [], {}
         for key, value in inspect.getmembers(object, inspect.isroutine):
@@ -62,8 +60,7 @@ class DefaultFormatter(pydoc.HTMLDoc):
                 if inspect.isfunction(value): fdict[value] = fdict[key]
         data = []
         for key, value in inspect.getmembers(object, pydoc.isdata):
-            if key not in ['__builtins__', '__doc__']:
-                data.append((key, value))
+            data.append((key, value))
 
         doc = self.markup(pydoc.getdoc(object), self.preformat, fdict, cdict)
         doc = doc and '<tt>%s</tt>' % doc
@@ -91,31 +88,31 @@ class DefaultFormatter(pydoc.HTMLDoc):
             result = result + self.moduleSection( object, packageContext)
         elif modules:
             contents = self.multicolumn(
-                modules, lambda (key, value), s=self: s.modulelink(value))
+                modules, lambda key_value, s=self: s.modulelink(key_value[1]))
             result = result + self.bigsection(
                 'Modules', '#fffff', '#aa55cc', contents)
 
         
         if classes:
-            classlist = map(lambda (key, value): value, classes)
+            classlist = map(lambda key_value: key_value[1], classes)
             contents = [
                 self.formattree(inspect.getclasstree(classlist, 1), name)]
             for key, value in classes:
                 contents.append(self.document(value, key, name, fdict, cdict))
             result = result + self.bigsection(
-                'Classes', '#ffffff', '#ee77aa', join(contents))
+                'Classes', '#ffffff', '#ee77aa', ''.join(contents))
         if funcs:
             contents = []
             for key, value in funcs:
                 contents.append(self.document(value, key, name, fdict, cdict))
             result = result + self.bigsection(
-                'Functions', '#ffffff', '#eeaa77', join(contents))
+                'Functions', '#ffffff', '#eeaa77', ''.join(contents))
         if data:
             contents = []
             for key, value in data:
                 contents.append(self.document(value, key))
             result = result + self.bigsection(
-                'Data', '#ffffff', '#55aa55', join(contents, '<br>\n'))
+                'Data', '#ffffff', '#55aa55', '<br>\n'.join(contents))
         if hasattr(object, '__author__'):
             contents = self.markup(str(object.__author__), self.preformat)
             result = result + self.bigsection(
@@ -156,7 +153,7 @@ class DefaultFormatter(pydoc.HTMLDoc):
             modpkgs.sort()
             # do more recursion here...
             for (modname, name, ya,yo) in modpkgs:
-                packageContext.addInteresting( join( (object.__name__, modname), '.'))
+                packageContext.addInteresting('.'.join( (object.__name__, modname) ))
             items = []
             for (modname, name, ispackage,isshadowed) in modpkgs:
                 try:
@@ -181,12 +178,12 @@ class DefaultFormatter(pydoc.HTMLDoc):
                     items.append(
                         self.modpkglink( (modname, name, ispackage, isshadowed) )
                     )
-            contents = string.join( items, '<br>')
+            contents = '<br>'.join( items )
             result = self.bigsection(
                 'Package Contents', '#ffffff', '#aa55cc', contents)
         elif modules:
             contents = self.multicolumn(
-                modules, lambda (key, value), s=self: s.modulelink(value))
+                modules, lambda key_value, s=self: s.modulelink(key_value[1]))
             result = self.bigsection(
                 'Modules', '#fffff', '#aa55cc', contents)
         else:
@@ -239,7 +236,7 @@ class PackageDocumentationGenerator:
         for exclusion in exclusions:
             try:
                 self.exclusions[ exclusion ]= pydoc.locate ( exclusion)
-            except pydoc.ErrorDuringImport, value:
+            except pydoc.ErrorDuringImport as value:
                 self.warn( """Unable to import the module %s which was specified as an exclusion module"""% (repr(exclusion)))
         self.formatter = formatter or DefaultFormatter()
         for base in baseModules:
@@ -249,18 +246,18 @@ class PackageDocumentationGenerator:
         self.warnings.append (message)
     def info (self, message):
         """Information/status report"""
-        print message
+        print(message)
     def addBase(self, specifier):
         """Set the base of the documentation set, only children of these modules will be documented"""
         try:
             self.baseSpecifiers [specifier] = pydoc.locate ( specifier)
             self.pending.append (specifier)
-        except pydoc.ErrorDuringImport, value:
+        except pydoc.ErrorDuringImport as value:
             self.warn( """Unable to import the module %s which was specified as a base module"""% (repr(specifier)))
     def addInteresting( self, specifier):
         """Add a module to the list of interesting modules"""
         if self.checkScope( specifier):
-##			print "addInteresting", specifier
+##			print("addInteresting", specifier)
             self.pending.append (specifier)
         else:
             self.completed[ specifier] = 1
@@ -268,17 +265,17 @@ class PackageDocumentationGenerator:
         """Check that the specifier is "in scope" for the recursion"""
         if not self.recursion:
             return 0
-        items = string.split (specifier, ".")
+        items = specifier.split(".")
         stopCheck = items [:]
         while stopCheck:
-            name = string.join(items, ".")
+            name = ".".join(items)
             if self.recursionStops.get( name):
                 return 0
             elif self.completed.get (name):
                 return 0
             del stopCheck[-1]
         while items:
-            if self.baseSpecifiers.get( string.join(items, ".")):
+            if self.baseSpecifiers.get( ".".join(items)):
                 return 1
             del items[-1]
         # was not within any given scope
@@ -292,20 +289,20 @@ class PackageDocumentationGenerator:
         try:
             while self.pending:
                 try:
-                    if self.completed.has_key( self.pending[0] ):
+                    if self.pending[0] in self.completed:
                         raise AlreadyDone( self.pending[0] )
                     self.info( """Start %s"""% (repr(self.pending[0])))
                     object = pydoc.locate ( self.pending[0] )
                     self.info( """   ... found %s"""% (repr(object.__name__)))
                 except AlreadyDone:
                     pass
-                except pydoc.ErrorDuringImport, value:
+                except pydoc.ErrorDuringImport as value:
                     self.info( """   ... FAILED %s"""% (repr( value)))
                     self.warn( """Unable to import the module %s"""% (repr(self.pending[0])))
-                except (SystemError, SystemExit), value:
+                except (SystemError, SystemExit) as value:
                     self.info( """   ... FAILED %s"""% (repr( value)))
                     self.warn( """Unable to import the module %s"""% (repr(self.pending[0])))
-                except Exception, value:
+                except Exception as value:
                     self.info( """   ... FAILED %s"""% (repr( value)))
                     self.warn( """Unable to import the module %s"""% (repr(self.pending[0])))
                 else:
@@ -330,7 +327,7 @@ class PackageDocumentationGenerator:
                 del self.pending[0]
         finally:
             for item in self.warnings:
-                print item
+                print(item)
             
     def clean (self, objectList, object):
         """callback from the formatter object asking us to remove
@@ -378,4 +375,3 @@ if __name__ == "__main__":
         destinationDirectory = "z:\\temp",
         exclusions = excludes,
     ).process ()
-        
\ No newline at end of file