41
41
import types , re , os .path , pickle
42
42
from epydoc import log
43
43
import epydoc
44
- import builtins
44
+ import __builtin__
45
45
from epydoc .compat import * # Backwards compatibility
46
46
from epydoc .util import decode_with_backslashreplace , py_src_filename
47
47
import epydoc .markup .pyval_repr
@@ -111,7 +111,7 @@ def __init__(self, *pieces, **options):
111
111
for piece in pieces :
112
112
if isinstance (piece , DottedName ):
113
113
self ._identifiers += piece ._identifiers
114
- elif isinstance (piece , str ):
114
+ elif isinstance (piece , basestring ):
115
115
for subpiece in piece .split ('.' ):
116
116
if piece not in self ._ok_identifiers :
117
117
if not self ._IDENTIFIER_RE .match (subpiece ):
@@ -129,7 +129,7 @@ def __init__(self, *pieces, **options):
129
129
self ._identifiers = tuple (self ._identifiers )
130
130
131
131
def __repr__ (self ):
132
- idents = [repr ( ident ) for ident in self ._identifiers ]
132
+ idents = [` ident` for ident in self ._identifiers ]
133
133
return 'DottedName(' + ', ' .join (idents ) + ')'
134
134
135
135
def __str__ (self ):
@@ -147,7 +147,7 @@ def __add__(self, other):
147
147
Return a new C{DottedName} whose identifier sequence is formed
148
148
by adding C{other}'s identifier sequence to C{self}'s.
149
149
"""
150
- if isinstance (other , (str , DottedName )):
150
+ if isinstance (other , (basestring , DottedName )):
151
151
return DottedName (self , other )
152
152
else :
153
153
return DottedName (self , * other )
@@ -157,7 +157,7 @@ def __radd__(self, other):
157
157
Return a new C{DottedName} whose identifier sequence is formed
158
158
by adding C{self}'s identifier sequence to C{other}'s.
159
159
"""
160
- if isinstance (other , (str , DottedName )):
160
+ if isinstance (other , (basestring , DottedName )):
161
161
return DottedName (other , self )
162
162
else :
163
163
return DottedName (* (list (other )+ [self ]))
@@ -169,7 +169,7 @@ def __getitem__(self, i):
169
169
identifiers selected by the slice. If C{i} is an empty slice,
170
170
return an empty list (since empty C{DottedName}s are not valid).
171
171
"""
172
- if isinstance (i , slice ):
172
+ if isinstance (i , types . SliceType ):
173
173
pieces = self ._identifiers [i .start :i .stop ]
174
174
if pieces : return DottedName (pieces )
175
175
else : return []
@@ -277,7 +277,7 @@ def __init__(self, name):
277
277
self .name = name
278
278
def __repr__ (self ):
279
279
return '<%s>' % self .name
280
- def __bool__ (self ):
280
+ def __nonzero__ (self ):
281
281
raise ValueError ('Sentinel value <%s> can not be used as a boolean' %
282
282
self .name )
283
283
@@ -974,17 +974,17 @@ def apidoc_links(self, **filters):
974
974
imports = filters .get ('imports' , True )
975
975
private = filters .get ('private' , True )
976
976
if variables and imports and private :
977
- return list ( self .variables .values () ) # list the common case first.
977
+ return self .variables .values () # list the common case first.
978
978
elif not variables :
979
979
return []
980
980
elif not imports and not private :
981
- return [v for v in list ( self .variables .values () ) if
981
+ return [v for v in self .variables .values () if
982
982
v .is_imported != True and v .is_public != False ]
983
983
elif not private :
984
- return [v for v in list ( self .variables .values () ) if
984
+ return [v for v in self .variables .values () if
985
985
v .is_public != False ]
986
986
elif not imports :
987
- return [v for v in list ( self .variables .values () ) if
987
+ return [v for v in self .variables .values () if
988
988
v .is_imported != True ]
989
989
assert 0 , 'this line should be unreachable'
990
990
@@ -1008,7 +1008,7 @@ def init_sorted_variables(self):
1008
1008
elif '*' in ident :
1009
1009
regexp = re .compile ('^%s$' % ident .replace ('*' , '(.*)' ))
1010
1010
# sort within matching group?
1011
- for name , var_doc in list ( unsorted .items () ):
1011
+ for name , var_doc in unsorted .items ():
1012
1012
if regexp .match (name ):
1013
1013
self .sorted_variables .append (unsorted .pop (name ))
1014
1014
unused_idents .discard (ident )
@@ -1019,7 +1019,7 @@ def init_sorted_variables(self):
1019
1019
1020
1020
1021
1021
# Add any remaining variables in alphabetical order.
1022
- var_docs = list ( unsorted .items () )
1022
+ var_docs = unsorted .items ()
1023
1023
var_docs .sort ()
1024
1024
for name , var_doc in var_docs :
1025
1025
self .sorted_variables .append (var_doc )
@@ -1096,7 +1096,7 @@ def report_unused_groups(self):
1096
1096
Issue a warning for any @group items that were not used by
1097
1097
L{_init_grouping()}.
1098
1098
"""
1099
- for (group , unused_idents ) in list ( self ._unused_groups .items () ):
1099
+ for (group , unused_idents ) in self ._unused_groups .items ():
1100
1100
for ident in unused_idents :
1101
1101
log .warning ("@group %s: %s.%s not found" %
1102
1102
(group , self .canonical_name , ident ))
@@ -1299,7 +1299,7 @@ def mro(self, warn_about_bad_bases=False):
1299
1299
if self .is_newstyle_class ():
1300
1300
try :
1301
1301
return self ._c3_mro (warn_about_bad_bases )
1302
- except ValueError as e : # (inconsistent hierarchy)
1302
+ except ValueError , e : # (inconsistent hierarchy)
1303
1303
log .error ('Error finding mro for %s: %s' %
1304
1304
(self .canonical_name , e ))
1305
1305
# Better than nothing:
@@ -1331,7 +1331,7 @@ def _c3_mro(self, warn_about_bad_bases):
1331
1331
base .proxy_for is not None ):
1332
1332
self ._report_bad_base (base )
1333
1333
w = [warn_about_bad_bases ]* len (bases )
1334
- return self ._c3_merge ([[self ]] + list ( map (ClassDoc ._c3_mro , bases , w ) ) +
1334
+ return self ._c3_merge ([[self ]] + map (ClassDoc ._c3_mro , bases , w ) +
1335
1335
[list (bases )])
1336
1336
1337
1337
def _report_bad_base (self , base ):
@@ -1879,7 +1879,7 @@ def find(self, name, context, not_found_exception=False):
1879
1879
if the name is not found anywhere (including builtins,
1880
1880
function parameters, etc.)
1881
1881
"""
1882
- if isinstance (name , str ):
1882
+ if isinstance (name , basestring ):
1883
1883
name = re .sub (r'\(.*\)$' , '' , name .strip ())
1884
1884
if re .match ('^([a-zA-Z_]\w*)(\.[a-zA-Z_]\w*)*$' , name ):
1885
1885
name = DottedName (name )
@@ -1959,7 +1959,7 @@ def _get_module_classes(self, docs):
1959
1959
if not isinstance (doc , ModuleDoc ):
1960
1960
continue
1961
1961
1962
- for var in list ( doc .variables .values () ):
1962
+ for var in doc .variables .values ():
1963
1963
if not isinstance (var .value , ClassDoc ):
1964
1964
continue
1965
1965
@@ -2043,7 +2043,7 @@ def read_profiling_info(self, profile_stats):
2043
2043
# from these `funcid`s to `RoutineDoc`s.
2044
2044
self ._update_funcid_to_doc (profile_stats )
2045
2045
2046
- for callee , (cc , nc , tt , ct , callers ) in list ( profile_stats .stats .items () ):
2046
+ for callee , (cc , nc , tt , ct , callers ) in profile_stats .stats .items ():
2047
2047
callee = self ._funcid_to_doc .get (callee )
2048
2048
if callee is None : continue
2049
2049
for caller in callers :
@@ -2123,15 +2123,15 @@ def pp_apidoc(api_doc, doublespace=0, depth=5, exclude=(), include=(),
2123
2123
s = '%s [%s]' % (name , backpointers [pyid ])
2124
2124
2125
2125
# Only print non-empty fields:
2126
- fields = [field for field in list ( api_doc .__dict__ .keys () )
2126
+ fields = [field for field in api_doc .__dict__ .keys ()
2127
2127
if (field in include or
2128
2128
(getattr (api_doc , field ) is not UNKNOWN
2129
2129
and field not in exclude ))]
2130
2130
if include :
2131
2131
fields = [field for field in dir (api_doc )
2132
2132
if field in include ]
2133
2133
else :
2134
- fields = [field for field in list ( api_doc .__dict__ .keys () )
2134
+ fields = [field for field in api_doc .__dict__ .keys ()
2135
2135
if (getattr (api_doc , field ) is not UNKNOWN
2136
2136
and field not in exclude )]
2137
2137
fields .sort ()
@@ -2141,15 +2141,15 @@ def pp_apidoc(api_doc, doublespace=0, depth=5, exclude=(), include=(),
2141
2141
if doublespace : s += '\n |'
2142
2142
s += '\n +- %s' % field
2143
2143
2144
- if (isinstance (fieldval , list ) and
2144
+ if (isinstance (fieldval , types . ListType ) and
2145
2145
len (fieldval )> 0 and
2146
2146
isinstance (fieldval [0 ], APIDoc )):
2147
2147
s += _pp_list (api_doc , fieldval , doublespace , depth ,
2148
2148
exclude , include , backpointers ,
2149
2149
(field is fields [- 1 ]))
2150
- elif (isinstance (fieldval , dict ) and
2150
+ elif (isinstance (fieldval , types . DictType ) and
2151
2151
len (fieldval )> 0 and
2152
- isinstance (list ( fieldval .values () )[0 ], APIDoc )):
2152
+ isinstance (fieldval .values ()[0 ], APIDoc )):
2153
2153
s += _pp_dict (api_doc , fieldval , doublespace ,
2154
2154
depth , exclude , include , backpointers ,
2155
2155
(field is fields [- 1 ]))
@@ -2179,7 +2179,7 @@ def _pp_list(api_doc, items, doublespace, depth, exclude, include,
2179
2179
2180
2180
def _pp_dict (api_doc , dict , doublespace , depth , exclude , include ,
2181
2181
backpointers , is_last ):
2182
- items = list ( dict .items () )
2182
+ items = dict .items ()
2183
2183
items .sort ()
2184
2184
line1 = (is_last and ' ' ) or '|'
2185
2185
s = ''
@@ -2210,7 +2210,7 @@ def _pp_val(api_doc, val, doublespace, depth, exclude, include, backpointers):
2210
2210
return pp_apidoc (val , doublespace , depth - 1 , exclude ,
2211
2211
include , backpointers )
2212
2212
elif isinstance (val , markup .ParsedDocstring ):
2213
- valrepr = repr ( val .to_plaintext (None ))
2213
+ valrepr = ` val.to_plaintext(None)`
2214
2214
if len (valrepr ) < 40 : return valrepr
2215
2215
else : return valrepr [:37 ]+ '...'
2216
2216
else :
0 commit comments