@@ -544,8 +544,8 @@ def parse_pieces(self, parts, additional_parts_count=0):
544544 raise TypeError ("Name parts must be strings. Got {0}" .format (type (part )))
545545 output += [x .strip (' ,' ) for x in part .split (' ' )]
546546
547- # If there's periods, check if it's titles without spaces and add spaces
548- # so they get picked up later as titles.
547+ # If part contains periods, check if it's multiple titles or suffixes together without spaces
548+ # if so, add the new part with periods to the constants so they get parsed correctly later
549549 for part in output :
550550 # if this part has a period not at the beginning or end
551551 if self .C .regexes .period_not_at_end .match (part ):
@@ -684,12 +684,15 @@ def cap_piece(self, piece):
684684 replacement = lambda m : self .cap_word (m .group (0 ))
685685 return self .C .regexes .word .sub (replacement , piece )
686686
687- def capitalize (self ):
687+ def capitalize (self , force = False ):
688688 """
689689 The HumanName class can try to guess the correct capitalization
690- of name entered in all upper or lower case. It will not adjust
691- the case of names entered in mixed case.
690+ of name entered in all upper or lower case. By default, it will not adjust
691+ the case of names entered in mixed case. To run capitalization on all names
692+ pass the parameter `force=True`.
692693
694+ :param bool force: force capitalization of strings that include mixed case
695+
693696 **Usage**
694697
695698 .. doctest:: capitalize
@@ -703,10 +706,13 @@ def capitalize(self):
703706 >>> name.capitalize()
704707 >>> str(name)
705708 'Shirley Maclaine'
709+ >>> name.capitalize(force=True)
710+ >>> str(name)
711+ 'Shirley MacLaine'
706712
707713 """
708714 name = u (self )
709- if not (name == name .upper () or name == name .lower ()):
715+ if not force and not (name == name .upper () or name == name .lower ()):
710716 return
711717 self .title_list = self .cap_piece (self .title ).split (' ' )
712718 self .first_list = self .cap_piece (self .first ).split (' ' )
0 commit comments