Example #1
0
    def validate_copy(self, data, columns, pfx=""):
        """Validate tab-separated fields"""

        ok, _unicode = safe_utf8_decode(data)
        if ok:
            return data

        # log error
        vals = data.split('\t')
        for i, v in enumerate(vals):
            ok, tmp = safe_utf8_decode(v)
            if not ok:
                self.show_error(columns[i], v, pfx, tmp)

        # return safe data
        return _unicode.encode('utf8')
Example #2
0
    def validate_copy(self, data, columns, pfx=""):
        """Validate tab-separated fields"""

        ok, _unicode = safe_utf8_decode(data)
        if ok:
            return data

        # log error
        vals = data.split('\t')
        for i, v in enumerate(vals):
            ok, tmp = safe_utf8_decode(v)
            if not ok:
                self.show_error(columns[i], v, pfx, tmp)

        # return safe data
        return _unicode.encode('utf8')
Example #3
0
 def validate_dict(self, data, pfx=""):
     """validates data in dict"""
     for k, v in data.items():
         if v:
             ok, u = safe_utf8_decode(v)
             if not ok:
                 self.show_error(k, v, pfx, u)
                 data[k] = u.encode('utf8')
     return data
Example #4
0
 def validate_dict(self, data, pfx=""):
     """validates data in dict"""
     for k, v in data.items():
         if v:
             ok, u = safe_utf8_decode(v)
             if not ok:
                 self.show_error(k, v, pfx, u)
                 data[k] = u.encode('utf8')
     return data