<s> from __future__ import ( unicode_literals , division , absolute_import , print_function ) <EOL> from powerline import Powerline <EOL> from powerline . lib . dict import mergedicts <EOL> from powerline . lib . unicode import string <EOL> class RewriteResult ( object ) : <EOL> def __init__ ( self , prompt ) : <EOL> self . prompt = string ( prompt ) <EOL> def __str__ ( self ) : <EOL> return self . prompt <EOL> def __add__ ( self , s ) : <EOL> if type ( s ) is not str : <EOL> try : <EOL> s = s . encode ( '<STR_LIT:utf-8>' ) <EOL> except AttributeError : <EOL> raise NotImplementedError <EOL> return RewriteResult ( self . prompt + s ) <EOL> class IPythonPowerline ( Powerline ) : <EOL> def init ( self , ** kwargs ) : <EOL> super ( IPythonPowerline , self ) . init ( <EOL> '<STR_LIT>' , <EOL> use_daemon_threads = True , <EOL> ** kwargs <EOL> ) <EOL> def get_config_paths ( self ) : <EOL> if self . config_paths : <EOL> return self . config_paths <EOL> else : <EOL> return super ( IPythonPowerline , self ) . get_config_paths ( ) <EOL> def get_local_themes ( self , local_themes ) : <EOL> return dict ( ( ( type , { '<STR_LIT>' : self . load_theme_config ( name ) } ) for type , name in local_themes . items ( ) ) ) <EOL> def load_main_config ( self ) : <EOL> r = super ( IPythonPowerline , self ) . load_main_config ( ) <EOL> if self . config_overrides : <EOL> mergedicts ( r , self . config_overrides ) <EOL> return r <EOL> def load_theme_config ( self , name ) : <EOL> r = super ( IPythonPowerline , self ) . load_theme_config ( name ) <EOL> if name in self . theme_overrides : <EOL> mergedicts ( r , self . theme_overrides [ name ] ) <EOL> return r <EOL> def do_setup ( self , wrefs ) : <EOL> for wref in wrefs : <EOL> obj = wref ( ) <EOL> if obj is not None : <EOL> setattr ( obj , '<STR_LIT>' , self ) </s>
