#!/usr/bin/env python
import os, shutil, re
outputDir = os.environ['VPWebExportOutputDirectory']
filePath = os.path.join(outputDir, 'index.html')
contents = file(filePath, 'r').read().replace('<!-- insert apple title here -->', '<meta name="AppleTitle" content="Changes Help" />').replace('<!-- insert apple icon here -->', '<meta name="AppleIcon" content="Changes Help/app_icon_16.png" />')
file(filePath,'w').write(contents)
for root, dirs, files in os.walk(outputDir):
filteredFN = [os.path.join(root, elem) for elem in files if elem.endswith('.html')]
for fileFn in filteredFN:
fileContents = file(fileFn, 'r')
newLineCollection = []
for line in fileContents:
m = re.search('\<p class="\w+"\>\$\$(\w+)\$\$\<\/p\>', line)
if m:
newLineCollection.append( '<a name="%s"></a>' % m.group(1) )
else:
newLineCollection.append(line[:-1])
newFileContents = '\n'.join(newLineCollection)
fileContents.close()
file(fileFn, 'w').write(newFileContents)
shutil.copyfile('/Volumes/Data/SharewareProjects/ChangesAppProj/Changes/Artwork/New Changes Icon/16.png', os.path.join(outputDir,'app_icon_16.png'))