def key_from_protobuf(pb):
 path_args = []
 for element in pb.path:
  path_args.append(element.kind)
  if element.id:
   path_args.append(element.id)
  if element.name:
   path_args.append(element.name)
 project = None
 if pb.partition_id.project_id:
  project = pb.partition_id.project_id
 namespace = None
 if pb.partition_id.namespace_id:
  namespace = pb.partition_id.namespace_id
 return Key(namespace=namespace, project=project, *path_args)

def key_from_protobuf ( pb ) : path_args = [ ] for element in pb . path : path_args . append ( element . kind ) if element . id : path_args . append ( element . id ) if element . name : path_args . append ( element . name ) project = None if pb . partition_id . project_id : project = pb . partition_id . project_id namespace = None if pb . partition_id . namespace_id : namespace = pb . partition_id . namespace_id return Key ( namespace = namespace , project = project , * path_args )
factory method for creating a key based on a protobuf .