diff --git a/gensbbsrss.py b/gensbbsrss.py index 14bb135..3cf0df8 100644 --- a/gensbbsrss.py +++ b/gensbbsrss.py @@ -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')