Fixed stuff

This commit is contained in:
Thomas Baruchel 2022-11-05 15:53:31 +01:00
parent c957c25307
commit 9dc820322c
2 changed files with 8 additions and 5 deletions

View File

@ -8,12 +8,13 @@
<email>baruchel@sdf.org</email>
</author>
<rights>CC BY-SA 4.0</rights>
<updated>2022-11-05T14:46:26.151657Z</updated>
<updated>2022-11-05T14:53:19.131349Z</updated>
<link href="https://git.sdf.org/baruchel/feeds/raw/branch/master/src/blog.rst" />
<link href="https://git.sdf.org/baruchel/feeds/raw/branch/master/atom/blog.xml" rel="self" />
<generator uri="https://git.sdf.org/baruchel/feeds/src/branch/master/rst2atom.py">rst2atom</generator>
<entry>
<id>https://git.sdf.org/baruchel/feeds/raw/branch/master/src/blog.rst#initial-entry</id>
<title>Initial entry</title>
<updated>2022-11-05T00:00:00Z</updated>
<content type="xhtml">

View File

@ -66,17 +66,19 @@ def find_date(d):
raise dateutil.parser.ParserError
def build_entry(d):
def build_entry(d, base_url):
"""
Print on stdout an Atom <entry> section built from the <div>.
"""
# Get the date
mydate = ""
mytitle = d.find("h1").text
try:
mydate = find_date(d)
except dateutil.parser.ParserError:
pass
print(""" <entry>
<id>%s</id>
<title>%s</title>
<updated>%s</updated>
<content type="xhtml">
@ -84,8 +86,8 @@ def build_entry(d):
</content>
</entry>
""" % (
d.find("h1").text,
mydate, d
base_url + "#" + mytitle.lower().replace(" ", "-"),
mytitle, mydate, d
))
@ -126,6 +128,6 @@ print("""<?xml version="1.0" encoding="utf-8"?>
for d in divs:
# don't handle subsections
if d.find_parent("div"): continue
build_entry(d)
build_entry(d, meta["original-source"])
print("</feed>")