def _NewFacetFromPb(pb):
 name = _DecodeUTF8(pb.name())
 val_type = pb.value().type()
 value = _DecodeValue(_GetValue(pb.value()), val_type)
 if (val_type == document_pb.FacetValue.ATOM):
  return AtomFacet(name, value)
 elif (val_type == document_pb.FacetValue.NUMBER):
  return NumberFacet(name, value)
 return InvalidRequest(('Unknown facet value type %d' % val_type))

def _NewFacetFromPb ( pb ) : name = _DecodeUTF8 ( pb . name ( ) ) val_type = pb . value ( ) . type ( ) value = _DecodeValue ( _GetValue ( pb . value ( ) ) , val_type ) if ( val_type == document_pb . FacetValue . ATOM ) : return AtomFacet ( name , value ) elif ( val_type == document_pb . FacetValue . NUMBER ) : return NumberFacet ( name , value ) return InvalidRequest ( ( 'Unknown facet value type %d' % val_type ) )
constructs a facet from a document_pb .