Line 0
Link Here
|
|
|
1 |
--- documentation/processHtml.py.orig 2018-07-18 02:17:49 UTC |
2 |
+++ documentation/processHtml.py |
3 |
@@ -25,9 +25,11 @@ |
4 |
|
5 |
import os |
6 |
import sys |
7 |
-import string |
8 |
import re |
9 |
-import HTMLParser |
10 |
+try: |
11 |
+ import HTMLParser |
12 |
+except: |
13 |
+ import html.parser as HTMLParser |
14 |
|
15 |
class HtmlToTextParser(HTMLParser.HTMLParser): |
16 |
def __init__(self): |
17 |
@@ -89,10 +91,10 @@ def ReadNavigationTemplate( filePath ): |
18 |
try: |
19 |
navFile = open( filePath, "r") |
20 |
except IOError: |
21 |
- print "Could not open file \'"+filePath+"\'" |
22 |
+ print("Could not open file \'"+filePath+"\'") |
23 |
|
24 |
with navFile: |
25 |
- print "Navigation template: \'"+filePath+"\'" |
26 |
+ print("Navigation template: \'"+filePath+"\'") |
27 |
navHtml = navFile.read() |
28 |
navHtml = StripHTMLComments(navHtml) |
29 |
navFile.close() |
30 |
@@ -109,7 +111,7 @@ def WriteIndexFile( outputFile, content ): |
31 |
except: |
32 |
pass |
33 |
|
34 |
- print "Creating Search-Index File : \""+outputFile+"\"" |
35 |
+ print("Creating Search-Index File : \""+outputFile+"\"") |
36 |
|
37 |
f = open(outputFile, "w") |
38 |
f.write(content) |
39 |
@@ -117,7 +119,7 @@ def WriteIndexFile( outputFile, content ): |
40 |
|
41 |
#------------------------------------------------------------------------------- |
42 |
def Usage(): |
43 |
- print str(sys.argv[0])+" <input directory> <output directory> <html template>" |
44 |
+ print(str(sys.argv[0])+" <input directory> <output directory> <html template>") |
45 |
exit(1); |
46 |
|
47 |
|
48 |
@@ -132,7 +134,7 @@ navTemplate = str(sys.argv[2]) |
49 |
|
50 |
navHtml = ReadNavigationTemplate( navTemplate ) |
51 |
|
52 |
-print "Scanning : \'"+rootDir+"\'" |
53 |
+print("Scanning : \'"+rootDir+"\'") |
54 |
|
55 |
searchIndex = 'var tipuesearch = { "pages": [ ' |
56 |
|
57 |
@@ -172,22 +174,22 @@ for root, dirs, files in os.walk(rootDir): |
58 |
|
59 |
# if necessary, insert navigation html |
60 |
if (not parser.HasNavigationSection()): |
61 |
- loc = string.find(html,"<body>") |
62 |
+ loc = html.find("<body>") |
63 |
html = html[:loc+6] + navHtml + html[loc+6:] |
64 |
|
65 |
msg += "added navigation" |
66 |
|
67 |
# replace the article title placeholder with the real title |
68 |
if title: |
69 |
- html = string.replace(html,"OSD_ARTICLE_TITLE", title) |
70 |
+ html = html.replace("OSD_ARTICLE_TITLE", title) |
71 |
else: |
72 |
- html = string.replace(html,"OSD_ARTICLE_TITLE", "") |
73 |
+ html = html.replace("OSD_ARTICLE_TITLE", "") |
74 |
|
75 |
f.seek(0) |
76 |
f.write(html) |
77 |
f.close() |
78 |
|
79 |
- print msg |
80 |
+ print(msg) |
81 |
|
82 |
searchIndex = searchIndex + "]};" |
83 |
|