Ignore:
Timestamp:
21 Feb 2022, 06:21:10 (3 years ago)
Author:
Henrik Bettermann
Message:

Don't complain but remove leading and trailing whitespaces while converting values during import.

Location:
main/waeup.kofa/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/CHANGES.txt

    r16812 r16818  
    441.7.2.dev0 (unreleased)
    55=======================
     6
     7* Don't complain but remove leading and trailing whitespaces
     8  while converting values during import.
    69
    710* Add 'Modules Level'.
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py

    r16538 r16818  
    15101510            invalid_line = check_csv_charset(filecontent.splitlines())
    15111511            if invalid_line:
    1512                 if invalid_line == -1:
    1513                     self.flash(_(
    1514                         "The data in your file contain trailing whitespaces. "
    1515                         "Please replace."), type='danger')
    1516                 else:
    1517                     self.flash(_(
    1518                         "Your file contains forbidden characters or "
    1519                         "has invalid CSV format. "
    1520                         "First problematic line detected: line %s. "
    1521                         "Please replace." % invalid_line), type='danger')
     1512                self.flash(_(
     1513                    "Your file contains forbidden characters or "
     1514                    "has invalid CSV format. "
     1515                    "First problematic line detected: line %s. "
     1516                    "Please replace." % invalid_line), type='danger')
    15221517                logger.info('%s - invalid file uploaded: %s' %
    15231518                            (ob_class, target))
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py

    r16187 r16818  
    204204        return
    205205
    206     def test_forbidden_file_upload_2(self):
     206    def deprecated_test_forbidden_file_upload_2(self):
    207207        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    208208        self.browser.open(self.datacenter_path)
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/converters.py

    r12415 r16818  
    280280        new_data = dict()
    281281        for key, val in data_dict.items():
     282            val = val.strip()
    282283            field = form_fields.get(key, None)
    283284            if field is not None:
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/helpers.py

    r15748 r16818  
    770770    Returns line num of first illegal char or ``None``. Line nums
    771771    start counting with 1 (not zero). Returns -1 if data contain
    772     trailing whitespaces.
     772    trailing whitespaces (deactivated).
    773773    """
    774774    linenum = 1
     
    777777        for row in reader:
    778778            linenum += 1
    779             for value in row.values():
    780                 if value.endswith(' '):
    781                     return -1
     779            #for value in row.values():
     780            #    if value.endswith(' '):
     781            #        return -1
    782782    except UnicodeDecodeError:
    783783        return linenum
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_converters.py

    r14008 r16818  
    200200        contact = Contact()
    201201        contact.age = 33
    202         input_data = dict(name='Rudi', age='99')
     202        input_data = dict(name='  Rudi    ', age=' 99 ')
    203203        converter = IObjectConverter(IContact)  # a converter to IContact
    204204        err, inv_err, data = converter.fromStringDict(
     
    283283    def test_textline(self):
    284284        contact = Contact()
    285         input_data = dict(name='Rudi')
     285        input_data = dict(name=' Rudi     ')
    286286        converter = IObjectConverter(IContact)  # a converter to IContact
    287287        err, inv_err, data = converter.fromStringDict(
     
    357357        # pass string ``contact`` instead of a real object
    358358        err, inv_err, data = converter.fromStringDict(
    359             dict(name='Gabi', age='23'), 'contact')
     359            dict(name='  Gabi  ', age='23  '), 'contact')
    360360        self.assertEqual(data['age'], 23)
    361361        self.assertEqual(data['name'], u'Gabi')
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_helpers.py

    r14948 r16818  
    545545            "FAC3,Fäcülty 3,school\n"
    546546            ).splitlines()
    547         self.assertEqual(helpers.check_csv_charset(csv), -1)
     547        self.assertEqual(helpers.check_csv_charset(csv), None)
    548548
    549549class MemInfoTestCase(unittest.TestCase):
Note: See TracChangeset for help on using the changeset viewer.