CMS 3D CMS Logo

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