# Path: objbrowser/qtpy/QtCore.py

# 
# Path: objbrowser/qtpy/QtGui.py

# 
# Path: objbrowser/qtpy/QtWidgets.py

# 
# Path: objbrowser/qtpy/QtCore.py

# 
# Path: objbrowser/treeitem.py
# class TreeItem(object):
#     """ Tree node class that can be used to build trees of objects.
#     """
#     def __init__(self, obj, name, obj_path, is_attribute, parent=None):
#         self.parent_item = parent
#         self.obj = obj
#         self.obj_name = str(name)
#         self.obj_path = str(obj_path)
#         self.is_attribute = is_attribute
#         self.child_items = []
#         self.has_children = True
#         self.children_fetched = False
# 
# 
#     def __str__(self):
#         n_children = len(self.child_items)
#         if n_children == 0:
#             return "<TreeItem(0x{:x}): {} = {}>" \
#                 .format(id(self.obj), self.obj_path, cut_off_str(self.obj, MAX_OBJ_STR_LEN))
#         else:
#             return "<TreeItem(0x{:x}): {} ({:d} children)>" \
#                 .format(id(self.obj), self.obj_path, len(self.child_items))
# 
# 
#     def __repr__(self):
#         n_children = len(self.child_items)
#         return "<TreeItem(0x{:x}): {} ({:d} children)>" \
#             .format(id(self.obj), self.obj_path, n_children)
#             
#     @property
#     def is_special_attribute(self):
#         " Return true if the items is an attribute and its name begins and end with 2 underscores" 
#         return self.is_attribute and name_is_special(self.obj_name)
# 
#     @property
#     def is_callable_attribute(self):
#         " Return true if the items is an attribute and it is callable."
#         return self.is_attribute and self.is_callable
# 
#     @property
#     def is_callable(self):
#         " Return true if the underlying object is callable "
#         return callable(self.obj)
#     
#     def append_child(self, item):
#         item.parent_item = self
#         self.child_items.append(item)
# 
#     def insert_children(self, idx, items):
#         self.child_items[idx:idx] = items
#         for item in items:
#             item.parent_item = self
# 
#     def child(self, row):
#         return self.child_items[row]
# 
#     def child_count(self):
#         return len(self.child_items)
# 
#     def parent(self):
#         return self.parent_item
# 
#     def row(self):
#         if self.parent_item:
#             return self.parent_item.child_items.index(self)
#         else:
#             return 0
# 
#     def pretty_print(self, indent=0):
#         if 0:
#             print(indent * "    " + str(self))
#         else:
#             logger.debug(indent * "    " + str(self))
#         for child_item in self.child_items:
#             child_item.pretty_print(indent + 1)


import logging, inspect
from difflib import SequenceMatcher
from collections import OrderedDict
from six import unichr
from objbrowser.qtpy import QtCore, QtGui, QtWidgets
from objbrowser.qtpy.QtCore import Qt
from objbrowser.treeitem import TreeItem
from objbrowser.utils import cut_off_str
        for attr_name, attr_value in sorted(inspect.getmembers(obj)):
            obj_children.append( (attr_name, attr_value) )
            path_strings.append('{}.{}'.format(obj_path, attr_name) if obj_path else attr_name)
            is_attr_list.append(True)

        assert len(obj_children) == len(path_strings), "sanity check"
        tree_items = []
        for item, path_str, is_attr in zip(obj_children, path_strings, is_attr_list):
            name, child_obj = item
            tree_items.append(TreeItem(child_obj, name, path_str, is_attr))
            
        return tree_items

   
    def populateTree(self, obj, obj_name='', inspected_node_is_visible=None):
        """ Fills the tree using a python object. Sets the rootItem.
        """
        logger.debug("populateTree with object id = 0x{:x}".format(id(obj)))
        
        if inspected_node_is_visible is None:
            inspected_node_is_visible = (obj_name != '')
        self._inspected_node_is_visible = inspected_node_is_visible
        
        if self._inspected_node_is_visible:
            self._root_item = TreeItem(None, '<invisible_root>', '<invisible_root>', None) 
            self._root_item.children_fetched = True
            self._inspected_item = TreeItem(obj, obj_name, obj_name, is_attribute = None)
            self._root_item.append_child(self._inspected_item)
        else:
            # The root itself will be invisible

# Path: objbrowser/qtpy/QtCore.py

