File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 11# -*- coding: UTF-8 -*-
2+ import codecs
23import os
34import re
45import glob
@@ -143,16 +144,14 @@ def gen_gallery(app, doctree):
143144 gallery_path = os .path .join (app .builder .srcdir ,
144145 '_templates' , 'gallery.html' )
145146 if os .path .exists (gallery_path ):
146- fh = open (gallery_path , 'r' )
147- regenerate = fh .read () != content
148- fh .close ()
147+ with codecs .open (gallery_path , 'r' , encoding = 'utf-8' ) as fh :
148+ regenerate = fh .read () != content
149149 else :
150150 regenerate = True
151151
152152 if regenerate :
153- fh = open (gallery_path , 'w' )
154- fh .write (content )
155- fh .close ()
153+ with codecs .open (gallery_path , 'w' , encoding = 'utf-8' ) as fh :
154+ fh .write (content )
156155
157156 for key in app .builder .status_iterator (
158157 iter (thumbnails .keys ()), "generating thumbnails... " ,
You can’t perform that action at this time.
0 commit comments