7 from BeautifulSoup
import *
13 fileNameTemplate =
None
15 tableClassName =
'directory'
23 table = htmlPage.find(
'table', {
'class' : tableClassName})
24 for row
in table.findAll(
'tr'):
31 if row.has_key(
'style'): styleFlag =
True
33 if not styleFlag: firstLetter = row.findAll(
'td')[0].text[0].
upper()
35 if not pages.has_key(firstLetter):
36 pages[firstLetter] = []
39 url = row.find(
'a')[
'href']
40 if '_cff' in url
or '_cfi' in url
or '_cfg' in url:
41 pages[firstLetter].
append(row)
43 pages[firstLetter].
append(row)
51 table = htmlPage.find(
'table', {
'class' : tableClassName})
52 for row
in table.findAll(
'tr'):
54 name = row.findAll(
'td')[0].text
56 name = name[name.find(
' '):name.find(
'/')].strip()
58 if not pages.has_key(name): pages[name] = []
64 itemTagMap = {}; tab =
''
66 fn = fileNameTemplate % item.replace(
' ',
'_')
67 if item != curr: tab +=
'<li><a href="%s">%s</a></li>' % (fn, item)
68 else: tab +=
'<li class="current"><a href="%s">%s</a></li>'%(fn, item)
69 return '<div class="%s"><ul class="tablist">%s</ul></div>' % (tabClass,tab)
71 if __name__ ==
"__main__":
73 sys.stderr.write(
"not enough parameter!\n")
77 htmlFullPath = sys.argv[1]
78 htmlFilePath = os.path.split(htmlFullPath)[0]
79 htmlFileName = os.path.split(htmlFullPath)[1]
80 fileNameTemplate = htmlFileName.replace(
'.html',
'_%s.html')
83 with open(htmlFullPath)
as f:
93 if htmlFileName ==
'packageDocumentation.html':
95 destTabClassName =
'tabs'
96 elif htmlFileName ==
'configfiles.html':
98 destTabClassName =
'tabs2'
101 destTabClassName =
'tabs2'
104 pageNames = pages.keys(); pageNames.sort()
105 for page
in pageNames:
106 allRows = allRows + pages[page]
107 pages[
'All'] = allRows
108 pageNames.append(
'All')
111 table = htmlPage.find(
'table', {
'class' : tableClassName})
113 for row
in table.findAll(
'tr'):
117 for page
in pageNames:
118 print 'generating %s...' % (fileNameTemplate % page)
120 table = temp.find(
'table', {
'class' : tableClassName})
121 oldTab = temp.find(
'div', {
'class' : destTabClassName})
123 oldTab.replaceWith(
BeautifulSoup(oldTab.prettify() + str(newTab)))
124 for row
in pages[page]:
128 page = page.replace(
' ',
'_')
129 with open(
'%s/%s'%(htmlFilePath, fileNameTemplate % page),
'w')
as f:
def extractPagesForPackage