1 from . import utilities
2 from .. import constants, exceptions
5 class BaseClass(constants.BASE_DICT):
6 """Base class which inherits from a base dictionary object."""
9 def __init__(self, parent=None, type=None):
10 constants.BASE_DICT.__init__(self)
16 constants.BASE_DICT.update(self, self._defaults.copy())
17 BaseClass._defaults = {}
19 def __setitem__(self, key, value):
20 if not isinstance(value, constants.VALID_DATA_TYPES):
21 msg = "Value is an invalid data type: %s" % type(value)
22 raise exceptions.ThreeValueError(msg)
23 constants.BASE_DICT.__setitem__(self, key, value)
29 :return: number of keys
33 return len(self.keys())
39 :return: parent object
48 :return: the type (if applicable)
54 """Copies the items to a standard dictionary object.
61 def _dict_copy(old, new):
62 """Recursive function for processing all values
68 for key, value in old.items():
69 if isinstance(value, (str, list)):
71 elif isinstance(value, tuple):
72 new[key] = value+tuple()
73 elif isinstance(value, dict):
75 _dict_copy(value, new[key])
79 _dict_copy(self, data)
84 class BaseNode(BaseClass):
85 """Base class for all nodes for the current platform."""
86 def __init__(self, node, parent, type):
87 BaseClass.__init__(self, parent=parent, type=type)
90 self[constants.UUID] = utilities.id()
92 self[constants.NAME] = node
93 self[constants.UUID] = utilities.id()
95 if isinstance(parent, BaseScene):
97 elif parent is not None:
108 :return: name of the node
117 :return: returns the scene point
127 :return: export options
131 return self.scene.options
134 class BaseScene(BaseClass):
135 """Base class that scenes inherit from."""
136 def __init__(self, filepath, options):
137 BaseClass.__init__(self, type=constants.SCENE)
139 self._filepath = filepath
141 self._options = options.copy()
145 return self._filepath