Skip to content

Commit 88893e7

Browse files
JanardhanamJanardhanam
authored andcommitted
command line arg compatibility and credits
1 parent a4a5c7e commit 88893e7

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

HTML-Beauti.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from bs4 import BeautifulSoup
2-
import os, glob
2+
import os, glob, sys
33

44
def file_replace_text(fname, toreplace, replacement):
5-
print("opening " + fname)
5+
#print("opening " + fname)
66
with open(fname, 'r', encoding='Windows-1252') as file:
77
filedata = file.read()
88
# Replace the text in file
@@ -12,7 +12,11 @@ def file_replace_text(fname, toreplace, replacement):
1212
file.write(filedata)
1313

1414
def main():
15-
KBID = str(input("Enter KB number to beautify: "))
15+
if len(sys.argv) <= 1:
16+
KBID = str(input("Enter KB number to beautify: "))
17+
else:
18+
KBID = sys.argv[1]
19+
1620
dirname = os.path.dirname(__file__)
1721
# print(dirname)
1822
folderpath = os.path.join(dirname, KBID)
@@ -37,10 +41,15 @@ def main():
3741

3842
#saves title name for later
3943
title = soup.title.get_text()
40-
print(title)
44+
#print(title)
45+
46+
#shameless self-promotion
47+
creditMe = soup.new_tag('meta', content='Converted to HTML by Vinay Janardhanam')
48+
soup.head.append(creditMe)
4149

4250
#remove style tag from header
43-
soup.find('style').extract()
51+
for s in soup('style'):
52+
s.extract()
4453

4554
#remove unnecessary attributes
4655
for tag in soup():

0 commit comments

Comments
 (0)