Ejemplo n.º 1
0
 def load_feeds_infos( self, url ):
     try:
         html = urllib.urlopen( url )
         if "code.google" in url:
             source = html.read()
             parsed = HTB.parse( StringIO( source ), "utf-8"  ).findall( self.tags[ 1 ] )
         else:
             source = re.sub( "<!\[CDATA\[|\]\]>", "", html.read() )
             parsed = HTB.parse( StringIO( source ), "utf-8"  ).findall( self.tags[ 0 ] )[ 0 ].findall( self.tags[ 1 ] )
         html.close()
         return parsed
     except:
         print_exc()
Ejemplo n.º 2
0
 def generateTitle(self):
     try:
         tree = HTMLTreeBuilder.parse(StringIO(self.input), encoding='utf8')
         result = tree.findtext("head/title")
     except Exception:
         result = None
     return result or self.context.Title()
Ejemplo n.º 3
0
def load_infos( url, onerror=True ):
    try:
        html = PassionXBMC.get_page( url )
        source = re.sub( "<!\[CDATA\[|\]\]>", "", html )
        return HTB.parse( StringIO( source ), "utf-8"  ).findall( "channel" )[ 0 ]
    except:
        if onerror:
            print_exc()
Ejemplo n.º 4
0
def kidified_rest(rest_file, template_name):
    xhtml_file = StringIO()
    # prevent docutils from autoclosing the StringIO
    xhtml_file.close = lambda: None
    xhtml = publish_file(rest_file,
                         writer_name='html',
                         destination=xhtml_file,
                         settings_overrides={"doctitle_xform": 0})
    xhtml_file.seek(0)
    xml = HTMLTreeBuilder.parse(xhtml_file)
    head = xml.find('head')
    body = xml.find('body')
    assert head is not None
    assert body is not None
    template = kid.Template(file=template_name, head=head, body=body)
    return (template.serialize(output="html"))
Ejemplo n.º 5
0
def kidified_rest(rest_file, template_name):
    xhtml_file = StringIO()
    # prevent docutils from autoclosing the StringIO
    xhtml_file.close = lambda: None
    xhtml = publish_file(rest_file, writer_name='html', destination=xhtml_file,
                         settings_overrides={"doctitle_xform": 0} 
    
    )
    xhtml_file.seek(0)
    xml = HTMLTreeBuilder.parse(xhtml_file)
    head = xml.find('head')
    body = xml.find('body')
    assert head is not None
    assert body is not None
    template=kid.Template(file=template_name, 
                          head=head, body=body)
    return (template.serialize(output="html"))