Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
 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