aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2019-05-30 16:16:31 +0100
committerYann Herklotz <git@yannherklotz.com>2019-05-30 16:24:46 +0100
commit515cd6d8da6a806ee4d5d830affb5aa7b2aed973 (patch)
tree15981ca6151a7e3ba2275ce5618046b439b0dddd /scripts
parenta52240fe4f9a160f3fcd65217b7f7307fa13e820 (diff)
downloadverismith-515cd6d8da6a806ee4d5d830affb5aa7b2aed973.tar.gz
verismith-515cd6d8da6a806ee4d5d830affb5aa7b2aed973.zip
Fix the conversion
Diffstat (limited to 'scripts')
-rwxr-xr-x[-rw-r--r--]scripts/convert.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/scripts/convert.py b/scripts/convert.py
index e179774..a1e68ca 100644..100755
--- a/scripts/convert.py
+++ b/scripts/convert.py
@@ -3,19 +3,29 @@
import sys
from bs4 import BeautifulSoup
import csv
+import re
def main(file_):
with open(file_, "r") as f:
file_contents = f.read()
- soup = BeautifulSoup(file_contents)
+ sec = re.compile(r"([0-9.]+)s")
+
+ soup = BeautifulSoup(file_contents, "html.parser")
table = soup.select_one("table")
- headers = [th.text.encode("utf-8") for th in table.select("tr th")]
+ headers = [th.text for th in table.select("tr th")]
+ vals = [[td.text for td in row.find_all("td")] for row in table.select("tr + tr")][:-2]
+
+ headers = map(lambda x: "Size" if x == "Size (loc)" else x, headers)
+
+ vals = map(lambda l: map(lambda s: sec.sub(r"\1", s), l), vals)
+ vals = map(lambda l: map(lambda s: re.sub(r"Failed", r"1", s), l), vals)
+ vals = map(lambda l: map(lambda s: re.sub(r"Passed", r"0", s), l), vals)
with open("out.csv", "w") as f:
wr = csv.writer(f)
wr.writerow(headers)
- wr.writerows([[td.text.encode("utf-8") for td in row.find_all("td")] for row in table.select("tr + tr")])
+ wr.writerows(vals)
if __name__ == '__main__':
main(sys.argv[1])