Coverage for distro_tracker/signon/utils.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2025-01-12 09:15 +0000

1# Copyright 2016-2023 Enrico Zini <enrico@debian.org> 

2# Copyright 2023 The Debusine Developers 

3# See the COPYRIGHT file at the top-level directory of this distribution 

4# 

5# This file is part of Distro Tracker. It is subject to the license terms 

6# in the LICENSE file found in the top-level directory of this 

7# distribution and at https://deb.li/DTLicense. No part of Distro Tracker, 

8# including this file, may be copied, modified, propagated, or distributed 

9# except according to the terms contained in the LICENSE file. 

10 

11"""Helper functions for the signon module.""" 

12 

13 

14def split_full_name(name: str) -> tuple[str, str]: 

15 """ 

16 Arbitrary split a full name into (first_name, last_name). 

17 

18 This is better than nothing, but not a lot better than that. 

19 """ 

20 # See http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ # noqa 

21 fn = name.split() 

22 if len(fn) == 1: 

23 return fn[0], "" 

24 elif len(fn) == 2: 

25 return fn[0], fn[1] 

26 elif len(fn) == 3: 

27 return " ".join(fn[0:2]), fn[2] 

28 else: 

29 middle = len(fn) // 2 

30 return " ".join(fn[:middle]), " ".join(fn[middle:])