Assign object default values according to the schema. This will not overwrite properties that have already been set.
(self)
| 918 | raise KeyError(self.__class__.__name__ + " requires " + property) |
| 919 | |
| 920 | def _SetDefaultsFromSchema(self): |
| 921 | """Assign object default values according to the schema. This will not |
| 922 | overwrite properties that have already been set.""" |
| 923 | |
| 924 | defaults = {} |
| 925 | for property, attributes in self._schema.items(): |
| 926 | (_is_list, _property_type, _is_strong, is_required) = attributes[0:4] |
| 927 | if ( |
| 928 | is_required |
| 929 | and len(attributes) >= 5 |
| 930 | and property not in self._properties |
| 931 | ): |
| 932 | default = attributes[4] |
| 933 | |
| 934 | defaults[property] = default |
| 935 | |
| 936 | if len(defaults) > 0: |
| 937 | # Use do_copy=True so that each new object gets its own copy of strong |
| 938 | # objects, lists, and dicts. |
| 939 | self.UpdateProperties(defaults, do_copy=True) |
| 940 | |
| 941 | |
| 942 | class XCHierarchicalElement(XCObject): |
no test coverage detected