test.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Purpose: test tools
  2. # Created: 27.03.2011
  3. # Copyright (c) 2011-2018, Manfred Moitzi
  4. # License: MIT License
  5. from typing import Sequence, TYPE_CHECKING, Iterable, List, Set
  6. from ezdxf.lldxf.tagger import internal_tag_compiler
  7. from ezdxf.modern import ModernDXFFactory
  8. if TYPE_CHECKING: # import forward declarations
  9. from ezdxf.eztypes import DXFTag, EntityDB, ExtendedTags, DXFEntity
  10. def compile_tags_without_handles(text: str) -> Iterable['DXFTag']:
  11. return (tag for tag in internal_tag_compiler(text) if tag.code not in (5, 105))
  12. def normlines(text: str) -> Sequence[str]:
  13. lines = text.split('\n')
  14. return [line.strip() for line in lines]
  15. def load_section(text: str, name: str, database: 'EntityDB' = None, dxfversion='AC1009') -> List['ExtendedTags']:
  16. from ezdxf.lldxf.loader import load_dxf_structure, fill_database
  17. dxf = load_dxf_structure(internal_tag_compiler(text), ignore_missing_eof=True)
  18. if database is not None:
  19. fill_database(database, dxf, dxfversion)
  20. return dxf[name]
  21. SUPPORTED_ENTITIES = ModernDXFFactory(None).ENTITY_WRAPPERS
  22. def find_unsupported_entities(container: Iterable['DXFEntity']) -> Set[str]:
  23. unsupported_entities = set()
  24. for entity in container:
  25. dxftype = entity.dxftype()
  26. if dxftype not in SUPPORTED_ENTITIES:
  27. unsupported_entities.add(dxftype)
  28. return unsupported_entities