Skip to content

Commit

Permalink
Dev: doc/website-v1: adapt to python3 (ClusterLabs#1374)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasyang2022 committed Apr 17, 2024
1 parent 16ffb53 commit 5772b7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions doc/website-v1/make-news.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Output a combined news.adoc document
Also write an Atom feed document
Expand Down Expand Up @@ -63,7 +63,7 @@ def __init__(self, fname):
raise ValueError("Missing date")

def atom_id(self):
return root_id + '::' + hashlib.sha1(self.filename).hexdigest()
return root_id + '::' + hashlib.sha1(self.filename.encode('utf-8')).hexdigest()

def atom_date(self):
return self.date.replace(' ', 'T') + ':00' + time.tzname[0]
Expand Down
21 changes: 11 additions & 10 deletions doc/website-v1/postprocess.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# create a table of contents for pages that need it

import sys
import re
import argparse

TOC_PAGES = ['man/index.html',
'man-4.6/index.html',
'man-4.3/index.html',
'man-3/index.html',
'man-2.0/index.html',
Expand Down Expand Up @@ -48,7 +49,7 @@ def read_toc_data(infile, debug):
def generate_toc(infile, outfile, debug):

if debug:
print "Infile:", infile
print(f"Infile: {infile}")
toc = read_toc_data(infile, debug)
'''
toc_data = []
Expand All @@ -73,11 +74,11 @@ def generate_toc(infile, outfile, debug):
# Write TOC to outfile
if outfile:
if debug:
print "Writing TOC:"
print "----"
print toc
print "----"
print "Outfile:", outfile
print("Writing TOC:")
print("----")
print(toc)
print("----")
print(f"Outfile: {outfile}")
fil = open(outfile)
f = fil.readlines()
fil.close()
Expand All @@ -96,14 +97,14 @@ def generate_v2(page, debug):
m = section.match(line)
if m:
if debug:
print "toc_data: %s" % str(((m.group('depth'), m.group('text'), m.group('id'))))
print("toc_data: %s" % str(((m.group('depth'), m.group('text'), m.group('id')))))
toc_data.append((m.group('depth'), m.group('text'), m.group('id')))

toc = ''
if len(toc_data) > 0:
toc = '<div id="toc">\n'
for depth, text, link in toc_data:
if depth >= 2 and link is not None:
if int(depth) >= 2 and link is not None:
toc += '<div class="toclevel%s"><a href="#%s">%s</a></div>\n' % (
int(depth) - 1, link, text)
toc += '</div>\n'
Expand All @@ -126,7 +127,7 @@ def main():
debug = args.debug
outfile = args.output
infile = args.input
print "+ %s -> %s" % (infile, outfile)
print("+ %s -> %s" % (infile, outfile))
gen = False
for tocpage in TOC_PAGES:
if not gen and outfile.endswith(tocpage):
Expand Down

0 comments on commit 5772b7c

Please sign in to comment.