Commit e3bb2065 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

process shapes: get images out of shapes.svg

parent f9fe4945
#!/usr/bin/env python3
import argparse
import os
import os.path
import xml.etree.ElementTree as ET
from pathlib import Path
from download_bbb import parser
def process_shapes(meeting):
"""Extract images from shapes.svg"""
for child in ET.parse(f'data/{meeting}/shapes.svg').getroot():
if child.attrib['class'] != 'slide':
continue
attrs = {key: val for key, val in child.attrib.items() if key != 'style'}
svg = ET.Element('svg', {'xmlns': 'http://www.w3.org/2000/svg'})
ET.SubElement(svg, 'image', attrs)
with open(f'data/{meeting}/{child.attrib["id"]}.svg', 'wb') as fileh:
for line in ET.tostringlist(svg):
fileh.write(line)
def main():
"""script entry point"""
args = parser.parse_args()
process_shapes(meeting=args.meeting)
if __name__ == '__main__':
main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment