예제 #1
0
 def deserialize(self, data: dict):
     self._source = serializer.simple_deserialize(data['source'])
     self.__origin = FieldValue.create(
         serializer.simple_deserialize(data['origin']))
     self.__matched = FieldValue.create(
         serializer.simple_deserialize(data['matched']))
     self.__suggested = FieldValue.create(
         serializer.simple_deserialize(data['suggested']))
     if 'exclude' in data:
         self._exclude = FieldValue.create(
             serializer.simple_deserialize(data['exclude']))
예제 #2
0
 def match(self, form):
     LOG.info("Match field %s with value %s" %
              (self._source, self.__origin))
     if self._matcher:
         if not FieldValue.is_empty(self.__origin):
             matched_value = self._matcher(self.__origin, form)
             self._validate_match(matched_value)
             self.__matched = FieldValue.create(matched_value)
             LOG.info("Matched value for field %s is %s(%s)" %
                      (self._source, self.__matched.__class__.__name__,
                       self.__matched))
예제 #3
0
 def _to_suggest_fieldvalue(self, value):
     if FieldValue.is_empty(self.origin):
         return super(ListField, self)._to_suggest_fieldvalue(value)
     return FieldValue.create(value)
예제 #4
0
 def _fill_origin(self, raw_payload):
     self.__origin = FieldValue.create(raw_payload.get(self._source, None))