1111from nameparser .util import log
1212from nameparser .config import CONSTANTS
1313from nameparser .config import Constants
14+ from nameparser .config import DEFAULT_ENCODING
1415
1516ENCODING = 'utf-8'
1617
@@ -69,13 +70,13 @@ class HumanName(object):
6970 unparsable = True
7071 _full_name = ''
7172
72- def __init__ (self , full_name = "" , constants = CONSTANTS , encoding = ENCODING ,
73+ def __init__ (self , full_name = "" , constants = CONSTANTS , encoding = DEFAULT_ENCODING ,
7374 string_format = None ):
7475 self .C = constants
7576 if type (self .C ) is not type (CONSTANTS ):
7677 self .C = Constants ()
7778
78- self .ENCODING = encoding
79+ self .encoding = encoding
7980 self .string_format = string_format or self .C .string_format
8081 # full_name setter triggers the parse
8182 self .full_name = full_name
@@ -127,15 +128,15 @@ def __unicode__(self):
127128 if self .string_format :
128129 # string_format = "{title} {first} {middle} {last} {suffix} ({nickname})"
129130 _s = self .string_format .format (** self .as_dict ())
130- # remove trailing punctation from missing nicknames
131+ # remove trailing punctuation from missing nicknames
131132 _s = _s .replace (str (self .C .empty_attribute_default ),'' ).replace (" ()" ,"" ).replace (" ''" ,"" ).replace (' ""' ,"" )
132133 return self .collapse_whitespace (_s ).strip (', ' )
133134 return " " .join (self )
134135
135136 def __str__ (self ):
136137 if sys .version >= '3' :
137138 return self .__unicode__ ()
138- return self .__unicode__ ().encode (self .ENCODING )
139+ return self .__unicode__ ().encode (self .encoding )
139140
140141 def __repr__ (self ):
141142 if self .unparsable :
@@ -152,7 +153,7 @@ def __repr__(self):
152153 }
153154 if sys .version >= '3' :
154155 return _string
155- return _string .encode (self .ENCODING )
156+ return _string .encode (self .encoding )
156157
157158 def as_dict (self , include_empty = True ):
158159 """
@@ -355,7 +356,7 @@ def full_name(self, value):
355356 self .original = value
356357 self ._full_name = value
357358 if isinstance (value , binary_type ):
358- self ._full_name = value .decode (self .ENCODING )
359+ self ._full_name = value .decode (self .encoding )
359360 self .parse_full_name ()
360361
361362 def collapse_whitespace (self , string ):
0 commit comments