www.iger.events/bin/filter_schedule.py

23 lines
596 B
Python
Executable File

#!/usr/bin/env python3
from argparse import ArgumentParser
from bs4 import BeautifulSoup
def main():
parser = ArgumentParser()
parser.add_argument('schedule')
parser.add_argument('room')
args = parser.parse_args()
with open(args.schedule) as f:
soup = BeautifulSoup(f.read(), 'xml')
for r in soup.find_all(lambda t: t.name == 'room' and 'name' in t.attrs and t.attrs['name'] != args.room):
r.decompose()
with open(args.schedule.removesuffix('.xml')+f'-{args.room}.xml', 'w') as f:
f.write(str(soup))
if __name__ == '__main__':
main()