|
[Rivet-svn] rivet: fixing unicode string conversion for python2.X in doc/mk-...Rivet Mercurial rivet at projects.hepforge.orgTue May 22 17:30:02 BST 2018
details: https://rivet.hepforge.org/hg/rivet/rev/6c480a0d835c branches: multiweight changeset: 6299:6c480a0d835c user: cspollard date: Tue May 22 17:25:56 2018 +0100 description: fixing unicode string conversion for python2.X in doc/mk-analyses-html diffs (39 lines): --- a/doc/mk-analysis-html Tue May 22 17:03:28 2018 +0100 +++ b/doc/mk-analysis-html Tue May 22 17:25:56 2018 +0100 @@ -190,6 +190,7 @@ page += "<b><kbd>%s</kbd></b>\n" % os.path.basename(cc) with open(cc, 'r') as f: src = f.read() + src = src.decode("UTF-8") try: import pygments from pygments.lexers import get_lexer_by_name @@ -207,7 +208,7 @@ outstr = head + page + foot if type(u'') != str: outstr = unicode(outstr) - f.write(outstr.encode(errors="ignore")) + f.write(outstr.encode("UTF-8")) f.close() @@ -223,14 +224,16 @@ ## Index file in dir f = open(os.path.join(OUTDIR, "index.html"), "wb") -f.write(outstr.encode(errors="ignore")) +if type(u'') != str: + outstr = unicode(outstr) +f.write(outstr.encode("UTF-8")) f.close() ## External index file outstr = outstr.replace("../%s" % OUTDIR, OUTDIR) #< correct link depth if OUTFILE == "-": - sys.stdout.write(outstr.encode(errors="ignore")) + sys.stdout.write(outstr.encode("UTF-8")) else: f = open(OUTFILE, "wb") - f.write(outstr.encode(errors="ignore")) + f.write(outstr.encode("UTF-8")) f.close()
More information about the Rivet-svn mailing list |