Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guilhem Saurel
bbb2vid
Commits
e3bb2065
Commit
e3bb2065
authored
Sep 19, 2020
by
Guilhem Saurel
Browse files
process shapes: get images out of shapes.svg
parent
f9fe4945
Changes
1
Hide whitespace changes
Inline
Side-by-side
main.py
0 → 100755
View file @
e3bb2065
#!/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
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment