CMS 3D CMS Logo

Functions
MainPageGenerator Namespace Reference

Functions

def bsBugFix ()
 
def costumFormatter (inp)
 
def fillContentTemplate (domains)
 
def generateTree (tree)
 
def generateTreeViewPage (tree, name)
 
def getClasses (classesPagePath)
 
def getFiles (filesPagePath)
 
def getPackages (packagesPagePath)
 
def prepareTemplate ()
 

Function Documentation

def MainPageGenerator.bsBugFix ( )

Definition at line 125 of file MainPageGenerator.py.

References harvestTrackValidationPlots.str.

Referenced by generateTreeViewPage().

125 def bsBugFix():
126  # this function fixes script tag bug of beautifulsoup (bs). bs is escaping
127  # javascript operators according to the html escape characters, such as
128  # > -> ">". The method to ged rid of this issue is to replace script
129  # tags with their original versions in the string level
130  html = str(htmlPage)
131  for scriptTag in BeautifulSoup(contentTmplOrg).findAll('script'):
132  js = scriptTag.text
133  html = html.replace(str(scriptTag), '<script>%s</script>' % js)
134  return html
135 
def MainPageGenerator.costumFormatter (   inp)

Definition at line 121 of file MainPageGenerator.py.

122  if inp.find_parent("script") is None: return EntitySubstitution.substitute_html(inp)
123  else: return inp
124 
def MainPageGenerator.fillContentTemplate (   domains)

Definition at line 136 of file MainPageGenerator.py.

References mps_setup.append, and relativeConstraints.keys.

Referenced by generateTreeViewPage().

136 def fillContentTemplate(domains):
137  rows = ''
138  rowTmpl = '<tr id="{0}"><td width="50%">{1}</td><td>{2}</td></tr>'
139  aTmpl = """<tr style="padding:0"><td colspan="2" style="padding:0">
140  <div class="accordion" id="{0}">
141  <iframe width="100%" height="250px" frameborder="0"
142  data-src="iframes/{0}.html"> </iframe>
143  </div></td></tr>"""
144  domainNames = domains.keys()
145  domainNames.sort()
146  for domain in domainNames:
147  persons = domains[domain].keys()
148  persons.sort()
149  cCell = ''
150  for person in persons:
151  email = domains[domain][person]
152  cCell = cCell+'<a href="mailto:{0}">{0}<a/>, '.format(person,email)
153  cCell = cCell.rstrip(', ')
154  escapedDomainName = domain.replace(' ', '')
155  rows = rows + rowTmpl.format(escapedDomainName, domain, cCell)
156  rows = rows + aTmpl.format(escapedDomainName)
157  contentTmpl.find('table').append(BeautifulSoup(rows))
158  # put cmssw version
159  contentTmpl.find('h2', {'id' : 'version'}).append(cmsswVersion)
160  content = htmlPage.find('div', {'class' : 'contents'})
161  content.append(contentTmpl)
162 
def fillContentTemplate(domains)
def MainPageGenerator.generateTree (   tree)

Definition at line 163 of file MainPageGenerator.py.

Referenced by generateTreeViewPage().

163 def generateTree(tree):
164  if type(tree) == dict and len(tree) == 0: return BeautifulSoup('')
165  # our recursive function to generate domain tree views
166  root = BeautifulSoup('<ul></ul>')
167  names = tree.keys(); names.sort()
168  for name in names:
169  node = BeautifulSoup('<li><div></div></li>')
170  if type(tree[name]) == dict:
171  title = BeautifulSoup('<span class="folder"></span>')
172  title.span.append(name)
173  node.li.append(title)
174  # __git__ and __packageDoc__ are special keys which address links,
175  # github and packade documentation links. please see in the section
176  # that we merge all what we have (under the __main__ block)
177  for i in ['__git__', '__packageDoc__']:
178  if not i in tree[name]: continue
179  link = BeautifulSoup(' <a></a>')
180  link.a['target'] = '_blank'
181  link.a['href'] = tree[name][i]
182  link.a.append('[%s]' % i.replace('_', ''))
183  del tree[name][i]
184  title.span.append(link)
185  if len(tree[name]) == 0:
186  title.span['class'] = 'emptyFolder'
187  else: node.li.div['class'] = 'hitarea expandable-hitarea'
188  node.li.append(generateTree(tree[name]))
189  elif type(tree[name]) == str or type(tree[name]) == unicode:
190  link = BeautifulSoup('<a><span class="file"></span></a>')
191  link.a['target'] = '_blank'
192  link.a['href'] = tree[name]
193  link.a.span.append(name)
194  node.li.append(link)
195  else:
196  node.li.append(name)
197  root.ul.append(node)
198  return root
199 
def MainPageGenerator.generateTreeViewPage (   tree,
  name 
)

