<s> _missing = object ( ) <EOL> class memoized_property ( property ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , func , name = None , doc = None ) : <EOL> self . __name__ = name or func . __name__ <EOL> self . __module__ = func . __module__ <EOL> self . __doc__ = doc or func . __doc__ <EOL> self . func = func <EOL> def __set__ ( self , obj , value ) : <EOL> obj . __dict__ [ self . __name__ ] = value <EOL> def __get__ ( self , obj , type = None ) : <EOL> if obj is None : <EOL> return self <EOL> value = obj . __dict__ . get ( self . __name__ , _missing ) <EOL> if value is _missing : <EOL> value = self . func ( obj ) <EOL> obj . __dict__ [ self . __name__ ] = value <EOL> return value <EOL> def __delete__ ( self , obj ) : <EOL> obj . __dict__ . pop ( self . __name__ , None ) <EOL> def unicode_str ( content , encoding = None , errors = None ) : <EOL> """<STR_LIT>""" <EOL> if not encoding or encoding == '<STR_LIT>' : <EOL> encoding = '<STR_LIT:utf-8>' <EOL> errors = errors or '<STR_LIT:strict>' <EOL> try : <EOL> if not isinstance ( content , unicode ) : <EOL> content = unicode ( content , encoding , errors = errors ) <EOL> except ( UnicodeDecodeError , LookupError , TypeError ) : <EOL> content = None <EOL> return content </s>
