def _entity_descriptor(entity, key):
 insp = inspection.inspect(entity)
 if insp.is_selectable:
  description = entity
  entity = insp.c
 elif insp.is_aliased_class:
  entity = insp.entity
  description = entity
 elif hasattr(insp, 'mapper'):
  description = entity = insp.mapper.class_
 else:
  description = entity
 try:
  return getattr(entity, key)
 except AttributeError:
  raise sa_exc.InvalidRequestError(("Entity '%s' has no property '%s'" % (description, key)))

def _entity_descriptor ( entity , key ) : insp = inspection . inspect ( entity ) if insp . is_selectable : description = entity entity = insp . c elif insp . is_aliased_class : entity = insp . entity description = entity elif hasattr ( insp , 'mapper' ) : description = entity = insp . mapper . class_ else : description = entity try : return getattr ( entity , key ) except AttributeError : raise sa_exc . InvalidRequestError ( ( "Entity '%s' has no property '%s'" % ( description , key ) ) )
return a class attribute given an entity and string name .