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
PackageSplitter.PackageSplitter Class Reference

PackageSplitter class is used for splitting package web page (pages.html) to increase usability. More...

Public Member Functions

def __init__
 Constructor method. More...
 
def AddTab2Page
 
def CreatePackagePage
 
def CreateSubPage
 
def GenerateTab
 
def PrepareData
 
def ReadFile
 
def WriteFile
 

Public Attributes

 data
 
 packages
 
 packageSource
 
 path
 
 prefix
 
 tr
 

Private Member Functions

def __GetFileName
 
def __GetPackageName
 

Detailed Description

PackageSplitter class is used for splitting package web page (pages.html) to increase usability.

Definition at line 5 of file PackageSplitter.py.

Constructor & Destructor Documentation

def PackageSplitter.PackageSplitter.__init__ (   self,
  path,
  prefix = 'package_' 
)

Constructor method.

Parameters
pathis the reference manual directory path and it is used as destination and source.
prefixis used for file naming as prefix.

Definition at line 9 of file PackageSplitter.py.

9 
10  def __init__(self, path, prefix = 'package_'):
11  self.path = path
12  self.prefix = prefix
13  self.packageSource = self.ReadFile('pages.html')
14  self.WriteFile('pages_backup.html', self.packageSource)
15  self.packages = {}
16  self.data = None
def __init__
Constructor method.

Member Function Documentation

def PackageSplitter.PackageSplitter.__GetFileName (   self,
  str_ 
)
private

Definition at line 42 of file PackageSplitter.py.

References PackageSplitter.PackageSplitter.prefix, ConfigFiles.ConfigFiles.prefix, cond::PfnEditor.prefix, and MuonGeometrySanityCheck.prefix.

Referenced by PackageSplitter.PackageSplitter.CreateSubPage(), and PackageSplitter.PackageSplitter.GenerateTab().

42 
43  def __GetFileName(self, str_):
44  return self.prefix + str_.replace(' ', '_') + '.html'
def PackageSplitter.PackageSplitter.__GetPackageName (   self,
  str_ 
)
private

Definition at line 36 of file PackageSplitter.py.

36 
37  def __GetPackageName(self, str_):
38  if str_.find('/') != -1:
39  return str_[0:str_.find('/')]
40  else:
41  return str_
def PackageSplitter.PackageSplitter.AddTab2Page (   self,
  packageLink 
)

Definition at line 115 of file PackageSplitter.py.

References PackageSplitter.PackageSplitter.GenerateTab(), PackageSplitter.PackageSplitter.ReadFile(), ConfigFiles.ConfigFiles.ReadFile(), MainPageGenerator.MainPageGenerator.ReadFile(), python.rootplot.root2matplotlib.replace(), PackageSplitter.PackageSplitter.WriteFile(), ConfigFiles.ConfigFiles.WriteFile(), and MainPageGenerator.MainPageGenerator.WriteFile().

Referenced by PackageSplitter.PackageSplitter.CreatePackagePage().

116  def AddTab2Page(self, packageLink):
117  tabHTML = self.GenerateTab(linkPrefix = "../../")
118 
119  orgSource = self.ReadFile(packageLink)
120 
121  soup = BeautifulSoup(orgSource)
122  tab = soup.find('ul', { "class" : "tablist" })
123  tab.replaceWith(tab.prettify() + tabHTML)
124  data = str(soup.prettify())
125  self.WriteFile(packageLink, data.replace('&lt;','<').replace('&gt;', '>'))
def PackageSplitter.PackageSplitter.CreatePackagePage (   self,
  outputFile 
)

Definition at line 93 of file PackageSplitter.py.

References PackageSplitter.PackageSplitter.AddTab2Page(), PackageSplitter.PackageSplitter.CreateSubPage(), PackageSplitter.PackageSplitter.data, CombinedSVCalibration.data, CombinedTauTagCalibration.data, TrackProbabilityCalibration.data, ElectronLikelihoodCalibration.data, python.multivaluedict.MyUserList.data, ConfigFiles.ConfigFiles.data, CondIter< DataT >.data, MainPageGenerator.MainPageGenerator.data, LASModuleProfile.data, comparisonPlots.data, cond::IOVProxyData.data, BaseMETv0.data, TkLasBeam.data, EcalGlobalShowerContainmentCorrectionsVsEta::Coefficients.data, edm::MapOfVectors< K, T >::Iter.data, edm::DetSet< T >.data, EcalShowerContainmentCorrections::Coefficients.data, python.DBCopy.DBCopy.data, PackageSplitter.PackageSplitter.GenerateTab(), PackageSplitter.PackageSplitter.packageSource, MainPageGenerator.MainPageGenerator.packageSource, ConfigFiles.ConfigFiles.PrepareData(), PackageSplitter.PackageSplitter.PrepareData(), MainPageGenerator.MainPageGenerator.PrepareData(), python.rootplot.root2matplotlib.replace(), PackageSplitter.PackageSplitter.WriteFile(), ConfigFiles.ConfigFiles.WriteFile(), and MainPageGenerator.MainPageGenerator.WriteFile().

