def get_stream_enc(stream, default=None):
 if ((not hasattr(stream, 'encoding')) or (not stream.encoding)):
  return default
 else:
  return stream.encoding

def get_stream_enc ( stream , default = None ) : if ( ( not hasattr ( stream , 'encoding' ) ) or ( not stream . encoding ) ) : return default else : return stream . encoding
return the given streams encoding or a default .