Fixed stuff
This commit is contained in:
parent
c957c25307
commit
9dc820322c
|
@ -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">
|
||||
|
|
10
rst2atom.py
10
rst2atom.py
|
@ -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>")
|
||||
|
|
Loading…
Reference in New Issue