Remove intermediary list
This commit is contained in:
parent
cf616b1d09
commit
17e046bf2f
|
@ -17,10 +17,7 @@ description = ElementTree.SubElement(channel, 'description')
|
||||||
description.text = 'just a showcase of software being broken :)'
|
description.text = 'just a showcase of software being broken :)'
|
||||||
language = ElementTree.SubElement(channel, 'language')
|
language = ElementTree.SubElement(channel, 'language')
|
||||||
language.text = 'en-us'
|
language.text = 'en-us'
|
||||||
items = []
|
def parse_file(i):
|
||||||
for i in os.listdir('.'):
|
|
||||||
if i in ('index.html', 'index.xml'):
|
|
||||||
continue
|
|
||||||
with open(i) as file:
|
with open(i) as file:
|
||||||
soup = BeautifulSoup(file.read())
|
soup = BeautifulSoup(file.read())
|
||||||
item = ElementTree.Element('item')
|
item = ElementTree.Element('item')
|
||||||
|
@ -32,8 +29,8 @@ for i in os.listdir('.'):
|
||||||
guid.text = f'sbbs/{os.path.splitext(i)[0]}'
|
guid.text = f'sbbs/{os.path.splitext(i)[0]}'
|
||||||
description = ElementTree.SubElement(item, 'description')
|
description = ElementTree.SubElement(item, 'description')
|
||||||
description.text = str(soup.find('div', class_='content'))
|
description.text = str(soup.find('div', class_='content'))
|
||||||
items.append((datetime.fromisoformat(soup.find('meta', {'name': 'created'})['content']), item))
|
return (datetime.fromisoformat(soup.find('meta', {'name': 'created'})['content']), item)
|
||||||
for date, i in sorted(items, reverse=True, key=lambda i: i[0]):
|
for date, i in sorted(map(parse_file, filter(lambda i: i not in ('index.html', 'index.xml'), os.listdir('.'))), reverse=True, key=lambda i: i[0]):
|
||||||
# http://johnbokma.com/blog/2019/10/09/rfc-822-and-rfc-3339-dates-in-python.html
|
# http://johnbokma.com/blog/2019/10/09/rfc-822-and-rfc-3339-dates-in-python.html
|
||||||
ctime = date.ctime()
|
ctime = date.ctime()
|
||||||
pubdate = ElementTree.SubElement(i, 'pubDate')
|
pubdate = ElementTree.SubElement(i, 'pubDate')
|
||||||
|
|
Loading…
Reference in New Issue