def get(key, lang): fn = os.path.basename(key) + '.' + lang + '.html' filename = util.get_path('page', fn) if filename is None: return None try: root = parse(filename) except IOError: return None try: body = root.find('.//body') title = root.find('.//title').text except AttributeError: log.debug(u'Failed to parse static document ' + filename) return None body.tag = 'span' return FileStaticPage(key, lang, tostring(body), title)
def get(key, languages): for lang in languages: fn = key + "." + lang + ".html" filename = util.get_path("page", fn) if filename is not None: try: root = parse(filename) except IOError: return None try: body = root.find(".//body") title = root.find(".//title").text except AttributeError: log.debug(u"Failed to parse static document " + filename) return None body.tag = "span" return FileStaticPage(key, lang, tostring(body), title) return None
def _lookup_lang(self, lang): fmt = self.name + '.%s' + self.SUFFIX path = util.get_path(self.DIR, fmt % lang) if path is not None and os.path.exists(path): return self._load(path) return None