@@ -29,7 +29,7 @@ def append(self, value):
2929 contact = self .contactClass (value )
3030 contact .core = self .core
3131 if self .contactInitFn is not None :
32- contact = self .contactInitFn (contact )
32+ contact = self .contactInitFn (contact ) or contact
3333 super (ContactList , self ).append (contact )
3434 def __deepcopy__ (self , memo ):
3535 return self .__class__ ([copy .deepcopy (v ) for v in self ])
@@ -38,6 +38,11 @@ def __getstate__(self):
3838 def __setstate__ (self , state ):
3939 for v in state :
4040 super (ContactList , self ).append (pickle .loads (v ))
41+ def __str__ (self ):
42+ return '[%s]' % ', ' .join ([repr (v ) for v in self ])
43+ def __repr__ (self ):
44+ return '<%s: %s>' % (self .__class__ .__name__ .split ('.' )[- 1 ],
45+ self .__str__ ())
4146
4247fakeContactList = ContactList
4348
@@ -99,16 +104,22 @@ def __getattr__(self, value):
99104 value = value [0 ].upper () + value [1 :]
100105 return self .get (value , '' )
101106 def __deepcopy__ (self , memo ):
102- r = self .__class__ ([
103- ( copy .deepcopy (k , memo ), copy .deepcopy (v , memo ) )
104- for k , v in self .items ()] )
107+ r = self .__class__ ({
108+ copy .deepcopy (k , memo ): copy .deepcopy (v , memo )
109+ for k , v in self .items ()} )
105110 r .core = self .core
106111 return r
107112 def __getstate__ (self ):
108113 return dict (self )
109114 def __setstate__ (self , state ):
110115 for k , v in state .items ():
111116 self [k ] = v
117+ def __str__ (self ):
118+ return '{%s}' % ', ' .join (
119+ ['%s: %s' % (repr (k ),repr (v )) for k ,v in self .items ()])
120+ def __repr__ (self ):
121+ return '<%s: %s>' % (self .__class__ .__name__ .split ('.' )[- 1 ],
122+ self .__str__ ())
112123
113124class User (AbstractUserDict ):
114125 def __init__ (self , * args , ** kwargs ):
@@ -128,7 +139,6 @@ def __deepcopy__(self, memo):
128139 r .verifyDict = copy .deepcopy (self .verifyDict )
129140 return r
130141
131-
132142class MassivePlatform (AbstractUserDict ):
133143 def __init__ (self , * args , ** kwargs ):
134144 super (MassivePlatform , self ).__init__ (* args , ** kwargs )
0 commit comments