-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
39 lines (27 loc) · 927 Bytes
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python3
import os
import requests
def checkAtom(file):
url = 'https://validator.w3.org/feed/check.cgi'
with open(file,'r') as index_file:
index_lines = index_file.read().replace('\n','')
payload = { 'rawdata': index_lines }
r = requests.post(url, data=payload)
if "This is a valid Atom 1.0 feed" in r.content.decode():
return "checkAtom: " + file + " is valid"
else:
return "checkAtom: " + file + " is NOT valid"
def checkHtml(file):
url = 'https://validator.w3.org/nu/'
files = {'file': open(file,'rb')}
r = requests.post(url, files=files)
if "The document validates" in r.content.decode():
return "checkHtml: " + file + " is valid"
else:
return "checkHtml: " + file + " is NOT valid"
if __name__ == "__main__":
os.system('hugo --cleanDestinationDir')
atom = checkAtom('public/index.xml')
print(atom)
html = checkHtml('public/index.html')
print(html)