<s> """<STR_LIT>""" <EOL> def resolve ( obj , attrspec ) : <EOL> """<STR_LIT>""" <EOL> for attr in attrspec . split ( "<STR_LIT:.>" ) : <EOL> try : <EOL> obj = obj [ attr ] <EOL> except ( TypeError , KeyError ) : <EOL> obj = getattr ( obj , attr ) <EOL> return obj <EOL> def resolve_with_default ( obj , attrspec , default = None ) : <EOL> """<STR_LIT>""" <EOL> result = default <EOL> try : <EOL> result = resolve ( obj , attrspec ) <EOL> except : <EOL> if default is None : <EOL> raise <EOL> return result <EOL> def multi_getattr ( obj , attr , default = None ) : <EOL> """<STR_LIT>""" <EOL> attributes = attr . split ( "<STR_LIT:.>" ) <EOL> for i in attributes : <EOL> try : <EOL> obj = getattr ( obj , i ) <EOL> except AttributeError : <EOL> if default is not None : <EOL> return default <EOL> else : <EOL> raise <EOL> return obj <EOL> def init_logger ( logger , level ) : <EOL> import logging <EOL> FORMAT = "<STR_LIT>" <EOL> logging . basicConfig ( format = FORMAT ) <EOL> logger . setLevel ( level ) </s>
