def add_object(self, entity: "DXFObject") -> None: """Add `entity` to OBJECTS section. (internal API)""" if is_dxf_object(entity): self._entity_space.add(entity) else: raise const.DXFTypeError( f"invalid DXF type {entity.dxftype()} for OBJECTS section" )
def audit(self, auditor: Auditor) -> None: """Audit and repair OBJECTS section. .. important:: Do not delete entities while auditing process, because this would alter the entity database while iterating, instead use:: auditor.trash(entity) to delete invalid entities after auditing automatically. """ assert self.doc is auditor.doc, "Auditor for different DXF document." for entity in self._entity_space: if not is_dxf_object(entity): auditor.fixed_error( code=AuditError.REMOVED_INVALID_DXF_OBJECT, message=f"Removed invalid DXF entity {str(entity)} " f"from OBJECTS section.", ) auditor.trash(entity)
def test_duplicate_existing_entry(self, collection_rw): count = len(collection_rw) obj = collection_rw.duplicate_entry("STANDARD", "Dup1") assert is_dxf_object(obj) is True assert obj.dxf.name == "Dup1" assert len(collection_rw) == count + 1
def test_new_entry_is_an_object(self, collection_rw): obj = collection_rw.new("New1") assert is_dxf_object(obj) is True assert obj.dxf.name == "New1"
def test_wrapped_mtext_is_not_a_dxf_object(entity): assert is_dxf_object(entity) is False
def test_wrapped_xrecord_is_a_dxf_object(entity): assert is_dxf_object(entity) is True
def test_is_dxf_object(): assert is_dxf_object(DXFObject()) is True
def test_entity_type(entity): assert is_graphic_entity(entity) is False assert is_dxf_object(entity) is False