blob: 455b45a9427ae8900ff3bdc26433424feb54e3de (
plain)
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
|
#! /bin/python3
import sys, subprocess
from datetime import date
from bs4 import BeautifulSoup
def handle(html):
soup = BeautifulSoup(html, 'html.parser')
for graph in soup.select('pre.language-graph'):
print()
print(date.today().strftime("%H:%M:%S"))
print('before:')
print(graph.string)
process = subprocess.Popen(
["/usr/bin/vendor_perl/graph-easy", "--boxart"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
output, error = process.communicate(input=graph.get_text().encode())
graph.string = output.decode()
print('After:')
print(graph.string)
print('Error:')
print(error.decode())
return str(soup)
for line in sys.stdin:
file = line.rstrip("\n")
with open(file, 'r') as html:
new_content = handle(html)
with open(file, 'w') as html:
html.write(new_content)
|