CMS 3D CMS Logo

postprocess-scan-build.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 from bs4 import BeautifulSoup
3 import sys
4 import os
5 url = os.path.abspath(sys.argv[1])
6 report_dir = os.path.dirname(url)
7 page = open(url)
8 soup = BeautifulSoup(page.read(), 'html.parser')
9 page.close()
10 seen = dict()
11 tables = soup.find_all('table', recursive=True)
12 
13 rowheader = tables[2].find('thead')
14 rowheaders = rowheader.find_all('tr')
15 htag = soup.new_tag('td')
16 htag.string = 'Num reports'
17 htag['class'] = 'Q'
18 rowheaders[-1].insert(7, htag)
19 sortable = rowheaders[-1].find_all('span')
20 sortable[0].string.replace_with(' ▾')
21 
22 rowsbody = tables[2].find('tbody')
23 rows = rowsbody.find_all('tr')
24 for row in rows:
25  cells = row.find_all('td')
26  if cells:
27  key = str(cells[2])+str(cells[3])+str(cells[4])
28  if key in seen.keys():
29  seen[key] = seen[key]+1
30  href = cells[6].find('a', href=True)
31  if href:
32  report = href['href'].split("#")[0]
33  report_file = os.path.join(report_dir, report)
34  if report.startswith("report-") and os.path.exists(report_file):
35  os.remove(report_file)
36  row.decompose()
37  else:
38  seen[key] = 1
39 
40 
41 rowsbody = tables[2].find('tbody')
42 rows = rowsbody.find_all('tr')
43 for row in rows:
44  cells = row.find_all('td')
45  if cells:
46  key = str(cells[2])+str(cells[3])+str(cells[4])
47  tag = soup.new_tag('td')
48  tag.string = '{}'.format(seen[key])
49  tag['class'] = 'Q'
50  row.insert(3, tag)
51 print(soup.prettify(formatter=None))
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
#define str(s)