def find_attdef(self, tag): for entity in iterflatlist(self.data): # flatten nested list if isinstance(entity, _Entity) and \ (entity.name == 'ATTDEF') and \ (entity['tag'] == tag): return entity raise KeyError("no attdef with tag '%s' found!" % str(tag))
def find_attdef(self, tag): """ Find ATTDEF entities in the block definition, which can occur on arbitrary places. """ for entity in iterflatlist(self.data): # flat data list if isinstance(entity, _Entity) and \ (entity.DXF_ENTITY_NAME == 'ATTDEF') and \ (entity['tag'] == tag): return entity raise KeyError("no attdef with tag '%s' found!" % str(tag))
def test_iterflatten(self): l1 = [1, 2, 3] l2 = [3, 4, l1] l3 = [l2, 7] self.assertEqual(list(iterflatlist(l3)), [3, 4, 1, 2, 3, 7])