<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import re <EOL> from traits . api import HasPrivateTraits , Trait , Bool <EOL> import traits . _py2to3 as _py2to3 <EOL> from . ui_traits import ( ATheme , AnObject , DockStyle , EditorStyle , ExportType , <EOL> HelpId , Image ) <EOL> label_pat = re . compile ( r"<STR_LIT>" , re . MULTILINE | re . DOTALL ) <EOL> label_pat2 = re . compile ( r"<STR_LIT>" , re . MULTILINE | re . DOTALL ) <EOL> class ViewElement ( HasPrivateTraits ) : <EOL> """<STR_LIT>""" <EOL> def replace_include ( self , view_elements ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def is_includable ( self ) : <EOL> """<STR_LIT>""" <EOL> return False <EOL> class DefaultViewElement ( ViewElement ) : <EOL> """<STR_LIT>""" <EOL> object = AnObject <EOL> style = EditorStyle <EOL> dock = DockStyle <EOL> image = Image <EOL> export = ExportType <EOL> show_labels = Bool ( True ) <EOL> item_theme = ATheme <EOL> label_theme = ATheme <EOL> Container = Trait ( DefaultViewElement ( ) , ViewElement ) <EOL> class ViewSubElement ( ViewElement ) : <EOL> """<STR_LIT>""" <EOL> container = Container <EOL> help_id = HelpId <EOL> def _split ( self , name , value , char , finder , assign , result ) : <EOL> """<STR_LIT>""" <EOL> col = finder ( value , char ) <EOL> if col < <NUM_LIT:0> : <EOL> return value <EOL> items = ( value [ : col ] . strip ( ) , value [ col + <NUM_LIT:1> : ] . strip ( ) ) <EOL> if items [ assign ] != '<STR_LIT>' : <EOL> setattr ( self , name , items [ assign ] ) <EOL> return items [ result ] <EOL> def _option ( self , string , option , name , value ) : <EOL> """<STR_LIT>""" <EOL> col = string . find ( option ) <EOL> if col >= <NUM_LIT:0> : <EOL> string = string [ : col ] + string [ col + len ( option ) : ] <EOL> setattr ( self , name , value ) <EOL> return string <EOL> def _parse_style ( self , value ) : <EOL> """<STR_LIT>""" <EOL> value = self . _option ( value , '<STR_LIT:$>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> value = self . _option ( value , '<STR_LIT:@>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> value = self . _option ( value , '<STR_LIT:*>' , '<STR_LIT>' , '<STR_LIT:text>' ) <EOL> value = self . _option ( value , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> value = self . _split ( '<STR_LIT>' , value , '<STR_LIT:;>' , _py2to3 . str_rfind , <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> return value <EOL> def _parse_label ( self , value ) : <EOL> """<STR_LIT>""" <EOL> match = label_pat . match ( value ) <EOL> if match is not None : <EOL> self . _parsed_label ( ) <EOL> else : <EOL> match = label_pat2 . match ( value ) <EOL> empty = False <EOL> if match is not None : <EOL> self . label = match . group ( <NUM_LIT:2> ) . strip ( ) <EOL> empty = ( self . label == '<STR_LIT>' ) <EOL> value = match . group ( <NUM_LIT:1> ) + match . group ( <NUM_LIT:3> ) <EOL> return ( value , empty ) <EOL> def _parsed_label ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def _repr_value ( self , value , prefix = '<STR_LIT>' , suffix = '<STR_LIT>' , ignore = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> if value == ignore : <EOL> return '<STR_LIT>' <EOL> return '<STR_LIT>' % ( prefix , value , suffix ) <EOL> def _repr_options ( self , * names ) : <EOL> """<STR_LIT>""" <EOL> result = [ ] <EOL> for name in names : <EOL> value = getattr ( self , name ) <EOL> if value != self . trait ( name ) . default_value_for ( self , name ) : <EOL> result . append ( ( name , repr ( value ) ) ) <EOL> if len ( result ) > <NUM_LIT:0> : <EOL> n = max ( [ len ( name ) for name , value in result ] ) <EOL> return '<STR_LIT>' . join ( [ '<STR_LIT>' % ( name . ljust ( n ) , value ) <EOL> for name , value in result ] ) <EOL> return None <EOL> def _indent ( self , string , indent = '<STR_LIT:U+0020>' ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT:\n>' . join ( [ indent + s for s in string . split ( '<STR_LIT:\n>' ) ] ) </s>