93 
94  def CreatePackagePage(self, outputFile):
95  if not self.data:
96  self.PrepareData()
97 
98  html = self.GenerateTab()
99 
100  temp = copy.deepcopy(self.packageSource)
101  soup = BeautifulSoup(temp)
102  tab = soup.find('ul', { "class" : "tablist" })
103  tab.replaceWith(tab.prettify() + html)
104 
105  data = str(soup.prettify())
106 
107  self.WriteFile(outputFile, data.replace('&lt;','<').replace('&gt;', '>'))
108 
109  for i in self.data:
110  self.CreateSubPage(i)
111 
112  for i in self.data:
113  for j in self.data[i]:
114  self.AddTab2Page(self.data[i][j])
def PackageSplitter.PackageSplitter.CreateSubPage (   self,
  packageName 
)

Definition at line 61 of file PackageSplitter.py.

References PackageSplitter.PackageSplitter.__GetFileName(), PackageSplitter.PackageSplitter.data, CombinedSVCalibration.data, CombinedTauTagCalibration.data, TrackProbabilityCalibration.data, ElectronLikelihoodCalibration.data, python.multivaluedict.MyUserList.data, ConfigFiles.ConfigFiles.data, CondIter< DataT >.data, MainPageGenerator.MainPageGenerator.data, LASModuleProfile.data, comparisonPlots.data, cond::IOVProxyData.data, BaseMETv0.data, TkLasBeam.data, EcalGlobalShowerContainmentCorrectionsVsEta::Coefficients.data, edm::MapOfVectors< K, T >::Iter.data, edm::DetSet< T >.data, EcalShowerContainmentCorrections::Coefficients.data, python.DBCopy.DBCopy.data, PackageSplitter.PackageSplitter.GenerateTab(), relativeConstraints.keys, PackageSplitter.PackageSplitter.packageSource, MainPageGenerator.MainPageGenerator.packageSource, ConfigFiles.ConfigFiles.PrepareData(), PackageSplitter.PackageSplitter.PrepareData(), MainPageGenerator.MainPageGenerator.PrepareData(), python.rootplot.root2matplotlib.replace(), PackageSplitter.PackageSplitter.WriteFile(), ConfigFiles.ConfigFiles.WriteFile(), and MainPageGenerator.MainPageGenerator.WriteFile().

Referenced by PackageSplitter.PackageSplitter.CreatePackagePage().

61 
62  def CreateSubPage(self, packageName):
63  if not self.data:
64  self.PrepareData()
65  tab = self.GenerateTab(current = packageName)
66  counter = 0
67  htmlList = '<table class="directory">\n<tbody>\n'
68  keysI = self.data[packageName].keys()
69  keysI.sort()
70  for i in keysI:
71  if counter % 2 == 0:
72  htmlList += '<tr id="row_%d_" class="even">\n' % counter
73  else:
74  htmlList += '<tr id="row_%d_">\n' % counter
75  htmlList += '<td class="entry">\n<img src="ftv2node.png" alt="o" width="16" height="22">\n'
76  htmlList += '<a class="el" href="%s" target="_self">%s</a>\n' % (self.data[packageName][i], i)
77  htmlList += '</td>\n<td class="desc">\n</td>\n</tr>\n'
78 
79  counter += 1
80  htmlList += '</tbody>\n</table>\n'
81 
82  temp = copy.deepcopy(self.packageSource)
83  soup = BeautifulSoup(temp)
84  list_ = soup.find('div', { "class" : "directory" })
85  list_.replaceWith(htmlList)
86 
87  tab_ = soup.find('ul', { "class" : "tablist" })
88  tab_.replaceWith(tab_.prettify() + tab)
89 
90  data = str(soup.prettify())
91 
92  self.WriteFile(self.__GetFileName(packageName), data.replace('&lt;','<').replace('&gt;', '>'))
def PackageSplitter.PackageSplitter.GenerateTab (   self,
  current = None,
  linkPrefix = "" 
)

Definition at line 45 of file PackageSplitter.py.

References PackageSplitter.PackageSplitter.__GetFileName().

Referenced by PackageSplitter.PackageSplitter.AddTab2Page(), PackageSplitter.PackageSplitter.CreatePackagePage(), and PackageSplitter.PackageSplitter.CreateSubPage().

