diff options
Diffstat (limited to 'mkfeed.py')
| -rwxr-xr-x | mkfeed.py | 28 | 
1 files changed, 19 insertions, 9 deletions
| @@ -24,9 +24,11 @@ for filename in sorted(os.listdir(OUTDIR), reverse=True):      tree = ET.parse(OUTDIR + filename + '/index.html').getroot()      title = tree.find('.//title')      data = dict( -        title = escape(title.text), -        html = ''.join(ET.tostring(c, 'unicode') for c in tree.find('.//div[@id="content"]')), -        path = DIR + escape(filename) +        title=escape(title.text), +        html=''.join( +            ET.tostring(c, 'unicode') for c in tree.find('.//div[@id="content"]') +        ), +        path=DIR + escape(filename),      )      dataEl = tree.find('.//meta[@name="dcterms.date"]')      if dataEl is not None: @@ -39,14 +41,19 @@ for filename in sorted(os.listdir(OUTDIR), reverse=True):  last_updated = max([p['dateMeta'] for p in posts if 'dateMeta' in p])  with open(OUTDIR + 'index.html', 'w') as f: -    f.write(f'<h2>{escape(DIRNAME.title())} <a href="{escape(DIR)}atom.xml" style="vertical-align:top">{FEED_SVG}</a></h2>') +    f.write( +        f'<h2>{escape(DIRNAME.title())} <a href="{escape(DIR)}atom.xml" style="vertical-align:top">{FEED_SVG}</a></h2>' +    )      f.write('<ul class="mkfeed-list">')      for post in posts: -        f.write(f"<li>{post.get('date')}: <a href=\"{post['path']}\">{post['title']}</a></li>") +        f.write( +            f"<li>{post.get('date')}: <a href=\"{post['path']}\">{post['title']}</a></li>" +        )      f.write('</ul>')  with open(OUTDIR + 'atom.xml', 'w') as f: -    f.write(f'''\ +    f.write( +        f'''\  <?xml version="1.0" encoding="utf-8"?>  <feed xmlns="http://www.w3.org/2005/Atom"> @@ -54,9 +61,11 @@ with open(OUTDIR + 'atom.xml', 'w') as f:   <title>{TITLE}</title>   <link href="{URL}"/>   <updated>{last_updated}</updated> -    ''') +    ''' +    )      for post in posts[:10]: -        f.write(f''' +        f.write( +            f'''           <entry>             <title>{post['title']}</title>             <link href="{URL.rstrip('/')}{post['path']}"/> @@ -64,5 +73,6 @@ with open(OUTDIR + 'atom.xml', 'w') as f:             <updated>{post.get('dateMeta')}</updated>             <content type="html"><![CDATA[{post['html']}]]></content>           </entry> -        ''') +        ''' +        )      f.write('</feed>') | 
