2022-03-02 05:32:31 +00:00
|
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
2022-03-05 07:04:26 +00:00
|
|
|
|
from bs4 import BeautifulSoup as bs
|
2022-03-05 04:35:57 +00:00
|
|
|
|
import datetime
|
2022-03-05 07:04:26 +00:00
|
|
|
|
import re
|
2022-03-05 04:35:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-05 04:41:12 +00:00
|
|
|
|
class readHead():
|
2022-03-05 04:35:57 +00:00
|
|
|
|
inFile = ""
|
|
|
|
|
outHead = ""
|
2022-03-05 07:04:26 +00:00
|
|
|
|
sTime = []
|
2022-03-05 04:35:57 +00:00
|
|
|
|
sTitle = ""
|
|
|
|
|
footStr = "\n</body>\n</html>"
|
|
|
|
|
|
2022-03-05 07:04:26 +00:00
|
|
|
|
def __init__(self, headerFile, sTitle):
|
2022-03-05 04:35:57 +00:00
|
|
|
|
self.inFile = headerFile
|
2022-03-05 07:04:26 +00:00
|
|
|
|
self.sTitle = sTitle
|
2022-03-05 04:35:57 +00:00
|
|
|
|
self.outHead = ""
|
2022-03-05 07:04:26 +00:00
|
|
|
|
self.stime = []
|
2022-03-05 04:35:57 +00:00
|
|
|
|
self.footStr = "\n</body>\n</html>"
|
|
|
|
|
|
|
|
|
|
def getTime(self):
|
|
|
|
|
gettime = datetime.datetime.now()
|
|
|
|
|
modDate = str(gettime.strftime("%A, %B %d, %Y at %X UTC−06:00")) #TODO: I don't want to hard-code this but the %z utc offset isn't printing
|
2022-03-05 07:04:26 +00:00
|
|
|
|
createDate = modDate #TODO: make this seperate
|
|
|
|
|
global sTime
|
|
|
|
|
self.sTime.append(str(modDate))
|
|
|
|
|
self.sTime.append(str(createDate))
|
|
|
|
|
return(self.sTime)
|
2022-03-05 04:35:57 +00:00
|
|
|
|
|
2022-03-05 07:04:26 +00:00
|
|
|
|
def read(self):
|
|
|
|
|
file = open(self.inFile, "r")
|
|
|
|
|
headStr = file.read()
|
|
|
|
|
file.close()
|
|
|
|
|
return(headStr)
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return(str(self.sed()))
|
|
|
|
|
|
|
|
|
|
def sed(self):
|
|
|
|
|
stdin = (str(self.read()))
|
|
|
|
|
#soupSed = soup(stdin, "lxml")
|
|
|
|
|
self.getTime()
|
|
|
|
|
stdin = str(re.sub("CREATEDATE", str(self.sTime[0]), stdin))
|
|
|
|
|
stdin = str(re.sub("MODDATE", str(self.sTime[1]), stdin))
|
|
|
|
|
|
|
|
|
|
soup = bs(stdin, "lxml")
|
|
|
|
|
soup.head.title = str(self.sTitle)
|
|
|
|
|
|
|
|
|
|
return(soup)
|