Definition at line 200 of file MainPageGenerator.py.

References bsBugFix(), fillContentTemplate(), generateTree(), getClasses(), getFiles(), getPackages(), prepareTemplate(), and harvestTrackValidationPlots.str.

200 def generateTreeViewPage(tree, name):
201  page = BeautifulSoup(treeViewTmpl)
202  treeTag = page.find('ul', {'id' : 'browser'})
203  treeTag.append(generateTree(tree))
204  twikiLink = page.find('a', {'id' : 'twiki'})
205  if name in data['TWIKI_PAGES']:
206  twikiLink['href'] = data['TWIKI_PAGES'][name]
207  else:
208  twikiLink.extract()
209  return page
210 
211 
def generateTreeViewPage(tree, name)
def MainPageGenerator.getClasses (   classesPagePath)

Definition at line 99 of file MainPageGenerator.py.

Referenced by generateTreeViewPage().

99 def getClasses(classesPagePath):
100  data = {}
101  with open(classesPagePath) as f: page = f.read()
102  page = BeautifulSoup(page)
103  content = page.find('div', {'class' : 'contents'})
104  for cell in content.findAll('td'):
105  aTag = cell.find('a')
106  if not aTag or not aTag.has_key('href'): continue
107  data[aTag.text] = '../' + aTag['href']
108  return data
109 
def getClasses(classesPagePath)
def MainPageGenerator.getFiles (   filesPagePath)

Definition at line 40 of file MainPageGenerator.py.

Referenced by generateTreeViewPage().

40 def getFiles(filesPagePath):
41  data = {}
42  # read and parse files.html to get the file hierarchy
43  with open(filesPagePath) as f: page = f.read()
44  page = BeautifulSoup(page)
45  # please have a look at the files.html page to understand the approach.
46  # in short, we use number of '_' character in the id attr to read the
47  # file hierarchy.
48  table = page.find('table', {'class' : 'directory'})
49  level = 0
50  path = []
51  for row in table.findAll('tr'):
52  # first cell is the cell where the info is stored
53  id = row['id']; cell = row.find('td')
54  text = cell.text; url = '../' + cell.find('a')['href']
55  currentLevel = id.count('_')
56  # if current level is more than old one, push current item
57  if currentLevel > level:
58  path.append(text)
59  # if current level equals to old one, pop anmd push (replace)
60  elif currentLevel == level:
61  path.pop(len(path) - 1)
62  path.append(text)
63  else:
64  # if current level is less than old one, pop all items to blance
65  # the level. 'plus one' in the loop is to replace last item
66  for i in range(level - currentLevel + 1):
67  path.pop(len(path) - 1)
68  path.append(text)
69  level = id.count('_')
70  # skip files which are not interface
71  if not 'interface' in path: continue
72  # no need to have 'interface' node on the tree
73  pathWithoutInterface = copy.copy(path)
74  pathWithoutInterface.remove('interface')
75  # conver the path into tree structure
76  node = data
77  for i in pathWithoutInterface:
78  if not node.has_key(i):
79  node[i] = {}
80  node = node[i]
81  return data
82 
def getFiles(filesPagePath)
def MainPageGenerator.getPackages (   packagesPagePath)

Definition at line 83 of file MainPageGenerator.py.

References split.

Referenced by generateTreeViewPage().

83 def getPackages(packagesPagePath):
84  data = {}
85  with open(packagesPagePath) as f: page = f.read()
86  page = BeautifulSoup(page)
87  table = page.find('table', {'class' : 'directory'})
88  for row in table.findAll('tr'):
89  cell = row.find('td')
90  url = '../' + cell.find('a')['href']
91  # yeah, it is not that good method to parse a string but it is
92  # simple... please see the pages.html file.
93  pkg = cell.text.replace('Package ', '').split('/')
94  if not data.has_key(pkg[0]): data[pkg[0]] = {}
95  if len(pkg) == 2: data[pkg[0]][pkg[1]] = url
96  else: data[pkg[0]][pkg[0]] = url
97  return data
98 
def getPackages(packagesPagePath)
double split
Definition: MVATrainer.cc:139
def MainPageGenerator.prepareTemplate ( )

Definition at line 110 of file MainPageGenerator.py.

Referenced by generateTreeViewPage().

111  # please notice the following hard coded tags and class names, you may need
112  # to change them in future if doxygen changes its html output structure
113  header = htmlPage.find('div', {'class' : 'header'})
114  content = htmlPage.find('div', {'class' : 'contents'})
115 
116  for tag in header.findAll():
117  tag.extract()
118  for tag in content.findAll():
119  tag.extract()
120