Fixed stuff
This commit is contained in:
parent
c957c25307
commit
9dc820322c
|
@ -8,12 +8,13 @@
|
||||||
<email>baruchel@sdf.org</email>
|
<email>baruchel@sdf.org</email>
|
||||||
</author>
|
</author>
|
||||||
<rights>CC BY-SA 4.0</rights>
|
<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/src/blog.rst" />
|
||||||
<link href="https://git.sdf.org/baruchel/feeds/raw/branch/master/atom/blog.xml" rel="self" />
|
<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>
|
<generator uri="https://git.sdf.org/baruchel/feeds/src/branch/master/rst2atom.py">rst2atom</generator>
|
||||||
|
|
||||||
<entry>
|
<entry>
|
||||||
|
<id>https://git.sdf.org/baruchel/feeds/raw/branch/master/src/blog.rst#initial-entry</id>
|
||||||
<title>Initial entry</title>
|
<title>Initial entry</title>
|
||||||
<updated>2022-11-05T00:00:00Z</updated>
|
<updated>2022-11-05T00:00:00Z</updated>
|
||||||
<content type="xhtml">
|
<content type="xhtml">
|
||||||
|
|
10
rst2atom.py
10
rst2atom.py
|
@ -66,17 +66,19 @@ def find_date(d):
|
||||||
raise dateutil.parser.ParserError
|
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>.
|
Print on stdout an Atom <entry> section built from the <div>.
|
||||||
"""
|
"""
|
||||||
# Get the date
|
# Get the date
|
||||||
mydate = ""
|
mydate = ""
|
||||||
|
mytitle = d.find("h1").text
|
||||||
try:
|
try:
|
||||||
mydate = find_date(d)
|
mydate = find_date(d)
|
||||||
except dateutil.parser.ParserError:
|
except dateutil.parser.ParserError:
|
||||||
pass
|
pass
|
||||||
print(""" <entry>
|
print(""" <entry>
|
||||||
|
<id>%s</id>
|
||||||
<title>%s</title>
|
<title>%s</title>
|
||||||
<updated>%s</updated>
|
<updated>%s</updated>
|
||||||
<content type="xhtml">
|
<content type="xhtml">
|
||||||
|
@ -84,8 +86,8 @@ def build_entry(d):
|
||||||
</content>
|
</content>
|
||||||
</entry>
|
</entry>
|
||||||
""" % (
|
""" % (
|
||||||
d.find("h1").text,
|
base_url + "#" + mytitle.lower().replace(" ", "-"),
|
||||||
mydate, d
|
mytitle, mydate, d
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,6 +128,6 @@ print("""<?xml version="1.0" encoding="utf-8"?>
|
||||||
for d in divs:
|
for d in divs:
|
||||||
# don't handle subsections
|
# don't handle subsections
|
||||||
if d.find_parent("div"): continue
|
if d.find_parent("div"): continue
|
||||||
build_entry(d)
|
build_entry(d, meta["original-source"])
|
||||||
|
|
||||||
print("</feed>")
|
print("</feed>")
|
||||||
|
|
Loading…
Reference in New Issue