Пример #1
0
 def validate_pre_coerce_validators(self, value):
     if self.validators is None:
         return
     for validator in ensure_tuple(self.validators):
         try:
             validator(value)
         except ValidationError as e:
             raise CellError((u'validator', validator.__name__), u'; '.join(e.messages))
Пример #2
0
 def do_confirm_unchanged_if_changed(self, sheet, row_idx, value, values, original):
     if not self.confirm_unchanged_if_changed:
         return
     if original and not self.has_changed(original, value):
         for other_name in ensure_tuple(self.confirm_unchanged_if_changed):
             other_field = sheet.columns.__dict__[other_name].field
             other_value = other_field.value_from_dict(values)
             if other_field.has_changed(original, other_value):
                 inputed = sheet.importer.input_yes_no(
                         u'{} in row {} changed {}:\n\t{} -> {}\nBut not {}:\n\t{}',
                         u'Is it correct?',
                         sheet.obj_repr(original), row_idx, other_field.name,
                         other_field.value_repr(other_field.value_from_obj(original)),
                         other_field.value_repr(other_value),
                         self.name, self.value_repr(value),
                         default=u'Y')
                 if inputed != u'Y':
                     raise RollingError
                 return
Пример #3
0
 def do_confirm_unchanged_if_changed(self, sheet, row_idx, value, values,
                                     original):
     if not self.confirm_unchanged_if_changed:
         return
     if original and not self.has_changed(original, value):
         for other_name in ensure_tuple(self.confirm_unchanged_if_changed):
             other_field = sheet.columns.__dict__[other_name].field
             other_value = other_field.value_from_dict(values)
             if other_field.has_changed(original, other_value):
                 inputed = sheet.importer.input_yes_no(
                     u'{} in row {} changed {}:\n\t{} -> {}\nBut not {}:\n\t{}',
                     u'Is it correct?',
                     sheet.obj_repr(original),
                     row_idx,
                     other_field.name,
                     other_field.value_repr(
                         other_field.value_from_obj(original)),
                     other_field.value_repr(other_value),
                     self.name,
                     self.value_repr(value),
                     default=u'Y')
                 if inputed != u'Y':
                     raise RollingError
                 return
Пример #4
0
 def apply_coercers(self, value):
     if self.coercers is None:
         return value
     for coercer in ensure_tuple(self.coercers):
         value = coercer(value)
     return value