1 """
2 Collection of tools for PISI
3
4 This file is part of Pisi.
5
6 Pisi is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 Pisi is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Pisi. If not, see <http://www.gnu.org/licenses/>.
18 """
20 retTitle = retLastname = retFirstname = retMiddlename = ''
21 fullName = fullName.strip()
22 list = fullName.split(" ")
23 try:
24 title = ''
25 moreTitles = True
26 while moreTitles:
27 moreTitles = False
28 if list[0].upper().startswith("PROF"):
29 title += 'Prof. '
30 del list[0]
31 moreTitles = True
32 if list[0].upper().startswith("DR"):
33 title += 'Dr. '
34 del list[0]
35 moreTitles = True
36 retTitle = title.strip()
37 retFirstname = list[0]
38 del list[0]
39 retLastname = list[len(list)-1]
40 del list[len(list)-1]
41 if len(list) > 0:
42 middlename = ''
43 for item in list:
44 middlename += item + ' '
45 retMiddlename = middlename.strip()
46 except IndexError:
47 pass
48 return retTitle, retFirstname, retLastname, retMiddlename
49
51 """
52 Assembles all information from a contact entry for the packed version of a one line full name
53 """
54 ret = ""
55 if contactEntry.attributes.has_key('title'):
56 title = contactEntry.attributes['title']
57 if title and title != '':
58 ret += title + " "
59 if contactEntry.attributes.has_key('firstname'):
60 firstname = contactEntry.attributes['firstname']
61 if firstname and firstname != '':
62 ret += firstname + " "
63 if contactEntry.attributes.has_key('middlename'):
64 middlename = contactEntry.attributes['middlename']
65 if middlename and middlename != '':
66 ret += middlename + " "
67 if contactEntry.attributes.has_key('lastname'):
68 lastname = contactEntry.attributes['lastname']
69 if lastname and lastname != '':
70 ret += lastname
71 return ret.strip()
72