@@ -104,8 +104,6 @@ def _generate(self):
104104
105105 if value not in visited [value .type ]:
106106 visited [value .type ].append (value )
107- else :
108- self ._all [name ] = visited [value .type ][visited [value .type ].index (value )]
109107
110108 def browse_all (self ):
111109 """Populate the browser and all descendents of the browser."""
@@ -114,61 +112,33 @@ def browse_all(self):
114112
115113 # populate child browsers if not already visited
116114 for name , value in self ._all .items ():
117- if type (value ) is Browser and value not in visited [value .type ]:
115+ if isinstance (value , Browser ) and value not in visited [value .type ]:
118116 name .browse_all ()
119117
120- def search (self , name : str , exact : bool = False ):
121- """Return a dictionary in format {path: item} matching the name.
122-
123- Search for all instances of a method or object containing a name.
124-
125- Parameters
126- ----------
127- exact: bool
128- A flag that searches for exact matches.
129- name: str
130- The name of the attribute to search for.
131-
132- Returns
133- -------
134- dict
135- The results of the search in format {path: item}.
136- """
137- ...
138-
139- def goto (self , path : str ):
140- """Retrieve an object at a given location.
141-
142- Parameters
143- ----------
144- path: str
145- The location of the item delimited by '/'.
146-
147- Examples
148- --------
149- `goto('Bodies/Item/1/HybridShapes/GetItem')` yields the 'GetItem' function.
150-
151- """
152- ...
153-
154- def view_vba (self ) -> str :
155- """Returns a string that replicates the VBA tree."""
156- ...
157-
158118 def regen (self ):
159119 """Regenerate the `all` property."""
160120 self ._all = {}
161121 self ._generate ()
162122
163123
164124class CollectionBrowser (Browser , CollectionViewer ):
165- def __init__ (self , obj : CollectionViewer ):
125+ def __init__ (self , obj ):
166126 super ().__init__ (obj .com , obj .name , obj .parent )
167- self ._items = [self .from_viewer (i ) for i in self ._items ]
127+ self ._items = [self .from_viewer (item ) for item in self ._items ]
168128
169129 def __str__ (self ):
170130 return "<class 'CollectionBrowser'>: " + self ._name
171131
172132 def _generate (self ):
133+ global visited
173134 super ()._generate ()
174135 self ._all ['Item' ] = self ._items
136+
137+ # add items to the visited dictionary
138+ for value in self ._all ['Item' ]:
139+ if isinstance (value , Viewer ):
140+ if value .type not in visited :
141+ visited [value .type ] = []
142+
143+ if value not in visited [value .type ]:
144+ visited [value .type ].append (value )
0 commit comments