import re import sys fileToUpdate = sys.argv[1] print(fileToUpdate) nodeOpenName="22222" nodeCloseName="44444" def cascadeStylingIncludes(): templateSectionBegin="" templateSectionEnd="" with open('templates/head.template') as templateFile: substitutionContent = templateFile.read() with open(fileToUpdate) as targetSubstitutionFile: s = targetSubstitutionFile.read() ddd=s ddd=re.sub(templateSectionBegin, templateSectionBegin+nodeOpenName, ddd, flags=re.DOTALL) ddd=re.sub(templateSectionEnd, nodeCloseName+templateSectionEnd, ddd, flags=re.DOTALL) ddd=re.sub(nodeOpenName+".*"+nodeCloseName,substitutionContent,ddd,flags=re.DOTALL) f = open(fileToUpdate, "w") f.write(ddd) f.close() def cascadeJavascriptIncludes(): templateSectionBegin="" templateSectionEnd="" with open('templates/body-javascript-includes.template') as templateFile: substitutionContent = templateFile.read() with open(fileToUpdate) as targetSubstitutionFile: s = targetSubstitutionFile.read() ddd=s ddd=re.sub(templateSectionBegin, templateSectionBegin+nodeOpenName, ddd, flags=re.DOTALL) ddd=re.sub(templateSectionEnd, nodeCloseName+templateSectionEnd, ddd, flags=re.DOTALL) ddd=re.sub(nodeOpenName+".*"+nodeCloseName,substitutionContent,ddd,flags=re.DOTALL) f = open(fileToUpdate, "w") f.write(ddd) f.close() def cascadeFooterContent(): templateSectionBegin="" templateSectionEnd="" with open('templates/body-footer-content.template') as templateFile: substitutionContent = templateFile.read() with open(fileToUpdate) as targetSubstitutionFile: s = targetSubstitutionFile.read() ddd=s ddd=re.sub(templateSectionBegin, templateSectionBegin+nodeOpenName, ddd, flags=re.DOTALL) ddd=re.sub(templateSectionEnd, nodeCloseName+templateSectionEnd, ddd, flags=re.DOTALL) ddd=re.sub(nodeOpenName+".*"+nodeCloseName,substitutionContent,ddd,flags=re.DOTALL) f = open(fileToUpdate, "w") f.write(ddd) f.close() def cascadeTopNavigation(): templateSectionBegin="" templateSectionEnd=" " with open('templates/navigation-top-menu.template') as templateFile: substitutionContent = templateFile.read() with open(fileToUpdate) as targetSubstitutionFile: s = targetSubstitutionFile.read() ddd=s ddd=re.sub(templateSectionBegin, templateSectionBegin+nodeOpenName, ddd, flags=re.DOTALL) ddd=re.sub(templateSectionEnd, nodeCloseName+templateSectionEnd, ddd, flags=re.DOTALL) ddd=re.sub(nodeOpenName+".*"+nodeCloseName,substitutionContent,ddd,flags=re.DOTALL) f = open(fileToUpdate, "w") f.write(ddd) f.close() def cascadeSideNavigation(): templateSectionBegin="" templateSectionEnd="" with open('templates/navigation-side-menu.template') as templateFile: substitutionContent = templateFile.read() with open(fileToUpdate) as targetSubstitutionFile: s = targetSubstitutionFile.read() ddd=s ddd=re.sub(templateSectionBegin, templateSectionBegin+nodeOpenName, ddd, flags=re.DOTALL) ddd=re.sub(templateSectionEnd, nodeCloseName+templateSectionEnd, ddd, flags=re.DOTALL) ddd=re.sub(nodeOpenName+".*"+nodeCloseName,substitutionContent,ddd,flags=re.DOTALL) f = open(fileToUpdate, "w") f.write(ddd) f.close() def cascadeFlyoutContent(): templateSectionBegin="" templateSectionEnd="" with open('templates/body-flyout-content.template') as templateFile: substitutionContent = templateFile.read() with open(fileToUpdate) as targetSubstitutionFile: s = targetSubstitutionFile.read() ddd=s ddd=re.sub(templateSectionBegin, templateSectionBegin+nodeOpenName, ddd, flags=re.DOTALL) ddd=re.sub(templateSectionEnd, nodeCloseName+templateSectionEnd, ddd, flags=re.DOTALL) ddd=re.sub(nodeOpenName+".*"+nodeCloseName,substitutionContent,ddd,flags=re.DOTALL) f = open(fileToUpdate, "w") f.write(ddd) f.close() ################################################################### ## ## driver ## ################################################################### cascadeStylingIncludes() ##cascadeJavascriptIncludes() ##cascadeFooterContent() ##cascadeTopNavigation() ##cascadeSideNavigation() ##cascadeFlyoutContent() ##updateSideBarDesktop() ##updateSideBarMobile()