environment/lib/python2.7/site-packages/IPython/config/configurable.py
def class_config_section(cls):
        """Get the config class config section"""
        def c(s):
            """return a commented, wrapped block."""
            s = '\n\n'.join(wrap_paragraphs(s, 78))

            return '# ' + s.replace('\n', '\n# ')

        # section header
        breaker = '#' + '-'*78
        s = "# %s configuration"%cls.__name__
        lines = [breaker, s, breaker, '']
        # get the description trait
        desc = cls.class_traits().get('description')
        if desc:
            desc = desc.default_value
        else:
            # no description trait, use __doc__
            desc = getattr(cls, '__doc__', '')
        if desc:
            lines.append(c(desc))
            lines.append('')

        parents = []
        for parent in cls.mro():
            # only include parents that are not base classes
            # and are not the class itself
            # and have some configurable traits to inherit
            if parent is not cls and issubclass(parent, Configurable) and \
                    parent.class_traits(config=True):
                parents.append(parent)

        if parents:
            pstr = ', '.join([ p.__name__ for p in parents ])
            lines.append(c('%s will inherit config from: %s'%(cls.__name__, pstr)))
            lines.append('')

        for name,trait in cls.class_traits(config=True).iteritems():
            help = trait.get_metadata('help') or ''
            lines.append(c(help))
            lines.append('# c.%s.%s = %r'%(cls.__name__, name, trait.get_default_value()))
            lines.append('')
        return '\n'.join(lines)
def class_config_section(cls):
        """Get the config class config section"""
        def c(s):
            """return a commented, wrapped block."""
            s = '\n\n'.join(wrap_paragraphs(s, 78))

            return '# ' + s.replace('\n', '\n# ')

        # section header
        breaker = '#' + '-'*78
        s = "# %s configuration"%cls.__name__
        lines = [breaker, s, breaker, '']
        # get the description trait
        desc = cls.class_traits().get('description')
        if desc:
            desc = desc.default_value
        else:
            # no description trait, use __doc__
            desc = getattr(cls, '__doc__', '')
        if desc:
            lines.append(c(desc))
            lines.append('')

        parents = []
        for parent in cls.mro():
            # only include parents that are not base classes
            # and are not the class itself
            # and have some configurable traits to inherit
            if parent is not cls and issubclass(parent, Configurable) and \
                    parent.class_traits(config=True):
                parents.append(parent)

        if parents:
            pstr = ', '.join([ p.__name__ for p in parents ])
            lines.append(c('%s will inherit config from: %s'%(cls.__name__, pstr)))
            lines.append('')

        for name,trait in cls.class_traits(config=True).iteritems():
            help = trait.get_metadata('help') or ''
            lines.append(c(help))
            lines.append('# c.%s.%s = %r'%(cls.__name__, name, trait.get_default_value()))
            lines.append('')
        return '\n'.join(lines)
def class_config_section ( cls ) : def c ( s ) : """return a commented, wrapped block.""" s = '\n\n' . join ( wrap_paragraphs ( s , 78 ) ) return '# ' + s . replace ( '\n' , '\n# ' ) # section header breaker = '#' + '-' * 78 s = "# %s configuration" % cls . __name__ lines = [ breaker , s , breaker , '' ] # get the description trait desc = cls . class_traits ( ) . get ( 'description' ) if desc : desc = desc . default_value else : # no description trait, use __doc__ desc = getattr ( cls , '__doc__' , '' ) if desc : lines . append ( c ( desc ) ) lines . append ( '' ) parents = [ ] for parent in cls . mro ( ) : # only include parents that are not base classes # and are not the class itself # and have some configurable traits to inherit if parent is not cls and issubclass ( parent , Configurable ) and parent . class_traits ( config = True ) : parents . append ( parent ) if parents : pstr = ', ' . join ( [ p . __name__ for p in parents ] ) lines . append ( c ( '%s will inherit config from: %s' % ( cls . __name__ , pstr ) ) ) lines . append ( '' ) for name , trait in cls . class_traits ( config = True ) . iteritems ( ) : help = trait . get_metadata ( 'help' ) or '' lines . append ( c ( help ) ) lines . append ( '# c.%s.%s = %r' % ( cls . __name__ , name , trait . get_default_value ( ) ) ) lines . append ( '' ) return '\n' . join ( lines )
Get the config class config section
Get the config class config section