def _asciiArt(self, char1='-', show_internal=True, compact=False, attributes=None):
        """
        Returns the ASCII representation of the tree.
        Code based on the PyCogent GPL project.
        """
        if not attributes:
            attributes = ["name"]
        
        # toytree edit:
        # removed six dependency for map with comprehension
        # node_name = ', '.join(map(str, [getattr(self, v) for v in attributes if hasattr(self, v)]))
        _attrlist = [getattr(self, v) for v in attributes if hasattr(self, v)]
        node_name = ", ".join([str(i) for i in _attrlist])

        LEN = max(3, len(node_name) if not self.children or show_internal else 3)
        PAD = ' ' * LEN
        PA = ' ' * (LEN-1)
        if not self.is_leaf():
            mids = []
            result = []
            for c in self.children:
                if len(self.children) == 1:
                    char2 = '/'
                elif c is self.children[0]:
                    char2 = '/'
                elif c is self.children[-1]:
                    char2 = '\\'
                else:
                    char2 = '-'
                (clines, mid) = c._asciiArt(char2, show_internal, compact, attributes)
                mids.append(mid+len(result))
                result.extend(clines)
                if not compact:
                    result.append('')
            if not compact:
                result.pop()
            (lo, hi, end) = (mids[0], mids[-1], len(result))
            prefixes = [PAD] * (lo+1) + [PA+'|'] * (hi-lo-1) + [PAD] * (end-hi)
            mid = int((lo + hi) / 2)
            prefixes[mid] = char1 + '-'*(LEN-2) + prefixes[mid][-1]
            result = [p+l for (p,l) in zip(prefixes, result)]
            if show_internal:
                stem = result[mid]
                result[mid] = stem[0] + node_name + stem[len(node_name)+1:]
            return (result, mid)
        else:
            return ([char1 + '-' + node_name], 0)
def _asciiArt ( self , char1 = '-' , show_internal = True , compact = False , attributes = None ) : if not attributes : attributes = [ "name" ] _attrlist = [ getattr ( self , v ) for v in attributes if hasattr ( self , v ) ] node_name = ", " . join ( [ str ( i ) for i in _attrlist ] ) LEN = max ( 3 , len ( node_name ) if not self . children or show_internal else 3 ) PAD = ' ' * LEN PA = ' ' * ( LEN - 1 ) if not self . is_leaf ( ) : mids = [ ] result = [ ] for c in self . children : if len ( self . children ) == 1 : char2 = '/' elif c is self . children [ 0 ] : char2 = '/' elif c is self . children [ - 1 ] : char2 = '\\' else : char2 = '-' ( clines , mid ) = c . _asciiArt ( char2 , show_internal , compact , attributes ) mids . append ( mid + len ( result ) ) result . extend ( clines ) if not compact : result . append ( '' ) if not compact : result . pop ( ) ( lo , hi , end ) = ( mids [ 0 ] , mids [ - 1 ] , len ( result ) ) prefixes = [ PAD ] * ( lo + 1 ) + [ PA + '|' ] * ( hi - lo - 1 ) + [ PAD ] * ( end - hi ) mid = int ( ( lo + hi ) / 2 ) prefixes [ mid ] = char1 + '-' * ( LEN - 2 ) + prefixes [ mid ] [ - 1 ] result = [ p + l for ( p , l ) in zip ( prefixes , result ) ] if show_internal : stem = result [ mid ] result [ mid ] = stem [ 0 ] + node_name + stem [ len ( node_name ) + 1 : ] return ( result , mid ) else : return ( [ char1 + '-' + node_name ] , 0 )
Returns the ASCII representation of the tree.
        Code based on the PyCogent GPL project.