CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Private Member Functions
Splitter.Splitter Class Reference

Splitter class is used for splitting class and namespace web pages to reduce access time. More...

Public Member Functions

def __init__
 
def Backup
 
def CreateFirstPage
 
def CreatePage
 
def CreatePages
 
def CreateTab
 
def GetContent
 
def GetDivHeader
 
def GetFooter
 
def GetHeader
 
def GetNsC
 
def WritePage
 

Public Attributes

 backupPrefix
 
 chr
 
 classImg
 
 contentPos
 
 contentStamp
 
 fileName
 
 filePath
 
 footerPos
 
 footerStamp
 
 headerPos
 
 headerStamp
 
 List
 
 minD
 
 namespaceImg
 
 parsedSource
 
 prefix
 
 source
 

Private Member Functions

def __GetDepth
 
def __GetInfo
 
def __GetLink
 
def __GetName
 
def __IsLink
 

Detailed Description

Splitter class is used for splitting class and namespace web pages to reduce access time.

Definition at line 5 of file Splitter.py.

Constructor & Destructor Documentation

def Splitter.Splitter.__init__ (   self,
  path,
  fileName,
  prefix 
)

Definition at line 9 of file Splitter.py.

9 
10  def __init__(self, path, fileName, prefix):
11  self.fileName = fileName
12  self.filePath = path
13  self.prefix = prefix
14 
15  self.backupPrefix= prefix + 'backup_'
16  self.headerStamp = '<div class="header">'
17  self.contentStamp= '<div class="contents">'
18  self.footerStamp = '<hr class="footer"/>'
19  self.namespaceImg= 'ftv2ns.png'
20  self.classImg = 'ftv2cl.png'
21 
22  #Min depth
23  self.minD = 2
24  self.chr = '_'
25  self.List = ()
26 
27  file = open(path + fileName, 'r')
28  self.source = file.read()
29  file.close()
30 
31  self.headerPos = self.source.find(self.headerStamp)
32  self.contentPos = self.source.find(self.contentStamp)
33  self.footerPos = self.source.find(self.footerStamp)
34 
35  self.parsedSource= None

Member Function Documentation

def Splitter.Splitter.__GetDepth (   self,
  node 
)
private
This method returns depth of the node. To determine this, '_' character is used.

Definition at line 86 of file Splitter.py.

References Splitter.Splitter.chr, prof2calltree.count, and Splitter.Splitter.minD.

Referenced by Splitter.Splitter.GetNsC().

86 
87  def __GetDepth(self, node):
88  """This method returns depth of the node. To determine this, '_' character is used."""
89  # <tr id="row_0_" ... It has two '_' character
90  # <tr id="row_0_0_" ... It has three '_' character
91  return node["id"].count(self.chr) - self.minD
def Splitter.Splitter.__GetInfo (   self,
  node 
)
private

Definition at line 71 of file Splitter.py.

Referenced by Splitter.Splitter.GetNsC().

71 
72  def __GetInfo(self, node):
73  if node.findAll("td", {"class":"desc"}):
74  return node.findAll("td", {"class":"desc"})[0].text
75  else:
76  return ""
def Splitter.Splitter.__GetLink (   self,
  node 
)
private
This method returns node link.

Definition at line 82 of file Splitter.py.

Referenced by Splitter.Splitter.GetNsC().

82 
83  def __GetLink(self, node):
84  """This method returns node link."""
85  return node.a['href']
def Splitter.Splitter.__GetName (   self,
  node 
)
private

Definition at line 63 of file Splitter.py.

Referenced by Splitter.Splitter.GetNsC().

63 
64  def __GetName(self, node):
65  if node.a:
66  return node.a.contents[0]
67  elif node.b:
68  return node.b.contents[0]
69  else:
70  return "---------"
def Splitter.Splitter.__IsLink (   self,
  node 
)
private
This method returns true if it has link.

Definition at line 77 of file Splitter.py.

References if().

Referenced by Splitter.Splitter.GetNsC().

77 
78  def __IsLink(self, node):
79  """This method returns true if it has link."""
80  if(node.a): return True
81  else: return False
if(conf.exists("allCellsPositionCalc"))
def Splitter.Splitter.Backup (   self)

Definition at line 55 of file Splitter.py.