# 
# Path: objbrowser/qtpy/QtGui.py

# 
# Path: objbrowser/qtpy/QtWidgets.py

# 
# Path: objbrowser/qtpy/QtCore.py

# 
# Path: objbrowser/treeitem.py
# class TreeItem(object):
#     """ Tree node class that can be used to build trees of objects.
#     """
#     def __init__(self, obj, name, obj_path, is_attribute, parent=None):
#         self.parent_item = parent
#         self.obj = obj
#         self.obj_name = str(name)
#         self.obj_path = str(obj_path)
#         self.is_attribute = is_attribute
#         self.child_items = []
#         self.has_children = True
#         self.children_fetched = False
# 
# 
#     def __str__(self):
#         n_children = len(self.child_items)
#         if n_children == 0:
#             return "<TreeItem(0x{:x}): {} = {}>" \
#                 .format(id(self.obj), self.obj_path, cut_off_str(self.obj, MAX_OBJ_STR_LEN))
#         else:
#             return "<TreeItem(0x{:x}): {} ({:d} children)>" \
#                 .format(id(self.obj), self.obj_path, len(self.child_items))
# 
# 
#     def __repr__(self):
#         n_children = len(self.child_items)
#         return "<TreeItem(0x{:x}): {} ({:d} children)>" \
#             .format(id(self.obj), self.obj_path, n_children)
#             
#     @property
#     def is_special_attribute(self):
#         " Return true if the items is an attribute and its name begins and end with 2 underscores" 
#         return self.is_attribute and name_is_special(self.obj_name)
# 
#     @property
#     def is_callable_attribute(self):
#         " Return true if the items is an attribute and it is callable."
#         return self.is_attribute and self.is_callable
# 
#     @property
#     def is_callable(self):
#         " Return true if the underlying object is callable "
#         return callable(self.obj)
#     
#     def append_child(self, item):
#         item.parent_item = self
#         self.child_items.append(item)
# 
#     def insert_children(self, idx, items):
#         self.child_items[idx:idx] = items
#         for item in items:
#             item.parent_item = self
# 
#     def child(self, row):
#         return self.child_items[row]
# 
#     def child_count(self):
#         return len(self.child_items)
# 
#     def parent(self):
#         return self.parent_item
# 
#     def row(self):
#         if self.parent_item:
#             return self.parent_item.child_items.index(self)
#         else:
#             return 0
# 
#     def pretty_print(self, indent=0):
#         if 0:
#             print(indent * "    " + str(self))
#         else:
#             logger.debug(indent * "    " + str(self))
#         for child_item in self.child_items:
#             child_item.pretty_print(indent + 1)


# Path: objbrowser/treemodel.py
import logging, inspect
from difflib import SequenceMatcher
from collections import OrderedDict
from six import unichr
from objbrowser.qtpy import QtCore, QtGui, QtWidgets
from objbrowser.qtpy.QtCore import Qt
from objbrowser.treeitem import TreeItem
from objbrowser.utils import cut_off_str

        for attr_name, attr_value in sorted(inspect.getmembers(obj)):
            obj_children.append( (attr_name, attr_value) )
            path_strings.append('{}.{}'.format(obj_path, attr_name) if obj_path else attr_name)
            is_attr_list.append(True)

        assert len(obj_children) == len(path_strings), "sanity check"
        tree_items = []
        for item, path_str, is_attr in zip(obj_children, path_strings, is_attr_list):
            name, child_obj = item
            tree_items.append(TreeItem(child_obj, name, path_str, is_attr))
            
        return tree_items

   
    def populateTree(self, obj, obj_name='', inspected_node_is_visible=None):
        """ Fills the tree using a python object. Sets the rootItem.
        """
        logger.debug("populateTree with object id = 0x{:x}".format(id(obj)))
        
        if inspected_node_is_visible is None:
            inspected_node_is_visible = (obj_name != '')
        self._inspected_node_is_visible = inspected_node_is_visible
        
        if self._inspected_node_is_visible:
            self._root_item = TreeItem(None, '<invisible_root>', '<invisible_root>', None) 
            self._root_item.children_fetched = True
            self._inspected_item = TreeItem(obj, obj_name, obj_name, is_attribute = None)
            self._root_item.append_child(self._inspected_item)
        else:
            # The root itself will be invisible

            self._root_item = TreeItem(obj, obj_name, obj_name, is_attribute = None)