def PropertyValueFromString(type_, value_string, _auth_domain=None):
 if (type_ == datetime.datetime):
  value_string = value_string.strip()
  if (value_string[(-6)] in ('+', '-')):
   if (value_string[(-5):] == '00:00'):
    value_string = value_string[:(-6)]
   else:
    raise ValueError('Non-UTC offsets in datetimes are not supported.')
  split = value_string.split('.')
  iso_date = split[0]
  microseconds = 0
  if (len(split) > 1):
   microseconds = int(split[1])
  time_struct = time.strptime(iso_date, '%Y-%m-%d %H:%M:%S')[0:6]
  value = datetime.datetime(*(time_struct + (microseconds,)))
  return value
 elif (type_ == Rating):
  return Rating(int(value_string))
 elif (type_ == bool):
  return (value_string == 'True')
 elif (type_ == users.User):
  return users.User(value_string, _auth_domain)
 elif (type_ == type(None)):
  return None
 return type_(value_string)

def PropertyValueFromString ( type_ , value_string , _auth_domain = None ) : if ( type_ == datetime . datetime ) : value_string = value_string . strip ( ) if ( value_string [ ( - 6 ) ] in ( '+' , '-' ) ) : if ( value_string [ ( - 5 ) : ] == '00:00' ) : value_string = value_string [ : ( - 6 ) ] else : raise ValueError ( 'Non-UTC offsets in datetimes are not supported.' ) split = value_string . split ( '.' ) iso_date = split [ 0 ] microseconds = 0 if ( len ( split ) > 1 ) : microseconds = int ( split [ 1 ] ) time_struct = time . strptime ( iso_date , '%Y-%m-%d %H:%M:%S' ) [ 0 : 6 ] value = datetime . datetime ( * ( time_struct + ( microseconds , ) ) ) return value elif ( type_ == Rating ) : return Rating ( int ( value_string ) ) elif ( type_ == bool ) : return ( value_string == 'True' ) elif ( type_ == users . User ) : return users . User ( value_string , _auth_domain ) elif ( type_ == type ( None ) ) : return None return type_ ( value_string )
returns an instance of a property value given a type and string value .