-
Notifications
You must be signed in to change notification settings - Fork 1
/
RVSlideGrouping.py
50 lines (37 loc) · 1.45 KB
/
RVSlideGrouping.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from RVObject import RVObject
from NSColor import NSColor
from RVDisplaySlide import RVDisplaySlide
import uuid
import xml.etree.ElementTree as xmltree
class RVSlideGrouping(RVObject):
def __init__(self,xmlelement=None):
self.name = ""
self.uuid = str(uuid.uuid4())
self.color = NSColor()
# Create child objects here.
self.slides = []
if xmlelement is None:
return
# Load variables from XML.
self.deserializexml(xmlelement)
def deserializexml(self,xmlelement):
self.name = xmlelement.get('name')
self.uuid = xmlelement.get('uuid')
self.color = NSColor(xmlelement.get('color'))
# Use XPath to find the slides object.
xml_slides = xmlelement.find("./*[@rvXMLIvarName='slides']")
if xml_slides is not None:
for xml_slide in xml_slides:
# Create the actual slide objects.
self.slides.append(RVDisplaySlide(xml_slide))
def serializexml(self):
xmlelement = xmltree.Element('RVSlideGrouping')
xmlelement.set('name', self.name)
xmlelement.set('uuid', self.uuid)
xmlelement.set('color', str(self.color))
# TODO - Serialize the child objects back out to XML
slideselement = self.createarray('slides')
xmlelement.append(slideselement)
for cslide in self.slides:
slideselement.append(cslide.serializexml())
return xmlelement