def post_new_hook(self): """ Post processing and integrity validation after entity creation (internal API) """ dxf = self.dxf if not is_valid_layer_name(dxf.layer): raise DXFInvalidLayerName(dxf.layer) if self.doc and dxf.hasattr('linetype'): if dxf.linetype not in self.doc.linetypes: raise DXFInvalidLineType('Linetype "{}" not defined.'.format(dxf.linetype))
def new(cls, handle, dxfattribs=None, drawing=None): if cls.TEMPLATE is None: raise NotImplementedError("new() for type %s not implemented." % cls.__name__) entity = cls(cls.TEMPLATE.clone(), drawing) entity.dxf.handle = handle if dxfattribs is not None: if 'layer' in dxfattribs: layer_name = dxfattribs['layer'] if not is_valid_layer_name(layer_name): raise DXFInvalidLayerName( "Invalid layer name '{}'".format(layer_name)) entity.update_dxf_attribs(dxfattribs) entity.post_new_hook() return entity
def post_new_hook(self) -> None: if not is_valid_layer_name(self.dxf.name): raise DXFInvalidLayerName("Invalid layer name '{}'".format( self.dxf.name))