parameters: (self)
return_statement: return flags, aliases
docstring: flatten flags and aliases, so cl-args override as expected.
  
          This prevents issues such as an alias pointing to InteractiveShell,
          but a config file setting the same trait in TerminalInteraciveShell
          getting inappropriate priority over the command-line arg.
  
          Only aliases with exactly one descendent in the class list
          will be promoted.
docstring_summary: flatten flags and aliases, so cl-args override as expected.
docstring_tokens: flatten flags and aliases so cl - args override as expected .
function: def flatten_flags(self):
          """flatten flags and aliases, so cl-args override as expected.
  
          This prevents issues such as an alias pointing to InteractiveShell,
          but a config file setting the same trait in TerminalInteraciveShell
          getting inappropriate priority over the command-line arg.
  
          Only aliases with exactly one descendent in the class list
          will be promoted.
  
          """
          # build a tree of classes in our list that inherit from a particular
          # it will be a dict by parent classname of classes in our list
          # that are descendents
          mro_tree = defaultdict(list)
          for cls in self.classes:
              clsname = cls.__name__
              for parent in cls.mro()[1:-3]:
                  # exclude cls itself and Configurable,HasTraits,object
                  mro_tree[parent.__name__].append(clsname)
          # flatten aliases, which have the form:
          # { 'alias' : 'Class.trait' }
          aliases = {}
          for alias, cls_trait in self.aliases.items():
              cls,trait = cls_trait.split('.',1)
              children = mro_tree[cls]
              if len(children) == 1:
                  # exactly one descendent, promote alias
                  cls = children[0]
              aliases[alias] = '.'.join([cls,trait])
  
          # flatten flags, which are of the form:
          # { 'key' : ({'Cls' : {'trait' : value}}, 'help')}
          flags = {}
          for key, (flagdict, help) in self.flags.items():
              newflag = {}
              for cls, subdict in flagdict.items():
                  children = mro_tree[cls]
                  # exactly one descendent, promote flag section
                  if len(children) == 1:
                      cls = children[0]
                  newflag[cls] = subdict
              flags[key] = (newflag, help)
          return flags, aliases
function_tokens: def flatten_flags ( self ) : # build a tree of classes in our list that inherit from a particular # it will be a dict by parent classname of classes in our list # that are descendents mro_tree = defaultdict ( list ) for cls in self . classes : clsname = cls . __name__ for parent in cls . mro ( ) [ 1 : - 3 ] : # exclude cls itself and Configurable,HasTraits,object mro_tree [ parent . __name__ ] . append ( clsname ) # flatten aliases, which have the form: # { 'alias' : 'Class.trait' } aliases = { } for alias , cls_trait in self . aliases . items ( ) : cls , trait = cls_trait . split ( '.' , 1 ) children = mro_tree [ cls ] if len ( children ) == 1 : # exactly one descendent, promote alias cls = children [ 0 ] aliases [ alias ] = '.' . join ( [ cls , trait ] ) # flatten flags, which are of the form: # { 'key' : ({'Cls' : {'trait' : value}}, 'help')} flags = { } for key , ( flagdict , help ) in self . flags . items ( ) : newflag = { } for cls , subdict in flagdict . items ( ) : children = mro_tree [ cls ] # exactly one descendent, promote flag section if len ( children ) == 1 : cls = children [ 0 ] newflag [ cls ] = subdict flags [ key ] = ( newflag , help ) return flags , aliases