MCPcopy Create free account
hub / github.com/PageBot/PageBot / _set_template

Method _set_template

Lib/pagebot/elements/element.py:4944–4972  ·  view source on GitHub ↗
(self, template)

Source from the content-addressed store, hash-verified

4942 return self._template
4943
4944 def _set_template(self, template):
4945 # Clear all existing child elements in self.
4946 self.clearElements()
4947 # Keep template reference to clone pages or if additional template info
4948 # is needed later.
4949 self._template = template
4950
4951 # Copy optional template stuff
4952 if template is not None:
4953 # Copy elements from the template and put them in the designated
4954 # positions.
4955 self.w = template.w
4956 self.h = template.h
4957 self.padding = template.padding
4958 self.margin = template.margin
4959 self.prevElement = template.prevElement
4960 self.nextElement = template.nextElement
4961 self.nextPage = template.nextPage
4962
4963 # Copy style items.
4964 for name, value in template.style.items():
4965 self.style[name] = value
4966
4967 # Copy condition list. Does not have to be deepCopy, condition
4968 # instances are multi-purpose.
4969 self.conditions = copy.copy(template.conditions)
4970
4971 for e in template.elements:
4972 self.appendElement(e.copy(parent=self))
4973
4974 template = property(_get_template, _set_template)
4975if __name__ == '__main__':

Callers

nothing calls this directly

Calls 3

clearElementsMethod · 0.95
copyMethod · 0.45
appendElementMethod · 0.45

Tested by

no test coverage detected