def tostatic(self, file=None): self._exports = {} if file: self._doc = nr.parseUri(file) stripws(self._doc) names = [getname(i) for i in tags(self._doc, psins, rsrc)] classes = [getclass(i) for i in tags(self._doc, psins, rsrc)] self._unexpanded = [i for i in tags(self._doc, psins, rsrc) if getclass(i) in names] self._templates = [i for i in tags(self._doc, psins, rsrc) if getname(i) in classes] self._expandTemplates() self._expandResources() self._exportResources()
def htmldom(file): htmlstring = tidy(open(file, 'rb').read(), output_xhtml=1, wrap=0)[2] htmldom = nr.parseString(htmlstring, htmlns) stripws(htmldom) htmldom.normalize() return htmldom