def _CopySortExpressionToProtocolBuffer(sort_expression, pb):
 pb.set_sort_expression(sort_expression.expression.encode('utf-8'))
 if (sort_expression.direction == SortExpression.ASCENDING):
  pb.set_sort_descending(False)
 if (sort_expression.default_value is not None):
  if isinstance(sort_expression.default_value, basestring):
   pb.set_default_value_text(sort_expression.default_value.encode('utf-8'))
  elif (isinstance(sort_expression.default_value, datetime.datetime) or isinstance(sort_expression.default_value, datetime.date)):
   pb.set_default_value_text(str(search_util.EpochTime(sort_expression.default_value)))
  else:
   pb.set_default_value_numeric(sort_expression.default_value)
 return pb

def _CopySortExpressionToProtocolBuffer ( sort_expression , pb ) : pb . set_sort_expression ( sort_expression . expression . encode ( 'utf-8' ) ) if ( sort_expression . direction == SortExpression . ASCENDING ) : pb . set_sort_descending ( False ) if ( sort_expression . default_value is not None ) : if isinstance ( sort_expression . default_value , basestring ) : pb . set_default_value_text ( sort_expression . default_value . encode ( 'utf-8' ) ) elif ( isinstance ( sort_expression . default_value , datetime . datetime ) or isinstance ( sort_expression . default_value , datetime . date ) ) : pb . set_default_value_text ( str ( search_util . EpochTime ( sort_expression . default_value ) ) ) else : pb . set_default_value_numeric ( sort_expression . default_value ) return pb
copies a sortexpression to a search_service_pb .