etetoolkit / ete

Python package for building, comparing, annotating, manipulating and visualising trees. It provides a comprehensive API and a collection of command line tools, including utilities to work with the NCBI taxonomy tree.
http://etetoolkit.org
GNU General Public License v3.0
768 stars 216 forks source link

Miss exception in loading NoteStyle from treeview in core #725

Closed dengzq1234 closed 8 months ago

dengzq1234 commented 8 months ago

in tree.pyx from core, there is a snippet, from line 18. It load the NodeStyle from treeview and also from Smartview

# the following imports are necessary to set fixed styles and faces
# try:
try:
    from ..treeview.main import NodeStyle
    from ..treeview.faces import Face
    TREEVIEW = True
except ImportError:
    TREEVIEW = False

from ..smartview.renderer.faces import Face as smartFace
from ..smartview.renderer.nodestyle import NodeStyle as smNodeStyle

The problem in this exception is, if ImportError occured, NodeStyle will become undefined, which effect and fail the following method set_style() in line 1960

...
if isinstance(node_style, NodeStyle):
...

It should go as how it is handle in method add_face()

if TREEVIEW and isinstance(node_style, NodeStyle)