References Splitter.Splitter.backupPrefix, ConfigFiles.ConfigFiles.CreateTab(), Splitter.Splitter.CreateTab(), Splitter.Splitter.fileName, WorkFlow.WorkFlowConnector.fileName, DTReadOutMappingHandler.fileName, DTStatusFlagHandler.fileName, DTMtimeHandler.fileName, DTT0Handler.fileName, DTDeadFlagHandler.fileName, DTTPGParametersHandler.fileName, DTTtrigHandler.fileName, DTRangeT0Handler.fileName, DTPerformanceHandler.fileName, EcalPnGraphs.fileName, ConfigBuilder.ConfigBuilder.fileName, Splitter.Splitter.GetContent(), Splitter.Splitter.GetDivHeader(), Splitter.Splitter.GetFooter(), Splitter.Splitter.GetHeader(), CocoaDaqRootEvent.GetHeader(), PackageSplitter.PackageSplitter.prefix, Splitter.Splitter.prefix, ConfigFiles.ConfigFiles.prefix, cond::PfnEditor.prefix, MuonGeometrySanityCheck.prefix, Splitter.Splitter.source, condformats_serialization_generate.SerializationCodeGenerator.source, BeautifulSoup.ResultSet.source, and Splitter.Splitter.WritePage().

Referenced by Splitter.Splitter.CreatePages().

55 
56  def Backup(self):
57  #backup
58  self.WritePage(self.backupPrefix + 'deep_' + self.fileName, self.source)
59 
60  #editted backup
61  edb = self.GetHeader() + self.CreateTab("All") + self.GetDivHeader() + self.GetContent() + self.GetFooter()
62  self.WritePage(self.prefix + '_ALL.html', edb)
def Splitter.Splitter.CreateFirstPage (   self,
  letter 
)

Definition at line 140 of file Splitter.py.

References Splitter.Splitter.CreatePage(), Splitter.Splitter.fileName, WorkFlow.WorkFlowConnector.fileName, DTPerformanceHandler.fileName, DTReadOutMappingHandler.fileName, DTTtrigHandler.fileName, DTRangeT0Handler.fileName, DTStatusFlagHandler.fileName, DTT0Handler.fileName, DTDeadFlagHandler.fileName, DTTPGParametersHandler.fileName, DTMtimeHandler.fileName, EcalPnGraphs.fileName, ConfigBuilder.ConfigBuilder.fileName, Splitter.Splitter.GetNsC(), Splitter.Splitter.parsedSource, and Splitter.Splitter.WritePage().

Referenced by Splitter.Splitter.CreatePages().

141  def CreateFirstPage(self, letter):
142  if not self.parsedSource:
143  self.parsedSource = self.GetNsC()
144  self.WritePage(self.fileName,
145  self.CreatePage(letter, self.parsedSource[letter]))
def Splitter.Splitter.CreatePage (   self,
  current,
  itemList 
)
This method creates web page.

Definition at line 115 of file Splitter.py.

References ConfigFiles.ConfigFiles.CreateTab(), Splitter.Splitter.CreateTab(), Splitter.Splitter.GetDivHeader(), Splitter.Splitter.GetFooter(), Splitter.Splitter.GetHeader(), and CocoaDaqRootEvent.GetHeader().

Referenced by Splitter.Splitter.CreateFirstPage(), and Splitter.Splitter.CreatePages().

116  def CreatePage(self, current, itemList):
117  """This method creates web page."""
118  data = ""
119  data = self.GetHeader()
120  data = data + self.CreateTab(current)
121  data = data + self.GetDivHeader()
122  data = data + '<div class="contents"><table width="100%">'
123 
124  for i in itemList:
125  data = data + '<tr><td class="indexkey"><a class="el" href="%s">%s</a></td><td class="indexvalue">%s</td></tr>\n' % i
126 
127  data = data + '</table></div>'
128  data = data + self.GetFooter()
129  return data
def Splitter.Splitter.CreatePages (   self)

Definition at line 130 of file Splitter.py.

References Splitter.Splitter.Backup(), Splitter.Splitter.CreateFirstPage(), Splitter.Splitter.CreatePage(), Splitter.Splitter.GetNsC(), Splitter.Splitter.parsedSource, PackageSplitter.PackageSplitter.prefix, Splitter.Splitter.prefix, ConfigFiles.ConfigFiles.prefix, cond::PfnEditor.prefix, MuonGeometrySanityCheck.prefix, and Splitter.Splitter.WritePage().

131  def CreatePages(self):
132  self.Backup()
133  self.CreateFirstPage('A')
134  if not self.parsedSource:
135  self.parsedSource = self.GetNsC()
136 
137  for i in self.parsedSource.keys():
138  print i, "is ok..."
139  self.WritePage("%s%s.html" % (self.prefix, i), self.CreatePage(i, self.parsedSource[i]))
def Splitter.Splitter.CreateTab (   self,
  current 
)

Definition at line 92 of file Splitter.py.

