Remove intermediary list

This commit is contained in:
blank X 2021-07-21 14:47:41 +07:00
parent cf616b1d09
commit 17e046bf2f
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 3 additions and 6 deletions

View File

@ -17,10 +17,7 @@ description = ElementTree.SubElement(channel, 'description')
description.text = 'just a showcase of software being broken :)'
language = ElementTree.SubElement(channel, 'language')
language.text = 'en-us'
items = []
for i in os.listdir('.'):
if i in ('index.html', 'index.xml'):
continue
def parse_file(i):
with open(i) as file:
soup = BeautifulSoup(file.read())
item = ElementTree.Element('item')
@ -32,8 +29,8 @@ for i in os.listdir('.'):
guid.text = f'sbbs/{os.path.splitext(i)[0]}'
description = ElementTree.SubElement(item, 'description')
description.text = str(soup.find('div', class_='content'))
items.append((datetime.fromisoformat(soup.find('meta', {'name': 'created'})['content']), item))
for date, i in sorted(items, reverse=True, key=lambda i: i[0]):
return (datetime.fromisoformat(soup.find('meta', {'name': 'created'})['content']), item)
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
ctime = date.ctime()
pubdate = ElementTree.SubElement(i, 'pubDate')