@@ -198,31 +198,38 @@ class TmuxMappingObject(collections.MutableMapping):
198198 :class:`Session` and :class:`Server`.
199199
200200 Instance attributes for useful information :term:`tmux(1)` uses for
201- Session, Window, Pane, stored :attr:`self._TMUX `. For example, a
201+ Session, Window, Pane, stored :attr:`self._info `. For example, a
202202 :class:`Window` will have a ``window_id`` and ``window_name``.
203203
204204 """
205205
206206 def __getitem__ (self , key ):
207- return self ._TMUX [key ]
207+ return self ._info [key ]
208208
209209 def __setitem__ (self , key , value ):
210- self ._TMUX [key ] = value
210+ self ._info [key ] = value
211211 self .dirty = True
212212
213213 def __delitem__ (self , key ):
214- del self ._TMUX [key ]
214+ del self ._info [key ]
215215 self .dirty = True
216216
217217 def keys (self ):
218218 """Return list of keys."""
219- return self ._TMUX .keys ()
219+ return self ._info .keys ()
220220
221221 def __iter__ (self ):
222- return self ._TMUX .__iter__ ()
222+ return self ._info .__iter__ ()
223223
224224 def __len__ (self ):
225- return len (self ._TMUX .keys ())
225+ return len (self ._info .keys ())
226+
227+ def __getattr__ (self , key ):
228+ try :
229+ return self ._info [self .formatter_prefix + key ]
230+ except :
231+ raise AttributeError ('%s has no property %s' %
232+ (self .__class__ , key ))
226233
227234
228235class TmuxRelationalObject (object ):
@@ -234,10 +241,10 @@ class TmuxRelationalObject(object):
234241 :class:`Window`)
235242
236243 Children of :class:`TmuxRelationalObject` are going to have a
237- ``self.children``, ``self.childIdAttribute `` and ``self.list_children``.
244+ ``self.children``, ``self.child_id_attribute `` and ``self.list_children``.
238245
239246 ================ ================== ===================== ============================
240- Object ``.children`` ``.childIdAttribute `` method
247+ Object ``.children`` ``.child_id_attribute `` method
241248 ================ ================== ===================== ============================
242249 :class:`Server` ``self._sessions`` 'session_id' :meth:`Server.list_sessions`
243250 :class:`Session` ``self._windows`` 'window_id' :meth:`Session.list_windows`
@@ -247,13 +254,11 @@ class TmuxRelationalObject(object):
247254
248255 """
249256
250- def findWhere (self , attrs ):
257+ def find_where (self , attrs ):
251258 """Return object on first match.
252259
253- Based on `.findWhere()`_ from `underscore.js`_.
254-
255- .. _.findWhere(): http://underscorejs.org/#findWhere
256- .. _underscore.js: http://underscorejs.org/
260+ :versionchanged: 0.4
261+ Renamed from ``.findWhere`` to ``.find_where``.
257262
258263 """
259264 try :
@@ -264,11 +269,6 @@ def findWhere(self, attrs):
264269 def where (self , attrs , first = False ):
265270 """Return objects matching child objects properties.
266271
267- Based on `.where()`_ from `underscore.js`_.
268-
269- .. _.where(): http://underscorejs.org/#where
270- .. _underscore.js: http://underscorejs.org/
271-
272272 :param attrs: tmux properties to match
273273 :type attrs: dict
274274 :rtype: list
@@ -290,8 +290,8 @@ def by(val, *args):
290290 else :
291291 return list (filter (by , self .children ))
292292
293- def getById (self , id ):
294- """Return object based on ``childIdAttribute ``.
293+ def get_by_id (self , id ):
294+ """Return object based on ``child_id_attribute ``.
295295
296296 Based on `.get()`_ from `backbone.js`_.
297297
@@ -304,7 +304,7 @@ def getById(self, id):
304304
305305 """
306306 for child in self .children :
307- if child [self .childIdAttribute ] == id :
307+ if child [self .child_id_attribute ] == id :
308308 return child
309309 else :
310310 continue
0 commit comments