1 from BeautifulSoup
import *
9 def __init__(self, path, prefix = 'package_'):
18 """This method reads file directly or from path."""
20 print "Read:", self.
path + fileName
21 f = open(self.
path + fileName)
24 print "Read:", fileName
30 """This method writes data"""
31 print "Write:", self.
path + fileName
32 f = open(self.
path + fileName,
"w")
37 if str_.find(
'/') != -1:
38 return str_[0:str_.find(
'/')]
43 return self.
prefix + str_.replace(
' ',
'_') +
'.html'
46 html =
'<div class="tabs3">\n<ul class="tablist">\n'
48 keys = self.data.keys()
53 html +=
'<li class="current"><a href="%s"><span>%s</span></a></li>\n' % (linkPrefix + self.
__GetFileName(i), i)
55 html +=
'<li><a href="%s"><span>%s</span></a></li>\n' % (linkPrefix + self.
__GetFileName(i), i)
57 html +=
'</ul>\n</div>'
66 htmlList =
'<table class="directory">\n<tbody>\n'
67 keysI = self.
data[packageName].
keys()
71 htmlList +=
'<tr id="row_%d_" class="even">\n' % counter
73 htmlList +=
'<tr id="row_%d_">\n' % counter
74 htmlList +=
'<td class="entry">\n<img src="ftv2node.png" alt="o" width="16" height="22">\n'
75 htmlList +=
'<a class="el" href="%s" target="_self">%s</a>\n' % (self.
data[packageName][i], i)
76 htmlList +=
'</td>\n<td class="desc">\n</td>\n</tr>\n'
79 htmlList +=
'</tbody>\n</table>\n'
83 list_ = soup.find(
'div', {
"class" :
"directory" })
84 list_.replaceWith(htmlList)
86 tab_ = soup.find(
'ul', {
"class" :
"tablist" })
87 tab_.replaceWith(tab_.prettify() + tab)
89 data = str(soup.prettify())
101 tab = soup.find(
'ul', {
"class" :
"tablist" })
102 tab.replaceWith(tab.prettify() + html)
104 data = str(soup.prettify())
112 for j
in self.
data[i]:
118 orgSource = self.
ReadFile(packageLink)
121 tab = soup.find(
'ul', {
"class" :
"tablist" })
122 tab.replaceWith(tab.prettify() + tabHTML)
123 data = str(soup.prettify())
128 contents = soup.find(
"div", {
"class" :
"contents" })
129 self.
tr = contents.findAll(
"tr", {})
137 if not "Package" in i:
145 if len(sys.argv) == 4:
152 l.CreatePackagePage(OUTF)
154 print "parameter error. It must be like this:\nrun.py CMSSW/doc/html/ INPUT_FILE PREFIX\nExample: PackageSplitter.py OUTPUT_PATH/ pages.html packageDocumentation_"
PackageSplitter class is used for splitting package web page (pages.html) to increase usability...
def __init__
Constructor method.