<s> from __future__ import ( unicode_literals , division , absolute_import , print_function ) <EOL> import itertools <EOL> from powerline . lib . unicode import unicode <EOL> from powerline . lint . markedjson . markedvalue import MarkedUnicode <EOL> from powerline . lint . selfcheck import havemarks <EOL> class JStr ( unicode ) : <EOL> def join ( self , iterable ) : <EOL> return super ( JStr , self ) . join ( ( unicode ( item ) for item in iterable ) ) <EOL> key_sep = JStr ( '<STR_LIT:/>' ) <EOL> def list_themes ( data , context ) : <EOL> theme_type = data [ '<STR_LIT>' ] <EOL> ext = data [ '<STR_LIT>' ] <EOL> main_theme_name = data [ '<STR_LIT>' ] . get ( '<STR_LIT>' , { } ) . get ( ext , { } ) . get ( '<STR_LIT>' , None ) <EOL> is_main_theme = ( data [ '<STR_LIT>' ] == main_theme_name ) <EOL> if theme_type == '<STR_LIT>' : <EOL> return list ( itertools . chain ( * [ <EOL> [ ( theme_ext , theme ) for theme in theme_configs . values ( ) ] <EOL> for theme_ext , theme_configs in data [ '<STR_LIT>' ] . items ( ) <EOL> ] ) ) <EOL> elif theme_type == '<STR_LIT>' or is_main_theme : <EOL> return [ ( ext , theme ) for theme in data [ '<STR_LIT>' ] . values ( ) ] <EOL> else : <EOL> return [ ( ext , context [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] ) ] <EOL> class Context ( tuple ) : <EOL> for func in dir ( tuple ) : <EOL> if func in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> continue <EOL> exec ( ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) . format ( func ) ) <EOL> del func <EOL> __slots__ = ( ) <EOL> def __new__ ( cls , base , context_key = None , context_value = None ) : <EOL> if context_key is not None : <EOL> assert ( context_value is not None ) <EOL> assert ( type ( base ) is Context ) <EOL> havemarks ( context_key , context_value ) <EOL> return tuple . __new__ ( cls , tuple . __add__ ( base , ( ( context_key , context_value ) , ) ) ) <EOL> else : <EOL> havemarks ( base ) <EOL> return tuple . __new__ ( cls , ( ( MarkedUnicode ( '<STR_LIT>' , base . mark ) , base ) , ) ) <EOL> @ property <EOL> def key ( self ) : <EOL> return key_sep . join ( ( c [ <NUM_LIT:0> ] for c in self ) ) <EOL> def enter_key ( self , value , key ) : <EOL> return self . enter ( value . keydict [ key ] , value [ key ] ) <EOL> def enter_item ( self , name , item ) : <EOL> return self . enter ( MarkedUnicode ( name , item . mark ) , item ) <EOL> def enter ( self , context_key , context_value ) : <EOL> return Context . __new__ ( Context , self , context_key , context_value ) </s>
