-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.py
47 lines (36 loc) · 984 Bytes
/
util.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
import NSColor
import NSNumber
import NSString
import RVBibleReference
import RVDateTime
import RVDisplaySlide
import RVEffect
import RVMediaCue
import RVMediaElement
import RVObject
import RVPresentationDocument
import RVRect3D
import RVScaleFactor
import RVSlideGrouping
import RVTimeline
import shadow
import types
import inspect
def imports():
for name, val in globals().items():
if isinstance(val, types.ModuleType):
yield val
def allclasses():
classes = list()
for module in imports():
classes.extend(inspect.getmembers(module ,inspect.isclass))
return classes
def createobject(xmlelement):
elementtype = xmlelement.tag
# List of imported modules.
importedclasses = allclasses()
# Use reflection.
for curclass in importedclasses:
if curclass[0] == elementtype:
return curclass[1](xmlelement)
raise Exception("No class with the name '" + elementtype + "' exists or is imported.")