autotest: fixed compatibility with python on wiki server

This commit is contained in:
Andrew Tridgell 2021-01-02 16:08:25 +11:00
parent f0954f35a7
commit 529bc6b77c
2 changed files with 13 additions and 7 deletions

View File

@ -5,7 +5,10 @@ Emit docs in a form acceptable to the old Ardupilot wordpress docs site
from param import known_param_fields, known_units
from emit import Emit
import html
try:
from cgi import escape as cescape
except Exception:
from html import escape as cescape
class HtmlEmit(Emit):
@ -59,7 +62,7 @@ DO NOT EDIT
t += '\n\n<h2>%s</h2>' % tag
if d.get('User', None) == 'Advanced':
t += '<em>Note: This parameter is for advanced users</em><br>'
t += "\n\n<p>%s</p>\n" % html.escape(param.Description)
t += "\n\n<p>%s</p>\n" % cescape(param.Description)
t += "<ul>\n"
for field in param.__dict__.keys():
@ -77,8 +80,8 @@ DO NOT EDIT
abreviated_units = param.__dict__[field]
if abreviated_units != '':
units = known_units[abreviated_units] # use the known_units dictionary to convert the abreviated unit into a full textual one
t += "<li>%s: %s</li>\n" % (field, html.escape(units))
t += "<li>%s: %s</li>\n" % (field, cescape(units))
else:
t += "<li>%s: %s</li>\n" % (field, html.escape(param.__dict__[field]))
t += "<li>%s: %s</li>\n" % (field, cescape(param.__dict__[field]))
t += "</ul>\n"
self.t += t

View File

@ -3,7 +3,10 @@ from __future__ import print_function
import re
from param import known_param_fields, known_units
from emit import Emit
import html
try:
from cgi import escape as cescape
except Exception:
from html import escape as cescape
# Emit docs in a RST format
@ -256,9 +259,9 @@ Complete Parameter List
# convert the abreviated unit into a full
# textual one:
units = known_units[abreviated_units]
row.append(html.escape(units))
row.append(cescape(units))
else:
row.append(html.escape(param.__dict__[field]))
row.append(cescape(param.__dict__[field]))
if len(row):
ret += "\n\n" + self.tablify([row], headings=headings) + "\n\n"
self.t += ret + "\n"