#NEWLINE# def deserialize_from_eclipse_color_theme_xml( xml ) : #NEWLINE# #INDENT# if ( isinstance ( xml , str ) or isinstance ( xml , unicode ) ) : #NEWLINE# #INDENT# with open ( xml , 'rt' ) as f : #NEWLINE# #INDENT# xmlLines = f . readlines ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( xml , list ) : #NEWLINE# #INDENT# xmlLines = xml #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# xmlLines = xml . readlines ( ) #NEWLINE# #UNINDENT# #UNINDENT# options = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# name = 'Untitled' #NEWLINE# author = 'ideacolorthemes.org' #NEWLINE# website = 'ideacolorthemes.org' #NEWLINE# for line in xmlLines : #NEWLINE# #INDENT# if ( '<colorTheme' in line ) : #NEWLINE# #INDENT# name = get_attribute ( line , 'name' ) #NEWLINE# author = get_attribute ( line , 'author' ) #NEWLINE# website = get_attribute ( line , 'website' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not ( '</colorTheme' in line ) ) and ( not ( '<?xml' in line ) ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# option = line . split ( '<' ) [ 1 ] . split ( ' ' ) [ 0 ] . strip ( ) #NEWLINE# color = get_attribute ( line , 'color' ) . split ( '#' ) [ 1 ] #NEWLINE# bold = get_attribute ( line , 'bold' ) #NEWLINE# italic = get_attribute ( line , 'italic' ) #NEWLINE# if get_attribute ( line , 'underline' ) : #NEWLINE# #INDENT# eff = 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if get_attribute ( line , 'strikethrough' ) : #NEWLINE# #INDENT# eff = 5 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# eff = 0 #NEWLINE# #UNINDENT# #UNINDENT# options [ option ] = ( ( True if bold else None ) , ( True if italic else None ) , color , None , None , ( eff if eff else None ) , ( color if eff else None ) ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# bg = 'FFFFFF' #NEWLINE# r = g = b = 255 #NEWLINE# if ( 'background' in options ) : #NEWLINE# #INDENT# bg = options [ 'background' ] [ elements . PARAM_FOREGROUND ] #NEWLINE# #UNINDENT# if ( len ( bg ) == 6 ) : #NEWLINE# #INDENT# r = int ( bg [ 0 : 2 ] , 16 ) #NEWLINE# g = int ( bg [ 2 : 4 ] , 16 ) #NEWLINE# b = int ( bg [ 4 : 6 ] , 16 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( bg ) >= 3 ) : #NEWLINE# #INDENT# r = int ( bg [ 0 : 1 ] , 16 ) #NEWLINE# g = int ( bg [ 1 : 2 ] , 16 ) #NEWLINE# b = int ( bg [ 2 : 3 ] , 16 ) #NEWLINE# #UNINDENT# #UNINDENT# med = ( ( ( r + g ) + b ) / ( 3.0 * 255 ) ) #NEWLINE# dark = ( med < 0.5 ) #NEWLINE# dependencies = [ ( 'TEXT' , ( None , None , 'foreground' , 'background' , None , None , None ) ) , ( 'FOLDED_TEXT_ATTRIBUTES' , ( None , None , 'selectionForeground' , 'selectionBackground' , None , None , None ) ) , ( 'DELETED_TEXT_ATTRIBUTES' , ( None , None , 'background' , 'foreground' , None , None , None ) ) , ( 'SEARCH_RESULT_ATTRIBUTES' , ( None , None , None , 'occurrenceIndication' , 'occurrenceIndication' , None , None ) ) , ( 'WRITE_SEARCH_RESULT_ATTRIBUTES' , ( None , None , None , 'writeOccurrenceIndication' , 'writeOccurrenceIndication' , None , None ) ) , ( 'IDENTIFIER_UNDER_CARET_ATTRIBUTES' , ( None , None , None , 'occurrenceIndication' , 'occurrenceIndication' , None , None ) ) , ( 'WRITE_IDENTIFIER_UNDER_CARET_ATTRIBUTES' , ( None , None , None , 'writeOccurrenceIndication' , 'writeOccurrenceIndication' , None , None ) ) , ( 'TEXT_SEARCH_RESULT_ATTRIBUTES' , ( None , None , None , 'searchResultIndication' , 'searchResultIndication' , None , None ) ) , ( 'TEMPLATE_VARIABLE_ATTRIBUTES' , 'foreground' ) , ( 'INJECTED_LANGUAGE_FRAGMENT' , 'foreground' ) , ( 'DEPRECATED_ATTRIBUTES' , 'deprecatedMember' ) , ( 'SELECTION_BACKGROUND' , 'selectionBackground' ) , ( 'SELECTION_FOREGROUND' , 'selectionForeground' ) , ( 'CARET_ROW_COLOR' , 'currentLine' ) , ( 'INDENT_GUIDE' , 'selectionBackground' ) , ( 'SELECTED_INDENT_GUIDE' , 'selectionForeground' ) , ( 'LINE_NUMBERS_COLOR' , 'lineNumber' ) , ( 'GUTTER_BACKGROUND' , 'background' ) , ( 'TEARLINE_COLOR' , 'currentLine' ) , ( 'SELECTED_TEARLINE_COLOR' , 'selectionBackground' ) , ( 'METHOD_SEPARATORS_COLOR' , 'currentLine' ) , ( 'BAD_CHARACTER' , 'deprecatedMember' ) , ( 'DEFAULT_KEYWORD' , 'keyword' ) , ( 'DEFAULT_IDENTIFIER' , 'foreground' ) , ( 'DEFAULT_STRING' , 'string' ) , ( 'DEFAULT_VALID_STRING_ESCAPE' , 'number' ) , ( 'DEFAULT_INVALID_STRING_ESCAPE' , 'deprecatedMember' ) , ( 'DEFAULT_NUMBER' , 'number' ) , ( 'DEFAULT_OPERATION_SIGN' , 'operator' ) , ( 'DEFAULT_BRACES' , 'bracket' ) , ( 'DEFAULT_PARENTHS' , 'bracket' ) , ( 'DEFAULT_BRACKETS' , 'bracket' ) , ( 'DEFAULT_DOT' , 'operator' ) , ( 'DEFAULT_COMMA' , 'operator' ) , ( 'DEFAULT_SEMICOLON' , 'operator' ) , ( 'DEFAULT_LINE_COMMENT' , 'singleLineComment' ) , ( 'Block comment' , 'multiLineComment' ) , ( 'DEFAULT_DOC_COMMENT' , 'javadoc' ) , ( 'DEFAULT_DOC_MARKUP' , 'javadocKeyword' ) , ( 'DEFAULT_DOC_COMMENT_TAG' , 'javadocTag' ) , ( 'DEFAULT_LABEL' , 'typeParameter' ) , ( 'DEFAULT_CONSTANT' , 'staticFinalField' ) , ( 'DEFAULT_PREDEFINED_SYMBOL' , 'constant' ) , ( 'DEFAULT_LOCAL_VARIABLE' , 'localVariable' ) , ( 'DEFAULT_GLOBAL_VARIABLE' , 'localVariable' ) , ( 'DEFAULT_FUNCTION_DECLARATION' , 'methodDeclaration' ) , ( 'DEFAULT_FUNCTION_CALL' , 'method' ) , ( 'DEFAULT_PARAMETER' , 'typeParameter' ) , ( 'DEFAULT_INTERFACE_NAME' , 'interface' ) , ( 'DEFAULT_METADATA' , 'annotation' ) , ( 'DEFAULT_CLASS_NAME' , 'class' ) , ( 'DEFAULT_CLASS_REFERENCE' , 'class' ) , ( 'DEFAULT_INSTANCE_METHOD' , 'method' ) , ( 'DEFAULT_INSTANCE_FIELD' , 'field' ) , ( 'DEFAULT_STATIC_METHOD' , 'staticMethod' ) , ( 'DEFAULT_STATIC_FIELD' , 'staticField' ) , ( 'DEFAULT_TAG' , 'bracket' ) , ( 'DEFAULT_ATTRIBUTE' , 'typeParameter' ) , ( 'DEFAULT_ENTITY' , 'number' ) , ( 'DEFAULT_TEMPLATE_LANGUAGE_COLOR' , 'foreground' ) , ( 'CONSOLE_NORMAL_OUTPUT' , ( None , None , 'foreground' , 'background' , None , None , None ) ) , ( 'CONSOLE_ERROR_OUTPUT' , 'string' ) , ( 'CONSOLE_USER_INPUT' , 'singleLineComment' ) , ( 'CONSOLE_SYSTEM_OUTPUT' , 'number' ) , ( 'LOG_ERROR_OUTPUT' , 'keyword' ) , ( 'LOG_WARNING_OUTPUT' , 'localVariable' ) , ( 'LOG_EXPIRED_ENTRY' , 'multiLineComment' ) , ( 'CONSOLE_BACKGROUND_KEY' , 'background' ) , ( 'CUSTOM_KEYWORD1_ATTRIBUTES' , 'keyword' ) , ( 'CUSTOM_KEYWORD2_ATTRIBUTES' , 'keyword' ) , ( 'CUSTOM_KEYWORD3_ATTRIBUTES' , 'keyword' ) , ( 'CUSTOM_KEYWORD4_ATTRIBUTES' , 'keyword' ) , ( 'CUSTOM_NUMBER_ATTRIBUTES' , 'number' ) , ( 'CUSTOM_STRING_ATTRIBUTES' , 'string' ) , ( 'CUSTOM_LINE_COMMENT_ATTRIBUTES' , 'singleLineComment' ) , ( 'CUSTOM_MULTI_LINE_COMMENT_ATTRIBUTES' , 'multiLineComment' ) , ( 'CUSTOM_VALID_STRING_ESCAPE_ATTRIBUTES' , 'number' ) , ( 'CUSTOM_INVALID_STRING_ESCAPE_ATTRIBUTES' , 'deprecatedMember' ) , ( 'DOC_COMMENT_TAG_VALUE' , 'javadocKeyword' ) , ( 'CLASS_NAME_ATTRIBUTES' , 'class' ) , ( 'ANONYMOUS_CLASS_NAME_ATTRIBUTES' , 'class' ) , ( 'TYPE_PARAMETER_NAME_ATTRIBUTES' , 'typeParameter' ) , ( 'ABSTRACT_CLASS_NAME_ATTRIBUTES' , 'class' ) , ( 'INTERFACE_NAME_ATTRIBUTES' , 'interface' ) , ( 'ENUM_NAME_ATTRIBUTES' , 'interface' ) , ( 'IMPLICIT_ANONYMOUS_CLASS_PARAMETER_ATTRIBUTES' , 'interface' ) , ( 'INSTANCE_FIELD_ATTRIBUTES' , 'field' ) , ( 'STATIC_FIELD_ATTRIBUTES' , 'staticField' ) , ( 'PARAMETER_ATTRIBUTES' , 'typeParameter' ) , ( 'ANNOTATION_NAME_ATTRIBUTES' , 'javadocKeyword' ) , ( 'ANNOTATION_ATTRIBUTE_NAME_ATTRIBUTES' , '' ) , ( 'STATIC_METHOD_ATTRIBUTES' , 'javadocTag' ) , ( 'METHOD_DECLARATION_ATTRIBUTES' , 'method' ) ] #NEWLINE# def get_option( name ) : #NEWLINE# #INDENT# if ( name in options ) : #NEWLINE# #INDENT# return options [ name ] #NEWLINE# #UNINDENT# return None #NEWLINE# #UNINDENT# def gen_theme( ) : #NEWLINE# #INDENT# for ( element , dependency ) in dependencies : #NEWLINE# #INDENT# colorElement = False #NEWLINE# for e in elements . FLATTEN : #NEWLINE# #INDENT# if ( e [ 0 ] == element ) : #NEWLINE# #INDENT# colorElement = ( ( len ( e ) > 2 ) and e [ 2 ] ) #NEWLINE# #UNINDENT# #UNINDENT# if isinstance ( dependency , tuple ) : #NEWLINE# #INDENT# ( yield ( element , tuple ( [ ( get_option ( t ) [ elements . PARAM_FOREGROUND ] if ( t and ( not ( get_option ( t ) is None ) ) ) else None ) for t in dependency ] ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# opt = get_option ( dependency ) #NEWLINE# if ( not ( opt is None ) ) : #NEWLINE# #INDENT# if colorElement : #NEWLINE# #INDENT# ( yield ( element , opt [ elements . PARAM_FOREGROUND ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( yield ( element , opt ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# default_elements = ( elements . DARK_DEFAULTS if dark else elements . LIGHT_DEFAULTS ) #NEWLINE# return ( ( name , author , website ) , ( list ( gen_theme ( ) ) + default_elements ) )