45 
46  def GenerateTab(self, current = None, linkPrefix = ""):
47  html = '<div class="tabs3">\n<ul class="tablist">\n'
48 
49  keys = self.data.keys()
50  keys.sort()
51 
52  for i in keys:
53  if i == current:
54  html += '<li class="current"><a href="%s"><span>%s</span></a></li>\n' % (linkPrefix + self.__GetFileName(i), i)
55  else:
56  html += '<li><a href="%s"><span>%s</span></a></li>\n' % (linkPrefix + self.__GetFileName(i), i)
57 
58  html += '</ul>\n</div>'
59 
60  return html
def PackageSplitter.PackageSplitter.PrepareData (   self)

Definition at line 126 of file PackageSplitter.py.

References PackageSplitter.PackageSplitter.packageSource, and MainPageGenerator.MainPageGenerator.packageSource.

Referenced by PackageSplitter.PackageSplitter.CreatePackagePage(), and PackageSplitter.PackageSplitter.CreateSubPage().

127  def PrepareData(self):
128  soup = BeautifulSoup(self.packageSource)
129  contents = soup.find("div", { "class" : "contents" })
130  self.tr = contents.findAll("tr", {})
131 
132  for i in self.tr:
133  self.packages[i.text] = i.a["href"]
134 
135  self.data = {}
136 
137  for i in self.packages:
138  if not "Package" in i:
139  continue
140  if not self.data.has_key(self.__GetPackageName(i).replace(u'Package ', u'')):
141  self.data[self.__GetPackageName(i).replace(u'Package ', u'')] = {}
142 
143  self.data[self.__GetPackageName(i).replace(u'Package ', u'')][i] = self.packages[i]
144 
def PackageSplitter.PackageSplitter.ReadFile (   self,
  fileName,
  pathFlag = True 
)
This method reads file directly or from path.

Definition at line 17 of file PackageSplitter.py.

References PackageSplitter.PackageSplitter.path, ConfigFiles.ConfigFiles.path, MainPageGenerator.MainPageGenerator.path, and ConfigBuilder.ConfigBuilder.path.

Referenced by PackageSplitter.PackageSplitter.AddTab2Page().

17 
18  def ReadFile(self, fileName, pathFlag = True):
19  """This method reads file directly or from path."""
20  if pathFlag:
21  print "Read:", self.path + fileName
22  f = open(self.path + fileName)
23  else:
24  f = open(fileName)
25  print "Read:", fileName
26  data = f.read()
27  f.close()
28  return data
def PackageSplitter.PackageSplitter.WriteFile (   self,
  fileName,
  data 
)
This method writes data

Definition at line 29 of file PackageSplitter.py.

References PackageSplitter.PackageSplitter.path, ConfigFiles.ConfigFiles.path, MainPageGenerator.MainPageGenerator.path, and ConfigBuilder.ConfigBuilder.path.

Referenced by PackageSplitter.PackageSplitter.AddTab2Page(), PackageSplitter.PackageSplitter.CreatePackagePage(), and PackageSplitter.PackageSplitter.CreateSubPage().

29 
30  def WriteFile(self, fileName, data):
31  """This method writes data"""
32  print "Write:", self.path + fileName
33  f = open(self.path + fileName, "w")
34  f.write(data)
35  f.close()

Member Data Documentation

PackageSplitter.PackageSplitter.data

Definition at line 15 of file PackageSplitter.py.

Referenced by cuy.FindIssue.__init__(), PackageSplitter.PackageSplitter.CreatePackagePage(), PackageSplitter.PackageSplitter.CreateSubPage(), confdb.HLTProcess.customize(), confdb.HLTProcess.dump(), confdb.HLTProcess.getRawConfigurationFromDB(), and confdb.HLTProcess.releaseSpecificCustomize().

PackageSplitter.PackageSplitter.packages

Definition at line 14 of file PackageSplitter.py.

PackageSplitter.PackageSplitter.packageSource

Definition at line 12 of file PackageSplitter.py.

Referenced by PackageSplitter.PackageSplitter.CreatePackagePage(), PackageSplitter.PackageSplitter.CreateSubPage(), and PackageSplitter.PackageSplitter.PrepareData().

PackageSplitter.PackageSplitter.path

Definition at line 10 of file PackageSplitter.py.

Referenced by python.rootplot.rootmath.Target.__repr__(), PackageSplitter.PackageSplitter.ReadFile(), and PackageSplitter.PackageSplitter.WriteFile().

PackageSplitter.PackageSplitter.prefix

Definition at line 11 of file PackageSplitter.py.

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

PackageSplitter.PackageSplitter.tr

Definition at line 129 of file PackageSplitter.py.