References Splitter.Splitter.GetNsC(), Splitter.Splitter.List, Splitter.Splitter.parsedSource, PackageSplitter.PackageSplitter.prefix, Splitter.Splitter.prefix, ConfigFiles.ConfigFiles.prefix, cond::PfnEditor.prefix, and MuonGeometrySanityCheck.prefix.

Referenced by Splitter.Splitter.Backup(), and Splitter.Splitter.CreatePage().

92 
93  def CreateTab(self, current):
94  # If source code was not parsed
95  if not self.parsedSource:
96  self.parsedSource = self.GetNsC()
97  header = '<div class="tabs3" align="center">\n<ul class="tablist">\n'
98  if current == "All":
99  all_ = '<li class="current"><a href="%s"><span>All</span></a></li>\n' % (self.prefix + '_ALL.html')
100  else:
101  all_ = '<li><a href="%s"><span>All</span></a></li>\n' % (self.prefix + '_ALL.html')
102  footer = '</ul>\n</div>\n'
103  tab = ''
104 
105  tab = header
106  for i in self.List:
107  if i != current:
108  tab = tab + u'<li><a href="%s"><span>%s</span></a></li>\n' % ("%s%s.html" % (self.prefix, i), i)
109  else:
110  tab = tab + u'<li class="current"><a href="%s"><span>%s</span></a></li>\n' % ("%s%s.html" % (self.prefix, current), i)
111 
112  tab = tab + all_ + footer
113 
114  return tab.encode("ascii")
def Splitter.Splitter.GetContent (   self)
This method returns content of the input page

Definition at line 46 of file Splitter.py.

References Splitter.Splitter.contentPos, Splitter.Splitter.footerPos, Splitter.Splitter.source, condformats_serialization_generate.SerializationCodeGenerator.source, and BeautifulSoup.ResultSet.source.

Referenced by Splitter.Splitter.Backup(), and Splitter.Splitter.GetNsC().

46 
47  def GetContent(self):
48  """This method returns content of the input page"""
49  return self.source[self.contentPos:self.footerPos]
def Splitter.Splitter.GetDivHeader (   self)

Definition at line 39 of file Splitter.py.

References Splitter.Splitter.contentPos, Splitter.Splitter.headerPos, Splitter.Splitter.source, condformats_serialization_generate.SerializationCodeGenerator.source, and BeautifulSoup.ResultSet.source.

Referenced by Splitter.Splitter.Backup(), and Splitter.Splitter.CreatePage().

39 
40  def GetDivHeader(self):
41  return self.source[self.headerPos:self.contentPos]
def Splitter.Splitter.GetFooter (   self)
This method returns footer of the input page

Definition at line 42 of file Splitter.py.

References Splitter.Splitter.footerPos, Splitter.Splitter.source, condformats_serialization_generate.SerializationCodeGenerator.source, and BeautifulSoup.ResultSet.source.

Referenced by Splitter.Splitter.Backup(), and Splitter.Splitter.CreatePage().

42 
43  def GetFooter(self):
44  """This method returns footer of the input page"""
45  return self.source[self.footerPos:len(self.source)]
def Splitter.Splitter.GetHeader (   self)

Definition at line 36 of file Splitter.py.

References Splitter.Splitter.headerPos, Splitter.Splitter.source, condformats_serialization_generate.SerializationCodeGenerator.source, and BeautifulSoup.ResultSet.source.

Referenced by Splitter.Splitter.Backup(), and Splitter.Splitter.CreatePage().

36 
37  def GetHeader(self):
38  return self.source[0:self.headerPos]
def Splitter.Splitter.GetNsC (   self)

Definition at line 146 of file Splitter.py.

References Splitter.Splitter.__GetDepth(), Splitter.Splitter.__GetInfo(), Splitter.Splitter.__GetLink(), Splitter.Splitter.__GetName(), Splitter.Splitter.__IsLink(), python.multivaluedict.append(), Splitter.Splitter.GetContent(), Splitter.Splitter.List, and pileupCalc.upper.

Referenced by Splitter.Splitter.CreateFirstPage(), Splitter.Splitter.CreatePages(), and Splitter.Splitter.CreateTab().

