Projet

Général

Profil

0001-misc-also-simplify-hashes-and-underscores-21227.patch

Frédéric Péters, 17 janvier 2018 15:43

Télécharger (1,58 ko)

Voir les différences:

Subject: [PATCH] misc: also simplify hashes and underscores (#21227)

 tests/test_misc.py | 5 +++++
 wcs/qommon/misc.py | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)
tests/test_misc.py
91 91
    assert simplify('test\'again') == 'test-again'
92 92
    assert simplify('test\'\'\'again') == 'test-again'
93 93

  
94
def test_simplify_dashes_and_underscores():
95
    assert simplify('8100-03_PT') == '8100-03-pt'
96
    assert simplify('8100-03_PT', ' ') == '8100 03 pt'
97
    assert simplify('8100-03_PT', '_') == '8100_03_pt'
98

  
94 99
def test_simplify_accented():
95 100
    assert simplify(u'cliché') == 'cliche'
96 101
    assert simplify(u'cliché'.encode('iso-8859-1')) == 'cliche'
wcs/qommon/misc.py
154 154
        else:
155 155
            s = unicode(s, 'iso-8859-1', 'ignore')
156 156
    s = unicodedata.normalize('NFKD', s).encode('ascii', 'ignore')
157
    s = re.sub(r'[^\w\s\'%s]' % space, '', s).strip().lower()
158
    s = re.sub(r'[\s\'%s]+' % space, space, s)
157
    s = re.sub(r'[^\w\s\'_\-%s]' % space, '', s).strip().lower()
158
    s = re.sub(r'[\s\'_\-%s]+' % space, space, s)
159 159
    return s
160 160

  
161 161
def get_datetime_language():
162
-