def _normalize_key(value):
  if getattr(value, "key", None):
    return value.key()
  elif isinstance(value, basestring):
    return datastore.Key(value)
  else:
    return value
Return a key from an entity, model instance, key, or key string.
dataset/ETHPy150Open livid/v2ex/mapreduce/context.py/_normalize_key