147  def GetNsC(self):
148  content = self.GetContent()
149  bs = BeautifulSoup(content)
150 
151  tr = bs.findAll("tr", {})
152  data = {}
153  path = {}
154 
155  #Structure of data variable:
156  # {letter:[(link, ::name, info), ...]}
157  #Example:
158  # {'G':[
159  # (grEng.html, 'GraphicEngine', ''),
160  # (grEngTerra.html, 'GraphicEngine::TerrainGenarator', ''),
161  # (grEngTerraGVC.html, 'GraphicEngine::TerrainGenarator::GetVerticesCount', ''),
162  # ],
163  # 'H':[...]
164  # }
165 
166  #Structure of path variable:
167  # {depth:node}
168  #Example:
169  # {0:'GraphicEngine',
170  # 1:'GraphicEngine::TerrainGenarator',
171  # 2:'GraphicEngine::TerrainGenarator::GetVerticesCount'}
172  for i in tr:
173  if self.__GetDepth(i) == 0:
174  path = {0:self.__GetName(i)}
175  else:
176  path[self.__GetDepth(i)] = path[self.__GetDepth(i) - 1] + "::" + self.__GetName(i)
177 
178  if self.__IsLink(i):
179  if not path[self.__GetDepth(i)][0].upper() in self.List:
180  self.List = self.List + (path[self.__GetDepth(i)][0].upper(), )
181  data[path[self.__GetDepth(i)][0].upper()] = []
182 
183  if not self.__GetName(i).upper()[0] in self.List:
184  data[self.__GetName(i)[0].upper()] = []
185 
186  if path[self.__GetDepth(i)] != self.__GetName(i):
187  data[path[self.__GetDepth(i)][0].upper()].append((self.__GetLink(i),
188  path[self.__GetDepth(i)],
189  self.__GetInfo(i)))
190  data[self.__GetName(i)[0].upper()].append((self.__GetLink(i),
191  self.__GetName(i),
192  self.__GetInfo(i)))
193 
194  return data
def Splitter.Splitter.WritePage (   self,
  fileName,
  data 
)

Definition at line 50 of file Splitter.py.

References Splitter.Splitter.filePath.

Referenced by Splitter.Splitter.Backup(), Splitter.Splitter.CreateFirstPage(), and Splitter.Splitter.CreatePages().

50 
51  def WritePage(self, fileName, data):
52  f = open(self.filePath + fileName, "w")
53  f.write(data)
54  f.close()

Member Data Documentation

Splitter.Splitter.backupPrefix

Definition at line 14 of file Splitter.py.

Referenced by Splitter.Splitter.Backup().

Splitter.Splitter.chr

Definition at line 23 of file Splitter.py.

Referenced by Splitter.Splitter.__GetDepth().

Splitter.Splitter.classImg

Definition at line 19 of file Splitter.py.

Splitter.Splitter.contentPos

Definition at line 31 of file Splitter.py.

Referenced by Splitter.Splitter.GetContent(), and Splitter.Splitter.GetDivHeader().

Splitter.Splitter.contentStamp

Definition at line 16 of file Splitter.py.

Splitter.Splitter.fileName

Definition at line 10 of file Splitter.py.

Referenced by Splitter.Splitter.Backup(), and Splitter.Splitter.CreateFirstPage().

Splitter.Splitter.filePath

Definition at line 11 of file Splitter.py.

Referenced by Splitter.Splitter.WritePage().

Splitter.Splitter.footerPos

Definition at line 32 of file Splitter.py.

Referenced by Splitter.Splitter.GetContent(), and Splitter.Splitter.GetFooter().

Splitter.Splitter.footerStamp

Definition at line 17 of file Splitter.py.

Splitter.Splitter.headerPos

Definition at line 30 of file Splitter.py.

Referenced by Splitter.Splitter.GetDivHeader(), and Splitter.Splitter.GetHeader().

Splitter.Splitter.headerStamp

Definition at line 15 of file Splitter.py.

Splitter.Splitter.List

Definition at line 24 of file Splitter.py.

Referenced by Splitter.Splitter.CreateTab(), and Splitter.Splitter.GetNsC().

Splitter.Splitter.minD

Definition at line 22 of file Splitter.py.

Referenced by Splitter.Splitter.__GetDepth().

Splitter.Splitter.namespaceImg

Definition at line 18 of file Splitter.py.

Splitter.Splitter.parsedSource

Definition at line 34 of file Splitter.py.

Referenced by Splitter.Splitter.CreateFirstPage(), Splitter.Splitter.CreatePages(), and Splitter.Splitter.CreateTab().

Splitter.Splitter.prefix

Definition at line 12 of file Splitter.py.

Referenced by Splitter.Splitter.Backup(), Splitter.Splitter.CreatePages(), and Splitter.Splitter.CreateTab().

Splitter.Splitter.source

Definition at line 27 of file Splitter.py.

Referenced by Splitter.Splitter.Backup(), Splitter.Splitter.GetContent(), Splitter.Splitter.GetDivHeader(), Splitter.Splitter.GetFooter(), and Splitter.Splitter.GetHeader().