summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLed Mitz <smoothshifter@tuta.io>2024-06-02 22:08:33 +0000
committerLed Mitz <smoothshifter@tuta.io>2024-06-02 22:08:33 +0000
commit87c41763bd3800eb365c20a5c28d44c1b4224eb3 (patch)
tree6d0a6b73d4bb473a5c578d7c3123cded963b8284
parent1dc56421493df2b9016b0096998cd668a429ab9e (diff)
parent0a4383b895d169670a3c25c52dcab4e8e656f182 (diff)
downloadtools-87c41763bd3800eb365c20a5c28d44c1b4224eb3.tar.gz
tools-87c41763bd3800eb365c20a5c28d44c1b4224eb3.tar.bz2
tools-87c41763bd3800eb365c20a5c28d44c1b4224eb3.tar.xz
tools-87c41763bd3800eb365c20a5c28d44c1b4224eb3.zip
Merge branch 'fix-news-python3' into 'master'
news.py: Fixed error when using Python 3.8 or later See merge request legacy/tools!43
-rw-r--r--_news_colors.py9
-rwxr-xr-xnews.py2
2 files changed, 8 insertions, 3 deletions
diff --git a/_news_colors.py b/_news_colors.py
index fd0782c..88bdc03 100644
--- a/_news_colors.py
+++ b/_news_colors.py
@@ -20,7 +20,12 @@
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
-import cgi
+try:
+ # py3
+ from html import escape as html_escape
+except ImportError:
+ # py2
+ from cgi import escape as html_escape
__all__ = ['make_html_colors_dict', 'make_txt_colors_dict', 'make_forum_colors_dict']
@@ -51,7 +56,7 @@ class HtmlDate(object):
class HtmlLink(object):
__slots__ = ()
def __format__(self, target):
- target = cgi.escape(target, True)
+ target = html_escape(target, True)
return '<a href="%s">%s</a>' % (target, target)
class HtmlSignature(object):
diff --git a/news.py b/news.py
index f5bbb52..531445a 100755
--- a/news.py
+++ b/news.py
@@ -124,7 +124,7 @@ class JSONWriter(BasicWriter):
entry, author = entry.rstrip('\n').rsplit('\n', 1)
self.stream.write('"title":"%s",' % title.format(**{'title':NOPFmt()})) # FIXME: assumes the first line is always the title
self.stream.write('"date":"%s",' % date.format(**{'date':NOPFmt()})) # FIXME: assumes the second line is always the date
- self.stream.write('"author":"%s",' % author.format(**{'author':NOPFmt()})) # FIXME: assumes the second line is always the date
+ self.stream.write('"author":"%s",' % author.format(**{'author':NOPFmt()})) # FIXME: assumes the last line is always the author
self.stream.write('"html":"')
entry = entry.lstrip('\n')
entry = entry.replace('\n\n', '<br/>')