File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,7 +38,10 @@ def generate_example_rst(app):
3838 continue
3939
4040 fullpath = os .path .join (root ,fname )
41- contents = io .open (fullpath , encoding = 'utf8' ).read ()
41+ if sys .version_info [0 ] >= 3 :
42+ contents = io .open (fullpath , encoding = 'utf8' ).read ()
43+ else :
44+ contents = io .open (fullpath ).read ()
4245 # indent
4346 relpath = os .path .split (root )[- 1 ]
4447 datad .setdefault (relpath , []).append ((fullpath , fname , contents ))
@@ -130,7 +133,10 @@ def generate_example_rst(app):
130133 if not out_of_date (fullpath , outrstfile ):
131134 continue
132135
133- fh = io .open (outrstfile , 'w' , encoding = 'utf8' )
136+ if sys .version_info [0 ] >= 3 :
137+ fh = io .open (outrstfile , 'w' , encoding = 'utf8' )
138+ else :
139+ fh = io .open (outrstfile , 'w' )
134140 fh .write ('.. _%s-%s:\n \n ' % (subdir , basename ))
135141 title = '%s example code: %s' % (subdir , fname )
136142 #title = '<img src=%s> %s example code: %s'%(thumbfile, subdir, fname)
You can’t perform that action at this time.
0 commit comments