<s> import six <EOL> from formats import FormatBank , discover_json , discover_yaml <EOL> formats = FormatBank ( ) <EOL> discover_json ( formats , content_type = '<STR_LIT:application/json>' ) <EOL> discover_yaml ( formats , content_type = '<STR_LIT>' ) <EOL> def run_from_ipython ( ) : <EOL> try : <EOL> __IPYTHON__ <EOL> return True <EOL> except NameError : <EOL> return False <EOL> class Bunch ( dict ) : <EOL> def __init__ ( self , kwargs = None ) : <EOL> if kwargs is None : <EOL> kwargs = { } <EOL> for key , value in six . iteritems ( kwargs ) : <EOL> kwargs [ key ] = bunchify ( value ) <EOL> dict . __init__ ( self , kwargs ) <EOL> self . __dict__ = self <EOL> def bunchify ( obj ) : <EOL> if isinstance ( obj , ( list , tuple ) ) : <EOL> return [ bunchify ( item ) for item in obj ] <EOL> if isinstance ( obj , dict ) : <EOL> return Bunch ( obj ) <EOL> return obj </s>
