Changeset - f888b13c56b0
[Not reviewed]
0 2 0
Brett Smith - 7 years ago 2017-10-22 18:05:56
brettcsmith@brettcsmith.org
hooks.add_entity: Better handle common name prefix parts.

Keep these with the name they're attached to, rather than breaking the name
in the middle.
2 files changed with 10 insertions and 0 deletions:
0 comments (0 inline, 0 general)
import2ledger/hooks/add_entity.py
Show inline comments
...
 
@@ -4,2 +4,7 @@ import unicodedata
 
class AddEntityHook:
 
    NAME_PREFIXES = frozenset([
 
        'da',
 
        'de',
 
        'van',
 
    ])
 
    NONASCII_RE = re.compile(r'[^-A-Za-z0-9]')
...
 
@@ -43,2 +48,4 @@ class AddEntityHook:
 
        parts.insert(0, parts.pop())
 
        if parts[-1].lower() in self.NAME_PREFIXES:
 
            parts.insert(0, parts.pop())
 
        return '-'.join(parts)
tests/test_hooks.py
Show inline comments
...
 
@@ -21,2 +21,5 @@ def test_load_all():
 
    ('Pøweł', 'Powel'),
 
    ('Elyse Jan Smith', 'Smith-Elyse-Jan'),
 
    ('Jan van Smith', 'van-Smith-Jan'),
 
    ('Francis da Silva', 'da-Silva-Francis'),
 
])
0 comments (0 inline, 0 general)